mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 08:27:05 +00:00
Replace FunctionDecoration::(Is|As)Workgroup with Castable
Change-Id: Ia365504fd745579b3bd7bef0b6eda73d3164f539 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34312 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
@@ -55,8 +55,8 @@ Function::~Function() = default;
|
||||
|
||||
std::tuple<uint32_t, uint32_t, uint32_t> Function::workgroup_size() const {
|
||||
for (auto* deco : decorations_) {
|
||||
if (deco->IsWorkgroup()) {
|
||||
return deco->AsWorkgroup()->values();
|
||||
if (auto* workgroup = deco->As<WorkgroupDecoration>()) {
|
||||
return workgroup->values();
|
||||
}
|
||||
}
|
||||
return {1, 1, 1};
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
|
||||
#include "src/ast/function_decoration.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "src/ast/workgroup_decoration.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
@@ -31,14 +27,5 @@ DecorationKind FunctionDecoration::GetKind() const {
|
||||
return Kind;
|
||||
}
|
||||
|
||||
bool FunctionDecoration::IsWorkgroup() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
const WorkgroupDecoration* FunctionDecoration::AsWorkgroup() const {
|
||||
assert(IsWorkgroup());
|
||||
return static_cast<const WorkgroupDecoration*>(this);
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
class WorkgroupDecoration;
|
||||
|
||||
/// A decoration attached to a function
|
||||
class FunctionDecoration : public Castable<FunctionDecoration, Decoration> {
|
||||
public:
|
||||
@@ -37,12 +35,6 @@ class FunctionDecoration : public Castable<FunctionDecoration, Decoration> {
|
||||
/// @return the decoration kind
|
||||
DecorationKind GetKind() const override;
|
||||
|
||||
/// @returns true if this is a workgroup decoration
|
||||
virtual bool IsWorkgroup() const;
|
||||
|
||||
/// @returns the decoration as a workgroup decoration
|
||||
const WorkgroupDecoration* AsWorkgroup() const;
|
||||
|
||||
protected:
|
||||
/// Constructor
|
||||
/// @param source the source of this decoration
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/workgroup_decoration.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -32,8 +33,8 @@ TEST_F(StageDecorationTest, Creation_1param) {
|
||||
TEST_F(StageDecorationTest, Is) {
|
||||
StageDecoration sd{ast::PipelineStage::kFragment, Source{}};
|
||||
Decoration* d = &sd;
|
||||
EXPECT_FALSE(sd.IsWorkgroup());
|
||||
EXPECT_TRUE(d->Is<ast::StageDecoration>());
|
||||
EXPECT_FALSE(d->Is<WorkgroupDecoration>());
|
||||
EXPECT_TRUE(d->Is<StageDecoration>());
|
||||
}
|
||||
|
||||
TEST_F(StageDecorationTest, ToStr) {
|
||||
|
||||
@@ -33,10 +33,6 @@ WorkgroupDecoration::WorkgroupDecoration(uint32_t x,
|
||||
|
||||
WorkgroupDecoration::~WorkgroupDecoration() = default;
|
||||
|
||||
bool WorkgroupDecoration::IsWorkgroup() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void WorkgroupDecoration::to_str(std::ostream& out, size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "WorkgroupDecoration{" << x_ << " " << y_ << " " << z_ << "}"
|
||||
|
||||
@@ -45,9 +45,6 @@ class WorkgroupDecoration
|
||||
WorkgroupDecoration(uint32_t x, uint32_t y, uint32_t z, const Source& source);
|
||||
~WorkgroupDecoration() override;
|
||||
|
||||
/// @returns true if this is a workgroup decoration
|
||||
bool IsWorkgroup() const override;
|
||||
|
||||
/// @returns the workgroup dimensions
|
||||
std::tuple<uint32_t, uint32_t, uint32_t> values() const {
|
||||
return {x_, y_, z_};
|
||||
|
||||
@@ -60,7 +60,7 @@ TEST_F(WorkgroupDecorationTest, Creation_3param) {
|
||||
TEST_F(WorkgroupDecorationTest, Is) {
|
||||
WorkgroupDecoration wd{2, 4, 6, Source{}};
|
||||
Decoration* d = &wd;
|
||||
EXPECT_TRUE(wd.IsWorkgroup());
|
||||
EXPECT_TRUE(d->Is<WorkgroupDecoration>());
|
||||
EXPECT_FALSE(d->Is<StageDecoration>());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user