2020-08-12 17:23:58 +00:00
|
|
|
// Copyright 2020 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.
|
|
|
|
|
2020-12-04 09:06:09 +00:00
|
|
|
#include "src/transform/vertex_pulling.h"
|
2020-08-12 17:23:58 +00:00
|
|
|
|
2020-11-03 16:26:09 +00:00
|
|
|
#include <utility>
|
|
|
|
|
2020-08-12 17:23:58 +00:00
|
|
|
#include "gtest/gtest.h"
|
2020-12-15 14:10:28 +00:00
|
|
|
#include "src/ast/builder.h"
|
2020-08-12 17:23:58 +00:00
|
|
|
#include "src/ast/function.h"
|
2020-09-22 14:53:03 +00:00
|
|
|
#include "src/ast/pipeline_stage.h"
|
|
|
|
#include "src/ast/stage_decoration.h"
|
2020-08-12 17:23:58 +00:00
|
|
|
#include "src/ast/type/array_type.h"
|
|
|
|
#include "src/ast/type/f32_type.h"
|
|
|
|
#include "src/ast/type/i32_type.h"
|
|
|
|
#include "src/ast/type/void_type.h"
|
2020-12-11 19:16:13 +00:00
|
|
|
#include "src/demangler.h"
|
2020-12-04 09:06:09 +00:00
|
|
|
#include "src/diagnostic/formatter.h"
|
2020-11-18 19:40:00 +00:00
|
|
|
#include "src/transform/manager.h"
|
2020-08-12 17:23:58 +00:00
|
|
|
#include "src/type_determiner.h"
|
2020-11-06 17:31:15 +00:00
|
|
|
#include "src/validator/validator.h"
|
2020-08-12 17:23:58 +00:00
|
|
|
|
|
|
|
namespace tint {
|
|
|
|
namespace transform {
|
|
|
|
namespace {
|
|
|
|
|
2020-12-15 14:10:28 +00:00
|
|
|
class VertexPullingHelper : public ast::BuilderWithModule {
|
2020-08-12 17:23:58 +00:00
|
|
|
public:
|
2020-12-04 09:06:09 +00:00
|
|
|
VertexPullingHelper() {
|
|
|
|
manager_ = std::make_unique<Manager>();
|
|
|
|
auto transform = std::make_unique<VertexPulling>();
|
2020-11-18 19:40:00 +00:00
|
|
|
transform_ = transform.get();
|
|
|
|
manager_->append(std::move(transform));
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create basic module with an entry point and vertex function
|
|
|
|
void InitBasicModule() {
|
2020-12-16 15:15:40 +00:00
|
|
|
auto* func =
|
|
|
|
Func("main", ast::VariableList{}, ty.void_, ast::StatementList{},
|
|
|
|
ast::FunctionDecorationList{
|
|
|
|
create<ast::StageDecoration>(ast::PipelineStage::kVertex)});
|
2020-12-15 14:10:28 +00:00
|
|
|
mod->AddFunction(func);
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set up the transformation, after building the module
|
|
|
|
void InitTransform(VertexStateDescriptor vertex_state) {
|
2020-12-15 14:10:28 +00:00
|
|
|
EXPECT_TRUE(mod->IsValid());
|
2020-08-12 17:23:58 +00:00
|
|
|
|
2020-12-15 14:10:28 +00:00
|
|
|
TypeDeterminer td(mod);
|
2020-08-12 17:23:58 +00:00
|
|
|
EXPECT_TRUE(td.Determine());
|
|
|
|
|
2020-12-04 09:06:09 +00:00
|
|
|
transform_->SetVertexState(vertex_state);
|
2020-08-12 17:23:58 +00:00
|
|
|
transform_->SetEntryPoint("main");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Inserts a variable which will be converted to vertex pulling
|
|
|
|
void AddVertexInputVariable(uint32_t location,
|
|
|
|
std::string name,
|
2020-09-24 14:30:34 +00:00
|
|
|
ast::type::Type* type) {
|
2020-12-15 14:10:28 +00:00
|
|
|
auto* var = Var(name, ast::StorageClass::kInput, type, nullptr,
|
|
|
|
ast::VariableDecorationList{
|
|
|
|
create<ast::LocationDecoration>(location),
|
|
|
|
});
|
2020-08-12 17:23:58 +00:00
|
|
|
|
2020-12-15 14:10:28 +00:00
|
|
|
mod->AddGlobalVariable(var);
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
2020-11-18 19:40:00 +00:00
|
|
|
Manager* manager() { return manager_.get(); }
|
2020-12-04 09:06:09 +00:00
|
|
|
VertexPulling* transform() { return transform_; }
|
2020-08-12 17:23:58 +00:00
|
|
|
|
|
|
|
private:
|
2020-11-18 19:40:00 +00:00
|
|
|
std::unique_ptr<Manager> manager_;
|
2020-12-04 09:06:09 +00:00
|
|
|
VertexPulling* transform_;
|
2020-08-12 17:23:58 +00:00
|
|
|
};
|
|
|
|
|
2020-12-04 09:06:09 +00:00
|
|
|
class VertexPullingTest : public VertexPullingHelper, public testing::Test {};
|
2020-08-12 17:23:58 +00:00
|
|
|
|
2020-12-04 09:06:09 +00:00
|
|
|
TEST_F(VertexPullingTest, Error_NoVertexState) {
|
2020-12-15 14:10:28 +00:00
|
|
|
auto result = manager()->Run(mod);
|
2020-12-04 09:06:09 +00:00
|
|
|
EXPECT_TRUE(result.diagnostics.contains_errors());
|
|
|
|
EXPECT_EQ(diag::Formatter().format(result.diagnostics),
|
|
|
|
"error: SetVertexState not called");
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:06:09 +00:00
|
|
|
TEST_F(VertexPullingTest, Error_NoEntryPoint) {
|
|
|
|
transform()->SetVertexState({});
|
2020-12-15 14:10:28 +00:00
|
|
|
auto result = manager()->Run(mod);
|
2020-12-04 09:06:09 +00:00
|
|
|
EXPECT_TRUE(result.diagnostics.contains_errors());
|
|
|
|
EXPECT_EQ(diag::Formatter().format(result.diagnostics),
|
|
|
|
"error: Vertex stage entry point not found");
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:06:09 +00:00
|
|
|
TEST_F(VertexPullingTest, Error_InvalidEntryPoint) {
|
2020-08-12 17:23:58 +00:00
|
|
|
InitBasicModule();
|
|
|
|
InitTransform({});
|
|
|
|
transform()->SetEntryPoint("_");
|
|
|
|
|
2020-12-15 14:10:28 +00:00
|
|
|
auto result = manager()->Run(mod);
|
2020-12-04 09:06:09 +00:00
|
|
|
EXPECT_TRUE(result.diagnostics.contains_errors());
|
|
|
|
EXPECT_EQ(diag::Formatter().format(result.diagnostics),
|
|
|
|
"error: Vertex stage entry point not found");
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:06:09 +00:00
|
|
|
TEST_F(VertexPullingTest, Error_EntryPointWrongStage) {
|
2020-12-16 15:15:40 +00:00
|
|
|
auto* func =
|
|
|
|
Func("main", ast::VariableList{}, ty.void_, ast::StatementList{},
|
|
|
|
ast::FunctionDecorationList{
|
|
|
|
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
|
|
|
});
|
2020-12-15 14:10:28 +00:00
|
|
|
mod->AddFunction(func);
|
2020-08-12 17:23:58 +00:00
|
|
|
|
|
|
|
InitTransform({});
|
2020-12-15 14:10:28 +00:00
|
|
|
auto result = manager()->Run(mod);
|
2020-12-04 09:06:09 +00:00
|
|
|
EXPECT_TRUE(result.diagnostics.contains_errors());
|
|
|
|
EXPECT_EQ(diag::Formatter().format(result.diagnostics),
|
|
|
|
"error: Vertex stage entry point not found");
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:06:09 +00:00
|
|
|
TEST_F(VertexPullingTest, BasicModule) {
|
2020-08-12 17:23:58 +00:00
|
|
|
InitBasicModule();
|
|
|
|
InitTransform({});
|
2020-12-15 14:10:28 +00:00
|
|
|
auto result = manager()->Run(mod);
|
2020-12-11 18:24:53 +00:00
|
|
|
ASSERT_FALSE(result.diagnostics.contains_errors())
|
|
|
|
<< diag::Formatter().format(result.diagnostics);
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:06:09 +00:00
|
|
|
TEST_F(VertexPullingTest, OneAttribute) {
|
2020-08-12 17:23:58 +00:00
|
|
|
InitBasicModule();
|
|
|
|
|
2020-11-30 23:30:58 +00:00
|
|
|
ast::type::F32 f32;
|
2020-08-12 17:23:58 +00:00
|
|
|
AddVertexInputVariable(0, "var_a", &f32);
|
|
|
|
|
|
|
|
InitTransform({{{4, InputStepMode::kVertex, {{VertexFormat::kF32, 0, 0}}}}});
|
|
|
|
|
2020-12-15 14:10:28 +00:00
|
|
|
auto result = manager()->Run(mod);
|
2020-12-11 18:24:53 +00:00
|
|
|
ASSERT_FALSE(result.diagnostics.contains_errors())
|
|
|
|
<< diag::Formatter().format(result.diagnostics);
|
2020-08-12 17:23:58 +00:00
|
|
|
|
|
|
|
EXPECT_EQ(R"(Module{
|
2020-10-19 15:31:47 +00:00
|
|
|
TintVertexData Struct{
|
2020-10-15 18:04:44 +00:00
|
|
|
[[block]]
|
|
|
|
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:23:58 +00:00
|
|
|
Decorations{
|
|
|
|
BuiltinDecoration{vertex_idx}
|
|
|
|
}
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_vertex_index
|
2020-08-12 17:23:58 +00:00
|
|
|
in
|
|
|
|
__i32
|
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:23:58 +00:00
|
|
|
Decorations{
|
|
|
|
BindingDecoration{0}
|
2020-08-12 17:44:01 +00:00
|
|
|
SetDecoration{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_vertex_buffer_0
|
2020-08-12 17:23:58 +00:00
|
|
|
storage_buffer
|
2020-10-19 15:31:47 +00:00
|
|
|
__struct_TintVertexData
|
2020-10-15 17:54:13 +00:00
|
|
|
}
|
2020-12-14 20:31:17 +00:00
|
|
|
Variable{
|
|
|
|
var_a
|
|
|
|
private
|
|
|
|
__f32
|
|
|
|
}
|
2020-12-11 19:16:13 +00:00
|
|
|
Function main -> __void
|
2020-09-22 14:53:03 +00:00
|
|
|
StageDecoration{vertex}
|
2020-08-12 17:23:58 +00:00
|
|
|
()
|
|
|
|
{
|
|
|
|
Block{
|
|
|
|
VariableDeclStatement{
|
|
|
|
Variable{
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_pos
|
2020-08-12 17:23:58 +00:00
|
|
|
function
|
|
|
|
__i32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_in__i32]{_tint_pulling_vertex_index}
|
2020-08-12 17:23:58 +00:00
|
|
|
multiply
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_private__f32]{var_a}
|
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_0}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)",
|
2020-12-11 19:16:13 +00:00
|
|
|
Demangler().Demangle(result.module, result.module.to_str()));
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:06:09 +00:00
|
|
|
TEST_F(VertexPullingTest, OneInstancedAttribute) {
|
2020-08-12 17:23:58 +00:00
|
|
|
InitBasicModule();
|
|
|
|
|
2020-11-30 23:30:58 +00:00
|
|
|
ast::type::F32 f32;
|
2020-08-12 17:23:58 +00:00
|
|
|
AddVertexInputVariable(0, "var_a", &f32);
|
|
|
|
|
2020-08-12 17:30:08 +00:00
|
|
|
InitTransform(
|
|
|
|
{{{4, InputStepMode::kInstance, {{VertexFormat::kF32, 0, 0}}}}});
|
|
|
|
|
2020-12-15 14:10:28 +00:00
|
|
|
auto result = manager()->Run(mod);
|
2020-12-11 18:24:53 +00:00
|
|
|
ASSERT_FALSE(result.diagnostics.contains_errors())
|
|
|
|
<< diag::Formatter().format(result.diagnostics);
|
2020-08-12 17:30:08 +00:00
|
|
|
|
|
|
|
EXPECT_EQ(R"(Module{
|
2020-10-19 15:31:47 +00:00
|
|
|
TintVertexData Struct{
|
2020-10-15 18:04:44 +00:00
|
|
|
[[block]]
|
|
|
|
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:30:08 +00:00
|
|
|
Decorations{
|
|
|
|
BuiltinDecoration{instance_idx}
|
|
|
|
}
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_instance_index
|
2020-08-12 17:30:08 +00:00
|
|
|
in
|
|
|
|
__i32
|
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:30:08 +00:00
|
|
|
Decorations{
|
|
|
|
BindingDecoration{0}
|
2020-08-12 17:44:01 +00:00
|
|
|
SetDecoration{4}
|
2020-08-12 17:30:08 +00:00
|
|
|
}
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_vertex_buffer_0
|
2020-08-12 17:30:08 +00:00
|
|
|
storage_buffer
|
2020-10-19 15:31:47 +00:00
|
|
|
__struct_TintVertexData
|
2020-10-15 17:54:13 +00:00
|
|
|
}
|
2020-12-14 20:31:17 +00:00
|
|
|
Variable{
|
|
|
|
var_a
|
|
|
|
private
|
|
|
|
__f32
|
|
|
|
}
|
2020-12-11 19:16:13 +00:00
|
|
|
Function main -> __void
|
2020-09-22 14:53:03 +00:00
|
|
|
StageDecoration{vertex}
|
2020-08-12 17:30:08 +00:00
|
|
|
()
|
|
|
|
{
|
|
|
|
Block{
|
|
|
|
VariableDeclStatement{
|
|
|
|
Variable{
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_pos
|
2020-08-12 17:30:08 +00:00
|
|
|
function
|
|
|
|
__i32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_in__i32]{_tint_pulling_instance_index}
|
2020-08-12 17:30:08 +00:00
|
|
|
multiply
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:30:08 +00:00
|
|
|
}
|
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:30:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_private__f32]{var_a}
|
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_0}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:30:08 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:30:08 +00:00
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:30:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)",
|
2020-12-11 19:16:13 +00:00
|
|
|
Demangler().Demangle(result.module, result.module.to_str()));
|
2020-08-12 17:30:08 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:06:09 +00:00
|
|
|
TEST_F(VertexPullingTest, OneAttributeDifferentOutputSet) {
|
2020-08-12 17:44:01 +00:00
|
|
|
InitBasicModule();
|
|
|
|
|
2020-11-30 23:30:58 +00:00
|
|
|
ast::type::F32 f32;
|
2020-08-12 17:44:01 +00:00
|
|
|
AddVertexInputVariable(0, "var_a", &f32);
|
|
|
|
|
|
|
|
InitTransform({{{4, InputStepMode::kVertex, {{VertexFormat::kF32, 0, 0}}}}});
|
|
|
|
transform()->SetPullingBufferBindingSet(5);
|
|
|
|
|
2020-12-15 14:10:28 +00:00
|
|
|
auto result = manager()->Run(mod);
|
2020-12-11 18:24:53 +00:00
|
|
|
ASSERT_FALSE(result.diagnostics.contains_errors())
|
|
|
|
<< diag::Formatter().format(result.diagnostics);
|
2020-08-12 17:44:01 +00:00
|
|
|
|
|
|
|
EXPECT_EQ(R"(Module{
|
2020-10-19 15:31:47 +00:00
|
|
|
TintVertexData Struct{
|
2020-10-15 18:04:44 +00:00
|
|
|
[[block]]
|
|
|
|
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:44:01 +00:00
|
|
|
Decorations{
|
|
|
|
BuiltinDecoration{vertex_idx}
|
|
|
|
}
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_vertex_index
|
2020-08-12 17:44:01 +00:00
|
|
|
in
|
|
|
|
__i32
|
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:44:01 +00:00
|
|
|
Decorations{
|
|
|
|
BindingDecoration{0}
|
|
|
|
SetDecoration{5}
|
|
|
|
}
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_vertex_buffer_0
|
2020-08-12 17:44:01 +00:00
|
|
|
storage_buffer
|
2020-10-19 15:31:47 +00:00
|
|
|
__struct_TintVertexData
|
2020-10-15 17:54:13 +00:00
|
|
|
}
|
2020-12-14 20:31:17 +00:00
|
|
|
Variable{
|
|
|
|
var_a
|
|
|
|
private
|
|
|
|
__f32
|
|
|
|
}
|
2020-12-11 19:16:13 +00:00
|
|
|
Function main -> __void
|
2020-09-22 14:53:03 +00:00
|
|
|
StageDecoration{vertex}
|
2020-08-12 17:44:01 +00:00
|
|
|
()
|
|
|
|
{
|
|
|
|
Block{
|
|
|
|
VariableDeclStatement{
|
|
|
|
Variable{
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_pos
|
2020-08-12 17:44:01 +00:00
|
|
|
function
|
|
|
|
__i32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_in__i32]{_tint_pulling_vertex_index}
|
2020-08-12 17:44:01 +00:00
|
|
|
multiply
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:44:01 +00:00
|
|
|
}
|
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:44:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_private__f32]{var_a}
|
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_0}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:44:01 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:44:01 +00:00
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:44:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)",
|
2020-12-11 19:16:13 +00:00
|
|
|
Demangler().Demangle(result.module, result.module.to_str()));
|
2020-08-12 17:44:01 +00:00
|
|
|
}
|
|
|
|
|
2020-08-12 17:30:08 +00:00
|
|
|
// We expect the transform to use an existing builtin variables if it finds them
|
2020-12-04 09:06:09 +00:00
|
|
|
TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex) {
|
2020-08-12 17:30:08 +00:00
|
|
|
InitBasicModule();
|
|
|
|
|
2020-11-30 23:30:58 +00:00
|
|
|
ast::type::F32 f32;
|
2020-08-12 17:30:08 +00:00
|
|
|
AddVertexInputVariable(0, "var_a", &f32);
|
|
|
|
AddVertexInputVariable(1, "var_b", &f32);
|
|
|
|
|
2020-11-30 23:30:58 +00:00
|
|
|
ast::type::I32 i32;
|
2020-08-12 17:30:08 +00:00
|
|
|
|
2020-12-15 14:10:28 +00:00
|
|
|
mod->AddGlobalVariable(
|
|
|
|
Var("custom_vertex_index", ast::StorageClass::kInput, &i32, nullptr,
|
|
|
|
ast::VariableDecorationList{
|
|
|
|
create<ast::BuiltinDecoration>(ast::Builtin::kVertexIdx),
|
|
|
|
}));
|
|
|
|
|
|
|
|
mod->AddGlobalVariable(
|
|
|
|
Var("custom_instance_index", ast::StorageClass::kInput, &i32, nullptr,
|
|
|
|
ast::VariableDecorationList{
|
|
|
|
create<ast::BuiltinDecoration>(ast::Builtin::kInstanceIdx),
|
|
|
|
}));
|
2020-08-12 17:30:08 +00:00
|
|
|
|
|
|
|
InitTransform(
|
|
|
|
{{{4, InputStepMode::kVertex, {{VertexFormat::kF32, 0, 0}}},
|
|
|
|
{4, InputStepMode::kInstance, {{VertexFormat::kF32, 0, 1}}}}});
|
2020-08-12 17:23:58 +00:00
|
|
|
|
2020-12-15 14:10:28 +00:00
|
|
|
auto result = manager()->Run(mod);
|
2020-12-11 18:24:53 +00:00
|
|
|
ASSERT_FALSE(result.diagnostics.contains_errors())
|
|
|
|
<< diag::Formatter().format(result.diagnostics);
|
2020-08-12 17:23:58 +00:00
|
|
|
|
|
|
|
EXPECT_EQ(R"(Module{
|
2020-10-19 15:31:47 +00:00
|
|
|
TintVertexData Struct{
|
2020-10-15 18:04:44 +00:00
|
|
|
[[block]]
|
|
|
|
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
|
|
|
}
|
2020-12-14 20:31:17 +00:00
|
|
|
Variable{
|
|
|
|
Decorations{
|
|
|
|
BindingDecoration{0}
|
|
|
|
SetDecoration{4}
|
|
|
|
}
|
|
|
|
_tint_pulling_vertex_buffer_0
|
|
|
|
storage_buffer
|
|
|
|
__struct_TintVertexData
|
|
|
|
}
|
|
|
|
Variable{
|
|
|
|
Decorations{
|
|
|
|
BindingDecoration{1}
|
|
|
|
SetDecoration{4}
|
|
|
|
}
|
|
|
|
_tint_pulling_vertex_buffer_1
|
|
|
|
storage_buffer
|
|
|
|
__struct_TintVertexData
|
|
|
|
}
|
2020-08-12 17:23:58 +00:00
|
|
|
Variable{
|
|
|
|
var_a
|
|
|
|
private
|
|
|
|
__f32
|
|
|
|
}
|
2020-08-12 17:30:08 +00:00
|
|
|
Variable{
|
|
|
|
var_b
|
|
|
|
private
|
|
|
|
__f32
|
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:23:58 +00:00
|
|
|
Decorations{
|
|
|
|
BuiltinDecoration{vertex_idx}
|
|
|
|
}
|
|
|
|
custom_vertex_index
|
|
|
|
in
|
|
|
|
__i32
|
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:30:08 +00:00
|
|
|
Decorations{
|
|
|
|
BuiltinDecoration{instance_idx}
|
|
|
|
}
|
|
|
|
custom_instance_index
|
|
|
|
in
|
|
|
|
__i32
|
|
|
|
}
|
2020-12-11 19:16:13 +00:00
|
|
|
Function main -> __void
|
2020-09-22 14:53:03 +00:00
|
|
|
StageDecoration{vertex}
|
2020-08-12 17:23:58 +00:00
|
|
|
()
|
|
|
|
{
|
|
|
|
Block{
|
|
|
|
VariableDeclStatement{
|
|
|
|
Variable{
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_pos
|
2020-08-12 17:23:58 +00:00
|
|
|
function
|
|
|
|
__i32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_in__i32]{custom_vertex_index}
|
2020-08-12 17:23:58 +00:00
|
|
|
multiply
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_private__f32]{var_a}
|
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_0}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:30:08 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:30:08 +00:00
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:30:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_in__i32]{custom_instance_index}
|
2020-08-12 17:30:08 +00:00
|
|
|
multiply
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:30:08 +00:00
|
|
|
}
|
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:30:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_private__f32]{var_b}
|
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_1}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)",
|
2020-12-11 19:16:13 +00:00
|
|
|
Demangler().Demangle(result.module, result.module.to_str()));
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:06:09 +00:00
|
|
|
TEST_F(VertexPullingTest, TwoAttributesSameBuffer) {
|
2020-08-12 17:23:58 +00:00
|
|
|
InitBasicModule();
|
|
|
|
|
2020-11-30 23:30:58 +00:00
|
|
|
ast::type::F32 f32;
|
2020-08-12 17:23:58 +00:00
|
|
|
AddVertexInputVariable(0, "var_a", &f32);
|
|
|
|
|
2020-12-07 22:19:27 +00:00
|
|
|
ast::type::Array vec4_f32{&f32, 4u, ast::ArrayDecorationList{}};
|
2020-08-12 17:23:58 +00:00
|
|
|
AddVertexInputVariable(1, "var_b", &vec4_f32);
|
|
|
|
|
|
|
|
InitTransform(
|
|
|
|
{{{16,
|
|
|
|
InputStepMode::kVertex,
|
|
|
|
{{VertexFormat::kF32, 0, 0}, {VertexFormat::kVec4F32, 0, 1}}}}});
|
|
|
|
|
2020-12-15 14:10:28 +00:00
|
|
|
auto result = manager()->Run(mod);
|
2020-12-11 18:24:53 +00:00
|
|
|
ASSERT_FALSE(result.diagnostics.contains_errors())
|
|
|
|
<< diag::Formatter().format(result.diagnostics);
|
2020-08-12 17:23:58 +00:00
|
|
|
|
|
|
|
EXPECT_EQ(R"(Module{
|
2020-10-19 15:31:47 +00:00
|
|
|
TintVertexData Struct{
|
2020-10-15 18:04:44 +00:00
|
|
|
[[block]]
|
|
|
|
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:23:58 +00:00
|
|
|
Decorations{
|
|
|
|
BuiltinDecoration{vertex_idx}
|
|
|
|
}
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_vertex_index
|
2020-08-12 17:23:58 +00:00
|
|
|
in
|
|
|
|
__i32
|
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:23:58 +00:00
|
|
|
Decorations{
|
|
|
|
BindingDecoration{0}
|
2020-08-12 17:44:01 +00:00
|
|
|
SetDecoration{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_vertex_buffer_0
|
2020-08-12 17:23:58 +00:00
|
|
|
storage_buffer
|
2020-10-19 15:31:47 +00:00
|
|
|
__struct_TintVertexData
|
2020-10-15 17:54:13 +00:00
|
|
|
}
|
2020-12-14 20:31:17 +00:00
|
|
|
Variable{
|
|
|
|
var_a
|
|
|
|
private
|
|
|
|
__f32
|
|
|
|
}
|
|
|
|
Variable{
|
|
|
|
var_b
|
|
|
|
private
|
|
|
|
__array__f32_4
|
|
|
|
}
|
2020-12-11 19:16:13 +00:00
|
|
|
Function main -> __void
|
2020-09-22 14:53:03 +00:00
|
|
|
StageDecoration{vertex}
|
2020-08-12 17:23:58 +00:00
|
|
|
()
|
|
|
|
{
|
|
|
|
Block{
|
|
|
|
VariableDeclStatement{
|
|
|
|
Variable{
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_pos
|
2020-08-12 17:23:58 +00:00
|
|
|
function
|
|
|
|
__i32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_in__i32]{_tint_pulling_vertex_index}
|
2020-08-12 17:23:58 +00:00
|
|
|
multiply
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{16}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_private__f32]{var_a}
|
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_0}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_in__i32]{_tint_pulling_vertex_index}
|
2020-08-12 17:23:58 +00:00
|
|
|
multiply
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{16}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_private__array__f32_4]{var_b}
|
|
|
|
TypeConstructor[__vec_4__f32]{
|
2020-08-12 17:23:58 +00:00
|
|
|
__vec_4__f32
|
2020-11-16 14:46:27 +00:00
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_0}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_0}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_0}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{8}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_0}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{12}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)",
|
2020-12-11 19:16:13 +00:00
|
|
|
Demangler().Demangle(result.module, result.module.to_str()));
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:06:09 +00:00
|
|
|
TEST_F(VertexPullingTest, FloatVectorAttributes) {
|
2020-08-12 17:23:58 +00:00
|
|
|
InitBasicModule();
|
|
|
|
|
2020-11-30 23:30:58 +00:00
|
|
|
ast::type::F32 f32;
|
2020-12-07 22:19:27 +00:00
|
|
|
ast::type::Array vec2_f32{&f32, 2u, ast::ArrayDecorationList{}};
|
2020-08-12 17:23:58 +00:00
|
|
|
AddVertexInputVariable(0, "var_a", &vec2_f32);
|
|
|
|
|
2020-12-07 22:19:27 +00:00
|
|
|
ast::type::Array vec3_f32{&f32, 3u, ast::ArrayDecorationList{}};
|
2020-08-12 17:23:58 +00:00
|
|
|
AddVertexInputVariable(1, "var_b", &vec3_f32);
|
|
|
|
|
2020-12-07 22:19:27 +00:00
|
|
|
ast::type::Array vec4_f32{&f32, 4u, ast::ArrayDecorationList{}};
|
2020-08-12 17:23:58 +00:00
|
|
|
AddVertexInputVariable(2, "var_c", &vec4_f32);
|
|
|
|
|
|
|
|
InitTransform(
|
|
|
|
{{{8, InputStepMode::kVertex, {{VertexFormat::kVec2F32, 0, 0}}},
|
|
|
|
{12, InputStepMode::kVertex, {{VertexFormat::kVec3F32, 0, 1}}},
|
|
|
|
{16, InputStepMode::kVertex, {{VertexFormat::kVec4F32, 0, 2}}}}});
|
|
|
|
|
2020-12-15 14:10:28 +00:00
|
|
|
auto result = manager()->Run(mod);
|
2020-12-11 18:24:53 +00:00
|
|
|
ASSERT_FALSE(result.diagnostics.contains_errors())
|
|
|
|
<< diag::Formatter().format(result.diagnostics);
|
2020-08-12 17:23:58 +00:00
|
|
|
|
|
|
|
EXPECT_EQ(R"(Module{
|
2020-10-19 15:31:47 +00:00
|
|
|
TintVertexData Struct{
|
2020-10-15 18:04:44 +00:00
|
|
|
[[block]]
|
|
|
|
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:23:58 +00:00
|
|
|
Decorations{
|
|
|
|
BuiltinDecoration{vertex_idx}
|
|
|
|
}
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_vertex_index
|
2020-08-12 17:23:58 +00:00
|
|
|
in
|
|
|
|
__i32
|
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:23:58 +00:00
|
|
|
Decorations{
|
|
|
|
BindingDecoration{0}
|
2020-08-12 17:44:01 +00:00
|
|
|
SetDecoration{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_vertex_buffer_0
|
2020-08-12 17:23:58 +00:00
|
|
|
storage_buffer
|
2020-10-19 15:31:47 +00:00
|
|
|
__struct_TintVertexData
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:23:58 +00:00
|
|
|
Decorations{
|
|
|
|
BindingDecoration{1}
|
2020-08-12 17:44:01 +00:00
|
|
|
SetDecoration{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_vertex_buffer_1
|
2020-08-12 17:23:58 +00:00
|
|
|
storage_buffer
|
2020-10-19 15:31:47 +00:00
|
|
|
__struct_TintVertexData
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-12-11 13:07:02 +00:00
|
|
|
Variable{
|
2020-08-12 17:23:58 +00:00
|
|
|
Decorations{
|
|
|
|
BindingDecoration{2}
|
2020-08-12 17:44:01 +00:00
|
|
|
SetDecoration{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_vertex_buffer_2
|
2020-08-12 17:23:58 +00:00
|
|
|
storage_buffer
|
2020-10-19 15:31:47 +00:00
|
|
|
__struct_TintVertexData
|
2020-10-15 17:54:13 +00:00
|
|
|
}
|
2020-12-14 20:31:17 +00:00
|
|
|
Variable{
|
|
|
|
var_a
|
|
|
|
private
|
|
|
|
__array__f32_2
|
|
|
|
}
|
|
|
|
Variable{
|
|
|
|
var_b
|
|
|
|
private
|
|
|
|
__array__f32_3
|
|
|
|
}
|
|
|
|
Variable{
|
|
|
|
var_c
|
|
|
|
private
|
|
|
|
__array__f32_4
|
|
|
|
}
|
2020-12-11 19:16:13 +00:00
|
|
|
Function main -> __void
|
2020-09-22 14:53:03 +00:00
|
|
|
StageDecoration{vertex}
|
2020-08-12 17:23:58 +00:00
|
|
|
()
|
|
|
|
{
|
|
|
|
Block{
|
|
|
|
VariableDeclStatement{
|
|
|
|
Variable{
|
2020-09-24 14:32:48 +00:00
|
|
|
_tint_pulling_pos
|
2020-08-12 17:23:58 +00:00
|
|
|
function
|
|
|
|
__i32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_in__i32]{_tint_pulling_vertex_index}
|
2020-08-12 17:23:58 +00:00
|
|
|
multiply
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{8}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_private__array__f32_2]{var_a}
|
|
|
|
TypeConstructor[__vec_2__f32]{
|
2020-08-12 17:23:58 +00:00
|
|
|
__vec_2__f32
|
2020-11-16 14:46:27 +00:00
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_0}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_0}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_in__i32]{_tint_pulling_vertex_index}
|
2020-08-12 17:23:58 +00:00
|
|
|
multiply
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{12}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_private__array__f32_3]{var_b}
|
|
|
|
TypeConstructor[__vec_3__f32]{
|
2020-08-12 17:23:58 +00:00
|
|
|
__vec_3__f32
|
2020-11-16 14:46:27 +00:00
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_1}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_1}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_1}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{8}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_in__i32]{_tint_pulling_vertex_index}
|
2020-08-12 17:23:58 +00:00
|
|
|
multiply
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{16}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Assignment{
|
2020-11-16 14:46:27 +00:00
|
|
|
Identifier[__ptr_private__array__f32_4]{var_c}
|
|
|
|
TypeConstructor[__vec_4__f32]{
|
2020-08-12 17:23:58 +00:00
|
|
|
__vec_4__f32
|
2020-11-16 14:46:27 +00:00
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_2}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{0}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_2}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_2}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{8}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Bitcast[__f32]<__f32>{
|
|
|
|
ArrayAccessor[__ptr_storage_buffer__u32]{
|
|
|
|
MemberAccessor[__ptr_storage_buffer__array__u32_stride_4]{
|
|
|
|
Identifier[__ptr_storage_buffer__struct_TintVertexData]{_tint_pulling_vertex_buffer_2}
|
|
|
|
Identifier[not set]{_tint_vertex_data}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
2020-11-16 14:46:27 +00:00
|
|
|
Binary[__i32]{
|
|
|
|
Binary[__i32]{
|
|
|
|
Identifier[__ptr_function__i32]{_tint_pulling_pos}
|
2020-08-12 17:23:58 +00:00
|
|
|
add
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{12}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
divide
|
2020-11-16 14:46:27 +00:00
|
|
|
ScalarConstructor[__u32]{4}
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)",
|
2020-12-11 19:16:13 +00:00
|
|
|
Demangler().Demangle(result.module, result.module.to_str()));
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace transform
|
|
|
|
} // namespace tint
|