mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-08 06:05:55 +00:00
Rename builtin constant_id to override
There are no downstream usages, so we can skip deprecation. Allowing the ID to be omitted will be done in a separate patch. Fixed: tint:754 Change-Id: I3bd6de4d0f426fc3c66708bfd5b411a4051b375b Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49581 Commit-Queue: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
083b591783
commit
e87ded8567
@ -292,8 +292,6 @@ libtint_source_set("libtint_core_all_src") {
|
|||||||
"ast/call_statement.h",
|
"ast/call_statement.h",
|
||||||
"ast/case_statement.cc",
|
"ast/case_statement.cc",
|
||||||
"ast/case_statement.h",
|
"ast/case_statement.h",
|
||||||
"ast/constant_id_decoration.cc",
|
|
||||||
"ast/constant_id_decoration.h",
|
|
||||||
"ast/constructor_expression.cc",
|
"ast/constructor_expression.cc",
|
||||||
"ast/constructor_expression.h",
|
"ast/constructor_expression.h",
|
||||||
"ast/continue_statement.cc",
|
"ast/continue_statement.cc",
|
||||||
@ -346,6 +344,8 @@ libtint_source_set("libtint_core_all_src") {
|
|||||||
"ast/multisampled_texture.h",
|
"ast/multisampled_texture.h",
|
||||||
"ast/node.cc",
|
"ast/node.cc",
|
||||||
"ast/node.h",
|
"ast/node.h",
|
||||||
|
"ast/override_decoration.cc",
|
||||||
|
"ast/override_decoration.h",
|
||||||
"ast/pipeline_stage.cc",
|
"ast/pipeline_stage.cc",
|
||||||
"ast/pipeline_stage.h",
|
"ast/pipeline_stage.h",
|
||||||
"ast/pointer.cc",
|
"ast/pointer.cc",
|
||||||
|
@ -74,8 +74,6 @@ set(TINT_LIB_SRCS
|
|||||||
ast/call_statement.h
|
ast/call_statement.h
|
||||||
ast/case_statement.cc
|
ast/case_statement.cc
|
||||||
ast/case_statement.h
|
ast/case_statement.h
|
||||||
ast/constant_id_decoration.cc
|
|
||||||
ast/constant_id_decoration.h
|
|
||||||
ast/constructor_expression.cc
|
ast/constructor_expression.cc
|
||||||
ast/constructor_expression.h
|
ast/constructor_expression.h
|
||||||
ast/continue_statement.cc
|
ast/continue_statement.cc
|
||||||
@ -128,6 +126,8 @@ set(TINT_LIB_SRCS
|
|||||||
ast/multisampled_texture.h
|
ast/multisampled_texture.h
|
||||||
ast/node.cc
|
ast/node.cc
|
||||||
ast/node.h
|
ast/node.h
|
||||||
|
ast/override_decoration.cc
|
||||||
|
ast/override_decoration.h
|
||||||
ast/pipeline_stage.cc
|
ast/pipeline_stage.cc
|
||||||
ast/pipeline_stage.h
|
ast/pipeline_stage.h
|
||||||
ast/pointer.cc
|
ast/pointer.cc
|
||||||
@ -479,7 +479,6 @@ if(${TINT_BUILD_TESTS})
|
|||||||
ast/call_expression_test.cc
|
ast/call_expression_test.cc
|
||||||
ast/call_statement_test.cc
|
ast/call_statement_test.cc
|
||||||
ast/case_statement_test.cc
|
ast/case_statement_test.cc
|
||||||
ast/constant_id_decoration_test.cc
|
|
||||||
ast/continue_statement_test.cc
|
ast/continue_statement_test.cc
|
||||||
ast/depth_texture_test.cc
|
ast/depth_texture_test.cc
|
||||||
ast/discard_statement_test.cc
|
ast/discard_statement_test.cc
|
||||||
@ -503,6 +502,7 @@ if(${TINT_BUILD_TESTS})
|
|||||||
ast/module_clone_test.cc
|
ast/module_clone_test.cc
|
||||||
ast/module_test.cc
|
ast/module_test.cc
|
||||||
ast/multisampled_texture_test.cc
|
ast/multisampled_texture_test.cc
|
||||||
|
ast/override_decoration_test.cc
|
||||||
ast/pointer_test.cc
|
ast/pointer_test.cc
|
||||||
ast/return_statement_test.cc
|
ast/return_statement_test.cc
|
||||||
ast/sampled_texture_test.cc
|
ast/sampled_texture_test.cc
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
@ -30,7 +30,7 @@ TEST_F(BindingDecorationTest, Is) {
|
|||||||
Decoration* d = create<BindingDecoration>(2);
|
Decoration* d = create<BindingDecoration>(2);
|
||||||
EXPECT_TRUE(d->Is<BindingDecoration>());
|
EXPECT_TRUE(d->Is<BindingDecoration>());
|
||||||
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
||||||
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
|
EXPECT_FALSE(d->Is<OverrideDecoration>());
|
||||||
EXPECT_FALSE(d->Is<LocationDecoration>());
|
EXPECT_FALSE(d->Is<LocationDecoration>());
|
||||||
EXPECT_FALSE(d->Is<GroupDecoration>());
|
EXPECT_FALSE(d->Is<GroupDecoration>());
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
@ -30,7 +30,7 @@ TEST_F(BuiltinDecorationTest, Is) {
|
|||||||
Decoration* d = create<BuiltinDecoration>(Builtin::kFragDepth);
|
Decoration* d = create<BuiltinDecoration>(Builtin::kFragDepth);
|
||||||
EXPECT_FALSE(d->Is<BindingDecoration>());
|
EXPECT_FALSE(d->Is<BindingDecoration>());
|
||||||
EXPECT_TRUE(d->Is<BuiltinDecoration>());
|
EXPECT_TRUE(d->Is<BuiltinDecoration>());
|
||||||
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
|
EXPECT_FALSE(d->Is<OverrideDecoration>());
|
||||||
EXPECT_FALSE(d->Is<LocationDecoration>());
|
EXPECT_FALSE(d->Is<LocationDecoration>());
|
||||||
EXPECT_FALSE(d->Is<GroupDecoration>());
|
EXPECT_FALSE(d->Is<GroupDecoration>());
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
@ -30,7 +30,7 @@ TEST_F(GroupDecorationTest, Is) {
|
|||||||
Decoration* d = create<GroupDecoration>(2);
|
Decoration* d = create<GroupDecoration>(2);
|
||||||
EXPECT_FALSE(d->Is<BindingDecoration>());
|
EXPECT_FALSE(d->Is<BindingDecoration>());
|
||||||
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
||||||
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
|
EXPECT_FALSE(d->Is<OverrideDecoration>());
|
||||||
EXPECT_FALSE(d->Is<LocationDecoration>());
|
EXPECT_FALSE(d->Is<LocationDecoration>());
|
||||||
EXPECT_TRUE(d->Is<GroupDecoration>());
|
EXPECT_TRUE(d->Is<GroupDecoration>());
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
@ -30,7 +30,7 @@ TEST_F(LocationDecorationTest, Is) {
|
|||||||
Decoration* d = create<LocationDecoration>(2);
|
Decoration* d = create<LocationDecoration>(2);
|
||||||
EXPECT_FALSE(d->Is<BindingDecoration>());
|
EXPECT_FALSE(d->Is<BindingDecoration>());
|
||||||
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
||||||
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
|
EXPECT_FALSE(d->Is<OverrideDecoration>());
|
||||||
EXPECT_TRUE(d->Is<LocationDecoration>());
|
EXPECT_TRUE(d->Is<LocationDecoration>());
|
||||||
EXPECT_FALSE(d->Is<GroupDecoration>());
|
EXPECT_FALSE(d->Is<GroupDecoration>());
|
||||||
}
|
}
|
||||||
|
@ -12,33 +12,33 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
|
|
||||||
#include "src/program_builder.h"
|
#include "src/program_builder.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::ast::ConstantIdDecoration);
|
TINT_INSTANTIATE_TYPEINFO(tint::ast::OverrideDecoration);
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
||||||
ConstantIdDecoration::ConstantIdDecoration(ProgramID program_id,
|
OverrideDecoration::OverrideDecoration(ProgramID program_id,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
uint32_t val)
|
uint32_t val)
|
||||||
: Base(program_id, source), value_(val) {}
|
: Base(program_id, source), value_(val) {}
|
||||||
|
|
||||||
ConstantIdDecoration::~ConstantIdDecoration() = default;
|
OverrideDecoration::~OverrideDecoration() = default;
|
||||||
|
|
||||||
void ConstantIdDecoration::to_str(const sem::Info&,
|
void OverrideDecoration::to_str(const sem::Info&,
|
||||||
std::ostream& out,
|
std::ostream& out,
|
||||||
size_t indent) const {
|
size_t indent) const {
|
||||||
make_indent(out, indent);
|
make_indent(out, indent);
|
||||||
out << "ConstantIdDecoration{" << value_ << "}" << std::endl;
|
out << "OverrideDecoration{" << value_ << "}" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstantIdDecoration* ConstantIdDecoration::Clone(CloneContext* ctx) const {
|
OverrideDecoration* OverrideDecoration::Clone(CloneContext* ctx) const {
|
||||||
// Clone arguments outside of create() call to have deterministic ordering
|
// Clone arguments outside of create() call to have deterministic ordering
|
||||||
auto src = ctx->Clone(source());
|
auto src = ctx->Clone(source());
|
||||||
return ctx->dst->create<ConstantIdDecoration>(src, value_);
|
return ctx->dst->create<OverrideDecoration>(src, value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ast
|
} // namespace ast
|
@ -12,27 +12,25 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_AST_CONSTANT_ID_DECORATION_H_
|
#ifndef SRC_AST_OVERRIDE_DECORATION_H_
|
||||||
#define SRC_AST_CONSTANT_ID_DECORATION_H_
|
#define SRC_AST_OVERRIDE_DECORATION_H_
|
||||||
|
|
||||||
#include "src/ast/decoration.h"
|
#include "src/ast/decoration.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
||||||
/// A constant id decoration
|
/// An override decoration
|
||||||
class ConstantIdDecoration : public Castable<ConstantIdDecoration, Decoration> {
|
class OverrideDecoration : public Castable<OverrideDecoration, Decoration> {
|
||||||
public:
|
public:
|
||||||
/// constructor
|
/// constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param program_id the identifier of the program that owns this node
|
||||||
/// @param source the source of this decoration
|
/// @param source the source of this decoration
|
||||||
/// @param val the constant_id value
|
/// @param val the override value
|
||||||
ConstantIdDecoration(ProgramID program_id,
|
OverrideDecoration(ProgramID program_id, const Source& source, uint32_t val);
|
||||||
const Source& source,
|
~OverrideDecoration() override;
|
||||||
uint32_t val);
|
|
||||||
~ConstantIdDecoration() override;
|
|
||||||
|
|
||||||
/// @returns the constant id value
|
/// @returns the override id value
|
||||||
uint32_t value() const { return value_; }
|
uint32_t value() const { return value_; }
|
||||||
|
|
||||||
/// Outputs the decoration to the given stream
|
/// Outputs the decoration to the given stream
|
||||||
@ -47,7 +45,7 @@ class ConstantIdDecoration : public Castable<ConstantIdDecoration, Decoration> {
|
|||||||
/// `ctx`.
|
/// `ctx`.
|
||||||
/// @param ctx the clone context
|
/// @param ctx the clone context
|
||||||
/// @return the newly cloned node
|
/// @return the newly cloned node
|
||||||
ConstantIdDecoration* Clone(CloneContext* ctx) const override;
|
OverrideDecoration* Clone(CloneContext* ctx) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t const value_;
|
uint32_t const value_;
|
||||||
@ -56,4 +54,4 @@ class ConstantIdDecoration : public Castable<ConstantIdDecoration, Decoration> {
|
|||||||
} // namespace ast
|
} // namespace ast
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
||||||
#endif // SRC_AST_CONSTANT_ID_DECORATION_H_
|
#endif // SRC_AST_OVERRIDE_DECORATION_H_
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
|
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
|
|
||||||
@ -20,25 +20,25 @@ namespace tint {
|
|||||||
namespace ast {
|
namespace ast {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using ConstantIdDecorationTest = TestHelper;
|
using OverrideDecorationTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(ConstantIdDecorationTest, Creation) {
|
TEST_F(OverrideDecorationTest, Creation) {
|
||||||
auto* d = create<ConstantIdDecoration>(12);
|
auto* d = create<OverrideDecoration>(12);
|
||||||
EXPECT_EQ(12u, d->value());
|
EXPECT_EQ(12u, d->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ConstantIdDecorationTest, Is) {
|
TEST_F(OverrideDecorationTest, Is) {
|
||||||
Decoration* d = create<ConstantIdDecoration>(27);
|
Decoration* d = create<OverrideDecoration>(27);
|
||||||
EXPECT_FALSE(d->Is<BindingDecoration>());
|
EXPECT_FALSE(d->Is<BindingDecoration>());
|
||||||
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
||||||
EXPECT_TRUE(d->Is<ConstantIdDecoration>());
|
EXPECT_TRUE(d->Is<OverrideDecoration>());
|
||||||
EXPECT_FALSE(d->Is<LocationDecoration>());
|
EXPECT_FALSE(d->Is<LocationDecoration>());
|
||||||
EXPECT_FALSE(d->Is<GroupDecoration>());
|
EXPECT_FALSE(d->Is<GroupDecoration>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ConstantIdDecorationTest, ToStr) {
|
TEST_F(OverrideDecorationTest, ToStr) {
|
||||||
auto* d = create<ConstantIdDecoration>(1200);
|
auto* d = create<OverrideDecoration>(1200);
|
||||||
EXPECT_EQ(str(d), R"(ConstantIdDecoration{1200}
|
EXPECT_EQ(str(d), R"(OverrideDecoration{1200}
|
||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/program_builder.h"
|
#include "src/program_builder.h"
|
||||||
#include "src/sem/variable.h"
|
#include "src/sem/variable.h"
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ Variable::BindingPoint Variable::binding_point() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Variable::constant_id() const {
|
uint32_t Variable::constant_id() const {
|
||||||
if (auto* cid = GetDecoration<ConstantIdDecoration>(decorations_)) {
|
if (auto* cid = GetDecoration<OverrideDecoration>(decorations_)) {
|
||||||
return cid->value();
|
return cid->value();
|
||||||
}
|
}
|
||||||
TINT_ASSERT(false);
|
TINT_ASSERT(false);
|
||||||
|
@ -146,8 +146,8 @@ class Variable : public Castable<Variable, Node> {
|
|||||||
/// @returns the binding point information for the variable
|
/// @returns the binding point information for the variable
|
||||||
BindingPoint binding_point() const;
|
BindingPoint binding_point() const;
|
||||||
|
|
||||||
/// @returns the constant_id value for the variable. Assumes that this
|
/// @returns the pipeline constant id value for the variable. Assumes that
|
||||||
/// variable has a constant ID decoration.
|
/// this variable has an override decoration.
|
||||||
uint32_t constant_id() const;
|
uint32_t constant_id() const;
|
||||||
|
|
||||||
/// Clones this node and all transitive child nodes using the `CloneContext`
|
/// Clones this node and all transitive child nodes using the `CloneContext`
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "gtest/gtest-spi.h"
|
#include "gtest/gtest-spi.h"
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
@ -115,13 +115,13 @@ TEST_F(VariableTest, WithDecorations) {
|
|||||||
DecorationList{
|
DecorationList{
|
||||||
create<LocationDecoration>(1),
|
create<LocationDecoration>(1),
|
||||||
create<BuiltinDecoration>(Builtin::kPosition),
|
create<BuiltinDecoration>(Builtin::kPosition),
|
||||||
create<ConstantIdDecoration>(1200),
|
create<OverrideDecoration>(1200),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto& decorations = var->decorations();
|
auto& decorations = var->decorations();
|
||||||
EXPECT_TRUE(ast::HasDecoration<ast::LocationDecoration>(decorations));
|
EXPECT_TRUE(ast::HasDecoration<ast::LocationDecoration>(decorations));
|
||||||
EXPECT_TRUE(ast::HasDecoration<ast::BuiltinDecoration>(decorations));
|
EXPECT_TRUE(ast::HasDecoration<ast::BuiltinDecoration>(decorations));
|
||||||
EXPECT_TRUE(ast::HasDecoration<ast::ConstantIdDecoration>(decorations));
|
EXPECT_TRUE(ast::HasDecoration<ast::OverrideDecoration>(decorations));
|
||||||
|
|
||||||
auto* location = ast::GetDecoration<ast::LocationDecoration>(decorations);
|
auto* location = ast::GetDecoration<ast::LocationDecoration>(decorations);
|
||||||
ASSERT_NE(nullptr, location);
|
ASSERT_NE(nullptr, location);
|
||||||
@ -172,7 +172,7 @@ TEST_F(VariableTest, BindingPointMissingBindingDecoration) {
|
|||||||
TEST_F(VariableTest, ConstantId) {
|
TEST_F(VariableTest, ConstantId) {
|
||||||
auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr,
|
auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr,
|
||||||
DecorationList{
|
DecorationList{
|
||||||
create<ConstantIdDecoration>(1200),
|
create<OverrideDecoration>(1200),
|
||||||
});
|
});
|
||||||
|
|
||||||
EXPECT_EQ(var->constant_id(), 1200u);
|
EXPECT_EQ(var->constant_id(), 1200u);
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "src/ast/bool_literal.h"
|
#include "src/ast/bool_literal.h"
|
||||||
#include "src/ast/constant_id_decoration.h"
|
|
||||||
#include "src/ast/float_literal.h"
|
#include "src/ast/float_literal.h"
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/scalar_constructor_expression.h"
|
#include "src/ast/scalar_constructor_expression.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
@ -273,7 +273,7 @@ std::string Inspector::GetRemappedNameForEntryPoint(
|
|||||||
std::map<uint32_t, Scalar> Inspector::GetConstantIDs() {
|
std::map<uint32_t, Scalar> Inspector::GetConstantIDs() {
|
||||||
std::map<uint32_t, Scalar> result;
|
std::map<uint32_t, Scalar> result;
|
||||||
for (auto* var : program_->AST().GlobalVariables()) {
|
for (auto* var : program_->AST().GlobalVariables()) {
|
||||||
if (!ast::HasDecoration<ast::ConstantIdDecoration>(var->decorations())) {
|
if (!ast::HasDecoration<ast::OverrideDecoration>(var->decorations())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/call_statement.h"
|
#include "src/ast/call_statement.h"
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/stage_decoration.h"
|
#include "src/ast/stage_decoration.h"
|
||||||
#include "src/ast/struct_block_decoration.h"
|
#include "src/ast/struct_block_decoration.h"
|
||||||
#include "src/ast/workgroup_decoration.h"
|
#include "src/ast/workgroup_decoration.h"
|
||||||
@ -151,7 +151,7 @@ class InspectorHelper : public ProgramBuilder {
|
|||||||
}
|
}
|
||||||
GlobalConst(name, type, constructor,
|
GlobalConst(name, type, constructor,
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
create<ast::ConstantIdDecoration>(id),
|
create<ast::OverrideDecoration>(id),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,32 +28,32 @@ namespace {
|
|||||||
|
|
||||||
const char* kWGSLReservedWords[] = {
|
const char* kWGSLReservedWords[] = {
|
||||||
// Please keep this list sorted
|
// Please keep this list sorted
|
||||||
"array", "as", "asm",
|
"array", "as", "asm",
|
||||||
"bf16", "binding", "block",
|
"bf16", "binding", "block",
|
||||||
"bool", "break", "builtin",
|
"bool", "break", "builtin",
|
||||||
"case", "cast", "compute",
|
"case", "cast", "compute",
|
||||||
"const", "constant_id", "continue",
|
"const", "continue", "default",
|
||||||
"default", "discard", "do",
|
"discard", "do", "else",
|
||||||
"else", "elseif", "entry_point",
|
"elseif", "entry_point", "enum",
|
||||||
"enum", "f16", "f32",
|
"f16", "f32", "fallthrough",
|
||||||
"fallthrough", "false", "fn",
|
"false", "fn", "for",
|
||||||
"for", "fragment", "i16",
|
"fragment", "i16", "i32",
|
||||||
"i32", "i64", "i8",
|
"i64", "i8", "if",
|
||||||
"if", "image", "import",
|
"image", "import", "in",
|
||||||
"in", "let", "location",
|
"let", "location", "loop",
|
||||||
"loop", "mat2x2", "mat2x3",
|
"mat2x2", "mat2x3", "mat2x4",
|
||||||
"mat2x4", "mat3x2", "mat3x3",
|
"mat3x2", "mat3x3", "mat3x4",
|
||||||
"mat3x4", "mat4x2", "mat4x3",
|
"mat4x2", "mat4x3", "mat4x4",
|
||||||
"mat4x4", "offset", "out",
|
"offset", "out", "override",
|
||||||
"premerge", "private", "ptr",
|
"premerge", "private", "ptr",
|
||||||
"regardless", "return", "set",
|
"regardless", "return", "set",
|
||||||
"storage", "struct", "switch",
|
"storage", "struct", "switch",
|
||||||
"true", "type", "typedef",
|
"true", "type", "typedef",
|
||||||
"u16", "u32", "u64",
|
"u16", "u32", "u64",
|
||||||
"u8", "uniform", "uniform_constant",
|
"u8", "uniform", "uniform_constant",
|
||||||
"unless", "using", "var",
|
"unless", "using", "var",
|
||||||
"vec2", "vec3", "vec4",
|
"vec2", "vec3", "vec4",
|
||||||
"vertex", "void", "while",
|
"vertex", "void", "while",
|
||||||
"workgroup",
|
"workgroup",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -372,32 +372,32 @@ INSTANTIATE_TEST_SUITE_P(SpvParserTest_ReservedWords,
|
|||||||
SpvNamerReservedWordTest,
|
SpvNamerReservedWordTest,
|
||||||
::testing::ValuesIn(std::vector<std::string>{
|
::testing::ValuesIn(std::vector<std::string>{
|
||||||
// Please keep this list sorted.
|
// Please keep this list sorted.
|
||||||
"array", "as", "asm",
|
"array", "as", "asm",
|
||||||
"bf16", "binding", "block",
|
"bf16", "binding", "block",
|
||||||
"bool", "break", "builtin",
|
"bool", "break", "builtin",
|
||||||
"case", "cast", "compute",
|
"case", "cast", "compute",
|
||||||
"const", "constant_id", "continue",
|
"const", "continue", "default",
|
||||||
"default", "discard", "do",
|
"discard", "do", "else",
|
||||||
"else", "elseif", "entry_point",
|
"elseif", "entry_point", "enum",
|
||||||
"enum", "f16", "f32",
|
"f16", "f32", "fallthrough",
|
||||||
"fallthrough", "false", "fn",
|
"false", "fn", "for",
|
||||||
"for", "fragment", "i16",
|
"fragment", "i16", "i32",
|
||||||
"i32", "i64", "i8",
|
"i64", "i8", "if",
|
||||||
"if", "image", "import",
|
"image", "import", "in",
|
||||||
"in", "let", "location",
|
"let", "location", "loop",
|
||||||
"loop", "mat2x2", "mat2x3",
|
"mat2x2", "mat2x3", "mat2x4",
|
||||||
"mat2x4", "mat3x2", "mat3x3",
|
"mat3x2", "mat3x3", "mat3x4",
|
||||||
"mat3x4", "mat4x2", "mat4x3",
|
"mat4x2", "mat4x3", "mat4x4",
|
||||||
"mat4x4", "offset", "out",
|
"offset", "out", "override",
|
||||||
"premerge", "private", "ptr",
|
"premerge", "private", "ptr",
|
||||||
"regardless", "return", "set",
|
"regardless", "return", "set",
|
||||||
"storage", "struct", "switch",
|
"storage", "struct", "switch",
|
||||||
"true", "type", "typedef",
|
"true", "type", "typedef",
|
||||||
"u16", "u32", "u64",
|
"u16", "u32", "u64",
|
||||||
"u8", "uniform", "uniform_constant",
|
"u8", "uniform", "uniform_constant",
|
||||||
"unless", "using", "var",
|
"unless", "using", "var",
|
||||||
"vec2", "vec3", "vec4",
|
"vec2", "vec3", "vec4",
|
||||||
"vertex", "void", "while",
|
"vertex", "void", "while",
|
||||||
"workgroup",
|
"workgroup",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "source/opt/build_module.h"
|
#include "source/opt/build_module.h"
|
||||||
#include "src/ast/bitcast_expression.h"
|
#include "src/ast/bitcast_expression.h"
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/struct_block_decoration.h"
|
#include "src/ast/struct_block_decoration.h"
|
||||||
#include "src/reader/spirv/function.h"
|
#include "src/reader/spirv/function.h"
|
||||||
#include "src/sem/access_control_type.h"
|
#include "src/sem/access_control_type.h"
|
||||||
@ -1157,7 +1157,7 @@ bool ParserImpl::EmitScalarSpecConstants() {
|
|||||||
ast::DecorationList spec_id_decos;
|
ast::DecorationList spec_id_decos;
|
||||||
for (const auto& deco : GetDecorationsFor(inst.result_id())) {
|
for (const auto& deco : GetDecorationsFor(inst.result_id())) {
|
||||||
if ((deco.size() == 2) && (deco[0] == SpvDecorationSpecId)) {
|
if ((deco.size() == 2) && (deco[0] == SpvDecorationSpecId)) {
|
||||||
auto* cid = create<ast::ConstantIdDecoration>(Source{}, deco[1]);
|
auto* cid = create<ast::OverrideDecoration>(Source{}, deco[1]);
|
||||||
spec_id_decos.push_back(cid);
|
spec_id_decos.push_back(cid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1851,7 +1851,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_True) {
|
|||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
Decorations{
|
Decorations{
|
||||||
ConstantIdDecoration{12}
|
OverrideDecoration{12}
|
||||||
}
|
}
|
||||||
myconst
|
myconst
|
||||||
none
|
none
|
||||||
@ -1876,7 +1876,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_False) {
|
|||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
Decorations{
|
Decorations{
|
||||||
ConstantIdDecoration{12}
|
OverrideDecoration{12}
|
||||||
}
|
}
|
||||||
myconst
|
myconst
|
||||||
none
|
none
|
||||||
@ -1901,7 +1901,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_U32) {
|
|||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
Decorations{
|
Decorations{
|
||||||
ConstantIdDecoration{12}
|
OverrideDecoration{12}
|
||||||
}
|
}
|
||||||
myconst
|
myconst
|
||||||
none
|
none
|
||||||
@ -1926,7 +1926,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_I32) {
|
|||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
Decorations{
|
Decorations{
|
||||||
ConstantIdDecoration{12}
|
OverrideDecoration{12}
|
||||||
}
|
}
|
||||||
myconst
|
myconst
|
||||||
none
|
none
|
||||||
@ -1951,7 +1951,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_F32) {
|
|||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
Decorations{
|
Decorations{
|
||||||
ConstantIdDecoration{12}
|
OverrideDecoration{12}
|
||||||
}
|
}
|
||||||
myconst
|
myconst
|
||||||
none
|
none
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
#include "src/ast/bitcast_expression.h"
|
#include "src/ast/bitcast_expression.h"
|
||||||
#include "src/ast/break_statement.h"
|
#include "src/ast/break_statement.h"
|
||||||
#include "src/ast/call_statement.h"
|
#include "src/ast/call_statement.h"
|
||||||
#include "src/ast/constant_id_decoration.h"
|
|
||||||
#include "src/ast/continue_statement.h"
|
#include "src/ast/continue_statement.h"
|
||||||
#include "src/ast/discard_statement.h"
|
#include "src/ast/discard_statement.h"
|
||||||
#include "src/ast/external_texture.h"
|
#include "src/ast/external_texture.h"
|
||||||
#include "src/ast/fallthrough_statement.h"
|
#include "src/ast/fallthrough_statement.h"
|
||||||
#include "src/ast/if_statement.h"
|
#include "src/ast/if_statement.h"
|
||||||
#include "src/ast/loop_statement.h"
|
#include "src/ast/loop_statement.h"
|
||||||
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/return_statement.h"
|
#include "src/ast/return_statement.h"
|
||||||
#include "src/ast/stage_decoration.h"
|
#include "src/ast/stage_decoration.h"
|
||||||
#include "src/ast/struct_block_decoration.h"
|
#include "src/ast/struct_block_decoration.h"
|
||||||
@ -121,9 +121,9 @@ const char kAccessDecoration[] = "access";
|
|||||||
const char kBindingDecoration[] = "binding";
|
const char kBindingDecoration[] = "binding";
|
||||||
const char kBlockDecoration[] = "block";
|
const char kBlockDecoration[] = "block";
|
||||||
const char kBuiltinDecoration[] = "builtin";
|
const char kBuiltinDecoration[] = "builtin";
|
||||||
const char kConstantIdDecoration[] = "constant_id";
|
|
||||||
const char kGroupDecoration[] = "group";
|
const char kGroupDecoration[] = "group";
|
||||||
const char kLocationDecoration[] = "location";
|
const char kLocationDecoration[] = "location";
|
||||||
|
const char kOverrideDecoration[] = "override";
|
||||||
const char kOffsetDecoration[] = "offset"; // DEPRECATED
|
const char kOffsetDecoration[] = "offset"; // DEPRECATED
|
||||||
const char kSizeDecoration[] = "size";
|
const char kSizeDecoration[] = "size";
|
||||||
const char kAlignDecoration[] = "align";
|
const char kAlignDecoration[] = "align";
|
||||||
@ -139,8 +139,8 @@ bool is_decoration(Token t) {
|
|||||||
auto s = t.to_str();
|
auto s = t.to_str();
|
||||||
return s == kAccessDecoration || s == kAlignDecoration ||
|
return s == kAccessDecoration || s == kAlignDecoration ||
|
||||||
s == kBindingDecoration || s == kBlockDecoration ||
|
s == kBindingDecoration || s == kBlockDecoration ||
|
||||||
s == kBuiltinDecoration || s == kConstantIdDecoration ||
|
s == kBuiltinDecoration || s == kGroupDecoration ||
|
||||||
s == kGroupDecoration || s == kLocationDecoration ||
|
s == kLocationDecoration || s == kOverrideDecoration ||
|
||||||
s == kOffsetDecoration || s == kSetDecoration ||
|
s == kOffsetDecoration || s == kSetDecoration ||
|
||||||
s == kSizeDecoration || s == kStageDecoration ||
|
s == kSizeDecoration || s == kStageDecoration ||
|
||||||
s == kStrideDecoration || s == kWorkgroupSizeDecoration;
|
s == kStrideDecoration || s == kWorkgroupSizeDecoration;
|
||||||
@ -3102,14 +3102,14 @@ Maybe<ast::Decoration*> ParserImpl::decoration() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s == kConstantIdDecoration) {
|
if (s == kOverrideDecoration) {
|
||||||
const char* use = "constant_id decoration";
|
const char* use = "override decoration";
|
||||||
return expect_paren_block(use, [&]() -> Result {
|
return expect_paren_block(use, [&]() -> Result {
|
||||||
auto val = expect_positive_sint(use);
|
auto val = expect_positive_sint(use);
|
||||||
if (val.errored)
|
if (val.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return create<ast::ConstantIdDecoration>(t.source(), val.value);
|
return create<ast::OverrideDecoration>(t.source(), val.value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
@ -45,7 +45,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl) {
|
|||||||
EXPECT_TRUE(e->constructor()->Is<ast::ConstructorExpression>());
|
EXPECT_TRUE(e->constructor()->Is<ast::ConstructorExpression>());
|
||||||
|
|
||||||
EXPECT_FALSE(
|
EXPECT_FALSE(
|
||||||
ast::HasDecoration<ast::ConstantIdDecoration>(e.value->decorations()));
|
ast::HasDecoration<ast::OverrideDecoration>(e.value->decorations()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, GlobalConstantDecl_MissingEqual) {
|
TEST_F(ParserImplTest, GlobalConstantDecl_MissingEqual) {
|
||||||
@ -100,8 +100,8 @@ TEST_F(ParserImplTest, GlobalConstantDecl_MissingExpression) {
|
|||||||
EXPECT_EQ(p->error(), "1:14: unable to parse constant literal");
|
EXPECT_EQ(p->error(), "1:14: unable to parse constant literal");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, GlobalConstantDec_ConstantId) {
|
TEST_F(ParserImplTest, GlobalConstantDec_Override_WithId) {
|
||||||
auto p = parser("[[constant_id(7)]] let a : f32 = 1.");
|
auto p = parser("[[override(7)]] let a : f32 = 1.");
|
||||||
auto decos = p->decoration_list();
|
auto decos = p->decoration_list();
|
||||||
EXPECT_FALSE(decos.errored);
|
EXPECT_FALSE(decos.errored);
|
||||||
EXPECT_TRUE(decos.matched);
|
EXPECT_TRUE(decos.matched);
|
||||||
@ -118,20 +118,20 @@ TEST_F(ParserImplTest, GlobalConstantDec_ConstantId) {
|
|||||||
EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
|
EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
|
||||||
|
|
||||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||||
EXPECT_EQ(e->source().range.begin.column, 24u);
|
EXPECT_EQ(e->source().range.begin.column, 21u);
|
||||||
EXPECT_EQ(e->source().range.end.line, 1u);
|
EXPECT_EQ(e->source().range.end.line, 1u);
|
||||||
EXPECT_EQ(e->source().range.end.column, 25u);
|
EXPECT_EQ(e->source().range.end.column, 22u);
|
||||||
|
|
||||||
ASSERT_NE(e->constructor(), nullptr);
|
ASSERT_NE(e->constructor(), nullptr);
|
||||||
EXPECT_TRUE(e->constructor()->Is<ast::ConstructorExpression>());
|
EXPECT_TRUE(e->constructor()->Is<ast::ConstructorExpression>());
|
||||||
|
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
ast::HasDecoration<ast::ConstantIdDecoration>(e.value->decorations()));
|
ast::HasDecoration<ast::OverrideDecoration>(e.value->decorations()));
|
||||||
EXPECT_EQ(e.value->constant_id(), 7u);
|
EXPECT_EQ(e.value->constant_id(), 7u);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, GlobalConstantDec_ConstantId_Missing) {
|
TEST_F(ParserImplTest, GlobalConstantDec_Override_MissingId) {
|
||||||
auto p = parser("[[constant_id()]] let a : f32 = 1.");
|
auto p = parser("[[override()]] let a : f32 = 1.");
|
||||||
auto decos = p->decoration_list();
|
auto decos = p->decoration_list();
|
||||||
EXPECT_TRUE(decos.errored);
|
EXPECT_TRUE(decos.errored);
|
||||||
EXPECT_FALSE(decos.matched);
|
EXPECT_FALSE(decos.matched);
|
||||||
@ -143,11 +143,11 @@ TEST_F(ParserImplTest, GlobalConstantDec_ConstantId_Missing) {
|
|||||||
|
|
||||||
EXPECT_TRUE(p->has_error());
|
EXPECT_TRUE(p->has_error());
|
||||||
EXPECT_EQ(p->error(),
|
EXPECT_EQ(p->error(),
|
||||||
"1:15: expected signed integer literal for constant_id decoration");
|
"1:12: expected signed integer literal for override decoration");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, GlobalConstantDec_ConstantId_Invalid) {
|
TEST_F(ParserImplTest, GlobalConstantDec_Override_InvalidId) {
|
||||||
auto p = parser("[[constant_id(-7)]] let a : f32 = 1.");
|
auto p = parser("[[override(-7)]] let a : f32 = 1.");
|
||||||
auto decos = p->decoration_list();
|
auto decos = p->decoration_list();
|
||||||
EXPECT_TRUE(decos.errored);
|
EXPECT_TRUE(decos.errored);
|
||||||
EXPECT_FALSE(decos.matched);
|
EXPECT_FALSE(decos.matched);
|
||||||
@ -158,10 +158,10 @@ TEST_F(ParserImplTest, GlobalConstantDec_ConstantId_Invalid) {
|
|||||||
ASSERT_NE(e.value, nullptr);
|
ASSERT_NE(e.value, nullptr);
|
||||||
|
|
||||||
EXPECT_TRUE(p->has_error());
|
EXPECT_TRUE(p->has_error());
|
||||||
EXPECT_EQ(p->error(), "1:15: constant_id decoration must be positive");
|
EXPECT_EQ(p->error(), "1:12: override decoration must be positive");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, GlobalConstantDec_ConstantId_Const) {
|
TEST_F(ParserImplTest, GlobalConstantDec_Const) {
|
||||||
auto p = parser("const a : i32 = 1");
|
auto p = parser("const a : i32 = 1");
|
||||||
auto decos = p->decoration_list();
|
auto decos = p->decoration_list();
|
||||||
EXPECT_FALSE(decos.errored);
|
EXPECT_FALSE(decos.errored);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/access_decoration.h"
|
#include "src/ast/access_decoration.h"
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/return_statement.h"
|
#include "src/ast/return_statement.h"
|
||||||
#include "src/ast/stage_decoration.h"
|
#include "src/ast/stage_decoration.h"
|
||||||
#include "src/ast/struct_block_decoration.h"
|
#include "src/ast/struct_block_decoration.h"
|
||||||
@ -64,7 +64,7 @@ static ast::Decoration* createDecoration(const Source& source,
|
|||||||
case DecorationKind::kBuiltin:
|
case DecorationKind::kBuiltin:
|
||||||
return builder.Builtin(source, ast::Builtin::kPosition);
|
return builder.Builtin(source, ast::Builtin::kPosition);
|
||||||
case DecorationKind::kConstantId:
|
case DecorationKind::kConstantId:
|
||||||
return builder.create<ast::ConstantIdDecoration>(source, 0u);
|
return builder.create<ast::OverrideDecoration>(source, 0u);
|
||||||
case DecorationKind::kGroup:
|
case DecorationKind::kGroup:
|
||||||
return builder.create<ast::GroupDecoration>(source, 1u);
|
return builder.create<ast::GroupDecoration>(source, 1u);
|
||||||
case DecorationKind::kLocation:
|
case DecorationKind::kLocation:
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "src/ast/bitcast_expression.h"
|
#include "src/ast/bitcast_expression.h"
|
||||||
#include "src/ast/break_statement.h"
|
#include "src/ast/break_statement.h"
|
||||||
#include "src/ast/call_statement.h"
|
#include "src/ast/call_statement.h"
|
||||||
#include "src/ast/constant_id_decoration.h"
|
|
||||||
#include "src/ast/continue_statement.h"
|
#include "src/ast/continue_statement.h"
|
||||||
#include "src/ast/depth_texture.h"
|
#include "src/ast/depth_texture.h"
|
||||||
#include "src/ast/discard_statement.h"
|
#include "src/ast/discard_statement.h"
|
||||||
@ -33,6 +32,7 @@
|
|||||||
#include "src/ast/internal_decoration.h"
|
#include "src/ast/internal_decoration.h"
|
||||||
#include "src/ast/loop_statement.h"
|
#include "src/ast/loop_statement.h"
|
||||||
#include "src/ast/matrix.h"
|
#include "src/ast/matrix.h"
|
||||||
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/pointer.h"
|
#include "src/ast/pointer.h"
|
||||||
#include "src/ast/return_statement.h"
|
#include "src/ast/return_statement.h"
|
||||||
#include "src/ast/sampled_texture.h"
|
#include "src/ast/sampled_texture.h"
|
||||||
@ -401,7 +401,7 @@ bool Resolver::GlobalVariable(ast::Variable* var) {
|
|||||||
Mark(deco);
|
Mark(deco);
|
||||||
if (!(deco->Is<ast::BindingDecoration>() ||
|
if (!(deco->Is<ast::BindingDecoration>() ||
|
||||||
deco->Is<ast::BuiltinDecoration>() ||
|
deco->Is<ast::BuiltinDecoration>() ||
|
||||||
deco->Is<ast::ConstantIdDecoration>() ||
|
deco->Is<ast::OverrideDecoration>() ||
|
||||||
deco->Is<ast::GroupDecoration>() ||
|
deco->Is<ast::GroupDecoration>() ||
|
||||||
deco->Is<ast::LocationDecoration>())) {
|
deco->Is<ast::LocationDecoration>())) {
|
||||||
diagnostics_.add_error("decoration is not valid for variables",
|
diagnostics_.add_error("decoration is not valid for variables",
|
||||||
|
@ -499,7 +499,7 @@ fn f() {
|
|||||||
|
|
||||||
// TODO(dsinclair): Implement when constant_id exists
|
// TODO(dsinclair): Implement when constant_id exists
|
||||||
TEST_F(BoundArrayAccessorsTest, DISABLED_Vector_Constant_Id_Clamps) {
|
TEST_F(BoundArrayAccessorsTest, DISABLED_Vector_Constant_Id_Clamps) {
|
||||||
// [[constant_id(1300)]] let idx : i32;
|
// [[override(1300)]] let idx : i32;
|
||||||
// var a : vec3<f32>
|
// var a : vec3<f32>
|
||||||
// var b : f32 = a[idx]
|
// var b : f32 = a[idx]
|
||||||
//
|
//
|
||||||
@ -508,7 +508,7 @@ TEST_F(BoundArrayAccessorsTest, DISABLED_Vector_Constant_Id_Clamps) {
|
|||||||
|
|
||||||
// TODO(dsinclair): Implement when constant_id exists
|
// TODO(dsinclair): Implement when constant_id exists
|
||||||
TEST_F(BoundArrayAccessorsTest, DISABLED_Array_Constant_Id_Clamps) {
|
TEST_F(BoundArrayAccessorsTest, DISABLED_Array_Constant_Id_Clamps) {
|
||||||
// [[constant_id(1300)]] let idx : i32;
|
// [[override(1300)]] let idx : i32;
|
||||||
// var a : array<f32, 4>
|
// var a : array<f32, 4>
|
||||||
// var b : f32 = a[idx]
|
// var b : f32 = a[idx]
|
||||||
//
|
//
|
||||||
@ -517,7 +517,7 @@ TEST_F(BoundArrayAccessorsTest, DISABLED_Array_Constant_Id_Clamps) {
|
|||||||
|
|
||||||
// TODO(dsinclair): Implement when constant_id exists
|
// TODO(dsinclair): Implement when constant_id exists
|
||||||
TEST_F(BoundArrayAccessorsTest, DISABLED_Matrix_Column_Constant_Id_Clamps) {
|
TEST_F(BoundArrayAccessorsTest, DISABLED_Matrix_Column_Constant_Id_Clamps) {
|
||||||
// [[constant_id(1300)]] let idx : i32;
|
// [[override(1300)]] let idx : i32;
|
||||||
// var a : mat3x2<f32>
|
// var a : mat3x2<f32>
|
||||||
// var b : f32 = a[idx][1]
|
// var b : f32 = a[idx][1]
|
||||||
//
|
//
|
||||||
@ -526,7 +526,7 @@ TEST_F(BoundArrayAccessorsTest, DISABLED_Matrix_Column_Constant_Id_Clamps) {
|
|||||||
|
|
||||||
// TODO(dsinclair): Implement when constant_id exists
|
// TODO(dsinclair): Implement when constant_id exists
|
||||||
TEST_F(BoundArrayAccessorsTest, DISABLED_Matrix_Row_Constant_Id_Clamps) {
|
TEST_F(BoundArrayAccessorsTest, DISABLED_Matrix_Row_Constant_Id_Clamps) {
|
||||||
// [[constant_id(1300)]] let idx : i32;
|
// [[override(1300)]] let idx : i32;
|
||||||
// var a : mat3x2<f32>
|
// var a : mat3x2<f32>
|
||||||
// var b : f32 = a[1][idx]
|
// var b : f32 = a[1][idx]
|
||||||
//
|
//
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "src/ast/call_statement.h"
|
#include "src/ast/call_statement.h"
|
||||||
#include "src/ast/constant_id_decoration.h"
|
|
||||||
#include "src/ast/fallthrough_statement.h"
|
#include "src/ast/fallthrough_statement.h"
|
||||||
#include "src/ast/internal_decoration.h"
|
#include "src/ast/internal_decoration.h"
|
||||||
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
#include "src/sem/access_control_type.h"
|
#include "src/sem/access_control_type.h"
|
||||||
#include "src/sem/array.h"
|
#include "src/sem/array.h"
|
||||||
@ -2681,7 +2681,7 @@ bool GeneratorImpl::EmitProgramConstVariable(std::ostream& out,
|
|||||||
make_indent(out);
|
make_indent(out);
|
||||||
|
|
||||||
for (auto* d : var->decorations()) {
|
for (auto* d : var->decorations()) {
|
||||||
if (!d->Is<ast::ConstantIdDecoration>()) {
|
if (!d->Is<ast::OverrideDecoration>()) {
|
||||||
diagnostics_.add_error("Decorated const values not valid");
|
diagnostics_.add_error("Decorated const values not valid");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2703,7 +2703,7 @@ bool GeneratorImpl::EmitProgramConstVariable(std::ostream& out,
|
|||||||
auto* sem = builder_.Sem().Get(var);
|
auto* sem = builder_.Sem().Get(var);
|
||||||
auto* type = sem->Type();
|
auto* type = sem->Type();
|
||||||
|
|
||||||
if (ast::HasDecoration<ast::ConstantIdDecoration>(var->decorations())) {
|
if (ast::HasDecoration<ast::OverrideDecoration>(var->decorations())) {
|
||||||
auto const_id = var->constant_id();
|
auto const_id = var->constant_id();
|
||||||
|
|
||||||
out << "#ifndef WGSL_SPEC_CONSTANT_" << const_id << std::endl;
|
out << "#ifndef WGSL_SPEC_CONSTANT_" << const_id << std::endl;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/writer/hlsl/test_helper.h"
|
#include "src/writer/hlsl/test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
@ -35,7 +35,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
|
|||||||
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) {
|
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) {
|
||||||
auto* var = Const("pos", ty.f32(), Expr(3.0f),
|
auto* var = Const("pos", ty.f32(), Expr(3.0f),
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
create<ast::ConstantIdDecoration>(23),
|
create<ast::OverrideDecoration>(23),
|
||||||
});
|
});
|
||||||
WrapInFunction(Decl(var));
|
WrapInFunction(Decl(var));
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ static const float pos = WGSL_SPEC_CONSTANT_23;
|
|||||||
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoConstructor) {
|
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoConstructor) {
|
||||||
auto* var = Const("pos", ty.f32(), nullptr,
|
auto* var = Const("pos", ty.f32(), nullptr,
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
create<ast::ConstantIdDecoration>(23),
|
create<ast::OverrideDecoration>(23),
|
||||||
});
|
});
|
||||||
WrapInFunction(Decl(var));
|
WrapInFunction(Decl(var));
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/stage_decoration.h"
|
#include "src/ast/stage_decoration.h"
|
||||||
#include "src/writer/hlsl/test_helper.h"
|
#include "src/writer/hlsl/test_helper.h"
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
#include "src/ast/bool_literal.h"
|
#include "src/ast/bool_literal.h"
|
||||||
#include "src/ast/call_statement.h"
|
#include "src/ast/call_statement.h"
|
||||||
#include "src/ast/constant_id_decoration.h"
|
|
||||||
#include "src/ast/fallthrough_statement.h"
|
#include "src/ast/fallthrough_statement.h"
|
||||||
#include "src/ast/float_literal.h"
|
#include "src/ast/float_literal.h"
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
@ -2250,7 +2250,7 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) {
|
|||||||
make_indent();
|
make_indent();
|
||||||
|
|
||||||
for (auto* d : var->decorations()) {
|
for (auto* d : var->decorations()) {
|
||||||
if (!d->Is<ast::ConstantIdDecoration>()) {
|
if (!d->Is<ast::OverrideDecoration>()) {
|
||||||
diagnostics_.add_error("Decorated const values not valid");
|
diagnostics_.add_error("Decorated const values not valid");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2269,7 +2269,7 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) {
|
|||||||
out_ << " " << program_->Symbols().NameFor(var->symbol());
|
out_ << " " << program_->Symbols().NameFor(var->symbol());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ast::HasDecoration<ast::ConstantIdDecoration>(var->decorations())) {
|
if (ast::HasDecoration<ast::OverrideDecoration>(var->decorations())) {
|
||||||
out_ << " [[function_constant(" << var->constant_id() << ")]]";
|
out_ << " [[function_constant(" << var->constant_id() << ")]]";
|
||||||
} else if (var->constructor() != nullptr) {
|
} else if (var->constructor() != nullptr) {
|
||||||
out_ << " = ";
|
out_ << " = ";
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/writer/msl/test_helper.h"
|
#include "src/writer/msl/test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
@ -35,7 +35,7 @@ TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) {
|
|||||||
TEST_F(MslGeneratorImplTest, Emit_SpecConstant) {
|
TEST_F(MslGeneratorImplTest, Emit_SpecConstant) {
|
||||||
auto* var = Const("pos", ty.f32(), Expr(3.f),
|
auto* var = Const("pos", ty.f32(), Expr(3.f),
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
create<ast::ConstantIdDecoration>(23),
|
create<ast::OverrideDecoration>(23),
|
||||||
});
|
});
|
||||||
WrapInFunction(Decl(var));
|
WrapInFunction(Decl(var));
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
#include "spirv/unified1/GLSL.std.450.h"
|
#include "spirv/unified1/GLSL.std.450.h"
|
||||||
#include "src/ast/call_statement.h"
|
#include "src/ast/call_statement.h"
|
||||||
#include "src/ast/constant_id_decoration.h"
|
|
||||||
#include "src/ast/fallthrough_statement.h"
|
#include "src/ast/fallthrough_statement.h"
|
||||||
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/sem/array.h"
|
#include "src/sem/array.h"
|
||||||
#include "src/sem/call.h"
|
#include "src/sem/call.h"
|
||||||
#include "src/sem/depth_texture_type.h"
|
#include "src/sem/depth_texture_type.h"
|
||||||
@ -745,12 +745,12 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) {
|
|||||||
} else if (!type_no_ac->Is<sem::Sampler>()) {
|
} else if (!type_no_ac->Is<sem::Sampler>()) {
|
||||||
// Certain cases require us to generate a constructor value.
|
// Certain cases require us to generate a constructor value.
|
||||||
//
|
//
|
||||||
// 1- ConstantId's must be attached to the OpConstant, if we have a
|
// 1- Pipeline constant IDs must be attached to the OpConstant, if we have a
|
||||||
// variable with a constant_id that doesn't have a constructor we make
|
// variable with an override attribute that doesn't have a constructor we
|
||||||
// one
|
// make one
|
||||||
// 2- If we don't have a constructor and we're an Output or Private variable
|
// 2- If we don't have a constructor and we're an Output or Private variable
|
||||||
// then WGSL requires an initializer.
|
// then WGSL requires an initializer.
|
||||||
if (ast::HasDecoration<ast::ConstantIdDecoration>(var->decorations())) {
|
if (ast::HasDecoration<ast::OverrideDecoration>(var->decorations())) {
|
||||||
if (type_no_ac->Is<sem::F32>()) {
|
if (type_no_ac->Is<sem::F32>()) {
|
||||||
ast::FloatLiteral l(ProgramID(), Source{}, 0.0f);
|
ast::FloatLiteral l(ProgramID(), Source{}, 0.0f);
|
||||||
init_id = GenerateLiteralIfNeeded(var, &l);
|
init_id = GenerateLiteralIfNeeded(var, &l);
|
||||||
@ -764,7 +764,7 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) {
|
|||||||
ast::BoolLiteral l(ProgramID(), Source{}, false);
|
ast::BoolLiteral l(ProgramID(), Source{}, false);
|
||||||
init_id = GenerateLiteralIfNeeded(var, &l);
|
init_id = GenerateLiteralIfNeeded(var, &l);
|
||||||
} else {
|
} else {
|
||||||
error_ = "invalid type for constant_id, must be scalar";
|
error_ = "invalid type for pipeline constant ID, must be scalar";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (init_id == 0) {
|
if (init_id == 0) {
|
||||||
@ -802,7 +802,7 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) {
|
|||||||
push_annot(spv::Op::OpDecorate, {Operand::Int(var_id),
|
push_annot(spv::Op::OpDecorate, {Operand::Int(var_id),
|
||||||
Operand::Int(SpvDecorationDescriptorSet),
|
Operand::Int(SpvDecorationDescriptorSet),
|
||||||
Operand::Int(group->value())});
|
Operand::Int(group->value())});
|
||||||
} else if (deco->Is<ast::ConstantIdDecoration>()) {
|
} else if (deco->Is<ast::OverrideDecoration>()) {
|
||||||
// Spec constants are handled elsewhere
|
// Spec constants are handled elsewhere
|
||||||
} else {
|
} else {
|
||||||
error_ = "unknown decoration";
|
error_ = "unknown decoration";
|
||||||
@ -1492,8 +1492,7 @@ uint32_t Builder::GenerateLiteralIfNeeded(ast::Variable* var,
|
|||||||
ast::Literal* lit) {
|
ast::Literal* lit) {
|
||||||
ScalarConstant constant;
|
ScalarConstant constant;
|
||||||
|
|
||||||
if (var &&
|
if (var && ast::HasDecoration<ast::OverrideDecoration>(var->decorations())) {
|
||||||
ast::HasDecoration<ast::ConstantIdDecoration>(var->decorations())) {
|
|
||||||
constant.is_spec_op = true;
|
constant.is_spec_op = true;
|
||||||
constant.constant_id = var->constant_id();
|
constant.constant_id = var->constant_id();
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/stage_decoration.h"
|
#include "src/ast/stage_decoration.h"
|
||||||
#include "src/ast/struct_block_decoration.h"
|
#include "src/ast/struct_block_decoration.h"
|
||||||
#include "src/writer/spirv/spv_dump.h"
|
#include "src/writer/spirv/spv_dump.h"
|
||||||
@ -206,7 +206,7 @@ TEST_F(BuilderTest, GlobalVar_WithBuiltin) {
|
|||||||
TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) {
|
TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) {
|
||||||
auto* v = Global("var", ty.bool_(), ast::StorageClass::kInput, Expr(true),
|
auto* v = Global("var", ty.bool_(), ast::StorageClass::kInput, Expr(true),
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
create<ast::ConstantIdDecoration>(1200),
|
create<ast::OverrideDecoration>(1200),
|
||||||
});
|
});
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
@ -226,7 +226,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) {
|
|||||||
TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) {
|
TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) {
|
||||||
auto* v = Global("var", ty.bool_(), ast::StorageClass::kInput, nullptr,
|
auto* v = Global("var", ty.bool_(), ast::StorageClass::kInput, nullptr,
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
create<ast::ConstantIdDecoration>(1200),
|
create<ast::OverrideDecoration>(1200),
|
||||||
});
|
});
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
@ -246,7 +246,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) {
|
|||||||
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) {
|
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) {
|
||||||
auto* v = Global("var", ty.f32(), ast::StorageClass::kInput, Expr(2.f),
|
auto* v = Global("var", ty.f32(), ast::StorageClass::kInput, Expr(2.f),
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
create<ast::ConstantIdDecoration>(0),
|
create<ast::OverrideDecoration>(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
@ -266,7 +266,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) {
|
|||||||
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) {
|
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) {
|
||||||
auto* v = Global("var", ty.f32(), ast::StorageClass::kInput, nullptr,
|
auto* v = Global("var", ty.f32(), ast::StorageClass::kInput, nullptr,
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
create<ast::ConstantIdDecoration>(0),
|
create<ast::OverrideDecoration>(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
@ -286,7 +286,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) {
|
|||||||
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) {
|
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) {
|
||||||
auto* v = Global("var", ty.i32(), ast::StorageClass::kInput, nullptr,
|
auto* v = Global("var", ty.i32(), ast::StorageClass::kInput, nullptr,
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
create<ast::ConstantIdDecoration>(0),
|
create<ast::OverrideDecoration>(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
@ -306,7 +306,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) {
|
|||||||
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_U32_NoConstructor) {
|
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_U32_NoConstructor) {
|
||||||
auto* v = Global("var", ty.u32(), ast::StorageClass::kInput, nullptr,
|
auto* v = Global("var", ty.u32(), ast::StorageClass::kInput, nullptr,
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
create<ast::ConstantIdDecoration>(0),
|
create<ast::OverrideDecoration>(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include "src/ast/bool.h"
|
#include "src/ast/bool.h"
|
||||||
#include "src/ast/bool_literal.h"
|
#include "src/ast/bool_literal.h"
|
||||||
#include "src/ast/call_statement.h"
|
#include "src/ast/call_statement.h"
|
||||||
#include "src/ast/constant_id_decoration.h"
|
|
||||||
#include "src/ast/depth_texture.h"
|
#include "src/ast/depth_texture.h"
|
||||||
#include "src/ast/f32.h"
|
#include "src/ast/f32.h"
|
||||||
#include "src/ast/float_literal.h"
|
#include "src/ast/float_literal.h"
|
||||||
@ -31,6 +30,7 @@
|
|||||||
#include "src/ast/matrix.h"
|
#include "src/ast/matrix.h"
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
#include "src/ast/multisampled_texture.h"
|
#include "src/ast/multisampled_texture.h"
|
||||||
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/ast/pointer.h"
|
#include "src/ast/pointer.h"
|
||||||
#include "src/ast/sampled_texture.h"
|
#include "src/ast/sampled_texture.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
@ -811,8 +811,8 @@ bool GeneratorImpl::EmitDecorations(const ast::DecorationList& decos) {
|
|||||||
out_ << "location(" << location->value() << ")";
|
out_ << "location(" << location->value() << ")";
|
||||||
} else if (auto* builtin = deco->As<ast::BuiltinDecoration>()) {
|
} else if (auto* builtin = deco->As<ast::BuiltinDecoration>()) {
|
||||||
out_ << "builtin(" << builtin->value() << ")";
|
out_ << "builtin(" << builtin->value() << ")";
|
||||||
} else if (auto* constant = deco->As<ast::ConstantIdDecoration>()) {
|
} else if (auto* override_deco = deco->As<ast::OverrideDecoration>()) {
|
||||||
out_ << "constant_id(" << constant->value() << ")";
|
out_ << "override(" << override_deco->value() << ")";
|
||||||
} else if (auto* size = deco->As<ast::StructMemberSizeDecoration>()) {
|
} else if (auto* size = deco->As<ast::StructMemberSizeDecoration>()) {
|
||||||
out_ << "size(" << size->size() << ")";
|
out_ << "size(" << size->size() << ")";
|
||||||
} else if (auto* align = deco->As<ast::StructMemberAlignDecoration>()) {
|
} else if (auto* align = deco->As<ast::StructMemberAlignDecoration>()) {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/override_decoration.h"
|
||||||
#include "src/writer/wgsl/test_helper.h"
|
#include "src/writer/wgsl/test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
@ -62,7 +62,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) {
|
|||||||
create<ast::BindingDecoration>(0),
|
create<ast::BindingDecoration>(0),
|
||||||
create<ast::GroupDecoration>(1),
|
create<ast::GroupDecoration>(1),
|
||||||
Location(2),
|
Location(2),
|
||||||
create<ast::ConstantIdDecoration>(42),
|
create<ast::OverrideDecoration>(42),
|
||||||
});
|
});
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
@ -70,7 +70,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) {
|
|||||||
ASSERT_TRUE(gen.EmitVariable(v)) << gen.error();
|
ASSERT_TRUE(gen.EmitVariable(v)) << gen.error();
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
gen.result(),
|
gen.result(),
|
||||||
R"([[builtin(position), binding(0), group(1), location(2), constant_id(42)]] var<private> a : f32;
|
R"([[builtin(position), binding(0), group(1), location(2), override(42)]] var<private> a : f32;
|
||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,6 @@ tint_unittests_source_set("tint_unittests_core_src") {
|
|||||||
"../src/ast/call_expression_test.cc",
|
"../src/ast/call_expression_test.cc",
|
||||||
"../src/ast/call_statement_test.cc",
|
"../src/ast/call_statement_test.cc",
|
||||||
"../src/ast/case_statement_test.cc",
|
"../src/ast/case_statement_test.cc",
|
||||||
"../src/ast/constant_id_decoration_test.cc",
|
|
||||||
"../src/ast/continue_statement_test.cc",
|
"../src/ast/continue_statement_test.cc",
|
||||||
"../src/ast/depth_texture_test.cc",
|
"../src/ast/depth_texture_test.cc",
|
||||||
"../src/ast/discard_statement_test.cc",
|
"../src/ast/discard_statement_test.cc",
|
||||||
@ -209,6 +208,7 @@ tint_unittests_source_set("tint_unittests_core_src") {
|
|||||||
"../src/ast/module_clone_test.cc",
|
"../src/ast/module_clone_test.cc",
|
||||||
"../src/ast/module_test.cc",
|
"../src/ast/module_test.cc",
|
||||||
"../src/ast/multisampled_texture_test.cc",
|
"../src/ast/multisampled_texture_test.cc",
|
||||||
|
"../src/ast/override_decoration_test.cc",
|
||||||
"../src/ast/pointer_test.cc",
|
"../src/ast/pointer_test.cc",
|
||||||
"../src/ast/return_statement_test.cc",
|
"../src/ast/return_statement_test.cc",
|
||||||
"../src/ast/sampled_texture_test.cc",
|
"../src/ast/sampled_texture_test.cc",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user