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

Declaration of global uniform bool raises validation error #3387

Closed
rdb opened this issue Jun 1, 2020 · 7 comments
Closed

Declaration of global uniform bool raises validation error #3387

rdb opened this issue Jun 1, 2020 · 7 comments

Comments

@rdb
Copy link
Contributor

rdb commented Jun 1, 2020

The use of "uniform bool" results in a spirv-val error:

error: line 17: 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
  %abc = OpVariable %_ptr_UniformConstant_bool UniformConstant

GLSL shader:

#version 430

layout(location=0) uniform bool abc;

void main() {
}

Compiled with:

glslangValidator -G test.vert

Disassembly of compiled SPIR-V code:

; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 8
; Bound: 13
; Schema: 0
               OpCapability Shader
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint Vertex %main "main" %gl_VertexID %gl_InstanceID
               OpSource GLSL 430
               OpName %main "main"
               OpName %abc "abc"
               OpName %gl_VertexID "gl_VertexID"
               OpName %gl_InstanceID "gl_InstanceID"
               OpDecorate %abc Location 0
               OpDecorate %gl_VertexID BuiltIn VertexId
               OpDecorate %gl_InstanceID BuiltIn InstanceId
       %void = OpTypeVoid
          %3 = OpTypeFunction %void
       %bool = OpTypeBool
%_ptr_UniformConstant_bool = OpTypePointer UniformConstant %bool
        %abc = OpVariable %_ptr_UniformConstant_bool UniformConstant
        %int = OpTypeInt 32 1
%_ptr_Input_int = OpTypePointer Input %int
%gl_VertexID = OpVariable %_ptr_Input_int Input
%gl_InstanceID = OpVariable %_ptr_Input_int Input
       %main = OpFunction %void None %3
          %5 = OpLabel
               OpReturn
               OpFunctionEnd

Possibly regression in #1872 (CC @jaebaek, linked issue #1405). Tested with latest master versions of glslang and SPIRV-Tools.

@johnkslang
Copy link
Member

johnkslang commented Jun 2, 2020

Are you targeting OpenGL?

This functionality does not exist in Vulkan, and hence might be a hole in some tools or specifications.

@rdb
Copy link
Contributor Author

rdb commented Jun 2, 2020

Yes, I'm targeting OpenGL. Explicitly specifying OpenGL target to spirv-val does not solve the problem.

@johnkslang
Copy link
Member

I suspect the specifications should be updated to allow Boolean type for this purpose.

@rdb
Copy link
Contributor Author

rdb commented Jun 2, 2020

Where should I file bugs against the SPIR-V specification?

@johnkslang
Copy link
Member

File SPIR-V specification bugs at https://github.com/KhronosGroup/SPIRV-Registry.

Thanks.

@s-perron
Copy link
Collaborator

The tooling will be updated once the spec is changed. Closing this issue.

@rdb
Copy link
Contributor Author

rdb commented Jun 17, 2023

Tooling was already updated actually in anticipation of a future spec change, see #5237

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

3 participants