From bd01bd3f4b8eecbfb924b8eb4090694e44e8166c Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Mon, 1 Jul 2024 20:06:58 -0700 Subject: Fix the type error in kIROp_RWStructuredBufferLoad (#4523) * Fix the type error in kIROp_RWStructuredBufferLoad In StructuredBuffer::Load(), we allow any type of integer as the input. However, when emitting glsl code, StructuredBuffer::Load(index) will be translated to the subscript index of the buffer, e.g. buffer[index], however, glsl doesn't allow 64bit integer as the subscript. So the easiest fix is to convert the index to uint when emitting glsl. * Add commit --- source/slang/slang-emit-glsl.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source') diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index 7cf478c36..eea672938 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -2068,7 +2068,10 @@ bool GLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu emitOperand(inst->getOperand(0), leftSide(outerPrec, prec)); m_writer->emit("._data["); + // glsl only support int/uint as array index + m_writer->emit("uint("); emitOperand(inst->getOperand(1), getInfo(EmitOp::General)); + m_writer->emit(")"); m_writer->emit("]"); maybeCloseParens(needClose); -- cgit v1.2.3