Re-allow dynamic indexing of 'let' arrays and matrices
Spec change: https://github.com/gpuweb/gpuweb/pull/2427 Reverses: tint:867 This reverts and fixes commits:b6fdcc54df
10442eff7d
Added a bunch of end-to-end tests. Fixed: tint:1352 Change-Id: I34968243bbec1cab838c8ba50a6f027146bbfd06 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75401 Reviewed-by: David Neto <dneto@google.com> Reviewed-by: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
294ce9394f
commit
3cbb136b8a
|
@ -13,6 +13,7 @@ The following features have been deprecated and will be removed in M102:
|
|||
|
||||
* Vector and matrix element type can now be inferred from constructor argument types. [tint:1334](https://crbug.com/tint/1334)
|
||||
* Added builtins `degrees()` and `radians()` for converting between degrees and radians. [tint:1329](https://crbug.com/tint/1329)
|
||||
* `let` arrays and matrices can now be dynamically indexed. [tint:1352](https://crbug.com/tint/1352)
|
||||
|
||||
## Changes for M98
|
||||
|
||||
|
|
|
@ -483,6 +483,8 @@ libtint_source_set("libtint_core_all_src") {
|
|||
"transform/transform.h",
|
||||
"transform/unshadow.cc",
|
||||
"transform/unshadow.h",
|
||||
"transform/var_for_dynamic_index.cc",
|
||||
"transform/var_for_dynamic_index.h",
|
||||
"transform/vectorize_scalar_matrix_constructors.cc",
|
||||
"transform/vectorize_scalar_matrix_constructors.h",
|
||||
"transform/vertex_pulling.cc",
|
||||
|
|
|
@ -350,6 +350,8 @@ set(TINT_LIB_SRCS
|
|||
transform/unshadow.h
|
||||
transform/vectorize_scalar_matrix_constructors.cc
|
||||
transform/vectorize_scalar_matrix_constructors.h
|
||||
transform/var_for_dynamic_index.cc
|
||||
transform/var_for_dynamic_index.h
|
||||
transform/vertex_pulling.cc
|
||||
transform/vertex_pulling.h
|
||||
transform/wrap_arrays_in_structs.cc
|
||||
|
@ -987,6 +989,7 @@ if(${TINT_BUILD_TESTS})
|
|||
transform/single_entry_point_test.cc
|
||||
transform/test_helper.h
|
||||
transform/unshadow_test.cc
|
||||
transform/var_for_dynamic_index_test.cc
|
||||
transform/vectorize_scalar_matrix_constructors_test.cc
|
||||
transform/vertex_pulling_test.cc
|
||||
transform/wrap_arrays_in_structs_test.cc
|
||||
|
|
|
@ -45,6 +45,7 @@ std::string CommonTypes() {
|
|||
|
||||
%uint_10 = OpConstant %uint 10
|
||||
%uint_20 = OpConstant %uint 20
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%uint_3 = OpConstant %uint 3
|
||||
%uint_4 = OpConstant %uint 4
|
||||
%uint_5 = OpConstant %uint 5
|
||||
|
@ -220,8 +221,9 @@ TEST_F(SpvParserTest_CompositeExtract, Vector_IndexTooBigError) {
|
|||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
auto fe = p->function_emitter(100);
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(), Eq("OpCompositeExtract %1 index value 900 is out of "
|
||||
"bounds for vector of 2 elements"));
|
||||
EXPECT_EQ(p->error(),
|
||||
"OpCompositeExtract %1 index value 900 is out of bounds for vector "
|
||||
"of 2 elements");
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest_CompositeExtract, Matrix) {
|
||||
|
@ -261,8 +263,9 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_IndexTooBigError) {
|
|||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
auto fe = p->function_emitter(100);
|
||||
EXPECT_FALSE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(p->error(), Eq("OpCompositeExtract %2 index value 3 is out of "
|
||||
"bounds for matrix of 3 elements"));
|
||||
EXPECT_EQ(p->error(),
|
||||
"OpCompositeExtract %2 index value 3 is out of bounds for matrix "
|
||||
"of 3 elements");
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest_CompositeExtract, Matrix_Vector) {
|
||||
|
@ -411,8 +414,9 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_IndexTooBigError) {
|
|||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
auto fe = p->function_emitter(100);
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(), Eq("OpCompositeExtract %2 index value 40 is out of "
|
||||
"bounds for structure %26 having 3 members"));
|
||||
EXPECT_EQ(p->error(),
|
||||
"OpCompositeExtract %2 index value 40 is out of bounds for "
|
||||
"structure %27 having 3 members");
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest_CompositeExtract, Struct_Array_Matrix_Vector) {
|
||||
|
@ -475,8 +479,9 @@ TEST_F(SpvParserTest_CompositeInsert, Vector_IndexTooBigError) {
|
|||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
auto fe = p->function_emitter(100);
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(), Eq("OpCompositeInsert %1 index value 900 is out of "
|
||||
"bounds for vector of 2 elements"));
|
||||
EXPECT_EQ(p->error(),
|
||||
"OpCompositeInsert %1 index value 900 is out of bounds for vector "
|
||||
"of 2 elements");
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest_CompositeInsert, Matrix) {
|
||||
|
@ -519,8 +524,9 @@ TEST_F(SpvParserTest_CompositeInsert, Matrix_IndexTooBigError) {
|
|||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
auto fe = p->function_emitter(100);
|
||||
EXPECT_FALSE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(p->error(), Eq("OpCompositeInsert %2 index value 3 is out of "
|
||||
"bounds for matrix of 3 elements"));
|
||||
EXPECT_EQ(p->error(),
|
||||
"OpCompositeInsert %2 index value 3 is out of bounds for matrix of "
|
||||
"3 elements");
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest_CompositeInsert, Matrix_Vector) {
|
||||
|
@ -611,8 +617,8 @@ TEST_F(SpvParserTest_CompositeInsert, Struct) {
|
|||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
auto ast_body = fe.ast_body();
|
||||
auto body_str = test::ToString(p->program(), ast_body);
|
||||
EXPECT_THAT(body_str, HasSubstr(R"(var x_35 : S;
|
||||
let x_1 : S = x_35;
|
||||
EXPECT_THAT(body_str, HasSubstr(R"(var x_36 : S;
|
||||
let x_1 : S = x_36;
|
||||
var x_2_1 : S = x_1;
|
||||
x_2_1.field2 = 30;
|
||||
let x_2 : S = x_2_1;
|
||||
|
@ -691,8 +697,9 @@ TEST_F(SpvParserTest_CompositeInsert, Struct_IndexTooBigError) {
|
|||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
auto fe = p->function_emitter(100);
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(), Eq("OpCompositeInsert %2 index value 40 is out of "
|
||||
"bounds for structure %26 having 3 members"));
|
||||
EXPECT_EQ(p->error(),
|
||||
"OpCompositeInsert %2 index value 40 is out of bounds for "
|
||||
"structure %27 having 3 members");
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest_CompositeInsert, Struct_Array_Matrix_Vector) {
|
||||
|
@ -715,8 +722,8 @@ TEST_F(SpvParserTest_CompositeInsert, Struct_Array_Matrix_Vector) {
|
|||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
auto ast_body = fe.ast_body();
|
||||
auto body_str = test::ToString(p->program(), ast_body);
|
||||
EXPECT_THAT(body_str, HasSubstr(R"(var x_37 : S_1;
|
||||
let x_1 : S_1 = x_37;
|
||||
EXPECT_THAT(body_str, HasSubstr(R"(var x_38 : S_1;
|
||||
let x_1 : S_1 = x_38;
|
||||
var x_2_1 : S_1 = x_1;
|
||||
x_2_1.field1[2u][0u].y = 70.0;
|
||||
let x_2 : S_1 = x_2_1;
|
||||
|
@ -901,7 +908,7 @@ TEST_F(SpvParserTest_VectorExtractDynamic, UnsignedIndex) {
|
|||
%100 = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
%1 = OpCopyObject %v2uint %v2uint_3_4
|
||||
%2 = OpCopyObject %uint %uint_3
|
||||
%2 = OpCopyObject %uint %uint_1
|
||||
%10 = OpVectorExtractDynamic %uint %1 %2
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
|
|
@ -59,9 +59,8 @@ TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic) {
|
|||
auto* acc = IndexAccessor("my_const", Expr(Source{{12, 34}}, idx));
|
||||
WrapInFunction(Decl(idx), acc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: index must be signed or unsigned integer literal");
|
||||
EXPECT_TRUE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "");
|
||||
}
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Matrix_XDimension_Dynamic) {
|
||||
|
@ -70,9 +69,8 @@ TEST_F(ResolverIndexAccessorTest, Matrix_XDimension_Dynamic) {
|
|||
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, idx));
|
||||
WrapInFunction(Decl(idx), acc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: index must be signed or unsigned integer literal");
|
||||
EXPECT_TRUE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "");
|
||||
}
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Matrix_BothDimension_Dynamic) {
|
||||
|
@ -82,9 +80,8 @@ TEST_F(ResolverIndexAccessorTest, Matrix_BothDimension_Dynamic) {
|
|||
IndexAccessor(IndexAccessor("my_var", Expr(Source{{12, 34}}, idx)), 1);
|
||||
WrapInFunction(Decl(idx), acc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: index must be signed or unsigned integer literal");
|
||||
EXPECT_TRUE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "");
|
||||
}
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Matrix) {
|
||||
|
@ -221,9 +218,8 @@ TEST_F(ResolverIndexAccessorTest, Array_Dynamic_I32) {
|
|||
},
|
||||
ast::DecorationList{});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: index must be signed or unsigned integer literal");
|
||||
EXPECT_TRUE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "");
|
||||
}
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Array_Literal_F32) {
|
||||
|
|
|
@ -1197,18 +1197,6 @@ sem::Expression* Resolver::IndexAccessor(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (obj_ty->IsAnyOf<sem::Array, sem::Matrix>()) {
|
||||
if (!obj_raw_ty->Is<sem::Reference>()) {
|
||||
// TODO(bclayton): expand this to allow any const_expr expression
|
||||
// https://github.com/gpuweb/gpuweb/issues/1272
|
||||
if (!idx->Declaration()->As<ast::IntLiteralExpression>()) {
|
||||
AddError("index must be signed or unsigned integer literal",
|
||||
idx->Declaration()->source);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we're extracting from a reference, we return a reference.
|
||||
if (auto* ref = obj_raw_ty->As<sem::Reference>()) {
|
||||
ty = builder_->create<sem::Reference>(ty, ref->StorageClass(),
|
||||
|
|
|
@ -126,6 +126,13 @@ class Constant {
|
|||
return func(~0);
|
||||
}
|
||||
|
||||
/// @param index the index of the scalar value
|
||||
/// @return the value of the scalar `static_cast` to type T.
|
||||
template <typename T>
|
||||
T ElementAs(size_t index) const {
|
||||
return WithScalarAt(index, [](auto val) { return static_cast<T>(val); });
|
||||
}
|
||||
|
||||
private:
|
||||
const sem::Type* type_ = nullptr;
|
||||
const sem::Type* elem_type_ = nullptr;
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
// Copyright 2021 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/transform/var_for_dynamic_index.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "src/program_builder.h"
|
||||
#include "src/sem/array.h"
|
||||
#include "src/sem/block_statement.h"
|
||||
#include "src/sem/expression.h"
|
||||
#include "src/sem/statement.h"
|
||||
#include "src/transform/for_loop_to_loop.h"
|
||||
|
||||
namespace tint {
|
||||
namespace transform {
|
||||
|
||||
VarForDynamicIndex::VarForDynamicIndex() = default;
|
||||
|
||||
VarForDynamicIndex::~VarForDynamicIndex() = default;
|
||||
|
||||
void VarForDynamicIndex::Run(CloneContext& ctx, const DataMap&, DataMap&) {
|
||||
ProgramBuilder out;
|
||||
if (!Requires<ForLoopToLoop>(ctx)) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& sem = ctx.src->Sem();
|
||||
|
||||
for (auto* node : ctx.src->ASTNodes().Objects()) {
|
||||
if (auto* access_expr = node->As<ast::IndexAccessorExpression>()) {
|
||||
// Found an array accessor expression
|
||||
auto* index_expr = access_expr->index;
|
||||
auto* object_expr = access_expr->object;
|
||||
|
||||
if (sem.Get(index_expr)->ConstantValue()) {
|
||||
// Index expression resolves to a compile time value.
|
||||
// As this isn't a dynamic index, we can ignore this.
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* indexed = sem.Get(object_expr);
|
||||
if (!indexed->Type()->IsAnyOf<sem::Array, sem::Matrix>()) {
|
||||
// This transform currently only cares about array and matrices.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Construct a `var` declaration to hold the value in memory.
|
||||
// TODO(bclayton): group multiple accesses in the same object.
|
||||
// e.g. arr[i] + arr[i+1] // Don't create two vars for this
|
||||
auto var_name = ctx.dst->Symbols().New("var_for_index");
|
||||
auto* var_decl = ctx.dst->Decl(
|
||||
ctx.dst->Var(var_name, nullptr, ctx.Clone(object_expr)));
|
||||
|
||||
// Statement that owns the expression
|
||||
auto* stmt = indexed->Stmt();
|
||||
// Block that owns the statement
|
||||
auto* block = stmt->Parent()->As<sem::BlockStatement>();
|
||||
if (!block) {
|
||||
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
||||
<< "statement parent was not a block";
|
||||
continue;
|
||||
}
|
||||
|
||||
// Insert the `var` declaration before the statement that performs the
|
||||
// indexing. Note that for indexing chains, AST node ordering guarantees
|
||||
// that the inner-most index variable will be placed first in the block.
|
||||
ctx.InsertBefore(block->Declaration()->statements, stmt->Declaration(),
|
||||
var_decl);
|
||||
|
||||
// Replace the original index expression with the new `var`.
|
||||
ctx.Replace(object_expr, ctx.dst->Expr(var_name));
|
||||
}
|
||||
}
|
||||
|
||||
ctx.Clone();
|
||||
}
|
||||
|
||||
} // namespace transform
|
||||
} // namespace tint
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright 2021 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef SRC_TRANSFORM_VAR_FOR_DYNAMIC_INDEX_H_
|
||||
#define SRC_TRANSFORM_VAR_FOR_DYNAMIC_INDEX_H_
|
||||
|
||||
#include "src/transform/transform.h"
|
||||
|
||||
namespace tint {
|
||||
namespace transform {
|
||||
|
||||
/// A transform that extracts array and matrix values that are dynamically
|
||||
/// indexed to a temporary `var` local before performing the index. This
|
||||
/// transform is used by the SPIR-V writer as there is no SPIR-V instruction
|
||||
/// that can dynamically index a non-pointer composite.
|
||||
/// Requires the ForLoopToLoop transform to be run first.
|
||||
class VarForDynamicIndex : public Transform {
|
||||
public:
|
||||
/// Constructor
|
||||
VarForDynamicIndex();
|
||||
|
||||
/// Destructor
|
||||
~VarForDynamicIndex() override;
|
||||
|
||||
protected:
|
||||
/// Runs the transform using the CloneContext built for transforming a
|
||||
/// program. Run() is responsible for calling Clone() on the CloneContext.
|
||||
/// @param ctx the CloneContext primed with the input program and
|
||||
/// ProgramBuilder
|
||||
/// @param inputs optional extra transform-specific input data
|
||||
/// @param outputs optional extra transform-specific output data
|
||||
void Run(CloneContext& ctx, const DataMap& inputs, DataMap& outputs) override;
|
||||
};
|
||||
|
||||
} // namespace transform
|
||||
} // namespace tint
|
||||
|
||||
#endif // SRC_TRANSFORM_VAR_FOR_DYNAMIC_INDEX_H_
|
|
@ -0,0 +1,327 @@
|
|||
// Copyright 2021 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/transform/var_for_dynamic_index.h"
|
||||
#include "src/transform/for_loop_to_loop.h"
|
||||
|
||||
#include "src/transform/test_helper.h"
|
||||
|
||||
namespace tint {
|
||||
namespace transform {
|
||||
namespace {
|
||||
|
||||
using VarForDynamicIndexTest = TransformTest;
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, EmptyModule) {
|
||||
auto* src = "";
|
||||
auto* expect = "";
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, ArrayIndexDynamic) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
let p = array<i32, 4>(1, 2, 3, 4);
|
||||
let x = p[i];
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
let p = array<i32, 4>(1, 2, 3, 4);
|
||||
var var_for_index = p;
|
||||
let x = var_for_index[i];
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, MatrixIndexDynamic) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
let p = mat2x2(1.0, 2.0, 3.0, 4.0);
|
||||
let x = p[i];
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
let p = mat2x2(1.0, 2.0, 3.0, 4.0);
|
||||
var var_for_index = p;
|
||||
let x = var_for_index[i];
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, ArrayIndexDynamicChain) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
var j : i32;
|
||||
let p = array<array<i32, 2>, 2>(array<i32, 2>(1, 2), array<i32, 2>(3, 4));
|
||||
let x = p[i][j];
|
||||
}
|
||||
)";
|
||||
|
||||
// TODO(bclayton): Optimize this case:
|
||||
// This output is not as efficient as it could be.
|
||||
// We only actually need to hoist the inner-most array to a `var`
|
||||
// (`var_for_index`), as later indexing operations will be working with
|
||||
// references, not values.
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
var j : i32;
|
||||
let p = array<array<i32, 2>, 2>(array<i32, 2>(1, 2), array<i32, 2>(3, 4));
|
||||
var var_for_index = p;
|
||||
var var_for_index_1 = var_for_index[i];
|
||||
let x = var_for_index_1[j];
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, ArrayIndexInForLoopInit) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
let p = array<array<i32, 2>, 2>(array<i32, 2>(1, 2), array<i32, 2>(3, 4));
|
||||
for(let x = p[i]; ; ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
let p = array<array<i32, 2>, 2>(array<i32, 2>(1, 2), array<i32, 2>(3, 4));
|
||||
{
|
||||
var var_for_index = p;
|
||||
let x = var_for_index[i];
|
||||
loop {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, MatrixIndexInForLoopInit) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
let p = mat2x2(1.0, 2.0, 3.0, 4.0);
|
||||
for(let x = p[i]; ; ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
let p = mat2x2(1.0, 2.0, 3.0, 4.0);
|
||||
{
|
||||
var var_for_index = p;
|
||||
let x = var_for_index[i];
|
||||
loop {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, ArrayIndexInForLoopCond) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
let p = array<i32, 2>(1, 2);
|
||||
for(; p[i] < 3; ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
let p = array<i32, 2>(1, 2);
|
||||
loop {
|
||||
var var_for_index = p;
|
||||
if (!((var_for_index[i] < 3))) {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, MatrixIndexInForLoopCond) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
let p = mat2x2(1.0, 2.0, 3.0, 4.0);
|
||||
for(; p[i].x < 3.0; ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var i : i32;
|
||||
let p = mat2x2(1.0, 2.0, 3.0, 4.0);
|
||||
loop {
|
||||
var var_for_index = p;
|
||||
if (!((var_for_index[i].x < 3.0))) {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, ArrayIndexLiteral) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
let p = array<i32, 4>(1, 2, 3, 4);
|
||||
let x = p[1];
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = src;
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, MatrixIndexLiteral) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
let p = mat2x2(1.0, 2.0, 3.0, 4.0);
|
||||
let x = p[1];
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = src;
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, ArrayIndexConstantLet) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
let p = array<i32, 4>(1, 2, 3, 4);
|
||||
let c = 1;
|
||||
let x = p[c];
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = src;
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, MatrixIndexConstantLet) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
let p = mat2x2(1.0, 2.0, 3.0, 4.0);
|
||||
let c = 1;
|
||||
let x = p[c];
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = src;
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, ArrayIndexLiteralChain) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
let p = array<array<i32, 2>, 2>(array<i32, 2>(1, 2), array<i32, 2>(3, 4));
|
||||
let x = p[0][1];
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = src;
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(VarForDynamicIndexTest, MatrixIndexLiteralChain) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
let p = mat2x2(1.0, 2.0, 3.0, 4.0);
|
||||
let x = p[0][1];
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = src;
|
||||
|
||||
auto got = Run<ForLoopToLoop, VarForDynamicIndex>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace transform
|
||||
} // namespace tint
|
|
@ -49,6 +49,7 @@
|
|||
#include "src/transform/manager.h"
|
||||
#include "src/transform/simplify_pointers.h"
|
||||
#include "src/transform/unshadow.h"
|
||||
#include "src/transform/var_for_dynamic_index.h"
|
||||
#include "src/transform/vectorize_scalar_matrix_constructors.h"
|
||||
#include "src/transform/zero_init_workgroup_memory.h"
|
||||
#include "src/utils/defer.h"
|
||||
|
@ -268,6 +269,7 @@ SanitizedResult Sanitize(const Program* in,
|
|||
manager.Add<transform::CanonicalizeEntryPointIO>();
|
||||
manager.Add<transform::AddEmptyEntryPoint>();
|
||||
manager.Add<transform::AddSpirvBlockDecoration>();
|
||||
manager.Add<transform::VarForDynamicIndex>();
|
||||
|
||||
data.Add<transform::CanonicalizeEntryPointIO::Config>(
|
||||
transform::CanonicalizeEntryPointIO::Config(
|
||||
|
@ -915,12 +917,17 @@ bool Builder::GenerateIndexAccessor(const ast::IndexAccessorExpression* expr,
|
|||
auto extract = result_op();
|
||||
auto extract_id = extract.to_i();
|
||||
|
||||
// If the index is a literal, we use OpCompositeExtract.
|
||||
if (auto* literal = expr->index->As<ast::IntLiteralExpression>()) {
|
||||
if (!push_function_inst(spv::Op::OpCompositeExtract,
|
||||
{Operand::Int(result_type_id), extract,
|
||||
Operand::Int(info->source_id),
|
||||
Operand::Int(literal->ValueAsU32())})) {
|
||||
// If the index is compile-time constant, we use OpCompositeExtract.
|
||||
auto* idx = builder_.Sem().Get(expr->index);
|
||||
if (auto idx_constval = idx->ConstantValue()) {
|
||||
if (!push_function_inst(
|
||||
spv::Op::OpCompositeExtract,
|
||||
{
|
||||
Operand::Int(result_type_id),
|
||||
extract,
|
||||
Operand::Int(info->source_id),
|
||||
Operand::Int(idx_constval.ElementAs<uint32_t>(0)),
|
||||
})) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1107,6 +1114,9 @@ uint32_t Builder::GenerateAccessorExpression(const ast::Expression* expr) {
|
|||
}
|
||||
info.source_type = TypeOf(source);
|
||||
|
||||
// Note: Dynamic index on array and matrix values (lets) should have been
|
||||
// promoted to storage with the VarForDynamicIndex transform.
|
||||
|
||||
for (auto* accessor : accessors) {
|
||||
if (auto* array = accessor->As<ast::IndexAccessorExpression>()) {
|
||||
if (!GenerateIndexAccessor(array, &info)) {
|
||||
|
|
|
@ -940,12 +940,12 @@ OpReturn
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, IndexAccessor_Array_Dynamic) {
|
||||
// var a : array<f32, 3>;
|
||||
// let a : array<f32, 3>;
|
||||
// idx : i32
|
||||
// a[idx]
|
||||
|
||||
auto* var = Var("a", ty.array<f32, 3>(),
|
||||
Construct(ty.array<f32, 3>(), 0.0f, 0.5f, 1.0f));
|
||||
auto* var = Const("a", ty.array<f32, 3>(),
|
||||
Construct(ty.array<f32, 3>(), 0.0f, 0.5f, 1.0f));
|
||||
|
||||
auto* idx = Var("idx", ty.i32());
|
||||
auto* expr = IndexAccessor("a", idx);
|
||||
|
@ -966,21 +966,21 @@ TEST_F(BuilderTest, IndexAccessor_Array_Dynamic) {
|
|||
%10 = OpConstant %6 0.5
|
||||
%11 = OpConstant %6 1
|
||||
%12 = OpConstantComposite %5 %9 %10 %11
|
||||
%14 = OpTypePointer Function %5
|
||||
%15 = OpConstantNull %5
|
||||
%18 = OpTypeInt 32 1
|
||||
%17 = OpTypePointer Function %18
|
||||
%19 = OpConstantNull %18
|
||||
%15 = OpTypeInt 32 1
|
||||
%14 = OpTypePointer Function %15
|
||||
%16 = OpConstantNull %15
|
||||
%18 = OpTypePointer Function %5
|
||||
%19 = OpConstantNull %5
|
||||
%21 = OpTypePointer Function %6
|
||||
)");
|
||||
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()),
|
||||
R"(%13 = OpVariable %14 Function %15
|
||||
%16 = OpVariable %17 Function %19
|
||||
R"(%13 = OpVariable %14 Function %16
|
||||
%17 = OpVariable %18 Function %19
|
||||
)");
|
||||
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
|
||||
R"(OpStore %13 %12
|
||||
%20 = OpLoad %18 %16
|
||||
%22 = OpAccessChain %21 %13 %20
|
||||
R"(OpStore %17 %12
|
||||
%20 = OpLoad %15 %13
|
||||
%22 = OpAccessChain %21 %17 %20
|
||||
%23 = OpLoad %6 %22
|
||||
OpReturn
|
||||
)");
|
||||
|
@ -989,14 +989,14 @@ OpReturn
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, IndexAccessor_Matrix_Dynamic) {
|
||||
// var a : mat2x2<f32>(vec2<f32>(1., 2.), vec2<f32>(3., 4.));
|
||||
// let a : mat2x2<f32>(vec2<f32>(1., 2.), vec2<f32>(3., 4.));
|
||||
// idx : i32
|
||||
// a[idx]
|
||||
|
||||
auto* var =
|
||||
Var("a", ty.mat2x2<f32>(),
|
||||
Construct(ty.mat2x2<f32>(), Construct(ty.vec2<f32>(), 1.f, 2.f),
|
||||
Construct(ty.vec2<f32>(), 3.f, 4.f)));
|
||||
Const("a", ty.mat2x2<f32>(),
|
||||
Construct(ty.mat2x2<f32>(), Construct(ty.vec2<f32>(), 1.f, 2.f),
|
||||
Construct(ty.vec2<f32>(), 3.f, 4.f)));
|
||||
|
||||
auto* idx = Var("idx", ty.i32());
|
||||
auto* expr = IndexAccessor("a", idx);
|
||||
|
@ -1019,21 +1019,21 @@ TEST_F(BuilderTest, IndexAccessor_Matrix_Dynamic) {
|
|||
%12 = OpConstant %7 4
|
||||
%13 = OpConstantComposite %6 %11 %12
|
||||
%14 = OpConstantComposite %5 %10 %13
|
||||
%16 = OpTypePointer Function %5
|
||||
%17 = OpConstantNull %5
|
||||
%20 = OpTypeInt 32 1
|
||||
%19 = OpTypePointer Function %20
|
||||
%21 = OpConstantNull %20
|
||||
%17 = OpTypeInt 32 1
|
||||
%16 = OpTypePointer Function %17
|
||||
%18 = OpConstantNull %17
|
||||
%20 = OpTypePointer Function %5
|
||||
%21 = OpConstantNull %5
|
||||
%23 = OpTypePointer Function %6
|
||||
)");
|
||||
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()),
|
||||
R"(%15 = OpVariable %16 Function %17
|
||||
%18 = OpVariable %19 Function %21
|
||||
R"(%15 = OpVariable %16 Function %18
|
||||
%19 = OpVariable %20 Function %21
|
||||
)");
|
||||
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
|
||||
R"(OpStore %15 %14
|
||||
%22 = OpLoad %20 %18
|
||||
%24 = OpAccessChain %23 %15 %22
|
||||
R"(OpStore %19 %14
|
||||
%22 = OpLoad %17 %15
|
||||
%24 = OpAccessChain %23 %19 %22
|
||||
%25 = OpLoad %6 %24
|
||||
OpReturn
|
||||
)");
|
||||
|
|
|
@ -330,6 +330,7 @@ tint_unittests_source_set("tint_unittests_transform_src") {
|
|||
"../src/transform/test_helper.h",
|
||||
"../src/transform/transform_test.cc",
|
||||
"../src/transform/unshadow_test.cc",
|
||||
"../src/transform/var_for_dynamic_index_test.cc",
|
||||
"../src/transform/vectorize_scalar_matrix_constructors_test.cc",
|
||||
"../src/transform/vertex_pulling_test.cc",
|
||||
"../src/transform/wrap_arrays_in_structs_test.cc",
|
||||
|
|
|
@ -6,7 +6,7 @@ struct Output {
|
|||
[[builtin(vertex_index)]] VertexIndex : u32,
|
||||
[[builtin(instance_index)]] InstanceIndex : u32) -> Output {
|
||||
// TODO: remove workaround for Tint unary array access broke
|
||||
var zv : array<vec2<f32>, 4> = array<vec2<f32>, 4>(
|
||||
let zv : array<vec2<f32>, 4> = array<vec2<f32>, 4>(
|
||||
vec2<f32>(0.2, 0.2),
|
||||
vec2<f32>(0.3, 0.3),
|
||||
vec2<f32>(-0.1, -0.1),
|
||||
|
@ -14,7 +14,7 @@ struct Output {
|
|||
let z : f32 = zv[InstanceIndex].x;
|
||||
var output : Output;
|
||||
output.Position = vec4<f32>(0.5, 0.5, z, 1.0);
|
||||
var colors : array<vec4<f32>, 4> = array<vec4<f32>, 4>(
|
||||
let colors : array<vec4<f32>, 4> = array<vec4<f32>, 4>(
|
||||
vec4<f32>(1.0, 0.0, 0.0, 1.0),
|
||||
vec4<f32>(0.0, 1.0, 0.0, 1.0),
|
||||
vec4<f32>(0.0, 0.0, 1.0, 1.0),
|
||||
|
@ -22,4 +22,4 @@ struct Output {
|
|||
);
|
||||
output.color = colors[InstanceIndex];
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@ struct tint_symbol_2 {
|
|||
};
|
||||
|
||||
Output main_inner(uint VertexIndex, uint InstanceIndex) {
|
||||
float2 zv[4] = {float2(0.200000003f, 0.200000003f), float2(0.300000012f, 0.300000012f), float2(-0.100000001f, -0.100000001f), float2(1.100000024f, 1.100000024f)};
|
||||
const float2 zv[4] = {float2(0.200000003f, 0.200000003f), float2(0.300000012f, 0.300000012f), float2(-0.100000001f, -0.100000001f), float2(1.100000024f, 1.100000024f)};
|
||||
const float z = zv[InstanceIndex].x;
|
||||
Output output = (Output)0;
|
||||
output.Position = float4(0.5f, 0.5f, z, 1.0f);
|
||||
float4 colors[4] = {float4(1.0f, 0.0f, 0.0f, 1.0f), float4(0.0f, 1.0f, 0.0f, 1.0f), float4(0.0f, 0.0f, 1.0f, 1.0f), float4(1.0f, 1.0f, 1.0f, 1.0f)};
|
||||
const float4 colors[4] = {float4(1.0f, 0.0f, 0.0f, 1.0f), float4(0.0f, 1.0f, 0.0f, 1.0f), float4(0.0f, 0.0f, 1.0f, 1.0f), float4(1.0f, 1.0f, 1.0f, 1.0f)};
|
||||
output.color = colors[InstanceIndex];
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ struct tint_array_wrapper_1 {
|
|||
};
|
||||
|
||||
Output tint_symbol_inner(uint VertexIndex, uint InstanceIndex) {
|
||||
tint_array_wrapper zv = {.arr={float2(0.200000003f, 0.200000003f), float2(0.300000012f, 0.300000012f), float2(-0.100000001f, -0.100000001f), float2(1.100000024f, 1.100000024f)}};
|
||||
tint_array_wrapper const zv = {.arr={float2(0.200000003f, 0.200000003f), float2(0.300000012f, 0.300000012f), float2(-0.100000001f, -0.100000001f), float2(1.100000024f, 1.100000024f)}};
|
||||
float const z = zv.arr[InstanceIndex][0];
|
||||
Output output = {};
|
||||
output.Position = float4(0.5f, 0.5f, z, 1.0f);
|
||||
tint_array_wrapper_1 colors = {.arr={float4(1.0f, 0.0f, 0.0f, 1.0f), float4(0.0f, 1.0f, 0.0f, 1.0f), float4(0.0f, 0.0f, 1.0f, 1.0f), float4(1.0f, 1.0f, 1.0f, 1.0f)}};
|
||||
tint_array_wrapper_1 const colors = {.arr={float4(1.0f, 0.0f, 0.0f, 1.0f), float4(0.0f, 1.0f, 0.0f, 1.0f), float4(0.0f, 0.0f, 1.0f, 1.0f), float4(1.0f, 1.0f, 1.0f, 1.0f)}};
|
||||
output.color = colors.arr[InstanceIndex];
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
OpName %main_inner "main_inner"
|
||||
OpName %VertexIndex "VertexIndex"
|
||||
OpName %InstanceIndex "InstanceIndex"
|
||||
OpName %zv "zv"
|
||||
OpName %var_for_index "var_for_index"
|
||||
OpName %output "output"
|
||||
OpName %colors "colors"
|
||||
OpName %var_for_index_1 "var_for_index_1"
|
||||
OpName %main "main"
|
||||
OpDecorate %VertexIndex_1 BuiltIn VertexIndex
|
||||
OpDecorate %InstanceIndex_1 BuiltIn InstanceIndex
|
||||
|
@ -82,18 +82,18 @@
|
|||
%VertexIndex = OpFunctionParameter %uint
|
||||
%InstanceIndex = OpFunctionParameter %uint
|
||||
%19 = OpLabel
|
||||
%zv = OpVariable %_ptr_Function__arr_v2float_uint_4 Function %34
|
||||
%var_for_index = OpVariable %_ptr_Function__arr_v2float_uint_4 Function %34
|
||||
%output = OpVariable %_ptr_Function_Output Function %41
|
||||
%colors = OpVariable %_ptr_Function__arr_v4float_uint_4 Function %56
|
||||
OpStore %zv %31
|
||||
%37 = OpAccessChain %_ptr_Function_float %zv %InstanceIndex %uint_0
|
||||
%var_for_index_1 = OpVariable %_ptr_Function__arr_v4float_uint_4 Function %56
|
||||
OpStore %var_for_index %31
|
||||
%37 = OpAccessChain %_ptr_Function_float %var_for_index %InstanceIndex %uint_0
|
||||
%38 = OpLoad %float %37
|
||||
%43 = OpAccessChain %_ptr_Function_v4float %output %uint_0
|
||||
%46 = OpCompositeConstruct %v4float %float_0_5 %float_0_5 %38 %float_1
|
||||
OpStore %43 %46
|
||||
OpStore %colors %53
|
||||
OpStore %var_for_index_1 %53
|
||||
%58 = OpAccessChain %_ptr_Function_v4float %output %uint_1
|
||||
%59 = OpAccessChain %_ptr_Function_v4float %colors %InstanceIndex
|
||||
%59 = OpAccessChain %_ptr_Function_v4float %var_for_index_1 %InstanceIndex
|
||||
%60 = OpLoad %v4float %59
|
||||
OpStore %58 %60
|
||||
%61 = OpLoad %Output %output
|
||||
|
|
|
@ -7,11 +7,11 @@ struct Output {
|
|||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32, [[builtin(instance_index)]] InstanceIndex : u32) -> Output {
|
||||
var zv : array<vec2<f32>, 4> = array<vec2<f32>, 4>(vec2<f32>(0.200000003, 0.200000003), vec2<f32>(0.300000012, 0.300000012), vec2<f32>(-0.100000001, -0.100000001), vec2<f32>(1.100000024, 1.100000024));
|
||||
let zv : array<vec2<f32>, 4> = array<vec2<f32>, 4>(vec2<f32>(0.200000003, 0.200000003), vec2<f32>(0.300000012, 0.300000012), vec2<f32>(-0.100000001, -0.100000001), vec2<f32>(1.100000024, 1.100000024));
|
||||
let z : f32 = zv[InstanceIndex].x;
|
||||
var output : Output;
|
||||
output.Position = vec4<f32>(0.5, 0.5, z, 1.0);
|
||||
var colors : array<vec4<f32>, 4> = array<vec4<f32>, 4>(vec4<f32>(1.0, 0.0, 0.0, 1.0), vec4<f32>(0.0, 1.0, 0.0, 1.0), vec4<f32>(0.0, 0.0, 1.0, 1.0), vec4<f32>(1.0, 1.0, 1.0, 1.0));
|
||||
let colors : array<vec4<f32>, 4> = array<vec4<f32>, 4>(vec4<f32>(1.0, 0.0, 0.0, 1.0), vec4<f32>(0.0, 1.0, 0.0, 1.0), vec4<f32>(0.0, 0.0, 1.0, 1.0), vec4<f32>(1.0, 1.0, 1.0, 1.0));
|
||||
output.color = colors[InstanceIndex];
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn f() {
|
||||
var i : i32;
|
||||
var j : i32;
|
||||
var m : mat2x2<f32> = mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0));
|
||||
let m : mat2x2<f32> = mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0));
|
||||
let f : f32 = m[i][j];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@ void unused_entry_point() {
|
|||
void f() {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
float2x2 m = float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
|
||||
const float2x2 m = float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
|
||||
const float f_1 = m[i][j];
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ using namespace metal;
|
|||
void f() {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
float2x2 m = float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
|
||||
float2x2 const m = float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
|
||||
float const f_1 = m[i][j];
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
OpName %f "f"
|
||||
OpName %i "i"
|
||||
OpName %j "j"
|
||||
OpName %m "m"
|
||||
OpName %var_for_index "var_for_index"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
|
@ -38,11 +38,11 @@
|
|||
%6 = OpLabel
|
||||
%i = OpVariable %_ptr_Function_int Function %10
|
||||
%j = OpVariable %_ptr_Function_int Function %10
|
||||
%m = OpVariable %_ptr_Function_mat2v2float Function %24
|
||||
OpStore %m %21
|
||||
%var_for_index = OpVariable %_ptr_Function_mat2v2float Function %24
|
||||
OpStore %var_for_index %21
|
||||
%25 = OpLoad %int %i
|
||||
%26 = OpLoad %int %j
|
||||
%28 = OpAccessChain %_ptr_Function_float %m %25 %26
|
||||
%28 = OpAccessChain %_ptr_Function_float %var_for_index %25 %26
|
||||
%29 = OpLoad %float %28
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn f() {
|
||||
var i : i32;
|
||||
var j : i32;
|
||||
var m : mat2x2<f32> = mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0));
|
||||
let m : mat2x2<f32> = mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0));
|
||||
let f : f32 = m[i][j];
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
fn f() -> i32 {
|
||||
let a = array<i32, 8>(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
let i = 1;
|
||||
return a[i];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
int f() {
|
||||
const int a[8] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
return a[1];
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct tint_array_wrapper {
|
||||
int arr[8];
|
||||
};
|
||||
|
||||
int f() {
|
||||
tint_array_wrapper const a = {.arr={1, 2, 3, 4, 5, 6, 7, 8}};
|
||||
int const i = 1;
|
||||
return a.arr[i];
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 22
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
OpDecorate %_arr_int_uint_8 ArrayStride 4
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%5 = OpTypeFunction %int
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_8 = OpConstant %uint 8
|
||||
%_arr_int_uint_8 = OpTypeArray %int %uint_8
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%int_4 = OpConstant %int 4
|
||||
%int_5 = OpConstant %int 5
|
||||
%int_6 = OpConstant %int 6
|
||||
%int_7 = OpConstant %int 7
|
||||
%int_8 = OpConstant %int 8
|
||||
%20 = OpConstantComposite %_arr_int_uint_8 %int_1 %int_2 %int_3 %int_4 %int_5 %int_6 %int_7 %int_8
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %int None %5
|
||||
%8 = OpLabel
|
||||
%21 = OpCompositeExtract %int %20 1
|
||||
OpReturnValue %21
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,5 @@
|
|||
fn f() -> i32 {
|
||||
let a = array<i32, 8>(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
let i = 1;
|
||||
return a[i];
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
fn f() -> vec3<f32> {
|
||||
let m = mat3x3<f32>(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
|
||||
let i = 1;
|
||||
return m[i];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
float3 f() {
|
||||
const float3x3 m = float3x3(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f);
|
||||
return m[1];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
float3 f() {
|
||||
float3x3 const m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
|
||||
int const i = 1;
|
||||
return m[i];
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 27
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v3float = OpTypeVector %float 3
|
||||
%5 = OpTypeFunction %v3float
|
||||
%mat3v3float = OpTypeMatrix %v3float 3
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%float_3 = OpConstant %float 3
|
||||
%14 = OpConstantComposite %v3float %float_1 %float_2 %float_3
|
||||
%float_4 = OpConstant %float 4
|
||||
%float_5 = OpConstant %float 5
|
||||
%float_6 = OpConstant %float 6
|
||||
%18 = OpConstantComposite %v3float %float_4 %float_5 %float_6
|
||||
%float_7 = OpConstant %float 7
|
||||
%float_8 = OpConstant %float 8
|
||||
%float_9 = OpConstant %float 9
|
||||
%22 = OpConstantComposite %v3float %float_7 %float_8 %float_9
|
||||
%23 = OpConstantComposite %mat3v3float %14 %18 %22
|
||||
%int = OpTypeInt 32 1
|
||||
%int_1 = OpConstant %int 1
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %v3float None %5
|
||||
%9 = OpLabel
|
||||
%26 = OpCompositeExtract %v3float %23 1
|
||||
OpReturnValue %26
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,5 @@
|
|||
fn f() -> vec3<f32> {
|
||||
let m = mat3x3<f32>(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
|
||||
let i = 1;
|
||||
return m[i];
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
fn f() -> f32 {
|
||||
let v = vec3<f32>(1.0, 2.0, 3.0);
|
||||
let i = 1;
|
||||
return v[i];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
float f() {
|
||||
const float3 v = float3(1.0f, 2.0f, 3.0f);
|
||||
return v[1];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
float f() {
|
||||
float3 const v = float3(1.0f, 2.0f, 3.0f);
|
||||
int const i = 1;
|
||||
return v[i];
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 17
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%5 = OpTypeFunction %float
|
||||
%v3float = OpTypeVector %float 3
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%float_3 = OpConstant %float 3
|
||||
%13 = OpConstantComposite %v3float %float_1 %float_2 %float_3
|
||||
%int = OpTypeInt 32 1
|
||||
%int_1 = OpConstant %int 1
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %float None %5
|
||||
%8 = OpLabel
|
||||
%16 = OpCompositeExtract %float %13 1
|
||||
OpReturnValue %16
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,5 @@
|
|||
fn f() -> f32 {
|
||||
let v = vec3<f32>(1.0, 2.0, 3.0);
|
||||
let i = 1;
|
||||
return v[i];
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
fn f(x : i32) -> i32 {
|
||||
let a = array<i32, 8>(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
let i = x;
|
||||
return a[i];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
int f(int x) {
|
||||
const int a[8] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
return a[x];
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct tint_array_wrapper {
|
||||
int arr[8];
|
||||
};
|
||||
|
||||
int f(int x) {
|
||||
tint_array_wrapper const a = {.arr={1, 2, 3, 4, 5, 6, 7, 8}};
|
||||
int const i = x;
|
||||
return a.arr[i];
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 28
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
OpName %x "x"
|
||||
OpName %var_for_index "var_for_index"
|
||||
OpDecorate %_arr_int_uint_8 ArrayStride 4
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%5 = OpTypeFunction %int %int
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_8 = OpConstant %uint 8
|
||||
%_arr_int_uint_8 = OpTypeArray %int %uint_8
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%int_4 = OpConstant %int 4
|
||||
%int_5 = OpConstant %int 5
|
||||
%int_6 = OpConstant %int 6
|
||||
%int_7 = OpConstant %int 7
|
||||
%int_8 = OpConstant %int 8
|
||||
%21 = OpConstantComposite %_arr_int_uint_8 %int_1 %int_2 %int_3 %int_4 %int_5 %int_6 %int_7 %int_8
|
||||
%_ptr_Function__arr_int_uint_8 = OpTypePointer Function %_arr_int_uint_8
|
||||
%24 = OpConstantNull %_arr_int_uint_8
|
||||
%_ptr_Function_int = OpTypePointer Function %int
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %int None %5
|
||||
%x = OpFunctionParameter %int
|
||||
%9 = OpLabel
|
||||
%var_for_index = OpVariable %_ptr_Function__arr_int_uint_8 Function %24
|
||||
OpStore %var_for_index %21
|
||||
%26 = OpAccessChain %_ptr_Function_int %var_for_index %x
|
||||
%27 = OpLoad %int %26
|
||||
OpReturnValue %27
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,5 @@
|
|||
fn f(x : i32) -> i32 {
|
||||
let a = array<i32, 8>(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
let i = x;
|
||||
return a[i];
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
fn f(x : i32) -> vec3<f32> {
|
||||
let m = mat3x3<f32>(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
|
||||
let i = x;
|
||||
return m[i];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
float3 f(int x) {
|
||||
const float3x3 m = float3x3(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f);
|
||||
return m[x];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
float3 f(int x) {
|
||||
float3x3 const m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
|
||||
int const i = x;
|
||||
return m[i];
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 32
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
OpName %x "x"
|
||||
OpName %var_for_index "var_for_index"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v3float = OpTypeVector %float 3
|
||||
%int = OpTypeInt 32 1
|
||||
%5 = OpTypeFunction %v3float %int
|
||||
%mat3v3float = OpTypeMatrix %v3float 3
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%float_3 = OpConstant %float 3
|
||||
%16 = OpConstantComposite %v3float %float_1 %float_2 %float_3
|
||||
%float_4 = OpConstant %float 4
|
||||
%float_5 = OpConstant %float 5
|
||||
%float_6 = OpConstant %float 6
|
||||
%20 = OpConstantComposite %v3float %float_4 %float_5 %float_6
|
||||
%float_7 = OpConstant %float 7
|
||||
%float_8 = OpConstant %float 8
|
||||
%float_9 = OpConstant %float 9
|
||||
%24 = OpConstantComposite %v3float %float_7 %float_8 %float_9
|
||||
%25 = OpConstantComposite %mat3v3float %16 %20 %24
|
||||
%_ptr_Function_mat3v3float = OpTypePointer Function %mat3v3float
|
||||
%28 = OpConstantNull %mat3v3float
|
||||
%_ptr_Function_v3float = OpTypePointer Function %v3float
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %v3float None %5
|
||||
%x = OpFunctionParameter %int
|
||||
%11 = OpLabel
|
||||
%var_for_index = OpVariable %_ptr_Function_mat3v3float Function %28
|
||||
OpStore %var_for_index %25
|
||||
%30 = OpAccessChain %_ptr_Function_v3float %var_for_index %x
|
||||
%31 = OpLoad %v3float %30
|
||||
OpReturnValue %31
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,5 @@
|
|||
fn f(x : i32) -> vec3<f32> {
|
||||
let m = mat3x3<f32>(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
|
||||
let i = x;
|
||||
return m[i];
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
fn f(x : i32) -> f32 {
|
||||
let v = vec3<f32>(1.0, 2.0, 3.0);
|
||||
let i = x;
|
||||
return v[i];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
float f(int x) {
|
||||
const float3 v = float3(1.0f, 2.0f, 3.0f);
|
||||
return v[x];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
float f(int x) {
|
||||
float3 const v = float3(1.0f, 2.0f, 3.0f);
|
||||
int const i = x;
|
||||
return v[i];
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 17
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
OpName %x "x"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%int = OpTypeInt 32 1
|
||||
%5 = OpTypeFunction %float %int
|
||||
%v3float = OpTypeVector %float 3
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%float_3 = OpConstant %float 3
|
||||
%15 = OpConstantComposite %v3float %float_1 %float_2 %float_3
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %float None %5
|
||||
%x = OpFunctionParameter %int
|
||||
%10 = OpLabel
|
||||
%16 = OpVectorExtractDynamic %float %15 %x
|
||||
OpReturnValue %16
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,5 @@
|
|||
fn f(x : i32) -> f32 {
|
||||
let v = vec3<f32>(1.0, 2.0, 3.0);
|
||||
let i = x;
|
||||
return v[i];
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
fn f() -> i32 {
|
||||
let a = array<i32, 8>(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
return a[1];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
int f() {
|
||||
const int a[8] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
return a[1];
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct tint_array_wrapper {
|
||||
int arr[8];
|
||||
};
|
||||
|
||||
int f() {
|
||||
tint_array_wrapper const a = {.arr={1, 2, 3, 4, 5, 6, 7, 8}};
|
||||
return a.arr[1];
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 22
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
OpDecorate %_arr_int_uint_8 ArrayStride 4
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%5 = OpTypeFunction %int
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_8 = OpConstant %uint 8
|
||||
%_arr_int_uint_8 = OpTypeArray %int %uint_8
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%int_4 = OpConstant %int 4
|
||||
%int_5 = OpConstant %int 5
|
||||
%int_6 = OpConstant %int 6
|
||||
%int_7 = OpConstant %int 7
|
||||
%int_8 = OpConstant %int 8
|
||||
%20 = OpConstantComposite %_arr_int_uint_8 %int_1 %int_2 %int_3 %int_4 %int_5 %int_6 %int_7 %int_8
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %int None %5
|
||||
%8 = OpLabel
|
||||
%21 = OpCompositeExtract %int %20 1
|
||||
OpReturnValue %21
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,4 @@
|
|||
fn f() -> i32 {
|
||||
let a = array<i32, 8>(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
return a[1];
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
fn f() -> vec3<f32> {
|
||||
let m = mat3x3<f32>(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
|
||||
return m[1];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
float3 f() {
|
||||
const float3x3 m = float3x3(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f);
|
||||
return m[1];
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
float3 f() {
|
||||
float3x3 const m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
|
||||
return m[1];
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 27
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v3float = OpTypeVector %float 3
|
||||
%5 = OpTypeFunction %v3float
|
||||
%mat3v3float = OpTypeMatrix %v3float 3
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%float_3 = OpConstant %float 3
|
||||
%14 = OpConstantComposite %v3float %float_1 %float_2 %float_3
|
||||
%float_4 = OpConstant %float 4
|
||||
%float_5 = OpConstant %float 5
|
||||
%float_6 = OpConstant %float 6
|
||||
%18 = OpConstantComposite %v3float %float_4 %float_5 %float_6
|
||||
%float_7 = OpConstant %float 7
|
||||
%float_8 = OpConstant %float 8
|
||||
%float_9 = OpConstant %float 9
|
||||
%22 = OpConstantComposite %v3float %float_7 %float_8 %float_9
|
||||
%23 = OpConstantComposite %mat3v3float %14 %18 %22
|
||||
%int = OpTypeInt 32 1
|
||||
%int_1 = OpConstant %int 1
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %v3float None %5
|
||||
%9 = OpLabel
|
||||
%26 = OpCompositeExtract %v3float %23 1
|
||||
OpReturnValue %26
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,4 @@
|
|||
fn f() -> vec3<f32> {
|
||||
let m = mat3x3<f32>(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
|
||||
return m[1];
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
fn f() -> f32 {
|
||||
let v = vec3<f32>(1.0, 2.0, 3.0);
|
||||
return v[1];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
float f() {
|
||||
const float3 v = float3(1.0f, 2.0f, 3.0f);
|
||||
return v[1];
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
float f() {
|
||||
float3 const v = float3(1.0f, 2.0f, 3.0f);
|
||||
return v[1];
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 17
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%5 = OpTypeFunction %float
|
||||
%v3float = OpTypeVector %float 3
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%float_3 = OpConstant %float 3
|
||||
%13 = OpConstantComposite %v3float %float_1 %float_2 %float_3
|
||||
%int = OpTypeInt 32 1
|
||||
%int_1 = OpConstant %int 1
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %float None %5
|
||||
%8 = OpLabel
|
||||
%16 = OpCompositeExtract %float %13 1
|
||||
OpReturnValue %16
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,4 @@
|
|||
fn f() -> f32 {
|
||||
let v = vec3<f32>(1.0, 2.0, 3.0);
|
||||
return v[1];
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
fn f(i : i32) -> i32 {
|
||||
let a = array<i32, 8>(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
return a[i];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
int f(int i) {
|
||||
const int a[8] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
return a[i];
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct tint_array_wrapper {
|
||||
int arr[8];
|
||||
};
|
||||
|
||||
int f(int i) {
|
||||
tint_array_wrapper const a = {.arr={1, 2, 3, 4, 5, 6, 7, 8}};
|
||||
return a.arr[i];
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 28
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
OpName %i "i"
|
||||
OpName %var_for_index "var_for_index"
|
||||
OpDecorate %_arr_int_uint_8 ArrayStride 4
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%5 = OpTypeFunction %int %int
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_8 = OpConstant %uint 8
|
||||
%_arr_int_uint_8 = OpTypeArray %int %uint_8
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%int_4 = OpConstant %int 4
|
||||
%int_5 = OpConstant %int 5
|
||||
%int_6 = OpConstant %int 6
|
||||
%int_7 = OpConstant %int 7
|
||||
%int_8 = OpConstant %int 8
|
||||
%21 = OpConstantComposite %_arr_int_uint_8 %int_1 %int_2 %int_3 %int_4 %int_5 %int_6 %int_7 %int_8
|
||||
%_ptr_Function__arr_int_uint_8 = OpTypePointer Function %_arr_int_uint_8
|
||||
%24 = OpConstantNull %_arr_int_uint_8
|
||||
%_ptr_Function_int = OpTypePointer Function %int
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %int None %5
|
||||
%i = OpFunctionParameter %int
|
||||
%9 = OpLabel
|
||||
%var_for_index = OpVariable %_ptr_Function__arr_int_uint_8 Function %24
|
||||
OpStore %var_for_index %21
|
||||
%26 = OpAccessChain %_ptr_Function_int %var_for_index %i
|
||||
%27 = OpLoad %int %26
|
||||
OpReturnValue %27
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,4 @@
|
|||
fn f(i : i32) -> i32 {
|
||||
let a = array<i32, 8>(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
return a[i];
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
fn f(i : i32) -> vec3<f32> {
|
||||
let m = mat3x3<f32>(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
|
||||
return m[i];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
float3 f(int i) {
|
||||
const float3x3 m = float3x3(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f);
|
||||
return m[i];
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
float3 f(int i) {
|
||||
float3x3 const m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
|
||||
return m[i];
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 32
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
OpName %i "i"
|
||||
OpName %var_for_index "var_for_index"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v3float = OpTypeVector %float 3
|
||||
%int = OpTypeInt 32 1
|
||||
%5 = OpTypeFunction %v3float %int
|
||||
%mat3v3float = OpTypeMatrix %v3float 3
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%float_3 = OpConstant %float 3
|
||||
%16 = OpConstantComposite %v3float %float_1 %float_2 %float_3
|
||||
%float_4 = OpConstant %float 4
|
||||
%float_5 = OpConstant %float 5
|
||||
%float_6 = OpConstant %float 6
|
||||
%20 = OpConstantComposite %v3float %float_4 %float_5 %float_6
|
||||
%float_7 = OpConstant %float 7
|
||||
%float_8 = OpConstant %float 8
|
||||
%float_9 = OpConstant %float 9
|
||||
%24 = OpConstantComposite %v3float %float_7 %float_8 %float_9
|
||||
%25 = OpConstantComposite %mat3v3float %16 %20 %24
|
||||
%_ptr_Function_mat3v3float = OpTypePointer Function %mat3v3float
|
||||
%28 = OpConstantNull %mat3v3float
|
||||
%_ptr_Function_v3float = OpTypePointer Function %v3float
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %v3float None %5
|
||||
%i = OpFunctionParameter %int
|
||||
%11 = OpLabel
|
||||
%var_for_index = OpVariable %_ptr_Function_mat3v3float Function %28
|
||||
OpStore %var_for_index %25
|
||||
%30 = OpAccessChain %_ptr_Function_v3float %var_for_index %i
|
||||
%31 = OpLoad %v3float %30
|
||||
OpReturnValue %31
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,4 @@
|
|||
fn f(i : i32) -> vec3<f32> {
|
||||
let m = mat3x3<f32>(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
|
||||
return m[i];
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
fn f(i : i32) -> f32 {
|
||||
let v = vec3<f32>(1.0, 2.0, 3.0);
|
||||
return v[i];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
float f(int i) {
|
||||
const float3 v = float3(1.0f, 2.0f, 3.0f);
|
||||
return v[i];
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
float f(int i) {
|
||||
float3 const v = float3(1.0f, 2.0f, 3.0f);
|
||||
return v[i];
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 17
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
OpName %i "i"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%int = OpTypeInt 32 1
|
||||
%5 = OpTypeFunction %float %int
|
||||
%v3float = OpTypeVector %float 3
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%float_3 = OpConstant %float 3
|
||||
%15 = OpConstantComposite %v3float %float_1 %float_2 %float_3
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %float None %5
|
||||
%i = OpFunctionParameter %int
|
||||
%10 = OpLabel
|
||||
%16 = OpVectorExtractDynamic %float %15 %i
|
||||
OpReturnValue %16
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,4 @@
|
|||
fn f(i : i32) -> f32 {
|
||||
let v = vec3<f32>(1.0, 2.0, 3.0);
|
||||
return v[i];
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
fn f() -> i32 {
|
||||
var a = array<i32, 8>(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
let i = 1;
|
||||
return a[i];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
int f() {
|
||||
int a[8] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
return a[1];
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct tint_array_wrapper {
|
||||
int arr[8];
|
||||
};
|
||||
|
||||
int f() {
|
||||
tint_array_wrapper a = {.arr={1, 2, 3, 4, 5, 6, 7, 8}};
|
||||
int const i = 1;
|
||||
return a.arr[i];
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 27
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
OpName %a "a"
|
||||
OpDecorate %_arr_int_uint_8 ArrayStride 4
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%5 = OpTypeFunction %int
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_8 = OpConstant %uint 8
|
||||
%_arr_int_uint_8 = OpTypeArray %int %uint_8
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%int_4 = OpConstant %int 4
|
||||
%int_5 = OpConstant %int 5
|
||||
%int_6 = OpConstant %int 6
|
||||
%int_7 = OpConstant %int 7
|
||||
%int_8 = OpConstant %int 8
|
||||
%20 = OpConstantComposite %_arr_int_uint_8 %int_1 %int_2 %int_3 %int_4 %int_5 %int_6 %int_7 %int_8
|
||||
%_ptr_Function__arr_int_uint_8 = OpTypePointer Function %_arr_int_uint_8
|
||||
%23 = OpConstantNull %_arr_int_uint_8
|
||||
%_ptr_Function_int = OpTypePointer Function %int
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %int None %5
|
||||
%8 = OpLabel
|
||||
%a = OpVariable %_ptr_Function__arr_int_uint_8 Function %23
|
||||
OpStore %a %20
|
||||
%25 = OpAccessChain %_ptr_Function_int %a %int_1
|
||||
%26 = OpLoad %int %25
|
||||
OpReturnValue %26
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,5 @@
|
|||
fn f() -> i32 {
|
||||
var a = array<i32, 8>(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
let i = 1;
|
||||
return a[i];
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
fn f() -> vec3<f32> {
|
||||
var m = mat3x3<f32>(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
|
||||
let i = 1;
|
||||
return m[i];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
float3 f() {
|
||||
float3x3 m = float3x3(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f);
|
||||
return m[1];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
float3 f() {
|
||||
float3x3 m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
|
||||
int const i = 1;
|
||||
return m[i];
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 32
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
OpName %m "m"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v3float = OpTypeVector %float 3
|
||||
%5 = OpTypeFunction %v3float
|
||||
%mat3v3float = OpTypeMatrix %v3float 3
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%float_3 = OpConstant %float 3
|
||||
%14 = OpConstantComposite %v3float %float_1 %float_2 %float_3
|
||||
%float_4 = OpConstant %float 4
|
||||
%float_5 = OpConstant %float 5
|
||||
%float_6 = OpConstant %float 6
|
||||
%18 = OpConstantComposite %v3float %float_4 %float_5 %float_6
|
||||
%float_7 = OpConstant %float 7
|
||||
%float_8 = OpConstant %float 8
|
||||
%float_9 = OpConstant %float 9
|
||||
%22 = OpConstantComposite %v3float %float_7 %float_8 %float_9
|
||||
%23 = OpConstantComposite %mat3v3float %14 %18 %22
|
||||
%_ptr_Function_mat3v3float = OpTypePointer Function %mat3v3float
|
||||
%26 = OpConstantNull %mat3v3float
|
||||
%int = OpTypeInt 32 1
|
||||
%int_1 = OpConstant %int 1
|
||||
%_ptr_Function_v3float = OpTypePointer Function %v3float
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %v3float None %5
|
||||
%9 = OpLabel
|
||||
%m = OpVariable %_ptr_Function_mat3v3float Function %26
|
||||
OpStore %m %23
|
||||
%30 = OpAccessChain %_ptr_Function_v3float %m %int_1
|
||||
%31 = OpLoad %v3float %30
|
||||
OpReturnValue %31
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,5 @@
|
|||
fn f() -> vec3<f32> {
|
||||
var m = mat3x3<f32>(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
|
||||
let i = 1;
|
||||
return m[i];
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
fn f() -> f32 {
|
||||
var v = vec3<f32>(1.0, 2.0, 3.0);
|
||||
let i = 1;
|
||||
return v[i];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
float f() {
|
||||
float3 v = float3(1.0f, 2.0f, 3.0f);
|
||||
return v[1];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
float f() {
|
||||
float3 v = float3(1.0f, 2.0f, 3.0f);
|
||||
int const i = 1;
|
||||
return v[i];
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 22
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
OpName %v "v"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%5 = OpTypeFunction %float
|
||||
%v3float = OpTypeVector %float 3
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%float_3 = OpConstant %float 3
|
||||
%13 = OpConstantComposite %v3float %float_1 %float_2 %float_3
|
||||
%_ptr_Function_v3float = OpTypePointer Function %v3float
|
||||
%16 = OpConstantNull %v3float
|
||||
%int = OpTypeInt 32 1
|
||||
%int_1 = OpConstant %int 1
|
||||
%_ptr_Function_float = OpTypePointer Function %float
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %float None %5
|
||||
%8 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_v3float Function %16
|
||||
OpStore %v %13
|
||||
%20 = OpAccessChain %_ptr_Function_float %v %int_1
|
||||
%21 = OpLoad %float %20
|
||||
OpReturnValue %21
|
||||
OpFunctionEnd
|
|
@ -0,0 +1,5 @@
|
|||
fn f() -> f32 {
|
||||
var v = vec3<f32>(1.0, 2.0, 3.0);
|
||||
let i = 1;
|
||||
return v[i];
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
fn f() -> i32 {
|
||||
var a = array<i32, 8>(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
let i = 1;
|
||||
return a[i];
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
int f() {
|
||||
int a[8] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
return a[1];
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue