summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-glsl.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-11-21 14:07:23 -0800
committerGitHub <noreply@github.com>2024-11-21 14:07:23 -0800
commitfdf061e278720ec066a1fac8f1f35a22e817bf2d (patch)
treedb6cc05613afacdb9c67a26695355ff1b0086d79 /source/slang/slang-emit-glsl.cpp
parentdcc7c6f009afc0f55e79ced050b772ea9d3b25ae (diff)
Add datalayout for constant buffers. (#5608)
* Add datalayout for constant buffers. * Fixes. * Fix test. * Fix glsl codegen. * Update spirv-specific doc. * Fix test. * Fix binding in the presense of specialization constants. * address comments. * Add a test for constant buffer layout.
Diffstat (limited to 'source/slang/slang-emit-glsl.cpp')
-rw-r--r--source/slang/slang-emit-glsl.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp
index 43ab7b74e..6c525d064 100644
--- a/source/slang/slang-emit-glsl.cpp
+++ b/source/slang/slang-emit-glsl.cpp
@@ -478,8 +478,31 @@ void GLSLSourceEmitter::_emitGLSLParameterGroup(
{
// uniform is implicitly read only
m_writer->emit("layout(");
- m_writer->emit(
- getTargetProgram()->getOptionSet().shouldUseScalarLayout() ? "scalar" : "std140");
+ if (getTargetProgram()->getOptionSet().shouldUseScalarLayout())
+ m_writer->emit("scalar");
+ else if (auto cbufferType = as<IRConstantBufferType>(type))
+ {
+ switch (cbufferType->getDataLayout()->getOp())
+ {
+ case kIROp_Std140BufferLayoutType:
+ m_writer->emit("std140");
+ break;
+ case kIROp_Std430BufferLayoutType:
+ m_writer->emit("std430");
+ break;
+ case kIROp_ScalarBufferLayoutType:
+ _requireGLSLExtension(toSlice("GL_EXT_scalar_block_layout"));
+ m_writer->emit("scalar");
+ break;
+ default:
+ m_writer->emit("std140");
+ break;
+ }
+ }
+ else
+ {
+ m_writer->emit("std140");
+ }
m_writer->emit(") uniform ");
}