From 88023aea669f258d66e53eab10215337a7f72853 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 19 Oct 2017 11:49:16 -0700 Subject: Reflection: allow querying of semantics on varying input/output (#224) This is functionality required to support a Falcor bug fix. Most of the code to compute the right semantic name/index for a parameter was already present. This change adds: - Storage for semantic name/index on every `VarLayout` - Note: this is wasteful and should be optimized later - A public API to query the semantic name/index - The contract is that this API returns `NULL` if the parameter had no semantic - A bit of work in `parameter-binding.cpp` to attach semantics to varying input/output when traversing varying parameters. - Note: this is intentionally set up so that it associates semantics even with non-leaf parameters, so that an API user can query the semantic of a `struct` parameter and know that its members will be assigned sequential semantic indices from its starting value. - Support for dumping this information in reflection tests One notable thing that I did *not* change here is that the reflection test fixture doesn't report information on the output of an entry point, even though it really should. That should be fixed in a separate change, though, because it would affect many of the expected outputs. --- source/slang/parameter-binding.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source/slang/parameter-binding.cpp') diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp index 4fbec5652..fed838e6b 100644 --- a/source/slang/parameter-binding.cpp +++ b/source/slang/parameter-binding.cpp @@ -1190,6 +1190,27 @@ static RefPtr processEntryPointParameter( EntryPointParameterState const& state, RefPtr varLayout) { + // If there is an available semantic name and index, + // then we should apply it to this parameter unconditionally + // (that is, not just if it is a leaf parameter). + auto optSemanticName = state.optSemanticName; + if (optSemanticName && varLayout) + { + // Always store semantics in upper-case for + // reflection information, since they are + // supposed to be case-insensitive and + // upper-case is the dominant convention. + String semanticName = *optSemanticName; + String sn = semanticName.ToUpper(); + + auto semanticIndex = *state.ioSemanticIndex; + + varLayout->semanticName = sn; + varLayout->semanticIndex = semanticIndex; + varLayout->flags |= VarLayoutFlag::HasSemantic; + } + + // Scalar and vector types are treated as outputs directly if(auto basicType = type->As()) { -- cgit v1.2.3