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/ir.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source/slang/ir.cpp') diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index 5ace50397..4c01e4fc1 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -3094,6 +3094,31 @@ namespace Slang clonedFunc, entryPointLayout); + // We will also go on and attach layout information + // to the function parameters, so that we have it + // available directly on the parameters, rather + // than having to look it up on the original entry-point layout. + if( auto firstBlock = clonedFunc->getFirstBlock() ) + { + UInt paramLayoutCount = entryPointLayout->fields.Count(); + UInt paramCounter = 0; + for( auto pp = firstBlock->getFirstParam(); pp; pp = pp->getNextParam() ) + { + UInt paramIndex = paramCounter++; + if( paramIndex < paramLayoutCount ) + { + auto paramLayout = entryPointLayout->fields[paramIndex]; + context->builder->addLayoutDecoration( + pp, + paramLayout); + } + else + { + SLANG_UNEXPECTED("too many parameters"); + } + } + } + return clonedFunc; } -- cgit v1.2.3