[wgsl-writer] Emit constant_id decorations.
This CL adds constant_id decorations to the WGSL writer. Bug: tint:152 Change-Id: I637d158c0ef4d0ace2ce70a6fb3cbe6f0b8b3b4e Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29102 Commit-Queue: dan sinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
5bb9b75684
commit
af780816ca
|
@ -29,6 +29,7 @@
|
|||
#include "src/ast/call_expression.h"
|
||||
#include "src/ast/call_statement.h"
|
||||
#include "src/ast/case_statement.h"
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/constructor_expression.h"
|
||||
#include "src/ast/continue_statement.h"
|
||||
#include "src/ast/decorated_variable.h"
|
||||
|
@ -724,6 +725,8 @@ bool GeneratorImpl::EmitVariableDecorations(ast::DecoratedVariable* var) {
|
|||
out_ << "location(" << deco->AsLocation()->value() << ")";
|
||||
} else if (deco->IsBuiltin()) {
|
||||
out_ << "builtin(" << deco->AsBuiltin()->value() << ")";
|
||||
} else if (deco->IsConstantId()) {
|
||||
out_ << "constant_id(" << deco->AsConstantId()->value() << ")";
|
||||
} else {
|
||||
error_ = "unknown variable decoration";
|
||||
return false;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
#include "src/ast/binding_decoration.h"
|
||||
#include "src/ast/builtin_decoration.h"
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/decorated_variable.h"
|
||||
#include "src/ast/location_decoration.h"
|
||||
#include "src/ast/set_decoration.h"
|
||||
|
@ -77,6 +78,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) {
|
|||
decos.push_back(std::make_unique<ast::BindingDecoration>(0));
|
||||
decos.push_back(std::make_unique<ast::SetDecoration>(1));
|
||||
decos.push_back(std::make_unique<ast::LocationDecoration>(2));
|
||||
decos.push_back(std::make_unique<ast::ConstantIdDecoration>(42));
|
||||
|
||||
ast::DecoratedVariable dv;
|
||||
dv.set_name("a");
|
||||
|
@ -87,7 +89,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) {
|
|||
ASSERT_TRUE(g.EmitVariable(&dv)) << g.error();
|
||||
EXPECT_EQ(
|
||||
g.result(),
|
||||
R"([[builtin(position), binding(0), set(1), location(2)]] var a : f32;
|
||||
R"([[builtin(position), binding(0), set(1), location(2), constant_id(42)]] var a : f32;
|
||||
)");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue