diff options
| author | Yong He <yonghe@outlook.com> | 2023-05-02 20:29:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-02 20:29:38 -0700 |
| commit | d52376a65f37fcbbb67428b917fd3819436b6dfb (patch) | |
| tree | da25b3c9a00bd003b1970b4a6c4eb38eccf62aa1 /source/slang/slang-emit-glsl.cpp | |
| parent | 55291b0bf6d729fcbaf75a01926da7da8975b8e9 (diff) | |
Various dxc/fxc compatibility fixes. (#2863)
* Various dxc/fxc compatibility fixes.
* Cleanup.
* Fix test cases.
* Fix comments.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit-glsl.cpp')
| -rw-r--r-- | source/slang/slang-emit-glsl.cpp | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index 0abd78137..bc170dadc 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -339,16 +339,25 @@ void GLSLSourceEmitter::_emitGLSLParameterGroup(IRGlobalParam* varDecl, IRUnifor m_writer->emit("_S"); m_writer->emit(m_uniqueIDCounter++); - m_writer->emit("\n{\n"); - m_writer->indent(); auto elementType = type->getElementType(); - - emitType(elementType, "_data"); - m_writer->emit(";\n"); - - m_writer->dedent(); - m_writer->emit("} "); + auto structType = as<IRStructType>(elementType); + if (!as<IRGLSLShaderStorageBufferType>(type) && structType) + { + // We need to emit the fields of the struct as individual variables + // in the constant buffer. + // + emitStructDeclarationsBlock(structType, true); + } + else + { + m_writer->emit("\n{\n"); + m_writer->indent(); + emitType(elementType, "_data"); + m_writer->emit(";\n"); + m_writer->dedent(); + m_writer->emit("} "); + } m_writer->emit(getName(varDecl)); @@ -794,7 +803,7 @@ void GLSLSourceEmitter::_maybeEmitGLSLBuiltin(IRGlobalParam* var, UnownedStringS m_writer->emit("out"); m_writer->emit(" "); m_writer->emit(elementTypeName); - emitStructDeclarationsBlock(elementType); + emitStructDeclarationsBlock(elementType, false); m_writer->emit(" "); m_writer->emit(name); emitArrayBrackets(arrayType); @@ -1157,7 +1166,7 @@ void GLSLSourceEmitter::_emitGLSLPerVertexVaryingFragmentInput(IRGlobalParam* pa // _emitType(type, &arrayDeclarator); - emitSemantics(param); + emitSemantics(param, false); emitLayoutSemantics(param); @@ -2372,6 +2381,17 @@ void GLSLSourceEmitter::emitInterpolationModifiersImpl(IRInst* varInst, IRType* } } +void GLSLSourceEmitter::emitPackOffsetModifier(IRInst* varInst, IRType* valueType, IRPackOffsetDecoration* decoration) +{ + SLANG_UNUSED(varInst); + SLANG_UNUSED(valueType); + + _requireGLSLExtension(UnownedStringSlice::fromLiteral("GL_ARB_enhanced_layouts")); + m_writer->emit("layout(offset = "); + m_writer->emit(decoration->getRegisterOffset()->getValue() * 16 + decoration->getComponentOffset()->getValue() * 4); + m_writer->emit(")\n"); +} + void GLSLSourceEmitter::emitMeshOutputModifiersImpl(IRInst* varInst) { if(varInst->findDecoration<IRGLSLPrimitivesRateDecoration>()) |
