-
-
Save seanbaxter/644a6b765ab0fccad64c301303141b53 to your computer and use it in GitHub Desktop.
Selection construct confusion
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
#version 450 | |
float get_range_attenuation(float range, float distance) { | |
if(range <= 0) | |
return range; | |
return distance; | |
} | |
layout(binding=0) | |
buffer data_t { | |
vec4 vec; | |
}; | |
void main() { | |
vec.z = get_range_attenuation(vec.x, vec.y); | |
} |
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
%main = OpFunction %void None %3 | |
%5 = OpLabel | |
%34 = OpAccessChain %_ptr_StorageBuffer_float %_ %int_0 %uint_0 | |
%35 = OpLoad %float %34 | |
%38 = OpAccessChain %_ptr_StorageBuffer_float %_ %int_0 %uint_1 | |
%39 = OpLoad %float %38 | |
OpSelectionMerge %62 None | |
OpSwitch %uint_0 %55 | |
%55 = OpLabel | |
%57 = OpFOrdLessThanEqual %bool %35 %float_0 | |
OpSelectionMerge %60 None | |
OpBranchConditional %57 %58 %60 | |
%58 = OpLabel | |
OpBranch %62 | |
%60 = OpLabel | |
OpBranch %62 | |
%62 = OpLabel | |
%64 = OpPhi %float %35 %58 %39 %60 | |
%42 = OpAccessChain %_ptr_StorageBuffer_float %_ %int_0 %uint_2 | |
OpStore %42 %64 | |
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
%_Z9comp_mainv = OpFunction %void None %8 | |
%9 = OpLabel | |
%13 = OpAccessChain %_ptr_StorageBuffer_v4float %buffer %uint_0 | |
%15 = OpAccessChain %_ptr_StorageBuffer_float %13 %uint_0 | |
%16 = OpLoad %float %15 | |
%17 = OpAccessChain %_ptr_StorageBuffer_v4float %buffer %uint_0 | |
%19 = OpAccessChain %_ptr_StorageBuffer_float %17 %uint_1 | |
%20 = OpLoad %float %19 | |
%23 = OpFOrdLessThanEqual %bool %16 %float_0 | |
OpSelectionMerge %24 None | |
OpBranchConditional %23 %25 %24 | |
%25 = OpLabel | |
OpBranch %26 | |
%24 = OpLabel | |
OpBranch %26 | |
%26 = OpLabel | |
%27 = OpPhi %float %20 %24 %16 %25 | |
%28 = OpAccessChain %_ptr_StorageBuffer_v4float %buffer %uint_0 | |
%30 = OpAccessChain %_ptr_StorageBuffer_float %28 %uint_2 | |
OpStore %30 %27 | |
OpReturn | |
OpFunctionEnd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment