Add helper uniforms to Runtime Effect tests.

This lets us use descriptive names like `colorRed` and `colorGreen`
instead of `half4(1,0,0,1)` and `half4(0,1,0,1)`. It also lets us use
actual unknown values instead of synthesizing sorta-kinda-unknowns by
calling sqrt.

Change-Id: I61481c33b7ff42182955777b05cfa5fcc13e0efc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/359567
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-01-26 16:28:12 -05:00 committed by Skia Commit-Bot
parent d8fc95dc02
commit b41d5bb3a7
24 changed files with 171 additions and 99 deletions

View File

@ -1,3 +1,5 @@
uniform half4 colorRed, colorGreen;
bool test() { bool test() {
bool a = 1 == 1 || 2 == 8; bool a = 1 == 1 || 2 == 8;
bool b = 1 > 1 || 2 == 8; bool b = 1 > 1 || 2 == 8;
@ -14,6 +16,6 @@ bool test() {
} }
half4 main() { half4 main() {
return test() ? half4(0,1,0,1) : half4(1,0,0,1); return test() ? colorGreen : colorRed;
} }

View File

@ -1,3 +1,5 @@
uniform half4 colorRed, colorGreen;
bool test() { bool test() {
bool ok = true; bool ok = true;
half x = 32.0 + 2.0; half x = 32.0 + 2.0;
@ -74,5 +76,5 @@ bool test() {
} }
half4 main() { half4 main() {
return test() ? half4(0,1,0,1) : half4(1,0,0,1); return test() ? colorGreen : colorRed;
} }

View File

@ -1,5 +1,8 @@
uniform half4 colorRed, colorGreen;
uniform half unknownInput;
bool test() { bool test() {
int unknown = int(sqrt(1)); int unknown = int(unknownInput);
bool ok = true; bool ok = true;
int x = 32 + 2; int x = 32 + 2;
@ -72,5 +75,5 @@ bool test() {
} }
half4 main() { half4 main() {
return test() ? half4(0,1,0,1) : half4(1,0,0,1); return test() ? colorGreen : colorRed;
} }

View File

@ -1,3 +1,5 @@
uniform half4 colorRed, colorGreen;
bool test() { bool test() {
bool ok = true; bool ok = true;
int x = 12 | 6; int x = 12 | 6;
@ -16,5 +18,5 @@ bool test() {
} }
half4 main() { half4 main() {
return test() ? half4(0,1,0,1) : half4(1,0,0,1); return test() ? colorGreen : colorRed;
} }

View File

@ -1,3 +1,5 @@
uniform half4 colorRed, colorGreen;
bool test() { bool test() {
bool ok = true; bool ok = true;
ok = ok && (float2x2(float2(1.0, 0.0), float2(0.0, 1.0)) == ok = ok && (float2x2(float2(1.0, 0.0), float2(0.0, 1.0)) ==
@ -23,5 +25,5 @@ bool test() {
} }
half4 main() { half4 main() {
return test() ? half4(0,1,0,1) : half4(1,0,0,1); return test() ? colorGreen : colorRed;
} }

View File

@ -1,3 +1,5 @@
uniform half4 colorRed, colorGreen;
bool test() { bool test() {
bool ok = true; bool ok = true;
ok = ok && (float3x2(2) == float3x2(float2(2.0, 0.0), float2(0.0, 2.0), float2(0.0))); ok = ok && (float3x2(2) == float3x2(float2(2.0, 0.0), float2(0.0, 2.0), float2(0.0)));
@ -5,5 +7,5 @@ bool test() {
} }
half4 main() { half4 main() {
return test() ? half4(0,1,0,1) : half4(1,0,0,1); return test() ? colorGreen : colorRed;
} }

View File

@ -1,5 +1,8 @@
uniform half4 colorRed, colorGreen;
uniform half unknownInput;
bool test() { bool test() {
bool expr = sqrt(1) > 0; bool expr = unknownInput > 0;
int ok = 0, bad = 0; int ok = 0, bad = 0;
@ -40,5 +43,5 @@ bool test() {
} }
half4 main() { half4 main() {
return test() ? half4(0,1,0,1) : half4(1,0,0,1); return test() ? colorGreen : colorRed;
} }

View File

@ -1,3 +1,6 @@
uniform half4 colorRed, colorGreen;
uniform half unknownInput;
bool test_half() { bool test_half() {
bool ok = true; bool ok = true;
@ -36,7 +39,7 @@ bool test_half() {
ok = ok && (x == half4(6)); ok = ok && (x == half4(6));
// Vector op unknown scalar // Vector op unknown scalar
half unknown = half(sqrt(2)); half unknown = unknownInput;
x = half4(0) + unknown; x = half4(0) + unknown;
ok = ok && (x == half4(unknown)); ok = ok && (x == half4(unknown));
x = half4(0) * unknown; x = half4(0) * unknown;
@ -117,7 +120,7 @@ bool test_int() {
ok = ok && (x == int4(6)); ok = ok && (x == int4(6));
// Vector op unknown scalar // Vector op unknown scalar
int unknown = int(sqrt(2)); int unknown = int(unknownInput);
x = int4(0) + unknown; x = int4(0) + unknown;
ok = ok && (x == int4(unknown)); ok = ok && (x == int4(unknown));
x = int4(0) * unknown; x = int4(0) * unknown;
@ -161,5 +164,5 @@ bool test_int() {
} }
half4 main() { half4 main() {
return test_half() && test_int() ? half4(0,1,0,1) : half4(1,0,0,1); return test_half() && test_int() ? colorGreen : colorRed;
} }

View File

@ -1,5 +1,8 @@
uniform half unknownInput;
uniform half4 colorRed, colorGreen;
bool test_half() { bool test_half() {
half unknown = half(sqrt(1)); half unknown = unknownInput;
bool ok = true; bool ok = true;
ok = ok && (half4(half2(1), half2(2, 3)) + half4(5, 6, 7, 8)) == half4(6, 7, 9, 11); ok = ok && (half4(half2(1), half2(2, 3)) + half4(5, 6, 7, 8)) == half4(6, 7, 9, 11);
@ -54,7 +57,7 @@ bool test_half() {
} }
bool test_int() { bool test_int() {
int unknown = int(sqrt(1)); int unknown = int(unknownInput);
bool ok = true; bool ok = true;
ok = ok && (int4(int2(1), int2(2, 3)) + int4(5, 6, 7, 8)) == int4(6, 7, 9, 11); ok = ok && (int4(int2(1), int2(2, 3)) + int4(5, 6, 7, 8)) == int4(6, 7, 9, 11);
@ -109,5 +112,5 @@ bool test_int() {
} }
half4 main() { half4 main() {
return test_half() && test_int() ? half4(0,1,0,1) : half4(1,0,0,1); return test_half() && test_int() ? colorGreen : colorRed;
} }

View File

@ -1,5 +1,7 @@
uniform half4 colorWhite;
half4 main() { half4 main() {
half4 x = half4(1, 1, 1, 1); half4 x = colorWhite;
// Verify that break is allowed in a for loop. // Verify that break is allowed in a for loop.
for (half r = -5; r < 5; r += 1) { for (half r = -5; r < 5; r += 1) {

View File

@ -1476,7 +1476,7 @@ bool MetalCodeGenerator::writeFunctionDeclaration(const FunctionDeclaration& f)
if (var.var().type().typeKind() == Type::TypeKind::kSampler) { if (var.var().type().typeKind() == Type::TypeKind::kSampler) {
if (var.var().modifiers().fLayout.fBinding < 0) { if (var.var().modifiers().fLayout.fBinding < 0) {
fErrors.error(decls.fOffset, fErrors.error(decls.fOffset,
"Metal samplers must have 'layout(binding=...)'"); "Metal samplers must have 'layout(binding=...)'");
return false; return false;
} }
if (var.var().type().dimensions() != SpvDim2D) { if (var.var().type().dimensions() != SpvDim2D) {

View File

@ -24,6 +24,14 @@
static const SkRect kRect = SkRect::MakeWH(1, 1); static const SkRect kRect = SkRect::MakeWH(1, 1);
template <typename T>
static void set_uniform(SkRuntimeShaderBuilder* builder, const char* name, const T& value) {
SkRuntimeShaderBuilder::BuilderUniform uniform = builder->uniform(name);
if (uniform.fVar) {
uniform = value;
}
}
static void test(skiatest::Reporter* r, SkSurface* surface, const char* testFile) { static void test(skiatest::Reporter* r, SkSurface* surface, const char* testFile) {
SkString resourcePath = SkStringPrintf("sksl/%s", testFile); SkString resourcePath = SkStringPrintf("sksl/%s", testFile);
sk_sp<SkData> shaderData = GetResourceAsData(resourcePath.c_str()); sk_sp<SkData> shaderData = GetResourceAsData(resourcePath.c_str());
@ -40,6 +48,13 @@ static void test(skiatest::Reporter* r, SkSurface* surface, const char* testFile
} }
SkRuntimeShaderBuilder builder(effect); SkRuntimeShaderBuilder builder(effect);
set_uniform(&builder, "colorBlack", SkV4{0, 0, 0, 1});
set_uniform(&builder, "colorRed", SkV4{1, 0, 0, 1});
set_uniform(&builder, "colorGreen", SkV4{0, 1, 0, 1});
set_uniform(&builder, "colorBlue", SkV4{0, 0, 1, 1});
set_uniform(&builder, "colorWhite", SkV4{1, 1, 1, 1});
set_uniform(&builder, "unknownInput", 1.0f);
sk_sp<SkShader> shader = builder.makeShader(/*localMatrix=*/nullptr, /*isOpaque=*/true); sk_sp<SkShader> shader = builder.makeShader(/*localMatrix=*/nullptr, /*isOpaque=*/true);
if (!shader) { if (!shader) {
ERRORF(r, "%s: Unable to build shader", testFile); ERRORF(r, "%s: Unable to build shader", testFile);

View File

@ -1,5 +1,7 @@
uniform vec4 colorRed;
uniform vec4 colorGreen;
vec4 main() { vec4 main() {
return vec4(0.0, 1.0, 0.0, 1.0); return colorGreen;
} }

View File

@ -1,4 +1,6 @@
uniform vec4 colorRed;
uniform vec4 colorGreen;
vec4 main() { vec4 main() {
bool _1_ok = true; bool _1_ok = true;
float _2_x = 34.0; float _2_x = 34.0;
@ -66,6 +68,6 @@ vec4 main() {
_1_ok = _1_ok && _2_x == -2.0; _1_ok = _1_ok && _2_x == -2.0;
_2_x /= 2.0; _2_x /= 2.0;
_1_ok = _1_ok && _2_x == -1.0; _1_ok = _1_ok && _2_x == -1.0;
return _1_ok ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0); return _1_ok ? colorGreen : colorRed;
} }

View File

@ -1,6 +1,9 @@
uniform vec4 colorRed;
uniform vec4 colorGreen;
uniform float unknownInput;
vec4 main() { vec4 main() {
int _1_unknown = int(sqrt(1.0)); int _1_unknown = int(unknownInput);
bool _2_ok = true; bool _2_ok = true;
int _3_x = 34; int _3_x = 34;
_2_ok = true; _2_ok = true;
@ -64,6 +67,6 @@ vec4 main() {
_2_ok = _2_ok && _3_x == -2; _2_ok = _2_ok && _3_x == -2;
_3_x /= 2; _3_x /= 2;
_2_ok = _2_ok && _3_x == -1; _2_ok = _2_ok && _3_x == -1;
return _2_ok ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0); return _2_ok ? colorGreen : colorRed;
} }

View File

@ -1,5 +1,7 @@
uniform vec4 colorRed;
uniform vec4 colorGreen;
vec4 main() { vec4 main() {
return vec4(0.0, 1.0, 0.0, 1.0); return colorGreen;
} }

View File

@ -1,5 +1,7 @@
uniform vec4 colorRed;
uniform vec4 colorGreen;
vec4 main() { vec4 main() {
return vec4(0.0, 1.0, 0.0, 1.0); return colorGreen;
} }

View File

@ -1,5 +1,7 @@
uniform vec4 colorRed;
uniform vec4 colorGreen;
vec4 main() { vec4 main() {
return vec4(0.0, 1.0, 0.0, 1.0); return colorGreen;
} }

View File

@ -1,6 +1,9 @@
uniform vec4 colorRed;
uniform vec4 colorGreen;
uniform float unknownInput;
vec4 main() { vec4 main() {
bool _1_expr = sqrt(1.0) > 0.0; bool _1_expr = unknownInput > 0.0;
int _2_ok = 0; int _2_ok = 0;
int _3_bad = 0; int _3_bad = 0;
@ -110,6 +113,6 @@ vec4 main() {
} else { } else {
++_3_bad; ++_3_bad;
} }
return _2_ok == 22 && _3_bad == 0 ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0); return _2_ok == 22 && _3_bad == 0 ? colorGreen : colorRed;
} }

View File

@ -1,4 +1,7 @@
uniform vec4 colorRed;
uniform vec4 colorGreen;
uniform float unknownInput;
bool test_int() { bool test_int() {
bool ok = true; bool ok = true;
ivec4 x = ivec4(6, 6, 7, 8); ivec4 x = ivec4(6, 6, 7, 8);
@ -27,7 +30,7 @@ bool test_int() {
ok = ok; ok = ok;
x = ivec4(6, 6, 6, 6); x = ivec4(6, 6, 6, 6);
ok = ok; ok = ok;
int unknown = int(sqrt(2.0)); int unknown = int(unknownInput);
x = ivec4(unknown); x = ivec4(unknown);
ok = ok && x == ivec4(unknown); ok = ok && x == ivec4(unknown);
x = ivec4(0); x = ivec4(0);
@ -90,7 +93,7 @@ vec4 main() {
_1_ok = _1_ok; _1_ok = _1_ok;
_2_x = vec4(6.0, 6.0, 6.0, 6.0); _2_x = vec4(6.0, 6.0, 6.0, 6.0);
_1_ok = _1_ok; _1_ok = _1_ok;
float _3_unknown = sqrt(2.0); float _3_unknown = unknownInput;
_2_x = vec4(_3_unknown); _2_x = vec4(_3_unknown);
_1_ok = _1_ok && _2_x == vec4(_3_unknown); _1_ok = _1_ok && _2_x == vec4(_3_unknown);
_2_x = vec4(0.0); _2_x = vec4(0.0);
@ -123,6 +126,6 @@ vec4 main() {
_1_ok = _1_ok && _2_x == vec4(_3_unknown); _1_ok = _1_ok && _2_x == vec4(_3_unknown);
_2_x = vec4(_3_unknown); _2_x = vec4(_3_unknown);
_1_ok = _1_ok && _2_x == vec4(_3_unknown); _1_ok = _1_ok && _2_x == vec4(_3_unknown);
return _1_ok && test_int() ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0); return _1_ok && test_int() ? colorGreen : colorRed;
} }

View File

@ -1,6 +1,9 @@
uniform float unknownInput;
uniform vec4 colorRed;
uniform vec4 colorGreen;
bool test_int() { bool test_int() {
int unknown = int(sqrt(1.0)); int unknown = int(unknownInput);
bool ok = true; bool ok = true;
ok = true; ok = true;
ok = true; ok = true;
@ -47,7 +50,7 @@ bool test_int() {
return ok; return ok;
} }
vec4 main() { vec4 main() {
float _1_unknown = sqrt(1.0); float _1_unknown = unknownInput;
bool _2_ok = true; bool _2_ok = true;
_2_ok = true; _2_ok = true;
_2_ok = true; _2_ok = true;
@ -91,6 +94,6 @@ vec4 main() {
_3_val *= vec4(2.0); _3_val *= vec4(2.0);
_3_val /= vec4(2.0); _3_val /= vec4(2.0);
_2_ok = _2_ok && _3_val == vec4(_1_unknown); _2_ok = _2_ok && _3_val == vec4(_1_unknown);
return _2_ok && test_int() ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0); return _2_ok && test_int() ? colorGreen : colorRed;
} }

View File

@ -9,107 +9,113 @@ OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %sk_Clockwise OpEntryPoint Fragment %main "main" %sk_Clockwise
OpExecutionMode %main OriginUpperLeft OpExecutionMode %main OriginUpperLeft
OpName %sk_Clockwise "sk_Clockwise" OpName %sk_Clockwise "sk_Clockwise"
OpName %colorWhite "colorWhite"
OpName %main "main" OpName %main "main"
OpName %x "x" OpName %x "x"
OpName %r "r" OpName %r "r"
OpName %b "b" OpName %b "b"
OpDecorate %sk_Clockwise RelaxedPrecision OpDecorate %sk_Clockwise RelaxedPrecision
OpDecorate %sk_Clockwise BuiltIn FrontFacing OpDecorate %sk_Clockwise BuiltIn FrontFacing
OpDecorate %22 RelaxedPrecision OpDecorate %colorWhite RelaxedPrecision
OpDecorate %26 RelaxedPrecision OpDecorate %colorWhite DescriptorSet 0
OpDecorate %30 RelaxedPrecision OpDecorate %14 RelaxedPrecision
OpDecorate %36 RelaxedPrecision OpDecorate %23 RelaxedPrecision
OpDecorate %27 RelaxedPrecision
OpDecorate %31 RelaxedPrecision
OpDecorate %37 RelaxedPrecision OpDecorate %37 RelaxedPrecision
OpDecorate %44 RelaxedPrecision OpDecorate %39 RelaxedPrecision
OpDecorate %46 RelaxedPrecision OpDecorate %46 RelaxedPrecision
OpDecorate %49 RelaxedPrecision OpDecorate %48 RelaxedPrecision
OpDecorate %56 RelaxedPrecision OpDecorate %51 RelaxedPrecision
OpDecorate %57 RelaxedPrecision
OpDecorate %58 RelaxedPrecision OpDecorate %58 RelaxedPrecision
OpDecorate %59 RelaxedPrecision
OpDecorate %60 RelaxedPrecision
%bool = OpTypeBool %bool = OpTypeBool
%_ptr_Input_bool = OpTypePointer Input %bool %_ptr_Input_bool = OpTypePointer Input %bool
%sk_Clockwise = OpVariable %_ptr_Input_bool Input %sk_Clockwise = OpVariable %_ptr_Input_bool Input
%float = OpTypeFloat 32 %float = OpTypeFloat 32
%v4float = OpTypeVector %float 4 %v4float = OpTypeVector %float 4
%8 = OpTypeFunction %v4float %_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%colorWhite = OpVariable %_ptr_Uniform_v4float Uniform
%10 = OpTypeFunction %v4float
%_ptr_Function_v4float = OpTypePointer Function %v4float %_ptr_Function_v4float = OpTypePointer Function %v4float
%float_1 = OpConstant %float 1
%13 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Function_float = OpTypePointer Function %float %_ptr_Function_float = OpTypePointer Function %float
%float_n5 = OpConstant %float -5 %float_n5 = OpConstant %float -5
%float_5 = OpConstant %float 5 %float_5 = OpConstant %float 5
%int = OpTypeInt 32 1 %int = OpTypeInt 32 1
%int_0 = OpConstant %int 0 %int_0 = OpConstant %int 0
%float_0 = OpConstant %float 0 %float_0 = OpConstant %float 0
%float_1 = OpConstant %float 1
%int_2 = OpConstant %int 2 %int_2 = OpConstant %int 2
%int_1 = OpConstant %int 1 %int_1 = OpConstant %int 1
%main = OpFunction %v4float None %8 %main = OpFunction %v4float None %10
%9 = OpLabel %11 = OpLabel
%x = OpVariable %_ptr_Function_v4float Function %x = OpVariable %_ptr_Function_v4float Function
%r = OpVariable %_ptr_Function_float Function %r = OpVariable %_ptr_Function_float Function
%b = OpVariable %_ptr_Function_float Function %b = OpVariable %_ptr_Function_float Function
OpStore %x %13 %14 = OpLoad %v4float %colorWhite
OpStore %x %14
OpStore %r %float_n5 OpStore %r %float_n5
OpBranch %17
%17 = OpLabel
OpLoopMerge %21 %20 None
OpBranch %18 OpBranch %18
%18 = OpLabel %18 = OpLabel
%22 = OpLoad %float %r OpLoopMerge %22 %21 None
%24 = OpFOrdLessThan %bool %22 %float_5 OpBranch %19
OpBranchConditional %24 %19 %21
%19 = OpLabel %19 = OpLabel
%26 = OpLoad %float %r %23 = OpLoad %float %r
%25 = OpExtInst %float %1 FAbs %26 %25 = OpFOrdLessThan %bool %23 %float_5
%27 = OpAccessChain %_ptr_Function_float %x %int_0 OpBranchConditional %25 %20 %22
OpStore %27 %25
%30 = OpLoad %v4float %x
%31 = OpCompositeExtract %float %30 0
%33 = OpFOrdEqual %bool %31 %float_0
OpSelectionMerge %35 None
OpBranchConditional %33 %34 %35
%34 = OpLabel
OpBranch %21
%35 = OpLabel
OpBranch %20
%20 = OpLabel %20 = OpLabel
%36 = OpLoad %float %r %27 = OpLoad %float %r
%37 = OpFAdd %float %36 %float_1 %26 = OpExtInst %float %1 FAbs %27
OpStore %r %37 %28 = OpAccessChain %_ptr_Function_float %x %int_0
OpBranch %17 OpStore %28 %26
%31 = OpLoad %v4float %x
%32 = OpCompositeExtract %float %31 0
%34 = OpFOrdEqual %bool %32 %float_0
OpSelectionMerge %36 None
OpBranchConditional %34 %35 %36
%35 = OpLabel
OpBranch %22
%36 = OpLabel
OpBranch %21
%21 = OpLabel %21 = OpLabel
%37 = OpLoad %float %r
%39 = OpFAdd %float %37 %float_1
OpStore %r %39
OpBranch %18
%22 = OpLabel
OpStore %b %float_5 OpStore %b %float_5
OpBranch %39 OpBranch %41
%39 = OpLabel
OpLoopMerge %43 %42 None
OpBranch %40
%40 = OpLabel
%44 = OpLoad %float %b
%45 = OpFOrdGreaterThanEqual %bool %44 %float_0
OpBranchConditional %45 %41 %43
%41 = OpLabel %41 = OpLabel
%46 = OpLoad %float %b OpLoopMerge %45 %44 None
%47 = OpAccessChain %_ptr_Function_float %x %int_2
OpStore %47 %46
%49 = OpLoad %v4float %x
%50 = OpCompositeExtract %float %49 3
%51 = OpFOrdEqual %bool %50 %float_1
OpSelectionMerge %53 None
OpBranchConditional %51 %52 %53
%52 = OpLabel
OpBranch %42
%53 = OpLabel
%54 = OpAccessChain %_ptr_Function_float %x %int_1
OpStore %54 %float_0
OpBranch %42 OpBranch %42
%42 = OpLabel %42 = OpLabel
%56 = OpLoad %float %b %46 = OpLoad %float %b
%57 = OpFSub %float %56 %float_1 %47 = OpFOrdGreaterThanEqual %bool %46 %float_0
OpStore %b %57 OpBranchConditional %47 %43 %45
OpBranch %39
%43 = OpLabel %43 = OpLabel
%58 = OpLoad %v4float %x %48 = OpLoad %float %b
OpReturnValue %58 %49 = OpAccessChain %_ptr_Function_float %x %int_2
OpStore %49 %48
%51 = OpLoad %v4float %x
%52 = OpCompositeExtract %float %51 3
%53 = OpFOrdEqual %bool %52 %float_1
OpSelectionMerge %55 None
OpBranchConditional %53 %54 %55
%54 = OpLabel
OpBranch %44
%55 = OpLabel
%56 = OpAccessChain %_ptr_Function_float %x %int_1
OpStore %56 %float_0
OpBranch %44
%44 = OpLabel
%58 = OpLoad %float %b
%59 = OpFSub %float %58 %float_1
OpStore %b %59
OpBranch %41
%45 = OpLabel
%60 = OpLoad %v4float %x
OpReturnValue %60
OpFunctionEnd OpFunctionEnd
1 error 1 error

View File

@ -1,6 +1,7 @@
uniform vec4 colorWhite;
vec4 main() { vec4 main() {
vec4 x = vec4(1.0, 1.0, 1.0, 1.0); vec4 x = colorWhite;
for (float r = -5.0;r < 5.0; r += 1.0) { for (float r = -5.0;r < 5.0; r += 1.0) {
x.x = abs(r); x.x = abs(r);
if (x.x == 0.0) break; if (x.x == 0.0) break;

View File

@ -1,15 +1,19 @@
#include <metal_stdlib> #include <metal_stdlib>
#include <simd/simd.h> #include <simd/simd.h>
using namespace metal; using namespace metal;
struct Uniforms {
float4 colorWhite;
};
struct Inputs { struct Inputs {
}; };
struct Outputs { struct Outputs {
float4 sk_FragColor [[color(0)]]; 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; Outputs _out;
(void)_out; (void)_out;
float4 x = float4(1.0, 1.0, 1.0, 1.0); float4 x = _uniforms.colorWhite;
for (float r = -5.0;r < 5.0; r += 1.0) { for (float r = -5.0;r < 5.0; r += 1.0) {
x.x = abs(r); x.x = abs(r);
if (x.x == 0.0) break; if (x.x == 0.0) break;