From f0633a7d0b1615f6b115d53763bedeeb857b7f3c Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 16 Jan 2019 08:16:53 -0800 Subject: Add proper IR codegen support for local static const variables (#779) Previously the IR codegen logic was treating function-scope `static const` variables just like `static` variables, which results in them generating less efficient output HLSL/GLSL. This change special-cases function-local `static const` variables with logic that mirrors how we handle global-scope `static const` variables. The approach in this change attempts to find a simpler solution to deal with `static const` variables inside of generic functions than what is currently done for `static` variables in generic functions, but I haven't tested whether that works in practice, so I didn't apply the same approach to the plain `static` case. That would make a good follow-on change. I've included a single test case to demonstrate that with this fix the Slang compiler generates output DXBC that uses an indexable "immediate" constant buffer, whereas without the fix it generates an array in local memory (slow). --- tools/slang-test/slang-test-main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tools') diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index c0e5bd95b..1f6b4cdb0 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -697,6 +697,13 @@ TestResult runCrossCompilerTest(TestContext* context, TestInput& input) expectedSpawner.pushArgument("dxc"); break; } + case SLANG_DXBC_ASM: + { + expectedSpawner.pushArgument(filePath + ".hlsl"); + expectedSpawner.pushArgument("-pass-through"); + expectedSpawner.pushArgument("fxc"); + break; + } default: { expectedSpawner.pushArgument(filePath + ".glsl"); -- cgit v1.2.3