-
-
Save seanbaxter/5a962b2726d175ed989d162f8bbbdcda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct buffer_t { | |
ivec4 data; | |
}; | |
[[using spirv: buffer, binding(0)]] | |
buffer_t buffer; | |
[[spirv::comp(1)]] | |
void comp_main() { | |
for(int i = 0; i < buffer.data.x; ++i) { | |
if(buffer.data.y < buffer.data.z) { } | |
} | |
} | |
int main() { | |
@spirv(comp_main); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OpCapability Shader | |
OpExtension "GL_EXT_scalar_block_layout" | |
OpMemoryModel Logical GLSL450 | |
OpEntryPoint GLCompute %_Z9comp_mainv "_Z9comp_mainv" %buffer | |
OpExecutionMode %_Z9comp_mainv LocalSize 1 1 1 | |
OpName %buffer_t "buffer_t" | |
OpMemberName %buffer_t 0 "data" | |
OpName %buffer "buffer" | |
OpName %_Z9comp_mainv "_Z9comp_mainv" | |
OpDecorate %buffer_t Block | |
OpMemberDecorate %buffer_t 0 Offset 0 | |
OpDecorate %buffer Binding 0 | |
OpDecorate %buffer DescriptorSet 0 | |
%uint = OpTypeInt 32 0 | |
%v4uint = OpTypeVector %uint 4 | |
%buffer_t = OpTypeStruct %v4uint | |
%_ptr_StorageBuffer_buffer_t = OpTypePointer StorageBuffer %buffer_t | |
%buffer = OpVariable %_ptr_StorageBuffer_buffer_t StorageBuffer | |
%void = OpTypeVoid | |
%8 = OpTypeFunction %void | |
%_ptr_Function_uint = OpTypePointer Function %uint | |
%uint_0 = OpConstant %uint 0 | |
%_ptr_StorageBuffer_v4uint = OpTypePointer StorageBuffer %v4uint | |
%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint | |
%bool = OpTypeBool | |
%uint_1 = OpConstant %uint 1 | |
%_Z9comp_mainv = OpFunction %void None %8 | |
%9 = OpLabel | |
%11 = OpVariable %_ptr_Function_uint Function | |
OpStore %11 %uint_0 | |
OpBranch %13 | |
; Loop header | |
%13 = OpLabel | |
%14 = OpLoad %uint %11 | |
%16 = OpAccessChain %_ptr_StorageBuffer_v4uint %buffer %uint_0 | |
%18 = OpAccessChain %_ptr_StorageBuffer_uint %16 %uint_0 | |
%19 = OpLoad %uint %18 | |
%21 = OpSLessThan %bool %14 %19 | |
OpLoopMerge %22 %23 None | |
OpBranchConditional %21 %24 %22 | |
; if-statement | |
%24 = OpLabel | |
%25 = OpAccessChain %_ptr_StorageBuffer_v4uint %buffer %uint_0 | |
%27 = OpAccessChain %_ptr_StorageBuffer_uint %25 %uint_1 | |
%28 = OpLoad %uint %27 | |
%29 = OpLoad %uint %11 | |
%30 = OpSLessThan %bool %28 %29 | |
; This shader fails to validate when the merge block is %23, | |
; even though it dominates both branch targets %31 and %32. | |
; It passes when the merge block is %32, even though that | |
; does not dominate both branch targets. | |
; OpSelectionMerge %32 None | |
OpSelectionMerge %23 None | |
OpBranchConditional %30 %31 %32 | |
%31 = OpLabel | |
OpBranch %23 | |
%32 = OpLabel | |
OpBranch %23 | |
%23 = OpLabel | |
%33 = OpLoad %uint %11 | |
%34 = OpIAdd %uint %33 %uint_1 | |
OpStore %11 %34 | |
OpBranch %13 | |
%22 = OpLabel | |
OpReturn | |
OpFunctionEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error: line 40: Header block 25[%25] is contained in the loop construct headed by 17[%17], but its merge block 24[%24] is not | |
%25 = OpLabel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment