Skip to content

Commit d43c566

Browse files
authored
Fix memory leaks around slang-test (shader-slang#757)
* Remove circular reference to renderer on Vk & D3D12 DescriptorSetImpl * Refactor Stbi image loading such that memory is correctly freed when goes out of scope. Added Crt memory dump at termination. Reduced erroneous reporting by scoping TestContext. * Used capitalized acronym for STBImage to keep Tim happy. * Split out TestReporter - to just handle reporting test results Split out Options Made TestContext hold options, and the reporter Removed remaining memory leaks. * Small optimization for rawWrite, such that it directly writes over print.. * Improve comments on TestCategorySet * Fix typos in TestCategorySet
1 parent ec745c0 commit d43c566

13 files changed

+1250
-1157
lines changed

slang.sln

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.25420.1
5-
MinimumVisualStudioVersion = 10.0.40219.1
64
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{EB5FC2C6-D72D-B6CC-C0C1-26F3AC2E9231}"
75
EndProject
86
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello-world", "examples\hello-world\hello-world.vcxproj", "{010BE414-ED5B-CF56-16C0-BD18027062C0}"

source/core/slang-writer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class WriterHelper
1414
public:
1515
SlangResult print(const char* format, ...);
1616
SlangResult put(const char* text);
17-
17+
SLANG_FORCE_INLINE SlangResult write(const char* chars, size_t numChars) { return m_writer->write(chars, numChars); }
1818
SLANG_FORCE_INLINE void flush() { m_writer->flush(); }
1919

2020
ISlangWriter* getWriter() const { return m_writer; }

source/slang/slang.vcxproj.filters

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup>
44
<Filter Include="Header Files">

tools/slang-reflection-test/main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ struct PrettyWriter
1818

1919
static void writeRaw(PrettyWriter& writer, char const* begin, char const* end)
2020
{
21-
Slang::AppContext::getStdOut().print("%.*s", int(end - begin), begin);
21+
SLANG_ASSERT(end >= begin);
22+
Slang::AppContext::getStdOut().write(begin, size_t(end - begin));
2223
}
2324

2425
static void writeRaw(PrettyWriter& writer, char const* begin)

0 commit comments

Comments
 (0)