Reland "Improve support for arrays in Metal."

This reverts commit 38df4c8470.

Reason for revert: updated ArrayTypes test for ES2 compatibility

Original change's description:
> Revert "Improve support for arrays in Metal."
>
> This reverts commit dd904af566.
>
> Reason for revert: breaks ANGLE
>
> Original change's description:
> > Improve support for arrays in Metal.
> >
> > Arrays in Metal now use the `array<T, N>` type instead of the C-style
> > `T[N]` type. This gives them semantics much more in line with GLSL,
> > so they can be initialized and assigned like GLSL arrays.
> >
> > This allows the ArrayTypes and Assignment tests to pass, so they have
> > been added to our dm SkSL tests. (ArrayConstructors also passes, but
> > is not ES2-compliant so it is not enabled.)
> >
> > Change-Id: Id1028311963084befd0e044e11e223af6a064dda
> > Bug: skia:10761, skia:10760, skia:11022, skia:10939
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365699
> > Commit-Queue: John Stiles <johnstiles@google.com>
> > Auto-Submit: John Stiles <johnstiles@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com
>
> Change-Id: If6a18dea7d6a45fa7836e9129bf81c2e536f07e3
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:10761
> Bug: skia:10760
> Bug: skia:11022
> Bug: skia:10939
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365976
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com

Bug: skia:10761
Bug: skia:10760
Bug: skia:11022
Bug: skia:10939
Change-Id: Ia1c4917f5d3c41162d282b3093814d861707ad30
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366144
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-02-04 10:57:08 -05:00 committed by Skia Commit-Bot
parent 420c8a505e
commit b44185086e
24 changed files with 441 additions and 471 deletions

View File

