Skip to content

Conversation

@Crispigt
Copy link

  • By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.

This PR implements the select() intrinsic for HLSL, MSL, and SPIR-V. It also fixes a missing boolean implementation in MSL.

Fixes a panic when compiling shaders using WGSL select().

  • HLSL: Mapped to the ternary operator (cond ? true : false).
  • MSL: Mapped to metal::select(false, true, cond).
    • Fix: Implemented emitBool for MSL (was previously commented out and not implemented), required for select conditions using literals.
  • SPIR-V: Emits OpSelect (OpCode 69).

Left GLSL unimplemented for now as the test suite appears commented out in test.zig, so I figured I wouldn't implement it.

Tested Verified output generation locally for HLSL, MSL, and SPIR-V using a simple test case.
Validated runtime behavior for HLSL and SPIR-V, by rendering a checkered triangle (using select in the fragment shader) on Windows 11 with an AMD Radeon RX 7900 XTX.

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.

1 participant