mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-12 22:56:09 +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:
committed by
Commit Bot service account
parent
083b591783
commit
e87ded8567
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/override_decoration.h"
|
||||
#include "src/ast/test_helper.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -30,7 +30,7 @@ TEST_F(BindingDecorationTest, Is) {
|
||||
Decoration* d = create<BindingDecoration>(2);
|
||||
EXPECT_TRUE(d->Is<BindingDecoration>());
|
||||
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
||||
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
|
||||
EXPECT_FALSE(d->Is<OverrideDecoration>());
|
||||
EXPECT_FALSE(d->Is<LocationDecoration>());
|
||||
EXPECT_FALSE(d->Is<GroupDecoration>());
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/override_decoration.h"
|
||||
#include "src/ast/test_helper.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -30,7 +30,7 @@ TEST_F(BuiltinDecorationTest, Is) {
|
||||
Decoration* d = create<BuiltinDecoration>(Builtin::kFragDepth);
|
||||
EXPECT_FALSE(d->Is<BindingDecoration>());
|
||||
EXPECT_TRUE(d->Is<BuiltinDecoration>());
|
||||
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
|
||||
EXPECT_FALSE(d->Is<OverrideDecoration>());
|
||||
EXPECT_FALSE(d->Is<LocationDecoration>());
|
||||
EXPECT_FALSE(d->Is<GroupDecoration>());
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/override_decoration.h"
|
||||
#include "src/ast/test_helper.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -30,7 +30,7 @@ TEST_F(GroupDecorationTest, Is) {
|
||||
Decoration* d = create<GroupDecoration>(2);
|
||||
EXPECT_FALSE(d->Is<BindingDecoration>());
|
||||
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
||||
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
|
||||
EXPECT_FALSE(d->Is<OverrideDecoration>());
|
||||
EXPECT_FALSE(d->Is<LocationDecoration>());
|
||||
EXPECT_TRUE(d->Is<GroupDecoration>());
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/override_decoration.h"
|
||||
#include "src/ast/test_helper.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -30,7 +30,7 @@ TEST_F(LocationDecorationTest, Is) {
|
||||
Decoration* d = create<LocationDecoration>(2);
|
||||
EXPECT_FALSE(d->Is<BindingDecoration>());
|
||||
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
||||
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
|
||||
EXPECT_FALSE(d->Is<OverrideDecoration>());
|
||||
EXPECT_TRUE(d->Is<LocationDecoration>());
|
||||
EXPECT_FALSE(d->Is<GroupDecoration>());
|
||||
}
|
||||
|
||||
@@ -12,33 +12,33 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/override_decoration.h"
|
||||
|
||||
#include "src/program_builder.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::ast::ConstantIdDecoration);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::ast::OverrideDecoration);
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
ConstantIdDecoration::ConstantIdDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t val)
|
||||
OverrideDecoration::OverrideDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t val)
|
||||
: Base(program_id, source), value_(val) {}
|
||||
|
||||
ConstantIdDecoration::~ConstantIdDecoration() = default;
|
||||
OverrideDecoration::~OverrideDecoration() = default;
|
||||
|
||||
void ConstantIdDecoration::to_str(const sem::Info&,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
void OverrideDecoration::to_str(const sem::Info&,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
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
|
||||
auto src = ctx->Clone(source());
|
||||
return ctx->dst->create<ConstantIdDecoration>(src, value_);
|
||||
return ctx->dst->create<OverrideDecoration>(src, value_);
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
@@ -12,27 +12,25 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef SRC_AST_CONSTANT_ID_DECORATION_H_
|
||||
#define SRC_AST_CONSTANT_ID_DECORATION_H_
|
||||
#ifndef SRC_AST_OVERRIDE_DECORATION_H_
|
||||
#define SRC_AST_OVERRIDE_DECORATION_H_
|
||||
|
||||
#include "src/ast/decoration.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
/// A constant id decoration
|
||||
class ConstantIdDecoration : public Castable<ConstantIdDecoration, Decoration> {
|
||||
/// An override decoration
|
||||
class OverrideDecoration : public Castable<OverrideDecoration, Decoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of this decoration
|
||||
/// @param val the constant_id value
|
||||
ConstantIdDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t val);
|
||||
~ConstantIdDecoration() override;
|
||||
/// @param val the override value
|
||||
OverrideDecoration(ProgramID program_id, const Source& source, uint32_t val);
|
||||
~OverrideDecoration() override;
|
||||
|
||||
/// @returns the constant id value
|
||||
/// @returns the override id value
|
||||
uint32_t value() const { return value_; }
|
||||
|
||||
/// Outputs the decoration to the given stream
|
||||
@@ -47,7 +45,7 @@ class ConstantIdDecoration : public Castable<ConstantIdDecoration, Decoration> {
|
||||
/// `ctx`.
|
||||
/// @param ctx the clone context
|
||||
/// @return the newly cloned node
|
||||
ConstantIdDecoration* Clone(CloneContext* ctx) const override;
|
||||
OverrideDecoration* Clone(CloneContext* ctx) const override;
|
||||
|
||||
private:
|
||||
uint32_t const value_;
|
||||
@@ -56,4 +54,4 @@ class ConstantIdDecoration : public Castable<ConstantIdDecoration, Decoration> {
|
||||
} // namespace ast
|
||||
} // 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
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/override_decoration.h"
|
||||
|
||||
#include "src/ast/test_helper.h"
|
||||
|
||||
@@ -20,25 +20,25 @@ namespace tint {
|
||||
namespace ast {
|
||||
namespace {
|
||||
|
||||
using ConstantIdDecorationTest = TestHelper;
|
||||
using OverrideDecorationTest = TestHelper;
|
||||
|
||||
TEST_F(ConstantIdDecorationTest, Creation) {
|
||||
auto* d = create<ConstantIdDecoration>(12);
|
||||
TEST_F(OverrideDecorationTest, Creation) {
|
||||
auto* d = create<OverrideDecoration>(12);
|
||||
EXPECT_EQ(12u, d->value());
|
||||
}
|
||||
|
||||
TEST_F(ConstantIdDecorationTest, Is) {
|
||||
Decoration* d = create<ConstantIdDecoration>(27);
|
||||
TEST_F(OverrideDecorationTest, Is) {
|
||||
Decoration* d = create<OverrideDecoration>(27);
|
||||
EXPECT_FALSE(d->Is<BindingDecoration>());
|
||||
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
||||
EXPECT_TRUE(d->Is<ConstantIdDecoration>());
|
||||
EXPECT_TRUE(d->Is<OverrideDecoration>());
|
||||
EXPECT_FALSE(d->Is<LocationDecoration>());
|
||||
EXPECT_FALSE(d->Is<GroupDecoration>());
|
||||
}
|
||||
|
||||
TEST_F(ConstantIdDecorationTest, ToStr) {
|
||||
auto* d = create<ConstantIdDecoration>(1200);
|
||||
EXPECT_EQ(str(d), R"(ConstantIdDecoration{1200}
|
||||
TEST_F(OverrideDecorationTest, ToStr) {
|
||||
auto* d = create<OverrideDecoration>(1200);
|
||||
EXPECT_EQ(str(d), R"(OverrideDecoration{1200}
|
||||
)");
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#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/sem/variable.h"
|
||||
|
||||
@@ -63,7 +63,7 @@ Variable::BindingPoint Variable::binding_point() const {
|
||||
}
|
||||
|
||||
uint32_t Variable::constant_id() const {
|
||||
if (auto* cid = GetDecoration<ConstantIdDecoration>(decorations_)) {
|
||||
if (auto* cid = GetDecoration<OverrideDecoration>(decorations_)) {
|
||||
return cid->value();
|
||||
}
|
||||
TINT_ASSERT(false);
|
||||
|
||||
@@ -146,8 +146,8 @@ class Variable : public Castable<Variable, Node> {
|
||||
/// @returns the binding point information for the variable
|
||||
BindingPoint binding_point() const;
|
||||
|
||||
/// @returns the constant_id value for the variable. Assumes that this
|
||||
/// variable has a constant ID decoration.
|
||||
/// @returns the pipeline constant id value for the variable. Assumes that
|
||||
/// this variable has an override decoration.
|
||||
uint32_t constant_id() const;
|
||||
|
||||
/// Clones this node and all transitive child nodes using the `CloneContext`
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include "gtest/gtest-spi.h"
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/override_decoration.h"
|
||||
#include "src/ast/test_helper.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -115,13 +115,13 @@ TEST_F(VariableTest, WithDecorations) {
|
||||
DecorationList{
|
||||
create<LocationDecoration>(1),
|
||||
create<BuiltinDecoration>(Builtin::kPosition),
|
||||
create<ConstantIdDecoration>(1200),
|
||||
create<OverrideDecoration>(1200),
|
||||
});
|
||||
|
||||
auto& decorations = var->decorations();
|
||||
EXPECT_TRUE(ast::HasDecoration<ast::LocationDecoration>(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);
|
||||
ASSERT_NE(nullptr, location);
|
||||
@@ -172,7 +172,7 @@ TEST_F(VariableTest, BindingPointMissingBindingDecoration) {
|
||||
TEST_F(VariableTest, ConstantId) {
|
||||
auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr,
|
||||
DecorationList{
|
||||
create<ConstantIdDecoration>(1200),
|
||||
create<OverrideDecoration>(1200),
|
||||
});
|
||||
|
||||
EXPECT_EQ(var->constant_id(), 1200u);
|
||||
|
||||
Reference in New Issue
Block a user