Cleanup TODO for constant-expression handling.

Support for constant-expression function calls in SkSL now exists, and
support for abs() was added at http://review.skia.org/405676.

Change-Id: I3144af993db93a3d640971734d4cb03e0cfb8589
Bug: skia:10835
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408642
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
John Stiles 2021-05-14 07:59:55 -04:00 committed by Skia Commit-Bot
parent 18d4964a4b
commit 6831635373
4 changed files with 7 additions and 44 deletions

View File

@ -3,9 +3,7 @@ uniform half4 colorGreen, colorRed;
half4 main(float2 coords) { half4 main(float2 coords) {
const float4 a = float4(0); const float4 a = float4(0);
const float4 b = float4(1); const float4 b = float4(1);
// This is a constant-expression in GLSL, but not in SkSL (yet). const float4 c = abs(b * 1);
// We can't declare this const, and we can't eliminate it. skbug.com/10835
/*const*/ float4 c = abs(b);
if (a == b || b != c) { if (a == b || b != c) {
return colorRed; return colorRed;
} else { } else {

View File

@ -10,8 +10,6 @@ OpMemberName %_UniformBuffer 0 "colorGreen"
OpMemberName %_UniformBuffer 1 "colorRed" OpMemberName %_UniformBuffer 1 "colorRed"
OpName %_entrypoint_v "_entrypoint_v" OpName %_entrypoint_v "_entrypoint_v"
OpName %main "main" OpName %main "main"
OpName %b "b"
OpName %c "c"
OpDecorate %sk_FragColor RelaxedPrecision OpDecorate %sk_FragColor RelaxedPrecision
OpDecorate %sk_FragColor Location 0 OpDecorate %sk_FragColor Location 0
OpDecorate %sk_FragColor Index 0 OpDecorate %sk_FragColor Index 0
@ -23,8 +21,7 @@ OpMemberDecorate %_UniformBuffer 1 RelaxedPrecision
OpDecorate %_UniformBuffer Block OpDecorate %_UniformBuffer Block
OpDecorate %10 Binding 0 OpDecorate %10 Binding 0
OpDecorate %10 DescriptorSet 0 OpDecorate %10 DescriptorSet 0
OpDecorate %43 RelaxedPrecision OpDecorate %30 RelaxedPrecision
OpDecorate %46 RelaxedPrecision
%float = OpTypeFloat 32 %float = OpTypeFloat 32
%v4float = OpTypeVector %float 4 %v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float %_ptr_Output_v4float = OpTypePointer Output %v4float
@ -42,13 +39,8 @@ OpDecorate %46 RelaxedPrecision
%19 = OpConstantComposite %v2float %float_0 %float_0 %19 = OpConstantComposite %v2float %float_0 %float_0
%_ptr_Function_v2float = OpTypePointer Function %v2float %_ptr_Function_v2float = OpTypePointer Function %v2float
%23 = OpTypeFunction %v4float %_ptr_Function_v2float %23 = OpTypeFunction %v4float %_ptr_Function_v2float
%_ptr_Function_v4float = OpTypePointer Function %v4float
%float_1 = OpConstant %float 1
%29 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%v4bool = OpTypeVector %bool 4
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float %_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%int = OpTypeInt 32 1 %int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%int_0 = OpConstant %int 0 %int_0 = OpConstant %int 0
%_entrypoint_v = OpFunction %void None %15 %_entrypoint_v = OpFunction %void None %15
%16 = OpLabel %16 = OpLabel
@ -61,24 +53,7 @@ OpFunctionEnd
%main = OpFunction %v4float None %23 %main = OpFunction %v4float None %23
%24 = OpFunctionParameter %_ptr_Function_v2float %24 = OpFunctionParameter %_ptr_Function_v2float
%25 = OpLabel %25 = OpLabel
%b = OpVariable %_ptr_Function_v4float Function %26 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
%c = OpVariable %_ptr_Function_v4float Function %30 = OpLoad %v4float %26
OpStore %b %29 OpReturnValue %30
OpStore %c %29
%31 = OpLoad %v4float %b
%32 = OpLoad %v4float %c
%33 = OpFOrdNotEqual %v4bool %31 %32
%35 = OpAny %bool %33
OpSelectionMerge %38 None
OpBranchConditional %35 %36 %37
%36 = OpLabel
%39 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
%43 = OpLoad %v4float %39
OpReturnValue %43
%37 = OpLabel
%44 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
%46 = OpLoad %v4float %44
OpReturnValue %46
%38 = OpLabel
OpUnreachable
OpFunctionEnd OpFunctionEnd

View File

@ -3,11 +3,7 @@ out vec4 sk_FragColor;
uniform vec4 colorGreen; uniform vec4 colorGreen;
uniform vec4 colorRed; uniform vec4 colorRed;
vec4 main() { vec4 main() {
const vec4 b = vec4(1.0); {
vec4 c = vec4(1.0, 1.0, 1.0, 1.0);
if (b != c) {
return colorRed;
} else {
return colorGreen; return colorGreen;
} }
} }

View File

@ -13,14 +13,8 @@ struct Outputs {
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out; Outputs _out;
(void)_out; (void)_out;
const float4 b = float4(1.0); {
float4 c = float4(1.0, 1.0, 1.0, 1.0);
if (any(b != c)) {
_out.sk_FragColor = _uniforms.colorRed;
return _out;
} else {
_out.sk_FragColor = _uniforms.colorGreen; _out.sk_FragColor = _uniforms.colorGreen;
return _out; return _out;
} }
return _out;
} }