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] Using bool types or their arrays in Hull and Domain stage IO fails compilation (works with DXIL backend) #3744

Closed
Dredhog opened this issue May 4, 2021 · 0 comments · Fixed by #6129
Assignees
Labels
spirv Work related to SPIR-V

Comments

@Dredhog
Copy link

Dredhog commented May 4, 2021

Title

[SPIR-V] Using bool types or their arrays in Hull and Domain stage IO fails compilation (works with DXIL backend)

Functional impact

Can't use bool types or their arrays in Hull stage input or output or domain input without the SPIR-V backend failing to compile. Using them only in Hull output fails validation and the error message asks to report a bug.

Minimal repro steps

  1. Compile repro_shader_0.txt with either dxc.exe -T hs_6_0 -E Hull -spirv repro_shader_0.txt or dxc.exe -T ds_6_0 -E Domain -spirv repro_shader_0.txt and observe the output:
error: translating binary operator '!=' unimplemented
error: getting value 0 for type unsigned int [3] unimplemented
  1. Compile repro_shader_1.txt with dxc.exe -T hs_6_0 -E Hull -spirv repro_shader_1.txt and observe the output:
fatal error: generated SPIR-V is invalid: OpStore Pointer <id> '33[%33]'s type does not match Object <id> '16[%false]'s type.
  OpStore %33 %false

note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible

Expected result

Compilation should succeed when bools, their vectors or arrays are used in Hull and Domain stage IO as they work for vertex output and also work with the DXIL backend.

Actual result

Compilation fails with the errors seen in the Minimal repro steps section

Further technical details

If the control point member's b type is changed from bool to an array of bools e.g. bool[2] the compiler will generate the following validation error:

fatal error: generated SPIR-V is invalid: If OpTypeBool is stored in conjunction with OpVariable, it can only be used with non-externally visible shader Storage Classes: Workgroup, CrossWorkgroup, Private, and Function
  %in_var_MY_BOOL = OpVariable %_ptr_Input__arr__arr_bool_uint_2_uint_3 Input

note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible

Vectors of books also generate errors.
Used DXC release v1.6.2104 (e09a454)

@jaebaek jaebaek added the spirv Work related to SPIR-V label May 4, 2021
@s-perron s-perron self-assigned this Nov 20, 2023
s-perron added a commit to s-perron/DirectXShaderCompiler that referenced this issue Jan 5, 2024
Inputs and outputs that are boolean in HLSL cannot be bools in SPIR-V
because it is not allowed by the spec. So they need to be treated as
ints in the interface.

This was not tested with Hull shaders, where these input and outputs
must also be turned into arrays. This commit adds the code that will
handle casting the arrays between int and bool.

Fixes microsoft#3744
s-perron added a commit that referenced this issue Jan 9, 2024
Inputs and outputs that are boolean in HLSL cannot be bools in SPIR-V
because it is not allowed by the spec. So they need to be treated as
ints in the interface.

This was not tested with Hull shaders, where these input and outputs
must also be turned into arrays. This commit adds the code that will
handle casting the arrays between int and bool.

Fixes #3744
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spirv Work related to SPIR-V
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants