diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-06-20 09:24:31 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-06-20 09:35:51 -0700 |
| commit | c163c33664af1a68613ecbf0c4e747ad3ee3dbb1 (patch) | |
| tree | b53ae92e80a1e447d738129e2015f8803da6bea4 /source/slang/syntax.cpp | |
| parent | 5b85b51686bafe969c4d1c75b59aa17bc014367a (diff) | |
Fix types for `InputPatch` and `OutputPatch`
Fixes #34.
I'd declared these as if they were `InputPatch<T>`, but they are really `InputPatch<T,N>`.
This change fixes the declarations, and makes these types no longer inherit from the contrived `BuiltinGenericType`.
Instead they are more-or-less ordinary `DeclRefType`s using the same approach that `MatrixExpressionType` uses.
Diffstat (limited to 'source/slang/syntax.cpp')
| -rw-r--r-- | source/slang/syntax.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp index d37f782f6..f78d3c8ec 100644 --- a/source/slang/syntax.cpp +++ b/source/slang/syntax.cpp @@ -525,6 +525,22 @@ namespace Slang return textureType; } + // TODO: eventually everything should follow this pattern, + // and we can drive the dispatch with a table instead + // of this ridiculously slow `if` cascade. + + #define CASE(n,T) \ + else if(magicMod->name == #n) { \ + auto type = new T(); \ + type->declRef = declRef; \ + return type; \ + } + + CASE(HLSLInputPatchType, HLSLInputPatchType) + CASE(HLSLOutputPatchType, HLSLOutputPatchType) + + #undef CASE + #define CASE(n,T) \ else if(magicMod->name == #n) { \ assert(subst && subst->args.Count() == 1); \ @@ -550,8 +566,6 @@ namespace Slang CASE(HLSLRWStructuredBufferType, HLSLRWStructuredBufferType) CASE(HLSLAppendStructuredBufferType, HLSLAppendStructuredBufferType) CASE(HLSLConsumeStructuredBufferType, HLSLConsumeStructuredBufferType) - CASE(HLSLInputPatchType, HLSLInputPatchType) - CASE(HLSLOutputPatchType, HLSLOutputPatchType) CASE(HLSLPointStreamType, HLSLPointStreamType) CASE(HLSLLineStreamType, HLSLPointStreamType) @@ -1470,4 +1484,17 @@ namespace Slang return IntrinsicOp::Unknown; } + // + + // HLSLPatchType + + ExpressionType* HLSLPatchType::getElementType() + { + return this->declRef.substitutions->args[0].As<ExpressionType>().Ptr(); + } + + IntVal* HLSLPatchType::getElementCount() + { + return this->declRef.substitutions->args[1].As<IntVal>().Ptr(); + } }
\ No newline at end of file |
