summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/diagnostics.h2
-rw-r--r--source/slang/emit.cpp5
-rw-r--r--source/slang/modifier-defs.h1
-rw-r--r--source/slang/parameter-binding.cpp7
-rw-r--r--source/slang/parser.cpp1
-rw-r--r--source/slang/type-layout.cpp29
-rw-r--r--source/slang/type-layout.h9
7 files changed, 48 insertions, 6 deletions
diff --git a/source/slang/diagnostics.h b/source/slang/diagnostics.h
index 6957fc763..988cb742b 100644
--- a/source/slang/diagnostics.h
+++ b/source/slang/diagnostics.h
@@ -206,7 +206,7 @@ namespace Slang
#define SLANG_UNIMPLEMENTED(sink, pos, what) \
(sink)->diagnose(Slang::CodePosition(__LINE__, 0, 0, __FILE__), Slang::Diagnostics::unimplemented, what)
-#define SLANG_UNREACHABLE(msg) do { assert(!"ureachable code:" msg); exit(1); } while(0)
+#define SLANG_UNREACHABLE(msg) do { assert(!"ureachable code:" msg); throw 0; } while(0)
#else
#define SLANG_INTERNAL_ERROR(sink, pos) \
(sink)->diagnose(pos, Slang::Diagnostics::internalCompilerError)
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 21c91a5c0..88b80589a 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -3161,6 +3161,11 @@ struct EmitVisitor
}
Emit(")\n");
break;
+
+ case LayoutResourceKind::PushConstantBuffer:
+ Emit("layout(push_constant)\n");
+ break;
+
}
}
diff --git a/source/slang/modifier-defs.h b/source/slang/modifier-defs.h
index 9806a12a5..665551b35 100644
--- a/source/slang/modifier-defs.h
+++ b/source/slang/modifier-defs.h
@@ -109,6 +109,7 @@ SIMPLE_SYNTAX_CLASS(GLSLConstantIDLayoutModifier , GLSLParsedLayoutModifier)
SIMPLE_SYNTAX_CLASS(GLSLBindingLayoutModifier , GLSLParsedLayoutModifier)
SIMPLE_SYNTAX_CLASS(GLSLSetLayoutModifier , GLSLParsedLayoutModifier)
SIMPLE_SYNTAX_CLASS(GLSLLocationLayoutModifier , GLSLParsedLayoutModifier)
+SIMPLE_SYNTAX_CLASS(GLSLPushConstantLayoutModifier, GLSLParsedLayoutModifier)
// A catch-all for single-keyword modifiers
SIMPLE_SYNTAX_CLASS(SimpleModifier, Modifier)
diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp
index 0683c7f8c..01727fb36 100644
--- a/source/slang/parameter-binding.cpp
+++ b/source/slang/parameter-binding.cpp
@@ -101,7 +101,7 @@ struct ParameterBindingInfo
enum
{
- kLayoutResourceKindCount = SLANG_PARAMETER_CATEGORY_MIXED,
+ kLayoutResourceKindCount = SLANG_PARAMETER_CATEGORY_COUNT,
};
// Information on a single parameter
@@ -290,6 +290,11 @@ getTypeLayoutForGlobalShaderParameter_GLSL(
// any more. As such we also inspect the type
// of the variable.
+ // We want to check for a constant-buffer type with a `push_constant` layout
+ // qualifier before we move on to anything else.
+ if (varDecl->HasModifier<GLSLPushConstantLayoutModifier>() && type->As<ConstantBufferType>())
+ return CreateTypeLayout(type, rules->getPushConstantBufferRules());
+
// TODO(tfoley): We have multiple variations of
// the `uniform` modifier right now, and that
// needs to get fixed...
diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp
index 8314b0930..e0ff85164 100644
--- a/source/slang/parser.cpp
+++ b/source/slang/parser.cpp
@@ -747,6 +747,7 @@ namespace Slang
CASE(binding, GLSLBindingLayoutModifier);
CASE(set, GLSLSetLayoutModifier);
CASE(location, GLSLLocationLayoutModifier);
+ CASE(push_constant, GLSLPushConstantLayoutModifier);
#undef CASE
else
diff --git a/source/slang/type-layout.cpp b/source/slang/type-layout.cpp
index 2977ee9b8..2e0f3035a 100644
--- a/source/slang/type-layout.cpp
+++ b/source/slang/type-layout.cpp
@@ -337,6 +337,19 @@ struct GLSLObjectLayoutRulesImpl : ObjectLayoutRulesImpl
};
GLSLObjectLayoutRulesImpl kGLSLObjectLayoutRulesImpl;
+struct GLSLPushConstantBufferObjectLayoutRulesImpl : GLSLObjectLayoutRulesImpl
+{
+ virtual SimpleLayoutInfo GetObjectLayout(ShaderParameterKind kind) override
+ {
+ // Special-case the layout for a constant-buffer, because we don't
+ // want it to allocate a descriptor-table slot
+ return SimpleLayoutInfo(LayoutResourceKind::PushConstantBuffer, 1);
+
+ return GLSLObjectLayoutRulesImpl::GetObjectLayout(kind);
+ }
+};
+GLSLPushConstantBufferObjectLayoutRulesImpl kGLSLPushConstantBufferObjectLayoutRulesImpl_;
+
struct HLSLObjectLayoutRulesImpl : ObjectLayoutRulesImpl
{
virtual SimpleLayoutInfo GetObjectLayout(ShaderParameterKind kind) override
@@ -392,6 +405,7 @@ HLSLVaryingLayoutRulesImpl kHLSLVaryingOutputLayoutRulesImpl(LayoutResourceKind:
struct GLSLLayoutRulesFamilyImpl : LayoutRulesFamilyImpl
{
virtual LayoutRulesImpl* getConstantBufferRules() override;
+ virtual LayoutRulesImpl* getPushConstantBufferRules() override;
virtual LayoutRulesImpl* getTextureBufferRules() override;
virtual LayoutRulesImpl* getVaryingInputRules() override;
virtual LayoutRulesImpl* getVaryingOutputRules() override;
@@ -402,6 +416,7 @@ struct GLSLLayoutRulesFamilyImpl : LayoutRulesFamilyImpl
struct HLSLLayoutRulesFamilyImpl : LayoutRulesFamilyImpl
{
virtual LayoutRulesImpl* getConstantBufferRules() override;
+ virtual LayoutRulesImpl* getPushConstantBufferRules() override;
virtual LayoutRulesImpl* getTextureBufferRules() override;
virtual LayoutRulesImpl* getVaryingInputRules() override;
virtual LayoutRulesImpl* getVaryingOutputRules() override;
@@ -423,6 +438,10 @@ LayoutRulesImpl kStd430LayoutRulesImpl_ = {
&kGLSLLayoutRulesFamilyImpl, &kStd430LayoutRulesImpl, &kGLSLObjectLayoutRulesImpl,
};
+LayoutRulesImpl kGLSLPushConstantLayoutRulesImpl_ = {
+ &kGLSLLayoutRulesFamilyImpl, &kStd430LayoutRulesImpl, &kGLSLPushConstantBufferObjectLayoutRulesImpl_,
+};
+
LayoutRulesImpl kGLSLVaryingInputLayoutRulesImpl_ = {
&kGLSLLayoutRulesFamilyImpl, &kGLSLVaryingInputLayoutRulesImpl, &kGLSLObjectLayoutRulesImpl,
};
@@ -460,6 +479,11 @@ LayoutRulesImpl* GLSLLayoutRulesFamilyImpl::getConstantBufferRules()
return &kStd140LayoutRulesImpl_;
}
+LayoutRulesImpl* GLSLLayoutRulesFamilyImpl::getPushConstantBufferRules()
+{
+ return &kGLSLPushConstantLayoutRulesImpl_;
+}
+
LayoutRulesImpl* GLSLLayoutRulesFamilyImpl::getTextureBufferRules()
{
return nullptr;
@@ -492,6 +516,11 @@ LayoutRulesImpl* HLSLLayoutRulesFamilyImpl::getConstantBufferRules()
return &kHLSLConstantBufferLayoutRulesImpl_;
}
+LayoutRulesImpl* HLSLLayoutRulesFamilyImpl::getPushConstantBufferRules()
+{
+ return &kHLSLConstantBufferLayoutRulesImpl_;
+}
+
LayoutRulesImpl* HLSLLayoutRulesFamilyImpl::getTextureBufferRules()
{
return nullptr;
diff --git a/source/slang/type-layout.h b/source/slang/type-layout.h
index add9930ae..d2254c9e5 100644
--- a/source/slang/type-layout.h
+++ b/source/slang/type-layout.h
@@ -517,10 +517,11 @@ struct LayoutRulesImpl
struct LayoutRulesFamilyImpl
{
- virtual LayoutRulesImpl* getConstantBufferRules() = 0;
- virtual LayoutRulesImpl* getTextureBufferRules() = 0;
- virtual LayoutRulesImpl* getVaryingInputRules() = 0;
- virtual LayoutRulesImpl* getVaryingOutputRules() = 0;
+ virtual LayoutRulesImpl* getConstantBufferRules() = 0;
+ virtual LayoutRulesImpl* getPushConstantBufferRules() = 0;
+ virtual LayoutRulesImpl* getTextureBufferRules() = 0;
+ virtual LayoutRulesImpl* getVaryingInputRules() = 0;
+ virtual LayoutRulesImpl* getVaryingOutputRules() = 0;
virtual LayoutRulesImpl* getSpecializationConstantRules() = 0;
virtual LayoutRulesImpl* getShaderStorageBufferRules() = 0;
};