summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-06-20 09:54:38 -0700
committerGitHub <noreply@github.com>2017-06-20 09:54:38 -0700
commit40617db15d87ece6e7cc88da23f747f8f827c69a (patch)
treeb53ae92e80a1e447d738129e2015f8803da6bea4 /source
parent5b85b51686bafe969c4d1c75b59aa17bc014367a (diff)
parentc163c33664af1a68613ecbf0c4e747ad3ee3dbb1 (diff)
Merge pull request #35 from tfoleyNV/input-patch-type-fix
Fix types for `InputPatch` and `OutputPatch`
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-stdlib.cpp4
-rw-r--r--source/slang/syntax.cpp31
-rw-r--r--source/slang/syntax.h11
3 files changed, 40 insertions, 6 deletions
diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp
index 9ff8a1078..19827285c 100644
--- a/source/slang/slang-stdlib.cpp
+++ b/source/slang/slang-stdlib.cpp
@@ -78,12 +78,12 @@ __generic<T> __magic_type(HLSLConsumeStructuredBufferType) struct ConsumeStructu
out uint stride);
};
-__generic<T> __magic_type(HLSLInputPatchType) struct InputPatch
+__generic<T, let N : int> __magic_type(HLSLInputPatchType) struct InputPatch
{
__intrinsic __subscript(uint index) -> T;
};
-__generic<T> __magic_type(HLSLOutputPatchType) struct OutputPatch
+__generic<T, let N : int> __magic_type(HLSLOutputPatchType) struct OutputPatch
{
__intrinsic __subscript(uint index) -> T { set; }
};
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
diff --git a/source/slang/syntax.h b/source/slang/syntax.h
index 56574d124..66eddc536 100644
--- a/source/slang/syntax.h
+++ b/source/slang/syntax.h
@@ -1044,8 +1044,15 @@ namespace Slang
class HLSLAppendStructuredBufferType : public BuiltinGenericType {};
class HLSLConsumeStructuredBufferType : public BuiltinGenericType {};
- class HLSLInputPatchType : public BuiltinGenericType {};
- class HLSLOutputPatchType : public BuiltinGenericType {};
+ class HLSLPatchType : public DeclRefType
+ {
+ public:
+ ExpressionType* getElementType();
+ IntVal* getElementCount();
+ };
+
+ class HLSLInputPatchType : public HLSLPatchType {};
+ class HLSLOutputPatchType : public HLSLPatchType {};
// HLSL geometry shader output stream types