Remove typ::TypePair.
You've helped us bridge two worlds. Good Night, Sweet Prince. Fixed: tint:724 Change-Id: I0b4ba960e9cf5dcff7df9d2f332ea36d6663c440 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51667 Reviewed-by: Antonio Maiorano <amaiorano@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com> Auto-Submit: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
19b0319963
commit
19d3205e15
|
@ -527,7 +527,6 @@ libtint_source_set("libtint_core_all_src") {
|
|||
"transform/var_for_dynamic_index.h",
|
||||
"transform/vertex_pulling.cc",
|
||||
"transform/vertex_pulling.h",
|
||||
"typepair.h",
|
||||
"utils/get_or_create.h",
|
||||
"utils/hash.h",
|
||||
"utils/math.h",
|
||||
|
|
|
@ -262,7 +262,6 @@ set(TINT_LIB_SRCS
|
|||
symbol.cc
|
||||
symbol.h
|
||||
traits.h
|
||||
typepair.h
|
||||
transform/binding_remapper.cc
|
||||
transform/binding_remapper.h
|
||||
transform/bound_array_accessors.cc
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
// Forward declaration
|
||||
class Type;
|
||||
|
||||
/// A bitcast expression
|
||||
class BitcastExpression : public Castable<BitcastExpression, Expression> {
|
||||
public:
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "src/ast/location_decoration.h"
|
||||
#include "src/ast/pipeline_stage.h"
|
||||
#include "src/ast/variable.h"
|
||||
#include "src/typepair.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
|
|
@ -171,7 +171,7 @@ ast::Variable* TextureOverloadCase::buildTextureVariable(
|
|||
ast::StorageClass::kNone, nullptr, decos);
|
||||
|
||||
case ast::intrinsic::test::TextureKind::kStorage: {
|
||||
auto st = b->ty.storage_texture(texture_dimension, image_format);
|
||||
auto* st = b->ty.storage_texture(texture_dimension, image_format);
|
||||
auto* ac = b->ty.access(access_control, st);
|
||||
return b->Global("texture", ac, ast::StorageClass::kNone, nullptr, decos);
|
||||
}
|
||||
|
|
|
@ -19,11 +19,13 @@
|
|||
#include <vector>
|
||||
|
||||
#include "src/ast/decoration.h"
|
||||
#include "src/typepair.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
// Forward declaration
|
||||
class Type;
|
||||
|
||||
/// A struct member statement.
|
||||
class StructMember : public Castable<StructMember, Node> {
|
||||
public:
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
// Forward declaration
|
||||
class Type;
|
||||
|
||||
/// A type specific constructor
|
||||
class TypeConstructorExpression
|
||||
: public Castable<TypeConstructorExpression, ConstructorExpression> {
|
||||
|
|
|
@ -25,9 +25,11 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
// Forward declarations
|
||||
class BindingDecoration;
|
||||
class GroupDecoration;
|
||||
class LocationDecoration;
|
||||
class Type;
|
||||
|
||||
/// A Variable statement.
|
||||
///
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "src/debug.h"
|
||||
#include "src/symbol.h"
|
||||
#include "src/traits.h"
|
||||
#include "src/typepair.h"
|
||||
|
||||
namespace tint {
|
||||
|
||||
|
@ -178,14 +177,6 @@ class CloneContext {
|
|||
return CheckedCast<T>(c);
|
||||
}
|
||||
|
||||
/// Clones the AST node of the type pair
|
||||
/// @param tp the type pair to clone
|
||||
/// @return the cloned AST node wrapped in a type pair
|
||||
template <typename AST, typename SEM>
|
||||
typ::TypePair<AST, SEM> Clone(const typ::TypePair<AST, SEM>& tp) {
|
||||
return Clone(const_cast<ast::Type*>(tp.ast));
|
||||
}
|
||||
|
||||
/// Clones the Source `s` into #dst
|
||||
/// TODO(bclayton) - Currently this 'clone' is a shallow copy. If/when
|
||||
/// `Source.File`s are owned by the Program this should make a copy of the
|
||||
|
|
|
@ -359,15 +359,15 @@ class InspectorHelper : public ProgramBuilder {
|
|||
/// @param dim the dimensions of the texture
|
||||
/// @param type the data type of the sampled texture
|
||||
/// @returns the generated SampleTextureType
|
||||
typ::SampledTexture MakeSampledTextureType(ast::TextureDimension dim,
|
||||
ast::Type* type) {
|
||||
ast::SampledTexture* MakeSampledTextureType(ast::TextureDimension dim,
|
||||
ast::Type* type) {
|
||||
return ty.sampled_texture(dim, type);
|
||||
}
|
||||
|
||||
/// Generates a DepthTexture appropriate for the params
|
||||
/// @param dim the dimensions of the texture
|
||||
/// @returns the generated DepthTexture
|
||||
typ::DepthTexture MakeDepthTextureType(ast::TextureDimension dim) {
|
||||
ast::DepthTexture* MakeDepthTextureType(ast::TextureDimension dim) {
|
||||
return ty.depth_texture(dim);
|
||||
}
|
||||
|
||||
|
@ -375,7 +375,7 @@ class InspectorHelper : public ProgramBuilder {
|
|||
/// @param dim the dimensions of the texture
|
||||
/// @param type the data type of the sampled texture
|
||||
/// @returns the generated SampleTextureType
|
||||
typ::MultisampledTexture MakeMultisampledTextureType(
|
||||
ast::MultisampledTexture* MakeMultisampledTextureType(
|
||||
ast::TextureDimension dim,
|
||||
ast::Type* type) {
|
||||
return ty.multisampled_texture(dim, type);
|
||||
|
@ -383,7 +383,7 @@ class InspectorHelper : public ProgramBuilder {
|
|||
|
||||
/// Generates an ExternalTexture appropriate for the params
|
||||
/// @returns the generated ExternalTexture
|
||||
typ::ExternalTexture MakeExternalTextureType() {
|
||||
ast::ExternalTexture* MakeExternalTextureType() {
|
||||
return ty.external_texture();
|
||||
}
|
||||
|
||||
|
@ -577,7 +577,7 @@ class InspectorHelper : public ProgramBuilder {
|
|||
bool read_only) {
|
||||
auto ac = read_only ? ast::AccessControl::kReadOnly
|
||||
: ast::AccessControl::kWriteOnly;
|
||||
auto tex = ty.storage_texture(dim, format);
|
||||
auto* tex = ty.storage_texture(dim, format);
|
||||
|
||||
return ty.access(ac, tex);
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ class InspectorHelper : public ProgramBuilder {
|
|||
/// @param group the binding/group to use for the sampled texture
|
||||
/// @param binding the binding number to use for the sampled texture
|
||||
void AddStorageTexture(const std::string& name,
|
||||
typ::Type type,
|
||||
ast::Type* type,
|
||||
uint32_t group,
|
||||
uint32_t binding) {
|
||||
AddBinding(name, type, ast::StorageClass::kNone, group, binding);
|
||||
|
@ -603,7 +603,7 @@ class InspectorHelper : public ProgramBuilder {
|
|||
ast::Function* MakeStorageTextureBodyFunction(
|
||||
const std::string& func_name,
|
||||
const std::string& st_name,
|
||||
typ::Type dim_type,
|
||||
ast::Type* dim_type,
|
||||
ast::DecorationList decorations) {
|
||||
ast::StatementList stmts;
|
||||
|
||||
|
@ -863,16 +863,16 @@ TEST_F(InspectorGetEntryPointTest, NoInOutVariables) {
|
|||
|
||||
TEST_P(InspectorGetEntryPointTestWithComponentTypeParam, InOutVariables) {
|
||||
ComponentType inspector_type = GetParam();
|
||||
std::function<typ::Type()> tint_type;
|
||||
std::function<ast::Type*()> tint_type;
|
||||
switch (inspector_type) {
|
||||
case ComponentType::kFloat:
|
||||
tint_type = [this]() -> typ::Type { return ty.f32(); };
|
||||
tint_type = [this]() -> ast::Type* { return ty.f32(); };
|
||||
break;
|
||||
case ComponentType::kSInt:
|
||||
tint_type = [this]() -> typ::Type { return ty.i32(); };
|
||||
tint_type = [this]() -> ast::Type* { return ty.i32(); };
|
||||
break;
|
||||
case ComponentType::kUInt:
|
||||
tint_type = [this]() -> typ::Type { return ty.u32(); };
|
||||
tint_type = [this]() -> ast::Type* { return ty.u32(); };
|
||||
break;
|
||||
case ComponentType::kUnknown:
|
||||
return;
|
||||
|
@ -1672,7 +1672,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
|||
MakeStructVariableReferenceBodyFunction("rosb_func", "rosb_var",
|
||||
{{0, ty.i32()}});
|
||||
|
||||
auto s_texture_type =
|
||||
auto* s_texture_type =
|
||||
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("s_texture", s_texture_type, 2, 0);
|
||||
AddSampler("s_var", 3, 0);
|
||||
|
@ -1680,7 +1680,8 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
|||
MakeSamplerReferenceBodyFunction("s_func", "s_texture", "s_var", "s_coords",
|
||||
ty.f32(), {});
|
||||
|
||||
auto cs_depth_texture_type = MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
auto* cs_depth_texture_type =
|
||||
MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
AddDepthTexture("cs_texture", cs_depth_texture_type, 3, 1);
|
||||
AddComparisonSampler("cs_var", 3, 2);
|
||||
AddGlobalVariable("cs_coords", ty.vec2<f32>());
|
||||
|
@ -2327,7 +2328,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) {
|
||||
auto sampled_texture_type =
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
|
@ -2364,7 +2365,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, NoSampler) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
||||
auto sampled_texture_type =
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
|
@ -2390,7 +2391,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||
auto sampled_texture_type =
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
|
@ -2409,7 +2410,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
|
||||
auto depth_texture_type = MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
auto* depth_texture_type = MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||
|
@ -2430,7 +2431,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) {
|
||||
auto depth_texture_type = MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
auto* depth_texture_type = MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||
|
@ -2468,7 +2469,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, NoSampler) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
|
||||
auto depth_texture_type = MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
auto* depth_texture_type = MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||
|
@ -2496,7 +2497,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||
auto depth_texture_type = MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
auto* depth_texture_type = MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||
|
@ -2515,7 +2516,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) {
|
||||
auto sampled_texture_type =
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
|
@ -2549,7 +2550,7 @@ TEST_F(InspectorGetSampledTextureResourceBindingsTest, Empty) {
|
|||
}
|
||||
|
||||
TEST_P(InspectorGetSampledTextureResourceBindingsTestWithParam, textureSample) {
|
||||
auto sampled_texture_type = MakeSampledTextureType(
|
||||
auto* sampled_texture_type = MakeSampledTextureType(
|
||||
GetParam().type_dim, GetBaseType(GetParam().sampled_kind));
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
|
@ -2607,7 +2608,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
|
||||
TEST_P(InspectorGetSampledArrayTextureResourceBindingsTestWithParam,
|
||||
textureSample) {
|
||||
auto sampled_texture_type = MakeSampledTextureType(
|
||||
auto* sampled_texture_type = MakeSampledTextureType(
|
||||
GetParam().type_dim, GetBaseType(GetParam().sampled_kind));
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
|
@ -2651,7 +2652,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
|
||||
TEST_P(InspectorGetMultisampledTextureResourceBindingsTestWithParam,
|
||||
textureLoad) {
|
||||
auto multisampled_texture_type = MakeMultisampledTextureType(
|
||||
auto* multisampled_texture_type = MakeMultisampledTextureType(
|
||||
GetParam().type_dim, GetBaseType(GetParam().sampled_kind));
|
||||
AddMultisampledTexture("foo_texture", multisampled_texture_type, 0, 0);
|
||||
auto* coord_type = GetCoordsType(GetParam().type_dim, ty.i32());
|
||||
|
@ -2720,7 +2721,7 @@ TEST_F(InspectorGetMultisampledArrayTextureResourceBindingsTest, Empty) {
|
|||
|
||||
TEST_P(InspectorGetMultisampledArrayTextureResourceBindingsTestWithParam,
|
||||
DISABLED_textureSample) {
|
||||
auto multisampled_texture_type = MakeMultisampledTextureType(
|
||||
auto* multisampled_texture_type = MakeMultisampledTextureType(
|
||||
GetParam().type_dim, GetBaseType(GetParam().sampled_kind));
|
||||
AddMultisampledTexture("foo_texture", multisampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
|
@ -2912,7 +2913,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
|
||||
TEST_P(InspectorGetDepthTextureResourceBindingsTestWithParam,
|
||||
textureDimensions) {
|
||||
auto depth_texture_type = MakeDepthTextureType(GetParam().type_dim);
|
||||
auto* depth_texture_type = MakeDepthTextureType(GetParam().type_dim);
|
||||
AddDepthTexture("dt", depth_texture_type, 0, 0);
|
||||
AddGlobalVariable("dt_level", ty.i32());
|
||||
|
||||
|
@ -2956,7 +2957,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
inspector::ResourceBinding::TextureDimension::kCubeArray}));
|
||||
|
||||
TEST_F(InspectorGetExternalTextureResourceBindingsTest, Simple) {
|
||||
auto external_texture_type = MakeExternalTextureType();
|
||||
auto* external_texture_type = MakeExternalTextureType();
|
||||
AddExternalTexture("et", external_texture_type, 0, 0);
|
||||
|
||||
Func("ep", ast::VariableList(), ty.void_(),
|
||||
|
|
|
@ -77,7 +77,6 @@
|
|||
#include "src/sem/u32_type.h"
|
||||
#include "src/sem/vector_type.h"
|
||||
#include "src/sem/void_type.h"
|
||||
#include "src/typepair.h"
|
||||
|
||||
namespace tint {
|
||||
|
||||
|
@ -350,59 +349,59 @@ class ProgramBuilder {
|
|||
|
||||
/// @return the tint AST type for the C type `T`.
|
||||
template <typename T>
|
||||
typ::Type Of() const {
|
||||
ast::Type* Of() const {
|
||||
return CToAST<T>::get(this);
|
||||
}
|
||||
|
||||
/// @returns a boolean type
|
||||
typ::Bool bool_() const { return builder->create<ast::Bool>(); }
|
||||
ast::Bool* bool_() const { return builder->create<ast::Bool>(); }
|
||||
|
||||
/// @param source the Source of the node
|
||||
/// @returns a boolean type
|
||||
typ::Bool bool_(const Source& source) const {
|
||||
ast::Bool* bool_(const Source& source) const {
|
||||
return builder->create<ast::Bool>(source);
|
||||
}
|
||||
|
||||
/// @returns a f32 type
|
||||
typ::F32 f32() const { return builder->create<ast::F32>(); }
|
||||
ast::F32* f32() const { return builder->create<ast::F32>(); }
|
||||
|
||||
/// @param source the Source of the node
|
||||
/// @returns a f32 type
|
||||
typ::F32 f32(const Source& source) const {
|
||||
ast::F32* f32(const Source& source) const {
|
||||
return builder->create<ast::F32>(source);
|
||||
}
|
||||
|
||||
/// @returns a i32 type
|
||||
typ::I32 i32() const { return builder->create<ast::I32>(); }
|
||||
ast::I32* i32() const { return builder->create<ast::I32>(); }
|
||||
|
||||
/// @param source the Source of the node
|
||||
/// @returns a i32 type
|
||||
typ::I32 i32(const Source& source) const {
|
||||
ast::I32* i32(const Source& source) const {
|
||||
return builder->create<ast::I32>(source);
|
||||
}
|
||||
|
||||
/// @returns a u32 type
|
||||
typ::U32 u32() const { return builder->create<ast::U32>(); }
|
||||
ast::U32* u32() const { return builder->create<ast::U32>(); }
|
||||
|
||||
/// @param source the Source of the node
|
||||
/// @returns a u32 type
|
||||
typ::U32 u32(const Source& source) const {
|
||||
ast::U32* u32(const Source& source) const {
|
||||
return builder->create<ast::U32>(source);
|
||||
}
|
||||
|
||||
/// @returns a void type
|
||||
typ::Void void_() const { return builder->create<ast::Void>(); }
|
||||
ast::Void* void_() const { return builder->create<ast::Void>(); }
|
||||
|
||||
/// @param source the Source of the node
|
||||
/// @returns a void type
|
||||
typ::Void void_(const Source& source) const {
|
||||
ast::Void* void_(const Source& source) const {
|
||||
return builder->create<ast::Void>(source);
|
||||
}
|
||||
|
||||
/// @param type vector subtype
|
||||
/// @param n vector width in elements
|
||||
/// @return the tint AST type for a `n`-element vector of `type`.
|
||||
typ::Vector vec(ast::Type* type, uint32_t n) const {
|
||||
ast::Vector* vec(ast::Type* type, uint32_t n) const {
|
||||
type = MaybeCreateTypename(type);
|
||||
return builder->create<ast::Vector>(type, n);
|
||||
}
|
||||
|
@ -411,45 +410,45 @@ class ProgramBuilder {
|
|||
/// @param type vector subtype
|
||||
/// @param n vector width in elements
|
||||
/// @return the tint AST type for a `n`-element vector of `type`.
|
||||
typ::Vector vec(const Source& source, ast::Type* type, uint32_t n) const {
|
||||
ast::Vector* vec(const Source& source, ast::Type* type, uint32_t n) const {
|
||||
type = MaybeCreateTypename(type);
|
||||
return builder->create<ast::Vector>(source, type, n);
|
||||
}
|
||||
|
||||
/// @param type vector subtype
|
||||
/// @return the tint AST type for a 2-element vector of `type`.
|
||||
typ::Vector vec2(ast::Type* type) const { return vec(type, 2u); }
|
||||
ast::Vector* vec2(ast::Type* type) const { return vec(type, 2u); }
|
||||
|
||||
/// @param type vector subtype
|
||||
/// @return the tint AST type for a 3-element vector of `type`.
|
||||
typ::Vector vec3(ast::Type* type) const { return vec(type, 3u); }
|
||||
ast::Vector* vec3(ast::Type* type) const { return vec(type, 3u); }
|
||||
|
||||
/// @param type vector subtype
|
||||
/// @return the tint AST type for a 4-element vector of `type`.
|
||||
typ::Vector vec4(ast::Type* type) const { return vec(type, 4u); }
|
||||
ast::Vector* vec4(ast::Type* type) const { return vec(type, 4u); }
|
||||
|
||||
/// @param n vector width in elements
|
||||
/// @return the tint AST type for a `n`-element vector of `type`.
|
||||
template <typename T>
|
||||
typ::Vector vec(uint32_t n) const {
|
||||
ast::Vector* vec(uint32_t n) const {
|
||||
return vec(Of<T>(), n);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 2-element vector of the C type `T`.
|
||||
template <typename T>
|
||||
typ::Vector vec2() const {
|
||||
ast::Vector* vec2() const {
|
||||
return vec2(Of<T>());
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 3-element vector of the C type `T`.
|
||||
template <typename T>
|
||||
typ::Vector vec3() const {
|
||||
ast::Vector* vec3() const {
|
||||
return vec3(Of<T>());
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 4-element vector of the C type `T`.
|
||||
template <typename T>
|
||||
typ::Vector vec4() const {
|
||||
ast::Vector* vec4() const {
|
||||
return vec4(Of<T>());
|
||||
}
|
||||
|
||||
|
@ -457,7 +456,7 @@ class ProgramBuilder {
|
|||
/// @param columns number of columns for the matrix
|
||||
/// @param rows number of rows for the matrix
|
||||
/// @return the tint AST type for a matrix of `type`
|
||||
typ::Matrix mat(ast::Type* type, uint32_t columns, uint32_t rows) const {
|
||||
ast::Matrix* mat(ast::Type* type, uint32_t columns, uint32_t rows) const {
|
||||
type = MaybeCreateTypename(type);
|
||||
return builder->create<ast::Matrix>(type, rows, columns);
|
||||
}
|
||||
|
@ -467,108 +466,108 @@ class ProgramBuilder {
|
|||
/// @param columns number of columns for the matrix
|
||||
/// @param rows number of rows for the matrix
|
||||
/// @return the tint AST type for a matrix of `type`
|
||||
typ::Matrix mat(const Source& source,
|
||||
typ::Type type,
|
||||
uint32_t columns,
|
||||
uint32_t rows) const {
|
||||
ast::Matrix* mat(const Source& source,
|
||||
ast::Type* type,
|
||||
uint32_t columns,
|
||||
uint32_t rows) const {
|
||||
return builder->create<ast::Matrix>(source, type, rows, columns);
|
||||
}
|
||||
|
||||
/// @param type matrix subtype
|
||||
/// @return the tint AST type for a 2x3 matrix of `type`.
|
||||
typ::Matrix mat2x2(ast::Type* type) const { return mat(type, 2u, 2u); }
|
||||
ast::Matrix* mat2x2(ast::Type* type) const { return mat(type, 2u, 2u); }
|
||||
|
||||
/// @param type matrix subtype
|
||||
/// @return the tint AST type for a 2x3 matrix of `type`.
|
||||
typ::Matrix mat2x3(ast::Type* type) const { return mat(type, 2u, 3u); }
|
||||
ast::Matrix* mat2x3(ast::Type* type) const { return mat(type, 2u, 3u); }
|
||||
|
||||
/// @param type matrix subtype
|
||||
/// @return the tint AST type for a 2x4 matrix of `type`.
|
||||
typ::Matrix mat2x4(ast::Type* type) const { return mat(type, 2u, 4u); }
|
||||
ast::Matrix* mat2x4(ast::Type* type) const { return mat(type, 2u, 4u); }
|
||||
|
||||
/// @param type matrix subtype
|
||||
/// @return the tint AST type for a 3x2 matrix of `type`.
|
||||
typ::Matrix mat3x2(ast::Type* type) const { return mat(type, 3u, 2u); }
|
||||
ast::Matrix* mat3x2(ast::Type* type) const { return mat(type, 3u, 2u); }
|
||||
|
||||
/// @param type matrix subtype
|
||||
/// @return the tint AST type for a 3x3 matrix of `type`.
|
||||
typ::Matrix mat3x3(ast::Type* type) const { return mat(type, 3u, 3u); }
|
||||
ast::Matrix* mat3x3(ast::Type* type) const { return mat(type, 3u, 3u); }
|
||||
|
||||
/// @param type matrix subtype
|
||||
/// @return the tint AST type for a 3x4 matrix of `type`.
|
||||
typ::Matrix mat3x4(ast::Type* type) const { return mat(type, 3u, 4u); }
|
||||
ast::Matrix* mat3x4(ast::Type* type) const { return mat(type, 3u, 4u); }
|
||||
|
||||
/// @param type matrix subtype
|
||||
/// @return the tint AST type for a 4x2 matrix of `type`.
|
||||
typ::Matrix mat4x2(ast::Type* type) const { return mat(type, 4u, 2u); }
|
||||
ast::Matrix* mat4x2(ast::Type* type) const { return mat(type, 4u, 2u); }
|
||||
|
||||
/// @param type matrix subtype
|
||||
/// @return the tint AST type for a 4x3 matrix of `type`.
|
||||
typ::Matrix mat4x3(ast::Type* type) const { return mat(type, 4u, 3u); }
|
||||
ast::Matrix* mat4x3(ast::Type* type) const { return mat(type, 4u, 3u); }
|
||||
|
||||
/// @param type matrix subtype
|
||||
/// @return the tint AST type for a 4x4 matrix of `type`.
|
||||
typ::Matrix mat4x4(ast::Type* type) const { return mat(type, 4u, 4u); }
|
||||
ast::Matrix* mat4x4(ast::Type* type) const { return mat(type, 4u, 4u); }
|
||||
|
||||
/// @param columns number of columns for the matrix
|
||||
/// @param rows number of rows for the matrix
|
||||
/// @return the tint AST type for a matrix of `type`
|
||||
template <typename T>
|
||||
typ::Matrix mat(uint32_t columns, uint32_t rows) const {
|
||||
ast::Matrix* mat(uint32_t columns, uint32_t rows) const {
|
||||
return mat(Of<T>(), columns, rows);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
typ::Matrix mat2x2() const {
|
||||
ast::Matrix* mat2x2() const {
|
||||
return mat2x2(Of<T>());
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
typ::Matrix mat2x3() const {
|
||||
ast::Matrix* mat2x3() const {
|
||||
return mat2x3(Of<T>());
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 2x4 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
typ::Matrix mat2x4() const {
|
||||
ast::Matrix* mat2x4() const {
|
||||
return mat2x4(Of<T>());
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 3x2 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
typ::Matrix mat3x2() const {
|
||||
ast::Matrix* mat3x2() const {
|
||||
return mat3x2(Of<T>());
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 3x3 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
typ::Matrix mat3x3() const {
|
||||
ast::Matrix* mat3x3() const {
|
||||
return mat3x3(Of<T>());
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 3x4 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
typ::Matrix mat3x4() const {
|
||||
ast::Matrix* mat3x4() const {
|
||||
return mat3x4(Of<T>());
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 4x2 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
typ::Matrix mat4x2() const {
|
||||
ast::Matrix* mat4x2() const {
|
||||
return mat4x2(Of<T>());
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 4x3 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
typ::Matrix mat4x3() const {
|
||||
ast::Matrix* mat4x3() const {
|
||||
return mat4x3(Of<T>());
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 4x4 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
typ::Matrix mat4x4() const {
|
||||
ast::Matrix* mat4x4() const {
|
||||
return mat4x4(Of<T>());
|
||||
}
|
||||
|
||||
|
@ -663,7 +662,7 @@ class ProgramBuilder {
|
|||
/// @param type the alias type
|
||||
/// @returns the alias pointer
|
||||
template <typename NAME>
|
||||
ast::Alias* alias(NAME&& name, typ::Type type) const {
|
||||
ast::Alias* alias(NAME&& name, ast::Type* type) const {
|
||||
type = MaybeCreateTypename(type);
|
||||
auto sym = builder->Sym(std::forward<NAME>(name));
|
||||
return builder->create<ast::Alias>(sym, type);
|
||||
|
@ -675,7 +674,9 @@ class ProgramBuilder {
|
|||
/// @param type the alias type
|
||||
/// @returns the alias pointer
|
||||
template <typename NAME>
|
||||
ast::Alias* alias(const Source& source, NAME&& name, typ::Type type) const {
|
||||
ast::Alias* alias(const Source& source,
|
||||
NAME&& name,
|
||||
ast::Type* type) const {
|
||||
type = MaybeCreateTypename(type);
|
||||
auto sym = builder->Sym(std::forward<NAME>(name));
|
||||
return builder->create<ast::Alias>(source, sym, type);
|
||||
|
@ -707,8 +708,8 @@ class ProgramBuilder {
|
|||
/// @param type the type of the pointer
|
||||
/// @param storage_class the storage class of the pointer
|
||||
/// @return the pointer to `type` with the given ast::StorageClass
|
||||
typ::Pointer pointer(ast::Type* type,
|
||||
ast::StorageClass storage_class) const {
|
||||
ast::Pointer* pointer(ast::Type* type,
|
||||
ast::StorageClass storage_class) const {
|
||||
type = MaybeCreateTypename(type);
|
||||
return builder->create<ast::Pointer>(type, storage_class);
|
||||
}
|
||||
|
@ -717,9 +718,9 @@ class ProgramBuilder {
|
|||
/// @param type the type of the pointer
|
||||
/// @param storage_class the storage class of the pointer
|
||||
/// @return the pointer to `type` with the given ast::StorageClass
|
||||
typ::Pointer pointer(const Source& source,
|
||||
typ::Type type,
|
||||
ast::StorageClass storage_class) const {
|
||||
ast::Pointer* pointer(const Source& source,
|
||||
ast::Type* type,
|
||||
ast::StorageClass storage_class) const {
|
||||
type = MaybeCreateTypename(type);
|
||||
return builder->create<ast::Pointer>(source, type, storage_class);
|
||||
}
|
||||
|
@ -727,42 +728,42 @@ class ProgramBuilder {
|
|||
/// @param storage_class the storage class of the pointer
|
||||
/// @return the pointer to type `T` with the given ast::StorageClass.
|
||||
template <typename T>
|
||||
typ::Pointer pointer(ast::StorageClass storage_class) const {
|
||||
ast::Pointer* pointer(ast::StorageClass storage_class) const {
|
||||
return pointer(Of<T>(), storage_class);
|
||||
}
|
||||
|
||||
/// @param kind the kind of sampler
|
||||
/// @returns the sampler
|
||||
typ::Sampler sampler(ast::SamplerKind kind) const {
|
||||
ast::Sampler* sampler(ast::SamplerKind kind) const {
|
||||
return builder->create<ast::Sampler>(kind);
|
||||
}
|
||||
|
||||
/// @param source the Source of the node
|
||||
/// @param kind the kind of sampler
|
||||
/// @returns the sampler
|
||||
typ::Sampler sampler(const Source& source, ast::SamplerKind kind) const {
|
||||
ast::Sampler* sampler(const Source& source, ast::SamplerKind kind) const {
|
||||
return builder->create<ast::Sampler>(source, kind);
|
||||
}
|
||||
|
||||
/// @param dims the dimensionality of the texture
|
||||
/// @returns the depth texture
|
||||
typ::DepthTexture depth_texture(ast::TextureDimension dims) const {
|
||||
ast::DepthTexture* depth_texture(ast::TextureDimension dims) const {
|
||||
return builder->create<ast::DepthTexture>(dims);
|
||||
}
|
||||
|
||||
/// @param source the Source of the node
|
||||
/// @param dims the dimensionality of the texture
|
||||
/// @returns the depth texture
|
||||
typ::DepthTexture depth_texture(const Source& source,
|
||||
ast::TextureDimension dims) const {
|
||||
ast::DepthTexture* depth_texture(const Source& source,
|
||||
ast::TextureDimension dims) const {
|
||||
return builder->create<ast::DepthTexture>(source, dims);
|
||||
}
|
||||
|
||||
/// @param dims the dimensionality of the texture
|
||||
/// @param subtype the texture subtype.
|
||||
/// @returns the sampled texture
|
||||
typ::SampledTexture sampled_texture(ast::TextureDimension dims,
|
||||
ast::Type* subtype) const {
|
||||
ast::SampledTexture* sampled_texture(ast::TextureDimension dims,
|
||||
ast::Type* subtype) const {
|
||||
return builder->create<ast::SampledTexture>(dims, subtype);
|
||||
}
|
||||
|
||||
|
@ -770,17 +771,17 @@ class ProgramBuilder {
|
|||
/// @param dims the dimensionality of the texture
|
||||
/// @param subtype the texture subtype.
|
||||
/// @returns the sampled texture
|
||||
typ::SampledTexture sampled_texture(const Source& source,
|
||||
ast::TextureDimension dims,
|
||||
ast::Type* subtype) const {
|
||||
ast::SampledTexture* sampled_texture(const Source& source,
|
||||
ast::TextureDimension dims,
|
||||
ast::Type* subtype) const {
|
||||
return builder->create<ast::SampledTexture>(source, dims, subtype);
|
||||
}
|
||||
|
||||
/// @param dims the dimensionality of the texture
|
||||
/// @param subtype the texture subtype.
|
||||
/// @returns the multisampled texture
|
||||
typ::MultisampledTexture multisampled_texture(ast::TextureDimension dims,
|
||||
ast::Type* subtype) const {
|
||||
ast::MultisampledTexture* multisampled_texture(ast::TextureDimension dims,
|
||||
ast::Type* subtype) const {
|
||||
return builder->create<ast::MultisampledTexture>(dims, subtype);
|
||||
}
|
||||
|
||||
|
@ -788,17 +789,17 @@ class ProgramBuilder {
|
|||
/// @param dims the dimensionality of the texture
|
||||
/// @param subtype the texture subtype.
|
||||
/// @returns the multisampled texture
|
||||
typ::MultisampledTexture multisampled_texture(const Source& source,
|
||||
ast::TextureDimension dims,
|
||||
ast::Type* subtype) const {
|
||||
ast::MultisampledTexture* multisampled_texture(const Source& source,
|
||||
ast::TextureDimension dims,
|
||||
ast::Type* subtype) const {
|
||||
return builder->create<ast::MultisampledTexture>(source, dims, subtype);
|
||||
}
|
||||
|
||||
/// @param dims the dimensionality of the texture
|
||||
/// @param format the image format of the texture
|
||||
/// @returns the storage texture
|
||||
typ::StorageTexture storage_texture(ast::TextureDimension dims,
|
||||
ast::ImageFormat format) const {
|
||||
ast::StorageTexture* storage_texture(ast::TextureDimension dims,
|
||||
ast::ImageFormat format) const {
|
||||
auto* subtype = ast::StorageTexture::SubtypeFor(format, *builder);
|
||||
return builder->create<ast::StorageTexture>(dims, format, subtype);
|
||||
}
|
||||
|
@ -807,22 +808,22 @@ class ProgramBuilder {
|
|||
/// @param dims the dimensionality of the texture
|
||||
/// @param format the image format of the texture
|
||||
/// @returns the storage texture
|
||||
typ::StorageTexture storage_texture(const Source& source,
|
||||
ast::TextureDimension dims,
|
||||
ast::ImageFormat format) const {
|
||||
ast::StorageTexture* storage_texture(const Source& source,
|
||||
ast::TextureDimension dims,
|
||||
ast::ImageFormat format) const {
|
||||
auto* subtype = ast::StorageTexture::SubtypeFor(format, *builder);
|
||||
return builder->create<ast::StorageTexture>(source, dims, format,
|
||||
subtype);
|
||||
}
|
||||
|
||||
/// @returns the external texture
|
||||
typ::ExternalTexture external_texture() const {
|
||||
ast::ExternalTexture* external_texture() const {
|
||||
return builder->create<ast::ExternalTexture>();
|
||||
}
|
||||
|
||||
/// @param source the Source of the node
|
||||
/// @returns the external texture
|
||||
typ::ExternalTexture external_texture(const Source& source) const {
|
||||
ast::ExternalTexture* external_texture(const Source& source) const {
|
||||
return builder->create<ast::ExternalTexture>(source);
|
||||
}
|
||||
|
||||
|
@ -847,7 +848,7 @@ class ProgramBuilder {
|
|||
/// contains a single static `get()` method for obtaining the corresponding
|
||||
/// AST type for the C type `T`.
|
||||
/// `get()` has the signature:
|
||||
/// `static typ::Type get(Types* t)`
|
||||
/// `static ast::Type* get(Types* t)`
|
||||
template <typename T>
|
||||
struct CToAST {};
|
||||
};
|
||||
|
@ -1333,7 +1334,7 @@ class ProgramBuilder {
|
|||
/// variable with the ast::Module.
|
||||
template <typename NAME>
|
||||
ast::Variable* GlobalConst(NAME&& name,
|
||||
typ::Type type,
|
||||
ast::Type* type,
|
||||
ast::Expression* constructor,
|
||||
ast::DecorationList decorations = {}) {
|
||||
auto* var = Const(std::forward<NAME>(name), type, constructor,
|
||||
|
@ -1353,7 +1354,7 @@ class ProgramBuilder {
|
|||
template <typename NAME>
|
||||
ast::Variable* GlobalConst(const Source& source,
|
||||
NAME&& name,
|
||||
typ::Type type,
|
||||
ast::Type* type,
|
||||
ast::Expression* constructor,
|
||||
ast::DecorationList decorations = {}) {
|
||||
auto* var = Const(source, std::forward<NAME>(name), type, constructor,
|
||||
|
@ -2003,31 +2004,31 @@ class ProgramBuilder {
|
|||
// Various template specializations for ProgramBuilder::TypesBuilder::CToAST.
|
||||
template <>
|
||||
struct ProgramBuilder::TypesBuilder::CToAST<ProgramBuilder::i32> {
|
||||
static typ::Type get(const ProgramBuilder::TypesBuilder* t) {
|
||||
static ast::Type* get(const ProgramBuilder::TypesBuilder* t) {
|
||||
return t->i32();
|
||||
}
|
||||
};
|
||||
template <>
|
||||
struct ProgramBuilder::TypesBuilder::CToAST<ProgramBuilder::u32> {
|
||||
static typ::Type get(const ProgramBuilder::TypesBuilder* t) {
|
||||
static ast::Type* get(const ProgramBuilder::TypesBuilder* t) {
|
||||
return t->u32();
|
||||
}
|
||||
};
|
||||
template <>
|
||||
struct ProgramBuilder::TypesBuilder::CToAST<ProgramBuilder::f32> {
|
||||
static typ::Type get(const ProgramBuilder::TypesBuilder* t) {
|
||||
static ast::Type* get(const ProgramBuilder::TypesBuilder* t) {
|
||||
return t->f32();
|
||||
}
|
||||
};
|
||||
template <>
|
||||
struct ProgramBuilder::TypesBuilder::CToAST<bool> {
|
||||
static typ::Type get(const ProgramBuilder::TypesBuilder* t) {
|
||||
static ast::Type* get(const ProgramBuilder::TypesBuilder* t) {
|
||||
return t->bool_();
|
||||
}
|
||||
};
|
||||
template <>
|
||||
struct ProgramBuilder::TypesBuilder::CToAST<void> {
|
||||
static typ::Type get(const ProgramBuilder::TypesBuilder* t) {
|
||||
static ast::Type* get(const ProgramBuilder::TypesBuilder* t) {
|
||||
return t->void_();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -33,7 +33,7 @@ TEST_F(ProgramBuilderTest, IDsAreUnique) {
|
|||
TEST_F(ProgramBuilderTest, WrapDoesntAffectInner) {
|
||||
Program inner([] {
|
||||
ProgramBuilder builder;
|
||||
auto ty = builder.ty.f32();
|
||||
auto* ty = builder.ty.f32();
|
||||
builder.Func("a", {}, ty, {}, {});
|
||||
return builder;
|
||||
}());
|
||||
|
@ -54,7 +54,7 @@ TEST_F(ProgramBuilderTest, WrapDoesntAffectInner) {
|
|||
EXPECT_FALSE(inner.Symbols().Get("b").IsValid());
|
||||
EXPECT_FALSE(outer.Symbols().Get("b").IsValid());
|
||||
|
||||
auto ty = outer.ty.f32();
|
||||
auto* ty = outer.ty.f32();
|
||||
outer.Func("b", {}, ty, {}, {});
|
||||
|
||||
ASSERT_EQ(inner.AST().Functions().size(), 1u);
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "src/reader/wgsl/parser_impl_detail.h"
|
||||
#include "src/reader/wgsl/token.h"
|
||||
#include "src/sem/storage_texture_type.h"
|
||||
#include "src/typepair.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#define SRC_READER_WGSL_PARSER_IMPL_DETAIL_H_
|
||||
|
||||
#include <memory>
|
||||
#include "src/typepair.h"
|
||||
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
|
@ -63,17 +62,6 @@ struct OperatorArrow<T*> {
|
|||
static inline T* ptr(T* val) { return val; }
|
||||
};
|
||||
|
||||
/// OperatorArrow template specialization for TypePair<T, U>.
|
||||
template <typename T, typename U>
|
||||
struct OperatorArrow<typ::TypePair<T, U>> {
|
||||
/// type resolves to the same as input type to allow for operator-> chaining
|
||||
using type = typ::TypePair<T, U>;
|
||||
/// @param val the value held by `ParserImpl::Expect<T>` or
|
||||
/// `ParserImpl::Maybe<T>`.
|
||||
/// @return `val`.
|
||||
static inline type& ptr(type& val) { return val; }
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace wgsl
|
||||
} // namespace reader
|
||||
|
|
|
@ -161,8 +161,8 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonStorable_Fail) {
|
|||
// a = b;
|
||||
|
||||
auto make_type = [&] {
|
||||
auto tex_type = ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kRgba8Unorm);
|
||||
auto* tex_type = ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kRgba8Unorm);
|
||||
return ty.access(ast::AccessControl::kReadOnly, tex_type);
|
||||
};
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ class ResolverIntrinsicTest_TextureOperation
|
|||
/// @param dim dimensionality of the texture being sampled
|
||||
/// @param scalar the scalar type
|
||||
/// @returns a pointer to a type appropriate for the coord param
|
||||
typ::Type GetCoordsType(ast::TextureDimension dim, typ::Type scalar) {
|
||||
ast::Type* GetCoordsType(ast::TextureDimension dim, ast::Type* scalar) {
|
||||
switch (dim) {
|
||||
case ast::TextureDimension::k1d:
|
||||
return scalar;
|
||||
|
@ -255,7 +255,7 @@ class ResolverIntrinsicTest_TextureOperation
|
|||
|
||||
call_params->push_back(Expr(name));
|
||||
}
|
||||
typ::Type subtype(Texture type) {
|
||||
ast::Type* subtype(Texture type) {
|
||||
if (type == Texture::kF32) {
|
||||
return ty.f32();
|
||||
}
|
||||
|
@ -273,8 +273,8 @@ TEST_P(ResolverIntrinsicTest_StorageTextureOperation, TextureLoadRo) {
|
|||
auto type = GetParam().type;
|
||||
auto format = GetParam().format;
|
||||
|
||||
auto coords_type = GetCoordsType(dim, ty.i32());
|
||||
auto texture_type = ty.storage_texture(dim, format);
|
||||
auto* coords_type = GetCoordsType(dim, ty.i32());
|
||||
auto* texture_type = ty.storage_texture(dim, format);
|
||||
auto* ro_texture_type =
|
||||
ty.access(ast::AccessControl::kReadOnly, texture_type);
|
||||
|
||||
|
@ -339,9 +339,9 @@ TEST_P(ResolverIntrinsicTest_SampledTextureOperation, TextureLoadSampled) {
|
|||
auto dim = GetParam().dim;
|
||||
auto type = GetParam().type;
|
||||
|
||||
auto s = subtype(type);
|
||||
auto coords_type = GetCoordsType(dim, ty.i32());
|
||||
auto texture_type = ty.sampled_texture(dim, s);
|
||||
auto* s = subtype(type);
|
||||
auto* coords_type = GetCoordsType(dim, ty.i32());
|
||||
auto* texture_type = ty.sampled_texture(dim, s);
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
||||
|
|
|
@ -2446,7 +2446,7 @@ bool Resolver::ValidateNamedType(const ast::NamedType* named_type) const {
|
|||
sem::Type* Resolver::TypeOf(const ast::Expression* expr) {
|
||||
auto it = expr_info_.find(expr);
|
||||
if (it != expr_info_.end()) {
|
||||
return it->second.type;
|
||||
return const_cast<sem::Type*>(it->second.type);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -2477,19 +2477,17 @@ sem::Type* Resolver::TypeOf(const ast::Literal* lit) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void Resolver::SetType(ast::Expression* expr, typ::Type type) {
|
||||
SetType(expr, type,
|
||||
type.sem ? type.sem->FriendlyName(builder_->Symbols())
|
||||
: type.ast->FriendlyName(builder_->Symbols()));
|
||||
void Resolver::SetType(ast::Expression* expr, const ast::Type* type) {
|
||||
SetType(expr, Type(type), type->FriendlyName(builder_->Symbols()));
|
||||
}
|
||||
|
||||
void Resolver::SetType(ast::Expression* expr, const sem::Type* type) {
|
||||
SetType(expr, type, type->FriendlyName(builder_->Symbols()));
|
||||
}
|
||||
|
||||
void Resolver::SetType(ast::Expression* expr,
|
||||
typ::Type type,
|
||||
const sem::Type* type,
|
||||
const std::string& type_name) {
|
||||
if (!type.sem) {
|
||||
type.sem = Type(type.ast);
|
||||
TINT_ASSERT(type.sem);
|
||||
}
|
||||
if (expr_info_.count(expr)) {
|
||||
TINT_ICE(diagnostics_) << "SetType() called twice for the same expression";
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ class Resolver {
|
|||
/// Structure holding semantic information about an expression.
|
||||
/// Used to build the sem::Expression nodes at the end of resolving.
|
||||
struct ExpressionInfo {
|
||||
sem::Type* type;
|
||||
sem::Type const* type;
|
||||
std::string const type_name; // Declared type name
|
||||
sem::Statement* statement;
|
||||
};
|
||||
|
@ -318,11 +318,17 @@ class Resolver {
|
|||
/// @param lit the literal
|
||||
sem::Type* TypeOf(const ast::Literal* lit);
|
||||
|
||||
/// Creates a sem::Expression node with the pre-resolved AST type `type`, and
|
||||
/// assigns this semantic node to the expression `expr`.
|
||||
/// @param expr the expression
|
||||
/// @param type the AST type
|
||||
void SetType(ast::Expression* expr, const ast::Type* type);
|
||||
|
||||
/// Creates a sem::Expression node with the resolved type `type`, and
|
||||
/// assigns this semantic node to the expression `expr`.
|
||||
/// @param expr the expression
|
||||
/// @param type the resolved type
|
||||
void SetType(ast::Expression* expr, typ::Type type);
|
||||
void SetType(ast::Expression* expr, const sem::Type* type);
|
||||
|
||||
/// Creates a sem::Expression node with the resolved type `type`, the declared
|
||||
/// type name `type_name` and assigns this semantic node to the expression
|
||||
|
@ -331,7 +337,7 @@ class Resolver {
|
|||
/// @param type the resolved type
|
||||
/// @param type_name the declared type name
|
||||
void SetType(ast::Expression* expr,
|
||||
typ::Type type,
|
||||
const sem::Type* type,
|
||||
const std::string& type_name);
|
||||
|
||||
/// Resolve the value of a scalar const_expr.
|
||||
|
|
|
@ -1579,8 +1579,8 @@ TEST_P(Expr_Binary_Test_Invalid_MatrixMatrixMultiply, All) {
|
|||
uint32_t rhs_mat_rows = std::get<2>(GetParam());
|
||||
uint32_t rhs_mat_cols = std::get<3>(GetParam());
|
||||
|
||||
auto lhs_type = ty.mat<f32>(lhs_mat_cols, lhs_mat_rows);
|
||||
auto rhs_type = ty.mat<f32>(rhs_mat_cols, rhs_mat_rows);
|
||||
auto* lhs_type = ty.mat<f32>(lhs_mat_cols, lhs_mat_rows);
|
||||
auto* rhs_type = ty.mat<f32>(rhs_mat_cols, rhs_mat_rows);
|
||||
|
||||
auto* f32 = create<sem::F32>();
|
||||
auto* col = create<sem::Vector>(f32, lhs_mat_rows);
|
||||
|
@ -1650,7 +1650,7 @@ TEST_F(ResolverTest, StorageClass_SetsIfMissing) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, StorageClass_SetForSampler) {
|
||||
auto t = ty.sampler(ast::SamplerKind::kSampler);
|
||||
auto* t = ty.sampler(ast::SamplerKind::kSampler);
|
||||
auto* var = Global("var", t, ast::StorageClass::kNone, nullptr,
|
||||
{
|
||||
create<ast::BindingDecoration>(0),
|
||||
|
@ -1664,7 +1664,7 @@ TEST_F(ResolverTest, StorageClass_SetForSampler) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, StorageClass_SetForTexture) {
|
||||
auto t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
auto* ac = ty.access(ast::AccessControl::kReadOnly, t);
|
||||
auto* var = Global("var", ac, ast::StorageClass::kNone, nullptr,
|
||||
{
|
||||
|
|
|
@ -99,9 +99,15 @@ class TestHelper : public ProgramBuilder {
|
|||
/// @param type a type
|
||||
/// @returns the name for `type` that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
std::string FriendlyName(typ::Type type) {
|
||||
return type.ast ? type.ast->FriendlyName(Symbols())
|
||||
: type.sem->FriendlyName(Symbols());
|
||||
std::string FriendlyName(const ast::Type* type) {
|
||||
return type->FriendlyName(Symbols());
|
||||
}
|
||||
|
||||
/// @param type a type
|
||||
/// @returns the name for `type` that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
std::string FriendlyName(const sem::Type* type) {
|
||||
return type->FriendlyName(Symbols());
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -513,7 +513,7 @@ TEST_P(StorageTextureDimensionTest, All) {
|
|||
// var a : [[access(read)]] texture_storage_*<ru32int>;
|
||||
auto& params = GetParam();
|
||||
|
||||
auto st = ty.storage_texture(params.dim, ast::ImageFormat::kR32Uint);
|
||||
auto* st = ty.storage_texture(params.dim, ast::ImageFormat::kR32Uint);
|
||||
auto* ac = ty.access(ast::AccessControl::kReadOnly, st);
|
||||
|
||||
Global("a", ac, ast::StorageClass::kNone, nullptr,
|
||||
|
@ -586,7 +586,7 @@ TEST_P(StorageTextureFormatTest, All) {
|
|||
// [[group(0), binding(3)]]
|
||||
// var d : [[access(read)]] texture_storage_3d<*>;
|
||||
|
||||
auto st_a = ty.storage_texture(ast::TextureDimension::k1d, params.format);
|
||||
auto* st_a = ty.storage_texture(ast::TextureDimension::k1d, params.format);
|
||||
auto* ac_a = ty.access(ast::AccessControl::kReadOnly, st_a);
|
||||
Global("a", ac_a, ast::StorageClass::kNone, nullptr,
|
||||
ast::DecorationList{
|
||||
|
@ -594,7 +594,7 @@ TEST_P(StorageTextureFormatTest, All) {
|
|||
create<ast::GroupDecoration>(0),
|
||||
});
|
||||
|
||||
auto st_b = ty.storage_texture(ast::TextureDimension::k2d, params.format);
|
||||
auto* st_b = ty.storage_texture(ast::TextureDimension::k2d, params.format);
|
||||
auto* ac_b = ty.access(ast::AccessControl::kReadOnly, st_b);
|
||||
Global("b", ac_b, ast::StorageClass::kNone, nullptr,
|
||||
ast::DecorationList{
|
||||
|
@ -602,7 +602,7 @@ TEST_P(StorageTextureFormatTest, All) {
|
|||
create<ast::GroupDecoration>(1),
|
||||
});
|
||||
|
||||
auto st_c =
|
||||
auto* st_c =
|
||||
ty.storage_texture(ast::TextureDimension::k2dArray, params.format);
|
||||
auto* ac_c = ty.access(ast::AccessControl::kReadOnly, st_c);
|
||||
Global("c", ac_c, ast::StorageClass::kNone, nullptr,
|
||||
|
@ -611,7 +611,7 @@ TEST_P(StorageTextureFormatTest, All) {
|
|||
create<ast::GroupDecoration>(2),
|
||||
});
|
||||
|
||||
auto st_d = ty.storage_texture(ast::TextureDimension::k3d, params.format);
|
||||
auto* st_d = ty.storage_texture(ast::TextureDimension::k3d, params.format);
|
||||
auto* ac_d = ty.access(ast::AccessControl::kReadOnly, st_d);
|
||||
Global("d", ac_d, ast::StorageClass::kNone, nullptr,
|
||||
ast::DecorationList{
|
||||
|
@ -635,8 +635,8 @@ TEST_F(StorageTextureAccessControlTest, MissingAccessControl_Fail) {
|
|||
// [[group(0), binding(0)]]
|
||||
// var a : texture_storage_1d<ru32int>;
|
||||
|
||||
auto st = ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
auto* st = ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
|
||||
Global("a", st, ast::StorageClass::kNone, nullptr,
|
||||
ast::DecorationList{
|
||||
|
@ -651,8 +651,8 @@ TEST_F(StorageTextureAccessControlTest, RWAccessControl_Fail) {
|
|||
// [[group(0), binding(0)]]
|
||||
// var a : [[access(readwrite)]] texture_storage_1d<ru32int>;
|
||||
|
||||
auto st = ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
auto* st = ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
|
||||
Global("a", st, ast::StorageClass::kNone, nullptr,
|
||||
ast::DecorationList{
|
||||
|
@ -667,8 +667,8 @@ TEST_F(StorageTextureAccessControlTest, ReadOnlyAccessControl_Pass) {
|
|||
// [[group(0), binding(0)]]
|
||||
// var a : [[access(read)]] texture_storage_1d<ru32int>;
|
||||
|
||||
auto st = ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
auto* st = ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
auto* ac = ty.access(ast::AccessControl::kReadOnly, st);
|
||||
|
||||
Global("a", ac, ast::StorageClass::kNone, nullptr,
|
||||
|
@ -684,8 +684,8 @@ TEST_F(StorageTextureAccessControlTest, WriteOnlyAccessControl_Pass) {
|
|||
// [[group(0), binding(0)]]
|
||||
// var a : [[access(write)]] texture_storage_1d<ru32int>;
|
||||
|
||||
auto st = ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
auto* st = ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
auto* ac = ty.access(ast::AccessControl::kWriteOnly, st);
|
||||
|
||||
Global("a", ac, ast::StorageClass::kNone, nullptr,
|
||||
|
|
|
@ -343,7 +343,7 @@ TEST_F(ResolverValidationTest, StorageClass_NonFunctionClassError) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, StorageClass_SamplerExplicitStorageClass) {
|
||||
auto t = ty.sampler(ast::SamplerKind::kSampler);
|
||||
auto* t = ty.sampler(ast::SamplerKind::kSampler);
|
||||
Global(Source{{12, 34}}, "var", t, ast::StorageClass::kUniformConstant,
|
||||
nullptr,
|
||||
{
|
||||
|
@ -359,7 +359,7 @@ TEST_F(ResolverValidationTest, StorageClass_SamplerExplicitStorageClass) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, StorageClass_TextureExplicitStorageClass) {
|
||||
auto t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
Global(Source{{12, 34}}, "var", t, ast::StorageClass::kUniformConstant,
|
||||
nullptr,
|
||||
{
|
||||
|
@ -1729,7 +1729,7 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vector_ElementTypeAlias_Error) {
|
|||
AST().AddConstructedType(f32_alias);
|
||||
|
||||
// vec2<Float32>(1.0f, 1u)
|
||||
auto vec_type = ty.vec(f32_alias, 2);
|
||||
auto* vec_type = ty.vec(f32_alias, 2);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, vec_type,
|
||||
ExprList(1.0f, create<ast::ScalarConstructorExpression>(Source{{12, 40}},
|
||||
|
@ -1748,7 +1748,7 @@ TEST_F(ResolverValidationTest,
|
|||
AST().AddConstructedType(f32_alias);
|
||||
|
||||
// vec2<Float32>(1.0f, 1.0f)
|
||||
auto vec_type = ty.vec(f32_alias, 2);
|
||||
auto* vec_type = ty.vec(f32_alias, 2);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(Source{{12, 34}}, vec_type,
|
||||
ExprList(1.0f, 1.0f));
|
||||
WrapInFunction(tc);
|
||||
|
@ -1762,7 +1762,7 @@ TEST_F(ResolverValidationTest,
|
|||
AST().AddConstructedType(f32_alias);
|
||||
|
||||
// vec3<u32>(vec<Float32>(), 1.0f)
|
||||
auto vec_type = ty.vec(f32_alias, 2);
|
||||
auto* vec_type = ty.vec(f32_alias, 2);
|
||||
auto* tc = vec3<u32>(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, vec_type, ExprList()),
|
||||
1.0f);
|
||||
|
@ -1780,7 +1780,7 @@ TEST_F(ResolverValidationTest,
|
|||
AST().AddConstructedType(f32_alias);
|
||||
|
||||
// vec3<f32>(vec<Float32>(), 1.0f)
|
||||
auto vec_type = ty.vec(f32_alias, 2);
|
||||
auto* vec_type = ty.vec(f32_alias, 2);
|
||||
auto* tc = vec3<f32>(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, vec_type, ExprList()),
|
||||
1.0f);
|
||||
|
@ -1813,12 +1813,12 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_Error_TooFewArguments) {
|
|||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns - 1; i++) {
|
||||
auto vec_type = ty.vec<f32>(param.rows);
|
||||
auto* vec_type = ty.vec<f32>(param.rows);
|
||||
args.push_back(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, i}}, vec_type, ExprList()));
|
||||
}
|
||||
|
||||
auto matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(Source{}, matrix_type,
|
||||
std::move(args));
|
||||
WrapInFunction(tc);
|
||||
|
@ -1837,12 +1837,12 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_Error_TooManyArguments) {
|
|||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns + 1; i++) {
|
||||
auto vec_type = ty.vec<f32>(param.rows);
|
||||
auto* vec_type = ty.vec<f32>(param.rows);
|
||||
args.push_back(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, i}}, vec_type, ExprList()));
|
||||
}
|
||||
|
||||
auto matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(Source{}, matrix_type,
|
||||
std::move(args));
|
||||
WrapInFunction(tc);
|
||||
|
@ -1865,7 +1865,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_Error_InvalidArgumentType) {
|
|||
Literal(1.0f)));
|
||||
}
|
||||
|
||||
auto matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(Source{}, matrix_type,
|
||||
std::move(args));
|
||||
WrapInFunction(tc);
|
||||
|
@ -1889,16 +1889,16 @@ TEST_P(MatrixConstructorTest,
|
|||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns - 1; i++) {
|
||||
auto valid_vec_type = ty.vec<f32>(param.rows);
|
||||
auto* valid_vec_type = ty.vec<f32>(param.rows);
|
||||
args.push_back(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, i}}, valid_vec_type, ExprList()));
|
||||
}
|
||||
const size_t kInvalidLoc = 2 * (param.columns - 1);
|
||||
auto invalid_vec_type = ty.vec<f32>(param.rows - 1);
|
||||
auto* invalid_vec_type = ty.vec<f32>(param.rows - 1);
|
||||
args.push_back(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, kInvalidLoc}}, invalid_vec_type, ExprList()));
|
||||
|
||||
auto matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(Source{}, matrix_type,
|
||||
std::move(args));
|
||||
WrapInFunction(tc);
|
||||
|
@ -1924,16 +1924,16 @@ TEST_P(MatrixConstructorTest,
|
|||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns - 1; i++) {
|
||||
auto valid_vec_type = ty.vec<f32>(param.rows);
|
||||
auto* valid_vec_type = ty.vec<f32>(param.rows);
|
||||
args.push_back(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, i}}, valid_vec_type, ExprList()));
|
||||
}
|
||||
const size_t kInvalidLoc = 2 * (param.columns - 1);
|
||||
auto invalid_vec_type = ty.vec<f32>(param.rows + 1);
|
||||
auto* invalid_vec_type = ty.vec<f32>(param.rows + 1);
|
||||
args.push_back(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, kInvalidLoc}}, invalid_vec_type, ExprList()));
|
||||
|
||||
auto matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(Source{}, matrix_type,
|
||||
std::move(args));
|
||||
WrapInFunction(tc);
|
||||
|
@ -1954,12 +1954,12 @@ TEST_P(MatrixConstructorTest,
|
|||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns; i++) {
|
||||
auto vec_type = ty.vec<u32>(param.rows);
|
||||
auto* vec_type = ty.vec<u32>(param.rows);
|
||||
args.push_back(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, i}}, vec_type, ExprList()));
|
||||
}
|
||||
|
||||
auto matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(Source{}, matrix_type,
|
||||
std::move(args));
|
||||
WrapInFunction(tc);
|
||||
|
@ -1975,7 +1975,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ZeroValue_Success) {
|
|||
// matNxM<f32>();
|
||||
|
||||
const auto param = GetParam();
|
||||
auto matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(Source{{12, 40}},
|
||||
matrix_type, ExprList());
|
||||
WrapInFunction(tc);
|
||||
|
@ -1990,12 +1990,12 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_WithArguments_Success) {
|
|||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns; i++) {
|
||||
auto vec_type = ty.vec<f32>(param.rows);
|
||||
auto* vec_type = ty.vec<f32>(param.rows);
|
||||
args.push_back(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, i}}, vec_type, ExprList()));
|
||||
}
|
||||
|
||||
auto matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(Source{}, matrix_type,
|
||||
std::move(args));
|
||||
WrapInFunction(tc);
|
||||
|
@ -2012,12 +2012,12 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ElementTypeAlias_Error) {
|
|||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns; i++) {
|
||||
auto vec_type = ty.vec(ty.u32(), param.rows);
|
||||
auto* vec_type = ty.vec(ty.u32(), param.rows);
|
||||
args.push_back(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, i}}, vec_type, ExprList()));
|
||||
}
|
||||
|
||||
auto matrix_type = ty.mat(f32_alias, param.columns, param.rows);
|
||||
auto* matrix_type = ty.mat(f32_alias, param.columns, param.rows);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(Source{}, matrix_type,
|
||||
std::move(args));
|
||||
WrapInFunction(tc);
|
||||
|
@ -2038,12 +2038,12 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ElementTypeAlias_Success) {
|
|||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns; i++) {
|
||||
auto vec_type = ty.vec<f32>(param.rows);
|
||||
auto* vec_type = ty.vec<f32>(param.rows);
|
||||
args.push_back(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, i}}, vec_type, ExprList()));
|
||||
}
|
||||
|
||||
auto matrix_type = ty.mat(f32_alias, param.columns, param.rows);
|
||||
auto* matrix_type = ty.mat(f32_alias, param.columns, param.rows);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(Source{}, matrix_type,
|
||||
std::move(args));
|
||||
WrapInFunction(tc);
|
||||
|
@ -2068,8 +2068,8 @@ TEST_F(ResolverValidationTest, Expr_MatrixConstructor_ArgumentTypeAlias_Error) {
|
|||
|
||||
TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentTypeAlias_Success) {
|
||||
const auto param = GetParam();
|
||||
auto matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto vec_type = ty.vec<f32>(param.rows);
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* vec_type = ty.vec<f32>(param.rows);
|
||||
auto* vec_alias = ty.alias("VectorFloat2", vec_type);
|
||||
AST().AddConstructedType(vec_alias);
|
||||
|
||||
|
@ -2088,13 +2088,13 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentTypeAlias_Success) {
|
|||
|
||||
TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentElementTypeAlias_Error) {
|
||||
const auto param = GetParam();
|
||||
auto matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* f32_alias = ty.alias("UnsignedInt", ty.u32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns; i++) {
|
||||
auto vec_type = ty.vec(f32_alias, param.rows);
|
||||
auto* vec_type = ty.vec(f32_alias, param.rows);
|
||||
args.push_back(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, i}}, vec_type, ExprList()));
|
||||
}
|
||||
|
@ -2118,12 +2118,12 @@ TEST_P(MatrixConstructorTest,
|
|||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns; i++) {
|
||||
auto vec_type = ty.vec(f32_alias, param.rows);
|
||||
auto* vec_type = ty.vec(f32_alias, param.rows);
|
||||
args.push_back(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, i}}, vec_type, ExprList()));
|
||||
}
|
||||
|
||||
auto matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(Source{}, matrix_type,
|
||||
std::move(args));
|
||||
WrapInFunction(tc);
|
||||
|
|
|
@ -108,8 +108,8 @@ Output ExternalTextureTransform::Run(const Program* in, const DataMap&) {
|
|||
if (Is<ast::ExternalTexture>(var->type())) {
|
||||
// Replace a single-plane external texture with a 2D, f32 sampled
|
||||
// texture.
|
||||
auto newType = ctx.dst->ty.sampled_texture(ast::TextureDimension::k2d,
|
||||
ctx.dst->ty.f32());
|
||||
auto* newType = ctx.dst->ty.sampled_texture(ast::TextureDimension::k2d,
|
||||
ctx.dst->ty.f32());
|
||||
auto clonedSrc = ctx.Clone(var->source());
|
||||
auto clonedSym = ctx.Clone(var->symbol());
|
||||
auto* clonedConstructor = ctx.Clone(var->constructor());
|
||||
|
|
273
src/typepair.h
273
src/typepair.h
|
@ -1,273 +0,0 @@
|
|||
// Copyright 2021 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// This file contains temporary code to help implement the new `ast::Type`s.
|
||||
// Once complete, this file should be completely removed.
|
||||
// Bug: crbug.com/tint/724
|
||||
|
||||
#ifndef SRC_TYPEPAIR_H_
|
||||
#define SRC_TYPEPAIR_H_
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
// X11 likes to #define Bool leading to confusing error messages.
|
||||
// If its defined, undefine it.
|
||||
#ifdef Bool
|
||||
#undef Bool
|
||||
#endif
|
||||
|
||||
namespace tint {
|
||||
|
||||
namespace ast {
|
||||
class AccessControl;
|
||||
class Array;
|
||||
class Bool;
|
||||
class DepthTexture;
|
||||
class ExternalTexture;
|
||||
class F32;
|
||||
class I32;
|
||||
class Matrix;
|
||||
class MultisampledTexture;
|
||||
class Pointer;
|
||||
class Sampler;
|
||||
class SampledTexture;
|
||||
class StorageTexture;
|
||||
class Struct;
|
||||
class Texture;
|
||||
class Type;
|
||||
class U32;
|
||||
class Vector;
|
||||
class Void;
|
||||
} // namespace ast
|
||||
|
||||
namespace sem {
|
||||
class AccessControl;
|
||||
class Array;
|
||||
class Bool;
|
||||
class DepthTexture;
|
||||
class ExternalTexture;
|
||||
class F32;
|
||||
class I32;
|
||||
class Matrix;
|
||||
class MultisampledTexture;
|
||||
class Pointer;
|
||||
class Sampler;
|
||||
class SampledTexture;
|
||||
class StorageTexture;
|
||||
class Struct;
|
||||
class Texture;
|
||||
class Type;
|
||||
class U32;
|
||||
class Vector;
|
||||
class Void;
|
||||
} // namespace sem
|
||||
|
||||
namespace typ { // type-pair
|
||||
|
||||
/// A simple wrapper around a raw pointer. Used to prevent a whole bunch of
|
||||
/// warnings about `auto` needing to be declared as `auto*` while we're
|
||||
/// migrating code.
|
||||
template <typename T>
|
||||
struct Ptr {
|
||||
/// The raw pointer
|
||||
T* const ptr;
|
||||
|
||||
/// Constructor
|
||||
Ptr() = default;
|
||||
|
||||
/// Copy constructor
|
||||
/// @param other the Ptr to copy
|
||||
template <typename OTHER>
|
||||
Ptr(const Ptr<OTHER>& other) : ptr(static_cast<T*>(other.ptr)) {}
|
||||
|
||||
/// Constructor
|
||||
/// @param p the pointer to wrap in a Ptr
|
||||
template <typename U>
|
||||
Ptr(U* p) : ptr(p) {} // NOLINT: explicit
|
||||
|
||||
/// @returns the pointer
|
||||
operator T*() { return ptr; }
|
||||
|
||||
/// @returns the pointer
|
||||
operator const T*() const { return ptr; }
|
||||
|
||||
/// @returns the pointer
|
||||
T* operator->() { return ptr; }
|
||||
|
||||
/// @returns the pointer
|
||||
const T* operator->() const { return ptr; }
|
||||
};
|
||||
|
||||
/// TypePair is a pair of ast::Type and sem::Type pointers used to simplify
|
||||
/// migration to the new ast::Type nodes.
|
||||
///
|
||||
/// Type attempts to behave as either an ast::Type or sem::Type:
|
||||
/// * Type has constructors that take either an ast::Type and sem::Type pointer
|
||||
/// pair, and single-parameter implicit constructors for either a single
|
||||
/// ast::Type or sem::Type pointer.
|
||||
/// * Type also has user-defined conversion functions for returning either an
|
||||
/// ast::Type or sem::Type pointer.
|
||||
/// * operator->() returns the sem::Type pointer. Later in the migration this
|
||||
/// will switch to returning the ast::Type pointer.
|
||||
template <typename AST, typename SEM>
|
||||
struct TypePair {
|
||||
/// Alias of the `AST` template type parameter
|
||||
using AST_TYPE = AST;
|
||||
/// Alias of the `SEM` template type parameter
|
||||
using SEM_TYPE = SEM;
|
||||
|
||||
/// The ast::Type pointer
|
||||
AST const* ast = nullptr;
|
||||
/// The sem::Type pointer
|
||||
SEM const* sem = nullptr;
|
||||
|
||||
/// Constructor
|
||||
TypePair() = default;
|
||||
/// Copy constructor
|
||||
/// @param other the TypePair to copy
|
||||
template <typename OTHER_AST, typename OTHER_SEM>
|
||||
TypePair(const TypePair<OTHER_AST, OTHER_SEM>& other)
|
||||
: ast(static_cast<const AST*>(other.ast)),
|
||||
sem(static_cast<const SEM*>(other.sem)) {}
|
||||
/// Constructor
|
||||
/// @param a the ast::Type pointer
|
||||
TypePair(const AST* a) : ast(a) {} // NOLINT: explicit
|
||||
/// Constructor
|
||||
/// @param s the sem::Type pointer
|
||||
TypePair(const SEM* s) : sem(s) {} // NOLINT: explicit
|
||||
/// Constructor
|
||||
/// @param a the ast::Type pointer
|
||||
/// @param s the sem::Type pointer
|
||||
TypePair(const AST* a, const SEM* s) : ast(a), sem(s) {}
|
||||
/// Constructor
|
||||
/// @param ptr the Ptr<T>
|
||||
template <typename T>
|
||||
TypePair(Ptr<T> ptr) : TypePair(ptr.ptr) {} // NOLINT: explicit
|
||||
/// Constructor
|
||||
TypePair(std::nullptr_t) {} // NOLINT: explicit
|
||||
|
||||
/// @returns the ast::Type pointer
|
||||
operator AST*() const { return const_cast<AST*>(ast); }
|
||||
/// @returns the sem::Type pointer
|
||||
operator SEM*() const { return const_cast<SEM*>(sem); }
|
||||
/// @returns the sem::Type pointer
|
||||
SEM* operator->() const { return const_cast<SEM*>(sem); }
|
||||
|
||||
/// @returns true if sem is valid
|
||||
explicit operator bool() const { return sem != nullptr; }
|
||||
|
||||
/// @param ty the semantic type to compare against
|
||||
/// @returns true if the semantic type is equal to `ty`
|
||||
bool operator==(sem::Type* ty) const { return sem == ty; }
|
||||
|
||||
/// @param ty the semantic type to compare against
|
||||
/// @returns true if the semantic type is not equal to `ty`
|
||||
bool operator!=(sem::Type* ty) const { return !((*this) == ty); }
|
||||
|
||||
/// @param other the TypePair to compare against
|
||||
/// @returns true if this TypePair is less than `other`
|
||||
template <typename OTHER_AST, typename OTHER_SEM>
|
||||
bool operator<(const TypePair<OTHER_AST, OTHER_SEM>& other) const {
|
||||
if (sem < other.sem) {
|
||||
return true;
|
||||
}
|
||||
if (sem > other.sem) {
|
||||
return false;
|
||||
}
|
||||
return ast < other.ast;
|
||||
}
|
||||
};
|
||||
|
||||
/// @param lhs LHS value to compare
|
||||
/// @param rhs RHS value to compare
|
||||
/// @returns true if values compare equal
|
||||
template <typename AST, typename SEM>
|
||||
bool operator==(const TypePair<AST, SEM>& lhs, const TypePair<AST, SEM>& rhs) {
|
||||
return lhs.sem == rhs.sem;
|
||||
}
|
||||
|
||||
/// @param lhs LHS value to compare
|
||||
/// @param rhs RHS value to compare
|
||||
/// @returns true if values compare not equal
|
||||
template <typename AST, typename SEM>
|
||||
bool operator!=(const TypePair<AST, SEM>& lhs, const TypePair<AST, SEM>& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
/// @param lhs LHS value to compare
|
||||
/// @returns true if `lhs` is nullptr
|
||||
template <typename AST, typename SEM>
|
||||
bool operator==(const TypePair<AST, SEM>& lhs, std::nullptr_t) {
|
||||
return lhs.sem == nullptr;
|
||||
}
|
||||
|
||||
/// @param lhs LHS value to compare
|
||||
/// @returns true if `lhs` is not nullptr
|
||||
template <typename AST, typename SEM>
|
||||
bool operator!=(const TypePair<AST, SEM>& lhs, std::nullptr_t) {
|
||||
return !(lhs == nullptr);
|
||||
}
|
||||
|
||||
/// @param rhs RHS value to compare
|
||||
/// @returns true if `rhs` is nullptr
|
||||
template <typename AST, typename SEM>
|
||||
bool operator==(std::nullptr_t, const TypePair<AST, SEM>& rhs) {
|
||||
return nullptr == rhs.sem;
|
||||
}
|
||||
|
||||
/// @param rhs RHS value to compare
|
||||
/// @returns true if `rhs` is not nullptr
|
||||
template <typename AST, typename SEM>
|
||||
bool operator!=(std::nullptr_t, const TypePair<AST, SEM>& rhs) {
|
||||
return !(nullptr == rhs);
|
||||
}
|
||||
|
||||
using Type = TypePair<ast::Type, sem::Type>;
|
||||
|
||||
|
||||
using Bool = Ptr<ast::Bool>;
|
||||
using U32 = Ptr<ast::U32>;
|
||||
using I32 = Ptr<ast::I32>;
|
||||
using F32 = Ptr<ast::F32>;
|
||||
using Void = Ptr<ast::Void>;
|
||||
using DepthTexture = Ptr<ast::DepthTexture>;
|
||||
using ExternalTexture = Ptr<ast::ExternalTexture>;
|
||||
using MultisampledTexture = Ptr<ast::MultisampledTexture>;
|
||||
using SampledTexture = Ptr<ast::SampledTexture>;
|
||||
using StorageTexture = Ptr<ast::StorageTexture>;
|
||||
using Texture = Ptr<ast::Texture>;
|
||||
using Sampler = Ptr<ast::Sampler>;
|
||||
using Matrix = Ptr<ast::Matrix>;
|
||||
using Vector = Ptr<ast::Vector>;
|
||||
using Pointer = Ptr<ast::Pointer>;
|
||||
using Struct = Ptr<ast::Struct>;
|
||||
|
||||
// Helpers
|
||||
|
||||
/// Makes a type pair, deducing the return type from input args
|
||||
/// @parm ast the ast node
|
||||
/// @param sem the sem node
|
||||
/// @returns a type pair
|
||||
template <typename AST, typename SEM>
|
||||
inline auto MakeTypePair(AST* ast, SEM* sem) {
|
||||
return TypePair<AST, SEM>{ast, sem};
|
||||
}
|
||||
|
||||
} // namespace typ
|
||||
|
||||
} // namespace tint
|
||||
|
||||
#endif // SRC_TYPEPAIR_H_
|
|
@ -25,63 +25,63 @@ namespace {
|
|||
using ::testing::HasSubstr;
|
||||
|
||||
using create_type_func_ptr =
|
||||
typ::Type (*)(const ProgramBuilder::TypesBuilder& ty);
|
||||
ast::Type* (*)(const ProgramBuilder::TypesBuilder& ty);
|
||||
|
||||
inline typ::Type ty_i32(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_i32(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.i32();
|
||||
}
|
||||
inline typ::Type ty_u32(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_u32(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.u32();
|
||||
}
|
||||
inline typ::Type ty_f32(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_f32(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.f32();
|
||||
}
|
||||
template <typename T>
|
||||
inline typ::Type ty_vec2(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_vec2(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.vec2<T>();
|
||||
}
|
||||
template <typename T>
|
||||
inline typ::Type ty_vec3(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_vec3(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.vec3<T>();
|
||||
}
|
||||
template <typename T>
|
||||
inline typ::Type ty_vec4(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_vec4(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.vec4<T>();
|
||||
}
|
||||
template <typename T>
|
||||
inline typ::Type ty_mat2x2(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_mat2x2(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.mat2x2<T>();
|
||||
}
|
||||
template <typename T>
|
||||
inline typ::Type ty_mat2x3(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_mat2x3(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.mat2x3<T>();
|
||||
}
|
||||
template <typename T>
|
||||
inline typ::Type ty_mat2x4(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_mat2x4(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.mat2x4<T>();
|
||||
}
|
||||
template <typename T>
|
||||
inline typ::Type ty_mat3x2(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_mat3x2(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.mat3x2<T>();
|
||||
}
|
||||
template <typename T>
|
||||
inline typ::Type ty_mat3x3(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_mat3x3(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.mat3x3<T>();
|
||||
}
|
||||
template <typename T>
|
||||
inline typ::Type ty_mat3x4(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_mat3x4(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.mat3x4<T>();
|
||||
}
|
||||
template <typename T>
|
||||
inline typ::Type ty_mat4x2(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_mat4x2(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.mat4x2<T>();
|
||||
}
|
||||
template <typename T>
|
||||
inline typ::Type ty_mat4x3(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_mat4x3(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.mat4x3<T>();
|
||||
}
|
||||
template <typename T>
|
||||
inline typ::Type ty_mat4x4(const ProgramBuilder::TypesBuilder& ty) {
|
||||
inline ast::Type* ty_mat4x4(const ProgramBuilder::TypesBuilder& ty) {
|
||||
return ty.mat4x4<T>();
|
||||
}
|
||||
|
||||
|
@ -154,12 +154,8 @@ struct TypeCase {
|
|||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, TypeCase c) {
|
||||
ProgramBuilder b;
|
||||
auto ty = c.member_type(b.ty);
|
||||
if (ty.sem) {
|
||||
out << ty.sem->FriendlyName(b.Symbols());
|
||||
} else {
|
||||
out << ty.ast->FriendlyName(b.Symbols());
|
||||
}
|
||||
auto* ty = c.member_type(b.ty);
|
||||
out << ty->FriendlyName(b.Symbols());
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
@ -352,7 +352,7 @@ using HlslDepthTexturesTest = TestParamHelper<HlslDepthTextureData>;
|
|||
TEST_P(HlslDepthTexturesTest, Emit) {
|
||||
auto params = GetParam();
|
||||
|
||||
auto t = ty.depth_texture(params.dim);
|
||||
auto* t = ty.depth_texture(params.dim);
|
||||
|
||||
Global("tex", t, ast::StorageClass::kNone, nullptr,
|
||||
ast::DecorationList{
|
||||
|
@ -399,7 +399,7 @@ using HlslSampledTexturesTest = TestParamHelper<HlslSampledTextureData>;
|
|||
TEST_P(HlslSampledTexturesTest, Emit) {
|
||||
auto params = GetParam();
|
||||
|
||||
typ::Type datatype;
|
||||
ast::Type* datatype = nullptr;
|
||||
switch (params.datatype) {
|
||||
case TextureDataType::F32:
|
||||
datatype = ty.f32();
|
||||
|
@ -411,7 +411,7 @@ TEST_P(HlslSampledTexturesTest, Emit) {
|
|||
datatype = ty.i32();
|
||||
break;
|
||||
}
|
||||
auto t = ty.sampled_texture(params.dim, datatype);
|
||||
auto* t = ty.sampled_texture(params.dim, datatype);
|
||||
|
||||
Global("tex", t, ast::StorageClass::kNone, nullptr,
|
||||
ast::DecorationList{
|
||||
|
@ -552,7 +552,7 @@ using HlslStorageTexturesTest = TestParamHelper<HlslStorageTextureData>;
|
|||
TEST_P(HlslStorageTexturesTest, Emit) {
|
||||
auto params = GetParam();
|
||||
|
||||
auto t = ty.storage_texture(params.dim, params.imgfmt);
|
||||
auto* t = ty.storage_texture(params.dim, params.imgfmt);
|
||||
auto* ac = ty.access(params.ro ? ast::AccessControl::kReadOnly
|
||||
: ast::AccessControl::kWriteOnly,
|
||||
t);
|
||||
|
|
|
@ -920,10 +920,7 @@ bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GeneratorImpl::EmitZeroValue(typ::Type type) {
|
||||
if (!type.sem) {
|
||||
type.sem = program_->Sem().Get(type.ast);
|
||||
}
|
||||
bool GeneratorImpl::EmitZeroValue(const sem::Type* type) {
|
||||
if (type->Is<sem::Bool>()) {
|
||||
out_ << "false";
|
||||
} else if (type->Is<sem::F32>()) {
|
||||
|
|
|
@ -227,7 +227,7 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// Emits the zero value for the given type
|
||||
/// @param type the type to emit the value for
|
||||
/// @returns true if the zero value was successfully emitted.
|
||||
bool EmitZeroValue(typ::Type type);
|
||||
bool EmitZeroValue(const sem::Type* type);
|
||||
|
||||
/// Determines if the function needs the input struct passed to it.
|
||||
/// @param func the function to check
|
||||
|
|
|
@ -765,7 +765,7 @@ using MslStorageTexturesTest = TestParamHelper<MslStorageTextureData>;
|
|||
TEST_P(MslStorageTexturesTest, Emit) {
|
||||
auto params = GetParam();
|
||||
|
||||
auto s = ty.storage_texture(params.dim, ast::ImageFormat::kR32Float);
|
||||
auto* s = ty.storage_texture(params.dim, ast::ImageFormat::kR32Float);
|
||||
auto* ac = ty.access(params.ro ? ast::AccessControl::kReadOnly
|
||||
: ast::AccessControl::kWriteOnly,
|
||||
s);
|
||||
|
|
|
@ -570,8 +570,8 @@ OpName %5 "c"
|
|||
TEST_F(BuilderTest, GlobalVar_TextureStorageReadOnly) {
|
||||
// var<uniform_constant> a : [[access(read)]] texture_storage_2d<r32uint>;
|
||||
|
||||
auto type = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
auto* type = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
|
||||
auto* ac = ty.access(ast::AccessControl::kReadOnly, type);
|
||||
|
||||
|
@ -599,8 +599,8 @@ OpDecorate %1 DescriptorSet 0
|
|||
TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) {
|
||||
// var<uniform_constant> a : [[access(write)]] texture_storage_2d<r32uint>;
|
||||
|
||||
auto type = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
auto* type = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
|
||||
auto* ac = ty.access(ast::AccessControl::kWriteOnly, type);
|
||||
|
||||
|
|
|
@ -370,8 +370,8 @@ TEST_F(IntrinsicBuilderTest, Call_Select) {
|
|||
|
||||
// This tests that we do not push OpTypeSampledImage and float_0 type twice.
|
||||
TEST_F(IntrinsicBuilderTest, Call_TextureSampleCompare_Twice) {
|
||||
auto s = ty.sampler(ast::SamplerKind::kComparisonSampler);
|
||||
auto t = ty.depth_texture(ast::TextureDimension::k2d);
|
||||
auto* s = ty.sampler(ast::SamplerKind::kComparisonSampler);
|
||||
auto* t = ty.depth_texture(ast::TextureDimension::k2d);
|
||||
|
||||
auto* tex = Global("texture", t, ast::StorageClass::kNone, nullptr,
|
||||
{
|
||||
|
|
|
@ -830,8 +830,8 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
|
||||
auto s = ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Float);
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Float);
|
||||
auto* ac = ty.access(ast::AccessControl::kReadOnly, s);
|
||||
|
||||
Global("test_var", ac, ast::StorageClass::kNone, nullptr,
|
||||
|
@ -850,8 +850,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
|
||||
auto s = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Float);
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Float);
|
||||
auto* ac = ty.access(ast::AccessControl::kReadOnly, s);
|
||||
|
||||
Global("test_var", ac, ast::StorageClass::kNone, nullptr,
|
||||
|
@ -870,8 +870,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
|
||||
auto s = ty.storage_texture(ast::TextureDimension::k2dArray,
|
||||
ast::ImageFormat::kR32Float);
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k2dArray,
|
||||
ast::ImageFormat::kR32Float);
|
||||
auto* ac = ty.access(ast::AccessControl::kReadOnly, s);
|
||||
|
||||
Global("test_var", ac, ast::StorageClass::kNone, nullptr,
|
||||
|
@ -890,8 +890,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
|
||||
auto s = ty.storage_texture(ast::TextureDimension::k3d,
|
||||
ast::ImageFormat::kR32Float);
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k3d,
|
||||
ast::ImageFormat::kR32Float);
|
||||
auto* ac = ty.access(ast::AccessControl::kReadOnly, s);
|
||||
|
||||
Global("test_var", ac, ast::StorageClass::kNone, nullptr,
|
||||
|
@ -911,8 +911,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
|
|||
|
||||
TEST_F(BuilderTest_Type,
|
||||
StorageTexture_Generate_SampledTypeFloat_Format_r32float) {
|
||||
auto s = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Float);
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Float);
|
||||
auto* ac = ty.access(ast::AccessControl::kReadOnly, s);
|
||||
|
||||
Global("test_var", ac, ast::StorageClass::kNone, nullptr,
|
||||
|
@ -932,8 +932,8 @@ TEST_F(BuilderTest_Type,
|
|||
|
||||
TEST_F(BuilderTest_Type,
|
||||
StorageTexture_Generate_SampledTypeSint_Format_r32sint) {
|
||||
auto s = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Sint);
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Sint);
|
||||
auto* ac = ty.access(ast::AccessControl::kReadOnly, s);
|
||||
|
||||
Global("test_var", ac, ast::StorageClass::kNone, nullptr,
|
||||
|
@ -953,8 +953,8 @@ TEST_F(BuilderTest_Type,
|
|||
|
||||
TEST_F(BuilderTest_Type,
|
||||
StorageTexture_Generate_SampledTypeUint_Format_r32uint) {
|
||||
auto s = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
auto* ac = ty.access(ast::AccessControl::kReadOnly, s);
|
||||
|
||||
Global("test_var", ac, ast::StorageClass::kNone, nullptr,
|
||||
|
|
|
@ -110,7 +110,7 @@ TEST_F(WgslGeneratorImplTest,
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_Function_EntryPoint_Parameters) {
|
||||
auto vec4 = ty.vec4<f32>();
|
||||
auto* vec4 = ty.vec4<f32>();
|
||||
auto* coord = Param("coord", vec4, {Builtin(ast::Builtin::kPosition)});
|
||||
auto* loc1 = Param("loc1", ty.f32(), {Location(1u)});
|
||||
auto* func = Func("frag_main", ast::VariableList{coord, loc1}, ty.void_(),
|
||||
|
|
|
@ -113,7 +113,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_Global_Texture) {
|
||||
auto st = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
auto* st = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
Global("t", ty.access(ast::AccessControl::kReadOnly, st),
|
||||
ast::StorageClass::kNone, nullptr,
|
||||
{create<ast::GroupDecoration>(0), create<ast::BindingDecoration>(0)});
|
||||
|
|
|
@ -92,7 +92,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Bool) {
|
||||
auto bool_ = ty.bool_();
|
||||
auto* bool_ = ty.bool_();
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", bool_));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -102,7 +102,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Bool) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_F32) {
|
||||
auto f32 = ty.f32();
|
||||
auto* f32 = ty.f32();
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", f32));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -112,7 +112,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_F32) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_I32) {
|
||||
auto i32 = ty.i32();
|
||||
auto* i32 = ty.i32();
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", i32));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -122,7 +122,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_I32) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Matrix) {
|
||||
auto mat2x3 = ty.mat2x3<f32>();
|
||||
auto* mat2x3 = ty.mat2x3<f32>();
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", mat2x3));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -132,7 +132,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Matrix) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Pointer) {
|
||||
auto p = ty.pointer<f32>(ast::StorageClass::kWorkgroup);
|
||||
auto* p = ty.pointer<f32>(ast::StorageClass::kWorkgroup);
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", p));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -275,7 +275,7 @@ struct S {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_U32) {
|
||||
auto u32 = ty.u32();
|
||||
auto* u32 = ty.u32();
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -284,7 +284,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_U32) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Vector) {
|
||||
auto vec3 = ty.vec3<f32>();
|
||||
auto* vec3 = ty.vec3<f32>();
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", vec3));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -306,7 +306,7 @@ using WgslGenerator_DepthTextureTest = TestParamHelper<TextureData>;
|
|||
TEST_P(WgslGenerator_DepthTextureTest, EmitType_DepthTexture) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto d = ty.depth_texture(param.dim);
|
||||
auto* d = ty.depth_texture(param.dim);
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", d));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -328,7 +328,7 @@ using WgslGenerator_SampledTextureTest = TestParamHelper<TextureData>;
|
|||
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_F32) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto t = ty.sampled_texture(param.dim, ty.f32());
|
||||
auto* t = ty.sampled_texture(param.dim, ty.f32());
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", t));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -340,7 +340,7 @@ TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_F32) {
|
|||
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_I32) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto t = ty.sampled_texture(param.dim, ty.i32());
|
||||
auto* t = ty.sampled_texture(param.dim, ty.i32());
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", t));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -352,7 +352,7 @@ TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_I32) {
|
|||
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_U32) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto t = ty.sampled_texture(param.dim, ty.u32());
|
||||
auto* t = ty.sampled_texture(param.dim, ty.u32());
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", t));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -375,7 +375,7 @@ using WgslGenerator_MultiampledTextureTest = TestParamHelper<TextureData>;
|
|||
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto t = ty.multisampled_texture(param.dim, ty.f32());
|
||||
auto* t = ty.multisampled_texture(param.dim, ty.f32());
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", t));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -387,7 +387,7 @@ TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) {
|
|||
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_I32) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto t = ty.multisampled_texture(param.dim, ty.i32());
|
||||
auto* t = ty.multisampled_texture(param.dim, ty.i32());
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", t));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -399,7 +399,7 @@ TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_I32) {
|
|||
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_U32) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto t = ty.multisampled_texture(param.dim, ty.u32());
|
||||
auto* t = ty.multisampled_texture(param.dim, ty.u32());
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", t));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -427,7 +427,7 @@ using WgslGenerator_StorageTextureTest = TestParamHelper<StorageTextureData>;
|
|||
TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto t = ty.storage_texture(param.dim, param.fmt);
|
||||
auto* t = ty.storage_texture(param.dim, param.fmt);
|
||||
auto* ac = ty.access(param.access, t);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -531,7 +531,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
ImageFormatData{ast::ImageFormat::kRgba32Float, "rgba32float"}));
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Sampler) {
|
||||
auto sampler = ty.sampler(ast::SamplerKind::kSampler);
|
||||
auto* sampler = ty.sampler(ast::SamplerKind::kSampler);
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", sampler));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -541,7 +541,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Sampler) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_SamplerComparison) {
|
||||
auto sampler = ty.sampler(ast::SamplerKind::kComparisonSampler);
|
||||
auto* sampler = ty.sampler(ast::SamplerKind::kComparisonSampler);
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", sampler));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
|
Loading…
Reference in New Issue