From ecd7c2278f45d91ff3a5d078bf423e751ce25f56 Mon Sep 17 00:00:00 2001 From: John Stiles Date: Mon, 8 Feb 2021 14:20:28 -0500 Subject: [PATCH] Migrate the last SkSL tests in shared/ to dm. The leftover tests in shared/ are not easily testable as Runtime Effects; they do things that ES2 doesn't support or use a feature not exposed directly by Runtime Effects. Change-Id: I7ebe170cf713c4a0d2dbef333c1fcbac2410c67f Bug: skia:11009 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/367059 Commit-Queue: John Stiles Auto-Submit: John Stiles Reviewed-by: Ethan Nicholas --- .../TernaryAsLValueEntirelyFoldable.sksl | 11 +- .../shared/TernaryAsLValueFoldableTest.sksl | 11 +- .../sksl/shared/UnaryPositiveNegative.sksl | 8 +- resources/sksl/shared/UnusedVariables.sksl | 5 +- resources/sksl/shared/VectorConstructors.sksl | 57 ++- tests/SkSLTest.cpp | 5 + .../TernaryAsLValueEntirelyFoldable.asm.frag | 29 +- .../TernaryAsLValueEntirelyFoldable.glsl | 5 +- .../TernaryAsLValueEntirelyFoldable.metal | 3 +- .../TernaryAsLValueFoldableTest.asm.frag | 64 ++- .../shared/TernaryAsLValueFoldableTest.glsl | 10 +- .../shared/TernaryAsLValueFoldableTest.metal | 13 +- .../shared/UnaryPositiveNegative.asm.frag | 83 +++- tests/sksl/shared/UnaryPositiveNegative.glsl | 10 +- tests/sksl/shared/UnaryPositiveNegative.metal | 15 +- tests/sksl/shared/UnusedVariables.asm.frag | 52 +- tests/sksl/shared/UnusedVariables.glsl | 4 +- tests/sksl/shared/UnusedVariables.metal | 2 +- tests/sksl/shared/VectorConstructors.asm.frag | 459 ++++++++++-------- tests/sksl/shared/VectorConstructors.glsl | 27 +- tests/sksl/shared/VectorConstructors.metal | 48 +- 21 files changed, 532 insertions(+), 389 deletions(-) diff --git a/resources/sksl/shared/TernaryAsLValueEntirelyFoldable.sksl b/resources/sksl/shared/TernaryAsLValueEntirelyFoldable.sksl index 4a35b4e430..602bf39eb9 100644 --- a/resources/sksl/shared/TernaryAsLValueEntirelyFoldable.sksl +++ b/resources/sksl/shared/TernaryAsLValueEntirelyFoldable.sksl @@ -1,7 +1,6 @@ -void main() { - int r, g; - (true ? r : g) = 1; - (false ? r : g) = 0; - sk_FragColor.x = half(r); - sk_FragColor.y = half(g); +half4 main() { + half r, g; + (true ? r : g) = 0; + (false ? r : g) = 1; + return half4(r, g, 0, 1); } diff --git a/resources/sksl/shared/TernaryAsLValueFoldableTest.sksl b/resources/sksl/shared/TernaryAsLValueFoldableTest.sksl index d2af4598aa..e61eb66a17 100644 --- a/resources/sksl/shared/TernaryAsLValueFoldableTest.sksl +++ b/resources/sksl/shared/TernaryAsLValueFoldableTest.sksl @@ -1,7 +1,8 @@ -void main() { +uniform half unknownInput; // 1 + +half4 main() { half r, g; - (true ? r : g) = half(sqrt(1)); - (false ? r : g) = half(sqrt(0)); - sk_FragColor.x = half(r); - sk_FragColor.y = half(g); + (true ? r : g) = 1 - unknownInput; + (false ? r : g) = unknownInput; + return half4(r, g, 0, 1); } diff --git a/resources/sksl/shared/UnaryPositiveNegative.sksl b/resources/sksl/shared/UnaryPositiveNegative.sksl index 52f852c806..e31d4668c1 100644 --- a/resources/sksl/shared/UnaryPositiveNegative.sksl +++ b/resources/sksl/shared/UnaryPositiveNegative.sksl @@ -1,6 +1,8 @@ -void main() { - half2 x = half2(1); +uniform half4 colorWhite, colorGreen, colorRed; + +half4 main() { + half2 x = colorWhite.rg; x = +x; x = -x; - sk_FragColor.rg = x; + return x == half2(-1) ? colorGreen : colorRed; } diff --git a/resources/sksl/shared/UnusedVariables.sksl b/resources/sksl/shared/UnusedVariables.sksl index 6715c30d20..db6df6bcd2 100644 --- a/resources/sksl/shared/UnusedVariables.sksl +++ b/resources/sksl/shared/UnusedVariables.sksl @@ -1,8 +1,9 @@ -void main() { +half4 main() { float a = 1, b = 2, c = 3; float d = c; float e = d; b++; d++; - sk_FragColor = half4(half(b), half(b), half(d), half(d)); + + return half4(b == 2, b == 3, d == 5, d == 4); } diff --git a/resources/sksl/shared/VectorConstructors.sksl b/resources/sksl/shared/VectorConstructors.sksl index 07cd0706d1..768f190e27 100644 --- a/resources/sksl/shared/VectorConstructors.sksl +++ b/resources/sksl/shared/VectorConstructors.sksl @@ -1,24 +1,37 @@ -float2 v1 = float2(1); -float2 v2 = float2(1, 2); -float2 v3 = float2(float2(1)); -float3 v4 = float3(float2(1), 1.0); -int2 v5 = int2(1); -int2 v6 = int2(float2(1, 2)); -float2 v7 = float2(int2(1, 2)); -float2 v8 = float2(v5); -float4 v9 = float4(v6.x, sqrt(2), int2(3, 4)); -int2 v10 = int2(3.14, v1.x); -bool4 v11 = bool4(bool2(true, false), true, false); -float2 v12 = float2(1.0, false); -float2 v13 = float2(false); -float2 v14 = float2(bool2(false)); -bool2 v15 = bool2(1.0); -bool2 v16 = bool2(float2(1)); -bool3 v17 = bool3(1.0, int2(77)); +/*#pragma settings NoInline*/ -void main() { - sk_FragColor.r = half(v1.x) + half(v2.x) + half(v3.x) + half(v4.x) + half(v5.x) + half(v6.x) + - half(v7.x) + half(v8.x) + half(v9.x) + half(v10.x) + half(v11.x) + - half(v12.x) + half(v13.x) + half(v14.x) + half(v15.x) + half(v16.x) + - half(v17.x); +uniform half4 colorGreen, colorRed; + +bool check(float2 v1, float2 v2, float2 v3, float3 v4, int2 v5, int2 v6, float2 v7, float2 v8, + float4 v9, int2 v10, bool4 v11, float2 v12, float2 v13, float2 v14, bool2 v15, + bool2 v16, bool3 v17) { + return half(v1.x) + half(v2.x) + half(v3.x) + half(v4.x) + + half(v5.x) + half(v6.x) + half(v7.x) + half(v8.x) + + half(v9.x) + half(v10.x) + half(v11.x) + half(v12.x) + + half(v13.x) + half(v14.x) + half(v15.x) + half(v16.x) + + half(v17.x) == 17; +} + +half4 main() { + float2 v1 = float2(1); + float2 v2 = float2(1, 2); + float2 v3 = float2(float2(1)); + float3 v4 = float3(float2(1), 1.0); + int2 v5 = int2(1); + int2 v6 = int2(float2(1, 2)); + float2 v7 = float2(int2(1, 2)); + float2 v8 = float2(v5); + float4 v9 = float4(v6.x, sqrt(2), int2(3, 4)); + int2 v10 = int2(3.14, v1.x); + bool4 v11 = bool4(bool2(true, false), true, false); + float2 v12 = float2(1.0, false); + float2 v13 = float2(false); + float2 v14 = float2(bool2(false)); + bool2 v15 = bool2(1.0); + bool2 v16 = bool2(float2(1)); + bool3 v17 = bool3(1.0, int2(77)); + + return check(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) + ? colorGreen + : colorRed; } diff --git a/tests/SkSLTest.cpp b/tests/SkSLTest.cpp index fa70cad556..0f1ca0f86c 100644 --- a/tests/SkSLTest.cpp +++ b/tests/SkSLTest.cpp @@ -166,6 +166,11 @@ SKSL_TEST(SkSLSwizzleConstants, "shared/SwizzleConstants.sksl") SKSL_TEST(SkSLSwizzleLTRB, "shared/SwizzleLTRB.sksl") SKSL_TEST(SkSLSwizzleOpt, "shared/SwizzleOpt.sksl") SKSL_TEST(SkSLSwizzleScalar, "shared/SwizzleScalar.sksl") +SKSL_TEST(SkSLTernaryAsLValueEntirelyFoldable, "shared/TernaryAsLValueEntirelyFoldable.sksl") +SKSL_TEST(SkSLTernaryAsLValueFoldableTest, "shared/TernaryAsLValueFoldableTest.sksl") +SKSL_TEST(SkSLUnaryPositiveNegative, "shared/UnaryPositiveNegative.sksl") +SKSL_TEST(SkSLUnusedVariables, "shared/UnusedVariables.sksl") +SKSL_TEST(SkSLVectorConstructors, "shared/VectorConstructors.sksl") /* // Incompatible with Runtime Effects because calling a function before its definition is disallowed. diff --git a/tests/sksl/shared/TernaryAsLValueEntirelyFoldable.asm.frag b/tests/sksl/shared/TernaryAsLValueEntirelyFoldable.asm.frag index 135daac77d..61d2e7bcf3 100644 --- a/tests/sksl/shared/TernaryAsLValueEntirelyFoldable.asm.frag +++ b/tests/sksl/shared/TernaryAsLValueEntirelyFoldable.asm.frag @@ -1,10 +1,11 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %sk_FragColor %sk_Clockwise -OpExecutionMode %main OriginUpperLeft +OpEntryPoint Fragment %_entrypoint "_entrypoint" %sk_FragColor %sk_Clockwise +OpExecutionMode %_entrypoint OriginUpperLeft OpName %sk_FragColor "sk_FragColor" OpName %sk_Clockwise "sk_Clockwise" +OpName %_entrypoint "_entrypoint" OpName %main "main" OpDecorate %sk_FragColor RelaxedPrecision OpDecorate %sk_FragColor Location 0 @@ -19,18 +20,18 @@ OpDecorate %sk_Clockwise BuiltIn FrontFacing %_ptr_Input_bool = OpTypePointer Input %bool %sk_Clockwise = OpVariable %_ptr_Input_bool Input %void = OpTypeVoid -%11 = OpTypeFunction %void -%float_1 = OpConstant %float 1 -%_ptr_Output_float = OpTypePointer Output %float -%int = OpTypeInt 32 1 -%int_0 = OpConstant %int 0 +%12 = OpTypeFunction %void +%15 = OpTypeFunction %v4float %float_0 = OpConstant %float 0 -%int_1 = OpConstant %int 1 -%main = OpFunction %void None %11 -%12 = OpLabel -%14 = OpAccessChain %_ptr_Output_float %sk_FragColor %int_0 -OpStore %14 %float_1 -%19 = OpAccessChain %_ptr_Output_float %sk_FragColor %int_1 -OpStore %19 %float_0 +%float_1 = OpConstant %float 1 +%19 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1 +%_entrypoint = OpFunction %void None %12 +%13 = OpLabel +%14 = OpFunctionCall %v4float %main +OpStore %sk_FragColor %14 OpReturn OpFunctionEnd +%main = OpFunction %v4float None %15 +%16 = OpLabel +OpReturnValue %19 +OpFunctionEnd diff --git a/tests/sksl/shared/TernaryAsLValueEntirelyFoldable.glsl b/tests/sksl/shared/TernaryAsLValueEntirelyFoldable.glsl index 7cb450e7c6..e26d14f25a 100644 --- a/tests/sksl/shared/TernaryAsLValueEntirelyFoldable.glsl +++ b/tests/sksl/shared/TernaryAsLValueEntirelyFoldable.glsl @@ -1,6 +1,5 @@ out vec4 sk_FragColor; -void main() { - sk_FragColor.x = 1.0; - sk_FragColor.y = 0.0; +vec4 main() { + return vec4(0.0, 1.0, 0.0, 1.0); } diff --git a/tests/sksl/shared/TernaryAsLValueEntirelyFoldable.metal b/tests/sksl/shared/TernaryAsLValueEntirelyFoldable.metal index e479538f8b..7254bd85d5 100644 --- a/tests/sksl/shared/TernaryAsLValueEntirelyFoldable.metal +++ b/tests/sksl/shared/TernaryAsLValueEntirelyFoldable.metal @@ -9,7 +9,6 @@ struct Outputs { fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { Outputs _out; (void)_out; - _out.sk_FragColor.x = 1.0; - _out.sk_FragColor.y = 0.0; + _out.sk_FragColor = float4(0.0, 1.0, 0.0, 1.0); return _out; } diff --git a/tests/sksl/shared/TernaryAsLValueFoldableTest.asm.frag b/tests/sksl/shared/TernaryAsLValueFoldableTest.asm.frag index 2827bbe5b5..aaac70b3e3 100644 --- a/tests/sksl/shared/TernaryAsLValueFoldableTest.asm.frag +++ b/tests/sksl/shared/TernaryAsLValueFoldableTest.asm.frag @@ -1,10 +1,13 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %sk_FragColor %sk_Clockwise -OpExecutionMode %main OriginUpperLeft +OpEntryPoint Fragment %_entrypoint "_entrypoint" %sk_FragColor %sk_Clockwise +OpExecutionMode %_entrypoint OriginUpperLeft OpName %sk_FragColor "sk_FragColor" OpName %sk_Clockwise "sk_Clockwise" +OpName %_UniformBuffer "_UniformBuffer" +OpMemberName %_UniformBuffer 0 "unknownInput" +OpName %_entrypoint "_entrypoint" OpName %main "main" OpName %r "r" OpName %g "g" @@ -13,8 +16,16 @@ OpDecorate %sk_FragColor Location 0 OpDecorate %sk_FragColor Index 0 OpDecorate %sk_Clockwise RelaxedPrecision OpDecorate %sk_Clockwise BuiltIn FrontFacing -OpDecorate %20 RelaxedPrecision -OpDecorate %25 RelaxedPrecision +OpMemberDecorate %_UniformBuffer 0 Offset 0 +OpMemberDecorate %_UniformBuffer 0 RelaxedPrecision +OpDecorate %_UniformBuffer Block +OpDecorate %10 Binding 0 +OpDecorate %10 DescriptorSet 0 +OpDecorate %28 RelaxedPrecision +OpDecorate %29 RelaxedPrecision +OpDecorate %31 RelaxedPrecision +OpDecorate %32 RelaxedPrecision +OpDecorate %33 RelaxedPrecision %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Output_v4float = OpTypePointer Output %v4float @@ -22,28 +33,37 @@ OpDecorate %25 RelaxedPrecision %bool = OpTypeBool %_ptr_Input_bool = OpTypePointer Input %bool %sk_Clockwise = OpVariable %_ptr_Input_bool Input +%_UniformBuffer = OpTypeStruct %float +%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer +%10 = OpVariable %_ptr_Uniform__UniformBuffer Uniform %void = OpTypeVoid -%11 = OpTypeFunction %void +%15 = OpTypeFunction %void +%18 = OpTypeFunction %v4float %_ptr_Function_float = OpTypePointer Function %float %float_1 = OpConstant %float 1 -%float_0 = OpConstant %float 0 -%_ptr_Output_float = OpTypePointer Output %float +%_ptr_Uniform_float = OpTypePointer Uniform %float %int = OpTypeInt 32 1 %int_0 = OpConstant %int 0 -%int_1 = OpConstant %int 1 -%main = OpFunction %void None %11 -%12 = OpLabel -%r = OpVariable %_ptr_Function_float Function -%g = OpVariable %_ptr_Function_float Function -%16 = OpExtInst %float %1 Sqrt %float_1 -OpStore %r %16 -%18 = OpExtInst %float %1 Sqrt %float_0 -OpStore %g %18 -%20 = OpLoad %float %r -%21 = OpAccessChain %_ptr_Output_float %sk_FragColor %int_0 -OpStore %21 %20 -%25 = OpLoad %float %g -%26 = OpAccessChain %_ptr_Output_float %sk_FragColor %int_1 -OpStore %26 %25 +%float_0 = OpConstant %float 0 +%_entrypoint = OpFunction %void None %15 +%16 = OpLabel +%17 = OpFunctionCall %v4float %main +OpStore %sk_FragColor %17 OpReturn OpFunctionEnd +%main = OpFunction %v4float None %18 +%19 = OpLabel +%r = OpVariable %_ptr_Function_float Function +%g = OpVariable %_ptr_Function_float Function +%24 = OpAccessChain %_ptr_Uniform_float %10 %int_0 +%28 = OpLoad %float %24 +%29 = OpFSub %float %float_1 %28 +OpStore %r %29 +%30 = OpAccessChain %_ptr_Uniform_float %10 %int_0 +%31 = OpLoad %float %30 +OpStore %g %31 +%32 = OpLoad %float %r +%33 = OpLoad %float %g +%35 = OpCompositeConstruct %v4float %32 %33 %float_0 %float_1 +OpReturnValue %35 +OpFunctionEnd diff --git a/tests/sksl/shared/TernaryAsLValueFoldableTest.glsl b/tests/sksl/shared/TernaryAsLValueFoldableTest.glsl index 8d09ae97e2..a887c09c6a 100644 --- a/tests/sksl/shared/TernaryAsLValueFoldableTest.glsl +++ b/tests/sksl/shared/TernaryAsLValueFoldableTest.glsl @@ -1,11 +1,11 @@ out vec4 sk_FragColor; -void main() { +uniform float unknownInput; +vec4 main() { float r; float g; - r = sqrt(1.0); - g = sqrt(0.0); - sk_FragColor.x = r; - sk_FragColor.y = g; + r = 1.0 - unknownInput; + g = unknownInput; + return vec4(r, g, 0.0, 1.0); } diff --git a/tests/sksl/shared/TernaryAsLValueFoldableTest.metal b/tests/sksl/shared/TernaryAsLValueFoldableTest.metal index 3f4cebaace..d8b42990fd 100644 --- a/tests/sksl/shared/TernaryAsLValueFoldableTest.metal +++ b/tests/sksl/shared/TernaryAsLValueFoldableTest.metal @@ -1,20 +1,23 @@ #include #include using namespace metal; +struct Uniforms { + float unknownInput; +}; struct Inputs { }; struct Outputs { float4 sk_FragColor [[color(0)]]; }; -fragment Outputs fragmentMain(Inputs _in [[stage_in]], 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; (void)_out; float r; float g; - r = sqrt(1.0); - g = sqrt(0.0); - _out.sk_FragColor.x = r; - _out.sk_FragColor.y = g; + r = 1.0 - _uniforms.unknownInput; + g = _uniforms.unknownInput; + _out.sk_FragColor = float4(r, g, 0.0, 1.0); return _out; } diff --git a/tests/sksl/shared/UnaryPositiveNegative.asm.frag b/tests/sksl/shared/UnaryPositiveNegative.asm.frag index 3918cd5e00..9f75293be5 100644 --- a/tests/sksl/shared/UnaryPositiveNegative.asm.frag +++ b/tests/sksl/shared/UnaryPositiveNegative.asm.frag @@ -1,17 +1,39 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %sk_FragColor %sk_Clockwise -OpExecutionMode %main OriginUpperLeft +OpEntryPoint Fragment %_entrypoint "_entrypoint" %sk_FragColor %sk_Clockwise +OpExecutionMode %_entrypoint OriginUpperLeft OpName %sk_FragColor "sk_FragColor" OpName %sk_Clockwise "sk_Clockwise" +OpName %_UniformBuffer "_UniformBuffer" +OpMemberName %_UniformBuffer 0 "colorWhite" +OpMemberName %_UniformBuffer 1 "colorGreen" +OpMemberName %_UniformBuffer 2 "colorRed" +OpName %_entrypoint "_entrypoint" OpName %main "main" +OpName %x "x" OpDecorate %sk_FragColor RelaxedPrecision OpDecorate %sk_FragColor Location 0 OpDecorate %sk_FragColor Index 0 OpDecorate %sk_Clockwise RelaxedPrecision OpDecorate %sk_Clockwise BuiltIn FrontFacing -OpDecorate %17 RelaxedPrecision +OpMemberDecorate %_UniformBuffer 0 Offset 0 +OpMemberDecorate %_UniformBuffer 0 RelaxedPrecision +OpMemberDecorate %_UniformBuffer 1 Offset 16 +OpMemberDecorate %_UniformBuffer 1 RelaxedPrecision +OpMemberDecorate %_UniformBuffer 2 Offset 32 +OpMemberDecorate %_UniformBuffer 2 RelaxedPrecision +OpDecorate %_UniformBuffer Block +OpDecorate %10 Binding 0 +OpDecorate %10 DescriptorSet 0 +OpDecorate %27 RelaxedPrecision +OpDecorate %29 RelaxedPrecision +OpDecorate %31 RelaxedPrecision +OpDecorate %30 RelaxedPrecision +OpDecorate %32 RelaxedPrecision +OpDecorate %45 RelaxedPrecision +OpDecorate %48 RelaxedPrecision +OpDecorate %49 RelaxedPrecision %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Output_v4float = OpTypePointer Output %v4float @@ -19,15 +41,58 @@ OpDecorate %17 RelaxedPrecision %bool = OpTypeBool %_ptr_Input_bool = OpTypePointer Input %bool %sk_Clockwise = OpVariable %_ptr_Input_bool Input +%_UniformBuffer = OpTypeStruct %v4float %v4float %v4float +%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer +%10 = OpVariable %_ptr_Uniform__UniformBuffer Uniform %void = OpTypeVoid -%11 = OpTypeFunction %void +%15 = OpTypeFunction %void +%18 = OpTypeFunction %v4float %v2float = OpTypeVector %float 2 +%_ptr_Function_v2float = OpTypePointer Function %v2float +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float +%int = OpTypeInt 32 1 +%int_0 = OpConstant %int 0 %float_n1 = OpConstant %float -1 -%15 = OpConstantComposite %v2float %float_n1 %float_n1 -%main = OpFunction %void None %11 -%12 = OpLabel -%16 = OpLoad %v4float %sk_FragColor -%17 = OpVectorShuffle %v4float %16 %15 4 5 2 3 +%34 = OpConstantComposite %v2float %float_n1 %float_n1 +%v2bool = OpTypeVector %bool 2 +%_ptr_Function_v4float = OpTypePointer Function %v4float +%int_1 = OpConstant %int 1 +%int_2 = OpConstant %int 2 +%_entrypoint = OpFunction %void None %15 +%16 = OpLabel +%17 = OpFunctionCall %v4float %main OpStore %sk_FragColor %17 OpReturn OpFunctionEnd +%main = OpFunction %v4float None %18 +%19 = OpLabel +%x = OpVariable %_ptr_Function_v2float Function +%38 = OpVariable %_ptr_Function_v4float Function +%23 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0 +%27 = OpLoad %v4float %23 +%28 = OpVectorShuffle %v2float %27 %27 0 1 +OpStore %x %28 +%29 = OpLoad %v2float %x +OpStore %x %29 +%31 = OpLoad %v2float %x +%30 = OpFNegate %v2float %31 +OpStore %x %30 +%32 = OpLoad %v2float %x +%35 = OpFOrdEqual %v2bool %32 %34 +%37 = OpAll %bool %35 +OpSelectionMerge %42 None +OpBranchConditional %37 %40 %41 +%40 = OpLabel +%43 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1 +%45 = OpLoad %v4float %43 +OpStore %38 %45 +OpBranch %42 +%41 = OpLabel +%46 = OpAccessChain %_ptr_Uniform_v4float %10 %int_2 +%48 = OpLoad %v4float %46 +OpStore %38 %48 +OpBranch %42 +%42 = OpLabel +%49 = OpLoad %v4float %38 +OpReturnValue %49 +OpFunctionEnd diff --git a/tests/sksl/shared/UnaryPositiveNegative.glsl b/tests/sksl/shared/UnaryPositiveNegative.glsl index 3d05ee7969..f3dcd894d4 100644 --- a/tests/sksl/shared/UnaryPositiveNegative.glsl +++ b/tests/sksl/shared/UnaryPositiveNegative.glsl @@ -1,5 +1,11 @@ out vec4 sk_FragColor; -void main() { - sk_FragColor.xy = vec2(-1.0); +uniform vec4 colorWhite; +uniform vec4 colorGreen; +uniform vec4 colorRed; +vec4 main() { + vec2 x = colorWhite.xy; + x = x; + x = -x; + return x == vec2(-1.0) ? colorGreen : colorRed; } diff --git a/tests/sksl/shared/UnaryPositiveNegative.metal b/tests/sksl/shared/UnaryPositiveNegative.metal index c097811b80..8cdaba4254 100644 --- a/tests/sksl/shared/UnaryPositiveNegative.metal +++ b/tests/sksl/shared/UnaryPositiveNegative.metal @@ -1,14 +1,25 @@ #include #include using namespace metal; +struct Uniforms { + float4 colorWhite; + float4 colorGreen; + float4 colorRed; +}; struct Inputs { }; struct Outputs { float4 sk_FragColor [[color(0)]]; }; -fragment Outputs fragmentMain(Inputs _in [[stage_in]], 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; (void)_out; - _out.sk_FragColor.xy = float2(-1.0); + float2 x = _uniforms.colorWhite.xy; + x = x; + x = -x; + _out.sk_FragColor = all(x == float2(-1.0)) ? _uniforms.colorGreen : _uniforms.colorRed; return _out; } diff --git a/tests/sksl/shared/UnusedVariables.asm.frag b/tests/sksl/shared/UnusedVariables.asm.frag index 184e639282..ccfba757de 100644 --- a/tests/sksl/shared/UnusedVariables.asm.frag +++ b/tests/sksl/shared/UnusedVariables.asm.frag @@ -1,10 +1,11 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %sk_FragColor %sk_Clockwise -OpExecutionMode %main OriginUpperLeft +OpEntryPoint Fragment %_entrypoint "_entrypoint" %sk_FragColor %sk_Clockwise +OpExecutionMode %_entrypoint OriginUpperLeft OpName %sk_FragColor "sk_FragColor" OpName %sk_Clockwise "sk_Clockwise" +OpName %_entrypoint "_entrypoint" OpName %main "main" OpName %b "b" OpName %d "d" @@ -21,28 +22,45 @@ OpDecorate %sk_Clockwise BuiltIn FrontFacing %_ptr_Input_bool = OpTypePointer Input %bool %sk_Clockwise = OpVariable %_ptr_Input_bool Input %void = OpTypeVoid -%11 = OpTypeFunction %void +%12 = OpTypeFunction %void +%15 = OpTypeFunction %v4float %_ptr_Function_float = OpTypePointer Function %float %float_2 = OpConstant %float 2 %float_3 = OpConstant %float 3 %float_1 = OpConstant %float 1 -%main = OpFunction %void None %11 -%12 = OpLabel +%float_0 = OpConstant %float 0 +%float_5 = OpConstant %float 5 +%float_4 = OpConstant %float 4 +%_entrypoint = OpFunction %void None %12 +%13 = OpLabel +%14 = OpFunctionCall %v4float %main +OpStore %sk_FragColor %14 +OpReturn +OpFunctionEnd +%main = OpFunction %v4float None %15 +%16 = OpLabel %b = OpVariable %_ptr_Function_float Function %d = OpVariable %_ptr_Function_float Function OpStore %b %float_2 OpStore %d %float_3 -%18 = OpLoad %float %b -%20 = OpFAdd %float %18 %float_1 -OpStore %b %20 -%21 = OpLoad %float %d -%22 = OpFAdd %float %21 %float_1 -OpStore %d %22 -%23 = OpLoad %float %b -%24 = OpLoad %float %b +%22 = OpLoad %float %b +%24 = OpFAdd %float %22 %float_1 +OpStore %b %24 %25 = OpLoad %float %d -%26 = OpLoad %float %d -%27 = OpCompositeConstruct %v4float %23 %24 %25 %26 -OpStore %sk_FragColor %27 -OpReturn +%26 = OpFAdd %float %25 %float_1 +OpStore %d %26 +%27 = OpLoad %float %b +%28 = OpFOrdEqual %bool %27 %float_2 +%29 = OpSelect %float %28 %float_1 %float_0 +%31 = OpLoad %float %b +%32 = OpFOrdEqual %bool %31 %float_3 +%33 = OpSelect %float %32 %float_1 %float_0 +%34 = OpLoad %float %d +%36 = OpFOrdEqual %bool %34 %float_5 +%37 = OpSelect %float %36 %float_1 %float_0 +%38 = OpLoad %float %d +%40 = OpFOrdEqual %bool %38 %float_4 +%41 = OpSelect %float %40 %float_1 %float_0 +%42 = OpCompositeConstruct %v4float %29 %33 %37 %41 +OpReturnValue %42 OpFunctionEnd diff --git a/tests/sksl/shared/UnusedVariables.glsl b/tests/sksl/shared/UnusedVariables.glsl index 575ed40c60..d97e26266f 100644 --- a/tests/sksl/shared/UnusedVariables.glsl +++ b/tests/sksl/shared/UnusedVariables.glsl @@ -1,10 +1,10 @@ out vec4 sk_FragColor; -void main() { +vec4 main() { float b = 2.0; float d = 3.0; b++; d++; - sk_FragColor = vec4(b, b, d, d); + return vec4(float(b == 2.0), float(b == 3.0), float(d == 5.0), float(d == 4.0)); } diff --git a/tests/sksl/shared/UnusedVariables.metal b/tests/sksl/shared/UnusedVariables.metal index 040ce77080..9892c73d6e 100644 --- a/tests/sksl/shared/UnusedVariables.metal +++ b/tests/sksl/shared/UnusedVariables.metal @@ -14,6 +14,6 @@ fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front float d = 3.0; b++; d++; - _out.sk_FragColor = float4(b, b, d, d); + _out.sk_FragColor = float4(float(b == 2.0), float(b == 3.0), float(d == 5.0), float(d == 4.0)); return _out; } diff --git a/tests/sksl/shared/VectorConstructors.asm.frag b/tests/sksl/shared/VectorConstructors.asm.frag index df11f85a8f..715d035cfd 100644 --- a/tests/sksl/shared/VectorConstructors.asm.frag +++ b/tests/sksl/shared/VectorConstructors.asm.frag @@ -1,57 +1,52 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %main "main" %sk_FragColor %sk_Clockwise -OpExecutionMode %main OriginUpperLeft +OpEntryPoint Fragment %_entrypoint "_entrypoint" %sk_FragColor %sk_Clockwise +OpExecutionMode %_entrypoint OriginUpperLeft OpName %sk_FragColor "sk_FragColor" OpName %sk_Clockwise "sk_Clockwise" -OpName %v1 "v1" -OpName %v2 "v2" -OpName %v3 "v3" -OpName %v4 "v4" -OpName %v5 "v5" -OpName %v6 "v6" -OpName %v7 "v7" -OpName %v8 "v8" -OpName %v9 "v9" -OpName %v10 "v10" -OpName %v11 "v11" -OpName %v12 "v12" -OpName %v13 "v13" -OpName %v14 "v14" -OpName %v15 "v15" -OpName %v16 "v16" -OpName %v17 "v17" +OpName %_UniformBuffer "_UniformBuffer" +OpMemberName %_UniformBuffer 0 "colorGreen" +OpMemberName %_UniformBuffer 1 "colorRed" +OpName %_entrypoint "_entrypoint" +OpName %check "check" OpName %main "main" +OpName %v9 "v9" OpDecorate %sk_FragColor RelaxedPrecision OpDecorate %sk_FragColor Location 0 OpDecorate %sk_FragColor Index 0 OpDecorate %sk_Clockwise RelaxedPrecision OpDecorate %sk_Clockwise BuiltIn FrontFacing -OpDecorate %v11 RelaxedPrecision -OpDecorate %v15 RelaxedPrecision -OpDecorate %v16 RelaxedPrecision -OpDecorate %v17 RelaxedPrecision -OpDecorate %111 RelaxedPrecision -OpDecorate %114 RelaxedPrecision -OpDecorate %117 RelaxedPrecision -OpDecorate %121 RelaxedPrecision -OpDecorate %125 RelaxedPrecision -OpDecorate %128 RelaxedPrecision -OpDecorate %131 RelaxedPrecision -OpDecorate %134 RelaxedPrecision -OpDecorate %138 RelaxedPrecision -OpDecorate %139 RelaxedPrecision -OpDecorate %142 RelaxedPrecision -OpDecorate %145 RelaxedPrecision -OpDecorate %148 RelaxedPrecision -OpDecorate %151 RelaxedPrecision -OpDecorate %152 RelaxedPrecision -OpDecorate %155 RelaxedPrecision -OpDecorate %156 RelaxedPrecision -OpDecorate %159 RelaxedPrecision -OpDecorate %160 RelaxedPrecision -OpDecorate %163 RelaxedPrecision +OpMemberDecorate %_UniformBuffer 0 Offset 0 +OpMemberDecorate %_UniformBuffer 0 RelaxedPrecision +OpMemberDecorate %_UniformBuffer 1 Offset 16 +OpMemberDecorate %_UniformBuffer 1 RelaxedPrecision +OpDecorate %_UniformBuffer Block +OpDecorate %11 Binding 0 +OpDecorate %11 DescriptorSet 0 +OpDecorate %56 RelaxedPrecision +OpDecorate %59 RelaxedPrecision +OpDecorate %62 RelaxedPrecision +OpDecorate %66 RelaxedPrecision +OpDecorate %70 RelaxedPrecision +OpDecorate %73 RelaxedPrecision +OpDecorate %76 RelaxedPrecision +OpDecorate %79 RelaxedPrecision +OpDecorate %83 RelaxedPrecision +OpDecorate %84 RelaxedPrecision +OpDecorate %89 RelaxedPrecision +OpDecorate %92 RelaxedPrecision +OpDecorate %95 RelaxedPrecision +OpDecorate %98 RelaxedPrecision +OpDecorate %99 RelaxedPrecision +OpDecorate %102 RelaxedPrecision +OpDecorate %103 RelaxedPrecision +OpDecorate %106 RelaxedPrecision +OpDecorate %107 RelaxedPrecision +OpDecorate %110 RelaxedPrecision +OpDecorate %196 RelaxedPrecision +OpDecorate %198 RelaxedPrecision +OpDecorate %199 RelaxedPrecision %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Output_v4float = OpTypePointer Output %v4float @@ -59,181 +54,225 @@ OpDecorate %163 RelaxedPrecision %bool = OpTypeBool %_ptr_Input_bool = OpTypePointer Input %bool %sk_Clockwise = OpVariable %_ptr_Input_bool Input +%_UniformBuffer = OpTypeStruct %v4float %v4float +%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer +%11 = OpVariable %_ptr_Uniform__UniformBuffer Uniform +%void = OpTypeVoid +%16 = OpTypeFunction %void %v2float = OpTypeVector %float 2 -%_ptr_Private_v2float = OpTypePointer Private %v2float -%v1 = OpVariable %_ptr_Private_v2float Private -%float_1 = OpConstant %float 1 -%14 = OpConstantComposite %v2float %float_1 %float_1 -%v2 = OpVariable %_ptr_Private_v2float Private -%float_2 = OpConstant %float 2 -%17 = OpConstantComposite %v2float %float_1 %float_2 -%v3 = OpVariable %_ptr_Private_v2float Private %v3float = OpTypeVector %float 3 -%_ptr_Private_v3float = OpTypePointer Private %v3float -%v4 = OpVariable %_ptr_Private_v3float Private -%22 = OpConstantComposite %v3float %float_1 %float_1 %float_1 %int = OpTypeInt 32 1 %v2int = OpTypeVector %int 2 -%_ptr_Private_v2int = OpTypePointer Private %v2int -%v5 = OpVariable %_ptr_Private_v2int Private -%int_1 = OpConstant %int 1 -%28 = OpConstantComposite %v2int %int_1 %int_1 -%v6 = OpVariable %_ptr_Private_v2int Private -%v7 = OpVariable %_ptr_Private_v2float Private -%int_2 = OpConstant %int 2 -%37 = OpConstantComposite %v2int %int_1 %int_2 -%v8 = OpVariable %_ptr_Private_v2float Private -%_ptr_Private_v4float = OpTypePointer Private %v4float -%v9 = OpVariable %_ptr_Private_v4float Private +%v4bool = OpTypeVector %bool 4 +%v2bool = OpTypeVector %bool 2 +%v3bool = OpTypeVector %bool 3 +%_ptr_Function_v2float = OpTypePointer Function %v2float +%_ptr_Function_v3float = OpTypePointer Function %v3float +%_ptr_Function_v2int = OpTypePointer Function %v2int +%_ptr_Function_v4float = OpTypePointer Function %v4float +%_ptr_Function_v4bool = OpTypePointer Function %v4bool +%_ptr_Function_v2bool = OpTypePointer Function %v2bool +%_ptr_Function_v3bool = OpTypePointer Function %v3bool +%26 = OpTypeFunction %bool %_ptr_Function_v2float %_ptr_Function_v2float %_ptr_Function_v2float %_ptr_Function_v3float %_ptr_Function_v2int %_ptr_Function_v2int %_ptr_Function_v2float %_ptr_Function_v2float %_ptr_Function_v4float %_ptr_Function_v2int %_ptr_Function_v4bool %_ptr_Function_v2float %_ptr_Function_v2float %_ptr_Function_v2float %_ptr_Function_v2bool %_ptr_Function_v2bool %_ptr_Function_v3bool +%float_1 = OpConstant %float 1 +%float_0 = OpConstant %float 0 +%float_17 = OpConstant %float 17 +%113 = OpTypeFunction %v4float +%float_2 = OpConstant %float 2 %int_3 = OpConstant %int 3 %int_4 = OpConstant %int 4 -%58 = OpConstantComposite %v2int %int_3 %int_4 -%v10 = OpVariable %_ptr_Private_v2int Private -%v4bool = OpTypeVector %bool 4 -%_ptr_Private_v4bool = OpTypePointer Private %v4bool -%v11 = OpVariable %_ptr_Private_v4bool Private +%120 = OpConstantComposite %v2int %int_3 %int_4 +%129 = OpConstantComposite %v2float %float_1 %float_1 +%131 = OpConstantComposite %v2float %float_1 %float_2 +%134 = OpConstantComposite %v3float %float_1 %float_1 %float_1 +%int_1 = OpConstant %int 1 +%137 = OpConstantComposite %v2int %int_1 %int_1 +%int_2 = OpConstant %int 2 +%146 = OpConstantComposite %v2int %int_1 %int_2 +%161 = OpConstantComposite %v2int %int_3 %int_1 %true = OpConstantTrue %bool %false = OpConstantFalse %bool -%77 = OpConstantComposite %v4bool %true %false %true %false -%v12 = OpVariable %_ptr_Private_v2float Private -%float_0 = OpConstant %float 0 -%80 = OpConstantComposite %v2float %float_1 %float_0 -%v13 = OpVariable %_ptr_Private_v2float Private -%82 = OpConstantComposite %v2float %float_0 %float_0 -%v14 = OpVariable %_ptr_Private_v2float Private -%v2bool = OpTypeVector %bool 2 -%85 = OpConstantComposite %v2bool %false %false -%_ptr_Private_v2bool = OpTypePointer Private %v2bool -%v15 = OpVariable %_ptr_Private_v2bool Private -%93 = OpConstantComposite %v2bool %true %true -%v16 = OpVariable %_ptr_Private_v2bool Private -%v3bool = OpTypeVector %bool 3 -%_ptr_Private_v3bool = OpTypePointer Private %v3bool -%v17 = OpVariable %_ptr_Private_v3bool Private -%103 = OpConstantComposite %v3bool %true %true %true -%void = OpTypeVoid -%105 = OpTypeFunction %void -%_ptr_Output_float = OpTypePointer Output %float +%165 = OpConstantComposite %v4bool %true %false %true %false +%167 = OpConstantComposite %v2float %float_1 %float_0 +%169 = OpConstantComposite %v2float %float_0 %float_0 +%171 = OpConstantComposite %v2bool %false %false +%178 = OpConstantComposite %v2bool %true %true +%186 = OpConstantComposite %v3bool %true %true %true +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float %int_0 = OpConstant %int 0 -%main = OpFunction %void None %105 -%106 = OpLabel -OpStore %v1 %14 -OpStore %v2 %17 -OpStore %v3 %14 -OpStore %v4 %22 -OpStore %v5 %28 -%30 = OpCompositeExtract %float %17 0 -%31 = OpConvertFToS %int %30 -%32 = OpCompositeExtract %float %17 1 -%33 = OpConvertFToS %int %32 -%34 = OpCompositeConstruct %v2int %31 %33 -OpStore %v6 %34 -%38 = OpCompositeExtract %int %37 0 -%39 = OpConvertSToF %float %38 -%40 = OpCompositeExtract %int %37 1 -%41 = OpConvertSToF %float %40 -%42 = OpCompositeConstruct %v2float %39 %41 -OpStore %v7 %42 -%44 = OpLoad %v2int %v5 -%45 = OpCompositeExtract %int %44 0 -%46 = OpConvertSToF %float %45 -%47 = OpCompositeExtract %int %44 1 -%48 = OpConvertSToF %float %47 -%49 = OpCompositeConstruct %v2float %46 %48 -OpStore %v8 %49 -%52 = OpLoad %v2int %v6 -%53 = OpCompositeExtract %int %52 0 -%54 = OpConvertSToF %float %53 -%55 = OpExtInst %float %1 Sqrt %float_2 -%59 = OpCompositeExtract %int %58 0 -%60 = OpConvertSToF %float %59 -%61 = OpCompositeExtract %int %58 1 -%62 = OpConvertSToF %float %61 -%63 = OpCompositeConstruct %v2float %60 %62 -%64 = OpCompositeExtract %float %63 0 -%65 = OpCompositeExtract %float %63 1 -%66 = OpCompositeConstruct %v4float %54 %55 %64 %65 -OpStore %v9 %66 -%68 = OpLoad %v2float %v1 -%69 = OpCompositeExtract %float %68 0 -%70 = OpConvertFToS %int %69 -%71 = OpCompositeConstruct %v2int %int_3 %70 -OpStore %v10 %71 -OpStore %v11 %77 -OpStore %v12 %80 -OpStore %v13 %82 -%86 = OpCompositeExtract %bool %85 0 -%87 = OpSelect %float %86 %float_1 %float_0 -%88 = OpCompositeExtract %bool %85 1 -%89 = OpSelect %float %88 %float_1 %float_0 -%90 = OpCompositeConstruct %v2float %87 %89 -OpStore %v14 %90 -OpStore %v15 %93 -%95 = OpCompositeExtract %float %14 0 -%96 = OpFUnordNotEqual %bool %95 %float_0 -%97 = OpCompositeExtract %float %14 1 -%98 = OpFUnordNotEqual %bool %97 %float_0 -%99 = OpCompositeConstruct %v2bool %96 %98 -OpStore %v16 %99 -OpStore %v17 %103 -%107 = OpLoad %v2float %v1 -%108 = OpCompositeExtract %float %107 0 -%109 = OpLoad %v2float %v2 -%110 = OpCompositeExtract %float %109 0 -%111 = OpFAdd %float %108 %110 -%112 = OpLoad %v2float %v3 -%113 = OpCompositeExtract %float %112 0 -%114 = OpFAdd %float %111 %113 -%115 = OpLoad %v3float %v4 -%116 = OpCompositeExtract %float %115 0 -%117 = OpFAdd %float %114 %116 -%118 = OpLoad %v2int %v5 -%119 = OpCompositeExtract %int %118 0 -%120 = OpConvertSToF %float %119 -%121 = OpFAdd %float %117 %120 -%122 = OpLoad %v2int %v6 -%123 = OpCompositeExtract %int %122 0 -%124 = OpConvertSToF %float %123 -%125 = OpFAdd %float %121 %124 -%126 = OpLoad %v2float %v7 -%127 = OpCompositeExtract %float %126 0 -%128 = OpFAdd %float %125 %127 -%129 = OpLoad %v2float %v8 -%130 = OpCompositeExtract %float %129 0 -%131 = OpFAdd %float %128 %130 -%132 = OpLoad %v4float %v9 -%133 = OpCompositeExtract %float %132 0 -%134 = OpFAdd %float %131 %133 -%135 = OpLoad %v2int %v10 -%136 = OpCompositeExtract %int %135 0 -%137 = OpConvertSToF %float %136 -%138 = OpFAdd %float %134 %137 -%139 = OpLoad %v4bool %v11 -%140 = OpCompositeExtract %bool %139 0 -%141 = OpSelect %float %140 %float_1 %float_0 -%142 = OpFAdd %float %138 %141 -%143 = OpLoad %v2float %v12 -%144 = OpCompositeExtract %float %143 0 -%145 = OpFAdd %float %142 %144 -%146 = OpLoad %v2float %v13 -%147 = OpCompositeExtract %float %146 0 -%148 = OpFAdd %float %145 %147 -%149 = OpLoad %v2float %v14 -%150 = OpCompositeExtract %float %149 0 -%151 = OpFAdd %float %148 %150 -%152 = OpLoad %v2bool %v15 -%153 = OpCompositeExtract %bool %152 0 -%154 = OpSelect %float %153 %float_1 %float_0 -%155 = OpFAdd %float %151 %154 -%156 = OpLoad %v2bool %v16 -%157 = OpCompositeExtract %bool %156 0 -%158 = OpSelect %float %157 %float_1 %float_0 -%159 = OpFAdd %float %155 %158 -%160 = OpLoad %v3bool %v17 -%161 = OpCompositeExtract %bool %160 0 -%162 = OpSelect %float %161 %float_1 %float_0 -%163 = OpFAdd %float %159 %162 -%164 = OpAccessChain %_ptr_Output_float %sk_FragColor %int_0 -OpStore %164 %163 +%_entrypoint = OpFunction %void None %16 +%17 = OpLabel +%18 = OpFunctionCall %v4float %main +OpStore %sk_FragColor %18 OpReturn OpFunctionEnd +%check = OpFunction %bool None %26 +%34 = OpFunctionParameter %_ptr_Function_v2float +%35 = OpFunctionParameter %_ptr_Function_v2float +%36 = OpFunctionParameter %_ptr_Function_v2float +%37 = OpFunctionParameter %_ptr_Function_v3float +%38 = OpFunctionParameter %_ptr_Function_v2int +%39 = OpFunctionParameter %_ptr_Function_v2int +%40 = OpFunctionParameter %_ptr_Function_v2float +%41 = OpFunctionParameter %_ptr_Function_v2float +%42 = OpFunctionParameter %_ptr_Function_v4float +%43 = OpFunctionParameter %_ptr_Function_v2int +%44 = OpFunctionParameter %_ptr_Function_v4bool +%45 = OpFunctionParameter %_ptr_Function_v2float +%46 = OpFunctionParameter %_ptr_Function_v2float +%47 = OpFunctionParameter %_ptr_Function_v2float +%48 = OpFunctionParameter %_ptr_Function_v2bool +%49 = OpFunctionParameter %_ptr_Function_v2bool +%50 = OpFunctionParameter %_ptr_Function_v3bool +%51 = OpLabel +%52 = OpLoad %v2float %34 +%53 = OpCompositeExtract %float %52 0 +%54 = OpLoad %v2float %35 +%55 = OpCompositeExtract %float %54 0 +%56 = OpFAdd %float %53 %55 +%57 = OpLoad %v2float %36 +%58 = OpCompositeExtract %float %57 0 +%59 = OpFAdd %float %56 %58 +%60 = OpLoad %v3float %37 +%61 = OpCompositeExtract %float %60 0 +%62 = OpFAdd %float %59 %61 +%63 = OpLoad %v2int %38 +%64 = OpCompositeExtract %int %63 0 +%65 = OpConvertSToF %float %64 +%66 = OpFAdd %float %62 %65 +%67 = OpLoad %v2int %39 +%68 = OpCompositeExtract %int %67 0 +%69 = OpConvertSToF %float %68 +%70 = OpFAdd %float %66 %69 +%71 = OpLoad %v2float %40 +%72 = OpCompositeExtract %float %71 0 +%73 = OpFAdd %float %70 %72 +%74 = OpLoad %v2float %41 +%75 = OpCompositeExtract %float %74 0 +%76 = OpFAdd %float %73 %75 +%77 = OpLoad %v4float %42 +%78 = OpCompositeExtract %float %77 0 +%79 = OpFAdd %float %76 %78 +%80 = OpLoad %v2int %43 +%81 = OpCompositeExtract %int %80 0 +%82 = OpConvertSToF %float %81 +%83 = OpFAdd %float %79 %82 +%84 = OpLoad %v4bool %44 +%85 = OpCompositeExtract %bool %84 0 +%86 = OpSelect %float %85 %float_1 %float_0 +%89 = OpFAdd %float %83 %86 +%90 = OpLoad %v2float %45 +%91 = OpCompositeExtract %float %90 0 +%92 = OpFAdd %float %89 %91 +%93 = OpLoad %v2float %46 +%94 = OpCompositeExtract %float %93 0 +%95 = OpFAdd %float %92 %94 +%96 = OpLoad %v2float %47 +%97 = OpCompositeExtract %float %96 0 +%98 = OpFAdd %float %95 %97 +%99 = OpLoad %v2bool %48 +%100 = OpCompositeExtract %bool %99 0 +%101 = OpSelect %float %100 %float_1 %float_0 +%102 = OpFAdd %float %98 %101 +%103 = OpLoad %v2bool %49 +%104 = OpCompositeExtract %bool %103 0 +%105 = OpSelect %float %104 %float_1 %float_0 +%106 = OpFAdd %float %102 %105 +%107 = OpLoad %v3bool %50 +%108 = OpCompositeExtract %bool %107 0 +%109 = OpSelect %float %108 %float_1 %float_0 +%110 = OpFAdd %float %106 %109 +%112 = OpFOrdEqual %bool %110 %float_17 +OpReturnValue %112 +OpFunctionEnd +%main = OpFunction %v4float None %113 +%114 = OpLabel +%v9 = OpVariable %_ptr_Function_v4float Function +%130 = OpVariable %_ptr_Function_v2float Function +%132 = OpVariable %_ptr_Function_v2float Function +%133 = OpVariable %_ptr_Function_v2float Function +%135 = OpVariable %_ptr_Function_v3float Function +%138 = OpVariable %_ptr_Function_v2int Function +%144 = OpVariable %_ptr_Function_v2int Function +%152 = OpVariable %_ptr_Function_v2float Function +%158 = OpVariable %_ptr_Function_v2float Function +%160 = OpVariable %_ptr_Function_v4float Function +%162 = OpVariable %_ptr_Function_v2int Function +%166 = OpVariable %_ptr_Function_v4bool Function +%168 = OpVariable %_ptr_Function_v2float Function +%170 = OpVariable %_ptr_Function_v2float Function +%177 = OpVariable %_ptr_Function_v2float Function +%179 = OpVariable %_ptr_Function_v2bool Function +%185 = OpVariable %_ptr_Function_v2bool Function +%187 = OpVariable %_ptr_Function_v3bool Function +%189 = OpVariable %_ptr_Function_v4float Function +%116 = OpExtInst %float %1 Sqrt %float_2 +%121 = OpCompositeExtract %int %120 0 +%122 = OpConvertSToF %float %121 +%123 = OpCompositeExtract %int %120 1 +%124 = OpConvertSToF %float %123 +%125 = OpCompositeConstruct %v2float %122 %124 +%126 = OpCompositeExtract %float %125 0 +%127 = OpCompositeExtract %float %125 1 +%128 = OpCompositeConstruct %v4float %float_1 %116 %126 %127 +OpStore %v9 %128 +OpStore %130 %129 +OpStore %132 %131 +OpStore %133 %129 +OpStore %135 %134 +OpStore %138 %137 +%139 = OpCompositeExtract %float %131 0 +%140 = OpConvertFToS %int %139 +%141 = OpCompositeExtract %float %131 1 +%142 = OpConvertFToS %int %141 +%143 = OpCompositeConstruct %v2int %140 %142 +OpStore %144 %143 +%147 = OpCompositeExtract %int %146 0 +%148 = OpConvertSToF %float %147 +%149 = OpCompositeExtract %int %146 1 +%150 = OpConvertSToF %float %149 +%151 = OpCompositeConstruct %v2float %148 %150 +OpStore %152 %151 +%153 = OpCompositeExtract %int %137 0 +%154 = OpConvertSToF %float %153 +%155 = OpCompositeExtract %int %137 1 +%156 = OpConvertSToF %float %155 +%157 = OpCompositeConstruct %v2float %154 %156 +OpStore %158 %157 +%159 = OpLoad %v4float %v9 +OpStore %160 %159 +OpStore %162 %161 +OpStore %166 %165 +OpStore %168 %167 +OpStore %170 %169 +%172 = OpCompositeExtract %bool %171 0 +%173 = OpSelect %float %172 %float_1 %float_0 +%174 = OpCompositeExtract %bool %171 1 +%175 = OpSelect %float %174 %float_1 %float_0 +%176 = OpCompositeConstruct %v2float %173 %175 +OpStore %177 %176 +OpStore %179 %178 +%180 = OpCompositeExtract %float %129 0 +%181 = OpFUnordNotEqual %bool %180 %float_0 +%182 = OpCompositeExtract %float %129 1 +%183 = OpFUnordNotEqual %bool %182 %float_0 +%184 = OpCompositeConstruct %v2bool %181 %183 +OpStore %185 %184 +OpStore %187 %186 +%188 = OpFunctionCall %bool %check %130 %132 %133 %135 %138 %144 %152 %158 %160 %162 %166 %168 %170 %177 %179 %185 %187 +OpSelectionMerge %192 None +OpBranchConditional %188 %190 %191 +%190 = OpLabel +%193 = OpAccessChain %_ptr_Uniform_v4float %11 %int_0 +%196 = OpLoad %v4float %193 +OpStore %189 %196 +OpBranch %192 +%191 = OpLabel +%197 = OpAccessChain %_ptr_Uniform_v4float %11 %int_1 +%198 = OpLoad %v4float %197 +OpStore %189 %198 +OpBranch %192 +%192 = OpLabel +%199 = OpLoad %v4float %189 +OpReturnValue %199 +OpFunctionEnd diff --git a/tests/sksl/shared/VectorConstructors.glsl b/tests/sksl/shared/VectorConstructors.glsl index 773793820d..22b0c5896f 100644 --- a/tests/sksl/shared/VectorConstructors.glsl +++ b/tests/sksl/shared/VectorConstructors.glsl @@ -1,22 +1,11 @@ out vec4 sk_FragColor; -vec2 v1 = vec2(1.0); -vec2 v2 = vec2(1.0, 2.0); -vec2 v3 = vec2(1.0); -vec3 v4 = vec3(vec2(1.0), 1.0); -ivec2 v5 = ivec2(1); -ivec2 v6 = ivec2(vec2(1.0, 2.0)); -vec2 v7 = vec2(ivec2(1, 2)); -vec2 v8 = vec2(v5); -vec4 v9 = vec4(float(v6.x), sqrt(2.0), vec2(ivec2(3, 4))); -ivec2 v10 = ivec2(3, int(v1.x)); -bvec4 v11 = bvec4(bvec2(true, false), true, false); -vec2 v12 = vec2(1.0, 0.0); -vec2 v13 = vec2(0.0); -vec2 v14 = vec2(bvec2(false)); -bvec2 v15 = bvec2(true); -bvec2 v16 = bvec2(vec2(1.0)); -bvec3 v17 = bvec3(true, bvec2(ivec2(77))); -void main() { - sk_FragColor.x = (((((((((((((((v1.x + v2.x) + v3.x) + v4.x) + float(v5.x)) + float(v6.x)) + v7.x) + v8.x) + v9.x) + float(v10.x)) + float(v11.x)) + v12.x) + v13.x) + v14.x) + float(v15.x)) + float(v16.x)) + float(v17.x); +uniform vec4 colorGreen; +uniform vec4 colorRed; +bool check(vec2 v1, vec2 v2, vec2 v3, vec3 v4, ivec2 v5, ivec2 v6, vec2 v7, vec2 v8, vec4 v9, ivec2 v10, bvec4 v11, vec2 v12, vec2 v13, vec2 v14, bvec2 v15, bvec2 v16, bvec3 v17) { + return (((((((((((((((v1.x + v2.x) + v3.x) + v4.x) + float(v5.x)) + float(v6.x)) + v7.x) + v8.x) + v9.x) + float(v10.x)) + float(v11.x)) + v12.x) + v13.x) + v14.x) + float(v15.x)) + float(v16.x)) + float(v17.x) == 17.0; +} +vec4 main() { + vec4 v9 = vec4(1.0, sqrt(2.0), vec2(ivec2(3, 4))); + return check(vec2(1.0), vec2(1.0, 2.0), vec2(1.0), vec3(vec2(1.0), 1.0), ivec2(1), ivec2(vec2(1.0, 2.0)), vec2(ivec2(1, 2)), vec2(ivec2(1)), v9, ivec2(3, 1), bvec4(true, false, true, false), vec2(1.0, 0.0), vec2(0.0), vec2(bvec2(false)), bvec2(true), bvec2(vec2(1.0)), bvec3(true, bvec2(ivec2(77)))) ? colorGreen : colorRed; } diff --git a/tests/sksl/shared/VectorConstructors.metal b/tests/sksl/shared/VectorConstructors.metal index 6ea56bcbd9..7dee1b93a7 100644 --- a/tests/sksl/shared/VectorConstructors.metal +++ b/tests/sksl/shared/VectorConstructors.metal @@ -1,52 +1,24 @@ #include #include using namespace metal; +struct Uniforms { + float4 colorGreen; + float4 colorRed; +}; struct Inputs { }; struct Outputs { float4 sk_FragColor [[color(0)]]; }; -struct Globals { - float2 v1; - float2 v2; - float2 v3; - float3 v4; - int2 v5; - int2 v6; - float2 v7; - float2 v8; - float4 v9; - int2 v10; - bool4 v11; - float2 v12; - float2 v13; - float2 v14; - bool2 v15; - bool2 v16; - bool3 v17; -}; - - - - - - - - - - - - - - - -fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { - Globals _globals{float2(1.0), float2(1.0, 2.0), float2(1.0), float3(float2(1.0), 1.0), int2(1), int2(float2(1.0, 2.0)), float2(int2(1, 2)), float2(_globals.v5), float4(float(_globals.v6.x), sqrt(2.0), float2(int2(3, 4))), int2(3, int(_globals.v1.x)), bool4(bool2(true, false), true, false), float2(1.0, 0.0), float2(0.0), float2(bool2(false)), bool2(true), bool2(float2(1.0)), bool3(true, bool2(int2(77)))}; - (void)_globals; +bool check(float2 v1, float2 v2, float2 v3, float3 v4, int2 v5, int2 v6, float2 v7, float2 v8, float4 v9, int2 v10, bool4 v11, float2 v12, float2 v13, float2 v14, bool2 v15, bool2 v16, bool3 v17) { + return (((((((((((((((v1.x + v2.x) + v3.x) + v4.x) + float(v5.x)) + float(v6.x)) + v7.x) + v8.x) + v9.x) + float(v10.x)) + float(v11.x)) + v12.x) + v13.x) + v14.x) + float(v15.x)) + float(v16.x)) + float(v17.x) == 17.0; +} +fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { Outputs _out; (void)_out; - _out.sk_FragColor.x = (((((((((((((((_globals.v1.x + _globals.v2.x) + _globals.v3.x) + _globals.v4.x) + float(_globals.v5.x)) + float(_globals.v6.x)) + _globals.v7.x) + _globals.v8.x) + _globals.v9.x) + float(_globals.v10.x)) + float(_globals.v11.x)) + _globals.v12.x) + _globals.v13.x) + _globals.v14.x) + float(_globals.v15.x)) + float(_globals.v16.x)) + float(_globals.v17.x); + float4 v9 = float4(1.0, sqrt(2.0), float2(int2(3, 4))); + _out.sk_FragColor = check(float2(1.0), float2(1.0, 2.0), float2(1.0), float3(float2(1.0), 1.0), int2(1), int2(float2(1.0, 2.0)), float2(int2(1, 2)), float2(int2(1)), v9, int2(3, 1), bool4(true, false, true, false), float2(1.0, 0.0), float2(0.0), float2(bool2(false)), bool2(true), bool2(float2(1.0)), bool3(true, bool2(int2(77)))) ? _uniforms.colorGreen : _uniforms.colorRed; return _out; }