@ -1,7 +1,9 @@
uniform half4 colorGreen, colorRed;
half4 main() {
float test1[4] = float[4](1, 2, 3, 4);
float2 test2[2] = float2[2](float2(1, 2), float2(3, 4));
float4x4 test3[1] = float4x4[1](float4x4(16));
void main() {
sk_FragColor.r = half(test1[0] + test2[0].x + test3[0][0][0]);
return (test1[3] + test2[1][1] + test3[0][3][3] == 24) ? colorGreen : colorRed;
}

View File

@ -1,6 +1,13 @@
void main() {
float2 x[2] = float2[2](float2(1), float2(2));
float2[2] y = float2[2](float2(3), float2(4));
half4 main() {
float2 x[2];
x[0] = float2( 0, 0);
x[1] = float2( 1, 0);
float2 y[2];
y[0] = float2( 0, 1);
y[1] = float2(-1, 2);
sk_FragColor = half4(half2(x[0]), half2(y[1]));
return half4(x[0][0] * x[0][1], // R=0
x[1][0] - x[1][1], // G=1
y[0][0] / y[0][1], // B=0
y[1][0] + y[1][1]); // A=1
}

View File

@ -1,41 +1,39 @@
struct S {
float f;
float af[5];
half4 h4;
half4 ah4[5];
};
uniform half4 colorGreen;
void main() {
// TODO(skia:10939): Structs not working in Runtime Effects yet
//struct S {
// float f;
// float af[5];
// half4 h4;
// half4 ah4[5];
//};
half4 main() {
/* assign to scalar */ int i; i = 0;
/* assign to vector */ int4 i4; i4 = int4(1,2,3,4);
/* assign to matrix */ float3x3 f3x3; f3x3 = float3x3(1,2,3,4,5,6,7,8,9);
/* assign to swizzle */ half4 x; x.w = 0; x.yx = half2(0);
/* assign to array of scalar */ int ai[1]; ai[0] = 0;
/* assign to array of vector */ int4 ai4[1]; ai4[0] = int4(1,2,3,4);
/* assign to array of matrix */ half2x4 ah2x4[1]; ah2x4[0] = half2x4(1,2,3,4,5,6,7,8);
/* assign to array idx by lookup */ ai[0] = 0; ai[ai[0]] = 0;
/* assign to array of matrix */ half3x3 ah2x4[1]; ah2x4[0] = half3x3(1,2,3,4,5,6,7,8,9);
/* assign to array swizzle */ float4 af4[1]; af4[0].x = 0; af4[0].ywxz = float4(1);
/* assign to struct variable */ S s; s.f = 0;
/* assign to struct array */ s.af[1] = 0;
/* assign to struct swizzle */ s.h4.zxy = half3(9);
/* assign to struct array swizzle */ s.ah4[2].yw = half2(5);
// TODO(skia:10939): Structs not working in Runtime Effects yet
// /* assign to struct variable */ S s; s.f = 0;
// /* assign to struct array */ s.af[1] = 0;
// /* assign to struct swizzle */ s.h4.zxy = half3(9);
// /* assign to struct array swizzle */ s.ah4[2].yw = half2(5);
// Not allowed in ES2
// /* assign to array idx by lookup */ ai[0] = 0; ai[ai[0]] = 0;
// Not allowed natively in GLSL, but SkSL will turn these into valid GLSL expressions.
/* assign to folded ternary */ float l; float r; (true ? l : r) = 0;
/* assign to unary plus */ +s.f = 1; +s.af[0] = 2;
+s.h4 = half4(1); +s.ah4[0] = half4(2);
/* assign to folded ternary */ half l, r; (true ? l : r) = 0;
// TODO(skia:10939): Structs not working in Runtime Effects yet
// /* assign to struct unary plus */ +s.f = 1; +s.af[0] = 2;
// +s.h4 = half4(1); +s.ah4[0] = half4(2);
sk_FragColor = half(i).xxxx;
sk_FragColor = half4(i4);
sk_FragColor = half4(f3x3[0].xxyz);
sk_FragColor = x;
sk_FragColor = half(ai[0]).xxxx;
sk_FragColor = half4(ai4[0]);
sk_FragColor = ah2x4[0][0];
sk_FragColor = half4(af4[0]);
sk_FragColor = half(l).xxxx;
sk_FragColor = half(s.f).xxxx;
sk_FragColor = half(s.af[1]).xxxx;
sk_FragColor = s.h4;
sk_FragColor = s.ah4[0];
i4.y *= i;
x.y *= l;
return ai, ai4, ah2x4, af4, colorGreen;
}

View File

@ -109,15 +109,24 @@ void MetalCodeGenerator::writeExtension(const Extension& ext) {
String MetalCodeGenerator::typeName(const Type& type) {
switch (type.typeKind()) {
case Type::TypeKind::kArray:
SkASSERTF(type.columns() > 0, "invalid array size: %s", type.description().c_str());
return String::printf("array<%s, %d>",
this->typeName(type.componentType()).c_str(), type.columns());
case Type::TypeKind::kVector:
return this->typeName(type.componentType()) + to_string(type.columns());
case Type::TypeKind::kMatrix:
return this->typeName(type.componentType()) + to_string(type.columns()) + "x" +
to_string(type.rows());
case Type::TypeKind::kSampler:
return "texture2d<float>"; // FIXME - support other texture types
case Type::TypeKind::kEnum:
return "int";
default:
if (type == *fContext.fTypes.fHalf) {
// FIXME - Currently only supporting floats in MSL to avoid type coercion issues.
@ -141,36 +150,8 @@ void MetalCodeGenerator::writeStructDefinition(const StructDefinition& s) {
this->writeLine("};");
}
// Flags an error if an array type is found. Meant to be used in places where an array type might
// appear in the SkSL/IR, but can't be represented by Metal.
void MetalCodeGenerator::disallowArrayTypes(const Type& type, int offset) {
if (type.isArray()) {
fErrors.error(offset, "Metal does not support array types in this context");
}
}
// Writes the base type, stripping array suffixes. e.g. `float[2]` will output `float`.
// Call `writeArrayDimensions` to write the type's accompanying array sizes.
void MetalCodeGenerator::writeBaseType(const Type& type) {
switch (type.typeKind()) {
case Type::TypeKind::kArray:
this->writeBaseType(type.componentType());
break;
default:
void MetalCodeGenerator::writeType(const Type& type) {
this->write(this->typeName(type));
break;
}
}
// Writes the array suffix of a type, if one exists. e.g. `float[2][4]` will output `[2][4]`.
void MetalCodeGenerator::writeArrayDimensions(const Type& type) {
if (type.isArray()) {
this->write("[");
if (type.columns() != Type::kUnsizedArray) {
this->write(to_string(type.columns()));
}
this->write("]");
}
}
void MetalCodeGenerator::writeExpression(const Expression& expr, Precedence parentPrecedence) {
@ -242,7 +223,7 @@ String MetalCodeGenerator::getOutParamHelper(const FunctionCall& call,
// `outVars` is non-null; in those places, we take the type of the VariableReference.
//
// float _skOutParamHelper0_originalFuncName(float _var0, float _var1, float& outParam) {
this->writeBaseType(call.type());
this->writeType(call.type());
this->write(" ");
this->write(name);
this->write("(");
@ -259,7 +240,7 @@ String MetalCodeGenerator::getOutParamHelper(const FunctionCall& call,
this->writeModifiers(param->modifiers(), /*globalContext=*/false);
const Type* type = outVars[index] ? &outVars[index]->type() : &arguments[index]->type();
this->writeBaseType(*type);
this->writeType(*type);
if (param->modifiers().fFlags & Modifiers::kOut_Flag) {
this->write("&");
@ -273,7 +254,6 @@ String MetalCodeGenerator::getOutParamHelper(const FunctionCall& call,
this->write(" _var");
this->write(to_string(index));
}
this->writeArrayDimensions(*type);
}
this->writeLine(") {");
@ -283,7 +263,7 @@ String MetalCodeGenerator::getOutParamHelper(const FunctionCall& call,
continue;
}
// float3 _var2[ = outParam.zyx];
this->writeBaseType(arguments[index]->type());
this->writeType(arguments[index]->type());
this->write(" _var");
this->write(to_string(index));
@ -301,7 +281,7 @@ String MetalCodeGenerator::getOutParamHelper(const FunctionCall& call,
// [int _skResult = ] myFunction(inputs, outputs, _globals, _var0, _var1, _var2, _var3);
bool hasResult = (call.type().name() != "void");
if (hasResult) {
this->writeBaseType(call.type());
this->writeType(call.type());
this->write(" _skResult = ");
}
@ -1082,9 +1062,8 @@ void MetalCodeGenerator::writeConstructor(const Constructor& c, Precedence paren
}
// Explicitly invoke the constructor, passing in the necessary arguments.
this->writeBaseType(constructorType);
this->disallowArrayTypes(constructorType, c.fOffset);
this->write("(");
this->writeType(constructorType);
this->write(constructorType.isArray() ? "{" : "(");
const char* separator = "";
int scalarCount = 0;
for (const std::unique_ptr<Expression>& arg : c.arguments()) {
@ -1095,7 +1074,7 @@ void MetalCodeGenerator::writeConstructor(const Constructor& c, Precedence paren
argType.columns() < constructorType.rows()) {
// Merge scalars and smaller vectors together.
if (!scalarCount) {
this->writeBaseType(constructorType.componentType());
this->writeType(constructorType.componentType());
this->write(to_string(constructorType.rows()));
this->write("(");
}
@ -1107,7 +1086,7 @@ void MetalCodeGenerator::writeConstructor(const Constructor& c, Precedence paren
scalarCount = 0;
}
}
this->write(")");
this->write(constructorType.isArray() ? "}" : ")");
}
void MetalCodeGenerator::writeFragCoord() {
@ -1500,7 +1479,7 @@ bool MetalCodeGenerator::writeFunctionDeclaration(const FunctionDeclaration& f)
continue;
}
this->write(", constant ");
this->writeBaseType(intf.variable().type());
this->writeType(intf.variable().type());
this->write("& " );
this->write(fInterfaceBlockNameMap[&intf]);
this->write(" [[buffer(");
@ -1520,8 +1499,7 @@ bool MetalCodeGenerator::writeFunctionDeclaration(const FunctionDeclaration& f)
}
separator = ", ";
} else {
this->writeBaseType(f.returnType());
this->disallowArrayTypes(f.returnType(), f.fOffset);
this->writeType(f.returnType());
this->write(" ");
this->writeName(f.name());
this->write("(");
@ -1532,13 +1510,12 @@ bool MetalCodeGenerator::writeFunctionDeclaration(const FunctionDeclaration& f)
separator = ", ";
this->writeModifiers(param->modifiers(), /*globalContext=*/false);
const Type* type = &param->type();
this->writeBaseType(*type);
this->writeType(*type);
if (param->modifiers().fFlags & Modifiers::kOut_Flag) {
this->write("&");
}
this->write(" ");
this->writeName(param->name());
this->writeArrayDimensions(*type);
}
this->write(")");
return true;
@ -1698,10 +1675,9 @@ void MetalCodeGenerator::writeFields(const std::vector<Type::Field>& fields, int
}
currentOffset += fieldSize;
this->writeModifiers(field.fModifiers, /*globalContext=*/false);
this->writeBaseType(*fieldType);
this->writeType(*fieldType);
this->write(" ");
this->writeName(field.fName);
this->writeArrayDimensions(*fieldType);
this->writeLine(";");
if (parentIntf) {
fInterfaceBlockMap[&field] = parentIntf;
@ -1720,25 +1696,17 @@ void MetalCodeGenerator::writeName(const String& name) {
this->write(name);
}
void MetalCodeGenerator::writeVarDeclaration(const VarDeclaration& var, bool global) {
if (global && !(var.var().modifiers().fFlags & Modifiers::kConst_Flag)) {
void MetalCodeGenerator::writeVarDeclaration(const VarDeclaration& varDecl, bool global) {
if (global && !(varDecl.var().modifiers().fFlags & Modifiers::kConst_Flag)) {
return;
}
this->writeModifiers(var.var().modifiers(), global);
this->writeBaseType(var.baseType());
this->disallowArrayTypes(var.baseType(), var.fOffset);
this->writeModifiers(varDecl.var().modifiers(), global);
this->writeType(varDecl.var().type());
this->write(" ");
this->writeName(var.var().name());
if (var.arraySize() > 0) {
this->write("[");
this->write(to_string(var.arraySize()));
this->write("]");
} else if (var.arraySize() == Type::kUnsizedArray){
this->write("[]");
}
if (var.value()) {
this->writeName(varDecl.var().name());
if (varDecl.value()) {
this->write(" = ");
this->writeVarInitializer(var.var(), *var.value());
this->writeVarInitializer(varDecl.var(), *varDecl.value());
}
this->write(";");
}
@ -1940,10 +1908,9 @@ void MetalCodeGenerator::writeUniformStruct() {
"the same 'layout(set=...)'");
}
this->write(" ");
this->writeBaseType(var.type());
this->writeType(var.type());
this->write(" ");
this->writeName(var.name());
this->writeArrayDimensions(var.type());
this->write(";\n");
}
}
@ -1962,10 +1929,9 @@ void MetalCodeGenerator::writeInputStruct() {
if (var.modifiers().fFlags & Modifiers::kIn_Flag &&
-1 == var.modifiers().fLayout.fBuiltin) {
this->write(" ");
this->writeBaseType(var.type());
this->writeType(var.type());
this->write(" ");
this->writeName(var.name());
this->writeArrayDimensions(var.type());
if (-1 != var.modifiers().fLayout.fLocation) {
if (fProgram.fKind == Program::kVertex_Kind) {
this->write(" [[attribute(" +
@ -1996,10 +1962,9 @@ void MetalCodeGenerator::writeOutputStruct() {
if (var.modifiers().fFlags & Modifiers::kOut_Flag &&
-1 == var.modifiers().fLayout.fBuiltin) {
this->write(" ");
this->writeBaseType(var.type());
this->writeType(var.type());
this->write(" ");
this->writeName(var.name());
this->writeArrayDimensions(var.type());
int location = var.modifiers().fLayout.fLocation;
if (location < 0) {
@ -2088,10 +2053,9 @@ void MetalCodeGenerator::writeGlobalStruct() {
void visitTexture(const Type& type, const String& name) override {
this->addElement();
fCodeGen->write(" ");
fCodeGen->writeBaseType(type);
fCodeGen->writeType(type);
fCodeGen->write(" ");
fCodeGen->writeName(name);
fCodeGen->writeArrayDimensions(type);
fCodeGen->write(";\n");
}
void visitSampler(const Type&, const String& name) override {
@ -2103,10 +2067,9 @@ void MetalCodeGenerator::writeGlobalStruct() {
void visitVariable(const Variable& var, const Expression* value) override {
this->addElement();
fCodeGen->write(" ");
fCodeGen->writeBaseType(var.type());
fCodeGen->writeType(var.type());
fCodeGen->write(" ");
fCodeGen->writeName(var.name());
fCodeGen->writeArrayDimensions(var.type());
fCodeGen->write(";\n");
}
void addElement() {

View File

@ -172,11 +172,7 @@ protected:
void writeStructDefinition(const StructDefinition& s);
void disallowArrayTypes(const Type& type, int offset);
void writeBaseType(const Type& type);
void writeArrayDimensions(const Type& type);
void writeType(const Type& type);
void writeExtension(const Extension& ext);

View File

@ -105,13 +105,15 @@ static void test_gpu(skiatest::Reporter* r, GrDirectContext* ctx, const char* te
test_permutations(r, surface.get(), testFile);
}
#define SKSL_TEST(name, path) \
#define SKSL_TEST_CPU(name, path) \
DEF_TEST(name ## _CPU, r) { \
test_cpu(r, path); \
} \
}
#define SKSL_TEST_GPU(name, path) \
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name ## _GPU, r, ctxInfo) { \
test_gpu(r, ctxInfo.directContext(), path); \
}
#define SKSL_TEST(name, path) SKSL_TEST_CPU(name, path) SKSL_TEST_GPU(name, path)
SKSL_TEST(SkSLBoolFolding, "folding/BoolFolding.sksl")
SKSL_TEST(SkSLIntFoldingES2, "folding/IntFoldingES2.sksl")
@ -129,6 +131,8 @@ SKSL_TEST(SkSLIntrinsicMinFloat, "intrinsics/MinFloat.sksl")
SKSL_TEST(SkSLIntrinsicMixFloat, "intrinsics/MixFloat.sksl")
SKSL_TEST(SkSLIntrinsicSignFloat, "intrinsics/SignFloat.sksl")
SKSL_TEST(SkSLArrayTypes, "shared/ArrayTypes.sksl")
SKSL_TEST(SkSLAssignment, "shared/Assignment.sksl")
SKSL_TEST(SkSLCastsRoundTowardZero, "shared/CastsRoundTowardZero.sksl")
SKSL_TEST(SkSLCommaMixedTypes, "shared/CommaMixedTypes.sksl")
SKSL_TEST(SkSLCommaSideEffects, "shared/CommaSideEffects.sksl")
@ -172,6 +176,7 @@ SKSL_TEST(SkSLIntrinsicMinInt, "intrinsics/MinInt.sksl")
SKSL_TEST(SkSLIntrinsicMixBool, "intrinsics/MixBool.sksl")
SKSL_TEST(SkSLIntrinsicSignInt, "intrinsics/SignInt.sksl")
SKSL_TEST(SkSLArrayConstructors, "shared/ArrayConstructors.sksl")
SKSL_TEST(SkSLDeadLoopVariable, "shared/DeadLoopVariable.sksl")
SKSL_TEST(SkSLDoWhileControlFlow, "shared/DoWhileControlFlow.sksl")
SKSL_TEST(SkSLEmptyBlocksES3, "shared/EmptyBlocksES3.sksl")

View File

@ -1,22 +1,33 @@
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 %test1 "test1"
OpName %test2 "test2"
OpName %test3 "test3"
OpName %_UniformBuffer "_UniformBuffer"
OpMemberName %_UniformBuffer 0 "colorGreen"
OpMemberName %_UniformBuffer 1 "colorRed"
OpName %_entrypoint "_entrypoint"
OpName %main "main"
OpDecorate %sk_FragColor RelaxedPrecision
OpDecorate %sk_FragColor Location 0
OpDecorate %sk_FragColor Index 0
OpDecorate %sk_Clockwise RelaxedPrecision
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 %10 Binding 0
OpDecorate %10 DescriptorSet 0
OpDecorate %_arr_float_int_4 ArrayStride 16
OpDecorate %_arr_v2float_int_2 ArrayStride 16
OpDecorate %_arr_mat4v4float_int_1 ArrayStride 64
OpDecorate %74 RelaxedPrecision
OpDecorate %76 RelaxedPrecision
OpDecorate %77 RelaxedPrecision
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
@ -24,60 +35,86 @@ OpDecorate %_arr_mat4v4float_int_1 ArrayStride 64
%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
%10 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
%15 = OpTypeFunction %void
%18 = OpTypeFunction %v4float
%int = OpTypeInt 32 1
%int_4 = OpConstant %int 4
%_arr_float_int_4 = OpTypeArray %float %int_4
%_ptr_Private__arr_float_int_4 = OpTypePointer Private %_arr_float_int_4
%test1 = OpVariable %_ptr_Private__arr_float_int_4 Private
%_ptr_Function__arr_float_int_4 = OpTypePointer Function %_arr_float_int_4
%float_1 = OpConstant %float 1
%float_2 = OpConstant %float 2
%float_3 = OpConstant %float 3
%float_4 = OpConstant %float 4
%int_3 = OpConstant %int 3
%_ptr_Function_float = OpTypePointer Function %float
%v2float = OpTypeVector %float 2
%int_2 = OpConstant %int 2
%_arr_v2float_int_2 = OpTypeArray %v2float %int_2
%_ptr_Private__arr_v2float_int_2 = OpTypePointer Private %_arr_v2float_int_2
%test2 = OpVariable %_ptr_Private__arr_v2float_int_2 Private
%25 = OpConstantComposite %v2float %float_1 %float_2
%26 = OpConstantComposite %v2float %float_3 %float_4
%mat4v4float = OpTypeMatrix %v4float 4
%_ptr_Function__arr_v2float_int_2 = OpTypePointer Function %_arr_v2float_int_2
%39 = OpConstantComposite %v2float %float_1 %float_2
%40 = OpConstantComposite %v2float %float_3 %float_4
%int_1 = OpConstant %int 1
%_ptr_Function_v2float = OpTypePointer Function %v2float
%mat4v4float = OpTypeMatrix %v4float 4
%_arr_mat4v4float_int_1 = OpTypeArray %mat4v4float %int_1
%_ptr_Private__arr_mat4v4float_int_1 = OpTypePointer Private %_arr_mat4v4float_int_1
%test3 = OpVariable %_ptr_Private__arr_mat4v4float_int_1 Private
%_ptr_Function__arr_mat4v4float_int_1 = OpTypePointer Function %_arr_mat4v4float_int_1
%float_16 = OpConstant %float 16
%float_0 = OpConstant %float 0
%void = OpTypeVoid
%42 = OpTypeFunction %void
%int_0 = OpConstant %int 0
%_ptr_Private_float = OpTypePointer Private %float
%_ptr_Private_v2float = OpTypePointer Private %v2float
%_ptr_Private_v4float = OpTypePointer Private %v4float
%_ptr_Output_float = OpTypePointer Output %float
%main = OpFunction %void None %42
%43 = OpLabel
%19 = OpCompositeConstruct %_arr_float_int_4 %float_1 %float_2 %float_3 %float_4
OpStore %test1 %19
%27 = OpCompositeConstruct %_arr_v2float_int_2 %25 %26
OpStore %test2 %27
%36 = OpCompositeConstruct %v4float %float_16 %float_0 %float_0 %float_0
%37 = OpCompositeConstruct %v4float %float_0 %float_16 %float_0 %float_0
%38 = OpCompositeConstruct %v4float %float_0 %float_0 %float_16 %float_0
%39 = OpCompositeConstruct %v4float %float_0 %float_0 %float_0 %float_16
%34 = OpCompositeConstruct %mat4v4float %36 %37 %38 %39
%40 = OpCompositeConstruct %_arr_mat4v4float_int_1 %34
OpStore %test3 %40
%45 = OpAccessChain %_ptr_Private_float %test1 %int_0
%47 = OpLoad %float %45
%48 = OpAccessChain %_ptr_Private_v2float %test2 %int_0
%50 = OpLoad %v2float %48
%51 = OpCompositeExtract %float %50 0
%52 = OpFAdd %float %47 %51
%53 = OpAccessChain %_ptr_Private_v4float %test3 %int_0 %int_0
%55 = OpLoad %v4float %53
%56 = OpCompositeExtract %float %55 0
%57 = OpFAdd %float %52 %56
%58 = OpAccessChain %_ptr_Output_float %sk_FragColor %int_0
OpStore %58 %57
%_ptr_Function_v4float = OpTypePointer Function %v4float
%float_24 = OpConstant %float 24
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%_entrypoint = OpFunction %void None %15
%16 = OpLabel
%17 = OpFunctionCall %v4float %main
OpStore %sk_FragColor %17
OpReturn
OpFunctionEnd
%main = OpFunction %v4float None %18
%19 = OpLabel
%20 = OpVariable %_ptr_Function__arr_float_int_4 Function
%34 = OpVariable %_ptr_Function__arr_v2float_int_2 Function
%48 = OpVariable %_ptr_Function__arr_mat4v4float_int_1 Function
%68 = OpVariable %_ptr_Function_v4float Function
%29 = OpCompositeConstruct %_arr_float_int_4 %float_1 %float_2 %float_3 %float_4
OpStore %20 %29
%31 = OpAccessChain %_ptr_Function_float %20 %int_3
%33 = OpLoad %float %31
%41 = OpCompositeConstruct %_arr_v2float_int_2 %39 %40
OpStore %34 %41
%43 = OpAccessChain %_ptr_Function_v2float %34 %int_1
%45 = OpLoad %v2float %43
%46 = OpCompositeExtract %float %45 1
%47 = OpFAdd %float %33 %46
%55 = OpCompositeConstruct %v4float %float_16 %float_0 %float_0 %float_0
%56 = OpCompositeConstruct %v4float %float_0 %float_16 %float_0 %float_0
%57 = OpCompositeConstruct %v4float %float_0 %float_0 %float_16 %float_0
%58 = OpCompositeConstruct %v4float %float_0 %float_0 %float_0 %float_16
%53 = OpCompositeConstruct %mat4v4float %55 %56 %57 %58
%59 = OpCompositeConstruct %_arr_mat4v4float_int_1 %53
OpStore %48 %59
%61 = OpAccessChain %_ptr_Function_v4float %48 %int_0 %int_3
%63 = OpLoad %v4float %61
%64 = OpCompositeExtract %float %63 3
%65 = OpFAdd %float %47 %64
%67 = OpFOrdEqual %bool %65 %float_24
OpSelectionMerge %71 None
OpBranchConditional %67 %69 %70
%69 = OpLabel
%72 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
%74 = OpLoad %v4float %72
OpStore %68 %74
OpBranch %71
%70 = OpLabel
%75 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
%76 = OpLoad %v4float %75
OpStore %68 %76
OpBranch %71
%71 = OpLabel
%77 = OpLoad %v4float %68
OpReturnValue %77
OpFunctionEnd

View File

@ -1,8 +1,7 @@
out vec4 sk_FragColor;
float test1[4] = float[4](1.0, 2.0, 3.0, 4.0);
vec2 test2[2] = vec2[2](vec2(1.0, 2.0), vec2(3.0, 4.0));
mat4 test3[1] = mat4[1](mat4(16.0));
void main() {
sk_FragColor.x = (test1[0] + test2[0].x) + test3[0][0].x;
uniform vec4 colorGreen;
uniform vec4 colorRed;
vec4 main() {
return (float[4](1.0, 2.0, 3.0, 4.0)[3] + vec2[2](vec2(1.0, 2.0), vec2(3.0, 4.0))[1].y) + mat4[1](mat4(16.0))[0][3].w == 24.0 ? colorGreen : colorRed;
}

View File

@ -1,6 +1,20 @@
### Compilation failed:
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Uniforms {
float4 colorGreen;
float4 colorRed;
};
struct Inputs {
};
struct Outputs {
float4 sk_FragColor [[color(0)]];
};
error: 1: Metal does not support array types in this context
error: 2: Metal does not support array types in this context
error: 3: Metal does not support array types in this context
3 errors
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 = (array<float, 4>{1.0, 2.0, 3.0, 4.0}[3] + array<float2, 2>{float2(1.0, 2.0), float2(3.0, 4.0)}[1].y) + array<float4x4, 1>{float4x4(16.0)}[0][3].w == 24.0 ? _uniforms.colorGreen : _uniforms.colorRed;
return _out;
}

View File

@ -1,7 +1,14 @@
### Compilation failed:
error: 2: Metal does not support array types in this context
error: 2: Metal does not support array types in this context
error: 2: Metal does not support array types in this context
error: 2: Metal does not support array types in this context
4 errors
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Inputs {
};
struct Outputs {
float4 sk_FragColor [[color(0)]];
};
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
_out.sk_FragColor = float4(array<float, 4>{1.0, 2.0, 3.0, 4.0}[0], array<float, 4>{1.0, 2.0, 3.0, 4.0}[1u], array<float, 4>{1.0, 2.0, 3.0, 4.0}[2], array<float, 4>{1.0, 2.0, 3.0, 4.0}[3u]);
return _out;
}

View File

@ -1,11 +1,14 @@
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 %x "x"
OpName %y "y"
OpDecorate %sk_FragColor RelaxedPrecision
OpDecorate %sk_FragColor Location 0
OpDecorate %sk_FragColor Index 0
@ -20,40 +23,70 @@ OpDecorate %_arr_v2float_int_2 ArrayStride 16
%_ptr_Input_bool = OpTypePointer Input %bool
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
%void = OpTypeVoid
%11 = OpTypeFunction %void
%12 = OpTypeFunction %void
%15 = OpTypeFunction %v4float
%v2float = OpTypeVector %float 2
%int = OpTypeInt 32 1
%int_2 = OpConstant %int 2
%_arr_v2float_int_2 = OpTypeArray %v2float %int_2
%_ptr_Function__arr_v2float_int_2 = OpTypePointer Function %_arr_v2float_int_2
%float_1 = OpConstant %float 1
%20 = OpConstantComposite %v2float %float_1 %float_1
%float_2 = OpConstant %float 2
%22 = OpConstantComposite %v2float %float_2 %float_2
%float_0 = OpConstant %float 0
%24 = OpConstantComposite %v2float %float_0 %float_0
%int_0 = OpConstant %int 0
%_ptr_Function_v2float = OpTypePointer Function %v2float
%float_3 = OpConstant %float 3
%32 = OpConstantComposite %v2float %float_3 %float_3
%float_4 = OpConstant %float 4
%34 = OpConstantComposite %v2float %float_4 %float_4
%float_1 = OpConstant %float 1
%29 = OpConstantComposite %v2float %float_1 %float_0
%int_1 = OpConstant %int 1
%main = OpFunction %void None %11
%12 = OpLabel
%13 = OpVariable %_ptr_Function__arr_v2float_int_2 Function
%30 = OpVariable %_ptr_Function__arr_v2float_int_2 Function
%23 = OpCompositeConstruct %_arr_v2float_int_2 %20 %22
OpStore %13 %23
%25 = OpAccessChain %_ptr_Function_v2float %13 %int_0
%27 = OpLoad %v2float %25
%28 = OpCompositeExtract %float %27 0
%29 = OpCompositeExtract %float %27 1
%35 = OpCompositeConstruct %_arr_v2float_int_2 %32 %34
OpStore %30 %35
%37 = OpAccessChain %_ptr_Function_v2float %30 %int_1
%38 = OpLoad %v2float %37
%39 = OpCompositeExtract %float %38 0
%40 = OpCompositeExtract %float %38 1
%41 = OpCompositeConstruct %v4float %28 %29 %39 %40
OpStore %sk_FragColor %41
%33 = OpConstantComposite %v2float %float_0 %float_1
%float_n1 = OpConstant %float -1
%float_2 = OpConstant %float 2
%37 = OpConstantComposite %v2float %float_n1 %float_2
%_entrypoint = OpFunction %void None %12
%13 = OpLabel
%14 = OpFunctionCall %v4float %main
OpStore %sk_FragColor %14
OpReturn
OpFunctionEnd
%main = OpFunction %v4float None %15
%16 = OpLabel
%x = OpVariable %_ptr_Function__arr_v2float_int_2 Function
%y = OpVariable %_ptr_Function__arr_v2float_int_2 Function
%26 = OpAccessChain %_ptr_Function_v2float %x %int_0
OpStore %26 %24
%31 = OpAccessChain %_ptr_Function_v2float %x %int_1
OpStore %31 %29
%34 = OpAccessChain %_ptr_Function_v2float %y %int_0
OpStore %34 %33
%38 = OpAccessChain %_ptr_Function_v2float %y %int_1
OpStore %38 %37
%39 = OpAccessChain %_ptr_Function_v2float %x %int_0
%40 = OpLoad %v2float %39
%41 = OpCompositeExtract %float %40 0
%42 = OpAccessChain %_ptr_Function_v2float %x %int_0
%43 = OpLoad %v2float %42
%44 = OpCompositeExtract %float %43 1
%45 = OpFMul %float %41 %44
%46 = OpAccessChain %_ptr_Function_v2float %x %int_1
%47 = OpLoad %v2float %46
%48 = OpCompositeExtract %float %47 0
%49 = OpAccessChain %_ptr_Function_v2float %x %int_1
%50 = OpLoad %v2float %49
%51 = OpCompositeExtract %float %50 1
%52 = OpFSub %float %48 %51
%53 = OpAccessChain %_ptr_Function_v2float %y %int_0
%54 = OpLoad %v2float %53
%55 = OpCompositeExtract %float %54 0
%56 = OpAccessChain %_ptr_Function_v2float %y %int_0
%57 = OpLoad %v2float %56
%58 = OpCompositeExtract %float %57 1
%59 = OpFDiv %float %55 %58
%60 = OpAccessChain %_ptr_Function_v2float %y %int_1
%61 = OpLoad %v2float %60
%62 = OpCompositeExtract %float %61 0
%63 = OpAccessChain %_ptr_Function_v2float %y %int_1
%64 = OpLoad %v2float %63
%65 = OpCompositeExtract %float %64 1
%66 = OpFAdd %float %62 %65
%67 = OpCompositeConstruct %v4float %45 %52 %59 %66
OpReturnValue %67
OpFunctionEnd

View File

@ -1,5 +1,11 @@
out vec4 sk_FragColor;
void main() {
sk_FragColor = vec4(vec2[2](vec2(1.0), vec2(2.0))[0], vec2[2](vec2(3.0), vec2(4.0))[1]);
vec4 main() {
vec2 x[2];
x[0] = vec2(0.0, 0.0);
x[1] = vec2(1.0, 0.0);
vec2 y[2];
y[0] = vec2(0.0, 1.0);
y[1] = vec2(-1.0, 2.0);
return vec4(x[0].x * x[0].y, x[1].x - x[1].y, y[0].x / y[0].y, y[1].x + y[1].y);
}

View File

@ -1,5 +1,20 @@
### Compilation failed:
error: 2: Metal does not support array types in this context
error: 3: Metal does not support array types in this context
2 errors
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Inputs {
};
struct Outputs {
float4 sk_FragColor [[color(0)]];
};
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
array<float2, 2> x;
x[0] = float2(0.0, 0.0);
x[1] = float2(1.0, 0.0);
array<float2, 2> y;
y[0] = float2(0.0, 1.0);
y[1] = float2(-1.0, 2.0);
_out.sk_FragColor = float4(x[0].x * x[0].y, x[1].x - x[1].y, y[0].x / y[0].y, y[1].x + y[1].y);
return _out;
}

View File

@ -1,49 +1,43 @@
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 "colorGreen"
OpName %_entrypoint "_entrypoint"
OpName %main "main"
OpName %i4 "i4"
OpName %x "x"
OpName %ai "ai"
OpName %ai4 "ai4"
OpName %ah2x4 "ah2x4"
OpName %af4 "af4"
OpName %S "S"
OpMemberName %S 0 "f"
OpMemberName %S 1 "af"
OpMemberName %S 2 "h4"
OpMemberName %S 3 "ah4"
OpName %s "s"
OpDecorate %sk_FragColor RelaxedPrecision
OpDecorate %sk_FragColor Location 0
OpDecorate %sk_FragColor Index 0
OpDecorate %sk_Clockwise RelaxedPrecision
OpDecorate %sk_Clockwise BuiltIn FrontFacing
OpDecorate %23 RelaxedPrecision
OpMemberDecorate %_UniformBuffer 0 Offset 0
OpMemberDecorate %_UniformBuffer 0 RelaxedPrecision
OpDecorate %_UniformBuffer Block
OpDecorate %10 Binding 0
OpDecorate %10 DescriptorSet 0
OpDecorate %37 RelaxedPrecision
OpDecorate %_arr_int_int_1 ArrayStride 16
OpDecorate %_arr_v4int_int_1 ArrayStride 16
OpDecorate %_arr_mat2v4float_int_1 ArrayStride 32
OpDecorate %53 RelaxedPrecision
OpDecorate %54 RelaxedPrecision
OpDecorate %52 RelaxedPrecision
OpDecorate %_arr_mat3v3float_int_1 ArrayStride 48
OpDecorate %63 RelaxedPrecision
OpDecorate %64 RelaxedPrecision
OpDecorate %65 RelaxedPrecision
OpDecorate %62 RelaxedPrecision
OpDecorate %_arr_v4float_int_1 ArrayStride 16
OpDecorate %_arr_float_int_5 ArrayStride 16
OpDecorate %_arr_v4float_int_5 ArrayStride 16
OpMemberDecorate %S 0 Offset 0
OpMemberDecorate %S 1 Offset 16
OpMemberDecorate %S 2 Offset 96
OpMemberDecorate %S 2 RelaxedPrecision
OpMemberDecorate %S 3 Offset 112
OpMemberDecorate %S 3 RelaxedPrecision
OpDecorate %83 RelaxedPrecision
OpDecorate %87 RelaxedPrecision
OpDecorate %114 RelaxedPrecision
OpDecorate %131 RelaxedPrecision
OpDecorate %141 RelaxedPrecision
OpDecorate %143 RelaxedPrecision
OpDecorate %81 RelaxedPrecision
OpDecorate %82 RelaxedPrecision
OpDecorate %85 RelaxedPrecision
OpDecorate %89 RelaxedPrecision
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
@ -51,30 +45,35 @@ OpDecorate %143 RelaxedPrecision
%bool = OpTypeBool
%_ptr_Input_bool = OpTypePointer Input %bool
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
%_UniformBuffer = OpTypeStruct %v4float
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
%10 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
%11 = OpTypeFunction %void
%15 = OpTypeFunction %void
%18 = OpTypeFunction %v4float
%int = OpTypeInt 32 1
%v4int = OpTypeVector %int 4
%_ptr_Function_v4int = OpTypePointer Function %v4int
%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
%int_3 = OpConstant %int 3
%int_4 = OpConstant %int 4
%28 = OpConstantComposite %v4int %int_1 %int_2 %int_3 %int_4
%_ptr_Function_v4float = OpTypePointer Function %v4float
%float_0 = OpConstant %float 0
%_ptr_Function_float = OpTypePointer Function %float
%int = OpTypeInt 32 1
%int_3 = OpConstant %int 3
%v2float = OpTypeVector %float 2
%21 = OpConstantComposite %v2float %float_0 %float_0
%int_1 = OpConstant %int 1
%35 = OpConstantComposite %v2float %float_0 %float_0
%_arr_int_int_1 = OpTypeArray %int %int_1
%_ptr_Function__arr_int_int_1 = OpTypePointer Function %_arr_int_int_1
%int_0 = OpConstant %int 0
%_ptr_Function_int = OpTypePointer Function %int
%v4int = OpTypeVector %int 4
%_arr_v4int_int_1 = OpTypeArray %v4int %int_1
%_ptr_Function__arr_v4int_int_1 = OpTypePointer Function %_arr_v4int_int_1
%int_2 = OpConstant %int 2
%int_4 = OpConstant %int 4
%37 = OpConstantComposite %v4int %int_1 %int_2 %int_3 %int_4
%_ptr_Function_v4int = OpTypePointer Function %v4int
%mat2v4float = OpTypeMatrix %v4float 2
%_arr_mat2v4float_int_1 = OpTypeArray %mat2v4float %int_1
%_ptr_Function__arr_mat2v4float_int_1 = OpTypePointer Function %_arr_mat2v4float_int_1
%v3float = OpTypeVector %float 3
%mat3v3float = OpTypeMatrix %v3float 3
%_arr_mat3v3float_int_1 = OpTypeArray %mat3v3float %int_1
%_ptr_Function__arr_mat3v3float_int_1 = OpTypePointer Function %_arr_mat3v3float_int_1
%float_1 = OpConstant %float 1
%float_2 = OpConstant %float 2
%float_3 = OpConstant %float 3
@ -83,139 +82,62 @@ OpDecorate %143 RelaxedPrecision
%float_6 = OpConstant %float 6
%float_7 = OpConstant %float 7
%float_8 = OpConstant %float 8
%_ptr_Function_mat2v4float = OpTypePointer Function %mat2v4float
%float_9 = OpConstant %float 9
%_ptr_Function_mat3v3float = OpTypePointer Function %mat3v3float
%_arr_v4float_int_1 = OpTypeArray %v4float %int_1
%_ptr_Function__arr_v4float_int_1 = OpTypePointer Function %_arr_v4float_int_1
%66 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%int_5 = OpConstant %int 5
%_arr_float_int_5 = OpTypeArray %float %int_5
%_arr_v4float_int_5 = OpTypeArray %v4float %int_5
%S = OpTypeStruct %float %_arr_float_int_5 %v4float %_arr_v4float_int_5
%_ptr_Function_S = OpTypePointer Function %S
%v3float = OpTypeVector %float 3
%float_9 = OpConstant %float 9
%80 = OpConstantComposite %v3float %float_9 %float_9 %float_9
%84 = OpConstantComposite %v2float %float_5 %float_5
%91 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%93 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
%mat3v3float = OpTypeMatrix %v3float 3
%_ptr_Function_mat3v3float = OpTypePointer Function %mat3v3float
%_ptr_Function_v3float = OpTypePointer Function %v3float
%main = OpFunction %void None %11
%12 = OpLabel
%73 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%_entrypoint = OpFunction %void None %15
%16 = OpLabel
%17 = OpFunctionCall %v4float %main
OpStore %sk_FragColor %17
OpReturn
OpFunctionEnd
%main = OpFunction %v4float None %18
%19 = OpLabel
%i4 = OpVariable %_ptr_Function_v4int Function
%x = OpVariable %_ptr_Function_v4float Function
%ai = OpVariable %_ptr_Function__arr_int_int_1 Function
%ai4 = OpVariable %_ptr_Function__arr_v4int_int_1 Function
%ah2x4 = OpVariable %_ptr_Function__arr_mat2v4float_int_1 Function
%ah2x4 = OpVariable %_ptr_Function__arr_mat3v3float_int_1 Function
%af4 = OpVariable %_ptr_Function__arr_v4float_int_1 Function
%s = OpVariable %_ptr_Function_S Function
%103 = OpVariable %_ptr_Function_mat3v3float Function
%16 = OpAccessChain %_ptr_Function_float %x %int_3
OpStore %16 %float_0
%22 = OpLoad %v4float %x
%23 = OpVectorShuffle %v4float %22 %21 5 4 2 3
OpStore %x %23
%29 = OpAccessChain %_ptr_Function_int %ai %int_0
OpStore %29 %int_0
%38 = OpAccessChain %_ptr_Function_v4int %ai4 %int_0
OpStore %38 %37
%53 = OpCompositeConstruct %v4float %float_1 %float_2 %float_3 %float_4
%54 = OpCompositeConstruct %v4float %float_5 %float_6 %float_7 %float_8
%52 = OpCompositeConstruct %mat2v4float %53 %54
%55 = OpAccessChain %_ptr_Function_mat2v4float %ah2x4 %int_0
OpStore %55 %52
%57 = OpAccessChain %_ptr_Function_int %ai %int_0
OpStore %57 %int_0
%58 = OpAccessChain %_ptr_Function_int %ai %int_0
%59 = OpLoad %int %58
%60 = OpAccessChain %_ptr_Function_int %ai %59
OpStore %60 %int_0
%64 = OpAccessChain %_ptr_Function_v4float %af4 %int_0
%65 = OpAccessChain %_ptr_Function_float %64 %int_0
OpStore %65 %float_0
%67 = OpAccessChain %_ptr_Function_v4float %af4 %int_0
%68 = OpLoad %v4float %67
%69 = OpVectorShuffle %v4float %68 %66 6 4 7 5
OpStore %67 %69
%76 = OpAccessChain %_ptr_Function_float %s %int_0
OpStore %76 %float_0
%77 = OpAccessChain %_ptr_Function_float %s %int_1 %int_1
OpStore %77 %float_0
%81 = OpAccessChain %_ptr_Function_v4float %s %int_2
%82 = OpLoad %v4float %81
%83 = OpVectorShuffle %v4float %82 %80 5 6 4 3
OpStore %81 %83
%85 = OpAccessChain %_ptr_Function_v4float %s %int_3 %int_2
%86 = OpLoad %v4float %85
%87 = OpVectorShuffle %v4float %86 %84 0 4 2 5
OpStore %85 %87
%88 = OpAccessChain %_ptr_Function_float %s %int_0
OpStore %88 %float_1
%89 = OpAccessChain %_ptr_Function_float %s %int_1 %int_0
OpStore %89 %float_2
%90 = OpAccessChain %_ptr_Function_v4float %s %int_2
OpStore %90 %66
%92 = OpAccessChain %_ptr_Function_v4float %s %int_3 %int_0
OpStore %92 %91
OpStore %sk_FragColor %93
%94 = OpCompositeExtract %int %37 0
%95 = OpConvertSToF %float %94
%96 = OpCompositeExtract %int %37 1
%97 = OpConvertSToF %float %96
%98 = OpCompositeExtract %int %37 2
%99 = OpConvertSToF %float %98
%100 = OpCompositeExtract %int %37 3
%101 = OpConvertSToF %float %100
%102 = OpCompositeConstruct %v4float %95 %97 %99 %101
OpStore %sk_FragColor %102
%107 = OpCompositeConstruct %v3float %float_1 %float_2 %float_3
%108 = OpCompositeConstruct %v3float %float_4 %float_5 %float_6
%109 = OpCompositeConstruct %v3float %float_7 %float_8 %float_9
%106 = OpCompositeConstruct %mat3v3float %107 %108 %109
OpStore %103 %106
%110 = OpAccessChain %_ptr_Function_v3float %103 %int_0
%112 = OpLoad %v3float %110
%113 = OpVectorShuffle %v4float %112 %112 0 0 1 2
OpStore %sk_FragColor %113
%114 = OpLoad %v4float %x
OpStore %sk_FragColor %114
%115 = OpAccessChain %_ptr_Function_int %ai %int_0
%116 = OpLoad %int %115
%117 = OpConvertSToF %float %116
%118 = OpCompositeConstruct %v4float %117 %117 %117 %117
OpStore %sk_FragColor %118
%119 = OpAccessChain %_ptr_Function_v4int %ai4 %int_0
%120 = OpLoad %v4int %119
%121 = OpCompositeExtract %int %120 0
%122 = OpConvertSToF %float %121
%123 = OpCompositeExtract %int %120 1
%124 = OpConvertSToF %float %123
%125 = OpCompositeExtract %int %120 2
%126 = OpConvertSToF %float %125
%127 = OpCompositeExtract %int %120 3
%128 = OpConvertSToF %float %127
%129 = OpCompositeConstruct %v4float %122 %124 %126 %128
OpStore %sk_FragColor %129
%130 = OpAccessChain %_ptr_Function_v4float %ah2x4 %int_0 %int_0
%131 = OpLoad %v4float %130
OpStore %sk_FragColor %131
%132 = OpAccessChain %_ptr_Function_v4float %af4 %int_0
%133 = OpLoad %v4float %132
OpStore %sk_FragColor %133
OpStore %sk_FragColor %93
%134 = OpAccessChain %_ptr_Function_float %s %int_0
%135 = OpLoad %float %134
%136 = OpCompositeConstruct %v4float %135 %135 %135 %135
OpStore %sk_FragColor %136
%137 = OpAccessChain %_ptr_Function_float %s %int_1 %int_1
%138 = OpLoad %float %137
%139 = OpCompositeConstruct %v4float %138 %138 %138 %138
OpStore %sk_FragColor %139
%140 = OpAccessChain %_ptr_Function_v4float %s %int_2
%141 = OpLoad %v4float %140
OpStore %sk_FragColor %141
%142 = OpAccessChain %_ptr_Function_v4float %s %int_3 %int_0
%143 = OpLoad %v4float %142
OpStore %sk_FragColor %143
OpReturn
OpStore %i4 %28
%32 = OpAccessChain %_ptr_Function_float %x %int_3
OpStore %32 %float_0
%36 = OpLoad %v4float %x
%37 = OpVectorShuffle %v4float %36 %35 5 4 2 3
OpStore %x %37
%42 = OpAccessChain %_ptr_Function_int %ai %int_0
OpStore %42 %int_0
%47 = OpAccessChain %_ptr_Function_v4int %ai4 %int_0
OpStore %47 %28
%63 = OpCompositeConstruct %v3float %float_1 %float_2 %float_3
%64 = OpCompositeConstruct %v3float %float_4 %float_5 %float_6
%65 = OpCompositeConstruct %v3float %float_7 %float_8 %float_9
%62 = OpCompositeConstruct %mat3v3float %63 %64 %65
%66 = OpAccessChain %_ptr_Function_mat3v3float %ah2x4 %int_0
OpStore %66 %62
%71 = OpAccessChain %_ptr_Function_v4float %af4 %int_0
%72 = OpAccessChain %_ptr_Function_float %71 %int_0
OpStore %72 %float_0
%74 = OpAccessChain %_ptr_Function_v4float %af4 %int_0
%75 = OpLoad %v4float %74
%76 = OpVectorShuffle %v4float %75 %73 6 4 7 5
OpStore %74 %76
%77 = OpAccessChain %_ptr_Function_int %i4 %int_1
%78 = OpLoad %int %77
%79 = OpIMul %int %78 %int_0
OpStore %77 %79
%80 = OpAccessChain %_ptr_Function_float %x %int_1
%81 = OpLoad %float %80
%82 = OpFMul %float %81 %float_0
OpStore %80 %82
%83 = OpLoad %_arr_int_int_1 %ai
%84 = OpLoad %_arr_v4int_int_1 %ai4
%85 = OpLoad %_arr_mat3v3float_int_1 %ah2x4
%86 = OpLoad %_arr_v4float_int_1 %af4
%87 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
%89 = OpLoad %v4float %87
OpReturnValue %89
OpFunctionEnd

View File

@ -1,12 +1,9 @@
out vec4 sk_FragColor;
struct S {
float f;
float[5] af;
vec4 h4;
vec4[5] ah4;
};
void main() {
uniform vec4 colorGreen;
vec4 main() {
ivec4 i4;
i4 = ivec4(1, 2, 3, 4);
vec4 x;
x.w = 0.0;
x.yx = vec2(0.0);
@ -14,33 +11,12 @@ void main() {
ai[0] = 0;
ivec4 ai4[1];
ai4[0] = ivec4(1, 2, 3, 4);
mat2x4 ah2x4[1];
ah2x4[0] = mat2x4(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);
ai[0] = 0;
ai[ai[0]] = 0;
mat3 ah2x4[1];
ah2x4[0] = mat3(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
vec4 af4[1];
af4[0].x = 0.0;
af4[0].ywxz = vec4(1.0);
S s;
s.f = 0.0;
s.af[1] = 0.0;
s.h4.zxy = vec3(9.0);
s.ah4[2].yw = vec2(5.0);
s.f = 1.0;
s.af[0] = 2.0;
s.h4 = vec4(1.0);
s.ah4[0] = vec4(2.0);
sk_FragColor = vec4(0.0);
sk_FragColor = vec4(ivec4(1, 2, 3, 4));
sk_FragColor = mat3(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)[0].xxyz;
sk_FragColor = x;
sk_FragColor = vec4(float(ai[0]));
sk_FragColor = vec4(ai4[0]);
sk_FragColor = ah2x4[0][0];
sk_FragColor = af4[0];
sk_FragColor = vec4(0.0);
sk_FragColor = vec4(s.f);
sk_FragColor = vec4(s.af[1]);
sk_FragColor = s.h4;
sk_FragColor = s.ah4[0];
i4.y *= 0;
x.y *= 0.0;
return ((((ai , ai4) , ah2x4) , af4) , colorGreen);
}

View File

@ -1,55 +1,34 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct S {
float f;
float af[5];
float4 h4;
float4 ah4[5];
struct Uniforms {
float4 colorGreen;
};
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;
int4 i4;
i4 = int4(1, 2, 3, 4);
float4 x;
x.w = 0.0;
x.yx = float2(0.0);
int ai[1];
array<int, 1> ai;
ai[0] = 0;
int4 ai4[1];
array<int4, 1> ai4;
ai4[0] = int4(1, 2, 3, 4);
float2x4 ah2x4[1];
ah2x4[0] = float2x4(float4(1.0, 2.0, 3.0, 4.0), float4(5.0, 6.0, 7.0, 8.0));
ai[0] = 0;
ai[ai[0]] = 0;
float4 af4[1];
array<float3x3, 1> ah2x4;
ah2x4[0] = float3x3(float3(1.0, 2.0, 3.0), float3(4.0, 5.0, 6.0), float3(7.0, 8.0, 9.0));
array<float4, 1> af4;
af4[0].x = 0.0;
af4[0].ywxz = float4(1.0);
S s;
s.f = 0.0;
s.af[1] = 0.0;
s.h4.zxy = float3(9.0);
s.ah4[2].yw = float2(5.0);
s.f = 1.0;
s.af[0] = 2.0;
s.h4 = float4(1.0);
s.ah4[0] = float4(2.0);
_out.sk_FragColor = float4(0.0);
_out.sk_FragColor = float4(int4(1, 2, 3, 4));
_out.sk_FragColor = float3x3(float3(1.0, 2.0, 3.0), float3(4.0, 5.0, 6.0), float3(7.0, 8.0, 9.0))[0].xxyz;
_out.sk_FragColor = x;
_out.sk_FragColor = float4(float(ai[0]));
_out.sk_FragColor = float4(ai4[0]);
_out.sk_FragColor = ah2x4[0][0];
_out.sk_FragColor = af4[0];
_out.sk_FragColor = float4(0.0);
_out.sk_FragColor = float4(s.f);
_out.sk_FragColor = float4(s.af[1]);
_out.sk_FragColor = s.h4;
_out.sk_FragColor = s.ah4[0];
i4.y = i4.y * 0;
x.y = x.y * 0.0;
_out.sk_FragColor = ((((ai , ai4) , ah2x4) , af4) , _uniforms.colorGreen);
return _out;
}

View File

@ -1,4 +1,15 @@
### Compilation failed:
error: 1: Metal does not support array types in this context
1 error
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Inputs {
};
struct Outputs {
float4 sk_FragColor [[color(0)]];
};
constant array<float, 4> test = array<float, 4>{1.0, 2.0, 3.0, 4.0};
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
_out.sk_FragColor = float4(_globals.test[0], _globals.test[1], _globals.test[2], _globals.test[3]);
return _out;
}

View File

@ -22,7 +22,7 @@ float foo(float2 v) {
return v.x * v.y;
}
void bar(thread float& x) {
float y[2];
array<float, 2> y;
y[0] = x;
y[1] = x * 2.0;
x = foo(float2(y[0], y[1]));

View File

@ -11,7 +11,7 @@ struct uniformBuffer {
float4 sk_RTAdjust;
float2 uIncrement_Stage1_c0;
char pad0[8];
float4 uKernel_Stage1_c0[7];
array<float4, 7> uKernel_Stage1_c0;
float3x3 umatrix_Stage1_c0_c0;
float4 uborder_Stage1_c0_c0_c0;
float4 usubset_Stage1_c0_c0_c0;

View File

@ -12,7 +12,7 @@ struct testBlock {
struct Globals {
constant testBlock* test;
};
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant testBlock& test [[buffer(123)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant array<testBlock, 2>& test [[buffer(123)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Globals _globals{&test};
(void)_globals;
Outputs _out;

View File

@ -26,32 +26,32 @@ struct S8 {
S7 x;
};
struct SA1 {
int x[8];
array<int, 8> x;
};
struct SA2 {
SA1 x[7];
array<SA1, 7> x;
};
struct SA3 {
SA2 x[6];
array<SA2, 6> x;
};
struct SA4 {
SA3 x[5];
array<SA3, 5> x;
};
struct SA5 {
SA4 x[4];
array<SA4, 4> x;
};
struct SA6 {
SA5 x[3];
array<SA5, 3> x;
};
struct SA7 {
SA6 x[2];
array<SA6, 2> x;
};
struct SA8 {
SA7 x[1];
array<SA7, 1> x;
};
struct Inputs {
S8 s8;
SA8 sa8[9];
array<SA8, 9> sa8;
};
struct Outputs {
float4 sk_FragColor [[color(0)]];

View File

@ -7,7 +7,7 @@ struct A {
};
struct B {
float x;
float y[2];
array<float, 2> y;
A z;
};
struct Inputs {

View File

@ -2,7 +2,7 @@
#include <simd/simd.h>
using namespace metal;
struct Uniforms {
float arr[3];
array<float, 3> arr;
};
struct Inputs {
};

View File

@ -10,7 +10,7 @@ struct testBlock {
float x;
int w;
char pad0[8];
float y[2];
array<float, 2> y;
char pad1[24];
float3x3 z;
};