Skip to content

Handle spirv_literal operands in spirv_instruction with a set - #4454

Open
saqibkh wants to merge 1 commit into
KhronosGroup:mainfrom
saqibkh:fix-spirv-literal-with-set
Open

saqibkh wants to merge 1 commit into
KhronosGroup:mainfrom
saqibkh:fix-spirv-literal-with-set

Conversation

@saqibkh

@saqibkh saqibkh commented Oct 1, 2026

Copy link
Copy Markdown

Fixes #4317.

When spirv_instruction names an extended instruction set (set = "..."), the operands were emitted through createBuiltinCall as ids, skipping the spirv_literal handling used for plain opcodes. A literal parameter became id 0, which triggered the addIdOperand assertion in debug builds and produced invalid OpExtInst operands in release builds.

This translates spirv_literal operands before choosing between OpExtInst and the plain opcode (in both the unary and aggregate paths), and adds a createBuiltinCall overload that takes IdImmediate operands, as createOp already does.

The new test spv.intrinsicsSpirvInstructionSetLiteral.comp covers both paths with OpenCL.std vloadn and OpenCL.DebugInfo.100 DebugOperation; spirv-dis shows the literals encoded correctly (vloadn ... 2, DebugOperation Swap). The module can't pass spirv-val: vloadn needs a physical addressing model and DebugInfo instructions must be at global scope, and no instruction set lets GLSL use a literal operand legally inside a function body. So the result is added to validation_fails.txt.

When spirv_instruction specified an extended instruction set, operands
were passed to createBuiltinCall as ids, so a spirv_literal parameter
became id 0 instead of its literal value. This asserted in debug builds
and silently produced bad SPIR-V in release builds.

Translate spirv_literal operands before choosing between OpExtInst and
the plain opcode, and add a createBuiltinCall overload that takes
IdImmediate operands, as createOp already does.

Fixes KhronosGroup#4317
@CLAassistant

CLAassistant commented Oct 1, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assert when using spirv_literal parameter in spirv_instruction with set

2 participants