transform: remove VarForDynamicIndex transform.
Dynamic indexes are limited to references to matrices and arrays https://github.com/gpuweb/gpuweb/pull/1801 Bug: tint:867 Change-Id: I114daa053c8a4ffd23ce784ac4538567a551cc21 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54701 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
This commit is contained in:
parent
4b1c9de503
commit
b6fdcc54df
|
@ -571,8 +571,6 @@ libtint_source_set("libtint_core_all_src") {
|
||||||
"transform/single_entry_point.h",
|
"transform/single_entry_point.h",
|
||||||
"transform/transform.cc",
|
"transform/transform.cc",
|
||||||
"transform/transform.h",
|
"transform/transform.h",
|
||||||
"transform/var_for_dynamic_index.cc",
|
|
||||||
"transform/var_for_dynamic_index.h",
|
|
||||||
"transform/vertex_pulling.cc",
|
"transform/vertex_pulling.cc",
|
||||||
"transform/vertex_pulling.h",
|
"transform/vertex_pulling.h",
|
||||||
"transform/wrap_arrays_in_structs.cc",
|
"transform/wrap_arrays_in_structs.cc",
|
||||||
|
|
|
@ -296,8 +296,6 @@ set(TINT_LIB_SRCS
|
||||||
transform/single_entry_point.h
|
transform/single_entry_point.h
|
||||||
transform/transform.cc
|
transform/transform.cc
|
||||||
transform/transform.h
|
transform/transform.h
|
||||||
transform/var_for_dynamic_index.cc
|
|
||||||
transform/var_for_dynamic_index.h
|
|
||||||
transform/vertex_pulling.cc
|
transform/vertex_pulling.cc
|
||||||
transform/vertex_pulling.h
|
transform/vertex_pulling.h
|
||||||
transform/wrap_arrays_in_structs.cc
|
transform/wrap_arrays_in_structs.cc
|
||||||
|
@ -859,7 +857,6 @@ if(${TINT_BUILD_TESTS})
|
||||||
transform/simplify_test.cc
|
transform/simplify_test.cc
|
||||||
transform/single_entry_point_test.cc
|
transform/single_entry_point_test.cc
|
||||||
transform/test_helper.h
|
transform/test_helper.h
|
||||||
transform/var_for_dynamic_index_test.cc
|
|
||||||
transform/vertex_pulling_test.cc
|
transform/vertex_pulling_test.cc
|
||||||
transform/wrap_arrays_in_structs_test.cc
|
transform/wrap_arrays_in_structs_test.cc
|
||||||
)
|
)
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include "src/transform/inline_pointer_lets.h"
|
#include "src/transform/inline_pointer_lets.h"
|
||||||
#include "src/transform/manager.h"
|
#include "src/transform/manager.h"
|
||||||
#include "src/transform/simplify.h"
|
#include "src/transform/simplify.h"
|
||||||
#include "src/transform/var_for_dynamic_index.h"
|
|
||||||
|
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::Spirv::Config);
|
TINT_INSTANTIATE_TYPEINFO(tint::transform::Spirv::Config);
|
||||||
|
|
||||||
|
@ -45,7 +44,6 @@ Output Spirv::Run(const Program* in, const DataMap& data) {
|
||||||
manager.Add<InlinePointerLets>(); // Required for arrayLength()
|
manager.Add<InlinePointerLets>(); // Required for arrayLength()
|
||||||
manager.Add<Simplify>(); // Required for arrayLength()
|
manager.Add<Simplify>(); // Required for arrayLength()
|
||||||
manager.Add<ExternalTextureTransform>();
|
manager.Add<ExternalTextureTransform>();
|
||||||
manager.Add<VarForDynamicIndex>();
|
|
||||||
auto transformedInput = manager.Run(in, data);
|
auto transformedInput = manager.Run(in, data);
|
||||||
|
|
||||||
auto* cfg = data.Get<Config>();
|
auto* cfg = data.Get<Config>();
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
// 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"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace transform {
|
|
||||||
|
|
||||||
VarForDynamicIndex::VarForDynamicIndex() = default;
|
|
||||||
|
|
||||||
VarForDynamicIndex::~VarForDynamicIndex() = default;
|
|
||||||
|
|
||||||
Output VarForDynamicIndex::Run(const Program* in, const DataMap&) {
|
|
||||||
ProgramBuilder out;
|
|
||||||
CloneContext ctx(&out, in);
|
|
||||||
|
|
||||||
for (auto* node : in->ASTNodes().Objects()) {
|
|
||||||
if (auto* access_expr = node->As<ast::ArrayAccessorExpression>()) {
|
|
||||||
// Found an array accessor expression
|
|
||||||
auto* index_expr = access_expr->idx_expr();
|
|
||||||
auto* indexed_expr = access_expr->array();
|
|
||||||
|
|
||||||
if (index_expr->Is<ast::ScalarConstructorExpression>()) {
|
|
||||||
// Index expression is a literal value. As this isn't a dynamic index,
|
|
||||||
// we can ignore this.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* indexed = ctx.src->Sem().Get(indexed_expr);
|
|
||||||
if (!indexed->Type()->IsAnyOf<sem::Array, sem::Matrix>()) {
|
|
||||||
// This transform currently only cares about array and matrices.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* stmt = indexed->Stmt(); // Statement that owns the expression
|
|
||||||
auto* block = stmt->Block(); // Block that owns the statement
|
|
||||||
|
|
||||||
// Construct a `var` declaration to hold the value in memory.
|
|
||||||
auto* ty = CreateASTTypeFor(&ctx, indexed->Type());
|
|
||||||
auto var_name = ctx.dst->Symbols().New("var_for_index");
|
|
||||||
auto* var_decl = ctx.dst->Decl(ctx.dst->Var(
|
|
||||||
var_name, ty, ast::StorageClass::kNone, ctx.Clone(indexed_expr)));
|
|
||||||
|
|
||||||
// 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(indexed_expr, ctx.dst->Expr(var_name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.Clone();
|
|
||||||
|
|
||||||
return Output(Program(std::move(out)));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace transform
|
|
||||||
} // namespace tint
|
|
|
@ -1,48 +0,0 @@
|
||||||
// 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 <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#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.
|
|
||||||
class VarForDynamicIndex : public Transform {
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
VarForDynamicIndex();
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
~VarForDynamicIndex() override;
|
|
||||||
|
|
||||||
/// Runs the transform on `program`, returning the transformation result.
|
|
||||||
/// @param program the source program to transform
|
|
||||||
/// @param data optional extra transform-specific input data
|
|
||||||
/// @returns the transformation result
|
|
||||||
Output Run(const Program* program, const DataMap& data = {}) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace transform
|
|
||||||
} // namespace tint
|
|
||||||
|
|
||||||
#endif // SRC_TRANSFORM_VAR_FOR_DYNAMIC_INDEX_H_
|
|
|
@ -1,121 +0,0 @@
|
||||||
// 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/test_helper.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace transform {
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
using VarForDynamicIndexTest = TransformTest;
|
|
||||||
|
|
||||||
TEST_F(VarForDynamicIndexTest, EmptyModule) {
|
|
||||||
auto* src = "";
|
|
||||||
auto* expect = "";
|
|
||||||
|
|
||||||
auto got = Run<VarForDynamicIndex>(src);
|
|
||||||
|
|
||||||
EXPECT_EQ(expect, str(got));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(VarForDynamicIndexTest, ArrayIndexDynamic) {
|
|
||||||
auto* src = R"(
|
|
||||||
fn f() {
|
|
||||||
var i : i32;
|
|
||||||
let p : array<i32, 4> = array<i32, 4>(1, 2, 3, 4);
|
|
||||||
let x : i32 = p[i];
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
|
|
||||||
auto* expect = R"(
|
|
||||||
fn f() {
|
|
||||||
var i : i32;
|
|
||||||
let p : array<i32, 4> = array<i32, 4>(1, 2, 3, 4);
|
|
||||||
var var_for_index : array<i32, 4> = p;
|
|
||||||
let x : i32 = var_for_index[i];
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
|
|
||||||
auto got = Run<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<array<i32, 2>, 2>(array<i32, 2>(1, 2), array<i32, 2>(3, 4));
|
|
||||||
let x : i32 = 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<array<i32, 2>, 2>(array<i32, 2>(1, 2), array<i32, 2>(3, 4));
|
|
||||||
var var_for_index : array<array<i32, 2>, 2> = p;
|
|
||||||
var var_for_index_1 : array<i32, 2> = var_for_index[i];
|
|
||||||
let x : i32 = var_for_index_1[j];
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
|
|
||||||
auto got = Run<VarForDynamicIndex>(src);
|
|
||||||
|
|
||||||
EXPECT_EQ(expect, str(got));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(VarForDynamicIndexTest, ArrayIndexLiteral) {
|
|
||||||
auto* src = R"(
|
|
||||||
fn f() {
|
|
||||||
let p : array<i32, 4> = array<i32, 4>(1, 2, 3, 4);
|
|
||||||
let x : i32 = p[1];
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
|
|
||||||
auto* expect = src;
|
|
||||||
|
|
||||||
auto got = Run<VarForDynamicIndex>(src);
|
|
||||||
|
|
||||||
EXPECT_EQ(expect, str(got));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(VarForDynamicIndexTest, ArrayIndexLiteralChain) {
|
|
||||||
auto* src = R"(
|
|
||||||
fn f() {
|
|
||||||
let p : array<array<i32, 2>, 2> = array<array<i32, 2>, 2>(array<i32, 2>(1, 2), array<i32, 2>(3, 4));
|
|
||||||
let x : i32 = p[0][1];
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
|
|
||||||
auto* expect = src;
|
|
||||||
|
|
||||||
auto got = Run<VarForDynamicIndex>(src);
|
|
||||||
|
|
||||||
EXPECT_EQ(expect, str(got));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
} // namespace transform
|
|
||||||
} // namespace tint
|
|
|
@ -1077,17 +1077,6 @@ uint32_t Builder::GenerateAccessorExpression(ast::Expression* expr) {
|
||||||
}
|
}
|
||||||
info.source_type = TypeOf(source);
|
info.source_type = TypeOf(source);
|
||||||
|
|
||||||
if (auto* access = accessors[0]->As<ast::ArrayAccessorExpression>()) {
|
|
||||||
auto* array = TypeOf(access->array())->As<sem::Array>();
|
|
||||||
bool literal_index =
|
|
||||||
array && access->idx_expr()->Is<ast::ScalarConstructorExpression>();
|
|
||||||
if (array && !literal_index) {
|
|
||||||
TINT_ICE(builder_.Diagnostics())
|
|
||||||
<< "Dynamic index on array value should have been promoted to "
|
|
||||||
"storage with the VarForDynamicIndex transform";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto* accessor : accessors) {
|
for (auto* accessor : accessors) {
|
||||||
if (auto* array = accessor->As<ast::ArrayAccessorExpression>()) {
|
if (auto* array = accessor->As<ast::ArrayAccessorExpression>()) {
|
||||||
if (!GenerateArrayAccessor(array, &info)) {
|
if (!GenerateArrayAccessor(array, &info)) {
|
||||||
|
|
|
@ -937,11 +937,11 @@ TEST_F(BuilderTest, ArrayAccessor_Array_Literal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, ArrayAccessor_Array_Dynamic) {
|
TEST_F(BuilderTest, ArrayAccessor_Array_Dynamic) {
|
||||||
// let a : array<f32, 3>;
|
// var a : array<f32, 3>;
|
||||||
// idx : i32
|
// idx : i32
|
||||||
// a[idx]
|
// a[idx]
|
||||||
|
|
||||||
auto* var = Const("a", ty.array<f32, 3>(),
|
auto* var = Var("a", ty.array<f32, 3>(),
|
||||||
Construct(ty.array<f32, 3>(), 0.0f, 0.5f, 1.0f));
|
Construct(ty.array<f32, 3>(), 0.0f, 0.5f, 1.0f));
|
||||||
|
|
||||||
auto* idx = Var("idx", ty.i32());
|
auto* idx = Var("idx", ty.i32());
|
||||||
|
@ -963,21 +963,21 @@ TEST_F(BuilderTest, ArrayAccessor_Array_Dynamic) {
|
||||||
%10 = OpConstant %6 0.5
|
%10 = OpConstant %6 0.5
|
||||||
%11 = OpConstant %6 1
|
%11 = OpConstant %6 1
|
||||||
%12 = OpConstantComposite %5 %9 %10 %11
|
%12 = OpConstantComposite %5 %9 %10 %11
|
||||||
%15 = OpTypeInt 32 1
|
%14 = OpTypePointer Function %5
|
||||||
%14 = OpTypePointer Function %15
|
%15 = OpConstantNull %5
|
||||||
%16 = OpConstantNull %15
|
%18 = OpTypeInt 32 1
|
||||||
%18 = OpTypePointer Function %5
|
%17 = OpTypePointer Function %18
|
||||||
%19 = OpConstantNull %5
|
%19 = OpConstantNull %18
|
||||||
%21 = OpTypePointer Function %6
|
%21 = OpTypePointer Function %6
|
||||||
)");
|
)");
|
||||||
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()),
|
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()),
|
||||||
R"(%13 = OpVariable %14 Function %16
|
R"(%13 = OpVariable %14 Function %15
|
||||||
%17 = OpVariable %18 Function %19
|
%16 = OpVariable %17 Function %19
|
||||||
)");
|
)");
|
||||||
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
|
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
|
||||||
R"(OpStore %17 %12
|
R"(OpStore %13 %12
|
||||||
%20 = OpLoad %15 %13
|
%20 = OpLoad %18 %16
|
||||||
%22 = OpAccessChain %21 %17 %20
|
%22 = OpAccessChain %21 %13 %20
|
||||||
%23 = OpLoad %6 %22
|
%23 = OpLoad %6 %22
|
||||||
)");
|
)");
|
||||||
|
|
||||||
|
@ -985,12 +985,12 @@ TEST_F(BuilderTest, ArrayAccessor_Array_Dynamic) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest, ArrayAccessor_Matrix_Dynamic) {
|
TEST_F(BuilderTest, ArrayAccessor_Matrix_Dynamic) {
|
||||||
// let a : mat2x2<f32>(vec2<f32>(1., 2.), vec2<f32>(3., 4.));
|
// var a : mat2x2<f32>(vec2<f32>(1., 2.), vec2<f32>(3., 4.));
|
||||||
// idx : i32
|
// idx : i32
|
||||||
// a[idx]
|
// a[idx]
|
||||||
|
|
||||||
auto* var =
|
auto* var =
|
||||||
Const("a", ty.mat2x2<f32>(),
|
Var("a", ty.mat2x2<f32>(),
|
||||||
Construct(ty.mat2x2<f32>(), Construct(ty.vec2<f32>(), 1.f, 2.f),
|
Construct(ty.mat2x2<f32>(), Construct(ty.vec2<f32>(), 1.f, 2.f),
|
||||||
Construct(ty.vec2<f32>(), 3.f, 4.f)));
|
Construct(ty.vec2<f32>(), 3.f, 4.f)));
|
||||||
|
|
||||||
|
@ -1015,21 +1015,21 @@ TEST_F(BuilderTest, ArrayAccessor_Matrix_Dynamic) {
|
||||||
%12 = OpConstant %7 4
|
%12 = OpConstant %7 4
|
||||||
%13 = OpConstantComposite %6 %11 %12
|
%13 = OpConstantComposite %6 %11 %12
|
||||||
%14 = OpConstantComposite %5 %10 %13
|
%14 = OpConstantComposite %5 %10 %13
|
||||||
%17 = OpTypeInt 32 1
|
%16 = OpTypePointer Function %5
|
||||||
%16 = OpTypePointer Function %17
|
%17 = OpConstantNull %5
|
||||||
%18 = OpConstantNull %17
|
%20 = OpTypeInt 32 1
|
||||||
%20 = OpTypePointer Function %5
|
%19 = OpTypePointer Function %20
|
||||||
%21 = OpConstantNull %5
|
%21 = OpConstantNull %20
|
||||||
%23 = OpTypePointer Function %6
|
%23 = OpTypePointer Function %6
|
||||||
)");
|
)");
|
||||||
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()),
|
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()),
|
||||||
R"(%15 = OpVariable %16 Function %18
|
R"(%15 = OpVariable %16 Function %17
|
||||||
%19 = OpVariable %20 Function %21
|
%18 = OpVariable %19 Function %21
|
||||||
)");
|
)");
|
||||||
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
|
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
|
||||||
R"(OpStore %19 %14
|
R"(OpStore %15 %14
|
||||||
%22 = OpLoad %17 %15
|
%22 = OpLoad %20 %18
|
||||||
%24 = OpAccessChain %23 %19 %22
|
%24 = OpAccessChain %23 %15 %22
|
||||||
%25 = OpLoad %6 %24
|
%25 = OpLoad %6 %24
|
||||||
)");
|
)");
|
||||||
|
|
||||||
|
|
|
@ -286,7 +286,6 @@ tint_unittests_source_set("tint_unittests_core_src") {
|
||||||
"../src/transform/single_entry_point_test.cc",
|
"../src/transform/single_entry_point_test.cc",
|
||||||
"../src/transform/test_helper.h",
|
"../src/transform/test_helper.h",
|
||||||
"../src/transform/transform_test.cc",
|
"../src/transform/transform_test.cc",
|
||||||
"../src/transform/var_for_dynamic_index_test.cc",
|
|
||||||
"../src/transform/vertex_pulling_test.cc",
|
"../src/transform/vertex_pulling_test.cc",
|
||||||
"../src/transform/wrap_arrays_in_structs_test.cc",
|
"../src/transform/wrap_arrays_in_structs_test.cc",
|
||||||
"../src/utils/enum_set_test.cc",
|
"../src/utils/enum_set_test.cc",
|
||||||
|
|
|
@ -6,7 +6,7 @@ struct Output {
|
||||||
[[builtin(vertex_index)]] VertexIndex : u32,
|
[[builtin(vertex_index)]] VertexIndex : u32,
|
||||||
[[builtin(instance_index)]] InstanceIndex : u32) -> Output {
|
[[builtin(instance_index)]] InstanceIndex : u32) -> Output {
|
||||||
// TODO: remove workaround for Tint unary array access broke
|
// TODO: remove workaround for Tint unary array access broke
|
||||||
let zv : array<vec2<f32>, 4> = array<vec2<f32>, 4>(
|
var zv : array<vec2<f32>, 4> = array<vec2<f32>, 4>(
|
||||||
vec2<f32>(0.2, 0.2),
|
vec2<f32>(0.2, 0.2),
|
||||||
vec2<f32>(0.3, 0.3),
|
vec2<f32>(0.3, 0.3),
|
||||||
vec2<f32>(-0.1, -0.1),
|
vec2<f32>(-0.1, -0.1),
|
||||||
|
@ -14,7 +14,7 @@ struct Output {
|
||||||
let z : f32 = zv[InstanceIndex].x;
|
let z : f32 = zv[InstanceIndex].x;
|
||||||
var output : Output;
|
var output : Output;
|
||||||
output.Position = vec4<f32>(0.5, 0.5, z, 1.0);
|
output.Position = vec4<f32>(0.5, 0.5, z, 1.0);
|
||||||
let colors : array<vec4<f32>, 4> = array<vec4<f32>, 4>(
|
var colors : array<vec4<f32>, 4> = array<vec4<f32>, 4>(
|
||||||
vec4<f32>(1.0, 0.0, 0.0, 1.0),
|
vec4<f32>(1.0, 0.0, 0.0, 1.0),
|
||||||
vec4<f32>(0.0, 1.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>(0.0, 0.0, 1.0, 1.0),
|
||||||
|
|
|
@ -20,11 +20,11 @@ struct tint_array_wrapper_1 {
|
||||||
tint_symbol_2 main(tint_symbol_1 tint_symbol) {
|
tint_symbol_2 main(tint_symbol_1 tint_symbol) {
|
||||||
const uint VertexIndex = tint_symbol.VertexIndex;
|
const uint VertexIndex = tint_symbol.VertexIndex;
|
||||||
const uint InstanceIndex = tint_symbol.InstanceIndex;
|
const uint InstanceIndex = tint_symbol.InstanceIndex;
|
||||||
const tint_array_wrapper zv = {{float2(0.200000003f, 0.200000003f), float2(0.300000012f, 0.300000012f), float2(-0.100000001f, -0.100000001f), float2(1.100000024f, 1.100000024f)}};
|
tint_array_wrapper zv = {{float2(0.200000003f, 0.200000003f), float2(0.300000012f, 0.300000012f), float2(-0.100000001f, -0.100000001f), float2(1.100000024f, 1.100000024f)}};
|
||||||
const float z = zv.arr[InstanceIndex].x;
|
const float z = zv.arr[InstanceIndex].x;
|
||||||
Output output = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
|
Output output = {float4(0.0f, 0.0f, 0.0f, 0.0f), float4(0.0f, 0.0f, 0.0f, 0.0f)};
|
||||||
output.Position = float4(0.5f, 0.5f, z, 1.0f);
|
output.Position = float4(0.5f, 0.5f, z, 1.0f);
|
||||||
const tint_array_wrapper_1 colors = {{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 colors = {{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];
|
output.color = colors.arr[InstanceIndex];
|
||||||
const tint_symbol_2 tint_symbol_3 = {output.color, output.Position};
|
const tint_symbol_2 tint_symbol_3 = {output.color, output.Position};
|
||||||
return tint_symbol_3;
|
return tint_symbol_3;
|
||||||
|
|
|
@ -17,11 +17,11 @@ struct tint_array_wrapper_1 {
|
||||||
};
|
};
|
||||||
|
|
||||||
vertex tint_symbol_2 tint_symbol(uint VertexIndex [[vertex_id]], uint InstanceIndex [[instance_id]]) {
|
vertex tint_symbol_2 tint_symbol(uint VertexIndex [[vertex_id]], uint InstanceIndex [[instance_id]]) {
|
||||||
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)}};
|
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)}};
|
||||||
float const z = zv.arr[InstanceIndex].x;
|
float const z = zv.arr[InstanceIndex].x;
|
||||||
Output output = {};
|
Output output = {};
|
||||||
output.Position = float4(0.5f, 0.5f, z, 1.0f);
|
output.Position = float4(0.5f, 0.5f, z, 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)}};
|
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)}};
|
||||||
output.color = colors.arr[InstanceIndex];
|
output.color = colors.arr[InstanceIndex];
|
||||||
tint_symbol_2 const tint_symbol_3 = {.color=output.color, .Position=output.Position};
|
tint_symbol_2 const tint_symbol_3 = {.color=output.color, .Position=output.Position};
|
||||||
return tint_symbol_3;
|
return tint_symbol_3;
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
OpName %tint_symbol_5 "tint_symbol_5"
|
OpName %tint_symbol_5 "tint_symbol_5"
|
||||||
OpName %tint_symbol_2 "tint_symbol_2"
|
OpName %tint_symbol_2 "tint_symbol_2"
|
||||||
OpName %main "main"
|
OpName %main "main"
|
||||||
OpName %var_for_index "var_for_index"
|
OpName %zv "zv"
|
||||||
OpName %output "output"
|
OpName %output "output"
|
||||||
OpName %var_for_index_1 "var_for_index_1"
|
OpName %colors "colors"
|
||||||
OpDecorate %tint_pointsize BuiltIn PointSize
|
OpDecorate %tint_pointsize BuiltIn PointSize
|
||||||
OpDecorate %tint_symbol BuiltIn VertexIndex
|
OpDecorate %tint_symbol BuiltIn VertexIndex
|
||||||
OpDecorate %tint_symbol_1 BuiltIn InstanceIndex
|
OpDecorate %tint_symbol_1 BuiltIn InstanceIndex
|
||||||
|
@ -88,21 +88,21 @@
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%main = OpFunction %void None %22
|
%main = OpFunction %void None %22
|
||||||
%24 = OpLabel
|
%24 = OpLabel
|
||||||
%var_for_index = OpVariable %_ptr_Function__arr_v2float_uint_4 Function %40
|
%zv = OpVariable %_ptr_Function__arr_v2float_uint_4 Function %40
|
||||||
%output = OpVariable %_ptr_Function_Output Function %48
|
%output = OpVariable %_ptr_Function_Output Function %48
|
||||||
%var_for_index_1 = OpVariable %_ptr_Function__arr_v4float_uint_4 Function %62
|
%colors = OpVariable %_ptr_Function__arr_v4float_uint_4 Function %62
|
||||||
OpStore %tint_pointsize %float_1
|
OpStore %tint_pointsize %float_1
|
||||||
OpStore %var_for_index %37
|
OpStore %zv %37
|
||||||
%41 = OpLoad %uint %tint_symbol_1
|
%41 = OpLoad %uint %tint_symbol_1
|
||||||
%44 = OpAccessChain %_ptr_Function_float %var_for_index %41 %uint_0
|
%44 = OpAccessChain %_ptr_Function_float %zv %41 %uint_0
|
||||||
%45 = OpLoad %float %44
|
%45 = OpLoad %float %44
|
||||||
%50 = OpAccessChain %_ptr_Function_v4float %output %uint_0
|
%50 = OpAccessChain %_ptr_Function_v4float %output %uint_0
|
||||||
%52 = OpCompositeConstruct %v4float %float_0_5 %float_0_5 %45 %float_1
|
%52 = OpCompositeConstruct %v4float %float_0_5 %float_0_5 %45 %float_1
|
||||||
OpStore %50 %52
|
OpStore %50 %52
|
||||||
OpStore %var_for_index_1 %59
|
OpStore %colors %59
|
||||||
%64 = OpAccessChain %_ptr_Function_v4float %output %uint_1
|
%64 = OpAccessChain %_ptr_Function_v4float %output %uint_1
|
||||||
%65 = OpLoad %uint %tint_symbol_1
|
%65 = OpLoad %uint %tint_symbol_1
|
||||||
%66 = OpAccessChain %_ptr_Function_v4float %var_for_index_1 %65
|
%66 = OpAccessChain %_ptr_Function_v4float %colors %65
|
||||||
%67 = OpLoad %v4float %66
|
%67 = OpLoad %v4float %66
|
||||||
OpStore %64 %67
|
OpStore %64 %67
|
||||||
%69 = OpLoad %Output %output
|
%69 = OpLoad %Output %output
|
||||||
|
|
|
@ -7,11 +7,11 @@ struct Output {
|
||||||
|
|
||||||
[[stage(vertex)]]
|
[[stage(vertex)]]
|
||||||
fn main([[builtin(vertex_index)]] VertexIndex : u32, [[builtin(instance_index)]] InstanceIndex : u32) -> Output {
|
fn main([[builtin(vertex_index)]] VertexIndex : u32, [[builtin(instance_index)]] InstanceIndex : u32) -> Output {
|
||||||
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));
|
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 z : f32 = zv[InstanceIndex].x;
|
let z : f32 = zv[InstanceIndex].x;
|
||||||
var output : Output;
|
var output : Output;
|
||||||
output.Position = vec4<f32>(0.5, 0.5, z, 1.0);
|
output.Position = vec4<f32>(0.5, 0.5, z, 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));
|
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));
|
||||||
output.color = colors[InstanceIndex];
|
output.color = colors[InstanceIndex];
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
fn f() {
|
fn f() {
|
||||||
var i : i32;
|
var i : i32;
|
||||||
var j : i32;
|
var j : i32;
|
||||||
let m : mat2x2<f32> = mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0));
|
var m : mat2x2<f32> = mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0));
|
||||||
let f : f32 = m[i][j];
|
let f : f32 = m[i][j];
|
||||||
}
|
}
|
|
@ -6,6 +6,6 @@ void unused_entry_point() {
|
||||||
void f() {
|
void f() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
const float2x2 m = float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
|
float2x2 m = float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
|
||||||
const float f = m[i][j];
|
const float f = m[i][j];
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ using namespace metal;
|
||||||
void f() {
|
void f() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
float2x2 const m = float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
|
float2x2 m = float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
|
||||||
float const f = m[i][j];
|
float const f = m[i][j];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
OpName %f "f"
|
OpName %f "f"
|
||||||
OpName %i "i"
|
OpName %i "i"
|
||||||
OpName %j "j"
|
OpName %j "j"
|
||||||
OpName %var_for_index "var_for_index"
|
OpName %m "m"
|
||||||
%void = OpTypeVoid
|
%void = OpTypeVoid
|
||||||
%1 = OpTypeFunction %void
|
%1 = OpTypeFunction %void
|
||||||
%int = OpTypeInt 32 1
|
%int = OpTypeInt 32 1
|
||||||
|
@ -38,11 +38,11 @@
|
||||||
%6 = OpLabel
|
%6 = OpLabel
|
||||||
%i = OpVariable %_ptr_Function_int Function %10
|
%i = OpVariable %_ptr_Function_int Function %10
|
||||||
%j = OpVariable %_ptr_Function_int Function %10
|
%j = OpVariable %_ptr_Function_int Function %10
|
||||||
%var_for_index = OpVariable %_ptr_Function_mat2v2float Function %24
|
%m = OpVariable %_ptr_Function_mat2v2float Function %24
|
||||||
OpStore %var_for_index %21
|
OpStore %m %21
|
||||||
%25 = OpLoad %int %i
|
%25 = OpLoad %int %i
|
||||||
%26 = OpLoad %int %j
|
%26 = OpLoad %int %j
|
||||||
%28 = OpAccessChain %_ptr_Function_float %var_for_index %25 %26
|
%28 = OpAccessChain %_ptr_Function_float %m %25 %26
|
||||||
%29 = OpLoad %float %28
|
%29 = OpLoad %float %28
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
fn f() {
|
fn f() {
|
||||||
var i : i32;
|
var i : i32;
|
||||||
var j : i32;
|
var j : i32;
|
||||||
let m : mat2x2<f32> = mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0));
|
var m : mat2x2<f32> = mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0));
|
||||||
let f : f32 = m[i][j];
|
let f : f32 = m[i][j];
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,13 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
// Vertex shader
|
// Vertex shader
|
||||||
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
|
||||||
vec2<f32>(0.0, 0.5),
|
|
||||||
vec2<f32>(-0.5, -0.5),
|
|
||||||
vec2<f32>(0.5, -0.5));
|
|
||||||
|
|
||||||
[[stage(vertex)]]
|
[[stage(vertex)]]
|
||||||
fn vtx_main([[builtin(vertex_index)]] VertexIndex : u32)
|
fn vtx_main([[builtin(vertex_index)]] VertexIndex : u32)
|
||||||
-> [[builtin(position)]] vec4<f32> {
|
-> [[builtin(position)]] vec4<f32> {
|
||||||
|
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
||||||
|
vec2<f32>(0.0, 0.5),
|
||||||
|
vec2<f32>(-0.5, -0.5),
|
||||||
|
vec2<f32>(0.5, -0.5));
|
||||||
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
struct tint_array_wrapper {
|
|
||||||
float2 arr[3];
|
|
||||||
};
|
|
||||||
|
|
||||||
static const tint_array_wrapper pos = {{float2(0.0f, 0.5f), float2(-0.5f, -0.5f), float2(0.5f, -0.5f)}};
|
|
||||||
|
|
||||||
struct tint_symbol_1 {
|
struct tint_symbol_1 {
|
||||||
uint VertexIndex : SV_VertexID;
|
uint VertexIndex : SV_VertexID;
|
||||||
};
|
};
|
||||||
struct tint_symbol_2 {
|
struct tint_symbol_2 {
|
||||||
float4 value : SV_Position;
|
float4 value : SV_Position;
|
||||||
};
|
};
|
||||||
|
struct tint_array_wrapper {
|
||||||
|
float2 arr[3];
|
||||||
|
};
|
||||||
|
|
||||||
tint_symbol_2 vtx_main(tint_symbol_1 tint_symbol) {
|
tint_symbol_2 vtx_main(tint_symbol_1 tint_symbol) {
|
||||||
const uint VertexIndex = tint_symbol.VertexIndex;
|
const uint VertexIndex = tint_symbol.VertexIndex;
|
||||||
|
tint_array_wrapper pos = {{float2(0.0f, 0.5f), float2(-0.5f, -0.5f), float2(0.5f, -0.5f)}};
|
||||||
const tint_symbol_2 tint_symbol_4 = {float4(pos.arr[VertexIndex], 0.0f, 1.0f)};
|
const tint_symbol_2 tint_symbol_4 = {float4(pos.arr[VertexIndex], 0.0f, 1.0f)};
|
||||||
return tint_symbol_4;
|
return tint_symbol_4;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
#include <metal_stdlib>
|
#include <metal_stdlib>
|
||||||
|
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
struct tint_array_wrapper {
|
|
||||||
float2 arr[3];
|
|
||||||
};
|
|
||||||
struct tint_symbol_1 {
|
struct tint_symbol_1 {
|
||||||
float4 value [[position]];
|
float4 value [[position]];
|
||||||
};
|
};
|
||||||
|
struct tint_array_wrapper {
|
||||||
|
float2 arr[3];
|
||||||
|
};
|
||||||
struct tint_symbol_2 {
|
struct tint_symbol_2 {
|
||||||
float4 value [[color(0)]];
|
float4 value [[color(0)]];
|
||||||
};
|
};
|
||||||
|
|
||||||
constant tint_array_wrapper pos = {.arr={float2(0.0f, 0.5f), float2(-0.5f, -0.5f), float2(0.5f, -0.5f)}};
|
|
||||||
vertex tint_symbol_1 vtx_main(uint VertexIndex [[vertex_id]]) {
|
vertex tint_symbol_1 vtx_main(uint VertexIndex [[vertex_id]]) {
|
||||||
|
tint_array_wrapper pos = {.arr={float2(0.0f, 0.5f), float2(-0.5f, -0.5f), float2(0.5f, -0.5f)}};
|
||||||
tint_symbol_1 const tint_symbol_3 = {.value=float4(pos.arr[VertexIndex], 0.0f, 1.0f)};
|
tint_symbol_1 const tint_symbol_3 = {.value=float4(pos.arr[VertexIndex], 0.0f, 1.0f)};
|
||||||
return tint_symbol_3;
|
return tint_symbol_3;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,65 +9,64 @@
|
||||||
OpEntryPoint Fragment %frag_main "frag_main" %tint_symbol_5
|
OpEntryPoint Fragment %frag_main "frag_main" %tint_symbol_5
|
||||||
OpExecutionMode %frag_main OriginUpperLeft
|
OpExecutionMode %frag_main OriginUpperLeft
|
||||||
OpName %tint_pointsize "tint_pointsize"
|
OpName %tint_pointsize "tint_pointsize"
|
||||||
OpName %pos "pos"
|
|
||||||
OpName %tint_symbol "tint_symbol"
|
OpName %tint_symbol "tint_symbol"
|
||||||
OpName %tint_symbol_2 "tint_symbol_2"
|
OpName %tint_symbol_2 "tint_symbol_2"
|
||||||
OpName %tint_symbol_5 "tint_symbol_5"
|
OpName %tint_symbol_5 "tint_symbol_5"
|
||||||
OpName %tint_symbol_3 "tint_symbol_3"
|
OpName %tint_symbol_3 "tint_symbol_3"
|
||||||
OpName %tint_symbol_1 "tint_symbol_1"
|
OpName %tint_symbol_1 "tint_symbol_1"
|
||||||
OpName %vtx_main "vtx_main"
|
OpName %vtx_main "vtx_main"
|
||||||
OpName %var_for_index "var_for_index"
|
OpName %pos "pos"
|
||||||
OpName %tint_symbol_6 "tint_symbol_6"
|
OpName %tint_symbol_6 "tint_symbol_6"
|
||||||
OpName %tint_symbol_4 "tint_symbol_4"
|
OpName %tint_symbol_4 "tint_symbol_4"
|
||||||
OpName %frag_main "frag_main"
|
OpName %frag_main "frag_main"
|
||||||
OpDecorate %tint_pointsize BuiltIn PointSize
|
OpDecorate %tint_pointsize BuiltIn PointSize
|
||||||
OpDecorate %_arr_v2float_uint_3 ArrayStride 8
|
|
||||||
OpDecorate %tint_symbol BuiltIn VertexIndex
|
OpDecorate %tint_symbol BuiltIn VertexIndex
|
||||||
OpDecorate %tint_symbol_2 BuiltIn Position
|
OpDecorate %tint_symbol_2 BuiltIn Position
|
||||||
OpDecorate %tint_symbol_5 Location 0
|
OpDecorate %tint_symbol_5 Location 0
|
||||||
|
OpDecorate %_arr_v2float_uint_3 ArrayStride 8
|
||||||
%float = OpTypeFloat 32
|
%float = OpTypeFloat 32
|
||||||
%_ptr_Output_float = OpTypePointer Output %float
|
%_ptr_Output_float = OpTypePointer Output %float
|
||||||
%4 = OpConstantNull %float
|
%4 = OpConstantNull %float
|
||||||
%tint_pointsize = OpVariable %_ptr_Output_float Output %4
|
%tint_pointsize = OpVariable %_ptr_Output_float Output %4
|
||||||
%v2float = OpTypeVector %float 2
|
|
||||||
%uint = OpTypeInt 32 0
|
%uint = OpTypeInt 32 0
|
||||||
%uint_3 = OpConstant %uint 3
|
|
||||||
%_arr_v2float_uint_3 = OpTypeArray %v2float %uint_3
|
|
||||||
%float_0 = OpConstant %float 0
|
|
||||||
%float_0_5 = OpConstant %float 0.5
|
|
||||||
%11 = OpConstantComposite %v2float %float_0 %float_0_5
|
|
||||||
%float_n0_5 = OpConstant %float -0.5
|
|
||||||
%13 = OpConstantComposite %v2float %float_n0_5 %float_n0_5
|
|
||||||
%14 = OpConstantComposite %v2float %float_0_5 %float_n0_5
|
|
||||||
%pos = OpConstantComposite %_arr_v2float_uint_3 %11 %13 %14
|
|
||||||
%_ptr_Input_uint = OpTypePointer Input %uint
|
%_ptr_Input_uint = OpTypePointer Input %uint
|
||||||
%tint_symbol = OpVariable %_ptr_Input_uint Input
|
%tint_symbol = OpVariable %_ptr_Input_uint Input
|
||||||
%v4float = OpTypeVector %float 4
|
%v4float = OpTypeVector %float 4
|
||||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||||
%21 = OpConstantNull %v4float
|
%11 = OpConstantNull %v4float
|
||||||
%tint_symbol_2 = OpVariable %_ptr_Output_v4float Output %21
|
%tint_symbol_2 = OpVariable %_ptr_Output_v4float Output %11
|
||||||
%tint_symbol_5 = OpVariable %_ptr_Output_v4float Output %21
|
%tint_symbol_5 = OpVariable %_ptr_Output_v4float Output %11
|
||||||
%void = OpTypeVoid
|
%void = OpTypeVoid
|
||||||
%23 = OpTypeFunction %void %v4float
|
%13 = OpTypeFunction %void %v4float
|
||||||
%28 = OpTypeFunction %void
|
%18 = OpTypeFunction %void
|
||||||
%float_1 = OpConstant %float 1
|
%float_1 = OpConstant %float 1
|
||||||
|
%v2float = OpTypeVector %float 2
|
||||||
|
%uint_3 = OpConstant %uint 3
|
||||||
|
%_arr_v2float_uint_3 = OpTypeArray %v2float %uint_3
|
||||||
|
%float_0 = OpConstant %float 0
|
||||||
|
%float_0_5 = OpConstant %float 0.5
|
||||||
|
%27 = OpConstantComposite %v2float %float_0 %float_0_5
|
||||||
|
%float_n0_5 = OpConstant %float -0.5
|
||||||
|
%29 = OpConstantComposite %v2float %float_n0_5 %float_n0_5
|
||||||
|
%30 = OpConstantComposite %v2float %float_0_5 %float_n0_5
|
||||||
|
%31 = OpConstantComposite %_arr_v2float_uint_3 %27 %29 %30
|
||||||
%_ptr_Function__arr_v2float_uint_3 = OpTypePointer Function %_arr_v2float_uint_3
|
%_ptr_Function__arr_v2float_uint_3 = OpTypePointer Function %_arr_v2float_uint_3
|
||||||
%34 = OpConstantNull %_arr_v2float_uint_3
|
%34 = OpConstantNull %_arr_v2float_uint_3
|
||||||
%_ptr_Function_v2float = OpTypePointer Function %v2float
|
%_ptr_Function_v2float = OpTypePointer Function %v2float
|
||||||
%49 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
|
%49 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
|
||||||
%tint_symbol_3 = OpFunction %void None %23
|
%tint_symbol_3 = OpFunction %void None %13
|
||||||
%tint_symbol_1 = OpFunctionParameter %v4float
|
%tint_symbol_1 = OpFunctionParameter %v4float
|
||||||
%27 = OpLabel
|
%17 = OpLabel
|
||||||
OpStore %tint_symbol_2 %tint_symbol_1
|
OpStore %tint_symbol_2 %tint_symbol_1
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vtx_main = OpFunction %void None %28
|
%vtx_main = OpFunction %void None %18
|
||||||
%30 = OpLabel
|
%20 = OpLabel
|
||||||
%var_for_index = OpVariable %_ptr_Function__arr_v2float_uint_3 Function %34
|
%pos = OpVariable %_ptr_Function__arr_v2float_uint_3 Function %34
|
||||||
OpStore %tint_pointsize %float_1
|
OpStore %tint_pointsize %float_1
|
||||||
OpStore %var_for_index %pos
|
OpStore %pos %31
|
||||||
%36 = OpLoad %uint %tint_symbol
|
%36 = OpLoad %uint %tint_symbol
|
||||||
%38 = OpAccessChain %_ptr_Function_v2float %var_for_index %36
|
%38 = OpAccessChain %_ptr_Function_v2float %pos %36
|
||||||
%39 = OpLoad %v2float %38
|
%39 = OpLoad %v2float %38
|
||||||
%40 = OpCompositeExtract %float %39 0
|
%40 = OpCompositeExtract %float %39 0
|
||||||
%41 = OpCompositeExtract %float %39 1
|
%41 = OpCompositeExtract %float %39 1
|
||||||
|
@ -75,13 +74,13 @@
|
||||||
%35 = OpFunctionCall %void %tint_symbol_3 %42
|
%35 = OpFunctionCall %void %tint_symbol_3 %42
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%tint_symbol_6 = OpFunction %void None %23
|
%tint_symbol_6 = OpFunction %void None %13
|
||||||
%tint_symbol_4 = OpFunctionParameter %v4float
|
%tint_symbol_4 = OpFunctionParameter %v4float
|
||||||
%45 = OpLabel
|
%45 = OpLabel
|
||||||
OpStore %tint_symbol_5 %tint_symbol_4
|
OpStore %tint_symbol_5 %tint_symbol_4
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%frag_main = OpFunction %void None %28
|
%frag_main = OpFunction %void None %18
|
||||||
%47 = OpLabel
|
%47 = OpLabel
|
||||||
%48 = OpFunctionCall %void %tint_symbol_6 %49
|
%48 = OpFunctionCall %void %tint_symbol_6 %49
|
||||||
OpReturn
|
OpReturn
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(vec2<f32>(0.0, 0.5), vec2<f32>(-0.5, -0.5), vec2<f32>(0.5, -0.5));
|
|
||||||
|
|
||||||
[[stage(vertex)]]
|
[[stage(vertex)]]
|
||||||
fn vtx_main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
fn vtx_main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||||
|
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(vec2<f32>(0.0, 0.5), vec2<f32>(-0.5, -0.5), vec2<f32>(0.5, -0.5));
|
||||||
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue