3 ms·
Hmm, godbolt is showing branches in the vulkan output: return x>0.923880?vec2(s.x,0.0): x>0.382683?s*sqrt(0.5):
by cwillu 2y ago
Hmm, godbolt is showing branches in the vulkan output:
return x>0.923880?vec2(s.x,0.0):
x>0.382683?s*sqrt(0.5):
vec2(0.0,s.y);
turns into
%24 = OpLoad %float %x
%27 = OpFOrdGreaterThan %bool %24 %float_0_923879981
OpSelectionMerge %30 None
OpBranchConditional %27 %29 %35
%29 = OpLabel
%31 = OpAccessChain %_ptr_Function_float %s %uint_0
%32 = OpLoad %float %31
%34 = OpCompositeConstruct %v2float %32 %float_0
OpStore %28 %34
OpBranch %30
%35 = OpLabel
%36 = OpLoad %float %x
%38 = OpFOrdGreaterThan %bool %36 %float_0_382683009
OpSelectionMerge %41 None
OpBranchConditional %38 %40 %45
%40 = OpLabel
%42 = OpLoad %v2float %s
%44 = OpVectorTimesScalar %v2float %42 %float_0_707106769
OpStore %39 %44
OpBranch %41
%45 = OpLabel
%47 = OpAccessChain %_ptr_Function_float %s %uint_1
%48 = OpLoad %float %47
%49 = OpCompositeConstruct %v2float %float_0 %48
OpStore %39 %49
OpBranch %41
%41 = OpLabel
%50 = OpLoad %v2float %39
OpStore %28 %50
OpBranch %30
%30 = OpLabel
%51 = OpLoad %v2float %28
OpReturnValue %51
https://godbolt.org/z/aqob7YfWq https://godbolt.org/z/aqob7YfWq
- SideQuark 2y agoVulcan opcode shader lang is not executed. It’s a platform neutral intermediate language, so won’t have the special purpose optional instructions most GPUs do since GPUs aren’t required to. It likely compiles down on the relevant platforms as the original article did.