[spirv-writer] Hash names

This Cl hashes the OpName, OpEntryPoint and OpMemberName strings so we
are no longer passing user provided strings through into the resulting
SPIR-V binary.

Bug: tint:273
Change-Id: I0ca2c65d0cd2800c54d867ab698c7751c341778c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32061
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
dan sinclair 2020-11-10 21:49:56 +00:00 committed by Commit Bot service account
parent 0573714bfd
commit 84f827506a
18 changed files with 315 additions and 158 deletions

View File

@ -393,6 +393,8 @@ source_set("libtint_core_src") {
"src/inspector/inspector.h", "src/inspector/inspector.h",
"src/inspector/scalar.cc", "src/inspector/scalar.cc",
"src/inspector/scalar.h", "src/inspector/scalar.h",
"src/namer.cc",
"src/namer.h",
"src/reader/reader.cc", "src/reader/reader.cc",
"src/reader/reader.h", "src/reader/reader.h",
"src/scope_stack.h", "src/scope_stack.h",
@ -790,6 +792,7 @@ source_set("tint_unittests_core_src") {
"src/diagnostic/formatter_test.cc", "src/diagnostic/formatter_test.cc",
"src/diagnostic/printer_test.cc", "src/diagnostic/printer_test.cc",
"src/inspector/inspector_test.cc", "src/inspector/inspector_test.cc",
"src/namer_test.cc",
"src/scope_stack_test.cc", "src/scope_stack_test.cc",
"src/transform/bound_array_accessors_transform_test.cc", "src/transform/bound_array_accessors_transform_test.cc",
"src/transform/vertex_pulling_transform_test.cc", "src/transform/vertex_pulling_transform_test.cc",

View File

@ -214,6 +214,8 @@ set(TINT_LIB_SRCS
inspector/inspector.h inspector/inspector.h
inspector/scalar.cc inspector/scalar.cc
inspector/scalar.h inspector/scalar.h
namer.cc
namer.h
reader/reader.cc reader/reader.cc
reader/reader.h reader/reader.h
scope_stack.h scope_stack.h
@ -400,6 +402,7 @@ set(TINT_TEST_SRCS
diagnostic/formatter_test.cc diagnostic/formatter_test.cc
diagnostic/printer_test.cc diagnostic/printer_test.cc
inspector/inspector_test.cc inspector/inspector_test.cc
namer_test.cc
scope_stack_test.cc scope_stack_test.cc
transform/bound_array_accessors_transform_test.cc transform/bound_array_accessors_transform_test.cc
transform/vertex_pulling_transform_test.cc transform/vertex_pulling_transform_test.cc

View File

@ -30,6 +30,7 @@
#include "src/ast/type/struct_type.h" #include "src/ast/type/struct_type.h"
#include "src/ast/type/type.h" #include "src/ast/type/type.h"
#include "src/ast/uint_literal.h" #include "src/ast/uint_literal.h"
#include "src/namer.h"
namespace tint { namespace tint {
namespace inspector { namespace inspector {
@ -46,8 +47,9 @@ std::vector<EntryPoint> Inspector::GetEntryPoints() {
continue; continue;
} }
Namer namer;
EntryPoint entry_point; EntryPoint entry_point;
entry_point.name = func->name(); entry_point.name = namer.NameFor(func->name());
entry_point.stage = func->pipeline_stage(); entry_point.stage = func->pipeline_stage();
std::tie(entry_point.workgroup_size_x, entry_point.workgroup_size_y, std::tie(entry_point.workgroup_size_x, entry_point.workgroup_size_y,
entry_point.workgroup_size_z) = func->workgroup_size(); entry_point.workgroup_size_z) = func->workgroup_size();

View File

@ -655,7 +655,7 @@ TEST_F(InspectorGetEntryPointTest, OneEntryPoint) {
ASSERT_FALSE(inspector()->has_error()) << inspector()->error(); ASSERT_FALSE(inspector()->has_error()) << inspector()->error();
ASSERT_EQ(1u, result.size()); ASSERT_EQ(1u, result.size());
EXPECT_EQ("foo", result[0].name); EXPECT_EQ("tint_666f6f", result[0].name);
EXPECT_EQ(ast::PipelineStage::kVertex, result[0].stage); EXPECT_EQ(ast::PipelineStage::kVertex, result[0].stage);
} }
@ -674,9 +674,9 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPoints) {
ASSERT_FALSE(inspector()->has_error()) << inspector()->error(); ASSERT_FALSE(inspector()->has_error()) << inspector()->error();
ASSERT_EQ(2u, result.size()); ASSERT_EQ(2u, result.size());
EXPECT_EQ("foo", result[0].name); EXPECT_EQ("tint_666f6f", result[0].name);
EXPECT_EQ(ast::PipelineStage::kVertex, result[0].stage); EXPECT_EQ(ast::PipelineStage::kVertex, result[0].stage);
EXPECT_EQ("bar", result[1].name); EXPECT_EQ("tint_626172", result[1].name);
EXPECT_EQ(ast::PipelineStage::kCompute, result[1].stage); EXPECT_EQ(ast::PipelineStage::kCompute, result[1].stage);
} }
@ -698,9 +698,9 @@ TEST_F(InspectorGetEntryPointTest, MixFunctionsAndEntryPoints) {
EXPECT_FALSE(inspector()->has_error()); EXPECT_FALSE(inspector()->has_error());
ASSERT_EQ(2u, result.size()); ASSERT_EQ(2u, result.size());
EXPECT_EQ("foo", result[0].name); EXPECT_EQ("tint_666f6f", result[0].name);
EXPECT_EQ(ast::PipelineStage::kVertex, result[0].stage); EXPECT_EQ(ast::PipelineStage::kVertex, result[0].stage);
EXPECT_EQ("bar", result[1].name); EXPECT_EQ("tint_626172", result[1].name);
EXPECT_EQ(ast::PipelineStage::kFragment, result[1].stage); EXPECT_EQ(ast::PipelineStage::kFragment, result[1].stage);
} }
@ -898,13 +898,13 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsInOutVariables) {
ASSERT_EQ(2u, result.size()); ASSERT_EQ(2u, result.size());
ASSERT_EQ("foo", result[0].name); ASSERT_EQ("tint_666f6f", result[0].name);
ASSERT_EQ(1u, result[0].input_variables.size()); ASSERT_EQ(1u, result[0].input_variables.size());
EXPECT_EQ("in_var", result[0].input_variables[0]); EXPECT_EQ("in_var", result[0].input_variables[0]);
ASSERT_EQ(1u, result[0].output_variables.size()); ASSERT_EQ(1u, result[0].output_variables.size());
EXPECT_EQ("out2_var", result[0].output_variables[0]); EXPECT_EQ("out2_var", result[0].output_variables[0]);
ASSERT_EQ("bar", result[1].name); ASSERT_EQ("tint_626172", result[1].name);
ASSERT_EQ(1u, result[1].input_variables.size()); ASSERT_EQ(1u, result[1].input_variables.size());
EXPECT_EQ("in2_var", result[1].input_variables[0]); EXPECT_EQ("in2_var", result[1].input_variables[0]);
ASSERT_EQ(1u, result[1].output_variables.size()); ASSERT_EQ(1u, result[1].output_variables.size());
@ -935,7 +935,7 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsSharedInOutVariables) {
ASSERT_EQ(2u, result.size()); ASSERT_EQ(2u, result.size());
ASSERT_EQ("foo", result[0].name); ASSERT_EQ("tint_666f6f", result[0].name);
EXPECT_EQ(2u, result[0].input_variables.size()); EXPECT_EQ(2u, result[0].input_variables.size());
EXPECT_TRUE(ContainsString(result[0].input_variables, "in_var")); EXPECT_TRUE(ContainsString(result[0].input_variables, "in_var"));
EXPECT_TRUE(ContainsString(result[0].input_variables, "in2_var")); EXPECT_TRUE(ContainsString(result[0].input_variables, "in2_var"));
@ -943,7 +943,7 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsSharedInOutVariables) {
EXPECT_TRUE(ContainsString(result[0].output_variables, "out_var")); EXPECT_TRUE(ContainsString(result[0].output_variables, "out_var"));
EXPECT_TRUE(ContainsString(result[0].output_variables, "out2_var")); EXPECT_TRUE(ContainsString(result[0].output_variables, "out2_var"));
ASSERT_EQ("bar", result[1].name); ASSERT_EQ("tint_626172", result[1].name);
EXPECT_EQ(1u, result[1].input_variables.size()); EXPECT_EQ(1u, result[1].input_variables.size());
EXPECT_EQ("in2_var", result[1].input_variables[0]); EXPECT_EQ("in2_var", result[1].input_variables[0]);
EXPECT_EQ(1u, result[1].output_variables.size()); EXPECT_EQ(1u, result[1].output_variables.size());

50
src/namer.cc Normal file
View File

@ -0,0 +1,50 @@
// 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.
#include "src/namer.h"
#include <algorithm>
#include <iomanip>
#include <sstream>
namespace tint {
Namer::Namer() = default;
Namer::~Namer() = default;
std::string Namer::NameFor(const std::string& name) {
auto it = name_map_.find(name);
if (it != name_map_.end()) {
return it->second;
}
std::stringstream ret_name;
ret_name << "tint_";
ret_name << std::hex << std::setfill('0') << std::setw(2);
for (size_t i = 0; i < name.size(); ++i) {
ret_name << static_cast<uint32_t>(name[i]);
}
name_map_[name] = ret_name.str();
return ret_name.str();
}
bool Namer::IsMapped(const std::string& name) {
auto it = name_map_.find(name);
return it != name_map_.end();
}
} // namespace tint

49
src/namer.h Normal file
View File

@ -0,0 +1,49 @@
// 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.
#ifndef SRC_NAMER_H_
#define SRC_NAMER_H_
#include <string>
#include <unordered_map>
#include <unordered_set>
namespace tint {
/// Remaps maps names to a hashed version. This keeps the provided user input
/// from traveling through to the backend compiler.
class Namer {
public:
/// Constructor
Namer();
~Namer();
/// Returns a sanitized version of |name|
/// @param name the name to sanitize
/// @returns the sanitized version of |name|
std::string NameFor(const std::string& name);
/// Returns if the given name has been mapped already
/// @param name the name to check
/// @returns true if the name has been mapped
bool IsMapped(const std::string& name);
private:
/// Map of original name to new name.
std::unordered_map<std::string, std::string> name_map_;
};
} // namespace tint
#endif // SRC_NAMER_H_

44
src/namer_test.cc Normal file
View File

@ -0,0 +1,44 @@
// 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.
#include "src/namer.h"
#include "gtest/gtest.h"
namespace tint {
namespace {
using NamerTest = testing::Test;
TEST_F(NamerTest, ReturnsName) {
Namer n;
EXPECT_EQ("tint_6d795f6e616d65", n.NameFor("my_name"));
}
TEST_F(NamerTest, ReturnsSameValueForSameName) {
Namer n;
EXPECT_EQ("tint_6e616d6531", n.NameFor("name1"));
EXPECT_EQ("tint_6e616d6532", n.NameFor("name2"));
EXPECT_EQ("tint_6e616d6531", n.NameFor("name1"));
}
TEST_F(NamerTest, IsMapped) {
Namer n;
EXPECT_FALSE(n.IsMapped("my_name"));
EXPECT_EQ("tint_6d795f6e616d65", n.NameFor("my_name"));
EXPECT_TRUE(n.IsMapped("my_name"));
}
} // namespace
} // namespace tint

View File

@ -420,7 +420,7 @@ bool Builder::GenerateEntryPoint(ast::Function* func, uint32_t id) {
} }
OperandList operands = {Operand::Int(stage), Operand::Int(id), OperandList operands = {Operand::Int(stage), Operand::Int(id),
Operand::String(func->name())}; Operand::String(namer_.NameFor(func->name()))};
for (const auto* var : func->referenced_module_variables()) { for (const auto* var : func->referenced_module_variables()) {
// For SPIR-V 1.3 we only output Input/output variables. If we update to // For SPIR-V 1.3 we only output Input/output variables. If we update to
@ -502,8 +502,8 @@ bool Builder::GenerateFunction(ast::Function* func) {
auto func_op = result_op(); auto func_op = result_op();
auto func_id = func_op.to_i(); auto func_id = func_op.to_i();
push_debug(spv::Op::OpName, push_debug(spv::Op::OpName, {Operand::Int(func_id),
{Operand::Int(func_id), Operand::String(func->name())}); Operand::String(namer_.NameFor(func->name()))});
auto ret_id = GenerateTypeIfNeeded(func->return_type()); auto ret_id = GenerateTypeIfNeeded(func->return_type());
if (ret_id == 0) { if (ret_id == 0) {
@ -528,7 +528,8 @@ bool Builder::GenerateFunction(ast::Function* func) {
} }
push_debug(spv::Op::OpName, push_debug(spv::Op::OpName,
{Operand::Int(param_id), Operand::String(param->name())}); {Operand::Int(param_id),
Operand::String(namer_.NameFor(param->name()))});
params.push_back(Instruction{spv::Op::OpFunctionParameter, params.push_back(Instruction{spv::Op::OpFunctionParameter,
{Operand::Int(param_type_id), param_op}}); {Operand::Int(param_type_id), param_op}});
@ -617,8 +618,8 @@ bool Builder::GenerateFunctionVariable(ast::Variable* var) {
return false; return false;
} }
push_debug(spv::Op::OpName, push_debug(spv::Op::OpName, {Operand::Int(var_id),
{Operand::Int(var_id), Operand::String(var->name())}); Operand::String(namer_.NameFor(var->name()))});
// TODO(dsinclair) We could detect if the constructor is fully const and emit // TODO(dsinclair) We could detect if the constructor is fully const and emit
// an initializer value for the variable instead of doing the OpLoad. // an initializer value for the variable instead of doing the OpLoad.
@ -666,8 +667,8 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) {
error_ = "missing constructor for constant"; error_ = "missing constructor for constant";
return false; return false;
} }
push_debug(spv::Op::OpName, push_debug(spv::Op::OpName, {Operand::Int(init_id),
{Operand::Int(init_id), Operand::String(var->name())}); Operand::String(namer_.NameFor(var->name()))});
scope_stack_.set_global(var->name(), init_id); scope_stack_.set_global(var->name(), init_id);
spirv_id_to_variable_[init_id] = var; spirv_id_to_variable_[init_id] = var;
@ -687,8 +688,8 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) {
return false; return false;
} }
push_debug(spv::Op::OpName, push_debug(spv::Op::OpName, {Operand::Int(var_id),
{Operand::Int(var_id), Operand::String(var->name())}); Operand::String(namer_.NameFor(var->name()))});
auto* type = var->type()->UnwrapAll(); auto* type = var->type()->UnwrapAll();
@ -2466,7 +2467,8 @@ bool Builder::GenerateStructType(ast::type::StructType* struct_type,
if (!struct_type->name().empty()) { if (!struct_type->name().empty()) {
push_debug(spv::Op::OpName, push_debug(spv::Op::OpName,
{Operand::Int(struct_id), Operand::String(struct_type->name())}); {Operand::Int(struct_id),
Operand::String(namer_.NameFor(struct_type->name()))});
} }
OperandList ops; OperandList ops;
@ -2507,8 +2509,9 @@ bool Builder::GenerateStructType(ast::type::StructType* struct_type,
uint32_t Builder::GenerateStructMember(uint32_t struct_id, uint32_t Builder::GenerateStructMember(uint32_t struct_id,
uint32_t idx, uint32_t idx,
ast::StructMember* member) { ast::StructMember* member) {
push_debug(spv::Op::OpMemberName, {Operand::Int(struct_id), Operand::Int(idx), push_debug(spv::Op::OpMemberName,
Operand::String(member->name())}); {Operand::Int(struct_id), Operand::Int(idx),
Operand::String(namer_.NameFor(member->name()))});
bool has_layout = false; bool has_layout = false;
for (const auto& deco : member->decorations()) { for (const auto& deco : member->decorations()) {

View File

@ -29,6 +29,7 @@
#include "src/ast/type/access_control_type.h" #include "src/ast/type/access_control_type.h"
#include "src/ast/type/storage_texture_type.h" #include "src/ast/type/storage_texture_type.h"
#include "src/ast/type_constructor_expression.h" #include "src/ast/type_constructor_expression.h"
#include "src/namer.h"
#include "src/scope_stack.h" #include "src/scope_stack.h"
#include "src/writer/spirv/function.h" #include "src/writer/spirv/function.h"
#include "src/writer/spirv/instruction.h" #include "src/writer/spirv/instruction.h"
@ -470,6 +471,7 @@ class Builder {
ast::Module* mod_; ast::Module* mod_;
std::string error_; std::string error_;
Namer namer_;
uint32_t next_id_ = 1; uint32_t next_id_ = 1;
uint32_t current_label_id_ = 0; uint32_t current_label_id_ = 0;
InstructionList capabilities_; InstructionList capabilities_;

View File

@ -81,10 +81,10 @@ TEST_F(BuilderTest, Expression_Call) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 14u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 14u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(OpName %3 "a_func" EXPECT_EQ(DumpBuilder(b), R"(OpName %3 "tint_615f66756e63"
OpName %4 "a" OpName %4 "tint_61"
OpName %5 "b" OpName %5 "tint_62"
OpName %12 "main" OpName %12 "tint_6d61696e"
%2 = OpTypeFloat 32 %2 = OpTypeFloat 32
%1 = OpTypeFunction %2 %2 %2 %1 = OpTypeFunction %2 %2 %2
%11 = OpTypeVoid %11 = OpTypeVoid
@ -149,10 +149,10 @@ TEST_F(BuilderTest, Statement_Call) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_TRUE(b.GenerateStatement(&expr)) << b.error(); EXPECT_TRUE(b.GenerateStatement(&expr)) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(OpName %4 "a_func" EXPECT_EQ(DumpBuilder(b), R"(OpName %4 "tint_615f66756e63"
OpName %5 "a" OpName %5 "tint_61"
OpName %6 "b" OpName %6 "tint_62"
OpName %12 "main" OpName %12 "tint_6d61696e"
%2 = OpTypeVoid %2 = OpTypeVoid
%3 = OpTypeFloat 32 %3 = OpTypeFloat 32
%1 = OpTypeFunction %2 %3 %3 %1 = OpTypeFunction %2 %3 %3

View File

@ -48,7 +48,8 @@ TEST_F(BuilderTest, FunctionDecoration_Stage) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(DumpInstructions(b.entry_points()), R"(OpEntryPoint Vertex %3 "main" EXPECT_EQ(DumpInstructions(b.entry_points()),
R"(OpEntryPoint Vertex %3 "tint_6d61696e"
)"); )");
} }
@ -116,10 +117,10 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUnusedInterfaceIds) {
mod.AddGlobalVariable(std::move(v_wg)); mod.AddGlobalVariable(std::move(v_wg));
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "my_in" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_6d795f696e"
OpName %4 "my_out" OpName %4 "tint_6d795f6f7574"
OpName %7 "my_wg" OpName %7 "tint_6d795f7767"
OpName %11 "main" OpName %11 "tint_6d61696e"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Input %3 %2 = OpTypePointer Input %3
@ -133,7 +134,7 @@ OpName %11 "main"
%9 = OpTypeFunction %10 %9 = OpTypeFunction %10
)"); )");
EXPECT_EQ(DumpInstructions(b.entry_points()), EXPECT_EQ(DumpInstructions(b.entry_points()),
R"(OpEntryPoint Vertex %11 "main" R"(OpEntryPoint Vertex %11 "tint_6d61696e"
)"); )");
} }
@ -185,10 +186,10 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUsedInterfaceIds) {
mod.AddGlobalVariable(std::move(v_wg)); mod.AddGlobalVariable(std::move(v_wg));
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "my_in" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_6d795f696e"
OpName %4 "my_out" OpName %4 "tint_6d795f6f7574"
OpName %7 "my_wg" OpName %7 "tint_6d795f7767"
OpName %11 "main" OpName %11 "tint_6d61696e"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Input %3 %2 = OpTypePointer Input %3
@ -202,7 +203,7 @@ OpName %11 "main"
%9 = OpTypeFunction %10 %9 = OpTypeFunction %10
)"); )");
EXPECT_EQ(DumpInstructions(b.entry_points()), EXPECT_EQ(DumpInstructions(b.entry_points()),
R"(OpEntryPoint Vertex %11 "main" %4 %1 R"(OpEntryPoint Vertex %11 "tint_6d61696e" %4 %1
)"); )");
} }
@ -269,12 +270,12 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_MultipleFragment) {
ASSERT_TRUE(b.GenerateFunction(&func1)) << b.error(); ASSERT_TRUE(b.GenerateFunction(&func1)) << b.error();
ASSERT_TRUE(b.GenerateFunction(&func2)) << b.error(); ASSERT_TRUE(b.GenerateFunction(&func2)) << b.error();
EXPECT_EQ(DumpBuilder(b), EXPECT_EQ(DumpBuilder(b),
R"(OpEntryPoint Fragment %3 "main1" R"(OpEntryPoint Fragment %3 "tint_6d61696e31"
OpEntryPoint Fragment %5 "main2" OpEntryPoint Fragment %5 "tint_6d61696e32"
OpExecutionMode %3 OriginUpperLeft OpExecutionMode %3 OriginUpperLeft
OpExecutionMode %5 OriginUpperLeft OpExecutionMode %5 OriginUpperLeft
OpName %3 "main1" OpName %3 "tint_6d61696e31"
OpName %5 "main2" OpName %5 "tint_6d61696e32"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%3 = OpFunction %2 None %1 %3 = OpFunction %2 None %1

View File

@ -53,7 +53,7 @@ TEST_F(BuilderTest, Function_Empty) {
Builder b(&mod); Builder b(&mod);
ASSERT_TRUE(b.GenerateFunction(&func)); ASSERT_TRUE(b.GenerateFunction(&func));
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "a_func" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_615f66756e63"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeVoid EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
@ -96,9 +96,9 @@ TEST_F(BuilderTest, Function_WithParams) {
Builder b(&mod); Builder b(&mod);
ASSERT_TRUE(b.GenerateFunction(&func)); ASSERT_TRUE(b.GenerateFunction(&func));
EXPECT_EQ(DumpBuilder(b), R"(OpName %4 "a_func" EXPECT_EQ(DumpBuilder(b), R"(OpName %4 "tint_615f66756e63"
OpName %5 "a" OpName %5 "tint_61"
OpName %6 "b" OpName %6 "tint_62"
%2 = OpTypeFloat 32 %2 = OpTypeFloat 32
%3 = OpTypeInt 32 1 %3 = OpTypeInt 32 1
%1 = OpTypeFunction %2 %2 %3 %1 = OpTypeFunction %2 %2 %3
@ -123,7 +123,7 @@ TEST_F(BuilderTest, Function_WithBody) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
ASSERT_TRUE(b.GenerateFunction(&func)); ASSERT_TRUE(b.GenerateFunction(&func));
EXPECT_EQ(DumpBuilder(b), R"(OpName %3 "a_func" EXPECT_EQ(DumpBuilder(b), R"(OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%3 = OpFunction %2 None %1 %3 = OpFunction %2 None %1
@ -261,17 +261,17 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
ASSERT_TRUE(b.Build()); ASSERT_TRUE(b.Build());
EXPECT_EQ(DumpBuilder(b), R"(OpCapability Shader EXPECT_EQ(DumpBuilder(b), R"(OpCapability Shader
OpMemoryModel Logical GLSL450 OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %7 "a" OpEntryPoint GLCompute %7 "tint_61"
OpEntryPoint GLCompute %17 "b" OpEntryPoint GLCompute %17 "tint_62"
OpExecutionMode %7 LocalSize 1 1 1 OpExecutionMode %7 LocalSize 1 1 1
OpExecutionMode %17 LocalSize 1 1 1 OpExecutionMode %17 LocalSize 1 1 1
OpName %3 "Data" OpName %3 "tint_44617461"
OpMemberName %3 0 "d" OpMemberName %3 0 "tint_64"
OpName %1 "data" OpName %1 "tint_64617461"
OpName %7 "a" OpName %7 "tint_61"
OpName %13 "v" OpName %13 "tint_76"
OpName %17 "b" OpName %17 "tint_62"
OpName %20 "v" OpName %20 "tint_76"
OpDecorate %3 Block OpDecorate %3 Block
OpMemberDecorate %3 0 Offset 0 OpMemberDecorate %3 0 Offset 0
OpDecorate %1 Binding 0 OpDecorate %1 Binding 0

View File

@ -53,7 +53,7 @@ TEST_F(BuilderTest, FunctionVar_NoStorageClass) {
Builder b(&mod); Builder b(&mod);
b.push_function(Function{}); b.push_function(Function{});
EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Function %3 %2 = OpTypePointer Function %3
@ -96,7 +96,7 @@ TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) {
EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error();
ASSERT_FALSE(b.has_error()) << b.error(); ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %6 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %6 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 3 %1 = OpTypeVector %2 3
@ -146,7 +146,7 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) {
EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error();
ASSERT_FALSE(b.has_error()) << b.error(); ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %7 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %7 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 2 %1 = OpTypeVector %2 2

View File

@ -57,7 +57,7 @@ TEST_F(BuilderTest, GlobalVar_NoStorageClass) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Private %3 %2 = OpTypePointer Private %3
@ -73,7 +73,7 @@ TEST_F(BuilderTest, GlobalVar_WithStorageClass) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Output %3 %2 = OpTypePointer Output %3
@ -89,7 +89,7 @@ TEST_F(BuilderTest, GlobalVar_WithStorageClass_Input) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Input %3 %2 = OpTypePointer Input %3
@ -125,7 +125,7 @@ TEST_F(BuilderTest, GlobalVar_WithConstructor) {
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
ASSERT_FALSE(b.has_error()) << b.error(); ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %6 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %6 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 3 %1 = OpTypeVector %2 3
@ -166,7 +166,7 @@ TEST_F(BuilderTest, GlobalVar_Const) {
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
ASSERT_FALSE(b.has_error()) << b.error(); ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %5 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %5 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 3 %1 = OpTypeVector %2 3
@ -276,7 +276,7 @@ TEST_F(BuilderTest, GlobalVar_WithLocation) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&dv)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&dv)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 Location 5 EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 Location 5
)"); )");
@ -301,7 +301,7 @@ TEST_F(BuilderTest, GlobalVar_WithBindingAndSet) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&dv)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&dv)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 Binding 2 EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 Binding 2
OpDecorate %1 DescriptorSet 3 OpDecorate %1 DescriptorSet 3
@ -327,7 +327,7 @@ TEST_F(BuilderTest, GlobalVar_WithBuiltin) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&dv)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&dv)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 BuiltIn Position EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 BuiltIn Position
)"); )");
@ -353,7 +353,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %2 SpecId 1200 EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %2 SpecId 1200
)"); )");
@ -377,7 +377,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %4 SpecId 1200 EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %4 SpecId 1200
)"); )");
@ -403,7 +403,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %2 SpecId 0 EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %2 SpecId 0
)"); )");
@ -427,7 +427,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %4 SpecId 0 EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %4 SpecId 0
)"); )");
@ -451,7 +451,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %4 SpecId 0 EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %4 SpecId 0
)"); )");
@ -475,7 +475,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_U32_NoConstructor) {
ast::Module mod; ast::Module mod;
Builder b(&mod); Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %4 SpecId 0 EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %4 SpecId 0
)"); )");
@ -551,10 +551,10 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) {
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable
OpMemberDecorate %3 1 NonWritable OpMemberDecorate %3 1 NonWritable
)"); )");
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "A" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_41"
OpMemberName %3 0 "a" OpMemberName %3 0 "tint_61"
OpMemberName %3 1 "b" OpMemberName %3 1 "tint_62"
OpName %1 "b" OpName %1 "tint_62"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 1 EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 1
%3 = OpTypeStruct %4 %4 %3 = OpTypeStruct %4 %4
@ -590,9 +590,9 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) {
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable
)"); )");
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "A" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_41"
OpMemberName %3 0 "a" OpMemberName %3 0 "tint_61"
OpName %1 "b" OpName %1 "tint_62"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 1 EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 1
%3 = OpTypeStruct %4 %3 = OpTypeStruct %4
@ -628,9 +628,9 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) {
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable
)"); )");
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "A" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_41"
OpMemberName %3 0 "a" OpMemberName %3 0 "tint_61"
OpName %1 "b" OpName %1 "tint_62"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 1 EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 1
%3 = OpTypeStruct %4 %3 = OpTypeStruct %4
@ -668,12 +668,12 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) {
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable
)"); )");
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "A" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_41"
OpMemberName %3 0 "a" OpMemberName %3 0 "tint_61"
OpName %1 "b" OpName %1 "tint_62"
OpName %7 "A" OpName %7 "tint_41"
OpMemberName %7 0 "a" OpMemberName %7 0 "tint_61"
OpName %5 "c" OpName %5 "tint_63"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 1 EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 1
%3 = OpTypeStruct %4 %3 = OpTypeStruct %4

