diff options
| author | Yong He <yonghe@outlook.com> | 2023-08-10 14:58:41 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-10 14:58:41 -0700 |
| commit | 38b0af3537f5d8412f0d69e39e38c5603ff62c15 (patch) | |
| tree | 5892b0b2427f0de0057259949e03105ec766143a /source/slang/slang-emit-glsl.cpp | |
| parent | 60ebadab1ec269c7017148a028307a9b5f32b1d4 (diff) | |
Add support for ConstBufferPointer on Vulkan. (#3089)
* Add support for `ConstBufferPointer` on Vulkan.
* Add spv compilation test.
* Fix.
* Fix code review issues.
---------
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 | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index 321f41d54..22a0c323b 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -1617,6 +1617,39 @@ bool GLSLSourceEmitter::_tryEmitBitBinOp(IRInst* inst, const EmitOpInfo& bitOp, } +void GLSLSourceEmitter::emitBufferPointerTypeDefinition(IRInst* ptrType) +{ + _requireGLSLExtension(UnownedStringSlice("GL_EXT_buffer_reference")); + + auto constPtrType = as<IRHLSLConstBufferPointerType>(ptrType); + auto ptrTypeName = getName(ptrType); + auto alignment = getIntVal(constPtrType->getBaseAlignment()); + m_writer->emit("layout(buffer_reference, std430, buffer_reference_align = "); + m_writer->emitInt64(alignment); + m_writer->emit(") readonly buffer "); + m_writer->emit(ptrTypeName); + m_writer->emit("\n"); + m_writer->emit("{\n"); + m_writer->indent(); + emitType((IRType*)constPtrType->getValueType(), "_data"); + m_writer->emit(";\n"); + m_writer->dedent(); + m_writer->emit("};\n"); +} + +void GLSLSourceEmitter::emitGlobalInstImpl(IRInst* inst) +{ + switch (inst->getOp()) + { + case kIROp_HLSLConstBufferPointerType: + emitBufferPointerTypeDefinition(inst); + break; + default: + Super::emitGlobalInstImpl(inst); + break; + } +} + bool GLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOuterPrec) { switch (inst->getOp()) @@ -2228,6 +2261,7 @@ void GLSLSourceEmitter::emitSimpleTypeImpl(IRType* type) return; } case kIROp_StructType: + case kIROp_HLSLConstBufferPointerType: m_writer->emit(getName(type)); return; @@ -2629,3 +2663,4 @@ void GLSLSourceEmitter::emitMatrixLayoutModifiersImpl(IRVarLayout* layout) } // namespace Slang + |
