diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-07-14 10:44:42 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-07-14 11:09:10 -0700 |
| commit | 2bf87743ffe73f041036ae62c8bf53f09215ca53 (patch) | |
| tree | 7f8302ad4eb9558e1260ad8aed048f1292092489 /source/slang/type-layout.cpp | |
| parent | 082003a1572d24fa3ff9aa0e0f51bf1154445a70 (diff) | |
Don't assign a `binding` to a `push_constant` buffer
Fixes #12
- This was a latent issue, but the previous commit brought it to the front.
- As indicated in #12, I don't allocate a descriptor-table slot to the block
- Instead I allocate a `PushConstantBuffer`
- Unlike what #12 asks for, I don't use a different resource type for the contents of the block
- Pretty much all the logic is easiest if these continue to be just plain `Uniform` data
Diffstat (limited to 'source/slang/type-layout.cpp')
| -rw-r--r-- | source/slang/type-layout.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
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; |
