KhronosGroup / KhronosGroup/Vulkan-ValidationLayers

Hitting assert at shader module creation validation with OpTypeRuntimeArray present

Open
#6,968 1 comment 0 reactions 1 assignee Claimed by @spencer-lunarg View on GitHub
ShaderVal
Dominant language
C++
Stars
1k
Forks
504
Avg merge
11h 35m
Merged PRs (30d)
224

Description

**Environment:**
- OS: Any
- GPU and driver version: Any
- SDK or header version if building from repo: ToT
- Options enabled (synchronization, best practices, etc.): None

**Describe the Issue**

While running CTS test `dEQP-VK.spirv_assembly.instruction.compute.physical_storage_buffer.vertex_in_out_in` at shader module creation VVL hits the following asser: `layers/state_tracker/shader_instruction.cpp:101: uint32_t Instruction::GetBitWidth() const: Assertion '0' failed`.

Here are the 2 shaders used in the test (both hit the assert):

Vertex shader:
```
OpCapability Shader
OpCapability PhysicalStorageBufferAddresses

OpExtension "SPV_KHR_physical_storage_buffer"
OpMemoryModel PhysicalStorageBuffer64 GLSL450

OpEntryPoint Vertex %vert "main" %gl_PerVertex %in_pos %out_idx %gl_VertexIndex %in_addr %out_addr

OpDecorate %PerVertex Block
OpDecorate %gl_VertexIndex BuiltIn VertexIndex
OpDecorate %in_pos Location 0
OpDecorate %in_addr Location 1
OpDecorate %in_addr RestrictPointerEXT
OpDecorate %out_addr RestrictPointerEXT
OpDecorate %out_idx Location 0
OpDecorate %out_addr Location 1

OpMemberDecorate %PerVertex 0 BuiltIn Position
OpMemberDecorate %PerVertex 1 BuiltIn PointSize
OpMemberDecorate %PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %PerVertex 3 BuiltIn CullDistance

OpDecorate %srta Block
OpMemberDecorate %srta 0 Offset 0

OpDecorate %rta ArrayStride 16

%void = OpTypeVoid
%voidf = OpTypeFunction %void

%int = OpTypeInt 32 1
%flt = OpTypeFloat 32
%vec4 = OpTypeVector %flt 4
%rta = OpTypeRuntimeArray %vec4

%zero = OpConstant %int 0
%one = OpConstant %int 1

%srta = OpTypeStruct %rta
%srta_psb = OpTypePointer PhysicalStorageBuffer %srta
%srta_psb_in = OpTypePointer Input %srta_psb
%srta_psb_out = OpTypePointer Output %srta_psb
%in_addr = OpVariable %srta_psb_in Input
%out_addr = OpVariable %srta_psb_out Output

%vec4_in = OpTypePointer Input %vec4
%vec4_out = OpTypePointer Output %vec4
%vec4_psb = OpTypePointer PhysicalStorageBuffer %vec4
%in_pos = OpVariable %vec4_in Input

%int_in = OpTypePointer Input %int
%int_out = OpTypePointer Output %int
%gl_VertexIndex = OpVariable %int_in Input
%out_idx = OpVariable %int_out Output

%flt_arr_1 = OpTypeArray %flt %one
%PerVertex = OpTypeStruct %vec4 %flt %flt_arr_1 %flt_arr_1
%pv_out = OpTypePointer Output %PerVertex
%gl_PerVertex = OpVariable %pv_out Output

%vert = OpFunction %void None %voidf
%vert_begin = OpLabel

%vpos = OpLoad %vec4 %in_pos
%gl_Position = OpAccessChain %vec4_out %gl_PerVertex %zero
OpStore %gl_Position %vpos

%vidx = OpLoad %int %gl_VertexIndex
OpStore %out_idx %vidx

%vaddr = OpLoad %srta_psb %in_addr Aligned 8
OpStore %out_addr %vaddr

OpReturn
OpFunctionEnd
```

Fragment shader:
```
OpCapability Shader
OpCapability PhysicalStorageBufferAddresses

OpExtension "SPV_KHR_physical_storage_buffer"
OpMemoryModel PhysicalStorageBuffer64 GLSL450

OpEntryPoint Fragment %frag "main" %in_idx %in_addr %dEQP_FragColor
OpExecutionMode %frag OriginUpperLeft

OpDecorate %in_idx Location 0
OpDecorate %in_idx Flat
OpDecorate %in_addr Location 1
OpDecorate %in_addr AliasedPointerEXT
OpDecorate %in_addr Flat
OpDecorate %dEQP_FragColor Location 0

OpDecorate %rta ArrayStride 16
OpDecorate %vec4_psb ArrayStride 16
OpDecorate %srta Block
OpMemberDecorate %srta 0 Offset 0

%void = OpTypeVoid
%voidf = OpTypeFunction %void

%int = OpTypeInt 32 1
%flt = OpTypeFloat 32
%vec4 = OpTypeVector %flt 4
%rta = OpTypeRuntimeArray %vec4

%zero = OpConstant %int 0

%int_in = OpTypePointer Input %int
%in_idx = OpVariable %int_in Input

%vec4_out = OpTypePointer Output %vec4
%dEQP_FragColor = OpVariable %vec4_out Output

%srta = OpTypeStruct %rta
%srta_psb = OpTypePointer PhysicalStorageBuffer %srta
%srta_psb_in = OpTypePointer Input %srta_psb
%in_addr = OpVariable %srta_psb_in Input
%rta_psb = OpTypePointer PhysicalStorageBuffer %rta
%rta_in = OpTypePointer Input %rta
%vec4_psb = OpTypePointer PhysicalStorageBuffer %vec4

%frag = OpFunction %void None %voidf
%frag_begin = OpLabel

%vidx = OpLoad %int %in_idx
%vaddr = OpLoad %srta_psb %in_addr
%pcolor = OpAccessChain %vec4_psb %vaddr %zero %vidx
%color = OpLoad %vec4 %pcolor Aligned 16
OpStore %dEQP_FragColor %color
OpReturn
OpFunctionEnd
```

**Expected behavior**

I believe no assert should be hit

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.