Skip to content

How do I use SPV_KHR_expect_assume in slang? #6256

Answered by csyonghe
Cazadorro asked this question in Q&A
Discussion options

You must be logged in to vote

This is not yet supported in Slang. However, you can use this SPIRV inst in Slang by defining the intrinsic yourself:

[ForceInline]
void assume(bool value)
{
     spirv_asm
     {
           OpExtension "SPV_KHR_expect_assume";
           OpCapability ExpectAssumeKHR;
           OpAssumeTrueKHR $value
     };
}

[ForceInline]
T expect<T>(T value, T expectedValue)
{
     return spirv_asm
     {
           OpExtension "SPV_KHR_expect_assume";
           OpCapability ExpectAssumeKHR;
           result:$$T = OpExpectKHR $value $expectedValue;
     };
}

See an example here.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Cazadorro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants