From de83628070614ec37349c9f334ed72a54a6889da Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 30 Aug 2024 12:03:23 -0700 Subject: Support specialization constants. (#4963) * Support specialization constants. * Fix. * Fix. * Fix. * Fix. * Make sure specialization constants have names. * Clean up and support the dxc [vk::constant_id] syntax. * Fix. * Fix. * Fix. --- source/slang/slang-emit-glsl.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/slang/slang-emit-glsl.cpp') diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index 902030791..fff1cddbe 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -385,6 +385,15 @@ void GLSLSourceEmitter::_emitGLSLSSBO(IRGlobalParam* varDecl, IRGLSLShaderStorag m_writer->emit(";\n"); } +void GLSLSourceEmitter::emitGlobalParamDefaultVal(IRGlobalParam* param) +{ + if (auto defaultValDecor = param->findDecoration()) + { + m_writer->emit(" = "); + emitInstExpr(defaultValDecor->getOperand(0), EmitOpInfo()); + } +} + void GLSLSourceEmitter::_emitGLSLParameterGroup(IRGlobalParam* varDecl, IRUniformParameterGroupType* type) { auto varLayout = getVarLayout(varDecl); @@ -418,6 +427,8 @@ void GLSLSourceEmitter::_emitGLSLParameterGroup(IRGlobalParam* varDecl, IRUnifor } _emitGLSLLayoutQualifier(LayoutResourceKind::PushConstantBuffer, &containerChain); + _emitGLSLLayoutQualifier(LayoutResourceKind::SpecializationConstant, &containerChain); + bool isShaderRecord = _emitGLSLLayoutQualifier(LayoutResourceKind::ShaderRecord, &containerChain); if (isShaderRecord) -- cgit v1.2.3