From 624d122a3a110922cd54aab7bbf13f1cac8fbbff Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Fri, 20 Oct 2017 15:16:10 -0700 Subject: Fix up emission of shader parameter semantics when using IR (#226) * Fix up emission of shader parameter semantics when using IR - Make sure to propagate entry point parameter layouts down to IR parameters when doing the initial cloning to form target-specific IR - When layout information is present on an IR node, prefer to use that over the original high-level declaration for outputting semantics in final HLSL - Fix up test runner to generate `.actual` files when running compute tests, in cases where the `render-test` application errors out (e.g., because of a Slang compilation error) - Add a first test of generics functionality, to show that they generate valid code through the IR - Right now this test is *not* using any "interesting" operations on the type parameter, so this is not a test that can confirm that interface constraints work * fixup: skip compute tests when running on Linux --- source/slang/emit.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source/slang/emit.cpp') diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 971f0345b..1b5db065f 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -5090,6 +5090,37 @@ emitDeclImpl(decl, nullptr); EmitContext* context, IRValue* inst) { + // Don't emit semantics if we aren't translating down to HLSL + switch (context->shared->target) + { + case CodeGenTarget::HLSL: + break; + + default: + return; + } + + if(auto layoutDecoration = inst->findDecoration()) + { + if(auto varLayout = layoutDecoration->layout.As()) + { + if(varLayout->flags & VarLayoutFlag::HasSemantic) + { + Emit(" : "); + emit(varLayout->semanticName); + if(varLayout->semanticIndex) + { + Emit(varLayout->semanticIndex); + } + + return; + } + } + } + + // TODO(tfoley): should we ever need to use the high-level declaration + // for this? It seems like the wrong approach... + auto decoration = inst->findDecoration(); if( decoration ) { -- cgit v1.2.3