Support the group decoration.
This CL changes the set decoration to a group decoration. We still parse `set` until downstream users can be updated. Bug: tint:338 Change-Id: I610d1ed769b3a26c117ad6d875f8a99a3d5b7754 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37920 Auto-Submit: dan sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
0e17caa361
commit
c068cfc139
6
BUILD.gn
6
BUILD.gn
|
@ -282,6 +282,8 @@ source_set("libtint_core_src") {
|
|||
"src/ast/function.h",
|
||||
"src/ast/function_decoration.cc",
|
||||
"src/ast/function_decoration.h",
|
||||
"src/ast/group_decoration.cc",
|
||||
"src/ast/group_decoration.h",
|
||||
"src/ast/identifier_expression.cc",
|
||||
"src/ast/identifier_expression.h",
|
||||
"src/ast/if_statement.cc",
|
||||
|
@ -310,8 +312,6 @@ source_set("libtint_core_src") {
|
|||
"src/ast/return_statement.h",
|
||||
"src/ast/scalar_constructor_expression.cc",
|
||||
"src/ast/scalar_constructor_expression.h",
|
||||
"src/ast/set_decoration.cc",
|
||||
"src/ast/set_decoration.h",
|
||||
"src/ast/sint_literal.cc",
|
||||
"src/ast/sint_literal.h",
|
||||
"src/ast/stage_decoration.cc",
|
||||
|
@ -780,6 +780,7 @@ source_set("tint_unittests_core_src") {
|
|||
"src/ast/fallthrough_statement_test.cc",
|
||||
"src/ast/float_literal_test.cc",
|
||||
"src/ast/function_test.cc",
|
||||
"src/ast/group_decoration_test.cc",
|
||||
"src/ast/identifier_expression_test.cc",
|
||||
"src/ast/if_statement_test.cc",
|
||||
"src/ast/int_literal_test.cc",
|
||||
|
@ -793,7 +794,6 @@ source_set("tint_unittests_core_src") {
|
|||
"src/ast/null_literal_test.cc",
|
||||
"src/ast/return_statement_test.cc",
|
||||
"src/ast/scalar_constructor_expression_test.cc",
|
||||
"src/ast/set_decoration_test.cc",
|
||||
"src/ast/sint_literal_test.cc",
|
||||
"src/ast/stage_decoration_test.cc",
|
||||
"src/ast/stride_decoration_test.cc",
|
||||
|
|
|
@ -96,6 +96,8 @@ set(TINT_LIB_SRCS
|
|||
ast/function.h
|
||||
ast/function_decoration.cc
|
||||
ast/function_decoration.h
|
||||
ast/group_decoration.cc
|
||||
ast/group_decoration.h
|
||||
ast/identifier_expression.cc
|
||||
ast/identifier_expression.h
|
||||
ast/if_statement.cc
|
||||
|
@ -124,8 +126,6 @@ set(TINT_LIB_SRCS
|
|||
ast/return_statement.h
|
||||
ast/scalar_constructor_expression.cc
|
||||
ast/scalar_constructor_expression.h
|
||||
ast/set_decoration.cc
|
||||
ast/set_decoration.h
|
||||
ast/sint_literal.cc
|
||||
ast/sint_literal.h
|
||||
ast/stage_decoration.cc
|
||||
|
@ -409,6 +409,7 @@ if(${TINT_BUILD_TESTS})
|
|||
ast/fallthrough_statement_test.cc
|
||||
ast/float_literal_test.cc
|
||||
ast/function_test.cc
|
||||
ast/group_decoration_test.cc
|
||||
ast/identifier_expression_test.cc
|
||||
ast/if_statement_test.cc
|
||||
ast/intrinsic_texture_helper_test.cc
|
||||
|
@ -423,7 +424,6 @@ if(${TINT_BUILD_TESTS})
|
|||
ast/binary_expression_test.cc
|
||||
ast/return_statement_test.cc
|
||||
ast/scalar_constructor_expression_test.cc
|
||||
ast/set_decoration_test.cc
|
||||
ast/sint_literal_test.cc
|
||||
ast/stage_decoration_test.cc
|
||||
ast/stride_decoration_test.cc
|
||||
|
|
|
@ -34,7 +34,7 @@ TEST_F(BindingDecorationTest, Is) {
|
|||
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
||||
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
|
||||
EXPECT_FALSE(d->Is<LocationDecoration>());
|
||||
EXPECT_FALSE(d->Is<SetDecoration>());
|
||||
EXPECT_FALSE(d->Is<GroupDecoration>());
|
||||
}
|
||||
|
||||
TEST_F(BindingDecorationTest, ToStr) {
|
||||
|
|
|
@ -34,7 +34,7 @@ TEST_F(BuiltinDecorationTest, Is) {
|
|||
EXPECT_TRUE(d->Is<BuiltinDecoration>());
|
||||
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
|
||||
EXPECT_FALSE(d->Is<LocationDecoration>());
|
||||
EXPECT_FALSE(d->Is<SetDecoration>());
|
||||
EXPECT_FALSE(d->Is<GroupDecoration>());
|
||||
}
|
||||
|
||||
TEST_F(BuiltinDecorationTest, ToStr) {
|
||||
|
|
|
@ -33,7 +33,7 @@ TEST_F(ConstantIdDecorationTest, Is) {
|
|||
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
||||
EXPECT_TRUE(d->Is<ConstantIdDecoration>());
|
||||
EXPECT_FALSE(d->Is<LocationDecoration>());
|
||||
EXPECT_FALSE(d->Is<SetDecoration>());
|
||||
EXPECT_FALSE(d->Is<GroupDecoration>());
|
||||
}
|
||||
|
||||
TEST_F(ConstantIdDecorationTest, ToStr) {
|
||||
|
|
|
@ -108,19 +108,19 @@ Function::referenced_uniform_variables() const {
|
|||
}
|
||||
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
GroupDecoration* group = nullptr;
|
||||
for (auto* deco : var->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
} else if (auto* g = deco->As<GroupDecoration>()) {
|
||||
group = g;
|
||||
}
|
||||
}
|
||||
if (binding == nullptr || set == nullptr) {
|
||||
if (binding == nullptr || group == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.push_back({var, BindingInfo{binding, set}});
|
||||
ret.push_back({var, BindingInfo{binding, group}});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -135,19 +135,19 @@ Function::referenced_storagebuffer_variables() const {
|
|||
}
|
||||
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
GroupDecoration* group = nullptr;
|
||||
for (auto* deco : var->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
} else if (auto* s = deco->As<GroupDecoration>()) {
|
||||
group = s;
|
||||
}
|
||||
}
|
||||
if (binding == nullptr || set == nullptr) {
|
||||
if (binding == nullptr || group == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.push_back({var, BindingInfo{binding, set}});
|
||||
ret.push_back({var, BindingInfo{binding, group}});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -305,20 +305,20 @@ Function::ReferencedSamplerVariablesImpl(type::SamplerKind kind) const {
|
|||
}
|
||||
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
GroupDecoration* group = nullptr;
|
||||
for (auto* deco : var->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
}
|
||||
if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
if (auto* s = deco->As<GroupDecoration>()) {
|
||||
group = s;
|
||||
}
|
||||
}
|
||||
if (binding == nullptr || set == nullptr) {
|
||||
if (binding == nullptr || group == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.push_back({var, BindingInfo{binding, set}});
|
||||
ret.push_back({var, BindingInfo{binding, group}});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -342,19 +342,19 @@ Function::ReferencedSampledTextureVariablesImpl(bool multisampled) const {
|
|||
}
|
||||
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
GroupDecoration* group = nullptr;
|
||||
for (auto* deco : var->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
} else if (auto* s = deco->As<GroupDecoration>()) {
|
||||
group = s;
|
||||
}
|
||||
}
|
||||
if (binding == nullptr || set == nullptr) {
|
||||
if (binding == nullptr || group == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.push_back({var, BindingInfo{binding, set}});
|
||||
ret.push_back({var, BindingInfo{binding, group}});
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
#include "src/ast/builtin_decoration.h"
|
||||
#include "src/ast/expression.h"
|
||||
#include "src/ast/function_decoration.h"
|
||||
#include "src/ast/group_decoration.h"
|
||||
#include "src/ast/location_decoration.h"
|
||||
#include "src/ast/node.h"
|
||||
#include "src/ast/pipeline_stage.h"
|
||||
#include "src/ast/set_decoration.h"
|
||||
#include "src/ast/statement.h"
|
||||
#include "src/ast/type/sampler_type.h"
|
||||
#include "src/ast/type/type.h"
|
||||
|
@ -47,8 +47,8 @@ class Function : public Castable<Function, Node> {
|
|||
struct BindingInfo {
|
||||
/// The binding decoration
|
||||
BindingDecoration* binding = nullptr;
|
||||
/// The set decoration
|
||||
SetDecoration* set = nullptr;
|
||||
/// The group decoration
|
||||
GroupDecoration* group = nullptr;
|
||||
};
|
||||
|
||||
/// Create a function
|
||||
|
@ -114,32 +114,32 @@ class Function : public Castable<Function, Node> {
|
|||
const std::vector<std::pair<Variable*, BuiltinDecoration*>>
|
||||
referenced_builtin_variables() const;
|
||||
/// Retrieves any referenced uniform variables. Note, the variables must be
|
||||
/// decorated with both binding and set decorations.
|
||||
/// decorated with both binding and group decorations.
|
||||
/// @returns the referenced uniforms
|
||||
const std::vector<std::pair<Variable*, Function::BindingInfo>>
|
||||
referenced_uniform_variables() const;
|
||||
/// Retrieves any referenced storagebuffer variables. Note, the variables
|
||||
/// must be decorated with both binding and set decorations.
|
||||
/// must be decorated with both binding and group decorations.
|
||||
/// @returns the referenced storagebuffers
|
||||
const std::vector<std::pair<Variable*, Function::BindingInfo>>
|
||||
referenced_storagebuffer_variables() const;
|
||||
/// Retrieves any referenced regular Sampler variables. Note, the
|
||||
/// variables must be decorated with both binding and set decorations.
|
||||
/// variables must be decorated with both binding and group decorations.
|
||||
/// @returns the referenced storagebuffers
|
||||
const std::vector<std::pair<Variable*, Function::BindingInfo>>
|
||||
referenced_sampler_variables() const;
|
||||
/// Retrieves any referenced comparison Sampler variables. Note, the
|
||||
/// variables must be decorated with both binding and set decorations.
|
||||
/// variables must be decorated with both binding and group decorations.
|
||||
/// @returns the referenced storagebuffers
|
||||
const std::vector<std::pair<Variable*, Function::BindingInfo>>
|
||||
referenced_comparison_sampler_variables() const;
|
||||
/// Retrieves any referenced sampled textures variables. Note, the
|
||||
/// variables must be decorated with both binding and set decorations.
|
||||
/// variables must be decorated with both binding and group decorations.
|
||||
/// @returns the referenced sampled textures
|
||||
const std::vector<std::pair<Variable*, Function::BindingInfo>>
|
||||
referenced_sampled_texture_variables() const;
|
||||
/// Retrieves any referenced multisampled textures variables. Note, the
|
||||
/// variables must be decorated with both binding and set decorations.
|
||||
/// variables must be decorated with both binding and group decorations.
|
||||
/// @returns the referenced sampled textures
|
||||
const std::vector<std::pair<Variable*, Function::BindingInfo>>
|
||||
referenced_multisampled_texture_variables() const;
|
||||
|
|
|
@ -12,28 +12,28 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/ast/set_decoration.h"
|
||||
#include "src/ast/group_decoration.h"
|
||||
|
||||
#include "src/ast/clone_context.h"
|
||||
#include "src/ast/module.h"
|
||||
|
||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::SetDecoration);
|
||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::GroupDecoration);
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
SetDecoration::SetDecoration(const Source& source, uint32_t val)
|
||||
GroupDecoration::GroupDecoration(const Source& source, uint32_t val)
|
||||
: Base(source), value_(val) {}
|
||||
|
||||
SetDecoration::~SetDecoration() = default;
|
||||
GroupDecoration::~GroupDecoration() = default;
|
||||
|
||||
void SetDecoration::to_str(std::ostream& out, size_t indent) const {
|
||||
void GroupDecoration::to_str(std::ostream& out, size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "SetDecoration{" << value_ << "}" << std::endl;
|
||||
out << "GroupDecoration{" << value_ << "}" << std::endl;
|
||||
}
|
||||
|
||||
SetDecoration* SetDecoration::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<SetDecoration>(ctx->Clone(source()), value_);
|
||||
GroupDecoration* GroupDecoration::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<GroupDecoration>(ctx->Clone(source()), value_);
|
||||
}
|
||||
|
||||
} // namespace ast
|
|
@ -12,8 +12,8 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef SRC_AST_SET_DECORATION_H_
|
||||
#define SRC_AST_SET_DECORATION_H_
|
||||
#ifndef SRC_AST_GROUP_DECORATION_H_
|
||||
#define SRC_AST_GROUP_DECORATION_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
@ -22,16 +22,16 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
/// A set decoration
|
||||
class SetDecoration : public Castable<SetDecoration, VariableDecoration> {
|
||||
/// A group decoration
|
||||
class GroupDecoration : public Castable<GroupDecoration, VariableDecoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param value the set value
|
||||
/// @param value the group value
|
||||
/// @param source the source of this decoration
|
||||
SetDecoration(const Source& source, uint32_t value);
|
||||
~SetDecoration() override;
|
||||
GroupDecoration(const Source& source, uint32_t value);
|
||||
~GroupDecoration() override;
|
||||
|
||||
/// @returns the set value
|
||||
/// @returns the group value
|
||||
uint32_t value() const { return value_; }
|
||||
|
||||
/// Outputs the decoration to the given stream
|
||||
|
@ -45,7 +45,7 @@ class SetDecoration : public Castable<SetDecoration, VariableDecoration> {
|
|||
/// information is not cloned.
|
||||
/// @param ctx the clone context
|
||||
/// @return the newly cloned node
|
||||
SetDecoration* Clone(CloneContext* ctx) const override;
|
||||
GroupDecoration* Clone(CloneContext* ctx) const override;
|
||||
|
||||
private:
|
||||
uint32_t const value_;
|
||||
|
@ -54,4 +54,4 @@ class SetDecoration : public Castable<SetDecoration, VariableDecoration> {
|
|||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
||||
#endif // SRC_AST_SET_DECORATION_H_
|
||||
#endif // SRC_AST_GROUP_DECORATION_H_
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/ast/set_decoration.h"
|
||||
#include "src/ast/group_decoration.h"
|
||||
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/test_helper.h"
|
||||
|
@ -21,27 +21,27 @@ namespace tint {
|
|||
namespace ast {
|
||||
namespace {
|
||||
|
||||
using SetDecorationTest = TestHelper;
|
||||
using GroupDecorationTest = TestHelper;
|
||||
|
||||
TEST_F(SetDecorationTest, Creation) {
|
||||
auto* d = create<SetDecoration>(2);
|
||||
TEST_F(GroupDecorationTest, Creation) {
|
||||
auto* d = create<GroupDecoration>(2);
|
||||
EXPECT_EQ(2u, d->value());
|
||||
}
|
||||
|
||||
TEST_F(SetDecorationTest, Is) {
|
||||
Decoration* d = create<SetDecoration>(2);
|
||||
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<LocationDecoration>());
|
||||
EXPECT_TRUE(d->Is<SetDecoration>());
|
||||
EXPECT_TRUE(d->Is<GroupDecoration>());
|
||||
}
|
||||
|
||||
TEST_F(SetDecorationTest, ToStr) {
|
||||
auto* d = create<SetDecoration>(2);
|
||||
TEST_F(GroupDecorationTest, ToStr) {
|
||||
auto* d = create<GroupDecoration>(2);
|
||||
std::ostringstream out;
|
||||
d->to_str(out, 0);
|
||||
EXPECT_EQ(out.str(), R"(SetDecoration{2}
|
||||
EXPECT_EQ(out.str(), R"(GroupDecoration{2}
|
||||
)");
|
||||
}
|
||||
|
|
@ -155,7 +155,7 @@ ast::Variable* TextureOverloadCase::buildTextureVariable(
|
|||
auto* datatype = resultVectorComponentType(b);
|
||||
|
||||
VariableDecorationList decos = {
|
||||
b->create<ast::SetDecoration>(0),
|
||||
b->create<ast::GroupDecoration>(0),
|
||||
b->create<ast::BindingDecoration>(0),
|
||||
};
|
||||
switch (texture_kind) {
|
||||
|
@ -194,7 +194,7 @@ ast::Variable* TextureOverloadCase::buildTextureVariable(
|
|||
ast::Variable* TextureOverloadCase::buildSamplerVariable(
|
||||
ast::Builder* b) const {
|
||||
VariableDecorationList decos = {
|
||||
b->create<ast::SetDecoration>(0),
|
||||
b->create<ast::GroupDecoration>(0),
|
||||
b->create<ast::BindingDecoration>(1),
|
||||
};
|
||||
return b->Var("sampler", ast::StorageClass::kUniformConstant,
|
||||
|
|
|
@ -36,7 +36,7 @@ TEST_F(LocationDecorationTest, Is) {
|
|||
EXPECT_FALSE(d->Is<BuiltinDecoration>());
|
||||
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
|
||||
EXPECT_TRUE(d->Is<LocationDecoration>());
|
||||
EXPECT_FALSE(d->Is<SetDecoration>());
|
||||
EXPECT_FALSE(d->Is<GroupDecoration>());
|
||||
}
|
||||
|
||||
TEST_F(LocationDecorationTest, ToStr) {
|
||||
|
|
|
@ -51,10 +51,10 @@ var<uniform> g5 : [[access(read)]] texture_storage_2d<r32uint>;
|
|||
var<uniform> g6 : [[access(write)]] texture_storage_2d<rg32float>;
|
||||
|
||||
[[builtin(position)]] var<uniform> g7 : vec3<f32>;
|
||||
[[set(10), binding(20)]] var<storage_buffer> g7 : S;
|
||||
[[set(10), binding(20)]] var<storage_buffer> g8 : [[access(read)]]
|
||||
[[group(10), binding(20)]] var<storage_buffer> g7 : S;
|
||||
[[group(10), binding(20)]] var<storage_buffer> g8 : [[access(read)]]
|
||||
S;
|
||||
[[set(10), binding(20)]] var<storage_buffer> g9 : [[access(read_write)]]
|
||||
[[group(10), binding(20)]] var<storage_buffer> g9 : [[access(read_write)]]
|
||||
S;
|
||||
|
||||
fn f0(p0 : bool) -> f32 {
|
||||
|
|
|
@ -138,7 +138,7 @@ TEST_F(VariableTest, Decorated_to_str) {
|
|||
auto* var = Var("my_var", StorageClass::kFunction, ty.f32, Expr("expr"),
|
||||
VariableDecorationList{
|
||||
create<BindingDecoration>(2),
|
||||
create<SetDecoration>(1),
|
||||
create<GroupDecoration>(1),
|
||||
});
|
||||
|
||||
std::ostringstream out;
|
||||
|
@ -146,7 +146,7 @@ TEST_F(VariableTest, Decorated_to_str) {
|
|||
EXPECT_EQ(demangle(out.str()), R"( Variable{
|
||||
Decorations{
|
||||
BindingDecoration{2}
|
||||
SetDecoration{1}
|
||||
GroupDecoration{1}
|
||||
}
|
||||
my_var
|
||||
function
|
||||
|
|
|
@ -187,7 +187,7 @@ std::vector<ResourceBinding> Inspector::GetUniformBufferResourceBindings(
|
|||
continue;
|
||||
}
|
||||
|
||||
entry.bind_group = binding_info.set->value();
|
||||
entry.bind_group = binding_info.group->value();
|
||||
entry.binding = binding_info.binding->value();
|
||||
entry.min_buffer_binding_size = var->type()->MinBufferBindingSize(
|
||||
ast::type::MemoryLayout::kUniformBuffer);
|
||||
|
@ -224,7 +224,7 @@ std::vector<ResourceBinding> Inspector::GetSamplerResourceBindings(
|
|||
ast::Function::BindingInfo binding_info;
|
||||
std::tie(var, binding_info) = rs;
|
||||
|
||||
entry.bind_group = binding_info.set->value();
|
||||
entry.bind_group = binding_info.group->value();
|
||||
entry.binding = binding_info.binding->value();
|
||||
|
||||
result.push_back(entry);
|
||||
|
@ -248,7 +248,7 @@ std::vector<ResourceBinding> Inspector::GetComparisonSamplerResourceBindings(
|
|||
ast::Function::BindingInfo binding_info;
|
||||
std::tie(var, binding_info) = rcs;
|
||||
|
||||
entry.bind_group = binding_info.set->value();
|
||||
entry.bind_group = binding_info.group->value();
|
||||
entry.binding = binding_info.binding->value();
|
||||
|
||||
result.push_back(entry);
|
||||
|
@ -310,7 +310,7 @@ std::vector<ResourceBinding> Inspector::GetStorageBufferResourceBindingsImpl(
|
|||
continue;
|
||||
}
|
||||
|
||||
entry.bind_group = binding_info.set->value();
|
||||
entry.bind_group = binding_info.group->value();
|
||||
entry.binding = binding_info.binding->value();
|
||||
entry.min_buffer_binding_size = var->type()->MinBufferBindingSize(
|
||||
ast::type::MemoryLayout::kStorageBuffer);
|
||||
|
@ -339,7 +339,7 @@ std::vector<ResourceBinding> Inspector::GetSampledTextureResourceBindingsImpl(
|
|||
ast::Function::BindingInfo binding_info;
|
||||
std::tie(var, binding_info) = ref;
|
||||
|
||||
entry.bind_group = binding_info.set->value();
|
||||
entry.bind_group = binding_info.group->value();
|
||||
entry.binding = binding_info.binding->value();
|
||||
|
||||
auto* texture_type =
|
||||
|
|
|
@ -319,17 +319,17 @@ class InspectorHelper : public ast::BuilderWithModule {
|
|||
/// @param name the name of the variable
|
||||
/// @param type the type to use
|
||||
/// @param storage_class the storage class to use
|
||||
/// @param set the binding group/set to use for the uniform buffer
|
||||
/// @param group the binding and group to use for the uniform buffer
|
||||
/// @param binding the binding number to use for the uniform buffer
|
||||
void AddBinding(const std::string& name,
|
||||
ast::type::Type* type,
|
||||
ast::StorageClass storage_class,
|
||||
uint32_t set,
|
||||
uint32_t group,
|
||||
uint32_t binding) {
|
||||
auto* var = Var(name, storage_class, type, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(binding),
|
||||
create<ast::SetDecoration>(set),
|
||||
create<ast::GroupDecoration>(group),
|
||||
});
|
||||
|
||||
mod->AddGlobalVariable(var);
|
||||
|
@ -338,25 +338,25 @@ class InspectorHelper : public ast::BuilderWithModule {
|
|||
/// Adds an uniform buffer variable to the module
|
||||
/// @param name the name of the variable
|
||||
/// @param type the type to use
|
||||
/// @param set the binding group/set to use for the uniform buffer
|
||||
/// @param group the binding/group/ to use for the uniform buffer
|
||||
/// @param binding the binding number to use for the uniform buffer
|
||||
void AddUniformBuffer(const std::string& name,
|
||||
ast::type::Type* type,
|
||||
uint32_t set,
|
||||
uint32_t group,
|
||||
uint32_t binding) {
|
||||
AddBinding(name, type, ast::StorageClass::kUniform, set, binding);
|
||||
AddBinding(name, type, ast::StorageClass::kUniform, group, binding);
|
||||
}
|
||||
|
||||
/// Adds a storage buffer variable to the module
|
||||
/// @param name the name of the variable
|
||||
/// @param type the type to use
|
||||
/// @param set the binding group/set to use for the storage buffer
|
||||
/// @param group the binding/group to use for the storage buffer
|
||||
/// @param binding the binding number to use for the storage buffer
|
||||
void AddStorageBuffer(const std::string& name,
|
||||
ast::type::Type* type,
|
||||
uint32_t set,
|
||||
uint32_t group,
|
||||
uint32_t binding) {
|
||||
AddBinding(name, type, ast::StorageClass::kStorageBuffer, set, binding);
|
||||
AddBinding(name, type, ast::StorageClass::kStorageBuffer, group, binding);
|
||||
}
|
||||
|
||||
/// Generates a function that references a specific struct variable
|
||||
|
@ -398,22 +398,22 @@ class InspectorHelper : public ast::BuilderWithModule {
|
|||
|
||||
/// Adds a regular sampler variable to the module
|
||||
/// @param name the name of the variable
|
||||
/// @param set the binding group/set to use for the storage buffer
|
||||
/// @param group the binding/group to use for the storage buffer
|
||||
/// @param binding the binding number to use for the storage buffer
|
||||
void AddSampler(const std::string& name, uint32_t set, uint32_t binding) {
|
||||
AddBinding(name, sampler_type(), ast::StorageClass::kUniformConstant, set,
|
||||
void AddSampler(const std::string& name, uint32_t group, uint32_t binding) {
|
||||
AddBinding(name, sampler_type(), ast::StorageClass::kUniformConstant, group,
|
||||
binding);
|
||||
}
|
||||
|
||||
/// Adds a comparison sampler variable to the module
|
||||
/// @param name the name of the variable
|
||||
/// @param set the binding group/set to use for the storage buffer
|
||||
/// @param group the binding/group to use for the storage buffer
|
||||
/// @param binding the binding number to use for the storage buffer
|
||||
void AddComparisonSampler(const std::string& name,
|
||||
uint32_t set,
|
||||
uint32_t group,
|
||||
uint32_t binding) {
|
||||
AddBinding(name, comparison_sampler_type(),
|
||||
ast::StorageClass::kUniformConstant, set, binding);
|
||||
ast::StorageClass::kUniformConstant, group, binding);
|
||||
}
|
||||
|
||||
/// Generates a SampledTexture appropriate for the params
|
||||
|
@ -447,25 +447,25 @@ class InspectorHelper : public ast::BuilderWithModule {
|
|||
/// Adds a sampled texture variable to the module
|
||||
/// @param name the name of the variable
|
||||
/// @param type the type to use
|
||||
/// @param set the binding group/set to use for the sampled texture
|
||||
/// @param group the binding/group to use for the sampled texture
|
||||
/// @param binding the binding number to use for the sampled texture
|
||||
void AddSampledTexture(const std::string& name,
|
||||
ast::type::Type* type,
|
||||
uint32_t set,
|
||||
uint32_t group,
|
||||
uint32_t binding) {
|
||||
AddBinding(name, type, ast::StorageClass::kUniformConstant, set, binding);
|
||||
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
|
||||
}
|
||||
|
||||
/// Adds a multi-sampled texture variable to the module
|
||||
/// @param name the name of the variable
|
||||
/// @param type the type to use
|
||||
/// @param set the binding group/set to use for the multi-sampled texture
|
||||
/// @param group the binding/group to use for the multi-sampled texture
|
||||
/// @param binding the binding number to use for the multi-sampled texture
|
||||
void AddMultisampledTexture(const std::string& name,
|
||||
ast::type::Type* type,
|
||||
uint32_t set,
|
||||
uint32_t group,
|
||||
uint32_t binding) {
|
||||
AddBinding(name, type, ast::StorageClass::kUniformConstant, set, binding);
|
||||
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
|
||||
}
|
||||
|
||||
void AddGlobalVariable(const std::string& name, ast::type::Type* type) {
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
#include "src/ast/builtin_decoration.h"
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/float_literal.h"
|
||||
#include "src/ast/group_decoration.h"
|
||||
#include "src/ast/scalar_constructor_expression.h"
|
||||
#include "src/ast/set_decoration.h"
|
||||
#include "src/ast/sint_literal.h"
|
||||
#include "src/ast/stride_decoration.h"
|
||||
#include "src/ast/struct.h"
|
||||
|
@ -1295,7 +1295,7 @@ ast::Variable* ParserImpl::MakeVariable(
|
|||
<< ": has no operand";
|
||||
return nullptr;
|
||||
}
|
||||
decorations.emplace_back(create<ast::SetDecoration>(Source{}, deco[1]));
|
||||
decorations.emplace_back(create<ast::GroupDecoration>(Source{}, deco[1]));
|
||||
}
|
||||
if (deco[0] == SpvDecorationBinding) {
|
||||
if (deco.size() == 1) {
|
||||
|
|
|
@ -1145,7 +1145,7 @@ INSTANTIATE_TEST_SUITE_P(Samplers,
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1163,7 +1163,7 @@ INSTANTIATE_TEST_SUITE_P(Images,
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1179,7 +1179,7 @@ INSTANTIATE_TEST_SUITE_P(Images,
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1195,7 +1195,7 @@ INSTANTIATE_TEST_SUITE_P(Images,
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1352,7 +1352,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1361,7 +1361,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1385,7 +1385,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1394,7 +1394,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1429,7 +1429,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1438,7 +1438,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1464,7 +1464,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1473,7 +1473,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1508,7 +1508,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1517,7 +1517,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1542,7 +1542,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1551,7 +1551,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1587,7 +1587,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1596,7 +1596,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1624,7 +1624,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1633,7 +1633,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1662,7 +1662,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1671,7 +1671,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1719,7 +1719,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1728,7 +1728,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1737,7 +1737,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_30
|
||||
|
@ -1798,7 +1798,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1807,7 +1807,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1831,7 +1831,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1840,7 +1840,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1875,7 +1875,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1884,7 +1884,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1910,7 +1910,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1919,7 +1919,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1960,7 +1960,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -1969,7 +1969,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -1994,7 +1994,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -2003,7 +2003,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2039,7 +2039,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -2048,7 +2048,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2076,7 +2076,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -2085,7 +2085,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2115,7 +2115,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -2124,7 +2124,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2161,7 +2161,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -2170,7 +2170,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2197,7 +2197,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -2206,7 +2206,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2243,7 +2243,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -2252,7 +2252,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2280,7 +2280,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -2289,7 +2289,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2320,7 +2320,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -2329,7 +2329,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2368,7 +2368,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -2377,7 +2377,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2427,7 +2427,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -2436,7 +2436,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2460,7 +2460,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -2469,7 +2469,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2573,7 +2573,7 @@ INSTANTIATE_TEST_SUITE_P(ImageWrite_OptionalParams,
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2601,7 +2601,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2621,7 +2621,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2644,7 +2644,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2667,7 +2667,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2690,7 +2690,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2710,7 +2710,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2733,7 +2733,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2757,7 +2757,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2923,7 +2923,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2943,7 +2943,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2965,7 +2965,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -2987,7 +2987,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3011,7 +3011,7 @@ INSTANTIATE_TEST_SUITE_P(ImageRead_OptionalParams,
|
|||
"%99 = OpImageRead %v4float %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3043,7 +3043,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
{"%float 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3071,7 +3071,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
"%99 = OpImageFetch %v4float %im %vi12 Lod %int_3",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3108,7 +3108,7 @@ INSTANTIATE_TEST_SUITE_P(ImageFetch_Depth,
|
|||
"%99 = OpImageFetch %v4float %im %vi12 ",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3150,7 +3150,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
"%99 = OpImageFetch %v4float %im %vi12 Sample %i1",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3179,7 +3179,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
"%99 = OpImageFetch %v4float %im %vi123 Sample %i1",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3219,7 +3219,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
"%99 = OpImageFetch %v4float %im %vi12 Sample %u1",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3269,7 +3269,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
{"%float 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3296,7 +3296,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
{"%uint 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4uint %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3323,7 +3323,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
{"%uint 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4int %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3352,7 +3352,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
{"%int 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4int %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3379,7 +3379,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
{"%int 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4uint %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3413,7 +3413,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
{"%float 2D 0 0 0 1 Rgba32f", "%99 = OpImageRead %v4float %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3440,7 +3440,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
{"%uint 2D 0 0 0 1 Rgba32ui", "%99 = OpImageRead %v4uint %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3467,7 +3467,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
{"%uint 2D 0 0 0 1 Rgba32ui", "%99 = OpImageRead %v4int %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3496,7 +3496,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
{"%int 2D 0 0 0 1 Rgba32i", "%99 = OpImageRead %v4int %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3523,7 +3523,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
{"%int 2D 0 0 0 1 Rgba32i", "%99 = OpImageRead %v4uint %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
@ -3561,7 +3561,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{0}
|
||||
GroupDecoration{0}
|
||||
BindingDecoration{0}
|
||||
}
|
||||
x_10
|
||||
|
@ -3570,7 +3570,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
|
|
|
@ -1571,7 +1571,7 @@ TEST_F(SpvModuleScopeVarParserTest,
|
|||
"instruction, found '4'."));
|
||||
}
|
||||
|
||||
TEST_F(SpvModuleScopeVarParserTest, DescriptorSetDecoration_Valid) {
|
||||
TEST_F(SpvModuleScopeVarParserTest, DescriptorGroupDecoration_Valid) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %myvar DescriptorSet 3
|
||||
|
@ -1587,7 +1587,7 @@ TEST_F(SpvModuleScopeVarParserTest, DescriptorSetDecoration_Valid) {
|
|||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
SetDecoration{3}
|
||||
GroupDecoration{3}
|
||||
}
|
||||
myvar
|
||||
storage_buffer
|
||||
|
@ -1597,7 +1597,7 @@ TEST_F(SpvModuleScopeVarParserTest, DescriptorSetDecoration_Valid) {
|
|||
}
|
||||
|
||||
TEST_F(SpvModuleScopeVarParserTest,
|
||||
DescriptorSetDecoration_MissingOperandWontAssemble) {
|
||||
DescriptorGroupDecoration_MissingOperandWontAssemble) {
|
||||
const auto assembly = R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %myvar DescriptorSet
|
||||
|
@ -1611,7 +1611,7 @@ TEST_F(SpvModuleScopeVarParserTest,
|
|||
}
|
||||
|
||||
TEST_F(SpvModuleScopeVarParserTest,
|
||||
DescriptorSetDecoration_TwoOperandsWontAssemble) {
|
||||
DescriptorGroupDecoration_TwoOperandsWontAssemble) {
|
||||
const auto assembly = R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %myvar DescriptorSet 3 4
|
||||
|
|
|
@ -32,13 +32,13 @@
|
|||
#include "src/ast/else_statement.h"
|
||||
#include "src/ast/fallthrough_statement.h"
|
||||
#include "src/ast/float_literal.h"
|
||||
#include "src/ast/group_decoration.h"
|
||||
#include "src/ast/identifier_expression.h"
|
||||
#include "src/ast/if_statement.h"
|
||||
#include "src/ast/location_decoration.h"
|
||||
#include "src/ast/member_accessor_expression.h"
|
||||
#include "src/ast/return_statement.h"
|
||||
#include "src/ast/scalar_constructor_expression.h"
|
||||
#include "src/ast/set_decoration.h"
|
||||
#include "src/ast/sint_literal.h"
|
||||
#include "src/ast/stage_decoration.h"
|
||||
#include "src/ast/stride_decoration.h"
|
||||
|
@ -134,6 +134,7 @@ const char kAccessDecoration[] = "access";
|
|||
const char kBindingDecoration[] = "binding";
|
||||
const char kBlockDecoration[] = "block";
|
||||
const char kBuiltinDecoration[] = "builtin";
|
||||
const char kGroupDecoration[] = "group";
|
||||
const char kLocationDecoration[] = "location";
|
||||
const char kOffsetDecoration[] = "offset";
|
||||
const char kSetDecoration[] = "set";
|
||||
|
@ -149,8 +150,9 @@ bool is_decoration(Token t) {
|
|||
return s == kAccessDecoration || s == kBindingDecoration ||
|
||||
s == kBlockDecoration || s == kBuiltinDecoration ||
|
||||
s == kLocationDecoration || s == kOffsetDecoration ||
|
||||
s == kSetDecoration || s == kStageDecoration ||
|
||||
s == kStrideDecoration || s == kWorkgroupSizeDecoration;
|
||||
s == kSetDecoration || s == kGroupDecoration ||
|
||||
s == kStageDecoration || s == kStrideDecoration ||
|
||||
s == kWorkgroupSizeDecoration;
|
||||
}
|
||||
|
||||
/// Enter-exit counters for block token types.
|
||||
|
@ -2863,7 +2865,7 @@ Maybe<bool> ParserImpl::decoration_bracketed_list(ast::DecorationList& decos) {
|
|||
|
||||
if (is_decoration(peek())) {
|
||||
// We have two decorations in a bracket without a separating comma.
|
||||
// e.g. [[location(1) set(2)]]
|
||||
// e.g. [[location(1) group(2)]]
|
||||
// ^^^ expected comma
|
||||
expect(use, Token::Type::kComma);
|
||||
return Failure::kErrored;
|
||||
|
@ -2934,14 +2936,14 @@ Maybe<ast::Decoration*> ParserImpl::decoration() {
|
|||
});
|
||||
}
|
||||
|
||||
if (s == kSetDecoration) {
|
||||
const char* use = "set decoration";
|
||||
if (s == kSetDecoration || s == kGroupDecoration) {
|
||||
const char* use = "group decoration";
|
||||
return expect_paren_block(use, [&]() -> Result {
|
||||
auto val = expect_positive_sint(use);
|
||||
if (val.errored)
|
||||
return Failure::kErrored;
|
||||
|
||||
return create<ast::SetDecoration>(val.source, val.value);
|
||||
return create<ast::GroupDecoration>(val.source, val.value);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -941,10 +941,10 @@ TEST_F(ParserImplErrorTest, GlobalDeclVarDecoListInvalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoListMissingComma) {
|
||||
EXPECT("[[location(1) set(2)]] var i : i32;",
|
||||
EXPECT("[[location(1) group(2)]] var i : i32;",
|
||||
"test.wgsl:1:15 error: expected ',' for decoration list\n"
|
||||
"[[location(1) set(2)]] var i : i32;\n"
|
||||
" ^^^\n");
|
||||
"[[location(1) group(2)]] var i : i32;\n"
|
||||
" ^^^^^\n");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoListMissingEnd) {
|
||||
|
@ -1026,26 +1026,26 @@ TEST_F(ParserImplErrorTest, GlobalDeclVarDecoBindingInvalidValue) {
|
|||
" ^\n");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoSetMissingLParen) {
|
||||
EXPECT("[[set 1]] var i : i32;",
|
||||
"test.wgsl:1:7 error: expected '(' for set decoration\n"
|
||||
"[[set 1]] var i : i32;\n"
|
||||
" ^\n");
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoGroupMissingLParen) {
|
||||
EXPECT("[[group 1]] var i : i32;",
|
||||
"test.wgsl:1:9 error: expected '(' for group decoration\n"
|
||||
"[[group 1]] var i : i32;\n"
|
||||
" ^\n");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoSetMissingRParen) {
|
||||
EXPECT("[[set(1]] var i : i32;",
|
||||
"test.wgsl:1:8 error: expected ')' for set decoration\n"
|
||||
"[[set(1]] var i : i32;\n"
|
||||
" ^^\n");
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoGroupMissingRParen) {
|
||||
EXPECT("[[group(1]] var i : i32;",
|
||||
"test.wgsl:1:10 error: expected ')' for group decoration\n"
|
||||
"[[group(1]] var i : i32;\n"
|
||||
" ^^\n");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoBindingSetValue) {
|
||||
EXPECT("[[set(x)]] var i : i32;",
|
||||
"test.wgsl:1:7 error: expected signed integer literal for set "
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoBindingGroupValue) {
|
||||
EXPECT("[[group(x)]] var i : i32;",
|
||||
"test.wgsl:1:9 error: expected signed integer literal for group "
|
||||
"decoration\n"
|
||||
"[[set(x)]] var i : i32;\n"
|
||||
" ^\n");
|
||||
"[[group(x)]] var i : i32;\n"
|
||||
" ^\n");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclVarInvalidIdentifier) {
|
||||
|
|
|
@ -74,7 +74,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithConstructor) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) {
|
||||
auto p = parser("[[binding(2), set(1)]] var<out> a : f32");
|
||||
auto p = parser("[[binding(2), group(1)]] var<out> a : f32");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_TRUE(decos.matched);
|
||||
|
@ -90,20 +90,20 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) {
|
|||
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
|
||||
|
||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||
EXPECT_EQ(e->source().range.begin.column, 33u);
|
||||
EXPECT_EQ(e->source().range.begin.column, 35u);
|
||||
EXPECT_EQ(e->source().range.end.line, 1u);
|
||||
EXPECT_EQ(e->source().range.end.column, 34u);
|
||||
EXPECT_EQ(e->source().range.end.column, 36u);
|
||||
|
||||
ASSERT_EQ(e->constructor(), nullptr);
|
||||
|
||||
auto& decorations = e->decorations();
|
||||
ASSERT_EQ(decorations.size(), 2u);
|
||||
ASSERT_TRUE(decorations[0]->Is<ast::BindingDecoration>());
|
||||
ASSERT_TRUE(decorations[1]->Is<ast::SetDecoration>());
|
||||
ASSERT_TRUE(decorations[1]->Is<ast::GroupDecoration>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) {
|
||||
auto p = parser("[[binding(2)]] [[set(1)]] var<out> a : f32");
|
||||
auto p = parser("[[binding(2)]] [[group(1)]] var<out> a : f32");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_TRUE(decos.matched);
|
||||
|
@ -120,16 +120,16 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) {
|
|||
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
|
||||
|
||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||
EXPECT_EQ(e->source().range.begin.column, 36u);
|
||||
EXPECT_EQ(e->source().range.begin.column, 38u);
|
||||
EXPECT_EQ(e->source().range.end.line, 1u);
|
||||
EXPECT_EQ(e->source().range.end.column, 37u);
|
||||
EXPECT_EQ(e->source().range.end.column, 39u);
|
||||
|
||||
ASSERT_EQ(e->constructor(), nullptr);
|
||||
|
||||
auto& decorations = e->decorations();
|
||||
ASSERT_EQ(decorations.size(), 2u);
|
||||
ASSERT_TRUE(decorations[0]->Is<ast::BindingDecoration>());
|
||||
ASSERT_TRUE(decorations[1]->Is<ast::SetDecoration>());
|
||||
ASSERT_TRUE(decorations[1]->Is<ast::GroupDecoration>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_InvalidDecoration) {
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#include "gtest/gtest.h"
|
||||
#include "src/ast/binding_decoration.h"
|
||||
#include "src/ast/builtin_decoration.h"
|
||||
#include "src/ast/group_decoration.h"
|
||||
#include "src/ast/location_decoration.h"
|
||||
#include "src/ast/set_decoration.h"
|
||||
#include "src/reader/wgsl/parser_impl.h"
|
||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||
|
||||
|
@ -231,6 +231,7 @@ TEST_F(ParserImplTest, VariableDecoration_Binding_MissingInvalid) {
|
|||
"1:9: expected signed integer literal for binding decoration");
|
||||
}
|
||||
|
||||
// DEPRECATED
|
||||
TEST_F(ParserImplTest, VariableDecoration_set) {
|
||||
auto p = parser("set(4)");
|
||||
auto deco = p->decoration();
|
||||
|
@ -240,52 +241,67 @@ TEST_F(ParserImplTest, VariableDecoration_set) {
|
|||
auto* var_deco = deco.value->As<ast::VariableDecoration>();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_NE(var_deco, nullptr);
|
||||
ASSERT_TRUE(var_deco->Is<ast::SetDecoration>());
|
||||
ASSERT_TRUE(var_deco->Is<ast::GroupDecoration>());
|
||||
|
||||
auto* set = var_deco->As<ast::SetDecoration>();
|
||||
EXPECT_EQ(set->value(), 4u);
|
||||
auto* group = var_deco->As<ast::GroupDecoration>();
|
||||
EXPECT_EQ(group->value(), 4u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Set_MissingLeftParen) {
|
||||
auto p = parser("set 2)");
|
||||
TEST_F(ParserImplTest, VariableDecoration_group) {
|
||||
auto p = parser("group(4)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_TRUE(deco.matched);
|
||||
EXPECT_FALSE(deco.errored);
|
||||
ASSERT_NE(deco.value, nullptr);
|
||||
auto* var_deco = deco.value->As<ast::VariableDecoration>();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_NE(var_deco, nullptr);
|
||||
ASSERT_TRUE(var_deco->Is<ast::GroupDecoration>());
|
||||
|
||||
auto* group = var_deco->As<ast::GroupDecoration>();
|
||||
EXPECT_EQ(group->value(), 4u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Group_MissingLeftParen) {
|
||||
auto p = parser("group 2)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
EXPECT_EQ(deco.value, nullptr);
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:5: expected '(' for set decoration");
|
||||
EXPECT_EQ(p->error(), "1:7: expected '(' for group decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Set_MissingRightParen) {
|
||||
auto p = parser("set(2");
|
||||
TEST_F(ParserImplTest, VariableDecoration_Group_MissingRightParen) {
|
||||
auto p = parser("group(2");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
EXPECT_EQ(deco.value, nullptr);
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:6: expected ')' for set decoration");
|
||||
EXPECT_EQ(p->error(), "1:8: expected ')' for group decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Set_MissingValue) {
|
||||
auto p = parser("set()");
|
||||
TEST_F(ParserImplTest, VariableDecoration_Group_MissingValue) {
|
||||
auto p = parser("group()");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
EXPECT_EQ(deco.value, nullptr);
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:5: expected signed integer literal for set decoration");
|
||||
"1:7: expected signed integer literal for group decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Set_MissingInvalid) {
|
||||
auto p = parser("set(nan)");
|
||||
TEST_F(ParserImplTest, VariableDecoration_Group_MissingInvalid) {
|
||||
auto p = parser("group(nan)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
EXPECT_EQ(deco.value, nullptr);
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:5: expected signed integer literal for set decoration");
|
||||
"1:7: expected signed integer literal for group decoration");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -76,8 +76,8 @@ ast::Variable* clone_variable_with_new_name(ast::CloneContext* ctx,
|
|||
|
||||
} // namespace
|
||||
|
||||
FirstIndexOffset::FirstIndexOffset(uint32_t binding, uint32_t set)
|
||||
: binding_(binding), set_(set) {}
|
||||
FirstIndexOffset::FirstIndexOffset(uint32_t binding, uint32_t group)
|
||||
: binding_(binding), group_(group) {}
|
||||
|
||||
FirstIndexOffset::~FirstIndexOffset() = default;
|
||||
|
||||
|
@ -237,7 +237,7 @@ ast::Variable* FirstIndexOffset::AddUniformBuffer(ast::Module* mod) {
|
|||
nullptr, // constructor
|
||||
ast::VariableDecorationList{
|
||||
mod->create<ast::BindingDecoration>(Source{}, binding_),
|
||||
mod->create<ast::SetDecoration>(Source{}, set_),
|
||||
mod->create<ast::GroupDecoration>(Source{}, group_),
|
||||
}); // decorations
|
||||
|
||||
mod->AddGlobalVariable(idx_var);
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace transform {
|
|||
/// [[offset(4)]] tint_first_instance_index : u32;
|
||||
/// };
|
||||
/// [[builtin(vertex_index)]] var<in> tint_first_index_offset_vert_idx : u32;
|
||||
/// [[binding(N), set(M)]] var<uniform> tint_first_index_data :
|
||||
/// [[binding(N), group(M)]] var<uniform> tint_first_index_data :
|
||||
/// TintFirstIndexOffsetData;
|
||||
/// fn func() -> u32 {
|
||||
/// const vert_idx = (tint_first_index_offset_vert_idx +
|
||||
|
@ -64,8 +64,8 @@ class FirstIndexOffset : public Transform {
|
|||
public:
|
||||
/// Constructor
|
||||
/// @param binding the binding() for firstVertex/Instance uniform
|
||||
/// @param set the set() for firstVertex/Instance uniform
|
||||
FirstIndexOffset(uint32_t binding, uint32_t set);
|
||||
/// @param group the group() for firstVertex/Instance uniform
|
||||
FirstIndexOffset(uint32_t binding, uint32_t group);
|
||||
~FirstIndexOffset() override;
|
||||
|
||||
/// Runs the transform on `module`, returning the transformation result.
|
||||
|
@ -104,7 +104,7 @@ class FirstIndexOffset : public Transform {
|
|||
ast::Module* module);
|
||||
|
||||
uint32_t binding_;
|
||||
uint32_t set_;
|
||||
uint32_t group_;
|
||||
|
||||
bool has_vertex_index_ = false;
|
||||
bool has_instance_index_ = false;
|
||||
|
|
|
@ -83,7 +83,7 @@ struct TintFirstIndexOffsetData {
|
|||
};
|
||||
|
||||
[[builtin(vertex_idx)]] var<in> tint_first_index_offset_vert_idx : u32;
|
||||
[[binding(1), set(2)]] var<uniform> tint_first_index_data : TintFirstIndexOffsetData;
|
||||
[[binding(1), group(2)]] var<uniform> tint_first_index_data : TintFirstIndexOffsetData;
|
||||
|
||||
fn test() -> u32 {
|
||||
const vert_idx : u32 = (tint_first_index_offset_vert_idx + tint_first_index_data.tint_first_vertex_index);
|
||||
|
@ -123,7 +123,7 @@ struct TintFirstIndexOffsetData {
|
|||
};
|
||||
|
||||
[[builtin(instance_idx)]] var<in> tint_first_index_offset_inst_idx : u32;
|
||||
[[binding(1), set(7)]] var<uniform> tint_first_index_data : TintFirstIndexOffsetData;
|
||||
[[binding(1), group(7)]] var<uniform> tint_first_index_data : TintFirstIndexOffsetData;
|
||||
|
||||
fn test() -> u32 {
|
||||
const inst_idx : u32 = (tint_first_index_offset_inst_idx + tint_first_index_data.tint_first_instance_index);
|
||||
|
@ -167,7 +167,7 @@ struct TintFirstIndexOffsetData {
|
|||
|
||||
[[builtin(instance_idx)]] var<in> tint_first_index_offset_instance_idx : u32;
|
||||
[[builtin(vertex_idx)]] var<in> tint_first_index_offset_vert_idx : u32;
|
||||
[[binding(1), set(2)]] var<uniform> tint_first_index_data : TintFirstIndexOffsetData;
|
||||
[[binding(1), group(2)]] var<uniform> tint_first_index_data : TintFirstIndexOffsetData;
|
||||
|
||||
fn test() -> u32 {
|
||||
const instance_idx : u32 = (tint_first_index_offset_instance_idx + tint_first_index_data.tint_first_instance_index);
|
||||
|
@ -212,7 +212,7 @@ struct TintFirstIndexOffsetData {
|
|||
};
|
||||
|
||||
[[builtin(vertex_idx)]] var<in> tint_first_index_offset_vert_idx : u32;
|
||||
[[binding(1), set(2)]] var<uniform> tint_first_index_data : TintFirstIndexOffsetData;
|
||||
[[binding(1), group(2)]] var<uniform> tint_first_index_data : TintFirstIndexOffsetData;
|
||||
|
||||
fn func1() -> u32 {
|
||||
const vert_idx : u32 = (tint_first_index_offset_vert_idx + tint_first_index_data.tint_first_vertex_index);
|
||||
|
|
|
@ -65,8 +65,12 @@ void VertexPulling::SetEntryPoint(std::string entry_point) {
|
|||
cfg.entry_point_name = std::move(entry_point);
|
||||
}
|
||||
|
||||
void VertexPulling::SetPullingBufferBindingGroup(uint32_t number) {
|
||||
cfg.pulling_group = number;
|
||||
}
|
||||
|
||||
void VertexPulling::SetPullingBufferBindingSet(uint32_t number) {
|
||||
cfg.pulling_set = number;
|
||||
cfg.pulling_group = number;
|
||||
}
|
||||
|
||||
Transform::Output VertexPulling::Run(ast::Module* in) {
|
||||
|
@ -293,7 +297,7 @@ void VertexPulling::State::AddVertexStorageBuffers() {
|
|||
ast::VariableDecorationList{
|
||||
// decorations
|
||||
out->create<ast::BindingDecoration>(Source{}, i),
|
||||
out->create<ast::SetDecoration>(Source{}, cfg.pulling_set),
|
||||
out->create<ast::GroupDecoration>(Source{}, cfg.pulling_group),
|
||||
});
|
||||
out->AddGlobalVariable(var);
|
||||
}
|
||||
|
|
|
@ -151,8 +151,13 @@ class VertexPulling : public Transform {
|
|||
|
||||
/// Sets the "set" we will put all our vertex buffers into (as storage
|
||||
/// buffers)
|
||||
/// DEPRECATED
|
||||
/// @param number the set number we will use
|
||||
void SetPullingBufferBindingSet(uint32_t number);
|
||||
/// Sets the "group" we will put all our vertex buffers into (as storage
|
||||
/// buffers)
|
||||
/// @param number the group number we will use
|
||||
void SetPullingBufferBindingGroup(uint32_t number);
|
||||
|
||||
/// Runs the transform on `module`, returning the transformation result.
|
||||
/// @note Users of Tint should register the transform with transform manager
|
||||
|
@ -171,8 +176,8 @@ class VertexPulling : public Transform {
|
|||
std::string entry_point_name;
|
||||
VertexStateDescriptor vertex_state;
|
||||
bool vertex_state_set = false;
|
||||
// Default to 4 as it is past the limits of user-accessible sets
|
||||
uint32_t pulling_set = 4u;
|
||||
// Default to 4 as it is past the limits of user-accessible groups
|
||||
uint32_t pulling_group = 4u;
|
||||
};
|
||||
|
||||
Config cfg;
|
||||
|
|
|
@ -134,7 +134,7 @@ struct TintVertexData {
|
|||
};
|
||||
|
||||
[[builtin(vertex_idx)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[binding(0), set(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
|
||||
[[stage(vertex)]]
|
||||
|
@ -173,7 +173,7 @@ struct TintVertexData {
|
|||
};
|
||||
|
||||
[[builtin(instance_idx)]] var<in> _tint_pulling_instance_index : i32;
|
||||
[[binding(0), set(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
|
||||
[[stage(vertex)]]
|
||||
|
@ -212,7 +212,7 @@ struct TintVertexData {
|
|||
};
|
||||
|
||||
[[builtin(vertex_idx)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[binding(0), set(5)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(0), group(5)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
|
||||
[[stage(vertex)]]
|
||||
|
@ -255,8 +255,8 @@ struct TintVertexData {
|
|||
_tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
};
|
||||
|
||||
[[binding(0), set(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(1), set(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(1), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
var<private> var_b : f32;
|
||||
[[builtin(vertex_idx)]] var<in> custom_vertex_index : i32;
|
||||
|
@ -302,7 +302,7 @@ struct TintVertexData {
|
|||
};
|
||||
|
||||
[[builtin(vertex_idx)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[binding(0), set(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
var<private> var_b : array<f32, 4>;
|
||||
|
||||
|
@ -348,9 +348,9 @@ struct TintVertexData {
|
|||
};
|
||||
|
||||
[[builtin(vertex_idx)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[binding(0), set(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(1), set(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
[[binding(2), set(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_2 : TintVertexData;
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(1), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
[[binding(2), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_2 : TintVertexData;
|
||||
var<private> var_a : array<f32, 2>;
|
||||
var<private> var_b : array<f32, 3>;
|
||||
var<private> var_c : array<f32, 4>;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "src/ast/call_expression.h"
|
||||
#include "src/ast/float_literal.h"
|
||||
#include "src/ast/function.h"
|
||||
#include "src/ast/group_decoration.h"
|
||||
#include "src/ast/identifier_expression.h"
|
||||
#include "src/ast/if_statement.h"
|
||||
#include "src/ast/location_decoration.h"
|
||||
|
@ -26,7 +27,6 @@
|
|||
#include "src/ast/pipeline_stage.h"
|
||||
#include "src/ast/return_statement.h"
|
||||
#include "src/ast/scalar_constructor_expression.h"
|
||||
#include "src/ast/set_decoration.h"
|
||||
#include "src/ast/sint_literal.h"
|
||||
#include "src/ast/stage_decoration.h"
|
||||
#include "src/ast/struct.h"
|
||||
|
@ -285,7 +285,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
Var("coord", ast::StorageClass::kUniform, ty.vec4<f32>(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1),
|
||||
create<ast::GroupDecoration>(1),
|
||||
});
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
|
@ -331,7 +331,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
auto* coord_var = Var("uniforms", ast::StorageClass::kUniform, s, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1),
|
||||
create<ast::GroupDecoration>(1),
|
||||
});
|
||||
|
||||
mod->AddConstructedType(s);
|
||||
|
@ -386,7 +386,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1),
|
||||
create<ast::GroupDecoration>(1),
|
||||
});
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
|
@ -434,7 +434,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
ast::VariableDecorationList{
|
||||
// decorations
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1),
|
||||
create<ast::GroupDecoration>(1),
|
||||
});
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
|
@ -481,7 +481,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1),
|
||||
create<ast::GroupDecoration>(1),
|
||||
});
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
|
@ -723,7 +723,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
Var("coord", ast::StorageClass::kUniform, ty.vec4<f32>(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1),
|
||||
create<ast::GroupDecoration>(1),
|
||||
});
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
|
@ -781,7 +781,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1),
|
||||
create<ast::GroupDecoration>(1),
|
||||
});
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
|
@ -969,7 +969,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
// [[block]] struct Data {
|
||||
// [[offset(0)]] d : f32;
|
||||
// };
|
||||
// [[binding(0), set(0)]] var<storage_buffer> data : Data;
|
||||
// [[binding(0), group(0)]] var<storage_buffer> data : Data;
|
||||
//
|
||||
// [[stage(compute)]]
|
||||
// fn a() -> void {
|
||||
|
@ -991,7 +991,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
auto* data_var = Var("data", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(0),
|
||||
create<ast::GroupDecoration>(0),
|
||||
});
|
||||
|
||||
mod->AddConstructedType(s);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "src/ast/call_expression.h"
|
||||
#include "src/ast/float_literal.h"
|
||||
#include "src/ast/function.h"
|
||||
#include "src/ast/group_decoration.h"
|
||||
#include "src/ast/identifier_expression.h"
|
||||
#include "src/ast/if_statement.h"
|
||||
#include "src/ast/location_decoration.h"
|
||||
|
@ -27,7 +28,6 @@
|
|||
#include "src/ast/pipeline_stage.h"
|
||||
#include "src/ast/return_statement.h"
|
||||
#include "src/ast/scalar_constructor_expression.h"
|
||||
#include "src/ast/set_decoration.h"
|
||||
#include "src/ast/sint_literal.h"
|
||||
#include "src/ast/stage_decoration.h"
|
||||
#include "src/ast/struct.h"
|
||||
|
@ -287,7 +287,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) {
|
|||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kUniform, ty.vec4<f32>(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1)});
|
||||
create<ast::GroupDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
|
||||
|
@ -336,7 +336,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1)});
|
||||
create<ast::GroupDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
|
||||
|
@ -388,7 +388,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1)});
|
||||
create<ast::GroupDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
mod->AddGlobalVariable(coord_var);
|
||||
|
@ -629,7 +629,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kUniform, ty.vec4<f32>(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1)});
|
||||
create<ast::GroupDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
mod->AddGlobalVariable(coord_var);
|
||||
|
@ -693,7 +693,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1)});
|
||||
create<ast::GroupDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
mod->AddGlobalVariable(coord_var);
|
||||
|
@ -760,7 +760,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1)});
|
||||
create<ast::GroupDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
mod->AddGlobalVariable(coord_var);
|
||||
|
@ -914,7 +914,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
// [[block]] struct Data {
|
||||
// [[offset(0)]] d : f32;
|
||||
// };
|
||||
// [[binding(0), set(0)]] var<storage_buffer> data : Data;
|
||||
// [[binding(0), group(0)]] var<storage_buffer> data : Data;
|
||||
//
|
||||
// [[stage(compute)]]
|
||||
// fn a() -> void {
|
||||
|
@ -938,7 +938,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
auto* data_var =
|
||||
Var("data", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(0)});
|
||||
create<ast::GroupDecoration>(0)});
|
||||
|
||||
mod->AddConstructedType(s);
|
||||
td.RegisterVariableForTesting(data_var);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "src/ast/else_statement.h"
|
||||
#include "src/ast/fallthrough_statement.h"
|
||||
#include "src/ast/float_literal.h"
|
||||
#include "src/ast/group_decoration.h"
|
||||
#include "src/ast/identifier_expression.h"
|
||||
#include "src/ast/if_statement.h"
|
||||
#include "src/ast/intrinsic.h"
|
||||
|
@ -46,7 +47,6 @@
|
|||
#include "src/ast/null_literal.h"
|
||||
#include "src/ast/return_statement.h"
|
||||
#include "src/ast/scalar_constructor_expression.h"
|
||||
#include "src/ast/set_decoration.h"
|
||||
#include "src/ast/sint_literal.h"
|
||||
#include "src/ast/struct.h"
|
||||
#include "src/ast/struct_member.h"
|
||||
|
@ -816,10 +816,10 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) {
|
|||
push_annot(spv::Op::OpDecorate,
|
||||
{Operand::Int(var_id), Operand::Int(SpvDecorationBinding),
|
||||
Operand::Int(binding->value())});
|
||||
} else if (auto* set = deco->As<ast::SetDecoration>()) {
|
||||
} else if (auto* group = deco->As<ast::GroupDecoration>()) {
|
||||
push_annot(spv::Op::OpDecorate, {Operand::Int(var_id),
|
||||
Operand::Int(SpvDecorationDescriptorSet),
|
||||
Operand::Int(set->value())});
|
||||
Operand::Int(group->value())});
|
||||
} else if (deco->Is<ast::ConstantIdDecoration>()) {
|
||||
// Spec constants are handled elsewhere
|
||||
} else {
|
||||
|
|
|
@ -198,7 +198,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
|
|||
// [[block]] struct Data {
|
||||
// [[offset(0)]] d : f32;
|
||||
// };
|
||||
// [[binding(0), set(0)]] var<storage_buffer> data : Data;
|
||||
// [[binding(0), group(0)]] var<storage_buffer> data : Data;
|
||||
//
|
||||
// [[stage(compute)]]
|
||||
// fn a() -> void {
|
||||
|
@ -222,7 +222,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
|
|||
auto* data_var = Var("data", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(0),
|
||||
create<ast::GroupDecoration>(0),
|
||||
});
|
||||
|
||||
mod->AddConstructedType(s);
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
#include "src/ast/builtin.h"
|
||||
#include "src/ast/builtin_decoration.h"
|
||||
#include "src/ast/float_literal.h"
|
||||
#include "src/ast/group_decoration.h"
|
||||
#include "src/ast/location_decoration.h"
|
||||
#include "src/ast/scalar_constructor_expression.h"
|
||||
#include "src/ast/set_decoration.h"
|
||||
#include "src/ast/storage_class.h"
|
||||
#include "src/ast/struct.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
#include "src/ast/builtin_decoration.h"
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/float_literal.h"
|
||||
#include "src/ast/group_decoration.h"
|
||||
#include "src/ast/location_decoration.h"
|
||||
#include "src/ast/module.h"
|
||||
#include "src/ast/scalar_constructor_expression.h"
|
||||
#include "src/ast/set_decoration.h"
|
||||
#include "src/ast/storage_class.h"
|
||||
#include "src/ast/struct.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
|
@ -194,11 +194,11 @@ TEST_F(BuilderTest, GlobalVar_WithLocation) {
|
|||
)");
|
||||
}
|
||||
|
||||
TEST_F(BuilderTest, GlobalVar_WithBindingAndSet) {
|
||||
TEST_F(BuilderTest, GlobalVar_WithBindingAndGroup) {
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(2),
|
||||
create<ast::SetDecoration>(3),
|
||||
create<ast::GroupDecoration>(3),
|
||||
});
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(v)) << b.error();
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "src/ast/continue_statement.h"
|
||||
#include "src/ast/else_statement.h"
|
||||
#include "src/ast/float_literal.h"
|
||||
#include "src/ast/group_decoration.h"
|
||||
#include "src/ast/identifier_expression.h"
|
||||
#include "src/ast/if_statement.h"
|
||||
#include "src/ast/location_decoration.h"
|
||||
|
@ -41,7 +42,6 @@
|
|||
#include "src/ast/member_accessor_expression.h"
|
||||
#include "src/ast/return_statement.h"
|
||||
#include "src/ast/scalar_constructor_expression.h"
|
||||
#include "src/ast/set_decoration.h"
|
||||
#include "src/ast/sint_literal.h"
|
||||
#include "src/ast/stage_decoration.h"
|
||||
#include "src/ast/statement.h"
|
||||
|
@ -620,8 +620,8 @@ bool GeneratorImpl::EmitVariableDecorations(ast::Variable* var) {
|
|||
|
||||
if (auto* binding = deco->As<ast::BindingDecoration>()) {
|
||||
out_ << "binding(" << binding->value() << ")";
|
||||
} else if (auto* set = deco->As<ast::SetDecoration>()) {
|
||||
out_ << "set(" << set->value() << ")";
|
||||
} else if (auto* group = deco->As<ast::GroupDecoration>()) {
|
||||
out_ << "group(" << group->value() << ")";
|
||||
} else if (auto* location = deco->As<ast::LocationDecoration>()) {
|
||||
out_ << "location(" << location->value() << ")";
|
||||
} else if (auto* builtin = deco->As<ast::BuiltinDecoration>()) {
|
||||
|
|
|
@ -153,7 +153,7 @@ TEST_F(WgslGeneratorImplTest,
|
|||
// [[block]] struct Data {
|
||||
// [[offset(0)]] d : f32;
|
||||
// };
|
||||
// [[binding(0), set(0)]] var<storage_buffer> data : Data;
|
||||
// [[binding(0), group(0)]] var<storage_buffer> data : Data;
|
||||
//
|
||||
// [[stage(compute)]]
|
||||
// fn a() -> void {
|
||||
|
@ -178,7 +178,7 @@ TEST_F(WgslGeneratorImplTest,
|
|||
ast::VariableDecorationList{
|
||||
// decorations
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(0),
|
||||
create<ast::GroupDecoration>(0),
|
||||
});
|
||||
|
||||
mod->AddConstructedType(s);
|
||||
|
@ -233,7 +233,7 @@ struct Data {
|
|||
d : f32;
|
||||
};
|
||||
|
||||
[[binding(0), set(0)]] var<storage_buffer> data : [[access(read_write)]]
|
||||
[[binding(0), group(0)]] var<storage_buffer> data : [[access(read_write)]]
|
||||
Data;
|
||||
|
||||
[[stage(compute)]]
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
#include "src/ast/binding_decoration.h"
|
||||
#include "src/ast/builtin_decoration.h"
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/group_decoration.h"
|
||||
#include "src/ast/location_decoration.h"
|
||||
#include "src/ast/set_decoration.h"
|
||||
#include "src/ast/type/f32_type.h"
|
||||
#include "src/ast/variable.h"
|
||||
#include "src/ast/variable_decoration.h"
|
||||
|
@ -65,7 +65,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) {
|
|||
ast::VariableDecorationList{
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kPosition),
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::SetDecoration>(1),
|
||||
create<ast::GroupDecoration>(1),
|
||||
create<ast::LocationDecoration>(2),
|
||||
create<ast::ConstantIdDecoration>(42),
|
||||
});
|
||||
|
@ -73,7 +73,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) {
|
|||
ASSERT_TRUE(gen.EmitVariable(v)) << gen.error();
|
||||
EXPECT_EQ(
|
||||
gen.result(),
|
||||
R"([[builtin(position), binding(0), set(1), location(2), constant_id(42)]] var a : f32;
|
||||
R"([[builtin(position), binding(0), group(1), location(2), constant_id(42)]] var a : f32;
|
||||
)");
|
||||
}
|
||||
|
||||
|
|
|
@ -56,9 +56,9 @@ fn frag_main() -> void {
|
|||
[[offset(0)]] particles : [[stride(16)]] array<Particle, 5>;
|
||||
};
|
||||
|
||||
[[binding(0), set(0)]] var<uniform> params : [[access(read)]] SimParams;
|
||||
[[binding(1), set(0)]] var<storage_buffer> particlesA : [[access(read_write)]] Particles;
|
||||
[[binding(2), set(0)]] var<storage_buffer> particlesB : [[access(read_write)]] Particles;
|
||||
[[binding(0), group(0)]] var<uniform> params : [[access(read)]] SimParams;
|
||||
[[binding(1), group(0)]] var<storage_buffer> particlesA : [[access(read_write)]] Particles;
|
||||
[[binding(2), group(0)]] var<storage_buffer> particlesB : [[access(read_write)]] Particles;
|
||||
|
||||
[[builtin(global_invocation_id)]] var<in> gl_GlobalInvocationID : vec3<u32>;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
[[offset(0)]] modelViewProjectionMatrix : mat4x4<f32>;
|
||||
};
|
||||
|
||||
[[binding(0), set(0)]] var<uniform> uniforms : [[access(read)]] Uniforms;
|
||||
[[binding(0), group(0)]] var<uniform> uniforms : [[access(read)]] Uniforms;
|
||||
|
||||
[[location(0)]] var<in> cur_position : vec4<f32>;
|
||||
[[location(1)]] var<in> color : vec4<f32>;
|
||||
|
|
Loading…
Reference in New Issue