View File

@ -92,7 +92,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalVar) {
Builder b(&mod); Builder b(&mod);
b.push_function(Function{}); b.push_function(Function{});
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Output %3 %2 = OpTypePointer Output %3
@ -158,7 +158,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionVar) {
Builder b(&mod); Builder b(&mod);
b.push_function(Function{}); b.push_function(Function{});
EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error(); EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Function %3 %2 = OpTypePointer Function %3

View File

@ -1409,8 +1409,8 @@ TEST_F(BuilderTest, Call_GLSLMethod_WithLoad) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 9u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 9u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%10 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%10 = OpExtInstImport "GLSL.std.450"
OpName %1 "ident" OpName %1 "tint_6964656e74"
OpName %7 "a_func" OpName %7 "tint_615f66756e63"
%3 = OpTypeFloat 32 %3 = OpTypeFloat 32
%2 = OpTypePointer Private %3 %2 = OpTypePointer Private %3
%4 = OpConstantNull %3 %4 = OpConstantNull %3
@ -1454,7 +1454,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Float_Test, Call_Scalar) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%6 = OpTypeFloat 32 %6 = OpTypeFloat 32
@ -1501,7 +1501,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Float_Test, Call_Vector) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%7 = OpTypeFloat 32 %7 = OpTypeFloat 32
@ -1565,7 +1565,7 @@ TEST_F(BuilderTest, Call_Length_Scalar) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%6 = OpTypeFloat 32 %6 = OpTypeFloat 32
@ -1608,7 +1608,7 @@ TEST_F(BuilderTest, Call_Length_Vector) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%6 = OpTypeFloat 32 %6 = OpTypeFloat 32
@ -1654,7 +1654,7 @@ TEST_F(BuilderTest, Call_Normalize) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%7 = OpTypeFloat 32 %7 = OpTypeFloat 32
@ -1699,7 +1699,7 @@ TEST_P(Intrinsic_Builtin_DualParam_Float_Test, Call_Scalar) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%6 = OpTypeFloat 32 %6 = OpTypeFloat 32
@ -1754,7 +1754,7 @@ TEST_P(Intrinsic_Builtin_DualParam_Float_Test, Call_Vector) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%7 = OpTypeFloat 32 %7 = OpTypeFloat 32
@ -1804,7 +1804,7 @@ TEST_F(BuilderTest, Call_Distance_Scalar) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%6 = OpTypeFloat 32 %6 = OpTypeFloat 32
@ -1856,7 +1856,7 @@ TEST_F(BuilderTest, Call_Distance_Vector) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%6 = OpTypeFloat 32 %6 = OpTypeFloat 32
@ -1913,7 +1913,7 @@ TEST_F(BuilderTest, Call_Cross) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%7 = OpTypeFloat 32 %7 = OpTypeFloat 32
@ -1960,7 +1960,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Float_Test, Call_Scalar) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%6 = OpTypeFloat 32 %6 = OpTypeFloat 32
@ -2023,7 +2023,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Float_Test, Call_Vector) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%7 = OpTypeFloat 32 %7 = OpTypeFloat 32
@ -2076,7 +2076,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Sint_Test, Call_Scalar) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%6 = OpTypeInt 32 1 %6 = OpTypeInt 32 1
@ -2123,7 +2123,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Sint_Test, Call_Vector) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%7 = OpTypeInt 32 1 %7 = OpTypeInt 32 1
@ -2170,7 +2170,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Uint_Test, Call_Scalar) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%6 = OpTypeInt 32 0 %6 = OpTypeInt 32 0
@ -2217,7 +2217,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Uint_Test, Call_Vector) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%7 = OpTypeInt 32 0 %7 = OpTypeInt 32 0
@ -2266,7 +2266,7 @@ TEST_P(Intrinsic_Builtin_DualParam_SInt_Test, Call_Scalar) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%6 = OpTypeInt 32 1 %6 = OpTypeInt 32 1
@ -2321,7 +2321,7 @@ TEST_P(Intrinsic_Builtin_DualParam_SInt_Test, Call_Vector) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%7 = OpTypeInt 32 1 %7 = OpTypeInt 32 1
@ -2371,7 +2371,7 @@ TEST_P(Intrinsic_Builtin_DualParam_UInt_Test, Call_Scalar) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%6 = OpTypeInt 32 0 %6 = OpTypeInt 32 0
@ -2426,7 +2426,7 @@ TEST_P(Intrinsic_Builtin_DualParam_UInt_Test, Call_Vector) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%7 = OpTypeInt 32 0 %7 = OpTypeInt 32 0
@ -2478,7 +2478,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Sint_Test, Call_Scalar) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%6 = OpTypeInt 32 1 %6 = OpTypeInt 32 1
@ -2541,7 +2541,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Sint_Test, Call_Vector) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%7 = OpTypeInt 32 1 %7 = OpTypeInt 32 1
@ -2592,7 +2592,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Uint_Test, Call_Scalar) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%6 = OpTypeInt 32 0 %6 = OpTypeInt 32 0
@ -2655,7 +2655,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Uint_Test, Call_Vector) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%7 = OpTypeInt 32 0 %7 = OpTypeInt 32 0
@ -2704,8 +2704,8 @@ TEST_F(BuilderTest, Call_Determinant) {
EXPECT_EQ(b.GenerateCallExpression(&expr), 11u) << b.error(); EXPECT_EQ(b.GenerateCallExpression(&expr), 11u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%12 = OpExtInstImport "GLSL.std.450" EXPECT_EQ(DumpBuilder(b), R"(%12 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func" OpName %3 "tint_615f66756e63"
OpName %5 "var" OpName %5 "tint_766172"
%2 = OpTypeVoid %2 = OpTypeVoid
%1 = OpTypeFunction %2 %1 = OpTypeFunction %2
%9 = OpTypeFloat 32 %9 = OpTypeFloat 32

View File

@ -128,9 +128,9 @@ TEST_F(BuilderTest, Switch_WithCase) {
EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error(); EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "v" EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "tint_76"
OpName %5 "a" OpName %5 "tint_61"
OpName %7 "a_func" OpName %7 "tint_615f66756e63"
%3 = OpTypeInt 32 1 %3 = OpTypeInt 32 1
%2 = OpTypePointer Private %3 %2 = OpTypePointer Private %3
%4 = OpConstantNull %3 %4 = OpConstantNull %3
@ -199,9 +199,9 @@ TEST_F(BuilderTest, Switch_WithDefault) {
EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error(); EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "v" EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "tint_76"
OpName %5 "a" OpName %5 "tint_61"
OpName %7 "a_func" OpName %7 "tint_615f66756e63"
%3 = OpTypeInt 32 1 %3 = OpTypeInt 32 1
%2 = OpTypePointer Private %3 %2 = OpTypePointer Private %3
%4 = OpConstantNull %3 %4 = OpConstantNull %3
@ -291,9 +291,9 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) {
EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error(); EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "v" EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "tint_76"
OpName %5 "a" OpName %5 "tint_61"
OpName %7 "a_func" OpName %7 "tint_615f66756e63"
%3 = OpTypeInt 32 1 %3 = OpTypeInt 32 1
%2 = OpTypePointer Private %3 %2 = OpTypePointer Private %3
%4 = OpConstantNull %3 %4 = OpConstantNull %3
@ -392,9 +392,9 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) {
EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error(); EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "v" EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "tint_76"
OpName %5 "a" OpName %5 "tint_61"
OpName %7 "a_func" OpName %7 "tint_615f66756e63"
%3 = OpTypeInt 32 1 %3 = OpTypeInt 32 1
%2 = OpTypePointer Private %3 %2 = OpTypePointer Private %3
%4 = OpConstantNull %3 %4 = OpConstantNull %3
@ -529,9 +529,9 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) {
EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error(); EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "v" EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "tint_76"
OpName %5 "a" OpName %5 "tint_61"
OpName %7 "a_func" OpName %7 "tint_615f66756e63"
%3 = OpTypeInt 32 1 %3 = OpTypeInt 32 1
%2 = OpTypePointer Private %3 %2 = OpTypePointer Private %3
%4 = OpConstantNull %3 %4 = OpConstantNull %3

View File

@ -322,7 +322,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_Empty) {
EXPECT_EQ(id, 1u); EXPECT_EQ(id, 1u);
EXPECT_EQ(b.types().size(), 1u); EXPECT_EQ(b.types().size(), 1u);
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "S" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_53"
)"); )");
EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeStruct EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeStruct
)"); )");
@ -348,8 +348,8 @@ TEST_F(BuilderTest_Type, GenerateStruct) {
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeStruct %2 %1 = OpTypeStruct %2
)"); )");
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "my_struct" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_6d795f737472756374"
OpMemberName %1 0 "a" OpMemberName %1 0 "tint_61"
)"); )");
} }
@ -378,8 +378,8 @@ TEST_F(BuilderTest_Type, GenerateStruct_Decorated) {
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeStruct %2 %1 = OpTypeStruct %2
)"); )");
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "my_struct" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_6d795f737472756374"
OpMemberName %1 0 "a" OpMemberName %1 0 "tint_61"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 Block EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 Block
)"); )");
@ -413,9 +413,9 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers) {
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeStruct %2 %2 %1 = OpTypeStruct %2 %2
)"); )");
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "S" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_53"
OpMemberName %1 0 "a" OpMemberName %1 0 "tint_61"
OpMemberName %1 1 "b" OpMemberName %1 1 "tint_62"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %1 0 Offset 0 EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %1 0 Offset 0
OpMemberDecorate %1 1 Offset 8 OpMemberDecorate %1 1 Offset 8
@ -458,10 +458,10 @@ TEST_F(BuilderTest_Type, GenerateStruct_NonLayout_Matrix) {
%7 = OpTypeMatrix %8 4 %7 = OpTypeMatrix %8 4
%1 = OpTypeStruct %2 %5 %7 %1 = OpTypeStruct %2 %5 %7
)"); )");
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "S" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_53"
OpMemberName %1 0 "a" OpMemberName %1 0 "tint_61"
OpMemberName %1 1 "b" OpMemberName %1 1 "tint_62"
OpMemberName %1 2 "c" OpMemberName %1 2 "tint_63"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), ""); EXPECT_EQ(DumpInstructions(b.annots()), "");
} }
@ -509,10 +509,10 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutMatrix) {
%7 = OpTypeMatrix %8 4 %7 = OpTypeMatrix %8 4
%1 = OpTypeStruct %2 %5 %7 %1 = OpTypeStruct %2 %5 %7
)"); )");
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "S" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_53"
OpMemberName %1 0 "a" OpMemberName %1 0 "tint_61"
OpMemberName %1 1 "b" OpMemberName %1 1 "tint_62"
OpMemberName %1 2 "c" OpMemberName %1 2 "tint_63"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %1 0 Offset 0 EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %1 0 Offset 0
OpMemberDecorate %1 0 ColMajor OpMemberDecorate %1 0 ColMajor
@ -578,10 +578,10 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutArraysOfMatrix) {
%7 = OpTypeMatrix %8 4 %7 = OpTypeMatrix %8 4
%1 = OpTypeStruct %2 %5 %7 %1 = OpTypeStruct %2 %5 %7
)"); )");
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "S" EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_53"
OpMemberName %1 0 "a" OpMemberName %1 0 "tint_61"
OpMemberName %1 1 "b" OpMemberName %1 1 "tint_62"
OpMemberName %1 2 "c" OpMemberName %1 2 "tint_63"
)"); )");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %1 0 Offset 0 EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %1 0 Offset 0
OpMemberDecorate %1 0 ColMajor OpMemberDecorate %1 0 ColMajor