Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPIR-V intrinsics spirv_execution_mode not works with SignedZeroInfNanPreserve #3794

Open
GinShio opened this issue Nov 15, 2024 · 0 comments

Comments

@GinShio
Copy link

GinShio commented Nov 15, 2024

According to vulkan spec 1.3.296:

  • If the environment is not specified in the SPIR-V then it is determined as follows:
    • If any of the following conditions are true then the flags NSZ, NotInf, and NotNaN are assumed:
      • The entry point does not use the Execution Mode SignedZeroInfNanPreserve with a bit-width corresponding to one of the operands or to the result type.

If I understand correctly, I should use execution mode SignedZeroInfNanPreserve if I want to disable the NotNaN flag. Therefore, I want to use spirv intrinsic in glsl. But it looks cannot work.

For example,

#version 450

#extension GL_EXT_spirv_intrinsics : enable

layout(local_size_x = 16, local_size_y = 16) in;

spirv_execution_mode(extensions=["SPV_KHR_float_controls"], capabilities=[4466], 4461);
// spirv_execution_mode(4461);  // SignedZeroInfNanPreserve

layout(std430, binding = 0) buffer SSBO {
  vec4 o[256];
};

layout(binding = 2) uniform UBO {
  vec4 v4[256];
};

const float kNan = 0.0 / 0.0;

//                     Quiet NaN,   Signaling NaN, Infinity,    Real (1.0)
const uvec4 k4 = uvec4(0x7FF0FFFFu, 0xFFA0FFFFu,   0x7F800000u, 0x3F800000u);

void main() {
  vec4 r0 = v4[gl_LocalInvocationID.x];
  r0.y = uintBitsToFloat(r0.y == 1.0 ? k4.x : 0u);
  r0.x = r0.x != 0.0 ? 0.0 : r0.y;
  o[gl_LocalInvocationID.x] = mix(vec4(1.0, 0.0, 0.0, 1.0), vec4(0.0, 1.0, 0.0, 1.0), notEqual(vec4(r0.xxxx), vec4(0.)));
}

Either glslc or glslangValidator, compiler generates spv file. But when I disassemble the file, get a error:

error: input:0:0:8: End of input reached while decoding OpExecutionMode starting at word 39: expected more operands after 3 words.
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

No branches or pull requests

1 participant