Move tint::ast::type to tint::type
Despite `tint::ast::type::Type` being in the AST namespace, these classes are clearly not AST nodes: * They don't derive from ast::Node * They're deduplicated by the type manager * None of the types have an Source - they have no lexical declaration point * The fact we have `ast::Struct` and `ast::type::Struct` clearly demonstrates what is an AST node, and what is a type. * We have code scattered in the codebase (TypeDeterminer, writers, etc) that create new types after parsing - so clearly not part of the original syntax tree. Types in tint are closer to being semantic info, but due to the parse-time generation of types, and tight dependency of ast::Nodes to types, I'd be reluctant to class these as semantic info. Instead, put these into a separate root level `tint::type` namespace and `src/tint` directory. The fact that types exist in the ast::Module has already caused bugs (https://dawn-review.googlesource.com/c/tint/+/37261). This is a first step in separating out types from the ast::Module. Bug: tint:390 Change-Id: I8349bbbd1b19597b8e6d51d5cda0890de46ecaec Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38002 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
587f387fd9
commit
207b5e2de1
116
BUILD.gn
116
BUILD.gn
|
@ -337,50 +337,10 @@ source_set("libtint_core_src") {
|
||||||
"src/ast/switch_statement.cc",
|
"src/ast/switch_statement.cc",
|
||||||
"src/ast/switch_statement.h",
|
"src/ast/switch_statement.h",
|
||||||
"src/ast/traits.h",
|
"src/ast/traits.h",
|
||||||
"src/ast/type/access_control_type.cc",
|
|
||||||
"src/ast/type/access_control_type.h",
|
|
||||||
"src/ast/type/alias_type.cc",
|
|
||||||
"src/ast/type/alias_type.h",
|
|
||||||
"src/ast/type/array_type.cc",
|
|
||||||
"src/ast/type/array_type.h",
|
|
||||||
"src/ast/type/bool_type.cc",
|
|
||||||
"src/ast/type/bool_type.h",
|
|
||||||
"src/ast/type/depth_texture_type.cc",
|
|
||||||
"src/ast/type/depth_texture_type.h",
|
|
||||||
"src/ast/type/f32_type.cc",
|
|
||||||
"src/ast/type/f32_type.h",
|
|
||||||
"src/ast/type/i32_type.cc",
|
|
||||||
"src/ast/type/i32_type.h",
|
|
||||||
"src/ast/type/matrix_type.cc",
|
|
||||||
"src/ast/type/matrix_type.h",
|
|
||||||
"src/ast/type/multisampled_texture_type.cc",
|
|
||||||
"src/ast/type/multisampled_texture_type.h",
|
|
||||||
"src/ast/type/pointer_type.cc",
|
|
||||||
"src/ast/type/pointer_type.h",
|
|
||||||
"src/ast/type/sampled_texture_type.cc",
|
|
||||||
"src/ast/type/sampled_texture_type.h",
|
|
||||||
"src/ast/type/sampler_type.cc",
|
|
||||||
"src/ast/type/sampler_type.h",
|
|
||||||
"src/ast/type/storage_texture_type.cc",
|
|
||||||
"src/ast/type/storage_texture_type.h",
|
|
||||||
"src/ast/type/struct_type.cc",
|
|
||||||
"src/ast/type/struct_type.h",
|
|
||||||
"src/ast/type/texture_type.cc",
|
|
||||||
"src/ast/type/texture_type.h",
|
|
||||||
"src/ast/type/type.cc",
|
|
||||||
"src/ast/type/type.h",
|
|
||||||
"src/ast/type/u32_type.cc",
|
|
||||||
"src/ast/type/u32_type.h",
|
|
||||||
"src/ast/type/vector_type.cc",
|
|
||||||
"src/ast/type/vector_type.h",
|
|
||||||
"src/ast/type/void_type.cc",
|
|
||||||
"src/ast/type/void_type.h",
|
|
||||||
"src/ast/type_constructor_expression.cc",
|
"src/ast/type_constructor_expression.cc",
|
||||||
"src/ast/type_constructor_expression.h",
|
"src/ast/type_constructor_expression.h",
|
||||||
"src/ast/type_decoration.cc",
|
"src/ast/type_decoration.cc",
|
||||||
"src/ast/type_decoration.h",
|
"src/ast/type_decoration.h",
|
||||||
"src/ast/type_manager.cc",
|
|
||||||
"src/ast/type_manager.h",
|
|
||||||
"src/ast/uint_literal.cc",
|
"src/ast/uint_literal.cc",
|
||||||
"src/ast/uint_literal.h",
|
"src/ast/uint_literal.h",
|
||||||
"src/ast/unary_op.cc",
|
"src/ast/unary_op.cc",
|
||||||
|
@ -439,6 +399,46 @@ source_set("libtint_core_src") {
|
||||||
"src/type_determiner.h",
|
"src/type_determiner.h",
|
||||||
"src/validator/validator.cc",
|
"src/validator/validator.cc",
|
||||||
"src/validator/validator.h",
|
"src/validator/validator.h",
|
||||||
|
"src/type/access_control_type.cc",
|
||||||
|
"src/type/access_control_type.h",
|
||||||
|
"src/type/alias_type.cc",
|
||||||
|
"src/type/alias_type.h",
|
||||||
|
"src/type/array_type.cc",
|
||||||
|
"src/type/array_type.h",
|
||||||
|
"src/type/bool_type.cc",
|
||||||
|
"src/type/bool_type.h",
|
||||||
|
"src/type/depth_texture_type.cc",
|
||||||
|
"src/type/depth_texture_type.h",
|
||||||
|
"src/type/f32_type.cc",
|
||||||
|
"src/type/f32_type.h",
|
||||||
|
"src/type/i32_type.cc",
|
||||||
|
"src/type/i32_type.h",
|
||||||
|
"src/type/matrix_type.cc",
|
||||||
|
"src/type/matrix_type.h",
|
||||||
|
"src/type/multisampled_texture_type.cc",
|
||||||
|
"src/type/multisampled_texture_type.h",
|
||||||
|
"src/type/pointer_type.cc",
|
||||||
|
"src/type/pointer_type.h",
|
||||||
|
"src/type/sampled_texture_type.cc",
|
||||||
|
"src/type/sampled_texture_type.h",
|
||||||
|
"src/type/sampler_type.cc",
|
||||||
|
"src/type/sampler_type.h",
|
||||||
|
"src/type/storage_texture_type.cc",
|
||||||
|
"src/type/storage_texture_type.h",
|
||||||
|
"src/type/struct_type.cc",
|
||||||
|
"src/type/struct_type.h",
|
||||||
|
"src/type/texture_type.cc",
|
||||||
|
"src/type/texture_type.h",
|
||||||
|
"src/type/type.cc",
|
||||||
|
"src/type/type.h",
|
||||||
|
"src/type/type_manager.cc",
|
||||||
|
"src/type/type_manager.h",
|
||||||
|
"src/type/u32_type.cc",
|
||||||
|
"src/type/u32_type.h",
|
||||||
|
"src/type/vector_type.cc",
|
||||||
|
"src/type/vector_type.h",
|
||||||
|
"src/type/void_type.cc",
|
||||||
|
"src/type/void_type.h",
|
||||||
"src/validator/validator_impl.cc",
|
"src/validator/validator_impl.cc",
|
||||||
"src/validator/validator_impl.h",
|
"src/validator/validator_impl.h",
|
||||||
"src/validator/validator_test_helper.cc",
|
"src/validator/validator_test_helper.cc",
|
||||||
|
@ -804,25 +804,7 @@ source_set("tint_unittests_core_src") {
|
||||||
"src/ast/switch_statement_test.cc",
|
"src/ast/switch_statement_test.cc",
|
||||||
"src/ast/test_helper.h",
|
"src/ast/test_helper.h",
|
||||||
"src/ast/traits_test.cc",
|
"src/ast/traits_test.cc",
|
||||||
"src/ast/type/access_control_type_test.cc",
|
|
||||||
"src/ast/type/alias_type_test.cc",
|
|
||||||
"src/ast/type/array_type_test.cc",
|
|
||||||
"src/ast/type/bool_type_test.cc",
|
|
||||||
"src/ast/type/depth_texture_type_test.cc",
|
|
||||||
"src/ast/type/f32_type_test.cc",
|
|
||||||
"src/ast/type/i32_type_test.cc",
|
|
||||||
"src/ast/type/matrix_type_test.cc",
|
|
||||||
"src/ast/type/multisampled_texture_type_test.cc",
|
|
||||||
"src/ast/type/pointer_type_test.cc",
|
|
||||||
"src/ast/type/sampled_texture_type_test.cc",
|
|
||||||
"src/ast/type/sampler_type_test.cc",
|
|
||||||
"src/ast/type/storage_texture_type_test.cc",
|
|
||||||
"src/ast/type/struct_type_test.cc",
|
|
||||||
"src/ast/type/texture_type_test.cc",
|
|
||||||
"src/ast/type/u32_type_test.cc",
|
|
||||||
"src/ast/type/vector_type_test.cc",
|
|
||||||
"src/ast/type_constructor_expression_test.cc",
|
"src/ast/type_constructor_expression_test.cc",
|
||||||
"src/ast/type_manager_test.cc",
|
|
||||||
"src/ast/uint_literal_test.cc",
|
"src/ast/uint_literal_test.cc",
|
||||||
"src/ast/unary_op_expression_test.cc",
|
"src/ast/unary_op_expression_test.cc",
|
||||||
"src/ast/variable_decl_statement_test.cc",
|
"src/ast/variable_decl_statement_test.cc",
|
||||||
|
@ -844,6 +826,24 @@ source_set("tint_unittests_core_src") {
|
||||||
"src/transform/test_helper.h",
|
"src/transform/test_helper.h",
|
||||||
"src/transform/vertex_pulling_test.cc",
|
"src/transform/vertex_pulling_test.cc",
|
||||||
"src/type_determiner_test.cc",
|
"src/type_determiner_test.cc",
|
||||||
|
"src/type/access_control_type_test.cc",
|
||||||
|
"src/type/alias_type_test.cc",
|
||||||
|
"src/type/array_type_test.cc",
|
||||||
|
"src/type/bool_type_test.cc",
|
||||||
|
"src/type/depth_texture_type_test.cc",
|
||||||
|
"src/type/f32_type_test.cc",
|
||||||
|
"src/type/i32_type_test.cc",
|
||||||
|
"src/type/matrix_type_test.cc",
|
||||||
|
"src/type/multisampled_texture_type_test.cc",
|
||||||
|
"src/type/pointer_type_test.cc",
|
||||||
|
"src/type/sampled_texture_type_test.cc",
|
||||||
|
"src/type/sampler_type_test.cc",
|
||||||
|
"src/type/storage_texture_type_test.cc",
|
||||||
|
"src/type/struct_type_test.cc",
|
||||||
|
"src/type/texture_type_test.cc",
|
||||||
|
"src/type/type_manager_test.cc",
|
||||||
|
"src/type/u32_type_test.cc",
|
||||||
|
"src/type/vector_type_test.cc",
|
||||||
"src/validator/validator_control_block_test.cc",
|
"src/validator/validator_control_block_test.cc",
|
||||||
"src/validator/validator_function_test.cc",
|
"src/validator/validator_function_test.cc",
|
||||||
"src/validator/validator_test.cc",
|
"src/validator/validator_test.cc",
|
||||||
|
|
|
@ -67,7 +67,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
for (auto* src_node : src.nodes()) {
|
for (auto* src_node : src.nodes()) {
|
||||||
src_nodes.emplace(src_node);
|
src_nodes.emplace(src_node);
|
||||||
}
|
}
|
||||||
std::unordered_set<tint::ast::type::Type*> src_types;
|
std::unordered_set<tint::type::Type*> src_types;
|
||||||
for (auto& src_type : src.types()) {
|
for (auto& src_type : src.types()) {
|
||||||
src_types.emplace(src_type.second.get());
|
src_types.emplace(src_type.second.get());
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
// headers will need to be moved to include/tint/.
|
// headers will need to be moved to include/tint/.
|
||||||
|
|
||||||
#include "src/ast/pipeline_stage.h"
|
#include "src/ast/pipeline_stage.h"
|
||||||
#include "src/ast/type_manager.h"
|
|
||||||
#include "src/demangler.h"
|
#include "src/demangler.h"
|
||||||
#include "src/diagnostic/printer.h"
|
#include "src/diagnostic/printer.h"
|
||||||
#include "src/inspector/inspector.h"
|
#include "src/inspector/inspector.h"
|
||||||
|
@ -30,6 +29,7 @@
|
||||||
#include "src/transform/first_index_offset.h"
|
#include "src/transform/first_index_offset.h"
|
||||||
#include "src/transform/manager.h"
|
#include "src/transform/manager.h"
|
||||||
#include "src/transform/vertex_pulling.h"
|
#include "src/transform/vertex_pulling.h"
|
||||||
|
#include "src/type/type_manager.h"
|
||||||
#include "src/type_determiner.h"
|
#include "src/type_determiner.h"
|
||||||
#include "src/validator/validator.h"
|
#include "src/validator/validator.h"
|
||||||
#include "src/writer/writer.h"
|
#include "src/writer/writer.h"
|
||||||
|
|
|
@ -56,16 +56,16 @@ set(TINT_LIB_SRCS
|
||||||
ast/bitcast_expression.h
|
ast/bitcast_expression.h
|
||||||
ast/block_statement.cc
|
ast/block_statement.cc
|
||||||
ast/block_statement.h
|
ast/block_statement.h
|
||||||
ast/bool_literal.h
|
|
||||||
ast/bool_literal.cc
|
ast/bool_literal.cc
|
||||||
|
ast/bool_literal.h
|
||||||
ast/break_statement.cc
|
ast/break_statement.cc
|
||||||
ast/break_statement.h
|
ast/break_statement.h
|
||||||
ast/builder.cc
|
ast/builder.cc
|
||||||
ast/builder.h
|
ast/builder.h
|
||||||
ast/builtin.cc
|
|
||||||
ast/builtin.h
|
|
||||||
ast/builtin_decoration.cc
|
ast/builtin_decoration.cc
|
||||||
ast/builtin_decoration.h
|
ast/builtin_decoration.h
|
||||||
|
ast/builtin.cc
|
||||||
|
ast/builtin.h
|
||||||
ast/call_expression.cc
|
ast/call_expression.cc
|
||||||
ast/call_expression.h
|
ast/call_expression.h
|
||||||
ast/call_statement.cc
|
ast/call_statement.cc
|
||||||
|
@ -106,8 +106,8 @@ set(TINT_LIB_SRCS
|
||||||
ast/int_literal.h
|
ast/int_literal.h
|
||||||
ast/intrinsic.cc
|
ast/intrinsic.cc
|
||||||
ast/intrinsic.h
|
ast/intrinsic.h
|
||||||
ast/literal.h
|
|
||||||
ast/literal.cc
|
ast/literal.cc
|
||||||
|
ast/literal.h
|
||||||
ast/location_decoration.cc
|
ast/location_decoration.cc
|
||||||
ast/location_decoration.h
|
ast/location_decoration.h
|
||||||
ast/loop_statement.cc
|
ast/loop_statement.cc
|
||||||
|
@ -151,50 +151,10 @@ set(TINT_LIB_SRCS
|
||||||
ast/switch_statement.cc
|
ast/switch_statement.cc
|
||||||
ast/switch_statement.h
|
ast/switch_statement.h
|
||||||
ast/traits.h
|
ast/traits.h
|
||||||
ast/type_constructor_expression.h
|
|
||||||
ast/type_constructor_expression.cc
|
ast/type_constructor_expression.cc
|
||||||
|
ast/type_constructor_expression.h
|
||||||
ast/type_decoration.cc
|
ast/type_decoration.cc
|
||||||
ast/type_decoration.h
|
ast/type_decoration.h
|
||||||
ast/type/access_control_type.cc
|
|
||||||
ast/type/access_control_type.h
|
|
||||||
ast/type/alias_type.cc
|
|
||||||
ast/type/alias_type.h
|
|
||||||
ast/type/array_type.cc
|
|
||||||
ast/type/array_type.h
|
|
||||||
ast/type/bool_type.cc
|
|
||||||
ast/type/bool_type.h
|
|
||||||
ast/type/depth_texture_type.cc
|
|
||||||
ast/type/depth_texture_type.h
|
|
||||||
ast/type/f32_type.cc
|
|
||||||
ast/type/f32_type.h
|
|
||||||
ast/type/i32_type.cc
|
|
||||||
ast/type/i32_type.h
|
|
||||||
ast/type/matrix_type.cc
|
|
||||||
ast/type/matrix_type.h
|
|
||||||
ast/type/multisampled_texture_type.cc
|
|
||||||
ast/type/multisampled_texture_type.h
|
|
||||||
ast/type/pointer_type.cc
|
|
||||||
ast/type/pointer_type.h
|
|
||||||
ast/type/sampled_texture_type.cc
|
|
||||||
ast/type/sampled_texture_type.h
|
|
||||||
ast/type/sampler_type.cc
|
|
||||||
ast/type/sampler_type.h
|
|
||||||
ast/type/storage_texture_type.cc
|
|
||||||
ast/type/storage_texture_type.h
|
|
||||||
ast/type/struct_type.cc
|
|
||||||
ast/type/struct_type.h
|
|
||||||
ast/type/texture_type.cc
|
|
||||||
ast/type/texture_type.h
|
|
||||||
ast/type/type.cc
|
|
||||||
ast/type/type.h
|
|
||||||
ast/type/u32_type.cc
|
|
||||||
ast/type/u32_type.h
|
|
||||||
ast/type/vector_type.cc
|
|
||||||
ast/type/vector_type.h
|
|
||||||
ast/type/void_type.cc
|
|
||||||
ast/type/void_type.h
|
|
||||||
ast/type_manager.cc
|
|
||||||
ast/type_manager.h
|
|
||||||
ast/uint_literal.cc
|
ast/uint_literal.cc
|
||||||
ast/uint_literal.h
|
ast/uint_literal.h
|
||||||
ast/unary_op.cc
|
ast/unary_op.cc
|
||||||
|
@ -251,6 +211,46 @@ set(TINT_LIB_SRCS
|
||||||
transform/vertex_pulling.h
|
transform/vertex_pulling.h
|
||||||
type_determiner.cc
|
type_determiner.cc
|
||||||
type_determiner.h
|
type_determiner.h
|
||||||
|
type/access_control_type.cc
|
||||||
|
type/access_control_type.h
|
||||||
|
type/alias_type.cc
|
||||||
|
type/alias_type.h
|
||||||
|
type/array_type.cc
|
||||||
|
type/array_type.h
|
||||||
|
type/bool_type.cc
|
||||||
|
type/bool_type.h
|
||||||
|
type/depth_texture_type.cc
|
||||||
|
type/depth_texture_type.h
|
||||||
|
type/f32_type.cc
|
||||||
|
type/f32_type.h
|
||||||
|
type/i32_type.cc
|
||||||
|
type/i32_type.h
|
||||||
|
type/matrix_type.cc
|
||||||
|
type/matrix_type.h
|
||||||
|
type/multisampled_texture_type.cc
|
||||||
|
type/multisampled_texture_type.h
|
||||||
|
type/pointer_type.cc
|
||||||
|
type/pointer_type.h
|
||||||
|
type/sampled_texture_type.cc
|
||||||
|
type/sampled_texture_type.h
|
||||||
|
type/sampler_type.cc
|
||||||
|
type/sampler_type.h
|
||||||
|
type/storage_texture_type.cc
|
||||||
|
type/storage_texture_type.h
|
||||||
|
type/struct_type.cc
|
||||||
|
type/struct_type.h
|
||||||
|
type/texture_type.cc
|
||||||
|
type/texture_type.h
|
||||||
|
type/type.cc
|
||||||
|
type/type.h
|
||||||
|
type/type_manager.cc
|
||||||
|
type/type_manager.h
|
||||||
|
type/u32_type.cc
|
||||||
|
type/u32_type.h
|
||||||
|
type/vector_type.cc
|
||||||
|
type/vector_type.h
|
||||||
|
type/void_type.cc
|
||||||
|
type/void_type.h
|
||||||
validator/validator.cc
|
validator/validator.cc
|
||||||
validator/validator.h
|
validator/validator.h
|
||||||
validator/validator_impl.cc
|
validator/validator_impl.cc
|
||||||
|
@ -391,6 +391,7 @@ if(${TINT_BUILD_TESTS})
|
||||||
ast/access_decoration_test.cc
|
ast/access_decoration_test.cc
|
||||||
ast/array_accessor_expression_test.cc
|
ast/array_accessor_expression_test.cc
|
||||||
ast/assignment_statement_test.cc
|
ast/assignment_statement_test.cc
|
||||||
|
ast/binary_expression_test.cc
|
||||||
ast/binding_decoration_test.cc
|
ast/binding_decoration_test.cc
|
||||||
ast/bitcast_expression_test.cc
|
ast/bitcast_expression_test.cc
|
||||||
ast/block_statement_test.cc
|
ast/block_statement_test.cc
|
||||||
|
@ -403,8 +404,8 @@ if(${TINT_BUILD_TESTS})
|
||||||
ast/clone_context_test.cc
|
ast/clone_context_test.cc
|
||||||
ast/constant_id_decoration_test.cc
|
ast/constant_id_decoration_test.cc
|
||||||
ast/continue_statement_test.cc
|
ast/continue_statement_test.cc
|
||||||
ast/discard_statement_test.cc
|
|
||||||
ast/decoration_test.cc
|
ast/decoration_test.cc
|
||||||
|
ast/discard_statement_test.cc
|
||||||
ast/else_statement_test.cc
|
ast/else_statement_test.cc
|
||||||
ast/expression_test.cc
|
ast/expression_test.cc
|
||||||
ast/fallthrough_statement_test.cc
|
ast/fallthrough_statement_test.cc
|
||||||
|
@ -413,53 +414,34 @@ if(${TINT_BUILD_TESTS})
|
||||||
ast/group_decoration_test.cc
|
ast/group_decoration_test.cc
|
||||||
ast/identifier_expression_test.cc
|
ast/identifier_expression_test.cc
|
||||||
ast/if_statement_test.cc
|
ast/if_statement_test.cc
|
||||||
|
ast/int_literal_test.cc
|
||||||
ast/intrinsic_texture_helper_test.cc
|
ast/intrinsic_texture_helper_test.cc
|
||||||
ast/intrinsic_texture_helper_test.h
|
ast/intrinsic_texture_helper_test.h
|
||||||
ast/int_literal_test.cc
|
|
||||||
ast/location_decoration_test.cc
|
ast/location_decoration_test.cc
|
||||||
ast/loop_statement_test.cc
|
ast/loop_statement_test.cc
|
||||||
ast/member_accessor_expression_test.cc
|
ast/member_accessor_expression_test.cc
|
||||||
ast/module_test.cc
|
|
||||||
ast/module_clone_test.cc
|
ast/module_clone_test.cc
|
||||||
|
ast/module_test.cc
|
||||||
ast/null_literal_test.cc
|
ast/null_literal_test.cc
|
||||||
ast/binary_expression_test.cc
|
|
||||||
ast/return_statement_test.cc
|
ast/return_statement_test.cc
|
||||||
ast/scalar_constructor_expression_test.cc
|
ast/scalar_constructor_expression_test.cc
|
||||||
ast/sint_literal_test.cc
|
ast/sint_literal_test.cc
|
||||||
ast/stage_decoration_test.cc
|
ast/stage_decoration_test.cc
|
||||||
ast/stride_decoration_test.cc
|
ast/stride_decoration_test.cc
|
||||||
ast/struct_member_test.cc
|
|
||||||
ast/struct_member_offset_decoration_test.cc
|
ast/struct_member_offset_decoration_test.cc
|
||||||
|
ast/struct_member_test.cc
|
||||||
ast/struct_test.cc
|
ast/struct_test.cc
|
||||||
ast/switch_statement_test.cc
|
ast/switch_statement_test.cc
|
||||||
ast/test_helper.h
|
ast/test_helper.h
|
||||||
ast/type/access_control_type_test.cc
|
|
||||||
ast/type/alias_type_test.cc
|
|
||||||
ast/type/array_type_test.cc
|
|
||||||
ast/type/bool_type_test.cc
|
|
||||||
ast/type/depth_texture_type_test.cc
|
|
||||||
ast/type/f32_type_test.cc
|
|
||||||
ast/type/i32_type_test.cc
|
|
||||||
ast/type/matrix_type_test.cc
|
|
||||||
ast/type/multisampled_texture_type_test.cc
|
|
||||||
ast/type/pointer_type_test.cc
|
|
||||||
ast/type/sampled_texture_type_test.cc
|
|
||||||
ast/type/sampler_type_test.cc
|
|
||||||
ast/type/storage_texture_type_test.cc
|
|
||||||
ast/type/struct_type_test.cc
|
|
||||||
ast/type/texture_type_test.cc
|
|
||||||
ast/type/u32_type_test.cc
|
|
||||||
ast/type/vector_type_test.cc
|
|
||||||
ast/traits_test.cc
|
ast/traits_test.cc
|
||||||
ast/type_constructor_expression_test.cc
|
ast/type_constructor_expression_test.cc
|
||||||
ast/type_manager_test.cc
|
|
||||||
ast/uint_literal_test.cc
|
ast/uint_literal_test.cc
|
||||||
ast/unary_op_expression_test.cc
|
ast/unary_op_expression_test.cc
|
||||||
ast/variable_decl_statement_test.cc
|
ast/variable_decl_statement_test.cc
|
||||||
ast/variable_test.cc
|
ast/variable_test.cc
|
||||||
ast/workgroup_decoration_test.cc
|
ast/workgroup_decoration_test.cc
|
||||||
castable_test.cc
|
|
||||||
block_allocator_test.cc
|
block_allocator_test.cc
|
||||||
|
castable_test.cc
|
||||||
demangler_test.cc
|
demangler_test.cc
|
||||||
diagnostic/formatter_test.cc
|
diagnostic/formatter_test.cc
|
||||||
diagnostic/printer_test.cc
|
diagnostic/printer_test.cc
|
||||||
|
@ -469,6 +451,24 @@ if(${TINT_BUILD_TESTS})
|
||||||
symbol_table_test.cc
|
symbol_table_test.cc
|
||||||
symbol_test.cc
|
symbol_test.cc
|
||||||
type_determiner_test.cc
|
type_determiner_test.cc
|
||||||
|
type/access_control_type_test.cc
|
||||||
|
type/alias_type_test.cc
|
||||||
|
type/array_type_test.cc
|
||||||
|
type/bool_type_test.cc
|
||||||
|
type/depth_texture_type_test.cc
|
||||||
|
type/f32_type_test.cc
|
||||||
|
type/i32_type_test.cc
|
||||||
|
type/matrix_type_test.cc
|
||||||
|
type/multisampled_texture_type_test.cc
|
||||||
|
type/pointer_type_test.cc
|
||||||
|
type/sampled_texture_type_test.cc
|
||||||
|
type/sampler_type_test.cc
|
||||||
|
type/storage_texture_type_test.cc
|
||||||
|
type/struct_type_test.cc
|
||||||
|
type/texture_type_test.cc
|
||||||
|
type/type_manager_test.cc
|
||||||
|
type/u32_type_test.cc
|
||||||
|
type/vector_type_test.cc
|
||||||
validator/validator_control_block_test.cc
|
validator/validator_control_block_test.cc
|
||||||
validator/validator_function_test.cc
|
validator/validator_function_test.cc
|
||||||
validator/validator_test.cc
|
validator/validator_test.cc
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "src/ast/expression.h"
|
#include "src/ast/expression.h"
|
||||||
#include "src/ast/literal.h"
|
#include "src/ast/literal.h"
|
||||||
#include "src/ast/type/type.h"
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "src/ast/identifier_expression.h"
|
#include "src/ast/identifier_expression.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/type/f32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
#include "src/ast/null_literal.h"
|
#include "src/ast/null_literal.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/bool_type.h"
|
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
|
#include "src/type/bool_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -33,20 +33,20 @@
|
||||||
#include "src/ast/struct.h"
|
#include "src/ast/struct.h"
|
||||||
#include "src/ast/struct_member.h"
|
#include "src/ast/struct_member.h"
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
#include "src/ast/type/alias_type.h"
|
|
||||||
#include "src/ast/type/array_type.h"
|
|
||||||
#include "src/ast/type/bool_type.h"
|
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/matrix_type.h"
|
|
||||||
#include "src/ast/type/pointer_type.h"
|
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/type/vector_type.h"
|
|
||||||
#include "src/ast/type/void_type.h"
|
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
|
#include "src/type/alias_type.h"
|
||||||
|
#include "src/type/array_type.h"
|
||||||
|
#include "src/type/bool_type.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/matrix_type.h"
|
||||||
|
#include "src/type/pointer_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
#include "src/type/void_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
#include "src/ast/if_statement.h"
|
#include "src/ast/if_statement.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "src/ast/if_statement.h"
|
#include "src/ast/if_statement.h"
|
||||||
#include "src/ast/scalar_constructor_expression.h"
|
#include "src/ast/scalar_constructor_expression.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/bool_type.h"
|
#include "src/type/bool_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "src/ast/node.h"
|
#include "src/ast/node.h"
|
||||||
#include "src/ast/type/type.h"
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include "src/ast/expression.h"
|
#include "src/ast/expression.h"
|
||||||
|
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/alias_type.h"
|
#include "src/type/alias_type.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/i32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
#include "src/ast/null_literal.h"
|
#include "src/ast/null_literal.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
#include "src/ast/clone_context.h"
|
#include "src/ast/clone_context.h"
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
#include "src/ast/stage_decoration.h"
|
#include "src/ast/stage_decoration.h"
|
||||||
#include "src/ast/type/multisampled_texture_type.h"
|
|
||||||
#include "src/ast/type/sampled_texture_type.h"
|
|
||||||
#include "src/ast/type/texture_type.h"
|
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/ast/workgroup_decoration.h"
|
#include "src/ast/workgroup_decoration.h"
|
||||||
|
#include "src/type/multisampled_texture_type.h"
|
||||||
|
#include "src/type/sampled_texture_type.h"
|
||||||
|
#include "src/type/texture_type.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::Function);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::Function);
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,10 @@
|
||||||
#include "src/ast/node.h"
|
#include "src/ast/node.h"
|
||||||
#include "src/ast/pipeline_stage.h"
|
#include "src/ast/pipeline_stage.h"
|
||||||
#include "src/ast/statement.h"
|
#include "src/ast/statement.h"
|
||||||
#include "src/ast/type/sampler_type.h"
|
|
||||||
#include "src/ast/type/type.h"
|
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/symbol.h"
|
#include "src/symbol.h"
|
||||||
|
#include "src/type/sampler_type.h"
|
||||||
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
#include "src/ast/null_literal.h"
|
#include "src/ast/null_literal.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -15,12 +15,12 @@
|
||||||
#include "src/ast/intrinsic_texture_helper_test.h"
|
#include "src/ast/intrinsic_texture_helper_test.h"
|
||||||
|
|
||||||
#include "src/ast/builder.h"
|
#include "src/ast/builder.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
|
||||||
#include "src/ast/type/depth_texture_type.h"
|
|
||||||
#include "src/ast/type/multisampled_texture_type.h"
|
|
||||||
#include "src/ast/type/sampled_texture_type.h"
|
|
||||||
#include "src/ast/type/storage_texture_type.h"
|
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
|
#include "src/type/access_control_type.h"
|
||||||
|
#include "src/type/depth_texture_type.h"
|
||||||
|
#include "src/type/multisampled_texture_type.h"
|
||||||
|
#include "src/type/sampled_texture_type.h"
|
||||||
|
#include "src/type/storage_texture_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
@ -135,7 +135,7 @@ std::ostream& operator<<(std::ostream& out, const TextureOverloadCase& data) {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* TextureOverloadCase::resultVectorComponentType(
|
type::Type* TextureOverloadCase::resultVectorComponentType(
|
||||||
ast::Builder* b) const {
|
ast::Builder* b) const {
|
||||||
switch (texture_data_type) {
|
switch (texture_data_type) {
|
||||||
case ast::intrinsic::test::TextureDataType::kF32:
|
case ast::intrinsic::test::TextureDataType::kF32:
|
||||||
|
@ -162,26 +162,26 @@ ast::Variable* TextureOverloadCase::buildTextureVariable(
|
||||||
case ast::intrinsic::test::TextureKind::kRegular:
|
case ast::intrinsic::test::TextureKind::kRegular:
|
||||||
return b->Var(
|
return b->Var(
|
||||||
"texture", ast::StorageClass::kUniformConstant,
|
"texture", ast::StorageClass::kUniformConstant,
|
||||||
b->create<ast::type::SampledTexture>(texture_dimension, datatype),
|
b->create<type::SampledTexture>(texture_dimension, datatype), nullptr,
|
||||||
nullptr, decos);
|
decos);
|
||||||
|
|
||||||
case ast::intrinsic::test::TextureKind::kDepth:
|
case ast::intrinsic::test::TextureKind::kDepth:
|
||||||
return b->Var("texture", ast::StorageClass::kUniformConstant,
|
return b->Var("texture", ast::StorageClass::kUniformConstant,
|
||||||
b->create<ast::type::DepthTexture>(texture_dimension),
|
b->create<type::DepthTexture>(texture_dimension), nullptr,
|
||||||
nullptr, decos);
|
decos);
|
||||||
|
|
||||||
case ast::intrinsic::test::TextureKind::kMultisampled:
|
case ast::intrinsic::test::TextureKind::kMultisampled:
|
||||||
return b->Var("texture", ast::StorageClass::kUniformConstant,
|
return b->Var(
|
||||||
b->create<ast::type::MultisampledTexture>(texture_dimension,
|
"texture", ast::StorageClass::kUniformConstant,
|
||||||
datatype),
|
b->create<type::MultisampledTexture>(texture_dimension, datatype),
|
||||||
nullptr, decos);
|
nullptr, decos);
|
||||||
|
|
||||||
case ast::intrinsic::test::TextureKind::kStorage: {
|
case ast::intrinsic::test::TextureKind::kStorage: {
|
||||||
auto* st =
|
auto* st =
|
||||||
b->create<ast::type::StorageTexture>(texture_dimension, image_format);
|
b->create<type::StorageTexture>(texture_dimension, image_format);
|
||||||
st->set_type(datatype);
|
st->set_type(datatype);
|
||||||
|
|
||||||
auto* ac = b->create<ast::type::AccessControl>(access_control, st);
|
auto* ac = b->create<type::AccessControl>(access_control, st);
|
||||||
return b->Var("texture", ast::StorageClass::kUniformConstant, ac, nullptr,
|
return b->Var("texture", ast::StorageClass::kUniformConstant, ac, nullptr,
|
||||||
decos);
|
decos);
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ ast::Variable* TextureOverloadCase::buildSamplerVariable(
|
||||||
b->create<ast::BindingDecoration>(1),
|
b->create<ast::BindingDecoration>(1),
|
||||||
};
|
};
|
||||||
return b->Var("sampler", ast::StorageClass::kUniformConstant,
|
return b->Var("sampler", ast::StorageClass::kUniformConstant,
|
||||||
b->create<ast::type::Sampler>(sampler_kind), nullptr, decos);
|
b->create<type::Sampler>(sampler_kind), nullptr, decos);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
|
@ -437,7 +437,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
ValidTextureOverload::kDimensionsStorageRO1d,
|
ValidTextureOverload::kDimensionsStorageRO1d,
|
||||||
"textureDimensions(t : texture_storage_1d<rgba32float>) -> i32",
|
"textureDimensions(t : texture_storage_1d<rgba32float>) -> i32",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k1d,
|
type::TextureDimension::k1d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureDimensions",
|
"textureDimensions",
|
||||||
|
@ -448,7 +448,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureDimensions(t : texture_storage_1d_array<rgba32float>) -> "
|
"textureDimensions(t : texture_storage_1d_array<rgba32float>) -> "
|
||||||
"i32",
|
"i32",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k1dArray,
|
type::TextureDimension::k1dArray,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureDimensions",
|
"textureDimensions",
|
||||||
|
@ -459,7 +459,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureDimensions(t : texture_storage_2d<rgba32float>) -> "
|
"textureDimensions(t : texture_storage_2d<rgba32float>) -> "
|
||||||
"vec2<i32>",
|
"vec2<i32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureDimensions",
|
"textureDimensions",
|
||||||
|
@ -470,7 +470,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> "
|
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> "
|
||||||
"vec2<i32>",
|
"vec2<i32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k2dArray,
|
type::TextureDimension::k2dArray,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureDimensions",
|
"textureDimensions",
|
||||||
|
@ -481,7 +481,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureDimensions(t : texture_storage_3d<rgba32float>) -> "
|
"textureDimensions(t : texture_storage_3d<rgba32float>) -> "
|
||||||
"vec3<i32>",
|
"vec3<i32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k3d,
|
type::TextureDimension::k3d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureDimensions",
|
"textureDimensions",
|
||||||
|
@ -491,7 +491,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
ValidTextureOverload::kDimensionsStorageWO1d,
|
ValidTextureOverload::kDimensionsStorageWO1d,
|
||||||
"textureDimensions(t : texture_storage_1d<rgba32float>) -> i32",
|
"textureDimensions(t : texture_storage_1d<rgba32float>) -> i32",
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k1d,
|
type::TextureDimension::k1d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureDimensions",
|
"textureDimensions",
|
||||||
|
@ -502,7 +502,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureDimensions(t : texture_storage_1d_array<rgba32float>) -> "
|
"textureDimensions(t : texture_storage_1d_array<rgba32float>) -> "
|
||||||
"i32",
|
"i32",
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k1dArray,
|
type::TextureDimension::k1dArray,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureDimensions",
|
"textureDimensions",
|
||||||
|
@ -513,7 +513,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureDimensions(t : texture_storage_2d<rgba32float>) -> "
|
"textureDimensions(t : texture_storage_2d<rgba32float>) -> "
|
||||||
"vec2<i32>",
|
"vec2<i32>",
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureDimensions",
|
"textureDimensions",
|
||||||
|
@ -524,7 +524,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> "
|
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> "
|
||||||
"vec2<i32>",
|
"vec2<i32>",
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k2dArray,
|
type::TextureDimension::k2dArray,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureDimensions",
|
"textureDimensions",
|
||||||
|
@ -535,7 +535,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureDimensions(t : texture_storage_3d<rgba32float>) -> "
|
"textureDimensions(t : texture_storage_3d<rgba32float>) -> "
|
||||||
"vec3<i32>",
|
"vec3<i32>",
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k3d,
|
type::TextureDimension::k3d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureDimensions",
|
"textureDimensions",
|
||||||
|
@ -605,7 +605,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
ValidTextureOverload::kNumLayersStorageWO1dArray,
|
ValidTextureOverload::kNumLayersStorageWO1dArray,
|
||||||
"textureNumLayers(t : texture_storage_1d_array<rgba32float>) -> i32",
|
"textureNumLayers(t : texture_storage_1d_array<rgba32float>) -> i32",
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k1dArray,
|
type::TextureDimension::k1dArray,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureNumLayers",
|
"textureNumLayers",
|
||||||
|
@ -615,7 +615,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
ValidTextureOverload::kNumLayersStorageWO2dArray,
|
ValidTextureOverload::kNumLayersStorageWO2dArray,
|
||||||
"textureNumLayers(t : texture_storage_2d_array<rgba32float>) -> i32",
|
"textureNumLayers(t : texture_storage_2d_array<rgba32float>) -> i32",
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k2dArray,
|
type::TextureDimension::k2dArray,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureNumLayers",
|
"textureNumLayers",
|
||||||
|
@ -2240,7 +2240,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_1d<rgba32float>,\n"
|
"textureLoad(t : texture_storage_1d<rgba32float>,\n"
|
||||||
" coords : i32) -> vec4<f32>",
|
" coords : i32) -> vec4<f32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k1d,
|
type::TextureDimension::k1d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2256,7 +2256,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
" coords : i32,\n"
|
" coords : i32,\n"
|
||||||
" array_index : i32) -> vec4<f32>",
|
" array_index : i32) -> vec4<f32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k1dArray,
|
type::TextureDimension::k1dArray,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2271,7 +2271,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<rgba8unorm>,\n"
|
"textureLoad(t : texture_storage_2d<rgba8unorm>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<f32>",
|
" coords : vec2<i32>) -> vec4<f32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba8Unorm,
|
type::ImageFormat::kRgba8Unorm,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2285,7 +2285,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<rgba8snorm>,\n"
|
"textureLoad(t : texture_storage_2d<rgba8snorm>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<f32>",
|
" coords : vec2<i32>) -> vec4<f32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba8Snorm,
|
type::ImageFormat::kRgba8Snorm,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2299,7 +2299,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<rgba8uint>,\n"
|
"textureLoad(t : texture_storage_2d<rgba8uint>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<u32>",
|
" coords : vec2<i32>) -> vec4<u32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba8Uint,
|
type::ImageFormat::kRgba8Uint,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kU32,
|
TextureDataType::kU32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2313,7 +2313,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<rgba8sint>,\n"
|
"textureLoad(t : texture_storage_2d<rgba8sint>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<i32>",
|
" coords : vec2<i32>) -> vec4<i32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba8Sint,
|
type::ImageFormat::kRgba8Sint,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kI32,
|
TextureDataType::kI32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2327,7 +2327,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<rgba16uint>,\n"
|
"textureLoad(t : texture_storage_2d<rgba16uint>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<u32>",
|
" coords : vec2<i32>) -> vec4<u32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba16Uint,
|
type::ImageFormat::kRgba16Uint,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kU32,
|
TextureDataType::kU32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2341,7 +2341,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<rgba16sint>,\n"
|
"textureLoad(t : texture_storage_2d<rgba16sint>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<i32>",
|
" coords : vec2<i32>) -> vec4<i32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba16Sint,
|
type::ImageFormat::kRgba16Sint,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kI32,
|
TextureDataType::kI32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2355,7 +2355,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<rgba16float>,\n"
|
"textureLoad(t : texture_storage_2d<rgba16float>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<f32>",
|
" coords : vec2<i32>) -> vec4<f32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba16Float,
|
type::ImageFormat::kRgba16Float,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2369,7 +2369,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<r32uint>,\n"
|
"textureLoad(t : texture_storage_2d<r32uint>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<u32>",
|
" coords : vec2<i32>) -> vec4<u32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kR32Uint,
|
type::ImageFormat::kR32Uint,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kU32,
|
TextureDataType::kU32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2383,7 +2383,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<r32sint>,\n"
|
"textureLoad(t : texture_storage_2d<r32sint>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<i32>",
|
" coords : vec2<i32>) -> vec4<i32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kR32Sint,
|
type::ImageFormat::kR32Sint,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kI32,
|
TextureDataType::kI32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2397,7 +2397,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<r32float>,\n"
|
"textureLoad(t : texture_storage_2d<r32float>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<f32>",
|
" coords : vec2<i32>) -> vec4<f32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kR32Float,
|
type::ImageFormat::kR32Float,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2411,7 +2411,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<rg32uint>,\n"
|
"textureLoad(t : texture_storage_2d<rg32uint>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<u32>",
|
" coords : vec2<i32>) -> vec4<u32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRg32Uint,
|
type::ImageFormat::kRg32Uint,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kU32,
|
TextureDataType::kU32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2425,7 +2425,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<rg32sint>,\n"
|
"textureLoad(t : texture_storage_2d<rg32sint>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<i32>",
|
" coords : vec2<i32>) -> vec4<i32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRg32Sint,
|
type::ImageFormat::kRg32Sint,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kI32,
|
TextureDataType::kI32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2439,7 +2439,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<rg32float>,\n"
|
"textureLoad(t : texture_storage_2d<rg32float>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<f32>",
|
" coords : vec2<i32>) -> vec4<f32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRg32Float,
|
type::ImageFormat::kRg32Float,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2453,7 +2453,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<rgba32uint>,\n"
|
"textureLoad(t : texture_storage_2d<rgba32uint>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<u32>",
|
" coords : vec2<i32>) -> vec4<u32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba32Uint,
|
type::ImageFormat::kRgba32Uint,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kU32,
|
TextureDataType::kU32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2467,7 +2467,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<rgba32sint>,\n"
|
"textureLoad(t : texture_storage_2d<rgba32sint>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<i32>",
|
" coords : vec2<i32>) -> vec4<i32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba32Sint,
|
type::ImageFormat::kRgba32Sint,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kI32,
|
TextureDataType::kI32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2481,7 +2481,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_2d<rgba32float>,\n"
|
"textureLoad(t : texture_storage_2d<rgba32float>,\n"
|
||||||
" coords : vec2<i32>) -> vec4<f32>",
|
" coords : vec2<i32>) -> vec4<f32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2497,7 +2497,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
" coords : vec2<i32>,\n"
|
" coords : vec2<i32>,\n"
|
||||||
" array_index : i32) -> vec4<f32>",
|
" array_index : i32) -> vec4<f32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k2dArray,
|
type::TextureDimension::k2dArray,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2512,7 +2512,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
"textureLoad(t : texture_storage_3d<rgba32float>,\n"
|
"textureLoad(t : texture_storage_3d<rgba32float>,\n"
|
||||||
" coords : vec3<i32>) -> vec4<f32>",
|
" coords : vec3<i32>) -> vec4<f32>",
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k3d,
|
type::TextureDimension::k3d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureLoad",
|
"textureLoad",
|
||||||
|
@ -2527,7 +2527,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
" coords : i32,\n"
|
" coords : i32,\n"
|
||||||
" value : vec4<T>) -> void",
|
" value : vec4<T>) -> void",
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k1d,
|
type::TextureDimension::k1d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureStore",
|
"textureStore",
|
||||||
|
@ -2544,7 +2544,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
" array_index : i32,\n"
|
" array_index : i32,\n"
|
||||||
" value : vec4<T>) -> void",
|
" value : vec4<T>) -> void",
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k1dArray,
|
type::TextureDimension::k1dArray,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureStore",
|
"textureStore",
|
||||||
|
@ -2561,7 +2561,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
" coords : vec2<i32>,\n"
|
" coords : vec2<i32>,\n"
|
||||||
" value : vec4<T>) -> void",
|
" value : vec4<T>) -> void",
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureStore",
|
"textureStore",
|
||||||
|
@ -2578,7 +2578,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
" array_index : i32,\n"
|
" array_index : i32,\n"
|
||||||
" value : vec4<T>) -> void",
|
" value : vec4<T>) -> void",
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k2dArray,
|
type::TextureDimension::k2dArray,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureStore",
|
"textureStore",
|
||||||
|
@ -2595,7 +2595,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||||
" coords : vec3<i32>,\n"
|
" coords : vec3<i32>,\n"
|
||||||
" value : vec4<T>) -> void",
|
" value : vec4<T>) -> void",
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
ast::type::ImageFormat::kRgba32Float,
|
type::ImageFormat::kRgba32Float,
|
||||||
type::TextureDimension::k3d,
|
type::TextureDimension::k3d,
|
||||||
TextureDataType::kF32,
|
TextureDataType::kF32,
|
||||||
"textureStore",
|
"textureStore",
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
|
|
||||||
#include "src/ast/access_control.h"
|
#include "src/ast/access_control.h"
|
||||||
#include "src/ast/builder.h"
|
#include "src/ast/builder.h"
|
||||||
#include "src/ast/type/sampler_type.h"
|
#include "src/type/sampler_type.h"
|
||||||
#include "src/ast/type/storage_texture_type.h"
|
#include "src/type/storage_texture_type.h"
|
||||||
#include "src/ast/type/texture_type.h"
|
#include "src/type/texture_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
@ -240,7 +240,7 @@ struct TextureOverloadCase {
|
||||||
|
|
||||||
/// @param builder the AST builder used for the test
|
/// @param builder the AST builder used for the test
|
||||||
/// @returns the vector component type of the texture function return value
|
/// @returns the vector component type of the texture function return value
|
||||||
ast::type::Type* resultVectorComponentType(ast::Builder* builder) const;
|
type::Type* resultVectorComponentType(ast::Builder* builder) const;
|
||||||
/// @param builder the AST builder used for the test
|
/// @param builder the AST builder used for the test
|
||||||
/// @returns a Variable holding the test texture
|
/// @returns a Variable holding the test texture
|
||||||
ast::Variable* buildTextureVariable(ast::Builder* builder) const;
|
ast::Variable* buildTextureVariable(ast::Builder* builder) const;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/ast/node.h"
|
#include "src/ast/node.h"
|
||||||
#include "src/ast/type/type.h"
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "src/ast/clone_context.h"
|
#include "src/ast/clone_context.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/type/struct_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -25,11 +25,11 @@
|
||||||
|
|
||||||
#include "src/ast/function.h"
|
#include "src/ast/function.h"
|
||||||
#include "src/ast/traits.h"
|
#include "src/ast/traits.h"
|
||||||
#include "src/ast/type/alias_type.h"
|
|
||||||
#include "src/ast/type_manager.h"
|
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/block_allocator.h"
|
#include "src/block_allocator.h"
|
||||||
#include "src/symbol_table.h"
|
#include "src/symbol_table.h"
|
||||||
|
#include "src/type/alias_type.h"
|
||||||
|
#include "src/type/type_manager.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
@ -181,7 +181,7 @@ class Module {
|
||||||
std::vector<type::Type*> constructed_types_;
|
std::vector<type::Type*> constructed_types_;
|
||||||
FunctionList functions_;
|
FunctionList functions_;
|
||||||
BlockAllocator<Node> ast_nodes_;
|
BlockAllocator<Node> ast_nodes_;
|
||||||
TypeManager type_mgr_;
|
type::Manager type_mgr_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ast
|
} // namespace ast
|
||||||
|
|
|
@ -126,7 +126,7 @@ fn main() -> void {
|
||||||
for (auto* src_node : src.nodes()) {
|
for (auto* src_node : src.nodes()) {
|
||||||
src_nodes.emplace(src_node);
|
src_nodes.emplace(src_node);
|
||||||
}
|
}
|
||||||
std::unordered_set<ast::type::Type*> src_types;
|
std::unordered_set<type::Type*> src_types;
|
||||||
for (auto& src_type : src.types()) {
|
for (auto& src_type : src.types()) {
|
||||||
src_types.emplace(src_type.second.get());
|
src_types.emplace(src_type.second.get());
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "src/ast/function.h"
|
#include "src/ast/function.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/alias_type.h"
|
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
|
#include "src/type/alias_type.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -23,15 +23,14 @@
|
||||||
#include "src/source.h"
|
#include "src/source.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
namespace type {
|
||||||
|
class Type;
|
||||||
|
}
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
||||||
class Module;
|
class Module;
|
||||||
class CloneContext;
|
class CloneContext;
|
||||||
|
|
||||||
namespace type {
|
|
||||||
class Type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// AST base class node
|
/// AST base class node
|
||||||
class Node : public Castable<Node> {
|
class Node : public Castable<Node> {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
#include "src/ast/float_literal.h"
|
#include "src/ast/float_literal.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "src/ast/bool_literal.h"
|
#include "src/ast/bool_literal.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/bool_type.h"
|
#include "src/type/bool_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
#include "src/ast/float_literal.h"
|
#include "src/ast/float_literal.h"
|
||||||
#include "src/ast/null_literal.h"
|
#include "src/ast/null_literal.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
|
|
||||||
#include "src/ast/node.h"
|
#include "src/ast/node.h"
|
||||||
#include "src/ast/struct_member_decoration.h"
|
#include "src/ast/struct_member_decoration.h"
|
||||||
#include "src/ast/type/type.h"
|
|
||||||
#include "src/symbol.h"
|
#include "src/symbol.h"
|
||||||
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/i32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "src/ast/struct_block_decoration.h"
|
#include "src/ast/struct_block_decoration.h"
|
||||||
#include "src/ast/struct_member.h"
|
#include "src/ast/struct_member.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/i32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "src/ast/identifier_expression.h"
|
#include "src/ast/identifier_expression.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/i32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "src/ast/constructor_expression.h"
|
#include "src/ast/constructor_expression.h"
|
||||||
#include "src/ast/type/type.h"
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
#include "src/ast/constructor_expression.h"
|
#include "src/ast/constructor_expression.h"
|
||||||
#include "src/ast/identifier_expression.h"
|
#include "src/ast/identifier_expression.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/type/f32_type.h"
|
||||||
#include "src/ast/type/vector_type.h"
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "src/ast/null_literal.h"
|
#include "src/ast/null_literal.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/u32_type.h"
|
#include "src/type/u32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
#include "src/ast/expression.h"
|
#include "src/ast/expression.h"
|
||||||
#include "src/ast/node.h"
|
#include "src/ast/node.h"
|
||||||
#include "src/ast/storage_class.h"
|
#include "src/ast/storage_class.h"
|
||||||
#include "src/ast/type/type.h"
|
|
||||||
#include "src/ast/variable_decoration.h"
|
#include "src/ast/variable_decoration.h"
|
||||||
#include "src/symbol.h"
|
#include "src/symbol.h"
|
||||||
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
|
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/constant_id_decoration.h"
|
||||||
#include "src/ast/identifier_expression.h"
|
#include "src/ast/identifier_expression.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/type/f32_type.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/i32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
|
@ -25,20 +25,20 @@
|
||||||
#include "src/ast/null_literal.h"
|
#include "src/ast/null_literal.h"
|
||||||
#include "src/ast/scalar_constructor_expression.h"
|
#include "src/ast/scalar_constructor_expression.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
|
||||||
#include "src/ast/type/array_type.h"
|
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/matrix_type.h"
|
|
||||||
#include "src/ast/type/multisampled_texture_type.h"
|
|
||||||
#include "src/ast/type/sampled_texture_type.h"
|
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/ast/type/texture_type.h"
|
|
||||||
#include "src/ast/type/type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/type/vector_type.h"
|
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
|
#include "src/type/access_control_type.h"
|
||||||
|
#include "src/type/array_type.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/matrix_type.h"
|
||||||
|
#include "src/type/multisampled_texture_type.h"
|
||||||
|
#include "src/type/sampled_texture_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
#include "src/type/texture_type.h"
|
||||||
|
#include "src/type/type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace inspector {
|
namespace inspector {
|
||||||
|
@ -183,12 +183,12 @@ std::vector<ResourceBinding> Inspector::GetUniformBufferResourceBindings(
|
||||||
ast::Variable* var = nullptr;
|
ast::Variable* var = nullptr;
|
||||||
ast::Function::BindingInfo binding_info;
|
ast::Function::BindingInfo binding_info;
|
||||||
std::tie(var, binding_info) = ruv;
|
std::tie(var, binding_info) = ruv;
|
||||||
if (!var->type()->Is<ast::type::AccessControl>()) {
|
if (!var->type()->Is<type::AccessControl>()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto* unwrapped_type = var->type()->UnwrapIfNeeded();
|
auto* unwrapped_type = var->type()->UnwrapIfNeeded();
|
||||||
|
|
||||||
auto* str = unwrapped_type->As<ast::type::Struct>();
|
auto* str = unwrapped_type->As<type::Struct>();
|
||||||
if (str == nullptr) {
|
if (str == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -199,8 +199,8 @@ std::vector<ResourceBinding> Inspector::GetUniformBufferResourceBindings(
|
||||||
|
|
||||||
entry.bind_group = binding_info.group->value();
|
entry.bind_group = binding_info.group->value();
|
||||||
entry.binding = binding_info.binding->value();
|
entry.binding = binding_info.binding->value();
|
||||||
entry.min_buffer_binding_size = var->type()->MinBufferBindingSize(
|
entry.min_buffer_binding_size =
|
||||||
ast::type::MemoryLayout::kUniformBuffer);
|
var->type()->MinBufferBindingSize(type::MemoryLayout::kUniformBuffer);
|
||||||
|
|
||||||
result.push_back(entry);
|
result.push_back(entry);
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ std::vector<ResourceBinding> Inspector::GetStorageBufferResourceBindingsImpl(
|
||||||
ast::Function::BindingInfo binding_info;
|
ast::Function::BindingInfo binding_info;
|
||||||
std::tie(var, binding_info) = rsv;
|
std::tie(var, binding_info) = rsv;
|
||||||
|
|
||||||
auto* ac_type = var->type()->As<ast::type::AccessControl>();
|
auto* ac_type = var->type()->As<type::AccessControl>();
|
||||||
if (ac_type == nullptr) {
|
if (ac_type == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -316,14 +316,14 @@ std::vector<ResourceBinding> Inspector::GetStorageBufferResourceBindingsImpl(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!var->type()->UnwrapIfNeeded()->Is<ast::type::Struct>()) {
|
if (!var->type()->UnwrapIfNeeded()->Is<type::Struct>()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.bind_group = binding_info.group->value();
|
entry.bind_group = binding_info.group->value();
|
||||||
entry.binding = binding_info.binding->value();
|
entry.binding = binding_info.binding->value();
|
||||||
entry.min_buffer_binding_size = var->type()->MinBufferBindingSize(
|
entry.min_buffer_binding_size =
|
||||||
ast::type::MemoryLayout::kStorageBuffer);
|
var->type()->MinBufferBindingSize(type::MemoryLayout::kStorageBuffer);
|
||||||
|
|
||||||
result.push_back(entry);
|
result.push_back(entry);
|
||||||
}
|
}
|
||||||
|
@ -352,28 +352,27 @@ std::vector<ResourceBinding> Inspector::GetSampledTextureResourceBindingsImpl(
|
||||||
entry.bind_group = binding_info.group->value();
|
entry.bind_group = binding_info.group->value();
|
||||||
entry.binding = binding_info.binding->value();
|
entry.binding = binding_info.binding->value();
|
||||||
|
|
||||||
auto* texture_type =
|
auto* texture_type = var->type()->UnwrapIfNeeded()->As<type::Texture>();
|
||||||
var->type()->UnwrapIfNeeded()->As<ast::type::Texture>();
|
|
||||||
switch (texture_type->dim()) {
|
switch (texture_type->dim()) {
|
||||||
case ast::type::TextureDimension::k1d:
|
case type::TextureDimension::k1d:
|
||||||
entry.dim = ResourceBinding::TextureDimension::k1d;
|
entry.dim = ResourceBinding::TextureDimension::k1d;
|
||||||
break;
|
break;
|
||||||
case ast::type::TextureDimension::k1dArray:
|
case type::TextureDimension::k1dArray:
|
||||||
entry.dim = ResourceBinding::TextureDimension::k1dArray;
|
entry.dim = ResourceBinding::TextureDimension::k1dArray;
|
||||||
break;
|
break;
|
||||||
case ast::type::TextureDimension::k2d:
|
case type::TextureDimension::k2d:
|
||||||
entry.dim = ResourceBinding::TextureDimension::k2d;
|
entry.dim = ResourceBinding::TextureDimension::k2d;
|
||||||
break;
|
break;
|
||||||
case ast::type::TextureDimension::k2dArray:
|
case type::TextureDimension::k2dArray:
|
||||||
entry.dim = ResourceBinding::TextureDimension::k2dArray;
|
entry.dim = ResourceBinding::TextureDimension::k2dArray;
|
||||||
break;
|
break;
|
||||||
case ast::type::TextureDimension::k3d:
|
case type::TextureDimension::k3d:
|
||||||
entry.dim = ResourceBinding::TextureDimension::k3d;
|
entry.dim = ResourceBinding::TextureDimension::k3d;
|
||||||
break;
|
break;
|
||||||
case ast::type::TextureDimension::kCube:
|
case type::TextureDimension::kCube:
|
||||||
entry.dim = ResourceBinding::TextureDimension::kCube;
|
entry.dim = ResourceBinding::TextureDimension::kCube;
|
||||||
break;
|
break;
|
||||||
case ast::type::TextureDimension::kCubeArray:
|
case type::TextureDimension::kCubeArray:
|
||||||
entry.dim = ResourceBinding::TextureDimension::kCubeArray;
|
entry.dim = ResourceBinding::TextureDimension::kCubeArray;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -381,30 +380,29 @@ std::vector<ResourceBinding> Inspector::GetSampledTextureResourceBindingsImpl(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* base_type = nullptr;
|
type::Type* base_type = nullptr;
|
||||||
if (multisampled_only) {
|
if (multisampled_only) {
|
||||||
base_type = texture_type->As<ast::type::MultisampledTexture>()
|
base_type = texture_type->As<type::MultisampledTexture>()
|
||||||
->type()
|
->type()
|
||||||
->UnwrapIfNeeded();
|
->UnwrapIfNeeded();
|
||||||
} else {
|
} else {
|
||||||
base_type = texture_type->As<ast::type::SampledTexture>()
|
base_type =
|
||||||
->type()
|
texture_type->As<type::SampledTexture>()->type()->UnwrapIfNeeded();
|
||||||
->UnwrapIfNeeded();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto* at = base_type->As<ast::type::Array>()) {
|
if (auto* at = base_type->As<type::Array>()) {
|
||||||
base_type = at->type();
|
base_type = at->type();
|
||||||
} else if (auto* mt = base_type->As<ast::type::Matrix>()) {
|
} else if (auto* mt = base_type->As<type::Matrix>()) {
|
||||||
base_type = mt->type();
|
base_type = mt->type();
|
||||||
} else if (auto* vt = base_type->As<ast::type::Vector>()) {
|
} else if (auto* vt = base_type->As<type::Vector>()) {
|
||||||
base_type = vt->type();
|
base_type = vt->type();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base_type->Is<ast::type::F32>()) {
|
if (base_type->Is<type::F32>()) {
|
||||||
entry.sampled_kind = ResourceBinding::SampledKind::kFloat;
|
entry.sampled_kind = ResourceBinding::SampledKind::kFloat;
|
||||||
} else if (base_type->Is<ast::type::U32>()) {
|
} else if (base_type->Is<type::U32>()) {
|
||||||
entry.sampled_kind = ResourceBinding::SampledKind::kUInt;
|
entry.sampled_kind = ResourceBinding::SampledKind::kUInt;
|
||||||
} else if (base_type->Is<ast::type::I32>()) {
|
} else if (base_type->Is<type::I32>()) {
|
||||||
entry.sampled_kind = ResourceBinding::SampledKind::kSInt;
|
entry.sampled_kind = ResourceBinding::SampledKind::kSInt;
|
||||||
} else {
|
} else {
|
||||||
entry.sampled_kind = ResourceBinding::SampledKind::kUnknown;
|
entry.sampled_kind = ResourceBinding::SampledKind::kUnknown;
|
||||||
|
|
|
@ -39,27 +39,27 @@
|
||||||
#include "src/ast/struct_member.h"
|
#include "src/ast/struct_member.h"
|
||||||
#include "src/ast/struct_member_decoration.h"
|
#include "src/ast/struct_member_decoration.h"
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
|
||||||
#include "src/ast/type/array_type.h"
|
|
||||||
#include "src/ast/type/bool_type.h"
|
|
||||||
#include "src/ast/type/depth_texture_type.h"
|
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/matrix_type.h"
|
|
||||||
#include "src/ast/type/multisampled_texture_type.h"
|
|
||||||
#include "src/ast/type/pointer_type.h"
|
|
||||||
#include "src/ast/type/sampled_texture_type.h"
|
|
||||||
#include "src/ast/type/sampler_type.h"
|
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/ast/type/type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/type/vector_type.h"
|
|
||||||
#include "src/ast/type/void_type.h"
|
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
#include "src/ast/variable_decoration.h"
|
#include "src/ast/variable_decoration.h"
|
||||||
#include "src/ast/workgroup_decoration.h"
|
#include "src/ast/workgroup_decoration.h"
|
||||||
|
#include "src/type/access_control_type.h"
|
||||||
|
#include "src/type/array_type.h"
|
||||||
|
#include "src/type/bool_type.h"
|
||||||
|
#include "src/type/depth_texture_type.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/matrix_type.h"
|
||||||
|
#include "src/type/multisampled_texture_type.h"
|
||||||
|
#include "src/type/pointer_type.h"
|
||||||
|
#include "src/type/sampled_texture_type.h"
|
||||||
|
#include "src/type/sampler_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
#include "src/type/type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
#include "src/type/void_type.h"
|
||||||
#include "src/type_determiner.h"
|
#include "src/type_determiner.h"
|
||||||
#include "tint/tint.h"
|
#include "tint/tint.h"
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
InspectorHelper()
|
InspectorHelper()
|
||||||
: td_(std::make_unique<TypeDeterminer>(mod)),
|
: td_(std::make_unique<TypeDeterminer>(mod)),
|
||||||
inspector_(std::make_unique<Inspector>(*mod)),
|
inspector_(std::make_unique<Inspector>(*mod)),
|
||||||
sampler_type_(ast::type::SamplerKind::kSampler),
|
sampler_type_(type::SamplerKind::kSampler),
|
||||||
comparison_sampler_type_(ast::type::SamplerKind::kComparisonSampler) {}
|
comparison_sampler_type_(type::SamplerKind::kComparisonSampler) {}
|
||||||
|
|
||||||
/// Generates an empty function
|
/// Generates an empty function
|
||||||
/// @param name name of the function created
|
/// @param name name of the function created
|
||||||
|
@ -177,10 +177,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// @param val value to initialize the variable with, if NULL no initializer
|
/// @param val value to initialize the variable with, if NULL no initializer
|
||||||
/// will be added.
|
/// will be added.
|
||||||
template <class T>
|
template <class T>
|
||||||
void AddConstantID(std::string name,
|
void AddConstantID(std::string name, uint32_t id, type::Type* type, T* val) {
|
||||||
uint32_t id,
|
|
||||||
ast::type::Type* type,
|
|
||||||
T* val) {
|
|
||||||
ast::Expression* constructor = nullptr;
|
ast::Expression* constructor = nullptr;
|
||||||
if (val) {
|
if (val) {
|
||||||
constructor =
|
constructor =
|
||||||
|
@ -196,28 +193,28 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// @param type AST type of the literal, must resolve to BoolLiteral
|
/// @param type AST type of the literal, must resolve to BoolLiteral
|
||||||
/// @param val scalar value for the literal to contain
|
/// @param val scalar value for the literal to contain
|
||||||
/// @returns a Literal of the expected type and value
|
/// @returns a Literal of the expected type and value
|
||||||
ast::Literal* MakeLiteral(ast::type::Type* type, bool* val) {
|
ast::Literal* MakeLiteral(type::Type* type, bool* val) {
|
||||||
return create<ast::BoolLiteral>(type, *val);
|
return create<ast::BoolLiteral>(type, *val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param type AST type of the literal, must resolve to UIntLiteral
|
/// @param type AST type of the literal, must resolve to UIntLiteral
|
||||||
/// @param val scalar value for the literal to contain
|
/// @param val scalar value for the literal to contain
|
||||||
/// @returns a Literal of the expected type and value
|
/// @returns a Literal of the expected type and value
|
||||||
ast::Literal* MakeLiteral(ast::type::Type* type, uint32_t* val) {
|
ast::Literal* MakeLiteral(type::Type* type, uint32_t* val) {
|
||||||
return create<ast::UintLiteral>(type, *val);
|
return create<ast::UintLiteral>(type, *val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param type AST type of the literal, must resolve to IntLiteral
|
/// @param type AST type of the literal, must resolve to IntLiteral
|
||||||
/// @param val scalar value for the literal to contain
|
/// @param val scalar value for the literal to contain
|
||||||
/// @returns a Literal of the expected type and value
|
/// @returns a Literal of the expected type and value
|
||||||
ast::Literal* MakeLiteral(ast::type::Type* type, int32_t* val) {
|
ast::Literal* MakeLiteral(type::Type* type, int32_t* val) {
|
||||||
return create<ast::SintLiteral>(type, *val);
|
return create<ast::SintLiteral>(type, *val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param type AST type of the literal, must resolve to FloattLiteral
|
/// @param type AST type of the literal, must resolve to FloattLiteral
|
||||||
/// @param val scalar value for the literal to contain
|
/// @param val scalar value for the literal to contain
|
||||||
/// @returns a Literal of the expected type and value
|
/// @returns a Literal of the expected type and value
|
||||||
ast::Literal* MakeLiteral(ast::type::Type* type, float* val) {
|
ast::Literal* MakeLiteral(type::Type* type, float* val) {
|
||||||
return create<ast::FloatLiteral>(type, *val);
|
return create<ast::FloatLiteral>(type, *val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +235,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// @param idx index of member
|
/// @param idx index of member
|
||||||
/// @param type type of member
|
/// @param type type of member
|
||||||
/// @returns a string for the member
|
/// @returns a string for the member
|
||||||
std::string StructMemberName(size_t idx, ast::type::Type* type) {
|
std::string StructMemberName(size_t idx, type::Type* type) {
|
||||||
return std::to_string(idx) + type->type_name();
|
return std::to_string(idx) + type->type_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,13 +245,13 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// type and offset of a member of the struct
|
/// type and offset of a member of the struct
|
||||||
/// @param is_block whether or not to decorate as a Block
|
/// @param is_block whether or not to decorate as a Block
|
||||||
/// @returns a struct type
|
/// @returns a struct type
|
||||||
ast::type::Struct* MakeStructType(
|
type::Struct* MakeStructType(
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info,
|
std::vector<std::tuple<type::Type*, uint32_t>> members_info,
|
||||||
bool is_block) {
|
bool is_block) {
|
||||||
ast::StructMemberList members;
|
ast::StructMemberList members;
|
||||||
for (auto& member_info : members_info) {
|
for (auto& member_info : members_info) {
|
||||||
ast::type::Type* type;
|
type::Type* type;
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
std::tie(type, offset) = member_info;
|
std::tie(type, offset) = member_info;
|
||||||
|
|
||||||
|
@ -278,12 +275,12 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// @returns a tuple {struct type, access control type}, where the struct has
|
/// @returns a tuple {struct type, access control type}, where the struct has
|
||||||
/// the layout for an uniform buffer, and the control type wraps the
|
/// the layout for an uniform buffer, and the control type wraps the
|
||||||
/// struct.
|
/// struct.
|
||||||
std::tuple<ast::type::Struct*, std::unique_ptr<ast::type::AccessControl>>
|
std::tuple<type::Struct*, std::unique_ptr<type::AccessControl>>
|
||||||
MakeUniformBufferTypes(
|
MakeUniformBufferTypes(
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info) {
|
std::vector<std::tuple<type::Type*, uint32_t>> members_info) {
|
||||||
auto* struct_type = MakeStructType(name, members_info, true);
|
auto* struct_type = MakeStructType(name, members_info, true);
|
||||||
auto access_type = std::make_unique<ast::type::AccessControl>(
|
auto access_type = std::make_unique<type::AccessControl>(
|
||||||
ast::AccessControl::kReadOnly, struct_type);
|
ast::AccessControl::kReadOnly, struct_type);
|
||||||
return {struct_type, std::move(access_type)};
|
return {struct_type, std::move(access_type)};
|
||||||
}
|
}
|
||||||
|
@ -295,12 +292,12 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// @returns a tuple {struct type, access control type}, where the struct has
|
/// @returns a tuple {struct type, access control type}, where the struct has
|
||||||
/// the layout for a storage buffer, and the control type wraps the
|
/// the layout for a storage buffer, and the control type wraps the
|
||||||
/// struct.
|
/// struct.
|
||||||
std::tuple<ast::type::Struct*, std::unique_ptr<ast::type::AccessControl>>
|
std::tuple<type::Struct*, std::unique_ptr<type::AccessControl>>
|
||||||
MakeStorageBufferTypes(
|
MakeStorageBufferTypes(
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info) {
|
std::vector<std::tuple<type::Type*, uint32_t>> members_info) {
|
||||||
auto* struct_type = MakeStructType(name, members_info, false);
|
auto* struct_type = MakeStructType(name, members_info, false);
|
||||||
auto access_type = std::make_unique<ast::type::AccessControl>(
|
auto access_type = std::make_unique<type::AccessControl>(
|
||||||
ast::AccessControl::kReadWrite, struct_type);
|
ast::AccessControl::kReadWrite, struct_type);
|
||||||
return {struct_type, std::move(access_type)};
|
return {struct_type, std::move(access_type)};
|
||||||
}
|
}
|
||||||
|
@ -312,12 +309,12 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// @returns a tuple {struct type, access control type}, where the struct has
|
/// @returns a tuple {struct type, access control type}, where the struct has
|
||||||
/// the layout for a read-only storage buffer, and the control type
|
/// the layout for a read-only storage buffer, and the control type
|
||||||
/// wraps the struct.
|
/// wraps the struct.
|
||||||
std::tuple<ast::type::Struct*, std::unique_ptr<ast::type::AccessControl>>
|
std::tuple<type::Struct*, std::unique_ptr<type::AccessControl>>
|
||||||
MakeReadOnlyStorageBufferTypes(
|
MakeReadOnlyStorageBufferTypes(
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info) {
|
std::vector<std::tuple<type::Type*, uint32_t>> members_info) {
|
||||||
auto* struct_type = MakeStructType(name, members_info, false);
|
auto* struct_type = MakeStructType(name, members_info, false);
|
||||||
auto access_type = std::make_unique<ast::type::AccessControl>(
|
auto access_type = std::make_unique<type::AccessControl>(
|
||||||
ast::AccessControl::kReadOnly, struct_type);
|
ast::AccessControl::kReadOnly, struct_type);
|
||||||
return {struct_type, std::move(access_type)};
|
return {struct_type, std::move(access_type)};
|
||||||
}
|
}
|
||||||
|
@ -329,7 +326,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// @param group the binding and group 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
|
/// @param binding the binding number to use for the uniform buffer
|
||||||
void AddBinding(const std::string& name,
|
void AddBinding(const std::string& name,
|
||||||
ast::type::Type* type,
|
type::Type* type,
|
||||||
ast::StorageClass storage_class,
|
ast::StorageClass storage_class,
|
||||||
uint32_t group,
|
uint32_t group,
|
||||||
uint32_t binding) {
|
uint32_t binding) {
|
||||||
|
@ -348,7 +345,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// @param group the binding/group/ 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
|
/// @param binding the binding number to use for the uniform buffer
|
||||||
void AddUniformBuffer(const std::string& name,
|
void AddUniformBuffer(const std::string& name,
|
||||||
ast::type::Type* type,
|
type::Type* type,
|
||||||
uint32_t group,
|
uint32_t group,
|
||||||
uint32_t binding) {
|
uint32_t binding) {
|
||||||
AddBinding(name, type, ast::StorageClass::kUniform, group, binding);
|
AddBinding(name, type, ast::StorageClass::kUniform, group, binding);
|
||||||
|
@ -360,7 +357,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// @param group the binding/group 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
|
/// @param binding the binding number to use for the storage buffer
|
||||||
void AddStorageBuffer(const std::string& name,
|
void AddStorageBuffer(const std::string& name,
|
||||||
ast::type::Type* type,
|
type::Type* type,
|
||||||
uint32_t group,
|
uint32_t group,
|
||||||
uint32_t binding) {
|
uint32_t binding) {
|
||||||
AddBinding(name, type, ast::StorageClass::kStorage, group, binding);
|
AddBinding(name, type, ast::StorageClass::kStorage, group, binding);
|
||||||
|
@ -374,11 +371,11 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
ast::Function* MakeStructVariableReferenceBodyFunction(
|
ast::Function* MakeStructVariableReferenceBodyFunction(
|
||||||
std::string func_name,
|
std::string func_name,
|
||||||
std::string struct_name,
|
std::string struct_name,
|
||||||
std::vector<std::tuple<size_t, ast::type::Type*>> members) {
|
std::vector<std::tuple<size_t, type::Type*>> members) {
|
||||||
ast::StatementList stmts;
|
ast::StatementList stmts;
|
||||||
for (auto member : members) {
|
for (auto member : members) {
|
||||||
size_t member_idx;
|
size_t member_idx;
|
||||||
ast::type::Type* member_type;
|
type::Type* member_type;
|
||||||
std::tie(member_idx, member_type) = member;
|
std::tie(member_idx, member_type) = member;
|
||||||
std::string member_name = StructMemberName(member_idx, member_type);
|
std::string member_name = StructMemberName(member_idx, member_type);
|
||||||
|
|
||||||
|
@ -388,7 +385,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
|
|
||||||
for (auto member : members) {
|
for (auto member : members) {
|
||||||
size_t member_idx;
|
size_t member_idx;
|
||||||
ast::type::Type* member_type;
|
type::Type* member_type;
|
||||||
std::tie(member_idx, member_type) = member;
|
std::tie(member_idx, member_type) = member;
|
||||||
std::string member_name = StructMemberName(member_idx, member_type);
|
std::string member_name = StructMemberName(member_idx, member_type);
|
||||||
|
|
||||||
|
@ -427,28 +424,28 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// @param dim the dimensions of the texture
|
/// @param dim the dimensions of the texture
|
||||||
/// @param type the data type of the sampled texture
|
/// @param type the data type of the sampled texture
|
||||||
/// @returns the generated SampleTextureType
|
/// @returns the generated SampleTextureType
|
||||||
std::unique_ptr<ast::type::SampledTexture> MakeSampledTextureType(
|
std::unique_ptr<type::SampledTexture> MakeSampledTextureType(
|
||||||
ast::type::TextureDimension dim,
|
type::TextureDimension dim,
|
||||||
ast::type::Type* type) {
|
type::Type* type) {
|
||||||
return std::make_unique<ast::type::SampledTexture>(dim, type);
|
return std::make_unique<type::SampledTexture>(dim, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates a DepthTexture appropriate for the params
|
/// Generates a DepthTexture appropriate for the params
|
||||||
/// @param dim the dimensions of the texture
|
/// @param dim the dimensions of the texture
|
||||||
/// @returns the generated DepthTexture
|
/// @returns the generated DepthTexture
|
||||||
std::unique_ptr<ast::type::DepthTexture> MakeDepthTextureType(
|
std::unique_ptr<type::DepthTexture> MakeDepthTextureType(
|
||||||
ast::type::TextureDimension dim) {
|
type::TextureDimension dim) {
|
||||||
return std::make_unique<ast::type::DepthTexture>(dim);
|
return std::make_unique<type::DepthTexture>(dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates a MultisampledTexture appropriate for the params
|
/// Generates a MultisampledTexture appropriate for the params
|
||||||
/// @param dim the dimensions of the texture
|
/// @param dim the dimensions of the texture
|
||||||
/// @param type the data type of the sampled texture
|
/// @param type the data type of the sampled texture
|
||||||
/// @returns the generated SampleTextureType
|
/// @returns the generated SampleTextureType
|
||||||
std::unique_ptr<ast::type::MultisampledTexture> MakeMultisampledTextureType(
|
std::unique_ptr<type::MultisampledTexture> MakeMultisampledTextureType(
|
||||||
ast::type::TextureDimension dim,
|
type::TextureDimension dim,
|
||||||
ast::type::Type* type) {
|
type::Type* type) {
|
||||||
return std::make_unique<ast::type::MultisampledTexture>(dim, type);
|
return std::make_unique<type::MultisampledTexture>(dim, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a sampled texture variable to the module
|
/// Adds a sampled texture variable to the module
|
||||||
|
@ -457,7 +454,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// @param group the binding/group 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
|
/// @param binding the binding number to use for the sampled texture
|
||||||
void AddSampledTexture(const std::string& name,
|
void AddSampledTexture(const std::string& name,
|
||||||
ast::type::Type* type,
|
type::Type* type,
|
||||||
uint32_t group,
|
uint32_t group,
|
||||||
uint32_t binding) {
|
uint32_t binding) {
|
||||||
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
|
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
|
||||||
|
@ -469,13 +466,13 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// @param group the binding/group 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
|
/// @param binding the binding number to use for the multi-sampled texture
|
||||||
void AddMultisampledTexture(const std::string& name,
|
void AddMultisampledTexture(const std::string& name,
|
||||||
ast::type::Type* type,
|
type::Type* type,
|
||||||
uint32_t group,
|
uint32_t group,
|
||||||
uint32_t binding) {
|
uint32_t binding) {
|
||||||
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
|
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddGlobalVariable(const std::string& name, ast::type::Type* type) {
|
void AddGlobalVariable(const std::string& name, type::Type* type) {
|
||||||
mod->AddGlobalVariable(
|
mod->AddGlobalVariable(
|
||||||
Var(name, ast::StorageClass::kUniformConstant, type));
|
Var(name, ast::StorageClass::kUniformConstant, type));
|
||||||
}
|
}
|
||||||
|
@ -483,7 +480,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// Adds a depth texture variable to the module
|
/// Adds a depth texture variable to the module
|
||||||
/// @param name the name of the variable
|
/// @param name the name of the variable
|
||||||
/// @param type the type to use
|
/// @param type the type to use
|
||||||
void AddDepthTexture(const std::string& name, ast::type::Type* type) {
|
void AddDepthTexture(const std::string& name, type::Type* type) {
|
||||||
mod->AddGlobalVariable(
|
mod->AddGlobalVariable(
|
||||||
Var(name, ast::StorageClass::kUniformConstant, type));
|
Var(name, ast::StorageClass::kUniformConstant, type));
|
||||||
}
|
}
|
||||||
|
@ -501,7 +498,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
const std::string& texture_name,
|
const std::string& texture_name,
|
||||||
const std::string& sampler_name,
|
const std::string& sampler_name,
|
||||||
const std::string& coords_name,
|
const std::string& coords_name,
|
||||||
ast::type::Type* base_type,
|
type::Type* base_type,
|
||||||
ast::FunctionDecorationList decorations) {
|
ast::FunctionDecorationList decorations) {
|
||||||
std::string result_name = "sampler_result";
|
std::string result_name = "sampler_result";
|
||||||
|
|
||||||
|
@ -533,7 +530,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
const std::string& sampler_name,
|
const std::string& sampler_name,
|
||||||
const std::string& coords_name,
|
const std::string& coords_name,
|
||||||
const std::string& array_index,
|
const std::string& array_index,
|
||||||
ast::type::Type* base_type,
|
type::Type* base_type,
|
||||||
ast::FunctionDecorationList decorations) {
|
ast::FunctionDecorationList decorations) {
|
||||||
std::string result_name = "sampler_result";
|
std::string result_name = "sampler_result";
|
||||||
|
|
||||||
|
@ -567,7 +564,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
const std::string& sampler_name,
|
const std::string& sampler_name,
|
||||||
const std::string& coords_name,
|
const std::string& coords_name,
|
||||||
const std::string& depth_name,
|
const std::string& depth_name,
|
||||||
ast::type::Type* base_type,
|
type::Type* base_type,
|
||||||
ast::FunctionDecorationList decorations) {
|
ast::FunctionDecorationList decorations) {
|
||||||
std::string result_name = "sampler_result";
|
std::string result_name = "sampler_result";
|
||||||
|
|
||||||
|
@ -586,7 +583,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// Gets an appropriate type for the data in a given texture type.
|
/// Gets an appropriate type for the data in a given texture type.
|
||||||
/// @param sampled_kind type of in the texture
|
/// @param sampled_kind type of in the texture
|
||||||
/// @returns a pointer to a type appropriate for the coord param
|
/// @returns a pointer to a type appropriate for the coord param
|
||||||
ast::type::Type* GetBaseType(ResourceBinding::SampledKind sampled_kind) {
|
type::Type* GetBaseType(ResourceBinding::SampledKind sampled_kind) {
|
||||||
switch (sampled_kind) {
|
switch (sampled_kind) {
|
||||||
case ResourceBinding::SampledKind::kFloat:
|
case ResourceBinding::SampledKind::kFloat:
|
||||||
return ty.f32;
|
return ty.f32;
|
||||||
|
@ -604,15 +601,15 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
/// @param dim dimensionality of the texture being sampled
|
/// @param dim dimensionality of the texture being sampled
|
||||||
/// @param sampled_kind type of data in the texture
|
/// @param sampled_kind type of data in the texture
|
||||||
/// @returns a pointer to a type appropriate for the coord param
|
/// @returns a pointer to a type appropriate for the coord param
|
||||||
ast::type::Type* GetCoordsType(ast::type::TextureDimension dim,
|
type::Type* GetCoordsType(type::TextureDimension dim,
|
||||||
ResourceBinding::SampledKind sampled_kind) {
|
ResourceBinding::SampledKind sampled_kind) {
|
||||||
ast::type::Type* base_type = GetBaseType(sampled_kind);
|
type::Type* base_type = GetBaseType(sampled_kind);
|
||||||
if (dim == ast::type::TextureDimension::k1d) {
|
if (dim == type::TextureDimension::k1d) {
|
||||||
return base_type;
|
return base_type;
|
||||||
} else if (dim == ast::type::TextureDimension::k1dArray ||
|
} else if (dim == type::TextureDimension::k1dArray ||
|
||||||
dim == ast::type::TextureDimension::k2d) {
|
dim == type::TextureDimension::k2d) {
|
||||||
return vec_type(base_type, 2);
|
return vec_type(base_type, 2);
|
||||||
} else if (dim == ast::type::TextureDimension::kCubeArray) {
|
} else if (dim == type::TextureDimension::kCubeArray) {
|
||||||
return vec_type(base_type, 4);
|
return vec_type(base_type, 4);
|
||||||
}
|
}
|
||||||
return vec_type(base_type, 3);
|
return vec_type(base_type, 3);
|
||||||
|
@ -621,38 +618,35 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
TypeDeterminer* td() { return td_.get(); }
|
TypeDeterminer* td() { return td_.get(); }
|
||||||
Inspector* inspector() { return inspector_.get(); }
|
Inspector* inspector() { return inspector_.get(); }
|
||||||
|
|
||||||
ast::type::Array* u32_array_type(uint32_t count) {
|
type::Array* u32_array_type(uint32_t count) {
|
||||||
if (array_type_memo_.find(count) == array_type_memo_.end()) {
|
if (array_type_memo_.find(count) == array_type_memo_.end()) {
|
||||||
array_type_memo_[count] =
|
array_type_memo_[count] =
|
||||||
create<ast::type::Array>(ty.u32, count,
|
create<type::Array>(ty.u32, count,
|
||||||
ast::ArrayDecorationList{
|
ast::ArrayDecorationList{
|
||||||
create<ast::StrideDecoration>(4),
|
create<ast::StrideDecoration>(4),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return array_type_memo_[count];
|
return array_type_memo_[count];
|
||||||
}
|
}
|
||||||
ast::type::Vector* vec_type(ast::type::Type* type, uint32_t count) {
|
type::Vector* vec_type(type::Type* type, uint32_t count) {
|
||||||
if (vector_type_memo_.find(std::tie(type, count)) ==
|
if (vector_type_memo_.find(std::tie(type, count)) ==
|
||||||
vector_type_memo_.end()) {
|
vector_type_memo_.end()) {
|
||||||
vector_type_memo_[std::tie(type, count)] =
|
vector_type_memo_[std::tie(type, count)] =
|
||||||
std::make_unique<ast::type::Vector>(ty.u32, count);
|
std::make_unique<type::Vector>(ty.u32, count);
|
||||||
}
|
}
|
||||||
return vector_type_memo_[std::tie(type, count)].get();
|
return vector_type_memo_[std::tie(type, count)].get();
|
||||||
}
|
}
|
||||||
ast::type::Sampler* sampler_type() { return &sampler_type_; }
|
type::Sampler* sampler_type() { return &sampler_type_; }
|
||||||
ast::type::Sampler* comparison_sampler_type() {
|
type::Sampler* comparison_sampler_type() { return &comparison_sampler_type_; }
|
||||||
return &comparison_sampler_type_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<TypeDeterminer> td_;
|
std::unique_ptr<TypeDeterminer> td_;
|
||||||
std::unique_ptr<Inspector> inspector_;
|
std::unique_ptr<Inspector> inspector_;
|
||||||
|
|
||||||
ast::type::Sampler sampler_type_;
|
type::Sampler sampler_type_;
|
||||||
ast::type::Sampler comparison_sampler_type_;
|
type::Sampler comparison_sampler_type_;
|
||||||
std::map<uint32_t, ast::type::Array*> array_type_memo_;
|
std::map<uint32_t, type::Array*> array_type_memo_;
|
||||||
std::map<std::tuple<ast::type::Type*, uint32_t>,
|
std::map<std::tuple<type::Type*, uint32_t>, std::unique_ptr<type::Vector>>
|
||||||
std::unique_ptr<ast::type::Vector>>
|
|
||||||
vector_type_memo_;
|
vector_type_memo_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -680,7 +674,7 @@ class InspectorGetSampledArrayTextureResourceBindingsTest
|
||||||
: public InspectorHelper,
|
: public InspectorHelper,
|
||||||
public testing::Test {};
|
public testing::Test {};
|
||||||
struct GetSampledTextureTestParams {
|
struct GetSampledTextureTestParams {
|
||||||
ast::type::TextureDimension type_dim;
|
type::TextureDimension type_dim;
|
||||||
inspector::ResourceBinding::TextureDimension inspector_dim;
|
inspector::ResourceBinding::TextureDimension inspector_dim;
|
||||||
inspector::ResourceBinding::SampledKind sampled_kind;
|
inspector::ResourceBinding::SampledKind sampled_kind;
|
||||||
};
|
};
|
||||||
|
@ -1287,8 +1281,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingEntryPoint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) {
|
TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) {
|
||||||
ast::type::Struct* foo_struct_type;
|
type::Struct* foo_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> foo_control_type;
|
std::unique_ptr<type::AccessControl> foo_control_type;
|
||||||
std::tie(foo_struct_type, foo_control_type) =
|
std::tie(foo_struct_type, foo_control_type) =
|
||||||
MakeUniformBufferTypes("foo_type", {{ty.i32, 0}});
|
MakeUniformBufferTypes("foo_type", {{ty.i32, 0}});
|
||||||
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
|
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
|
||||||
|
@ -1340,8 +1334,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingBlockDeco) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) {
|
TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) {
|
||||||
ast::type::Struct* foo_struct_type;
|
type::Struct* foo_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> foo_control_type;
|
std::unique_ptr<type::AccessControl> foo_control_type;
|
||||||
std::tie(foo_struct_type, foo_control_type) =
|
std::tie(foo_struct_type, foo_control_type) =
|
||||||
MakeUniformBufferTypes("foo_type", {{ty.i32, 0}});
|
MakeUniformBufferTypes("foo_type", {{ty.i32, 0}});
|
||||||
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
|
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
|
||||||
|
@ -1369,8 +1363,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) {
|
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) {
|
||||||
ast::type::Struct* foo_struct_type;
|
type::Struct* foo_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> foo_control_type;
|
std::unique_ptr<type::AccessControl> foo_control_type;
|
||||||
std::tie(foo_struct_type, foo_control_type) = MakeUniformBufferTypes(
|
std::tie(foo_struct_type, foo_control_type) = MakeUniformBufferTypes(
|
||||||
"foo_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
"foo_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
||||||
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
|
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
|
||||||
|
@ -1398,8 +1392,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
|
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
|
||||||
ast::type::Struct* ub_struct_type;
|
type::Struct* ub_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> ub_control_type;
|
std::unique_ptr<type::AccessControl> ub_control_type;
|
||||||
std::tie(ub_struct_type, ub_control_type) = MakeUniformBufferTypes(
|
std::tie(ub_struct_type, ub_control_type) = MakeUniformBufferTypes(
|
||||||
"ub_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
"ub_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
||||||
AddUniformBuffer("ub_foo", ub_control_type.get(), 0, 0);
|
AddUniformBuffer("ub_foo", ub_control_type.get(), 0, 0);
|
||||||
|
@ -1450,8 +1444,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) {
|
TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) {
|
||||||
ast::type::Struct* foo_struct_type;
|
type::Struct* foo_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> foo_control_type;
|
std::unique_ptr<type::AccessControl> foo_control_type;
|
||||||
std::tie(foo_struct_type, foo_control_type) =
|
std::tie(foo_struct_type, foo_control_type) =
|
||||||
MakeUniformBufferTypes("foo_type", {{ty.i32, 0}, {u32_array_type(4), 4}});
|
MakeUniformBufferTypes("foo_type", {{ty.i32, 0}, {u32_array_type(4), 4}});
|
||||||
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
|
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
|
||||||
|
@ -1479,8 +1473,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) {
|
TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) {
|
||||||
ast::type::Struct* foo_struct_type;
|
type::Struct* foo_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> foo_control_type;
|
std::unique_ptr<type::AccessControl> foo_control_type;
|
||||||
std::tie(foo_struct_type, foo_control_type) =
|
std::tie(foo_struct_type, foo_control_type) =
|
||||||
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}});
|
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}});
|
||||||
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
||||||
|
@ -1508,8 +1502,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) {
|
TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) {
|
||||||
ast::type::Struct* foo_struct_type;
|
type::Struct* foo_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> foo_control_type;
|
std::unique_ptr<type::AccessControl> foo_control_type;
|
||||||
std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes(
|
std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes(
|
||||||
"foo_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
"foo_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
||||||
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
||||||
|
@ -1537,8 +1531,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
|
TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
|
||||||
ast::type::Struct* sb_struct_type;
|
type::Struct* sb_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> sb_control_type;
|
std::unique_ptr<type::AccessControl> sb_control_type;
|
||||||
std::tie(sb_struct_type, sb_control_type) = MakeStorageBufferTypes(
|
std::tie(sb_struct_type, sb_control_type) = MakeStorageBufferTypes(
|
||||||
"sb_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
"sb_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
||||||
AddStorageBuffer("sb_foo", sb_control_type.get(), 0, 0);
|
AddStorageBuffer("sb_foo", sb_control_type.get(), 0, 0);
|
||||||
|
@ -1592,8 +1586,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) {
|
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) {
|
||||||
ast::type::Struct* foo_struct_type;
|
type::Struct* foo_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> foo_control_type;
|
std::unique_ptr<type::AccessControl> foo_control_type;
|
||||||
std::tie(foo_struct_type, foo_control_type) =
|
std::tie(foo_struct_type, foo_control_type) =
|
||||||
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}, {u32_array_type(4), 4}});
|
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}, {u32_array_type(4), 4}});
|
||||||
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
||||||
|
@ -1621,8 +1615,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) {
|
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) {
|
||||||
ast::type::Struct* foo_struct_type;
|
type::Struct* foo_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> foo_control_type;
|
std::unique_ptr<type::AccessControl> foo_control_type;
|
||||||
std::tie(foo_struct_type, foo_control_type) =
|
std::tie(foo_struct_type, foo_control_type) =
|
||||||
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}, {u32_array_type(0), 4}});
|
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}, {u32_array_type(0), 4}});
|
||||||
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
||||||
|
@ -1650,8 +1644,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) {
|
TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) {
|
||||||
ast::type::Struct* foo_struct_type;
|
type::Struct* foo_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> foo_control_type;
|
std::unique_ptr<type::AccessControl> foo_control_type;
|
||||||
std::tie(foo_struct_type, foo_control_type) =
|
std::tie(foo_struct_type, foo_control_type) =
|
||||||
MakeReadOnlyStorageBufferTypes("foo_type", {{ty.i32, 0}});
|
MakeReadOnlyStorageBufferTypes("foo_type", {{ty.i32, 0}});
|
||||||
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
||||||
|
@ -1675,8 +1669,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) {
|
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) {
|
||||||
ast::type::Struct* foo_struct_type;
|
type::Struct* foo_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> foo_control_type;
|
std::unique_ptr<type::AccessControl> foo_control_type;
|
||||||
std::tie(foo_struct_type, foo_control_type) =
|
std::tie(foo_struct_type, foo_control_type) =
|
||||||
MakeReadOnlyStorageBufferTypes("foo_type", {{ty.i32, 0}});
|
MakeReadOnlyStorageBufferTypes("foo_type", {{ty.i32, 0}});
|
||||||
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
||||||
|
@ -1706,8 +1700,8 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) {
|
||||||
|
|
||||||
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
|
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
|
||||||
MultipleStorageBuffers) {
|
MultipleStorageBuffers) {
|
||||||
ast::type::Struct* sb_struct_type;
|
type::Struct* sb_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> sb_control_type;
|
std::unique_ptr<type::AccessControl> sb_control_type;
|
||||||
std::tie(sb_struct_type, sb_control_type) = MakeReadOnlyStorageBufferTypes(
|
std::tie(sb_struct_type, sb_control_type) = MakeReadOnlyStorageBufferTypes(
|
||||||
"sb_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
"sb_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
||||||
AddStorageBuffer("sb_foo", sb_control_type.get(), 0, 0);
|
AddStorageBuffer("sb_foo", sb_control_type.get(), 0, 0);
|
||||||
|
@ -1762,8 +1756,8 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) {
|
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) {
|
||||||
ast::type::Struct* foo_struct_type;
|
type::Struct* foo_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> foo_control_type;
|
std::unique_ptr<type::AccessControl> foo_control_type;
|
||||||
std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes(
|
std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes(
|
||||||
"foo_type", {{ty.i32, 0}, {u32_array_type(4), 4}});
|
"foo_type", {{ty.i32, 0}, {u32_array_type(4), 4}});
|
||||||
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
||||||
|
@ -1793,8 +1787,8 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) {
|
||||||
|
|
||||||
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
|
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
|
||||||
ContainingRuntimeArray) {
|
ContainingRuntimeArray) {
|
||||||
ast::type::Struct* foo_struct_type;
|
type::Struct* foo_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> foo_control_type;
|
std::unique_ptr<type::AccessControl> foo_control_type;
|
||||||
std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes(
|
std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes(
|
||||||
"foo_type", {{ty.i32, 0}, {u32_array_type(0), 4}});
|
"foo_type", {{ty.i32, 0}, {u32_array_type(0), 4}});
|
||||||
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
||||||
|
@ -1823,8 +1817,8 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
|
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
|
||||||
ast::type::Struct* foo_struct_type;
|
type::Struct* foo_struct_type;
|
||||||
std::unique_ptr<ast::type::AccessControl> foo_control_type;
|
std::unique_ptr<type::AccessControl> foo_control_type;
|
||||||
std::tie(foo_struct_type, foo_control_type) =
|
std::tie(foo_struct_type, foo_control_type) =
|
||||||
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}});
|
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}});
|
||||||
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
|
||||||
|
@ -1850,7 +1844,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
|
||||||
|
|
||||||
TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) {
|
TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) {
|
||||||
auto sampled_texture_type =
|
auto sampled_texture_type =
|
||||||
MakeSampledTextureType(ast::type::TextureDimension::k1d, ty.f32);
|
MakeSampledTextureType(type::TextureDimension::k1d, ty.f32);
|
||||||
AddSampledTexture("foo_texture", sampled_texture_type.get(), 0, 0);
|
AddSampledTexture("foo_texture", sampled_texture_type.get(), 0, 0);
|
||||||
AddSampler("foo_sampler", 0, 1);
|
AddSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.f32);
|
AddGlobalVariable("foo_coords", ty.f32);
|
||||||
|
@ -1889,7 +1883,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, NoSampler) {
|
||||||
|
|
||||||
TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
||||||
auto sampled_texture_type =
|
auto sampled_texture_type =
|
||||||
MakeSampledTextureType(ast::type::TextureDimension::k1d, ty.f32);
|
MakeSampledTextureType(type::TextureDimension::k1d, ty.f32);
|
||||||
AddSampledTexture("foo_texture", sampled_texture_type.get(), 0, 0);
|
AddSampledTexture("foo_texture", sampled_texture_type.get(), 0, 0);
|
||||||
AddSampler("foo_sampler", 0, 1);
|
AddSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.f32);
|
AddGlobalVariable("foo_coords", ty.f32);
|
||||||
|
@ -1917,7 +1911,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
||||||
|
|
||||||
TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
|
TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||||
auto sampled_texture_type =
|
auto sampled_texture_type =
|
||||||
MakeSampledTextureType(ast::type::TextureDimension::k1d, ty.f32);
|
MakeSampledTextureType(type::TextureDimension::k1d, ty.f32);
|
||||||
AddSampledTexture("foo_texture", sampled_texture_type.get(), 0, 0);
|
AddSampledTexture("foo_texture", sampled_texture_type.get(), 0, 0);
|
||||||
AddSampler("foo_sampler", 0, 1);
|
AddSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.f32);
|
AddGlobalVariable("foo_coords", ty.f32);
|
||||||
|
@ -1936,8 +1930,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
|
TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
|
||||||
auto depth_texture_type =
|
auto depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
|
||||||
MakeDepthTextureType(ast::type::TextureDimension::k2d);
|
|
||||||
AddDepthTexture("foo_texture", depth_texture_type.get());
|
AddDepthTexture("foo_texture", depth_texture_type.get());
|
||||||
AddComparisonSampler("foo_sampler", 0, 1);
|
AddComparisonSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.f32);
|
AddGlobalVariable("foo_coords", ty.f32);
|
||||||
|
@ -1959,8 +1952,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) {
|
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) {
|
||||||
auto depth_texture_type =
|
auto depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
|
||||||
MakeDepthTextureType(ast::type::TextureDimension::k2d);
|
|
||||||
AddDepthTexture("foo_texture", depth_texture_type.get());
|
AddDepthTexture("foo_texture", depth_texture_type.get());
|
||||||
AddComparisonSampler("foo_sampler", 0, 1);
|
AddComparisonSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.f32);
|
AddGlobalVariable("foo_coords", ty.f32);
|
||||||
|
@ -1999,8 +1991,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, NoSampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
|
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
|
||||||
auto depth_texture_type =
|
auto depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
|
||||||
MakeDepthTextureType(ast::type::TextureDimension::k2d);
|
|
||||||
AddDepthTexture("foo_texture", depth_texture_type.get());
|
AddDepthTexture("foo_texture", depth_texture_type.get());
|
||||||
AddComparisonSampler("foo_sampler", 0, 1);
|
AddComparisonSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.f32);
|
AddGlobalVariable("foo_coords", ty.f32);
|
||||||
|
@ -2029,8 +2020,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
|
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||||
auto depth_texture_type =
|
auto depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
|
||||||
MakeDepthTextureType(ast::type::TextureDimension::k2d);
|
|
||||||
AddDepthTexture("foo_texture", depth_texture_type.get());
|
AddDepthTexture("foo_texture", depth_texture_type.get());
|
||||||
AddComparisonSampler("foo_sampler", 0, 1);
|
AddComparisonSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.f32);
|
AddGlobalVariable("foo_coords", ty.f32);
|
||||||
|
@ -2051,7 +2041,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||||
|
|
||||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) {
|
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) {
|
||||||
auto sampled_texture_type =
|
auto sampled_texture_type =
|
||||||
MakeSampledTextureType(ast::type::TextureDimension::k1d, ty.f32);
|
MakeSampledTextureType(type::TextureDimension::k1d, ty.f32);
|
||||||
AddSampledTexture("foo_texture", sampled_texture_type.get(), 0, 0);
|
AddSampledTexture("foo_texture", sampled_texture_type.get(), 0, 0);
|
||||||
AddSampler("foo_sampler", 0, 1);
|
AddSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.f32);
|
AddGlobalVariable("foo_coords", ty.f32);
|
||||||
|
@ -2125,51 +2115,51 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
InspectorGetSampledTextureResourceBindingsTestWithParam,
|
InspectorGetSampledTextureResourceBindingsTestWithParam,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k1d,
|
type::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::TextureDimension::k1d,
|
inspector::ResourceBinding::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k1d,
|
type::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::TextureDimension::k1d,
|
inspector::ResourceBinding::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::SampledKind::kSInt},
|
inspector::ResourceBinding::SampledKind::kSInt},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k1d,
|
type::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::TextureDimension::k1d,
|
inspector::ResourceBinding::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::SampledKind::kUInt},
|
inspector::ResourceBinding::SampledKind::kUInt},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::TextureDimension::k2d,
|
inspector::ResourceBinding::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::TextureDimension::k2d,
|
inspector::ResourceBinding::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::SampledKind::kSInt},
|
inspector::ResourceBinding::SampledKind::kSInt},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::TextureDimension::k2d,
|
inspector::ResourceBinding::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::SampledKind::kUInt},
|
inspector::ResourceBinding::SampledKind::kUInt},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k3d,
|
type::TextureDimension::k3d,
|
||||||
inspector::ResourceBinding::TextureDimension::k3d,
|
inspector::ResourceBinding::TextureDimension::k3d,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k3d,
|
type::TextureDimension::k3d,
|
||||||
inspector::ResourceBinding::TextureDimension::k3d,
|
inspector::ResourceBinding::TextureDimension::k3d,
|
||||||
inspector::ResourceBinding::SampledKind::kSInt},
|
inspector::ResourceBinding::SampledKind::kSInt},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k3d,
|
type::TextureDimension::k3d,
|
||||||
inspector::ResourceBinding::TextureDimension::k3d,
|
inspector::ResourceBinding::TextureDimension::k3d,
|
||||||
inspector::ResourceBinding::SampledKind::kUInt},
|
inspector::ResourceBinding::SampledKind::kUInt},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::kCube,
|
type::TextureDimension::kCube,
|
||||||
inspector::ResourceBinding::TextureDimension::kCube,
|
inspector::ResourceBinding::TextureDimension::kCube,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::kCube,
|
type::TextureDimension::kCube,
|
||||||
inspector::ResourceBinding::TextureDimension::kCube,
|
inspector::ResourceBinding::TextureDimension::kCube,
|
||||||
inspector::ResourceBinding::SampledKind::kSInt},
|
inspector::ResourceBinding::SampledKind::kSInt},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::kCube,
|
type::TextureDimension::kCube,
|
||||||
inspector::ResourceBinding::TextureDimension::kCube,
|
inspector::ResourceBinding::TextureDimension::kCube,
|
||||||
inspector::ResourceBinding::SampledKind::kUInt}));
|
inspector::ResourceBinding::SampledKind::kUInt}));
|
||||||
|
|
||||||
|
@ -2209,39 +2199,39 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
InspectorGetSampledArrayTextureResourceBindingsTestWithParam,
|
InspectorGetSampledArrayTextureResourceBindingsTestWithParam,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k1dArray,
|
type::TextureDimension::k1dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k1dArray,
|
inspector::ResourceBinding::TextureDimension::k1dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k1dArray,
|
type::TextureDimension::k1dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k1dArray,
|
inspector::ResourceBinding::TextureDimension::k1dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kSInt},
|
inspector::ResourceBinding::SampledKind::kSInt},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k1dArray,
|
type::TextureDimension::k1dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k1dArray,
|
inspector::ResourceBinding::TextureDimension::k1dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kUInt},
|
inspector::ResourceBinding::SampledKind::kUInt},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k2dArray,
|
type::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k2dArray,
|
inspector::ResourceBinding::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k2dArray,
|
type::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k2dArray,
|
inspector::ResourceBinding::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kSInt},
|
inspector::ResourceBinding::SampledKind::kSInt},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k2dArray,
|
type::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k2dArray,
|
inspector::ResourceBinding::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kUInt},
|
inspector::ResourceBinding::SampledKind::kUInt},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::kCubeArray,
|
type::TextureDimension::kCubeArray,
|
||||||
inspector::ResourceBinding::TextureDimension::kCubeArray,
|
inspector::ResourceBinding::TextureDimension::kCubeArray,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::kCubeArray,
|
type::TextureDimension::kCubeArray,
|
||||||
inspector::ResourceBinding::TextureDimension::kCubeArray,
|
inspector::ResourceBinding::TextureDimension::kCubeArray,
|
||||||
inspector::ResourceBinding::SampledKind::kSInt},
|
inspector::ResourceBinding::SampledKind::kSInt},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
ast::type::TextureDimension::kCubeArray,
|
type::TextureDimension::kCubeArray,
|
||||||
inspector::ResourceBinding::TextureDimension::kCubeArray,
|
inspector::ResourceBinding::TextureDimension::kCubeArray,
|
||||||
inspector::ResourceBinding::SampledKind::kUInt}));
|
inspector::ResourceBinding::SampledKind::kUInt}));
|
||||||
|
|
||||||
|
@ -2287,27 +2277,27 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
InspectorGetMultisampledTextureResourceBindingsTestWithParam,
|
InspectorGetMultisampledTextureResourceBindingsTestWithParam,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k1d,
|
type::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::TextureDimension::k1d,
|
inspector::ResourceBinding::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k1d,
|
type::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::TextureDimension::k1d,
|
inspector::ResourceBinding::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::SampledKind::kSInt},
|
inspector::ResourceBinding::SampledKind::kSInt},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k1d,
|
type::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::TextureDimension::k1d,
|
inspector::ResourceBinding::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::SampledKind::kUInt},
|
inspector::ResourceBinding::SampledKind::kUInt},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::TextureDimension::k2d,
|
inspector::ResourceBinding::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::TextureDimension::k2d,
|
inspector::ResourceBinding::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::SampledKind::kSInt},
|
inspector::ResourceBinding::SampledKind::kSInt},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k2d,
|
type::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::TextureDimension::k2d,
|
inspector::ResourceBinding::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::SampledKind::kUInt}));
|
inspector::ResourceBinding::SampledKind::kUInt}));
|
||||||
|
|
||||||
|
@ -2360,27 +2350,27 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
InspectorGetMultisampledArrayTextureResourceBindingsTestWithParam,
|
InspectorGetMultisampledArrayTextureResourceBindingsTestWithParam,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k1dArray,
|
type::TextureDimension::k1dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k1dArray,
|
inspector::ResourceBinding::TextureDimension::k1dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k1dArray,
|
type::TextureDimension::k1dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k1dArray,
|
inspector::ResourceBinding::TextureDimension::k1dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kSInt},
|
inspector::ResourceBinding::SampledKind::kSInt},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k1dArray,
|
type::TextureDimension::k1dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k1dArray,
|
inspector::ResourceBinding::TextureDimension::k1dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kUInt},
|
inspector::ResourceBinding::SampledKind::kUInt},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k2dArray,
|
type::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k2dArray,
|
inspector::ResourceBinding::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k2dArray,
|
type::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k2dArray,
|
inspector::ResourceBinding::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kSInt},
|
inspector::ResourceBinding::SampledKind::kSInt},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
ast::type::TextureDimension::k2dArray,
|
type::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k2dArray,
|
inspector::ResourceBinding::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kUInt}));
|
inspector::ResourceBinding::SampledKind::kUInt}));
|
||||||
|
|
||||||
|
|
|
@ -94,85 +94,85 @@ ast::Builtin EnumConverter::ToBuiltin(SpvBuiltIn b) {
|
||||||
return ast::Builtin::kNone;
|
return ast::Builtin::kNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
|
type::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
|
||||||
if (arrayed) {
|
if (arrayed) {
|
||||||
switch (dim) {
|
switch (dim) {
|
||||||
case SpvDim1D:
|
case SpvDim1D:
|
||||||
return ast::type::TextureDimension::k1dArray;
|
return type::TextureDimension::k1dArray;
|
||||||
case SpvDim2D:
|
case SpvDim2D:
|
||||||
return ast::type::TextureDimension::k2dArray;
|
return type::TextureDimension::k2dArray;
|
||||||
case SpvDimCube:
|
case SpvDimCube:
|
||||||
return ast::type::TextureDimension::kCubeArray;
|
return type::TextureDimension::kCubeArray;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Fail() << "arrayed dimension must be 1D, 2D, or Cube. Got " << int(dim);
|
Fail() << "arrayed dimension must be 1D, 2D, or Cube. Got " << int(dim);
|
||||||
return ast::type::TextureDimension::kNone;
|
return type::TextureDimension::kNone;
|
||||||
}
|
}
|
||||||
// Assume non-arrayed
|
// Assume non-arrayed
|
||||||
switch (dim) {
|
switch (dim) {
|
||||||
case SpvDim1D:
|
case SpvDim1D:
|
||||||
return ast::type::TextureDimension::k1d;
|
return type::TextureDimension::k1d;
|
||||||
case SpvDim2D:
|
case SpvDim2D:
|
||||||
return ast::type::TextureDimension::k2d;
|
return type::TextureDimension::k2d;
|
||||||
case SpvDim3D:
|
case SpvDim3D:
|
||||||
return ast::type::TextureDimension::k3d;
|
return type::TextureDimension::k3d;
|
||||||
case SpvDimCube:
|
case SpvDimCube:
|
||||||
return ast::type::TextureDimension::kCube;
|
return type::TextureDimension::kCube;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Fail() << "invalid dimension: " << int(dim);
|
Fail() << "invalid dimension: " << int(dim);
|
||||||
return ast::type::TextureDimension::kNone;
|
return type::TextureDimension::kNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::ImageFormat EnumConverter::ToImageFormat(SpvImageFormat fmt) {
|
type::ImageFormat EnumConverter::ToImageFormat(SpvImageFormat fmt) {
|
||||||
switch (fmt) {
|
switch (fmt) {
|
||||||
case SpvImageFormatUnknown:
|
case SpvImageFormatUnknown:
|
||||||
return ast::type::ImageFormat::kNone;
|
return type::ImageFormat::kNone;
|
||||||
|
|
||||||
// 8 bit channels
|
// 8 bit channels
|
||||||
case SpvImageFormatRgba8:
|
case SpvImageFormatRgba8:
|
||||||
return ast::type::ImageFormat::kRgba8Unorm;
|
return type::ImageFormat::kRgba8Unorm;
|
||||||
case SpvImageFormatRgba8Snorm:
|
case SpvImageFormatRgba8Snorm:
|
||||||
return ast::type::ImageFormat::kRgba8Snorm;
|
return type::ImageFormat::kRgba8Snorm;
|
||||||
case SpvImageFormatRgba8ui:
|
case SpvImageFormatRgba8ui:
|
||||||
return ast::type::ImageFormat::kRgba8Uint;
|
return type::ImageFormat::kRgba8Uint;
|
||||||
case SpvImageFormatRgba8i:
|
case SpvImageFormatRgba8i:
|
||||||
return ast::type::ImageFormat::kRgba8Sint;
|
return type::ImageFormat::kRgba8Sint;
|
||||||
|
|
||||||
// 16 bit channels
|
// 16 bit channels
|
||||||
case SpvImageFormatRgba16ui:
|
case SpvImageFormatRgba16ui:
|
||||||
return ast::type::ImageFormat::kRgba16Uint;
|
return type::ImageFormat::kRgba16Uint;
|
||||||
case SpvImageFormatRgba16i:
|
case SpvImageFormatRgba16i:
|
||||||
return ast::type::ImageFormat::kRgba16Sint;
|
return type::ImageFormat::kRgba16Sint;
|
||||||
case SpvImageFormatRgba16f:
|
case SpvImageFormatRgba16f:
|
||||||
return ast::type::ImageFormat::kRgba16Float;
|
return type::ImageFormat::kRgba16Float;
|
||||||
|
|
||||||
// 32 bit channels
|
// 32 bit channels
|
||||||
case SpvImageFormatR32ui:
|
case SpvImageFormatR32ui:
|
||||||
return ast::type::ImageFormat::kR32Uint;
|
return type::ImageFormat::kR32Uint;
|
||||||
case SpvImageFormatR32i:
|
case SpvImageFormatR32i:
|
||||||
return ast::type::ImageFormat::kR32Sint;
|
return type::ImageFormat::kR32Sint;
|
||||||
case SpvImageFormatR32f:
|
case SpvImageFormatR32f:
|
||||||
return ast::type::ImageFormat::kR32Float;
|
return type::ImageFormat::kR32Float;
|
||||||
case SpvImageFormatRg32ui:
|
case SpvImageFormatRg32ui:
|
||||||
return ast::type::ImageFormat::kRg32Uint;
|
return type::ImageFormat::kRg32Uint;
|
||||||
case SpvImageFormatRg32i:
|
case SpvImageFormatRg32i:
|
||||||
return ast::type::ImageFormat::kRg32Sint;
|
return type::ImageFormat::kRg32Sint;
|
||||||
case SpvImageFormatRg32f:
|
case SpvImageFormatRg32f:
|
||||||
return ast::type::ImageFormat::kRg32Float;
|
return type::ImageFormat::kRg32Float;
|
||||||
case SpvImageFormatRgba32ui:
|
case SpvImageFormatRgba32ui:
|
||||||
return ast::type::ImageFormat::kRgba32Uint;
|
return type::ImageFormat::kRgba32Uint;
|
||||||
case SpvImageFormatRgba32i:
|
case SpvImageFormatRgba32i:
|
||||||
return ast::type::ImageFormat::kRgba32Sint;
|
return type::ImageFormat::kRgba32Sint;
|
||||||
case SpvImageFormatRgba32f:
|
case SpvImageFormatRgba32f:
|
||||||
return ast::type::ImageFormat::kRgba32Float;
|
return type::ImageFormat::kRgba32Float;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Fail() << "invalid image format: " << int(fmt);
|
Fail() << "invalid image format: " << int(fmt);
|
||||||
return ast::type::ImageFormat::kNone;
|
return type::ImageFormat::kNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace spirv
|
} // namespace spirv
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
#include "src/ast/builtin.h"
|
#include "src/ast/builtin.h"
|
||||||
#include "src/ast/pipeline_stage.h"
|
#include "src/ast/pipeline_stage.h"
|
||||||
#include "src/ast/storage_class.h"
|
#include "src/ast/storage_class.h"
|
||||||
#include "src/ast/type/storage_texture_type.h"
|
#include "src/type/storage_texture_type.h"
|
||||||
#include "src/ast/type/texture_type.h"
|
#include "src/type/texture_type.h"
|
||||||
#include "src/reader/spirv/fail_stream.h"
|
#include "src/reader/spirv/fail_stream.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -59,13 +59,13 @@ class EnumConverter {
|
||||||
/// @param dim the SPIR-V Dim value
|
/// @param dim the SPIR-V Dim value
|
||||||
/// @param arrayed true if the texture is arrayed
|
/// @param arrayed true if the texture is arrayed
|
||||||
/// @returns a Tint AST texture dimension
|
/// @returns a Tint AST texture dimension
|
||||||
ast::type::TextureDimension ToDim(SpvDim dim, bool arrayed);
|
type::TextureDimension ToDim(SpvDim dim, bool arrayed);
|
||||||
|
|
||||||
/// Converts a SPIR-V Image Format to a Tint ImageFormat
|
/// Converts a SPIR-V Image Format to a Tint ImageFormat
|
||||||
/// On failure, logs an error and returns kNone
|
/// On failure, logs an error and returns kNone
|
||||||
/// @param fmt the SPIR-V format
|
/// @param fmt the SPIR-V format
|
||||||
/// @returns a Tint AST format
|
/// @returns a Tint AST format
|
||||||
ast::type::ImageFormat ToImageFormat(SpvImageFormat fmt);
|
type::ImageFormat ToImageFormat(SpvImageFormat fmt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Registers a failure and returns a stream for log diagnostics.
|
/// Registers a failure and returns a stream for log diagnostics.
|
||||||
|
|
|
@ -236,7 +236,7 @@ struct DimCase {
|
||||||
SpvDim dim;
|
SpvDim dim;
|
||||||
bool arrayed;
|
bool arrayed;
|
||||||
bool expect_success;
|
bool expect_success;
|
||||||
ast::type::TextureDimension expected;
|
type::TextureDimension expected;
|
||||||
};
|
};
|
||||||
inline std::ostream& operator<<(std::ostream& out, DimCase dc) {
|
inline std::ostream& operator<<(std::ostream& out, DimCase dc) {
|
||||||
out << "DimCase{ SpvDim:" << int(dc.dim) << " arrayed?:" << int(dc.arrayed)
|
out << "DimCase{ SpvDim:" << int(dc.dim) << " arrayed?:" << int(dc.arrayed)
|
||||||
|
@ -280,41 +280,39 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
SpvDimTest,
|
SpvDimTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
// Non-arrayed
|
// Non-arrayed
|
||||||
DimCase{SpvDim1D, false, true, ast::type::TextureDimension::k1d},
|
DimCase{SpvDim1D, false, true, type::TextureDimension::k1d},
|
||||||
DimCase{SpvDim2D, false, true, ast::type::TextureDimension::k2d},
|
DimCase{SpvDim2D, false, true, type::TextureDimension::k2d},
|
||||||
DimCase{SpvDim3D, false, true, ast::type::TextureDimension::k3d},
|
DimCase{SpvDim3D, false, true, type::TextureDimension::k3d},
|
||||||
DimCase{SpvDimCube, false, true, ast::type::TextureDimension::kCube},
|
DimCase{SpvDimCube, false, true, type::TextureDimension::kCube},
|
||||||
// Arrayed
|
// Arrayed
|
||||||
DimCase{SpvDim1D, true, true, ast::type::TextureDimension::k1dArray},
|
DimCase{SpvDim1D, true, true, type::TextureDimension::k1dArray},
|
||||||
DimCase{SpvDim2D, true, true, ast::type::TextureDimension::k2dArray},
|
DimCase{SpvDim2D, true, true, type::TextureDimension::k2dArray},
|
||||||
DimCase{SpvDimCube, true, true,
|
DimCase{SpvDimCube, true, true, type::TextureDimension::kCubeArray}));
|
||||||
ast::type::TextureDimension::kCubeArray}));
|
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
EnumConverterBad,
|
EnumConverterBad,
|
||||||
SpvDimTest,
|
SpvDimTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
// Invalid SPIR-V dimensionality.
|
// Invalid SPIR-V dimensionality.
|
||||||
DimCase{SpvDimMax, false, false, ast::type::TextureDimension::kNone},
|
DimCase{SpvDimMax, false, false, type::TextureDimension::kNone},
|
||||||
DimCase{SpvDimMax, true, false, ast::type::TextureDimension::kNone},
|
DimCase{SpvDimMax, true, false, type::TextureDimension::kNone},
|
||||||
// Vulkan non-arrayed dimensionalities not supported by WGSL.
|
// Vulkan non-arrayed dimensionalities not supported by WGSL.
|
||||||
DimCase{SpvDimRect, false, false, ast::type::TextureDimension::kNone},
|
DimCase{SpvDimRect, false, false, type::TextureDimension::kNone},
|
||||||
DimCase{SpvDimBuffer, false, false, ast::type::TextureDimension::kNone},
|
DimCase{SpvDimBuffer, false, false, type::TextureDimension::kNone},
|
||||||
DimCase{SpvDimSubpassData, false, false,
|
DimCase{SpvDimSubpassData, false, false, type::TextureDimension::kNone},
|
||||||
ast::type::TextureDimension::kNone},
|
|
||||||
// Arrayed dimensionalities not supported by WGSL
|
// Arrayed dimensionalities not supported by WGSL
|
||||||
DimCase{SpvDim3D, true, false, ast::type::TextureDimension::kNone},
|
DimCase{SpvDim3D, true, false, type::TextureDimension::kNone},
|
||||||
DimCase{SpvDimRect, true, false, ast::type::TextureDimension::kNone},
|
DimCase{SpvDimRect, true, false, type::TextureDimension::kNone},
|
||||||
DimCase{SpvDimBuffer, true, false, ast::type::TextureDimension::kNone},
|
DimCase{SpvDimBuffer, true, false, type::TextureDimension::kNone},
|
||||||
DimCase{SpvDimSubpassData, true, false,
|
DimCase{SpvDimSubpassData, true, false,
|
||||||
ast::type::TextureDimension::kNone}));
|
type::TextureDimension::kNone}));
|
||||||
|
|
||||||
// ImageFormat
|
// ImageFormat
|
||||||
|
|
||||||
struct ImageFormatCase {
|
struct ImageFormatCase {
|
||||||
SpvImageFormat format;
|
SpvImageFormat format;
|
||||||
bool expect_success;
|
bool expect_success;
|
||||||
ast::type::ImageFormat expected;
|
type::ImageFormat expected;
|
||||||
};
|
};
|
||||||
inline std::ostream& operator<<(std::ostream& out, ImageFormatCase ifc) {
|
inline std::ostream& operator<<(std::ostream& out, ImageFormatCase ifc) {
|
||||||
out << "ImageFormatCase{ SpvImageFormat:" << int(ifc.format)
|
out << "ImageFormatCase{ SpvImageFormat:" << int(ifc.format)
|
||||||
|
@ -358,85 +356,70 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
SpvImageFormatTest,
|
SpvImageFormatTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
// Unknown. This is used for sampled images.
|
// Unknown. This is used for sampled images.
|
||||||
ImageFormatCase{SpvImageFormatUnknown, true,
|
ImageFormatCase{SpvImageFormatUnknown, true, type::ImageFormat::kNone},
|
||||||
ast::type::ImageFormat::kNone},
|
|
||||||
// 8 bit channels
|
// 8 bit channels
|
||||||
ImageFormatCase{SpvImageFormatRgba8, true,
|
ImageFormatCase{SpvImageFormatRgba8, true,
|
||||||
ast::type::ImageFormat::kRgba8Unorm},
|
type::ImageFormat::kRgba8Unorm},
|
||||||
ImageFormatCase{SpvImageFormatRgba8Snorm, true,
|
ImageFormatCase{SpvImageFormatRgba8Snorm, true,
|
||||||
ast::type::ImageFormat::kRgba8Snorm},
|
type::ImageFormat::kRgba8Snorm},
|
||||||
ImageFormatCase{SpvImageFormatRgba8ui, true,
|
ImageFormatCase{SpvImageFormatRgba8ui, true,
|
||||||
ast::type::ImageFormat::kRgba8Uint},
|
type::ImageFormat::kRgba8Uint},
|
||||||
ImageFormatCase{SpvImageFormatRgba8i, true,
|
ImageFormatCase{SpvImageFormatRgba8i, true,
|
||||||
ast::type::ImageFormat::kRgba8Sint},
|
type::ImageFormat::kRgba8Sint},
|
||||||
// 16 bit channels
|
// 16 bit channels
|
||||||
ImageFormatCase{SpvImageFormatRgba16ui, true,
|
ImageFormatCase{SpvImageFormatRgba16ui, true,
|
||||||
ast::type::ImageFormat::kRgba16Uint},
|
type::ImageFormat::kRgba16Uint},
|
||||||
ImageFormatCase{SpvImageFormatRgba16i, true,
|
ImageFormatCase{SpvImageFormatRgba16i, true,
|
||||||
ast::type::ImageFormat::kRgba16Sint},
|
type::ImageFormat::kRgba16Sint},
|
||||||
ImageFormatCase{SpvImageFormatRgba16f, true,
|
ImageFormatCase{SpvImageFormatRgba16f, true,
|
||||||
ast::type::ImageFormat::kRgba16Float},
|
type::ImageFormat::kRgba16Float},
|
||||||
// 32 bit channels
|
// 32 bit channels
|
||||||
// ... 1 channel
|
// ... 1 channel
|
||||||
ImageFormatCase{SpvImageFormatR32ui, true,
|
ImageFormatCase{SpvImageFormatR32ui, true, type::ImageFormat::kR32Uint},
|
||||||
ast::type::ImageFormat::kR32Uint},
|
ImageFormatCase{SpvImageFormatR32i, true, type::ImageFormat::kR32Sint},
|
||||||
ImageFormatCase{SpvImageFormatR32i, true,
|
ImageFormatCase{SpvImageFormatR32f, true, type::ImageFormat::kR32Float},
|
||||||
ast::type::ImageFormat::kR32Sint},
|
|
||||||
ImageFormatCase{SpvImageFormatR32f, true,
|
|
||||||
ast::type::ImageFormat::kR32Float},
|
|
||||||
// ... 2 channels
|
// ... 2 channels
|
||||||
ImageFormatCase{SpvImageFormatRg32ui, true,
|
ImageFormatCase{SpvImageFormatRg32ui, true,
|
||||||
ast::type::ImageFormat::kRg32Uint},
|
type::ImageFormat::kRg32Uint},
|
||||||
ImageFormatCase{SpvImageFormatRg32i, true,
|
ImageFormatCase{SpvImageFormatRg32i, true,
|
||||||
ast::type::ImageFormat::kRg32Sint},
|
type::ImageFormat::kRg32Sint},
|
||||||
ImageFormatCase{SpvImageFormatRg32f, true,
|
ImageFormatCase{SpvImageFormatRg32f, true,
|
||||||
ast::type::ImageFormat::kRg32Float},
|
type::ImageFormat::kRg32Float},
|
||||||
// ... 4 channels
|
// ... 4 channels
|
||||||
ImageFormatCase{SpvImageFormatRgba32ui, true,
|
ImageFormatCase{SpvImageFormatRgba32ui, true,
|
||||||
ast::type::ImageFormat::kRgba32Uint},
|
type::ImageFormat::kRgba32Uint},
|
||||||
ImageFormatCase{SpvImageFormatRgba32i, true,
|
ImageFormatCase{SpvImageFormatRgba32i, true,
|
||||||
ast::type::ImageFormat::kRgba32Sint},
|
type::ImageFormat::kRgba32Sint},
|
||||||
ImageFormatCase{SpvImageFormatRgba32f, true,
|
ImageFormatCase{SpvImageFormatRgba32f, true,
|
||||||
ast::type::ImageFormat::kRgba32Float}));
|
type::ImageFormat::kRgba32Float}));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(EnumConverterBad,
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
SpvImageFormatTest,
|
EnumConverterBad,
|
||||||
testing::Values(
|
SpvImageFormatTest,
|
||||||
// Scanning in order from the SPIR-V spec.
|
testing::Values(
|
||||||
ImageFormatCase{SpvImageFormatRg16f, false,
|
// Scanning in order from the SPIR-V spec.
|
||||||
ast::type::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRg16f, false, type::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatR11fG11fB10f, false,
|
ImageFormatCase{SpvImageFormatR11fG11fB10f, false,
|
||||||
ast::type::ImageFormat::kNone},
|
type::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatR16f, false,
|
ImageFormatCase{SpvImageFormatR16f, false, type::ImageFormat::kNone},
|
||||||
ast::type::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRgb10A2, false, type::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRgb10A2, false,
|
ImageFormatCase{SpvImageFormatRg16, false, type::ImageFormat::kNone},
|
||||||
ast::type::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRg8, false, type::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRg16, false,
|
ImageFormatCase{SpvImageFormatR16, false, type::ImageFormat::kNone},
|
||||||
ast::type::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatR8, false, type::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRg8, false,
|
ImageFormatCase{SpvImageFormatRgba16Snorm, false,
|
||||||
ast::type::ImageFormat::kNone},
|
type::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatR16, false,
|
ImageFormatCase{SpvImageFormatRg16Snorm, false,
|
||||||
ast::type::ImageFormat::kNone},
|
type::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatR8, false,
|
ImageFormatCase{SpvImageFormatRg8Snorm, false,
|
||||||
ast::type::ImageFormat::kNone},
|
type::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRgba16Snorm, false,
|
ImageFormatCase{SpvImageFormatRg16i, false, type::ImageFormat::kNone},
|
||||||
ast::type::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRg8i, false, type::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRg16Snorm, false,
|
ImageFormatCase{SpvImageFormatR8i, false, type::ImageFormat::kNone},
|
||||||
ast::type::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRgb10a2ui, false,
|
||||||
ImageFormatCase{SpvImageFormatRg8Snorm, false,
|
type::ImageFormat::kNone},
|
||||||
ast::type::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRg16ui, false, type::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRg16i, false,
|
ImageFormatCase{SpvImageFormatRg8ui, false, type::ImageFormat::kNone}));
|
||||||
ast::type::ImageFormat::kNone},
|
|
||||||
ImageFormatCase{SpvImageFormatRg8i, false,
|
|
||||||
ast::type::ImageFormat::kNone},
|
|
||||||
ImageFormatCase{SpvImageFormatR8i, false,
|
|
||||||
ast::type::ImageFormat::kNone},
|
|
||||||
ImageFormatCase{SpvImageFormatRgb10a2ui, false,
|
|
||||||
ast::type::ImageFormat::kNone},
|
|
||||||
ImageFormatCase{SpvImageFormatRg16ui, false,
|
|
||||||
ast::type::ImageFormat::kNone},
|
|
||||||
ImageFormatCase{SpvImageFormatRg8ui, false,
|
|
||||||
ast::type::ImageFormat::kNone}));
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace spirv
|
} // namespace spirv
|
||||||
|
|
|
@ -53,18 +53,6 @@
|
||||||
#include "src/ast/stage_decoration.h"
|
#include "src/ast/stage_decoration.h"
|
||||||
#include "src/ast/storage_class.h"
|
#include "src/ast/storage_class.h"
|
||||||
#include "src/ast/switch_statement.h"
|
#include "src/ast/switch_statement.h"
|
||||||
#include "src/ast/type/bool_type.h"
|
|
||||||
#include "src/ast/type/depth_texture_type.h"
|
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/matrix_type.h"
|
|
||||||
#include "src/ast/type/pointer_type.h"
|
|
||||||
#include "src/ast/type/storage_texture_type.h"
|
|
||||||
#include "src/ast/type/texture_type.h"
|
|
||||||
#include "src/ast/type/type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/type/vector_type.h"
|
|
||||||
#include "src/ast/type/void_type.h"
|
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
#include "src/ast/unary_op.h"
|
#include "src/ast/unary_op.h"
|
||||||
|
@ -74,6 +62,18 @@
|
||||||
#include "src/reader/spirv/construct.h"
|
#include "src/reader/spirv/construct.h"
|
||||||
#include "src/reader/spirv/fail_stream.h"
|
#include "src/reader/spirv/fail_stream.h"
|
||||||
#include "src/reader/spirv/parser_impl.h"
|
#include "src/reader/spirv/parser_impl.h"
|
||||||
|
#include "src/type/bool_type.h"
|
||||||
|
#include "src/type/depth_texture_type.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/matrix_type.h"
|
||||||
|
#include "src/type/pointer_type.h"
|
||||||
|
#include "src/type/storage_texture_type.h"
|
||||||
|
#include "src/type/texture_type.h"
|
||||||
|
#include "src/type/type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
#include "src/type/void_type.h"
|
||||||
|
|
||||||
// Terms:
|
// Terms:
|
||||||
// CFG: the control flow graph of the function, where basic blocks are the
|
// CFG: the control flow graph of the function, where basic blocks are the
|
||||||
|
@ -725,7 +725,7 @@ FunctionEmitter::FunctionEmitter(ParserImpl* pi,
|
||||||
fail_stream_(pi->fail_stream()),
|
fail_stream_(pi->fail_stream()),
|
||||||
namer_(pi->namer()),
|
namer_(pi->namer()),
|
||||||
function_(function),
|
function_(function),
|
||||||
i32_(ast_module_.create<ast::type::I32>()),
|
i32_(ast_module_.create<type::I32>()),
|
||||||
ep_info_(ep_info) {
|
ep_info_(ep_info) {
|
||||||
PushNewStatementBlock(nullptr, 0, nullptr);
|
PushNewStatementBlock(nullptr, 0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -929,7 +929,7 @@ bool FunctionEmitter::ParseFunctionDeclaration(FunctionDeclaration* decl) {
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* FunctionEmitter::GetVariableStoreType(
|
type::Type* FunctionEmitter::GetVariableStoreType(
|
||||||
const spvtools::opt::Instruction& var_decl_inst) {
|
const spvtools::opt::Instruction& var_decl_inst) {
|
||||||
const auto type_id = var_decl_inst.type_id();
|
const auto type_id = var_decl_inst.type_id();
|
||||||
auto* var_ref_type = type_mgr_->GetType(type_id);
|
auto* var_ref_type = type_mgr_->GetType(type_id);
|
||||||
|
@ -1998,7 +1998,7 @@ TypedExpression FunctionEmitter::MakeExpression(uint32_t id) {
|
||||||
<< id;
|
<< id;
|
||||||
return {};
|
return {};
|
||||||
case SkipReason::kPointSizeBuiltinValue: {
|
case SkipReason::kPointSizeBuiltinValue: {
|
||||||
auto* f32 = create<ast::type::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
return {f32,
|
return {f32,
|
||||||
create<ast::ScalarConstructorExpression>(
|
create<ast::ScalarConstructorExpression>(
|
||||||
Source{}, create<ast::FloatLiteral>(Source{}, f32, 1.0f))};
|
Source{}, create<ast::FloatLiteral>(Source{}, f32, 1.0f))};
|
||||||
|
@ -2985,8 +2985,8 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) {
|
||||||
}
|
}
|
||||||
auto expr = MakeExpression(ptr_id);
|
auto expr = MakeExpression(ptr_id);
|
||||||
// The load result type is the pointee type of its operand.
|
// The load result type is the pointee type of its operand.
|
||||||
assert(expr.type->Is<ast::type::Pointer>());
|
assert(expr.type->Is<type::Pointer>());
|
||||||
expr.type = expr.type->As<ast::type::Pointer>()->type();
|
expr.type = expr.type->As<type::Pointer>()->type();
|
||||||
return EmitConstDefOrWriteToHoistedVar(inst, expr);
|
return EmitConstDefOrWriteToHoistedVar(inst, expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3043,7 +3043,7 @@ TypedExpression FunctionEmitter::MaybeEmitCombinatorialValue(
|
||||||
|
|
||||||
const auto opcode = inst.opcode();
|
const auto opcode = inst.opcode();
|
||||||
|
|
||||||
ast::type::Type* ast_type =
|
type::Type* ast_type =
|
||||||
inst.type_id() != 0 ? parser_impl_.ConvertType(inst.type_id()) : nullptr;
|
inst.type_id() != 0 ? parser_impl_.ConvertType(inst.type_id()) : nullptr;
|
||||||
|
|
||||||
auto binary_op = ConvertBinaryOp(opcode);
|
auto binary_op = ConvertBinaryOp(opcode);
|
||||||
|
@ -3181,7 +3181,7 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst(
|
||||||
auto* func = create<ast::IdentifierExpression>(
|
auto* func = create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(name));
|
Source{}, ast_module_.RegisterSymbol(name));
|
||||||
ast::ExpressionList operands;
|
ast::ExpressionList operands;
|
||||||
ast::type::Type* first_operand_type = nullptr;
|
type::Type* first_operand_type = nullptr;
|
||||||
// All parameters to GLSL.std.450 extended instructions are IDs.
|
// All parameters to GLSL.std.450 extended instructions are IDs.
|
||||||
for (uint32_t iarg = 2; iarg < inst.NumInOperands(); ++iarg) {
|
for (uint32_t iarg = 2; iarg < inst.NumInOperands(); ++iarg) {
|
||||||
TypedExpression operand = MakeOperand(inst, iarg);
|
TypedExpression operand = MakeOperand(inst, iarg);
|
||||||
|
@ -3423,7 +3423,7 @@ TypedExpression FunctionEmitter::MakeAccessChain(
|
||||||
type_mgr_->FindPointerToType(pointee_type_id, storage_class);
|
type_mgr_->FindPointerToType(pointee_type_id, storage_class);
|
||||||
auto* ast_pointer_type = parser_impl_.ConvertType(pointer_type_id);
|
auto* ast_pointer_type = parser_impl_.ConvertType(pointer_type_id);
|
||||||
assert(ast_pointer_type);
|
assert(ast_pointer_type);
|
||||||
assert(ast_pointer_type->Is<ast::type::Pointer>());
|
assert(ast_pointer_type->Is<type::Pointer>());
|
||||||
current_expr = TypedExpression{ast_pointer_type, next_expr};
|
current_expr = TypedExpression{ast_pointer_type, next_expr};
|
||||||
}
|
}
|
||||||
return current_expr;
|
return current_expr;
|
||||||
|
@ -3443,7 +3443,7 @@ TypedExpression FunctionEmitter::MakeCompositeExtract(
|
||||||
TypedExpression current_expr(MakeOperand(inst, 0));
|
TypedExpression current_expr(MakeOperand(inst, 0));
|
||||||
|
|
||||||
auto make_index = [this, source](uint32_t literal) {
|
auto make_index = [this, source](uint32_t literal) {
|
||||||
auto* type = create<ast::type::U32>();
|
auto* type = create<type::U32>();
|
||||||
return create<ast::ScalarConstructorExpression>(
|
return create<ast::ScalarConstructorExpression>(
|
||||||
source, create<ast::UintLiteral>(source, type, literal));
|
source, create<ast::UintLiteral>(source, type, literal));
|
||||||
};
|
};
|
||||||
|
@ -3551,7 +3551,7 @@ ast::Expression* FunctionEmitter::MakeTrue(const Source& source) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::Expression* FunctionEmitter::MakeFalse(const Source& source) const {
|
ast::Expression* FunctionEmitter::MakeFalse(const Source& source) const {
|
||||||
ast::type::Bool bool_type;
|
type::Bool bool_type;
|
||||||
return create<ast::ScalarConstructorExpression>(
|
return create<ast::ScalarConstructorExpression>(
|
||||||
source, create<ast::BoolLiteral>(source, parser_impl_.Bool(), false));
|
source, create<ast::BoolLiteral>(source, parser_impl_.Bool(), false));
|
||||||
}
|
}
|
||||||
|
@ -3572,8 +3572,8 @@ TypedExpression FunctionEmitter::MakeVectorShuffle(
|
||||||
// Generate an ast::TypeConstructor expression.
|
// Generate an ast::TypeConstructor expression.
|
||||||
// Assume the literal indices are valid, and there is a valid number of them.
|
// Assume the literal indices are valid, and there is a valid number of them.
|
||||||
auto source = GetSourceForInst(inst);
|
auto source = GetSourceForInst(inst);
|
||||||
ast::type::Vector* result_type =
|
type::Vector* result_type =
|
||||||
parser_impl_.ConvertType(inst.type_id())->As<ast::type::Vector>();
|
parser_impl_.ConvertType(inst.type_id())->As<type::Vector>();
|
||||||
ast::ExpressionList values;
|
ast::ExpressionList values;
|
||||||
for (uint32_t i = 2; i < inst.NumInOperands(); ++i) {
|
for (uint32_t i = 2; i < inst.NumInOperands(); ++i) {
|
||||||
const auto index = inst.GetSingleWordInOperand(i);
|
const auto index = inst.GetSingleWordInOperand(i);
|
||||||
|
@ -3642,7 +3642,7 @@ bool FunctionEmitter::RegisterLocallyDefinedValues() {
|
||||||
if (type) {
|
if (type) {
|
||||||
if (type->AsPointer()) {
|
if (type->AsPointer()) {
|
||||||
if (const auto* ast_type = parser_impl_.ConvertType(inst.type_id())) {
|
if (const auto* ast_type = parser_impl_.ConvertType(inst.type_id())) {
|
||||||
if (auto* ptr = ast_type->As<ast::type::Pointer>()) {
|
if (auto* ptr = ast_type->As<type::Pointer>()) {
|
||||||
info->storage_class = ptr->storage_class();
|
info->storage_class = ptr->storage_class();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3686,21 +3686,21 @@ ast::StorageClass FunctionEmitter::GetStorageClassForPointerValue(uint32_t id) {
|
||||||
const auto type_id = def_use_mgr_->GetDef(id)->type_id();
|
const auto type_id = def_use_mgr_->GetDef(id)->type_id();
|
||||||
if (type_id) {
|
if (type_id) {
|
||||||
auto* ast_type = parser_impl_.ConvertType(type_id);
|
auto* ast_type = parser_impl_.ConvertType(type_id);
|
||||||
if (ast_type && ast_type->Is<ast::type::Pointer>()) {
|
if (ast_type && ast_type->Is<type::Pointer>()) {
|
||||||
return ast_type->As<ast::type::Pointer>()->storage_class();
|
return ast_type->As<type::Pointer>()->storage_class();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ast::StorageClass::kNone;
|
return ast::StorageClass::kNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* FunctionEmitter::RemapStorageClass(ast::type::Type* type,
|
type::Type* FunctionEmitter::RemapStorageClass(type::Type* type,
|
||||||
uint32_t result_id) {
|
uint32_t result_id) {
|
||||||
if (const auto* ast_ptr_type = type->As<ast::type::Pointer>()) {
|
if (const auto* ast_ptr_type = type->As<type::Pointer>()) {
|
||||||
// Remap an old-style storage buffer pointer to a new-style storage
|
// Remap an old-style storage buffer pointer to a new-style storage
|
||||||
// buffer pointer.
|
// buffer pointer.
|
||||||
const auto sc = GetStorageClassForPointerValue(result_id);
|
const auto sc = GetStorageClassForPointerValue(result_id);
|
||||||
if (ast_ptr_type->storage_class() != sc) {
|
if (ast_ptr_type->storage_class() != sc) {
|
||||||
return parser_impl_.get_module().create<ast::type::Pointer>(
|
return parser_impl_.get_module().create<type::Pointer>(
|
||||||
ast_ptr_type->type(), sc);
|
ast_ptr_type->type(), sc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3884,7 +3884,7 @@ TypedExpression FunctionEmitter::MakeNumericConversion(
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* expr_type = nullptr;
|
type::Type* expr_type = nullptr;
|
||||||
if ((opcode == SpvOpConvertSToF) || (opcode == SpvOpConvertUToF)) {
|
if ((opcode == SpvOpConvertSToF) || (opcode == SpvOpConvertUToF)) {
|
||||||
if (arg_expr.type->is_integer_scalar_or_vector()) {
|
if (arg_expr.type->is_integer_scalar_or_vector()) {
|
||||||
expr_type = requested_type;
|
expr_type = requested_type;
|
||||||
|
@ -3946,7 +3946,7 @@ bool FunctionEmitter::EmitFunctionCall(const spvtools::opt::Instruction& inst) {
|
||||||
<< inst.PrettyPrint();
|
<< inst.PrettyPrint();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result_type->Is<ast::type::Void>()) {
|
if (result_type->Is<type::Void>()) {
|
||||||
return nullptr !=
|
return nullptr !=
|
||||||
AddStatement(create<ast::CallStatement>(Source{}, call_expr));
|
AddStatement(create<ast::CallStatement>(Source{}, call_expr));
|
||||||
}
|
}
|
||||||
|
@ -3965,7 +3965,7 @@ TypedExpression FunctionEmitter::MakeIntrinsicCall(
|
||||||
ident->set_intrinsic(intrinsic);
|
ident->set_intrinsic(intrinsic);
|
||||||
|
|
||||||
ast::ExpressionList params;
|
ast::ExpressionList params;
|
||||||
ast::type::Type* first_operand_type = nullptr;
|
type::Type* first_operand_type = nullptr;
|
||||||
for (uint32_t iarg = 0; iarg < inst.NumInOperands(); ++iarg) {
|
for (uint32_t iarg = 0; iarg < inst.NumInOperands(); ++iarg) {
|
||||||
TypedExpression operand = MakeOperand(inst, iarg);
|
TypedExpression operand = MakeOperand(inst, iarg);
|
||||||
if (first_operand_type == nullptr) {
|
if (first_operand_type == nullptr) {
|
||||||
|
@ -3997,8 +3997,8 @@ TypedExpression FunctionEmitter::MakeSimpleSelect(
|
||||||
// - you can't select over pointers or pointer vectors, unless you also have
|
// - you can't select over pointers or pointer vectors, unless you also have
|
||||||
// a VariablePointers* capability, which is not allowed in by WebGPU.
|
// a VariablePointers* capability, which is not allowed in by WebGPU.
|
||||||
auto* op_ty = operand1.type;
|
auto* op_ty = operand1.type;
|
||||||
if (op_ty->Is<ast::type::Vector>() || op_ty->is_float_scalar() ||
|
if (op_ty->Is<type::Vector>() || op_ty->is_float_scalar() ||
|
||||||
op_ty->is_integer_scalar() || op_ty->Is<ast::type::Bool>()) {
|
op_ty->is_integer_scalar() || op_ty->Is<type::Bool>()) {
|
||||||
ast::ExpressionList params;
|
ast::ExpressionList params;
|
||||||
params.push_back(operand1.expr);
|
params.push_back(operand1.expr);
|
||||||
params.push_back(operand2.expr);
|
params.push_back(operand2.expr);
|
||||||
|
@ -4050,13 +4050,12 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||||
Source{}, ast_module_.RegisterSymbol(param_name)));
|
Source{}, ast_module_.RegisterSymbol(param_name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Pointer* texture_ptr_type =
|
type::Pointer* texture_ptr_type = parser_impl_.GetTypeForHandleVar(*image);
|
||||||
parser_impl_.GetTypeForHandleVar(*image);
|
|
||||||
if (!texture_ptr_type) {
|
if (!texture_ptr_type) {
|
||||||
return Fail();
|
return Fail();
|
||||||
}
|
}
|
||||||
ast::type::Texture* texture_type =
|
type::Texture* texture_type =
|
||||||
texture_ptr_type->type()->UnwrapAll()->As<ast::type::Texture>();
|
texture_ptr_type->type()->UnwrapAll()->As<type::Texture>();
|
||||||
if (!texture_type) {
|
if (!texture_type) {
|
||||||
return Fail();
|
return Fail();
|
||||||
}
|
}
|
||||||
|
@ -4160,7 +4159,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||||
}
|
}
|
||||||
TypedExpression lod = MakeOperand(inst, arg_index);
|
TypedExpression lod = MakeOperand(inst, arg_index);
|
||||||
// When sampling from a depth texture, the Lod operand must be an I32.
|
// When sampling from a depth texture, the Lod operand must be an I32.
|
||||||
if (texture_type->Is<ast::type::DepthTexture>()) {
|
if (texture_type->Is<type::DepthTexture>()) {
|
||||||
// Convert it to a signed integer type.
|
// Convert it to a signed integer type.
|
||||||
lod = ToI32(lod);
|
lod = ToI32(lod);
|
||||||
}
|
}
|
||||||
|
@ -4188,9 +4187,9 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||||
<< inst.PrettyPrint();
|
<< inst.PrettyPrint();
|
||||||
}
|
}
|
||||||
switch (texture_type->dim()) {
|
switch (texture_type->dim()) {
|
||||||
case ast::type::TextureDimension::k2d:
|
case type::TextureDimension::k2d:
|
||||||
case ast::type::TextureDimension::k2dArray:
|
case type::TextureDimension::k2dArray:
|
||||||
case ast::type::TextureDimension::k3d:
|
case type::TextureDimension::k3d:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return Fail() << "ConstOffset is only permitted for 2D, 2D Arrayed, "
|
return Fail() << "ConstOffset is only permitted for 2D, 2D Arrayed, "
|
||||||
|
@ -4226,7 +4225,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||||
// The result type, derived from the SPIR-V instruction.
|
// The result type, derived from the SPIR-V instruction.
|
||||||
auto* result_type = parser_impl_.ConvertType(inst.type_id());
|
auto* result_type = parser_impl_.ConvertType(inst.type_id());
|
||||||
auto* result_component_type = result_type;
|
auto* result_component_type = result_type;
|
||||||
if (auto* result_vector_type = result_type->As<ast::type::Vector>()) {
|
if (auto* result_vector_type = result_type->As<type::Vector>()) {
|
||||||
result_component_type = result_vector_type->type();
|
result_component_type = result_vector_type->type();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4241,7 +4240,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||||
// dref gather vec4 ImageFetch vec4 TODO(dneto)
|
// dref gather vec4 ImageFetch vec4 TODO(dneto)
|
||||||
// Construct a 4-element vector with the result from the builtin in the
|
// Construct a 4-element vector with the result from the builtin in the
|
||||||
// first component.
|
// first component.
|
||||||
if (texture_type->Is<ast::type::DepthTexture>()) {
|
if (texture_type->Is<type::DepthTexture>()) {
|
||||||
if (is_non_dref_sample || (opcode == SpvOpImageFetch)) {
|
if (is_non_dref_sample || (opcode == SpvOpImageFetch)) {
|
||||||
value = create<ast::TypeConstructorExpression>(
|
value = create<ast::TypeConstructorExpression>(
|
||||||
Source{},
|
Source{},
|
||||||
|
@ -4269,7 +4268,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||||
// or vice versa. Perform a bitcast.
|
// or vice versa. Perform a bitcast.
|
||||||
value = create<ast::BitcastExpression>(Source{}, result_type, call_expr);
|
value = create<ast::BitcastExpression>(Source{}, result_type, call_expr);
|
||||||
}
|
}
|
||||||
if (!expected_component_type->Is<ast::type::F32>() &&
|
if (!expected_component_type->Is<type::F32>() &&
|
||||||
IsSampledImageAccess(opcode)) {
|
IsSampledImageAccess(opcode)) {
|
||||||
// WGSL permits sampled image access only on float textures.
|
// WGSL permits sampled image access only on float textures.
|
||||||
// Reject this case in the SPIR-V reader, at least until SPIR-V validation
|
// Reject this case in the SPIR-V reader, at least until SPIR-V validation
|
||||||
|
@ -4326,22 +4325,21 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
|
||||||
if (!raw_coords.type) {
|
if (!raw_coords.type) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
ast::type::Pointer* type = parser_impl_.GetTypeForHandleVar(*image);
|
type::Pointer* type = parser_impl_.GetTypeForHandleVar(*image);
|
||||||
if (!parser_impl_.success()) {
|
if (!parser_impl_.success()) {
|
||||||
Fail();
|
Fail();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (!type || !type->type()->UnwrapAll()->Is<ast::type::Texture>()) {
|
if (!type || !type->type()->UnwrapAll()->Is<type::Texture>()) {
|
||||||
Fail() << "invalid texture type for " << image->PrettyPrint();
|
Fail() << "invalid texture type for " << image->PrettyPrint();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* unwrapped_type = type->type()->UnwrapAll();
|
auto* unwrapped_type = type->type()->UnwrapAll();
|
||||||
ast::type::TextureDimension dim =
|
type::TextureDimension dim = unwrapped_type->As<type::Texture>()->dim();
|
||||||
unwrapped_type->As<ast::type::Texture>()->dim();
|
|
||||||
// Number of regular coordinates.
|
// Number of regular coordinates.
|
||||||
uint32_t num_axes = ast::type::NumCoordinateAxes(dim);
|
uint32_t num_axes = type::NumCoordinateAxes(dim);
|
||||||
bool is_arrayed = ast::type::IsTextureArray(dim);
|
bool is_arrayed = type::IsTextureArray(dim);
|
||||||
if ((num_axes == 0) || (num_axes > 3)) {
|
if ((num_axes == 0) || (num_axes > 3)) {
|
||||||
Fail() << "unsupported image dimensionality for " << type->type_name()
|
Fail() << "unsupported image dimensionality for " << type->type_name()
|
||||||
<< " prompted by " << inst.PrettyPrint();
|
<< " prompted by " << inst.PrettyPrint();
|
||||||
|
@ -4352,7 +4350,7 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
|
||||||
if (component_type->is_float_scalar() ||
|
if (component_type->is_float_scalar() ||
|
||||||
component_type->is_integer_scalar()) {
|
component_type->is_integer_scalar()) {
|
||||||
num_coords_supplied = 1;
|
num_coords_supplied = 1;
|
||||||
} else if (auto* vec_type = raw_coords.type->As<ast::type::Vector>()) {
|
} else if (auto* vec_type = raw_coords.type->As<type::Vector>()) {
|
||||||
component_type = vec_type->type();
|
component_type = vec_type->type();
|
||||||
num_coords_supplied = vec_type->size();
|
num_coords_supplied = vec_type->size();
|
||||||
}
|
}
|
||||||
|
@ -4377,9 +4375,9 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
|
||||||
// will actually use them.
|
// will actually use them.
|
||||||
auto prefix_swizzle_expr = [this, num_axes, component_type,
|
auto prefix_swizzle_expr = [this, num_axes, component_type,
|
||||||
raw_coords]() -> ast::Expression* {
|
raw_coords]() -> ast::Expression* {
|
||||||
auto* swizzle_type =
|
auto* swizzle_type = (num_axes == 1)
|
||||||
(num_axes == 1) ? component_type
|
? component_type
|
||||||
: create<ast::type::Vector>(component_type, num_axes);
|
: create<type::Vector>(component_type, num_axes);
|
||||||
auto* swizzle = create<ast::MemberAccessorExpression>(
|
auto* swizzle = create<ast::MemberAccessorExpression>(
|
||||||
Source{}, raw_coords.expr, PrefixSwizzle(num_axes));
|
Source{}, raw_coords.expr, PrefixSwizzle(num_axes));
|
||||||
return ToSignedIfUnsigned({swizzle_type, swizzle}).expr;
|
return ToSignedIfUnsigned({swizzle_type, swizzle}).expr;
|
||||||
|
@ -4413,8 +4411,8 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
|
||||||
ast::Expression* FunctionEmitter::ConvertTexelForStorage(
|
ast::Expression* FunctionEmitter::ConvertTexelForStorage(
|
||||||
const spvtools::opt::Instruction& inst,
|
const spvtools::opt::Instruction& inst,
|
||||||
TypedExpression texel,
|
TypedExpression texel,
|
||||||
ast::type::Texture* texture_type) {
|
type::Texture* texture_type) {
|
||||||
auto* storage_texture_type = texture_type->As<ast::type::StorageTexture>();
|
auto* storage_texture_type = texture_type->As<type::StorageTexture>();
|
||||||
auto* src_type = texel.type;
|
auto* src_type = texel.type;
|
||||||
if (!storage_texture_type) {
|
if (!storage_texture_type) {
|
||||||
Fail() << "writing to other than storage texture: " << inst.PrettyPrint();
|
Fail() << "writing to other than storage texture: " << inst.PrettyPrint();
|
||||||
|
@ -4431,14 +4429,14 @@ ast::Expression* FunctionEmitter::ConvertTexelForStorage(
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t dest_count =
|
const uint32_t dest_count =
|
||||||
dest_type->is_scalar() ? 1 : dest_type->As<ast::type::Vector>()->size();
|
dest_type->is_scalar() ? 1 : dest_type->As<type::Vector>()->size();
|
||||||
if (dest_count == 3) {
|
if (dest_count == 3) {
|
||||||
Fail() << "3-channel storage textures are not supported: "
|
Fail() << "3-channel storage textures are not supported: "
|
||||||
<< inst.PrettyPrint();
|
<< inst.PrettyPrint();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
const uint32_t src_count =
|
const uint32_t src_count =
|
||||||
src_type->is_scalar() ? 1 : src_type->As<ast::type::Vector>()->size();
|
src_type->is_scalar() ? 1 : src_type->As<type::Vector>()->size();
|
||||||
if (src_count < dest_count) {
|
if (src_count < dest_count) {
|
||||||
Fail() << "texel has too few components for storage texture: " << src_count
|
Fail() << "texel has too few components for storage texture: " << src_count
|
||||||
<< " provided but " << dest_count
|
<< " provided but " << dest_count
|
||||||
|
@ -4508,8 +4506,8 @@ TypedExpression FunctionEmitter::ToSignedIfUnsigned(TypedExpression value) {
|
||||||
if (!value.type || !value.type->is_unsigned_scalar_or_vector()) {
|
if (!value.type || !value.type->is_unsigned_scalar_or_vector()) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
if (auto* vec_type = value.type->As<ast::type::Vector>()) {
|
if (auto* vec_type = value.type->As<type::Vector>()) {
|
||||||
auto* new_type = create<ast::type::Vector>(i32_, vec_type->size());
|
auto* new_type = create<type::Vector>(i32_, vec_type->size());
|
||||||
return {new_type, create<ast::TypeConstructorExpression>(
|
return {new_type, create<ast::TypeConstructorExpression>(
|
||||||
Source{}, new_type, ast::ExpressionList{value.expr})};
|
Source{}, new_type, ast::ExpressionList{value.expr})};
|
||||||
}
|
}
|
||||||
|
@ -4560,10 +4558,10 @@ TypedExpression FunctionEmitter::MakeOuterProduct(
|
||||||
// Synthesize the result.
|
// Synthesize the result.
|
||||||
auto col = MakeOperand(inst, 0);
|
auto col = MakeOperand(inst, 0);
|
||||||
auto row = MakeOperand(inst, 1);
|
auto row = MakeOperand(inst, 1);
|
||||||
auto* col_ty = col.type->As<ast::type::Vector>();
|
auto* col_ty = col.type->As<type::Vector>();
|
||||||
auto* row_ty = row.type->As<ast::type::Vector>();
|
auto* row_ty = row.type->As<type::Vector>();
|
||||||
auto* result_ty =
|
auto* result_ty =
|
||||||
parser_impl_.ConvertType(inst.type_id())->As<ast::type::Matrix>();
|
parser_impl_.ConvertType(inst.type_id())->As<type::Matrix>();
|
||||||
if (!col_ty || !col_ty || !result_ty || result_ty->type() != col_ty->type() ||
|
if (!col_ty || !col_ty || !result_ty || result_ty->type() != col_ty->type() ||
|
||||||
result_ty->type() != row_ty->type() ||
|
result_ty->type() != row_ty->type() ||
|
||||||
result_ty->columns() != row_ty->size() ||
|
result_ty->columns() != row_ty->size() ||
|
||||||
|
|
|
@ -36,12 +36,12 @@
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
#include "src/ast/statement.h"
|
#include "src/ast/statement.h"
|
||||||
#include "src/ast/storage_class.h"
|
#include "src/ast/storage_class.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/reader/spirv/construct.h"
|
#include "src/reader/spirv/construct.h"
|
||||||
#include "src/reader/spirv/entry_point_info.h"
|
#include "src/reader/spirv/entry_point_info.h"
|
||||||
#include "src/reader/spirv/fail_stream.h"
|
#include "src/reader/spirv/fail_stream.h"
|
||||||
#include "src/reader/spirv/namer.h"
|
#include "src/reader/spirv/namer.h"
|
||||||
#include "src/reader/spirv/parser_impl.h"
|
#include "src/reader/spirv/parser_impl.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -485,7 +485,7 @@ class FunctionEmitter {
|
||||||
/// @param type the AST type
|
/// @param type the AST type
|
||||||
/// @param result_id the SPIR-V ID for the locally defined value
|
/// @param result_id the SPIR-V ID for the locally defined value
|
||||||
/// @returns an possibly updated type
|
/// @returns an possibly updated type
|
||||||
ast::type::Type* RemapStorageClass(ast::type::Type* type, uint32_t result_id);
|
type::Type* RemapStorageClass(type::Type* type, uint32_t result_id);
|
||||||
|
|
||||||
/// Marks locally defined values when they should get a 'const'
|
/// Marks locally defined values when they should get a 'const'
|
||||||
/// definition in WGSL, or a 'var' definition at an outer scope.
|
/// definition in WGSL, or a 'var' definition at an outer scope.
|
||||||
|
@ -804,7 +804,7 @@ class FunctionEmitter {
|
||||||
/// Function parameters
|
/// Function parameters
|
||||||
ast::VariableList params;
|
ast::VariableList params;
|
||||||
/// Function return type
|
/// Function return type
|
||||||
ast::type::Type* return_type;
|
type::Type* return_type;
|
||||||
/// Function decorations
|
/// Function decorations
|
||||||
ast::FunctionDecorationList decorations;
|
ast::FunctionDecorationList decorations;
|
||||||
};
|
};
|
||||||
|
@ -817,7 +817,7 @@ class FunctionEmitter {
|
||||||
|
|
||||||
/// @returns the store type for the OpVariable instruction, or
|
/// @returns the store type for the OpVariable instruction, or
|
||||||
/// null on failure.
|
/// null on failure.
|
||||||
ast::type::Type* GetVariableStoreType(
|
type::Type* GetVariableStoreType(
|
||||||
const spvtools::opt::Instruction& var_decl_inst);
|
const spvtools::opt::Instruction& var_decl_inst);
|
||||||
|
|
||||||
/// Returns an expression for an instruction operand. Signedness conversion is
|
/// Returns an expression for an instruction operand. Signedness conversion is
|
||||||
|
@ -874,7 +874,7 @@ class FunctionEmitter {
|
||||||
ast::Expression* ConvertTexelForStorage(
|
ast::Expression* ConvertTexelForStorage(
|
||||||
const spvtools::opt::Instruction& inst,
|
const spvtools::opt::Instruction& inst,
|
||||||
TypedExpression texel,
|
TypedExpression texel,
|
||||||
ast::type::Texture* texture_type);
|
type::Texture* texture_type);
|
||||||
|
|
||||||
/// Returns an expression for an OpSelect, if its operands are scalars
|
/// Returns an expression for an OpSelect, if its operands are scalars
|
||||||
/// or vectors. These translate directly to WGSL select. Otherwise, return
|
/// or vectors. These translate directly to WGSL select. Otherwise, return
|
||||||
|
@ -1037,7 +1037,7 @@ class FunctionEmitter {
|
||||||
FailStream& fail_stream_;
|
FailStream& fail_stream_;
|
||||||
Namer& namer_;
|
Namer& namer_;
|
||||||
const spvtools::opt::Function& function_;
|
const spvtools::opt::Function& function_;
|
||||||
ast::type::I32* const i32_; // The unique I32 type object.
|
type::I32* const i32_; // The unique I32 type object.
|
||||||
|
|
||||||
// A stack of statement lists. Each list is contained in a construct in
|
// A stack of statement lists. Each list is contained in a construct in
|
||||||
// the next deeper element of stack. The 0th entry represents the statements
|
// the next deeper element of stack. The 0th entry represents the statements
|
||||||
|
|
|
@ -52,24 +52,6 @@
|
||||||
#include "src/ast/struct_member.h"
|
#include "src/ast/struct_member.h"
|
||||||
#include "src/ast/struct_member_decoration.h"
|
#include "src/ast/struct_member_decoration.h"
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
|
||||||
#include "src/ast/type/alias_type.h"
|
|
||||||
#include "src/ast/type/array_type.h"
|
|
||||||
#include "src/ast/type/bool_type.h"
|
|
||||||
#include "src/ast/type/depth_texture_type.h"
|
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/matrix_type.h"
|
|
||||||
#include "src/ast/type/multisampled_texture_type.h"
|
|
||||||
#include "src/ast/type/pointer_type.h"
|
|
||||||
#include "src/ast/type/sampled_texture_type.h"
|
|
||||||
#include "src/ast/type/sampler_type.h"
|
|
||||||
#include "src/ast/type/storage_texture_type.h"
|
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/ast/type/type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/type/vector_type.h"
|
|
||||||
#include "src/ast/type/void_type.h"
|
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
#include "src/ast/unary_op_expression.h"
|
#include "src/ast/unary_op_expression.h"
|
||||||
|
@ -79,6 +61,24 @@
|
||||||
#include "src/reader/spirv/enum_converter.h"
|
#include "src/reader/spirv/enum_converter.h"
|
||||||
#include "src/reader/spirv/function.h"
|
#include "src/reader/spirv/function.h"
|
||||||
#include "src/reader/spirv/usage.h"
|
#include "src/reader/spirv/usage.h"
|
||||||
|
#include "src/type/access_control_type.h"
|
||||||
|
#include "src/type/alias_type.h"
|
||||||
|
#include "src/type/array_type.h"
|
||||||
|
#include "src/type/bool_type.h"
|
||||||
|
#include "src/type/depth_texture_type.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/matrix_type.h"
|
||||||
|
#include "src/type/multisampled_texture_type.h"
|
||||||
|
#include "src/type/pointer_type.h"
|
||||||
|
#include "src/type/sampled_texture_type.h"
|
||||||
|
#include "src/type/sampler_type.h"
|
||||||
|
#include "src/type/storage_texture_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
#include "src/type/type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
#include "src/type/void_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -255,7 +255,7 @@ ParserImpl::ParserImpl(const std::vector<uint32_t>& spv_binary)
|
||||||
: Reader(),
|
: Reader(),
|
||||||
spv_binary_(spv_binary),
|
spv_binary_(spv_binary),
|
||||||
fail_stream_(&success_, &errors_),
|
fail_stream_(&success_, &errors_),
|
||||||
bool_type_(ast_module_.create<ast::type::Bool>()),
|
bool_type_(ast_module_.create<type::Bool>()),
|
||||||
namer_(fail_stream_),
|
namer_(fail_stream_),
|
||||||
enum_converter_(fail_stream_),
|
enum_converter_(fail_stream_),
|
||||||
tools_context_(kInputEnv) {
|
tools_context_(kInputEnv) {
|
||||||
|
@ -313,7 +313,7 @@ ast::Module ParserImpl::module() {
|
||||||
return std::move(ast_module_);
|
return std::move(ast_module_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
||||||
if (!success_) {
|
if (!success_) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ ast::type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto save = [this, type_id, spirv_type](ast::type::Type* type) {
|
auto save = [this, type_id, spirv_type](type::Type* type) {
|
||||||
if (type != nullptr) {
|
if (type != nullptr) {
|
||||||
id_to_type_[type_id] = type;
|
id_to_type_[type_id] = type;
|
||||||
MaybeGenerateAlias(type_id, spirv_type);
|
MaybeGenerateAlias(type_id, spirv_type);
|
||||||
|
@ -344,7 +344,7 @@ ast::type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
||||||
|
|
||||||
switch (spirv_type->kind()) {
|
switch (spirv_type->kind()) {
|
||||||
case spvtools::opt::analysis::Type::kVoid:
|
case spvtools::opt::analysis::Type::kVoid:
|
||||||
return save(ast_module_.create<ast::type::Void>());
|
return save(ast_module_.create<type::Void>());
|
||||||
case spvtools::opt::analysis::Type::kBool:
|
case spvtools::opt::analysis::Type::kBool:
|
||||||
return save(bool_type_);
|
return save(bool_type_);
|
||||||
case spvtools::opt::analysis::Type::kInteger:
|
case spvtools::opt::analysis::Type::kInteger:
|
||||||
|
@ -374,7 +374,7 @@ ast::type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
||||||
case spvtools::opt::analysis::Type::kImage:
|
case spvtools::opt::analysis::Type::kImage:
|
||||||
// Fake it for sampler and texture types. These are handled in an
|
// Fake it for sampler and texture types. These are handled in an
|
||||||
// entirely different way.
|
// entirely different way.
|
||||||
return save(ast_module_.create<ast::type::Void>());
|
return save(ast_module_.create<type::Void>());
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -710,11 +710,11 @@ bool ParserImpl::RegisterEntryPoints() {
|
||||||
return success_;
|
return success_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::ConvertType(
|
type::Type* ParserImpl::ConvertType(
|
||||||
const spvtools::opt::analysis::Integer* int_ty) {
|
const spvtools::opt::analysis::Integer* int_ty) {
|
||||||
if (int_ty->width() == 32) {
|
if (int_ty->width() == 32) {
|
||||||
ast::type::Type* signed_ty = ast_module_.create<ast::type::I32>();
|
type::Type* signed_ty = ast_module_.create<type::I32>();
|
||||||
ast::type::Type* unsigned_ty = ast_module_.create<ast::type::U32>();
|
type::Type* unsigned_ty = ast_module_.create<type::U32>();
|
||||||
signed_type_for_[unsigned_ty] = signed_ty;
|
signed_type_for_[unsigned_ty] = signed_ty;
|
||||||
unsigned_type_for_[signed_ty] = unsigned_ty;
|
unsigned_type_for_[signed_ty] = unsigned_ty;
|
||||||
return int_ty->IsSigned() ? signed_ty : unsigned_ty;
|
return int_ty->IsSigned() ? signed_ty : unsigned_ty;
|
||||||
|
@ -723,31 +723,31 @@ ast::type::Type* ParserImpl::ConvertType(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::ConvertType(
|
type::Type* ParserImpl::ConvertType(
|
||||||
const spvtools::opt::analysis::Float* float_ty) {
|
const spvtools::opt::analysis::Float* float_ty) {
|
||||||
if (float_ty->width() == 32) {
|
if (float_ty->width() == 32) {
|
||||||
return ast_module_.create<ast::type::F32>();
|
return ast_module_.create<type::F32>();
|
||||||
}
|
}
|
||||||
Fail() << "unhandled float width: " << float_ty->width();
|
Fail() << "unhandled float width: " << float_ty->width();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::ConvertType(
|
type::Type* ParserImpl::ConvertType(
|
||||||
const spvtools::opt::analysis::Vector* vec_ty) {
|
const spvtools::opt::analysis::Vector* vec_ty) {
|
||||||
const auto num_elem = vec_ty->element_count();
|
const auto num_elem = vec_ty->element_count();
|
||||||
auto* ast_elem_ty = ConvertType(type_mgr_->GetId(vec_ty->element_type()));
|
auto* ast_elem_ty = ConvertType(type_mgr_->GetId(vec_ty->element_type()));
|
||||||
if (ast_elem_ty == nullptr) {
|
if (ast_elem_ty == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto* this_ty = ast_module_.create<ast::type::Vector>(ast_elem_ty, num_elem);
|
auto* this_ty = ast_module_.create<type::Vector>(ast_elem_ty, num_elem);
|
||||||
// Generate the opposite-signedness vector type, if this type is integral.
|
// Generate the opposite-signedness vector type, if this type is integral.
|
||||||
if (unsigned_type_for_.count(ast_elem_ty)) {
|
if (unsigned_type_for_.count(ast_elem_ty)) {
|
||||||
auto* other_ty = ast_module_.create<ast::type::Vector>(
|
auto* other_ty = ast_module_.create<type::Vector>(
|
||||||
unsigned_type_for_[ast_elem_ty], num_elem);
|
unsigned_type_for_[ast_elem_ty], num_elem);
|
||||||
signed_type_for_[other_ty] = this_ty;
|
signed_type_for_[other_ty] = this_ty;
|
||||||
unsigned_type_for_[this_ty] = other_ty;
|
unsigned_type_for_[this_ty] = other_ty;
|
||||||
} else if (signed_type_for_.count(ast_elem_ty)) {
|
} else if (signed_type_for_.count(ast_elem_ty)) {
|
||||||
auto* other_ty = ast_module_.create<ast::type::Vector>(
|
auto* other_ty = ast_module_.create<type::Vector>(
|
||||||
signed_type_for_[ast_elem_ty], num_elem);
|
signed_type_for_[ast_elem_ty], num_elem);
|
||||||
unsigned_type_for_[other_ty] = this_ty;
|
unsigned_type_for_[other_ty] = this_ty;
|
||||||
signed_type_for_[this_ty] = other_ty;
|
signed_type_for_[this_ty] = other_ty;
|
||||||
|
@ -755,7 +755,7 @@ ast::type::Type* ParserImpl::ConvertType(
|
||||||
return this_ty;
|
return this_ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::ConvertType(
|
type::Type* ParserImpl::ConvertType(
|
||||||
const spvtools::opt::analysis::Matrix* mat_ty) {
|
const spvtools::opt::analysis::Matrix* mat_ty) {
|
||||||
const auto* vec_ty = mat_ty->element_type()->AsVector();
|
const auto* vec_ty = mat_ty->element_type()->AsVector();
|
||||||
const auto* scalar_ty = vec_ty->element_type();
|
const auto* scalar_ty = vec_ty->element_type();
|
||||||
|
@ -765,11 +765,10 @@ ast::type::Type* ParserImpl::ConvertType(
|
||||||
if (ast_scalar_ty == nullptr) {
|
if (ast_scalar_ty == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return ast_module_.create<ast::type::Matrix>(ast_scalar_ty, num_rows,
|
return ast_module_.create<type::Matrix>(ast_scalar_ty, num_rows, num_columns);
|
||||||
num_columns);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::ConvertType(
|
type::Type* ParserImpl::ConvertType(
|
||||||
const spvtools::opt::analysis::RuntimeArray* rtarr_ty) {
|
const spvtools::opt::analysis::RuntimeArray* rtarr_ty) {
|
||||||
auto* ast_elem_ty = ConvertType(type_mgr_->GetId(rtarr_ty->element_type()));
|
auto* ast_elem_ty = ConvertType(type_mgr_->GetId(rtarr_ty->element_type()));
|
||||||
if (ast_elem_ty == nullptr) {
|
if (ast_elem_ty == nullptr) {
|
||||||
|
@ -779,10 +778,10 @@ ast::type::Type* ParserImpl::ConvertType(
|
||||||
if (!ParseArrayDecorations(rtarr_ty, &decorations)) {
|
if (!ParseArrayDecorations(rtarr_ty, &decorations)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return create<ast::type::Array>(ast_elem_ty, 0, std::move(decorations));
|
return create<type::Array>(ast_elem_ty, 0, std::move(decorations));
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::ConvertType(
|
type::Type* ParserImpl::ConvertType(
|
||||||
const spvtools::opt::analysis::Array* arr_ty) {
|
const spvtools::opt::analysis::Array* arr_ty) {
|
||||||
const auto elem_type_id = type_mgr_->GetId(arr_ty->element_type());
|
const auto elem_type_id = type_mgr_->GetId(arr_ty->element_type());
|
||||||
auto* ast_elem_ty = ConvertType(elem_type_id);
|
auto* ast_elem_ty = ConvertType(elem_type_id);
|
||||||
|
@ -824,8 +823,8 @@ ast::type::Type* ParserImpl::ConvertType(
|
||||||
if (remap_buffer_block_type_.count(elem_type_id)) {
|
if (remap_buffer_block_type_.count(elem_type_id)) {
|
||||||
remap_buffer_block_type_.insert(type_mgr_->GetId(arr_ty));
|
remap_buffer_block_type_.insert(type_mgr_->GetId(arr_ty));
|
||||||
}
|
}
|
||||||
return create<ast::type::Array>(ast_elem_ty, static_cast<uint32_t>(num_elem),
|
return create<type::Array>(ast_elem_ty, static_cast<uint32_t>(num_elem),
|
||||||
std::move(decorations));
|
std::move(decorations));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParserImpl::ParseArrayDecorations(
|
bool ParserImpl::ParseArrayDecorations(
|
||||||
|
@ -857,7 +856,7 @@ bool ParserImpl::ParseArrayDecorations(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::ConvertType(
|
type::Type* ParserImpl::ConvertType(
|
||||||
uint32_t type_id,
|
uint32_t type_id,
|
||||||
const spvtools::opt::analysis::Struct* struct_ty) {
|
const spvtools::opt::analysis::Struct* struct_ty) {
|
||||||
// Compute the struct decoration.
|
// Compute the struct decoration.
|
||||||
|
@ -964,7 +963,7 @@ ast::type::Type* ParserImpl::ConvertType(
|
||||||
namer_.SuggestSanitizedName(type_id, "S");
|
namer_.SuggestSanitizedName(type_id, "S");
|
||||||
|
|
||||||
auto name = namer_.GetName(type_id);
|
auto name = namer_.GetName(type_id);
|
||||||
auto* result = ast_module_.create<ast::type::Struct>(
|
auto* result = ast_module_.create<type::Struct>(
|
||||||
ast_module_.RegisterSymbol(name), ast_struct);
|
ast_module_.RegisterSymbol(name), ast_struct);
|
||||||
id_to_type_[type_id] = result;
|
id_to_type_[type_id] = result;
|
||||||
if (num_non_writable_members == members.size()) {
|
if (num_non_writable_members == members.size()) {
|
||||||
|
@ -974,9 +973,8 @@ ast::type::Type* ParserImpl::ConvertType(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::ConvertType(
|
type::Type* ParserImpl::ConvertType(uint32_t type_id,
|
||||||
uint32_t type_id,
|
const spvtools::opt::analysis::Pointer*) {
|
||||||
const spvtools::opt::analysis::Pointer*) {
|
|
||||||
const auto* inst = def_use_mgr_->GetDef(type_id);
|
const auto* inst = def_use_mgr_->GetDef(type_id);
|
||||||
const auto pointee_type_id = inst->GetSingleWordInOperand(1);
|
const auto pointee_type_id = inst->GetSingleWordInOperand(1);
|
||||||
const auto storage_class = SpvStorageClass(inst->GetSingleWordInOperand(0));
|
const auto storage_class = SpvStorageClass(inst->GetSingleWordInOperand(0));
|
||||||
|
@ -1005,7 +1003,7 @@ ast::type::Type* ParserImpl::ConvertType(
|
||||||
ast_storage_class = ast::StorageClass::kStorage;
|
ast_storage_class = ast::StorageClass::kStorage;
|
||||||
remap_buffer_block_type_.insert(type_id);
|
remap_buffer_block_type_.insert(type_id);
|
||||||
}
|
}
|
||||||
return ast_module_.create<ast::type::Pointer>(ast_elem_ty, ast_storage_class);
|
return ast_module_.create<type::Pointer>(ast_elem_ty, ast_storage_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParserImpl::RegisterTypes() {
|
bool ParserImpl::RegisterTypes() {
|
||||||
|
@ -1038,7 +1036,7 @@ bool ParserImpl::EmitScalarSpecConstants() {
|
||||||
// that is OpSpecConstantTrue, OpSpecConstantFalse, or OpSpecConstant.
|
// that is OpSpecConstantTrue, OpSpecConstantFalse, or OpSpecConstant.
|
||||||
for (auto& inst : module_->types_values()) {
|
for (auto& inst : module_->types_values()) {
|
||||||
// These will be populated for a valid scalar spec constant.
|
// These will be populated for a valid scalar spec constant.
|
||||||
ast::type::Type* ast_type = nullptr;
|
type::Type* ast_type = nullptr;
|
||||||
ast::ScalarConstructorExpression* ast_expr = nullptr;
|
ast::ScalarConstructorExpression* ast_expr = nullptr;
|
||||||
|
|
||||||
switch (inst.opcode()) {
|
switch (inst.opcode()) {
|
||||||
|
@ -1054,17 +1052,17 @@ bool ParserImpl::EmitScalarSpecConstants() {
|
||||||
case SpvOpSpecConstant: {
|
case SpvOpSpecConstant: {
|
||||||
ast_type = ConvertType(inst.type_id());
|
ast_type = ConvertType(inst.type_id());
|
||||||
const uint32_t literal_value = inst.GetSingleWordInOperand(0);
|
const uint32_t literal_value = inst.GetSingleWordInOperand(0);
|
||||||
if (ast_type->Is<ast::type::I32>()) {
|
if (ast_type->Is<type::I32>()) {
|
||||||
ast_expr = create<ast::ScalarConstructorExpression>(
|
ast_expr = create<ast::ScalarConstructorExpression>(
|
||||||
Source{},
|
Source{},
|
||||||
create<ast::SintLiteral>(Source{}, ast_type,
|
create<ast::SintLiteral>(Source{}, ast_type,
|
||||||
static_cast<int32_t>(literal_value)));
|
static_cast<int32_t>(literal_value)));
|
||||||
} else if (ast_type->Is<ast::type::U32>()) {
|
} else if (ast_type->Is<type::U32>()) {
|
||||||
ast_expr = create<ast::ScalarConstructorExpression>(
|
ast_expr = create<ast::ScalarConstructorExpression>(
|
||||||
Source{},
|
Source{},
|
||||||
create<ast::UintLiteral>(Source{}, ast_type,
|
create<ast::UintLiteral>(Source{}, ast_type,
|
||||||
static_cast<uint32_t>(literal_value)));
|
static_cast<uint32_t>(literal_value)));
|
||||||
} else if (ast_type->Is<ast::type::F32>()) {
|
} else if (ast_type->Is<type::F32>()) {
|
||||||
float float_value;
|
float float_value;
|
||||||
// Copy the bits so we can read them as a float.
|
// Copy the bits so we can read them as a float.
|
||||||
std::memcpy(&float_value, &literal_value, sizeof(float_value));
|
std::memcpy(&float_value, &literal_value, sizeof(float_value));
|
||||||
|
@ -1131,7 +1129,7 @@ void ParserImpl::MaybeGenerateAlias(uint32_t type_id,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto name = namer_.GetName(type_id);
|
const auto name = namer_.GetName(type_id);
|
||||||
auto* ast_alias_type = ast_module_.create<ast::type::Alias>(
|
auto* ast_alias_type = ast_module_.create<type::Alias>(
|
||||||
ast_module_.RegisterSymbol(name), ast_underlying_type);
|
ast_module_.RegisterSymbol(name), ast_underlying_type);
|
||||||
// Record this new alias as the AST type for this SPIR-V ID.
|
// Record this new alias as the AST type for this SPIR-V ID.
|
||||||
id_to_type_[type_id] = ast_alias_type;
|
id_to_type_[type_id] = ast_alias_type;
|
||||||
|
@ -1176,7 +1174,7 @@ bool ParserImpl::EmitModuleScopeVariables() {
|
||||||
if (!success_) {
|
if (!success_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ast::type::Type* ast_type = nullptr;
|
type::Type* ast_type = nullptr;
|
||||||
if (spirv_storage_class == SpvStorageClassUniformConstant) {
|
if (spirv_storage_class == SpvStorageClassUniformConstant) {
|
||||||
// These are opaque handles: samplers or textures
|
// These are opaque handles: samplers or textures
|
||||||
ast_type = GetTypeForHandleVar(var);
|
ast_type = GetTypeForHandleVar(var);
|
||||||
|
@ -1190,15 +1188,14 @@ bool ParserImpl::EmitModuleScopeVariables() {
|
||||||
"SPIR-V type with ID: "
|
"SPIR-V type with ID: "
|
||||||
<< var.type_id();
|
<< var.type_id();
|
||||||
}
|
}
|
||||||
if (!ast_type->Is<ast::type::Pointer>()) {
|
if (!ast_type->Is<type::Pointer>()) {
|
||||||
return Fail() << "variable with ID " << var.result_id()
|
return Fail() << "variable with ID " << var.result_id()
|
||||||
<< " has non-pointer type " << var.type_id();
|
<< " has non-pointer type " << var.type_id();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* ast_store_type = ast_type->As<ast::type::Pointer>()->type();
|
auto* ast_store_type = ast_type->As<type::Pointer>()->type();
|
||||||
auto ast_storage_class =
|
auto ast_storage_class = ast_type->As<type::Pointer>()->storage_class();
|
||||||
ast_type->As<ast::type::Pointer>()->storage_class();
|
|
||||||
ast::Expression* ast_constructor = nullptr;
|
ast::Expression* ast_constructor = nullptr;
|
||||||
if (var.NumInOperands() > 1) {
|
if (var.NumInOperands() > 1) {
|
||||||
// SPIR-V initializers are always constants.
|
// SPIR-V initializers are always constants.
|
||||||
|
@ -1237,7 +1234,7 @@ bool ParserImpl::EmitModuleScopeVariables() {
|
||||||
ast::Variable* ParserImpl::MakeVariable(
|
ast::Variable* ParserImpl::MakeVariable(
|
||||||
uint32_t id,
|
uint32_t id,
|
||||||
ast::StorageClass sc,
|
ast::StorageClass sc,
|
||||||
ast::type::Type* type,
|
type::Type* type,
|
||||||
bool is_const,
|
bool is_const,
|
||||||
ast::Expression* constructor,
|
ast::Expression* constructor,
|
||||||
ast::VariableDecorationList decorations) {
|
ast::VariableDecorationList decorations) {
|
||||||
|
@ -1251,7 +1248,7 @@ ast::Variable* ParserImpl::MakeVariable(
|
||||||
auto access = read_only_struct_types_.count(type)
|
auto access = read_only_struct_types_.count(type)
|
||||||
? ast::AccessControl::kReadOnly
|
? ast::AccessControl::kReadOnly
|
||||||
: ast::AccessControl::kReadWrite;
|
: ast::AccessControl::kReadWrite;
|
||||||
type = ast_module_.create<ast::type::AccessControl>(access, type);
|
type = ast_module_.create<type::AccessControl>(access, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& deco : GetDecorationsFor(id)) {
|
for (auto& deco : GetDecorationsFor(id)) {
|
||||||
|
@ -1351,25 +1348,25 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
|
||||||
// So canonicalization should map that way too.
|
// So canonicalization should map that way too.
|
||||||
// Currently "null<type>" is missing from the WGSL parser.
|
// Currently "null<type>" is missing from the WGSL parser.
|
||||||
// See https://bugs.chromium.org/p/tint/issues/detail?id=34
|
// See https://bugs.chromium.org/p/tint/issues/detail?id=34
|
||||||
if (ast_type->Is<ast::type::U32>()) {
|
if (ast_type->Is<type::U32>()) {
|
||||||
return {ast_type,
|
return {ast_type,
|
||||||
create<ast::ScalarConstructorExpression>(
|
create<ast::ScalarConstructorExpression>(
|
||||||
Source{}, create<ast::UintLiteral>(source, ast_type,
|
Source{}, create<ast::UintLiteral>(source, ast_type,
|
||||||
spirv_const->GetU32()))};
|
spirv_const->GetU32()))};
|
||||||
}
|
}
|
||||||
if (ast_type->Is<ast::type::I32>()) {
|
if (ast_type->Is<type::I32>()) {
|
||||||
return {ast_type,
|
return {ast_type,
|
||||||
create<ast::ScalarConstructorExpression>(
|
create<ast::ScalarConstructorExpression>(
|
||||||
Source{}, create<ast::SintLiteral>(source, ast_type,
|
Source{}, create<ast::SintLiteral>(source, ast_type,
|
||||||
spirv_const->GetS32()))};
|
spirv_const->GetS32()))};
|
||||||
}
|
}
|
||||||
if (ast_type->Is<ast::type::F32>()) {
|
if (ast_type->Is<type::F32>()) {
|
||||||
return {ast_type,
|
return {ast_type,
|
||||||
create<ast::ScalarConstructorExpression>(
|
create<ast::ScalarConstructorExpression>(
|
||||||
Source{}, create<ast::FloatLiteral>(source, ast_type,
|
Source{}, create<ast::FloatLiteral>(source, ast_type,
|
||||||
spirv_const->GetFloat()))};
|
spirv_const->GetFloat()))};
|
||||||
}
|
}
|
||||||
if (ast_type->Is<ast::type::Bool>()) {
|
if (ast_type->Is<type::Bool>()) {
|
||||||
const bool value = spirv_const->AsNullConstant()
|
const bool value = spirv_const->AsNullConstant()
|
||||||
? false
|
? false
|
||||||
: spirv_const->AsBoolConstant()->value();
|
: spirv_const->AsBoolConstant()->value();
|
||||||
|
@ -1413,7 +1410,7 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
|
ast::Expression* ParserImpl::MakeNullValue(type::Type* type) {
|
||||||
// TODO(dneto): Use the no-operands constructor syntax when it becomes
|
// TODO(dneto): Use the no-operands constructor syntax when it becomes
|
||||||
// available in Tint.
|
// available in Tint.
|
||||||
// https://github.com/gpuweb/gpuweb/issues/685
|
// https://github.com/gpuweb/gpuweb/issues/685
|
||||||
|
@ -1427,23 +1424,23 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
|
||||||
auto* original_type = type;
|
auto* original_type = type;
|
||||||
type = type->UnwrapIfNeeded();
|
type = type->UnwrapIfNeeded();
|
||||||
|
|
||||||
if (type->Is<ast::type::Bool>()) {
|
if (type->Is<type::Bool>()) {
|
||||||
return create<ast::ScalarConstructorExpression>(
|
return create<ast::ScalarConstructorExpression>(
|
||||||
Source{}, create<ast::BoolLiteral>(Source{}, type, false));
|
Source{}, create<ast::BoolLiteral>(Source{}, type, false));
|
||||||
}
|
}
|
||||||
if (type->Is<ast::type::U32>()) {
|
if (type->Is<type::U32>()) {
|
||||||
return create<ast::ScalarConstructorExpression>(
|
return create<ast::ScalarConstructorExpression>(
|
||||||
Source{}, create<ast::UintLiteral>(Source{}, type, 0u));
|
Source{}, create<ast::UintLiteral>(Source{}, type, 0u));
|
||||||
}
|
}
|
||||||
if (type->Is<ast::type::I32>()) {
|
if (type->Is<type::I32>()) {
|
||||||
return create<ast::ScalarConstructorExpression>(
|
return create<ast::ScalarConstructorExpression>(
|
||||||
Source{}, create<ast::SintLiteral>(Source{}, type, 0));
|
Source{}, create<ast::SintLiteral>(Source{}, type, 0));
|
||||||
}
|
}
|
||||||
if (type->Is<ast::type::F32>()) {
|
if (type->Is<type::F32>()) {
|
||||||
return create<ast::ScalarConstructorExpression>(
|
return create<ast::ScalarConstructorExpression>(
|
||||||
Source{}, create<ast::FloatLiteral>(Source{}, type, 0.0f));
|
Source{}, create<ast::FloatLiteral>(Source{}, type, 0.0f));
|
||||||
}
|
}
|
||||||
if (const auto* vec_ty = type->As<ast::type::Vector>()) {
|
if (const auto* vec_ty = type->As<type::Vector>()) {
|
||||||
ast::ExpressionList ast_components;
|
ast::ExpressionList ast_components;
|
||||||
for (size_t i = 0; i < vec_ty->size(); ++i) {
|
for (size_t i = 0; i < vec_ty->size(); ++i) {
|
||||||
ast_components.emplace_back(MakeNullValue(vec_ty->type()));
|
ast_components.emplace_back(MakeNullValue(vec_ty->type()));
|
||||||
|
@ -1451,10 +1448,10 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
|
||||||
return create<ast::TypeConstructorExpression>(Source{}, type,
|
return create<ast::TypeConstructorExpression>(Source{}, type,
|
||||||
std::move(ast_components));
|
std::move(ast_components));
|
||||||
}
|
}
|
||||||
if (const auto* mat_ty = type->As<ast::type::Matrix>()) {
|
if (const auto* mat_ty = type->As<type::Matrix>()) {
|
||||||
// Matrix components are columns
|
// Matrix components are columns
|
||||||
auto* column_ty =
|
auto* column_ty =
|
||||||
ast_module_.create<ast::type::Vector>(mat_ty->type(), mat_ty->rows());
|
ast_module_.create<type::Vector>(mat_ty->type(), mat_ty->rows());
|
||||||
ast::ExpressionList ast_components;
|
ast::ExpressionList ast_components;
|
||||||
for (size_t i = 0; i < mat_ty->columns(); ++i) {
|
for (size_t i = 0; i < mat_ty->columns(); ++i) {
|
||||||
ast_components.emplace_back(MakeNullValue(column_ty));
|
ast_components.emplace_back(MakeNullValue(column_ty));
|
||||||
|
@ -1462,7 +1459,7 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
|
||||||
return create<ast::TypeConstructorExpression>(Source{}, type,
|
return create<ast::TypeConstructorExpression>(Source{}, type,
|
||||||
std::move(ast_components));
|
std::move(ast_components));
|
||||||
}
|
}
|
||||||
if (auto* arr_ty = type->As<ast::type::Array>()) {
|
if (auto* arr_ty = type->As<type::Array>()) {
|
||||||
ast::ExpressionList ast_components;
|
ast::ExpressionList ast_components;
|
||||||
for (size_t i = 0; i < arr_ty->size(); ++i) {
|
for (size_t i = 0; i < arr_ty->size(); ++i) {
|
||||||
ast_components.emplace_back(MakeNullValue(arr_ty->type()));
|
ast_components.emplace_back(MakeNullValue(arr_ty->type()));
|
||||||
|
@ -1470,7 +1467,7 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
|
||||||
return create<ast::TypeConstructorExpression>(Source{}, original_type,
|
return create<ast::TypeConstructorExpression>(Source{}, original_type,
|
||||||
std::move(ast_components));
|
std::move(ast_components));
|
||||||
}
|
}
|
||||||
if (auto* struct_ty = type->As<ast::type::Struct>()) {
|
if (auto* struct_ty = type->As<type::Struct>()) {
|
||||||
ast::ExpressionList ast_components;
|
ast::ExpressionList ast_components;
|
||||||
for (auto* member : struct_ty->impl()->members()) {
|
for (auto* member : struct_ty->impl()->members()) {
|
||||||
ast_components.emplace_back(MakeNullValue(member->type()));
|
ast_components.emplace_back(MakeNullValue(member->type()));
|
||||||
|
@ -1529,9 +1526,8 @@ TypedExpression ParserImpl::RectifyOperandSignedness(
|
||||||
return std::move(expr);
|
return std::move(expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::ForcedResultType(
|
type::Type* ParserImpl::ForcedResultType(const spvtools::opt::Instruction& inst,
|
||||||
const spvtools::opt::Instruction& inst,
|
type::Type* first_operand_type) {
|
||||||
ast::type::Type* first_operand_type) {
|
|
||||||
const auto opcode = inst.opcode();
|
const auto opcode = inst.opcode();
|
||||||
if (AssumesResultSignednessMatchesFirstOperand(opcode)) {
|
if (AssumesResultSignednessMatchesFirstOperand(opcode)) {
|
||||||
return first_operand_type;
|
return first_operand_type;
|
||||||
|
@ -1546,37 +1542,36 @@ ast::type::Type* ParserImpl::ForcedResultType(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::GetSignedIntMatchingShape(ast::type::Type* other) {
|
type::Type* ParserImpl::GetSignedIntMatchingShape(type::Type* other) {
|
||||||
if (other == nullptr) {
|
if (other == nullptr) {
|
||||||
Fail() << "no type provided";
|
Fail() << "no type provided";
|
||||||
}
|
}
|
||||||
auto* i32 = ast_module_.create<ast::type::I32>();
|
auto* i32 = ast_module_.create<type::I32>();
|
||||||
if (other->Is<ast::type::F32>() || other->Is<ast::type::U32>() ||
|
if (other->Is<type::F32>() || other->Is<type::U32>() ||
|
||||||
other->Is<ast::type::I32>()) {
|
other->Is<type::I32>()) {
|
||||||
return i32;
|
return i32;
|
||||||
}
|
}
|
||||||
auto* vec_ty = other->As<ast::type::Vector>();
|
auto* vec_ty = other->As<type::Vector>();
|
||||||
if (vec_ty) {
|
if (vec_ty) {
|
||||||
return ast_module_.create<ast::type::Vector>(i32, vec_ty->size());
|
return ast_module_.create<type::Vector>(i32, vec_ty->size());
|
||||||
}
|
}
|
||||||
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::GetUnsignedIntMatchingShape(
|
type::Type* ParserImpl::GetUnsignedIntMatchingShape(type::Type* other) {
|
||||||
ast::type::Type* other) {
|
|
||||||
if (other == nullptr) {
|
if (other == nullptr) {
|
||||||
Fail() << "no type provided";
|
Fail() << "no type provided";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto* u32 = ast_module_.create<ast::type::U32>();
|
auto* u32 = ast_module_.create<type::U32>();
|
||||||
if (other->Is<ast::type::F32>() || other->Is<ast::type::U32>() ||
|
if (other->Is<type::F32>() || other->Is<type::U32>() ||
|
||||||
other->Is<ast::type::I32>()) {
|
other->Is<type::I32>()) {
|
||||||
return u32;
|
return u32;
|
||||||
}
|
}
|
||||||
auto* vec_ty = other->As<ast::type::Vector>();
|
auto* vec_ty = other->As<type::Vector>();
|
||||||
if (vec_ty) {
|
if (vec_ty) {
|
||||||
return ast_module_.create<ast::type::Vector>(u32, vec_ty->size());
|
return ast_module_.create<type::Vector>(u32, vec_ty->size());
|
||||||
}
|
}
|
||||||
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -1585,7 +1580,7 @@ ast::type::Type* ParserImpl::GetUnsignedIntMatchingShape(
|
||||||
TypedExpression ParserImpl::RectifyForcedResultType(
|
TypedExpression ParserImpl::RectifyForcedResultType(
|
||||||
TypedExpression expr,
|
TypedExpression expr,
|
||||||
const spvtools::opt::Instruction& inst,
|
const spvtools::opt::Instruction& inst,
|
||||||
ast::type::Type* first_operand_type) {
|
type::Type* first_operand_type) {
|
||||||
auto* forced_result_ty = ForcedResultType(inst, first_operand_type);
|
auto* forced_result_ty = ForcedResultType(inst, first_operand_type);
|
||||||
if ((forced_result_ty == nullptr) || (forced_result_ty == expr.type)) {
|
if ((forced_result_ty == nullptr) || (forced_result_ty == expr.type)) {
|
||||||
return expr;
|
return expr;
|
||||||
|
@ -1764,7 +1759,7 @@ ParserImpl::GetSpirvTypeForHandleMemoryObjectDeclaration(
|
||||||
return raw_handle_type;
|
return raw_handle_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Pointer* ParserImpl::GetTypeForHandleVar(
|
type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
const spvtools::opt::Instruction& var) {
|
const spvtools::opt::Instruction& var) {
|
||||||
auto where = handle_type_.find(&var);
|
auto where = handle_type_.find(&var);
|
||||||
if (where != handle_type_.end()) {
|
if (where != handle_type_.end()) {
|
||||||
|
@ -1848,11 +1843,11 @@ ast::type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the Tint handle type.
|
// Construct the Tint handle type.
|
||||||
ast::type::Type* ast_store_type = nullptr;
|
type::Type* ast_store_type = nullptr;
|
||||||
if (usage.IsSampler()) {
|
if (usage.IsSampler()) {
|
||||||
ast_store_type = ast_module_.create<ast::type::Sampler>(
|
ast_store_type = ast_module_.create<type::Sampler>(
|
||||||
usage.IsComparisonSampler() ? ast::type::SamplerKind::kComparisonSampler
|
usage.IsComparisonSampler() ? type::SamplerKind::kComparisonSampler
|
||||||
: ast::type::SamplerKind::kSampler);
|
: type::SamplerKind::kSampler);
|
||||||
} else if (usage.IsTexture()) {
|
} else if (usage.IsTexture()) {
|
||||||
const spvtools::opt::analysis::Image* image_type =
|
const spvtools::opt::analysis::Image* image_type =
|
||||||
type_mgr_->GetType(raw_handle_type->result_id())->AsImage();
|
type_mgr_->GetType(raw_handle_type->result_id())->AsImage();
|
||||||
|
@ -1862,9 +1857,9 @@ ast::type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ast::type::TextureDimension dim =
|
const type::TextureDimension dim =
|
||||||
enum_converter_.ToDim(image_type->dim(), image_type->is_arrayed());
|
enum_converter_.ToDim(image_type->dim(), image_type->is_arrayed());
|
||||||
if (dim == ast::type::TextureDimension::kNone) {
|
if (dim == type::TextureDimension::kNone) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1881,13 +1876,13 @@ ast::type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
// OpImage variable with an OpImage*Dref* instruction. In WGSL we must
|
// OpImage variable with an OpImage*Dref* instruction. In WGSL we must
|
||||||
// treat that as a depth texture.
|
// treat that as a depth texture.
|
||||||
if (image_type->depth() || usage.IsDepthTexture()) {
|
if (image_type->depth() || usage.IsDepthTexture()) {
|
||||||
ast_store_type = ast_module_.create<ast::type::DepthTexture>(dim);
|
ast_store_type = ast_module_.create<type::DepthTexture>(dim);
|
||||||
} else if (image_type->is_multisampled()) {
|
} else if (image_type->is_multisampled()) {
|
||||||
// Multisampled textures are never depth textures.
|
// Multisampled textures are never depth textures.
|
||||||
ast_store_type = ast_module_.create<ast::type::MultisampledTexture>(
|
ast_store_type = ast_module_.create<type::MultisampledTexture>(
|
||||||
dim, ast_sampled_component_type);
|
dim, ast_sampled_component_type);
|
||||||
} else {
|
} else {
|
||||||
ast_store_type = ast_module_.create<ast::type::SampledTexture>(
|
ast_store_type = ast_module_.create<type::SampledTexture>(
|
||||||
dim, ast_sampled_component_type);
|
dim, ast_sampled_component_type);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1895,11 +1890,11 @@ ast::type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
? ast::AccessControl::kReadOnly
|
? ast::AccessControl::kReadOnly
|
||||||
: ast::AccessControl::kWriteOnly;
|
: ast::AccessControl::kWriteOnly;
|
||||||
const auto format = enum_converter_.ToImageFormat(image_type->format());
|
const auto format = enum_converter_.ToImageFormat(image_type->format());
|
||||||
if (format == ast::type::ImageFormat::kNone) {
|
if (format == type::ImageFormat::kNone) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ast_store_type = ast_module_.create<ast::type::AccessControl>(
|
ast_store_type = ast_module_.create<type::AccessControl>(
|
||||||
access, ast_module_.create<ast::type::StorageTexture>(dim, format));
|
access, ast_module_.create<type::StorageTexture>(dim, format));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Fail() << "unsupported: UniformConstant variable is not a recognized "
|
Fail() << "unsupported: UniformConstant variable is not a recognized "
|
||||||
|
@ -1909,56 +1904,55 @@ ast::type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Form the pointer type.
|
// Form the pointer type.
|
||||||
auto* result = ast_module_.create<ast::type::Pointer>(
|
auto* result = ast_module_.create<type::Pointer>(
|
||||||
ast_store_type, ast::StorageClass::kUniformConstant);
|
ast_store_type, ast::StorageClass::kUniformConstant);
|
||||||
// Remember it for later.
|
// Remember it for later.
|
||||||
handle_type_[&var] = result;
|
handle_type_[&var] = result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::GetComponentTypeForFormat(
|
type::Type* ParserImpl::GetComponentTypeForFormat(type::ImageFormat format) {
|
||||||
ast::type::ImageFormat format) {
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case ast::type::ImageFormat::kR8Uint:
|
case type::ImageFormat::kR8Uint:
|
||||||
case ast::type::ImageFormat::kR16Uint:
|
case type::ImageFormat::kR16Uint:
|
||||||
case ast::type::ImageFormat::kRg8Uint:
|
case type::ImageFormat::kRg8Uint:
|
||||||
case ast::type::ImageFormat::kR32Uint:
|
case type::ImageFormat::kR32Uint:
|
||||||
case ast::type::ImageFormat::kRg16Uint:
|
case type::ImageFormat::kRg16Uint:
|
||||||
case ast::type::ImageFormat::kRgba8Uint:
|
case type::ImageFormat::kRgba8Uint:
|
||||||
case ast::type::ImageFormat::kRg32Uint:
|
case type::ImageFormat::kRg32Uint:
|
||||||
case ast::type::ImageFormat::kRgba16Uint:
|
case type::ImageFormat::kRgba16Uint:
|
||||||
case ast::type::ImageFormat::kRgba32Uint:
|
case type::ImageFormat::kRgba32Uint:
|
||||||
return ast_module_.create<ast::type::U32>();
|
return ast_module_.create<type::U32>();
|
||||||
|
|
||||||
case ast::type::ImageFormat::kR8Sint:
|
case type::ImageFormat::kR8Sint:
|
||||||
case ast::type::ImageFormat::kR16Sint:
|
case type::ImageFormat::kR16Sint:
|
||||||
case ast::type::ImageFormat::kRg8Sint:
|
case type::ImageFormat::kRg8Sint:
|
||||||
case ast::type::ImageFormat::kR32Sint:
|
case type::ImageFormat::kR32Sint:
|
||||||
case ast::type::ImageFormat::kRg16Sint:
|
case type::ImageFormat::kRg16Sint:
|
||||||
case ast::type::ImageFormat::kRgba8Sint:
|
case type::ImageFormat::kRgba8Sint:
|
||||||
case ast::type::ImageFormat::kRg32Sint:
|
case type::ImageFormat::kRg32Sint:
|
||||||
case ast::type::ImageFormat::kRgba16Sint:
|
case type::ImageFormat::kRgba16Sint:
|
||||||
case ast::type::ImageFormat::kRgba32Sint:
|
case type::ImageFormat::kRgba32Sint:
|
||||||
return ast_module_.create<ast::type::I32>();
|
return ast_module_.create<type::I32>();
|
||||||
|
|
||||||
case ast::type::ImageFormat::kR8Unorm:
|
case type::ImageFormat::kR8Unorm:
|
||||||
case ast::type::ImageFormat::kRg8Unorm:
|
case type::ImageFormat::kRg8Unorm:
|
||||||
case ast::type::ImageFormat::kRgba8Unorm:
|
case type::ImageFormat::kRgba8Unorm:
|
||||||
case ast::type::ImageFormat::kRgba8UnormSrgb:
|
case type::ImageFormat::kRgba8UnormSrgb:
|
||||||
case ast::type::ImageFormat::kBgra8Unorm:
|
case type::ImageFormat::kBgra8Unorm:
|
||||||
case ast::type::ImageFormat::kBgra8UnormSrgb:
|
case type::ImageFormat::kBgra8UnormSrgb:
|
||||||
case ast::type::ImageFormat::kRgb10A2Unorm:
|
case type::ImageFormat::kRgb10A2Unorm:
|
||||||
case ast::type::ImageFormat::kR8Snorm:
|
case type::ImageFormat::kR8Snorm:
|
||||||
case ast::type::ImageFormat::kRg8Snorm:
|
case type::ImageFormat::kRg8Snorm:
|
||||||
case ast::type::ImageFormat::kRgba8Snorm:
|
case type::ImageFormat::kRgba8Snorm:
|
||||||
case ast::type::ImageFormat::kR16Float:
|
case type::ImageFormat::kR16Float:
|
||||||
case ast::type::ImageFormat::kR32Float:
|
case type::ImageFormat::kR32Float:
|
||||||
case ast::type::ImageFormat::kRg16Float:
|
case type::ImageFormat::kRg16Float:
|
||||||
case ast::type::ImageFormat::kRg11B10Float:
|
case type::ImageFormat::kRg11B10Float:
|
||||||
case ast::type::ImageFormat::kRg32Float:
|
case type::ImageFormat::kRg32Float:
|
||||||
case ast::type::ImageFormat::kRgba16Float:
|
case type::ImageFormat::kRgba16Float:
|
||||||
case ast::type::ImageFormat::kRgba32Float:
|
case type::ImageFormat::kRgba32Float:
|
||||||
return ast_module_.create<ast::type::F32>();
|
return ast_module_.create<type::F32>();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1966,57 +1960,56 @@ ast::type::Type* ParserImpl::GetComponentTypeForFormat(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::GetTexelTypeForFormat(
|
type::Type* ParserImpl::GetTexelTypeForFormat(type::ImageFormat format) {
|
||||||
ast::type::ImageFormat format) {
|
|
||||||
auto* component_type = GetComponentTypeForFormat(format);
|
auto* component_type = GetComponentTypeForFormat(format);
|
||||||
if (!component_type) {
|
if (!component_type) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case ast::type::ImageFormat::kR16Float:
|
case type::ImageFormat::kR16Float:
|
||||||
case ast::type::ImageFormat::kR16Sint:
|
case type::ImageFormat::kR16Sint:
|
||||||
case ast::type::ImageFormat::kR16Uint:
|
case type::ImageFormat::kR16Uint:
|
||||||
case ast::type::ImageFormat::kR32Float:
|
case type::ImageFormat::kR32Float:
|
||||||
case ast::type::ImageFormat::kR32Sint:
|
case type::ImageFormat::kR32Sint:
|
||||||
case ast::type::ImageFormat::kR32Uint:
|
case type::ImageFormat::kR32Uint:
|
||||||
case ast::type::ImageFormat::kR8Sint:
|
case type::ImageFormat::kR8Sint:
|
||||||
case ast::type::ImageFormat::kR8Snorm:
|
case type::ImageFormat::kR8Snorm:
|
||||||
case ast::type::ImageFormat::kR8Uint:
|
case type::ImageFormat::kR8Uint:
|
||||||
case ast::type::ImageFormat::kR8Unorm:
|
case type::ImageFormat::kR8Unorm:
|
||||||
// One channel
|
// One channel
|
||||||
return component_type;
|
return component_type;
|
||||||
|
|
||||||
case ast::type::ImageFormat::kRg11B10Float:
|
case type::ImageFormat::kRg11B10Float:
|
||||||
case ast::type::ImageFormat::kRg16Float:
|
case type::ImageFormat::kRg16Float:
|
||||||
case ast::type::ImageFormat::kRg16Sint:
|
case type::ImageFormat::kRg16Sint:
|
||||||
case ast::type::ImageFormat::kRg16Uint:
|
case type::ImageFormat::kRg16Uint:
|
||||||
case ast::type::ImageFormat::kRg32Float:
|
case type::ImageFormat::kRg32Float:
|
||||||
case ast::type::ImageFormat::kRg32Sint:
|
case type::ImageFormat::kRg32Sint:
|
||||||
case ast::type::ImageFormat::kRg32Uint:
|
case type::ImageFormat::kRg32Uint:
|
||||||
case ast::type::ImageFormat::kRg8Sint:
|
case type::ImageFormat::kRg8Sint:
|
||||||
case ast::type::ImageFormat::kRg8Snorm:
|
case type::ImageFormat::kRg8Snorm:
|
||||||
case ast::type::ImageFormat::kRg8Uint:
|
case type::ImageFormat::kRg8Uint:
|
||||||
case ast::type::ImageFormat::kRg8Unorm:
|
case type::ImageFormat::kRg8Unorm:
|
||||||
// Two channels
|
// Two channels
|
||||||
return ast_module_.create<ast::type::Vector>(component_type, 2);
|
return ast_module_.create<type::Vector>(component_type, 2);
|
||||||
|
|
||||||
case ast::type::ImageFormat::kBgra8Unorm:
|
case type::ImageFormat::kBgra8Unorm:
|
||||||
case ast::type::ImageFormat::kBgra8UnormSrgb:
|
case type::ImageFormat::kBgra8UnormSrgb:
|
||||||
case ast::type::ImageFormat::kRgb10A2Unorm:
|
case type::ImageFormat::kRgb10A2Unorm:
|
||||||
case ast::type::ImageFormat::kRgba16Float:
|
case type::ImageFormat::kRgba16Float:
|
||||||
case ast::type::ImageFormat::kRgba16Sint:
|
case type::ImageFormat::kRgba16Sint:
|
||||||
case ast::type::ImageFormat::kRgba16Uint:
|
case type::ImageFormat::kRgba16Uint:
|
||||||
case ast::type::ImageFormat::kRgba32Float:
|
case type::ImageFormat::kRgba32Float:
|
||||||
case ast::type::ImageFormat::kRgba32Sint:
|
case type::ImageFormat::kRgba32Sint:
|
||||||
case ast::type::ImageFormat::kRgba32Uint:
|
case type::ImageFormat::kRgba32Uint:
|
||||||
case ast::type::ImageFormat::kRgba8Sint:
|
case type::ImageFormat::kRgba8Sint:
|
||||||
case ast::type::ImageFormat::kRgba8Snorm:
|
case type::ImageFormat::kRgba8Snorm:
|
||||||
case ast::type::ImageFormat::kRgba8Uint:
|
case type::ImageFormat::kRgba8Uint:
|
||||||
case ast::type::ImageFormat::kRgba8Unorm:
|
case type::ImageFormat::kRgba8Unorm:
|
||||||
case ast::type::ImageFormat::kRgba8UnormSrgb:
|
case type::ImageFormat::kRgba8UnormSrgb:
|
||||||
// Four channels
|
// Four channels
|
||||||
return ast_module_.create<ast::type::Vector>(component_type, 4);
|
return ast_module_.create<type::Vector>(component_type, 4);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -34,10 +34,6 @@
|
||||||
#include "src/ast/expression.h"
|
#include "src/ast/expression.h"
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
#include "src/ast/struct_member_decoration.h"
|
#include "src/ast/struct_member_decoration.h"
|
||||||
#include "src/ast/type/alias_type.h"
|
|
||||||
#include "src/ast/type/array_type.h"
|
|
||||||
#include "src/ast/type/pointer_type.h"
|
|
||||||
#include "src/ast/type/type.h"
|
|
||||||
#include "src/reader/reader.h"
|
#include "src/reader/reader.h"
|
||||||
#include "src/reader/spirv/entry_point_info.h"
|
#include "src/reader/spirv/entry_point_info.h"
|
||||||
#include "src/reader/spirv/enum_converter.h"
|
#include "src/reader/spirv/enum_converter.h"
|
||||||
|
@ -45,6 +41,10 @@
|
||||||
#include "src/reader/spirv/namer.h"
|
#include "src/reader/spirv/namer.h"
|
||||||
#include "src/reader/spirv/usage.h"
|
#include "src/reader/spirv/usage.h"
|
||||||
#include "src/source.h"
|
#include "src/source.h"
|
||||||
|
#include "src/type/alias_type.h"
|
||||||
|
#include "src/type/array_type.h"
|
||||||
|
#include "src/type/pointer_type.h"
|
||||||
|
#include "src/type/type.h"
|
||||||
|
|
||||||
/// This is the implementation of the SPIR-V parser for Tint.
|
/// This is the implementation of the SPIR-V parser for Tint.
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ using DecorationList = std::vector<Decoration>;
|
||||||
/// An AST expression with its type.
|
/// An AST expression with its type.
|
||||||
struct TypedExpression {
|
struct TypedExpression {
|
||||||
/// The type
|
/// The type
|
||||||
ast::type::Type* type = nullptr;
|
type::Type* type = nullptr;
|
||||||
/// The expression
|
/// The expression
|
||||||
ast::Expression* expr = nullptr;
|
ast::Expression* expr = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -147,7 +147,7 @@ class ParserImpl : Reader {
|
||||||
/// after the internal representation of the module has been built.
|
/// after the internal representation of the module has been built.
|
||||||
/// @param type_id the SPIR-V ID of a type.
|
/// @param type_id the SPIR-V ID of a type.
|
||||||
/// @returns a Tint type, or nullptr
|
/// @returns a Tint type, or nullptr
|
||||||
ast::type::Type* ConvertType(uint32_t type_id);
|
type::Type* ConvertType(uint32_t type_id);
|
||||||
|
|
||||||
/// Emits an alias type declaration for the given type, if necessary, and
|
/// Emits an alias type declaration for the given type, if necessary, and
|
||||||
/// also updates the mapping of the SPIR-V type ID to the alias type.
|
/// also updates the mapping of the SPIR-V type ID to the alias type.
|
||||||
|
@ -298,7 +298,7 @@ class ParserImpl : Reader {
|
||||||
/// in the error case
|
/// in the error case
|
||||||
ast::Variable* MakeVariable(uint32_t id,
|
ast::Variable* MakeVariable(uint32_t id,
|
||||||
ast::StorageClass sc,
|
ast::StorageClass sc,
|
||||||
ast::type::Type* type,
|
type::Type* type,
|
||||||
bool is_const,
|
bool is_const,
|
||||||
ast::Expression* constructor,
|
ast::Expression* constructor,
|
||||||
ast::VariableDecorationList decorations);
|
ast::VariableDecorationList decorations);
|
||||||
|
@ -311,7 +311,7 @@ class ParserImpl : Reader {
|
||||||
/// Creates an AST expression node for the null value for the given type.
|
/// Creates an AST expression node for the null value for the given type.
|
||||||
/// @param type the AST type
|
/// @param type the AST type
|
||||||
/// @returns a new expression
|
/// @returns a new expression
|
||||||
ast::Expression* MakeNullValue(ast::type::Type* type);
|
ast::Expression* MakeNullValue(type::Type* type);
|
||||||
|
|
||||||
/// Converts a given expression to the signedness demanded for an operand
|
/// Converts a given expression to the signedness demanded for an operand
|
||||||
/// of the given SPIR-V instruction, if required. If the instruction assumes
|
/// of the given SPIR-V instruction, if required. If the instruction assumes
|
||||||
|
@ -334,8 +334,8 @@ class ParserImpl : Reader {
|
||||||
/// @param inst the SPIR-V instruction
|
/// @param inst the SPIR-V instruction
|
||||||
/// @param first_operand_type the AST type for the first operand.
|
/// @param first_operand_type the AST type for the first operand.
|
||||||
/// @returns the forced AST result type, or nullptr if no forcing is required.
|
/// @returns the forced AST result type, or nullptr if no forcing is required.
|
||||||
ast::type::Type* ForcedResultType(const spvtools::opt::Instruction& inst,
|
type::Type* ForcedResultType(const spvtools::opt::Instruction& inst,
|
||||||
ast::type::Type* first_operand_type);
|
type::Type* first_operand_type);
|
||||||
|
|
||||||
/// Returns a signed integer scalar or vector type matching the shape (scalar,
|
/// Returns a signed integer scalar or vector type matching the shape (scalar,
|
||||||
/// vector, and component bit width) of another type, which itself is a
|
/// vector, and component bit width) of another type, which itself is a
|
||||||
|
@ -343,7 +343,7 @@ class ParserImpl : Reader {
|
||||||
/// requirement.
|
/// requirement.
|
||||||
/// @param other the type whose shape must be matched
|
/// @param other the type whose shape must be matched
|
||||||
/// @returns the signed scalar or vector type
|
/// @returns the signed scalar or vector type
|
||||||
ast::type::Type* GetSignedIntMatchingShape(ast::type::Type* other);
|
type::Type* GetSignedIntMatchingShape(type::Type* other);
|
||||||
|
|
||||||
/// Returns a signed integer scalar or vector type matching the shape (scalar,
|
/// Returns a signed integer scalar or vector type matching the shape (scalar,
|
||||||
/// vector, and component bit width) of another type, which itself is a
|
/// vector, and component bit width) of another type, which itself is a
|
||||||
|
@ -351,7 +351,7 @@ class ParserImpl : Reader {
|
||||||
/// requirement.
|
/// requirement.
|
||||||
/// @param other the type whose shape must be matched
|
/// @param other the type whose shape must be matched
|
||||||
/// @returns the unsigned scalar or vector type
|
/// @returns the unsigned scalar or vector type
|
||||||
ast::type::Type* GetUnsignedIntMatchingShape(ast::type::Type* other);
|
type::Type* GetUnsignedIntMatchingShape(type::Type* other);
|
||||||
|
|
||||||
/// Wraps the given expression in an as-cast to the given expression's type,
|
/// Wraps the given expression in an as-cast to the given expression's type,
|
||||||
/// when the underlying operation produces a forced result type different
|
/// when the underlying operation produces a forced result type different
|
||||||
|
@ -364,10 +364,10 @@ class ParserImpl : Reader {
|
||||||
TypedExpression RectifyForcedResultType(
|
TypedExpression RectifyForcedResultType(
|
||||||
TypedExpression expr,
|
TypedExpression expr,
|
||||||
const spvtools::opt::Instruction& inst,
|
const spvtools::opt::Instruction& inst,
|
||||||
ast::type::Type* first_operand_type);
|
type::Type* first_operand_type);
|
||||||
|
|
||||||
/// @returns the registered boolean type.
|
/// @returns the registered boolean type.
|
||||||
ast::type::Type* Bool() const { return bool_type_; }
|
type::Type* Bool() const { return bool_type_; }
|
||||||
|
|
||||||
/// Bookkeeping used for tracking the "position" builtin variable.
|
/// Bookkeeping used for tracking the "position" builtin variable.
|
||||||
struct BuiltInPositionInfo {
|
struct BuiltInPositionInfo {
|
||||||
|
@ -455,19 +455,18 @@ class ParserImpl : Reader {
|
||||||
/// @param var the OpVariable instruction
|
/// @param var the OpVariable instruction
|
||||||
/// @returns the Tint AST type for the poiner-to-{sampler|texture} or null on
|
/// @returns the Tint AST type for the poiner-to-{sampler|texture} or null on
|
||||||
/// error
|
/// error
|
||||||
ast::type::Pointer* GetTypeForHandleVar(
|
type::Pointer* GetTypeForHandleVar(const spvtools::opt::Instruction& var);
|
||||||
const spvtools::opt::Instruction& var);
|
|
||||||
|
|
||||||
/// Returns the channel component type corresponding to the given image
|
/// Returns the channel component type corresponding to the given image
|
||||||
/// format.
|
/// format.
|
||||||
/// @param format image texel format
|
/// @param format image texel format
|
||||||
/// @returns the component type, one of f32, i32, u32
|
/// @returns the component type, one of f32, i32, u32
|
||||||
ast::type::Type* GetComponentTypeForFormat(ast::type::ImageFormat format);
|
type::Type* GetComponentTypeForFormat(type::ImageFormat format);
|
||||||
|
|
||||||
/// Returns texel type corresponding to the given image format.
|
/// Returns texel type corresponding to the given image format.
|
||||||
/// @param format image texel format
|
/// @param format image texel format
|
||||||
/// @returns the texel format
|
/// @returns the texel format
|
||||||
ast::type::Type* GetTexelTypeForFormat(ast::type::ImageFormat format);
|
type::Type* GetTexelTypeForFormat(type::ImageFormat format);
|
||||||
|
|
||||||
/// Returns the SPIR-V instruction with the given ID, or nullptr.
|
/// Returns the SPIR-V instruction with the given ID, or nullptr.
|
||||||
/// @param id the SPIR-V result ID
|
/// @param id the SPIR-V result ID
|
||||||
|
@ -483,20 +482,20 @@ class ParserImpl : Reader {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Converts a specific SPIR-V type to a Tint type. Integer case
|
/// Converts a specific SPIR-V type to a Tint type. Integer case
|
||||||
ast::type::Type* ConvertType(const spvtools::opt::analysis::Integer* int_ty);
|
type::Type* ConvertType(const spvtools::opt::analysis::Integer* int_ty);
|
||||||
/// Converts a specific SPIR-V type to a Tint type. Float case
|
/// Converts a specific SPIR-V type to a Tint type. Float case
|
||||||
ast::type::Type* ConvertType(const spvtools::opt::analysis::Float* float_ty);
|
type::Type* ConvertType(const spvtools::opt::analysis::Float* float_ty);
|
||||||
/// Converts a specific SPIR-V type to a Tint type. Vector case
|
/// Converts a specific SPIR-V type to a Tint type. Vector case
|
||||||
ast::type::Type* ConvertType(const spvtools::opt::analysis::Vector* vec_ty);
|
type::Type* ConvertType(const spvtools::opt::analysis::Vector* vec_ty);
|
||||||
/// Converts a specific SPIR-V type to a Tint type. Matrix case
|
/// Converts a specific SPIR-V type to a Tint type. Matrix case
|
||||||
ast::type::Type* ConvertType(const spvtools::opt::analysis::Matrix* mat_ty);
|
type::Type* ConvertType(const spvtools::opt::analysis::Matrix* mat_ty);
|
||||||
/// Converts a specific SPIR-V type to a Tint type. RuntimeArray case
|
/// Converts a specific SPIR-V type to a Tint type. RuntimeArray case
|
||||||
/// @param rtarr_ty the Tint type
|
/// @param rtarr_ty the Tint type
|
||||||
ast::type::Type* ConvertType(
|
type::Type* ConvertType(
|
||||||
const spvtools::opt::analysis::RuntimeArray* rtarr_ty);
|
const spvtools::opt::analysis::RuntimeArray* rtarr_ty);
|
||||||
/// Converts a specific SPIR-V type to a Tint type. Array case
|
/// Converts a specific SPIR-V type to a Tint type. Array case
|
||||||
/// @param arr_ty the Tint type
|
/// @param arr_ty the Tint type
|
||||||
ast::type::Type* ConvertType(const spvtools::opt::analysis::Array* arr_ty);
|
type::Type* ConvertType(const spvtools::opt::analysis::Array* arr_ty);
|
||||||
/// Converts a specific SPIR-V type to a Tint type. Struct case.
|
/// Converts a specific SPIR-V type to a Tint type. Struct case.
|
||||||
/// SPIR-V allows distinct struct type definitions for two OpTypeStruct
|
/// SPIR-V allows distinct struct type definitions for two OpTypeStruct
|
||||||
/// that otherwise have the same set of members (and struct and member
|
/// that otherwise have the same set of members (and struct and member
|
||||||
|
@ -508,16 +507,15 @@ class ParserImpl : Reader {
|
||||||
/// not significant to the optimizer's module representation.
|
/// not significant to the optimizer's module representation.
|
||||||
/// @param type_id the SPIR-V ID for the type.
|
/// @param type_id the SPIR-V ID for the type.
|
||||||
/// @param struct_ty the Tint type
|
/// @param struct_ty the Tint type
|
||||||
ast::type::Type* ConvertType(
|
type::Type* ConvertType(uint32_t type_id,
|
||||||
uint32_t type_id,
|
const spvtools::opt::analysis::Struct* struct_ty);
|
||||||
const spvtools::opt::analysis::Struct* struct_ty);
|
|
||||||
/// Converts a specific SPIR-V type to a Tint type. Pointer case
|
/// Converts a specific SPIR-V type to a Tint type. Pointer case
|
||||||
/// The pointer to gl_PerVertex maps to nullptr, and instead is recorded
|
/// The pointer to gl_PerVertex maps to nullptr, and instead is recorded
|
||||||
/// in member #builtin_position_.
|
/// in member #builtin_position_.
|
||||||
/// @param type_id the SPIR-V ID for the type.
|
/// @param type_id the SPIR-V ID for the type.
|
||||||
/// @param ptr_ty the Tint type
|
/// @param ptr_ty the Tint type
|
||||||
ast::type::Type* ConvertType(uint32_t type_id,
|
type::Type* ConvertType(uint32_t type_id,
|
||||||
const spvtools::opt::analysis::Pointer* ptr_ty);
|
const spvtools::opt::analysis::Pointer* ptr_ty);
|
||||||
|
|
||||||
/// Parses the array or runtime-array decorations.
|
/// Parses the array or runtime-array decorations.
|
||||||
/// @param spv_type the SPIR-V array or runtime-array type.
|
/// @param spv_type the SPIR-V array or runtime-array type.
|
||||||
|
@ -549,7 +547,7 @@ class ParserImpl : Reader {
|
||||||
spvtools::MessageConsumer message_consumer_;
|
spvtools::MessageConsumer message_consumer_;
|
||||||
|
|
||||||
// The registered boolean type.
|
// The registered boolean type.
|
||||||
ast::type::Type* bool_type_;
|
type::Type* bool_type_;
|
||||||
|
|
||||||
// An object used to store and generate names for SPIR-V objects.
|
// An object used to store and generate names for SPIR-V objects.
|
||||||
Namer namer_;
|
Namer namer_;
|
||||||
|
@ -582,12 +580,12 @@ class ParserImpl : Reader {
|
||||||
std::unordered_set<uint32_t> glsl_std_450_imports_;
|
std::unordered_set<uint32_t> glsl_std_450_imports_;
|
||||||
|
|
||||||
// Maps a SPIR-V type ID to the corresponding Tint type.
|
// Maps a SPIR-V type ID to the corresponding Tint type.
|
||||||
std::unordered_map<uint32_t, ast::type::Type*> id_to_type_;
|
std::unordered_map<uint32_t, type::Type*> id_to_type_;
|
||||||
|
|
||||||
// Maps an unsigned type corresponding to the given signed type.
|
// Maps an unsigned type corresponding to the given signed type.
|
||||||
std::unordered_map<ast::type::Type*, ast::type::Type*> signed_type_for_;
|
std::unordered_map<type::Type*, type::Type*> signed_type_for_;
|
||||||
// Maps an signed type corresponding to the given unsigned type.
|
// Maps an signed type corresponding to the given unsigned type.
|
||||||
std::unordered_map<ast::type::Type*, ast::type::Type*> unsigned_type_for_;
|
std::unordered_map<type::Type*, type::Type*> unsigned_type_for_;
|
||||||
|
|
||||||
// Bookkeeping for the gl_Position builtin.
|
// Bookkeeping for the gl_Position builtin.
|
||||||
// In Vulkan SPIR-V, it's the 0 member of the gl_PerVertex structure.
|
// In Vulkan SPIR-V, it's the 0 member of the gl_PerVertex structure.
|
||||||
|
@ -607,7 +605,7 @@ class ParserImpl : Reader {
|
||||||
std::unordered_set<uint32_t> remap_buffer_block_type_;
|
std::unordered_set<uint32_t> remap_buffer_block_type_;
|
||||||
|
|
||||||
// The struct types with only read-only members.
|
// The struct types with only read-only members.
|
||||||
std::unordered_set<ast::type::Type*> read_only_struct_types_;
|
std::unordered_set<type::Type*> read_only_struct_types_;
|
||||||
|
|
||||||
// The IDs of scalar spec constants
|
// The IDs of scalar spec constants
|
||||||
std::unordered_set<uint32_t> scalar_spec_constants_;
|
std::unordered_set<uint32_t> scalar_spec_constants_;
|
||||||
|
@ -632,7 +630,7 @@ class ParserImpl : Reader {
|
||||||
// usages implied by usages of the memory-object-declaration.
|
// usages implied by usages of the memory-object-declaration.
|
||||||
std::unordered_map<const spvtools::opt::Instruction*, Usage> handle_usage_;
|
std::unordered_map<const spvtools::opt::Instruction*, Usage> handle_usage_;
|
||||||
// The inferred pointer type for the given handle variable.
|
// The inferred pointer type for the given handle variable.
|
||||||
std::unordered_map<const spvtools::opt::Instruction*, ast::type::Pointer*>
|
std::unordered_map<const spvtools::opt::Instruction*, type::Pointer*>
|
||||||
handle_type_;
|
handle_type_;
|
||||||
|
|
||||||
/// Maps the SPIR-V ID of a module-scope builtin variable that should be
|
/// Maps the SPIR-V ID of a module-scope builtin variable that should be
|
||||||
|
|
|
@ -18,20 +18,20 @@
|
||||||
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "src/ast/struct.h"
|
#include "src/ast/struct.h"
|
||||||
#include "src/ast/type/array_type.h"
|
|
||||||
#include "src/ast/type/bool_type.h"
|
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/matrix_type.h"
|
|
||||||
#include "src/ast/type/pointer_type.h"
|
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/ast/type/type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/type/vector_type.h"
|
|
||||||
#include "src/ast/type/void_type.h"
|
|
||||||
#include "src/reader/spirv/parser_impl.h"
|
#include "src/reader/spirv/parser_impl.h"
|
||||||
#include "src/reader/spirv/parser_impl_test_helper.h"
|
#include "src/reader/spirv/parser_impl_test_helper.h"
|
||||||
#include "src/reader/spirv/spirv_tools_helpers_test.h"
|
#include "src/reader/spirv/spirv_tools_helpers_test.h"
|
||||||
|
#include "src/type/array_type.h"
|
||||||
|
#include "src/type/bool_type.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/matrix_type.h"
|
||||||
|
#include "src/type/pointer_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
#include "src/type/type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
#include "src/type/void_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -92,7 +92,7 @@ TEST_F(SpvParserTest, ConvertType_Void) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(1);
|
auto* type = p->ConvertType(1);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Void>());
|
EXPECT_TRUE(type->Is<type::Void>());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ TEST_F(SpvParserTest, ConvertType_Bool) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(100);
|
auto* type = p->ConvertType(100);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Bool>());
|
EXPECT_TRUE(type->Is<type::Bool>());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ TEST_F(SpvParserTest, ConvertType_I32) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(2);
|
auto* type = p->ConvertType(2);
|
||||||
EXPECT_TRUE(type->Is<ast::type::I32>());
|
EXPECT_TRUE(type->Is<type::I32>());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ TEST_F(SpvParserTest, ConvertType_U32) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(3);
|
auto* type = p->ConvertType(3);
|
||||||
EXPECT_TRUE(type->Is<ast::type::U32>());
|
EXPECT_TRUE(type->Is<type::U32>());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ TEST_F(SpvParserTest, ConvertType_F32) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(4);
|
auto* type = p->ConvertType(4);
|
||||||
EXPECT_TRUE(type->Is<ast::type::F32>());
|
EXPECT_TRUE(type->Is<type::F32>());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,19 +172,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverF32) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* v2xf32 = p->ConvertType(20);
|
auto* v2xf32 = p->ConvertType(20);
|
||||||
EXPECT_TRUE(v2xf32->Is<ast::type::Vector>());
|
EXPECT_TRUE(v2xf32->Is<type::Vector>());
|
||||||
EXPECT_TRUE(v2xf32->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(v2xf32->As<type::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(v2xf32->As<ast::type::Vector>()->size(), 2u);
|
EXPECT_EQ(v2xf32->As<type::Vector>()->size(), 2u);
|
||||||
|
|
||||||
auto* v3xf32 = p->ConvertType(30);
|
auto* v3xf32 = p->ConvertType(30);
|
||||||
EXPECT_TRUE(v3xf32->Is<ast::type::Vector>());
|
EXPECT_TRUE(v3xf32->Is<type::Vector>());
|
||||||
EXPECT_TRUE(v3xf32->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(v3xf32->As<type::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(v3xf32->As<ast::type::Vector>()->size(), 3u);
|
EXPECT_EQ(v3xf32->As<type::Vector>()->size(), 3u);
|
||||||
|
|
||||||
auto* v4xf32 = p->ConvertType(40);
|
auto* v4xf32 = p->ConvertType(40);
|
||||||
EXPECT_TRUE(v4xf32->Is<ast::type::Vector>());
|
EXPECT_TRUE(v4xf32->Is<type::Vector>());
|
||||||
EXPECT_TRUE(v4xf32->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(v4xf32->As<type::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(v4xf32->As<ast::type::Vector>()->size(), 4u);
|
EXPECT_EQ(v4xf32->As<type::Vector>()->size(), 4u);
|
||||||
|
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -199,19 +199,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverI32) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* v2xi32 = p->ConvertType(20);
|
auto* v2xi32 = p->ConvertType(20);
|
||||||
EXPECT_TRUE(v2xi32->Is<ast::type::Vector>());
|
EXPECT_TRUE(v2xi32->Is<type::Vector>());
|
||||||
EXPECT_TRUE(v2xi32->As<ast::type::Vector>()->type()->Is<ast::type::I32>());
|
EXPECT_TRUE(v2xi32->As<type::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(v2xi32->As<ast::type::Vector>()->size(), 2u);
|
EXPECT_EQ(v2xi32->As<type::Vector>()->size(), 2u);
|
||||||
|
|
||||||
auto* v3xi32 = p->ConvertType(30);
|
auto* v3xi32 = p->ConvertType(30);
|
||||||
EXPECT_TRUE(v3xi32->Is<ast::type::Vector>());
|
EXPECT_TRUE(v3xi32->Is<type::Vector>());
|
||||||
EXPECT_TRUE(v3xi32->As<ast::type::Vector>()->type()->Is<ast::type::I32>());
|
EXPECT_TRUE(v3xi32->As<type::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(v3xi32->As<ast::type::Vector>()->size(), 3u);
|
EXPECT_EQ(v3xi32->As<type::Vector>()->size(), 3u);
|
||||||
|
|
||||||
auto* v4xi32 = p->ConvertType(40);
|
auto* v4xi32 = p->ConvertType(40);
|
||||||
EXPECT_TRUE(v4xi32->Is<ast::type::Vector>());
|
EXPECT_TRUE(v4xi32->Is<type::Vector>());
|
||||||
EXPECT_TRUE(v4xi32->As<ast::type::Vector>()->type()->Is<ast::type::I32>());
|
EXPECT_TRUE(v4xi32->As<type::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(v4xi32->As<ast::type::Vector>()->size(), 4u);
|
EXPECT_EQ(v4xi32->As<type::Vector>()->size(), 4u);
|
||||||
|
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -226,19 +226,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverU32) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* v2xu32 = p->ConvertType(20);
|
auto* v2xu32 = p->ConvertType(20);
|
||||||
EXPECT_TRUE(v2xu32->Is<ast::type::Vector>());
|
EXPECT_TRUE(v2xu32->Is<type::Vector>());
|
||||||
EXPECT_TRUE(v2xu32->As<ast::type::Vector>()->type()->Is<ast::type::U32>());
|
EXPECT_TRUE(v2xu32->As<type::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(v2xu32->As<ast::type::Vector>()->size(), 2u);
|
EXPECT_EQ(v2xu32->As<type::Vector>()->size(), 2u);
|
||||||
|
|
||||||
auto* v3xu32 = p->ConvertType(30);
|
auto* v3xu32 = p->ConvertType(30);
|
||||||
EXPECT_TRUE(v3xu32->Is<ast::type::Vector>());
|
EXPECT_TRUE(v3xu32->Is<type::Vector>());
|
||||||
EXPECT_TRUE(v3xu32->As<ast::type::Vector>()->type()->Is<ast::type::U32>());
|
EXPECT_TRUE(v3xu32->As<type::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(v3xu32->As<ast::type::Vector>()->size(), 3u);
|
EXPECT_EQ(v3xu32->As<type::Vector>()->size(), 3u);
|
||||||
|
|
||||||
auto* v4xu32 = p->ConvertType(40);
|
auto* v4xu32 = p->ConvertType(40);
|
||||||
EXPECT_TRUE(v4xu32->Is<ast::type::Vector>());
|
EXPECT_TRUE(v4xu32->Is<type::Vector>());
|
||||||
EXPECT_TRUE(v4xu32->As<ast::type::Vector>()->type()->Is<ast::type::U32>());
|
EXPECT_TRUE(v4xu32->As<type::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(v4xu32->As<ast::type::Vector>()->size(), 4u);
|
EXPECT_EQ(v4xu32->As<type::Vector>()->size(), 4u);
|
||||||
|
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -278,58 +278,58 @@ TEST_F(SpvParserTest, ConvertType_MatrixOverF32) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* m22 = p->ConvertType(22);
|
auto* m22 = p->ConvertType(22);
|
||||||
EXPECT_TRUE(m22->Is<ast::type::Matrix>());
|
EXPECT_TRUE(m22->Is<type::Matrix>());
|
||||||
EXPECT_TRUE(m22->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(m22->As<type::Matrix>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(m22->As<ast::type::Matrix>()->rows(), 2u);
|
EXPECT_EQ(m22->As<type::Matrix>()->rows(), 2u);
|
||||||
EXPECT_EQ(m22->As<ast::type::Matrix>()->columns(), 2u);
|
EXPECT_EQ(m22->As<type::Matrix>()->columns(), 2u);
|
||||||
|
|
||||||
auto* m23 = p->ConvertType(23);
|
auto* m23 = p->ConvertType(23);
|
||||||
EXPECT_TRUE(m23->Is<ast::type::Matrix>());
|
EXPECT_TRUE(m23->Is<type::Matrix>());
|
||||||
EXPECT_TRUE(m23->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(m23->As<type::Matrix>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(m23->As<ast::type::Matrix>()->rows(), 2u);
|
EXPECT_EQ(m23->As<type::Matrix>()->rows(), 2u);
|
||||||
EXPECT_EQ(m23->As<ast::type::Matrix>()->columns(), 3u);
|
EXPECT_EQ(m23->As<type::Matrix>()->columns(), 3u);
|
||||||
|
|
||||||
auto* m24 = p->ConvertType(24);
|
auto* m24 = p->ConvertType(24);
|
||||||
EXPECT_TRUE(m24->Is<ast::type::Matrix>());
|
EXPECT_TRUE(m24->Is<type::Matrix>());
|
||||||
EXPECT_TRUE(m24->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(m24->As<type::Matrix>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(m24->As<ast::type::Matrix>()->rows(), 2u);
|
EXPECT_EQ(m24->As<type::Matrix>()->rows(), 2u);
|
||||||
EXPECT_EQ(m24->As<ast::type::Matrix>()->columns(), 4u);
|
EXPECT_EQ(m24->As<type::Matrix>()->columns(), 4u);
|
||||||
|
|
||||||
auto* m32 = p->ConvertType(32);
|
auto* m32 = p->ConvertType(32);
|
||||||
EXPECT_TRUE(m32->Is<ast::type::Matrix>());
|
EXPECT_TRUE(m32->Is<type::Matrix>());
|
||||||
EXPECT_TRUE(m32->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(m32->As<type::Matrix>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(m32->As<ast::type::Matrix>()->rows(), 3u);
|
EXPECT_EQ(m32->As<type::Matrix>()->rows(), 3u);
|
||||||
EXPECT_EQ(m32->As<ast::type::Matrix>()->columns(), 2u);
|
EXPECT_EQ(m32->As<type::Matrix>()->columns(), 2u);
|
||||||
|
|
||||||
auto* m33 = p->ConvertType(33);
|
auto* m33 = p->ConvertType(33);
|
||||||
EXPECT_TRUE(m33->Is<ast::type::Matrix>());
|
EXPECT_TRUE(m33->Is<type::Matrix>());
|
||||||
EXPECT_TRUE(m33->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(m33->As<type::Matrix>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(m33->As<ast::type::Matrix>()->rows(), 3u);
|
EXPECT_EQ(m33->As<type::Matrix>()->rows(), 3u);
|
||||||
EXPECT_EQ(m33->As<ast::type::Matrix>()->columns(), 3u);
|
EXPECT_EQ(m33->As<type::Matrix>()->columns(), 3u);
|
||||||
|
|
||||||
auto* m34 = p->ConvertType(34);
|
auto* m34 = p->ConvertType(34);
|
||||||
EXPECT_TRUE(m34->Is<ast::type::Matrix>());
|
EXPECT_TRUE(m34->Is<type::Matrix>());
|
||||||
EXPECT_TRUE(m34->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(m34->As<type::Matrix>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(m34->As<ast::type::Matrix>()->rows(), 3u);
|
EXPECT_EQ(m34->As<type::Matrix>()->rows(), 3u);
|
||||||
EXPECT_EQ(m34->As<ast::type::Matrix>()->columns(), 4u);
|
EXPECT_EQ(m34->As<type::Matrix>()->columns(), 4u);
|
||||||
|
|
||||||
auto* m42 = p->ConvertType(42);
|
auto* m42 = p->ConvertType(42);
|
||||||
EXPECT_TRUE(m42->Is<ast::type::Matrix>());
|
EXPECT_TRUE(m42->Is<type::Matrix>());
|
||||||
EXPECT_TRUE(m42->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(m42->As<type::Matrix>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(m42->As<ast::type::Matrix>()->rows(), 4u);
|
EXPECT_EQ(m42->As<type::Matrix>()->rows(), 4u);
|
||||||
EXPECT_EQ(m42->As<ast::type::Matrix>()->columns(), 2u);
|
EXPECT_EQ(m42->As<type::Matrix>()->columns(), 2u);
|
||||||
|
|
||||||
auto* m43 = p->ConvertType(43);
|
auto* m43 = p->ConvertType(43);
|
||||||
EXPECT_TRUE(m43->Is<ast::type::Matrix>());
|
EXPECT_TRUE(m43->Is<type::Matrix>());
|
||||||
EXPECT_TRUE(m43->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(m43->As<type::Matrix>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(m43->As<ast::type::Matrix>()->rows(), 4u);
|
EXPECT_EQ(m43->As<type::Matrix>()->rows(), 4u);
|
||||||
EXPECT_EQ(m43->As<ast::type::Matrix>()->columns(), 3u);
|
EXPECT_EQ(m43->As<type::Matrix>()->columns(), 3u);
|
||||||
|
|
||||||
auto* m44 = p->ConvertType(44);
|
auto* m44 = p->ConvertType(44);
|
||||||
EXPECT_TRUE(m44->Is<ast::type::Matrix>());
|
EXPECT_TRUE(m44->Is<type::Matrix>());
|
||||||
EXPECT_TRUE(m44->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(m44->As<type::Matrix>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(m44->As<ast::type::Matrix>()->rows(), 4u);
|
EXPECT_EQ(m44->As<type::Matrix>()->rows(), 4u);
|
||||||
EXPECT_EQ(m44->As<ast::type::Matrix>()->columns(), 4u);
|
EXPECT_EQ(m44->As<type::Matrix>()->columns(), 4u);
|
||||||
|
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -343,8 +343,8 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) {
|
||||||
|
|
||||||
auto* type = p->ConvertType(10);
|
auto* type = p->ConvertType(10);
|
||||||
ASSERT_NE(type, nullptr);
|
ASSERT_NE(type, nullptr);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Array>());
|
EXPECT_TRUE(type->Is<type::Array>());
|
||||||
auto* arr_type = type->As<ast::type::Array>();
|
auto* arr_type = type->As<type::Array>();
|
||||||
EXPECT_TRUE(arr_type->IsRuntimeArray());
|
EXPECT_TRUE(arr_type->IsRuntimeArray());
|
||||||
ASSERT_NE(arr_type, nullptr);
|
ASSERT_NE(arr_type, nullptr);
|
||||||
EXPECT_EQ(arr_type->size(), 0u);
|
EXPECT_EQ(arr_type->size(), 0u);
|
||||||
|
@ -352,7 +352,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) {
|
||||||
EXPECT_FALSE(arr_type->has_array_stride());
|
EXPECT_FALSE(arr_type->has_array_stride());
|
||||||
auto* elem_type = arr_type->type();
|
auto* elem_type = arr_type->type();
|
||||||
ASSERT_NE(elem_type, nullptr);
|
ASSERT_NE(elem_type, nullptr);
|
||||||
EXPECT_TRUE(elem_type->Is<ast::type::U32>());
|
EXPECT_TRUE(elem_type->Is<type::U32>());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_Valid) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
auto* type = p->ConvertType(10);
|
auto* type = p->ConvertType(10);
|
||||||
ASSERT_NE(type, nullptr);
|
ASSERT_NE(type, nullptr);
|
||||||
auto* arr_type = type->As<ast::type::Array>();
|
auto* arr_type = type->As<type::Array>();
|
||||||
EXPECT_TRUE(arr_type->IsRuntimeArray());
|
EXPECT_TRUE(arr_type->IsRuntimeArray());
|
||||||
ASSERT_NE(arr_type, nullptr);
|
ASSERT_NE(arr_type, nullptr);
|
||||||
EXPECT_EQ(arr_type->array_stride(), 64u);
|
EXPECT_EQ(arr_type->array_stride(), 64u);
|
||||||
|
@ -425,8 +425,8 @@ TEST_F(SpvParserTest, ConvertType_Array) {
|
||||||
|
|
||||||
auto* type = p->ConvertType(10);
|
auto* type = p->ConvertType(10);
|
||||||
ASSERT_NE(type, nullptr);
|
ASSERT_NE(type, nullptr);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Array>());
|
EXPECT_TRUE(type->Is<type::Array>());
|
||||||
auto* arr_type = type->As<ast::type::Array>();
|
auto* arr_type = type->As<type::Array>();
|
||||||
EXPECT_FALSE(arr_type->IsRuntimeArray());
|
EXPECT_FALSE(arr_type->IsRuntimeArray());
|
||||||
ASSERT_NE(arr_type, nullptr);
|
ASSERT_NE(arr_type, nullptr);
|
||||||
EXPECT_EQ(arr_type->size(), 42u);
|
EXPECT_EQ(arr_type->size(), 42u);
|
||||||
|
@ -434,7 +434,7 @@ TEST_F(SpvParserTest, ConvertType_Array) {
|
||||||
EXPECT_FALSE(arr_type->has_array_stride());
|
EXPECT_FALSE(arr_type->has_array_stride());
|
||||||
auto* elem_type = arr_type->type();
|
auto* elem_type = arr_type->type();
|
||||||
ASSERT_NE(elem_type, nullptr);
|
ASSERT_NE(elem_type, nullptr);
|
||||||
EXPECT_TRUE(elem_type->Is<ast::type::U32>());
|
EXPECT_TRUE(elem_type->Is<type::U32>());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,8 +513,8 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_Valid) {
|
||||||
|
|
||||||
auto* type = p->ConvertType(10);
|
auto* type = p->ConvertType(10);
|
||||||
ASSERT_NE(type, nullptr);
|
ASSERT_NE(type, nullptr);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Array>());
|
EXPECT_TRUE(type->Is<type::Array>());
|
||||||
auto* arr_type = type->As<ast::type::Array>();
|
auto* arr_type = type->As<type::Array>();
|
||||||
ASSERT_NE(arr_type, nullptr);
|
ASSERT_NE(arr_type, nullptr);
|
||||||
ASSERT_EQ(arr_type->array_stride(), 8u);
|
ASSERT_EQ(arr_type->array_stride(), 8u);
|
||||||
EXPECT_TRUE(arr_type->has_array_stride());
|
EXPECT_TRUE(arr_type->has_array_stride());
|
||||||
|
@ -563,9 +563,9 @@ TEST_F(SpvParserTest, ConvertType_StructTwoMembers) {
|
||||||
|
|
||||||
auto* type = p->ConvertType(10);
|
auto* type = p->ConvertType(10);
|
||||||
ASSERT_NE(type, nullptr);
|
ASSERT_NE(type, nullptr);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Struct>());
|
EXPECT_TRUE(type->Is<type::Struct>());
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
type->As<ast::type::Struct>()->impl()->to_str(ss, 0);
|
type->As<type::Struct>()->impl()->to_str(ss, 0);
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), ss.str()), Eq(R"(Struct{
|
EXPECT_THAT(Demangler().Demangle(p->get_module(), ss.str()), Eq(R"(Struct{
|
||||||
StructMember{field0: __u32}
|
StructMember{field0: __u32}
|
||||||
StructMember{field1: __f32}
|
StructMember{field1: __f32}
|
||||||
|
@ -584,9 +584,9 @@ TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) {
|
||||||
|
|
||||||
auto* type = p->ConvertType(10);
|
auto* type = p->ConvertType(10);
|
||||||
ASSERT_NE(type, nullptr);
|
ASSERT_NE(type, nullptr);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Struct>());
|
EXPECT_TRUE(type->Is<type::Struct>());
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
type->As<ast::type::Struct>()->impl()->to_str(ss, 0);
|
type->As<type::Struct>()->impl()->to_str(ss, 0);
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), ss.str()), Eq(R"(Struct{
|
EXPECT_THAT(Demangler().Demangle(p->get_module(), ss.str()), Eq(R"(Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
StructMember{field0: __u32}
|
StructMember{field0: __u32}
|
||||||
|
@ -609,9 +609,9 @@ TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) {
|
||||||
|
|
||||||
auto* type = p->ConvertType(10);
|
auto* type = p->ConvertType(10);
|
||||||
ASSERT_NE(type, nullptr);
|
ASSERT_NE(type, nullptr);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Struct>());
|
EXPECT_TRUE(type->Is<type::Struct>());
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
type->As<ast::type::Struct>()->impl()->to_str(ss, 0);
|
type->As<type::Struct>()->impl()->to_str(ss, 0);
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), ss.str()), Eq(R"(Struct{
|
EXPECT_THAT(Demangler().Demangle(p->get_module(), ss.str()), Eq(R"(Struct{
|
||||||
StructMember{[[ offset 0 ]] field0: __f32}
|
StructMember{[[ offset 0 ]] field0: __f32}
|
||||||
StructMember{[[ offset 8 ]] field1: __vec_2__f32}
|
StructMember{[[ offset 8 ]] field1: __vec_2__f32}
|
||||||
|
@ -658,10 +658,10 @@ TEST_F(SpvParserTest, ConvertType_PointerInput) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(3);
|
auto* type = p->ConvertType(3);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Pointer>());
|
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||||
auto* ptr_ty = type->As<ast::type::Pointer>();
|
auto* ptr_ty = type->As<type::Pointer>();
|
||||||
EXPECT_NE(ptr_ty, nullptr);
|
EXPECT_NE(ptr_ty, nullptr);
|
||||||
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
|
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -674,10 +674,10 @@ TEST_F(SpvParserTest, ConvertType_PointerOutput) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(3);
|
auto* type = p->ConvertType(3);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Pointer>());
|
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||||
auto* ptr_ty = type->As<ast::type::Pointer>();
|
auto* ptr_ty = type->As<type::Pointer>();
|
||||||
EXPECT_NE(ptr_ty, nullptr);
|
EXPECT_NE(ptr_ty, nullptr);
|
||||||
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kOutput);
|
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kOutput);
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -690,10 +690,10 @@ TEST_F(SpvParserTest, ConvertType_PointerUniform) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(3);
|
auto* type = p->ConvertType(3);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Pointer>());
|
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||||
auto* ptr_ty = type->As<ast::type::Pointer>();
|
auto* ptr_ty = type->As<type::Pointer>();
|
||||||
EXPECT_NE(ptr_ty, nullptr);
|
EXPECT_NE(ptr_ty, nullptr);
|
||||||
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniform);
|
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniform);
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -706,10 +706,10 @@ TEST_F(SpvParserTest, ConvertType_PointerWorkgroup) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(3);
|
auto* type = p->ConvertType(3);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Pointer>());
|
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||||
auto* ptr_ty = type->As<ast::type::Pointer>();
|
auto* ptr_ty = type->As<type::Pointer>();
|
||||||
EXPECT_NE(ptr_ty, nullptr);
|
EXPECT_NE(ptr_ty, nullptr);
|
||||||
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kWorkgroup);
|
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kWorkgroup);
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -722,10 +722,10 @@ TEST_F(SpvParserTest, ConvertType_PointerUniformConstant) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(3);
|
auto* type = p->ConvertType(3);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Pointer>());
|
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||||
auto* ptr_ty = type->As<ast::type::Pointer>();
|
auto* ptr_ty = type->As<type::Pointer>();
|
||||||
EXPECT_NE(ptr_ty, nullptr);
|
EXPECT_NE(ptr_ty, nullptr);
|
||||||
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniformConstant);
|
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniformConstant);
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -738,10 +738,10 @@ TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(3);
|
auto* type = p->ConvertType(3);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Pointer>());
|
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||||
auto* ptr_ty = type->As<ast::type::Pointer>();
|
auto* ptr_ty = type->As<type::Pointer>();
|
||||||
EXPECT_NE(ptr_ty, nullptr);
|
EXPECT_NE(ptr_ty, nullptr);
|
||||||
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kStorage);
|
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kStorage);
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -754,10 +754,10 @@ TEST_F(SpvParserTest, ConvertType_PointerImage) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(3);
|
auto* type = p->ConvertType(3);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Pointer>());
|
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||||
auto* ptr_ty = type->As<ast::type::Pointer>();
|
auto* ptr_ty = type->As<type::Pointer>();
|
||||||
EXPECT_NE(ptr_ty, nullptr);
|
EXPECT_NE(ptr_ty, nullptr);
|
||||||
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kImage);
|
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kImage);
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -770,10 +770,10 @@ TEST_F(SpvParserTest, ConvertType_PointerPrivate) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(3);
|
auto* type = p->ConvertType(3);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Pointer>());
|
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||||
auto* ptr_ty = type->As<ast::type::Pointer>();
|
auto* ptr_ty = type->As<type::Pointer>();
|
||||||
EXPECT_NE(ptr_ty, nullptr);
|
EXPECT_NE(ptr_ty, nullptr);
|
||||||
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kPrivate);
|
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kPrivate);
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -786,10 +786,10 @@ TEST_F(SpvParserTest, ConvertType_PointerFunction) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(3);
|
auto* type = p->ConvertType(3);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Pointer>());
|
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||||
auto* ptr_ty = type->As<ast::type::Pointer>();
|
auto* ptr_ty = type->As<type::Pointer>();
|
||||||
EXPECT_NE(ptr_ty, nullptr);
|
EXPECT_NE(ptr_ty, nullptr);
|
||||||
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kFunction);
|
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kFunction);
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -805,17 +805,17 @@ TEST_F(SpvParserTest, ConvertType_PointerToPointer) {
|
||||||
|
|
||||||
auto* type = p->ConvertType(3);
|
auto* type = p->ConvertType(3);
|
||||||
EXPECT_NE(type, nullptr);
|
EXPECT_NE(type, nullptr);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Pointer>());
|
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||||
|
|
||||||
auto* ptr_ty = type->As<ast::type::Pointer>();
|
auto* ptr_ty = type->As<type::Pointer>();
|
||||||
EXPECT_NE(ptr_ty, nullptr);
|
EXPECT_NE(ptr_ty, nullptr);
|
||||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
|
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
|
||||||
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::Pointer>());
|
EXPECT_TRUE(ptr_ty->type()->Is<type::Pointer>());
|
||||||
|
|
||||||
auto* ptr_ptr_ty = ptr_ty->type()->As<ast::type::Pointer>();
|
auto* ptr_ptr_ty = ptr_ty->type()->As<type::Pointer>();
|
||||||
EXPECT_NE(ptr_ptr_ty, nullptr);
|
EXPECT_NE(ptr_ptr_ty, nullptr);
|
||||||
EXPECT_EQ(ptr_ptr_ty->storage_class(), ast::StorageClass::kOutput);
|
EXPECT_EQ(ptr_ptr_ty->storage_class(), ast::StorageClass::kOutput);
|
||||||
EXPECT_TRUE(ptr_ptr_ty->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(ptr_ptr_ty->type()->Is<type::F32>());
|
||||||
|
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
@ -828,7 +828,7 @@ TEST_F(SpvParserTest, ConvertType_Sampler_PretendVoid) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(1);
|
auto* type = p->ConvertType(1);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Void>());
|
EXPECT_TRUE(type->Is<type::Void>());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -841,7 +841,7 @@ TEST_F(SpvParserTest, ConvertType_Image_PretendVoid) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(1);
|
auto* type = p->ConvertType(1);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Void>());
|
EXPECT_TRUE(type->Is<type::Void>());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -854,7 +854,7 @@ TEST_F(SpvParserTest, ConvertType_SampledImage_PretendVoid) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(1);
|
auto* type = p->ConvertType(1);
|
||||||
EXPECT_TRUE(type->Is<ast::type::Void>());
|
EXPECT_TRUE(type->Is<type::Void>());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "src/ast/struct.h"
|
#include "src/ast/struct.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/type/array_type.h"
|
||||||
#include "src/ast/type/matrix_type.h"
|
#include "src/type/matrix_type.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/type/struct_type.h"
|
||||||
#include "src/ast/type/vector_type.h"
|
#include "src/type/vector_type.h"
|
||||||
#include "src/demangler.h"
|
#include "src/demangler.h"
|
||||||
#include "src/reader/spirv/parser_impl.h"
|
#include "src/reader/spirv/parser_impl.h"
|
||||||
#include "src/reader/spirv/parser_impl_test_helper.h"
|
#include "src/reader/spirv/parser_impl_test_helper.h"
|
||||||
|
|
|
@ -45,22 +45,6 @@
|
||||||
#include "src/ast/struct_block_decoration.h"
|
#include "src/ast/struct_block_decoration.h"
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
#include "src/ast/switch_statement.h"
|
#include "src/ast/switch_statement.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
|
||||||
#include "src/ast/type/alias_type.h"
|
|
||||||
#include "src/ast/type/array_type.h"
|
|
||||||
#include "src/ast/type/bool_type.h"
|
|
||||||
#include "src/ast/type/depth_texture_type.h"
|
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/matrix_type.h"
|
|
||||||
#include "src/ast/type/multisampled_texture_type.h"
|
|
||||||
#include "src/ast/type/pointer_type.h"
|
|
||||||
#include "src/ast/type/sampled_texture_type.h"
|
|
||||||
#include "src/ast/type/sampler_type.h"
|
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/type/vector_type.h"
|
|
||||||
#include "src/ast/type/void_type.h"
|
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
#include "src/ast/type_decoration.h"
|
#include "src/ast/type_decoration.h"
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
|
@ -70,6 +54,22 @@
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
#include "src/ast/workgroup_decoration.h"
|
#include "src/ast/workgroup_decoration.h"
|
||||||
#include "src/reader/wgsl/lexer.h"
|
#include "src/reader/wgsl/lexer.h"
|
||||||
|
#include "src/type/access_control_type.h"
|
||||||
|
#include "src/type/alias_type.h"
|
||||||
|
#include "src/type/array_type.h"
|
||||||
|
#include "src/type/bool_type.h"
|
||||||
|
#include "src/type/depth_texture_type.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/matrix_type.h"
|
||||||
|
#include "src/type/multisampled_texture_type.h"
|
||||||
|
#include "src/type/pointer_type.h"
|
||||||
|
#include "src/type/sampled_texture_type.h"
|
||||||
|
#include "src/type/sampler_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
#include "src/type/void_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -196,7 +196,7 @@ ParserImpl::FunctionHeader::FunctionHeader(const FunctionHeader&) = default;
|
||||||
ParserImpl::FunctionHeader::FunctionHeader(Source src,
|
ParserImpl::FunctionHeader::FunctionHeader(Source src,
|
||||||
std::string n,
|
std::string n,
|
||||||
ast::VariableList p,
|
ast::VariableList p,
|
||||||
ast::type::Type* ret_ty)
|
type::Type* ret_ty)
|
||||||
: source(src), name(n), params(p), return_type(ret_ty) {}
|
: source(src), name(n), params(p), return_type(ret_ty) {}
|
||||||
|
|
||||||
ParserImpl::FunctionHeader::~FunctionHeader() = default;
|
ParserImpl::FunctionHeader::~FunctionHeader() = default;
|
||||||
|
@ -260,12 +260,12 @@ Token ParserImpl::peek() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserImpl::register_constructed(const std::string& name,
|
void ParserImpl::register_constructed(const std::string& name,
|
||||||
ast::type::Type* type) {
|
type::Type* type) {
|
||||||
assert(type);
|
assert(type);
|
||||||
registered_constructs_[name] = type;
|
registered_constructs_[name] = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::get_constructed(const std::string& name) {
|
type::Type* ParserImpl::get_constructed(const std::string& name) {
|
||||||
if (registered_constructs_.find(name) == registered_constructs_.end()) {
|
if (registered_constructs_.find(name) == registered_constructs_.end()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ Expect<bool> ParserImpl::expect_global_decl() {
|
||||||
|
|
||||||
auto* type = module_.unique_type(std::move(str.value));
|
auto* type = module_.unique_type(std::move(str.value));
|
||||||
register_constructed(
|
register_constructed(
|
||||||
module_.SymbolToName(type->As<ast::type::Struct>()->symbol()), type);
|
module_.SymbolToName(type->As<type::Struct>()->symbol()), type);
|
||||||
module_.AddConstructedType(type);
|
module_.AddConstructedType(type);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -497,7 +497,7 @@ Maybe<ParserImpl::VarDeclInfo> ParserImpl::variable_decl() {
|
||||||
// | sampled_texture_type LESS_THAN type_decl GREATER_THAN
|
// | sampled_texture_type LESS_THAN type_decl GREATER_THAN
|
||||||
// | multisampled_texture_type LESS_THAN type_decl GREATER_THAN
|
// | multisampled_texture_type LESS_THAN type_decl GREATER_THAN
|
||||||
// | storage_texture_type LESS_THAN image_storage_type GREATER_THAN
|
// | storage_texture_type LESS_THAN image_storage_type GREATER_THAN
|
||||||
Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
|
Maybe<type::Type*> ParserImpl::texture_sampler_types() {
|
||||||
auto type = sampler_type();
|
auto type = sampler_type();
|
||||||
if (type.matched)
|
if (type.matched)
|
||||||
return type;
|
return type;
|
||||||
|
@ -514,7 +514,7 @@ Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
|
||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<ast::type::SampledTexture>(dim.value, subtype.value);
|
return module_.create<type::SampledTexture>(dim.value, subtype.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ms_dim = multisampled_texture_type();
|
auto ms_dim = multisampled_texture_type();
|
||||||
|
@ -525,8 +525,8 @@ Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
|
||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<ast::type::MultisampledTexture>(ms_dim.value,
|
return module_.create<type::MultisampledTexture>(ms_dim.value,
|
||||||
subtype.value);
|
subtype.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto storage = storage_texture_type();
|
auto storage = storage_texture_type();
|
||||||
|
@ -539,8 +539,7 @@ Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
|
||||||
if (format.errored)
|
if (format.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<ast::type::StorageTexture>(storage.value,
|
return module_.create<type::StorageTexture>(storage.value, format.value);
|
||||||
format.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEPRECATED
|
// DEPRECATED
|
||||||
|
@ -554,9 +553,9 @@ Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
|
||||||
if (format.errored)
|
if (format.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<ast::type::AccessControl>(
|
return module_.create<type::AccessControl>(
|
||||||
ac_storage->second, module_.create<ast::type::StorageTexture>(
|
ac_storage->second,
|
||||||
ac_storage->first, format.value));
|
module_.create<type::StorageTexture>(ac_storage->first, format.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
|
@ -565,13 +564,12 @@ Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
|
||||||
// sampler_type
|
// sampler_type
|
||||||
// : SAMPLER
|
// : SAMPLER
|
||||||
// | SAMPLER_COMPARISON
|
// | SAMPLER_COMPARISON
|
||||||
Maybe<ast::type::Type*> ParserImpl::sampler_type() {
|
Maybe<type::Type*> ParserImpl::sampler_type() {
|
||||||
if (match(Token::Type::kSampler))
|
if (match(Token::Type::kSampler))
|
||||||
return module_.create<ast::type::Sampler>(ast::type::SamplerKind::kSampler);
|
return module_.create<type::Sampler>(type::SamplerKind::kSampler);
|
||||||
|
|
||||||
if (match(Token::Type::kComparisonSampler))
|
if (match(Token::Type::kComparisonSampler))
|
||||||
return module_.create<ast::type::Sampler>(
|
return module_.create<type::Sampler>(type::SamplerKind::kComparisonSampler);
|
||||||
ast::type::SamplerKind::kComparisonSampler);
|
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
|
@ -584,36 +582,36 @@ Maybe<ast::type::Type*> ParserImpl::sampler_type() {
|
||||||
// | TEXTURE_SAMPLED_3D
|
// | TEXTURE_SAMPLED_3D
|
||||||
// | TEXTURE_SAMPLED_CUBE
|
// | TEXTURE_SAMPLED_CUBE
|
||||||
// | TEXTURE_SAMPLED_CUBE_ARRAY
|
// | TEXTURE_SAMPLED_CUBE_ARRAY
|
||||||
Maybe<ast::type::TextureDimension> ParserImpl::sampled_texture_type() {
|
Maybe<type::TextureDimension> ParserImpl::sampled_texture_type() {
|
||||||
if (match(Token::Type::kTextureSampled1d))
|
if (match(Token::Type::kTextureSampled1d))
|
||||||
return ast::type::TextureDimension::k1d;
|
return type::TextureDimension::k1d;
|
||||||
|
|
||||||
if (match(Token::Type::kTextureSampled1dArray))
|
if (match(Token::Type::kTextureSampled1dArray))
|
||||||
return ast::type::TextureDimension::k1dArray;
|
return type::TextureDimension::k1dArray;
|
||||||
|
|
||||||
if (match(Token::Type::kTextureSampled2d))
|
if (match(Token::Type::kTextureSampled2d))
|
||||||
return ast::type::TextureDimension::k2d;
|
return type::TextureDimension::k2d;
|
||||||
|
|
||||||
if (match(Token::Type::kTextureSampled2dArray))
|
if (match(Token::Type::kTextureSampled2dArray))
|
||||||
return ast::type::TextureDimension::k2dArray;
|
return type::TextureDimension::k2dArray;
|
||||||
|
|
||||||
if (match(Token::Type::kTextureSampled3d))
|
if (match(Token::Type::kTextureSampled3d))
|
||||||
return ast::type::TextureDimension::k3d;
|
return type::TextureDimension::k3d;
|
||||||
|
|
||||||
if (match(Token::Type::kTextureSampledCube))
|
if (match(Token::Type::kTextureSampledCube))
|
||||||
return ast::type::TextureDimension::kCube;
|
return type::TextureDimension::kCube;
|
||||||
|
|
||||||
if (match(Token::Type::kTextureSampledCubeArray))
|
if (match(Token::Type::kTextureSampledCubeArray))
|
||||||
return ast::type::TextureDimension::kCubeArray;
|
return type::TextureDimension::kCubeArray;
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
// multisampled_texture_type
|
// multisampled_texture_type
|
||||||
// : TEXTURE_MULTISAMPLED_2D
|
// : TEXTURE_MULTISAMPLED_2D
|
||||||
Maybe<ast::type::TextureDimension> ParserImpl::multisampled_texture_type() {
|
Maybe<type::TextureDimension> ParserImpl::multisampled_texture_type() {
|
||||||
if (match(Token::Type::kTextureMultisampled2d))
|
if (match(Token::Type::kTextureMultisampled2d))
|
||||||
return ast::type::TextureDimension::k2d;
|
return type::TextureDimension::k2d;
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
|
@ -624,17 +622,17 @@ Maybe<ast::type::TextureDimension> ParserImpl::multisampled_texture_type() {
|
||||||
// | TEXTURE_STORAGE_2D
|
// | TEXTURE_STORAGE_2D
|
||||||
// | TEXTURE_STORAGE_2D_ARRAY
|
// | TEXTURE_STORAGE_2D_ARRAY
|
||||||
// | TEXTURE_STORAGE_3D
|
// | TEXTURE_STORAGE_3D
|
||||||
Maybe<ast::type::TextureDimension> ParserImpl::storage_texture_type() {
|
Maybe<type::TextureDimension> ParserImpl::storage_texture_type() {
|
||||||
if (match(Token::Type::kTextureStorage1d))
|
if (match(Token::Type::kTextureStorage1d))
|
||||||
return ast::type::TextureDimension::k1d;
|
return type::TextureDimension::k1d;
|
||||||
if (match(Token::Type::kTextureStorage1dArray))
|
if (match(Token::Type::kTextureStorage1dArray))
|
||||||
return ast::type::TextureDimension::k1dArray;
|
return type::TextureDimension::k1dArray;
|
||||||
if (match(Token::Type::kTextureStorage2d))
|
if (match(Token::Type::kTextureStorage2d))
|
||||||
return ast::type::TextureDimension::k2d;
|
return type::TextureDimension::k2d;
|
||||||
if (match(Token::Type::kTextureStorage2dArray))
|
if (match(Token::Type::kTextureStorage2dArray))
|
||||||
return ast::type::TextureDimension::k2dArray;
|
return type::TextureDimension::k2dArray;
|
||||||
if (match(Token::Type::kTextureStorage3d))
|
if (match(Token::Type::kTextureStorage3d))
|
||||||
return ast::type::TextureDimension::k3d;
|
return type::TextureDimension::k3d;
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
|
@ -661,54 +659,49 @@ Maybe<ast::type::TextureDimension> ParserImpl::storage_texture_type() {
|
||||||
// | TEXTURE_STORAGE_WO_2D
|
// | TEXTURE_STORAGE_WO_2D
|
||||||
// | TEXTURE_STORAGE_WO_2D_ARRAY
|
// | TEXTURE_STORAGE_WO_2D_ARRAY
|
||||||
// | TEXTURE_STORAGE_WO_3D
|
// | TEXTURE_STORAGE_WO_3D
|
||||||
Maybe<std::pair<ast::type::TextureDimension, ast::AccessControl>>
|
Maybe<std::pair<type::TextureDimension, ast::AccessControl>>
|
||||||
ParserImpl::storage_texture_type_access_control() {
|
ParserImpl::storage_texture_type_access_control() {
|
||||||
using Ret = std::pair<ast::type::TextureDimension, ast::AccessControl>;
|
using Ret = std::pair<type::TextureDimension, ast::AccessControl>;
|
||||||
if (match(Token::Type::kTextureStorageReadonly1d)) {
|
if (match(Token::Type::kTextureStorageReadonly1d)) {
|
||||||
return Ret{ast::type::TextureDimension::k1d, ast::AccessControl::kReadOnly};
|
return Ret{type::TextureDimension::k1d, ast::AccessControl::kReadOnly};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Token::Type::kTextureStorageReadonly1dArray)) {
|
if (match(Token::Type::kTextureStorageReadonly1dArray)) {
|
||||||
return Ret{ast::type::TextureDimension::k1dArray,
|
return Ret{type::TextureDimension::k1dArray, ast::AccessControl::kReadOnly};
|
||||||
ast::AccessControl::kReadOnly};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Token::Type::kTextureStorageReadonly2d)) {
|
if (match(Token::Type::kTextureStorageReadonly2d)) {
|
||||||
return Ret{ast::type::TextureDimension::k2d, ast::AccessControl::kReadOnly};
|
return Ret{type::TextureDimension::k2d, ast::AccessControl::kReadOnly};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Token::Type::kTextureStorageReadonly2dArray)) {
|
if (match(Token::Type::kTextureStorageReadonly2dArray)) {
|
||||||
return Ret{ast::type::TextureDimension::k2dArray,
|
return Ret{type::TextureDimension::k2dArray, ast::AccessControl::kReadOnly};
|
||||||
ast::AccessControl::kReadOnly};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Token::Type::kTextureStorageReadonly3d)) {
|
if (match(Token::Type::kTextureStorageReadonly3d)) {
|
||||||
return Ret{ast::type::TextureDimension::k3d, ast::AccessControl::kReadOnly};
|
return Ret{type::TextureDimension::k3d, ast::AccessControl::kReadOnly};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Token::Type::kTextureStorageWriteonly1d)) {
|
if (match(Token::Type::kTextureStorageWriteonly1d)) {
|
||||||
return Ret{ast::type::TextureDimension::k1d,
|
return Ret{type::TextureDimension::k1d, ast::AccessControl::kWriteOnly};
|
||||||
ast::AccessControl::kWriteOnly};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Token::Type::kTextureStorageWriteonly1dArray)) {
|
if (match(Token::Type::kTextureStorageWriteonly1dArray)) {
|
||||||
return Ret{ast::type::TextureDimension::k1dArray,
|
return Ret{type::TextureDimension::k1dArray,
|
||||||
ast::AccessControl::kWriteOnly};
|
ast::AccessControl::kWriteOnly};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Token::Type::kTextureStorageWriteonly2d)) {
|
if (match(Token::Type::kTextureStorageWriteonly2d)) {
|
||||||
return Ret{ast::type::TextureDimension::k2d,
|
return Ret{type::TextureDimension::k2d, ast::AccessControl::kWriteOnly};
|
||||||
ast::AccessControl::kWriteOnly};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Token::Type::kTextureStorageWriteonly2dArray)) {
|
if (match(Token::Type::kTextureStorageWriteonly2dArray)) {
|
||||||
return Ret{ast::type::TextureDimension::k2dArray,
|
return Ret{type::TextureDimension::k2dArray,
|
||||||
ast::AccessControl::kWriteOnly};
|
ast::AccessControl::kWriteOnly};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Token::Type::kTextureStorageWriteonly3d)) {
|
if (match(Token::Type::kTextureStorageWriteonly3d)) {
|
||||||
return Ret{ast::type::TextureDimension::k3d,
|
return Ret{type::TextureDimension::k3d, ast::AccessControl::kWriteOnly};
|
||||||
ast::AccessControl::kWriteOnly};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
|
@ -719,22 +712,19 @@ ParserImpl::storage_texture_type_access_control() {
|
||||||
// | TEXTURE_DEPTH_2D_ARRAY
|
// | TEXTURE_DEPTH_2D_ARRAY
|
||||||
// | TEXTURE_DEPTH_CUBE
|
// | TEXTURE_DEPTH_CUBE
|
||||||
// | TEXTURE_DEPTH_CUBE_ARRAY
|
// | TEXTURE_DEPTH_CUBE_ARRAY
|
||||||
Maybe<ast::type::Type*> ParserImpl::depth_texture_type() {
|
Maybe<type::Type*> ParserImpl::depth_texture_type() {
|
||||||
if (match(Token::Type::kTextureDepth2d))
|
if (match(Token::Type::kTextureDepth2d))
|
||||||
return module_.create<ast::type::DepthTexture>(
|
return module_.create<type::DepthTexture>(type::TextureDimension::k2d);
|
||||||
ast::type::TextureDimension::k2d);
|
|
||||||
|
|
||||||
if (match(Token::Type::kTextureDepth2dArray))
|
if (match(Token::Type::kTextureDepth2dArray))
|
||||||
return module_.create<ast::type::DepthTexture>(
|
return module_.create<type::DepthTexture>(type::TextureDimension::k2dArray);
|
||||||
ast::type::TextureDimension::k2dArray);
|
|
||||||
|
|
||||||
if (match(Token::Type::kTextureDepthCube))
|
if (match(Token::Type::kTextureDepthCube))
|
||||||
return module_.create<ast::type::DepthTexture>(
|
return module_.create<type::DepthTexture>(type::TextureDimension::kCube);
|
||||||
ast::type::TextureDimension::kCube);
|
|
||||||
|
|
||||||
if (match(Token::Type::kTextureDepthCubeArray))
|
if (match(Token::Type::kTextureDepthCubeArray))
|
||||||
return module_.create<ast::type::DepthTexture>(
|
return module_.create<type::DepthTexture>(
|
||||||
ast::type::TextureDimension::kCubeArray);
|
type::TextureDimension::kCubeArray);
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
|
@ -775,112 +765,112 @@ Maybe<ast::type::Type*> ParserImpl::depth_texture_type() {
|
||||||
// | RGBA32UINT
|
// | RGBA32UINT
|
||||||
// | RGBA32SINT
|
// | RGBA32SINT
|
||||||
// | RGBA32FLOAT
|
// | RGBA32FLOAT
|
||||||
Expect<ast::type::ImageFormat> ParserImpl::expect_image_storage_type(
|
Expect<type::ImageFormat> ParserImpl::expect_image_storage_type(
|
||||||
const std::string& use) {
|
const std::string& use) {
|
||||||
if (match(Token::Type::kFormatR8Unorm))
|
if (match(Token::Type::kFormatR8Unorm))
|
||||||
return ast::type::ImageFormat::kR8Unorm;
|
return type::ImageFormat::kR8Unorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR8Snorm))
|
if (match(Token::Type::kFormatR8Snorm))
|
||||||
return ast::type::ImageFormat::kR8Snorm;
|
return type::ImageFormat::kR8Snorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR8Uint))
|
if (match(Token::Type::kFormatR8Uint))
|
||||||
return ast::type::ImageFormat::kR8Uint;
|
return type::ImageFormat::kR8Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR8Sint))
|
if (match(Token::Type::kFormatR8Sint))
|
||||||
return ast::type::ImageFormat::kR8Sint;
|
return type::ImageFormat::kR8Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR16Uint))
|
if (match(Token::Type::kFormatR16Uint))
|
||||||
return ast::type::ImageFormat::kR16Uint;
|
return type::ImageFormat::kR16Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR16Sint))
|
if (match(Token::Type::kFormatR16Sint))
|
||||||
return ast::type::ImageFormat::kR16Sint;
|
return type::ImageFormat::kR16Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR16Float))
|
if (match(Token::Type::kFormatR16Float))
|
||||||
return ast::type::ImageFormat::kR16Float;
|
return type::ImageFormat::kR16Float;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg8Unorm))
|
if (match(Token::Type::kFormatRg8Unorm))
|
||||||
return ast::type::ImageFormat::kRg8Unorm;
|
return type::ImageFormat::kRg8Unorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg8Snorm))
|
if (match(Token::Type::kFormatRg8Snorm))
|
||||||
return ast::type::ImageFormat::kRg8Snorm;
|
return type::ImageFormat::kRg8Snorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg8Uint))
|
if (match(Token::Type::kFormatRg8Uint))
|
||||||
return ast::type::ImageFormat::kRg8Uint;
|
return type::ImageFormat::kRg8Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg8Sint))
|
if (match(Token::Type::kFormatRg8Sint))
|
||||||
return ast::type::ImageFormat::kRg8Sint;
|
return type::ImageFormat::kRg8Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR32Uint))
|
if (match(Token::Type::kFormatR32Uint))
|
||||||
return ast::type::ImageFormat::kR32Uint;
|
return type::ImageFormat::kR32Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR32Sint))
|
if (match(Token::Type::kFormatR32Sint))
|
||||||
return ast::type::ImageFormat::kR32Sint;
|
return type::ImageFormat::kR32Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR32Float))
|
if (match(Token::Type::kFormatR32Float))
|
||||||
return ast::type::ImageFormat::kR32Float;
|
return type::ImageFormat::kR32Float;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg16Uint))
|
if (match(Token::Type::kFormatRg16Uint))
|
||||||
return ast::type::ImageFormat::kRg16Uint;
|
return type::ImageFormat::kRg16Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg16Sint))
|
if (match(Token::Type::kFormatRg16Sint))
|
||||||
return ast::type::ImageFormat::kRg16Sint;
|
return type::ImageFormat::kRg16Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg16Float))
|
if (match(Token::Type::kFormatRg16Float))
|
||||||
return ast::type::ImageFormat::kRg16Float;
|
return type::ImageFormat::kRg16Float;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba8Unorm))
|
if (match(Token::Type::kFormatRgba8Unorm))
|
||||||
return ast::type::ImageFormat::kRgba8Unorm;
|
return type::ImageFormat::kRgba8Unorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba8UnormSrgb))
|
if (match(Token::Type::kFormatRgba8UnormSrgb))
|
||||||
return ast::type::ImageFormat::kRgba8UnormSrgb;
|
return type::ImageFormat::kRgba8UnormSrgb;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba8Snorm))
|
if (match(Token::Type::kFormatRgba8Snorm))
|
||||||
return ast::type::ImageFormat::kRgba8Snorm;
|
return type::ImageFormat::kRgba8Snorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba8Uint))
|
if (match(Token::Type::kFormatRgba8Uint))
|
||||||
return ast::type::ImageFormat::kRgba8Uint;
|
return type::ImageFormat::kRgba8Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba8Sint))
|
if (match(Token::Type::kFormatRgba8Sint))
|
||||||
return ast::type::ImageFormat::kRgba8Sint;
|
return type::ImageFormat::kRgba8Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatBgra8Unorm))
|
if (match(Token::Type::kFormatBgra8Unorm))
|
||||||
return ast::type::ImageFormat::kBgra8Unorm;
|
return type::ImageFormat::kBgra8Unorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatBgra8UnormSrgb))
|
if (match(Token::Type::kFormatBgra8UnormSrgb))
|
||||||
return ast::type::ImageFormat::kBgra8UnormSrgb;
|
return type::ImageFormat::kBgra8UnormSrgb;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgb10A2Unorm))
|
if (match(Token::Type::kFormatRgb10A2Unorm))
|
||||||
return ast::type::ImageFormat::kRgb10A2Unorm;
|
return type::ImageFormat::kRgb10A2Unorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg11B10Float))
|
if (match(Token::Type::kFormatRg11B10Float))
|
||||||
return ast::type::ImageFormat::kRg11B10Float;
|
return type::ImageFormat::kRg11B10Float;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg32Uint))
|
if (match(Token::Type::kFormatRg32Uint))
|
||||||
return ast::type::ImageFormat::kRg32Uint;
|
return type::ImageFormat::kRg32Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg32Sint))
|
if (match(Token::Type::kFormatRg32Sint))
|
||||||
return ast::type::ImageFormat::kRg32Sint;
|
return type::ImageFormat::kRg32Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg32Float))
|
if (match(Token::Type::kFormatRg32Float))
|
||||||
return ast::type::ImageFormat::kRg32Float;
|
return type::ImageFormat::kRg32Float;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba16Uint))
|
if (match(Token::Type::kFormatRgba16Uint))
|
||||||
return ast::type::ImageFormat::kRgba16Uint;
|
return type::ImageFormat::kRgba16Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba16Sint))
|
if (match(Token::Type::kFormatRgba16Sint))
|
||||||
return ast::type::ImageFormat::kRgba16Sint;
|
return type::ImageFormat::kRgba16Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba16Float))
|
if (match(Token::Type::kFormatRgba16Float))
|
||||||
return ast::type::ImageFormat::kRgba16Float;
|
return type::ImageFormat::kRgba16Float;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba32Uint))
|
if (match(Token::Type::kFormatRgba32Uint))
|
||||||
return ast::type::ImageFormat::kRgba32Uint;
|
return type::ImageFormat::kRgba32Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba32Sint))
|
if (match(Token::Type::kFormatRgba32Sint))
|
||||||
return ast::type::ImageFormat::kRgba32Sint;
|
return type::ImageFormat::kRgba32Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba32Float))
|
if (match(Token::Type::kFormatRgba32Float))
|
||||||
return ast::type::ImageFormat::kRgba32Float;
|
return type::ImageFormat::kRgba32Float;
|
||||||
|
|
||||||
return add_error(peek().source(), "invalid format", use);
|
return add_error(peek().source(), "invalid format", use);
|
||||||
}
|
}
|
||||||
|
@ -919,7 +909,7 @@ Expect<ParserImpl::TypedIdentifier> ParserImpl::expect_variable_ident_decl(
|
||||||
for (auto* deco : access_decos) {
|
for (auto* deco : access_decos) {
|
||||||
// If we have an access control decoration then we take it and wrap our
|
// If we have an access control decoration then we take it and wrap our
|
||||||
// type up with that decoration
|
// type up with that decoration
|
||||||
ty = module_.create<ast::type::AccessControl>(
|
ty = module_.create<type::AccessControl>(
|
||||||
deco->As<ast::AccessDecoration>()->value(), ty);
|
deco->As<ast::AccessDecoration>()->value(), ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,7 +949,7 @@ Maybe<ast::StorageClass> ParserImpl::variable_storage_decoration() {
|
||||||
|
|
||||||
// type_alias
|
// type_alias
|
||||||
// : TYPE IDENT EQUAL type_decl
|
// : TYPE IDENT EQUAL type_decl
|
||||||
Maybe<ast::type::Type*> ParserImpl::type_alias() {
|
Maybe<type::Type*> ParserImpl::type_alias() {
|
||||||
auto t = peek();
|
auto t = peek();
|
||||||
if (!t.IsType())
|
if (!t.IsType())
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
|
@ -981,8 +971,8 @@ Maybe<ast::type::Type*> ParserImpl::type_alias() {
|
||||||
if (!type.matched)
|
if (!type.matched)
|
||||||
return add_error(peek(), "invalid type alias");
|
return add_error(peek(), "invalid type alias");
|
||||||
|
|
||||||
auto* alias = module_.create<ast::type::Alias>(
|
auto* alias = module_.create<type::Alias>(module_.RegisterSymbol(name.value),
|
||||||
module_.RegisterSymbol(name.value), type.value);
|
type.value);
|
||||||
register_constructed(name.value, alias);
|
register_constructed(name.value, alias);
|
||||||
|
|
||||||
return alias;
|
return alias;
|
||||||
|
@ -1012,7 +1002,7 @@ Maybe<ast::type::Type*> ParserImpl::type_alias() {
|
||||||
// | MAT4x3 LESS_THAN type_decl GREATER_THAN
|
// | MAT4x3 LESS_THAN type_decl GREATER_THAN
|
||||||
// | MAT4x4 LESS_THAN type_decl GREATER_THAN
|
// | MAT4x4 LESS_THAN type_decl GREATER_THAN
|
||||||
// | texture_sampler_types
|
// | texture_sampler_types
|
||||||
Maybe<ast::type::Type*> ParserImpl::type_decl() {
|
Maybe<type::Type*> ParserImpl::type_decl() {
|
||||||
auto decos = decoration_list();
|
auto decos = decoration_list();
|
||||||
if (decos.errored)
|
if (decos.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
@ -1029,7 +1019,7 @@ Maybe<ast::type::Type*> ParserImpl::type_decl() {
|
||||||
return type.value;
|
return type.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Maybe<ast::type::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
|
Maybe<type::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
|
||||||
auto t = peek();
|
auto t = peek();
|
||||||
if (match(Token::Type::kIdentifier)) {
|
if (match(Token::Type::kIdentifier)) {
|
||||||
auto* ty = get_constructed(t.to_str());
|
auto* ty = get_constructed(t.to_str());
|
||||||
|
@ -1040,16 +1030,16 @@ Maybe<ast::type::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Token::Type::kBool))
|
if (match(Token::Type::kBool))
|
||||||
return module_.create<ast::type::Bool>();
|
return module_.create<type::Bool>();
|
||||||
|
|
||||||
if (match(Token::Type::kF32))
|
if (match(Token::Type::kF32))
|
||||||
return module_.create<ast::type::F32>();
|
return module_.create<type::F32>();
|
||||||
|
|
||||||
if (match(Token::Type::kI32))
|
if (match(Token::Type::kI32))
|
||||||
return module_.create<ast::type::I32>();
|
return module_.create<type::I32>();
|
||||||
|
|
||||||
if (match(Token::Type::kU32))
|
if (match(Token::Type::kU32))
|
||||||
return module_.create<ast::type::U32>();
|
return module_.create<type::U32>();
|
||||||
|
|
||||||
if (t.IsVec2() || t.IsVec3() || t.IsVec4()) {
|
if (t.IsVec2() || t.IsVec3() || t.IsVec4()) {
|
||||||
next(); // Consume the peek
|
next(); // Consume the peek
|
||||||
|
@ -1083,7 +1073,7 @@ Maybe<ast::type::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
Expect<ast::type::Type*> ParserImpl::expect_type(const std::string& use) {
|
Expect<type::Type*> ParserImpl::expect_type(const std::string& use) {
|
||||||
auto type = type_decl();
|
auto type = type_decl();
|
||||||
if (type.errored)
|
if (type.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
@ -1092,10 +1082,10 @@ Expect<ast::type::Type*> ParserImpl::expect_type(const std::string& use) {
|
||||||
return type.value;
|
return type.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Expect<ast::type::Type*> ParserImpl::expect_type_decl_pointer() {
|
Expect<type::Type*> ParserImpl::expect_type_decl_pointer() {
|
||||||
const char* use = "ptr declaration";
|
const char* use = "ptr declaration";
|
||||||
|
|
||||||
return expect_lt_gt_block(use, [&]() -> Expect<ast::type::Type*> {
|
return expect_lt_gt_block(use, [&]() -> Expect<type::Type*> {
|
||||||
auto sc = expect_storage_class(use);
|
auto sc = expect_storage_class(use);
|
||||||
if (sc.errored)
|
if (sc.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
@ -1107,11 +1097,11 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_pointer() {
|
||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<ast::type::Pointer>(subtype.value, sc.value);
|
return module_.create<type::Pointer>(subtype.value, sc.value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Expect<ast::type::Type*> ParserImpl::expect_type_decl_vector(Token t) {
|
Expect<type::Type*> ParserImpl::expect_type_decl_vector(Token t) {
|
||||||
uint32_t count = 2;
|
uint32_t count = 2;
|
||||||
if (t.IsVec3())
|
if (t.IsVec3())
|
||||||
count = 3;
|
count = 3;
|
||||||
|
@ -1124,14 +1114,14 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_vector(Token t) {
|
||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<ast::type::Vector>(subtype.value, count);
|
return module_.create<type::Vector>(subtype.value, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
Expect<ast::type::Type*> ParserImpl::expect_type_decl_array(
|
Expect<type::Type*> ParserImpl::expect_type_decl_array(
|
||||||
ast::ArrayDecorationList decos) {
|
ast::ArrayDecorationList decos) {
|
||||||
const char* use = "array declaration";
|
const char* use = "array declaration";
|
||||||
|
|
||||||
return expect_lt_gt_block(use, [&]() -> Expect<ast::type::Type*> {
|
return expect_lt_gt_block(use, [&]() -> Expect<type::Type*> {
|
||||||
auto subtype = expect_type(use);
|
auto subtype = expect_type(use);
|
||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
@ -1144,11 +1134,11 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_array(
|
||||||
size = val.value;
|
size = val.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return create<ast::type::Array>(subtype.value, size, std::move(decos));
|
return create<type::Array>(subtype.value, size, std::move(decos));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Expect<ast::type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
|
Expect<type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
|
||||||
uint32_t rows = 2;
|
uint32_t rows = 2;
|
||||||
uint32_t columns = 2;
|
uint32_t columns = 2;
|
||||||
if (t.IsMat3x2() || t.IsMat3x3() || t.IsMat3x4()) {
|
if (t.IsMat3x2() || t.IsMat3x3() || t.IsMat3x4()) {
|
||||||
|
@ -1168,7 +1158,7 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
|
||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<ast::type::Matrix>(subtype.value, rows, columns);
|
return module_.create<type::Matrix>(subtype.value, rows, columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
// storage_class
|
// storage_class
|
||||||
|
@ -1215,7 +1205,7 @@ Expect<ast::StorageClass> ParserImpl::expect_storage_class(
|
||||||
|
|
||||||
// struct_decl
|
// struct_decl
|
||||||
// : struct_decoration_decl* STRUCT IDENT struct_body_decl
|
// : struct_decoration_decl* STRUCT IDENT struct_body_decl
|
||||||
Maybe<std::unique_ptr<ast::type::Struct>> ParserImpl::struct_decl(
|
Maybe<std::unique_ptr<type::Struct>> ParserImpl::struct_decl(
|
||||||
ast::DecorationList& decos) {
|
ast::DecorationList& decos) {
|
||||||
auto t = peek();
|
auto t = peek();
|
||||||
auto source = t.source();
|
auto source = t.source();
|
||||||
|
@ -1235,7 +1225,7 @@ Maybe<std::unique_ptr<ast::type::Struct>> ParserImpl::struct_decl(
|
||||||
if (struct_decos.errored)
|
if (struct_decos.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return std::make_unique<ast::type::Struct>(
|
return std::make_unique<type::Struct>(
|
||||||
module_.RegisterSymbol(name.value),
|
module_.RegisterSymbol(name.value),
|
||||||
create<ast::Struct>(source, std::move(body.value),
|
create<ast::Struct>(source, std::move(body.value),
|
||||||
std::move(struct_decos.value)));
|
std::move(struct_decos.value)));
|
||||||
|
@ -1335,9 +1325,9 @@ Maybe<ast::Function*> ParserImpl::function_decl(ast::DecorationList& decos) {
|
||||||
// function_type_decl
|
// function_type_decl
|
||||||
// : type_decl
|
// : type_decl
|
||||||
// | VOID
|
// | VOID
|
||||||
Maybe<ast::type::Type*> ParserImpl::function_type_decl() {
|
Maybe<type::Type*> ParserImpl::function_type_decl() {
|
||||||
if (match(Token::Type::kVoid))
|
if (match(Token::Type::kVoid))
|
||||||
return module_.create<ast::type::Void>();
|
return module_.create<type::Void>();
|
||||||
|
|
||||||
return type_decl();
|
return type_decl();
|
||||||
}
|
}
|
||||||
|
@ -2749,19 +2739,19 @@ Maybe<ast::AssignmentStatement*> ParserImpl::assignment_stmt() {
|
||||||
Maybe<ast::Literal*> ParserImpl::const_literal() {
|
Maybe<ast::Literal*> ParserImpl::const_literal() {
|
||||||
auto t = peek();
|
auto t = peek();
|
||||||
if (match(Token::Type::kTrue)) {
|
if (match(Token::Type::kTrue)) {
|
||||||
auto* type = module_.create<ast::type::Bool>();
|
auto* type = module_.create<type::Bool>();
|
||||||
return create<ast::BoolLiteral>(Source{}, type, true);
|
return create<ast::BoolLiteral>(Source{}, type, true);
|
||||||
}
|
}
|
||||||
if (match(Token::Type::kFalse)) {
|
if (match(Token::Type::kFalse)) {
|
||||||
auto* type = module_.create<ast::type::Bool>();
|
auto* type = module_.create<type::Bool>();
|
||||||
return create<ast::BoolLiteral>(Source{}, type, false);
|
return create<ast::BoolLiteral>(Source{}, type, false);
|
||||||
}
|
}
|
||||||
if (match(Token::Type::kSintLiteral)) {
|
if (match(Token::Type::kSintLiteral)) {
|
||||||
auto* type = module_.create<ast::type::I32>();
|
auto* type = module_.create<type::I32>();
|
||||||
return create<ast::SintLiteral>(Source{}, type, t.to_i32());
|
return create<ast::SintLiteral>(Source{}, type, t.to_i32());
|
||||||
}
|
}
|
||||||
if (match(Token::Type::kUintLiteral)) {
|
if (match(Token::Type::kUintLiteral)) {
|
||||||
auto* type = module_.create<ast::type::U32>();
|
auto* type = module_.create<type::U32>();
|
||||||
return create<ast::UintLiteral>(Source{}, type, t.to_u32());
|
return create<ast::UintLiteral>(Source{}, type, t.to_u32());
|
||||||
}
|
}
|
||||||
if (match(Token::Type::kFloatLiteral)) {
|
if (match(Token::Type::kFloatLiteral)) {
|
||||||
|
@ -2770,7 +2760,7 @@ Maybe<ast::Literal*> ParserImpl::const_literal() {
|
||||||
next(); // Consume 'f'
|
next(); // Consume 'f'
|
||||||
add_error(p.source(), "float literals must not be suffixed with 'f'");
|
add_error(p.source(), "float literals must not be suffixed with 'f'");
|
||||||
}
|
}
|
||||||
auto* type = module_.create<ast::type::F32>();
|
auto* type = module_.create<type::F32>();
|
||||||
return create<ast::FloatLiteral>(Source{}, type, t.to_f32());
|
return create<ast::FloatLiteral>(Source{}, type, t.to_f32());
|
||||||
}
|
}
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
|
|
|
@ -48,10 +48,6 @@
|
||||||
#include "src/ast/struct_member.h"
|
#include "src/ast/struct_member.h"
|
||||||
#include "src/ast/struct_member_decoration.h"
|
#include "src/ast/struct_member_decoration.h"
|
||||||
#include "src/ast/switch_statement.h"
|
#include "src/ast/switch_statement.h"
|
||||||
#include "src/ast/type/storage_texture_type.h"
|
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/ast/type/texture_type.h"
|
|
||||||
#include "src/ast/type/type.h"
|
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
#include "src/ast/variable_decoration.h"
|
#include "src/ast/variable_decoration.h"
|
||||||
|
@ -59,6 +55,10 @@
|
||||||
#include "src/diagnostic/formatter.h"
|
#include "src/diagnostic/formatter.h"
|
||||||
#include "src/reader/wgsl/parser_impl_detail.h"
|
#include "src/reader/wgsl/parser_impl_detail.h"
|
||||||
#include "src/reader/wgsl/token.h"
|
#include "src/reader/wgsl/token.h"
|
||||||
|
#include "src/type/storage_texture_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
#include "src/type/texture_type.h"
|
||||||
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -222,7 +222,7 @@ class ParserImpl {
|
||||||
/// variable_ident_decl().
|
/// variable_ident_decl().
|
||||||
struct TypedIdentifier {
|
struct TypedIdentifier {
|
||||||
/// Parsed type.
|
/// Parsed type.
|
||||||
ast::type::Type* type = nullptr;
|
type::Type* type = nullptr;
|
||||||
/// Parsed identifier.
|
/// Parsed identifier.
|
||||||
std::string name;
|
std::string name;
|
||||||
/// Source to the identifier.
|
/// Source to the identifier.
|
||||||
|
@ -244,7 +244,7 @@ class ParserImpl {
|
||||||
FunctionHeader(Source src,
|
FunctionHeader(Source src,
|
||||||
std::string n,
|
std::string n,
|
||||||
ast::VariableList p,
|
ast::VariableList p,
|
||||||
ast::type::Type* ret_ty);
|
type::Type* ret_ty);
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~FunctionHeader();
|
~FunctionHeader();
|
||||||
/// Assignment operator
|
/// Assignment operator
|
||||||
|
@ -259,7 +259,7 @@ class ParserImpl {
|
||||||
/// Function parameters
|
/// Function parameters
|
||||||
ast::VariableList params;
|
ast::VariableList params;
|
||||||
/// Function return type
|
/// Function return type
|
||||||
ast::type::Type* return_type;
|
type::Type* return_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// VarDeclInfo contains the parsed information for variable declaration.
|
/// VarDeclInfo contains the parsed information for variable declaration.
|
||||||
|
@ -271,7 +271,7 @@ class ParserImpl {
|
||||||
/// Variable storage class
|
/// Variable storage class
|
||||||
ast::StorageClass storage_class;
|
ast::StorageClass storage_class;
|
||||||
/// Variable type
|
/// Variable type
|
||||||
ast::type::Type* type;
|
type::Type* type;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Creates a new parser using the given file
|
/// Creates a new parser using the given file
|
||||||
|
@ -348,11 +348,11 @@ class ParserImpl {
|
||||||
/// Registers a constructed type into the parser
|
/// Registers a constructed type into the parser
|
||||||
/// @param name the constructed name
|
/// @param name the constructed name
|
||||||
/// @param type the constructed type
|
/// @param type the constructed type
|
||||||
void register_constructed(const std::string& name, ast::type::Type* type);
|
void register_constructed(const std::string& name, type::Type* type);
|
||||||
/// Retrieves a constructed type
|
/// Retrieves a constructed type
|
||||||
/// @param name The name to lookup
|
/// @param name The name to lookup
|
||||||
/// @returns the constructed type for `name` or `nullptr` if not found
|
/// @returns the constructed type for `name` or `nullptr` if not found
|
||||||
ast::type::Type* get_constructed(const std::string& name);
|
type::Type* get_constructed(const std::string& name);
|
||||||
|
|
||||||
/// Parses the `translation_unit` grammar element
|
/// Parses the `translation_unit` grammar element
|
||||||
void translation_unit();
|
void translation_unit();
|
||||||
|
@ -380,15 +380,15 @@ class ParserImpl {
|
||||||
Maybe<ast::StorageClass> variable_storage_decoration();
|
Maybe<ast::StorageClass> variable_storage_decoration();
|
||||||
/// Parses a `type_alias` grammar element
|
/// Parses a `type_alias` grammar element
|
||||||
/// @returns the type alias or nullptr on error
|
/// @returns the type alias or nullptr on error
|
||||||
Maybe<ast::type::Type*> type_alias();
|
Maybe<type::Type*> type_alias();
|
||||||
/// Parses a `type_decl` grammar element
|
/// Parses a `type_decl` grammar element
|
||||||
/// @returns the parsed Type or nullptr if none matched.
|
/// @returns the parsed Type or nullptr if none matched.
|
||||||
Maybe<ast::type::Type*> type_decl();
|
Maybe<type::Type*> type_decl();
|
||||||
/// Parses a `type_decl` grammar element with the given pre-parsed
|
/// Parses a `type_decl` grammar element with the given pre-parsed
|
||||||
/// decorations.
|
/// decorations.
|
||||||
/// @param decos the list of decorations for the type.
|
/// @param decos the list of decorations for the type.
|
||||||
/// @returns the parsed Type or nullptr if none matched.
|
/// @returns the parsed Type or nullptr if none matched.
|
||||||
Maybe<ast::type::Type*> type_decl(ast::DecorationList& decos);
|
Maybe<type::Type*> type_decl(ast::DecorationList& decos);
|
||||||
/// Parses a `storage_class` grammar element, erroring on parse failure.
|
/// Parses a `storage_class` grammar element, erroring on parse failure.
|
||||||
/// @param use a description of what was being parsed if an error was raised.
|
/// @param use a description of what was being parsed if an error was raised.
|
||||||
/// @returns the storage class or StorageClass::kNone if none matched
|
/// @returns the storage class or StorageClass::kNone if none matched
|
||||||
|
@ -397,8 +397,7 @@ class ParserImpl {
|
||||||
/// `struct_decoration_decl*` provided as `decos`.
|
/// `struct_decoration_decl*` provided as `decos`.
|
||||||
/// @returns the struct type or nullptr on error
|
/// @returns the struct type or nullptr on error
|
||||||
/// @param decos the list of decorations for the struct declaration.
|
/// @param decos the list of decorations for the struct declaration.
|
||||||
Maybe<std::unique_ptr<ast::type::Struct>> struct_decl(
|
Maybe<std::unique_ptr<type::Struct>> struct_decl(ast::DecorationList& decos);
|
||||||
ast::DecorationList& decos);
|
|
||||||
/// Parses a `struct_body_decl` grammar element, erroring on parse failure.
|
/// Parses a `struct_body_decl` grammar element, erroring on parse failure.
|
||||||
/// @returns the struct members
|
/// @returns the struct members
|
||||||
Expect<ast::StructMemberList> expect_struct_body_decl();
|
Expect<ast::StructMemberList> expect_struct_body_decl();
|
||||||
|
@ -415,37 +414,36 @@ class ParserImpl {
|
||||||
Maybe<ast::Function*> function_decl(ast::DecorationList& decos);
|
Maybe<ast::Function*> function_decl(ast::DecorationList& decos);
|
||||||
/// Parses a `texture_sampler_types` grammar element
|
/// Parses a `texture_sampler_types` grammar element
|
||||||
/// @returns the parsed Type or nullptr if none matched.
|
/// @returns the parsed Type or nullptr if none matched.
|
||||||
Maybe<ast::type::Type*> texture_sampler_types();
|
Maybe<type::Type*> texture_sampler_types();
|
||||||
/// Parses a `sampler_type` grammar element
|
/// Parses a `sampler_type` grammar element
|
||||||
/// @returns the parsed Type or nullptr if none matched.
|
/// @returns the parsed Type or nullptr if none matched.
|
||||||
Maybe<ast::type::Type*> sampler_type();
|
Maybe<type::Type*> sampler_type();
|
||||||
/// Parses a `multisampled_texture_type` grammar element
|
/// Parses a `multisampled_texture_type` grammar element
|
||||||
/// @returns returns the multisample texture dimension or kNone if none
|
/// @returns returns the multisample texture dimension or kNone if none
|
||||||
/// matched.
|
/// matched.
|
||||||
Maybe<ast::type::TextureDimension> multisampled_texture_type();
|
Maybe<type::TextureDimension> multisampled_texture_type();
|
||||||
/// Parses a `sampled_texture_type` grammar element
|
/// Parses a `sampled_texture_type` grammar element
|
||||||
/// @returns returns the sample texture dimension or kNone if none matched.
|
/// @returns returns the sample texture dimension or kNone if none matched.
|
||||||
Maybe<ast::type::TextureDimension> sampled_texture_type();
|
Maybe<type::TextureDimension> sampled_texture_type();
|
||||||
/// Parses a `storage_texture_type` grammar element
|
/// Parses a `storage_texture_type` grammar element
|
||||||
/// @returns returns the storage texture dimension.
|
/// @returns returns the storage texture dimension.
|
||||||
/// Returns kNone if none matched.
|
/// Returns kNone if none matched.
|
||||||
Maybe<ast::type::TextureDimension> storage_texture_type();
|
Maybe<type::TextureDimension> storage_texture_type();
|
||||||
/// Parses a deprecated `storage_texture_type` grammar element
|
/// Parses a deprecated `storage_texture_type` grammar element
|
||||||
/// @returns returns the storage texture dimension and the storage access.
|
/// @returns returns the storage texture dimension and the storage access.
|
||||||
/// Returns kNone and kRead if none matched.
|
/// Returns kNone and kRead if none matched.
|
||||||
Maybe<std::pair<ast::type::TextureDimension, ast::AccessControl>>
|
Maybe<std::pair<type::TextureDimension, ast::AccessControl>>
|
||||||
storage_texture_type_access_control();
|
storage_texture_type_access_control();
|
||||||
/// Parses a `depth_texture_type` grammar element
|
/// Parses a `depth_texture_type` grammar element
|
||||||
/// @returns the parsed Type or nullptr if none matched.
|
/// @returns the parsed Type or nullptr if none matched.
|
||||||
Maybe<ast::type::Type*> depth_texture_type();
|
Maybe<type::Type*> depth_texture_type();
|
||||||
/// Parses a `image_storage_type` grammar element
|
/// Parses a `image_storage_type` grammar element
|
||||||
/// @param use a description of what was being parsed if an error was raised
|
/// @param use a description of what was being parsed if an error was raised
|
||||||
/// @returns returns the image format or kNone if none matched.
|
/// @returns returns the image format or kNone if none matched.
|
||||||
Expect<ast::type::ImageFormat> expect_image_storage_type(
|
Expect<type::ImageFormat> expect_image_storage_type(const std::string& use);
|
||||||
const std::string& use);
|
|
||||||
/// Parses a `function_type_decl` grammar element
|
/// Parses a `function_type_decl` grammar element
|
||||||
/// @returns the parsed type or nullptr otherwise
|
/// @returns the parsed type or nullptr otherwise
|
||||||
Maybe<ast::type::Type*> function_type_decl();
|
Maybe<type::Type*> function_type_decl();
|
||||||
/// Parses a `function_header` grammar element
|
/// Parses a `function_header` grammar element
|
||||||
/// @returns the parsed function header
|
/// @returns the parsed function header
|
||||||
Maybe<FunctionHeader> function_header();
|
Maybe<FunctionHeader> function_header();
|
||||||
|
@ -811,16 +809,15 @@ class ParserImpl {
|
||||||
/// Used to ensure that all decorations are consumed.
|
/// Used to ensure that all decorations are consumed.
|
||||||
bool expect_decorations_consumed(const ast::DecorationList& list);
|
bool expect_decorations_consumed(const ast::DecorationList& list);
|
||||||
|
|
||||||
Expect<ast::type::Type*> expect_type_decl_pointer();
|
Expect<type::Type*> expect_type_decl_pointer();
|
||||||
Expect<ast::type::Type*> expect_type_decl_vector(Token t);
|
Expect<type::Type*> expect_type_decl_vector(Token t);
|
||||||
Expect<ast::type::Type*> expect_type_decl_array(
|
Expect<type::Type*> expect_type_decl_array(ast::ArrayDecorationList decos);
|
||||||
ast::ArrayDecorationList decos);
|
Expect<type::Type*> expect_type_decl_matrix(Token t);
|
||||||
Expect<ast::type::Type*> expect_type_decl_matrix(Token t);
|
|
||||||
|
|
||||||
Expect<ast::ConstructorExpression*> expect_const_expr_internal(
|
Expect<ast::ConstructorExpression*> expect_const_expr_internal(
|
||||||
uint32_t depth);
|
uint32_t depth);
|
||||||
|
|
||||||
Expect<ast::type::Type*> expect_type(const std::string& use);
|
Expect<type::Type*> expect_type(const std::string& use);
|
||||||
|
|
||||||
Maybe<ast::Statement*> non_block_statement();
|
Maybe<ast::Statement*> non_block_statement();
|
||||||
Maybe<ast::Statement*> for_header_initializer();
|
Maybe<ast::Statement*> for_header_initializer();
|
||||||
|
@ -841,7 +838,7 @@ class ParserImpl {
|
||||||
bool synchronized_ = true;
|
bool synchronized_ = true;
|
||||||
std::vector<Token::Type> sync_tokens_;
|
std::vector<Token::Type> sync_tokens_;
|
||||||
int silence_errors_ = 0;
|
int silence_errors_ = 0;
|
||||||
std::unordered_map<std::string, ast::type::Type*> registered_constructs_;
|
std::unordered_map<std::string, type::Type*> registered_constructs_;
|
||||||
ast::Module module_;
|
ast::Module module_;
|
||||||
size_t max_errors_ = 25;
|
size_t max_errors_ = 25;
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
#include "src/ast/bool_literal.h"
|
#include "src/ast/bool_literal.h"
|
||||||
#include "src/ast/float_literal.h"
|
#include "src/ast/float_literal.h"
|
||||||
#include "src/ast/scalar_constructor_expression.h"
|
#include "src/ast/scalar_constructor_expression.h"
|
||||||
#include "src/ast/type/vector_type.h"
|
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -35,8 +35,8 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl) {
|
||||||
ASSERT_TRUE(e->Is<ast::TypeConstructorExpression>());
|
ASSERT_TRUE(e->Is<ast::TypeConstructorExpression>());
|
||||||
|
|
||||||
auto* t = e->As<ast::TypeConstructorExpression>();
|
auto* t = e->As<ast::TypeConstructorExpression>();
|
||||||
ASSERT_TRUE(t->type()->Is<ast::type::Vector>());
|
ASSERT_TRUE(t->type()->Is<type::Vector>());
|
||||||
EXPECT_EQ(t->type()->As<ast::type::Vector>()->size(), 2u);
|
EXPECT_EQ(t->type()->As<type::Vector>()->size(), 2u);
|
||||||
|
|
||||||
ASSERT_EQ(t->values().size(), 2u);
|
ASSERT_EQ(t->values().size(), 2u);
|
||||||
auto& v = t->values();
|
auto& v = t->values();
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/depth_texture_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/depth_texture_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -36,10 +36,9 @@ TEST_F(ParserImplTest, DepthTextureType_2d) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::DepthTexture>());
|
ASSERT_TRUE(t->Is<type::DepthTexture>());
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
|
||||||
ast::type::TextureDimension::k2d);
|
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,10 +48,9 @@ TEST_F(ParserImplTest, DepthTextureType_2dArray) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::DepthTexture>());
|
ASSERT_TRUE(t->Is<type::DepthTexture>());
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2dArray);
|
||||||
ast::type::TextureDimension::k2dArray);
|
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,10 +60,9 @@ TEST_F(ParserImplTest, DepthTextureType_Cube) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::DepthTexture>());
|
ASSERT_TRUE(t->Is<type::DepthTexture>());
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::kCube);
|
||||||
ast::type::TextureDimension::kCube);
|
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,10 +72,9 @@ TEST_F(ParserImplTest, DepthTextureType_CubeArray) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::DepthTexture>());
|
ASSERT_TRUE(t->Is<type::DepthTexture>());
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::kCubeArray);
|
||||||
ast::type::TextureDimension::kCubeArray);
|
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,11 @@
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/function.h"
|
#include "src/ast/function.h"
|
||||||
#include "src/ast/type/type.h"
|
|
||||||
#include "src/ast/type/void_type.h"
|
|
||||||
#include "src/ast/workgroup_decoration.h"
|
#include "src/ast/workgroup_decoration.h"
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/type.h"
|
||||||
|
#include "src/type/void_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -39,14 +39,14 @@ TEST_F(ParserImplTest, FunctionDecl) {
|
||||||
|
|
||||||
EXPECT_EQ(f->symbol(), p->get_module().RegisterSymbol("main"));
|
EXPECT_EQ(f->symbol(), p->get_module().RegisterSymbol("main"));
|
||||||
ASSERT_NE(f->return_type(), nullptr);
|
ASSERT_NE(f->return_type(), nullptr);
|
||||||
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
|
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||||
|
|
||||||
ASSERT_EQ(f->params().size(), 2u);
|
ASSERT_EQ(f->params().size(), 2u);
|
||||||
EXPECT_EQ(f->params()[0]->symbol(), p->get_module().RegisterSymbol("a"));
|
EXPECT_EQ(f->params()[0]->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
EXPECT_EQ(f->params()[1]->symbol(), p->get_module().RegisterSymbol("b"));
|
EXPECT_EQ(f->params()[1]->symbol(), p->get_module().RegisterSymbol("b"));
|
||||||
|
|
||||||
ASSERT_NE(f->return_type(), nullptr);
|
ASSERT_NE(f->return_type(), nullptr);
|
||||||
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
|
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||||
|
|
||||||
auto* body = f->body();
|
auto* body = f->body();
|
||||||
ASSERT_EQ(body->size(), 1u);
|
ASSERT_EQ(body->size(), 1u);
|
||||||
|
@ -67,10 +67,10 @@ TEST_F(ParserImplTest, FunctionDecl_DecorationList) {
|
||||||
|
|
||||||
EXPECT_EQ(f->symbol(), p->get_module().RegisterSymbol("main"));
|
EXPECT_EQ(f->symbol(), p->get_module().RegisterSymbol("main"));
|
||||||
ASSERT_NE(f->return_type(), nullptr);
|
ASSERT_NE(f->return_type(), nullptr);
|
||||||
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
|
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||||
ASSERT_EQ(f->params().size(), 0u);
|
ASSERT_EQ(f->params().size(), 0u);
|
||||||
ASSERT_NE(f->return_type(), nullptr);
|
ASSERT_NE(f->return_type(), nullptr);
|
||||||
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
|
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||||
|
|
||||||
auto& decorations = f->decorations();
|
auto& decorations = f->decorations();
|
||||||
ASSERT_EQ(decorations.size(), 1u);
|
ASSERT_EQ(decorations.size(), 1u);
|
||||||
|
@ -105,10 +105,10 @@ fn main() -> void { return; })");
|
||||||
|
|
||||||
EXPECT_EQ(f->symbol(), p->get_module().RegisterSymbol("main"));
|
EXPECT_EQ(f->symbol(), p->get_module().RegisterSymbol("main"));
|
||||||
ASSERT_NE(f->return_type(), nullptr);
|
ASSERT_NE(f->return_type(), nullptr);
|
||||||
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
|
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||||
ASSERT_EQ(f->params().size(), 0u);
|
ASSERT_EQ(f->params().size(), 0u);
|
||||||
ASSERT_NE(f->return_type(), nullptr);
|
ASSERT_NE(f->return_type(), nullptr);
|
||||||
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
|
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||||
|
|
||||||
auto& decorations = f->decorations();
|
auto& decorations = f->decorations();
|
||||||
ASSERT_EQ(decorations.size(), 2u);
|
ASSERT_EQ(decorations.size(), 2u);
|
||||||
|
@ -150,10 +150,10 @@ fn main() -> void { return; })");
|
||||||
|
|
||||||
EXPECT_EQ(f->symbol(), p->get_module().RegisterSymbol("main"));
|
EXPECT_EQ(f->symbol(), p->get_module().RegisterSymbol("main"));
|
||||||
ASSERT_NE(f->return_type(), nullptr);
|
ASSERT_NE(f->return_type(), nullptr);
|
||||||
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
|
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||||
ASSERT_EQ(f->params().size(), 0u);
|
ASSERT_EQ(f->params().size(), 0u);
|
||||||
ASSERT_NE(f->return_type(), nullptr);
|
ASSERT_NE(f->return_type(), nullptr);
|
||||||
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
|
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||||
|
|
||||||
auto& decos = f->decorations();
|
auto& decos = f->decorations();
|
||||||
ASSERT_EQ(decos.size(), 2u);
|
ASSERT_EQ(decos.size(), 2u);
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/function.h"
|
#include "src/ast/function.h"
|
||||||
#include "src/ast/type/type.h"
|
|
||||||
#include "src/ast/type/void_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/type.h"
|
||||||
|
#include "src/type/void_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -35,7 +35,7 @@ TEST_F(ParserImplTest, FunctionHeader) {
|
||||||
ASSERT_EQ(f->params.size(), 2u);
|
ASSERT_EQ(f->params.size(), 2u);
|
||||||
EXPECT_EQ(f->params[0]->symbol(), p->get_module().RegisterSymbol("a"));
|
EXPECT_EQ(f->params[0]->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
EXPECT_EQ(f->params[1]->symbol(), p->get_module().RegisterSymbol("b"));
|
EXPECT_EQ(f->params[1]->symbol(), p->get_module().RegisterSymbol("b"));
|
||||||
EXPECT_TRUE(f->return_type->Is<ast::type::Void>());
|
EXPECT_TRUE(f->return_type->Is<type::Void>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, FunctionHeader_MissingIdent) {
|
TEST_F(ParserImplTest, FunctionHeader_MissingIdent) {
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/vector_type.h"
|
|
||||||
#include "src/ast/type/void_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
#include "src/type/void_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -30,7 +30,7 @@ TEST_F(ParserImplTest, FunctionTypeDecl_Void) {
|
||||||
auto p = parser("void");
|
auto p = parser("void");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* v = mod.create<ast::type::Void>();
|
auto* v = mod.create<type::Void>();
|
||||||
|
|
||||||
auto e = p->function_type_decl();
|
auto e = p->function_type_decl();
|
||||||
EXPECT_TRUE(e.matched);
|
EXPECT_TRUE(e.matched);
|
||||||
|
@ -43,8 +43,8 @@ TEST_F(ParserImplTest, FunctionTypeDecl_Type) {
|
||||||
auto p = parser("vec2<f32>");
|
auto p = parser("vec2<f32>");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* f32 = mod.create<ast::type::F32>();
|
auto* f32 = mod.create<type::F32>();
|
||||||
auto* vec2 = mod.create<ast::type::Vector>(f32, 2);
|
auto* vec2 = mod.create<type::Vector>(f32, 2);
|
||||||
|
|
||||||
auto e = p->function_type_decl();
|
auto e = p->function_type_decl();
|
||||||
EXPECT_TRUE(e.matched);
|
EXPECT_TRUE(e.matched);
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/ast/variable_decoration.h"
|
#include "src/ast/variable_decoration.h"
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -35,7 +35,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl) {
|
||||||
EXPECT_TRUE(e->is_const());
|
EXPECT_TRUE(e->is_const());
|
||||||
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
|
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
ASSERT_NE(e->type(), nullptr);
|
ASSERT_NE(e->type(), nullptr);
|
||||||
EXPECT_TRUE(e->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(e->type()->Is<type::F32>());
|
||||||
|
|
||||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||||
EXPECT_EQ(e->source().range.begin.column, 7u);
|
EXPECT_EQ(e->source().range.begin.column, 7u);
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/array_type.h"
|
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/array_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -88,10 +88,10 @@ TEST_F(ParserImplTest, GlobalDecl_TypeAlias) {
|
||||||
|
|
||||||
auto& m = p->get_module();
|
auto& m = p->get_module();
|
||||||
ASSERT_EQ(m.constructed_types().size(), 1u);
|
ASSERT_EQ(m.constructed_types().size(), 1u);
|
||||||
ASSERT_TRUE(m.constructed_types()[0]->Is<ast::type::Alias>());
|
ASSERT_TRUE(m.constructed_types()[0]->Is<type::Alias>());
|
||||||
EXPECT_EQ(m.SymbolToName(
|
EXPECT_EQ(
|
||||||
m.constructed_types()[0]->As<ast::type::Alias>()->symbol()),
|
m.SymbolToName(m.constructed_types()[0]->As<type::Alias>()->symbol()),
|
||||||
"A");
|
"A");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_StructIdent) {
|
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_StructIdent) {
|
||||||
|
@ -105,12 +105,12 @@ type B = A;)");
|
||||||
|
|
||||||
auto& m = p->get_module();
|
auto& m = p->get_module();
|
||||||
ASSERT_EQ(m.constructed_types().size(), 2u);
|
ASSERT_EQ(m.constructed_types().size(), 2u);
|
||||||
ASSERT_TRUE(m.constructed_types()[0]->Is<ast::type::Struct>());
|
ASSERT_TRUE(m.constructed_types()[0]->Is<type::Struct>());
|
||||||
auto* str = m.constructed_types()[0]->As<ast::type::Struct>();
|
auto* str = m.constructed_types()[0]->As<type::Struct>();
|
||||||
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
|
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
|
||||||
|
|
||||||
ASSERT_TRUE(m.constructed_types()[1]->Is<ast::type::Alias>());
|
ASSERT_TRUE(m.constructed_types()[1]->Is<type::Alias>());
|
||||||
auto* alias = m.constructed_types()[1]->As<ast::type::Alias>();
|
auto* alias = m.constructed_types()[1]->As<type::Alias>();
|
||||||
EXPECT_EQ(alias->symbol(), p->get_module().RegisterSymbol("B"));
|
EXPECT_EQ(alias->symbol(), p->get_module().RegisterSymbol("B"));
|
||||||
EXPECT_EQ(alias->type(), str);
|
EXPECT_EQ(alias->type(), str);
|
||||||
}
|
}
|
||||||
|
@ -166,9 +166,9 @@ TEST_F(ParserImplTest, GlobalDecl_ParsesStruct) {
|
||||||
|
|
||||||
auto* t = m.constructed_types()[0];
|
auto* t = m.constructed_types()[0];
|
||||||
ASSERT_NE(t, nullptr);
|
ASSERT_NE(t, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Struct>());
|
ASSERT_TRUE(t->Is<type::Struct>());
|
||||||
|
|
||||||
auto* str = t->As<ast::type::Struct>();
|
auto* str = t->As<type::Struct>();
|
||||||
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
|
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
|
||||||
EXPECT_EQ(str->impl()->members().size(), 2u);
|
EXPECT_EQ(str->impl()->members().size(), 2u);
|
||||||
}
|
}
|
||||||
|
@ -185,16 +185,16 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) {
|
||||||
|
|
||||||
auto* t = m.constructed_types()[0];
|
auto* t = m.constructed_types()[0];
|
||||||
ASSERT_NE(t, nullptr);
|
ASSERT_NE(t, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Struct>());
|
ASSERT_TRUE(t->Is<type::Struct>());
|
||||||
|
|
||||||
auto* str = t->As<ast::type::Struct>();
|
auto* str = t->As<type::Struct>();
|
||||||
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
|
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
|
||||||
EXPECT_EQ(str->impl()->members().size(), 1u);
|
EXPECT_EQ(str->impl()->members().size(), 1u);
|
||||||
EXPECT_FALSE(str->IsBlockDecorated());
|
EXPECT_FALSE(str->IsBlockDecorated());
|
||||||
|
|
||||||
const auto* ty = str->impl()->members()[0]->type();
|
const auto* ty = str->impl()->members()[0]->type();
|
||||||
ASSERT_TRUE(ty->Is<ast::type::Array>());
|
ASSERT_TRUE(ty->Is<type::Array>());
|
||||||
const auto* arr = ty->As<ast::type::Array>();
|
const auto* arr = ty->As<type::Array>();
|
||||||
EXPECT_TRUE(arr->has_array_stride());
|
EXPECT_TRUE(arr->has_array_stride());
|
||||||
EXPECT_EQ(arr->array_stride(), 4u);
|
EXPECT_EQ(arr->array_stride(), 4u);
|
||||||
}
|
}
|
||||||
|
@ -209,9 +209,9 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithDecoration) {
|
||||||
|
|
||||||
auto* t = m.constructed_types()[0];
|
auto* t = m.constructed_types()[0];
|
||||||
ASSERT_NE(t, nullptr);
|
ASSERT_NE(t, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Struct>());
|
ASSERT_TRUE(t->Is<type::Struct>());
|
||||||
|
|
||||||
auto* str = t->As<ast::type::Struct>();
|
auto* str = t->As<type::Struct>();
|
||||||
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
|
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
|
||||||
EXPECT_EQ(str->impl()->members().size(), 1u);
|
EXPECT_EQ(str->impl()->members().size(), 1u);
|
||||||
EXPECT_TRUE(str->IsBlockDecorated());
|
EXPECT_TRUE(str->IsBlockDecorated());
|
||||||
|
|
|
@ -14,11 +14,11 @@
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/scalar_constructor_expression.h"
|
#include "src/ast/scalar_constructor_expression.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/ast/variable_decoration.h"
|
#include "src/ast/variable_decoration.h"
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -37,7 +37,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithoutConstructor) {
|
||||||
ASSERT_NE(e.value, nullptr);
|
ASSERT_NE(e.value, nullptr);
|
||||||
|
|
||||||
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
|
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
EXPECT_TRUE(e->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(e->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
|
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
|
||||||
|
|
||||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||||
|
@ -60,7 +60,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithConstructor) {
|
||||||
ASSERT_NE(e.value, nullptr);
|
ASSERT_NE(e.value, nullptr);
|
||||||
|
|
||||||
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
|
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
EXPECT_TRUE(e->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(e->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
|
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
|
||||||
|
|
||||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||||
|
@ -86,7 +86,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) {
|
||||||
|
|
||||||
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
|
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
ASSERT_NE(e->type(), nullptr);
|
ASSERT_NE(e->type(), nullptr);
|
||||||
EXPECT_TRUE(e->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(e->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
|
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
|
||||||
|
|
||||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||||
|
@ -116,7 +116,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) {
|
||||||
|
|
||||||
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
|
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
ASSERT_NE(e->type(), nullptr);
|
ASSERT_NE(e->type(), nullptr);
|
||||||
EXPECT_TRUE(e->type()->Is<ast::type::F32>());
|
EXPECT_TRUE(e->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
|
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
|
||||||
|
|
||||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/texture_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/texture_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -34,7 +34,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Unorm) {
|
||||||
auto p = parser("r8unorm");
|
auto p = parser("r8unorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR8Unorm);
|
EXPECT_EQ(t.value, type::ImageFormat::kR8Unorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Snorm) {
|
||||||
auto p = parser("r8snorm");
|
auto p = parser("r8snorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR8Snorm);
|
EXPECT_EQ(t.value, type::ImageFormat::kR8Snorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Uint) {
|
||||||
auto p = parser("r8uint");
|
auto p = parser("r8uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR8Uint);
|
EXPECT_EQ(t.value, type::ImageFormat::kR8Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Sint) {
|
||||||
auto p = parser("r8sint");
|
auto p = parser("r8sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR8Sint);
|
EXPECT_EQ(t.value, type::ImageFormat::kR8Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Uint) {
|
||||||
auto p = parser("r16uint");
|
auto p = parser("r16uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR16Uint);
|
EXPECT_EQ(t.value, type::ImageFormat::kR16Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Sint) {
|
||||||
auto p = parser("r16sint");
|
auto p = parser("r16sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR16Sint);
|
EXPECT_EQ(t.value, type::ImageFormat::kR16Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Float) {
|
||||||
auto p = parser("r16float");
|
auto p = parser("r16float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR16Float);
|
EXPECT_EQ(t.value, type::ImageFormat::kR16Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Unorm) {
|
||||||
auto p = parser("rg8unorm");
|
auto p = parser("rg8unorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg8Unorm);
|
EXPECT_EQ(t.value, type::ImageFormat::kRg8Unorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Snorm) {
|
||||||
auto p = parser("rg8snorm");
|
auto p = parser("rg8snorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg8Snorm);
|
EXPECT_EQ(t.value, type::ImageFormat::kRg8Snorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Uint) {
|
||||||
auto p = parser("rg8uint");
|
auto p = parser("rg8uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg8Uint);
|
EXPECT_EQ(t.value, type::ImageFormat::kRg8Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Sint) {
|
||||||
auto p = parser("rg8sint");
|
auto p = parser("rg8sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg8Sint);
|
EXPECT_EQ(t.value, type::ImageFormat::kRg8Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Uint) {
|
||||||
auto p = parser("r32uint");
|
auto p = parser("r32uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR32Uint);
|
EXPECT_EQ(t.value, type::ImageFormat::kR32Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Sint) {
|
||||||
auto p = parser("r32sint");
|
auto p = parser("r32sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR32Sint);
|
EXPECT_EQ(t.value, type::ImageFormat::kR32Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Float) {
|
||||||
auto p = parser("r32float");
|
auto p = parser("r32float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR32Float);
|
EXPECT_EQ(t.value, type::ImageFormat::kR32Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Uint) {
|
||||||
auto p = parser("rg16uint");
|
auto p = parser("rg16uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg16Uint);
|
EXPECT_EQ(t.value, type::ImageFormat::kRg16Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Sint) {
|
||||||
auto p = parser("rg16sint");
|
auto p = parser("rg16sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg16Sint);
|
EXPECT_EQ(t.value, type::ImageFormat::kRg16Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Float) {
|
||||||
auto p = parser("rg16float");
|
auto p = parser("rg16float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg16Float);
|
EXPECT_EQ(t.value, type::ImageFormat::kRg16Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Unorm) {
|
||||||
auto p = parser("rgba8unorm");
|
auto p = parser("rgba8unorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8Unorm);
|
EXPECT_EQ(t.value, type::ImageFormat::kRgba8Unorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8UnormSrgb) {
|
||||||
auto p = parser("rgba8unorm_srgb");
|
auto p = parser("rgba8unorm_srgb");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8UnormSrgb);
|
EXPECT_EQ(t.value, type::ImageFormat::kRgba8UnormSrgb);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Snorm) {
|
||||||
auto p = parser("rgba8snorm");
|
auto p = parser("rgba8snorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8Snorm);
|
EXPECT_EQ(t.value, type::ImageFormat::kRgba8Snorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Uint) {
|
||||||
auto p = parser("rgba8uint");
|
auto p = parser("rgba8uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8Uint);
|
EXPECT_EQ(t.value, type::ImageFormat::kRgba8Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Sint) {
|
||||||
auto p = parser("rgba8sint");
|
auto p = parser("rgba8sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8Sint);
|
EXPECT_EQ(t.value, type::ImageFormat::kRgba8Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ TEST_F(ParserImplTest, ImageStorageType_Bgra8Unorm) {
|
||||||
auto p = parser("bgra8unorm");
|
auto p = parser("bgra8unorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kBgra8Unorm);
|
EXPECT_EQ(t.value, type::ImageFormat::kBgra8Unorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ TEST_F(ParserImplTest, ImageStorageType_Bgra8UnormSrgb) {
|
||||||
auto p = parser("bgra8unorm_srgb");
|
auto p = parser("bgra8unorm_srgb");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kBgra8UnormSrgb);
|
EXPECT_EQ(t.value, type::ImageFormat::kBgra8UnormSrgb);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgb10A2Unorm) {
|
||||||
auto p = parser("rgb10a2unorm");
|
auto p = parser("rgb10a2unorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgb10A2Unorm);
|
EXPECT_EQ(t.value, type::ImageFormat::kRgb10A2Unorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg11B10Float) {
|
||||||
auto p = parser("rg11b10float");
|
auto p = parser("rg11b10float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg11B10Float);
|
EXPECT_EQ(t.value, type::ImageFormat::kRg11B10Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Uint) {
|
||||||
auto p = parser("rg32uint");
|
auto p = parser("rg32uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg32Uint);
|
EXPECT_EQ(t.value, type::ImageFormat::kRg32Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Sint) {
|
||||||
auto p = parser("rg32sint");
|
auto p = parser("rg32sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg32Sint);
|
EXPECT_EQ(t.value, type::ImageFormat::kRg32Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Float) {
|
||||||
auto p = parser("rg32float");
|
auto p = parser("rg32float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg32Float);
|
EXPECT_EQ(t.value, type::ImageFormat::kRg32Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Uint) {
|
||||||
auto p = parser("rgba16uint");
|
auto p = parser("rgba16uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba16Uint);
|
EXPECT_EQ(t.value, type::ImageFormat::kRgba16Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Sint) {
|
||||||
auto p = parser("rgba16sint");
|
auto p = parser("rgba16sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba16Sint);
|
EXPECT_EQ(t.value, type::ImageFormat::kRgba16Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Float) {
|
||||||
auto p = parser("rgba16float");
|
auto p = parser("rgba16float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba16Float);
|
EXPECT_EQ(t.value, type::ImageFormat::kRgba16Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Uint) {
|
||||||
auto p = parser("rgba32uint");
|
auto p = parser("rgba32uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba32Uint);
|
EXPECT_EQ(t.value, type::ImageFormat::kRgba32Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Sint) {
|
||||||
auto p = parser("rgba32sint");
|
auto p = parser("rgba32sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba32Sint);
|
EXPECT_EQ(t.value, type::ImageFormat::kRgba32Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Float) {
|
||||||
auto p = parser("rgba32float");
|
auto p = parser("rgba32float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba32Float);
|
EXPECT_EQ(t.value, type::ImageFormat::kRgba32Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,12 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/vector_type.h"
|
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -31,7 +31,7 @@ TEST_F(ParserImplTest, ParamList_Single) {
|
||||||
auto p = parser("a : i32");
|
auto p = parser("a : i32");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.create<ast::type::I32>();
|
auto* i32 = mod.create<type::I32>();
|
||||||
|
|
||||||
auto e = p->expect_param_list();
|
auto e = p->expect_param_list();
|
||||||
ASSERT_FALSE(p->has_error()) << p->error();
|
ASSERT_FALSE(p->has_error()) << p->error();
|
||||||
|
@ -52,9 +52,9 @@ TEST_F(ParserImplTest, ParamList_Multiple) {
|
||||||
auto p = parser("a : i32, b: f32, c: vec2<f32>");
|
auto p = parser("a : i32, b: f32, c: vec2<f32>");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.create<ast::type::I32>();
|
auto* i32 = mod.create<type::I32>();
|
||||||
auto* f32 = mod.create<ast::type::F32>();
|
auto* f32 = mod.create<type::F32>();
|
||||||
auto* vec2 = mod.create<ast::type::Vector>(f32, 2);
|
auto* vec2 = mod.create<type::Vector>(f32, 2);
|
||||||
|
|
||||||
auto e = p->expect_param_list();
|
auto e = p->expect_param_list();
|
||||||
ASSERT_FALSE(p->has_error()) << p->error();
|
ASSERT_FALSE(p->has_error()) << p->error();
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
#include "src/ast/identifier_expression.h"
|
#include "src/ast/identifier_expression.h"
|
||||||
#include "src/ast/scalar_constructor_expression.h"
|
#include "src/ast/scalar_constructor_expression.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
#include "src/ast/unary_op_expression.h"
|
#include "src/ast/unary_op_expression.h"
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -194,7 +194,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast) {
|
||||||
auto p = parser("f32(1)");
|
auto p = parser("f32(1)");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* f32 = mod.create<ast::type::F32>();
|
auto* f32 = mod.create<type::F32>();
|
||||||
|
|
||||||
auto e = p->primary_expression();
|
auto e = p->primary_expression();
|
||||||
EXPECT_TRUE(e.matched);
|
EXPECT_TRUE(e.matched);
|
||||||
|
@ -216,7 +216,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Bitcast) {
|
||||||
auto p = parser("bitcast<f32>(1)");
|
auto p = parser("bitcast<f32>(1)");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* f32 = mod.create<ast::type::F32>();
|
auto* f32 = mod.create<type::F32>();
|
||||||
|
|
||||||
auto e = p->primary_expression();
|
auto e = p->primary_expression();
|
||||||
EXPECT_TRUE(e.matched);
|
EXPECT_TRUE(e.matched);
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/texture_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/texture_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -35,7 +35,7 @@ TEST_F(ParserImplTest, SampledTextureType_1d_Old) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k1d);
|
EXPECT_EQ(t.value, type::TextureDimension::k1d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ TEST_F(ParserImplTest, SampledTextureType_1dArray_Old) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k1dArray);
|
EXPECT_EQ(t.value, type::TextureDimension::k1dArray);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ TEST_F(ParserImplTest, SampledTextureType_2d_Old) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k2d);
|
EXPECT_EQ(t.value, type::TextureDimension::k2d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ TEST_F(ParserImplTest, SampledTextureType_2dArray_Old) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k2dArray);
|
EXPECT_EQ(t.value, type::TextureDimension::k2dArray);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ TEST_F(ParserImplTest, SampledTextureType_3d_Old) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k3d);
|
EXPECT_EQ(t.value, type::TextureDimension::k3d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ TEST_F(ParserImplTest, SampledTextureType_Cube_Old) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::kCube);
|
EXPECT_EQ(t.value, type::TextureDimension::kCube);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ TEST_F(ParserImplTest, SampledTextureType_kCubeArray_Old) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::kCubeArray);
|
EXPECT_EQ(t.value, type::TextureDimension::kCubeArray);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ TEST_F(ParserImplTest, SampledTextureType_1d) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k1d);
|
EXPECT_EQ(t.value, type::TextureDimension::k1d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ TEST_F(ParserImplTest, SampledTextureType_1dArray) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k1dArray);
|
EXPECT_EQ(t.value, type::TextureDimension::k1dArray);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ TEST_F(ParserImplTest, SampledTextureType_2d) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k2d);
|
EXPECT_EQ(t.value, type::TextureDimension::k2d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ TEST_F(ParserImplTest, SampledTextureType_2dArray) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k2dArray);
|
EXPECT_EQ(t.value, type::TextureDimension::k2dArray);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ TEST_F(ParserImplTest, SampledTextureType_3d) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k3d);
|
EXPECT_EQ(t.value, type::TextureDimension::k3d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ TEST_F(ParserImplTest, SampledTextureType_Cube) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::kCube);
|
EXPECT_EQ(t.value, type::TextureDimension::kCube);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ TEST_F(ParserImplTest, SampledTextureType_kCubeArray) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::kCubeArray);
|
EXPECT_EQ(t.value, type::TextureDimension::kCubeArray);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/sampler_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/sampler_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -37,8 +37,8 @@ TEST_F(ParserImplTest, SamplerType_Sampler) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Sampler>());
|
ASSERT_TRUE(t->Is<type::Sampler>());
|
||||||
EXPECT_FALSE(t->As<ast::type::Sampler>()->IsComparison());
|
EXPECT_FALSE(t->As<type::Sampler>()->IsComparison());
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ TEST_F(ParserImplTest, SamplerType_ComparisonSampler) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Sampler>());
|
ASSERT_TRUE(t->Is<type::Sampler>());
|
||||||
EXPECT_TRUE(t->As<ast::type::Sampler>()->IsComparison());
|
EXPECT_TRUE(t->As<type::Sampler>()->IsComparison());
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/storage_texture_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/storage_texture_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -35,7 +35,7 @@ TEST_F(ParserImplTest, StorageTextureType_1d) {
|
||||||
auto t = p->storage_texture_type();
|
auto t = p->storage_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k1d);
|
EXPECT_EQ(t.value, type::TextureDimension::k1d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ TEST_F(ParserImplTest, StorageTextureType_1dArray) {
|
||||||
auto t = p->storage_texture_type();
|
auto t = p->storage_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k1dArray);
|
EXPECT_EQ(t.value, type::TextureDimension::k1dArray);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ TEST_F(ParserImplTest, StorageTextureType_2d) {
|
||||||
auto t = p->storage_texture_type();
|
auto t = p->storage_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k2d);
|
EXPECT_EQ(t.value, type::TextureDimension::k2d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ TEST_F(ParserImplTest, StorageTextureType_2dArray) {
|
||||||
auto t = p->storage_texture_type();
|
auto t = p->storage_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k2dArray);
|
EXPECT_EQ(t.value, type::TextureDimension::k2dArray);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ TEST_F(ParserImplTest, StorageTextureType_3d) {
|
||||||
auto t = p->storage_texture_type();
|
auto t = p->storage_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, ast::type::TextureDimension::k3d);
|
EXPECT_EQ(t.value, type::TextureDimension::k3d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly1d_Old) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1d);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1d);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly1dArray_Old) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1dArray);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1dArray);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly2d_Old) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2d);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2d);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly2dArray_Old) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2dArray);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2dArray);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly3d_Old) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k3d);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k3d);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly1d_Old) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1d);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1d);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly1dArray_Old) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1dArray);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1dArray);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly2d_Old) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2d);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2d);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly2dArray_Old) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2dArray);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2dArray);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly3d_Old) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k3d);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k3d);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ TEST_F(ParserImplTest, StorageTextureType_ro_1d) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1d);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1d);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ TEST_F(ParserImplTest, StorageTextureType_ro_1dArray) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1dArray);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1dArray);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ TEST_F(ParserImplTest, StorageTextureType_ro_2d) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2d);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2d);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ TEST_F(ParserImplTest, StorageTextureType_ro_2dArray) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2dArray);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2dArray);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ TEST_F(ParserImplTest, StorageTextureType_ro_3d) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k3d);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k3d);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ TEST_F(ParserImplTest, StorageTextureType_wo_1d) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1d);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1d);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ TEST_F(ParserImplTest, StorageTextureType_wo_1dArray) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1dArray);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1dArray);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ TEST_F(ParserImplTest, StorageTextureType_wo_2d) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2d);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2d);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ TEST_F(ParserImplTest, StorageTextureType_wo_2dArray) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2dArray);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2dArray);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ TEST_F(ParserImplTest, StorageTextureType_wo_3d) {
|
||||||
auto t = p->storage_texture_type_access_control();
|
auto t = p->storage_texture_type_access_control();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k3d);
|
EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k3d);
|
||||||
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -26,7 +26,7 @@ TEST_F(ParserImplTest, StructBodyDecl_Parses) {
|
||||||
auto p = parser("{a : i32;}");
|
auto p = parser("{a : i32;}");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.create<ast::type::I32>();
|
auto* i32 = mod.create<type::I32>();
|
||||||
|
|
||||||
auto m = p->expect_struct_body_decl();
|
auto m = p->expect_struct_body_decl();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/struct_block_decoration.h"
|
#include "src/ast/struct_block_decoration.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/type/struct_type.h"
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -27,7 +27,7 @@ TEST_F(ParserImplTest, StructMember_Parses) {
|
||||||
auto p = parser("a : i32;");
|
auto p = parser("a : i32;");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.create<ast::type::I32>();
|
auto* i32 = mod.create<type::I32>();
|
||||||
|
|
||||||
auto decos = p->decoration_list();
|
auto decos = p->decoration_list();
|
||||||
EXPECT_FALSE(decos.errored);
|
EXPECT_FALSE(decos.errored);
|
||||||
|
@ -53,7 +53,7 @@ TEST_F(ParserImplTest, StructMember_ParsesWithDecoration) {
|
||||||
auto p = parser("[[offset(2)]] a : i32;");
|
auto p = parser("[[offset(2)]] a : i32;");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.create<ast::type::I32>();
|
auto* i32 = mod.create<type::I32>();
|
||||||
|
|
||||||
auto decos = p->decoration_list();
|
auto decos = p->decoration_list();
|
||||||
EXPECT_FALSE(decos.errored);
|
EXPECT_FALSE(decos.errored);
|
||||||
|
@ -84,7 +84,7 @@ TEST_F(ParserImplTest, StructMember_ParsesWithMultipleDecorations) {
|
||||||
[[offset(4)]] a : i32;)");
|
[[offset(4)]] a : i32;)");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.create<ast::type::I32>();
|
auto* i32 = mod.create<type::I32>();
|
||||||
|
|
||||||
auto decos = p->decoration_list();
|
auto decos = p->decoration_list();
|
||||||
EXPECT_FALSE(decos.errored);
|
EXPECT_FALSE(decos.errored);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/i32_type.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
|
|
@ -13,16 +13,16 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
|
||||||
#include "src/ast/type/depth_texture_type.h"
|
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/multisampled_texture_type.h"
|
|
||||||
#include "src/ast/type/sampled_texture_type.h"
|
|
||||||
#include "src/ast/type/sampler_type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/access_control_type.h"
|
||||||
|
#include "src/type/depth_texture_type.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/multisampled_texture_type.h"
|
||||||
|
#include "src/type/sampled_texture_type.h"
|
||||||
|
#include "src/type/sampler_type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -45,8 +45,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_Sampler) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Sampler>());
|
ASSERT_TRUE(t->Is<type::Sampler>());
|
||||||
ASSERT_FALSE(t->As<ast::type::Sampler>()->IsComparison());
|
ASSERT_FALSE(t->As<type::Sampler>()->IsComparison());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
|
||||||
|
@ -56,8 +56,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Sampler>());
|
ASSERT_TRUE(t->Is<type::Sampler>());
|
||||||
ASSERT_TRUE(t->As<ast::type::Sampler>()->IsComparison());
|
ASSERT_TRUE(t->As<type::Sampler>()->IsComparison());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
|
||||||
|
@ -67,10 +67,9 @@ TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::DepthTexture>());
|
ASSERT_TRUE(t->Is<type::DepthTexture>());
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
|
||||||
ast::type::TextureDimension::k2d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32_Old) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32_Old) {
|
||||||
|
@ -80,11 +79,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32_Old) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
|
ASSERT_TRUE(t->Is<type::SampledTexture>());
|
||||||
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
|
ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
|
||||||
ast::type::TextureDimension::k1d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32_Old) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32_Old) {
|
||||||
|
@ -94,11 +92,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32_Old) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
|
ASSERT_TRUE(t->Is<type::SampledTexture>());
|
||||||
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::I32>());
|
ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
|
||||||
ast::type::TextureDimension::k2d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32_Old) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32_Old) {
|
||||||
|
@ -108,11 +105,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32_Old) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
|
ASSERT_TRUE(t->Is<type::SampledTexture>());
|
||||||
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::U32>());
|
ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k3d);
|
||||||
ast::type::TextureDimension::k3d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid_Old) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid_Old) {
|
||||||
|
@ -163,11 +159,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
|
ASSERT_TRUE(t->Is<type::SampledTexture>());
|
||||||
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
|
ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
|
||||||
ast::type::TextureDimension::k1d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
|
||||||
|
@ -177,11 +172,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
|
ASSERT_TRUE(t->Is<type::SampledTexture>());
|
||||||
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::I32>());
|
ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
|
||||||
ast::type::TextureDimension::k2d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
|
||||||
|
@ -191,11 +185,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
|
ASSERT_TRUE(t->Is<type::SampledTexture>());
|
||||||
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::U32>());
|
ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k3d);
|
||||||
ast::type::TextureDimension::k3d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid) {
|
||||||
|
@ -245,12 +238,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_I32) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::MultisampledTexture>());
|
ASSERT_TRUE(t->Is<type::MultisampledTexture>());
|
||||||
ASSERT_TRUE(
|
ASSERT_TRUE(t->As<type::MultisampledTexture>()->type()->Is<type::I32>());
|
||||||
t->As<ast::type::MultisampledTexture>()->type()->Is<ast::type::I32>());
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
|
||||||
ast::type::TextureDimension::k2d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_Invalid) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_Invalid) {
|
||||||
|
@ -302,17 +293,16 @@ TEST_F(ParserImplTest,
|
||||||
EXPECT_FALSE(ac.errored);
|
EXPECT_FALSE(ac.errored);
|
||||||
ASSERT_NE(ac.value, nullptr);
|
ASSERT_NE(ac.value, nullptr);
|
||||||
|
|
||||||
ASSERT_TRUE(ac->Is<ast::type::AccessControl>());
|
ASSERT_TRUE(ac->Is<type::AccessControl>());
|
||||||
EXPECT_EQ(ac->As<ast::type::AccessControl>()->access_control(),
|
EXPECT_EQ(ac->As<type::AccessControl>()->access_control(),
|
||||||
ast::AccessControl::kReadOnly);
|
ast::AccessControl::kReadOnly);
|
||||||
|
|
||||||
auto* t = ac->As<ast::type::AccessControl>()->type();
|
auto* t = ac->As<type::AccessControl>()->type();
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
|
ASSERT_TRUE(t->Is<type::StorageTexture>());
|
||||||
EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
|
EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
|
||||||
ast::type::ImageFormat::kR8Unorm);
|
type::ImageFormat::kR8Unorm);
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
|
||||||
ast::type::TextureDimension::k1d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest,
|
TEST_F(ParserImplTest,
|
||||||
|
@ -324,17 +314,16 @@ TEST_F(ParserImplTest,
|
||||||
EXPECT_FALSE(ac.errored);
|
EXPECT_FALSE(ac.errored);
|
||||||
ASSERT_NE(ac.value, nullptr);
|
ASSERT_NE(ac.value, nullptr);
|
||||||
|
|
||||||
ASSERT_TRUE(ac->Is<ast::type::AccessControl>());
|
ASSERT_TRUE(ac->Is<type::AccessControl>());
|
||||||
EXPECT_EQ(ac->As<ast::type::AccessControl>()->access_control(),
|
EXPECT_EQ(ac->As<type::AccessControl>()->access_control(),
|
||||||
ast::AccessControl::kWriteOnly);
|
ast::AccessControl::kWriteOnly);
|
||||||
|
|
||||||
auto* t = ac->As<ast::type::AccessControl>()->type();
|
auto* t = ac->As<type::AccessControl>()->type();
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
|
ASSERT_TRUE(t->Is<type::StorageTexture>());
|
||||||
EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
|
EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
|
||||||
ast::type::ImageFormat::kR16Float);
|
type::ImageFormat::kR16Float);
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
|
||||||
ast::type::TextureDimension::k2d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType_Old) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType_Old) {
|
||||||
|
@ -383,17 +372,16 @@ TEST_F(ParserImplTest,
|
||||||
EXPECT_FALSE(ac.errored);
|
EXPECT_FALSE(ac.errored);
|
||||||
ASSERT_NE(ac.value, nullptr);
|
ASSERT_NE(ac.value, nullptr);
|
||||||
|
|
||||||
ASSERT_TRUE(ac->Is<ast::type::AccessControl>());
|
ASSERT_TRUE(ac->Is<type::AccessControl>());
|
||||||
EXPECT_EQ(ac->As<ast::type::AccessControl>()->access_control(),
|
EXPECT_EQ(ac->As<type::AccessControl>()->access_control(),
|
||||||
ast::AccessControl::kReadOnly);
|
ast::AccessControl::kReadOnly);
|
||||||
|
|
||||||
auto* t = ac->As<ast::type::AccessControl>()->type();
|
auto* t = ac->As<type::AccessControl>()->type();
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
|
ASSERT_TRUE(t->Is<type::StorageTexture>());
|
||||||
EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
|
EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
|
||||||
ast::type::ImageFormat::kR8Unorm);
|
type::ImageFormat::kR8Unorm);
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
|
||||||
ast::type::TextureDimension::k1d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest,
|
TEST_F(ParserImplTest,
|
||||||
|
@ -405,17 +393,16 @@ TEST_F(ParserImplTest,
|
||||||
EXPECT_FALSE(ac.errored);
|
EXPECT_FALSE(ac.errored);
|
||||||
ASSERT_NE(ac.value, nullptr);
|
ASSERT_NE(ac.value, nullptr);
|
||||||
|
|
||||||
ASSERT_TRUE(ac->Is<ast::type::AccessControl>());
|
ASSERT_TRUE(ac->Is<type::AccessControl>());
|
||||||
EXPECT_EQ(ac->As<ast::type::AccessControl>()->access_control(),
|
EXPECT_EQ(ac->As<type::AccessControl>()->access_control(),
|
||||||
ast::AccessControl::kWriteOnly);
|
ast::AccessControl::kWriteOnly);
|
||||||
|
|
||||||
auto* t = ac->As<ast::type::AccessControl>()->type();
|
auto* t = ac->As<type::AccessControl>()->type();
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
|
ASSERT_TRUE(t->Is<type::StorageTexture>());
|
||||||
EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
|
EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
|
||||||
ast::type::ImageFormat::kR16Float);
|
type::ImageFormat::kR16Float);
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
|
||||||
ast::type::TextureDimension::k2d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType_old) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType_old) {
|
||||||
|
@ -463,12 +450,11 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
|
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
|
ASSERT_TRUE(t->Is<type::StorageTexture>());
|
||||||
EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
|
EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
|
||||||
ast::type::ImageFormat::kR8Unorm);
|
type::ImageFormat::kR8Unorm);
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
|
||||||
ast::type::TextureDimension::k1d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
|
||||||
|
@ -479,12 +465,11 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
|
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
|
ASSERT_TRUE(t->Is<type::StorageTexture>());
|
||||||
EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
|
EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
|
||||||
ast::type::ImageFormat::kR16Float);
|
type::ImageFormat::kR16Float);
|
||||||
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
|
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
|
||||||
ast::type::TextureDimension::k2d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {
|
||||||
|
|
|
@ -13,12 +13,12 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/alias_type.h"
|
|
||||||
#include "src/ast/type/array_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/alias_type.h"
|
||||||
|
#include "src/type/array_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -29,23 +29,23 @@ TEST_F(ParserImplTest, TypeDecl_ParsesType) {
|
||||||
auto p = parser("type a = i32");
|
auto p = parser("type a = i32");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.create<ast::type::I32>();
|
auto* i32 = mod.create<type::I32>();
|
||||||
|
|
||||||
auto t = p->type_alias();
|
auto t = p->type_alias();
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Alias>());
|
ASSERT_TRUE(t->Is<type::Alias>());
|
||||||
auto* alias = t->As<ast::type::Alias>();
|
auto* alias = t->As<type::Alias>();
|
||||||
ASSERT_TRUE(alias->type()->Is<ast::type::I32>());
|
ASSERT_TRUE(alias->type()->Is<type::I32>());
|
||||||
ASSERT_EQ(alias->type(), i32);
|
ASSERT_EQ(alias->type(), i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
|
TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
|
||||||
auto p = parser("type a = B");
|
auto p = parser("type a = B");
|
||||||
|
|
||||||
ast::type::Struct str(p->get_module().RegisterSymbol("B"), {});
|
type::Struct str(p->get_module().RegisterSymbol("B"), {});
|
||||||
p->register_constructed("B", &str);
|
p->register_constructed("B", &str);
|
||||||
|
|
||||||
auto t = p->type_alias();
|
auto t = p->type_alias();
|
||||||
|
@ -53,12 +53,12 @@ TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Alias>());
|
ASSERT_TRUE(t->Is<type::Alias>());
|
||||||
auto* alias = t->As<ast::type::Alias>();
|
auto* alias = t->As<type::Alias>();
|
||||||
EXPECT_EQ(p->get_module().SymbolToName(alias->symbol()), "a");
|
EXPECT_EQ(p->get_module().SymbolToName(alias->symbol()), "a");
|
||||||
ASSERT_TRUE(alias->type()->Is<ast::type::Struct>());
|
ASSERT_TRUE(alias->type()->Is<type::Struct>());
|
||||||
|
|
||||||
auto* s = alias->type()->As<ast::type::Struct>();
|
auto* s = alias->type()->As<type::Struct>();
|
||||||
EXPECT_EQ(s->symbol(), p->get_module().RegisterSymbol("B"));
|
EXPECT_EQ(s->symbol(), p->get_module().RegisterSymbol("B"));
|
||||||
EXPECT_EQ(s->symbol(), p->get_module().RegisterSymbol("B"));
|
EXPECT_EQ(s->symbol(), p->get_module().RegisterSymbol("B"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,20 +14,20 @@
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/stride_decoration.h"
|
#include "src/ast/stride_decoration.h"
|
||||||
#include "src/ast/type/alias_type.h"
|
|
||||||
#include "src/ast/type/array_type.h"
|
|
||||||
#include "src/ast/type/bool_type.h"
|
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/matrix_type.h"
|
|
||||||
#include "src/ast/type/pointer_type.h"
|
|
||||||
#include "src/ast/type/sampled_texture_type.h"
|
|
||||||
#include "src/ast/type/sampler_type.h"
|
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/type/vector_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/alias_type.h"
|
||||||
|
#include "src/type/array_type.h"
|
||||||
|
#include "src/type/bool_type.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/matrix_type.h"
|
||||||
|
#include "src/type/pointer_type.h"
|
||||||
|
#include "src/type/sampled_texture_type.h"
|
||||||
|
#include "src/type/sampler_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -48,9 +48,8 @@ TEST_F(ParserImplTest, TypeDecl_Identifier) {
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
|
|
||||||
auto* int_type = mod.create<ast::type::I32>();
|
auto* int_type = mod.create<type::I32>();
|
||||||
auto* alias_type =
|
auto* alias_type = mod.create<type::Alias>(mod.RegisterSymbol("A"), int_type);
|
||||||
mod.create<ast::type::Alias>(mod.RegisterSymbol("A"), int_type);
|
|
||||||
|
|
||||||
p->register_constructed("A", alias_type);
|
p->register_constructed("A", alias_type);
|
||||||
|
|
||||||
|
@ -59,9 +58,9 @@ TEST_F(ParserImplTest, TypeDecl_Identifier) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
EXPECT_EQ(t.value, alias_type);
|
EXPECT_EQ(t.value, alias_type);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Alias>());
|
ASSERT_TRUE(t->Is<type::Alias>());
|
||||||
|
|
||||||
auto* alias = t->As<ast::type::Alias>();
|
auto* alias = t->As<type::Alias>();
|
||||||
EXPECT_EQ(p->get_module().SymbolToName(alias->symbol()), "A");
|
EXPECT_EQ(p->get_module().SymbolToName(alias->symbol()), "A");
|
||||||
EXPECT_EQ(alias->type(), int_type);
|
EXPECT_EQ(alias->type(), int_type);
|
||||||
}
|
}
|
||||||
|
@ -81,56 +80,56 @@ TEST_F(ParserImplTest, TypeDecl_Bool) {
|
||||||
auto p = parser("bool");
|
auto p = parser("bool");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* bool_type = mod.create<ast::type::Bool>();
|
auto* bool_type = mod.create<type::Bool>();
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
EXPECT_EQ(t.value, bool_type);
|
EXPECT_EQ(t.value, bool_type);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Bool>());
|
ASSERT_TRUE(t->Is<type::Bool>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TypeDecl_F32) {
|
TEST_F(ParserImplTest, TypeDecl_F32) {
|
||||||
auto p = parser("f32");
|
auto p = parser("f32");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* float_type = mod.create<ast::type::F32>();
|
auto* float_type = mod.create<type::F32>();
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
EXPECT_EQ(t.value, float_type);
|
EXPECT_EQ(t.value, float_type);
|
||||||
ASSERT_TRUE(t->Is<ast::type::F32>());
|
ASSERT_TRUE(t->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TypeDecl_I32) {
|
TEST_F(ParserImplTest, TypeDecl_I32) {
|
||||||
auto p = parser("i32");
|
auto p = parser("i32");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* int_type = mod.create<ast::type::I32>();
|
auto* int_type = mod.create<type::I32>();
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
EXPECT_EQ(t.value, int_type);
|
EXPECT_EQ(t.value, int_type);
|
||||||
ASSERT_TRUE(t->Is<ast::type::I32>());
|
ASSERT_TRUE(t->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TypeDecl_U32) {
|
TEST_F(ParserImplTest, TypeDecl_U32) {
|
||||||
auto p = parser("u32");
|
auto p = parser("u32");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* uint_type = mod.create<ast::type::U32>();
|
auto* uint_type = mod.create<type::U32>();
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
EXPECT_EQ(t.value, uint_type);
|
EXPECT_EQ(t.value, uint_type);
|
||||||
ASSERT_TRUE(t->Is<ast::type::U32>());
|
ASSERT_TRUE(t->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
struct VecData {
|
struct VecData {
|
||||||
|
@ -152,8 +151,8 @@ TEST_P(VecTest, Parse) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
EXPECT_TRUE(t->Is<ast::type::Vector>());
|
EXPECT_TRUE(t->Is<type::Vector>());
|
||||||
EXPECT_EQ(t->As<ast::type::Vector>()->size(), params.count);
|
EXPECT_EQ(t->As<type::Vector>()->size(), params.count);
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_SUITE_P(ParserImplTest,
|
INSTANTIATE_TEST_SUITE_P(ParserImplTest,
|
||||||
VecTest,
|
VecTest,
|
||||||
|
@ -240,10 +239,10 @@ TEST_F(ParserImplTest, TypeDecl_Ptr) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
ASSERT_TRUE(t->Is<ast::type::Pointer>());
|
ASSERT_TRUE(t->Is<type::Pointer>());
|
||||||
|
|
||||||
auto* ptr = t->As<ast::type::Pointer>();
|
auto* ptr = t->As<type::Pointer>();
|
||||||
ASSERT_TRUE(ptr->type()->Is<ast::type::F32>());
|
ASSERT_TRUE(ptr->type()->Is<type::F32>());
|
||||||
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
|
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,15 +253,15 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_ToVec) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
ASSERT_TRUE(t->Is<ast::type::Pointer>());
|
ASSERT_TRUE(t->Is<type::Pointer>());
|
||||||
|
|
||||||
auto* ptr = t->As<ast::type::Pointer>();
|
auto* ptr = t->As<type::Pointer>();
|
||||||
ASSERT_TRUE(ptr->type()->Is<ast::type::Vector>());
|
ASSERT_TRUE(ptr->type()->Is<type::Vector>());
|
||||||
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
|
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
|
||||||
|
|
||||||
auto* vec = ptr->type()->As<ast::type::Vector>();
|
auto* vec = ptr->type()->As<type::Vector>();
|
||||||
ASSERT_EQ(vec->size(), 2u);
|
ASSERT_EQ(vec->size(), 2u);
|
||||||
ASSERT_TRUE(vec->type()->Is<ast::type::F32>());
|
ASSERT_TRUE(vec->type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TypeDecl_Ptr_MissingLessThan) {
|
TEST_F(ParserImplTest, TypeDecl_Ptr_MissingLessThan) {
|
||||||
|
@ -352,12 +351,12 @@ TEST_F(ParserImplTest, TypeDecl_Array) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
ASSERT_TRUE(t->Is<ast::type::Array>());
|
ASSERT_TRUE(t->Is<type::Array>());
|
||||||
|
|
||||||
auto* a = t->As<ast::type::Array>();
|
auto* a = t->As<type::Array>();
|
||||||
ASSERT_FALSE(a->IsRuntimeArray());
|
ASSERT_FALSE(a->IsRuntimeArray());
|
||||||
ASSERT_EQ(a->size(), 5u);
|
ASSERT_EQ(a->size(), 5u);
|
||||||
ASSERT_TRUE(a->type()->Is<ast::type::F32>());
|
ASSERT_TRUE(a->type()->Is<type::F32>());
|
||||||
ASSERT_FALSE(a->has_array_stride());
|
ASSERT_FALSE(a->has_array_stride());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,12 +367,12 @@ TEST_F(ParserImplTest, TypeDecl_Array_Stride) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
ASSERT_TRUE(t->Is<ast::type::Array>());
|
ASSERT_TRUE(t->Is<type::Array>());
|
||||||
|
|
||||||
auto* a = t->As<ast::type::Array>();
|
auto* a = t->As<type::Array>();
|
||||||
ASSERT_FALSE(a->IsRuntimeArray());
|
ASSERT_FALSE(a->IsRuntimeArray());
|
||||||
ASSERT_EQ(a->size(), 5u);
|
ASSERT_EQ(a->size(), 5u);
|
||||||
ASSERT_TRUE(a->type()->Is<ast::type::F32>());
|
ASSERT_TRUE(a->type()->Is<type::F32>());
|
||||||
ASSERT_TRUE(a->has_array_stride());
|
ASSERT_TRUE(a->has_array_stride());
|
||||||
EXPECT_EQ(a->array_stride(), 16u);
|
EXPECT_EQ(a->array_stride(), 16u);
|
||||||
}
|
}
|
||||||
|
@ -385,11 +384,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Stride) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
ASSERT_TRUE(t->Is<ast::type::Array>());
|
ASSERT_TRUE(t->Is<type::Array>());
|
||||||
|
|
||||||
auto* a = t->As<ast::type::Array>();
|
auto* a = t->As<type::Array>();
|
||||||
ASSERT_TRUE(a->IsRuntimeArray());
|
ASSERT_TRUE(a->IsRuntimeArray());
|
||||||
ASSERT_TRUE(a->type()->Is<ast::type::F32>());
|
ASSERT_TRUE(a->type()->Is<type::F32>());
|
||||||
ASSERT_TRUE(a->has_array_stride());
|
ASSERT_TRUE(a->has_array_stride());
|
||||||
EXPECT_EQ(a->array_stride(), 16u);
|
EXPECT_EQ(a->array_stride(), 16u);
|
||||||
}
|
}
|
||||||
|
@ -401,11 +400,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_OneBlock) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
ASSERT_TRUE(t->Is<ast::type::Array>());
|
ASSERT_TRUE(t->Is<type::Array>());
|
||||||
|
|
||||||
auto* a = t->As<ast::type::Array>();
|
auto* a = t->As<type::Array>();
|
||||||
ASSERT_TRUE(a->IsRuntimeArray());
|
ASSERT_TRUE(a->IsRuntimeArray());
|
||||||
ASSERT_TRUE(a->type()->Is<ast::type::F32>());
|
ASSERT_TRUE(a->type()->Is<type::F32>());
|
||||||
|
|
||||||
auto& decos = a->decorations();
|
auto& decos = a->decorations();
|
||||||
ASSERT_EQ(decos.size(), 2u);
|
ASSERT_EQ(decos.size(), 2u);
|
||||||
|
@ -422,11 +421,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_MultipleBlocks) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
ASSERT_TRUE(t->Is<ast::type::Array>());
|
ASSERT_TRUE(t->Is<type::Array>());
|
||||||
|
|
||||||
auto* a = t->As<ast::type::Array>();
|
auto* a = t->As<type::Array>();
|
||||||
ASSERT_TRUE(a->IsRuntimeArray());
|
ASSERT_TRUE(a->IsRuntimeArray());
|
||||||
ASSERT_TRUE(a->type()->Is<ast::type::F32>());
|
ASSERT_TRUE(a->type()->Is<type::F32>());
|
||||||
|
|
||||||
auto& decos = a->decorations();
|
auto& decos = a->decorations();
|
||||||
ASSERT_EQ(decos.size(), 2u);
|
ASSERT_EQ(decos.size(), 2u);
|
||||||
|
@ -525,11 +524,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
ASSERT_TRUE(t->Is<ast::type::Array>());
|
ASSERT_TRUE(t->Is<type::Array>());
|
||||||
|
|
||||||
auto* a = t->As<ast::type::Array>();
|
auto* a = t->As<type::Array>();
|
||||||
ASSERT_TRUE(a->IsRuntimeArray());
|
ASSERT_TRUE(a->IsRuntimeArray());
|
||||||
ASSERT_TRUE(a->type()->Is<ast::type::U32>());
|
ASSERT_TRUE(a->type()->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TypeDecl_Array_BadType) {
|
TEST_F(ParserImplTest, TypeDecl_Array_BadType) {
|
||||||
|
@ -622,8 +621,8 @@ TEST_P(MatrixTest, Parse) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
EXPECT_TRUE(t->Is<ast::type::Matrix>());
|
EXPECT_TRUE(t->Is<type::Matrix>());
|
||||||
auto* mat = t->As<ast::type::Matrix>();
|
auto* mat = t->As<type::Matrix>();
|
||||||
EXPECT_EQ(mat->rows(), params.rows);
|
EXPECT_EQ(mat->rows(), params.rows);
|
||||||
EXPECT_EQ(mat->columns(), params.columns);
|
EXPECT_EQ(mat->columns(), params.columns);
|
||||||
}
|
}
|
||||||
|
@ -740,49 +739,49 @@ TEST_F(ParserImplTest, TypeDecl_Sampler) {
|
||||||
auto p = parser("sampler");
|
auto p = parser("sampler");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* type = mod.create<ast::type::Sampler>(ast::type::SamplerKind::kSampler);
|
auto* type = mod.create<type::Sampler>(type::SamplerKind::kSampler);
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
EXPECT_EQ(t.value, type);
|
EXPECT_EQ(t.value, type);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Sampler>());
|
ASSERT_TRUE(t->Is<type::Sampler>());
|
||||||
ASSERT_FALSE(t->As<ast::type::Sampler>()->IsComparison());
|
ASSERT_FALSE(t->As<type::Sampler>()->IsComparison());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TypeDecl_Texture_Old) {
|
TEST_F(ParserImplTest, TypeDecl_Texture_Old) {
|
||||||
auto p = parser("texture_sampled_cube<f32>");
|
auto p = parser("texture_sampled_cube<f32>");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* type = mod.create<ast::type::SampledTexture>(
|
auto* type =
|
||||||
ast::type::TextureDimension::kCube, ty.f32);
|
mod.create<type::SampledTexture>(type::TextureDimension::kCube, ty.f32);
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
EXPECT_EQ(t.value, type);
|
EXPECT_EQ(t.value, type);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
|
ASSERT_TRUE(t->Is<type::SampledTexture>());
|
||||||
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
|
ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TypeDecl_Texture) {
|
TEST_F(ParserImplTest, TypeDecl_Texture) {
|
||||||
auto p = parser("texture_cube<f32>");
|
auto p = parser("texture_cube<f32>");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* type = mod.create<ast::type::SampledTexture>(
|
auto* type =
|
||||||
ast::type::TextureDimension::kCube, ty.f32);
|
mod.create<type::SampledTexture>(type::TextureDimension::kCube, ty.f32);
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
EXPECT_EQ(t.value, type);
|
EXPECT_EQ(t.value, type);
|
||||||
ASSERT_TRUE(t->Is<ast::type::Texture>());
|
ASSERT_TRUE(t->Is<type::Texture>());
|
||||||
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
|
ASSERT_TRUE(t->Is<type::SampledTexture>());
|
||||||
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
|
ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -31,7 +31,7 @@ TEST_F(ParserImplTest, VariableDecl_Parses) {
|
||||||
EXPECT_FALSE(v.errored);
|
EXPECT_FALSE(v.errored);
|
||||||
EXPECT_EQ(v->name, "my_var");
|
EXPECT_EQ(v->name, "my_var");
|
||||||
EXPECT_NE(v->type, nullptr);
|
EXPECT_NE(v->type, nullptr);
|
||||||
EXPECT_TRUE(v->type->Is<ast::type::F32>());
|
EXPECT_TRUE(v->type->Is<type::F32>());
|
||||||
|
|
||||||
EXPECT_EQ(v->source.range.begin.line, 1u);
|
EXPECT_EQ(v->source.range.begin.line, 1u);
|
||||||
EXPECT_EQ(v->source.range.begin.column, 5u);
|
EXPECT_EQ(v->source.range.begin.column, 5u);
|
||||||
|
@ -66,7 +66,7 @@ TEST_F(ParserImplTest, VariableDecl_WithStorageClass) {
|
||||||
EXPECT_FALSE(v.errored);
|
EXPECT_FALSE(v.errored);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
EXPECT_EQ(v->name, "my_var");
|
EXPECT_EQ(v->name, "my_var");
|
||||||
EXPECT_TRUE(v->type->Is<ast::type::F32>());
|
EXPECT_TRUE(v->type->Is<type::F32>());
|
||||||
EXPECT_EQ(v->storage_class, ast::StorageClass::kPrivate);
|
EXPECT_EQ(v->storage_class, ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
EXPECT_EQ(v->source.range.begin.line, 1u);
|
EXPECT_EQ(v->source.range.begin.line, 1u);
|
||||||
|
|
|
@ -15,12 +15,12 @@
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/struct.h"
|
#include "src/ast/struct.h"
|
||||||
#include "src/ast/struct_block_decoration.h"
|
#include "src/ast/struct_block_decoration.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/reader/wgsl/parser_impl.h"
|
#include "src/reader/wgsl/parser_impl.h"
|
||||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
#include "src/type/access_control_type.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -34,7 +34,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_Parses) {
|
||||||
ASSERT_FALSE(decl.errored);
|
ASSERT_FALSE(decl.errored);
|
||||||
ASSERT_EQ(decl->name, "my_var");
|
ASSERT_EQ(decl->name, "my_var");
|
||||||
ASSERT_NE(decl->type, nullptr);
|
ASSERT_NE(decl->type, nullptr);
|
||||||
ASSERT_TRUE(decl->type->Is<ast::type::F32>());
|
ASSERT_TRUE(decl->type->Is<type::F32>());
|
||||||
|
|
||||||
ASSERT_EQ(decl->source.range.begin.line, 1u);
|
ASSERT_EQ(decl->source.range.begin.line, 1u);
|
||||||
ASSERT_EQ(decl->source.range.begin.column, 1u);
|
ASSERT_EQ(decl->source.range.begin.column, 1u);
|
||||||
|
@ -90,11 +90,11 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Read) {
|
||||||
ASSERT_FALSE(decl.errored);
|
ASSERT_FALSE(decl.errored);
|
||||||
ASSERT_EQ(decl->name, "my_var");
|
ASSERT_EQ(decl->name, "my_var");
|
||||||
ASSERT_NE(decl->type, nullptr);
|
ASSERT_NE(decl->type, nullptr);
|
||||||
ASSERT_TRUE(decl->type->Is<ast::type::AccessControl>());
|
ASSERT_TRUE(decl->type->Is<type::AccessControl>());
|
||||||
EXPECT_TRUE(decl->type->As<ast::type::AccessControl>()->IsReadOnly());
|
EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsReadOnly());
|
||||||
ASSERT_TRUE(decl->type->As<ast::type::AccessControl>()
|
ASSERT_TRUE(decl->type->As<type::AccessControl>()
|
||||||
->type()
|
->type()
|
||||||
->Is<ast::type::StorageTexture>());
|
->Is<type::StorageTexture>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Write) {
|
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Write) {
|
||||||
|
@ -105,11 +105,11 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Write) {
|
||||||
ASSERT_FALSE(decl.errored);
|
ASSERT_FALSE(decl.errored);
|
||||||
ASSERT_EQ(decl->name, "my_var");
|
ASSERT_EQ(decl->name, "my_var");
|
||||||
ASSERT_NE(decl->type, nullptr);
|
ASSERT_NE(decl->type, nullptr);
|
||||||
ASSERT_TRUE(decl->type->Is<ast::type::AccessControl>());
|
ASSERT_TRUE(decl->type->Is<type::AccessControl>());
|
||||||
EXPECT_TRUE(decl->type->As<ast::type::AccessControl>()->IsWriteOnly());
|
EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsWriteOnly());
|
||||||
ASSERT_TRUE(decl->type->As<ast::type::AccessControl>()
|
ASSERT_TRUE(decl->type->As<type::AccessControl>()
|
||||||
->type()
|
->type()
|
||||||
->Is<ast::type::StorageTexture>());
|
->Is<type::StorageTexture>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
||||||
|
@ -133,8 +133,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
||||||
ASSERT_FALSE(decl.errored);
|
ASSERT_FALSE(decl.errored);
|
||||||
ASSERT_EQ(decl->name, "my_var");
|
ASSERT_EQ(decl->name, "my_var");
|
||||||
ASSERT_NE(decl->type, nullptr);
|
ASSERT_NE(decl->type, nullptr);
|
||||||
ASSERT_TRUE(decl->type->Is<ast::type::AccessControl>());
|
ASSERT_TRUE(decl->type->Is<type::AccessControl>());
|
||||||
EXPECT_TRUE(decl->type->As<ast::type::AccessControl>()->IsReadOnly());
|
EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsReadOnly());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
||||||
|
@ -158,8 +158,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
||||||
ASSERT_FALSE(decl.errored);
|
ASSERT_FALSE(decl.errored);
|
||||||
ASSERT_EQ(decl->name, "my_var");
|
ASSERT_EQ(decl->name, "my_var");
|
||||||
ASSERT_NE(decl->type, nullptr);
|
ASSERT_NE(decl->type, nullptr);
|
||||||
ASSERT_TRUE(decl->type->Is<ast::type::AccessControl>());
|
ASSERT_TRUE(decl->type->Is<type::AccessControl>());
|
||||||
EXPECT_TRUE(decl->type->As<ast::type::AccessControl>()->IsReadWrite());
|
EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsReadWrite());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
|
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/builder.h"
|
#include "src/ast/builder.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/symbol.h"
|
#include "src/symbol.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -39,15 +39,15 @@
|
||||||
#include "src/ast/scalar_constructor_expression.h"
|
#include "src/ast/scalar_constructor_expression.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
#include "src/ast/switch_statement.h"
|
#include "src/ast/switch_statement.h"
|
||||||
#include "src/ast/type/array_type.h"
|
|
||||||
#include "src/ast/type/matrix_type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/type/vector_type.h"
|
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
#include "src/ast/unary_op_expression.h"
|
#include "src/ast/unary_op_expression.h"
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
|
#include "src/type/array_type.h"
|
||||||
|
#include "src/type/matrix_type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace transform {
|
namespace transform {
|
||||||
|
@ -71,8 +71,8 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
|
||||||
ast::CloneContext* ctx,
|
ast::CloneContext* ctx,
|
||||||
diag::List* diags) {
|
diag::List* diags) {
|
||||||
auto* ret_type = expr->array()->result_type()->UnwrapAll();
|
auto* ret_type = expr->array()->result_type()->UnwrapAll();
|
||||||
if (!ret_type->Is<ast::type::Array>() && !ret_type->Is<ast::type::Matrix>() &&
|
if (!ret_type->Is<type::Array>() && !ret_type->Is<type::Matrix>() &&
|
||||||
!ret_type->Is<ast::type::Vector>()) {
|
!ret_type->Is<type::Vector>()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,15 +80,15 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
|
||||||
using u32 = ast::Builder::u32;
|
using u32 = ast::Builder::u32;
|
||||||
|
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
bool is_vec = ret_type->Is<ast::type::Vector>();
|
bool is_vec = ret_type->Is<type::Vector>();
|
||||||
bool is_arr = ret_type->Is<ast::type::Array>();
|
bool is_arr = ret_type->Is<type::Array>();
|
||||||
if (is_vec || is_arr) {
|
if (is_vec || is_arr) {
|
||||||
size = is_vec ? ret_type->As<ast::type::Vector>()->size()
|
size = is_vec ? ret_type->As<type::Vector>()->size()
|
||||||
: ret_type->As<ast::type::Array>()->size();
|
: ret_type->As<type::Array>()->size();
|
||||||
} else {
|
} else {
|
||||||
// The row accessor would have been an embedded array accessor and already
|
// The row accessor would have been an embedded array accessor and already
|
||||||
// handled, so we just need to do columns here.
|
// handled, so we just need to do columns here.
|
||||||
size = ret_type->As<ast::type::Matrix>()->columns();
|
size = ret_type->As<type::Matrix>()->columns();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* const old_idx = expr->idx_expr();
|
auto* const old_idx = expr->idx_expr();
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
#include "src/ast/float_literal.h"
|
#include "src/ast/float_literal.h"
|
||||||
#include "src/ast/identifier_expression.h"
|
#include "src/ast/identifier_expression.h"
|
||||||
#include "src/ast/scalar_constructor_expression.h"
|
#include "src/ast/scalar_constructor_expression.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type_manager.h"
|
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/type_manager.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace transform {
|
namespace transform {
|
||||||
|
@ -47,7 +47,7 @@ Transform::Output EmitVertexPointSize::Run(ast::Module* in) {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* f32 = out.module.create<ast::type::F32>();
|
auto* f32 = out.module.create<type::F32>();
|
||||||
|
|
||||||
// Declare the pointsize builtin output variable.
|
// Declare the pointsize builtin output variable.
|
||||||
auto* pointsize_var = out.module.create<ast::Variable>(
|
auto* pointsize_var = out.module.create<ast::Variable>(
|
||||||
|
|
|
@ -42,13 +42,13 @@
|
||||||
#include "src/ast/struct_member.h"
|
#include "src/ast/struct_member.h"
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
#include "src/ast/switch_statement.h"
|
#include "src/ast/switch_statement.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
#include "src/ast/unary_op_expression.h"
|
#include "src/ast/unary_op_expression.h"
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
#include "src/ast/variable_decoration.h"
|
#include "src/ast/variable_decoration.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
#include "src/type_determiner.h"
|
#include "src/type_determiner.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -196,7 +196,7 @@ uint32_t FirstIndexOffset::GetFirstInstanceOffset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::Variable* FirstIndexOffset::AddUniformBuffer(ast::Module* mod) {
|
ast::Variable* FirstIndexOffset::AddUniformBuffer(ast::Module* mod) {
|
||||||
auto* u32_type = mod->create<ast::type::U32>();
|
auto* u32_type = mod->create<type::U32>();
|
||||||
ast::StructMemberList members;
|
ast::StructMemberList members;
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
if (has_vertex_index_) {
|
if (has_vertex_index_) {
|
||||||
|
@ -224,7 +224,7 @@ ast::Variable* FirstIndexOffset::AddUniformBuffer(ast::Module* mod) {
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
decos.push_back(mod->create<ast::StructBlockDecoration>(Source{}));
|
decos.push_back(mod->create<ast::StructBlockDecoration>(Source{}));
|
||||||
|
|
||||||
auto* struct_type = mod->create<ast::type::Struct>(
|
auto* struct_type = mod->create<type::Struct>(
|
||||||
mod->RegisterSymbol(kStructName),
|
mod->RegisterSymbol(kStructName),
|
||||||
mod->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
|
mod->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
|
||||||
|
|
||||||
|
@ -268,9 +268,9 @@ ast::VariableDeclStatement* FirstIndexOffset::CreateFirstIndexOffset(
|
||||||
mod->create<ast::Variable>(Source{}, // source
|
mod->create<ast::Variable>(Source{}, // source
|
||||||
mod->RegisterSymbol(original_name), // symbol
|
mod->RegisterSymbol(original_name), // symbol
|
||||||
ast::StorageClass::kNone, // storage_class
|
ast::StorageClass::kNone, // storage_class
|
||||||
mod->create<ast::type::U32>(), // type
|
mod->create<type::U32>(), // type
|
||||||
true, // is_const
|
true, // is_const
|
||||||
constructor, // constructor
|
constructor, // constructor
|
||||||
ast::VariableDecorationList{}); // decorations
|
ast::VariableDecorationList{}); // decorations
|
||||||
return mod->create<ast::VariableDeclStatement>(Source{}, var);
|
return mod->create<ast::VariableDeclStatement>(Source{}, var);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,16 +29,16 @@
|
||||||
#include "src/ast/struct_decoration.h"
|
#include "src/ast/struct_decoration.h"
|
||||||
#include "src/ast/struct_member.h"
|
#include "src/ast/struct_member.h"
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
#include "src/ast/type/array_type.h"
|
|
||||||
#include "src/ast/type/f32_type.h"
|
|
||||||
#include "src/ast/type/i32_type.h"
|
|
||||||
#include "src/ast/type/struct_type.h"
|
|
||||||
#include "src/ast/type/u32_type.h"
|
|
||||||
#include "src/ast/type/vector_type.h"
|
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
|
#include "src/type/array_type.h"
|
||||||
|
#include "src/type/f32_type.h"
|
||||||
|
#include "src/type/i32_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
#include "src/type/u32_type.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace transform {
|
namespace transform {
|
||||||
|
@ -261,7 +261,7 @@ void VertexPulling::State::ConvertVertexInputVariablesToPrivate() {
|
||||||
void VertexPulling::State::AddVertexStorageBuffers() {
|
void VertexPulling::State::AddVertexStorageBuffers() {
|
||||||
// TODO(idanr): Make this readonly https://github.com/gpuweb/gpuweb/issues/935
|
// TODO(idanr): Make this readonly https://github.com/gpuweb/gpuweb/issues/935
|
||||||
// The array inside the struct definition
|
// The array inside the struct definition
|
||||||
auto* internal_array_type = out->create<ast::type::Array>(
|
auto* internal_array_type = out->create<type::Array>(
|
||||||
GetU32Type(), 0,
|
GetU32Type(), 0,
|
||||||
ast::ArrayDecorationList{
|
ast::ArrayDecorationList{
|
||||||
out->create<ast::StrideDecoration>(Source{}, 4u),
|
out->create<ast::StrideDecoration>(Source{}, 4u),
|
||||||
|
@ -280,7 +280,7 @@ void VertexPulling::State::AddVertexStorageBuffers() {
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
decos.push_back(out->create<ast::StructBlockDecoration>(Source{}));
|
decos.push_back(out->create<ast::StructBlockDecoration>(Source{}));
|
||||||
|
|
||||||
auto* struct_type = out->create<ast::type::Struct>(
|
auto* struct_type = out->create<type::Struct>(
|
||||||
out->RegisterSymbol(kStructName),
|
out->RegisterSymbol(kStructName),
|
||||||
out->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
|
out->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ ast::Expression* VertexPulling::State::AccessPrimitive(
|
||||||
|
|
||||||
ast::Expression* VertexPulling::State::AccessVec(uint32_t buffer,
|
ast::Expression* VertexPulling::State::AccessVec(uint32_t buffer,
|
||||||
uint32_t element_stride,
|
uint32_t element_stride,
|
||||||
ast::type::Type* base_type,
|
type::Type* base_type,
|
||||||
VertexFormat base_format,
|
VertexFormat base_format,
|
||||||
uint32_t count) const {
|
uint32_t count) const {
|
||||||
ast::ExpressionList expr_list;
|
ast::ExpressionList expr_list;
|
||||||
|
@ -476,20 +476,20 @@ ast::Expression* VertexPulling::State::AccessVec(uint32_t buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
return out->create<ast::TypeConstructorExpression>(
|
return out->create<ast::TypeConstructorExpression>(
|
||||||
Source{}, out->create<ast::type::Vector>(base_type, count),
|
Source{}, out->create<type::Vector>(base_type, count),
|
||||||
std::move(expr_list));
|
std::move(expr_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* VertexPulling::State::GetU32Type() const {
|
type::Type* VertexPulling::State::GetU32Type() const {
|
||||||
return out->create<ast::type::U32>();
|
return out->create<type::U32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* VertexPulling::State::GetI32Type() const {
|
type::Type* VertexPulling::State::GetI32Type() const {
|
||||||
return out->create<ast::type::I32>();
|
return out->create<type::I32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* VertexPulling::State::GetF32Type() const {
|
type::Type* VertexPulling::State::GetF32Type() const {
|
||||||
return out->create<ast::type::F32>();
|
return out->create<type::F32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexBufferLayoutDescriptor::VertexBufferLayoutDescriptor() = default;
|
VertexBufferLayoutDescriptor::VertexBufferLayoutDescriptor() = default;
|
||||||
|
|
|
@ -254,14 +254,14 @@ class VertexPulling : public Transform {
|
||||||
/// @param count how many elements the vector has
|
/// @param count how many elements the vector has
|
||||||
ast::Expression* AccessVec(uint32_t buffer,
|
ast::Expression* AccessVec(uint32_t buffer,
|
||||||
uint32_t element_stride,
|
uint32_t element_stride,
|
||||||
ast::type::Type* base_type,
|
type::Type* base_type,
|
||||||
VertexFormat base_format,
|
VertexFormat base_format,
|
||||||
uint32_t count) const;
|
uint32_t count) const;
|
||||||
|
|
||||||
// Used to grab corresponding types from the type manager
|
// Used to grab corresponding types from the type manager
|
||||||
ast::type::Type* GetU32Type() const;
|
type::Type* GetU32Type() const;
|
||||||
ast::type::Type* GetI32Type() const;
|
type::Type* GetI32Type() const;
|
||||||
ast::type::Type* GetF32Type() const;
|
type::Type* GetF32Type() const;
|
||||||
|
|
||||||
ast::Module* const in;
|
ast::Module* const in;
|
||||||
ast::Module* const out;
|
ast::Module* const out;
|
||||||
|
|
|
@ -12,17 +12,16 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/type/access_control_type.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "src/ast/clone_context.h"
|
#include "src/ast/clone_context.h"
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::type::AccessControl);
|
TINT_INSTANTIATE_CLASS_ID(tint::type::AccessControl);
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
AccessControl::AccessControl(ast::AccessControl access, Type* subtype)
|
AccessControl::AccessControl(ast::AccessControl access, Type* subtype)
|
||||||
|
@ -64,5 +63,4 @@ AccessControl* AccessControl::Clone(CloneContext* ctx) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -12,16 +12,15 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_AST_TYPE_ACCESS_CONTROL_TYPE_H_
|
#ifndef SRC_TYPE_ACCESS_CONTROL_TYPE_H_
|
||||||
#define SRC_AST_TYPE_ACCESS_CONTROL_TYPE_H_
|
#define SRC_TYPE_ACCESS_CONTROL_TYPE_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/ast/access_control.h"
|
#include "src/ast/access_control.h"
|
||||||
#include "src/ast/type/type.h"
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
/// An access control type. Holds an access setting and pointer to another type.
|
/// An access control type. Holds an access setting and pointer to another type.
|
||||||
|
@ -71,7 +70,6 @@ class AccessControl : public Castable<AccessControl, Type> {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
||||||
#endif // SRC_AST_TYPE_ACCESS_CONTROL_TYPE_H_
|
#endif // SRC_TYPE_ACCESS_CONTROL_TYPE_H_
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/type/access_control_type.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -22,20 +22,19 @@
|
||||||
#include "src/ast/struct_member.h"
|
#include "src/ast/struct_member.h"
|
||||||
#include "src/ast/struct_member_decoration.h"
|
#include "src/ast/struct_member_decoration.h"
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/type/array_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/type/bool_type.h"
|
||||||
#include "src/ast/type/bool_type.h"
|
#include "src/type/f32_type.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/type/i32_type.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/matrix_type.h"
|
||||||
#include "src/ast/type/matrix_type.h"
|
#include "src/type/pointer_type.h"
|
||||||
#include "src/ast/type/pointer_type.h"
|
#include "src/type/struct_type.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/type/test_helper.h"
|
||||||
#include "src/ast/type/texture_type.h"
|
#include "src/type/texture_type.h"
|
||||||
#include "src/ast/type/u32_type.h"
|
#include "src/type/u32_type.h"
|
||||||
#include "src/ast/type/vector_type.h"
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -106,23 +105,25 @@ TEST_F(AccessControlTest, MinBufferBindingSizeU32) {
|
||||||
|
|
||||||
TEST_F(AccessControlTest, MinBufferBindingSizeArray) {
|
TEST_F(AccessControlTest, MinBufferBindingSizeArray) {
|
||||||
U32 u32;
|
U32 u32;
|
||||||
Array array(&u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
|
Array array(&u32, 4,
|
||||||
|
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||||
AccessControl at{ast::AccessControl::kReadOnly, &array};
|
AccessControl at{ast::AccessControl::kReadOnly, &array};
|
||||||
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AccessControlTest, MinBufferBindingSizeRuntimeArray) {
|
TEST_F(AccessControlTest, MinBufferBindingSizeRuntimeArray) {
|
||||||
U32 u32;
|
U32 u32;
|
||||||
Array array(&u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
|
Array array(&u32, 0,
|
||||||
|
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||||
AccessControl at{ast::AccessControl::kReadOnly, &array};
|
AccessControl at{ast::AccessControl::kReadOnly, &array};
|
||||||
EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AccessControlTest, MinBufferBindingSizeStruct) {
|
TEST_F(AccessControlTest, MinBufferBindingSizeStruct) {
|
||||||
auto* str = create<ast::Struct>(
|
auto* str = create<ast::Struct>(
|
||||||
StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||||
Member("bar", ty.u32, {MemberOffset(4)})},
|
Member("bar", ty.u32, {MemberOffset(4)})},
|
||||||
StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
auto* struct_type = ty.struct_("struct_type", str);
|
auto* struct_type = ty.struct_("struct_type", str);
|
||||||
AccessControl at{ast::AccessControl::kReadOnly, struct_type};
|
AccessControl at{ast::AccessControl::kReadOnly, struct_type};
|
||||||
|
@ -138,23 +139,25 @@ TEST_F(AccessControlTest, BaseAlignmentU32) {
|
||||||
|
|
||||||
TEST_F(AccessControlTest, BaseAlignmentArray) {
|
TEST_F(AccessControlTest, BaseAlignmentArray) {
|
||||||
U32 u32;
|
U32 u32;
|
||||||
Array array(&u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
|
Array array(&u32, 4,
|
||||||
|
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||||
AccessControl at{ast::AccessControl::kReadOnly, &array};
|
AccessControl at{ast::AccessControl::kReadOnly, &array};
|
||||||
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AccessControlTest, BaseAlignmentRuntimeArray) {
|
TEST_F(AccessControlTest, BaseAlignmentRuntimeArray) {
|
||||||
U32 u32;
|
U32 u32;
|
||||||
Array array(&u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
|
Array array(&u32, 0,
|
||||||
|
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||||
AccessControl at{ast::AccessControl::kReadOnly, &array};
|
AccessControl at{ast::AccessControl::kReadOnly, &array};
|
||||||
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AccessControlTest, BaseAlignmentStruct) {
|
TEST_F(AccessControlTest, BaseAlignmentStruct) {
|
||||||
auto* str = create<ast::Struct>(
|
auto* str = create<ast::Struct>(
|
||||||
StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||||
Member("bar", ty.u32, {MemberOffset(4)})},
|
Member("bar", ty.u32, {MemberOffset(4)})},
|
||||||
StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
auto* struct_type = ty.struct_("struct_type", str);
|
auto* struct_type = ty.struct_("struct_type", str);
|
||||||
|
|
||||||
AccessControl at{ast::AccessControl::kReadOnly, struct_type};
|
AccessControl at{ast::AccessControl::kReadOnly, struct_type};
|
||||||
|
@ -164,5 +167,4 @@ TEST_F(AccessControlTest, BaseAlignmentStruct) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -12,17 +12,16 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/alias_type.h"
|
#include "src/type/alias_type.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "src/ast/clone_context.h"
|
#include "src/ast/clone_context.h"
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Alias);
|
TINT_INSTANTIATE_CLASS_ID(tint::type::Alias);
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
Alias::Alias(const Symbol& sym, Type* subtype)
|
Alias::Alias(const Symbol& sym, Type* subtype)
|
||||||
|
@ -51,5 +50,4 @@ Alias* Alias::Clone(CloneContext* ctx) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -12,16 +12,15 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_AST_TYPE_ALIAS_TYPE_H_
|
#ifndef SRC_TYPE_ALIAS_TYPE_H_
|
||||||
#define SRC_AST_TYPE_ALIAS_TYPE_H_
|
#define SRC_TYPE_ALIAS_TYPE_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/ast/type/type.h"
|
|
||||||
#include "src/symbol.h"
|
#include "src/symbol.h"
|
||||||
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
/// A type alias type. Holds a name and pointer to another type.
|
/// A type alias type. Holds a name and pointer to another type.
|
||||||
|
@ -65,7 +64,6 @@ class Alias : public Castable<Alias, Type> {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
||||||
#endif // SRC_AST_TYPE_ALIAS_TYPE_H_
|
#endif // SRC_TYPE_ALIAS_TYPE_H_
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/alias_type.h"
|
#include "src/type/alias_type.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -22,20 +22,19 @@
|
||||||
#include "src/ast/struct_member.h"
|
#include "src/ast/struct_member.h"
|
||||||
#include "src/ast/struct_member_decoration.h"
|
#include "src/ast/struct_member_decoration.h"
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/type/access_control_type.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/type/array_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/type/bool_type.h"
|
||||||
#include "src/ast/type/bool_type.h"
|
#include "src/type/f32_type.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/type/i32_type.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/matrix_type.h"
|
||||||
#include "src/ast/type/matrix_type.h"
|
#include "src/type/pointer_type.h"
|
||||||
#include "src/ast/type/pointer_type.h"
|
#include "src/type/struct_type.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/type/test_helper.h"
|
||||||
#include "src/ast/type/texture_type.h"
|
#include "src/type/texture_type.h"
|
||||||
#include "src/ast/type/vector_type.h"
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -104,7 +103,7 @@ TEST_F(AliasTest, UnwrapIfNeeded_MultiLevel_AliasAccessControl) {
|
||||||
TEST_F(AliasTest, UnwrapAll_TwiceAliasPointerTwiceAlias) {
|
TEST_F(AliasTest, UnwrapAll_TwiceAliasPointerTwiceAlias) {
|
||||||
auto* a = ty.alias("a_type", ty.u32);
|
auto* a = ty.alias("a_type", ty.u32);
|
||||||
auto* aa = ty.alias("aa_type", a);
|
auto* aa = ty.alias("aa_type", a);
|
||||||
Pointer paa{aa, StorageClass::kUniform};
|
Pointer paa{aa, ast::StorageClass::kUniform};
|
||||||
auto* apaa = ty.alias("paa_type", &paa);
|
auto* apaa = ty.alias("paa_type", &paa);
|
||||||
auto* aapaa = ty.alias("aapaa_type", apaa);
|
auto* aapaa = ty.alias("aapaa_type", apaa);
|
||||||
|
|
||||||
|
@ -117,8 +116,8 @@ TEST_F(AliasTest, UnwrapAll_SecondConsecutivePointerBlocksUnrapping) {
|
||||||
auto* a = ty.alias("a_type", ty.u32);
|
auto* a = ty.alias("a_type", ty.u32);
|
||||||
auto* aa = ty.alias("aa_type", a);
|
auto* aa = ty.alias("aa_type", a);
|
||||||
|
|
||||||
Pointer paa{aa, StorageClass::kUniform};
|
Pointer paa{aa, ast::StorageClass::kUniform};
|
||||||
Pointer ppaa{&paa, StorageClass::kUniform};
|
Pointer ppaa{&paa, ast::StorageClass::kUniform};
|
||||||
auto* appaa = ty.alias("appaa_type", &ppaa);
|
auto* appaa = ty.alias("appaa_type", &ppaa);
|
||||||
EXPECT_EQ(appaa->UnwrapAll(), &paa);
|
EXPECT_EQ(appaa->UnwrapAll(), &paa);
|
||||||
}
|
}
|
||||||
|
@ -126,11 +125,11 @@ TEST_F(AliasTest, UnwrapAll_SecondConsecutivePointerBlocksUnrapping) {
|
||||||
TEST_F(AliasTest, UnwrapAll_SecondNonConsecutivePointerBlocksUnrapping) {
|
TEST_F(AliasTest, UnwrapAll_SecondNonConsecutivePointerBlocksUnrapping) {
|
||||||
auto* a = ty.alias("a_type", ty.u32);
|
auto* a = ty.alias("a_type", ty.u32);
|
||||||
auto* aa = ty.alias("aa_type", a);
|
auto* aa = ty.alias("aa_type", a);
|
||||||
Pointer paa{aa, StorageClass::kUniform};
|
Pointer paa{aa, ast::StorageClass::kUniform};
|
||||||
|
|
||||||
auto* apaa = ty.alias("apaa_type", &paa);
|
auto* apaa = ty.alias("apaa_type", &paa);
|
||||||
auto* aapaa = ty.alias("aapaa_type", apaa);
|
auto* aapaa = ty.alias("aapaa_type", apaa);
|
||||||
Pointer paapaa{aapaa, StorageClass::kUniform};
|
Pointer paapaa{aapaa, ast::StorageClass::kUniform};
|
||||||
auto* apaapaa = ty.alias("apaapaa_type", &paapaa);
|
auto* apaapaa = ty.alias("apaapaa_type", &paapaa);
|
||||||
|
|
||||||
EXPECT_EQ(apaapaa->UnwrapAll(), &paa);
|
EXPECT_EQ(apaapaa->UnwrapAll(), &paa);
|
||||||
|
@ -138,13 +137,13 @@ TEST_F(AliasTest, UnwrapAll_SecondNonConsecutivePointerBlocksUnrapping) {
|
||||||
|
|
||||||
TEST_F(AliasTest, UnwrapAll_AccessControlPointer) {
|
TEST_F(AliasTest, UnwrapAll_AccessControlPointer) {
|
||||||
AccessControl a{ast::AccessControl::kReadOnly, ty.u32};
|
AccessControl a{ast::AccessControl::kReadOnly, ty.u32};
|
||||||
Pointer pa{&a, StorageClass::kUniform};
|
Pointer pa{&a, ast::StorageClass::kUniform};
|
||||||
EXPECT_EQ(pa.type(), &a);
|
EXPECT_EQ(pa.type(), &a);
|
||||||
EXPECT_EQ(pa.UnwrapAll(), ty.u32);
|
EXPECT_EQ(pa.UnwrapAll(), ty.u32);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AliasTest, UnwrapAll_PointerAccessControl) {
|
TEST_F(AliasTest, UnwrapAll_PointerAccessControl) {
|
||||||
Pointer p{ty.u32, StorageClass::kUniform};
|
Pointer p{ty.u32, ast::StorageClass::kUniform};
|
||||||
AccessControl a{ast::AccessControl::kReadOnly, &p};
|
AccessControl a{ast::AccessControl::kReadOnly, &p};
|
||||||
|
|
||||||
EXPECT_EQ(a.type(), &p);
|
EXPECT_EQ(a.type(), &p);
|
||||||
|
@ -158,8 +157,8 @@ TEST_F(AliasTest, MinBufferBindingSizeU32) {
|
||||||
|
|
||||||
TEST_F(AliasTest, MinBufferBindingSizeArray) {
|
TEST_F(AliasTest, MinBufferBindingSizeArray) {
|
||||||
Array array(ty.u32, 4,
|
Array array(ty.u32, 4,
|
||||||
ArrayDecorationList{
|
ast::ArrayDecorationList{
|
||||||
create<StrideDecoration>(4),
|
create<ast::StrideDecoration>(4),
|
||||||
});
|
});
|
||||||
auto* alias = ty.alias("alias", &array);
|
auto* alias = ty.alias("alias", &array);
|
||||||
EXPECT_EQ(16u, alias->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, alias->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -167,8 +166,8 @@ TEST_F(AliasTest, MinBufferBindingSizeArray) {
|
||||||
|
|
||||||
TEST_F(AliasTest, MinBufferBindingSizeRuntimeArray) {
|
TEST_F(AliasTest, MinBufferBindingSizeRuntimeArray) {
|
||||||
Array array(ty.u32, 0,
|
Array array(ty.u32, 0,
|
||||||
ArrayDecorationList{
|
ast::ArrayDecorationList{
|
||||||
create<StrideDecoration>(4),
|
create<ast::StrideDecoration>(4),
|
||||||
});
|
});
|
||||||
auto* alias = ty.alias("alias", &array);
|
auto* alias = ty.alias("alias", &array);
|
||||||
EXPECT_EQ(4u, alias->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(4u, alias->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -176,9 +175,9 @@ TEST_F(AliasTest, MinBufferBindingSizeRuntimeArray) {
|
||||||
|
|
||||||
TEST_F(AliasTest, MinBufferBindingSizeStruct) {
|
TEST_F(AliasTest, MinBufferBindingSizeStruct) {
|
||||||
auto* str = create<ast::Struct>(
|
auto* str = create<ast::Struct>(
|
||||||
StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||||
Member("bar", ty.u32, {MemberOffset(4)})},
|
Member("bar", ty.u32, {MemberOffset(4)})},
|
||||||
StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
auto* struct_type = ty.struct_("struct_type", str);
|
auto* struct_type = ty.struct_("struct_type", str);
|
||||||
auto* alias = ty.alias("alias", struct_type);
|
auto* alias = ty.alias("alias", struct_type);
|
||||||
|
|
||||||
|
@ -193,8 +192,8 @@ TEST_F(AliasTest, BaseAlignmentU32) {
|
||||||
|
|
||||||
TEST_F(AliasTest, BaseAlignmentArray) {
|
TEST_F(AliasTest, BaseAlignmentArray) {
|
||||||
Array array(ty.u32, 4,
|
Array array(ty.u32, 4,
|
||||||
ArrayDecorationList{
|
ast::ArrayDecorationList{
|
||||||
create<StrideDecoration>(4),
|
create<ast::StrideDecoration>(4),
|
||||||
});
|
});
|
||||||
auto* alias = ty.alias("alias", &array);
|
auto* alias = ty.alias("alias", &array);
|
||||||
EXPECT_EQ(16u, alias->BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, alias->BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -202,8 +201,8 @@ TEST_F(AliasTest, BaseAlignmentArray) {
|
||||||
|
|
||||||
TEST_F(AliasTest, BaseAlignmentRuntimeArray) {
|
TEST_F(AliasTest, BaseAlignmentRuntimeArray) {
|
||||||
Array array(ty.u32, 0,
|
Array array(ty.u32, 0,
|
||||||
ArrayDecorationList{
|
ast::ArrayDecorationList{
|
||||||
create<StrideDecoration>(4),
|
create<ast::StrideDecoration>(4),
|
||||||
});
|
});
|
||||||
auto* alias = ty.alias("alias", &array);
|
auto* alias = ty.alias("alias", &array);
|
||||||
EXPECT_EQ(16u, alias->BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, alias->BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -211,9 +210,9 @@ TEST_F(AliasTest, BaseAlignmentRuntimeArray) {
|
||||||
|
|
||||||
TEST_F(AliasTest, BaseAlignmentStruct) {
|
TEST_F(AliasTest, BaseAlignmentStruct) {
|
||||||
auto* str = create<ast::Struct>(
|
auto* str = create<ast::Struct>(
|
||||||
StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||||
Member("bar", ty.u32, {MemberOffset(4)})},
|
Member("bar", ty.u32, {MemberOffset(4)})},
|
||||||
StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
auto* struct_type = ty.struct_("struct_type", str);
|
auto* struct_type = ty.struct_("struct_type", str);
|
||||||
auto* alias = ty.alias("alias", struct_type);
|
auto* alias = ty.alias("alias", struct_type);
|
||||||
|
|
||||||
|
@ -223,5 +222,4 @@ TEST_F(AliasTest, BaseAlignmentStruct) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/type/array_type.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -20,15 +20,14 @@
|
||||||
#include "src/ast/clone_context.h"
|
#include "src/ast/clone_context.h"
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
#include "src/ast/stride_decoration.h"
|
#include "src/ast/stride_decoration.h"
|
||||||
#include "src/ast/type/vector_type.h"
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Array);
|
TINT_INSTANTIATE_CLASS_ID(tint::type::Array);
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
Array::Array(Type* subtype, uint32_t size, ArrayDecorationList decorations)
|
Array::Array(Type* subtype, uint32_t size, ast::ArrayDecorationList decorations)
|
||||||
: subtype_(subtype), size_(size), decos_(decorations) {}
|
: subtype_(subtype), size_(size), decos_(decorations) {}
|
||||||
|
|
||||||
Array::Array(Array&&) = default;
|
Array::Array(Array&&) = default;
|
||||||
|
@ -68,7 +67,7 @@ uint64_t Array::BaseAlignment(MemoryLayout mem_layout) const {
|
||||||
|
|
||||||
uint32_t Array::array_stride() const {
|
uint32_t Array::array_stride() const {
|
||||||
for (auto* deco : decos_) {
|
for (auto* deco : decos_) {
|
||||||
if (auto* stride = deco->As<StrideDecoration>()) {
|
if (auto* stride = deco->As<ast::StrideDecoration>()) {
|
||||||
return stride->stride();
|
return stride->stride();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +76,7 @@ uint32_t Array::array_stride() const {
|
||||||
|
|
||||||
bool Array::has_array_stride() const {
|
bool Array::has_array_stride() const {
|
||||||
for (auto* deco : decos_) {
|
for (auto* deco : decos_) {
|
||||||
if (deco->Is<StrideDecoration>()) {
|
if (deco->Is<ast::StrideDecoration>()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,5 +101,4 @@ Array* Array::Clone(CloneContext* ctx) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -12,8 +12,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_AST_TYPE_ARRAY_TYPE_H_
|
#ifndef SRC_TYPE_ARRAY_TYPE_H_
|
||||||
#define SRC_AST_TYPE_ARRAY_TYPE_H_
|
#define SRC_TYPE_ARRAY_TYPE_H_
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
@ -21,10 +21,9 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "src/ast/array_decoration.h"
|
#include "src/ast/array_decoration.h"
|
||||||
#include "src/ast/type/type.h"
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
/// An array type. If size is zero then it is a runtime array.
|
/// An array type. If size is zero then it is a runtime array.
|
||||||
|
@ -35,7 +34,7 @@ class Array : public Castable<Array, Type> {
|
||||||
/// @param size the number of elements in the array. `0` represents a
|
/// @param size the number of elements in the array. `0` represents a
|
||||||
/// runtime-sized array.
|
/// runtime-sized array.
|
||||||
/// @param decorations the array decorations
|
/// @param decorations the array decorations
|
||||||
Array(Type* subtype, uint32_t size, ArrayDecorationList decorations);
|
Array(Type* subtype, uint32_t size, ast::ArrayDecorationList decorations);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
Array(Array&&);
|
Array(Array&&);
|
||||||
~Array() override;
|
~Array() override;
|
||||||
|
@ -55,7 +54,7 @@ class Array : public Castable<Array, Type> {
|
||||||
uint64_t BaseAlignment(MemoryLayout mem_layout) const override;
|
uint64_t BaseAlignment(MemoryLayout mem_layout) const override;
|
||||||
|
|
||||||
/// @returns the array decorations
|
/// @returns the array decorations
|
||||||
const ArrayDecorationList& decorations() const { return decos_; }
|
const ast::ArrayDecorationList& decorations() const { return decos_; }
|
||||||
|
|
||||||
/// @returns the array stride or 0 if none set.
|
/// @returns the array stride or 0 if none set.
|
||||||
uint32_t array_stride() const;
|
uint32_t array_stride() const;
|
||||||
|
@ -78,11 +77,10 @@ class Array : public Castable<Array, Type> {
|
||||||
private:
|
private:
|
||||||
Type* const subtype_;
|
Type* const subtype_;
|
||||||
uint32_t const size_;
|
uint32_t const size_;
|
||||||
ArrayDecorationList const decos_;
|
ast::ArrayDecorationList const decos_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
||||||
#endif // SRC_AST_TYPE_ARRAY_TYPE_H_
|
#endif // SRC_TYPE_ARRAY_TYPE_H_
|
|
@ -12,26 +12,25 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/type/array_type.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "src/ast/stride_decoration.h"
|
#include "src/ast/stride_decoration.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/type/access_control_type.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/type/bool_type.h"
|
||||||
#include "src/ast/type/bool_type.h"
|
#include "src/type/f32_type.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/type/i32_type.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/matrix_type.h"
|
||||||
#include "src/ast/type/matrix_type.h"
|
#include "src/type/pointer_type.h"
|
||||||
#include "src/ast/type/pointer_type.h"
|
#include "src/type/struct_type.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/type/test_helper.h"
|
||||||
#include "src/ast/type/texture_type.h"
|
#include "src/type/texture_type.h"
|
||||||
#include "src/ast/type/u32_type.h"
|
#include "src/type/u32_type.h"
|
||||||
#include "src/ast/type/vector_type.h"
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@ using ArrayTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(ArrayTest, CreateSizedArray) {
|
TEST_F(ArrayTest, CreateSizedArray) {
|
||||||
U32 u32;
|
U32 u32;
|
||||||
Array arr{&u32, 3, ArrayDecorationList{}};
|
Array arr{&u32, 3, ast::ArrayDecorationList{}};
|
||||||
EXPECT_EQ(arr.type(), &u32);
|
EXPECT_EQ(arr.type(), &u32);
|
||||||
EXPECT_EQ(arr.size(), 3u);
|
EXPECT_EQ(arr.size(), 3u);
|
||||||
EXPECT_TRUE(arr.Is<Array>());
|
EXPECT_TRUE(arr.Is<Array>());
|
||||||
|
@ -48,7 +47,7 @@ TEST_F(ArrayTest, CreateSizedArray) {
|
||||||
|
|
||||||
TEST_F(ArrayTest, CreateRuntimeArray) {
|
TEST_F(ArrayTest, CreateRuntimeArray) {
|
||||||
U32 u32;
|
U32 u32;
|
||||||
Array arr{&u32, 0, ArrayDecorationList{}};
|
Array arr{&u32, 0, ast::ArrayDecorationList{}};
|
||||||
EXPECT_EQ(arr.type(), &u32);
|
EXPECT_EQ(arr.type(), &u32);
|
||||||
EXPECT_EQ(arr.size(), 0u);
|
EXPECT_EQ(arr.size(), 0u);
|
||||||
EXPECT_TRUE(arr.Is<Array>());
|
EXPECT_TRUE(arr.Is<Array>());
|
||||||
|
@ -58,7 +57,7 @@ TEST_F(ArrayTest, CreateRuntimeArray) {
|
||||||
TEST_F(ArrayTest, Is) {
|
TEST_F(ArrayTest, Is) {
|
||||||
I32 i32;
|
I32 i32;
|
||||||
|
|
||||||
Array arr{&i32, 3, ArrayDecorationList{}};
|
Array arr{&i32, 3, ast::ArrayDecorationList{}};
|
||||||
Type* ty = &arr;
|
Type* ty = &arr;
|
||||||
EXPECT_FALSE(ty->Is<AccessControl>());
|
EXPECT_FALSE(ty->Is<AccessControl>());
|
||||||
EXPECT_FALSE(ty->Is<Alias>());
|
EXPECT_FALSE(ty->Is<Alias>());
|
||||||
|
@ -77,55 +76,59 @@ TEST_F(ArrayTest, Is) {
|
||||||
|
|
||||||
TEST_F(ArrayTest, TypeName) {
|
TEST_F(ArrayTest, TypeName) {
|
||||||
I32 i32;
|
I32 i32;
|
||||||
Array arr{&i32, 0, ArrayDecorationList{}};
|
Array arr{&i32, 0, ast::ArrayDecorationList{}};
|
||||||
EXPECT_EQ(arr.type_name(), "__array__i32");
|
EXPECT_EQ(arr.type_name(), "__array__i32");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, TypeName_RuntimeArray) {
|
TEST_F(ArrayTest, TypeName_RuntimeArray) {
|
||||||
I32 i32;
|
I32 i32;
|
||||||
Array arr{&i32, 3, ArrayDecorationList{}};
|
Array arr{&i32, 3, ast::ArrayDecorationList{}};
|
||||||
EXPECT_EQ(arr.type_name(), "__array__i32_3");
|
EXPECT_EQ(arr.type_name(), "__array__i32_3");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, TypeName_WithStride) {
|
TEST_F(ArrayTest, TypeName_WithStride) {
|
||||||
I32 i32;
|
I32 i32;
|
||||||
Array arr{&i32, 3, ArrayDecorationList{create<StrideDecoration>(16)}};
|
Array arr{&i32, 3,
|
||||||
|
ast::ArrayDecorationList{create<ast::StrideDecoration>(16)}};
|
||||||
EXPECT_EQ(arr.type_name(), "__array__i32_3_stride_16");
|
EXPECT_EQ(arr.type_name(), "__array__i32_3_stride_16");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, MinBufferBindingSizeNoStride) {
|
TEST_F(ArrayTest, MinBufferBindingSizeNoStride) {
|
||||||
U32 u32;
|
U32 u32;
|
||||||
Array arr(&u32, 4, ArrayDecorationList{});
|
Array arr(&u32, 4, ast::ArrayDecorationList{});
|
||||||
EXPECT_EQ(0u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(0u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, MinBufferBindingSizeArray) {
|
TEST_F(ArrayTest, MinBufferBindingSizeArray) {
|
||||||
U32 u32;
|
U32 u32;
|
||||||
Array arr(&u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
|
Array arr(&u32, 4,
|
||||||
|
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||||
EXPECT_EQ(16u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, MinBufferBindingSizeRuntimeArray) {
|
TEST_F(ArrayTest, MinBufferBindingSizeRuntimeArray) {
|
||||||
U32 u32;
|
U32 u32;
|
||||||
Array arr(&u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
|
Array arr(&u32, 0,
|
||||||
|
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||||
EXPECT_EQ(4u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(4u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, BaseAlignmentArray) {
|
TEST_F(ArrayTest, BaseAlignmentArray) {
|
||||||
U32 u32;
|
U32 u32;
|
||||||
Array arr(&u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
|
Array arr(&u32, 4,
|
||||||
|
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||||
EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, BaseAlignmentRuntimeArray) {
|
TEST_F(ArrayTest, BaseAlignmentRuntimeArray) {
|
||||||
U32 u32;
|
U32 u32;
|
||||||
Array arr(&u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
|
Array arr(&u32, 0,
|
||||||
|
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||||
EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -12,15 +12,14 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/bool_type.h"
|
#include "src/type/bool_type.h"
|
||||||
|
|
||||||
#include "src/ast/clone_context.h"
|
#include "src/ast/clone_context.h"
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Bool);
|
TINT_INSTANTIATE_CLASS_ID(tint::type::Bool);
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
Bool::Bool() = default;
|
Bool::Bool() = default;
|
||||||
|
@ -38,5 +37,4 @@ Bool* Bool::Clone(CloneContext* ctx) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -12,15 +12,14 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_AST_TYPE_BOOL_TYPE_H_
|
#ifndef SRC_TYPE_BOOL_TYPE_H_
|
||||||
#define SRC_AST_TYPE_BOOL_TYPE_H_
|
#define SRC_TYPE_BOOL_TYPE_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/ast/type/type.h"
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
/// A boolean type
|
/// A boolean type
|
||||||
|
@ -42,7 +41,6 @@ class Bool : public Castable<Bool, Type> {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
||||||
#endif // SRC_AST_TYPE_BOOL_TYPE_H_
|
#endif // SRC_TYPE_BOOL_TYPE_H_
|
|
@ -12,22 +12,21 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/bool_type.h"
|
#include "src/type/bool_type.h"
|
||||||
|
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/type/access_control_type.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/type/array_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/type/f32_type.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/type/i32_type.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/matrix_type.h"
|
||||||
#include "src/ast/type/matrix_type.h"
|
#include "src/type/pointer_type.h"
|
||||||
#include "src/ast/type/pointer_type.h"
|
#include "src/type/struct_type.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/type/test_helper.h"
|
||||||
#include "src/ast/type/texture_type.h"
|
#include "src/type/texture_type.h"
|
||||||
#include "src/ast/type/u32_type.h"
|
#include "src/type/u32_type.h"
|
||||||
#include "src/ast/type/vector_type.h"
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -63,5 +62,4 @@ TEST_F(BoolTest, MinBufferBindingSize) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/depth_texture_type.h"
|
#include "src/type/depth_texture_type.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -20,10 +20,9 @@
|
||||||
#include "src/ast/clone_context.h"
|
#include "src/ast/clone_context.h"
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::type::DepthTexture);
|
TINT_INSTANTIATE_CLASS_ID(tint::type::DepthTexture);
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -57,5 +56,4 @@ DepthTexture* DepthTexture::Clone(CloneContext* ctx) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -12,15 +12,14 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_AST_TYPE_DEPTH_TEXTURE_TYPE_H_
|
#ifndef SRC_TYPE_DEPTH_TEXTURE_TYPE_H_
|
||||||
#define SRC_AST_TYPE_DEPTH_TEXTURE_TYPE_H_
|
#define SRC_TYPE_DEPTH_TEXTURE_TYPE_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/ast/type/texture_type.h"
|
#include "src/type/texture_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
/// A depth texture type.
|
/// A depth texture type.
|
||||||
|
@ -43,7 +42,6 @@ class DepthTexture : public Castable<DepthTexture, Texture> {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
||||||
#endif // SRC_AST_TYPE_DEPTH_TEXTURE_TYPE_H_
|
#endif // SRC_TYPE_DEPTH_TEXTURE_TYPE_H_
|
|
@ -12,25 +12,24 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/depth_texture_type.h"
|
#include "src/type/depth_texture_type.h"
|
||||||
|
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/type/test_helper.h"
|
||||||
|
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/type/array_type.h"
|
||||||
#include "src/ast/type/bool_type.h"
|
#include "src/type/bool_type.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/type/f32_type.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/i32_type.h"
|
||||||
#include "src/ast/type/matrix_type.h"
|
#include "src/type/matrix_type.h"
|
||||||
#include "src/ast/type/pointer_type.h"
|
#include "src/type/pointer_type.h"
|
||||||
#include "src/ast/type/sampled_texture_type.h"
|
#include "src/type/sampled_texture_type.h"
|
||||||
#include "src/ast/type/storage_texture_type.h"
|
#include "src/type/storage_texture_type.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/type/struct_type.h"
|
||||||
#include "src/ast/type/u32_type.h"
|
#include "src/type/u32_type.h"
|
||||||
#include "src/ast/type/vector_type.h"
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -79,5 +78,4 @@ TEST_F(DepthTextureTest, MinBufferBindingSize) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -12,15 +12,14 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/type/f32_type.h"
|
||||||
|
|
||||||
#include "src/ast/clone_context.h"
|
#include "src/ast/clone_context.h"
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::type::F32);
|
TINT_INSTANTIATE_CLASS_ID(tint::type::F32);
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
F32::F32() = default;
|
F32::F32() = default;
|
||||||
|
@ -46,5 +45,4 @@ F32* F32::Clone(CloneContext* ctx) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -12,15 +12,14 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_AST_TYPE_F32_TYPE_H_
|
#ifndef SRC_TYPE_F32_TYPE_H_
|
||||||
#define SRC_AST_TYPE_F32_TYPE_H_
|
#define SRC_TYPE_F32_TYPE_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/ast/type/type.h"
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
/// A float 32 type
|
/// A float 32 type
|
||||||
|
@ -52,7 +51,6 @@ class F32 : public Castable<F32, Type> {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
||||||
#endif // SRC_AST_TYPE_F32_TYPE_H_
|
#endif // SRC_TYPE_F32_TYPE_H_
|
|
@ -12,22 +12,21 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/type/f32_type.h"
|
||||||
|
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/type/access_control_type.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/type/array_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/type/bool_type.h"
|
||||||
#include "src/ast/type/bool_type.h"
|
#include "src/type/i32_type.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/matrix_type.h"
|
||||||
#include "src/ast/type/matrix_type.h"
|
#include "src/type/pointer_type.h"
|
||||||
#include "src/ast/type/pointer_type.h"
|
#include "src/type/struct_type.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/type/test_helper.h"
|
||||||
#include "src/ast/type/texture_type.h"
|
#include "src/type/texture_type.h"
|
||||||
#include "src/ast/type/u32_type.h"
|
#include "src/type/u32_type.h"
|
||||||
#include "src/ast/type/vector_type.h"
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -68,5 +67,4 @@ TEST_F(F32Test, BaseAlignment) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -12,15 +12,14 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/i32_type.h"
|
||||||
|
|
||||||
#include "src/ast/clone_context.h"
|
#include "src/ast/clone_context.h"
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::type::I32);
|
TINT_INSTANTIATE_CLASS_ID(tint::type::I32);
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
I32::I32() = default;
|
I32::I32() = default;
|
||||||
|
@ -46,5 +45,4 @@ I32* I32::Clone(CloneContext* ctx) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -12,15 +12,14 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_AST_TYPE_I32_TYPE_H_
|
#ifndef SRC_TYPE_I32_TYPE_H_
|
||||||
#define SRC_AST_TYPE_I32_TYPE_H_
|
#define SRC_TYPE_I32_TYPE_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/ast/type/type.h"
|
#include "src/type/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
/// A signed int 32 type.
|
/// A signed int 32 type.
|
||||||
|
@ -52,7 +51,6 @@ class I32 : public Castable<I32, Type> {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
||||||
#endif // SRC_AST_TYPE_I32_TYPE_H_
|
#endif // SRC_TYPE_I32_TYPE_H_
|
|
@ -12,22 +12,21 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/type/i32_type.h"
|
||||||
|
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/type/access_control_type.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/type/array_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/type/bool_type.h"
|
||||||
#include "src/ast/type/bool_type.h"
|
#include "src/type/f32_type.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/type/matrix_type.h"
|
||||||
#include "src/ast/type/matrix_type.h"
|
#include "src/type/pointer_type.h"
|
||||||
#include "src/ast/type/pointer_type.h"
|
#include "src/type/struct_type.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/type/test_helper.h"
|
||||||
#include "src/ast/type/texture_type.h"
|
#include "src/type/texture_type.h"
|
||||||
#include "src/ast/type/u32_type.h"
|
#include "src/type/u32_type.h"
|
||||||
#include "src/ast/type/vector_type.h"
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace type {
|
namespace type {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -68,5 +67,4 @@ TEST_F(I32Test, BaseAlignment) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace type
|
} // namespace type
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue