Resolver: Add ast -> sem type resolving

Not currently called (nothing currently attaches ast::Type nodes to the AST), but implements some of the boilerplate that'll be shortly required.

This change also removes a bunch of duplicated enumerators from the sem namespace for their counterpart in the ast namespace.

Bug: tint:724
Change-Id: I0372a9f4eca2f9357ff161e7ec1b67eae1c4c8f6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48603
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Ben Clayton 2021-04-21 13:47:12 +00:00 committed by Commit Bot service account
parent a922e65d72
commit fec63b7aa6
62 changed files with 1405 additions and 1591 deletions

File diff suppressed because it is too large Load Diff

View File

@ -176,8 +176,8 @@ struct TextureOverloadCase {
TextureOverloadCase(ValidTextureOverload,
const char*,
TextureKind,
sem::SamplerKind,
sem::TextureDimension,
ast::SamplerKind,
ast::TextureDimension,
TextureDataType,
const char*,
std::function<ExpressionList(ProgramBuilder*)>);
@ -185,7 +185,7 @@ struct TextureOverloadCase {
TextureOverloadCase(ValidTextureOverload,
const char*,
TextureKind,
sem::TextureDimension,
ast::TextureDimension,
TextureDataType,
const char*,
std::function<ExpressionList(ProgramBuilder*)>);
@ -193,8 +193,8 @@ struct TextureOverloadCase {
TextureOverloadCase(ValidTextureOverload,
const char*,
AccessControl::Access,
sem::ImageFormat,
sem::TextureDimension,
ast::ImageFormat,
ast::TextureDimension,
TextureDataType,
const char*,
std::function<ExpressionList(ProgramBuilder*)>);
@ -227,15 +227,15 @@ struct TextureOverloadCase {
TextureKind const texture_kind;
/// The sampler kind for the sampler parameter
/// Used only when texture_kind is not kStorage
sem::SamplerKind const sampler_kind = sem::SamplerKind::kSampler;
ast::SamplerKind const sampler_kind = ast::SamplerKind::kSampler;
/// The access control for the storage texture
/// Used only when texture_kind is kStorage
AccessControl::Access const access_control = AccessControl::kReadWrite;
/// The image format for the storage texture
/// Used only when texture_kind is kStorage
sem::ImageFormat const image_format = sem::ImageFormat::kNone;
ast::ImageFormat const image_format = ast::ImageFormat::kNone;
/// The dimensions of the texture parameter
sem::TextureDimension const texture_dimension;
ast::TextureDimension const texture_dimension;
/// The data type of the texture parameter
TextureDataType const texture_data_type;
/// Name of the function. e.g. `textureSample`, `textureSampleGrad`, etc

View File

@ -57,21 +57,21 @@ void AppendResourceBindings(std::vector<ResourceBinding>* dest,
ResourceBinding::TextureDimension
TypeTextureDimensionToResourceBindingTextureDimension(
const sem::TextureDimension& type_dim) {
const ast::TextureDimension& type_dim) {
switch (type_dim) {
case sem::TextureDimension::k1d:
case ast::TextureDimension::k1d:
return ResourceBinding::TextureDimension::k1d;
case sem::TextureDimension::k2d:
case ast::TextureDimension::k2d:
return ResourceBinding::TextureDimension::k2d;
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2dArray:
return ResourceBinding::TextureDimension::k2dArray;
case sem::TextureDimension::k3d:
case ast::TextureDimension::k3d:
return ResourceBinding::TextureDimension::k3d;
case sem::TextureDimension::kCube:
case ast::TextureDimension::kCube:
return ResourceBinding::TextureDimension::kCube;
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::kCubeArray:
return ResourceBinding::TextureDimension::kCubeArray;
case sem::TextureDimension::kNone:
case ast::TextureDimension::kNone:
return ResourceBinding::TextureDimension::kNone;
}
return ResourceBinding::TextureDimension::kNone;
@ -102,79 +102,79 @@ ResourceBinding::SampledKind BaseTypeToSampledKind(sem::Type* base_type) {
}
ResourceBinding::ImageFormat TypeImageFormatToResourceBindingImageFormat(
const sem::ImageFormat& image_format) {
const ast::ImageFormat& image_format) {
switch (image_format) {
case sem::ImageFormat::kR8Unorm:
case ast::ImageFormat::kR8Unorm:
return ResourceBinding::ImageFormat::kR8Unorm;
case sem::ImageFormat::kR8Snorm:
case ast::ImageFormat::kR8Snorm:
return ResourceBinding::ImageFormat::kR8Snorm;
case sem::ImageFormat::kR8Uint:
case ast::ImageFormat::kR8Uint:
return ResourceBinding::ImageFormat::kR8Uint;
case sem::ImageFormat::kR8Sint:
case ast::ImageFormat::kR8Sint:
return ResourceBinding::ImageFormat::kR8Sint;
case sem::ImageFormat::kR16Uint:
case ast::ImageFormat::kR16Uint:
return ResourceBinding::ImageFormat::kR16Uint;
case sem::ImageFormat::kR16Sint:
case ast::ImageFormat::kR16Sint:
return ResourceBinding::ImageFormat::kR16Sint;
case sem::ImageFormat::kR16Float:
case ast::ImageFormat::kR16Float:
return ResourceBinding::ImageFormat::kR16Float;
case sem::ImageFormat::kRg8Unorm:
case ast::ImageFormat::kRg8Unorm:
return ResourceBinding::ImageFormat::kRg8Unorm;
case sem::ImageFormat::kRg8Snorm:
case ast::ImageFormat::kRg8Snorm:
return ResourceBinding::ImageFormat::kRg8Snorm;
case sem::ImageFormat::kRg8Uint:
case ast::ImageFormat::kRg8Uint:
return ResourceBinding::ImageFormat::kRg8Uint;
case sem::ImageFormat::kRg8Sint:
case ast::ImageFormat::kRg8Sint:
return ResourceBinding::ImageFormat::kRg8Sint;
case sem::ImageFormat::kR32Uint:
case ast::ImageFormat::kR32Uint:
return ResourceBinding::ImageFormat::kR32Uint;
case sem::ImageFormat::kR32Sint:
case ast::ImageFormat::kR32Sint:
return ResourceBinding::ImageFormat::kR32Sint;
case sem::ImageFormat::kR32Float:
case ast::ImageFormat::kR32Float:
return ResourceBinding::ImageFormat::kR32Float;
case sem::ImageFormat::kRg16Uint:
case ast::ImageFormat::kRg16Uint:
return ResourceBinding::ImageFormat::kRg16Uint;
case sem::ImageFormat::kRg16Sint:
case ast::ImageFormat::kRg16Sint:
return ResourceBinding::ImageFormat::kRg16Sint;
case sem::ImageFormat::kRg16Float:
case ast::ImageFormat::kRg16Float:
return ResourceBinding::ImageFormat::kRg16Float;
case sem::ImageFormat::kRgba8Unorm:
case ast::ImageFormat::kRgba8Unorm:
return ResourceBinding::ImageFormat::kRgba8Unorm;
case sem::ImageFormat::kRgba8UnormSrgb:
case ast::ImageFormat::kRgba8UnormSrgb:
return ResourceBinding::ImageFormat::kRgba8UnormSrgb;
case sem::ImageFormat::kRgba8Snorm:
case ast::ImageFormat::kRgba8Snorm:
return ResourceBinding::ImageFormat::kRgba8Snorm;
case sem::ImageFormat::kRgba8Uint:
case ast::ImageFormat::kRgba8Uint:
return ResourceBinding::ImageFormat::kRgba8Uint;
case sem::ImageFormat::kRgba8Sint:
case ast::ImageFormat::kRgba8Sint:
return ResourceBinding::ImageFormat::kRgba8Sint;
case sem::ImageFormat::kBgra8Unorm:
case ast::ImageFormat::kBgra8Unorm:
return ResourceBinding::ImageFormat::kBgra8Unorm;
case sem::ImageFormat::kBgra8UnormSrgb:
case ast::ImageFormat::kBgra8UnormSrgb:
return ResourceBinding::ImageFormat::kBgra8UnormSrgb;
case sem::ImageFormat::kRgb10A2Unorm:
case ast::ImageFormat::kRgb10A2Unorm:
return ResourceBinding::ImageFormat::kRgb10A2Unorm;
case sem::ImageFormat::kRg11B10Float:
case ast::ImageFormat::kRg11B10Float:
return ResourceBinding::ImageFormat::kRg11B10Float;
case sem::ImageFormat::kRg32Uint:
case ast::ImageFormat::kRg32Uint:
return ResourceBinding::ImageFormat::kRg32Uint;
case sem::ImageFormat::kRg32Sint:
case ast::ImageFormat::kRg32Sint:
return ResourceBinding::ImageFormat::kRg32Sint;
case sem::ImageFormat::kRg32Float:
case ast::ImageFormat::kRg32Float:
return ResourceBinding::ImageFormat::kRg32Float;
case sem::ImageFormat::kRgba16Uint:
case ast::ImageFormat::kRgba16Uint:
return ResourceBinding::ImageFormat::kRgba16Uint;
case sem::ImageFormat::kRgba16Sint:
case ast::ImageFormat::kRgba16Sint:
return ResourceBinding::ImageFormat::kRgba16Sint;
case sem::ImageFormat::kRgba16Float:
case ast::ImageFormat::kRgba16Float:
return ResourceBinding::ImageFormat::kRgba16Float;
case sem::ImageFormat::kRgba32Uint:
case ast::ImageFormat::kRgba32Uint:
return ResourceBinding::ImageFormat::kRgba32Uint;
case sem::ImageFormat::kRgba32Sint:
case ast::ImageFormat::kRgba32Sint:
return ResourceBinding::ImageFormat::kRgba32Sint;
case sem::ImageFormat::kRgba32Float:
case ast::ImageFormat::kRgba32Float:
return ResourceBinding::ImageFormat::kRgba32Float;
case sem::ImageFormat::kNone:
case ast::ImageFormat::kNone:
return ResourceBinding::ImageFormat::kNone;
}
return ResourceBinding::ImageFormat::kNone;

View File

@ -30,8 +30,8 @@ namespace {
class InspectorHelper : public ProgramBuilder {
public:
InspectorHelper()
: sampler_type_(sem::SamplerKind::kSampler),
comparison_sampler_type_(sem::SamplerKind::kComparisonSampler) {}
: sampler_type_(ast::SamplerKind::kSampler),
comparison_sampler_type_(ast::SamplerKind::kComparisonSampler) {}
/// Generates an empty function
/// @param name name of the function created
@ -374,7 +374,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
sem::SampledTexture* MakeSampledTextureType(sem::TextureDimension dim,
sem::SampledTexture* MakeSampledTextureType(ast::TextureDimension dim,
sem::Type* type) {
return create<sem::SampledTexture>(dim, type);
}
@ -382,7 +382,7 @@ class InspectorHelper : public ProgramBuilder {
/// Generates a DepthTexture appropriate for the params
/// @param dim the dimensions of the texture
/// @returns the generated DepthTexture
sem::DepthTexture* MakeDepthTextureType(sem::TextureDimension dim) {
sem::DepthTexture* MakeDepthTextureType(ast::TextureDimension dim) {
return create<sem::DepthTexture>(dim);
}
@ -391,7 +391,7 @@ class InspectorHelper : public ProgramBuilder {
/// @param type the data type of the sampled texture
/// @returns the generated SampleTextureType
sem::MultisampledTexture* MakeMultisampledTextureType(
sem::TextureDimension dim,
ast::TextureDimension dim,
sem::Type* type) {
return create<sem::MultisampledTexture>(dim, type);
}
@ -552,16 +552,16 @@ class InspectorHelper : public ProgramBuilder {
/// @param dim dimensionality of the texture being sampled
/// @param scalar the scalar type
/// @returns a pointer to a type appropriate for the coord param
sem::Type* GetCoordsType(sem::TextureDimension dim, sem::Type* scalar) {
sem::Type* GetCoordsType(ast::TextureDimension dim, sem::Type* scalar) {
switch (dim) {
case sem::TextureDimension::k1d:
case ast::TextureDimension::k1d:
return scalar;
case sem::TextureDimension::k2d:
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2d:
case ast::TextureDimension::k2dArray:
return create<sem::Vector>(scalar, 2);
case sem::TextureDimension::k3d:
case sem::TextureDimension::kCube:
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::k3d:
case ast::TextureDimension::kCube:
case ast::TextureDimension::kCubeArray:
return create<sem::Vector>(scalar, 3);
default:
[=]() { FAIL() << "Unsupported texture dimension: " << dim; }();
@ -574,8 +574,8 @@ class InspectorHelper : public ProgramBuilder {
/// @param format the image format of the storage texture
/// @returns the storage texture type and subtype
std::tuple<sem::StorageTexture*, sem::Type*> MakeStorageTextureTypes(
sem::TextureDimension dim,
sem::ImageFormat format) {
ast::TextureDimension dim,
ast::ImageFormat format) {
sem::Type* subtype = sem::StorageTexture::SubtypeFor(format, Types());
return {create<sem::StorageTexture>(dim, format, subtype), subtype};
}
@ -586,8 +586,8 @@ class InspectorHelper : public ProgramBuilder {
/// @param read_only should the access type be read only, otherwise write only
/// @returns the storage texture type, subtype & access control type
std::tuple<sem::StorageTexture*, sem::Type*, sem::AccessControl*>
MakeStorageTextureTypes(sem::TextureDimension dim,
sem::ImageFormat format,
MakeStorageTextureTypes(ast::TextureDimension dim,
ast::ImageFormat format,
bool read_only) {
sem::StorageTexture* texture_type;
sem::Type* subtype;
@ -705,7 +705,7 @@ class InspectorGetSampledArrayTextureResourceBindingsTest
: public InspectorHelper,
public testing::Test {};
struct GetSampledTextureTestParams {
sem::TextureDimension type_dim;
ast::TextureDimension type_dim;
inspector::ResourceBinding::TextureDimension inspector_dim;
inspector::ResourceBinding::SampledKind sampled_kind;
};
@ -731,16 +731,16 @@ class InspectorGetMultisampledTextureResourceBindingsTestWithParam
class InspectorGetStorageTextureResourceBindingsTest : public InspectorHelper,
public testing::Test {};
struct GetDepthTextureTestParams {
sem::TextureDimension type_dim;
ast::TextureDimension type_dim;
inspector::ResourceBinding::TextureDimension inspector_dim;
};
class InspectorGetDepthTextureResourceBindingsTestWithParam
: public InspectorHelper,
public testing::TestWithParam<GetDepthTextureTestParams> {};
typedef std::tuple<sem::TextureDimension, ResourceBinding::TextureDimension>
typedef std::tuple<ast::TextureDimension, ResourceBinding::TextureDimension>
DimensionParams;
typedef std::tuple<sem::ImageFormat,
typedef std::tuple<ast::ImageFormat,
ResourceBinding::ImageFormat,
ResourceBinding::SampledKind>
ImageFormatParams;
@ -1702,7 +1702,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
{{0, ty.i32()}});
auto* s_texture_type =
MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
AddSampledTexture("s_texture", s_texture_type, 2, 0);
AddSampler("s_var", 3, 0);
AddGlobalVariable("s_coords", ty.f32());
@ -1710,7 +1710,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
ty.f32(), {});
auto* cs_depth_texture_type =
MakeDepthTextureType(sem::TextureDimension::k2d);
MakeDepthTextureType(ast::TextureDimension::k2d);
AddDepthTexture("cs_texture", cs_depth_texture_type, 3, 1);
AddComparisonSampler("cs_var", 3, 2);
AddGlobalVariable("cs_coords", ty.vec2<f32>());
@ -1722,7 +1722,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
sem::Type* st_subtype;
sem::AccessControl* st_ac;
std::tie(st_type, st_subtype, st_ac) = MakeStorageTextureTypes(
sem::TextureDimension::k2d, sem::ImageFormat::kR32Uint, false);
ast::TextureDimension::k2d, ast::ImageFormat::kR32Uint, false);
AddStorageTexture("st_var", st_ac, 4, 0);
MakeStorageTextureBodyFunction("st_func", "st_var", ty.vec2<i32>(), {});
@ -1730,7 +1730,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
sem::Type* rost_subtype;
sem::AccessControl* rost_ac;
std::tie(rost_type, rost_subtype, rost_ac) = MakeStorageTextureTypes(
sem::TextureDimension::k2d, sem::ImageFormat::kR32Uint, true);
ast::TextureDimension::k2d, ast::ImageFormat::kR32Uint, true);
AddStorageTexture("rost_var", rost_ac, 4, 1);
MakeStorageTextureBodyFunction("rost_func", "rost_var", ty.vec2<i32>(), {});
@ -2420,7 +2420,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) {
auto* sampled_texture_type =
MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
AddSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32());
@ -2458,7 +2458,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, NoSampler) {
TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
auto* sampled_texture_type =
MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
AddSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32());
@ -2485,7 +2485,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
auto* sampled_texture_type =
MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
AddSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32());
@ -2503,7 +2503,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
}
TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
auto* depth_texture_type = MakeDepthTextureType(sem::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>());
@ -2524,7 +2524,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
}
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) {
auto* depth_texture_type = MakeDepthTextureType(sem::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>());
@ -2563,7 +2563,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, NoSampler) {
}
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
auto* depth_texture_type = MakeDepthTextureType(sem::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>());
@ -2592,7 +2592,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
}
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
auto* depth_texture_type = MakeDepthTextureType(sem::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>());
@ -2612,7 +2612,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) {
auto* sampled_texture_type =
MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
AddSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32());
@ -2686,19 +2686,19 @@ INSTANTIATE_TEST_SUITE_P(
InspectorGetSampledTextureResourceBindingsTestWithParam,
testing::Values(
GetSampledTextureTestParams{
sem::TextureDimension::k1d,
ast::TextureDimension::k1d,
inspector::ResourceBinding::TextureDimension::k1d,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
sem::TextureDimension::k2d,
ast::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
sem::TextureDimension::k3d,
ast::TextureDimension::k3d,
inspector::ResourceBinding::TextureDimension::k3d,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
sem::TextureDimension::kCube,
ast::TextureDimension::kCube,
inspector::ResourceBinding::TextureDimension::kCube,
inspector::ResourceBinding::SampledKind::kFloat}));
@ -2738,11 +2738,11 @@ INSTANTIATE_TEST_SUITE_P(
InspectorGetSampledArrayTextureResourceBindingsTestWithParam,
testing::Values(
GetSampledTextureTestParams{
sem::TextureDimension::k2dArray,
ast::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
sem::TextureDimension::kCubeArray,
ast::TextureDimension::kCubeArray,
inspector::ResourceBinding::TextureDimension::kCubeArray,
inspector::ResourceBinding::SampledKind::kFloat}));
@ -2790,15 +2790,15 @@ INSTANTIATE_TEST_SUITE_P(
InspectorGetMultisampledTextureResourceBindingsTestWithParam,
testing::Values(
GetMultisampledTextureTestParams{
sem::TextureDimension::k2d,
ast::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kFloat},
GetMultisampledTextureTestParams{
sem::TextureDimension::k2d,
ast::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kSInt},
GetMultisampledTextureTestParams{
sem::TextureDimension::k2d,
ast::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kUInt}));
@ -2852,15 +2852,15 @@ INSTANTIATE_TEST_SUITE_P(
InspectorGetMultisampledArrayTextureResourceBindingsTestWithParam,
testing::Values(
GetMultisampledTextureTestParams{
sem::TextureDimension::k2dArray,
ast::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kFloat},
GetMultisampledTextureTestParams{
sem::TextureDimension::k2dArray,
ast::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kSInt},
GetMultisampledTextureTestParams{
sem::TextureDimension::k2dArray,
ast::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kUInt}));
@ -2887,11 +2887,11 @@ TEST_P(InspectorGetStorageTextureResourceBindingsTestWithParam, Simple) {
ImageFormatParams format_params;
std::tie(read_only, dim_params, format_params) = GetParam();
sem::TextureDimension dim;
ast::TextureDimension dim;
ResourceBinding::TextureDimension expected_dim;
std::tie(dim, expected_dim) = dim_params;
sem::ImageFormat format;
ast::ImageFormat format;
ResourceBinding::ImageFormat expected_format;
ResourceBinding::SampledKind expected_kind;
std::tie(format, expected_format, expected_kind) = format_params;
@ -2905,14 +2905,14 @@ TEST_P(InspectorGetStorageTextureResourceBindingsTestWithParam, Simple) {
sem::Type* dim_type = nullptr;
switch (dim) {
case sem::TextureDimension::k1d:
case ast::TextureDimension::k1d:
dim_type = ty.i32();
break;
case sem::TextureDimension::k2d:
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2d:
case ast::TextureDimension::k2dArray:
dim_type = ty.vec2<i32>();
break;
case sem::TextureDimension::k3d:
case ast::TextureDimension::k3d:
dim_type = ty.vec3<i32>();
break;
default:
@ -2956,61 +2956,61 @@ INSTANTIATE_TEST_SUITE_P(
testing::Combine(
testing::Bool(),
testing::Values(
std::make_tuple(sem::TextureDimension::k1d,
std::make_tuple(ast::TextureDimension::k1d,
ResourceBinding::TextureDimension::k1d),
std::make_tuple(sem::TextureDimension::k2d,
std::make_tuple(ast::TextureDimension::k2d,
ResourceBinding::TextureDimension::k2d),
std::make_tuple(sem::TextureDimension::k2dArray,
std::make_tuple(ast::TextureDimension::k2dArray,
ResourceBinding::TextureDimension::k2dArray),
std::make_tuple(sem::TextureDimension::k3d,
std::make_tuple(ast::TextureDimension::k3d,
ResourceBinding::TextureDimension::k3d)),
testing::Values(
std::make_tuple(sem::ImageFormat::kR32Float,
std::make_tuple(ast::ImageFormat::kR32Float,
ResourceBinding::ImageFormat::kR32Float,
ResourceBinding::SampledKind::kFloat),
std::make_tuple(sem::ImageFormat::kR32Sint,
std::make_tuple(ast::ImageFormat::kR32Sint,
ResourceBinding::ImageFormat::kR32Sint,
ResourceBinding::SampledKind::kSInt),
std::make_tuple(sem::ImageFormat::kR32Uint,
std::make_tuple(ast::ImageFormat::kR32Uint,
ResourceBinding::ImageFormat::kR32Uint,
ResourceBinding::SampledKind::kUInt),
std::make_tuple(sem::ImageFormat::kRg32Float,
std::make_tuple(ast::ImageFormat::kRg32Float,
ResourceBinding::ImageFormat::kRg32Float,
ResourceBinding::SampledKind::kFloat),
std::make_tuple(sem::ImageFormat::kRg32Sint,
std::make_tuple(ast::ImageFormat::kRg32Sint,
ResourceBinding::ImageFormat::kRg32Sint,
ResourceBinding::SampledKind::kSInt),
std::make_tuple(sem::ImageFormat::kRg32Uint,
std::make_tuple(ast::ImageFormat::kRg32Uint,
ResourceBinding::ImageFormat::kRg32Uint,
ResourceBinding::SampledKind::kUInt),
std::make_tuple(sem::ImageFormat::kRgba16Float,
std::make_tuple(ast::ImageFormat::kRgba16Float,
ResourceBinding::ImageFormat::kRgba16Float,
ResourceBinding::SampledKind::kFloat),
std::make_tuple(sem::ImageFormat::kRgba16Sint,
std::make_tuple(ast::ImageFormat::kRgba16Sint,
ResourceBinding::ImageFormat::kRgba16Sint,
ResourceBinding::SampledKind::kSInt),
std::make_tuple(sem::ImageFormat::kRgba16Uint,
std::make_tuple(ast::ImageFormat::kRgba16Uint,
ResourceBinding::ImageFormat::kRgba16Uint,
ResourceBinding::SampledKind::kUInt),
std::make_tuple(sem::ImageFormat::kRgba32Float,
std::make_tuple(ast::ImageFormat::kRgba32Float,
ResourceBinding::ImageFormat::kRgba32Float,
ResourceBinding::SampledKind::kFloat),
std::make_tuple(sem::ImageFormat::kRgba32Sint,
std::make_tuple(ast::ImageFormat::kRgba32Sint,
ResourceBinding::ImageFormat::kRgba32Sint,
ResourceBinding::SampledKind::kSInt),
std::make_tuple(sem::ImageFormat::kRgba32Uint,
std::make_tuple(ast::ImageFormat::kRgba32Uint,
ResourceBinding::ImageFormat::kRgba32Uint,
ResourceBinding::SampledKind::kUInt),
std::make_tuple(sem::ImageFormat::kRgba8Sint,
std::make_tuple(ast::ImageFormat::kRgba8Sint,
ResourceBinding::ImageFormat::kRgba8Sint,
ResourceBinding::SampledKind::kSInt),
std::make_tuple(sem::ImageFormat::kRgba8Snorm,
std::make_tuple(ast::ImageFormat::kRgba8Snorm,
ResourceBinding::ImageFormat::kRgba8Snorm,
ResourceBinding::SampledKind::kFloat),
std::make_tuple(sem::ImageFormat::kRgba8Uint,
std::make_tuple(ast::ImageFormat::kRgba8Uint,
ResourceBinding::ImageFormat::kRgba8Uint,
ResourceBinding::SampledKind::kUInt),
std::make_tuple(sem::ImageFormat::kRgba8Unorm,
std::make_tuple(ast::ImageFormat::kRgba8Unorm,
ResourceBinding::ImageFormat::kRgba8Unorm,
ResourceBinding::SampledKind::kFloat))));
@ -3047,16 +3047,16 @@ INSTANTIATE_TEST_SUITE_P(
InspectorGetDepthTextureResourceBindingsTestWithParam,
testing::Values(
GetDepthTextureTestParams{
sem::TextureDimension::k2d,
ast::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d},
GetDepthTextureTestParams{
sem::TextureDimension::k2dArray,
ast::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray},
GetDepthTextureTestParams{
sem::TextureDimension::kCube,
ast::TextureDimension::kCube,
inspector::ResourceBinding::TextureDimension::kCube},
GetDepthTextureTestParams{
sem::TextureDimension::kCubeArray,
ast::TextureDimension::kCubeArray,
inspector::ResourceBinding::TextureDimension::kCubeArray}));
} // namespace

View File

@ -428,7 +428,7 @@ class ArrayBuilder : public Builder {
/// SampledTextureBuilder is a Matcher / Builder for sampled texture types.
class SampledTextureBuilder : public Builder {
public:
explicit SampledTextureBuilder(sem::TextureDimension dimensions,
explicit SampledTextureBuilder(ast::TextureDimension dimensions,
Builder* type_builder)
: dimensions_(dimensions), type_builder_(type_builder) {}
@ -453,7 +453,7 @@ class SampledTextureBuilder : public Builder {
}
private:
sem::TextureDimension const dimensions_;
ast::TextureDimension const dimensions_;
Builder* const type_builder_;
};
@ -461,7 +461,7 @@ class SampledTextureBuilder : public Builder {
/// types.
class MultisampledTextureBuilder : public Builder {
public:
explicit MultisampledTextureBuilder(sem::TextureDimension dimensions,
explicit MultisampledTextureBuilder(ast::TextureDimension dimensions,
Builder* type_builder)
: dimensions_(dimensions), type_builder_(type_builder) {}
@ -487,14 +487,14 @@ class MultisampledTextureBuilder : public Builder {
}
private:
sem::TextureDimension const dimensions_;
ast::TextureDimension const dimensions_;
Builder* const type_builder_;
};
/// DepthTextureBuilder is a Matcher / Builder for depth texture types.
class DepthTextureBuilder : public Builder {
public:
explicit DepthTextureBuilder(sem::TextureDimension dimensions)
explicit DepthTextureBuilder(ast::TextureDimension dimensions)
: dimensions_(dimensions) {}
bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
@ -515,7 +515,7 @@ class DepthTextureBuilder : public Builder {
}
private:
sem::TextureDimension const dimensions_;
ast::TextureDimension const dimensions_;
};
/// StorageTextureBuilder is a Matcher / Builder for storage texture types of
@ -523,7 +523,7 @@ class DepthTextureBuilder : public Builder {
class StorageTextureBuilder : public Builder {
public:
explicit StorageTextureBuilder(
sem::TextureDimension dimensions,
ast::TextureDimension dimensions,
OpenNumber texel_format, // a.k.a "image format"
OpenType channel_format) // a.k.a "storage subtype"
: dimensions_(dimensions),
@ -552,7 +552,7 @@ class StorageTextureBuilder : public Builder {
sem::Type* Build(BuildState& state) const override {
auto texel_format =
static_cast<sem::ImageFormat>(state.open_numbers.at(texel_format_));
static_cast<ast::ImageFormat>(state.open_numbers.at(texel_format_));
auto* channel_format = state.open_types.at(channel_format_);
return state.ty_mgr.Get<sem::StorageTexture>(dimensions_, texel_format,
channel_format);
@ -565,7 +565,7 @@ class StorageTextureBuilder : public Builder {
}
private:
sem::TextureDimension const dimensions_;
ast::TextureDimension const dimensions_;
OpenNumber const texel_format_;
OpenType const channel_format_;
};
@ -573,7 +573,7 @@ class StorageTextureBuilder : public Builder {
/// SamplerBuilder is a Matcher / Builder for sampler types of the given kind.
class SamplerBuilder : public Builder {
public:
explicit SamplerBuilder(sem::SamplerKind kind) : kind_(kind) {}
explicit SamplerBuilder(ast::SamplerKind kind) : kind_(kind) {}
bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
if (auto* sampler = ty->As<sem::Sampler>()) {
@ -588,16 +588,16 @@ class SamplerBuilder : public Builder {
std::string str() const override {
switch (kind_) {
case sem::SamplerKind::kSampler:
case ast::SamplerKind::kSampler:
return "sampler";
case sem::SamplerKind::kComparisonSampler:
case ast::SamplerKind::kComparisonSampler:
return "sampler_comparison";
}
return "sampler";
}
private:
sem::SamplerKind const kind_;
ast::SamplerKind const kind_;
};
/// AccessControlBuilder is a Matcher / Builder for AccessControl types
@ -732,13 +732,13 @@ class Impl : public IntrinsicTable {
/// @returns a Matcher / Builder that matches a sampled texture with the given
/// dimensions and type
Builder* sampled_texture(sem::TextureDimension dimensions, Builder* type) {
Builder* sampled_texture(ast::TextureDimension dimensions, Builder* type) {
return matcher_allocator_.Create<SampledTextureBuilder>(dimensions, type);
}
/// @returns a Matcher / Builder that matches a multisampled texture with the
/// given dimensions and type
Builder* multisampled_texture(sem::TextureDimension dimensions,
Builder* multisampled_texture(ast::TextureDimension dimensions,
Builder* type) {
return matcher_allocator_.Create<MultisampledTextureBuilder>(dimensions,
type);
@ -746,13 +746,13 @@ class Impl : public IntrinsicTable {
/// @returns a Matcher / Builder that matches a depth texture with the
/// given dimensions
Builder* depth_texture(sem::TextureDimension dimensions) {
Builder* depth_texture(ast::TextureDimension dimensions) {
return matcher_allocator_.Create<DepthTextureBuilder>(dimensions);
}
/// @returns a Matcher / Builder that matches a storage texture of the given
/// format with the given dimensions
Builder* storage_texture(sem::TextureDimension dimensions,
Builder* storage_texture(ast::TextureDimension dimensions,
OpenNumber texel_format,
OpenType channel_format) {
return matcher_allocator_.Create<StorageTextureBuilder>(
@ -760,7 +760,7 @@ class Impl : public IntrinsicTable {
}
/// @returns a Matcher / Builder that matches a sampler type
Builder* sampler(sem::SamplerKind kind) {
Builder* sampler(ast::SamplerKind kind) {
return matcher_allocator_.Create<SamplerBuilder>(kind);
}
@ -797,7 +797,7 @@ class Impl : public IntrinsicTable {
Impl::Impl() {
using I = sem::IntrinsicType;
using Dim = sem::TextureDimension;
using Dim = ast::TextureDimension;
auto* void_ = &matchers_.void_; // void
auto* bool_ = &matchers_.bool_; // bool
@ -1115,9 +1115,9 @@ Impl::Impl() {
access_control(ast::AccessControl::kWriteOnly, tex_storage_2d_array_FT);
auto* tex_storage_wo_3d_FT =
access_control(ast::AccessControl::kWriteOnly, tex_storage_3d_FT);
auto* sampler = this->sampler(sem::SamplerKind::kSampler);
auto* sampler = this->sampler(ast::SamplerKind::kSampler);
auto* sampler_comparison =
this->sampler(sem::SamplerKind::kComparisonSampler);
this->sampler(ast::SamplerKind::kComparisonSampler);
auto t = sem::Parameter::Usage::kTexture;
auto s = sem::Parameter::Usage::kSampler;
auto coords = sem::Parameter::Usage::kCoords;

View File

@ -69,7 +69,7 @@ TEST_F(IntrinsicTableTest, MismatchU32) {
}
TEST_F(IntrinsicTableTest, MatchI32) {
auto* tex = create<sem::SampledTexture>(sem::TextureDimension::k1d, ty.f32());
auto* tex = create<sem::SampledTexture>(ast::TextureDimension::k1d, ty.f32());
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
{tex, ty.i32(), ty.i32()}, Source{});
ASSERT_NE(result.intrinsic, nullptr);
@ -83,7 +83,7 @@ TEST_F(IntrinsicTableTest, MatchI32) {
}
TEST_F(IntrinsicTableTest, MismatchI32) {
auto* tex = create<sem::SampledTexture>(sem::TextureDimension::k1d, ty.f32());
auto* tex = create<sem::SampledTexture>(ast::TextureDimension::k1d, ty.f32());
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
{tex, ty.f32()}, Source{});
ASSERT_EQ(result.intrinsic, nullptr);
@ -219,8 +219,8 @@ TEST_F(IntrinsicTableTest, MismatchArray) {
}
TEST_F(IntrinsicTableTest, MatchSampler) {
auto* tex = create<sem::SampledTexture>(sem::TextureDimension::k2d, ty.f32());
auto* sampler = create<sem::Sampler>(sem::SamplerKind::kSampler);
auto* tex = create<sem::SampledTexture>(ast::TextureDimension::k2d, ty.f32());
auto* sampler = create<sem::Sampler>(ast::SamplerKind::kSampler);
auto result = table->Lookup(*this, IntrinsicType::kTextureSample,
{tex, sampler, ty.vec2<f32>()}, Source{});
ASSERT_NE(result.intrinsic, nullptr);
@ -235,7 +235,7 @@ TEST_F(IntrinsicTableTest, MatchSampler) {
}
TEST_F(IntrinsicTableTest, MismatchSampler) {
auto* tex = create<sem::SampledTexture>(sem::TextureDimension::k2d, ty.f32());
auto* tex = create<sem::SampledTexture>(ast::TextureDimension::k2d, ty.f32());
auto result = table->Lookup(*this, IntrinsicType::kTextureSample,
{tex, ty.f32(), ty.vec2<f32>()}, Source{});
ASSERT_EQ(result.intrinsic, nullptr);
@ -243,7 +243,7 @@ TEST_F(IntrinsicTableTest, MismatchSampler) {
}
TEST_F(IntrinsicTableTest, MatchSampledTexture) {
auto* tex = create<sem::SampledTexture>(sem::TextureDimension::k2d, ty.f32());
auto* tex = create<sem::SampledTexture>(ast::TextureDimension::k2d, ty.f32());
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
{tex, ty.vec2<i32>(), ty.i32()}, Source{});
ASSERT_NE(result.intrinsic, nullptr);
@ -258,7 +258,7 @@ TEST_F(IntrinsicTableTest, MatchSampledTexture) {
TEST_F(IntrinsicTableTest, MatchMultisampledTexture) {
auto* tex =
create<sem::MultisampledTexture>(sem::TextureDimension::k2d, ty.f32());
create<sem::MultisampledTexture>(ast::TextureDimension::k2d, ty.f32());
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
{tex, ty.vec2<i32>(), ty.i32()}, Source{});
ASSERT_NE(result.intrinsic, nullptr);
@ -272,7 +272,7 @@ TEST_F(IntrinsicTableTest, MatchMultisampledTexture) {
}
TEST_F(IntrinsicTableTest, MatchDepthTexture) {
auto* tex = create<sem::DepthTexture>(sem::TextureDimension::k2d);
auto* tex = create<sem::DepthTexture>(ast::TextureDimension::k2d);
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
{tex, ty.vec2<i32>(), ty.i32()}, Source{});
ASSERT_NE(result.intrinsic, nullptr);
@ -287,8 +287,8 @@ TEST_F(IntrinsicTableTest, MatchDepthTexture) {
TEST_F(IntrinsicTableTest, MatchROStorageTexture) {
auto* tex = create<sem::StorageTexture>(
sem::TextureDimension::k2d, sem::ImageFormat::kR16Float,
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types()));
ast::TextureDimension::k2d, ast::ImageFormat::kR16Float,
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR16Float, Types()));
auto* tex_ac = create<sem::AccessControl>(ast::AccessControl::kReadOnly, tex);
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
{tex_ac, ty.vec2<i32>()}, Source{});
@ -304,8 +304,8 @@ TEST_F(IntrinsicTableTest, MatchROStorageTexture) {
TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
auto* tex = create<sem::StorageTexture>(
sem::TextureDimension::k2d, sem::ImageFormat::kR16Float,
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types()));
ast::TextureDimension::k2d, ast::ImageFormat::kR16Float,
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR16Float, Types()));
auto* tex_ac =
create<sem::AccessControl>(ast::AccessControl::kWriteOnly, tex);
auto result =
@ -464,7 +464,7 @@ TEST_F(IntrinsicTableTest, OverloadOrderByNumberOfParameters) {
}
TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) {
auto* tex = create<sem::DepthTexture>(sem::TextureDimension::k2d);
auto* tex = create<sem::DepthTexture>(ast::TextureDimension::k2d);
auto result = table->Lookup(*this, IntrinsicType::kTextureDimensions,
{tex, ty.bool_()}, Source{});
ASSERT_EQ(

View File

@ -100,83 +100,83 @@ ast::Builtin EnumConverter::ToBuiltin(SpvBuiltIn b) {
return ast::Builtin::kNone;
}
sem::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
ast::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
if (arrayed) {
switch (dim) {
case SpvDim2D:
return sem::TextureDimension::k2dArray;
return ast::TextureDimension::k2dArray;
case SpvDimCube:
return sem::TextureDimension::kCubeArray;
return ast::TextureDimension::kCubeArray;
default:
break;
}
Fail() << "arrayed dimension must be 1D, 2D, or Cube. Got " << int(dim);
return sem::TextureDimension::kNone;
return ast::TextureDimension::kNone;
}
// Assume non-arrayed
switch (dim) {
case SpvDim1D:
return sem::TextureDimension::k1d;
return ast::TextureDimension::k1d;
case SpvDim2D:
return sem::TextureDimension::k2d;
return ast::TextureDimension::k2d;
case SpvDim3D:
return sem::TextureDimension::k3d;
return ast::TextureDimension::k3d;
case SpvDimCube:
return sem::TextureDimension::kCube;
return ast::TextureDimension::kCube;
default:
break;
}
Fail() << "invalid dimension: " << int(dim);
return sem::TextureDimension::kNone;
return ast::TextureDimension::kNone;
}
sem::ImageFormat EnumConverter::ToImageFormat(SpvImageFormat fmt) {
ast::ImageFormat EnumConverter::ToImageFormat(SpvImageFormat fmt) {
switch (fmt) {
case SpvImageFormatUnknown:
return sem::ImageFormat::kNone;
return ast::ImageFormat::kNone;
// 8 bit channels
case SpvImageFormatRgba8:
return sem::ImageFormat::kRgba8Unorm;
return ast::ImageFormat::kRgba8Unorm;
case SpvImageFormatRgba8Snorm:
return sem::ImageFormat::kRgba8Snorm;
return ast::ImageFormat::kRgba8Snorm;
case SpvImageFormatRgba8ui:
return sem::ImageFormat::kRgba8Uint;
return ast::ImageFormat::kRgba8Uint;
case SpvImageFormatRgba8i:
return sem::ImageFormat::kRgba8Sint;
return ast::ImageFormat::kRgba8Sint;
// 16 bit channels
case SpvImageFormatRgba16ui:
return sem::ImageFormat::kRgba16Uint;
return ast::ImageFormat::kRgba16Uint;
case SpvImageFormatRgba16i:
return sem::ImageFormat::kRgba16Sint;
return ast::ImageFormat::kRgba16Sint;
case SpvImageFormatRgba16f:
return sem::ImageFormat::kRgba16Float;
return ast::ImageFormat::kRgba16Float;
// 32 bit channels
case SpvImageFormatR32ui:
return sem::ImageFormat::kR32Uint;
return ast::ImageFormat::kR32Uint;
case SpvImageFormatR32i:
return sem::ImageFormat::kR32Sint;
return ast::ImageFormat::kR32Sint;
case SpvImageFormatR32f:
return sem::ImageFormat::kR32Float;
return ast::ImageFormat::kR32Float;
case SpvImageFormatRg32ui:
return sem::ImageFormat::kRg32Uint;
return ast::ImageFormat::kRg32Uint;
case SpvImageFormatRg32i:
return sem::ImageFormat::kRg32Sint;
return ast::ImageFormat::kRg32Sint;
case SpvImageFormatRg32f:
return sem::ImageFormat::kRg32Float;
return ast::ImageFormat::kRg32Float;
case SpvImageFormatRgba32ui:
return sem::ImageFormat::kRgba32Uint;
return ast::ImageFormat::kRgba32Uint;
case SpvImageFormatRgba32i:
return sem::ImageFormat::kRgba32Sint;
return ast::ImageFormat::kRgba32Sint;
case SpvImageFormatRgba32f:
return sem::ImageFormat::kRgba32Float;
return ast::ImageFormat::kRgba32Float;
default:
break;
}
Fail() << "invalid image format: " << int(fmt);
return sem::ImageFormat::kNone;
return ast::ImageFormat::kNone;
}
} // namespace spirv

View File

@ -58,13 +58,13 @@ class EnumConverter {
/// @param dim the SPIR-V Dim value
/// @param arrayed true if the texture is arrayed
/// @returns a Tint AST texture dimension
sem::TextureDimension ToDim(SpvDim dim, bool arrayed);
ast::TextureDimension ToDim(SpvDim dim, bool arrayed);
/// Converts a SPIR-V Image Format to a Tint ImageFormat
/// On failure, logs an error and returns kNone
/// @param fmt the SPIR-V format
/// @returns a Tint AST format
sem::ImageFormat ToImageFormat(SpvImageFormat fmt);
ast::ImageFormat ToImageFormat(SpvImageFormat fmt);
private:
/// Registers a failure and returns a stream for log diagnostics.

View File

@ -243,7 +243,7 @@ struct DimCase {
SpvDim dim;
bool arrayed;
bool expect_success;
sem::TextureDimension expected;
ast::TextureDimension expected;
};
inline std::ostream& operator<<(std::ostream& out, DimCase dc) {
out << "DimCase{ SpvDim:" << int(dc.dim) << " arrayed?:" << int(dc.arrayed)
@ -287,37 +287,37 @@ INSTANTIATE_TEST_SUITE_P(
SpvDimTest,
testing::Values(
// Non-arrayed
DimCase{SpvDim1D, false, true, sem::TextureDimension::k1d},
DimCase{SpvDim2D, false, true, sem::TextureDimension::k2d},
DimCase{SpvDim3D, false, true, sem::TextureDimension::k3d},
DimCase{SpvDimCube, false, true, sem::TextureDimension::kCube},
DimCase{SpvDim1D, false, true, ast::TextureDimension::k1d},
DimCase{SpvDim2D, false, true, ast::TextureDimension::k2d},
DimCase{SpvDim3D, false, true, ast::TextureDimension::k3d},
DimCase{SpvDimCube, false, true, ast::TextureDimension::kCube},
// Arrayed
DimCase{SpvDim2D, true, true, sem::TextureDimension::k2dArray},
DimCase{SpvDimCube, true, true, sem::TextureDimension::kCubeArray}));
DimCase{SpvDim2D, true, true, ast::TextureDimension::k2dArray},
DimCase{SpvDimCube, true, true, ast::TextureDimension::kCubeArray}));
INSTANTIATE_TEST_SUITE_P(
EnumConverterBad,
SpvDimTest,
testing::Values(
// Invalid SPIR-V dimensionality.
DimCase{SpvDimMax, false, false, sem::TextureDimension::kNone},
DimCase{SpvDimMax, true, false, sem::TextureDimension::kNone},
DimCase{SpvDimMax, false, false, ast::TextureDimension::kNone},
DimCase{SpvDimMax, true, false, ast::TextureDimension::kNone},
// Vulkan non-arrayed dimensionalities not supported by WGSL.
DimCase{SpvDimRect, false, false, sem::TextureDimension::kNone},
DimCase{SpvDimBuffer, false, false, sem::TextureDimension::kNone},
DimCase{SpvDimSubpassData, false, false, sem::TextureDimension::kNone},
DimCase{SpvDimRect, false, false, ast::TextureDimension::kNone},
DimCase{SpvDimBuffer, false, false, ast::TextureDimension::kNone},
DimCase{SpvDimSubpassData, false, false, ast::TextureDimension::kNone},
// Arrayed dimensionalities not supported by WGSL
DimCase{SpvDim3D, true, false, sem::TextureDimension::kNone},
DimCase{SpvDimRect, true, false, sem::TextureDimension::kNone},
DimCase{SpvDimBuffer, true, false, sem::TextureDimension::kNone},
DimCase{SpvDimSubpassData, true, false, sem::TextureDimension::kNone}));
DimCase{SpvDim3D, true, false, ast::TextureDimension::kNone},
DimCase{SpvDimRect, true, false, ast::TextureDimension::kNone},
DimCase{SpvDimBuffer, true, false, ast::TextureDimension::kNone},
DimCase{SpvDimSubpassData, true, false, ast::TextureDimension::kNone}));
// ImageFormat
struct ImageFormatCase {
SpvImageFormat format;
bool expect_success;
sem::ImageFormat expected;
ast::ImageFormat expected;
};
inline std::ostream& operator<<(std::ostream& out, ImageFormatCase ifc) {
out << "ImageFormatCase{ SpvImageFormat:" << int(ifc.format)
@ -361,68 +361,68 @@ INSTANTIATE_TEST_SUITE_P(
SpvImageFormatTest,
testing::Values(
// Unknown. This is used for sampled images.
ImageFormatCase{SpvImageFormatUnknown, true, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatUnknown, true, ast::ImageFormat::kNone},
// 8 bit channels
ImageFormatCase{SpvImageFormatRgba8, true,
sem::ImageFormat::kRgba8Unorm},
ast::ImageFormat::kRgba8Unorm},
ImageFormatCase{SpvImageFormatRgba8Snorm, true,
sem::ImageFormat::kRgba8Snorm},
ast::ImageFormat::kRgba8Snorm},
ImageFormatCase{SpvImageFormatRgba8ui, true,
sem::ImageFormat::kRgba8Uint},
ast::ImageFormat::kRgba8Uint},
ImageFormatCase{SpvImageFormatRgba8i, true,
sem::ImageFormat::kRgba8Sint},
ast::ImageFormat::kRgba8Sint},
// 16 bit channels
ImageFormatCase{SpvImageFormatRgba16ui, true,
sem::ImageFormat::kRgba16Uint},
ast::ImageFormat::kRgba16Uint},
ImageFormatCase{SpvImageFormatRgba16i, true,
sem::ImageFormat::kRgba16Sint},
ast::ImageFormat::kRgba16Sint},
ImageFormatCase{SpvImageFormatRgba16f, true,
sem::ImageFormat::kRgba16Float},
ast::ImageFormat::kRgba16Float},
// 32 bit channels
// ... 1 channel
ImageFormatCase{SpvImageFormatR32ui, true, sem::ImageFormat::kR32Uint},
ImageFormatCase{SpvImageFormatR32i, true, sem::ImageFormat::kR32Sint},
ImageFormatCase{SpvImageFormatR32f, true, sem::ImageFormat::kR32Float},
ImageFormatCase{SpvImageFormatR32ui, true, ast::ImageFormat::kR32Uint},
ImageFormatCase{SpvImageFormatR32i, true, ast::ImageFormat::kR32Sint},
ImageFormatCase{SpvImageFormatR32f, true, ast::ImageFormat::kR32Float},
// ... 2 channels
ImageFormatCase{SpvImageFormatRg32ui, true,
sem::ImageFormat::kRg32Uint},
ImageFormatCase{SpvImageFormatRg32i, true, sem::ImageFormat::kRg32Sint},
ast::ImageFormat::kRg32Uint},
ImageFormatCase{SpvImageFormatRg32i, true, ast::ImageFormat::kRg32Sint},
ImageFormatCase{SpvImageFormatRg32f, true,
sem::ImageFormat::kRg32Float},
ast::ImageFormat::kRg32Float},
// ... 4 channels
ImageFormatCase{SpvImageFormatRgba32ui, true,
sem::ImageFormat::kRgba32Uint},
ast::ImageFormat::kRgba32Uint},
ImageFormatCase{SpvImageFormatRgba32i, true,
sem::ImageFormat::kRgba32Sint},
ast::ImageFormat::kRgba32Sint},
ImageFormatCase{SpvImageFormatRgba32f, true,
sem::ImageFormat::kRgba32Float}));
ast::ImageFormat::kRgba32Float}));
INSTANTIATE_TEST_SUITE_P(
EnumConverterBad,
SpvImageFormatTest,
testing::Values(
// Scanning in order from the SPIR-V spec.
ImageFormatCase{SpvImageFormatRg16f, false, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg16f, false, ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatR11fG11fB10f, false,
sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatR16f, false, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRgb10A2, false, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg16, false, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg8, false, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatR16, false, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatR8, false, sem::ImageFormat::kNone},
ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatR16f, false, ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRgb10A2, false, ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg16, false, ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg8, false, ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatR16, false, ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatR8, false, ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRgba16Snorm, false,
sem::ImageFormat::kNone},
ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg16Snorm, false,
sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg8Snorm, false, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg16i, false, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg8i, false, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatR8i, false, sem::ImageFormat::kNone},
ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg8Snorm, false, ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg16i, false, ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg8i, false, ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatR8i, false, ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRgb10a2ui, false,
sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg16ui, false, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg8ui, false, sem::ImageFormat::kNone}));
ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg16ui, false, ast::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg8ui, false, ast::ImageFormat::kNone}));
} // namespace
} // namespace spirv

View File

@ -4549,9 +4549,9 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
<< inst.PrettyPrint();
}
switch (texture_type->dim()) {
case sem::TextureDimension::k2d:
case sem::TextureDimension::k2dArray:
case sem::TextureDimension::k3d:
case ast::TextureDimension::k2d:
case ast::TextureDimension::k2dArray:
case ast::TextureDimension::k3d:
break;
default:
return Fail() << "ConstOffset is only permitted for 2D, 2D Arrayed, "
@ -4674,7 +4674,7 @@ bool FunctionEmitter::EmitImageQuery(const spvtools::opt::Instruction& inst) {
}
exprs.push_back(
create<ast::CallExpression>(Source{}, dims_ident, dims_args));
if (sem::IsTextureArray(texture_type->dim())) {
if (ast::IsTextureArray(texture_type->dim())) {
auto* layers_ident = create<ast::IdentifierExpression>(
Source{}, builder_.Symbols().Register("textureNumLayers"));
exprs.push_back(create<ast::CallExpression>(
@ -4753,10 +4753,10 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
if (!texture_type) {
return {};
}
sem::TextureDimension dim = texture_type->dim();
ast::TextureDimension dim = texture_type->dim();
// Number of regular coordinates.
uint32_t num_axes = sem::NumCoordinateAxes(dim);
bool is_arrayed = sem::IsTextureArray(dim);
uint32_t num_axes = ast::NumCoordinateAxes(dim);
bool is_arrayed = ast::IsTextureArray(dim);
if ((num_axes == 0) || (num_axes > 3)) {
Fail() << "unsupported image dimensionality for "
<< texture_type->type_name() << " prompted by "

View File

@ -1898,8 +1898,8 @@ sem::Pointer* ParserImpl::GetTypeForHandleVar(
sem::Type* ast_store_type = nullptr;
if (usage.IsSampler()) {
ast_store_type = builder_.create<sem::Sampler>(
usage.IsComparisonSampler() ? sem::SamplerKind::kComparisonSampler
: sem::SamplerKind::kSampler);
usage.IsComparisonSampler() ? ast::SamplerKind::kComparisonSampler
: ast::SamplerKind::kSampler);
} else if (usage.IsTexture()) {
const spvtools::opt::analysis::Image* image_type =
type_mgr_->GetType(raw_handle_type->result_id())->AsImage();
@ -1909,9 +1909,9 @@ sem::Pointer* ParserImpl::GetTypeForHandleVar(
return nullptr;
}
const sem::TextureDimension dim =
const ast::TextureDimension dim =
enum_converter_.ToDim(image_type->dim(), image_type->is_arrayed());
if (dim == sem::TextureDimension::kNone) {
if (dim == ast::TextureDimension::kNone) {
return nullptr;
}
@ -1942,7 +1942,7 @@ sem::Pointer* ParserImpl::GetTypeForHandleVar(
? ast::AccessControl::kReadOnly
: ast::AccessControl::kWriteOnly;
const auto format = enum_converter_.ToImageFormat(image_type->format());
if (format == sem::ImageFormat::kNone) {
if (format == ast::ImageFormat::kNone) {
return nullptr;
}
auto* subtype = sem::StorageTexture::SubtypeFor(format, builder_.Types());
@ -1964,47 +1964,47 @@ sem::Pointer* ParserImpl::GetTypeForHandleVar(
return result;
}
sem::Type* ParserImpl::GetComponentTypeForFormat(sem::ImageFormat format) {
sem::Type* ParserImpl::GetComponentTypeForFormat(ast::ImageFormat format) {
switch (format) {
case sem::ImageFormat::kR8Uint:
case sem::ImageFormat::kR16Uint:
case sem::ImageFormat::kRg8Uint:
case sem::ImageFormat::kR32Uint:
case sem::ImageFormat::kRg16Uint:
case sem::ImageFormat::kRgba8Uint:
case sem::ImageFormat::kRg32Uint:
case sem::ImageFormat::kRgba16Uint:
case sem::ImageFormat::kRgba32Uint:
case ast::ImageFormat::kR8Uint:
case ast::ImageFormat::kR16Uint:
case ast::ImageFormat::kRg8Uint:
case ast::ImageFormat::kR32Uint:
case ast::ImageFormat::kRg16Uint:
case ast::ImageFormat::kRgba8Uint:
case ast::ImageFormat::kRg32Uint:
case ast::ImageFormat::kRgba16Uint:
case ast::ImageFormat::kRgba32Uint:
return builder_.create<sem::U32>();
case sem::ImageFormat::kR8Sint:
case sem::ImageFormat::kR16Sint:
case sem::ImageFormat::kRg8Sint:
case sem::ImageFormat::kR32Sint:
case sem::ImageFormat::kRg16Sint:
case sem::ImageFormat::kRgba8Sint:
case sem::ImageFormat::kRg32Sint:
case sem::ImageFormat::kRgba16Sint:
case sem::ImageFormat::kRgba32Sint:
case ast::ImageFormat::kR8Sint:
case ast::ImageFormat::kR16Sint:
case ast::ImageFormat::kRg8Sint:
case ast::ImageFormat::kR32Sint:
case ast::ImageFormat::kRg16Sint:
case ast::ImageFormat::kRgba8Sint:
case ast::ImageFormat::kRg32Sint:
case ast::ImageFormat::kRgba16Sint:
case ast::ImageFormat::kRgba32Sint:
return builder_.create<sem::I32>();
case sem::ImageFormat::kR8Unorm:
case sem::ImageFormat::kRg8Unorm:
case sem::ImageFormat::kRgba8Unorm:
case sem::ImageFormat::kRgba8UnormSrgb:
case sem::ImageFormat::kBgra8Unorm:
case sem::ImageFormat::kBgra8UnormSrgb:
case sem::ImageFormat::kRgb10A2Unorm:
case sem::ImageFormat::kR8Snorm:
case sem::ImageFormat::kRg8Snorm:
case sem::ImageFormat::kRgba8Snorm:
case sem::ImageFormat::kR16Float:
case sem::ImageFormat::kR32Float:
case sem::ImageFormat::kRg16Float:
case sem::ImageFormat::kRg11B10Float:
case sem::ImageFormat::kRg32Float:
case sem::ImageFormat::kRgba16Float:
case sem::ImageFormat::kRgba32Float:
case ast::ImageFormat::kR8Unorm:
case ast::ImageFormat::kRg8Unorm:
case ast::ImageFormat::kRgba8Unorm:
case ast::ImageFormat::kRgba8UnormSrgb:
case ast::ImageFormat::kBgra8Unorm:
case ast::ImageFormat::kBgra8UnormSrgb:
case ast::ImageFormat::kRgb10A2Unorm:
case ast::ImageFormat::kR8Snorm:
case ast::ImageFormat::kRg8Snorm:
case ast::ImageFormat::kRgba8Snorm:
case ast::ImageFormat::kR16Float:
case ast::ImageFormat::kR32Float:
case ast::ImageFormat::kRg16Float:
case ast::ImageFormat::kRg11B10Float:
case ast::ImageFormat::kRg32Float:
case ast::ImageFormat::kRgba16Float:
case ast::ImageFormat::kRgba32Float:
return builder_.create<sem::F32>();
default:
break;
@ -2013,54 +2013,54 @@ sem::Type* ParserImpl::GetComponentTypeForFormat(sem::ImageFormat format) {
return nullptr;
}
sem::Type* ParserImpl::GetTexelTypeForFormat(sem::ImageFormat format) {
sem::Type* ParserImpl::GetTexelTypeForFormat(ast::ImageFormat format) {
auto* component_type = GetComponentTypeForFormat(format);
if (!component_type) {
return nullptr;
}
switch (format) {
case sem::ImageFormat::kR16Float:
case sem::ImageFormat::kR16Sint:
case sem::ImageFormat::kR16Uint:
case sem::ImageFormat::kR32Float:
case sem::ImageFormat::kR32Sint:
case sem::ImageFormat::kR32Uint:
case sem::ImageFormat::kR8Sint:
case sem::ImageFormat::kR8Snorm:
case sem::ImageFormat::kR8Uint:
case sem::ImageFormat::kR8Unorm:
case ast::ImageFormat::kR16Float:
case ast::ImageFormat::kR16Sint:
case ast::ImageFormat::kR16Uint:
case ast::ImageFormat::kR32Float:
case ast::ImageFormat::kR32Sint:
case ast::ImageFormat::kR32Uint:
case ast::ImageFormat::kR8Sint:
case ast::ImageFormat::kR8Snorm:
case ast::ImageFormat::kR8Uint:
case ast::ImageFormat::kR8Unorm:
// One channel
return component_type;
case sem::ImageFormat::kRg11B10Float:
case sem::ImageFormat::kRg16Float:
case sem::ImageFormat::kRg16Sint:
case sem::ImageFormat::kRg16Uint:
case sem::ImageFormat::kRg32Float:
case sem::ImageFormat::kRg32Sint:
case sem::ImageFormat::kRg32Uint:
case sem::ImageFormat::kRg8Sint:
case sem::ImageFormat::kRg8Snorm:
case sem::ImageFormat::kRg8Uint:
case sem::ImageFormat::kRg8Unorm:
case ast::ImageFormat::kRg11B10Float:
case ast::ImageFormat::kRg16Float:
case ast::ImageFormat::kRg16Sint:
case ast::ImageFormat::kRg16Uint:
case ast::ImageFormat::kRg32Float:
case ast::ImageFormat::kRg32Sint:
case ast::ImageFormat::kRg32Uint:
case ast::ImageFormat::kRg8Sint:
case ast::ImageFormat::kRg8Snorm:
case ast::ImageFormat::kRg8Uint:
case ast::ImageFormat::kRg8Unorm:
// Two channels
return builder_.create<sem::Vector>(component_type, 2);
case sem::ImageFormat::kBgra8Unorm:
case sem::ImageFormat::kBgra8UnormSrgb:
case sem::ImageFormat::kRgb10A2Unorm:
case sem::ImageFormat::kRgba16Float:
case sem::ImageFormat::kRgba16Sint:
case sem::ImageFormat::kRgba16Uint:
case sem::ImageFormat::kRgba32Float:
case sem::ImageFormat::kRgba32Sint:
case sem::ImageFormat::kRgba32Uint:
case sem::ImageFormat::kRgba8Sint:
case sem::ImageFormat::kRgba8Snorm:
case sem::ImageFormat::kRgba8Uint:
case sem::ImageFormat::kRgba8Unorm:
case sem::ImageFormat::kRgba8UnormSrgb:
case ast::ImageFormat::kBgra8Unorm:
case ast::ImageFormat::kBgra8UnormSrgb:
case ast::ImageFormat::kRgb10A2Unorm:
case ast::ImageFormat::kRgba16Float:
case ast::ImageFormat::kRgba16Sint:
case ast::ImageFormat::kRgba16Uint:
case ast::ImageFormat::kRgba32Float:
case ast::ImageFormat::kRgba32Sint:
case ast::ImageFormat::kRgba32Uint:
case ast::ImageFormat::kRgba8Sint:
case ast::ImageFormat::kRgba8Snorm:
case ast::ImageFormat::kRgba8Uint:
case ast::ImageFormat::kRgba8Unorm:
case ast::ImageFormat::kRgba8UnormSrgb:
// Four channels
return builder_.create<sem::Vector>(component_type, 4);

View File

@ -475,12 +475,12 @@ class ParserImpl : Reader {
/// format.
/// @param format image texel format
/// @returns the component type, one of f32, i32, u32
sem::Type* GetComponentTypeForFormat(sem::ImageFormat format);
sem::Type* GetComponentTypeForFormat(ast::ImageFormat format);
/// Returns texel type corresponding to the given image format.
/// @param format image texel format
/// @returns the texel format
sem::Type* GetTexelTypeForFormat(sem::ImageFormat format);
sem::Type* GetTexelTypeForFormat(ast::ImageFormat format);
/// Returns the SPIR-V instruction with the given ID, or nullptr.
/// @param id the SPIR-V result ID

View File

@ -563,10 +563,10 @@ Maybe<sem::Type*> ParserImpl::texture_sampler_types() {
// | SAMPLER_COMPARISON
Maybe<sem::Type*> ParserImpl::sampler_type() {
if (match(Token::Type::kSampler))
return builder_.create<sem::Sampler>(sem::SamplerKind::kSampler);
return builder_.create<sem::Sampler>(ast::SamplerKind::kSampler);
if (match(Token::Type::kComparisonSampler))
return builder_.create<sem::Sampler>(sem::SamplerKind::kComparisonSampler);
return builder_.create<sem::Sampler>(ast::SamplerKind::kComparisonSampler);
return Failure::kNoMatch;
}
@ -578,33 +578,33 @@ Maybe<sem::Type*> ParserImpl::sampler_type() {
// | TEXTURE_SAMPLED_3D
// | TEXTURE_SAMPLED_CUBE
// | TEXTURE_SAMPLED_CUBE_ARRAY
Maybe<sem::TextureDimension> ParserImpl::sampled_texture_type() {
Maybe<ast::TextureDimension> ParserImpl::sampled_texture_type() {
if (match(Token::Type::kTextureSampled1d))
return sem::TextureDimension::k1d;
return ast::TextureDimension::k1d;
if (match(Token::Type::kTextureSampled2d))
return sem::TextureDimension::k2d;
return ast::TextureDimension::k2d;
if (match(Token::Type::kTextureSampled2dArray))
return sem::TextureDimension::k2dArray;
return ast::TextureDimension::k2dArray;
if (match(Token::Type::kTextureSampled3d))
return sem::TextureDimension::k3d;
return ast::TextureDimension::k3d;
if (match(Token::Type::kTextureSampledCube))
return sem::TextureDimension::kCube;
return ast::TextureDimension::kCube;
if (match(Token::Type::kTextureSampledCubeArray))
return sem::TextureDimension::kCubeArray;
return ast::TextureDimension::kCubeArray;
return Failure::kNoMatch;
}
// multisampled_texture_type
// : TEXTURE_MULTISAMPLED_2D
Maybe<sem::TextureDimension> ParserImpl::multisampled_texture_type() {
Maybe<ast::TextureDimension> ParserImpl::multisampled_texture_type() {
if (match(Token::Type::kTextureMultisampled2d))
return sem::TextureDimension::k2d;
return ast::TextureDimension::k2d;
return Failure::kNoMatch;
}
@ -614,15 +614,15 @@ Maybe<sem::TextureDimension> ParserImpl::multisampled_texture_type() {
// | TEXTURE_STORAGE_2D
// | TEXTURE_STORAGE_2D_ARRAY
// | TEXTURE_STORAGE_3D
Maybe<sem::TextureDimension> ParserImpl::storage_texture_type() {
Maybe<ast::TextureDimension> ParserImpl::storage_texture_type() {
if (match(Token::Type::kTextureStorage1d))
return sem::TextureDimension::k1d;
return ast::TextureDimension::k1d;
if (match(Token::Type::kTextureStorage2d))
return sem::TextureDimension::k2d;
return ast::TextureDimension::k2d;
if (match(Token::Type::kTextureStorage2dArray))
return sem::TextureDimension::k2dArray;
return ast::TextureDimension::k2dArray;
if (match(Token::Type::kTextureStorage3d))
return sem::TextureDimension::k3d;
return ast::TextureDimension::k3d;
return Failure::kNoMatch;
}
@ -634,17 +634,17 @@ Maybe<sem::TextureDimension> ParserImpl::storage_texture_type() {
// | TEXTURE_DEPTH_CUBE_ARRAY
Maybe<sem::Type*> ParserImpl::depth_texture_type() {
if (match(Token::Type::kTextureDepth2d))
return builder_.create<sem::DepthTexture>(sem::TextureDimension::k2d);
return builder_.create<sem::DepthTexture>(ast::TextureDimension::k2d);
if (match(Token::Type::kTextureDepth2dArray))
return builder_.create<sem::DepthTexture>(sem::TextureDimension::k2dArray);
return builder_.create<sem::DepthTexture>(ast::TextureDimension::k2dArray);
if (match(Token::Type::kTextureDepthCube))
return builder_.create<sem::DepthTexture>(sem::TextureDimension::kCube);
return builder_.create<sem::DepthTexture>(ast::TextureDimension::kCube);
if (match(Token::Type::kTextureDepthCubeArray))
return builder_.create<sem::DepthTexture>(
sem::TextureDimension::kCubeArray);
ast::TextureDimension::kCubeArray);
return Failure::kNoMatch;
}
@ -685,112 +685,112 @@ Maybe<sem::Type*> ParserImpl::depth_texture_type() {
// | RGBA32UINT
// | RGBA32SINT
// | RGBA32FLOAT
Expect<sem::ImageFormat> ParserImpl::expect_image_storage_type(
Expect<ast::ImageFormat> ParserImpl::expect_image_storage_type(
const std::string& use) {
if (match(Token::Type::kFormatR8Unorm))
return sem::ImageFormat::kR8Unorm;
return ast::ImageFormat::kR8Unorm;
if (match(Token::Type::kFormatR8Snorm))
return sem::ImageFormat::kR8Snorm;
return ast::ImageFormat::kR8Snorm;
if (match(Token::Type::kFormatR8Uint))
return sem::ImageFormat::kR8Uint;
return ast::ImageFormat::kR8Uint;
if (match(Token::Type::kFormatR8Sint))
return sem::ImageFormat::kR8Sint;
return ast::ImageFormat::kR8Sint;
if (match(Token::Type::kFormatR16Uint))
return sem::ImageFormat::kR16Uint;
return ast::ImageFormat::kR16Uint;
if (match(Token::Type::kFormatR16Sint))
return sem::ImageFormat::kR16Sint;
return ast::ImageFormat::kR16Sint;
if (match(Token::Type::kFormatR16Float))
return sem::ImageFormat::kR16Float;
return ast::ImageFormat::kR16Float;
if (match(Token::Type::kFormatRg8Unorm))
return sem::ImageFormat::kRg8Unorm;
return ast::ImageFormat::kRg8Unorm;
if (match(Token::Type::kFormatRg8Snorm))
return sem::ImageFormat::kRg8Snorm;
return ast::ImageFormat::kRg8Snorm;
if (match(Token::Type::kFormatRg8Uint))
return sem::ImageFormat::kRg8Uint;
return ast::ImageFormat::kRg8Uint;
if (match(Token::Type::kFormatRg8Sint))
return sem::ImageFormat::kRg8Sint;
return ast::ImageFormat::kRg8Sint;
if (match(Token::Type::kFormatR32Uint))
return sem::ImageFormat::kR32Uint;
return ast::ImageFormat::kR32Uint;
if (match(Token::Type::kFormatR32Sint))
return sem::ImageFormat::kR32Sint;
return ast::ImageFormat::kR32Sint;
if (match(Token::Type::kFormatR32Float))
return sem::ImageFormat::kR32Float;
return ast::ImageFormat::kR32Float;
if (match(Token::Type::kFormatRg16Uint))
return sem::ImageFormat::kRg16Uint;
return ast::ImageFormat::kRg16Uint;
if (match(Token::Type::kFormatRg16Sint))
return sem::ImageFormat::kRg16Sint;
return ast::ImageFormat::kRg16Sint;
if (match(Token::Type::kFormatRg16Float))
return sem::ImageFormat::kRg16Float;
return ast::ImageFormat::kRg16Float;
if (match(Token::Type::kFormatRgba8Unorm))
return sem::ImageFormat::kRgba8Unorm;
return ast::ImageFormat::kRgba8Unorm;
if (match(Token::Type::kFormatRgba8UnormSrgb))
return sem::ImageFormat::kRgba8UnormSrgb;
return ast::ImageFormat::kRgba8UnormSrgb;
if (match(Token::Type::kFormatRgba8Snorm))
return sem::ImageFormat::kRgba8Snorm;
return ast::ImageFormat::kRgba8Snorm;
if (match(Token::Type::kFormatRgba8Uint))
return sem::ImageFormat::kRgba8Uint;
return ast::ImageFormat::kRgba8Uint;
if (match(Token::Type::kFormatRgba8Sint))
return sem::ImageFormat::kRgba8Sint;
return ast::ImageFormat::kRgba8Sint;
if (match(Token::Type::kFormatBgra8Unorm))
return sem::ImageFormat::kBgra8Unorm;
return ast::ImageFormat::kBgra8Unorm;
if (match(Token::Type::kFormatBgra8UnormSrgb))
return sem::ImageFormat::kBgra8UnormSrgb;
return ast::ImageFormat::kBgra8UnormSrgb;
if (match(Token::Type::kFormatRgb10A2Unorm))
return sem::ImageFormat::kRgb10A2Unorm;
return ast::ImageFormat::kRgb10A2Unorm;
if (match(Token::Type::kFormatRg11B10Float))
return sem::ImageFormat::kRg11B10Float;
return ast::ImageFormat::kRg11B10Float;
if (match(Token::Type::kFormatRg32Uint))
return sem::ImageFormat::kRg32Uint;
return ast::ImageFormat::kRg32Uint;
if (match(Token::Type::kFormatRg32Sint))
return sem::ImageFormat::kRg32Sint;
return ast::ImageFormat::kRg32Sint;
if (match(Token::Type::kFormatRg32Float))
return sem::ImageFormat::kRg32Float;
return ast::ImageFormat::kRg32Float;
if (match(Token::Type::kFormatRgba16Uint))
return sem::ImageFormat::kRgba16Uint;
return ast::ImageFormat::kRgba16Uint;
if (match(Token::Type::kFormatRgba16Sint))
return sem::ImageFormat::kRgba16Sint;
return ast::ImageFormat::kRgba16Sint;
if (match(Token::Type::kFormatRgba16Float))
return sem::ImageFormat::kRgba16Float;
return ast::ImageFormat::kRgba16Float;
if (match(Token::Type::kFormatRgba32Uint))
return sem::ImageFormat::kRgba32Uint;
return ast::ImageFormat::kRgba32Uint;
if (match(Token::Type::kFormatRgba32Sint))
return sem::ImageFormat::kRgba32Sint;
return ast::ImageFormat::kRgba32Sint;
if (match(Token::Type::kFormatRgba32Float))
return sem::ImageFormat::kRgba32Float;
return ast::ImageFormat::kRgba32Float;
return add_error(peek().source(), "invalid format", use);
}

View File

@ -403,21 +403,21 @@ class ParserImpl {
/// Parses a `multisampled_texture_type` grammar element
/// @returns returns the multisample texture dimension or kNone if none
/// matched.
Maybe<sem::TextureDimension> multisampled_texture_type();
Maybe<ast::TextureDimension> multisampled_texture_type();
/// Parses a `sampled_texture_type` grammar element
/// @returns returns the sample texture dimension or kNone if none matched.
Maybe<sem::TextureDimension> sampled_texture_type();
Maybe<ast::TextureDimension> sampled_texture_type();
/// Parses a `storage_texture_type` grammar element
/// @returns returns the storage texture dimension.
/// Returns kNone if none matched.
Maybe<sem::TextureDimension> storage_texture_type();
Maybe<ast::TextureDimension> storage_texture_type();
/// Parses a `depth_texture_type` grammar element
/// @returns the parsed Type or nullptr if none matched.
Maybe<sem::Type*> depth_texture_type();
/// Parses a `image_storage_type` grammar element
/// @param use a description of what was being parsed if an error was raised
/// @returns returns the image format or kNone if none matched.
Expect<sem::ImageFormat> expect_image_storage_type(const std::string& use);
Expect<ast::ImageFormat> expect_image_storage_type(const std::string& use);
/// Parses a `function_type_decl` grammar element
/// @returns the parsed type or nullptr otherwise
Maybe<sem::Type*> function_type_decl();

View File

@ -36,7 +36,7 @@ TEST_F(ParserImplTest, DepthTextureType_2d) {
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<sem::Texture>());
ASSERT_TRUE(t->Is<sem::DepthTexture>());
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
EXPECT_EQ(t->As<sem::Texture>()->dim(), ast::TextureDimension::k2d);
EXPECT_FALSE(p->has_error());
}
@ -48,7 +48,7 @@ TEST_F(ParserImplTest, DepthTextureType_2dArray) {
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<sem::Texture>());
ASSERT_TRUE(t->Is<sem::DepthTexture>());
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2dArray);
EXPECT_EQ(t->As<sem::Texture>()->dim(), ast::TextureDimension::k2dArray);
EXPECT_FALSE(p->has_error());
}
@ -60,7 +60,7 @@ TEST_F(ParserImplTest, DepthTextureType_Cube) {
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<sem::Texture>());
ASSERT_TRUE(t->Is<sem::DepthTexture>());
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::kCube);
EXPECT_EQ(t->As<sem::Texture>()->dim(), ast::TextureDimension::kCube);
EXPECT_FALSE(p->has_error());
}
@ -72,7 +72,7 @@ TEST_F(ParserImplTest, DepthTextureType_CubeArray) {
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<sem::Texture>());
ASSERT_TRUE(t->Is<sem::DepthTexture>());
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::kCubeArray);
EXPECT_EQ(t->As<sem::Texture>()->dim(), ast::TextureDimension::kCubeArray);
EXPECT_FALSE(p->has_error());
}

View File

@ -31,7 +31,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Unorm) {
auto p = parser("r8unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kR8Unorm);
EXPECT_EQ(t.value, ast::ImageFormat::kR8Unorm);
EXPECT_FALSE(p->has_error());
}
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Snorm) {
auto p = parser("r8snorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kR8Snorm);
EXPECT_EQ(t.value, ast::ImageFormat::kR8Snorm);
EXPECT_FALSE(p->has_error());
}
@ -47,7 +47,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Uint) {
auto p = parser("r8uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kR8Uint);
EXPECT_EQ(t.value, ast::ImageFormat::kR8Uint);
EXPECT_FALSE(p->has_error());
}
@ -55,7 +55,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Sint) {
auto p = parser("r8sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kR8Sint);
EXPECT_EQ(t.value, ast::ImageFormat::kR8Sint);
EXPECT_FALSE(p->has_error());
}
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Uint) {
auto p = parser("r16uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kR16Uint);
EXPECT_EQ(t.value, ast::ImageFormat::kR16Uint);
EXPECT_FALSE(p->has_error());
}
@ -71,7 +71,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Sint) {
auto p = parser("r16sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kR16Sint);
EXPECT_EQ(t.value, ast::ImageFormat::kR16Sint);
EXPECT_FALSE(p->has_error());
}
@ -79,7 +79,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Float) {
auto p = parser("r16float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kR16Float);
EXPECT_EQ(t.value, ast::ImageFormat::kR16Float);
EXPECT_FALSE(p->has_error());
}
@ -87,7 +87,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Unorm) {
auto p = parser("rg8unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRg8Unorm);
EXPECT_EQ(t.value, ast::ImageFormat::kRg8Unorm);
EXPECT_FALSE(p->has_error());
}
@ -95,7 +95,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Snorm) {
auto p = parser("rg8snorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRg8Snorm);
EXPECT_EQ(t.value, ast::ImageFormat::kRg8Snorm);
EXPECT_FALSE(p->has_error());
}
@ -103,7 +103,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Uint) {
auto p = parser("rg8uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRg8Uint);
EXPECT_EQ(t.value, ast::ImageFormat::kRg8Uint);
EXPECT_FALSE(p->has_error());
}
@ -111,7 +111,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Sint) {
auto p = parser("rg8sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRg8Sint);
EXPECT_EQ(t.value, ast::ImageFormat::kRg8Sint);
EXPECT_FALSE(p->has_error());
}
@ -119,7 +119,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Uint) {
auto p = parser("r32uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kR32Uint);
EXPECT_EQ(t.value, ast::ImageFormat::kR32Uint);
EXPECT_FALSE(p->has_error());
}
@ -127,7 +127,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Sint) {
auto p = parser("r32sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kR32Sint);
EXPECT_EQ(t.value, ast::ImageFormat::kR32Sint);
EXPECT_FALSE(p->has_error());
}
@ -135,7 +135,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Float) {
auto p = parser("r32float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kR32Float);
EXPECT_EQ(t.value, ast::ImageFormat::kR32Float);
EXPECT_FALSE(p->has_error());
}
@ -143,7 +143,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Uint) {
auto p = parser("rg16uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRg16Uint);
EXPECT_EQ(t.value, ast::ImageFormat::kRg16Uint);
EXPECT_FALSE(p->has_error());
}
@ -151,7 +151,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Sint) {
auto p = parser("rg16sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRg16Sint);
EXPECT_EQ(t.value, ast::ImageFormat::kRg16Sint);
EXPECT_FALSE(p->has_error());
}
@ -159,7 +159,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Float) {
auto p = parser("rg16float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRg16Float);
EXPECT_EQ(t.value, ast::ImageFormat::kRg16Float);
EXPECT_FALSE(p->has_error());
}
@ -167,7 +167,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Unorm) {
auto p = parser("rgba8unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Unorm);
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8Unorm);
EXPECT_FALSE(p->has_error());
}
@ -175,7 +175,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8UnormSrgb) {
auto p = parser("rgba8unorm_srgb");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8UnormSrgb);
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8UnormSrgb);
EXPECT_FALSE(p->has_error());
}
@ -183,7 +183,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Snorm) {
auto p = parser("rgba8snorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Snorm);
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8Snorm);
EXPECT_FALSE(p->has_error());
}
@ -191,7 +191,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Uint) {
auto p = parser("rgba8uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Uint);
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8Uint);
EXPECT_FALSE(p->has_error());
}
@ -199,7 +199,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Sint) {
auto p = parser("rgba8sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Sint);
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8Sint);
EXPECT_FALSE(p->has_error());
}
@ -207,7 +207,7 @@ TEST_F(ParserImplTest, ImageStorageType_Bgra8Unorm) {
auto p = parser("bgra8unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kBgra8Unorm);
EXPECT_EQ(t.value, ast::ImageFormat::kBgra8Unorm);
EXPECT_FALSE(p->has_error());
}
@ -215,7 +215,7 @@ TEST_F(ParserImplTest, ImageStorageType_Bgra8UnormSrgb) {
auto p = parser("bgra8unorm_srgb");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kBgra8UnormSrgb);
EXPECT_EQ(t.value, ast::ImageFormat::kBgra8UnormSrgb);
EXPECT_FALSE(p->has_error());
}
@ -223,7 +223,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgb10A2Unorm) {
auto p = parser("rgb10a2unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRgb10A2Unorm);
EXPECT_EQ(t.value, ast::ImageFormat::kRgb10A2Unorm);
EXPECT_FALSE(p->has_error());
}
@ -231,7 +231,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg11B10Float) {
auto p = parser("rg11b10float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRg11B10Float);
EXPECT_EQ(t.value, ast::ImageFormat::kRg11B10Float);
EXPECT_FALSE(p->has_error());
}
@ -239,7 +239,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Uint) {
auto p = parser("rg32uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRg32Uint);
EXPECT_EQ(t.value, ast::ImageFormat::kRg32Uint);
EXPECT_FALSE(p->has_error());
}
@ -247,7 +247,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Sint) {
auto p = parser("rg32sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRg32Sint);
EXPECT_EQ(t.value, ast::ImageFormat::kRg32Sint);
EXPECT_FALSE(p->has_error());
}
@ -255,7 +255,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Float) {
auto p = parser("rg32float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRg32Float);
EXPECT_EQ(t.value, ast::ImageFormat::kRg32Float);
EXPECT_FALSE(p->has_error());
}
@ -263,7 +263,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Uint) {
auto p = parser("rgba16uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRgba16Uint);
EXPECT_EQ(t.value, ast::ImageFormat::kRgba16Uint);
EXPECT_FALSE(p->has_error());
}
@ -271,7 +271,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Sint) {
auto p = parser("rgba16sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRgba16Sint);
EXPECT_EQ(t.value, ast::ImageFormat::kRgba16Sint);
EXPECT_FALSE(p->has_error());
}
@ -279,7 +279,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Float) {
auto p = parser("rgba16float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRgba16Float);
EXPECT_EQ(t.value, ast::ImageFormat::kRgba16Float);
EXPECT_FALSE(p->has_error());
}
@ -287,7 +287,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Uint) {
auto p = parser("rgba32uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRgba32Uint);
EXPECT_EQ(t.value, ast::ImageFormat::kRgba32Uint);
EXPECT_FALSE(p->has_error());
}
@ -295,7 +295,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Sint) {
auto p = parser("rgba32sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRgba32Sint);
EXPECT_EQ(t.value, ast::ImageFormat::kRgba32Sint);
EXPECT_FALSE(p->has_error());
}
@ -303,7 +303,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Float) {
auto p = parser("rgba32float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::ImageFormat::kRgba32Float);
EXPECT_EQ(t.value, ast::ImageFormat::kRgba32Float);
EXPECT_FALSE(p->has_error());
}

View File

@ -32,7 +32,7 @@ TEST_F(ParserImplTest, SampledTextureType_1d) {
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::TextureDimension::k1d);
EXPECT_EQ(t.value, ast::TextureDimension::k1d);
EXPECT_FALSE(p->has_error());
}
@ -41,7 +41,7 @@ TEST_F(ParserImplTest, SampledTextureType_2d) {
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::TextureDimension::k2d);
EXPECT_EQ(t.value, ast::TextureDimension::k2d);
EXPECT_FALSE(p->has_error());
}
@ -50,7 +50,7 @@ TEST_F(ParserImplTest, SampledTextureType_2dArray) {
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::TextureDimension::k2dArray);
EXPECT_EQ(t.value, ast::TextureDimension::k2dArray);
EXPECT_FALSE(p->has_error());
}
@ -59,7 +59,7 @@ TEST_F(ParserImplTest, SampledTextureType_3d) {
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::TextureDimension::k3d);
EXPECT_EQ(t.value, ast::TextureDimension::k3d);
EXPECT_FALSE(p->has_error());
}
@ -68,7 +68,7 @@ TEST_F(ParserImplTest, SampledTextureType_Cube) {
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::TextureDimension::kCube);
EXPECT_EQ(t.value, ast::TextureDimension::kCube);
EXPECT_FALSE(p->has_error());
}
@ -77,7 +77,7 @@ TEST_F(ParserImplTest, SampledTextureType_kCubeArray) {
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::TextureDimension::kCubeArray);
EXPECT_EQ(t.value, ast::TextureDimension::kCubeArray);
EXPECT_FALSE(p->has_error());
}

View File

@ -32,7 +32,7 @@ TEST_F(ParserImplTest, StorageTextureType_1d) {
auto t = p->storage_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::TextureDimension::k1d);
EXPECT_EQ(t.value, ast::TextureDimension::k1d);
EXPECT_FALSE(p->has_error());
}
@ -41,7 +41,7 @@ TEST_F(ParserImplTest, StorageTextureType_2d) {
auto t = p->storage_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::TextureDimension::k2d);
EXPECT_EQ(t.value, ast::TextureDimension::k2d);
EXPECT_FALSE(p->has_error());
}
@ -50,7 +50,7 @@ TEST_F(ParserImplTest, StorageTextureType_2dArray) {
auto t = p->storage_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::TextureDimension::k2dArray);
EXPECT_EQ(t.value, ast::TextureDimension::k2dArray);
EXPECT_FALSE(p->has_error());
}
@ -59,7 +59,7 @@ TEST_F(ParserImplTest, StorageTextureType_3d) {
auto t = p->storage_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, sem::TextureDimension::k3d);
EXPECT_EQ(t.value, ast::TextureDimension::k3d);
EXPECT_FALSE(p->has_error());
}

View File

@ -62,7 +62,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<sem::Texture>());
ASSERT_TRUE(t->Is<sem::DepthTexture>());
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
EXPECT_EQ(t->As<sem::Texture>()->dim(), ast::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) {
@ -75,7 +75,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) {
ASSERT_TRUE(t->Is<sem::Texture>());
ASSERT_TRUE(t->Is<sem::SampledTexture>());
ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::F32>());
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k1d);
EXPECT_EQ(t->As<sem::Texture>()->dim(), ast::TextureDimension::k1d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
@ -88,7 +88,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
ASSERT_TRUE(t->Is<sem::Texture>());
ASSERT_TRUE(t->Is<sem::SampledTexture>());
ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::I32>());
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
EXPECT_EQ(t->As<sem::Texture>()->dim(), ast::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
@ -101,7 +101,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
ASSERT_TRUE(t->Is<sem::Texture>());
ASSERT_TRUE(t->Is<sem::SampledTexture>());
ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::U32>());
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k3d);
EXPECT_EQ(t->As<sem::Texture>()->dim(), ast::TextureDimension::k3d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid) {
@ -154,7 +154,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_I32) {
ASSERT_TRUE(t->Is<sem::Texture>());
ASSERT_TRUE(t->Is<sem::MultisampledTexture>());
ASSERT_TRUE(t->As<sem::MultisampledTexture>()->type()->Is<sem::I32>());
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
EXPECT_EQ(t->As<sem::Texture>()->dim(), ast::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_Invalid) {
@ -208,8 +208,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) {
ASSERT_TRUE(t->Is<sem::Texture>());
ASSERT_TRUE(t->Is<sem::StorageTexture>());
EXPECT_EQ(t->As<sem::StorageTexture>()->image_format(),
sem::ImageFormat::kR8Unorm);
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k1d);
ast::ImageFormat::kR8Unorm);
EXPECT_EQ(t->As<sem::Texture>()->dim(), ast::TextureDimension::k1d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
@ -223,8 +223,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
ASSERT_TRUE(t->Is<sem::Texture>());
ASSERT_TRUE(t->Is<sem::StorageTexture>());
EXPECT_EQ(t->As<sem::StorageTexture>()->image_format(),
sem::ImageFormat::kR16Float);
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
ast::ImageFormat::kR16Float);
EXPECT_EQ(t->As<sem::Texture>()->dim(), ast::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {

View File

@ -746,7 +746,7 @@ TEST_F(ParserImplTest, TypeDecl_Sampler) {
auto p = parser("sampler");
auto& builder = p->builder();
auto* type = builder.create<sem::Sampler>(sem::SamplerKind::kSampler);
auto* type = builder.create<sem::Sampler>(ast::SamplerKind::kSampler);
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
@ -761,7 +761,7 @@ TEST_F(ParserImplTest, TypeDecl_Texture) {
auto p = parser("texture_cube<f32>");
auto& builder = p->builder();
auto* type = builder.create<sem::SampledTexture>(sem::TextureDimension::kCube,
auto* type = builder.create<sem::SampledTexture>(ast::TextureDimension::kCube,
ty.f32());
auto t = p->type_decl();

View File

@ -256,8 +256,8 @@ TEST_F(ResolverAssignmentValidationTest, AssignFromPointer_Fail) {
// a = b;
auto* tex_type = create<sem::StorageTexture>(
sem::TextureDimension::k1d, sem::ImageFormat::kRgba8Unorm,
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kRgba8Unorm, Types()));
ast::TextureDimension::k1d, ast::ImageFormat::kRgba8Unorm,
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRgba8Unorm, Types()));
auto* tex_ac =
create<sem::AccessControl>(ast::AccessControl::kReadOnly, tex_type);

View File

@ -206,9 +206,9 @@ inline std::ostream& operator<<(std::ostream& out, Texture data) {
}
struct TextureTestParams {
sem::TextureDimension dim;
ast::TextureDimension dim;
Texture type = Texture::kF32;
sem::ImageFormat format = sem::ImageFormat::kR16Float;
ast::ImageFormat format = ast::ImageFormat::kR16Float;
};
inline std::ostream& operator<<(std::ostream& out, TextureTestParams data) {
out << data.dim << "_" << data.type;
@ -223,16 +223,16 @@ 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
sem::Type* GetCoordsType(sem::TextureDimension dim, sem::Type* scalar) {
sem::Type* GetCoordsType(ast::TextureDimension dim, sem::Type* scalar) {
switch (dim) {
case sem::TextureDimension::k1d:
case ast::TextureDimension::k1d:
return scalar;
case sem::TextureDimension::k2d:
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2d:
case ast::TextureDimension::k2dArray:
return create<sem::Vector>(scalar, 2);
case sem::TextureDimension::k3d:
case sem::TextureDimension::kCube:
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::k3d:
case ast::TextureDimension::kCube:
case ast::TextureDimension::kCubeArray:
return create<sem::Vector>(scalar, 3);
default:
[=]() { FAIL() << "Unsupported texture dimension: " << dim; }();
@ -276,7 +276,7 @@ TEST_P(ResolverIntrinsicTest_StorageTextureOperation, TextureLoadRo) {
add_call_param("texture", ro_texture_type, &call_params);
add_call_param("coords", coords_type, &call_params);
if (sem::IsTextureArray(dim)) {
if (ast::IsTextureArray(dim)) {
add_call_param("array_index", ty.i32(), &call_params);
}
@ -301,30 +301,30 @@ INSTANTIATE_TEST_SUITE_P(
ResolverTest,
ResolverIntrinsicTest_StorageTextureOperation,
testing::Values(
TextureTestParams{sem::TextureDimension::k1d, Texture::kF32,
sem::ImageFormat::kR32Float},
TextureTestParams{sem::TextureDimension::k1d, Texture::kI32,
sem::ImageFormat::kR32Sint},
TextureTestParams{sem::TextureDimension::k1d, Texture::kF32,
sem::ImageFormat::kRgba8Unorm},
TextureTestParams{sem::TextureDimension::k2d, Texture::kF32,
sem::ImageFormat::kR32Float},
TextureTestParams{sem::TextureDimension::k2d, Texture::kI32,
sem::ImageFormat::kR32Sint},
TextureTestParams{sem::TextureDimension::k2d, Texture::kF32,
sem::ImageFormat::kRgba8Unorm},
TextureTestParams{sem::TextureDimension::k2dArray, Texture::kF32,
sem::ImageFormat::kR32Float},
TextureTestParams{sem::TextureDimension::k2dArray, Texture::kI32,
sem::ImageFormat::kR32Sint},
TextureTestParams{sem::TextureDimension::k2dArray, Texture::kF32,
sem::ImageFormat::kRgba8Unorm},
TextureTestParams{sem::TextureDimension::k3d, Texture::kF32,
sem::ImageFormat::kR32Float},
TextureTestParams{sem::TextureDimension::k3d, Texture::kI32,
sem::ImageFormat::kR32Sint},
TextureTestParams{sem::TextureDimension::k3d, Texture::kF32,
sem::ImageFormat::kRgba8Unorm}));
TextureTestParams{ast::TextureDimension::k1d, Texture::kF32,
ast::ImageFormat::kR32Float},
TextureTestParams{ast::TextureDimension::k1d, Texture::kI32,
ast::ImageFormat::kR32Sint},
TextureTestParams{ast::TextureDimension::k1d, Texture::kF32,
ast::ImageFormat::kRgba8Unorm},
TextureTestParams{ast::TextureDimension::k2d, Texture::kF32,
ast::ImageFormat::kR32Float},
TextureTestParams{ast::TextureDimension::k2d, Texture::kI32,
ast::ImageFormat::kR32Sint},
TextureTestParams{ast::TextureDimension::k2d, Texture::kF32,
ast::ImageFormat::kRgba8Unorm},
TextureTestParams{ast::TextureDimension::k2dArray, Texture::kF32,
ast::ImageFormat::kR32Float},
TextureTestParams{ast::TextureDimension::k2dArray, Texture::kI32,
ast::ImageFormat::kR32Sint},
TextureTestParams{ast::TextureDimension::k2dArray, Texture::kF32,
ast::ImageFormat::kRgba8Unorm},
TextureTestParams{ast::TextureDimension::k3d, Texture::kF32,
ast::ImageFormat::kR32Float},
TextureTestParams{ast::TextureDimension::k3d, Texture::kI32,
ast::ImageFormat::kR32Sint},
TextureTestParams{ast::TextureDimension::k3d, Texture::kF32,
ast::ImageFormat::kRgba8Unorm}));
using ResolverIntrinsicTest_SampledTextureOperation =
ResolverIntrinsicTest_TextureOperation;
@ -340,7 +340,7 @@ TEST_P(ResolverIntrinsicTest_SampledTextureOperation, TextureLoadSampled) {
add_call_param("texture", texture_type, &call_params);
add_call_param("coords", coords_type, &call_params);
if (dim == sem::TextureDimension::k2dArray) {
if (dim == ast::TextureDimension::k2dArray) {
add_call_param("array_index", ty.i32(), &call_params);
}
add_call_param("level", ty.i32(), &call_params);
@ -365,10 +365,10 @@ TEST_P(ResolverIntrinsicTest_SampledTextureOperation, TextureLoadSampled) {
INSTANTIATE_TEST_SUITE_P(
ResolverTest,
ResolverIntrinsicTest_SampledTextureOperation,
testing::Values(TextureTestParams{sem::TextureDimension::k1d},
TextureTestParams{sem::TextureDimension::k2d},
TextureTestParams{sem::TextureDimension::k2dArray},
TextureTestParams{sem::TextureDimension::k3d}));
testing::Values(TextureTestParams{ast::TextureDimension::k1d},
TextureTestParams{ast::TextureDimension::k2d},
TextureTestParams{ast::TextureDimension::k2dArray},
TextureTestParams{ast::TextureDimension::k3d}));
TEST_F(ResolverIntrinsicTest, Dot_Vec2) {
Global("my_var", ty.vec2<f32>(), ast::StorageClass::kInput);
@ -1924,16 +1924,16 @@ TEST_P(ResolverIntrinsicTest_Texture, Call) {
switch (param.texture_dimension) {
default:
FAIL() << "invalid texture dimensions: " << param.texture_dimension;
case sem::TextureDimension::k1d:
case ast::TextureDimension::k1d:
EXPECT_EQ(TypeOf(call)->type_name(), ty.i32()->type_name());
break;
case sem::TextureDimension::k2d:
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2d:
case ast::TextureDimension::k2dArray:
EXPECT_EQ(TypeOf(call)->type_name(), ty.vec2<i32>()->type_name());
break;
case sem::TextureDimension::k3d:
case sem::TextureDimension::kCube:
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::k3d:
case ast::TextureDimension::kCube:
case ast::TextureDimension::kCubeArray:
EXPECT_EQ(TypeOf(call)->type_name(), ty.vec3<i32>()->type_name());
break;
}

View File

@ -18,29 +18,42 @@
#include <utility>
#include "src/ast/access_decoration.h"
#include "src/ast/alias.h"
#include "src/ast/array.h"
#include "src/ast/assignment_statement.h"
#include "src/ast/bitcast_expression.h"
#include "src/ast/break_statement.h"
#include "src/ast/call_statement.h"
#include "src/ast/constant_id_decoration.h"
#include "src/ast/continue_statement.h"
#include "src/ast/depth_texture.h"
#include "src/ast/discard_statement.h"
#include "src/ast/fallthrough_statement.h"
#include "src/ast/if_statement.h"
#include "src/ast/internal_decoration.h"
#include "src/ast/loop_statement.h"
#include "src/ast/matrix.h"
#include "src/ast/pointer.h"
#include "src/ast/return_statement.h"
#include "src/ast/sampled_texture.h"
#include "src/ast/sampler.h"
#include "src/ast/storage_texture.h"
#include "src/ast/struct_block_decoration.h"
#include "src/ast/switch_statement.h"
#include "src/ast/unary_op_expression.h"
#include "src/ast/variable_decl_statement.h"
#include "src/ast/vector.h"
#include "src/ast/workgroup_decoration.h"
#include "src/sem/access_control_type.h"
#include "src/sem/array.h"
#include "src/sem/call.h"
#include "src/sem/depth_texture_type.h"
#include "src/sem/function.h"
#include "src/sem/member_accessor_expression.h"
#include "src/sem/multisampled_texture_type.h"
#include "src/sem/pointer_type.h"
#include "src/sem/sampled_texture_type.h"
#include "src/sem/sampler_type.h"
#include "src/sem/statement.h"
#include "src/sem/storage_texture_type.h"
#include "src/sem/struct.h"
@ -78,36 +91,36 @@ Source CombineSourceRange(const Source& start, const Source& end) {
start.file_path, start.file_content);
}
bool IsValidStorageTextureDimension(sem::TextureDimension dim) {
bool IsValidStorageTextureDimension(ast::TextureDimension dim) {
switch (dim) {
case sem::TextureDimension::k1d:
case sem::TextureDimension::k2d:
case sem::TextureDimension::k2dArray:
case sem::TextureDimension::k3d:
case ast::TextureDimension::k1d:
case ast::TextureDimension::k2d:
case ast::TextureDimension::k2dArray:
case ast::TextureDimension::k3d:
return true;
default:
return false;
}
}
bool IsValidStorageTextureImageFormat(sem::ImageFormat format) {
bool IsValidStorageTextureImageFormat(ast::ImageFormat format) {
switch (format) {
case sem::ImageFormat::kR32Uint:
case sem::ImageFormat::kR32Sint:
case sem::ImageFormat::kR32Float:
case sem::ImageFormat::kRg32Uint:
case sem::ImageFormat::kRg32Sint:
case sem::ImageFormat::kRg32Float:
case sem::ImageFormat::kRgba8Unorm:
case sem::ImageFormat::kRgba8Snorm:
case sem::ImageFormat::kRgba8Uint:
case sem::ImageFormat::kRgba8Sint:
case sem::ImageFormat::kRgba16Uint:
case sem::ImageFormat::kRgba16Sint:
case sem::ImageFormat::kRgba16Float:
case sem::ImageFormat::kRgba32Uint:
case sem::ImageFormat::kRgba32Sint:
case sem::ImageFormat::kRgba32Float:
case ast::ImageFormat::kR32Uint:
case ast::ImageFormat::kR32Sint:
case ast::ImageFormat::kR32Float:
case ast::ImageFormat::kRg32Uint:
case ast::ImageFormat::kRg32Sint:
case ast::ImageFormat::kRg32Float:
case ast::ImageFormat::kRgba8Unorm:
case ast::ImageFormat::kRgba8Snorm:
case ast::ImageFormat::kRgba8Uint:
case ast::ImageFormat::kRgba8Sint:
case ast::ImageFormat::kRgba16Uint:
case ast::ImageFormat::kRgba16Sint:
case ast::ImageFormat::kRgba16Float:
case ast::ImageFormat::kRgba32Uint:
case ast::ImageFormat::kRgba32Sint:
case ast::ImageFormat::kRgba32Float:
return true;
default:
return false;
@ -266,6 +279,61 @@ bool Resolver::ResolveInternal() {
return true;
}
sem::Type* Resolver::Type(ast::Type* ty) {
Mark(ty);
sem::Type* s = nullptr;
if (ty->Is<ast::Void>()) {
s = builder_->create<sem::Void>();
} else if (ty->Is<ast::Bool>()) {
s = builder_->create<sem::Bool>();
} else if (ty->Is<ast::I32>()) {
s = builder_->create<sem::I32>();
} else if (ty->Is<ast::U32>()) {
s = builder_->create<sem::U32>();
} else if (ty->Is<ast::F32>()) {
s = builder_->create<sem::F32>();
} else if (auto* alias = ty->As<ast::Alias>()) {
auto* el = Type(alias->type());
s = builder_->create<sem::Alias>(alias->symbol(), el);
} else if (auto* access = ty->As<ast::AccessControl>()) {
auto* el = Type(access->type());
s = builder_->create<sem::AccessControl>(access->access_control(), el);
} else if (auto* vec = ty->As<ast::Vector>()) {
auto* el = Type(vec->type());
s = builder_->create<sem::Vector>(el, vec->size());
} else if (auto* mat = ty->As<ast::Matrix>()) {
auto* el = Type(mat->type());
s = builder_->create<sem::Matrix>(el, mat->rows(), mat->columns());
} else if (auto* arr = ty->As<ast::Array>()) {
auto* el = Type(arr->type());
s = builder_->create<sem::ArrayType>(el, arr->size(), arr->decorations());
} else if (auto* ptr = ty->As<ast::Pointer>()) {
auto* el = Type(ptr->type());
s = builder_->create<sem::Pointer>(el, ptr->storage_class());
} else if (auto* str = ty->As<ast::Struct>()) {
s = builder_->create<sem::StructType>(str);
} else if (auto* sampler = ty->As<ast::Sampler>()) {
s = builder_->create<sem::Sampler>(sampler->kind());
} else if (auto* sampled_tex = ty->As<ast::SampledTexture>()) {
auto* el = Type(sampled_tex->type());
s = builder_->create<sem::SampledTexture>(sampled_tex->dim(), el);
} else if (auto* depth_tex = ty->As<ast::DepthTexture>()) {
s = builder_->create<sem::DepthTexture>(depth_tex->dim());
} else if (auto* storage_tex = ty->As<ast::StorageTexture>()) {
auto* el = Type(storage_tex->type());
s = builder_->create<sem::StorageTexture>(storage_tex->dim(),
storage_tex->image_format(), el);
}
if (s == nullptr) {
return nullptr;
}
if (!Type(s)) {
return nullptr;
}
return s;
}
// TODO(crbug.com/tint/724): This method should be replaced by Type(ast::Type*)
bool Resolver::Type(sem::Type* ty) {
ty = ty->UnwrapAliasIfNeeded();
if (auto* str = ty->As<sem::StructType>()) {
@ -413,7 +481,7 @@ bool Resolver::ValidateVariable(const ast::Variable* var) {
}
if (auto* r = type->UnwrapAll()->As<sem::MultisampledTexture>()) {
if (r->dim() != sem::TextureDimension::k2d) {
if (r->dim() != ast::TextureDimension::k2d) {
diagnostics_.add_error("Only 2d multisampled textures are supported",
var->source());
return false;

View File

@ -251,6 +251,12 @@ class Resolver {
bool ValidateVectorConstructor(const sem::Vector* vec_type,
const ast::ExpressionList& values);
/// @returns the sem::Type for the ast::Type `ty`, building it if it
/// hasn't been constructed already. If an error is raised, nullptr is
/// returned.
/// @param ty the ast::Type
sem::Type* Type(ast::Type* ty);
/// @returns the semantic information for the array `arr`, building it if it
/// hasn't been constructed already. If an error is raised, nullptr is
/// returned.

View File

@ -536,17 +536,17 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
namespace MultisampledTextureTests {
struct DimensionParams {
sem::TextureDimension dim;
ast::TextureDimension dim;
bool is_valid;
};
static constexpr DimensionParams dimension_cases[] = {
DimensionParams{sem::TextureDimension::k1d, false},
DimensionParams{sem::TextureDimension::k2d, true},
DimensionParams{sem::TextureDimension::k2dArray, false},
DimensionParams{sem::TextureDimension::k3d, false},
DimensionParams{sem::TextureDimension::kCube, false},
DimensionParams{sem::TextureDimension::kCubeArray, false}};
DimensionParams{ast::TextureDimension::k1d, false},
DimensionParams{ast::TextureDimension::k2d, true},
DimensionParams{ast::TextureDimension::k2dArray, false},
DimensionParams{ast::TextureDimension::k3d, false},
DimensionParams{ast::TextureDimension::kCube, false},
DimensionParams{ast::TextureDimension::kCubeArray, false}};
using MultisampledTextureDimensionTest = ResolverTestWithParam<DimensionParams>;
TEST_P(MultisampledTextureDimensionTest, All) {
@ -594,7 +594,7 @@ using MultisampledTextureTypeTest = ResolverTestWithParam<TypeParams>;
TEST_P(MultisampledTextureTypeTest, All) {
auto& params = GetParam();
Global("a",
create<sem::MultisampledTexture>(sem::TextureDimension::k2d,
create<sem::MultisampledTexture>(ast::TextureDimension::k2d,
params.type_func(ty)),
ast::StorageClass::kUniformConstant, nullptr,
ast::DecorationList{
@ -616,25 +616,25 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
namespace StorageTextureTests {
struct DimensionParams {
sem::TextureDimension dim;
ast::TextureDimension dim;
bool is_valid;
};
static constexpr DimensionParams Dimension_cases[] = {
DimensionParams{sem::TextureDimension::k1d, true},
DimensionParams{sem::TextureDimension::k2d, true},
DimensionParams{sem::TextureDimension::k2dArray, true},
DimensionParams{sem::TextureDimension::k3d, true},
DimensionParams{sem::TextureDimension::kCube, false},
DimensionParams{sem::TextureDimension::kCubeArray, false}};
DimensionParams{ast::TextureDimension::k1d, true},
DimensionParams{ast::TextureDimension::k2d, true},
DimensionParams{ast::TextureDimension::k2dArray, true},
DimensionParams{ast::TextureDimension::k3d, true},
DimensionParams{ast::TextureDimension::kCube, false},
DimensionParams{ast::TextureDimension::kCubeArray, false}};
using StorageTextureDimensionTest = ResolverTestWithParam<DimensionParams>;
TEST_P(StorageTextureDimensionTest, All) {
auto& params = GetParam();
Global("a",
create<sem::StorageTexture>(params.dim, sem::ImageFormat::kR32Uint,
create<sem::StorageTexture>(params.dim, ast::ImageFormat::kR32Uint,
sem::StorageTexture::SubtypeFor(
sem::ImageFormat::kR32Uint, Types())),
ast::ImageFormat::kR32Uint, Types())),
ast::StorageClass::kUniformConstant, nullptr,
ast::DecorationList{
create<ast::BindingDecoration>(0),
@ -652,46 +652,46 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
testing::ValuesIn(Dimension_cases));
struct FormatParams {
sem::ImageFormat format;
ast::ImageFormat format;
bool is_valid;
};
static constexpr FormatParams format_cases[] = {
FormatParams{sem::ImageFormat::kBgra8Unorm, false},
FormatParams{sem::ImageFormat::kBgra8UnormSrgb, false},
FormatParams{sem::ImageFormat::kR16Float, false},
FormatParams{sem::ImageFormat::kR16Sint, false},
FormatParams{sem::ImageFormat::kR16Uint, false},
FormatParams{sem::ImageFormat::kR32Float, true},
FormatParams{sem::ImageFormat::kR32Sint, true},
FormatParams{sem::ImageFormat::kR32Uint, true},
FormatParams{sem::ImageFormat::kR8Sint, false},
FormatParams{sem::ImageFormat::kR8Snorm, false},
FormatParams{sem::ImageFormat::kR8Uint, false},
FormatParams{sem::ImageFormat::kR8Unorm, false},
FormatParams{sem::ImageFormat::kRg11B10Float, false},
FormatParams{sem::ImageFormat::kRg16Float, false},
FormatParams{sem::ImageFormat::kRg16Sint, false},
FormatParams{sem::ImageFormat::kRg16Uint, false},
FormatParams{sem::ImageFormat::kRg32Float, true},
FormatParams{sem::ImageFormat::kRg32Sint, true},
FormatParams{sem::ImageFormat::kRg32Uint, true},
FormatParams{sem::ImageFormat::kRg8Sint, false},
FormatParams{sem::ImageFormat::kRg8Snorm, false},
FormatParams{sem::ImageFormat::kRg8Uint, false},
FormatParams{sem::ImageFormat::kRg8Unorm, false},
FormatParams{sem::ImageFormat::kRgb10A2Unorm, false},
FormatParams{sem::ImageFormat::kRgba16Float, true},
FormatParams{sem::ImageFormat::kRgba16Sint, true},
FormatParams{sem::ImageFormat::kRgba16Uint, true},
FormatParams{sem::ImageFormat::kRgba32Float, true},
FormatParams{sem::ImageFormat::kRgba32Sint, true},
FormatParams{sem::ImageFormat::kRgba32Uint, true},
FormatParams{sem::ImageFormat::kRgba8Sint, true},
FormatParams{sem::ImageFormat::kRgba8Snorm, true},
FormatParams{sem::ImageFormat::kRgba8Uint, true},
FormatParams{sem::ImageFormat::kRgba8Unorm, true},
FormatParams{sem::ImageFormat::kRgba8UnormSrgb, false}};
FormatParams{ast::ImageFormat::kBgra8Unorm, false},
FormatParams{ast::ImageFormat::kBgra8UnormSrgb, false},
FormatParams{ast::ImageFormat::kR16Float, false},
FormatParams{ast::ImageFormat::kR16Sint, false},
FormatParams{ast::ImageFormat::kR16Uint, false},
FormatParams{ast::ImageFormat::kR32Float, true},
FormatParams{ast::ImageFormat::kR32Sint, true},
FormatParams{ast::ImageFormat::kR32Uint, true},
FormatParams{ast::ImageFormat::kR8Sint, false},
FormatParams{ast::ImageFormat::kR8Snorm, false},
FormatParams{ast::ImageFormat::kR8Uint, false},
FormatParams{ast::ImageFormat::kR8Unorm, false},
FormatParams{ast::ImageFormat::kRg11B10Float, false},
FormatParams{ast::ImageFormat::kRg16Float, false},
FormatParams{ast::ImageFormat::kRg16Sint, false},
FormatParams{ast::ImageFormat::kRg16Uint, false},
FormatParams{ast::ImageFormat::kRg32Float, true},
FormatParams{ast::ImageFormat::kRg32Sint, true},
FormatParams{ast::ImageFormat::kRg32Uint, true},
FormatParams{ast::ImageFormat::kRg8Sint, false},
FormatParams{ast::ImageFormat::kRg8Snorm, false},
FormatParams{ast::ImageFormat::kRg8Uint, false},
FormatParams{ast::ImageFormat::kRg8Unorm, false},
FormatParams{ast::ImageFormat::kRgb10A2Unorm, false},
FormatParams{ast::ImageFormat::kRgba16Float, true},
FormatParams{ast::ImageFormat::kRgba16Sint, true},
FormatParams{ast::ImageFormat::kRgba16Uint, true},
FormatParams{ast::ImageFormat::kRgba32Float, true},
FormatParams{ast::ImageFormat::kRgba32Sint, true},
FormatParams{ast::ImageFormat::kRgba32Uint, true},
FormatParams{ast::ImageFormat::kRgba8Sint, true},
FormatParams{ast::ImageFormat::kRgba8Snorm, true},
FormatParams{ast::ImageFormat::kRgba8Uint, true},
FormatParams{ast::ImageFormat::kRgba8Unorm, true},
FormatParams{ast::ImageFormat::kRgba8UnormSrgb, false}};
using StorageTextureFormatTest = ResolverTestWithParam<FormatParams>;
TEST_P(StorageTextureFormatTest, All) {
@ -705,7 +705,7 @@ TEST_P(StorageTextureFormatTest, All) {
Global("a",
create<sem::StorageTexture>(
sem::TextureDimension::k1d, params.format,
ast::TextureDimension::k1d, params.format,
sem::StorageTexture::SubtypeFor(params.format, Types())),
ast::StorageClass::kUniformConstant, nullptr,
ast::DecorationList{
@ -715,7 +715,7 @@ TEST_P(StorageTextureFormatTest, All) {
Global("b",
create<sem::StorageTexture>(
sem::TextureDimension::k2d, params.format,
ast::TextureDimension::k2d, params.format,
sem::StorageTexture::SubtypeFor(params.format, Types())),
ast::StorageClass::kUniformConstant, nullptr,
ast::DecorationList{
@ -725,7 +725,7 @@ TEST_P(StorageTextureFormatTest, All) {
Global("c",
create<sem::StorageTexture>(
sem::TextureDimension::k2dArray, params.format,
ast::TextureDimension::k2dArray, params.format,
sem::StorageTexture::SubtypeFor(params.format, Types())),
ast::StorageClass::kUniformConstant, nullptr,
ast::DecorationList{
@ -735,7 +735,7 @@ TEST_P(StorageTextureFormatTest, All) {
Global("d",
create<sem::StorageTexture>(
sem::TextureDimension::k3d, params.format,
ast::TextureDimension::k3d, params.format,
sem::StorageTexture::SubtypeFor(params.format, Types())),
ast::StorageClass::kUniformConstant, nullptr,
ast::DecorationList{

View File

@ -22,14 +22,16 @@ namespace tint {
namespace sem {
namespace {
bool IsValidDepthDimension(TextureDimension dim) {
return dim == TextureDimension::k2d || dim == TextureDimension::k2dArray ||
dim == TextureDimension::kCube || dim == TextureDimension::kCubeArray;
bool IsValidDepthDimension(ast::TextureDimension dim) {
return dim == ast::TextureDimension::k2d ||
dim == ast::TextureDimension::k2dArray ||
dim == ast::TextureDimension::kCube ||
dim == ast::TextureDimension::kCubeArray;
}
} // namespace
DepthTexture::DepthTexture(TextureDimension dim) : Base(dim) {
DepthTexture::DepthTexture(ast::TextureDimension dim) : Base(dim) {
TINT_ASSERT(IsValidDepthDimension(dim));
}

View File

@ -27,7 +27,7 @@ class DepthTexture : public Castable<DepthTexture, Texture> {
public:
/// Constructor
/// @param dim the dimensionality of the texture
explicit DepthTexture(TextureDimension dim);
explicit DepthTexture(ast::TextureDimension dim);
/// Move constructor
DepthTexture(DepthTexture&&);
~DepthTexture() override;

View File

@ -28,7 +28,7 @@ namespace {
using DepthTextureTest = TestHelper;
TEST_F(DepthTextureTest, Is) {
DepthTexture d(TextureDimension::kCube);
DepthTexture d(ast::TextureDimension::kCube);
Type* ty = &d;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
@ -46,7 +46,7 @@ TEST_F(DepthTextureTest, Is) {
}
TEST_F(DepthTextureTest, IsTexture) {
DepthTexture d(TextureDimension::kCube);
DepthTexture d(ast::TextureDimension::kCube);
Texture* ty = &d;
EXPECT_TRUE(ty->Is<DepthTexture>());
EXPECT_FALSE(ty->Is<ExternalTexture>());
@ -55,17 +55,17 @@ TEST_F(DepthTextureTest, IsTexture) {
}
TEST_F(DepthTextureTest, Dim) {
DepthTexture d(TextureDimension::kCube);
EXPECT_EQ(d.dim(), TextureDimension::kCube);
DepthTexture d(ast::TextureDimension::kCube);
EXPECT_EQ(d.dim(), ast::TextureDimension::kCube);
}
TEST_F(DepthTextureTest, TypeName) {
DepthTexture d(TextureDimension::kCube);
DepthTexture d(ast::TextureDimension::kCube);
EXPECT_EQ(d.type_name(), "__depth_texture_cube");
}
TEST_F(DepthTextureTest, FriendlyName) {
DepthTexture d(TextureDimension::kCube);
DepthTexture d(ast::TextureDimension::kCube);
EXPECT_EQ(d.FriendlyName(Symbols()), "texture_depth_cube");
}

View File

@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::ExternalTexture);
namespace tint {
namespace sem {
ExternalTexture::ExternalTexture() : Base(TextureDimension::k2d) {}
ExternalTexture::ExternalTexture() : Base(ast::TextureDimension::k2d) {}
ExternalTexture::ExternalTexture(ExternalTexture&&) = default;

View File

@ -60,7 +60,7 @@ TEST_F(ExternalTextureTest, IsTexture) {
TEST_F(ExternalTextureTest, Dim) {
F32 f32;
ExternalTexture s;
EXPECT_EQ(s.dim(), TextureDimension::k2d);
EXPECT_EQ(s.dim(), ast::TextureDimension::k2d);
}
TEST_F(ExternalTextureTest, TypeName) {

View File

@ -117,12 +117,12 @@ Function::ReferencedBuiltinVariables() const {
}
Function::VariableBindings Function::ReferencedSamplerVariables() const {
return ReferencedSamplerVariablesImpl(sem::SamplerKind::kSampler);
return ReferencedSamplerVariablesImpl(ast::SamplerKind::kSampler);
}
Function::VariableBindings Function::ReferencedComparisonSamplerVariables()
const {
return ReferencedSamplerVariablesImpl(sem::SamplerKind::kComparisonSampler);
return ReferencedSamplerVariablesImpl(ast::SamplerKind::kComparisonSampler);
}
Function::VariableBindings Function::ReferencedSampledTextureVariables() const {
@ -180,7 +180,7 @@ bool Function::HasAncestorEntryPoint(Symbol symbol) const {
}
Function::VariableBindings Function::ReferencedSamplerVariablesImpl(
sem::SamplerKind kind) const {
ast::SamplerKind kind) const {
VariableBindings ret;
for (auto* var : ReferencedModuleVariables()) {

View File

@ -142,7 +142,7 @@ class Function : public Castable<Function, CallTarget> {
bool HasAncestorEntryPoint(Symbol sym) const;
private:
VariableBindings ReferencedSamplerVariablesImpl(sem::SamplerKind kind) const;
VariableBindings ReferencedSamplerVariablesImpl(ast::SamplerKind kind) const;
VariableBindings ReferencedSampledTextureVariablesImpl(
bool multisampled) const;

View File

@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::MultisampledTexture);
namespace tint {
namespace sem {
MultisampledTexture::MultisampledTexture(TextureDimension dim, Type* type)
MultisampledTexture::MultisampledTexture(ast::TextureDimension dim, Type* type)
: Base(dim), type_(type) {
TINT_ASSERT(type_);
}

View File

@ -28,7 +28,7 @@ class MultisampledTexture : public Castable<MultisampledTexture, Texture> {
/// Constructor
/// @param dim the dimensionality of the texture
/// @param type the data type of the multisampled texture
MultisampledTexture(TextureDimension dim, Type* type);
MultisampledTexture(ast::TextureDimension dim, Type* type);
/// Move constructor
MultisampledTexture(MultisampledTexture&&);
~MultisampledTexture() override;

View File

@ -29,7 +29,7 @@ using MultisampledTextureTest = TestHelper;
TEST_F(MultisampledTextureTest, Is) {
F32 f32;
MultisampledTexture s(TextureDimension::kCube, &f32);
MultisampledTexture s(ast::TextureDimension::kCube, &f32);
Type* ty = &s;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
@ -48,7 +48,7 @@ TEST_F(MultisampledTextureTest, Is) {
TEST_F(MultisampledTextureTest, IsTexture) {
F32 f32;
MultisampledTexture s(TextureDimension::kCube, &f32);
MultisampledTexture s(ast::TextureDimension::kCube, &f32);
Texture* ty = &s;
EXPECT_FALSE(ty->Is<DepthTexture>());
EXPECT_FALSE(ty->Is<ExternalTexture>());
@ -59,24 +59,24 @@ TEST_F(MultisampledTextureTest, IsTexture) {
TEST_F(MultisampledTextureTest, Dim) {
F32 f32;
MultisampledTexture s(TextureDimension::k3d, &f32);
EXPECT_EQ(s.dim(), TextureDimension::k3d);
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
}
TEST_F(MultisampledTextureTest, Type) {
F32 f32;
MultisampledTexture s(TextureDimension::k3d, &f32);
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.type(), &f32);
}
TEST_F(MultisampledTextureTest, TypeName) {
F32 f32;
MultisampledTexture s(TextureDimension::k3d, &f32);
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.type_name(), "__multisampled_texture_3d__f32");
}
TEST_F(MultisampledTextureTest, FriendlyName) {
MultisampledTexture s(TextureDimension::k3d, ty.f32());
MultisampledTexture s(ast::TextureDimension::k3d, ty.f32());
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_multisampled_3d<f32>");
}

View File

@ -29,7 +29,7 @@ class Pointer : public Castable<Pointer, Type> {
/// Construtor
/// @param subtype the pointee type
/// @param storage_class the storage class of the pointer
explicit Pointer(Type* subtype, ast::StorageClass storage_class);
Pointer(Type* subtype, ast::StorageClass storage_class);
/// Move constructor
Pointer(Pointer&&);
~Pointer() override;

View File

@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::SampledTexture);
namespace tint {
namespace sem {
SampledTexture::SampledTexture(TextureDimension dim, Type* type)
SampledTexture::SampledTexture(ast::TextureDimension dim, Type* type)
: Base(dim), type_(type) {
TINT_ASSERT(type_);
}

View File

@ -28,7 +28,7 @@ class SampledTexture : public Castable<SampledTexture, Texture> {
/// Constructor
/// @param dim the dimensionality of the texture
/// @param type the data type of the sampled texture
SampledTexture(TextureDimension dim, Type* type);
SampledTexture(ast::TextureDimension dim, Type* type);
/// Move constructor
SampledTexture(SampledTexture&&);
~SampledTexture() override;

View File

@ -28,7 +28,7 @@ using SampledTextureTest = TestHelper;
TEST_F(SampledTextureTest, Is) {
F32 f32;
SampledTexture s(TextureDimension::kCube, &f32);
SampledTexture s(ast::TextureDimension::kCube, &f32);
Type* ty = &s;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
@ -47,7 +47,7 @@ TEST_F(SampledTextureTest, Is) {
TEST_F(SampledTextureTest, IsTexture) {
F32 f32;
SampledTexture s(TextureDimension::kCube, &f32);
SampledTexture s(ast::TextureDimension::kCube, &f32);
Texture* ty = &s;
EXPECT_FALSE(ty->Is<DepthTexture>());
EXPECT_FALSE(ty->Is<ExternalTexture>());
@ -57,24 +57,24 @@ TEST_F(SampledTextureTest, IsTexture) {
TEST_F(SampledTextureTest, Dim) {
F32 f32;
SampledTexture s(TextureDimension::k3d, &f32);
EXPECT_EQ(s.dim(), TextureDimension::k3d);
SampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
}
TEST_F(SampledTextureTest, Type) {
F32 f32;
SampledTexture s(TextureDimension::k3d, &f32);
SampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.type(), &f32);
}
TEST_F(SampledTextureTest, TypeName) {
F32 f32;
SampledTexture s(TextureDimension::k3d, &f32);
SampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.type_name(), "__sampled_texture_3d__f32");
}
TEST_F(SampledTextureTest, FriendlyName) {
SampledTexture s(TextureDimension::k3d, ty.f32());
SampledTexture s(ast::TextureDimension::k3d, ty.f32());
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_3d<f32>");
}

View File

@ -21,19 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::Sampler);
namespace tint {
namespace sem {
std::ostream& operator<<(std::ostream& out, SamplerKind kind) {
switch (kind) {
case SamplerKind::kSampler:
out << "sampler";
break;
case SamplerKind::kComparisonSampler:
out << "comparison_sampler";
break;
}
return out;
}
Sampler::Sampler(SamplerKind kind) : kind_(kind) {}
Sampler::Sampler(ast::SamplerKind kind) : kind_(kind) {}
Sampler::Sampler(Sampler&&) = default;
@ -41,11 +29,11 @@ Sampler::~Sampler() = default;
std::string Sampler::type_name() const {
return std::string("__sampler_") +
(kind_ == SamplerKind::kSampler ? "sampler" : "comparison");
(kind_ == ast::SamplerKind::kSampler ? "sampler" : "comparison");
}
std::string Sampler::FriendlyName(const SymbolTable&) const {
return kind_ == SamplerKind::kSampler ? "sampler" : "sampler_comparison";
return kind_ == ast::SamplerKind::kSampler ? "sampler" : "sampler_comparison";
}
Sampler* Sampler::Clone(CloneContext* ctx) const {

View File

@ -17,35 +17,29 @@
#include <string>
#include "src/ast/sampler.h"
#include "src/sem/type.h"
namespace tint {
namespace sem {
/// The different kinds of samplers
enum class SamplerKind {
/// A regular sampler
kSampler,
/// A comparison sampler
kComparisonSampler
};
std::ostream& operator<<(std::ostream& out, SamplerKind kind);
/// A sampler type.
class Sampler : public Castable<Sampler, Type> {
public:
/// Constructor
/// @param kind the kind of sampler
explicit Sampler(SamplerKind kind);
explicit Sampler(ast::SamplerKind kind);
/// Move constructor
Sampler(Sampler&&);
~Sampler() override;
/// @returns the sampler type
SamplerKind kind() const { return kind_; }
ast::SamplerKind kind() const { return kind_; }
/// @returns true if this is a comparison sampler
bool IsComparison() const { return kind_ == SamplerKind::kComparisonSampler; }
bool IsComparison() const {
return kind_ == ast::SamplerKind::kComparisonSampler;
}
/// @returns the name for this type
std::string type_name() const override;
@ -61,7 +55,7 @@ class Sampler : public Castable<Sampler, Type> {
Sampler* Clone(CloneContext* ctx) const override;
private:
SamplerKind const kind_;
ast::SamplerKind const kind_;
};
} // namespace sem

View File

@ -23,18 +23,18 @@ namespace {
using SamplerTest = TestHelper;
TEST_F(SamplerTest, Creation) {
Sampler s{SamplerKind::kSampler};
EXPECT_EQ(s.kind(), SamplerKind::kSampler);
Sampler s{ast::SamplerKind::kSampler};
EXPECT_EQ(s.kind(), ast::SamplerKind::kSampler);
}
TEST_F(SamplerTest, Creation_ComparisonSampler) {
Sampler s{SamplerKind::kComparisonSampler};
EXPECT_EQ(s.kind(), SamplerKind::kComparisonSampler);
Sampler s{ast::SamplerKind::kComparisonSampler};
EXPECT_EQ(s.kind(), ast::SamplerKind::kComparisonSampler);
EXPECT_TRUE(s.IsComparison());
}
TEST_F(SamplerTest, Is) {
Sampler s{SamplerKind::kSampler};
Sampler s{ast::SamplerKind::kSampler};
Type* ty = &s;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
@ -52,22 +52,22 @@ TEST_F(SamplerTest, Is) {
}
TEST_F(SamplerTest, TypeName_Sampler) {
Sampler s{SamplerKind::kSampler};
Sampler s{ast::SamplerKind::kSampler};
EXPECT_EQ(s.type_name(), "__sampler_sampler");
}
TEST_F(SamplerTest, TypeName_Comparison) {
Sampler s{SamplerKind::kComparisonSampler};
Sampler s{ast::SamplerKind::kComparisonSampler};
EXPECT_EQ(s.type_name(), "__sampler_comparison");
}
TEST_F(SamplerTest, FriendlyNameSampler) {
Sampler s{SamplerKind::kSampler};
Sampler s{ast::SamplerKind::kSampler};
EXPECT_EQ(s.FriendlyName(Symbols()), "sampler");
}
TEST_F(SamplerTest, FriendlyNameComparisonSampler) {
Sampler s{SamplerKind::kComparisonSampler};
Sampler s{ast::SamplerKind::kComparisonSampler};
EXPECT_EQ(s.FriendlyName(Symbols()), "sampler_comparison");
}

View File

@ -21,124 +21,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::StorageTexture);
namespace tint {
namespace sem {
// Note, these names match the names in the WGSL spec. This behaviour is used
// in the WGSL writer to emit the texture format names.
std::ostream& operator<<(std::ostream& out, ImageFormat format) {
switch (format) {
case ImageFormat::kNone:
out << "none";
break;
case ImageFormat::kR8Unorm:
out << "r8unorm";
break;
case ImageFormat::kR8Snorm:
out << "r8snorm";
break;
case ImageFormat::kR8Uint:
out << "r8uint";
break;
case ImageFormat::kR8Sint:
out << "r8sint";
break;
case ImageFormat::kR16Uint:
out << "r16uint";
break;
case ImageFormat::kR16Sint:
out << "r16sint";
break;
case ImageFormat::kR16Float:
out << "r16float";
break;
case ImageFormat::kRg8Unorm:
out << "rg8unorm";
break;
case ImageFormat::kRg8Snorm:
out << "rg8snorm";
break;
case ImageFormat::kRg8Uint:
out << "rg8uint";
break;
case ImageFormat::kRg8Sint:
out << "rg8sint";
break;
case ImageFormat::kR32Uint:
out << "r32uint";
break;
case ImageFormat::kR32Sint:
out << "r32sint";
break;
case ImageFormat::kR32Float:
out << "r32float";
break;
case ImageFormat::kRg16Uint:
out << "rg16uint";
break;
case ImageFormat::kRg16Sint:
out << "rg16sint";
break;
case ImageFormat::kRg16Float:
out << "rg16float";
break;
case ImageFormat::kRgba8Unorm:
out << "rgba8unorm";
break;
case ImageFormat::kRgba8UnormSrgb:
out << "rgba8unorm_srgb";
break;
case ImageFormat::kRgba8Snorm:
out << "rgba8snorm";
break;
case ImageFormat::kRgba8Uint:
out << "rgba8uint";
break;
case ImageFormat::kRgba8Sint:
out << "rgba8sint";
break;
case ImageFormat::kBgra8Unorm:
out << "bgra8unorm";
break;
case ImageFormat::kBgra8UnormSrgb:
out << "bgra8unorm_srgb";
break;
case ImageFormat::kRgb10A2Unorm:
out << "rgb10a2unorm";
break;
case ImageFormat::kRg11B10Float:
out << "rg11b10float";
break;
case ImageFormat::kRg32Uint:
out << "rg32uint";
break;
case ImageFormat::kRg32Sint:
out << "rg32sint";
break;
case ImageFormat::kRg32Float:
out << "rg32float";
break;
case ImageFormat::kRgba16Uint:
out << "rgba16uint";
break;
case ImageFormat::kRgba16Sint:
out << "rgba16sint";
break;
case ImageFormat::kRgba16Float:
out << "rgba16float";
break;
case ImageFormat::kRgba32Uint:
out << "rgba32uint";
break;
case ImageFormat::kRgba32Sint:
out << "rgba32sint";
break;
case ImageFormat::kRgba32Float:
out << "rgba32float";
break;
}
return out;
}
StorageTexture::StorageTexture(TextureDimension dim,
ImageFormat format,
StorageTexture::StorageTexture(ast::TextureDimension dim,
ast::ImageFormat format,
sem::Type* subtype)
: Base(dim), image_format_(format), subtype_(subtype) {}
@ -164,54 +48,54 @@ StorageTexture* StorageTexture::Clone(CloneContext* ctx) const {
return ctx->dst->create<StorageTexture>(dim(), image_format_, ty);
}
sem::Type* StorageTexture::SubtypeFor(sem::ImageFormat format,
sem::Type* StorageTexture::SubtypeFor(ast::ImageFormat format,
sem::Manager& type_mgr) {
switch (format) {
case sem::ImageFormat::kR8Uint:
case sem::ImageFormat::kR16Uint:
case sem::ImageFormat::kRg8Uint:
case sem::ImageFormat::kR32Uint:
case sem::ImageFormat::kRg16Uint:
case sem::ImageFormat::kRgba8Uint:
case sem::ImageFormat::kRg32Uint:
case sem::ImageFormat::kRgba16Uint:
case sem::ImageFormat::kRgba32Uint: {
case ast::ImageFormat::kR8Uint:
case ast::ImageFormat::kR16Uint:
case ast::ImageFormat::kRg8Uint:
case ast::ImageFormat::kR32Uint:
case ast::ImageFormat::kRg16Uint:
case ast::ImageFormat::kRgba8Uint:
case ast::ImageFormat::kRg32Uint:
case ast::ImageFormat::kRgba16Uint:
case ast::ImageFormat::kRgba32Uint: {
return type_mgr.Get<sem::U32>();
}
case sem::ImageFormat::kR8Sint:
case sem::ImageFormat::kR16Sint:
case sem::ImageFormat::kRg8Sint:
case sem::ImageFormat::kR32Sint:
case sem::ImageFormat::kRg16Sint:
case sem::ImageFormat::kRgba8Sint:
case sem::ImageFormat::kRg32Sint:
case sem::ImageFormat::kRgba16Sint:
case sem::ImageFormat::kRgba32Sint: {
case ast::ImageFormat::kR8Sint:
case ast::ImageFormat::kR16Sint:
case ast::ImageFormat::kRg8Sint:
case ast::ImageFormat::kR32Sint:
case ast::ImageFormat::kRg16Sint:
case ast::ImageFormat::kRgba8Sint:
case ast::ImageFormat::kRg32Sint:
case ast::ImageFormat::kRgba16Sint:
case ast::ImageFormat::kRgba32Sint: {
return type_mgr.Get<sem::I32>();
}
case sem::ImageFormat::kR8Unorm:
case sem::ImageFormat::kRg8Unorm:
case sem::ImageFormat::kRgba8Unorm:
case sem::ImageFormat::kRgba8UnormSrgb:
case sem::ImageFormat::kBgra8Unorm:
case sem::ImageFormat::kBgra8UnormSrgb:
case sem::ImageFormat::kRgb10A2Unorm:
case sem::ImageFormat::kR8Snorm:
case sem::ImageFormat::kRg8Snorm:
case sem::ImageFormat::kRgba8Snorm:
case sem::ImageFormat::kR16Float:
case sem::ImageFormat::kR32Float:
case sem::ImageFormat::kRg16Float:
case sem::ImageFormat::kRg11B10Float:
case sem::ImageFormat::kRg32Float:
case sem::ImageFormat::kRgba16Float:
case sem::ImageFormat::kRgba32Float: {
case ast::ImageFormat::kR8Unorm:
case ast::ImageFormat::kRg8Unorm:
case ast::ImageFormat::kRgba8Unorm:
case ast::ImageFormat::kRgba8UnormSrgb:
case ast::ImageFormat::kBgra8Unorm:
case ast::ImageFormat::kBgra8UnormSrgb:
case ast::ImageFormat::kRgb10A2Unorm:
case ast::ImageFormat::kR8Snorm:
case ast::ImageFormat::kRg8Snorm:
case ast::ImageFormat::kRgba8Snorm:
case ast::ImageFormat::kR16Float:
case ast::ImageFormat::kR32Float:
case ast::ImageFormat::kRg16Float:
case ast::ImageFormat::kRg11B10Float:
case ast::ImageFormat::kRg32Float:
case ast::ImageFormat::kRgba16Float:
case ast::ImageFormat::kRgba32Float: {
return type_mgr.Get<sem::F32>();
}
case sem::ImageFormat::kNone:
case ast::ImageFormat::kNone:
break;
}

View File

@ -17,6 +17,7 @@
#include <string>
#include "src/ast/storage_texture.h"
#include "src/sem/texture_type.h"
namespace tint {
@ -24,47 +25,6 @@ namespace sem {
class Manager;
/// The image format in the storage texture
enum class ImageFormat {
kNone = -1,
kR8Unorm,
kR8Snorm,
kR8Uint,
kR8Sint,
kR16Uint,
kR16Sint,
kR16Float,
kRg8Unorm,
kRg8Snorm,
kRg8Uint,
kRg8Sint,
kR32Uint,
kR32Sint,
kR32Float,
kRg16Uint,
kRg16Sint,
kRg16Float,
kRgba8Unorm,
kRgba8UnormSrgb,
kRgba8Snorm,
kRgba8Uint,
kRgba8Sint,
kBgra8Unorm,
kBgra8UnormSrgb,
kRgb10A2Unorm,
kRg11B10Float,
kRg32Uint,
kRg32Sint,
kRg32Float,
kRgba16Uint,
kRgba16Sint,
kRgba16Float,
kRgba32Uint,
kRgba32Sint,
kRgba32Float,
};
std::ostream& operator<<(std::ostream& out, ImageFormat dim);
/// A storage texture type.
class StorageTexture : public Castable<StorageTexture, Texture> {
public:
@ -72,7 +32,9 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
/// @param dim the dimensionality of the texture
/// @param format the image format of the texture
/// @param subtype the storage subtype. Use SubtypeFor() to calculate this.
StorageTexture(TextureDimension dim, ImageFormat format, sem::Type* subtype);
StorageTexture(ast::TextureDimension dim,
ast::ImageFormat format,
sem::Type* subtype);
/// Move constructor
StorageTexture(StorageTexture&&);
@ -82,7 +44,7 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
Type* type() const { return subtype_; }
/// @returns the image format
ImageFormat image_format() const { return image_format_; }
ast::ImageFormat image_format() const { return image_format_; }
/// @returns the name for this type
std::string type_name() const override;
@ -100,10 +62,10 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
/// @param format the storage texture image format
/// @param type_mgr the sem::Manager used to build the returned type
/// @returns the storage texture subtype for the given ImageFormat
static sem::Type* SubtypeFor(sem::ImageFormat format, sem::Manager& type_mgr);
static sem::Type* SubtypeFor(ast::ImageFormat format, sem::Manager& type_mgr);
private:
ImageFormat const image_format_;
ast::ImageFormat const image_format_;
Type* const subtype_;
};

View File

@ -28,9 +28,9 @@ using StorageTextureTest = TestHelper;
TEST_F(StorageTextureTest, Is) {
auto* subtype =
StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Float, subtype);
Type* ty = s;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
@ -49,9 +49,9 @@ TEST_F(StorageTextureTest, Is) {
TEST_F(StorageTextureTest, IsTexture) {
auto* subtype =
StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Float, subtype);
Texture* ty = s;
EXPECT_FALSE(ty->Is<DepthTexture>());
EXPECT_FALSE(ty->Is<ExternalTexture>());
@ -61,42 +61,42 @@ TEST_F(StorageTextureTest, IsTexture) {
TEST_F(StorageTextureTest, Dim) {
auto* subtype =
StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
EXPECT_EQ(s->dim(), TextureDimension::k2dArray);
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Float, subtype);
EXPECT_EQ(s->dim(), ast::TextureDimension::k2dArray);
}
TEST_F(StorageTextureTest, Format) {
auto* subtype =
StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
EXPECT_EQ(s->image_format(), ImageFormat::kRgba32Float);
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Float, subtype);
EXPECT_EQ(s->image_format(), ast::ImageFormat::kRgba32Float);
}
TEST_F(StorageTextureTest, TypeName) {
auto* subtype =
StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Float, subtype);
EXPECT_EQ(s->type_name(), "__storage_texture_2d_array_rgba32float");
}
TEST_F(StorageTextureTest, FriendlyName) {
auto* subtype =
StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Float, subtype);
EXPECT_EQ(s->FriendlyName(Symbols()),
"texture_storage_2d_array<rgba32float>");
}
TEST_F(StorageTextureTest, F32) {
auto* subtype =
sem::StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Float, subtype);
auto program = Build();
@ -108,9 +108,9 @@ TEST_F(StorageTextureTest, F32) {
TEST_F(StorageTextureTest, U32) {
auto* subtype =
sem::StorageTexture::SubtypeFor(ImageFormat::kRg32Uint, Types());
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRg32Uint, subtype);
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRg32Uint, Types());
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRg32Uint, subtype);
auto program = Build();
@ -122,9 +122,9 @@ TEST_F(StorageTextureTest, U32) {
TEST_F(StorageTextureTest, I32) {
auto* subtype =
sem::StorageTexture::SubtypeFor(ImageFormat::kRgba32Sint, Types());
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Sint, subtype);
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Sint, Types());
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Sint, subtype);
auto program = Build();

View File

@ -19,66 +19,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::Texture);
namespace tint {
namespace sem {
std::ostream& operator<<(std::ostream& out, TextureDimension dim) {
switch (dim) {
case TextureDimension::kNone:
out << "None";
break;
case TextureDimension::k1d:
out << "1d";
break;
case TextureDimension::k2d:
out << "2d";
break;
case TextureDimension::k2dArray:
out << "2d_array";
break;
case TextureDimension::k3d:
out << "3d";
break;
case TextureDimension::kCube:
out << "cube";
break;
case TextureDimension::kCubeArray:
out << "cube_array";
break;
}
return out;
}
bool IsTextureArray(TextureDimension dim) {
switch (dim) {
case TextureDimension::k2dArray:
case TextureDimension::kCubeArray:
return true;
case TextureDimension::k2d:
case TextureDimension::kNone:
case TextureDimension::k1d:
case TextureDimension::k3d:
case TextureDimension::kCube:
return false;
}
return false;
}
int NumCoordinateAxes(TextureDimension dim) {
switch (dim) {
case TextureDimension::kNone:
return 0;
case TextureDimension::k1d:
return 1;
case TextureDimension::k2d:
case TextureDimension::k2dArray:
return 2;
case TextureDimension::k3d:
case TextureDimension::kCube:
case TextureDimension::kCubeArray:
return 3;
}
return 0;
}
Texture::Texture(TextureDimension dim) : dim_(dim) {}
Texture::Texture(ast::TextureDimension dim) : dim_(dim) {}
Texture::Texture(Texture&&) = default;

View File

@ -15,58 +15,27 @@
#ifndef SRC_SEM_TEXTURE_TYPE_H_
#define SRC_SEM_TEXTURE_TYPE_H_
#include "src/ast/texture.h"
#include "src/sem/type.h"
namespace tint {
namespace sem {
/// The dimensionality of the texture
enum class TextureDimension {
/// Invalid texture
kNone = -1,
/// 1 dimensional texture
k1d,
/// 2 dimensional texture
k2d,
/// 2 dimensional array texture
k2dArray,
/// 3 dimensional texture
k3d,
/// cube texture
kCube,
/// cube array texture
kCubeArray,
};
std::ostream& operator<<(std::ostream& out, TextureDimension dim);
/// @param dim the TextureDimension to query
/// @return true if the given TextureDimension is an array texture
bool IsTextureArray(TextureDimension dim);
/// Returns the number of axes in the coordinate for a dimensionality.
/// None -> 0
/// 1D -> 1
/// 2D, 2DArray -> 2
/// 3D, Cube, CubeArray -> 3
/// @param dim the TextureDimension to query
/// @return number of dimensions in a coordinate for the dimensionality
int NumCoordinateAxes(TextureDimension dim);
/// A texture type.
class Texture : public Castable<Texture, Type> {
public:
/// Constructor
/// @param dim the dimensionality of the texture
explicit Texture(TextureDimension dim);
explicit Texture(ast::TextureDimension dim);
/// Move constructor
Texture(Texture&&);
~Texture() override;
/// @returns the texture dimension
TextureDimension dim() const { return dim_; }
ast::TextureDimension dim() const { return dim_; }
private:
TextureDimension const dim_;
ast::TextureDimension const dim_;
};
} // namespace sem

View File

@ -23,23 +23,23 @@ namespace {
using TextureTypeTest = TestHelper;
TEST_F(TextureTypeTest, IsTextureArray) {
EXPECT_EQ(false, IsTextureArray(TextureDimension::kNone));
EXPECT_EQ(false, IsTextureArray(TextureDimension::k1d));
EXPECT_EQ(false, IsTextureArray(TextureDimension::k2d));
EXPECT_EQ(true, IsTextureArray(TextureDimension::k2dArray));
EXPECT_EQ(false, IsTextureArray(TextureDimension::k3d));
EXPECT_EQ(false, IsTextureArray(TextureDimension::kCube));
EXPECT_EQ(true, IsTextureArray(TextureDimension::kCubeArray));
EXPECT_EQ(false, IsTextureArray(ast::TextureDimension::kNone));
EXPECT_EQ(false, IsTextureArray(ast::TextureDimension::k1d));
EXPECT_EQ(false, IsTextureArray(ast::TextureDimension::k2d));
EXPECT_EQ(true, IsTextureArray(ast::TextureDimension::k2dArray));
EXPECT_EQ(false, IsTextureArray(ast::TextureDimension::k3d));
EXPECT_EQ(false, IsTextureArray(ast::TextureDimension::kCube));
EXPECT_EQ(true, IsTextureArray(ast::TextureDimension::kCubeArray));
}
TEST_F(TextureTypeTest, NumCoordinateAxes) {
EXPECT_EQ(0, NumCoordinateAxes(TextureDimension::kNone));
EXPECT_EQ(1, NumCoordinateAxes(TextureDimension::k1d));
EXPECT_EQ(2, NumCoordinateAxes(TextureDimension::k2d));
EXPECT_EQ(2, NumCoordinateAxes(TextureDimension::k2dArray));
EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::k3d));
EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::kCube));
EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::kCubeArray));
EXPECT_EQ(0, NumCoordinateAxes(ast::TextureDimension::kNone));
EXPECT_EQ(1, NumCoordinateAxes(ast::TextureDimension::k1d));
EXPECT_EQ(2, NumCoordinateAxes(ast::TextureDimension::k2d));
EXPECT_EQ(2, NumCoordinateAxes(ast::TextureDimension::k2dArray));
EXPECT_EQ(3, NumCoordinateAxes(ast::TextureDimension::k3d));
EXPECT_EQ(3, NumCoordinateAxes(ast::TextureDimension::kCube));
EXPECT_EQ(3, NumCoordinateAxes(ast::TextureDimension::kCubeArray));
}
} // namespace

View File

@ -58,26 +58,26 @@ bool last_is_break_or_fallthrough(const ast::BlockStatement* stmts) {
stmts->last()->Is<ast::FallthroughStatement>();
}
const char* image_format_to_rwtexture_type(sem::ImageFormat image_format) {
const char* image_format_to_rwtexture_type(ast::ImageFormat image_format) {
switch (image_format) {
case sem::ImageFormat::kRgba8Unorm:
case sem::ImageFormat::kRgba8Snorm:
case sem::ImageFormat::kRgba16Float:
case sem::ImageFormat::kR32Float:
case sem::ImageFormat::kRg32Float:
case sem::ImageFormat::kRgba32Float:
case ast::ImageFormat::kRgba8Unorm:
case ast::ImageFormat::kRgba8Snorm:
case ast::ImageFormat::kRgba16Float:
case ast::ImageFormat::kR32Float:
case ast::ImageFormat::kRg32Float:
case ast::ImageFormat::kRgba32Float:
return "float4";
case sem::ImageFormat::kRgba8Uint:
case sem::ImageFormat::kRgba16Uint:
case sem::ImageFormat::kR32Uint:
case sem::ImageFormat::kRg32Uint:
case sem::ImageFormat::kRgba32Uint:
case ast::ImageFormat::kRgba8Uint:
case ast::ImageFormat::kRgba16Uint:
case ast::ImageFormat::kR32Uint:
case ast::ImageFormat::kRg32Uint:
case ast::ImageFormat::kRgba32Uint:
return "uint4";
case sem::ImageFormat::kRgba8Sint:
case sem::ImageFormat::kRgba16Sint:
case sem::ImageFormat::kR32Sint:
case sem::ImageFormat::kRg32Sint:
case sem::ImageFormat::kRgba32Sint:
case ast::ImageFormat::kRgba8Sint:
case ast::ImageFormat::kRgba16Sint:
case ast::ImageFormat::kR32Sint:
case ast::ImageFormat::kRg32Sint:
case ast::ImageFormat::kRgba32Sint:
return "int4";
default:
return nullptr;
@ -881,30 +881,30 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre,
switch (intrinsic->Type()) {
case sem::IntrinsicType::kTextureDimensions:
switch (texture_type->dim()) {
case sem::TextureDimension::kNone:
case ast::TextureDimension::kNone:
TINT_ICE(diagnostics_) << "texture dimension is kNone";
return false;
case sem::TextureDimension::k1d:
case ast::TextureDimension::k1d:
num_dimensions = 1;
break;
case sem::TextureDimension::k2d:
case ast::TextureDimension::k2d:
num_dimensions = is_ms ? 3 : 2;
swizzle = is_ms ? ".xy" : "";
break;
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2dArray:
num_dimensions = is_ms ? 4 : 3;
swizzle = ".xy";
break;
case sem::TextureDimension::k3d:
case ast::TextureDimension::k3d:
num_dimensions = 3;
break;
case sem::TextureDimension::kCube:
case ast::TextureDimension::kCube:
// width == height == depth for cubes
// See https://github.com/gpuweb/gpuweb/issues/1345
num_dimensions = 2;
swizzle = ".xyy"; // [width, height, height]
break;
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::kCubeArray:
// width == height == depth for cubes
// See https://github.com/gpuweb/gpuweb/issues/1345
num_dimensions = 3;
@ -917,11 +917,11 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre,
default:
TINT_ICE(diagnostics_) << "texture dimension is not arrayed";
return false;
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2dArray:
num_dimensions = is_ms ? 4 : 3;
swizzle = ".z";
break;
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::kCubeArray:
num_dimensions = 3;
swizzle = ".z";
break;
@ -933,14 +933,14 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre,
TINT_ICE(diagnostics_)
<< "texture dimension does not support mips";
return false;
case sem::TextureDimension::k2d:
case sem::TextureDimension::kCube:
case ast::TextureDimension::k2d:
case ast::TextureDimension::kCube:
num_dimensions = 3;
swizzle = ".z";
break;
case sem::TextureDimension::k2dArray:
case sem::TextureDimension::k3d:
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::k2dArray:
case ast::TextureDimension::k3d:
case ast::TextureDimension::kCubeArray:
num_dimensions = 4;
swizzle = ".w";
break;
@ -952,11 +952,11 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre,
TINT_ICE(diagnostics_)
<< "texture dimension does not support multisampling";
return false;
case sem::TextureDimension::k2d:
case ast::TextureDimension::k2d:
num_dimensions = 3;
swizzle = ".z";
break;
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2dArray:
num_dimensions = 4;
swizzle = ".w";
break;
@ -2466,22 +2466,22 @@ bool GeneratorImpl::EmitType(std::ostream& out,
out << "Texture";
switch (tex->dim()) {
case sem::TextureDimension::k1d:
case ast::TextureDimension::k1d:
out << "1D";
break;
case sem::TextureDimension::k2d:
case ast::TextureDimension::k2d:
out << (multism ? "2DMS" : "2D");
break;
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2dArray:
out << (multism ? "2DMSArray" : "2DArray");
break;
case sem::TextureDimension::k3d:
case ast::TextureDimension::k3d:
out << "3D";
break;
case sem::TextureDimension::kCube:
case ast::TextureDimension::kCube:
out << "Cube";
break;
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::kCubeArray:
out << "CubeArray";
break;
default:

View File

@ -295,7 +295,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Void) {
}
TEST_F(HlslGeneratorImplTest_Type, EmitSampler) {
sem::Sampler sampler(sem::SamplerKind::kSampler);
sem::Sampler sampler(ast::SamplerKind::kSampler);
GeneratorImpl& gen = Build();
@ -305,7 +305,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSampler) {
}
TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) {
sem::Sampler sampler(sem::SamplerKind::kComparisonSampler);
sem::Sampler sampler(ast::SamplerKind::kComparisonSampler);
GeneratorImpl& gen = Build();
@ -315,7 +315,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) {
}
struct HlslDepthTextureData {
sem::TextureDimension dim;
ast::TextureDimension dim;
std::string result;
};
inline std::ostream& operator<<(std::ostream& out, HlslDepthTextureData data) {
@ -349,18 +349,18 @@ INSTANTIATE_TEST_SUITE_P(
HlslGeneratorImplTest_Type,
HlslDepthTexturesTest,
testing::Values(
HlslDepthTextureData{sem::TextureDimension::k2d,
HlslDepthTextureData{ast::TextureDimension::k2d,
"Texture2D tex : register(t1, space2);"},
HlslDepthTextureData{sem::TextureDimension::k2dArray,
HlslDepthTextureData{ast::TextureDimension::k2dArray,
"Texture2DArray tex : register(t1, space2);"},
HlslDepthTextureData{sem::TextureDimension::kCube,
HlslDepthTextureData{ast::TextureDimension::kCube,
"TextureCube tex : register(t1, space2);"},
HlslDepthTextureData{sem::TextureDimension::kCubeArray,
HlslDepthTextureData{ast::TextureDimension::kCubeArray,
"TextureCubeArray tex : register(t1, space2);"}));
enum class TextureDataType { F32, U32, I32 };
struct HlslSampledTextureData {
sem::TextureDimension dim;
ast::TextureDimension dim;
TextureDataType datatype;
std::string result;
};
@ -409,98 +409,98 @@ INSTANTIATE_TEST_SUITE_P(
HlslSampledTexturesTest,
testing::Values(
HlslSampledTextureData{
sem::TextureDimension::k1d,
ast::TextureDimension::k1d,
TextureDataType::F32,
"Texture1D<float4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::k2d,
ast::TextureDimension::k2d,
TextureDataType::F32,
"Texture2D<float4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::k2dArray,
ast::TextureDimension::k2dArray,
TextureDataType::F32,
"Texture2DArray<float4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::k3d,
ast::TextureDimension::k3d,
TextureDataType::F32,
"Texture3D<float4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::kCube,
ast::TextureDimension::kCube,
TextureDataType::F32,
"TextureCube<float4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::kCubeArray,
ast::TextureDimension::kCubeArray,
TextureDataType::F32,
"TextureCubeArray<float4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::k1d,
ast::TextureDimension::k1d,
TextureDataType::U32,
"Texture1D<uint4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::k2d,
ast::TextureDimension::k2d,
TextureDataType::U32,
"Texture2D<uint4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::k2dArray,
ast::TextureDimension::k2dArray,
TextureDataType::U32,
"Texture2DArray<uint4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::k3d,
ast::TextureDimension::k3d,
TextureDataType::U32,
"Texture3D<uint4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::kCube,
ast::TextureDimension::kCube,
TextureDataType::U32,
"TextureCube<uint4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::kCubeArray,
ast::TextureDimension::kCubeArray,
TextureDataType::U32,
"TextureCubeArray<uint4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::k1d,
ast::TextureDimension::k1d,
TextureDataType::I32,
"Texture1D<int4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::k2d,
ast::TextureDimension::k2d,
TextureDataType::I32,
"Texture2D<int4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::k2dArray,
ast::TextureDimension::k2dArray,
TextureDataType::I32,
"Texture2DArray<int4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::k3d,
ast::TextureDimension::k3d,
TextureDataType::I32,
"Texture3D<int4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::kCube,
ast::TextureDimension::kCube,
TextureDataType::I32,
"TextureCube<int4> tex : register(t1, space2);",
},
HlslSampledTextureData{
sem::TextureDimension::kCubeArray,
ast::TextureDimension::kCubeArray,
TextureDataType::I32,
"TextureCubeArray<int4> tex : register(t1, space2);",
}));
TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
sem::MultisampledTexture s(sem::TextureDimension::k2d, ty.f32());
sem::MultisampledTexture s(ast::TextureDimension::k2d, ty.f32());
GeneratorImpl& gen = Build();
@ -510,8 +510,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
}
struct HlslStorageTextureData {
sem::TextureDimension dim;
sem::ImageFormat imgfmt;
ast::TextureDimension dim;
ast::ImageFormat imgfmt;
bool ro;
std::string result;
};
@ -552,44 +552,44 @@ INSTANTIATE_TEST_SUITE_P(
HlslGeneratorImplTest_Type,
HlslStorageTexturesTest,
testing::Values(
HlslStorageTextureData{sem::TextureDimension::k1d,
sem::ImageFormat::kRgba8Unorm, true,
HlslStorageTextureData{ast::TextureDimension::k1d,
ast::ImageFormat::kRgba8Unorm, true,
"Texture1D<float4> tex : register(t1, space2);"},
HlslStorageTextureData{sem::TextureDimension::k2d,
sem::ImageFormat::kRgba16Float, true,
HlslStorageTextureData{ast::TextureDimension::k2d,
ast::ImageFormat::kRgba16Float, true,
"Texture2D<float4> tex : register(t1, space2);"},
HlslStorageTextureData{
sem::TextureDimension::k2dArray, sem::ImageFormat::kR32Float, true,
ast::TextureDimension::k2dArray, ast::ImageFormat::kR32Float, true,
"Texture2DArray<float4> tex : register(t1, space2);"},
HlslStorageTextureData{sem::TextureDimension::k3d,
sem::ImageFormat::kRg32Float, true,
HlslStorageTextureData{ast::TextureDimension::k3d,
ast::ImageFormat::kRg32Float, true,
"Texture3D<float4> tex : register(t1, space2);"},
HlslStorageTextureData{
sem::TextureDimension::k1d, sem::ImageFormat::kRgba32Float, false,
ast::TextureDimension::k1d, ast::ImageFormat::kRgba32Float, false,
"RWTexture1D<float4> tex : register(u1, space2);"},
HlslStorageTextureData{
sem::TextureDimension::k2d, sem::ImageFormat::kRgba16Uint, false,
ast::TextureDimension::k2d, ast::ImageFormat::kRgba16Uint, false,
"RWTexture2D<uint4> tex : register(u1, space2);"},
HlslStorageTextureData{
sem::TextureDimension::k2dArray, sem::ImageFormat::kR32Uint, false,
ast::TextureDimension::k2dArray, ast::ImageFormat::kR32Uint, false,
"RWTexture2DArray<uint4> tex : register(u1, space2);"},
HlslStorageTextureData{
sem::TextureDimension::k3d, sem::ImageFormat::kRg32Uint, false,
ast::TextureDimension::k3d, ast::ImageFormat::kRg32Uint, false,
"RWTexture3D<uint4> tex : register(u1, space2);"},
HlslStorageTextureData{sem::TextureDimension::k1d,
sem::ImageFormat::kRgba32Uint, true,
HlslStorageTextureData{ast::TextureDimension::k1d,
ast::ImageFormat::kRgba32Uint, true,
"Texture1D<uint4> tex : register(t1, space2);"},
HlslStorageTextureData{sem::TextureDimension::k2d,
sem::ImageFormat::kRgba16Sint, true,
HlslStorageTextureData{ast::TextureDimension::k2d,
ast::ImageFormat::kRgba16Sint, true,
"Texture2D<int4> tex : register(t1, space2);"},
HlslStorageTextureData{
sem::TextureDimension::k2dArray, sem::ImageFormat::kR32Sint, true,
ast::TextureDimension::k2dArray, ast::ImageFormat::kR32Sint, true,
"Texture2DArray<int4> tex : register(t1, space2);"},
HlslStorageTextureData{sem::TextureDimension::k3d,
sem::ImageFormat::kRg32Sint, true,
HlslStorageTextureData{ast::TextureDimension::k3d,
ast::ImageFormat::kRg32Sint, true,
"Texture3D<int4> tex : register(t1, space2);"},
HlslStorageTextureData{
sem::TextureDimension::k1d, sem::ImageFormat::kRgba32Sint, false,
ast::TextureDimension::k1d, ast::ImageFormat::kRgba32Sint, false,
"RWTexture1D<int4> tex : register(u1, space2);"}));
} // namespace

View File

@ -496,21 +496,21 @@ bool GeneratorImpl::EmitTextureCall(ast::CallExpression* expr,
case sem::IntrinsicType::kTextureDimensions: {
std::vector<const char*> dims;
switch (texture_type->dim()) {
case sem::TextureDimension::kNone:
case ast::TextureDimension::kNone:
diagnostics_.add_error("texture dimension is kNone");
return false;
case sem::TextureDimension::k1d:
case ast::TextureDimension::k1d:
dims = {"width"};
break;
case sem::TextureDimension::k2d:
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2d:
case ast::TextureDimension::k2dArray:
dims = {"width", "height"};
break;
case sem::TextureDimension::k3d:
case ast::TextureDimension::k3d:
dims = {"width", "height", "depth"};
break;
case sem::TextureDimension::kCube:
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::kCube:
case ast::TextureDimension::kCubeArray:
// width == height == depth for cubes
// See https://github.com/gpuweb/gpuweb/issues/1345
dims = {"width", "height", "height"};
@ -645,17 +645,17 @@ bool GeneratorImpl::EmitTextureCall(ast::CallExpression* expr,
if (auto* ddx = arg(Usage::kDdx)) {
auto dim = texture_type->dim();
switch (dim) {
case sem::TextureDimension::k2d:
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2d:
case ast::TextureDimension::k2dArray:
maybe_write_comma();
out_ << "gradient2d(";
break;
case sem::TextureDimension::k3d:
case ast::TextureDimension::k3d:
maybe_write_comma();
out_ << "gradient3d(";
break;
case sem::TextureDimension::kCube:
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::kCube:
case ast::TextureDimension::kCubeArray:
maybe_write_comma();
out_ << "gradientcube(";
break;
@ -1959,22 +1959,22 @@ bool GeneratorImpl::EmitType(sem::Type* type, const std::string& name) {
}
switch (tex->dim()) {
case sem::TextureDimension::k1d:
case ast::TextureDimension::k1d:
out_ << "1d";
break;
case sem::TextureDimension::k2d:
case ast::TextureDimension::k2d:
out_ << "2d";
break;
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2dArray:
out_ << "2d_array";
break;
case sem::TextureDimension::k3d:
case ast::TextureDimension::k3d:
out_ << "3d";
break;
case sem::TextureDimension::kCube:
case ast::TextureDimension::kCube:
out_ << "cube";
break;
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::kCubeArray:
out_ << "cube_array";
break;
default:

View File

@ -631,7 +631,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Void) {
}
TEST_F(MslGeneratorImplTest, EmitType_Sampler) {
sem::Sampler sampler(sem::SamplerKind::kSampler);
sem::Sampler sampler(ast::SamplerKind::kSampler);
GeneratorImpl& gen = Build();
@ -640,7 +640,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Sampler) {
}
TEST_F(MslGeneratorImplTest, EmitType_SamplerComparison) {
sem::Sampler sampler(sem::SamplerKind::kComparisonSampler);
sem::Sampler sampler(ast::SamplerKind::kComparisonSampler);
GeneratorImpl& gen = Build();
@ -649,7 +649,7 @@ TEST_F(MslGeneratorImplTest, EmitType_SamplerComparison) {
}
struct MslDepthTextureData {
sem::TextureDimension dim;
ast::TextureDimension dim;
std::string result;
};
inline std::ostream& operator<<(std::ostream& out, MslDepthTextureData data) {
@ -670,18 +670,18 @@ TEST_P(MslDepthTexturesTest, Emit) {
INSTANTIATE_TEST_SUITE_P(
MslGeneratorImplTest,
MslDepthTexturesTest,
testing::Values(MslDepthTextureData{sem::TextureDimension::k2d,
testing::Values(MslDepthTextureData{ast::TextureDimension::k2d,
"depth2d<float, access::sample>"},
MslDepthTextureData{sem::TextureDimension::k2dArray,
MslDepthTextureData{ast::TextureDimension::k2dArray,
"depth2d_array<float, access::sample>"},
MslDepthTextureData{sem::TextureDimension::kCube,
MslDepthTextureData{ast::TextureDimension::kCube,
"depthcube<float, access::sample>"},
MslDepthTextureData{
sem::TextureDimension::kCubeArray,
ast::TextureDimension::kCubeArray,
"depthcube_array<float, access::sample>"}));
struct MslTextureData {
sem::TextureDimension dim;
ast::TextureDimension dim;
std::string result;
};
inline std::ostream& operator<<(std::ostream& out, MslTextureData data) {
@ -702,22 +702,22 @@ TEST_P(MslSampledtexturesTest, Emit) {
INSTANTIATE_TEST_SUITE_P(
MslGeneratorImplTest,
MslSampledtexturesTest,
testing::Values(MslTextureData{sem::TextureDimension::k1d,
testing::Values(MslTextureData{ast::TextureDimension::k1d,
"texture1d<float, access::sample>"},
MslTextureData{sem::TextureDimension::k2d,
MslTextureData{ast::TextureDimension::k2d,
"texture2d<float, access::sample>"},
MslTextureData{sem::TextureDimension::k2dArray,
MslTextureData{ast::TextureDimension::k2dArray,
"texture2d_array<float, access::sample>"},
MslTextureData{sem::TextureDimension::k3d,
MslTextureData{ast::TextureDimension::k3d,
"texture3d<float, access::sample>"},
MslTextureData{sem::TextureDimension::kCube,
MslTextureData{ast::TextureDimension::kCube,
"texturecube<float, access::sample>"},
MslTextureData{
sem::TextureDimension::kCubeArray,
ast::TextureDimension::kCubeArray,
"texturecube_array<float, access::sample>"}));
TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
sem::MultisampledTexture s(sem::TextureDimension::k2d, ty.u32());
sem::MultisampledTexture s(ast::TextureDimension::k2d, ty.u32());
GeneratorImpl& gen = Build();
@ -726,7 +726,7 @@ TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
}
struct MslStorageTextureData {
sem::TextureDimension dim;
ast::TextureDimension dim;
bool ro;
std::string result;
};
@ -739,8 +739,8 @@ TEST_P(MslStorageTexturesTest, Emit) {
auto params = GetParam();
auto* subtype =
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types());
auto* s = create<sem::StorageTexture>(params.dim, sem::ImageFormat::kR32Float,
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Float, Types());
auto* s = create<sem::StorageTexture>(params.dim, ast::ImageFormat::kR32Float,
subtype);
auto* ac =
create<sem::AccessControl>(params.ro ? ast::AccessControl::kReadOnly
@ -757,21 +757,21 @@ INSTANTIATE_TEST_SUITE_P(
MslGeneratorImplTest,
MslStorageTexturesTest,
testing::Values(
MslStorageTextureData{sem::TextureDimension::k1d, true,
MslStorageTextureData{ast::TextureDimension::k1d, true,
"texture1d<float, access::read>"},
MslStorageTextureData{sem::TextureDimension::k2d, true,
MslStorageTextureData{ast::TextureDimension::k2d, true,
"texture2d<float, access::read>"},
MslStorageTextureData{sem::TextureDimension::k2dArray, true,
MslStorageTextureData{ast::TextureDimension::k2dArray, true,
"texture2d_array<float, access::read>"},
MslStorageTextureData{sem::TextureDimension::k3d, true,
MslStorageTextureData{ast::TextureDimension::k3d, true,
"texture3d<float, access::read>"},
MslStorageTextureData{sem::TextureDimension::k1d, false,
MslStorageTextureData{ast::TextureDimension::k1d, false,
"texture1d<float, access::write>"},
MslStorageTextureData{sem::TextureDimension::k2d, false,
MslStorageTextureData{ast::TextureDimension::k2d, false,
"texture2d<float, access::write>"},
MslStorageTextureData{sem::TextureDimension::k2dArray, false,
MslStorageTextureData{ast::TextureDimension::k2dArray, false,
"texture2d_array<float, access::write>"},
MslStorageTextureData{sem::TextureDimension::k3d, false,
MslStorageTextureData{ast::TextureDimension::k3d, false,
"texture3d<float, access::write>"}));
} // namespace

View File

@ -2271,22 +2271,22 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call,
std::vector<uint32_t> swizzle;
uint32_t spirv_dims = 0;
switch (texture_type->dim()) {
case sem::TextureDimension::kNone:
case ast::TextureDimension::kNone:
error_ = "texture dimension is kNone";
return false;
case sem::TextureDimension::k1d:
case sem::TextureDimension::k2d:
case sem::TextureDimension::k3d:
case ast::TextureDimension::k1d:
case ast::TextureDimension::k2d:
case ast::TextureDimension::k3d:
break; // No swizzle needed
case sem::TextureDimension::kCube:
case ast::TextureDimension::kCube:
swizzle = {0, 1, 1}; // Duplicate height for depth
spirv_dims = 2; // [width, height]
break;
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2dArray:
swizzle = {0, 1}; // Strip array index
spirv_dims = 3; // [width, height, array_count]
break;
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::kCubeArray:
swizzle = {0, 1, 1}; // Strip array index, duplicate height for depth
spirv_dims = 3; // [width, height, array_count]
break;
@ -2319,8 +2319,8 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call,
default:
error_ = "texture is not arrayed";
return false;
case sem::TextureDimension::k2dArray:
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::k2dArray:
case ast::TextureDimension::kCubeArray:
spirv_dims = 3;
break;
}
@ -3010,13 +3010,13 @@ bool Builder::GenerateTextureType(sem::Texture* texture,
const Operand& result) {
uint32_t array_literal = 0u;
const auto dim = texture->dim();
if (dim == sem::TextureDimension::k2dArray ||
dim == sem::TextureDimension::kCubeArray) {
if (dim == ast::TextureDimension::k2dArray ||
dim == ast::TextureDimension::kCubeArray) {
array_literal = 1u;
}
uint32_t dim_literal = SpvDim2D;
if (dim == sem::TextureDimension::k1d) {
if (dim == ast::TextureDimension::k1d) {
dim_literal = SpvDim1D;
if (texture->Is<sem::SampledTexture>()) {
push_capability(SpvCapabilitySampled1D);
@ -3024,11 +3024,11 @@ bool Builder::GenerateTextureType(sem::Texture* texture,
push_capability(SpvCapabilityImage1D);
}
}
if (dim == sem::TextureDimension::k3d) {
if (dim == ast::TextureDimension::k3d) {
dim_literal = SpvDim3D;
}
if (dim == sem::TextureDimension::kCube ||
dim == sem::TextureDimension::kCubeArray) {
if (dim == ast::TextureDimension::kCube ||
dim == ast::TextureDimension::kCubeArray) {
dim_literal = SpvDimCube;
}
@ -3048,7 +3048,7 @@ bool Builder::GenerateTextureType(sem::Texture* texture,
sampled_literal = 1u;
}
if (dim == sem::TextureDimension::kCubeArray) {
if (dim == ast::TextureDimension::kCubeArray) {
if (texture->Is<sem::SampledTexture>() ||
texture->Is<sem::DepthTexture>()) {
push_capability(SpvCapabilitySampledCubeArray);
@ -3321,98 +3321,98 @@ SpvBuiltIn Builder::ConvertBuiltin(ast::Builtin builtin,
}
SpvImageFormat Builder::convert_image_format_to_spv(
const sem::ImageFormat format) {
const ast::ImageFormat format) {
switch (format) {
case sem::ImageFormat::kR8Unorm:
case ast::ImageFormat::kR8Unorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8;
case sem::ImageFormat::kR8Snorm:
case ast::ImageFormat::kR8Snorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8Snorm;
case sem::ImageFormat::kR8Uint:
case ast::ImageFormat::kR8Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8ui;
case sem::ImageFormat::kR8Sint:
case ast::ImageFormat::kR8Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8i;
case sem::ImageFormat::kR16Uint:
case ast::ImageFormat::kR16Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR16ui;
case sem::ImageFormat::kR16Sint:
case ast::ImageFormat::kR16Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR16i;
case sem::ImageFormat::kR16Float:
case ast::ImageFormat::kR16Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR16f;
case sem::ImageFormat::kRg8Unorm:
case ast::ImageFormat::kRg8Unorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8;
case sem::ImageFormat::kRg8Snorm:
case ast::ImageFormat::kRg8Snorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8Snorm;
case sem::ImageFormat::kRg8Uint:
case ast::ImageFormat::kRg8Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8ui;
case sem::ImageFormat::kRg8Sint:
case ast::ImageFormat::kRg8Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8i;
case sem::ImageFormat::kR32Uint:
case ast::ImageFormat::kR32Uint:
return SpvImageFormatR32ui;
case sem::ImageFormat::kR32Sint:
case ast::ImageFormat::kR32Sint:
return SpvImageFormatR32i;
case sem::ImageFormat::kR32Float:
case ast::ImageFormat::kR32Float:
return SpvImageFormatR32f;
case sem::ImageFormat::kRg16Uint:
case ast::ImageFormat::kRg16Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg16ui;
case sem::ImageFormat::kRg16Sint:
case ast::ImageFormat::kRg16Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg16i;
case sem::ImageFormat::kRg16Float:
case ast::ImageFormat::kRg16Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg16f;
case sem::ImageFormat::kRgba8Unorm:
case ast::ImageFormat::kRgba8Unorm:
return SpvImageFormatRgba8;
case sem::ImageFormat::kRgba8UnormSrgb:
case ast::ImageFormat::kRgba8UnormSrgb:
return SpvImageFormatUnknown;
case sem::ImageFormat::kRgba8Snorm:
case ast::ImageFormat::kRgba8Snorm:
return SpvImageFormatRgba8Snorm;
case sem::ImageFormat::kRgba8Uint:
case ast::ImageFormat::kRgba8Uint:
return SpvImageFormatRgba8ui;
case sem::ImageFormat::kRgba8Sint:
case ast::ImageFormat::kRgba8Sint:
return SpvImageFormatRgba8i;
case sem::ImageFormat::kBgra8Unorm:
case ast::ImageFormat::kBgra8Unorm:
return SpvImageFormatUnknown;
case sem::ImageFormat::kBgra8UnormSrgb:
case ast::ImageFormat::kBgra8UnormSrgb:
return SpvImageFormatUnknown;
case sem::ImageFormat::kRgb10A2Unorm:
case ast::ImageFormat::kRgb10A2Unorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRgb10A2;
case sem::ImageFormat::kRg11B10Float:
case ast::ImageFormat::kRg11B10Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR11fG11fB10f;
case sem::ImageFormat::kRg32Uint:
case ast::ImageFormat::kRg32Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg32ui;
case sem::ImageFormat::kRg32Sint:
case ast::ImageFormat::kRg32Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg32i;
case sem::ImageFormat::kRg32Float:
case ast::ImageFormat::kRg32Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg32f;
case sem::ImageFormat::kRgba16Uint:
case ast::ImageFormat::kRgba16Uint:
return SpvImageFormatRgba16ui;
case sem::ImageFormat::kRgba16Sint:
case ast::ImageFormat::kRgba16Sint:
return SpvImageFormatRgba16i;
case sem::ImageFormat::kRgba16Float:
case ast::ImageFormat::kRgba16Float:
return SpvImageFormatRgba16f;
case sem::ImageFormat::kRgba32Uint:
case ast::ImageFormat::kRgba32Uint:
return SpvImageFormatRgba32ui;
case sem::ImageFormat::kRgba32Sint:
case ast::ImageFormat::kRgba32Sint:
return SpvImageFormatRgba32i;
case sem::ImageFormat::kRgba32Float:
case ast::ImageFormat::kRgba32Float:
return SpvImageFormatRgba32f;
case sem::ImageFormat::kNone:
case ast::ImageFormat::kNone:
return SpvImageFormatUnknown;
}
return SpvImageFormatUnknown;

View File

@ -473,7 +473,7 @@ class Builder {
/// Converts AST image format to SPIR-V and pushes an appropriate capability.
/// @param format AST image format type
/// @returns SPIR-V image format type
SpvImageFormat convert_image_format_to_spv(const sem::ImageFormat format);
SpvImageFormat convert_image_format_to_spv(const ast::ImageFormat format);
/// Determines if the given type constructor is created from constant values
/// @param expr the expression to check

View File

@ -21,7 +21,7 @@ namespace spirv {
namespace {
struct TestData {
sem::ImageFormat ast_format;
ast::ImageFormat ast_format;
SpvImageFormat_ spv_format;
bool extended_format = false;
};
@ -51,42 +51,42 @@ INSTANTIATE_TEST_SUITE_P(
BuilderTest,
ImageFormatConversionTest,
testing::Values(
TestData{sem::ImageFormat::kR8Unorm, SpvImageFormatR8, true},
TestData{sem::ImageFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
TestData{sem::ImageFormat::kR8Uint, SpvImageFormatR8ui, true},
TestData{sem::ImageFormat::kR8Sint, SpvImageFormatR8i, true},
TestData{sem::ImageFormat::kR16Uint, SpvImageFormatR16ui, true},
TestData{sem::ImageFormat::kR16Sint, SpvImageFormatR16i, true},
TestData{sem::ImageFormat::kR16Float, SpvImageFormatR16f, true},
TestData{sem::ImageFormat::kRg8Unorm, SpvImageFormatRg8, true},
TestData{sem::ImageFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true},
TestData{sem::ImageFormat::kRg8Uint, SpvImageFormatRg8ui, true},
TestData{sem::ImageFormat::kRg8Sint, SpvImageFormatRg8i, true},
TestData{sem::ImageFormat::kR32Uint, SpvImageFormatR32ui},
TestData{sem::ImageFormat::kR32Sint, SpvImageFormatR32i},
TestData{sem::ImageFormat::kR32Float, SpvImageFormatR32f},
TestData{sem::ImageFormat::kRg16Uint, SpvImageFormatRg16ui, true},
TestData{sem::ImageFormat::kRg16Sint, SpvImageFormatRg16i, true},
TestData{sem::ImageFormat::kRg16Float, SpvImageFormatRg16f, true},
TestData{sem::ImageFormat::kRgba8Unorm, SpvImageFormatRgba8},
TestData{sem::ImageFormat::kRgba8UnormSrgb, SpvImageFormatUnknown},
TestData{sem::ImageFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
TestData{sem::ImageFormat::kRgba8Uint, SpvImageFormatRgba8ui},
TestData{sem::ImageFormat::kRgba8Sint, SpvImageFormatRgba8i},
TestData{sem::ImageFormat::kBgra8Unorm, SpvImageFormatUnknown},
TestData{sem::ImageFormat::kBgra8UnormSrgb, SpvImageFormatUnknown},
TestData{sem::ImageFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true},
TestData{sem::ImageFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f,
TestData{ast::ImageFormat::kR8Unorm, SpvImageFormatR8, true},
TestData{ast::ImageFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
TestData{ast::ImageFormat::kR8Uint, SpvImageFormatR8ui, true},
TestData{ast::ImageFormat::kR8Sint, SpvImageFormatR8i, true},
TestData{ast::ImageFormat::kR16Uint, SpvImageFormatR16ui, true},
TestData{ast::ImageFormat::kR16Sint, SpvImageFormatR16i, true},
TestData{ast::ImageFormat::kR16Float, SpvImageFormatR16f, true},
TestData{ast::ImageFormat::kRg8Unorm, SpvImageFormatRg8, true},
TestData{ast::ImageFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true},
TestData{ast::ImageFormat::kRg8Uint, SpvImageFormatRg8ui, true},
TestData{ast::ImageFormat::kRg8Sint, SpvImageFormatRg8i, true},
TestData{ast::ImageFormat::kR32Uint, SpvImageFormatR32ui},
TestData{ast::ImageFormat::kR32Sint, SpvImageFormatR32i},
TestData{ast::ImageFormat::kR32Float, SpvImageFormatR32f},
TestData{ast::ImageFormat::kRg16Uint, SpvImageFormatRg16ui, true},
TestData{ast::ImageFormat::kRg16Sint, SpvImageFormatRg16i, true},
TestData{ast::ImageFormat::kRg16Float, SpvImageFormatRg16f, true},
TestData{ast::ImageFormat::kRgba8Unorm, SpvImageFormatRgba8},
TestData{ast::ImageFormat::kRgba8UnormSrgb, SpvImageFormatUnknown},
TestData{ast::ImageFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
TestData{ast::ImageFormat::kRgba8Uint, SpvImageFormatRgba8ui},
TestData{ast::ImageFormat::kRgba8Sint, SpvImageFormatRgba8i},
TestData{ast::ImageFormat::kBgra8Unorm, SpvImageFormatUnknown},
TestData{ast::ImageFormat::kBgra8UnormSrgb, SpvImageFormatUnknown},
TestData{ast::ImageFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true},
TestData{ast::ImageFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f,
true},
TestData{sem::ImageFormat::kRg32Uint, SpvImageFormatRg32ui, true},
TestData{sem::ImageFormat::kRg32Sint, SpvImageFormatRg32i, true},
TestData{sem::ImageFormat::kRg32Float, SpvImageFormatRg32f, true},
TestData{sem::ImageFormat::kRgba16Uint, SpvImageFormatRgba16ui},
TestData{sem::ImageFormat::kRgba16Sint, SpvImageFormatRgba16i},
TestData{sem::ImageFormat::kRgba16Float, SpvImageFormatRgba16f},
TestData{sem::ImageFormat::kRgba32Uint, SpvImageFormatRgba32ui},
TestData{sem::ImageFormat::kRgba32Sint, SpvImageFormatRgba32i},
TestData{sem::ImageFormat::kRgba32Float, SpvImageFormatRgba32f}));
TestData{ast::ImageFormat::kRg32Uint, SpvImageFormatRg32ui, true},
TestData{ast::ImageFormat::kRg32Sint, SpvImageFormatRg32i, true},
TestData{ast::ImageFormat::kRg32Float, SpvImageFormatRg32f, true},
TestData{ast::ImageFormat::kRgba16Uint, SpvImageFormatRgba16ui},
TestData{ast::ImageFormat::kRgba16Sint, SpvImageFormatRgba16i},
TestData{ast::ImageFormat::kRgba16Float, SpvImageFormatRgba16f},
TestData{ast::ImageFormat::kRgba32Uint, SpvImageFormatRgba32ui},
TestData{ast::ImageFormat::kRgba32Sint, SpvImageFormatRgba32i},
TestData{ast::ImageFormat::kRgba32Float, SpvImageFormatRgba32f}));
} // namespace
} // namespace spirv

View File

@ -532,9 +532,9 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageReadOnly) {
// var<uniform_constant> a : [[access(read)]] texture_storage_2d<r32uint>;
auto* subtype =
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types());
auto* type = create<sem::StorageTexture>(sem::TextureDimension::k2d,
sem::ImageFormat::kR32Uint, subtype);
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Uint, Types());
auto* type = create<sem::StorageTexture>(ast::TextureDimension::k2d,
ast::ImageFormat::kR32Uint, subtype);
auto* ac = create<sem::AccessControl>(ast::AccessControl::kReadOnly, type);
@ -557,9 +557,9 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) {
// var<uniform_constant> a : [[access(write)]] texture_storage_2d<r32uint>;
auto* subtype =
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types());
auto* type = create<sem::StorageTexture>(sem::TextureDimension::k2d,
sem::ImageFormat::kR32Uint, subtype);
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Uint, Types());
auto* type = create<sem::StorageTexture>(ast::TextureDimension::k2d,
ast::ImageFormat::kR32Uint, subtype);
Global("test_var", type, ast::StorageClass::kInput);
auto* ac = create<sem::AccessControl>(ast::AccessControl::kWriteOnly, type);
@ -586,9 +586,9 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWithDifferentAccess) {
// var<uniform_constant> b : [[access(write)]] texture_storage_2d<r32uint>;
auto* subtype =
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types());
auto* st = create<sem::StorageTexture>(sem::TextureDimension::k2d,
sem::ImageFormat::kR32Uint, subtype);
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Uint, Types());
auto* st = create<sem::StorageTexture>(ast::TextureDimension::k2d,
ast::ImageFormat::kR32Uint, subtype);
Global("test_var", st, ast::StorageClass::kInput);

View File

@ -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) {
sem::Sampler s(sem::SamplerKind::kComparisonSampler);
sem::DepthTexture t(sem::TextureDimension::k2d);
sem::Sampler s(ast::SamplerKind::kComparisonSampler);
sem::DepthTexture t(ast::TextureDimension::k2d);
auto* tex = Global("texture", &t, ast::StorageClass::kInput);

View File

@ -617,7 +617,7 @@ INSTANTIATE_TEST_SUITE_P(
PtrData{ast::StorageClass::kFunction, SpvStorageClassFunction}));
TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) {
sem::DepthTexture two_d(sem::TextureDimension::k2d);
sem::DepthTexture two_d(ast::TextureDimension::k2d);
spirv::Builder& b = Build();
@ -631,7 +631,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) {
}
TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) {
sem::DepthTexture two_d_array(sem::TextureDimension::k2dArray);
sem::DepthTexture two_d_array(ast::TextureDimension::k2dArray);
spirv::Builder& b = Build();
@ -645,7 +645,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) {
}
TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) {
sem::DepthTexture cube(sem::TextureDimension::kCube);
sem::DepthTexture cube(ast::TextureDimension::kCube);
spirv::Builder& b = Build();
@ -660,7 +660,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) {
}
TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) {
sem::DepthTexture cube_array(sem::TextureDimension::kCubeArray);
sem::DepthTexture cube_array(ast::TextureDimension::kCubeArray);
spirv::Builder& b = Build();
@ -677,7 +677,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) {
}
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
sem::MultisampledTexture ms(sem::TextureDimension::k2d, ty.i32());
sem::MultisampledTexture ms(ast::TextureDimension::k2d, ty.i32());
spirv::Builder& b = Build();
@ -689,7 +689,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
}
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
sem::MultisampledTexture ms(sem::TextureDimension::k2d, ty.u32());
sem::MultisampledTexture ms(ast::TextureDimension::k2d, ty.u32());
spirv::Builder& b = Build();
@ -702,7 +702,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
}
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
sem::MultisampledTexture ms(sem::TextureDimension::k2d, ty.f32());
sem::MultisampledTexture ms(ast::TextureDimension::k2d, ty.f32());
spirv::Builder& b = Build();
@ -715,7 +715,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
auto* s = create<sem::SampledTexture>(sem::TextureDimension::k1d, ty.i32());
auto* s = create<sem::SampledTexture>(ast::TextureDimension::k1d, ty.i32());
spirv::Builder& b = Build();
@ -732,7 +732,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
auto* s = create<sem::SampledTexture>(sem::TextureDimension::k1d, ty.u32());
auto* s = create<sem::SampledTexture>(ast::TextureDimension::k1d, ty.u32());
spirv::Builder& b = Build();
@ -749,7 +749,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
auto* s = create<sem::SampledTexture>(sem::TextureDimension::k1d, ty.f32());
auto* s = create<sem::SampledTexture>(ast::TextureDimension::k1d, ty.f32());
spirv::Builder& b = Build();
@ -766,7 +766,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
auto* s = create<sem::SampledTexture>(sem::TextureDimension::k2d, ty.f32());
auto* s = create<sem::SampledTexture>(ast::TextureDimension::k2d, ty.f32());
spirv::Builder& b = Build();
@ -780,7 +780,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
auto* s =
create<sem::SampledTexture>(sem::TextureDimension::k2dArray, ty.f32());
create<sem::SampledTexture>(ast::TextureDimension::k2dArray, ty.f32());
spirv::Builder& b = Build();
@ -793,7 +793,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
auto* s = create<sem::SampledTexture>(sem::TextureDimension::k3d, ty.f32());
auto* s = create<sem::SampledTexture>(ast::TextureDimension::k3d, ty.f32());
spirv::Builder& b = Build();
@ -806,7 +806,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
auto* s = create<sem::SampledTexture>(sem::TextureDimension::kCube, ty.f32());
auto* s = create<sem::SampledTexture>(ast::TextureDimension::kCube, ty.f32());
spirv::Builder& b = Build();
@ -821,7 +821,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
auto* s =
create<sem::SampledTexture>(sem::TextureDimension::kCubeArray, ty.f32());
create<sem::SampledTexture>(ast::TextureDimension::kCubeArray, ty.f32());
spirv::Builder& b = Build();
@ -838,9 +838,9 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
auto* subtype =
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types());
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k1d,
sem::ImageFormat::kR32Float, subtype);
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Float, Types());
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k1d,
ast::ImageFormat::kR32Float, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@ -855,9 +855,9 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
auto* subtype =
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types());
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2d,
sem::ImageFormat::kR32Float, subtype);
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Float, Types());
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k2d,
ast::ImageFormat::kR32Float, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@ -872,9 +872,9 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
auto* subtype =
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types());
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2dArray,
sem::ImageFormat::kR32Float, subtype);
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Float, Types());
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kR32Float, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@ -889,9 +889,9 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
auto* subtype =
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types());
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k3d,
sem::ImageFormat::kR32Float, subtype);
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Float, Types());
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k3d,
ast::ImageFormat::kR32Float, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@ -907,9 +907,9 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
TEST_F(BuilderTest_Type,
StorageTexture_Generate_SampledTypeFloat_Format_r32float) {
auto* subtype =
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types());
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2d,
sem::ImageFormat::kR32Float, subtype);
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Float, Types());
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k2d,
ast::ImageFormat::kR32Float, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@ -925,9 +925,9 @@ TEST_F(BuilderTest_Type,
TEST_F(BuilderTest_Type,
StorageTexture_Generate_SampledTypeSint_Format_r32sint) {
auto* subtype =
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Sint, Types());
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2d,
sem::ImageFormat::kR32Sint, subtype);
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Sint, Types());
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k2d,
ast::ImageFormat::kR32Sint, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@ -943,9 +943,9 @@ TEST_F(BuilderTest_Type,
TEST_F(BuilderTest_Type,
StorageTexture_Generate_SampledTypeUint_Format_r32uint) {
auto* subtype =
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types());
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2d,
sem::ImageFormat::kR32Uint, subtype);
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Uint, Types());
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k2d,
ast::ImageFormat::kR32Uint, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@ -959,7 +959,7 @@ TEST_F(BuilderTest_Type,
}
TEST_F(BuilderTest_Type, Sampler) {
sem::Sampler sampler(sem::SamplerKind::kSampler);
sem::Sampler sampler(ast::SamplerKind::kSampler);
spirv::Builder& b = Build();
@ -969,7 +969,7 @@ TEST_F(BuilderTest_Type, Sampler) {
}
TEST_F(BuilderTest_Type, ComparisonSampler) {
sem::Sampler sampler(sem::SamplerKind::kComparisonSampler);
sem::Sampler sampler(ast::SamplerKind::kComparisonSampler);
spirv::Builder& b = Build();
@ -979,8 +979,8 @@ TEST_F(BuilderTest_Type, ComparisonSampler) {
}
TEST_F(BuilderTest_Type, Dedup_Sampler_And_ComparisonSampler) {
sem::Sampler comp_sampler(sem::SamplerKind::kComparisonSampler);
sem::Sampler sampler(sem::SamplerKind::kSampler);
sem::Sampler comp_sampler(ast::SamplerKind::kComparisonSampler);
sem::Sampler sampler(ast::SamplerKind::kSampler);
spirv::Builder& b = Build();

View File

@ -358,9 +358,9 @@ bool GeneratorImpl::EmitFunction(ast::Function* func) {
return true;
}
bool GeneratorImpl::EmitImageFormat(const sem::ImageFormat fmt) {
bool GeneratorImpl::EmitImageFormat(const ast::ImageFormat fmt) {
switch (fmt) {
case sem::ImageFormat::kNone:
case ast::ImageFormat::kNone:
diagnostics_.add_error("unknown image format");
return false;
default:
@ -450,22 +450,22 @@ bool GeneratorImpl::EmitType(sem::Type* type) {
}
switch (texture->dim()) {
case sem::TextureDimension::k1d:
case ast::TextureDimension::k1d:
out_ << "1d";
break;
case sem::TextureDimension::k2d:
case ast::TextureDimension::k2d:
out_ << "2d";
break;
case sem::TextureDimension::k2dArray:
case ast::TextureDimension::k2dArray:
out_ << "2d_array";
break;
case sem::TextureDimension::k3d:
case ast::TextureDimension::k3d:
out_ << "3d";
break;
case sem::TextureDimension::kCube:
case ast::TextureDimension::kCube:
out_ << "cube";
break;
case sem::TextureDimension::kCubeArray:
case ast::TextureDimension::kCubeArray:
out_ << "cube_array";
break;
default:

View File

@ -180,7 +180,7 @@ class GeneratorImpl : public TextGenerator {
/// Handles emitting an image format
/// @param fmt the format to generate
/// @returns true if the format is emitted
bool EmitImageFormat(const sem::ImageFormat fmt);
bool EmitImageFormat(const ast::ImageFormat fmt);
/// Handles emitting a type constructor
/// @param expr the type constructor expression
/// @returns true if the constructor is emitted

View File

@ -101,7 +101,7 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) {
}
TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) {
Global("s", create<sem::Sampler>(sem::SamplerKind::kSampler),
Global("s", create<sem::Sampler>(ast::SamplerKind::kSampler),
ast::StorageClass::kUniformConstant);
GeneratorImpl& gen = Build();
@ -113,7 +113,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) {
}
TEST_F(WgslGeneratorImplTest, Emit_Global_Texture) {
auto* st = create<sem::SampledTexture>(sem::TextureDimension::k1d, ty.f32());
auto* st = create<sem::SampledTexture>(ast::TextureDimension::k1d, ty.f32());
Global("t", ty.access(ast::AccessControl::kReadOnly, st),
ast::StorageClass::kUniformConstant);

View File

@ -314,7 +314,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Vector) {
}
struct TextureData {
sem::TextureDimension dim;
ast::TextureDimension dim;
const char* name;
};
inline std::ostream& operator<<(std::ostream& out, TextureData data) {
@ -338,10 +338,10 @@ INSTANTIATE_TEST_SUITE_P(
WgslGeneratorImplTest,
WgslGenerator_DepthTextureTest,
testing::Values(
TextureData{sem::TextureDimension::k2d, "texture_depth_2d"},
TextureData{sem::TextureDimension::k2dArray, "texture_depth_2d_array"},
TextureData{sem::TextureDimension::kCube, "texture_depth_cube"},
TextureData{sem::TextureDimension::kCubeArray,
TextureData{ast::TextureDimension::k2d, "texture_depth_2d"},
TextureData{ast::TextureDimension::k2dArray, "texture_depth_2d_array"},
TextureData{ast::TextureDimension::kCube, "texture_depth_cube"},
TextureData{ast::TextureDimension::kCubeArray,
"texture_depth_cube_array"}));
using WgslGenerator_SampledTextureTest = TestParamHelper<TextureData>;
@ -384,12 +384,12 @@ INSTANTIATE_TEST_SUITE_P(
WgslGeneratorImplTest,
WgslGenerator_SampledTextureTest,
testing::Values(
TextureData{sem::TextureDimension::k1d, "texture_1d"},
TextureData{sem::TextureDimension::k2d, "texture_2d"},
TextureData{sem::TextureDimension::k2dArray, "texture_2d_array"},
TextureData{sem::TextureDimension::k3d, "texture_3d"},
TextureData{sem::TextureDimension::kCube, "texture_cube"},
TextureData{sem::TextureDimension::kCubeArray, "texture_cube_array"}));
TextureData{ast::TextureDimension::k1d, "texture_1d"},
TextureData{ast::TextureDimension::k2d, "texture_2d"},
TextureData{ast::TextureDimension::k2dArray, "texture_2d_array"},
TextureData{ast::TextureDimension::k3d, "texture_3d"},
TextureData{ast::TextureDimension::kCube, "texture_cube"},
TextureData{ast::TextureDimension::kCubeArray, "texture_cube_array"}));
using WgslGenerator_MultiampledTextureTest = TestParamHelper<TextureData>;
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) {
@ -430,12 +430,12 @@ TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_U32) {
INSTANTIATE_TEST_SUITE_P(WgslGeneratorImplTest,
WgslGenerator_MultiampledTextureTest,
testing::Values(TextureData{
sem::TextureDimension::k2d,
ast::TextureDimension::k2d,
"texture_multisampled_2d"}));
struct StorageTextureData {
sem::ImageFormat fmt;
sem::TextureDimension dim;
ast::ImageFormat fmt;
ast::TextureDimension dim;
ast::AccessControl::Access access;
const char* name;
};
@ -460,41 +460,41 @@ INSTANTIATE_TEST_SUITE_P(
WgslGeneratorImplTest,
WgslGenerator_StorageTextureTest,
testing::Values(
StorageTextureData{sem::ImageFormat::kR8Unorm,
sem::TextureDimension::k1d,
StorageTextureData{ast::ImageFormat::kR8Unorm,
ast::TextureDimension::k1d,
ast::AccessControl::kReadOnly,
"[[access(read)]] texture_storage_1d<r8unorm>"},
StorageTextureData{sem::ImageFormat::kR8Unorm,
sem::TextureDimension::k2d,
StorageTextureData{ast::ImageFormat::kR8Unorm,
ast::TextureDimension::k2d,
ast::AccessControl::kReadOnly,
"[[access(read)]] texture_storage_2d<r8unorm>"},
StorageTextureData{
sem::ImageFormat::kR8Unorm, sem::TextureDimension::k2dArray,
ast::ImageFormat::kR8Unorm, ast::TextureDimension::k2dArray,
ast::AccessControl::kReadOnly,
"[[access(read)]] texture_storage_2d_array<r8unorm>"},
StorageTextureData{sem::ImageFormat::kR8Unorm,
sem::TextureDimension::k3d,
StorageTextureData{ast::ImageFormat::kR8Unorm,
ast::TextureDimension::k3d,
ast::AccessControl::kReadOnly,
"[[access(read)]] texture_storage_3d<r8unorm>"},
StorageTextureData{sem::ImageFormat::kR8Unorm,
sem::TextureDimension::k1d,
StorageTextureData{ast::ImageFormat::kR8Unorm,
ast::TextureDimension::k1d,
ast::AccessControl::kWriteOnly,
"[[access(write)]] texture_storage_1d<r8unorm>"},
StorageTextureData{sem::ImageFormat::kR8Unorm,
sem::TextureDimension::k2d,
StorageTextureData{ast::ImageFormat::kR8Unorm,
ast::TextureDimension::k2d,
ast::AccessControl::kWriteOnly,
"[[access(write)]] texture_storage_2d<r8unorm>"},
StorageTextureData{
sem::ImageFormat::kR8Unorm, sem::TextureDimension::k2dArray,
ast::ImageFormat::kR8Unorm, ast::TextureDimension::k2dArray,
ast::AccessControl::kWriteOnly,
"[[access(write)]] texture_storage_2d_array<r8unorm>"},
StorageTextureData{sem::ImageFormat::kR8Unorm,
sem::TextureDimension::k3d,
StorageTextureData{ast::ImageFormat::kR8Unorm,
ast::TextureDimension::k3d,
ast::AccessControl::kWriteOnly,
"[[access(write)]] texture_storage_3d<r8unorm>"}));
struct ImageFormatData {
sem::ImageFormat fmt;
ast::ImageFormat fmt;
const char* name;
};
inline std::ostream& operator<<(std::ostream& out, ImageFormatData data) {
@ -515,44 +515,44 @@ INSTANTIATE_TEST_SUITE_P(
WgslGeneratorImplTest,
WgslGenerator_ImageFormatTest,
testing::Values(
ImageFormatData{sem::ImageFormat::kR8Unorm, "r8unorm"},
ImageFormatData{sem::ImageFormat::kR8Snorm, "r8snorm"},
ImageFormatData{sem::ImageFormat::kR8Uint, "r8uint"},
ImageFormatData{sem::ImageFormat::kR8Sint, "r8sint"},
ImageFormatData{sem::ImageFormat::kR16Uint, "r16uint"},
ImageFormatData{sem::ImageFormat::kR16Sint, "r16sint"},
ImageFormatData{sem::ImageFormat::kR16Float, "r16float"},
ImageFormatData{sem::ImageFormat::kRg8Unorm, "rg8unorm"},
ImageFormatData{sem::ImageFormat::kRg8Snorm, "rg8snorm"},
ImageFormatData{sem::ImageFormat::kRg8Uint, "rg8uint"},
ImageFormatData{sem::ImageFormat::kRg8Sint, "rg8sint"},
ImageFormatData{sem::ImageFormat::kR32Uint, "r32uint"},
ImageFormatData{sem::ImageFormat::kR32Sint, "r32sint"},
ImageFormatData{sem::ImageFormat::kR32Float, "r32float"},
ImageFormatData{sem::ImageFormat::kRg16Uint, "rg16uint"},
ImageFormatData{sem::ImageFormat::kRg16Sint, "rg16sint"},
ImageFormatData{sem::ImageFormat::kRg16Float, "rg16float"},
ImageFormatData{sem::ImageFormat::kRgba8Unorm, "rgba8unorm"},
ImageFormatData{sem::ImageFormat::kRgba8UnormSrgb, "rgba8unorm_srgb"},
ImageFormatData{sem::ImageFormat::kRgba8Snorm, "rgba8snorm"},
ImageFormatData{sem::ImageFormat::kRgba8Uint, "rgba8uint"},
ImageFormatData{sem::ImageFormat::kRgba8Sint, "rgba8sint"},
ImageFormatData{sem::ImageFormat::kBgra8Unorm, "bgra8unorm"},
ImageFormatData{sem::ImageFormat::kBgra8UnormSrgb, "bgra8unorm_srgb"},
ImageFormatData{sem::ImageFormat::kRgb10A2Unorm, "rgb10a2unorm"},
ImageFormatData{sem::ImageFormat::kRg11B10Float, "rg11b10float"},
ImageFormatData{sem::ImageFormat::kRg32Uint, "rg32uint"},
ImageFormatData{sem::ImageFormat::kRg32Sint, "rg32sint"},
ImageFormatData{sem::ImageFormat::kRg32Float, "rg32float"},
ImageFormatData{sem::ImageFormat::kRgba16Uint, "rgba16uint"},
ImageFormatData{sem::ImageFormat::kRgba16Sint, "rgba16sint"},
ImageFormatData{sem::ImageFormat::kRgba16Float, "rgba16float"},
ImageFormatData{sem::ImageFormat::kRgba32Uint, "rgba32uint"},
ImageFormatData{sem::ImageFormat::kRgba32Sint, "rgba32sint"},
ImageFormatData{sem::ImageFormat::kRgba32Float, "rgba32float"}));
ImageFormatData{ast::ImageFormat::kR8Unorm, "r8unorm"},
ImageFormatData{ast::ImageFormat::kR8Snorm, "r8snorm"},
ImageFormatData{ast::ImageFormat::kR8Uint, "r8uint"},
ImageFormatData{ast::ImageFormat::kR8Sint, "r8sint"},
ImageFormatData{ast::ImageFormat::kR16Uint, "r16uint"},
ImageFormatData{ast::ImageFormat::kR16Sint, "r16sint"},
ImageFormatData{ast::ImageFormat::kR16Float, "r16float"},
ImageFormatData{ast::ImageFormat::kRg8Unorm, "rg8unorm"},
ImageFormatData{ast::ImageFormat::kRg8Snorm, "rg8snorm"},
ImageFormatData{ast::ImageFormat::kRg8Uint, "rg8uint"},
ImageFormatData{ast::ImageFormat::kRg8Sint, "rg8sint"},
ImageFormatData{ast::ImageFormat::kR32Uint, "r32uint"},
ImageFormatData{ast::ImageFormat::kR32Sint, "r32sint"},
ImageFormatData{ast::ImageFormat::kR32Float, "r32float"},
ImageFormatData{ast::ImageFormat::kRg16Uint, "rg16uint"},
ImageFormatData{ast::ImageFormat::kRg16Sint, "rg16sint"},
ImageFormatData{ast::ImageFormat::kRg16Float, "rg16float"},
ImageFormatData{ast::ImageFormat::kRgba8Unorm, "rgba8unorm"},
ImageFormatData{ast::ImageFormat::kRgba8UnormSrgb, "rgba8unorm_srgb"},
ImageFormatData{ast::ImageFormat::kRgba8Snorm, "rgba8snorm"},
ImageFormatData{ast::ImageFormat::kRgba8Uint, "rgba8uint"},
ImageFormatData{ast::ImageFormat::kRgba8Sint, "rgba8sint"},
ImageFormatData{ast::ImageFormat::kBgra8Unorm, "bgra8unorm"},
ImageFormatData{ast::ImageFormat::kBgra8UnormSrgb, "bgra8unorm_srgb"},
ImageFormatData{ast::ImageFormat::kRgb10A2Unorm, "rgb10a2unorm"},
ImageFormatData{ast::ImageFormat::kRg11B10Float, "rg11b10float"},
ImageFormatData{ast::ImageFormat::kRg32Uint, "rg32uint"},
ImageFormatData{ast::ImageFormat::kRg32Sint, "rg32sint"},
ImageFormatData{ast::ImageFormat::kRg32Float, "rg32float"},
ImageFormatData{ast::ImageFormat::kRgba16Uint, "rgba16uint"},
ImageFormatData{ast::ImageFormat::kRgba16Sint, "rgba16sint"},
ImageFormatData{ast::ImageFormat::kRgba16Float, "rgba16float"},
ImageFormatData{ast::ImageFormat::kRgba32Uint, "rgba32uint"},
ImageFormatData{ast::ImageFormat::kRgba32Sint, "rgba32sint"},
ImageFormatData{ast::ImageFormat::kRgba32Float, "rgba32float"}));
TEST_F(WgslGeneratorImplTest, EmitType_Sampler) {
auto* sampler = create<sem::Sampler>(sem::SamplerKind::kSampler);
auto* sampler = create<sem::Sampler>(ast::SamplerKind::kSampler);
AST().AddConstructedType(ty.alias("make_type_reachable", sampler));
GeneratorImpl& gen = Build();
@ -562,7 +562,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Sampler) {
}
TEST_F(WgslGeneratorImplTest, EmitType_SamplerComparison) {
auto* sampler = create<sem::Sampler>(sem::SamplerKind::kComparisonSampler);
auto* sampler = create<sem::Sampler>(ast::SamplerKind::kComparisonSampler);
AST().AddConstructedType(ty.alias("make_type_reachable", sampler));
GeneratorImpl& gen = Build();