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-09-24 14:30:34 +00:00
|
|
|
#include "src/transform/vertex_pulling_transform.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"
|
|
|
|
#include "src/ast/decorated_variable.h"
|
|
|
|
#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-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 {
|
|
|
|
|
|
|
|
class VertexPullingTransformHelper {
|
|
|
|
public:
|
|
|
|
VertexPullingTransformHelper() {
|
2020-11-16 16:31:07 +00:00
|
|
|
mod_ = std::make_unique<ast::Module>();
|
2020-11-18 19:40:00 +00:00
|
|
|
manager_ = std::make_unique<Manager>(&ctx_, mod_.get());
|
|
|
|
auto transform =
|
|
|
|
std::make_unique<VertexPullingTransform>(&ctx_, mod_.get());
|
|
|
|
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-11-23 19:58:55 +00:00
|
|
|
auto* func = create<ast::Function>("main", ast::VariableList{},
|
2020-11-30 23:30:58 +00:00
|
|
|
mod_->create<ast::type::Void>(),
|
2020-11-23 19:58:55 +00:00
|
|
|
create<ast::BlockStatement>());
|
2020-11-13 22:16:25 +00:00
|
|
|
func->add_decoration(
|
2020-11-16 16:31:07 +00:00
|
|
|
create<ast::StageDecoration>(ast::PipelineStage::kVertex, Source{}));
|
2020-11-16 16:41:47 +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) {
|
|
|
|
EXPECT_TRUE(mod_->IsValid());
|
|
|
|
|
2020-09-24 14:30:34 +00:00
|
|
|
TypeDeterminer td(&ctx_, mod_.get());
|
2020-08-12 17:23:58 +00:00
|
|
|
EXPECT_TRUE(td.Determine());
|
|
|
|
|
|
|
|
transform_->SetVertexState(
|
2020-11-16 16:41:47 +00:00
|
|
|
std::make_unique<VertexStateDescriptor>(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-11-16 16:31:07 +00:00
|
|
|
auto* var = create<ast::DecoratedVariable>(
|
2020-11-13 22:16:25 +00:00
|
|
|
create<ast::Variable>(name, ast::StorageClass::kInput, type));
|
2020-08-12 17:23:58 +00:00
|
|
|
|
2020-09-24 14:30:34 +00:00
|
|
|
ast::VariableDecorationList decorations;
|
2020-11-13 22:16:25 +00:00
|
|
|
decorations.push_back(create<ast::LocationDecoration>(location, Source{}));
|
2020-08-12 17:23:58 +00:00
|
|
|
|
2020-11-16 16:41:47 +00:00
|
|
|
var->set_decorations(decorations);
|
|
|
|
mod_->AddGlobalVariable(var);
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ast::Module* mod() { return mod_.get(); }
|
2020-11-18 19:40:00 +00:00
|
|
|
Manager* manager() { return manager_.get(); }
|
|
|
|
VertexPullingTransform* transform() { return transform_; }
|
2020-08-12 17:23:58 +00:00
|
|
|
|
2020-11-18 20:58:20 +00:00
|
|
|
/// Creates a new `ast::Node` owned by the Module. When the Module is
|
2020-11-16 16:31:07 +00:00
|
|
|
/// destructed, the `ast::Node` will also be destructed.
|
|
|
|
/// @param args the arguments to pass to the type constructor
|
|
|
|
/// @returns the node pointer
|
2020-11-13 22:16:25 +00:00
|
|
|
template <typename T, typename... ARGS>
|
2020-11-16 16:31:07 +00:00
|
|
|
T* create(ARGS&&... args) {
|
2020-11-18 20:58:20 +00:00
|
|
|
return mod_->create<T>(std::forward<ARGS>(args)...);
|
2020-11-13 22:16:25 +00:00
|
|
|
}
|
|
|
|
|
2020-08-12 17:23:58 +00:00
|
|
|
private:
|
|
|
|
Context ctx_;
|
|
|
|
std::unique_ptr<ast::Module> mod_;
|
2020-11-18 19:40:00 +00:00
|
|
|
std::unique_ptr<Manager> manager_;
|
|
|
|
VertexPullingTransform* transform_;
|
2020-08-12 17:23:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class VertexPullingTransformTest : public VertexPullingTransformHelper,
|
|
|
|
public testing::Test {};
|
|
|
|
|
|
|
|
TEST_F(VertexPullingTransformTest, Error_NoVertexState) {
|
2020-11-18 19:40:00 +00:00
|
|
|
EXPECT_FALSE(manager()->Run());
|
|
|
|
EXPECT_EQ(manager()->error(), "SetVertexState not called");
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(VertexPullingTransformTest, Error_NoEntryPoint) {
|
|
|
|
transform()->SetVertexState(std::make_unique<VertexStateDescriptor>());
|
2020-11-18 19:40:00 +00:00
|
|
|
EXPECT_FALSE(manager()->Run());
|
|
|
|
EXPECT_EQ(manager()->error(), "Vertex stage entry point not found");
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(VertexPullingTransformTest, Error_InvalidEntryPoint) {
|
|
|
|
InitBasicModule();
|
|
|
|
InitTransform({});
|
|
|
|
transform()->SetEntryPoint("_");
|
|
|
|
|
2020-11-18 19:40:00 +00:00
|
|
|
EXPECT_FALSE(manager()->Run());
|
|
|
|
EXPECT_EQ(manager()->error(), "Vertex stage entry point not found");
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(VertexPullingTransformTest, Error_EntryPointWrongStage) {
|
2020-11-23 19:58:55 +00:00
|
|
|
auto* func = create<ast::Function>("main", ast::VariableList{},
|
2020-11-30 23:30:58 +00:00
|
|
|
mod()->create<ast::type::Void>(),
|
2020-11-23 19:58:55 +00:00
|
|
|
create<ast::BlockStatement>());
|
2020-11-13 22:16:25 +00:00
|
|
|
func->add_decoration(
|
|
|
|
create<ast::StageDecoration>(ast::PipelineStage::kFragment, Source{}));
|
2020-11-16 16:41:47 +00:00
|
|
|
mod()->AddFunction(func);
|
2020-08-12 17:23:58 +00:00
|
|
|
|
|
|
|
InitTransform({});
|
2020-11-18 19:40:00 +00:00
|
|
|
EXPECT_FALSE(manager()->Run());
|
|
|
|
EXPECT_EQ(manager()->error(), "Vertex stage entry point not found");
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(VertexPullingTransformTest, BasicModule) {
|
|
|
|
InitBasicModule();
|
|
|
|
InitTransform({});
|
2020-11-18 19:40:00 +00:00
|
|
|
EXPECT_TRUE(manager()->Run());
|
2020-08-12 17:23:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(VertexPullingTransformTest, OneAttribute) {
|
|
|
|
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-11-18 19:40:00 +00:00
|
|
|
EXPECT_TRUE(manager()->Run());
|
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-08-12 17:23:58 +00:00
|
|
|
Variable{
|
|
|
|
var_a
|
|
|
|
private
|
|
|
|
__f32
|
|
|
|
}
|
|
|
|
DecoratedVariable{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
DecoratedVariable{
|
|
|
|
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-09-22 14:53:03 +00:00
|
|
|
Function main -> __void
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)",
|
|
|
|
mod()->to_str());
|
|
|
|
}
|
|
|
|
|
2020-08-12 17:30:08 +00:00
|
|
|
TEST_F(VertexPullingTransformTest, 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-11-18 19:40:00 +00:00
|
|
|
EXPECT_TRUE(manager()->Run());
|
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-08-12 17:30:08 +00:00
|
|
|
Variable{
|
|
|
|
var_a
|
|
|
|
private
|
|
|
|
__f32
|
|
|
|
}
|
|
|
|
DecoratedVariable{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
DecoratedVariable{
|
|
|
|
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-09-22 14:53:03 +00:00
|
|
|
Function main -> __void
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)",
|
|
|
|
mod()->to_str());
|
|
|
|
}
|
|
|
|
|
2020-08-12 17:44:01 +00:00
|
|
|
TEST_F(VertexPullingTransformTest, OneAttributeDifferentOutputSet) {
|
|
|
|
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-11-18 19:40:00 +00:00
|
|
|
EXPECT_TRUE(manager()->Run());
|
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-08-12 17:44:01 +00:00
|
|
|
Variable{
|
|
|
|
var_a
|
|
|
|
private
|
|
|
|
__f32
|
|
|
|
}
|
|
|
|
DecoratedVariable{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
DecoratedVariable{
|
|
|
|
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-09-22 14:53:03 +00:00
|
|
|
Function main -> __void
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)",
|
|
|
|
mod()->to_str());
|
|
|
|
}
|
|
|
|
|
2020-08-12 17:30:08 +00:00
|
|
|
// We expect the transform to use an existing builtin variables if it finds them
|
|
|
|
TEST_F(VertexPullingTransformTest, ExistingVertexIndexAndInstanceIndex) {
|
|
|
|
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-11-16 16:31:07 +00:00
|
|
|
auto* vertex_index_var =
|
2020-11-13 22:16:25 +00:00
|
|
|
create<ast::DecoratedVariable>(create<ast::Variable>(
|
|
|
|
"custom_vertex_index", ast::StorageClass::kInput, &i32));
|
2020-08-12 17:23:58 +00:00
|
|
|
|
2020-09-24 14:30:34 +00:00
|
|
|
ast::VariableDecorationList decorations;
|
2020-11-13 22:16:25 +00:00
|
|
|
decorations.push_back(
|
|
|
|
create<ast::BuiltinDecoration>(ast::Builtin::kVertexIdx, Source{}));
|
2020-08-12 17:23:58 +00:00
|
|
|
|
2020-11-16 16:41:47 +00:00
|
|
|
vertex_index_var->set_decorations(decorations);
|
|
|
|
mod()->AddGlobalVariable(vertex_index_var);
|
2020-08-12 17:30:08 +00:00
|
|
|
}
|
2020-08-12 17:23:58 +00:00
|
|
|
|
2020-08-12 17:30:08 +00:00
|
|
|
{
|
2020-11-16 16:31:07 +00:00
|
|
|
auto* instance_index_var =
|
2020-11-13 22:16:25 +00:00
|
|
|
create<ast::DecoratedVariable>(create<ast::Variable>(
|
|
|
|
"custom_instance_index", ast::StorageClass::kInput, &i32));
|
2020-08-12 17:30:08 +00:00
|
|
|
|
2020-09-24 14:30:34 +00:00
|
|
|
ast::VariableDecorationList decorations;
|
2020-11-13 22:16:25 +00:00
|
|
|
decorations.push_back(
|
|
|
|
create<ast::BuiltinDecoration>(ast::Builtin::kInstanceIdx, Source{}));
|
2020-08-12 17:30:08 +00:00
|
|
|
|
2020-11-16 16:41:47 +00:00
|
|
|
instance_index_var->set_decorations(decorations);
|
|
|
|
mod()->AddGlobalVariable(instance_index_var);
|
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-11-18 19:40:00 +00:00
|
|
|
EXPECT_TRUE(manager()->Run());
|
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-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-08-12 17:23:58 +00:00
|
|
|
DecoratedVariable{
|
|
|
|
Decorations{
|
|
|
|
BuiltinDecoration{vertex_idx}
|
|
|
|
}
|
|
|
|
custom_vertex_index
|
|
|
|
in
|
|
|
|
__i32
|
|
|
|
}
|
2020-08-12 17:30:08 +00:00
|
|
|
DecoratedVariable{
|
|
|
|
Decorations{
|
|
|
|
BuiltinDecoration{instance_idx}
|
|
|
|
}
|
|
|
|
custom_instance_index
|
|
|
|
in
|
|
|
|
__i32
|
|
|
|
}
|
2020-08-12 17:23:58 +00:00
|
|
|
DecoratedVariable{
|
|
|
|
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-08-12 17:30:08 +00:00
|
|
|
DecoratedVariable{
|
|
|
|
Decorations{
|
|
|
|
BindingDecoration{1}
|
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_1
|
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-09-22 14:53:03 +00:00
|
|
|
Function main -> __void
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)",
|
|
|
|
mod()->to_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(VertexPullingTransformTest, TwoAttributesSameBuffer) {
|
|
|
|
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-11-30 23:30:58 +00:00
|
|
|
ast::type::Array vec4_f32{&f32, 4u};
|
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-11-18 19:40:00 +00:00
|
|
|
EXPECT_TRUE(manager()->Run());
|
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-08-12 17:23:58 +00:00
|
|
|
Variable{
|
|
|
|
var_a
|
|
|
|
private
|
|
|
|
__f32
|
|
|
|
}
|
|
|
|
Variable{
|
|
|
|
var_b
|
|
|
|
private
|
|
|
|
__array__f32_4
|
|
|
|
}
|
|
|
|
DecoratedVariable{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
DecoratedVariable{
|
|
|
|
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-09-22 14:53:03 +00:00
|
|
|
Function main -> __void
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)",
|
|
|
|
mod()->to_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(VertexPullingTransformTest, FloatVectorAttributes) {
|
|
|
|
InitBasicModule();
|
|
|
|
|
2020-11-30 23:30:58 +00:00
|
|
|
ast::type::F32 f32;
|
|
|
|
ast::type::Array vec2_f32{&f32, 2u};
|
2020-08-12 17:23:58 +00:00
|
|
|
AddVertexInputVariable(0, "var_a", &vec2_f32);
|
|
|
|
|
2020-11-30 23:30:58 +00:00
|
|
|
ast::type::Array vec3_f32{&f32, 3u};
|
2020-08-12 17:23:58 +00:00
|
|
|
AddVertexInputVariable(1, "var_b", &vec3_f32);
|
|
|
|
|
2020-11-30 23:30:58 +00:00
|
|
|
ast::type::Array vec4_f32{&f32, 4u};
|
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-11-18 19:40:00 +00:00
|
|
|
EXPECT_TRUE(manager()->Run());
|
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-08-12 17:23:58 +00:00
|
|
|
Variable{
|
|
|
|
var_a
|
|
|
|
private
|
|
|
|
__array__f32_2
|
|
|
|
}
|
|
|
|
Variable{
|
|
|
|
var_b
|
|
|
|
private
|
|
|
|
__array__f32_3
|
|
|
|
}
|
|
|
|
Variable{
|
|
|
|
var_c
|
|
|
|
private
|
|
|
|
__array__f32_4
|
|
|
|
}
|
|
|
|
DecoratedVariable{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
DecoratedVariable{
|
|
|
|
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
|
|
|
}
|
|
|
|
DecoratedVariable{
|
|
|
|
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
|
|
|
}
|
|
|
|
DecoratedVariable{
|
|
|
|
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-09-22 14:53:03 +00:00
|
|
|
Function main -> __void
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)",
|
|
|
|
mod()->to_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace transform
|
|
|
|
} // namespace tint
|