From a77d22bf3bfc3098b01e4886c3a63fb751edc704 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 21 Jul 2025 09:31:31 -0700 Subject: Fix C-style casts in GLSL pointer cast operations (#7841) * Initial plan * Fix C-style casts in GLSL pointer cast operations Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --- source/slang/slang-emit-glsl.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source') diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index 9d4f72b07..eb71286a2 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -2727,6 +2727,23 @@ bool GLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu } break; } + case kIROp_CastPtrToInt: + case kIROp_CastIntToPtr: + case kIROp_PtrCast: + { + // For GLSL, emit constructor-style casts instead of C-style casts + auto prec = getInfo(EmitOp::Postfix); + EmitOpInfo outerPrec = inOuterPrec; // Make a mutable copy + bool needClose = maybeEmitParens(outerPrec, prec); + + emitType(inst->getDataType()); + m_writer->emit("("); + emitOperand(inst->getOperand(0), getInfo(EmitOp::General)); + m_writer->emit(")"); + + maybeCloseParens(needClose); + return true; + } default: break; } -- cgit v1.2.3