Improve distinct-out-param test cases.
Added new aliasing tests inspired by syoussefi@'s ANGLE changes at http://go/crrv/c/3561278. Change-Id: Ifa312faa9503b211b7c09edd2abd5087ead35e5f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/526018 Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Arman Uguray <armansito@google.com> Commit-Queue: Arman Uguray <armansito@google.com>
This commit is contained in:
parent
a43a68a015
commit
674eb326f4
@ -427,6 +427,7 @@ sksl_shared_tests = [
|
||||
"/sksl/shared/Hex.sksl",
|
||||
"/sksl/shared/HexUnsigned.sksl",
|
||||
"/sksl/shared/InoutParameters.sksl",
|
||||
"/sksl/shared/InoutParamsAreDistinct.sksl",
|
||||
"/sksl/shared/InstanceID.vert",
|
||||
"/sksl/shared/InterfaceBlockNamed.sksl",
|
||||
"/sksl/shared/InterfaceBlockNamedArray.sksl",
|
||||
@ -461,6 +462,7 @@ sksl_shared_tests = [
|
||||
"/sksl/shared/Ossfuzz41000.sksl",
|
||||
"/sksl/shared/OutParams.sksl",
|
||||
"/sksl/shared/OutParamsAreDistinct.sksl",
|
||||
"/sksl/shared/OutParamsAreDistinctFromGlobal.sksl",
|
||||
"/sksl/shared/OutParamsTricky.sksl",
|
||||
"/sksl/shared/Overflow.sksl",
|
||||
"/sksl/shared/RectangleTexture.sksl",
|
||||
|
12
resources/sksl/shared/InoutParamsAreDistinct.sksl
Normal file
12
resources/sksl/shared/InoutParamsAreDistinct.sksl
Normal file
@ -0,0 +1,12 @@
|
||||
uniform half4 colorGreen, colorRed;
|
||||
|
||||
bool inout_params_are_distinct(inout half x, inout half y) {
|
||||
x = 1;
|
||||
y = 2;
|
||||
return x == 1 && y == 2;
|
||||
}
|
||||
|
||||
half4 main(float2 coords) {
|
||||
half x = 0;
|
||||
return inout_params_are_distinct(x, x) ? colorGreen : colorRed;
|
||||
}
|
11
resources/sksl/shared/OutParamsAreDistinctFromGlobal.sksl
Normal file
11
resources/sksl/shared/OutParamsAreDistinctFromGlobal.sksl
Normal file
@ -0,0 +1,11 @@
|
||||
uniform half4 colorGreen, colorRed;
|
||||
|
||||
half x = 1;
|
||||
bool out_params_are_distinct_from_global(out half y) {
|
||||
y = 2;
|
||||
return x == 1 && y == 2;
|
||||
}
|
||||
|
||||
half4 main(float2 coords) {
|
||||
return out_params_are_distinct_from_global(x) ? colorGreen : colorRed;
|
||||
}
|
@ -469,6 +469,7 @@ SKSL_TEST(CPU + GPU + SkQP, HelloWorld, "shared/HelloWorld.
|
||||
SKSL_TEST(CPU + GPU + SkQP, Hex, "shared/Hex.sksl")
|
||||
SKSL_TEST(GPU_ES3, HexUnsigned, "shared/HexUnsigned.sksl")
|
||||
SKSL_TEST(CPU + GPU + SkQP, InoutParameters, "shared/InoutParameters.sksl")
|
||||
SKSL_TEST(CPU + GPU + SkQP, InoutParamsAreDistinct, "shared/InoutParamsAreDistinct.sksl")
|
||||
SKSL_TEST(CPU + GPU + SkQP, Matrices, "shared/Matrices.sksl")
|
||||
SKSL_TEST(GPU_ES3, MatricesNonsquare, "shared/MatricesNonsquare.sksl")
|
||||
// TODO(skia:12443) These tests actually don't work on MANY devices. The GLSL SkQP suite
|
||||
@ -485,6 +486,7 @@ SKSL_TEST(GPU_ES3, OperatorsES3, "shared/OperatorsES
|
||||
SKSL_TEST(CPU + GPU + SkQP, Ossfuzz36852, "shared/Ossfuzz36852.sksl")
|
||||
SKSL_TEST(CPU + GPU + SkQP, OutParams, "shared/OutParams.sksl")
|
||||
SKSL_TEST(CPU + GPU + SkQP, OutParamsAreDistinct, "shared/OutParamsAreDistinct.sksl")
|
||||
SKSL_TEST(CPU + GPU + SkQP, OutParamsAreDistinctFromGlobal, "shared/OutParamsAreDistinctFromGlobal.sksl")
|
||||
SKSL_TEST(CPU + GPU + SkQP, OutParamsTricky, "shared/OutParamsTricky.sksl")
|
||||
SKSL_TEST(CPU + GPU + SkQP, ResizeMatrix, "shared/ResizeMatrix.sksl")
|
||||
SKSL_TEST(GPU_ES3, ResizeMatrixNonsquare, "shared/ResizeMatrixNonsquare.sksl")
|
||||
|
123
tests/sksl/shared/InoutParamsAreDistinct.asm.frag
Normal file
123
tests/sksl/shared/InoutParamsAreDistinct.asm.frag
Normal file
@ -0,0 +1,123 @@
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %_entrypoint_v "_entrypoint" %sk_FragColor %sk_Clockwise
|
||||
OpExecutionMode %_entrypoint_v OriginUpperLeft
|
||||
OpName %sk_FragColor "sk_FragColor"
|
||||
OpName %sk_Clockwise "sk_Clockwise"
|
||||
OpName %_UniformBuffer "_UniformBuffer"
|
||||
OpMemberName %_UniformBuffer 0 "colorGreen"
|
||||
OpMemberName %_UniformBuffer 1 "colorRed"
|
||||
OpName %_entrypoint_v "_entrypoint_v"
|
||||
OpName %inout_params_are_distinct_bhh "inout_params_are_distinct_bhh"
|
||||
OpName %main "main"
|
||||
OpName %x "x"
|
||||
OpDecorate %sk_FragColor RelaxedPrecision
|
||||
OpDecorate %sk_FragColor Location 0
|
||||
OpDecorate %sk_FragColor Index 0
|
||||
OpDecorate %sk_Clockwise BuiltIn FrontFacing
|
||||
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 %32 RelaxedPrecision
|
||||
OpDecorate %36 RelaxedPrecision
|
||||
OpDecorate %x RelaxedPrecision
|
||||
OpDecorate %43 RelaxedPrecision
|
||||
OpDecorate %44 RelaxedPrecision
|
||||
OpDecorate %45 RelaxedPrecision
|
||||
OpDecorate %46 RelaxedPrecision
|
||||
OpDecorate %48 RelaxedPrecision
|
||||
OpDecorate %49 RelaxedPrecision
|
||||
OpDecorate %59 RelaxedPrecision
|
||||
OpDecorate %62 RelaxedPrecision
|
||||
OpDecorate %63 RelaxedPrecision
|
||||
%float = OpTypeFloat 32
|
||||
%v4float = OpTypeVector %float 4
|
||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||
%sk_FragColor = OpVariable %_ptr_Output_v4float Output
|
||||
%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
|
||||
%float_0 = OpConstant %float 0
|
||||
%20 = OpConstantComposite %v2float %float_0 %float_0
|
||||
%_ptr_Function_v2float = OpTypePointer Function %v2float
|
||||
%_ptr_Function_float = OpTypePointer Function %float
|
||||
%24 = OpTypeFunction %bool %_ptr_Function_float %_ptr_Function_float
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%false = OpConstantFalse %bool
|
||||
%39 = OpTypeFunction %v4float %_ptr_Function_v2float
|
||||
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
||||
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
|
||||
%int = OpTypeInt 32 1
|
||||
%int_0 = OpConstant %int 0
|
||||
%int_1 = OpConstant %int 1
|
||||
%_entrypoint_v = OpFunction %void None %16
|
||||
%17 = OpLabel
|
||||
%21 = OpVariable %_ptr_Function_v2float Function
|
||||
OpStore %21 %20
|
||||
%23 = OpFunctionCall %v4float %main %21
|
||||
OpStore %sk_FragColor %23
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%inout_params_are_distinct_bhh = OpFunction %bool None %24
|
||||
%26 = OpFunctionParameter %_ptr_Function_float
|
||||
%27 = OpFunctionParameter %_ptr_Function_float
|
||||
%28 = OpLabel
|
||||
OpStore %26 %float_1
|
||||
OpStore %27 %float_2
|
||||
%32 = OpLoad %float %26
|
||||
%33 = OpFOrdEqual %bool %32 %float_1
|
||||
OpSelectionMerge %35 None
|
||||
OpBranchConditional %33 %34 %35
|
||||
%34 = OpLabel
|
||||
%36 = OpLoad %float %27
|
||||
%37 = OpFOrdEqual %bool %36 %float_2
|
||||
OpBranch %35
|
||||
%35 = OpLabel
|
||||
%38 = OpPhi %bool %false %28 %37 %34
|
||||
OpReturnValue %38
|
||||
OpFunctionEnd
|
||||
%main = OpFunction %v4float None %39
|
||||
%40 = OpFunctionParameter %_ptr_Function_v2float
|
||||
%41 = OpLabel
|
||||
%x = OpVariable %_ptr_Function_float Function
|
||||
%44 = OpVariable %_ptr_Function_float Function
|
||||
%46 = OpVariable %_ptr_Function_float Function
|
||||
%50 = OpVariable %_ptr_Function_v4float Function
|
||||
OpStore %x %float_0
|
||||
%43 = OpLoad %float %x
|
||||
OpStore %44 %43
|
||||
%45 = OpLoad %float %x
|
||||
OpStore %46 %45
|
||||
%47 = OpFunctionCall %bool %inout_params_are_distinct_bhh %44 %46
|
||||
%48 = OpLoad %float %44
|
||||
OpStore %x %48
|
||||
%49 = OpLoad %float %46
|
||||
OpStore %x %49
|
||||
OpSelectionMerge %54 None
|
||||
OpBranchConditional %47 %52 %53
|
||||
%52 = OpLabel
|
||||
%55 = OpAccessChain %_ptr_Uniform_v4float %11 %int_0
|
||||
%59 = OpLoad %v4float %55
|
||||
OpStore %50 %59
|
||||
OpBranch %54
|
||||
%53 = OpLabel
|
||||
%60 = OpAccessChain %_ptr_Uniform_v4float %11 %int_1
|
||||
%62 = OpLoad %v4float %60
|
||||
OpStore %50 %62
|
||||
OpBranch %54
|
||||
%54 = OpLabel
|
||||
%63 = OpLoad %v4float %50
|
||||
OpReturnValue %63
|
||||
OpFunctionEnd
|
13
tests/sksl/shared/InoutParamsAreDistinct.glsl
Normal file
13
tests/sksl/shared/InoutParamsAreDistinct.glsl
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
uniform vec4 colorGreen;
|
||||
uniform vec4 colorRed;
|
||||
bool inout_params_are_distinct_bhh(inout float x, inout float y) {
|
||||
x = 1.0;
|
||||
y = 2.0;
|
||||
return x == 1.0 && y == 2.0;
|
||||
}
|
||||
vec4 main() {
|
||||
float x = 0.0;
|
||||
return inout_params_are_distinct_bhh(x, x) ? colorGreen : colorRed;
|
||||
}
|
33
tests/sksl/shared/InoutParamsAreDistinct.metal
Normal file
33
tests/sksl/shared/InoutParamsAreDistinct.metal
Normal file
@ -0,0 +1,33 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Uniforms {
|
||||
half4 colorGreen;
|
||||
half4 colorRed;
|
||||
};
|
||||
struct Inputs {
|
||||
};
|
||||
struct Outputs {
|
||||
half4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
bool inout_params_are_distinct_bhh(thread half& x, thread half& y);
|
||||
bool _skOutParamHelper0_inout_params_are_distinct_bhh(thread half& x, thread half&) {
|
||||
half _var0 = x;
|
||||
half _var1 = x;
|
||||
bool _skResult = inout_params_are_distinct_bhh(_var0, _var1);
|
||||
x = _var0;
|
||||
x = _var1;
|
||||
return _skResult;
|
||||
}
|
||||
bool inout_params_are_distinct_bhh(thread half& x, thread half& y) {
|
||||
x = 1.0h;
|
||||
y = 2.0h;
|
||||
return x == 1.0h && y == 2.0h;
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _out;
|
||||
(void)_out;
|
||||
half x = 0.0h;
|
||||
_out.sk_FragColor = _skOutParamHelper0_inout_params_are_distinct_bhh(x, x) ? _uniforms.colorGreen : _uniforms.colorRed;
|
||||
return _out;
|
||||
}
|
111
tests/sksl/shared/OutParamsAreDistinctFromGlobal.asm.frag
Normal file
111
tests/sksl/shared/OutParamsAreDistinctFromGlobal.asm.frag
Normal file
@ -0,0 +1,111 @@
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %_entrypoint_v "_entrypoint" %sk_FragColor %sk_Clockwise
|
||||
OpExecutionMode %_entrypoint_v OriginUpperLeft
|
||||
OpName %sk_FragColor "sk_FragColor"
|
||||
OpName %sk_Clockwise "sk_Clockwise"
|
||||
OpName %x "x"
|
||||
OpName %_UniformBuffer "_UniformBuffer"
|
||||
OpMemberName %_UniformBuffer 0 "colorGreen"
|
||||
OpMemberName %_UniformBuffer 1 "colorRed"
|
||||
OpName %_entrypoint_v "_entrypoint_v"
|
||||
OpName %out_params_are_distinct_from_global_bh "out_params_are_distinct_from_global_bh"
|
||||
OpName %main "main"
|
||||
OpDecorate %sk_FragColor RelaxedPrecision
|
||||
OpDecorate %sk_FragColor Location 0
|
||||
OpDecorate %sk_FragColor Index 0
|
||||
OpDecorate %sk_Clockwise BuiltIn FrontFacing
|
||||
OpDecorate %x RelaxedPrecision
|
||||
OpMemberDecorate %_UniformBuffer 0 Offset 0
|
||||
OpMemberDecorate %_UniformBuffer 0 RelaxedPrecision
|
||||
OpMemberDecorate %_UniformBuffer 1 Offset 16
|
||||
OpMemberDecorate %_UniformBuffer 1 RelaxedPrecision
|
||||
OpDecorate %_UniformBuffer Block
|
||||
OpDecorate %14 Binding 0
|
||||
OpDecorate %14 DescriptorSet 0
|
||||
OpDecorate %33 RelaxedPrecision
|
||||
OpDecorate %37 RelaxedPrecision
|
||||
OpDecorate %43 RelaxedPrecision
|
||||
OpDecorate %45 RelaxedPrecision
|
||||
OpDecorate %55 RelaxedPrecision
|
||||
OpDecorate %58 RelaxedPrecision
|
||||
OpDecorate %59 RelaxedPrecision
|
||||
%float = OpTypeFloat 32
|
||||
%v4float = OpTypeVector %float 4
|
||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||
%sk_FragColor = OpVariable %_ptr_Output_v4float Output
|
||||
%bool = OpTypeBool
|
||||
%_ptr_Input_bool = OpTypePointer Input %bool
|
||||
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
|
||||
%_ptr_Private_float = OpTypePointer Private %float
|
||||
%x = OpVariable %_ptr_Private_float Private
|
||||
%float_1 = OpConstant %float 1
|
||||
%_UniformBuffer = OpTypeStruct %v4float %v4float
|
||||
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
|
||||
%14 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
|
||||
%void = OpTypeVoid
|
||||
%19 = OpTypeFunction %void
|
||||
%v2float = OpTypeVector %float 2
|
||||
%float_0 = OpConstant %float 0
|
||||
%23 = OpConstantComposite %v2float %float_0 %float_0
|
||||
%_ptr_Function_v2float = OpTypePointer Function %v2float
|
||||
%_ptr_Function_float = OpTypePointer Function %float
|
||||
%27 = OpTypeFunction %bool %_ptr_Function_float
|
||||
%float_2 = OpConstant %float 2
|
||||
%false = OpConstantFalse %bool
|
||||
%40 = OpTypeFunction %v4float %_ptr_Function_v2float
|
||||
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
||||
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
|
||||
%int = OpTypeInt 32 1
|
||||
%int_0 = OpConstant %int 0
|
||||
%int_1 = OpConstant %int 1
|
||||
%_entrypoint_v = OpFunction %void None %19
|
||||
%20 = OpLabel
|
||||
%24 = OpVariable %_ptr_Function_v2float Function
|
||||
OpStore %24 %23
|
||||
%26 = OpFunctionCall %v4float %main %24
|
||||
OpStore %sk_FragColor %26
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%out_params_are_distinct_from_global_bh = OpFunction %bool None %27
|
||||
%29 = OpFunctionParameter %_ptr_Function_float
|
||||
%30 = OpLabel
|
||||
OpStore %29 %float_2
|
||||
%33 = OpLoad %float %x
|
||||
%34 = OpFOrdEqual %bool %33 %float_1
|
||||
OpSelectionMerge %36 None
|
||||
OpBranchConditional %34 %35 %36
|
||||
%35 = OpLabel
|
||||
%37 = OpLoad %float %29
|
||||
%38 = OpFOrdEqual %bool %37 %float_2
|
||||
OpBranch %36
|
||||
%36 = OpLabel
|
||||
%39 = OpPhi %bool %false %30 %38 %35
|
||||
OpReturnValue %39
|
||||
OpFunctionEnd
|
||||
%main = OpFunction %v4float None %40
|
||||
%41 = OpFunctionParameter %_ptr_Function_v2float
|
||||
%42 = OpLabel
|
||||
%43 = OpVariable %_ptr_Function_float Function
|
||||
%46 = OpVariable %_ptr_Function_v4float Function
|
||||
OpStore %x %float_1
|
||||
%44 = OpFunctionCall %bool %out_params_are_distinct_from_global_bh %43
|
||||
%45 = OpLoad %float %43
|
||||
OpStore %x %45
|
||||
OpSelectionMerge %50 None
|
||||
OpBranchConditional %44 %48 %49
|
||||
%48 = OpLabel
|
||||
%51 = OpAccessChain %_ptr_Uniform_v4float %14 %int_0
|
||||
%55 = OpLoad %v4float %51
|
||||
OpStore %46 %55
|
||||
OpBranch %50
|
||||
%49 = OpLabel
|
||||
%56 = OpAccessChain %_ptr_Uniform_v4float %14 %int_1
|
||||
%58 = OpLoad %v4float %56
|
||||
OpStore %46 %58
|
||||
OpBranch %50
|
||||
%50 = OpLabel
|
||||
%59 = OpLoad %v4float %46
|
||||
OpReturnValue %59
|
||||
OpFunctionEnd
|
12
tests/sksl/shared/OutParamsAreDistinctFromGlobal.glsl
Normal file
12
tests/sksl/shared/OutParamsAreDistinctFromGlobal.glsl
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
uniform vec4 colorGreen;
|
||||
uniform vec4 colorRed;
|
||||
float x = 1.0;
|
||||
bool out_params_are_distinct_from_global_bh(out float y) {
|
||||
y = 2.0;
|
||||
return x == 1.0 && y == 2.0;
|
||||
}
|
||||
vec4 main() {
|
||||
return out_params_are_distinct_from_global_bh(x) ? colorGreen : colorRed;
|
||||
}
|
34
tests/sksl/shared/OutParamsAreDistinctFromGlobal.metal
Normal file
34
tests/sksl/shared/OutParamsAreDistinctFromGlobal.metal
Normal file
@ -0,0 +1,34 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Uniforms {
|
||||
half4 colorGreen;
|
||||
half4 colorRed;
|
||||
};
|
||||
struct Inputs {
|
||||
};
|
||||
struct Outputs {
|
||||
half4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
struct Globals {
|
||||
half x;
|
||||
};
|
||||
bool out_params_are_distinct_from_global_bh(thread Globals& _globals, thread half& y);
|
||||
bool _skOutParamHelper0_out_params_are_distinct_from_global_bh(thread Globals& _globals, thread half& x) {
|
||||
half _var0;
|
||||
bool _skResult = out_params_are_distinct_from_global_bh(_globals, _var0);
|
||||
x = _var0;
|
||||
return _skResult;
|
||||
}
|
||||
bool out_params_are_distinct_from_global_bh(thread Globals& _globals, thread half& y) {
|
||||
y = 2.0h;
|
||||
return _globals.x == 1.0h && y == 2.0h;
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Globals _globals{1.0h};
|
||||
(void)_globals;
|
||||
Outputs _out;
|
||||
(void)_out;
|
||||
_out.sk_FragColor = _skOutParamHelper0_out_params_are_distinct_from_global_bh(_globals, _globals.x) ? _uniforms.colorGreen : _uniforms.colorRed;
|
||||
return _out;
|
||||
}
|
Loading…
Reference in New Issue
Block a user