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:
parent
a922e65d72
commit
fec63b7aa6
File diff suppressed because it is too large
Load Diff
|
@ -176,8 +176,8 @@ struct TextureOverloadCase {
|
||||||
TextureOverloadCase(ValidTextureOverload,
|
TextureOverloadCase(ValidTextureOverload,
|
||||||
const char*,
|
const char*,
|
||||||
TextureKind,
|
TextureKind,
|
||||||
sem::SamplerKind,
|
ast::SamplerKind,
|
||||||
sem::TextureDimension,
|
ast::TextureDimension,
|
||||||
TextureDataType,
|
TextureDataType,
|
||||||
const char*,
|
const char*,
|
||||||
std::function<ExpressionList(ProgramBuilder*)>);
|
std::function<ExpressionList(ProgramBuilder*)>);
|
||||||
|
@ -185,7 +185,7 @@ struct TextureOverloadCase {
|
||||||
TextureOverloadCase(ValidTextureOverload,
|
TextureOverloadCase(ValidTextureOverload,
|
||||||
const char*,
|
const char*,
|
||||||
TextureKind,
|
TextureKind,
|
||||||
sem::TextureDimension,
|
ast::TextureDimension,
|
||||||
TextureDataType,
|
TextureDataType,
|
||||||
const char*,
|
const char*,
|
||||||
std::function<ExpressionList(ProgramBuilder*)>);
|
std::function<ExpressionList(ProgramBuilder*)>);
|
||||||
|
@ -193,8 +193,8 @@ struct TextureOverloadCase {
|
||||||
TextureOverloadCase(ValidTextureOverload,
|
TextureOverloadCase(ValidTextureOverload,
|
||||||
const char*,
|
const char*,
|
||||||
AccessControl::Access,
|
AccessControl::Access,
|
||||||
sem::ImageFormat,
|
ast::ImageFormat,
|
||||||
sem::TextureDimension,
|
ast::TextureDimension,
|
||||||
TextureDataType,
|
TextureDataType,
|
||||||
const char*,
|
const char*,
|
||||||
std::function<ExpressionList(ProgramBuilder*)>);
|
std::function<ExpressionList(ProgramBuilder*)>);
|
||||||
|
@ -227,15 +227,15 @@ struct TextureOverloadCase {
|
||||||
TextureKind const texture_kind;
|
TextureKind const texture_kind;
|
||||||
/// The sampler kind for the sampler parameter
|
/// The sampler kind for the sampler parameter
|
||||||
/// Used only when texture_kind is not kStorage
|
/// 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
|
/// The access control for the storage texture
|
||||||
/// Used only when texture_kind is kStorage
|
/// Used only when texture_kind is kStorage
|
||||||
AccessControl::Access const access_control = AccessControl::kReadWrite;
|
AccessControl::Access const access_control = AccessControl::kReadWrite;
|
||||||
/// The image format for the storage texture
|
/// The image format for the storage texture
|
||||||
/// Used only when texture_kind is kStorage
|
/// 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
|
/// The dimensions of the texture parameter
|
||||||
sem::TextureDimension const texture_dimension;
|
ast::TextureDimension const texture_dimension;
|
||||||
/// The data type of the texture parameter
|
/// The data type of the texture parameter
|
||||||
TextureDataType const texture_data_type;
|
TextureDataType const texture_data_type;
|
||||||
/// Name of the function. e.g. `textureSample`, `textureSampleGrad`, etc
|
/// Name of the function. e.g. `textureSample`, `textureSampleGrad`, etc
|
||||||
|
|
|
@ -57,21 +57,21 @@ void AppendResourceBindings(std::vector<ResourceBinding>* dest,
|
||||||
|
|
||||||
ResourceBinding::TextureDimension
|
ResourceBinding::TextureDimension
|
||||||
TypeTextureDimensionToResourceBindingTextureDimension(
|
TypeTextureDimensionToResourceBindingTextureDimension(
|
||||||
const sem::TextureDimension& type_dim) {
|
const ast::TextureDimension& type_dim) {
|
||||||
switch (type_dim) {
|
switch (type_dim) {
|
||||||
case sem::TextureDimension::k1d:
|
case ast::TextureDimension::k1d:
|
||||||
return ResourceBinding::TextureDimension::k1d;
|
return ResourceBinding::TextureDimension::k1d;
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
return ResourceBinding::TextureDimension::k2d;
|
return ResourceBinding::TextureDimension::k2d;
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
return ResourceBinding::TextureDimension::k2dArray;
|
return ResourceBinding::TextureDimension::k2dArray;
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
return ResourceBinding::TextureDimension::k3d;
|
return ResourceBinding::TextureDimension::k3d;
|
||||||
case sem::TextureDimension::kCube:
|
case ast::TextureDimension::kCube:
|
||||||
return ResourceBinding::TextureDimension::kCube;
|
return ResourceBinding::TextureDimension::kCube;
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
return ResourceBinding::TextureDimension::kCubeArray;
|
return ResourceBinding::TextureDimension::kCubeArray;
|
||||||
case sem::TextureDimension::kNone:
|
case ast::TextureDimension::kNone:
|
||||||
return ResourceBinding::TextureDimension::kNone;
|
return ResourceBinding::TextureDimension::kNone;
|
||||||
}
|
}
|
||||||
return ResourceBinding::TextureDimension::kNone;
|
return ResourceBinding::TextureDimension::kNone;
|
||||||
|
@ -102,79 +102,79 @@ ResourceBinding::SampledKind BaseTypeToSampledKind(sem::Type* base_type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceBinding::ImageFormat TypeImageFormatToResourceBindingImageFormat(
|
ResourceBinding::ImageFormat TypeImageFormatToResourceBindingImageFormat(
|
||||||
const sem::ImageFormat& image_format) {
|
const ast::ImageFormat& image_format) {
|
||||||
switch (image_format) {
|
switch (image_format) {
|
||||||
case sem::ImageFormat::kR8Unorm:
|
case ast::ImageFormat::kR8Unorm:
|
||||||
return ResourceBinding::ImageFormat::kR8Unorm;
|
return ResourceBinding::ImageFormat::kR8Unorm;
|
||||||
case sem::ImageFormat::kR8Snorm:
|
case ast::ImageFormat::kR8Snorm:
|
||||||
return ResourceBinding::ImageFormat::kR8Snorm;
|
return ResourceBinding::ImageFormat::kR8Snorm;
|
||||||
case sem::ImageFormat::kR8Uint:
|
case ast::ImageFormat::kR8Uint:
|
||||||
return ResourceBinding::ImageFormat::kR8Uint;
|
return ResourceBinding::ImageFormat::kR8Uint;
|
||||||
case sem::ImageFormat::kR8Sint:
|
case ast::ImageFormat::kR8Sint:
|
||||||
return ResourceBinding::ImageFormat::kR8Sint;
|
return ResourceBinding::ImageFormat::kR8Sint;
|
||||||
case sem::ImageFormat::kR16Uint:
|
case ast::ImageFormat::kR16Uint:
|
||||||
return ResourceBinding::ImageFormat::kR16Uint;
|
return ResourceBinding::ImageFormat::kR16Uint;
|
||||||
case sem::ImageFormat::kR16Sint:
|
case ast::ImageFormat::kR16Sint:
|
||||||
return ResourceBinding::ImageFormat::kR16Sint;
|
return ResourceBinding::ImageFormat::kR16Sint;
|
||||||
case sem::ImageFormat::kR16Float:
|
case ast::ImageFormat::kR16Float:
|
||||||
return ResourceBinding::ImageFormat::kR16Float;
|
return ResourceBinding::ImageFormat::kR16Float;
|
||||||
case sem::ImageFormat::kRg8Unorm:
|
case ast::ImageFormat::kRg8Unorm:
|
||||||
return ResourceBinding::ImageFormat::kRg8Unorm;
|
return ResourceBinding::ImageFormat::kRg8Unorm;
|
||||||
case sem::ImageFormat::kRg8Snorm:
|
case ast::ImageFormat::kRg8Snorm:
|
||||||
return ResourceBinding::ImageFormat::kRg8Snorm;
|
return ResourceBinding::ImageFormat::kRg8Snorm;
|
||||||
case sem::ImageFormat::kRg8Uint:
|
case ast::ImageFormat::kRg8Uint:
|
||||||
return ResourceBinding::ImageFormat::kRg8Uint;
|
return ResourceBinding::ImageFormat::kRg8Uint;
|
||||||
case sem::ImageFormat::kRg8Sint:
|
case ast::ImageFormat::kRg8Sint:
|
||||||
return ResourceBinding::ImageFormat::kRg8Sint;
|
return ResourceBinding::ImageFormat::kRg8Sint;
|
||||||
case sem::ImageFormat::kR32Uint:
|
case ast::ImageFormat::kR32Uint:
|
||||||
return ResourceBinding::ImageFormat::kR32Uint;
|
return ResourceBinding::ImageFormat::kR32Uint;
|
||||||
case sem::ImageFormat::kR32Sint:
|
case ast::ImageFormat::kR32Sint:
|
||||||
return ResourceBinding::ImageFormat::kR32Sint;
|
return ResourceBinding::ImageFormat::kR32Sint;
|
||||||
case sem::ImageFormat::kR32Float:
|
case ast::ImageFormat::kR32Float:
|
||||||
return ResourceBinding::ImageFormat::kR32Float;
|
return ResourceBinding::ImageFormat::kR32Float;
|
||||||
case sem::ImageFormat::kRg16Uint:
|
case ast::ImageFormat::kRg16Uint:
|
||||||
return ResourceBinding::ImageFormat::kRg16Uint;
|
return ResourceBinding::ImageFormat::kRg16Uint;
|
||||||
case sem::ImageFormat::kRg16Sint:
|
case ast::ImageFormat::kRg16Sint:
|
||||||
return ResourceBinding::ImageFormat::kRg16Sint;
|
return ResourceBinding::ImageFormat::kRg16Sint;
|
||||||
case sem::ImageFormat::kRg16Float:
|
case ast::ImageFormat::kRg16Float:
|
||||||
return ResourceBinding::ImageFormat::kRg16Float;
|
return ResourceBinding::ImageFormat::kRg16Float;
|
||||||
case sem::ImageFormat::kRgba8Unorm:
|
case ast::ImageFormat::kRgba8Unorm:
|
||||||
return ResourceBinding::ImageFormat::kRgba8Unorm;
|
return ResourceBinding::ImageFormat::kRgba8Unorm;
|
||||||
case sem::ImageFormat::kRgba8UnormSrgb:
|
case ast::ImageFormat::kRgba8UnormSrgb:
|
||||||
return ResourceBinding::ImageFormat::kRgba8UnormSrgb;
|
return ResourceBinding::ImageFormat::kRgba8UnormSrgb;
|
||||||
case sem::ImageFormat::kRgba8Snorm:
|
case ast::ImageFormat::kRgba8Snorm:
|
||||||
return ResourceBinding::ImageFormat::kRgba8Snorm;
|
return ResourceBinding::ImageFormat::kRgba8Snorm;
|
||||||
case sem::ImageFormat::kRgba8Uint:
|
case ast::ImageFormat::kRgba8Uint:
|
||||||
return ResourceBinding::ImageFormat::kRgba8Uint;
|
return ResourceBinding::ImageFormat::kRgba8Uint;
|
||||||
case sem::ImageFormat::kRgba8Sint:
|
case ast::ImageFormat::kRgba8Sint:
|
||||||
return ResourceBinding::ImageFormat::kRgba8Sint;
|
return ResourceBinding::ImageFormat::kRgba8Sint;
|
||||||
case sem::ImageFormat::kBgra8Unorm:
|
case ast::ImageFormat::kBgra8Unorm:
|
||||||
return ResourceBinding::ImageFormat::kBgra8Unorm;
|
return ResourceBinding::ImageFormat::kBgra8Unorm;
|
||||||
case sem::ImageFormat::kBgra8UnormSrgb:
|
case ast::ImageFormat::kBgra8UnormSrgb:
|
||||||
return ResourceBinding::ImageFormat::kBgra8UnormSrgb;
|
return ResourceBinding::ImageFormat::kBgra8UnormSrgb;
|
||||||
case sem::ImageFormat::kRgb10A2Unorm:
|
case ast::ImageFormat::kRgb10A2Unorm:
|
||||||
return ResourceBinding::ImageFormat::kRgb10A2Unorm;
|
return ResourceBinding::ImageFormat::kRgb10A2Unorm;
|
||||||
case sem::ImageFormat::kRg11B10Float:
|
case ast::ImageFormat::kRg11B10Float:
|
||||||
return ResourceBinding::ImageFormat::kRg11B10Float;
|
return ResourceBinding::ImageFormat::kRg11B10Float;
|
||||||
case sem::ImageFormat::kRg32Uint:
|
case ast::ImageFormat::kRg32Uint:
|
||||||
return ResourceBinding::ImageFormat::kRg32Uint;
|
return ResourceBinding::ImageFormat::kRg32Uint;
|
||||||
case sem::ImageFormat::kRg32Sint:
|
case ast::ImageFormat::kRg32Sint:
|
||||||
return ResourceBinding::ImageFormat::kRg32Sint;
|
return ResourceBinding::ImageFormat::kRg32Sint;
|
||||||
case sem::ImageFormat::kRg32Float:
|
case ast::ImageFormat::kRg32Float:
|
||||||
return ResourceBinding::ImageFormat::kRg32Float;
|
return ResourceBinding::ImageFormat::kRg32Float;
|
||||||
case sem::ImageFormat::kRgba16Uint:
|
case ast::ImageFormat::kRgba16Uint:
|
||||||
return ResourceBinding::ImageFormat::kRgba16Uint;
|
return ResourceBinding::ImageFormat::kRgba16Uint;
|
||||||
case sem::ImageFormat::kRgba16Sint:
|
case ast::ImageFormat::kRgba16Sint:
|
||||||
return ResourceBinding::ImageFormat::kRgba16Sint;
|
return ResourceBinding::ImageFormat::kRgba16Sint;
|
||||||
case sem::ImageFormat::kRgba16Float:
|
case ast::ImageFormat::kRgba16Float:
|
||||||
return ResourceBinding::ImageFormat::kRgba16Float;
|
return ResourceBinding::ImageFormat::kRgba16Float;
|
||||||
case sem::ImageFormat::kRgba32Uint:
|
case ast::ImageFormat::kRgba32Uint:
|
||||||
return ResourceBinding::ImageFormat::kRgba32Uint;
|
return ResourceBinding::ImageFormat::kRgba32Uint;
|
||||||
case sem::ImageFormat::kRgba32Sint:
|
case ast::ImageFormat::kRgba32Sint:
|
||||||
return ResourceBinding::ImageFormat::kRgba32Sint;
|
return ResourceBinding::ImageFormat::kRgba32Sint;
|
||||||
case sem::ImageFormat::kRgba32Float:
|
case ast::ImageFormat::kRgba32Float:
|
||||||
return ResourceBinding::ImageFormat::kRgba32Float;
|
return ResourceBinding::ImageFormat::kRgba32Float;
|
||||||
case sem::ImageFormat::kNone:
|
case ast::ImageFormat::kNone:
|
||||||
return ResourceBinding::ImageFormat::kNone;
|
return ResourceBinding::ImageFormat::kNone;
|
||||||
}
|
}
|
||||||
return ResourceBinding::ImageFormat::kNone;
|
return ResourceBinding::ImageFormat::kNone;
|
||||||
|
|
|
@ -30,8 +30,8 @@ namespace {
|
||||||
class InspectorHelper : public ProgramBuilder {
|
class InspectorHelper : public ProgramBuilder {
|
||||||
public:
|
public:
|
||||||
InspectorHelper()
|
InspectorHelper()
|
||||||
: sampler_type_(sem::SamplerKind::kSampler),
|
: sampler_type_(ast::SamplerKind::kSampler),
|
||||||
comparison_sampler_type_(sem::SamplerKind::kComparisonSampler) {}
|
comparison_sampler_type_(ast::SamplerKind::kComparisonSampler) {}
|
||||||
|
|
||||||
/// Generates an empty function
|
/// Generates an empty function
|
||||||
/// @param name name of the function created
|
/// @param name name of the function created
|
||||||
|
@ -374,7 +374,7 @@ class InspectorHelper : public ProgramBuilder {
|
||||||
/// @param dim the dimensions of the texture
|
/// @param dim the dimensions of the texture
|
||||||
/// @param type the data type of the sampled texture
|
/// @param type the data type of the sampled texture
|
||||||
/// @returns the generated SampleTextureType
|
/// @returns the generated SampleTextureType
|
||||||
sem::SampledTexture* MakeSampledTextureType(sem::TextureDimension dim,
|
sem::SampledTexture* MakeSampledTextureType(ast::TextureDimension dim,
|
||||||
sem::Type* type) {
|
sem::Type* type) {
|
||||||
return create<sem::SampledTexture>(dim, type);
|
return create<sem::SampledTexture>(dim, type);
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ class InspectorHelper : public ProgramBuilder {
|
||||||
/// Generates a DepthTexture appropriate for the params
|
/// Generates a DepthTexture appropriate for the params
|
||||||
/// @param dim the dimensions of the texture
|
/// @param dim the dimensions of the texture
|
||||||
/// @returns the generated DepthTexture
|
/// @returns the generated DepthTexture
|
||||||
sem::DepthTexture* MakeDepthTextureType(sem::TextureDimension dim) {
|
sem::DepthTexture* MakeDepthTextureType(ast::TextureDimension dim) {
|
||||||
return create<sem::DepthTexture>(dim);
|
return create<sem::DepthTexture>(dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ class InspectorHelper : public ProgramBuilder {
|
||||||
/// @param type the data type of the sampled texture
|
/// @param type the data type of the sampled texture
|
||||||
/// @returns the generated SampleTextureType
|
/// @returns the generated SampleTextureType
|
||||||
sem::MultisampledTexture* MakeMultisampledTextureType(
|
sem::MultisampledTexture* MakeMultisampledTextureType(
|
||||||
sem::TextureDimension dim,
|
ast::TextureDimension dim,
|
||||||
sem::Type* type) {
|
sem::Type* type) {
|
||||||
return create<sem::MultisampledTexture>(dim, type);
|
return create<sem::MultisampledTexture>(dim, type);
|
||||||
}
|
}
|
||||||
|
@ -552,16 +552,16 @@ class InspectorHelper : public ProgramBuilder {
|
||||||
/// @param dim dimensionality of the texture being sampled
|
/// @param dim dimensionality of the texture being sampled
|
||||||
/// @param scalar the scalar type
|
/// @param scalar the scalar type
|
||||||
/// @returns a pointer to a type appropriate for the coord param
|
/// @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) {
|
switch (dim) {
|
||||||
case sem::TextureDimension::k1d:
|
case ast::TextureDimension::k1d:
|
||||||
return scalar;
|
return scalar;
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
return create<sem::Vector>(scalar, 2);
|
return create<sem::Vector>(scalar, 2);
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
case sem::TextureDimension::kCube:
|
case ast::TextureDimension::kCube:
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
return create<sem::Vector>(scalar, 3);
|
return create<sem::Vector>(scalar, 3);
|
||||||
default:
|
default:
|
||||||
[=]() { FAIL() << "Unsupported texture dimension: " << dim; }();
|
[=]() { FAIL() << "Unsupported texture dimension: " << dim; }();
|
||||||
|
@ -574,8 +574,8 @@ class InspectorHelper : public ProgramBuilder {
|
||||||
/// @param format the image format of the storage texture
|
/// @param format the image format of the storage texture
|
||||||
/// @returns the storage texture type and subtype
|
/// @returns the storage texture type and subtype
|
||||||
std::tuple<sem::StorageTexture*, sem::Type*> MakeStorageTextureTypes(
|
std::tuple<sem::StorageTexture*, sem::Type*> MakeStorageTextureTypes(
|
||||||
sem::TextureDimension dim,
|
ast::TextureDimension dim,
|
||||||
sem::ImageFormat format) {
|
ast::ImageFormat format) {
|
||||||
sem::Type* subtype = sem::StorageTexture::SubtypeFor(format, Types());
|
sem::Type* subtype = sem::StorageTexture::SubtypeFor(format, Types());
|
||||||
return {create<sem::StorageTexture>(dim, format, subtype), subtype};
|
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
|
/// @param read_only should the access type be read only, otherwise write only
|
||||||
/// @returns the storage texture type, subtype & access control type
|
/// @returns the storage texture type, subtype & access control type
|
||||||
std::tuple<sem::StorageTexture*, sem::Type*, sem::AccessControl*>
|
std::tuple<sem::StorageTexture*, sem::Type*, sem::AccessControl*>
|
||||||
MakeStorageTextureTypes(sem::TextureDimension dim,
|
MakeStorageTextureTypes(ast::TextureDimension dim,
|
||||||
sem::ImageFormat format,
|
ast::ImageFormat format,
|
||||||
bool read_only) {
|
bool read_only) {
|
||||||
sem::StorageTexture* texture_type;
|
sem::StorageTexture* texture_type;
|
||||||
sem::Type* subtype;
|
sem::Type* subtype;
|
||||||
|
@ -705,7 +705,7 @@ class InspectorGetSampledArrayTextureResourceBindingsTest
|
||||||
: public InspectorHelper,
|
: public InspectorHelper,
|
||||||
public testing::Test {};
|
public testing::Test {};
|
||||||
struct GetSampledTextureTestParams {
|
struct GetSampledTextureTestParams {
|
||||||
sem::TextureDimension type_dim;
|
ast::TextureDimension type_dim;
|
||||||
inspector::ResourceBinding::TextureDimension inspector_dim;
|
inspector::ResourceBinding::TextureDimension inspector_dim;
|
||||||
inspector::ResourceBinding::SampledKind sampled_kind;
|
inspector::ResourceBinding::SampledKind sampled_kind;
|
||||||
};
|
};
|
||||||
|
@ -731,16 +731,16 @@ class InspectorGetMultisampledTextureResourceBindingsTestWithParam
|
||||||
class InspectorGetStorageTextureResourceBindingsTest : public InspectorHelper,
|
class InspectorGetStorageTextureResourceBindingsTest : public InspectorHelper,
|
||||||
public testing::Test {};
|
public testing::Test {};
|
||||||
struct GetDepthTextureTestParams {
|
struct GetDepthTextureTestParams {
|
||||||
sem::TextureDimension type_dim;
|
ast::TextureDimension type_dim;
|
||||||
inspector::ResourceBinding::TextureDimension inspector_dim;
|
inspector::ResourceBinding::TextureDimension inspector_dim;
|
||||||
};
|
};
|
||||||
class InspectorGetDepthTextureResourceBindingsTestWithParam
|
class InspectorGetDepthTextureResourceBindingsTestWithParam
|
||||||
: public InspectorHelper,
|
: public InspectorHelper,
|
||||||
public testing::TestWithParam<GetDepthTextureTestParams> {};
|
public testing::TestWithParam<GetDepthTextureTestParams> {};
|
||||||
|
|
||||||
typedef std::tuple<sem::TextureDimension, ResourceBinding::TextureDimension>
|
typedef std::tuple<ast::TextureDimension, ResourceBinding::TextureDimension>
|
||||||
DimensionParams;
|
DimensionParams;
|
||||||
typedef std::tuple<sem::ImageFormat,
|
typedef std::tuple<ast::ImageFormat,
|
||||||
ResourceBinding::ImageFormat,
|
ResourceBinding::ImageFormat,
|
||||||
ResourceBinding::SampledKind>
|
ResourceBinding::SampledKind>
|
||||||
ImageFormatParams;
|
ImageFormatParams;
|
||||||
|
@ -1702,7 +1702,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
||||||
{{0, ty.i32()}});
|
{{0, ty.i32()}});
|
||||||
|
|
||||||
auto* s_texture_type =
|
auto* s_texture_type =
|
||||||
MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
|
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||||
AddSampledTexture("s_texture", s_texture_type, 2, 0);
|
AddSampledTexture("s_texture", s_texture_type, 2, 0);
|
||||||
AddSampler("s_var", 3, 0);
|
AddSampler("s_var", 3, 0);
|
||||||
AddGlobalVariable("s_coords", ty.f32());
|
AddGlobalVariable("s_coords", ty.f32());
|
||||||
|
@ -1710,7 +1710,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
||||||
ty.f32(), {});
|
ty.f32(), {});
|
||||||
|
|
||||||
auto* cs_depth_texture_type =
|
auto* cs_depth_texture_type =
|
||||||
MakeDepthTextureType(sem::TextureDimension::k2d);
|
MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||||
AddDepthTexture("cs_texture", cs_depth_texture_type, 3, 1);
|
AddDepthTexture("cs_texture", cs_depth_texture_type, 3, 1);
|
||||||
AddComparisonSampler("cs_var", 3, 2);
|
AddComparisonSampler("cs_var", 3, 2);
|
||||||
AddGlobalVariable("cs_coords", ty.vec2<f32>());
|
AddGlobalVariable("cs_coords", ty.vec2<f32>());
|
||||||
|
@ -1722,7 +1722,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
||||||
sem::Type* st_subtype;
|
sem::Type* st_subtype;
|
||||||
sem::AccessControl* st_ac;
|
sem::AccessControl* st_ac;
|
||||||
std::tie(st_type, st_subtype, st_ac) = MakeStorageTextureTypes(
|
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);
|
AddStorageTexture("st_var", st_ac, 4, 0);
|
||||||
MakeStorageTextureBodyFunction("st_func", "st_var", ty.vec2<i32>(), {});
|
MakeStorageTextureBodyFunction("st_func", "st_var", ty.vec2<i32>(), {});
|
||||||
|
|
||||||
|
@ -1730,7 +1730,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
||||||
sem::Type* rost_subtype;
|
sem::Type* rost_subtype;
|
||||||
sem::AccessControl* rost_ac;
|
sem::AccessControl* rost_ac;
|
||||||
std::tie(rost_type, rost_subtype, rost_ac) = MakeStorageTextureTypes(
|
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);
|
AddStorageTexture("rost_var", rost_ac, 4, 1);
|
||||||
MakeStorageTextureBodyFunction("rost_func", "rost_var", ty.vec2<i32>(), {});
|
MakeStorageTextureBodyFunction("rost_func", "rost_var", ty.vec2<i32>(), {});
|
||||||
|
|
||||||
|
@ -2420,7 +2420,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
|
||||||
|
|
||||||
TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) {
|
TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) {
|
||||||
auto* sampled_texture_type =
|
auto* sampled_texture_type =
|
||||||
MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
|
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||||
AddSampler("foo_sampler", 0, 1);
|
AddSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.f32());
|
AddGlobalVariable("foo_coords", ty.f32());
|
||||||
|
@ -2458,7 +2458,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, NoSampler) {
|
||||||
|
|
||||||
TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
||||||
auto* sampled_texture_type =
|
auto* sampled_texture_type =
|
||||||
MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
|
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||||
AddSampler("foo_sampler", 0, 1);
|
AddSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.f32());
|
AddGlobalVariable("foo_coords", ty.f32());
|
||||||
|
@ -2485,7 +2485,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
||||||
|
|
||||||
TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
|
TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||||
auto* sampled_texture_type =
|
auto* sampled_texture_type =
|
||||||
MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
|
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||||
AddSampler("foo_sampler", 0, 1);
|
AddSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.f32());
|
AddGlobalVariable("foo_coords", ty.f32());
|
||||||
|
@ -2503,7 +2503,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
|
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);
|
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
|
||||||
AddComparisonSampler("foo_sampler", 0, 1);
|
AddComparisonSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||||
|
@ -2524,7 +2524,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) {
|
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);
|
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
|
||||||
AddComparisonSampler("foo_sampler", 0, 1);
|
AddComparisonSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||||
|
@ -2563,7 +2563,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, NoSampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
|
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);
|
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
|
||||||
AddComparisonSampler("foo_sampler", 0, 1);
|
AddComparisonSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||||
|
@ -2592,7 +2592,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
|
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);
|
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
|
||||||
AddComparisonSampler("foo_sampler", 0, 1);
|
AddComparisonSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||||
|
@ -2612,7 +2612,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||||
|
|
||||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) {
|
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) {
|
||||||
auto* sampled_texture_type =
|
auto* sampled_texture_type =
|
||||||
MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
|
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||||
AddSampler("foo_sampler", 0, 1);
|
AddSampler("foo_sampler", 0, 1);
|
||||||
AddGlobalVariable("foo_coords", ty.f32());
|
AddGlobalVariable("foo_coords", ty.f32());
|
||||||
|
@ -2686,19 +2686,19 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
InspectorGetSampledTextureResourceBindingsTestWithParam,
|
InspectorGetSampledTextureResourceBindingsTestWithParam,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
sem::TextureDimension::k1d,
|
ast::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::TextureDimension::k1d,
|
inspector::ResourceBinding::TextureDimension::k1d,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
sem::TextureDimension::k2d,
|
ast::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::TextureDimension::k2d,
|
inspector::ResourceBinding::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
sem::TextureDimension::k3d,
|
ast::TextureDimension::k3d,
|
||||||
inspector::ResourceBinding::TextureDimension::k3d,
|
inspector::ResourceBinding::TextureDimension::k3d,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
sem::TextureDimension::kCube,
|
ast::TextureDimension::kCube,
|
||||||
inspector::ResourceBinding::TextureDimension::kCube,
|
inspector::ResourceBinding::TextureDimension::kCube,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat}));
|
inspector::ResourceBinding::SampledKind::kFloat}));
|
||||||
|
|
||||||
|
@ -2738,11 +2738,11 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
InspectorGetSampledArrayTextureResourceBindingsTestWithParam,
|
InspectorGetSampledArrayTextureResourceBindingsTestWithParam,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
sem::TextureDimension::k2dArray,
|
ast::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k2dArray,
|
inspector::ResourceBinding::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetSampledTextureTestParams{
|
GetSampledTextureTestParams{
|
||||||
sem::TextureDimension::kCubeArray,
|
ast::TextureDimension::kCubeArray,
|
||||||
inspector::ResourceBinding::TextureDimension::kCubeArray,
|
inspector::ResourceBinding::TextureDimension::kCubeArray,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat}));
|
inspector::ResourceBinding::SampledKind::kFloat}));
|
||||||
|
|
||||||
|
@ -2790,15 +2790,15 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
InspectorGetMultisampledTextureResourceBindingsTestWithParam,
|
InspectorGetMultisampledTextureResourceBindingsTestWithParam,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
sem::TextureDimension::k2d,
|
ast::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::TextureDimension::k2d,
|
inspector::ResourceBinding::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
sem::TextureDimension::k2d,
|
ast::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::TextureDimension::k2d,
|
inspector::ResourceBinding::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::SampledKind::kSInt},
|
inspector::ResourceBinding::SampledKind::kSInt},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
sem::TextureDimension::k2d,
|
ast::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::TextureDimension::k2d,
|
inspector::ResourceBinding::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::SampledKind::kUInt}));
|
inspector::ResourceBinding::SampledKind::kUInt}));
|
||||||
|
|
||||||
|
@ -2852,15 +2852,15 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
InspectorGetMultisampledArrayTextureResourceBindingsTestWithParam,
|
InspectorGetMultisampledArrayTextureResourceBindingsTestWithParam,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
sem::TextureDimension::k2dArray,
|
ast::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k2dArray,
|
inspector::ResourceBinding::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kFloat},
|
inspector::ResourceBinding::SampledKind::kFloat},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
sem::TextureDimension::k2dArray,
|
ast::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k2dArray,
|
inspector::ResourceBinding::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kSInt},
|
inspector::ResourceBinding::SampledKind::kSInt},
|
||||||
GetMultisampledTextureTestParams{
|
GetMultisampledTextureTestParams{
|
||||||
sem::TextureDimension::k2dArray,
|
ast::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k2dArray,
|
inspector::ResourceBinding::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::SampledKind::kUInt}));
|
inspector::ResourceBinding::SampledKind::kUInt}));
|
||||||
|
|
||||||
|
@ -2887,11 +2887,11 @@ TEST_P(InspectorGetStorageTextureResourceBindingsTestWithParam, Simple) {
|
||||||
ImageFormatParams format_params;
|
ImageFormatParams format_params;
|
||||||
std::tie(read_only, dim_params, format_params) = GetParam();
|
std::tie(read_only, dim_params, format_params) = GetParam();
|
||||||
|
|
||||||
sem::TextureDimension dim;
|
ast::TextureDimension dim;
|
||||||
ResourceBinding::TextureDimension expected_dim;
|
ResourceBinding::TextureDimension expected_dim;
|
||||||
std::tie(dim, expected_dim) = dim_params;
|
std::tie(dim, expected_dim) = dim_params;
|
||||||
|
|
||||||
sem::ImageFormat format;
|
ast::ImageFormat format;
|
||||||
ResourceBinding::ImageFormat expected_format;
|
ResourceBinding::ImageFormat expected_format;
|
||||||
ResourceBinding::SampledKind expected_kind;
|
ResourceBinding::SampledKind expected_kind;
|
||||||
std::tie(format, expected_format, expected_kind) = format_params;
|
std::tie(format, expected_format, expected_kind) = format_params;
|
||||||
|
@ -2905,14 +2905,14 @@ TEST_P(InspectorGetStorageTextureResourceBindingsTestWithParam, Simple) {
|
||||||
|
|
||||||
sem::Type* dim_type = nullptr;
|
sem::Type* dim_type = nullptr;
|
||||||
switch (dim) {
|
switch (dim) {
|
||||||
case sem::TextureDimension::k1d:
|
case ast::TextureDimension::k1d:
|
||||||
dim_type = ty.i32();
|
dim_type = ty.i32();
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
dim_type = ty.vec2<i32>();
|
dim_type = ty.vec2<i32>();
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
dim_type = ty.vec3<i32>();
|
dim_type = ty.vec3<i32>();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -2956,61 +2956,61 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
testing::Combine(
|
testing::Combine(
|
||||||
testing::Bool(),
|
testing::Bool(),
|
||||||
testing::Values(
|
testing::Values(
|
||||||
std::make_tuple(sem::TextureDimension::k1d,
|
std::make_tuple(ast::TextureDimension::k1d,
|
||||||
ResourceBinding::TextureDimension::k1d),
|
ResourceBinding::TextureDimension::k1d),
|
||||||
std::make_tuple(sem::TextureDimension::k2d,
|
std::make_tuple(ast::TextureDimension::k2d,
|
||||||
ResourceBinding::TextureDimension::k2d),
|
ResourceBinding::TextureDimension::k2d),
|
||||||
std::make_tuple(sem::TextureDimension::k2dArray,
|
std::make_tuple(ast::TextureDimension::k2dArray,
|
||||||
ResourceBinding::TextureDimension::k2dArray),
|
ResourceBinding::TextureDimension::k2dArray),
|
||||||
std::make_tuple(sem::TextureDimension::k3d,
|
std::make_tuple(ast::TextureDimension::k3d,
|
||||||
ResourceBinding::TextureDimension::k3d)),
|
ResourceBinding::TextureDimension::k3d)),
|
||||||
testing::Values(
|
testing::Values(
|
||||||
std::make_tuple(sem::ImageFormat::kR32Float,
|
std::make_tuple(ast::ImageFormat::kR32Float,
|
||||||
ResourceBinding::ImageFormat::kR32Float,
|
ResourceBinding::ImageFormat::kR32Float,
|
||||||
ResourceBinding::SampledKind::kFloat),
|
ResourceBinding::SampledKind::kFloat),
|
||||||
std::make_tuple(sem::ImageFormat::kR32Sint,
|
std::make_tuple(ast::ImageFormat::kR32Sint,
|
||||||
ResourceBinding::ImageFormat::kR32Sint,
|
ResourceBinding::ImageFormat::kR32Sint,
|
||||||
ResourceBinding::SampledKind::kSInt),
|
ResourceBinding::SampledKind::kSInt),
|
||||||
std::make_tuple(sem::ImageFormat::kR32Uint,
|
std::make_tuple(ast::ImageFormat::kR32Uint,
|
||||||
ResourceBinding::ImageFormat::kR32Uint,
|
ResourceBinding::ImageFormat::kR32Uint,
|
||||||
ResourceBinding::SampledKind::kUInt),
|
ResourceBinding::SampledKind::kUInt),
|
||||||
std::make_tuple(sem::ImageFormat::kRg32Float,
|
std::make_tuple(ast::ImageFormat::kRg32Float,
|
||||||
ResourceBinding::ImageFormat::kRg32Float,
|
ResourceBinding::ImageFormat::kRg32Float,
|
||||||
ResourceBinding::SampledKind::kFloat),
|
ResourceBinding::SampledKind::kFloat),
|
||||||
std::make_tuple(sem::ImageFormat::kRg32Sint,
|
std::make_tuple(ast::ImageFormat::kRg32Sint,
|
||||||
ResourceBinding::ImageFormat::kRg32Sint,
|
ResourceBinding::ImageFormat::kRg32Sint,
|
||||||
ResourceBinding::SampledKind::kSInt),
|
ResourceBinding::SampledKind::kSInt),
|
||||||
std::make_tuple(sem::ImageFormat::kRg32Uint,
|
std::make_tuple(ast::ImageFormat::kRg32Uint,
|
||||||
ResourceBinding::ImageFormat::kRg32Uint,
|
ResourceBinding::ImageFormat::kRg32Uint,
|
||||||
ResourceBinding::SampledKind::kUInt),
|
ResourceBinding::SampledKind::kUInt),
|
||||||
std::make_tuple(sem::ImageFormat::kRgba16Float,
|
std::make_tuple(ast::ImageFormat::kRgba16Float,
|
||||||
ResourceBinding::ImageFormat::kRgba16Float,
|
ResourceBinding::ImageFormat::kRgba16Float,
|
||||||
ResourceBinding::SampledKind::kFloat),
|
ResourceBinding::SampledKind::kFloat),
|
||||||
std::make_tuple(sem::ImageFormat::kRgba16Sint,
|
std::make_tuple(ast::ImageFormat::kRgba16Sint,
|
||||||
ResourceBinding::ImageFormat::kRgba16Sint,
|
ResourceBinding::ImageFormat::kRgba16Sint,
|
||||||
ResourceBinding::SampledKind::kSInt),
|
ResourceBinding::SampledKind::kSInt),
|
||||||
std::make_tuple(sem::ImageFormat::kRgba16Uint,
|
std::make_tuple(ast::ImageFormat::kRgba16Uint,
|
||||||
ResourceBinding::ImageFormat::kRgba16Uint,
|
ResourceBinding::ImageFormat::kRgba16Uint,
|
||||||
ResourceBinding::SampledKind::kUInt),
|
ResourceBinding::SampledKind::kUInt),
|
||||||
std::make_tuple(sem::ImageFormat::kRgba32Float,
|
std::make_tuple(ast::ImageFormat::kRgba32Float,
|
||||||
ResourceBinding::ImageFormat::kRgba32Float,
|
ResourceBinding::ImageFormat::kRgba32Float,
|
||||||
ResourceBinding::SampledKind::kFloat),
|
ResourceBinding::SampledKind::kFloat),
|
||||||
std::make_tuple(sem::ImageFormat::kRgba32Sint,
|
std::make_tuple(ast::ImageFormat::kRgba32Sint,
|
||||||
ResourceBinding::ImageFormat::kRgba32Sint,
|
ResourceBinding::ImageFormat::kRgba32Sint,
|
||||||
ResourceBinding::SampledKind::kSInt),
|
ResourceBinding::SampledKind::kSInt),
|
||||||
std::make_tuple(sem::ImageFormat::kRgba32Uint,
|
std::make_tuple(ast::ImageFormat::kRgba32Uint,
|
||||||
ResourceBinding::ImageFormat::kRgba32Uint,
|
ResourceBinding::ImageFormat::kRgba32Uint,
|
||||||
ResourceBinding::SampledKind::kUInt),
|
ResourceBinding::SampledKind::kUInt),
|
||||||
std::make_tuple(sem::ImageFormat::kRgba8Sint,
|
std::make_tuple(ast::ImageFormat::kRgba8Sint,
|
||||||
ResourceBinding::ImageFormat::kRgba8Sint,
|
ResourceBinding::ImageFormat::kRgba8Sint,
|
||||||
ResourceBinding::SampledKind::kSInt),
|
ResourceBinding::SampledKind::kSInt),
|
||||||
std::make_tuple(sem::ImageFormat::kRgba8Snorm,
|
std::make_tuple(ast::ImageFormat::kRgba8Snorm,
|
||||||
ResourceBinding::ImageFormat::kRgba8Snorm,
|
ResourceBinding::ImageFormat::kRgba8Snorm,
|
||||||
ResourceBinding::SampledKind::kFloat),
|
ResourceBinding::SampledKind::kFloat),
|
||||||
std::make_tuple(sem::ImageFormat::kRgba8Uint,
|
std::make_tuple(ast::ImageFormat::kRgba8Uint,
|
||||||
ResourceBinding::ImageFormat::kRgba8Uint,
|
ResourceBinding::ImageFormat::kRgba8Uint,
|
||||||
ResourceBinding::SampledKind::kUInt),
|
ResourceBinding::SampledKind::kUInt),
|
||||||
std::make_tuple(sem::ImageFormat::kRgba8Unorm,
|
std::make_tuple(ast::ImageFormat::kRgba8Unorm,
|
||||||
ResourceBinding::ImageFormat::kRgba8Unorm,
|
ResourceBinding::ImageFormat::kRgba8Unorm,
|
||||||
ResourceBinding::SampledKind::kFloat))));
|
ResourceBinding::SampledKind::kFloat))));
|
||||||
|
|
||||||
|
@ -3047,16 +3047,16 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
InspectorGetDepthTextureResourceBindingsTestWithParam,
|
InspectorGetDepthTextureResourceBindingsTestWithParam,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
GetDepthTextureTestParams{
|
GetDepthTextureTestParams{
|
||||||
sem::TextureDimension::k2d,
|
ast::TextureDimension::k2d,
|
||||||
inspector::ResourceBinding::TextureDimension::k2d},
|
inspector::ResourceBinding::TextureDimension::k2d},
|
||||||
GetDepthTextureTestParams{
|
GetDepthTextureTestParams{
|
||||||
sem::TextureDimension::k2dArray,
|
ast::TextureDimension::k2dArray,
|
||||||
inspector::ResourceBinding::TextureDimension::k2dArray},
|
inspector::ResourceBinding::TextureDimension::k2dArray},
|
||||||
GetDepthTextureTestParams{
|
GetDepthTextureTestParams{
|
||||||
sem::TextureDimension::kCube,
|
ast::TextureDimension::kCube,
|
||||||
inspector::ResourceBinding::TextureDimension::kCube},
|
inspector::ResourceBinding::TextureDimension::kCube},
|
||||||
GetDepthTextureTestParams{
|
GetDepthTextureTestParams{
|
||||||
sem::TextureDimension::kCubeArray,
|
ast::TextureDimension::kCubeArray,
|
||||||
inspector::ResourceBinding::TextureDimension::kCubeArray}));
|
inspector::ResourceBinding::TextureDimension::kCubeArray}));
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -428,7 +428,7 @@ class ArrayBuilder : public Builder {
|
||||||
/// SampledTextureBuilder is a Matcher / Builder for sampled texture types.
|
/// SampledTextureBuilder is a Matcher / Builder for sampled texture types.
|
||||||
class SampledTextureBuilder : public Builder {
|
class SampledTextureBuilder : public Builder {
|
||||||
public:
|
public:
|
||||||
explicit SampledTextureBuilder(sem::TextureDimension dimensions,
|
explicit SampledTextureBuilder(ast::TextureDimension dimensions,
|
||||||
Builder* type_builder)
|
Builder* type_builder)
|
||||||
: dimensions_(dimensions), type_builder_(type_builder) {}
|
: dimensions_(dimensions), type_builder_(type_builder) {}
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ class SampledTextureBuilder : public Builder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sem::TextureDimension const dimensions_;
|
ast::TextureDimension const dimensions_;
|
||||||
Builder* const type_builder_;
|
Builder* const type_builder_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ class SampledTextureBuilder : public Builder {
|
||||||
/// types.
|
/// types.
|
||||||
class MultisampledTextureBuilder : public Builder {
|
class MultisampledTextureBuilder : public Builder {
|
||||||
public:
|
public:
|
||||||
explicit MultisampledTextureBuilder(sem::TextureDimension dimensions,
|
explicit MultisampledTextureBuilder(ast::TextureDimension dimensions,
|
||||||
Builder* type_builder)
|
Builder* type_builder)
|
||||||
: dimensions_(dimensions), type_builder_(type_builder) {}
|
: dimensions_(dimensions), type_builder_(type_builder) {}
|
||||||
|
|
||||||
|
@ -487,14 +487,14 @@ class MultisampledTextureBuilder : public Builder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sem::TextureDimension const dimensions_;
|
ast::TextureDimension const dimensions_;
|
||||||
Builder* const type_builder_;
|
Builder* const type_builder_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// DepthTextureBuilder is a Matcher / Builder for depth texture types.
|
/// DepthTextureBuilder is a Matcher / Builder for depth texture types.
|
||||||
class DepthTextureBuilder : public Builder {
|
class DepthTextureBuilder : public Builder {
|
||||||
public:
|
public:
|
||||||
explicit DepthTextureBuilder(sem::TextureDimension dimensions)
|
explicit DepthTextureBuilder(ast::TextureDimension dimensions)
|
||||||
: dimensions_(dimensions) {}
|
: dimensions_(dimensions) {}
|
||||||
|
|
||||||
bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
|
bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
|
||||||
|
@ -515,7 +515,7 @@ class DepthTextureBuilder : public Builder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sem::TextureDimension const dimensions_;
|
ast::TextureDimension const dimensions_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// StorageTextureBuilder is a Matcher / Builder for storage texture types of
|
/// StorageTextureBuilder is a Matcher / Builder for storage texture types of
|
||||||
|
@ -523,7 +523,7 @@ class DepthTextureBuilder : public Builder {
|
||||||
class StorageTextureBuilder : public Builder {
|
class StorageTextureBuilder : public Builder {
|
||||||
public:
|
public:
|
||||||
explicit StorageTextureBuilder(
|
explicit StorageTextureBuilder(
|
||||||
sem::TextureDimension dimensions,
|
ast::TextureDimension dimensions,
|
||||||
OpenNumber texel_format, // a.k.a "image format"
|
OpenNumber texel_format, // a.k.a "image format"
|
||||||
OpenType channel_format) // a.k.a "storage subtype"
|
OpenType channel_format) // a.k.a "storage subtype"
|
||||||
: dimensions_(dimensions),
|
: dimensions_(dimensions),
|
||||||
|
@ -552,7 +552,7 @@ class StorageTextureBuilder : public Builder {
|
||||||
|
|
||||||
sem::Type* Build(BuildState& state) const override {
|
sem::Type* Build(BuildState& state) const override {
|
||||||
auto texel_format =
|
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_);
|
auto* channel_format = state.open_types.at(channel_format_);
|
||||||
return state.ty_mgr.Get<sem::StorageTexture>(dimensions_, texel_format,
|
return state.ty_mgr.Get<sem::StorageTexture>(dimensions_, texel_format,
|
||||||
channel_format);
|
channel_format);
|
||||||
|
@ -565,7 +565,7 @@ class StorageTextureBuilder : public Builder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sem::TextureDimension const dimensions_;
|
ast::TextureDimension const dimensions_;
|
||||||
OpenNumber const texel_format_;
|
OpenNumber const texel_format_;
|
||||||
OpenType const channel_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.
|
/// SamplerBuilder is a Matcher / Builder for sampler types of the given kind.
|
||||||
class SamplerBuilder : public Builder {
|
class SamplerBuilder : public Builder {
|
||||||
public:
|
public:
|
||||||
explicit SamplerBuilder(sem::SamplerKind kind) : kind_(kind) {}
|
explicit SamplerBuilder(ast::SamplerKind kind) : kind_(kind) {}
|
||||||
|
|
||||||
bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
|
bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
|
||||||
if (auto* sampler = ty->As<sem::Sampler>()) {
|
if (auto* sampler = ty->As<sem::Sampler>()) {
|
||||||
|
@ -588,16 +588,16 @@ class SamplerBuilder : public Builder {
|
||||||
|
|
||||||
std::string str() const override {
|
std::string str() const override {
|
||||||
switch (kind_) {
|
switch (kind_) {
|
||||||
case sem::SamplerKind::kSampler:
|
case ast::SamplerKind::kSampler:
|
||||||
return "sampler";
|
return "sampler";
|
||||||
case sem::SamplerKind::kComparisonSampler:
|
case ast::SamplerKind::kComparisonSampler:
|
||||||
return "sampler_comparison";
|
return "sampler_comparison";
|
||||||
}
|
}
|
||||||
return "sampler";
|
return "sampler";
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sem::SamplerKind const kind_;
|
ast::SamplerKind const kind_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// AccessControlBuilder is a Matcher / Builder for AccessControl types
|
/// 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
|
/// @returns a Matcher / Builder that matches a sampled texture with the given
|
||||||
/// dimensions and type
|
/// 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);
|
return matcher_allocator_.Create<SampledTextureBuilder>(dimensions, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @returns a Matcher / Builder that matches a multisampled texture with the
|
/// @returns a Matcher / Builder that matches a multisampled texture with the
|
||||||
/// given dimensions and type
|
/// given dimensions and type
|
||||||
Builder* multisampled_texture(sem::TextureDimension dimensions,
|
Builder* multisampled_texture(ast::TextureDimension dimensions,
|
||||||
Builder* type) {
|
Builder* type) {
|
||||||
return matcher_allocator_.Create<MultisampledTextureBuilder>(dimensions,
|
return matcher_allocator_.Create<MultisampledTextureBuilder>(dimensions,
|
||||||
type);
|
type);
|
||||||
|
@ -746,13 +746,13 @@ class Impl : public IntrinsicTable {
|
||||||
|
|
||||||
/// @returns a Matcher / Builder that matches a depth texture with the
|
/// @returns a Matcher / Builder that matches a depth texture with the
|
||||||
/// given dimensions
|
/// given dimensions
|
||||||
Builder* depth_texture(sem::TextureDimension dimensions) {
|
Builder* depth_texture(ast::TextureDimension dimensions) {
|
||||||
return matcher_allocator_.Create<DepthTextureBuilder>(dimensions);
|
return matcher_allocator_.Create<DepthTextureBuilder>(dimensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @returns a Matcher / Builder that matches a storage texture of the given
|
/// @returns a Matcher / Builder that matches a storage texture of the given
|
||||||
/// format with the given dimensions
|
/// format with the given dimensions
|
||||||
Builder* storage_texture(sem::TextureDimension dimensions,
|
Builder* storage_texture(ast::TextureDimension dimensions,
|
||||||
OpenNumber texel_format,
|
OpenNumber texel_format,
|
||||||
OpenType channel_format) {
|
OpenType channel_format) {
|
||||||
return matcher_allocator_.Create<StorageTextureBuilder>(
|
return matcher_allocator_.Create<StorageTextureBuilder>(
|
||||||
|
@ -760,7 +760,7 @@ class Impl : public IntrinsicTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @returns a Matcher / Builder that matches a sampler type
|
/// @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);
|
return matcher_allocator_.Create<SamplerBuilder>(kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -797,7 +797,7 @@ class Impl : public IntrinsicTable {
|
||||||
|
|
||||||
Impl::Impl() {
|
Impl::Impl() {
|
||||||
using I = sem::IntrinsicType;
|
using I = sem::IntrinsicType;
|
||||||
using Dim = sem::TextureDimension;
|
using Dim = ast::TextureDimension;
|
||||||
|
|
||||||
auto* void_ = &matchers_.void_; // void
|
auto* void_ = &matchers_.void_; // void
|
||||||
auto* bool_ = &matchers_.bool_; // bool
|
auto* bool_ = &matchers_.bool_; // bool
|
||||||
|
@ -1115,9 +1115,9 @@ Impl::Impl() {
|
||||||
access_control(ast::AccessControl::kWriteOnly, tex_storage_2d_array_FT);
|
access_control(ast::AccessControl::kWriteOnly, tex_storage_2d_array_FT);
|
||||||
auto* tex_storage_wo_3d_FT =
|
auto* tex_storage_wo_3d_FT =
|
||||||
access_control(ast::AccessControl::kWriteOnly, tex_storage_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 =
|
auto* sampler_comparison =
|
||||||
this->sampler(sem::SamplerKind::kComparisonSampler);
|
this->sampler(ast::SamplerKind::kComparisonSampler);
|
||||||
auto t = sem::Parameter::Usage::kTexture;
|
auto t = sem::Parameter::Usage::kTexture;
|
||||||
auto s = sem::Parameter::Usage::kSampler;
|
auto s = sem::Parameter::Usage::kSampler;
|
||||||
auto coords = sem::Parameter::Usage::kCoords;
|
auto coords = sem::Parameter::Usage::kCoords;
|
||||||
|
|
|
@ -69,7 +69,7 @@ TEST_F(IntrinsicTableTest, MismatchU32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchI32) {
|
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,
|
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
|
||||||
{tex, ty.i32(), ty.i32()}, Source{});
|
{tex, ty.i32(), ty.i32()}, Source{});
|
||||||
ASSERT_NE(result.intrinsic, nullptr);
|
ASSERT_NE(result.intrinsic, nullptr);
|
||||||
|
@ -83,7 +83,7 @@ TEST_F(IntrinsicTableTest, MatchI32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchI32) {
|
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,
|
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
|
||||||
{tex, ty.f32()}, Source{});
|
{tex, ty.f32()}, Source{});
|
||||||
ASSERT_EQ(result.intrinsic, nullptr);
|
ASSERT_EQ(result.intrinsic, nullptr);
|
||||||
|
@ -219,8 +219,8 @@ TEST_F(IntrinsicTableTest, MismatchArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchSampler) {
|
TEST_F(IntrinsicTableTest, MatchSampler) {
|
||||||
auto* tex = create<sem::SampledTexture>(sem::TextureDimension::k2d, ty.f32());
|
auto* tex = create<sem::SampledTexture>(ast::TextureDimension::k2d, ty.f32());
|
||||||
auto* sampler = create<sem::Sampler>(sem::SamplerKind::kSampler);
|
auto* sampler = create<sem::Sampler>(ast::SamplerKind::kSampler);
|
||||||
auto result = table->Lookup(*this, IntrinsicType::kTextureSample,
|
auto result = table->Lookup(*this, IntrinsicType::kTextureSample,
|
||||||
{tex, sampler, ty.vec2<f32>()}, Source{});
|
{tex, sampler, ty.vec2<f32>()}, Source{});
|
||||||
ASSERT_NE(result.intrinsic, nullptr);
|
ASSERT_NE(result.intrinsic, nullptr);
|
||||||
|
@ -235,7 +235,7 @@ TEST_F(IntrinsicTableTest, MatchSampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchSampler) {
|
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,
|
auto result = table->Lookup(*this, IntrinsicType::kTextureSample,
|
||||||
{tex, ty.f32(), ty.vec2<f32>()}, Source{});
|
{tex, ty.f32(), ty.vec2<f32>()}, Source{});
|
||||||
ASSERT_EQ(result.intrinsic, nullptr);
|
ASSERT_EQ(result.intrinsic, nullptr);
|
||||||
|
@ -243,7 +243,7 @@ TEST_F(IntrinsicTableTest, MismatchSampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchSampledTexture) {
|
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,
|
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
|
||||||
{tex, ty.vec2<i32>(), ty.i32()}, Source{});
|
{tex, ty.vec2<i32>(), ty.i32()}, Source{});
|
||||||
ASSERT_NE(result.intrinsic, nullptr);
|
ASSERT_NE(result.intrinsic, nullptr);
|
||||||
|
@ -258,7 +258,7 @@ TEST_F(IntrinsicTableTest, MatchSampledTexture) {
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchMultisampledTexture) {
|
TEST_F(IntrinsicTableTest, MatchMultisampledTexture) {
|
||||||
auto* tex =
|
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,
|
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
|
||||||
{tex, ty.vec2<i32>(), ty.i32()}, Source{});
|
{tex, ty.vec2<i32>(), ty.i32()}, Source{});
|
||||||
ASSERT_NE(result.intrinsic, nullptr);
|
ASSERT_NE(result.intrinsic, nullptr);
|
||||||
|
@ -272,7 +272,7 @@ TEST_F(IntrinsicTableTest, MatchMultisampledTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchDepthTexture) {
|
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,
|
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
|
||||||
{tex, ty.vec2<i32>(), ty.i32()}, Source{});
|
{tex, ty.vec2<i32>(), ty.i32()}, Source{});
|
||||||
ASSERT_NE(result.intrinsic, nullptr);
|
ASSERT_NE(result.intrinsic, nullptr);
|
||||||
|
@ -287,8 +287,8 @@ TEST_F(IntrinsicTableTest, MatchDepthTexture) {
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchROStorageTexture) {
|
TEST_F(IntrinsicTableTest, MatchROStorageTexture) {
|
||||||
auto* tex = create<sem::StorageTexture>(
|
auto* tex = create<sem::StorageTexture>(
|
||||||
sem::TextureDimension::k2d, sem::ImageFormat::kR16Float,
|
ast::TextureDimension::k2d, ast::ImageFormat::kR16Float,
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types()));
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR16Float, Types()));
|
||||||
auto* tex_ac = create<sem::AccessControl>(ast::AccessControl::kReadOnly, tex);
|
auto* tex_ac = create<sem::AccessControl>(ast::AccessControl::kReadOnly, tex);
|
||||||
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
|
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
|
||||||
{tex_ac, ty.vec2<i32>()}, Source{});
|
{tex_ac, ty.vec2<i32>()}, Source{});
|
||||||
|
@ -304,8 +304,8 @@ TEST_F(IntrinsicTableTest, MatchROStorageTexture) {
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
|
TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
|
||||||
auto* tex = create<sem::StorageTexture>(
|
auto* tex = create<sem::StorageTexture>(
|
||||||
sem::TextureDimension::k2d, sem::ImageFormat::kR16Float,
|
ast::TextureDimension::k2d, ast::ImageFormat::kR16Float,
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types()));
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR16Float, Types()));
|
||||||
auto* tex_ac =
|
auto* tex_ac =
|
||||||
create<sem::AccessControl>(ast::AccessControl::kWriteOnly, tex);
|
create<sem::AccessControl>(ast::AccessControl::kWriteOnly, tex);
|
||||||
auto result =
|
auto result =
|
||||||
|
@ -464,7 +464,7 @@ TEST_F(IntrinsicTableTest, OverloadOrderByNumberOfParameters) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) {
|
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,
|
auto result = table->Lookup(*this, IntrinsicType::kTextureDimensions,
|
||||||
{tex, ty.bool_()}, Source{});
|
{tex, ty.bool_()}, Source{});
|
||||||
ASSERT_EQ(
|
ASSERT_EQ(
|
||||||
|
|
|
@ -100,83 +100,83 @@ ast::Builtin EnumConverter::ToBuiltin(SpvBuiltIn b) {
|
||||||
return ast::Builtin::kNone;
|
return ast::Builtin::kNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
sem::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
|
ast::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
|
||||||
if (arrayed) {
|
if (arrayed) {
|
||||||
switch (dim) {
|
switch (dim) {
|
||||||
case SpvDim2D:
|
case SpvDim2D:
|
||||||
return sem::TextureDimension::k2dArray;
|
return ast::TextureDimension::k2dArray;
|
||||||
case SpvDimCube:
|
case SpvDimCube:
|
||||||
return sem::TextureDimension::kCubeArray;
|
return ast::TextureDimension::kCubeArray;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Fail() << "arrayed dimension must be 1D, 2D, or Cube. Got " << int(dim);
|
Fail() << "arrayed dimension must be 1D, 2D, or Cube. Got " << int(dim);
|
||||||
return sem::TextureDimension::kNone;
|
return ast::TextureDimension::kNone;
|
||||||
}
|
}
|
||||||
// Assume non-arrayed
|
// Assume non-arrayed
|
||||||
switch (dim) {
|
switch (dim) {
|
||||||
case SpvDim1D:
|
case SpvDim1D:
|
||||||
return sem::TextureDimension::k1d;
|
return ast::TextureDimension::k1d;
|
||||||
case SpvDim2D:
|
case SpvDim2D:
|
||||||
return sem::TextureDimension::k2d;
|
return ast::TextureDimension::k2d;
|
||||||
case SpvDim3D:
|
case SpvDim3D:
|
||||||
return sem::TextureDimension::k3d;
|
return ast::TextureDimension::k3d;
|
||||||
case SpvDimCube:
|
case SpvDimCube:
|
||||||
return sem::TextureDimension::kCube;
|
return ast::TextureDimension::kCube;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Fail() << "invalid dimension: " << int(dim);
|
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) {
|
switch (fmt) {
|
||||||
case SpvImageFormatUnknown:
|
case SpvImageFormatUnknown:
|
||||||
return sem::ImageFormat::kNone;
|
return ast::ImageFormat::kNone;
|
||||||
|
|
||||||
// 8 bit channels
|
// 8 bit channels
|
||||||
case SpvImageFormatRgba8:
|
case SpvImageFormatRgba8:
|
||||||
return sem::ImageFormat::kRgba8Unorm;
|
return ast::ImageFormat::kRgba8Unorm;
|
||||||
case SpvImageFormatRgba8Snorm:
|
case SpvImageFormatRgba8Snorm:
|
||||||
return sem::ImageFormat::kRgba8Snorm;
|
return ast::ImageFormat::kRgba8Snorm;
|
||||||
case SpvImageFormatRgba8ui:
|
case SpvImageFormatRgba8ui:
|
||||||
return sem::ImageFormat::kRgba8Uint;
|
return ast::ImageFormat::kRgba8Uint;
|
||||||
case SpvImageFormatRgba8i:
|
case SpvImageFormatRgba8i:
|
||||||
return sem::ImageFormat::kRgba8Sint;
|
return ast::ImageFormat::kRgba8Sint;
|
||||||
|
|
||||||
// 16 bit channels
|
// 16 bit channels
|
||||||
case SpvImageFormatRgba16ui:
|
case SpvImageFormatRgba16ui:
|
||||||
return sem::ImageFormat::kRgba16Uint;
|
return ast::ImageFormat::kRgba16Uint;
|
||||||
case SpvImageFormatRgba16i:
|
case SpvImageFormatRgba16i:
|
||||||
return sem::ImageFormat::kRgba16Sint;
|
return ast::ImageFormat::kRgba16Sint;
|
||||||
case SpvImageFormatRgba16f:
|
case SpvImageFormatRgba16f:
|
||||||
return sem::ImageFormat::kRgba16Float;
|
return ast::ImageFormat::kRgba16Float;
|
||||||
|
|
||||||
// 32 bit channels
|
// 32 bit channels
|
||||||
case SpvImageFormatR32ui:
|
case SpvImageFormatR32ui:
|
||||||
return sem::ImageFormat::kR32Uint;
|
return ast::ImageFormat::kR32Uint;
|
||||||
case SpvImageFormatR32i:
|
case SpvImageFormatR32i:
|
||||||
return sem::ImageFormat::kR32Sint;
|
return ast::ImageFormat::kR32Sint;
|
||||||
case SpvImageFormatR32f:
|
case SpvImageFormatR32f:
|
||||||
return sem::ImageFormat::kR32Float;
|
return ast::ImageFormat::kR32Float;
|
||||||
case SpvImageFormatRg32ui:
|
case SpvImageFormatRg32ui:
|
||||||
return sem::ImageFormat::kRg32Uint;
|
return ast::ImageFormat::kRg32Uint;
|
||||||
case SpvImageFormatRg32i:
|
case SpvImageFormatRg32i:
|
||||||
return sem::ImageFormat::kRg32Sint;
|
return ast::ImageFormat::kRg32Sint;
|
||||||
case SpvImageFormatRg32f:
|
case SpvImageFormatRg32f:
|
||||||
return sem::ImageFormat::kRg32Float;
|
return ast::ImageFormat::kRg32Float;
|
||||||
case SpvImageFormatRgba32ui:
|
case SpvImageFormatRgba32ui:
|
||||||
return sem::ImageFormat::kRgba32Uint;
|
return ast::ImageFormat::kRgba32Uint;
|
||||||
case SpvImageFormatRgba32i:
|
case SpvImageFormatRgba32i:
|
||||||
return sem::ImageFormat::kRgba32Sint;
|
return ast::ImageFormat::kRgba32Sint;
|
||||||
case SpvImageFormatRgba32f:
|
case SpvImageFormatRgba32f:
|
||||||
return sem::ImageFormat::kRgba32Float;
|
return ast::ImageFormat::kRgba32Float;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Fail() << "invalid image format: " << int(fmt);
|
Fail() << "invalid image format: " << int(fmt);
|
||||||
return sem::ImageFormat::kNone;
|
return ast::ImageFormat::kNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace spirv
|
} // namespace spirv
|
||||||
|
|
|
@ -58,13 +58,13 @@ class EnumConverter {
|
||||||
/// @param dim the SPIR-V Dim value
|
/// @param dim the SPIR-V Dim value
|
||||||
/// @param arrayed true if the texture is arrayed
|
/// @param arrayed true if the texture is arrayed
|
||||||
/// @returns a Tint AST texture dimension
|
/// @returns a Tint AST texture dimension
|
||||||
sem::TextureDimension ToDim(SpvDim dim, bool arrayed);
|
ast::TextureDimension ToDim(SpvDim dim, bool arrayed);
|
||||||
|
|
||||||
/// Converts a SPIR-V Image Format to a Tint ImageFormat
|
/// Converts a SPIR-V Image Format to a Tint ImageFormat
|
||||||
/// On failure, logs an error and returns kNone
|
/// On failure, logs an error and returns kNone
|
||||||
/// @param fmt the SPIR-V format
|
/// @param fmt the SPIR-V format
|
||||||
/// @returns a Tint AST format
|
/// @returns a Tint AST format
|
||||||
sem::ImageFormat ToImageFormat(SpvImageFormat fmt);
|
ast::ImageFormat ToImageFormat(SpvImageFormat fmt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Registers a failure and returns a stream for log diagnostics.
|
/// Registers a failure and returns a stream for log diagnostics.
|
||||||
|
|
|
@ -243,7 +243,7 @@ struct DimCase {
|
||||||
SpvDim dim;
|
SpvDim dim;
|
||||||
bool arrayed;
|
bool arrayed;
|
||||||
bool expect_success;
|
bool expect_success;
|
||||||
sem::TextureDimension expected;
|
ast::TextureDimension expected;
|
||||||
};
|
};
|
||||||
inline std::ostream& operator<<(std::ostream& out, DimCase dc) {
|
inline std::ostream& operator<<(std::ostream& out, DimCase dc) {
|
||||||
out << "DimCase{ SpvDim:" << int(dc.dim) << " arrayed?:" << int(dc.arrayed)
|
out << "DimCase{ SpvDim:" << int(dc.dim) << " arrayed?:" << int(dc.arrayed)
|
||||||
|
@ -287,37 +287,37 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
SpvDimTest,
|
SpvDimTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
// Non-arrayed
|
// Non-arrayed
|
||||||
DimCase{SpvDim1D, false, true, sem::TextureDimension::k1d},
|
DimCase{SpvDim1D, false, true, ast::TextureDimension::k1d},
|
||||||
DimCase{SpvDim2D, false, true, sem::TextureDimension::k2d},
|
DimCase{SpvDim2D, false, true, ast::TextureDimension::k2d},
|
||||||
DimCase{SpvDim3D, false, true, sem::TextureDimension::k3d},
|
DimCase{SpvDim3D, false, true, ast::TextureDimension::k3d},
|
||||||
DimCase{SpvDimCube, false, true, sem::TextureDimension::kCube},
|
DimCase{SpvDimCube, false, true, ast::TextureDimension::kCube},
|
||||||
// Arrayed
|
// Arrayed
|
||||||
DimCase{SpvDim2D, true, true, sem::TextureDimension::k2dArray},
|
DimCase{SpvDim2D, true, true, ast::TextureDimension::k2dArray},
|
||||||
DimCase{SpvDimCube, true, true, sem::TextureDimension::kCubeArray}));
|
DimCase{SpvDimCube, true, true, ast::TextureDimension::kCubeArray}));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
EnumConverterBad,
|
EnumConverterBad,
|
||||||
SpvDimTest,
|
SpvDimTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
// Invalid SPIR-V dimensionality.
|
// Invalid SPIR-V dimensionality.
|
||||||
DimCase{SpvDimMax, false, false, sem::TextureDimension::kNone},
|
DimCase{SpvDimMax, false, false, ast::TextureDimension::kNone},
|
||||||
DimCase{SpvDimMax, true, false, sem::TextureDimension::kNone},
|
DimCase{SpvDimMax, true, false, ast::TextureDimension::kNone},
|
||||||
// Vulkan non-arrayed dimensionalities not supported by WGSL.
|
// Vulkan non-arrayed dimensionalities not supported by WGSL.
|
||||||
DimCase{SpvDimRect, false, false, sem::TextureDimension::kNone},
|
DimCase{SpvDimRect, false, false, ast::TextureDimension::kNone},
|
||||||
DimCase{SpvDimBuffer, false, false, sem::TextureDimension::kNone},
|
DimCase{SpvDimBuffer, false, false, ast::TextureDimension::kNone},
|
||||||
DimCase{SpvDimSubpassData, false, false, sem::TextureDimension::kNone},
|
DimCase{SpvDimSubpassData, false, false, ast::TextureDimension::kNone},
|
||||||
// Arrayed dimensionalities not supported by WGSL
|
// Arrayed dimensionalities not supported by WGSL
|
||||||
DimCase{SpvDim3D, true, false, sem::TextureDimension::kNone},
|
DimCase{SpvDim3D, true, false, ast::TextureDimension::kNone},
|
||||||
DimCase{SpvDimRect, true, false, sem::TextureDimension::kNone},
|
DimCase{SpvDimRect, true, false, ast::TextureDimension::kNone},
|
||||||
DimCase{SpvDimBuffer, true, false, sem::TextureDimension::kNone},
|
DimCase{SpvDimBuffer, true, false, ast::TextureDimension::kNone},
|
||||||
DimCase{SpvDimSubpassData, true, false, sem::TextureDimension::kNone}));
|
DimCase{SpvDimSubpassData, true, false, ast::TextureDimension::kNone}));
|
||||||
|
|
||||||
// ImageFormat
|
// ImageFormat
|
||||||
|
|
||||||
struct ImageFormatCase {
|
struct ImageFormatCase {
|
||||||
SpvImageFormat format;
|
SpvImageFormat format;
|
||||||
bool expect_success;
|
bool expect_success;
|
||||||
sem::ImageFormat expected;
|
ast::ImageFormat expected;
|
||||||
};
|
};
|
||||||
inline std::ostream& operator<<(std::ostream& out, ImageFormatCase ifc) {
|
inline std::ostream& operator<<(std::ostream& out, ImageFormatCase ifc) {
|
||||||
out << "ImageFormatCase{ SpvImageFormat:" << int(ifc.format)
|
out << "ImageFormatCase{ SpvImageFormat:" << int(ifc.format)
|
||||||
|
@ -361,68 +361,68 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
SpvImageFormatTest,
|
SpvImageFormatTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
// Unknown. This is used for sampled images.
|
// Unknown. This is used for sampled images.
|
||||||
ImageFormatCase{SpvImageFormatUnknown, true, sem::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatUnknown, true, ast::ImageFormat::kNone},
|
||||||
// 8 bit channels
|
// 8 bit channels
|
||||||
ImageFormatCase{SpvImageFormatRgba8, true,
|
ImageFormatCase{SpvImageFormatRgba8, true,
|
||||||
sem::ImageFormat::kRgba8Unorm},
|
ast::ImageFormat::kRgba8Unorm},
|
||||||
ImageFormatCase{SpvImageFormatRgba8Snorm, true,
|
ImageFormatCase{SpvImageFormatRgba8Snorm, true,
|
||||||
sem::ImageFormat::kRgba8Snorm},
|
ast::ImageFormat::kRgba8Snorm},
|
||||||
ImageFormatCase{SpvImageFormatRgba8ui, true,
|
ImageFormatCase{SpvImageFormatRgba8ui, true,
|
||||||
sem::ImageFormat::kRgba8Uint},
|
ast::ImageFormat::kRgba8Uint},
|
||||||
ImageFormatCase{SpvImageFormatRgba8i, true,
|
ImageFormatCase{SpvImageFormatRgba8i, true,
|
||||||
sem::ImageFormat::kRgba8Sint},
|
ast::ImageFormat::kRgba8Sint},
|
||||||
// 16 bit channels
|
// 16 bit channels
|
||||||
ImageFormatCase{SpvImageFormatRgba16ui, true,
|
ImageFormatCase{SpvImageFormatRgba16ui, true,
|
||||||
sem::ImageFormat::kRgba16Uint},
|
ast::ImageFormat::kRgba16Uint},
|
||||||
ImageFormatCase{SpvImageFormatRgba16i, true,
|
ImageFormatCase{SpvImageFormatRgba16i, true,
|
||||||
sem::ImageFormat::kRgba16Sint},
|
ast::ImageFormat::kRgba16Sint},
|
||||||
ImageFormatCase{SpvImageFormatRgba16f, true,
|
ImageFormatCase{SpvImageFormatRgba16f, true,
|
||||||
sem::ImageFormat::kRgba16Float},
|
ast::ImageFormat::kRgba16Float},
|
||||||
// 32 bit channels
|
// 32 bit channels
|
||||||
// ... 1 channel
|
// ... 1 channel
|
||||||
ImageFormatCase{SpvImageFormatR32ui, true, sem::ImageFormat::kR32Uint},
|
ImageFormatCase{SpvImageFormatR32ui, true, ast::ImageFormat::kR32Uint},
|
||||||
ImageFormatCase{SpvImageFormatR32i, true, sem::ImageFormat::kR32Sint},
|
ImageFormatCase{SpvImageFormatR32i, true, ast::ImageFormat::kR32Sint},
|
||||||
ImageFormatCase{SpvImageFormatR32f, true, sem::ImageFormat::kR32Float},
|
ImageFormatCase{SpvImageFormatR32f, true, ast::ImageFormat::kR32Float},
|
||||||
// ... 2 channels
|
// ... 2 channels
|
||||||
ImageFormatCase{SpvImageFormatRg32ui, true,
|
ImageFormatCase{SpvImageFormatRg32ui, true,
|
||||||
sem::ImageFormat::kRg32Uint},
|
ast::ImageFormat::kRg32Uint},
|
||||||
ImageFormatCase{SpvImageFormatRg32i, true, sem::ImageFormat::kRg32Sint},
|
ImageFormatCase{SpvImageFormatRg32i, true, ast::ImageFormat::kRg32Sint},
|
||||||
ImageFormatCase{SpvImageFormatRg32f, true,
|
ImageFormatCase{SpvImageFormatRg32f, true,
|
||||||
sem::ImageFormat::kRg32Float},
|
ast::ImageFormat::kRg32Float},
|
||||||
// ... 4 channels
|
// ... 4 channels
|
||||||
ImageFormatCase{SpvImageFormatRgba32ui, true,
|
ImageFormatCase{SpvImageFormatRgba32ui, true,
|
||||||
sem::ImageFormat::kRgba32Uint},
|
ast::ImageFormat::kRgba32Uint},
|
||||||
ImageFormatCase{SpvImageFormatRgba32i, true,
|
ImageFormatCase{SpvImageFormatRgba32i, true,
|
||||||
sem::ImageFormat::kRgba32Sint},
|
ast::ImageFormat::kRgba32Sint},
|
||||||
ImageFormatCase{SpvImageFormatRgba32f, true,
|
ImageFormatCase{SpvImageFormatRgba32f, true,
|
||||||
sem::ImageFormat::kRgba32Float}));
|
ast::ImageFormat::kRgba32Float}));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
EnumConverterBad,
|
EnumConverterBad,
|
||||||
SpvImageFormatTest,
|
SpvImageFormatTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
// Scanning in order from the SPIR-V spec.
|
// Scanning in order from the SPIR-V spec.
|
||||||
ImageFormatCase{SpvImageFormatRg16f, false, sem::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRg16f, false, ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatR11fG11fB10f, false,
|
ImageFormatCase{SpvImageFormatR11fG11fB10f, false,
|
||||||
sem::ImageFormat::kNone},
|
ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatR16f, false, sem::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatR16f, false, ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRgb10A2, false, sem::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRgb10A2, false, ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRg16, false, sem::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRg16, false, ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRg8, false, sem::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRg8, false, ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatR16, false, sem::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatR16, false, ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatR8, false, sem::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatR8, false, ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRgba16Snorm, false,
|
ImageFormatCase{SpvImageFormatRgba16Snorm, false,
|
||||||
sem::ImageFormat::kNone},
|
ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRg16Snorm, false,
|
ImageFormatCase{SpvImageFormatRg16Snorm, false,
|
||||||
sem::ImageFormat::kNone},
|
ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRg8Snorm, false, sem::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRg8Snorm, false, ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRg16i, false, sem::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRg16i, false, ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRg8i, false, sem::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRg8i, false, ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatR8i, false, sem::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatR8i, false, ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRgb10a2ui, false,
|
ImageFormatCase{SpvImageFormatRgb10a2ui, false,
|
||||||
sem::ImageFormat::kNone},
|
ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRg16ui, false, sem::ImageFormat::kNone},
|
ImageFormatCase{SpvImageFormatRg16ui, false, ast::ImageFormat::kNone},
|
||||||
ImageFormatCase{SpvImageFormatRg8ui, false, sem::ImageFormat::kNone}));
|
ImageFormatCase{SpvImageFormatRg8ui, false, ast::ImageFormat::kNone}));
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace spirv
|
} // namespace spirv
|
||||||
|
|
|
@ -4549,9 +4549,9 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||||
<< inst.PrettyPrint();
|
<< inst.PrettyPrint();
|
||||||
}
|
}
|
||||||
switch (texture_type->dim()) {
|
switch (texture_type->dim()) {
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return Fail() << "ConstOffset is only permitted for 2D, 2D Arrayed, "
|
return Fail() << "ConstOffset is only permitted for 2D, 2D Arrayed, "
|
||||||
|
@ -4674,7 +4674,7 @@ bool FunctionEmitter::EmitImageQuery(const spvtools::opt::Instruction& inst) {
|
||||||
}
|
}
|
||||||
exprs.push_back(
|
exprs.push_back(
|
||||||
create<ast::CallExpression>(Source{}, dims_ident, dims_args));
|
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>(
|
auto* layers_ident = create<ast::IdentifierExpression>(
|
||||||
Source{}, builder_.Symbols().Register("textureNumLayers"));
|
Source{}, builder_.Symbols().Register("textureNumLayers"));
|
||||||
exprs.push_back(create<ast::CallExpression>(
|
exprs.push_back(create<ast::CallExpression>(
|
||||||
|
@ -4753,10 +4753,10 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
|
||||||
if (!texture_type) {
|
if (!texture_type) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
sem::TextureDimension dim = texture_type->dim();
|
ast::TextureDimension dim = texture_type->dim();
|
||||||
// Number of regular coordinates.
|
// Number of regular coordinates.
|
||||||
uint32_t num_axes = sem::NumCoordinateAxes(dim);
|
uint32_t num_axes = ast::NumCoordinateAxes(dim);
|
||||||
bool is_arrayed = sem::IsTextureArray(dim);
|
bool is_arrayed = ast::IsTextureArray(dim);
|
||||||
if ((num_axes == 0) || (num_axes > 3)) {
|
if ((num_axes == 0) || (num_axes > 3)) {
|
||||||
Fail() << "unsupported image dimensionality for "
|
Fail() << "unsupported image dimensionality for "
|
||||||
<< texture_type->type_name() << " prompted by "
|
<< texture_type->type_name() << " prompted by "
|
||||||
|
|
|
@ -1898,8 +1898,8 @@ sem::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
sem::Type* ast_store_type = nullptr;
|
sem::Type* ast_store_type = nullptr;
|
||||||
if (usage.IsSampler()) {
|
if (usage.IsSampler()) {
|
||||||
ast_store_type = builder_.create<sem::Sampler>(
|
ast_store_type = builder_.create<sem::Sampler>(
|
||||||
usage.IsComparisonSampler() ? sem::SamplerKind::kComparisonSampler
|
usage.IsComparisonSampler() ? ast::SamplerKind::kComparisonSampler
|
||||||
: sem::SamplerKind::kSampler);
|
: ast::SamplerKind::kSampler);
|
||||||
} else if (usage.IsTexture()) {
|
} else if (usage.IsTexture()) {
|
||||||
const spvtools::opt::analysis::Image* image_type =
|
const spvtools::opt::analysis::Image* image_type =
|
||||||
type_mgr_->GetType(raw_handle_type->result_id())->AsImage();
|
type_mgr_->GetType(raw_handle_type->result_id())->AsImage();
|
||||||
|
@ -1909,9 +1909,9 @@ sem::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sem::TextureDimension dim =
|
const ast::TextureDimension dim =
|
||||||
enum_converter_.ToDim(image_type->dim(), image_type->is_arrayed());
|
enum_converter_.ToDim(image_type->dim(), image_type->is_arrayed());
|
||||||
if (dim == sem::TextureDimension::kNone) {
|
if (dim == ast::TextureDimension::kNone) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1942,7 +1942,7 @@ sem::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
? ast::AccessControl::kReadOnly
|
? ast::AccessControl::kReadOnly
|
||||||
: ast::AccessControl::kWriteOnly;
|
: ast::AccessControl::kWriteOnly;
|
||||||
const auto format = enum_converter_.ToImageFormat(image_type->format());
|
const auto format = enum_converter_.ToImageFormat(image_type->format());
|
||||||
if (format == sem::ImageFormat::kNone) {
|
if (format == ast::ImageFormat::kNone) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto* subtype = sem::StorageTexture::SubtypeFor(format, builder_.Types());
|
auto* subtype = sem::StorageTexture::SubtypeFor(format, builder_.Types());
|
||||||
|
@ -1964,47 +1964,47 @@ sem::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
sem::Type* ParserImpl::GetComponentTypeForFormat(sem::ImageFormat format) {
|
sem::Type* ParserImpl::GetComponentTypeForFormat(ast::ImageFormat format) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case sem::ImageFormat::kR8Uint:
|
case ast::ImageFormat::kR8Uint:
|
||||||
case sem::ImageFormat::kR16Uint:
|
case ast::ImageFormat::kR16Uint:
|
||||||
case sem::ImageFormat::kRg8Uint:
|
case ast::ImageFormat::kRg8Uint:
|
||||||
case sem::ImageFormat::kR32Uint:
|
case ast::ImageFormat::kR32Uint:
|
||||||
case sem::ImageFormat::kRg16Uint:
|
case ast::ImageFormat::kRg16Uint:
|
||||||
case sem::ImageFormat::kRgba8Uint:
|
case ast::ImageFormat::kRgba8Uint:
|
||||||
case sem::ImageFormat::kRg32Uint:
|
case ast::ImageFormat::kRg32Uint:
|
||||||
case sem::ImageFormat::kRgba16Uint:
|
case ast::ImageFormat::kRgba16Uint:
|
||||||
case sem::ImageFormat::kRgba32Uint:
|
case ast::ImageFormat::kRgba32Uint:
|
||||||
return builder_.create<sem::U32>();
|
return builder_.create<sem::U32>();
|
||||||
|
|
||||||
case sem::ImageFormat::kR8Sint:
|
case ast::ImageFormat::kR8Sint:
|
||||||
case sem::ImageFormat::kR16Sint:
|
case ast::ImageFormat::kR16Sint:
|
||||||
case sem::ImageFormat::kRg8Sint:
|
case ast::ImageFormat::kRg8Sint:
|
||||||
case sem::ImageFormat::kR32Sint:
|
case ast::ImageFormat::kR32Sint:
|
||||||
case sem::ImageFormat::kRg16Sint:
|
case ast::ImageFormat::kRg16Sint:
|
||||||
case sem::ImageFormat::kRgba8Sint:
|
case ast::ImageFormat::kRgba8Sint:
|
||||||
case sem::ImageFormat::kRg32Sint:
|
case ast::ImageFormat::kRg32Sint:
|
||||||
case sem::ImageFormat::kRgba16Sint:
|
case ast::ImageFormat::kRgba16Sint:
|
||||||
case sem::ImageFormat::kRgba32Sint:
|
case ast::ImageFormat::kRgba32Sint:
|
||||||
return builder_.create<sem::I32>();
|
return builder_.create<sem::I32>();
|
||||||
|
|
||||||
case sem::ImageFormat::kR8Unorm:
|
case ast::ImageFormat::kR8Unorm:
|
||||||
case sem::ImageFormat::kRg8Unorm:
|
case ast::ImageFormat::kRg8Unorm:
|
||||||
case sem::ImageFormat::kRgba8Unorm:
|
case ast::ImageFormat::kRgba8Unorm:
|
||||||
case sem::ImageFormat::kRgba8UnormSrgb:
|
case ast::ImageFormat::kRgba8UnormSrgb:
|
||||||
case sem::ImageFormat::kBgra8Unorm:
|
case ast::ImageFormat::kBgra8Unorm:
|
||||||
case sem::ImageFormat::kBgra8UnormSrgb:
|
case ast::ImageFormat::kBgra8UnormSrgb:
|
||||||
case sem::ImageFormat::kRgb10A2Unorm:
|
case ast::ImageFormat::kRgb10A2Unorm:
|
||||||
case sem::ImageFormat::kR8Snorm:
|
case ast::ImageFormat::kR8Snorm:
|
||||||
case sem::ImageFormat::kRg8Snorm:
|
case ast::ImageFormat::kRg8Snorm:
|
||||||
case sem::ImageFormat::kRgba8Snorm:
|
case ast::ImageFormat::kRgba8Snorm:
|
||||||
case sem::ImageFormat::kR16Float:
|
case ast::ImageFormat::kR16Float:
|
||||||
case sem::ImageFormat::kR32Float:
|
case ast::ImageFormat::kR32Float:
|
||||||
case sem::ImageFormat::kRg16Float:
|
case ast::ImageFormat::kRg16Float:
|
||||||
case sem::ImageFormat::kRg11B10Float:
|
case ast::ImageFormat::kRg11B10Float:
|
||||||
case sem::ImageFormat::kRg32Float:
|
case ast::ImageFormat::kRg32Float:
|
||||||
case sem::ImageFormat::kRgba16Float:
|
case ast::ImageFormat::kRgba16Float:
|
||||||
case sem::ImageFormat::kRgba32Float:
|
case ast::ImageFormat::kRgba32Float:
|
||||||
return builder_.create<sem::F32>();
|
return builder_.create<sem::F32>();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -2013,54 +2013,54 @@ sem::Type* ParserImpl::GetComponentTypeForFormat(sem::ImageFormat format) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
sem::Type* ParserImpl::GetTexelTypeForFormat(sem::ImageFormat format) {
|
sem::Type* ParserImpl::GetTexelTypeForFormat(ast::ImageFormat format) {
|
||||||
auto* component_type = GetComponentTypeForFormat(format);
|
auto* component_type = GetComponentTypeForFormat(format);
|
||||||
if (!component_type) {
|
if (!component_type) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case sem::ImageFormat::kR16Float:
|
case ast::ImageFormat::kR16Float:
|
||||||
case sem::ImageFormat::kR16Sint:
|
case ast::ImageFormat::kR16Sint:
|
||||||
case sem::ImageFormat::kR16Uint:
|
case ast::ImageFormat::kR16Uint:
|
||||||
case sem::ImageFormat::kR32Float:
|
case ast::ImageFormat::kR32Float:
|
||||||
case sem::ImageFormat::kR32Sint:
|
case ast::ImageFormat::kR32Sint:
|
||||||
case sem::ImageFormat::kR32Uint:
|
case ast::ImageFormat::kR32Uint:
|
||||||
case sem::ImageFormat::kR8Sint:
|
case ast::ImageFormat::kR8Sint:
|
||||||
case sem::ImageFormat::kR8Snorm:
|
case ast::ImageFormat::kR8Snorm:
|
||||||
case sem::ImageFormat::kR8Uint:
|
case ast::ImageFormat::kR8Uint:
|
||||||
case sem::ImageFormat::kR8Unorm:
|
case ast::ImageFormat::kR8Unorm:
|
||||||
// One channel
|
// One channel
|
||||||
return component_type;
|
return component_type;
|
||||||
|
|
||||||
case sem::ImageFormat::kRg11B10Float:
|
case ast::ImageFormat::kRg11B10Float:
|
||||||
case sem::ImageFormat::kRg16Float:
|
case ast::ImageFormat::kRg16Float:
|
||||||
case sem::ImageFormat::kRg16Sint:
|
case ast::ImageFormat::kRg16Sint:
|
||||||
case sem::ImageFormat::kRg16Uint:
|
case ast::ImageFormat::kRg16Uint:
|
||||||
case sem::ImageFormat::kRg32Float:
|
case ast::ImageFormat::kRg32Float:
|
||||||
case sem::ImageFormat::kRg32Sint:
|
case ast::ImageFormat::kRg32Sint:
|
||||||
case sem::ImageFormat::kRg32Uint:
|
case ast::ImageFormat::kRg32Uint:
|
||||||
case sem::ImageFormat::kRg8Sint:
|
case ast::ImageFormat::kRg8Sint:
|
||||||
case sem::ImageFormat::kRg8Snorm:
|
case ast::ImageFormat::kRg8Snorm:
|
||||||
case sem::ImageFormat::kRg8Uint:
|
case ast::ImageFormat::kRg8Uint:
|
||||||
case sem::ImageFormat::kRg8Unorm:
|
case ast::ImageFormat::kRg8Unorm:
|
||||||
// Two channels
|
// Two channels
|
||||||
return builder_.create<sem::Vector>(component_type, 2);
|
return builder_.create<sem::Vector>(component_type, 2);
|
||||||
|
|
||||||
case sem::ImageFormat::kBgra8Unorm:
|
case ast::ImageFormat::kBgra8Unorm:
|
||||||
case sem::ImageFormat::kBgra8UnormSrgb:
|
case ast::ImageFormat::kBgra8UnormSrgb:
|
||||||
case sem::ImageFormat::kRgb10A2Unorm:
|
case ast::ImageFormat::kRgb10A2Unorm:
|
||||||
case sem::ImageFormat::kRgba16Float:
|
case ast::ImageFormat::kRgba16Float:
|
||||||
case sem::ImageFormat::kRgba16Sint:
|
case ast::ImageFormat::kRgba16Sint:
|
||||||
case sem::ImageFormat::kRgba16Uint:
|
case ast::ImageFormat::kRgba16Uint:
|
||||||
case sem::ImageFormat::kRgba32Float:
|
case ast::ImageFormat::kRgba32Float:
|
||||||
case sem::ImageFormat::kRgba32Sint:
|
case ast::ImageFormat::kRgba32Sint:
|
||||||
case sem::ImageFormat::kRgba32Uint:
|
case ast::ImageFormat::kRgba32Uint:
|
||||||
case sem::ImageFormat::kRgba8Sint:
|
case ast::ImageFormat::kRgba8Sint:
|
||||||
case sem::ImageFormat::kRgba8Snorm:
|
case ast::ImageFormat::kRgba8Snorm:
|
||||||
case sem::ImageFormat::kRgba8Uint:
|
case ast::ImageFormat::kRgba8Uint:
|
||||||
case sem::ImageFormat::kRgba8Unorm:
|
case ast::ImageFormat::kRgba8Unorm:
|
||||||
case sem::ImageFormat::kRgba8UnormSrgb:
|
case ast::ImageFormat::kRgba8UnormSrgb:
|
||||||
// Four channels
|
// Four channels
|
||||||
return builder_.create<sem::Vector>(component_type, 4);
|
return builder_.create<sem::Vector>(component_type, 4);
|
||||||
|
|
||||||
|
|
|
@ -475,12 +475,12 @@ class ParserImpl : Reader {
|
||||||
/// format.
|
/// format.
|
||||||
/// @param format image texel format
|
/// @param format image texel format
|
||||||
/// @returns the component type, one of f32, i32, u32
|
/// @returns the component type, one of f32, i32, u32
|
||||||
sem::Type* GetComponentTypeForFormat(sem::ImageFormat format);
|
sem::Type* GetComponentTypeForFormat(ast::ImageFormat format);
|
||||||
|
|
||||||
/// Returns texel type corresponding to the given image format.
|
/// Returns texel type corresponding to the given image format.
|
||||||
/// @param format image texel format
|
/// @param format image texel format
|
||||||
/// @returns the texel format
|
/// @returns the texel format
|
||||||
sem::Type* GetTexelTypeForFormat(sem::ImageFormat format);
|
sem::Type* GetTexelTypeForFormat(ast::ImageFormat format);
|
||||||
|
|
||||||
/// Returns the SPIR-V instruction with the given ID, or nullptr.
|
/// Returns the SPIR-V instruction with the given ID, or nullptr.
|
||||||
/// @param id the SPIR-V result ID
|
/// @param id the SPIR-V result ID
|
||||||
|
|
|
@ -563,10 +563,10 @@ Maybe<sem::Type*> ParserImpl::texture_sampler_types() {
|
||||||
// | SAMPLER_COMPARISON
|
// | SAMPLER_COMPARISON
|
||||||
Maybe<sem::Type*> ParserImpl::sampler_type() {
|
Maybe<sem::Type*> ParserImpl::sampler_type() {
|
||||||
if (match(Token::Type::kSampler))
|
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))
|
if (match(Token::Type::kComparisonSampler))
|
||||||
return builder_.create<sem::Sampler>(sem::SamplerKind::kComparisonSampler);
|
return builder_.create<sem::Sampler>(ast::SamplerKind::kComparisonSampler);
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
|
@ -578,33 +578,33 @@ Maybe<sem::Type*> ParserImpl::sampler_type() {
|
||||||
// | TEXTURE_SAMPLED_3D
|
// | TEXTURE_SAMPLED_3D
|
||||||
// | TEXTURE_SAMPLED_CUBE
|
// | TEXTURE_SAMPLED_CUBE
|
||||||
// | TEXTURE_SAMPLED_CUBE_ARRAY
|
// | TEXTURE_SAMPLED_CUBE_ARRAY
|
||||||
Maybe<sem::TextureDimension> ParserImpl::sampled_texture_type() {
|
Maybe<ast::TextureDimension> ParserImpl::sampled_texture_type() {
|
||||||
if (match(Token::Type::kTextureSampled1d))
|
if (match(Token::Type::kTextureSampled1d))
|
||||||
return sem::TextureDimension::k1d;
|
return ast::TextureDimension::k1d;
|
||||||
|
|
||||||
if (match(Token::Type::kTextureSampled2d))
|
if (match(Token::Type::kTextureSampled2d))
|
||||||
return sem::TextureDimension::k2d;
|
return ast::TextureDimension::k2d;
|
||||||
|
|
||||||
if (match(Token::Type::kTextureSampled2dArray))
|
if (match(Token::Type::kTextureSampled2dArray))
|
||||||
return sem::TextureDimension::k2dArray;
|
return ast::TextureDimension::k2dArray;
|
||||||
|
|
||||||
if (match(Token::Type::kTextureSampled3d))
|
if (match(Token::Type::kTextureSampled3d))
|
||||||
return sem::TextureDimension::k3d;
|
return ast::TextureDimension::k3d;
|
||||||
|
|
||||||
if (match(Token::Type::kTextureSampledCube))
|
if (match(Token::Type::kTextureSampledCube))
|
||||||
return sem::TextureDimension::kCube;
|
return ast::TextureDimension::kCube;
|
||||||
|
|
||||||
if (match(Token::Type::kTextureSampledCubeArray))
|
if (match(Token::Type::kTextureSampledCubeArray))
|
||||||
return sem::TextureDimension::kCubeArray;
|
return ast::TextureDimension::kCubeArray;
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
// multisampled_texture_type
|
// multisampled_texture_type
|
||||||
// : TEXTURE_MULTISAMPLED_2D
|
// : TEXTURE_MULTISAMPLED_2D
|
||||||
Maybe<sem::TextureDimension> ParserImpl::multisampled_texture_type() {
|
Maybe<ast::TextureDimension> ParserImpl::multisampled_texture_type() {
|
||||||
if (match(Token::Type::kTextureMultisampled2d))
|
if (match(Token::Type::kTextureMultisampled2d))
|
||||||
return sem::TextureDimension::k2d;
|
return ast::TextureDimension::k2d;
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
|
@ -614,15 +614,15 @@ Maybe<sem::TextureDimension> ParserImpl::multisampled_texture_type() {
|
||||||
// | TEXTURE_STORAGE_2D
|
// | TEXTURE_STORAGE_2D
|
||||||
// | TEXTURE_STORAGE_2D_ARRAY
|
// | TEXTURE_STORAGE_2D_ARRAY
|
||||||
// | TEXTURE_STORAGE_3D
|
// | TEXTURE_STORAGE_3D
|
||||||
Maybe<sem::TextureDimension> ParserImpl::storage_texture_type() {
|
Maybe<ast::TextureDimension> ParserImpl::storage_texture_type() {
|
||||||
if (match(Token::Type::kTextureStorage1d))
|
if (match(Token::Type::kTextureStorage1d))
|
||||||
return sem::TextureDimension::k1d;
|
return ast::TextureDimension::k1d;
|
||||||
if (match(Token::Type::kTextureStorage2d))
|
if (match(Token::Type::kTextureStorage2d))
|
||||||
return sem::TextureDimension::k2d;
|
return ast::TextureDimension::k2d;
|
||||||
if (match(Token::Type::kTextureStorage2dArray))
|
if (match(Token::Type::kTextureStorage2dArray))
|
||||||
return sem::TextureDimension::k2dArray;
|
return ast::TextureDimension::k2dArray;
|
||||||
if (match(Token::Type::kTextureStorage3d))
|
if (match(Token::Type::kTextureStorage3d))
|
||||||
return sem::TextureDimension::k3d;
|
return ast::TextureDimension::k3d;
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
|
@ -634,17 +634,17 @@ Maybe<sem::TextureDimension> ParserImpl::storage_texture_type() {
|
||||||
// | TEXTURE_DEPTH_CUBE_ARRAY
|
// | TEXTURE_DEPTH_CUBE_ARRAY
|
||||||
Maybe<sem::Type*> ParserImpl::depth_texture_type() {
|
Maybe<sem::Type*> ParserImpl::depth_texture_type() {
|
||||||
if (match(Token::Type::kTextureDepth2d))
|
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))
|
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))
|
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))
|
if (match(Token::Type::kTextureDepthCubeArray))
|
||||||
return builder_.create<sem::DepthTexture>(
|
return builder_.create<sem::DepthTexture>(
|
||||||
sem::TextureDimension::kCubeArray);
|
ast::TextureDimension::kCubeArray);
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
|
@ -685,112 +685,112 @@ Maybe<sem::Type*> ParserImpl::depth_texture_type() {
|
||||||
// | RGBA32UINT
|
// | RGBA32UINT
|
||||||
// | RGBA32SINT
|
// | RGBA32SINT
|
||||||
// | RGBA32FLOAT
|
// | RGBA32FLOAT
|
||||||
Expect<sem::ImageFormat> ParserImpl::expect_image_storage_type(
|
Expect<ast::ImageFormat> ParserImpl::expect_image_storage_type(
|
||||||
const std::string& use) {
|
const std::string& use) {
|
||||||
if (match(Token::Type::kFormatR8Unorm))
|
if (match(Token::Type::kFormatR8Unorm))
|
||||||
return sem::ImageFormat::kR8Unorm;
|
return ast::ImageFormat::kR8Unorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR8Snorm))
|
if (match(Token::Type::kFormatR8Snorm))
|
||||||
return sem::ImageFormat::kR8Snorm;
|
return ast::ImageFormat::kR8Snorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR8Uint))
|
if (match(Token::Type::kFormatR8Uint))
|
||||||
return sem::ImageFormat::kR8Uint;
|
return ast::ImageFormat::kR8Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR8Sint))
|
if (match(Token::Type::kFormatR8Sint))
|
||||||
return sem::ImageFormat::kR8Sint;
|
return ast::ImageFormat::kR8Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR16Uint))
|
if (match(Token::Type::kFormatR16Uint))
|
||||||
return sem::ImageFormat::kR16Uint;
|
return ast::ImageFormat::kR16Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR16Sint))
|
if (match(Token::Type::kFormatR16Sint))
|
||||||
return sem::ImageFormat::kR16Sint;
|
return ast::ImageFormat::kR16Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR16Float))
|
if (match(Token::Type::kFormatR16Float))
|
||||||
return sem::ImageFormat::kR16Float;
|
return ast::ImageFormat::kR16Float;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg8Unorm))
|
if (match(Token::Type::kFormatRg8Unorm))
|
||||||
return sem::ImageFormat::kRg8Unorm;
|
return ast::ImageFormat::kRg8Unorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg8Snorm))
|
if (match(Token::Type::kFormatRg8Snorm))
|
||||||
return sem::ImageFormat::kRg8Snorm;
|
return ast::ImageFormat::kRg8Snorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg8Uint))
|
if (match(Token::Type::kFormatRg8Uint))
|
||||||
return sem::ImageFormat::kRg8Uint;
|
return ast::ImageFormat::kRg8Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg8Sint))
|
if (match(Token::Type::kFormatRg8Sint))
|
||||||
return sem::ImageFormat::kRg8Sint;
|
return ast::ImageFormat::kRg8Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR32Uint))
|
if (match(Token::Type::kFormatR32Uint))
|
||||||
return sem::ImageFormat::kR32Uint;
|
return ast::ImageFormat::kR32Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR32Sint))
|
if (match(Token::Type::kFormatR32Sint))
|
||||||
return sem::ImageFormat::kR32Sint;
|
return ast::ImageFormat::kR32Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatR32Float))
|
if (match(Token::Type::kFormatR32Float))
|
||||||
return sem::ImageFormat::kR32Float;
|
return ast::ImageFormat::kR32Float;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg16Uint))
|
if (match(Token::Type::kFormatRg16Uint))
|
||||||
return sem::ImageFormat::kRg16Uint;
|
return ast::ImageFormat::kRg16Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg16Sint))
|
if (match(Token::Type::kFormatRg16Sint))
|
||||||
return sem::ImageFormat::kRg16Sint;
|
return ast::ImageFormat::kRg16Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg16Float))
|
if (match(Token::Type::kFormatRg16Float))
|
||||||
return sem::ImageFormat::kRg16Float;
|
return ast::ImageFormat::kRg16Float;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba8Unorm))
|
if (match(Token::Type::kFormatRgba8Unorm))
|
||||||
return sem::ImageFormat::kRgba8Unorm;
|
return ast::ImageFormat::kRgba8Unorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba8UnormSrgb))
|
if (match(Token::Type::kFormatRgba8UnormSrgb))
|
||||||
return sem::ImageFormat::kRgba8UnormSrgb;
|
return ast::ImageFormat::kRgba8UnormSrgb;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba8Snorm))
|
if (match(Token::Type::kFormatRgba8Snorm))
|
||||||
return sem::ImageFormat::kRgba8Snorm;
|
return ast::ImageFormat::kRgba8Snorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba8Uint))
|
if (match(Token::Type::kFormatRgba8Uint))
|
||||||
return sem::ImageFormat::kRgba8Uint;
|
return ast::ImageFormat::kRgba8Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba8Sint))
|
if (match(Token::Type::kFormatRgba8Sint))
|
||||||
return sem::ImageFormat::kRgba8Sint;
|
return ast::ImageFormat::kRgba8Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatBgra8Unorm))
|
if (match(Token::Type::kFormatBgra8Unorm))
|
||||||
return sem::ImageFormat::kBgra8Unorm;
|
return ast::ImageFormat::kBgra8Unorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatBgra8UnormSrgb))
|
if (match(Token::Type::kFormatBgra8UnormSrgb))
|
||||||
return sem::ImageFormat::kBgra8UnormSrgb;
|
return ast::ImageFormat::kBgra8UnormSrgb;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgb10A2Unorm))
|
if (match(Token::Type::kFormatRgb10A2Unorm))
|
||||||
return sem::ImageFormat::kRgb10A2Unorm;
|
return ast::ImageFormat::kRgb10A2Unorm;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg11B10Float))
|
if (match(Token::Type::kFormatRg11B10Float))
|
||||||
return sem::ImageFormat::kRg11B10Float;
|
return ast::ImageFormat::kRg11B10Float;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg32Uint))
|
if (match(Token::Type::kFormatRg32Uint))
|
||||||
return sem::ImageFormat::kRg32Uint;
|
return ast::ImageFormat::kRg32Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg32Sint))
|
if (match(Token::Type::kFormatRg32Sint))
|
||||||
return sem::ImageFormat::kRg32Sint;
|
return ast::ImageFormat::kRg32Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRg32Float))
|
if (match(Token::Type::kFormatRg32Float))
|
||||||
return sem::ImageFormat::kRg32Float;
|
return ast::ImageFormat::kRg32Float;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba16Uint))
|
if (match(Token::Type::kFormatRgba16Uint))
|
||||||
return sem::ImageFormat::kRgba16Uint;
|
return ast::ImageFormat::kRgba16Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba16Sint))
|
if (match(Token::Type::kFormatRgba16Sint))
|
||||||
return sem::ImageFormat::kRgba16Sint;
|
return ast::ImageFormat::kRgba16Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba16Float))
|
if (match(Token::Type::kFormatRgba16Float))
|
||||||
return sem::ImageFormat::kRgba16Float;
|
return ast::ImageFormat::kRgba16Float;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba32Uint))
|
if (match(Token::Type::kFormatRgba32Uint))
|
||||||
return sem::ImageFormat::kRgba32Uint;
|
return ast::ImageFormat::kRgba32Uint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba32Sint))
|
if (match(Token::Type::kFormatRgba32Sint))
|
||||||
return sem::ImageFormat::kRgba32Sint;
|
return ast::ImageFormat::kRgba32Sint;
|
||||||
|
|
||||||
if (match(Token::Type::kFormatRgba32Float))
|
if (match(Token::Type::kFormatRgba32Float))
|
||||||
return sem::ImageFormat::kRgba32Float;
|
return ast::ImageFormat::kRgba32Float;
|
||||||
|
|
||||||
return add_error(peek().source(), "invalid format", use);
|
return add_error(peek().source(), "invalid format", use);
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,21 +403,21 @@ class ParserImpl {
|
||||||
/// Parses a `multisampled_texture_type` grammar element
|
/// Parses a `multisampled_texture_type` grammar element
|
||||||
/// @returns returns the multisample texture dimension or kNone if none
|
/// @returns returns the multisample texture dimension or kNone if none
|
||||||
/// matched.
|
/// matched.
|
||||||
Maybe<sem::TextureDimension> multisampled_texture_type();
|
Maybe<ast::TextureDimension> multisampled_texture_type();
|
||||||
/// Parses a `sampled_texture_type` grammar element
|
/// Parses a `sampled_texture_type` grammar element
|
||||||
/// @returns returns the sample texture dimension or kNone if none matched.
|
/// @returns returns the sample texture dimension or kNone if none matched.
|
||||||
Maybe<sem::TextureDimension> sampled_texture_type();
|
Maybe<ast::TextureDimension> sampled_texture_type();
|
||||||
/// Parses a `storage_texture_type` grammar element
|
/// Parses a `storage_texture_type` grammar element
|
||||||
/// @returns returns the storage texture dimension.
|
/// @returns returns the storage texture dimension.
|
||||||
/// Returns kNone if none matched.
|
/// Returns kNone if none matched.
|
||||||
Maybe<sem::TextureDimension> storage_texture_type();
|
Maybe<ast::TextureDimension> storage_texture_type();
|
||||||
/// Parses a `depth_texture_type` grammar element
|
/// Parses a `depth_texture_type` grammar element
|
||||||
/// @returns the parsed Type or nullptr if none matched.
|
/// @returns the parsed Type or nullptr if none matched.
|
||||||
Maybe<sem::Type*> depth_texture_type();
|
Maybe<sem::Type*> depth_texture_type();
|
||||||
/// Parses a `image_storage_type` grammar element
|
/// Parses a `image_storage_type` grammar element
|
||||||
/// @param use a description of what was being parsed if an error was raised
|
/// @param use a description of what was being parsed if an error was raised
|
||||||
/// @returns returns the image format or kNone if none matched.
|
/// @returns returns the image format or kNone if none matched.
|
||||||
Expect<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
|
/// Parses a `function_type_decl` grammar element
|
||||||
/// @returns the parsed type or nullptr otherwise
|
/// @returns the parsed type or nullptr otherwise
|
||||||
Maybe<sem::Type*> function_type_decl();
|
Maybe<sem::Type*> function_type_decl();
|
||||||
|
|
|
@ -36,7 +36,7 @@ TEST_F(ParserImplTest, DepthTextureType_2d) {
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||||
ASSERT_TRUE(t->Is<sem::DepthTexture>());
|
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());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ TEST_F(ParserImplTest, DepthTextureType_2dArray) {
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||||
ASSERT_TRUE(t->Is<sem::DepthTexture>());
|
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());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ TEST_F(ParserImplTest, DepthTextureType_Cube) {
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||||
ASSERT_TRUE(t->Is<sem::DepthTexture>());
|
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());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ TEST_F(ParserImplTest, DepthTextureType_CubeArray) {
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||||
ASSERT_TRUE(t->Is<sem::DepthTexture>());
|
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());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Unorm) {
|
||||||
auto p = parser("r8unorm");
|
auto p = parser("r8unorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kR8Unorm);
|
EXPECT_EQ(t.value, ast::ImageFormat::kR8Unorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Snorm) {
|
||||||
auto p = parser("r8snorm");
|
auto p = parser("r8snorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kR8Snorm);
|
EXPECT_EQ(t.value, ast::ImageFormat::kR8Snorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Uint) {
|
||||||
auto p = parser("r8uint");
|
auto p = parser("r8uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kR8Uint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kR8Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Sint) {
|
||||||
auto p = parser("r8sint");
|
auto p = parser("r8sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kR8Sint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kR8Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Uint) {
|
||||||
auto p = parser("r16uint");
|
auto p = parser("r16uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kR16Uint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kR16Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Sint) {
|
||||||
auto p = parser("r16sint");
|
auto p = parser("r16sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kR16Sint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kR16Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Float) {
|
||||||
auto p = parser("r16float");
|
auto p = parser("r16float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kR16Float);
|
EXPECT_EQ(t.value, ast::ImageFormat::kR16Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Unorm) {
|
||||||
auto p = parser("rg8unorm");
|
auto p = parser("rg8unorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg8Unorm);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRg8Unorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Snorm) {
|
||||||
auto p = parser("rg8snorm");
|
auto p = parser("rg8snorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg8Snorm);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRg8Snorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Uint) {
|
||||||
auto p = parser("rg8uint");
|
auto p = parser("rg8uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg8Uint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRg8Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Sint) {
|
||||||
auto p = parser("rg8sint");
|
auto p = parser("rg8sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg8Sint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRg8Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Uint) {
|
||||||
auto p = parser("r32uint");
|
auto p = parser("r32uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kR32Uint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kR32Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Sint) {
|
||||||
auto p = parser("r32sint");
|
auto p = parser("r32sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kR32Sint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kR32Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Float) {
|
||||||
auto p = parser("r32float");
|
auto p = parser("r32float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kR32Float);
|
EXPECT_EQ(t.value, ast::ImageFormat::kR32Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Uint) {
|
||||||
auto p = parser("rg16uint");
|
auto p = parser("rg16uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg16Uint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRg16Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Sint) {
|
||||||
auto p = parser("rg16sint");
|
auto p = parser("rg16sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg16Sint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRg16Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Float) {
|
||||||
auto p = parser("rg16float");
|
auto p = parser("rg16float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg16Float);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRg16Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Unorm) {
|
||||||
auto p = parser("rgba8unorm");
|
auto p = parser("rgba8unorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Unorm);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8Unorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8UnormSrgb) {
|
||||||
auto p = parser("rgba8unorm_srgb");
|
auto p = parser("rgba8unorm_srgb");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8UnormSrgb);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8UnormSrgb);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Snorm) {
|
||||||
auto p = parser("rgba8snorm");
|
auto p = parser("rgba8snorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Snorm);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8Snorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Uint) {
|
||||||
auto p = parser("rgba8uint");
|
auto p = parser("rgba8uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Uint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Sint) {
|
||||||
auto p = parser("rgba8sint");
|
auto p = parser("rgba8sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Sint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ TEST_F(ParserImplTest, ImageStorageType_Bgra8Unorm) {
|
||||||
auto p = parser("bgra8unorm");
|
auto p = parser("bgra8unorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kBgra8Unorm);
|
EXPECT_EQ(t.value, ast::ImageFormat::kBgra8Unorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ TEST_F(ParserImplTest, ImageStorageType_Bgra8UnormSrgb) {
|
||||||
auto p = parser("bgra8unorm_srgb");
|
auto p = parser("bgra8unorm_srgb");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kBgra8UnormSrgb);
|
EXPECT_EQ(t.value, ast::ImageFormat::kBgra8UnormSrgb);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgb10A2Unorm) {
|
||||||
auto p = parser("rgb10a2unorm");
|
auto p = parser("rgb10a2unorm");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgb10A2Unorm);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRgb10A2Unorm);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg11B10Float) {
|
||||||
auto p = parser("rg11b10float");
|
auto p = parser("rg11b10float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg11B10Float);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRg11B10Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Uint) {
|
||||||
auto p = parser("rg32uint");
|
auto p = parser("rg32uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg32Uint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRg32Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Sint) {
|
||||||
auto p = parser("rg32sint");
|
auto p = parser("rg32sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg32Sint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRg32Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Float) {
|
||||||
auto p = parser("rg32float");
|
auto p = parser("rg32float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg32Float);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRg32Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Uint) {
|
||||||
auto p = parser("rgba16uint");
|
auto p = parser("rgba16uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba16Uint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRgba16Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Sint) {
|
||||||
auto p = parser("rgba16sint");
|
auto p = parser("rgba16sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba16Sint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRgba16Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Float) {
|
||||||
auto p = parser("rgba16float");
|
auto p = parser("rgba16float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba16Float);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRgba16Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Uint) {
|
||||||
auto p = parser("rgba32uint");
|
auto p = parser("rgba32uint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba32Uint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRgba32Uint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Sint) {
|
||||||
auto p = parser("rgba32sint");
|
auto p = parser("rgba32sint");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba32Sint);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRgba32Sint);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Float) {
|
||||||
auto p = parser("rgba32float");
|
auto p = parser("rgba32float");
|
||||||
auto t = p->expect_image_storage_type("test");
|
auto t = p->expect_image_storage_type("test");
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba32Float);
|
EXPECT_EQ(t.value, ast::ImageFormat::kRgba32Float);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ TEST_F(ParserImplTest, SampledTextureType_1d) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::TextureDimension::k1d);
|
EXPECT_EQ(t.value, ast::TextureDimension::k1d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ TEST_F(ParserImplTest, SampledTextureType_2d) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::TextureDimension::k2d);
|
EXPECT_EQ(t.value, ast::TextureDimension::k2d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ TEST_F(ParserImplTest, SampledTextureType_2dArray) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::TextureDimension::k2dArray);
|
EXPECT_EQ(t.value, ast::TextureDimension::k2dArray);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ TEST_F(ParserImplTest, SampledTextureType_3d) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::TextureDimension::k3d);
|
EXPECT_EQ(t.value, ast::TextureDimension::k3d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ TEST_F(ParserImplTest, SampledTextureType_Cube) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::TextureDimension::kCube);
|
EXPECT_EQ(t.value, ast::TextureDimension::kCube);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ TEST_F(ParserImplTest, SampledTextureType_kCubeArray) {
|
||||||
auto t = p->sampled_texture_type();
|
auto t = p->sampled_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::TextureDimension::kCubeArray);
|
EXPECT_EQ(t.value, ast::TextureDimension::kCubeArray);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ TEST_F(ParserImplTest, StorageTextureType_1d) {
|
||||||
auto t = p->storage_texture_type();
|
auto t = p->storage_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::TextureDimension::k1d);
|
EXPECT_EQ(t.value, ast::TextureDimension::k1d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ TEST_F(ParserImplTest, StorageTextureType_2d) {
|
||||||
auto t = p->storage_texture_type();
|
auto t = p->storage_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::TextureDimension::k2d);
|
EXPECT_EQ(t.value, ast::TextureDimension::k2d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ TEST_F(ParserImplTest, StorageTextureType_2dArray) {
|
||||||
auto t = p->storage_texture_type();
|
auto t = p->storage_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::TextureDimension::k2dArray);
|
EXPECT_EQ(t.value, ast::TextureDimension::k2dArray);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ TEST_F(ParserImplTest, StorageTextureType_3d) {
|
||||||
auto t = p->storage_texture_type();
|
auto t = p->storage_texture_type();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
EXPECT_EQ(t.value, sem::TextureDimension::k3d);
|
EXPECT_EQ(t.value, ast::TextureDimension::k3d);
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||||
ASSERT_TRUE(t->Is<sem::DepthTexture>());
|
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) {
|
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::Texture>());
|
||||||
ASSERT_TRUE(t->Is<sem::SampledTexture>());
|
ASSERT_TRUE(t->Is<sem::SampledTexture>());
|
||||||
ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::F32>());
|
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) {
|
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::Texture>());
|
||||||
ASSERT_TRUE(t->Is<sem::SampledTexture>());
|
ASSERT_TRUE(t->Is<sem::SampledTexture>());
|
||||||
ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::I32>());
|
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) {
|
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::Texture>());
|
||||||
ASSERT_TRUE(t->Is<sem::SampledTexture>());
|
ASSERT_TRUE(t->Is<sem::SampledTexture>());
|
||||||
ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::U32>());
|
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) {
|
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::Texture>());
|
||||||
ASSERT_TRUE(t->Is<sem::MultisampledTexture>());
|
ASSERT_TRUE(t->Is<sem::MultisampledTexture>());
|
||||||
ASSERT_TRUE(t->As<sem::MultisampledTexture>()->type()->Is<sem::I32>());
|
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) {
|
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::Texture>());
|
||||||
ASSERT_TRUE(t->Is<sem::StorageTexture>());
|
ASSERT_TRUE(t->Is<sem::StorageTexture>());
|
||||||
EXPECT_EQ(t->As<sem::StorageTexture>()->image_format(),
|
EXPECT_EQ(t->As<sem::StorageTexture>()->image_format(),
|
||||||
sem::ImageFormat::kR8Unorm);
|
ast::ImageFormat::kR8Unorm);
|
||||||
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k1d);
|
EXPECT_EQ(t->As<sem::Texture>()->dim(), ast::TextureDimension::k1d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
|
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::Texture>());
|
||||||
ASSERT_TRUE(t->Is<sem::StorageTexture>());
|
ASSERT_TRUE(t->Is<sem::StorageTexture>());
|
||||||
EXPECT_EQ(t->As<sem::StorageTexture>()->image_format(),
|
EXPECT_EQ(t->As<sem::StorageTexture>()->image_format(),
|
||||||
sem::ImageFormat::kR16Float);
|
ast::ImageFormat::kR16Float);
|
||||||
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
|
EXPECT_EQ(t->As<sem::Texture>()->dim(), ast::TextureDimension::k2d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {
|
||||||
|
|
|
@ -746,7 +746,7 @@ TEST_F(ParserImplTest, TypeDecl_Sampler) {
|
||||||
auto p = parser("sampler");
|
auto p = parser("sampler");
|
||||||
|
|
||||||
auto& builder = p->builder();
|
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();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
|
@ -761,7 +761,7 @@ TEST_F(ParserImplTest, TypeDecl_Texture) {
|
||||||
auto p = parser("texture_cube<f32>");
|
auto p = parser("texture_cube<f32>");
|
||||||
|
|
||||||
auto& builder = p->builder();
|
auto& builder = p->builder();
|
||||||
auto* type = builder.create<sem::SampledTexture>(sem::TextureDimension::kCube,
|
auto* type = builder.create<sem::SampledTexture>(ast::TextureDimension::kCube,
|
||||||
ty.f32());
|
ty.f32());
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
|
|
|
@ -256,8 +256,8 @@ TEST_F(ResolverAssignmentValidationTest, AssignFromPointer_Fail) {
|
||||||
// a = b;
|
// a = b;
|
||||||
|
|
||||||
auto* tex_type = create<sem::StorageTexture>(
|
auto* tex_type = create<sem::StorageTexture>(
|
||||||
sem::TextureDimension::k1d, sem::ImageFormat::kRgba8Unorm,
|
ast::TextureDimension::k1d, ast::ImageFormat::kRgba8Unorm,
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kRgba8Unorm, Types()));
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRgba8Unorm, Types()));
|
||||||
auto* tex_ac =
|
auto* tex_ac =
|
||||||
create<sem::AccessControl>(ast::AccessControl::kReadOnly, tex_type);
|
create<sem::AccessControl>(ast::AccessControl::kReadOnly, tex_type);
|
||||||
|
|
||||||
|
|
|
@ -206,9 +206,9 @@ inline std::ostream& operator<<(std::ostream& out, Texture data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TextureTestParams {
|
struct TextureTestParams {
|
||||||
sem::TextureDimension dim;
|
ast::TextureDimension dim;
|
||||||
Texture type = Texture::kF32;
|
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) {
|
inline std::ostream& operator<<(std::ostream& out, TextureTestParams data) {
|
||||||
out << data.dim << "_" << data.type;
|
out << data.dim << "_" << data.type;
|
||||||
|
@ -223,16 +223,16 @@ class ResolverIntrinsicTest_TextureOperation
|
||||||
/// @param dim dimensionality of the texture being sampled
|
/// @param dim dimensionality of the texture being sampled
|
||||||
/// @param scalar the scalar type
|
/// @param scalar the scalar type
|
||||||
/// @returns a pointer to a type appropriate for the coord param
|
/// @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) {
|
switch (dim) {
|
||||||
case sem::TextureDimension::k1d:
|
case ast::TextureDimension::k1d:
|
||||||
return scalar;
|
return scalar;
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
return create<sem::Vector>(scalar, 2);
|
return create<sem::Vector>(scalar, 2);
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
case sem::TextureDimension::kCube:
|
case ast::TextureDimension::kCube:
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
return create<sem::Vector>(scalar, 3);
|
return create<sem::Vector>(scalar, 3);
|
||||||
default:
|
default:
|
||||||
[=]() { FAIL() << "Unsupported texture dimension: " << dim; }();
|
[=]() { 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("texture", ro_texture_type, &call_params);
|
||||||
add_call_param("coords", coords_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);
|
add_call_param("array_index", ty.i32(), &call_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,30 +301,30 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
ResolverTest,
|
ResolverTest,
|
||||||
ResolverIntrinsicTest_StorageTextureOperation,
|
ResolverIntrinsicTest_StorageTextureOperation,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
TextureTestParams{sem::TextureDimension::k1d, Texture::kF32,
|
TextureTestParams{ast::TextureDimension::k1d, Texture::kF32,
|
||||||
sem::ImageFormat::kR32Float},
|
ast::ImageFormat::kR32Float},
|
||||||
TextureTestParams{sem::TextureDimension::k1d, Texture::kI32,
|
TextureTestParams{ast::TextureDimension::k1d, Texture::kI32,
|
||||||
sem::ImageFormat::kR32Sint},
|
ast::ImageFormat::kR32Sint},
|
||||||
TextureTestParams{sem::TextureDimension::k1d, Texture::kF32,
|
TextureTestParams{ast::TextureDimension::k1d, Texture::kF32,
|
||||||
sem::ImageFormat::kRgba8Unorm},
|
ast::ImageFormat::kRgba8Unorm},
|
||||||
TextureTestParams{sem::TextureDimension::k2d, Texture::kF32,
|
TextureTestParams{ast::TextureDimension::k2d, Texture::kF32,
|
||||||
sem::ImageFormat::kR32Float},
|
ast::ImageFormat::kR32Float},
|
||||||
TextureTestParams{sem::TextureDimension::k2d, Texture::kI32,
|
TextureTestParams{ast::TextureDimension::k2d, Texture::kI32,
|
||||||
sem::ImageFormat::kR32Sint},
|
ast::ImageFormat::kR32Sint},
|
||||||
TextureTestParams{sem::TextureDimension::k2d, Texture::kF32,
|
TextureTestParams{ast::TextureDimension::k2d, Texture::kF32,
|
||||||
sem::ImageFormat::kRgba8Unorm},
|
ast::ImageFormat::kRgba8Unorm},
|
||||||
TextureTestParams{sem::TextureDimension::k2dArray, Texture::kF32,
|
TextureTestParams{ast::TextureDimension::k2dArray, Texture::kF32,
|
||||||
sem::ImageFormat::kR32Float},
|
ast::ImageFormat::kR32Float},
|
||||||
TextureTestParams{sem::TextureDimension::k2dArray, Texture::kI32,
|
TextureTestParams{ast::TextureDimension::k2dArray, Texture::kI32,
|
||||||
sem::ImageFormat::kR32Sint},
|
ast::ImageFormat::kR32Sint},
|
||||||
TextureTestParams{sem::TextureDimension::k2dArray, Texture::kF32,
|
TextureTestParams{ast::TextureDimension::k2dArray, Texture::kF32,
|
||||||
sem::ImageFormat::kRgba8Unorm},
|
ast::ImageFormat::kRgba8Unorm},
|
||||||
TextureTestParams{sem::TextureDimension::k3d, Texture::kF32,
|
TextureTestParams{ast::TextureDimension::k3d, Texture::kF32,
|
||||||
sem::ImageFormat::kR32Float},
|
ast::ImageFormat::kR32Float},
|
||||||
TextureTestParams{sem::TextureDimension::k3d, Texture::kI32,
|
TextureTestParams{ast::TextureDimension::k3d, Texture::kI32,
|
||||||
sem::ImageFormat::kR32Sint},
|
ast::ImageFormat::kR32Sint},
|
||||||
TextureTestParams{sem::TextureDimension::k3d, Texture::kF32,
|
TextureTestParams{ast::TextureDimension::k3d, Texture::kF32,
|
||||||
sem::ImageFormat::kRgba8Unorm}));
|
ast::ImageFormat::kRgba8Unorm}));
|
||||||
|
|
||||||
using ResolverIntrinsicTest_SampledTextureOperation =
|
using ResolverIntrinsicTest_SampledTextureOperation =
|
||||||
ResolverIntrinsicTest_TextureOperation;
|
ResolverIntrinsicTest_TextureOperation;
|
||||||
|
@ -340,7 +340,7 @@ TEST_P(ResolverIntrinsicTest_SampledTextureOperation, TextureLoadSampled) {
|
||||||
|
|
||||||
add_call_param("texture", texture_type, &call_params);
|
add_call_param("texture", texture_type, &call_params);
|
||||||
add_call_param("coords", coords_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("array_index", ty.i32(), &call_params);
|
||||||
}
|
}
|
||||||
add_call_param("level", 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(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
ResolverTest,
|
ResolverTest,
|
||||||
ResolverIntrinsicTest_SampledTextureOperation,
|
ResolverIntrinsicTest_SampledTextureOperation,
|
||||||
testing::Values(TextureTestParams{sem::TextureDimension::k1d},
|
testing::Values(TextureTestParams{ast::TextureDimension::k1d},
|
||||||
TextureTestParams{sem::TextureDimension::k2d},
|
TextureTestParams{ast::TextureDimension::k2d},
|
||||||
TextureTestParams{sem::TextureDimension::k2dArray},
|
TextureTestParams{ast::TextureDimension::k2dArray},
|
||||||
TextureTestParams{sem::TextureDimension::k3d}));
|
TextureTestParams{ast::TextureDimension::k3d}));
|
||||||
|
|
||||||
TEST_F(ResolverIntrinsicTest, Dot_Vec2) {
|
TEST_F(ResolverIntrinsicTest, Dot_Vec2) {
|
||||||
Global("my_var", ty.vec2<f32>(), ast::StorageClass::kInput);
|
Global("my_var", ty.vec2<f32>(), ast::StorageClass::kInput);
|
||||||
|
@ -1924,16 +1924,16 @@ TEST_P(ResolverIntrinsicTest_Texture, Call) {
|
||||||
switch (param.texture_dimension) {
|
switch (param.texture_dimension) {
|
||||||
default:
|
default:
|
||||||
FAIL() << "invalid texture dimensions: " << param.texture_dimension;
|
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());
|
EXPECT_EQ(TypeOf(call)->type_name(), ty.i32()->type_name());
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
EXPECT_EQ(TypeOf(call)->type_name(), ty.vec2<i32>()->type_name());
|
EXPECT_EQ(TypeOf(call)->type_name(), ty.vec2<i32>()->type_name());
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
case sem::TextureDimension::kCube:
|
case ast::TextureDimension::kCube:
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
EXPECT_EQ(TypeOf(call)->type_name(), ty.vec3<i32>()->type_name());
|
EXPECT_EQ(TypeOf(call)->type_name(), ty.vec3<i32>()->type_name());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,29 +18,42 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "src/ast/access_decoration.h"
|
#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/assignment_statement.h"
|
||||||
#include "src/ast/bitcast_expression.h"
|
#include "src/ast/bitcast_expression.h"
|
||||||
#include "src/ast/break_statement.h"
|
#include "src/ast/break_statement.h"
|
||||||
#include "src/ast/call_statement.h"
|
#include "src/ast/call_statement.h"
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/constant_id_decoration.h"
|
||||||
#include "src/ast/continue_statement.h"
|
#include "src/ast/continue_statement.h"
|
||||||
|
#include "src/ast/depth_texture.h"
|
||||||
#include "src/ast/discard_statement.h"
|
#include "src/ast/discard_statement.h"
|
||||||
#include "src/ast/fallthrough_statement.h"
|
#include "src/ast/fallthrough_statement.h"
|
||||||
#include "src/ast/if_statement.h"
|
#include "src/ast/if_statement.h"
|
||||||
#include "src/ast/internal_decoration.h"
|
#include "src/ast/internal_decoration.h"
|
||||||
#include "src/ast/loop_statement.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/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/struct_block_decoration.h"
|
||||||
#include "src/ast/switch_statement.h"
|
#include "src/ast/switch_statement.h"
|
||||||
#include "src/ast/unary_op_expression.h"
|
#include "src/ast/unary_op_expression.h"
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
|
#include "src/ast/vector.h"
|
||||||
#include "src/ast/workgroup_decoration.h"
|
#include "src/ast/workgroup_decoration.h"
|
||||||
#include "src/sem/access_control_type.h"
|
#include "src/sem/access_control_type.h"
|
||||||
#include "src/sem/array.h"
|
#include "src/sem/array.h"
|
||||||
#include "src/sem/call.h"
|
#include "src/sem/call.h"
|
||||||
|
#include "src/sem/depth_texture_type.h"
|
||||||
#include "src/sem/function.h"
|
#include "src/sem/function.h"
|
||||||
#include "src/sem/member_accessor_expression.h"
|
#include "src/sem/member_accessor_expression.h"
|
||||||
#include "src/sem/multisampled_texture_type.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/statement.h"
|
||||||
#include "src/sem/storage_texture_type.h"
|
#include "src/sem/storage_texture_type.h"
|
||||||
#include "src/sem/struct.h"
|
#include "src/sem/struct.h"
|
||||||
|
@ -78,36 +91,36 @@ Source CombineSourceRange(const Source& start, const Source& end) {
|
||||||
start.file_path, start.file_content);
|
start.file_path, start.file_content);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsValidStorageTextureDimension(sem::TextureDimension dim) {
|
bool IsValidStorageTextureDimension(ast::TextureDimension dim) {
|
||||||
switch (dim) {
|
switch (dim) {
|
||||||
case sem::TextureDimension::k1d:
|
case ast::TextureDimension::k1d:
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsValidStorageTextureImageFormat(sem::ImageFormat format) {
|
bool IsValidStorageTextureImageFormat(ast::ImageFormat format) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case sem::ImageFormat::kR32Uint:
|
case ast::ImageFormat::kR32Uint:
|
||||||
case sem::ImageFormat::kR32Sint:
|
case ast::ImageFormat::kR32Sint:
|
||||||
case sem::ImageFormat::kR32Float:
|
case ast::ImageFormat::kR32Float:
|
||||||
case sem::ImageFormat::kRg32Uint:
|
case ast::ImageFormat::kRg32Uint:
|
||||||
case sem::ImageFormat::kRg32Sint:
|
case ast::ImageFormat::kRg32Sint:
|
||||||
case sem::ImageFormat::kRg32Float:
|
case ast::ImageFormat::kRg32Float:
|
||||||
case sem::ImageFormat::kRgba8Unorm:
|
case ast::ImageFormat::kRgba8Unorm:
|
||||||
case sem::ImageFormat::kRgba8Snorm:
|
case ast::ImageFormat::kRgba8Snorm:
|
||||||
case sem::ImageFormat::kRgba8Uint:
|
case ast::ImageFormat::kRgba8Uint:
|
||||||
case sem::ImageFormat::kRgba8Sint:
|
case ast::ImageFormat::kRgba8Sint:
|
||||||
case sem::ImageFormat::kRgba16Uint:
|
case ast::ImageFormat::kRgba16Uint:
|
||||||
case sem::ImageFormat::kRgba16Sint:
|
case ast::ImageFormat::kRgba16Sint:
|
||||||
case sem::ImageFormat::kRgba16Float:
|
case ast::ImageFormat::kRgba16Float:
|
||||||
case sem::ImageFormat::kRgba32Uint:
|
case ast::ImageFormat::kRgba32Uint:
|
||||||
case sem::ImageFormat::kRgba32Sint:
|
case ast::ImageFormat::kRgba32Sint:
|
||||||
case sem::ImageFormat::kRgba32Float:
|
case ast::ImageFormat::kRgba32Float:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -266,6 +279,61 @@ bool Resolver::ResolveInternal() {
|
||||||
return true;
|
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) {
|
bool Resolver::Type(sem::Type* ty) {
|
||||||
ty = ty->UnwrapAliasIfNeeded();
|
ty = ty->UnwrapAliasIfNeeded();
|
||||||
if (auto* str = ty->As<sem::StructType>()) {
|
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 (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",
|
diagnostics_.add_error("Only 2d multisampled textures are supported",
|
||||||
var->source());
|
var->source());
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -251,6 +251,12 @@ class Resolver {
|
||||||
bool ValidateVectorConstructor(const sem::Vector* vec_type,
|
bool ValidateVectorConstructor(const sem::Vector* vec_type,
|
||||||
const ast::ExpressionList& values);
|
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
|
/// @returns the semantic information for the array `arr`, building it if it
|
||||||
/// hasn't been constructed already. If an error is raised, nullptr is
|
/// hasn't been constructed already. If an error is raised, nullptr is
|
||||||
/// returned.
|
/// returned.
|
||||||
|
|
|
@ -536,17 +536,17 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
|
||||||
|
|
||||||
namespace MultisampledTextureTests {
|
namespace MultisampledTextureTests {
|
||||||
struct DimensionParams {
|
struct DimensionParams {
|
||||||
sem::TextureDimension dim;
|
ast::TextureDimension dim;
|
||||||
bool is_valid;
|
bool is_valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr DimensionParams dimension_cases[] = {
|
static constexpr DimensionParams dimension_cases[] = {
|
||||||
DimensionParams{sem::TextureDimension::k1d, false},
|
DimensionParams{ast::TextureDimension::k1d, false},
|
||||||
DimensionParams{sem::TextureDimension::k2d, true},
|
DimensionParams{ast::TextureDimension::k2d, true},
|
||||||
DimensionParams{sem::TextureDimension::k2dArray, false},
|
DimensionParams{ast::TextureDimension::k2dArray, false},
|
||||||
DimensionParams{sem::TextureDimension::k3d, false},
|
DimensionParams{ast::TextureDimension::k3d, false},
|
||||||
DimensionParams{sem::TextureDimension::kCube, false},
|
DimensionParams{ast::TextureDimension::kCube, false},
|
||||||
DimensionParams{sem::TextureDimension::kCubeArray, false}};
|
DimensionParams{ast::TextureDimension::kCubeArray, false}};
|
||||||
|
|
||||||
using MultisampledTextureDimensionTest = ResolverTestWithParam<DimensionParams>;
|
using MultisampledTextureDimensionTest = ResolverTestWithParam<DimensionParams>;
|
||||||
TEST_P(MultisampledTextureDimensionTest, All) {
|
TEST_P(MultisampledTextureDimensionTest, All) {
|
||||||
|
@ -594,7 +594,7 @@ using MultisampledTextureTypeTest = ResolverTestWithParam<TypeParams>;
|
||||||
TEST_P(MultisampledTextureTypeTest, All) {
|
TEST_P(MultisampledTextureTypeTest, All) {
|
||||||
auto& params = GetParam();
|
auto& params = GetParam();
|
||||||
Global("a",
|
Global("a",
|
||||||
create<sem::MultisampledTexture>(sem::TextureDimension::k2d,
|
create<sem::MultisampledTexture>(ast::TextureDimension::k2d,
|
||||||
params.type_func(ty)),
|
params.type_func(ty)),
|
||||||
ast::StorageClass::kUniformConstant, nullptr,
|
ast::StorageClass::kUniformConstant, nullptr,
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
|
@ -616,25 +616,25 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
|
||||||
|
|
||||||
namespace StorageTextureTests {
|
namespace StorageTextureTests {
|
||||||
struct DimensionParams {
|
struct DimensionParams {
|
||||||
sem::TextureDimension dim;
|
ast::TextureDimension dim;
|
||||||
bool is_valid;
|
bool is_valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr DimensionParams Dimension_cases[] = {
|
static constexpr DimensionParams Dimension_cases[] = {
|
||||||
DimensionParams{sem::TextureDimension::k1d, true},
|
DimensionParams{ast::TextureDimension::k1d, true},
|
||||||
DimensionParams{sem::TextureDimension::k2d, true},
|
DimensionParams{ast::TextureDimension::k2d, true},
|
||||||
DimensionParams{sem::TextureDimension::k2dArray, true},
|
DimensionParams{ast::TextureDimension::k2dArray, true},
|
||||||
DimensionParams{sem::TextureDimension::k3d, true},
|
DimensionParams{ast::TextureDimension::k3d, true},
|
||||||
DimensionParams{sem::TextureDimension::kCube, false},
|
DimensionParams{ast::TextureDimension::kCube, false},
|
||||||
DimensionParams{sem::TextureDimension::kCubeArray, false}};
|
DimensionParams{ast::TextureDimension::kCubeArray, false}};
|
||||||
|
|
||||||
using StorageTextureDimensionTest = ResolverTestWithParam<DimensionParams>;
|
using StorageTextureDimensionTest = ResolverTestWithParam<DimensionParams>;
|
||||||
TEST_P(StorageTextureDimensionTest, All) {
|
TEST_P(StorageTextureDimensionTest, All) {
|
||||||
auto& params = GetParam();
|
auto& params = GetParam();
|
||||||
Global("a",
|
Global("a",
|
||||||
create<sem::StorageTexture>(params.dim, sem::ImageFormat::kR32Uint,
|
create<sem::StorageTexture>(params.dim, ast::ImageFormat::kR32Uint,
|
||||||
sem::StorageTexture::SubtypeFor(
|
sem::StorageTexture::SubtypeFor(
|
||||||
sem::ImageFormat::kR32Uint, Types())),
|
ast::ImageFormat::kR32Uint, Types())),
|
||||||
ast::StorageClass::kUniformConstant, nullptr,
|
ast::StorageClass::kUniformConstant, nullptr,
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
create<ast::BindingDecoration>(0),
|
create<ast::BindingDecoration>(0),
|
||||||
|
@ -652,46 +652,46 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
|
||||||
testing::ValuesIn(Dimension_cases));
|
testing::ValuesIn(Dimension_cases));
|
||||||
|
|
||||||
struct FormatParams {
|
struct FormatParams {
|
||||||
sem::ImageFormat format;
|
ast::ImageFormat format;
|
||||||
bool is_valid;
|
bool is_valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr FormatParams format_cases[] = {
|
static constexpr FormatParams format_cases[] = {
|
||||||
FormatParams{sem::ImageFormat::kBgra8Unorm, false},
|
FormatParams{ast::ImageFormat::kBgra8Unorm, false},
|
||||||
FormatParams{sem::ImageFormat::kBgra8UnormSrgb, false},
|
FormatParams{ast::ImageFormat::kBgra8UnormSrgb, false},
|
||||||
FormatParams{sem::ImageFormat::kR16Float, false},
|
FormatParams{ast::ImageFormat::kR16Float, false},
|
||||||
FormatParams{sem::ImageFormat::kR16Sint, false},
|
FormatParams{ast::ImageFormat::kR16Sint, false},
|
||||||
FormatParams{sem::ImageFormat::kR16Uint, false},
|
FormatParams{ast::ImageFormat::kR16Uint, false},
|
||||||
FormatParams{sem::ImageFormat::kR32Float, true},
|
FormatParams{ast::ImageFormat::kR32Float, true},
|
||||||
FormatParams{sem::ImageFormat::kR32Sint, true},
|
FormatParams{ast::ImageFormat::kR32Sint, true},
|
||||||
FormatParams{sem::ImageFormat::kR32Uint, true},
|
FormatParams{ast::ImageFormat::kR32Uint, true},
|
||||||
FormatParams{sem::ImageFormat::kR8Sint, false},
|
FormatParams{ast::ImageFormat::kR8Sint, false},
|
||||||
FormatParams{sem::ImageFormat::kR8Snorm, false},
|
FormatParams{ast::ImageFormat::kR8Snorm, false},
|
||||||
FormatParams{sem::ImageFormat::kR8Uint, false},
|
FormatParams{ast::ImageFormat::kR8Uint, false},
|
||||||
FormatParams{sem::ImageFormat::kR8Unorm, false},
|
FormatParams{ast::ImageFormat::kR8Unorm, false},
|
||||||
FormatParams{sem::ImageFormat::kRg11B10Float, false},
|
FormatParams{ast::ImageFormat::kRg11B10Float, false},
|
||||||
FormatParams{sem::ImageFormat::kRg16Float, false},
|
FormatParams{ast::ImageFormat::kRg16Float, false},
|
||||||
FormatParams{sem::ImageFormat::kRg16Sint, false},
|
FormatParams{ast::ImageFormat::kRg16Sint, false},
|
||||||
FormatParams{sem::ImageFormat::kRg16Uint, false},
|
FormatParams{ast::ImageFormat::kRg16Uint, false},
|
||||||
FormatParams{sem::ImageFormat::kRg32Float, true},
|
FormatParams{ast::ImageFormat::kRg32Float, true},
|
||||||
FormatParams{sem::ImageFormat::kRg32Sint, true},
|
FormatParams{ast::ImageFormat::kRg32Sint, true},
|
||||||
FormatParams{sem::ImageFormat::kRg32Uint, true},
|
FormatParams{ast::ImageFormat::kRg32Uint, true},
|
||||||
FormatParams{sem::ImageFormat::kRg8Sint, false},
|
FormatParams{ast::ImageFormat::kRg8Sint, false},
|
||||||
FormatParams{sem::ImageFormat::kRg8Snorm, false},
|
FormatParams{ast::ImageFormat::kRg8Snorm, false},
|
||||||
FormatParams{sem::ImageFormat::kRg8Uint, false},
|
FormatParams{ast::ImageFormat::kRg8Uint, false},
|
||||||
FormatParams{sem::ImageFormat::kRg8Unorm, false},
|
FormatParams{ast::ImageFormat::kRg8Unorm, false},
|
||||||
FormatParams{sem::ImageFormat::kRgb10A2Unorm, false},
|
FormatParams{ast::ImageFormat::kRgb10A2Unorm, false},
|
||||||
FormatParams{sem::ImageFormat::kRgba16Float, true},
|
FormatParams{ast::ImageFormat::kRgba16Float, true},
|
||||||
FormatParams{sem::ImageFormat::kRgba16Sint, true},
|
FormatParams{ast::ImageFormat::kRgba16Sint, true},
|
||||||
FormatParams{sem::ImageFormat::kRgba16Uint, true},
|
FormatParams{ast::ImageFormat::kRgba16Uint, true},
|
||||||
FormatParams{sem::ImageFormat::kRgba32Float, true},
|
FormatParams{ast::ImageFormat::kRgba32Float, true},
|
||||||
FormatParams{sem::ImageFormat::kRgba32Sint, true},
|
FormatParams{ast::ImageFormat::kRgba32Sint, true},
|
||||||
FormatParams{sem::ImageFormat::kRgba32Uint, true},
|
FormatParams{ast::ImageFormat::kRgba32Uint, true},
|
||||||
FormatParams{sem::ImageFormat::kRgba8Sint, true},
|
FormatParams{ast::ImageFormat::kRgba8Sint, true},
|
||||||
FormatParams{sem::ImageFormat::kRgba8Snorm, true},
|
FormatParams{ast::ImageFormat::kRgba8Snorm, true},
|
||||||
FormatParams{sem::ImageFormat::kRgba8Uint, true},
|
FormatParams{ast::ImageFormat::kRgba8Uint, true},
|
||||||
FormatParams{sem::ImageFormat::kRgba8Unorm, true},
|
FormatParams{ast::ImageFormat::kRgba8Unorm, true},
|
||||||
FormatParams{sem::ImageFormat::kRgba8UnormSrgb, false}};
|
FormatParams{ast::ImageFormat::kRgba8UnormSrgb, false}};
|
||||||
|
|
||||||
using StorageTextureFormatTest = ResolverTestWithParam<FormatParams>;
|
using StorageTextureFormatTest = ResolverTestWithParam<FormatParams>;
|
||||||
TEST_P(StorageTextureFormatTest, All) {
|
TEST_P(StorageTextureFormatTest, All) {
|
||||||
|
@ -705,7 +705,7 @@ TEST_P(StorageTextureFormatTest, All) {
|
||||||
|
|
||||||
Global("a",
|
Global("a",
|
||||||
create<sem::StorageTexture>(
|
create<sem::StorageTexture>(
|
||||||
sem::TextureDimension::k1d, params.format,
|
ast::TextureDimension::k1d, params.format,
|
||||||
sem::StorageTexture::SubtypeFor(params.format, Types())),
|
sem::StorageTexture::SubtypeFor(params.format, Types())),
|
||||||
ast::StorageClass::kUniformConstant, nullptr,
|
ast::StorageClass::kUniformConstant, nullptr,
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
|
@ -715,7 +715,7 @@ TEST_P(StorageTextureFormatTest, All) {
|
||||||
|
|
||||||
Global("b",
|
Global("b",
|
||||||
create<sem::StorageTexture>(
|
create<sem::StorageTexture>(
|
||||||
sem::TextureDimension::k2d, params.format,
|
ast::TextureDimension::k2d, params.format,
|
||||||
sem::StorageTexture::SubtypeFor(params.format, Types())),
|
sem::StorageTexture::SubtypeFor(params.format, Types())),
|
||||||
ast::StorageClass::kUniformConstant, nullptr,
|
ast::StorageClass::kUniformConstant, nullptr,
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
|
@ -725,7 +725,7 @@ TEST_P(StorageTextureFormatTest, All) {
|
||||||
|
|
||||||
Global("c",
|
Global("c",
|
||||||
create<sem::StorageTexture>(
|
create<sem::StorageTexture>(
|
||||||
sem::TextureDimension::k2dArray, params.format,
|
ast::TextureDimension::k2dArray, params.format,
|
||||||
sem::StorageTexture::SubtypeFor(params.format, Types())),
|
sem::StorageTexture::SubtypeFor(params.format, Types())),
|
||||||
ast::StorageClass::kUniformConstant, nullptr,
|
ast::StorageClass::kUniformConstant, nullptr,
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
|
@ -735,7 +735,7 @@ TEST_P(StorageTextureFormatTest, All) {
|
||||||
|
|
||||||
Global("d",
|
Global("d",
|
||||||
create<sem::StorageTexture>(
|
create<sem::StorageTexture>(
|
||||||
sem::TextureDimension::k3d, params.format,
|
ast::TextureDimension::k3d, params.format,
|
||||||
sem::StorageTexture::SubtypeFor(params.format, Types())),
|
sem::StorageTexture::SubtypeFor(params.format, Types())),
|
||||||
ast::StorageClass::kUniformConstant, nullptr,
|
ast::StorageClass::kUniformConstant, nullptr,
|
||||||
ast::DecorationList{
|
ast::DecorationList{
|
||||||
|
|
|
@ -22,14 +22,16 @@ namespace tint {
|
||||||
namespace sem {
|
namespace sem {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool IsValidDepthDimension(TextureDimension dim) {
|
bool IsValidDepthDimension(ast::TextureDimension dim) {
|
||||||
return dim == TextureDimension::k2d || dim == TextureDimension::k2dArray ||
|
return dim == ast::TextureDimension::k2d ||
|
||||||
dim == TextureDimension::kCube || dim == TextureDimension::kCubeArray;
|
dim == ast::TextureDimension::k2dArray ||
|
||||||
|
dim == ast::TextureDimension::kCube ||
|
||||||
|
dim == ast::TextureDimension::kCubeArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
DepthTexture::DepthTexture(TextureDimension dim) : Base(dim) {
|
DepthTexture::DepthTexture(ast::TextureDimension dim) : Base(dim) {
|
||||||
TINT_ASSERT(IsValidDepthDimension(dim));
|
TINT_ASSERT(IsValidDepthDimension(dim));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class DepthTexture : public Castable<DepthTexture, Texture> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param dim the dimensionality of the texture
|
/// @param dim the dimensionality of the texture
|
||||||
explicit DepthTexture(TextureDimension dim);
|
explicit DepthTexture(ast::TextureDimension dim);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
DepthTexture(DepthTexture&&);
|
DepthTexture(DepthTexture&&);
|
||||||
~DepthTexture() override;
|
~DepthTexture() override;
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace {
|
||||||
using DepthTextureTest = TestHelper;
|
using DepthTextureTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(DepthTextureTest, Is) {
|
TEST_F(DepthTextureTest, Is) {
|
||||||
DepthTexture d(TextureDimension::kCube);
|
DepthTexture d(ast::TextureDimension::kCube);
|
||||||
Type* ty = &d;
|
Type* ty = &d;
|
||||||
EXPECT_FALSE(ty->Is<AccessControl>());
|
EXPECT_FALSE(ty->Is<AccessControl>());
|
||||||
EXPECT_FALSE(ty->Is<Alias>());
|
EXPECT_FALSE(ty->Is<Alias>());
|
||||||
|
@ -46,7 +46,7 @@ TEST_F(DepthTextureTest, Is) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DepthTextureTest, IsTexture) {
|
TEST_F(DepthTextureTest, IsTexture) {
|
||||||
DepthTexture d(TextureDimension::kCube);
|
DepthTexture d(ast::TextureDimension::kCube);
|
||||||
Texture* ty = &d;
|
Texture* ty = &d;
|
||||||
EXPECT_TRUE(ty->Is<DepthTexture>());
|
EXPECT_TRUE(ty->Is<DepthTexture>());
|
||||||
EXPECT_FALSE(ty->Is<ExternalTexture>());
|
EXPECT_FALSE(ty->Is<ExternalTexture>());
|
||||||
|
@ -55,17 +55,17 @@ TEST_F(DepthTextureTest, IsTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DepthTextureTest, Dim) {
|
TEST_F(DepthTextureTest, Dim) {
|
||||||
DepthTexture d(TextureDimension::kCube);
|
DepthTexture d(ast::TextureDimension::kCube);
|
||||||
EXPECT_EQ(d.dim(), TextureDimension::kCube);
|
EXPECT_EQ(d.dim(), ast::TextureDimension::kCube);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DepthTextureTest, TypeName) {
|
TEST_F(DepthTextureTest, TypeName) {
|
||||||
DepthTexture d(TextureDimension::kCube);
|
DepthTexture d(ast::TextureDimension::kCube);
|
||||||
EXPECT_EQ(d.type_name(), "__depth_texture_cube");
|
EXPECT_EQ(d.type_name(), "__depth_texture_cube");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DepthTextureTest, FriendlyName) {
|
TEST_F(DepthTextureTest, FriendlyName) {
|
||||||
DepthTexture d(TextureDimension::kCube);
|
DepthTexture d(ast::TextureDimension::kCube);
|
||||||
EXPECT_EQ(d.FriendlyName(Symbols()), "texture_depth_cube");
|
EXPECT_EQ(d.FriendlyName(Symbols()), "texture_depth_cube");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::ExternalTexture);
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace sem {
|
namespace sem {
|
||||||
|
|
||||||
ExternalTexture::ExternalTexture() : Base(TextureDimension::k2d) {}
|
ExternalTexture::ExternalTexture() : Base(ast::TextureDimension::k2d) {}
|
||||||
|
|
||||||
ExternalTexture::ExternalTexture(ExternalTexture&&) = default;
|
ExternalTexture::ExternalTexture(ExternalTexture&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ TEST_F(ExternalTextureTest, IsTexture) {
|
||||||
TEST_F(ExternalTextureTest, Dim) {
|
TEST_F(ExternalTextureTest, Dim) {
|
||||||
F32 f32;
|
F32 f32;
|
||||||
ExternalTexture s;
|
ExternalTexture s;
|
||||||
EXPECT_EQ(s.dim(), TextureDimension::k2d);
|
EXPECT_EQ(s.dim(), ast::TextureDimension::k2d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ExternalTextureTest, TypeName) {
|
TEST_F(ExternalTextureTest, TypeName) {
|
||||||
|
|
|
@ -117,12 +117,12 @@ Function::ReferencedBuiltinVariables() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Function::VariableBindings Function::ReferencedSamplerVariables() const {
|
Function::VariableBindings Function::ReferencedSamplerVariables() const {
|
||||||
return ReferencedSamplerVariablesImpl(sem::SamplerKind::kSampler);
|
return ReferencedSamplerVariablesImpl(ast::SamplerKind::kSampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
Function::VariableBindings Function::ReferencedComparisonSamplerVariables()
|
Function::VariableBindings Function::ReferencedComparisonSamplerVariables()
|
||||||
const {
|
const {
|
||||||
return ReferencedSamplerVariablesImpl(sem::SamplerKind::kComparisonSampler);
|
return ReferencedSamplerVariablesImpl(ast::SamplerKind::kComparisonSampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
Function::VariableBindings Function::ReferencedSampledTextureVariables() const {
|
Function::VariableBindings Function::ReferencedSampledTextureVariables() const {
|
||||||
|
@ -180,7 +180,7 @@ bool Function::HasAncestorEntryPoint(Symbol symbol) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Function::VariableBindings Function::ReferencedSamplerVariablesImpl(
|
Function::VariableBindings Function::ReferencedSamplerVariablesImpl(
|
||||||
sem::SamplerKind kind) const {
|
ast::SamplerKind kind) const {
|
||||||
VariableBindings ret;
|
VariableBindings ret;
|
||||||
|
|
||||||
for (auto* var : ReferencedModuleVariables()) {
|
for (auto* var : ReferencedModuleVariables()) {
|
||||||
|
|
|
@ -142,7 +142,7 @@ class Function : public Castable<Function, CallTarget> {
|
||||||
bool HasAncestorEntryPoint(Symbol sym) const;
|
bool HasAncestorEntryPoint(Symbol sym) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VariableBindings ReferencedSamplerVariablesImpl(sem::SamplerKind kind) const;
|
VariableBindings ReferencedSamplerVariablesImpl(ast::SamplerKind kind) const;
|
||||||
VariableBindings ReferencedSampledTextureVariablesImpl(
|
VariableBindings ReferencedSampledTextureVariablesImpl(
|
||||||
bool multisampled) const;
|
bool multisampled) const;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::MultisampledTexture);
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace sem {
|
namespace sem {
|
||||||
|
|
||||||
MultisampledTexture::MultisampledTexture(TextureDimension dim, Type* type)
|
MultisampledTexture::MultisampledTexture(ast::TextureDimension dim, Type* type)
|
||||||
: Base(dim), type_(type) {
|
: Base(dim), type_(type) {
|
||||||
TINT_ASSERT(type_);
|
TINT_ASSERT(type_);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class MultisampledTexture : public Castable<MultisampledTexture, Texture> {
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param dim the dimensionality of the texture
|
/// @param dim the dimensionality of the texture
|
||||||
/// @param type the data type of the multisampled texture
|
/// @param type the data type of the multisampled texture
|
||||||
MultisampledTexture(TextureDimension dim, Type* type);
|
MultisampledTexture(ast::TextureDimension dim, Type* type);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
MultisampledTexture(MultisampledTexture&&);
|
MultisampledTexture(MultisampledTexture&&);
|
||||||
~MultisampledTexture() override;
|
~MultisampledTexture() override;
|
||||||
|
|
|
@ -29,7 +29,7 @@ using MultisampledTextureTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(MultisampledTextureTest, Is) {
|
TEST_F(MultisampledTextureTest, Is) {
|
||||||
F32 f32;
|
F32 f32;
|
||||||
MultisampledTexture s(TextureDimension::kCube, &f32);
|
MultisampledTexture s(ast::TextureDimension::kCube, &f32);
|
||||||
Type* ty = &s;
|
Type* ty = &s;
|
||||||
EXPECT_FALSE(ty->Is<AccessControl>());
|
EXPECT_FALSE(ty->Is<AccessControl>());
|
||||||
EXPECT_FALSE(ty->Is<Alias>());
|
EXPECT_FALSE(ty->Is<Alias>());
|
||||||
|
@ -48,7 +48,7 @@ TEST_F(MultisampledTextureTest, Is) {
|
||||||
|
|
||||||
TEST_F(MultisampledTextureTest, IsTexture) {
|
TEST_F(MultisampledTextureTest, IsTexture) {
|
||||||
F32 f32;
|
F32 f32;
|
||||||
MultisampledTexture s(TextureDimension::kCube, &f32);
|
MultisampledTexture s(ast::TextureDimension::kCube, &f32);
|
||||||
Texture* ty = &s;
|
Texture* ty = &s;
|
||||||
EXPECT_FALSE(ty->Is<DepthTexture>());
|
EXPECT_FALSE(ty->Is<DepthTexture>());
|
||||||
EXPECT_FALSE(ty->Is<ExternalTexture>());
|
EXPECT_FALSE(ty->Is<ExternalTexture>());
|
||||||
|
@ -59,24 +59,24 @@ TEST_F(MultisampledTextureTest, IsTexture) {
|
||||||
|
|
||||||
TEST_F(MultisampledTextureTest, Dim) {
|
TEST_F(MultisampledTextureTest, Dim) {
|
||||||
F32 f32;
|
F32 f32;
|
||||||
MultisampledTexture s(TextureDimension::k3d, &f32);
|
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||||
EXPECT_EQ(s.dim(), TextureDimension::k3d);
|
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MultisampledTextureTest, Type) {
|
TEST_F(MultisampledTextureTest, Type) {
|
||||||
F32 f32;
|
F32 f32;
|
||||||
MultisampledTexture s(TextureDimension::k3d, &f32);
|
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||||
EXPECT_EQ(s.type(), &f32);
|
EXPECT_EQ(s.type(), &f32);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MultisampledTextureTest, TypeName) {
|
TEST_F(MultisampledTextureTest, TypeName) {
|
||||||
F32 f32;
|
F32 f32;
|
||||||
MultisampledTexture s(TextureDimension::k3d, &f32);
|
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||||
EXPECT_EQ(s.type_name(), "__multisampled_texture_3d__f32");
|
EXPECT_EQ(s.type_name(), "__multisampled_texture_3d__f32");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MultisampledTextureTest, FriendlyName) {
|
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>");
|
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_multisampled_3d<f32>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Pointer : public Castable<Pointer, Type> {
|
||||||
/// Construtor
|
/// Construtor
|
||||||
/// @param subtype the pointee type
|
/// @param subtype the pointee type
|
||||||
/// @param storage_class the storage class of the pointer
|
/// @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
|
/// Move constructor
|
||||||
Pointer(Pointer&&);
|
Pointer(Pointer&&);
|
||||||
~Pointer() override;
|
~Pointer() override;
|
||||||
|
|
|
@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::SampledTexture);
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace sem {
|
namespace sem {
|
||||||
|
|
||||||
SampledTexture::SampledTexture(TextureDimension dim, Type* type)
|
SampledTexture::SampledTexture(ast::TextureDimension dim, Type* type)
|
||||||
: Base(dim), type_(type) {
|
: Base(dim), type_(type) {
|
||||||
TINT_ASSERT(type_);
|
TINT_ASSERT(type_);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class SampledTexture : public Castable<SampledTexture, Texture> {
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param dim the dimensionality of the texture
|
/// @param dim the dimensionality of the texture
|
||||||
/// @param type the data type of the sampled texture
|
/// @param type the data type of the sampled texture
|
||||||
SampledTexture(TextureDimension dim, Type* type);
|
SampledTexture(ast::TextureDimension dim, Type* type);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
SampledTexture(SampledTexture&&);
|
SampledTexture(SampledTexture&&);
|
||||||
~SampledTexture() override;
|
~SampledTexture() override;
|
||||||
|
|
|
@ -28,7 +28,7 @@ using SampledTextureTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(SampledTextureTest, Is) {
|
TEST_F(SampledTextureTest, Is) {
|
||||||
F32 f32;
|
F32 f32;
|
||||||
SampledTexture s(TextureDimension::kCube, &f32);
|
SampledTexture s(ast::TextureDimension::kCube, &f32);
|
||||||
Type* ty = &s;
|
Type* ty = &s;
|
||||||
EXPECT_FALSE(ty->Is<AccessControl>());
|
EXPECT_FALSE(ty->Is<AccessControl>());
|
||||||
EXPECT_FALSE(ty->Is<Alias>());
|
EXPECT_FALSE(ty->Is<Alias>());
|
||||||
|
@ -47,7 +47,7 @@ TEST_F(SampledTextureTest, Is) {
|
||||||
|
|
||||||
TEST_F(SampledTextureTest, IsTexture) {
|
TEST_F(SampledTextureTest, IsTexture) {
|
||||||
F32 f32;
|
F32 f32;
|
||||||
SampledTexture s(TextureDimension::kCube, &f32);
|
SampledTexture s(ast::TextureDimension::kCube, &f32);
|
||||||
Texture* ty = &s;
|
Texture* ty = &s;
|
||||||
EXPECT_FALSE(ty->Is<DepthTexture>());
|
EXPECT_FALSE(ty->Is<DepthTexture>());
|
||||||
EXPECT_FALSE(ty->Is<ExternalTexture>());
|
EXPECT_FALSE(ty->Is<ExternalTexture>());
|
||||||
|
@ -57,24 +57,24 @@ TEST_F(SampledTextureTest, IsTexture) {
|
||||||
|
|
||||||
TEST_F(SampledTextureTest, Dim) {
|
TEST_F(SampledTextureTest, Dim) {
|
||||||
F32 f32;
|
F32 f32;
|
||||||
SampledTexture s(TextureDimension::k3d, &f32);
|
SampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||||
EXPECT_EQ(s.dim(), TextureDimension::k3d);
|
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SampledTextureTest, Type) {
|
TEST_F(SampledTextureTest, Type) {
|
||||||
F32 f32;
|
F32 f32;
|
||||||
SampledTexture s(TextureDimension::k3d, &f32);
|
SampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||||
EXPECT_EQ(s.type(), &f32);
|
EXPECT_EQ(s.type(), &f32);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SampledTextureTest, TypeName) {
|
TEST_F(SampledTextureTest, TypeName) {
|
||||||
F32 f32;
|
F32 f32;
|
||||||
SampledTexture s(TextureDimension::k3d, &f32);
|
SampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||||
EXPECT_EQ(s.type_name(), "__sampled_texture_3d__f32");
|
EXPECT_EQ(s.type_name(), "__sampled_texture_3d__f32");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SampledTextureTest, FriendlyName) {
|
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>");
|
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_3d<f32>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,19 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::Sampler);
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace sem {
|
namespace sem {
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& out, SamplerKind kind) {
|
Sampler::Sampler(ast::SamplerKind kind) : kind_(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(Sampler&&) = default;
|
Sampler::Sampler(Sampler&&) = default;
|
||||||
|
|
||||||
|
@ -41,11 +29,11 @@ Sampler::~Sampler() = default;
|
||||||
|
|
||||||
std::string Sampler::type_name() const {
|
std::string Sampler::type_name() const {
|
||||||
return std::string("__sampler_") +
|
return std::string("__sampler_") +
|
||||||
(kind_ == SamplerKind::kSampler ? "sampler" : "comparison");
|
(kind_ == ast::SamplerKind::kSampler ? "sampler" : "comparison");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Sampler::FriendlyName(const SymbolTable&) const {
|
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 {
|
Sampler* Sampler::Clone(CloneContext* ctx) const {
|
||||||
|
|
|
@ -17,35 +17,29 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "src/ast/sampler.h"
|
||||||
#include "src/sem/type.h"
|
#include "src/sem/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace sem {
|
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.
|
/// A sampler type.
|
||||||
class Sampler : public Castable<Sampler, Type> {
|
class Sampler : public Castable<Sampler, Type> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param kind the kind of sampler
|
/// @param kind the kind of sampler
|
||||||
explicit Sampler(SamplerKind kind);
|
explicit Sampler(ast::SamplerKind kind);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
Sampler(Sampler&&);
|
Sampler(Sampler&&);
|
||||||
~Sampler() override;
|
~Sampler() override;
|
||||||
|
|
||||||
/// @returns the sampler type
|
/// @returns the sampler type
|
||||||
SamplerKind kind() const { return kind_; }
|
ast::SamplerKind kind() const { return kind_; }
|
||||||
|
|
||||||
/// @returns true if this is a comparison sampler
|
/// @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
|
/// @returns the name for this type
|
||||||
std::string type_name() const override;
|
std::string type_name() const override;
|
||||||
|
@ -61,7 +55,7 @@ class Sampler : public Castable<Sampler, Type> {
|
||||||
Sampler* Clone(CloneContext* ctx) const override;
|
Sampler* Clone(CloneContext* ctx) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SamplerKind const kind_;
|
ast::SamplerKind const kind_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sem
|
} // namespace sem
|
||||||
|
|
|
@ -23,18 +23,18 @@ namespace {
|
||||||
using SamplerTest = TestHelper;
|
using SamplerTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(SamplerTest, Creation) {
|
TEST_F(SamplerTest, Creation) {
|
||||||
Sampler s{SamplerKind::kSampler};
|
Sampler s{ast::SamplerKind::kSampler};
|
||||||
EXPECT_EQ(s.kind(), SamplerKind::kSampler);
|
EXPECT_EQ(s.kind(), ast::SamplerKind::kSampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SamplerTest, Creation_ComparisonSampler) {
|
TEST_F(SamplerTest, Creation_ComparisonSampler) {
|
||||||
Sampler s{SamplerKind::kComparisonSampler};
|
Sampler s{ast::SamplerKind::kComparisonSampler};
|
||||||
EXPECT_EQ(s.kind(), SamplerKind::kComparisonSampler);
|
EXPECT_EQ(s.kind(), ast::SamplerKind::kComparisonSampler);
|
||||||
EXPECT_TRUE(s.IsComparison());
|
EXPECT_TRUE(s.IsComparison());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SamplerTest, Is) {
|
TEST_F(SamplerTest, Is) {
|
||||||
Sampler s{SamplerKind::kSampler};
|
Sampler s{ast::SamplerKind::kSampler};
|
||||||
Type* ty = &s;
|
Type* ty = &s;
|
||||||
EXPECT_FALSE(ty->Is<AccessControl>());
|
EXPECT_FALSE(ty->Is<AccessControl>());
|
||||||
EXPECT_FALSE(ty->Is<Alias>());
|
EXPECT_FALSE(ty->Is<Alias>());
|
||||||
|
@ -52,22 +52,22 @@ TEST_F(SamplerTest, Is) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SamplerTest, TypeName_Sampler) {
|
TEST_F(SamplerTest, TypeName_Sampler) {
|
||||||
Sampler s{SamplerKind::kSampler};
|
Sampler s{ast::SamplerKind::kSampler};
|
||||||
EXPECT_EQ(s.type_name(), "__sampler_sampler");
|
EXPECT_EQ(s.type_name(), "__sampler_sampler");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SamplerTest, TypeName_Comparison) {
|
TEST_F(SamplerTest, TypeName_Comparison) {
|
||||||
Sampler s{SamplerKind::kComparisonSampler};
|
Sampler s{ast::SamplerKind::kComparisonSampler};
|
||||||
EXPECT_EQ(s.type_name(), "__sampler_comparison");
|
EXPECT_EQ(s.type_name(), "__sampler_comparison");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SamplerTest, FriendlyNameSampler) {
|
TEST_F(SamplerTest, FriendlyNameSampler) {
|
||||||
Sampler s{SamplerKind::kSampler};
|
Sampler s{ast::SamplerKind::kSampler};
|
||||||
EXPECT_EQ(s.FriendlyName(Symbols()), "sampler");
|
EXPECT_EQ(s.FriendlyName(Symbols()), "sampler");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SamplerTest, FriendlyNameComparisonSampler) {
|
TEST_F(SamplerTest, FriendlyNameComparisonSampler) {
|
||||||
Sampler s{SamplerKind::kComparisonSampler};
|
Sampler s{ast::SamplerKind::kComparisonSampler};
|
||||||
EXPECT_EQ(s.FriendlyName(Symbols()), "sampler_comparison");
|
EXPECT_EQ(s.FriendlyName(Symbols()), "sampler_comparison");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,124 +21,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::StorageTexture);
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace sem {
|
namespace sem {
|
||||||
|
|
||||||
// Note, these names match the names in the WGSL spec. This behaviour is used
|
StorageTexture::StorageTexture(ast::TextureDimension dim,
|
||||||
// in the WGSL writer to emit the texture format names.
|
ast::ImageFormat format,
|
||||||
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,
|
|
||||||
sem::Type* subtype)
|
sem::Type* subtype)
|
||||||
: Base(dim), image_format_(format), subtype_(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);
|
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) {
|
sem::Manager& type_mgr) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case sem::ImageFormat::kR8Uint:
|
case ast::ImageFormat::kR8Uint:
|
||||||
case sem::ImageFormat::kR16Uint:
|
case ast::ImageFormat::kR16Uint:
|
||||||
case sem::ImageFormat::kRg8Uint:
|
case ast::ImageFormat::kRg8Uint:
|
||||||
case sem::ImageFormat::kR32Uint:
|
case ast::ImageFormat::kR32Uint:
|
||||||
case sem::ImageFormat::kRg16Uint:
|
case ast::ImageFormat::kRg16Uint:
|
||||||
case sem::ImageFormat::kRgba8Uint:
|
case ast::ImageFormat::kRgba8Uint:
|
||||||
case sem::ImageFormat::kRg32Uint:
|
case ast::ImageFormat::kRg32Uint:
|
||||||
case sem::ImageFormat::kRgba16Uint:
|
case ast::ImageFormat::kRgba16Uint:
|
||||||
case sem::ImageFormat::kRgba32Uint: {
|
case ast::ImageFormat::kRgba32Uint: {
|
||||||
return type_mgr.Get<sem::U32>();
|
return type_mgr.Get<sem::U32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
case sem::ImageFormat::kR8Sint:
|
case ast::ImageFormat::kR8Sint:
|
||||||
case sem::ImageFormat::kR16Sint:
|
case ast::ImageFormat::kR16Sint:
|
||||||
case sem::ImageFormat::kRg8Sint:
|
case ast::ImageFormat::kRg8Sint:
|
||||||
case sem::ImageFormat::kR32Sint:
|
case ast::ImageFormat::kR32Sint:
|
||||||
case sem::ImageFormat::kRg16Sint:
|
case ast::ImageFormat::kRg16Sint:
|
||||||
case sem::ImageFormat::kRgba8Sint:
|
case ast::ImageFormat::kRgba8Sint:
|
||||||
case sem::ImageFormat::kRg32Sint:
|
case ast::ImageFormat::kRg32Sint:
|
||||||
case sem::ImageFormat::kRgba16Sint:
|
case ast::ImageFormat::kRgba16Sint:
|
||||||
case sem::ImageFormat::kRgba32Sint: {
|
case ast::ImageFormat::kRgba32Sint: {
|
||||||
return type_mgr.Get<sem::I32>();
|
return type_mgr.Get<sem::I32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
case sem::ImageFormat::kR8Unorm:
|
case ast::ImageFormat::kR8Unorm:
|
||||||
case sem::ImageFormat::kRg8Unorm:
|
case ast::ImageFormat::kRg8Unorm:
|
||||||
case sem::ImageFormat::kRgba8Unorm:
|
case ast::ImageFormat::kRgba8Unorm:
|
||||||
case sem::ImageFormat::kRgba8UnormSrgb:
|
case ast::ImageFormat::kRgba8UnormSrgb:
|
||||||
case sem::ImageFormat::kBgra8Unorm:
|
case ast::ImageFormat::kBgra8Unorm:
|
||||||
case sem::ImageFormat::kBgra8UnormSrgb:
|
case ast::ImageFormat::kBgra8UnormSrgb:
|
||||||
case sem::ImageFormat::kRgb10A2Unorm:
|
case ast::ImageFormat::kRgb10A2Unorm:
|
||||||
case sem::ImageFormat::kR8Snorm:
|
case ast::ImageFormat::kR8Snorm:
|
||||||
case sem::ImageFormat::kRg8Snorm:
|
case ast::ImageFormat::kRg8Snorm:
|
||||||
case sem::ImageFormat::kRgba8Snorm:
|
case ast::ImageFormat::kRgba8Snorm:
|
||||||
case sem::ImageFormat::kR16Float:
|
case ast::ImageFormat::kR16Float:
|
||||||
case sem::ImageFormat::kR32Float:
|
case ast::ImageFormat::kR32Float:
|
||||||
case sem::ImageFormat::kRg16Float:
|
case ast::ImageFormat::kRg16Float:
|
||||||
case sem::ImageFormat::kRg11B10Float:
|
case ast::ImageFormat::kRg11B10Float:
|
||||||
case sem::ImageFormat::kRg32Float:
|
case ast::ImageFormat::kRg32Float:
|
||||||
case sem::ImageFormat::kRgba16Float:
|
case ast::ImageFormat::kRgba16Float:
|
||||||
case sem::ImageFormat::kRgba32Float: {
|
case ast::ImageFormat::kRgba32Float: {
|
||||||
return type_mgr.Get<sem::F32>();
|
return type_mgr.Get<sem::F32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
case sem::ImageFormat::kNone:
|
case ast::ImageFormat::kNone:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "src/ast/storage_texture.h"
|
||||||
#include "src/sem/texture_type.h"
|
#include "src/sem/texture_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -24,47 +25,6 @@ namespace sem {
|
||||||
|
|
||||||
class Manager;
|
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.
|
/// A storage texture type.
|
||||||
class StorageTexture : public Castable<StorageTexture, Texture> {
|
class StorageTexture : public Castable<StorageTexture, Texture> {
|
||||||
public:
|
public:
|
||||||
|
@ -72,7 +32,9 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
|
||||||
/// @param dim the dimensionality of the texture
|
/// @param dim the dimensionality of the texture
|
||||||
/// @param format the image format of the texture
|
/// @param format the image format of the texture
|
||||||
/// @param subtype the storage subtype. Use SubtypeFor() to calculate this.
|
/// @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
|
/// Move constructor
|
||||||
StorageTexture(StorageTexture&&);
|
StorageTexture(StorageTexture&&);
|
||||||
|
@ -82,7 +44,7 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
|
||||||
Type* type() const { return subtype_; }
|
Type* type() const { return subtype_; }
|
||||||
|
|
||||||
/// @returns the image format
|
/// @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
|
/// @returns the name for this type
|
||||||
std::string type_name() const override;
|
std::string type_name() const override;
|
||||||
|
@ -100,10 +62,10 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
|
||||||
/// @param format the storage texture image format
|
/// @param format the storage texture image format
|
||||||
/// @param type_mgr the sem::Manager used to build the returned type
|
/// @param type_mgr the sem::Manager used to build the returned type
|
||||||
/// @returns the storage texture subtype for the given ImageFormat
|
/// @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:
|
private:
|
||||||
ImageFormat const image_format_;
|
ast::ImageFormat const image_format_;
|
||||||
Type* const subtype_;
|
Type* const subtype_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,9 @@ using StorageTextureTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(StorageTextureTest, Is) {
|
TEST_F(StorageTextureTest, Is) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
|
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
|
||||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
|
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||||
ImageFormat::kRgba32Float, subtype);
|
ast::ImageFormat::kRgba32Float, subtype);
|
||||||
Type* ty = s;
|
Type* ty = s;
|
||||||
EXPECT_FALSE(ty->Is<AccessControl>());
|
EXPECT_FALSE(ty->Is<AccessControl>());
|
||||||
EXPECT_FALSE(ty->Is<Alias>());
|
EXPECT_FALSE(ty->Is<Alias>());
|
||||||
|
@ -49,9 +49,9 @@ TEST_F(StorageTextureTest, Is) {
|
||||||
|
|
||||||
TEST_F(StorageTextureTest, IsTexture) {
|
TEST_F(StorageTextureTest, IsTexture) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
|
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
|
||||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
|
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||||
ImageFormat::kRgba32Float, subtype);
|
ast::ImageFormat::kRgba32Float, subtype);
|
||||||
Texture* ty = s;
|
Texture* ty = s;
|
||||||
EXPECT_FALSE(ty->Is<DepthTexture>());
|
EXPECT_FALSE(ty->Is<DepthTexture>());
|
||||||
EXPECT_FALSE(ty->Is<ExternalTexture>());
|
EXPECT_FALSE(ty->Is<ExternalTexture>());
|
||||||
|
@ -61,42 +61,42 @@ TEST_F(StorageTextureTest, IsTexture) {
|
||||||
|
|
||||||
TEST_F(StorageTextureTest, Dim) {
|
TEST_F(StorageTextureTest, Dim) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
|
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
|
||||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
|
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||||
ImageFormat::kRgba32Float, subtype);
|
ast::ImageFormat::kRgba32Float, subtype);
|
||||||
EXPECT_EQ(s->dim(), TextureDimension::k2dArray);
|
EXPECT_EQ(s->dim(), ast::TextureDimension::k2dArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StorageTextureTest, Format) {
|
TEST_F(StorageTextureTest, Format) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
|
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
|
||||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
|
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||||
ImageFormat::kRgba32Float, subtype);
|
ast::ImageFormat::kRgba32Float, subtype);
|
||||||
EXPECT_EQ(s->image_format(), ImageFormat::kRgba32Float);
|
EXPECT_EQ(s->image_format(), ast::ImageFormat::kRgba32Float);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StorageTextureTest, TypeName) {
|
TEST_F(StorageTextureTest, TypeName) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
|
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
|
||||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
|
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||||
ImageFormat::kRgba32Float, subtype);
|
ast::ImageFormat::kRgba32Float, subtype);
|
||||||
EXPECT_EQ(s->type_name(), "__storage_texture_2d_array_rgba32float");
|
EXPECT_EQ(s->type_name(), "__storage_texture_2d_array_rgba32float");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StorageTextureTest, FriendlyName) {
|
TEST_F(StorageTextureTest, FriendlyName) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
|
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
|
||||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
|
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||||
ImageFormat::kRgba32Float, subtype);
|
ast::ImageFormat::kRgba32Float, subtype);
|
||||||
EXPECT_EQ(s->FriendlyName(Symbols()),
|
EXPECT_EQ(s->FriendlyName(Symbols()),
|
||||||
"texture_storage_2d_array<rgba32float>");
|
"texture_storage_2d_array<rgba32float>");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StorageTextureTest, F32) {
|
TEST_F(StorageTextureTest, F32) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
|
||||||
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
|
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||||
ImageFormat::kRgba32Float, subtype);
|
ast::ImageFormat::kRgba32Float, subtype);
|
||||||
|
|
||||||
auto program = Build();
|
auto program = Build();
|
||||||
|
|
||||||
|
@ -108,9 +108,9 @@ TEST_F(StorageTextureTest, F32) {
|
||||||
|
|
||||||
TEST_F(StorageTextureTest, U32) {
|
TEST_F(StorageTextureTest, U32) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(ImageFormat::kRg32Uint, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRg32Uint, Types());
|
||||||
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
|
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||||
ImageFormat::kRg32Uint, subtype);
|
ast::ImageFormat::kRg32Uint, subtype);
|
||||||
|
|
||||||
auto program = Build();
|
auto program = Build();
|
||||||
|
|
||||||
|
@ -122,9 +122,9 @@ TEST_F(StorageTextureTest, U32) {
|
||||||
|
|
||||||
TEST_F(StorageTextureTest, I32) {
|
TEST_F(StorageTextureTest, I32) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(ImageFormat::kRgba32Sint, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Sint, Types());
|
||||||
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
|
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||||
ImageFormat::kRgba32Sint, subtype);
|
ast::ImageFormat::kRgba32Sint, subtype);
|
||||||
|
|
||||||
auto program = Build();
|
auto program = Build();
|
||||||
|
|
||||||
|
|
|
@ -19,66 +19,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::Texture);
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace sem {
|
namespace sem {
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& out, TextureDimension dim) {
|
Texture::Texture(ast::TextureDimension dim) : dim_(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(Texture&&) = default;
|
Texture::Texture(Texture&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -15,58 +15,27 @@
|
||||||
#ifndef SRC_SEM_TEXTURE_TYPE_H_
|
#ifndef SRC_SEM_TEXTURE_TYPE_H_
|
||||||
#define SRC_SEM_TEXTURE_TYPE_H_
|
#define SRC_SEM_TEXTURE_TYPE_H_
|
||||||
|
|
||||||
|
#include "src/ast/texture.h"
|
||||||
#include "src/sem/type.h"
|
#include "src/sem/type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace sem {
|
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.
|
/// A texture type.
|
||||||
class Texture : public Castable<Texture, Type> {
|
class Texture : public Castable<Texture, Type> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param dim the dimensionality of the texture
|
/// @param dim the dimensionality of the texture
|
||||||
explicit Texture(TextureDimension dim);
|
explicit Texture(ast::TextureDimension dim);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
Texture(Texture&&);
|
Texture(Texture&&);
|
||||||
~Texture() override;
|
~Texture() override;
|
||||||
|
|
||||||
/// @returns the texture dimension
|
/// @returns the texture dimension
|
||||||
TextureDimension dim() const { return dim_; }
|
ast::TextureDimension dim() const { return dim_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextureDimension const dim_;
|
ast::TextureDimension const dim_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sem
|
} // namespace sem
|
||||||
|
|
|
@ -23,23 +23,23 @@ namespace {
|
||||||
using TextureTypeTest = TestHelper;
|
using TextureTypeTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(TextureTypeTest, IsTextureArray) {
|
TEST_F(TextureTypeTest, IsTextureArray) {
|
||||||
EXPECT_EQ(false, IsTextureArray(TextureDimension::kNone));
|
EXPECT_EQ(false, IsTextureArray(ast::TextureDimension::kNone));
|
||||||
EXPECT_EQ(false, IsTextureArray(TextureDimension::k1d));
|
EXPECT_EQ(false, IsTextureArray(ast::TextureDimension::k1d));
|
||||||
EXPECT_EQ(false, IsTextureArray(TextureDimension::k2d));
|
EXPECT_EQ(false, IsTextureArray(ast::TextureDimension::k2d));
|
||||||
EXPECT_EQ(true, IsTextureArray(TextureDimension::k2dArray));
|
EXPECT_EQ(true, IsTextureArray(ast::TextureDimension::k2dArray));
|
||||||
EXPECT_EQ(false, IsTextureArray(TextureDimension::k3d));
|
EXPECT_EQ(false, IsTextureArray(ast::TextureDimension::k3d));
|
||||||
EXPECT_EQ(false, IsTextureArray(TextureDimension::kCube));
|
EXPECT_EQ(false, IsTextureArray(ast::TextureDimension::kCube));
|
||||||
EXPECT_EQ(true, IsTextureArray(TextureDimension::kCubeArray));
|
EXPECT_EQ(true, IsTextureArray(ast::TextureDimension::kCubeArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TextureTypeTest, NumCoordinateAxes) {
|
TEST_F(TextureTypeTest, NumCoordinateAxes) {
|
||||||
EXPECT_EQ(0, NumCoordinateAxes(TextureDimension::kNone));
|
EXPECT_EQ(0, NumCoordinateAxes(ast::TextureDimension::kNone));
|
||||||
EXPECT_EQ(1, NumCoordinateAxes(TextureDimension::k1d));
|
EXPECT_EQ(1, NumCoordinateAxes(ast::TextureDimension::k1d));
|
||||||
EXPECT_EQ(2, NumCoordinateAxes(TextureDimension::k2d));
|
EXPECT_EQ(2, NumCoordinateAxes(ast::TextureDimension::k2d));
|
||||||
EXPECT_EQ(2, NumCoordinateAxes(TextureDimension::k2dArray));
|
EXPECT_EQ(2, NumCoordinateAxes(ast::TextureDimension::k2dArray));
|
||||||
EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::k3d));
|
EXPECT_EQ(3, NumCoordinateAxes(ast::TextureDimension::k3d));
|
||||||
EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::kCube));
|
EXPECT_EQ(3, NumCoordinateAxes(ast::TextureDimension::kCube));
|
||||||
EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::kCubeArray));
|
EXPECT_EQ(3, NumCoordinateAxes(ast::TextureDimension::kCubeArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -58,26 +58,26 @@ bool last_is_break_or_fallthrough(const ast::BlockStatement* stmts) {
|
||||||
stmts->last()->Is<ast::FallthroughStatement>();
|
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) {
|
switch (image_format) {
|
||||||
case sem::ImageFormat::kRgba8Unorm:
|
case ast::ImageFormat::kRgba8Unorm:
|
||||||
case sem::ImageFormat::kRgba8Snorm:
|
case ast::ImageFormat::kRgba8Snorm:
|
||||||
case sem::ImageFormat::kRgba16Float:
|
case ast::ImageFormat::kRgba16Float:
|
||||||
case sem::ImageFormat::kR32Float:
|
case ast::ImageFormat::kR32Float:
|
||||||
case sem::ImageFormat::kRg32Float:
|
case ast::ImageFormat::kRg32Float:
|
||||||
case sem::ImageFormat::kRgba32Float:
|
case ast::ImageFormat::kRgba32Float:
|
||||||
return "float4";
|
return "float4";
|
||||||
case sem::ImageFormat::kRgba8Uint:
|
case ast::ImageFormat::kRgba8Uint:
|
||||||
case sem::ImageFormat::kRgba16Uint:
|
case ast::ImageFormat::kRgba16Uint:
|
||||||
case sem::ImageFormat::kR32Uint:
|
case ast::ImageFormat::kR32Uint:
|
||||||
case sem::ImageFormat::kRg32Uint:
|
case ast::ImageFormat::kRg32Uint:
|
||||||
case sem::ImageFormat::kRgba32Uint:
|
case ast::ImageFormat::kRgba32Uint:
|
||||||
return "uint4";
|
return "uint4";
|
||||||
case sem::ImageFormat::kRgba8Sint:
|
case ast::ImageFormat::kRgba8Sint:
|
||||||
case sem::ImageFormat::kRgba16Sint:
|
case ast::ImageFormat::kRgba16Sint:
|
||||||
case sem::ImageFormat::kR32Sint:
|
case ast::ImageFormat::kR32Sint:
|
||||||
case sem::ImageFormat::kRg32Sint:
|
case ast::ImageFormat::kRg32Sint:
|
||||||
case sem::ImageFormat::kRgba32Sint:
|
case ast::ImageFormat::kRgba32Sint:
|
||||||
return "int4";
|
return "int4";
|
||||||
default:
|
default:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -881,30 +881,30 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre,
|
||||||
switch (intrinsic->Type()) {
|
switch (intrinsic->Type()) {
|
||||||
case sem::IntrinsicType::kTextureDimensions:
|
case sem::IntrinsicType::kTextureDimensions:
|
||||||
switch (texture_type->dim()) {
|
switch (texture_type->dim()) {
|
||||||
case sem::TextureDimension::kNone:
|
case ast::TextureDimension::kNone:
|
||||||
TINT_ICE(diagnostics_) << "texture dimension is kNone";
|
TINT_ICE(diagnostics_) << "texture dimension is kNone";
|
||||||
return false;
|
return false;
|
||||||
case sem::TextureDimension::k1d:
|
case ast::TextureDimension::k1d:
|
||||||
num_dimensions = 1;
|
num_dimensions = 1;
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
num_dimensions = is_ms ? 3 : 2;
|
num_dimensions = is_ms ? 3 : 2;
|
||||||
swizzle = is_ms ? ".xy" : "";
|
swizzle = is_ms ? ".xy" : "";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
num_dimensions = is_ms ? 4 : 3;
|
num_dimensions = is_ms ? 4 : 3;
|
||||||
swizzle = ".xy";
|
swizzle = ".xy";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
num_dimensions = 3;
|
num_dimensions = 3;
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::kCube:
|
case ast::TextureDimension::kCube:
|
||||||
// width == height == depth for cubes
|
// width == height == depth for cubes
|
||||||
// See https://github.com/gpuweb/gpuweb/issues/1345
|
// See https://github.com/gpuweb/gpuweb/issues/1345
|
||||||
num_dimensions = 2;
|
num_dimensions = 2;
|
||||||
swizzle = ".xyy"; // [width, height, height]
|
swizzle = ".xyy"; // [width, height, height]
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
// width == height == depth for cubes
|
// width == height == depth for cubes
|
||||||
// See https://github.com/gpuweb/gpuweb/issues/1345
|
// See https://github.com/gpuweb/gpuweb/issues/1345
|
||||||
num_dimensions = 3;
|
num_dimensions = 3;
|
||||||
|
@ -917,11 +917,11 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre,
|
||||||
default:
|
default:
|
||||||
TINT_ICE(diagnostics_) << "texture dimension is not arrayed";
|
TINT_ICE(diagnostics_) << "texture dimension is not arrayed";
|
||||||
return false;
|
return false;
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
num_dimensions = is_ms ? 4 : 3;
|
num_dimensions = is_ms ? 4 : 3;
|
||||||
swizzle = ".z";
|
swizzle = ".z";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
num_dimensions = 3;
|
num_dimensions = 3;
|
||||||
swizzle = ".z";
|
swizzle = ".z";
|
||||||
break;
|
break;
|
||||||
|
@ -933,14 +933,14 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre,
|
||||||
TINT_ICE(diagnostics_)
|
TINT_ICE(diagnostics_)
|
||||||
<< "texture dimension does not support mips";
|
<< "texture dimension does not support mips";
|
||||||
return false;
|
return false;
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
case sem::TextureDimension::kCube:
|
case ast::TextureDimension::kCube:
|
||||||
num_dimensions = 3;
|
num_dimensions = 3;
|
||||||
swizzle = ".z";
|
swizzle = ".z";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
num_dimensions = 4;
|
num_dimensions = 4;
|
||||||
swizzle = ".w";
|
swizzle = ".w";
|
||||||
break;
|
break;
|
||||||
|
@ -952,11 +952,11 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre,
|
||||||
TINT_ICE(diagnostics_)
|
TINT_ICE(diagnostics_)
|
||||||
<< "texture dimension does not support multisampling";
|
<< "texture dimension does not support multisampling";
|
||||||
return false;
|
return false;
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
num_dimensions = 3;
|
num_dimensions = 3;
|
||||||
swizzle = ".z";
|
swizzle = ".z";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
num_dimensions = 4;
|
num_dimensions = 4;
|
||||||
swizzle = ".w";
|
swizzle = ".w";
|
||||||
break;
|
break;
|
||||||
|
@ -2466,22 +2466,22 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
out << "Texture";
|
out << "Texture";
|
||||||
|
|
||||||
switch (tex->dim()) {
|
switch (tex->dim()) {
|
||||||
case sem::TextureDimension::k1d:
|
case ast::TextureDimension::k1d:
|
||||||
out << "1D";
|
out << "1D";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
out << (multism ? "2DMS" : "2D");
|
out << (multism ? "2DMS" : "2D");
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
out << (multism ? "2DMSArray" : "2DArray");
|
out << (multism ? "2DMSArray" : "2DArray");
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
out << "3D";
|
out << "3D";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::kCube:
|
case ast::TextureDimension::kCube:
|
||||||
out << "Cube";
|
out << "Cube";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
out << "CubeArray";
|
out << "CubeArray";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -295,7 +295,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitSampler) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitSampler) {
|
||||||
sem::Sampler sampler(sem::SamplerKind::kSampler);
|
sem::Sampler sampler(ast::SamplerKind::kSampler);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) {
|
||||||
sem::Sampler sampler(sem::SamplerKind::kComparisonSampler);
|
sem::Sampler sampler(ast::SamplerKind::kComparisonSampler);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct HlslDepthTextureData {
|
struct HlslDepthTextureData {
|
||||||
sem::TextureDimension dim;
|
ast::TextureDimension dim;
|
||||||
std::string result;
|
std::string result;
|
||||||
};
|
};
|
||||||
inline std::ostream& operator<<(std::ostream& out, HlslDepthTextureData data) {
|
inline std::ostream& operator<<(std::ostream& out, HlslDepthTextureData data) {
|
||||||
|
@ -349,18 +349,18 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
HlslGeneratorImplTest_Type,
|
HlslGeneratorImplTest_Type,
|
||||||
HlslDepthTexturesTest,
|
HlslDepthTexturesTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
HlslDepthTextureData{sem::TextureDimension::k2d,
|
HlslDepthTextureData{ast::TextureDimension::k2d,
|
||||||
"Texture2D tex : register(t1, space2);"},
|
"Texture2D tex : register(t1, space2);"},
|
||||||
HlslDepthTextureData{sem::TextureDimension::k2dArray,
|
HlslDepthTextureData{ast::TextureDimension::k2dArray,
|
||||||
"Texture2DArray tex : register(t1, space2);"},
|
"Texture2DArray tex : register(t1, space2);"},
|
||||||
HlslDepthTextureData{sem::TextureDimension::kCube,
|
HlslDepthTextureData{ast::TextureDimension::kCube,
|
||||||
"TextureCube tex : register(t1, space2);"},
|
"TextureCube tex : register(t1, space2);"},
|
||||||
HlslDepthTextureData{sem::TextureDimension::kCubeArray,
|
HlslDepthTextureData{ast::TextureDimension::kCubeArray,
|
||||||
"TextureCubeArray tex : register(t1, space2);"}));
|
"TextureCubeArray tex : register(t1, space2);"}));
|
||||||
|
|
||||||
enum class TextureDataType { F32, U32, I32 };
|
enum class TextureDataType { F32, U32, I32 };
|
||||||
struct HlslSampledTextureData {
|
struct HlslSampledTextureData {
|
||||||
sem::TextureDimension dim;
|
ast::TextureDimension dim;
|
||||||
TextureDataType datatype;
|
TextureDataType datatype;
|
||||||
std::string result;
|
std::string result;
|
||||||
};
|
};
|
||||||
|
@ -409,98 +409,98 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
HlslSampledTexturesTest,
|
HlslSampledTexturesTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::k1d,
|
ast::TextureDimension::k1d,
|
||||||
TextureDataType::F32,
|
TextureDataType::F32,
|
||||||
"Texture1D<float4> tex : register(t1, space2);",
|
"Texture1D<float4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::k2d,
|
ast::TextureDimension::k2d,
|
||||||
TextureDataType::F32,
|
TextureDataType::F32,
|
||||||
"Texture2D<float4> tex : register(t1, space2);",
|
"Texture2D<float4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::k2dArray,
|
ast::TextureDimension::k2dArray,
|
||||||
TextureDataType::F32,
|
TextureDataType::F32,
|
||||||
"Texture2DArray<float4> tex : register(t1, space2);",
|
"Texture2DArray<float4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::k3d,
|
ast::TextureDimension::k3d,
|
||||||
TextureDataType::F32,
|
TextureDataType::F32,
|
||||||
"Texture3D<float4> tex : register(t1, space2);",
|
"Texture3D<float4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::kCube,
|
ast::TextureDimension::kCube,
|
||||||
TextureDataType::F32,
|
TextureDataType::F32,
|
||||||
"TextureCube<float4> tex : register(t1, space2);",
|
"TextureCube<float4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::kCubeArray,
|
ast::TextureDimension::kCubeArray,
|
||||||
TextureDataType::F32,
|
TextureDataType::F32,
|
||||||
"TextureCubeArray<float4> tex : register(t1, space2);",
|
"TextureCubeArray<float4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::k1d,
|
ast::TextureDimension::k1d,
|
||||||
TextureDataType::U32,
|
TextureDataType::U32,
|
||||||
"Texture1D<uint4> tex : register(t1, space2);",
|
"Texture1D<uint4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::k2d,
|
ast::TextureDimension::k2d,
|
||||||
TextureDataType::U32,
|
TextureDataType::U32,
|
||||||
"Texture2D<uint4> tex : register(t1, space2);",
|
"Texture2D<uint4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::k2dArray,
|
ast::TextureDimension::k2dArray,
|
||||||
TextureDataType::U32,
|
TextureDataType::U32,
|
||||||
"Texture2DArray<uint4> tex : register(t1, space2);",
|
"Texture2DArray<uint4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::k3d,
|
ast::TextureDimension::k3d,
|
||||||
TextureDataType::U32,
|
TextureDataType::U32,
|
||||||
"Texture3D<uint4> tex : register(t1, space2);",
|
"Texture3D<uint4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::kCube,
|
ast::TextureDimension::kCube,
|
||||||
TextureDataType::U32,
|
TextureDataType::U32,
|
||||||
"TextureCube<uint4> tex : register(t1, space2);",
|
"TextureCube<uint4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::kCubeArray,
|
ast::TextureDimension::kCubeArray,
|
||||||
TextureDataType::U32,
|
TextureDataType::U32,
|
||||||
"TextureCubeArray<uint4> tex : register(t1, space2);",
|
"TextureCubeArray<uint4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::k1d,
|
ast::TextureDimension::k1d,
|
||||||
TextureDataType::I32,
|
TextureDataType::I32,
|
||||||
"Texture1D<int4> tex : register(t1, space2);",
|
"Texture1D<int4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::k2d,
|
ast::TextureDimension::k2d,
|
||||||
TextureDataType::I32,
|
TextureDataType::I32,
|
||||||
"Texture2D<int4> tex : register(t1, space2);",
|
"Texture2D<int4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::k2dArray,
|
ast::TextureDimension::k2dArray,
|
||||||
TextureDataType::I32,
|
TextureDataType::I32,
|
||||||
"Texture2DArray<int4> tex : register(t1, space2);",
|
"Texture2DArray<int4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::k3d,
|
ast::TextureDimension::k3d,
|
||||||
TextureDataType::I32,
|
TextureDataType::I32,
|
||||||
"Texture3D<int4> tex : register(t1, space2);",
|
"Texture3D<int4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::kCube,
|
ast::TextureDimension::kCube,
|
||||||
TextureDataType::I32,
|
TextureDataType::I32,
|
||||||
"TextureCube<int4> tex : register(t1, space2);",
|
"TextureCube<int4> tex : register(t1, space2);",
|
||||||
},
|
},
|
||||||
HlslSampledTextureData{
|
HlslSampledTextureData{
|
||||||
sem::TextureDimension::kCubeArray,
|
ast::TextureDimension::kCubeArray,
|
||||||
TextureDataType::I32,
|
TextureDataType::I32,
|
||||||
"TextureCubeArray<int4> tex : register(t1, space2);",
|
"TextureCubeArray<int4> tex : register(t1, space2);",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
||||||
sem::MultisampledTexture s(sem::TextureDimension::k2d, ty.f32());
|
sem::MultisampledTexture s(ast::TextureDimension::k2d, ty.f32());
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -510,8 +510,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct HlslStorageTextureData {
|
struct HlslStorageTextureData {
|
||||||
sem::TextureDimension dim;
|
ast::TextureDimension dim;
|
||||||
sem::ImageFormat imgfmt;
|
ast::ImageFormat imgfmt;
|
||||||
bool ro;
|
bool ro;
|
||||||
std::string result;
|
std::string result;
|
||||||
};
|
};
|
||||||
|
@ -552,44 +552,44 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
HlslGeneratorImplTest_Type,
|
HlslGeneratorImplTest_Type,
|
||||||
HlslStorageTexturesTest,
|
HlslStorageTexturesTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
HlslStorageTextureData{sem::TextureDimension::k1d,
|
HlslStorageTextureData{ast::TextureDimension::k1d,
|
||||||
sem::ImageFormat::kRgba8Unorm, true,
|
ast::ImageFormat::kRgba8Unorm, true,
|
||||||
"Texture1D<float4> tex : register(t1, space2);"},
|
"Texture1D<float4> tex : register(t1, space2);"},
|
||||||
HlslStorageTextureData{sem::TextureDimension::k2d,
|
HlslStorageTextureData{ast::TextureDimension::k2d,
|
||||||
sem::ImageFormat::kRgba16Float, true,
|
ast::ImageFormat::kRgba16Float, true,
|
||||||
"Texture2D<float4> tex : register(t1, space2);"},
|
"Texture2D<float4> tex : register(t1, space2);"},
|
||||||
HlslStorageTextureData{
|
HlslStorageTextureData{
|
||||||
sem::TextureDimension::k2dArray, sem::ImageFormat::kR32Float, true,
|
ast::TextureDimension::k2dArray, ast::ImageFormat::kR32Float, true,
|
||||||
"Texture2DArray<float4> tex : register(t1, space2);"},
|
"Texture2DArray<float4> tex : register(t1, space2);"},
|
||||||
HlslStorageTextureData{sem::TextureDimension::k3d,
|
HlslStorageTextureData{ast::TextureDimension::k3d,
|
||||||
sem::ImageFormat::kRg32Float, true,
|
ast::ImageFormat::kRg32Float, true,
|
||||||
"Texture3D<float4> tex : register(t1, space2);"},
|
"Texture3D<float4> tex : register(t1, space2);"},
|
||||||
HlslStorageTextureData{
|
HlslStorageTextureData{
|
||||||
sem::TextureDimension::k1d, sem::ImageFormat::kRgba32Float, false,
|
ast::TextureDimension::k1d, ast::ImageFormat::kRgba32Float, false,
|
||||||
"RWTexture1D<float4> tex : register(u1, space2);"},
|
"RWTexture1D<float4> tex : register(u1, space2);"},
|
||||||
HlslStorageTextureData{
|
HlslStorageTextureData{
|
||||||
sem::TextureDimension::k2d, sem::ImageFormat::kRgba16Uint, false,
|
ast::TextureDimension::k2d, ast::ImageFormat::kRgba16Uint, false,
|
||||||
"RWTexture2D<uint4> tex : register(u1, space2);"},
|
"RWTexture2D<uint4> tex : register(u1, space2);"},
|
||||||
HlslStorageTextureData{
|
HlslStorageTextureData{
|
||||||
sem::TextureDimension::k2dArray, sem::ImageFormat::kR32Uint, false,
|
ast::TextureDimension::k2dArray, ast::ImageFormat::kR32Uint, false,
|
||||||
"RWTexture2DArray<uint4> tex : register(u1, space2);"},
|
"RWTexture2DArray<uint4> tex : register(u1, space2);"},
|
||||||
HlslStorageTextureData{
|
HlslStorageTextureData{
|
||||||
sem::TextureDimension::k3d, sem::ImageFormat::kRg32Uint, false,
|
ast::TextureDimension::k3d, ast::ImageFormat::kRg32Uint, false,
|
||||||
"RWTexture3D<uint4> tex : register(u1, space2);"},
|
"RWTexture3D<uint4> tex : register(u1, space2);"},
|
||||||
HlslStorageTextureData{sem::TextureDimension::k1d,
|
HlslStorageTextureData{ast::TextureDimension::k1d,
|
||||||
sem::ImageFormat::kRgba32Uint, true,
|
ast::ImageFormat::kRgba32Uint, true,
|
||||||
"Texture1D<uint4> tex : register(t1, space2);"},
|
"Texture1D<uint4> tex : register(t1, space2);"},
|
||||||
HlslStorageTextureData{sem::TextureDimension::k2d,
|
HlslStorageTextureData{ast::TextureDimension::k2d,
|
||||||
sem::ImageFormat::kRgba16Sint, true,
|
ast::ImageFormat::kRgba16Sint, true,
|
||||||
"Texture2D<int4> tex : register(t1, space2);"},
|
"Texture2D<int4> tex : register(t1, space2);"},
|
||||||
HlslStorageTextureData{
|
HlslStorageTextureData{
|
||||||
sem::TextureDimension::k2dArray, sem::ImageFormat::kR32Sint, true,
|
ast::TextureDimension::k2dArray, ast::ImageFormat::kR32Sint, true,
|
||||||
"Texture2DArray<int4> tex : register(t1, space2);"},
|
"Texture2DArray<int4> tex : register(t1, space2);"},
|
||||||
HlslStorageTextureData{sem::TextureDimension::k3d,
|
HlslStorageTextureData{ast::TextureDimension::k3d,
|
||||||
sem::ImageFormat::kRg32Sint, true,
|
ast::ImageFormat::kRg32Sint, true,
|
||||||
"Texture3D<int4> tex : register(t1, space2);"},
|
"Texture3D<int4> tex : register(t1, space2);"},
|
||||||
HlslStorageTextureData{
|
HlslStorageTextureData{
|
||||||
sem::TextureDimension::k1d, sem::ImageFormat::kRgba32Sint, false,
|
ast::TextureDimension::k1d, ast::ImageFormat::kRgba32Sint, false,
|
||||||
"RWTexture1D<int4> tex : register(u1, space2);"}));
|
"RWTexture1D<int4> tex : register(u1, space2);"}));
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -496,21 +496,21 @@ bool GeneratorImpl::EmitTextureCall(ast::CallExpression* expr,
|
||||||
case sem::IntrinsicType::kTextureDimensions: {
|
case sem::IntrinsicType::kTextureDimensions: {
|
||||||
std::vector<const char*> dims;
|
std::vector<const char*> dims;
|
||||||
switch (texture_type->dim()) {
|
switch (texture_type->dim()) {
|
||||||
case sem::TextureDimension::kNone:
|
case ast::TextureDimension::kNone:
|
||||||
diagnostics_.add_error("texture dimension is kNone");
|
diagnostics_.add_error("texture dimension is kNone");
|
||||||
return false;
|
return false;
|
||||||
case sem::TextureDimension::k1d:
|
case ast::TextureDimension::k1d:
|
||||||
dims = {"width"};
|
dims = {"width"};
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
dims = {"width", "height"};
|
dims = {"width", "height"};
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
dims = {"width", "height", "depth"};
|
dims = {"width", "height", "depth"};
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::kCube:
|
case ast::TextureDimension::kCube:
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
// width == height == depth for cubes
|
// width == height == depth for cubes
|
||||||
// See https://github.com/gpuweb/gpuweb/issues/1345
|
// See https://github.com/gpuweb/gpuweb/issues/1345
|
||||||
dims = {"width", "height", "height"};
|
dims = {"width", "height", "height"};
|
||||||
|
@ -645,17 +645,17 @@ bool GeneratorImpl::EmitTextureCall(ast::CallExpression* expr,
|
||||||
if (auto* ddx = arg(Usage::kDdx)) {
|
if (auto* ddx = arg(Usage::kDdx)) {
|
||||||
auto dim = texture_type->dim();
|
auto dim = texture_type->dim();
|
||||||
switch (dim) {
|
switch (dim) {
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
maybe_write_comma();
|
maybe_write_comma();
|
||||||
out_ << "gradient2d(";
|
out_ << "gradient2d(";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
maybe_write_comma();
|
maybe_write_comma();
|
||||||
out_ << "gradient3d(";
|
out_ << "gradient3d(";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::kCube:
|
case ast::TextureDimension::kCube:
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
maybe_write_comma();
|
maybe_write_comma();
|
||||||
out_ << "gradientcube(";
|
out_ << "gradientcube(";
|
||||||
break;
|
break;
|
||||||
|
@ -1959,22 +1959,22 @@ bool GeneratorImpl::EmitType(sem::Type* type, const std::string& name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (tex->dim()) {
|
switch (tex->dim()) {
|
||||||
case sem::TextureDimension::k1d:
|
case ast::TextureDimension::k1d:
|
||||||
out_ << "1d";
|
out_ << "1d";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
out_ << "2d";
|
out_ << "2d";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
out_ << "2d_array";
|
out_ << "2d_array";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
out_ << "3d";
|
out_ << "3d";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::kCube:
|
case ast::TextureDimension::kCube:
|
||||||
out_ << "cube";
|
out_ << "cube";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
out_ << "cube_array";
|
out_ << "cube_array";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -631,7 +631,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitType_Sampler) {
|
TEST_F(MslGeneratorImplTest, EmitType_Sampler) {
|
||||||
sem::Sampler sampler(sem::SamplerKind::kSampler);
|
sem::Sampler sampler(ast::SamplerKind::kSampler);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Sampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitType_SamplerComparison) {
|
TEST_F(MslGeneratorImplTest, EmitType_SamplerComparison) {
|
||||||
sem::Sampler sampler(sem::SamplerKind::kComparisonSampler);
|
sem::Sampler sampler(ast::SamplerKind::kComparisonSampler);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -649,7 +649,7 @@ TEST_F(MslGeneratorImplTest, EmitType_SamplerComparison) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MslDepthTextureData {
|
struct MslDepthTextureData {
|
||||||
sem::TextureDimension dim;
|
ast::TextureDimension dim;
|
||||||
std::string result;
|
std::string result;
|
||||||
};
|
};
|
||||||
inline std::ostream& operator<<(std::ostream& out, MslDepthTextureData data) {
|
inline std::ostream& operator<<(std::ostream& out, MslDepthTextureData data) {
|
||||||
|
@ -670,18 +670,18 @@ TEST_P(MslDepthTexturesTest, Emit) {
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
MslGeneratorImplTest,
|
MslGeneratorImplTest,
|
||||||
MslDepthTexturesTest,
|
MslDepthTexturesTest,
|
||||||
testing::Values(MslDepthTextureData{sem::TextureDimension::k2d,
|
testing::Values(MslDepthTextureData{ast::TextureDimension::k2d,
|
||||||
"depth2d<float, access::sample>"},
|
"depth2d<float, access::sample>"},
|
||||||
MslDepthTextureData{sem::TextureDimension::k2dArray,
|
MslDepthTextureData{ast::TextureDimension::k2dArray,
|
||||||
"depth2d_array<float, access::sample>"},
|
"depth2d_array<float, access::sample>"},
|
||||||
MslDepthTextureData{sem::TextureDimension::kCube,
|
MslDepthTextureData{ast::TextureDimension::kCube,
|
||||||
"depthcube<float, access::sample>"},
|
"depthcube<float, access::sample>"},
|
||||||
MslDepthTextureData{
|
MslDepthTextureData{
|
||||||
sem::TextureDimension::kCubeArray,
|
ast::TextureDimension::kCubeArray,
|
||||||
"depthcube_array<float, access::sample>"}));
|
"depthcube_array<float, access::sample>"}));
|
||||||
|
|
||||||
struct MslTextureData {
|
struct MslTextureData {
|
||||||
sem::TextureDimension dim;
|
ast::TextureDimension dim;
|
||||||
std::string result;
|
std::string result;
|
||||||
};
|
};
|
||||||
inline std::ostream& operator<<(std::ostream& out, MslTextureData data) {
|
inline std::ostream& operator<<(std::ostream& out, MslTextureData data) {
|
||||||
|
@ -702,22 +702,22 @@ TEST_P(MslSampledtexturesTest, Emit) {
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
MslGeneratorImplTest,
|
MslGeneratorImplTest,
|
||||||
MslSampledtexturesTest,
|
MslSampledtexturesTest,
|
||||||
testing::Values(MslTextureData{sem::TextureDimension::k1d,
|
testing::Values(MslTextureData{ast::TextureDimension::k1d,
|
||||||
"texture1d<float, access::sample>"},
|
"texture1d<float, access::sample>"},
|
||||||
MslTextureData{sem::TextureDimension::k2d,
|
MslTextureData{ast::TextureDimension::k2d,
|
||||||
"texture2d<float, access::sample>"},
|
"texture2d<float, access::sample>"},
|
||||||
MslTextureData{sem::TextureDimension::k2dArray,
|
MslTextureData{ast::TextureDimension::k2dArray,
|
||||||
"texture2d_array<float, access::sample>"},
|
"texture2d_array<float, access::sample>"},
|
||||||
MslTextureData{sem::TextureDimension::k3d,
|
MslTextureData{ast::TextureDimension::k3d,
|
||||||
"texture3d<float, access::sample>"},
|
"texture3d<float, access::sample>"},
|
||||||
MslTextureData{sem::TextureDimension::kCube,
|
MslTextureData{ast::TextureDimension::kCube,
|
||||||
"texturecube<float, access::sample>"},
|
"texturecube<float, access::sample>"},
|
||||||
MslTextureData{
|
MslTextureData{
|
||||||
sem::TextureDimension::kCubeArray,
|
ast::TextureDimension::kCubeArray,
|
||||||
"texturecube_array<float, access::sample>"}));
|
"texturecube_array<float, access::sample>"}));
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
|
TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
|
||||||
sem::MultisampledTexture s(sem::TextureDimension::k2d, ty.u32());
|
sem::MultisampledTexture s(ast::TextureDimension::k2d, ty.u32());
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -726,7 +726,7 @@ TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MslStorageTextureData {
|
struct MslStorageTextureData {
|
||||||
sem::TextureDimension dim;
|
ast::TextureDimension dim;
|
||||||
bool ro;
|
bool ro;
|
||||||
std::string result;
|
std::string result;
|
||||||
};
|
};
|
||||||
|
@ -739,8 +739,8 @@ TEST_P(MslStorageTexturesTest, Emit) {
|
||||||
auto params = GetParam();
|
auto params = GetParam();
|
||||||
|
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Float, Types());
|
||||||
auto* s = create<sem::StorageTexture>(params.dim, sem::ImageFormat::kR32Float,
|
auto* s = create<sem::StorageTexture>(params.dim, ast::ImageFormat::kR32Float,
|
||||||
subtype);
|
subtype);
|
||||||
auto* ac =
|
auto* ac =
|
||||||
create<sem::AccessControl>(params.ro ? ast::AccessControl::kReadOnly
|
create<sem::AccessControl>(params.ro ? ast::AccessControl::kReadOnly
|
||||||
|
@ -757,21 +757,21 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
MslGeneratorImplTest,
|
MslGeneratorImplTest,
|
||||||
MslStorageTexturesTest,
|
MslStorageTexturesTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
MslStorageTextureData{sem::TextureDimension::k1d, true,
|
MslStorageTextureData{ast::TextureDimension::k1d, true,
|
||||||
"texture1d<float, access::read>"},
|
"texture1d<float, access::read>"},
|
||||||
MslStorageTextureData{sem::TextureDimension::k2d, true,
|
MslStorageTextureData{ast::TextureDimension::k2d, true,
|
||||||
"texture2d<float, access::read>"},
|
"texture2d<float, access::read>"},
|
||||||
MslStorageTextureData{sem::TextureDimension::k2dArray, true,
|
MslStorageTextureData{ast::TextureDimension::k2dArray, true,
|
||||||
"texture2d_array<float, access::read>"},
|
"texture2d_array<float, access::read>"},
|
||||||
MslStorageTextureData{sem::TextureDimension::k3d, true,
|
MslStorageTextureData{ast::TextureDimension::k3d, true,
|
||||||
"texture3d<float, access::read>"},
|
"texture3d<float, access::read>"},
|
||||||
MslStorageTextureData{sem::TextureDimension::k1d, false,
|
MslStorageTextureData{ast::TextureDimension::k1d, false,
|
||||||
"texture1d<float, access::write>"},
|
"texture1d<float, access::write>"},
|
||||||
MslStorageTextureData{sem::TextureDimension::k2d, false,
|
MslStorageTextureData{ast::TextureDimension::k2d, false,
|
||||||
"texture2d<float, access::write>"},
|
"texture2d<float, access::write>"},
|
||||||
MslStorageTextureData{sem::TextureDimension::k2dArray, false,
|
MslStorageTextureData{ast::TextureDimension::k2dArray, false,
|
||||||
"texture2d_array<float, access::write>"},
|
"texture2d_array<float, access::write>"},
|
||||||
MslStorageTextureData{sem::TextureDimension::k3d, false,
|
MslStorageTextureData{ast::TextureDimension::k3d, false,
|
||||||
"texture3d<float, access::write>"}));
|
"texture3d<float, access::write>"}));
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -2271,22 +2271,22 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call,
|
||||||
std::vector<uint32_t> swizzle;
|
std::vector<uint32_t> swizzle;
|
||||||
uint32_t spirv_dims = 0;
|
uint32_t spirv_dims = 0;
|
||||||
switch (texture_type->dim()) {
|
switch (texture_type->dim()) {
|
||||||
case sem::TextureDimension::kNone:
|
case ast::TextureDimension::kNone:
|
||||||
error_ = "texture dimension is kNone";
|
error_ = "texture dimension is kNone";
|
||||||
return false;
|
return false;
|
||||||
case sem::TextureDimension::k1d:
|
case ast::TextureDimension::k1d:
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
break; // No swizzle needed
|
break; // No swizzle needed
|
||||||
case sem::TextureDimension::kCube:
|
case ast::TextureDimension::kCube:
|
||||||
swizzle = {0, 1, 1}; // Duplicate height for depth
|
swizzle = {0, 1, 1}; // Duplicate height for depth
|
||||||
spirv_dims = 2; // [width, height]
|
spirv_dims = 2; // [width, height]
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
swizzle = {0, 1}; // Strip array index
|
swizzle = {0, 1}; // Strip array index
|
||||||
spirv_dims = 3; // [width, height, array_count]
|
spirv_dims = 3; // [width, height, array_count]
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
swizzle = {0, 1, 1}; // Strip array index, duplicate height for depth
|
swizzle = {0, 1, 1}; // Strip array index, duplicate height for depth
|
||||||
spirv_dims = 3; // [width, height, array_count]
|
spirv_dims = 3; // [width, height, array_count]
|
||||||
break;
|
break;
|
||||||
|
@ -2319,8 +2319,8 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call,
|
||||||
default:
|
default:
|
||||||
error_ = "texture is not arrayed";
|
error_ = "texture is not arrayed";
|
||||||
return false;
|
return false;
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
spirv_dims = 3;
|
spirv_dims = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3010,13 +3010,13 @@ bool Builder::GenerateTextureType(sem::Texture* texture,
|
||||||
const Operand& result) {
|
const Operand& result) {
|
||||||
uint32_t array_literal = 0u;
|
uint32_t array_literal = 0u;
|
||||||
const auto dim = texture->dim();
|
const auto dim = texture->dim();
|
||||||
if (dim == sem::TextureDimension::k2dArray ||
|
if (dim == ast::TextureDimension::k2dArray ||
|
||||||
dim == sem::TextureDimension::kCubeArray) {
|
dim == ast::TextureDimension::kCubeArray) {
|
||||||
array_literal = 1u;
|
array_literal = 1u;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t dim_literal = SpvDim2D;
|
uint32_t dim_literal = SpvDim2D;
|
||||||
if (dim == sem::TextureDimension::k1d) {
|
if (dim == ast::TextureDimension::k1d) {
|
||||||
dim_literal = SpvDim1D;
|
dim_literal = SpvDim1D;
|
||||||
if (texture->Is<sem::SampledTexture>()) {
|
if (texture->Is<sem::SampledTexture>()) {
|
||||||
push_capability(SpvCapabilitySampled1D);
|
push_capability(SpvCapabilitySampled1D);
|
||||||
|
@ -3024,11 +3024,11 @@ bool Builder::GenerateTextureType(sem::Texture* texture,
|
||||||
push_capability(SpvCapabilityImage1D);
|
push_capability(SpvCapabilityImage1D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dim == sem::TextureDimension::k3d) {
|
if (dim == ast::TextureDimension::k3d) {
|
||||||
dim_literal = SpvDim3D;
|
dim_literal = SpvDim3D;
|
||||||
}
|
}
|
||||||
if (dim == sem::TextureDimension::kCube ||
|
if (dim == ast::TextureDimension::kCube ||
|
||||||
dim == sem::TextureDimension::kCubeArray) {
|
dim == ast::TextureDimension::kCubeArray) {
|
||||||
dim_literal = SpvDimCube;
|
dim_literal = SpvDimCube;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3048,7 +3048,7 @@ bool Builder::GenerateTextureType(sem::Texture* texture,
|
||||||
sampled_literal = 1u;
|
sampled_literal = 1u;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dim == sem::TextureDimension::kCubeArray) {
|
if (dim == ast::TextureDimension::kCubeArray) {
|
||||||
if (texture->Is<sem::SampledTexture>() ||
|
if (texture->Is<sem::SampledTexture>() ||
|
||||||
texture->Is<sem::DepthTexture>()) {
|
texture->Is<sem::DepthTexture>()) {
|
||||||
push_capability(SpvCapabilitySampledCubeArray);
|
push_capability(SpvCapabilitySampledCubeArray);
|
||||||
|
@ -3321,98 +3321,98 @@ SpvBuiltIn Builder::ConvertBuiltin(ast::Builtin builtin,
|
||||||
}
|
}
|
||||||
|
|
||||||
SpvImageFormat Builder::convert_image_format_to_spv(
|
SpvImageFormat Builder::convert_image_format_to_spv(
|
||||||
const sem::ImageFormat format) {
|
const ast::ImageFormat format) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case sem::ImageFormat::kR8Unorm:
|
case ast::ImageFormat::kR8Unorm:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatR8;
|
return SpvImageFormatR8;
|
||||||
case sem::ImageFormat::kR8Snorm:
|
case ast::ImageFormat::kR8Snorm:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatR8Snorm;
|
return SpvImageFormatR8Snorm;
|
||||||
case sem::ImageFormat::kR8Uint:
|
case ast::ImageFormat::kR8Uint:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatR8ui;
|
return SpvImageFormatR8ui;
|
||||||
case sem::ImageFormat::kR8Sint:
|
case ast::ImageFormat::kR8Sint:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatR8i;
|
return SpvImageFormatR8i;
|
||||||
case sem::ImageFormat::kR16Uint:
|
case ast::ImageFormat::kR16Uint:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatR16ui;
|
return SpvImageFormatR16ui;
|
||||||
case sem::ImageFormat::kR16Sint:
|
case ast::ImageFormat::kR16Sint:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatR16i;
|
return SpvImageFormatR16i;
|
||||||
case sem::ImageFormat::kR16Float:
|
case ast::ImageFormat::kR16Float:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatR16f;
|
return SpvImageFormatR16f;
|
||||||
case sem::ImageFormat::kRg8Unorm:
|
case ast::ImageFormat::kRg8Unorm:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatRg8;
|
return SpvImageFormatRg8;
|
||||||
case sem::ImageFormat::kRg8Snorm:
|
case ast::ImageFormat::kRg8Snorm:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatRg8Snorm;
|
return SpvImageFormatRg8Snorm;
|
||||||
case sem::ImageFormat::kRg8Uint:
|
case ast::ImageFormat::kRg8Uint:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatRg8ui;
|
return SpvImageFormatRg8ui;
|
||||||
case sem::ImageFormat::kRg8Sint:
|
case ast::ImageFormat::kRg8Sint:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatRg8i;
|
return SpvImageFormatRg8i;
|
||||||
case sem::ImageFormat::kR32Uint:
|
case ast::ImageFormat::kR32Uint:
|
||||||
return SpvImageFormatR32ui;
|
return SpvImageFormatR32ui;
|
||||||
case sem::ImageFormat::kR32Sint:
|
case ast::ImageFormat::kR32Sint:
|
||||||
return SpvImageFormatR32i;
|
return SpvImageFormatR32i;
|
||||||
case sem::ImageFormat::kR32Float:
|
case ast::ImageFormat::kR32Float:
|
||||||
return SpvImageFormatR32f;
|
return SpvImageFormatR32f;
|
||||||
case sem::ImageFormat::kRg16Uint:
|
case ast::ImageFormat::kRg16Uint:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatRg16ui;
|
return SpvImageFormatRg16ui;
|
||||||
case sem::ImageFormat::kRg16Sint:
|
case ast::ImageFormat::kRg16Sint:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatRg16i;
|
return SpvImageFormatRg16i;
|
||||||
case sem::ImageFormat::kRg16Float:
|
case ast::ImageFormat::kRg16Float:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatRg16f;
|
return SpvImageFormatRg16f;
|
||||||
case sem::ImageFormat::kRgba8Unorm:
|
case ast::ImageFormat::kRgba8Unorm:
|
||||||
return SpvImageFormatRgba8;
|
return SpvImageFormatRgba8;
|
||||||
case sem::ImageFormat::kRgba8UnormSrgb:
|
case ast::ImageFormat::kRgba8UnormSrgb:
|
||||||
return SpvImageFormatUnknown;
|
return SpvImageFormatUnknown;
|
||||||
case sem::ImageFormat::kRgba8Snorm:
|
case ast::ImageFormat::kRgba8Snorm:
|
||||||
return SpvImageFormatRgba8Snorm;
|
return SpvImageFormatRgba8Snorm;
|
||||||
case sem::ImageFormat::kRgba8Uint:
|
case ast::ImageFormat::kRgba8Uint:
|
||||||
return SpvImageFormatRgba8ui;
|
return SpvImageFormatRgba8ui;
|
||||||
case sem::ImageFormat::kRgba8Sint:
|
case ast::ImageFormat::kRgba8Sint:
|
||||||
return SpvImageFormatRgba8i;
|
return SpvImageFormatRgba8i;
|
||||||
case sem::ImageFormat::kBgra8Unorm:
|
case ast::ImageFormat::kBgra8Unorm:
|
||||||
return SpvImageFormatUnknown;
|
return SpvImageFormatUnknown;
|
||||||
case sem::ImageFormat::kBgra8UnormSrgb:
|
case ast::ImageFormat::kBgra8UnormSrgb:
|
||||||
return SpvImageFormatUnknown;
|
return SpvImageFormatUnknown;
|
||||||
case sem::ImageFormat::kRgb10A2Unorm:
|
case ast::ImageFormat::kRgb10A2Unorm:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatRgb10A2;
|
return SpvImageFormatRgb10A2;
|
||||||
case sem::ImageFormat::kRg11B10Float:
|
case ast::ImageFormat::kRg11B10Float:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatR11fG11fB10f;
|
return SpvImageFormatR11fG11fB10f;
|
||||||
case sem::ImageFormat::kRg32Uint:
|
case ast::ImageFormat::kRg32Uint:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatRg32ui;
|
return SpvImageFormatRg32ui;
|
||||||
case sem::ImageFormat::kRg32Sint:
|
case ast::ImageFormat::kRg32Sint:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatRg32i;
|
return SpvImageFormatRg32i;
|
||||||
case sem::ImageFormat::kRg32Float:
|
case ast::ImageFormat::kRg32Float:
|
||||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||||
return SpvImageFormatRg32f;
|
return SpvImageFormatRg32f;
|
||||||
case sem::ImageFormat::kRgba16Uint:
|
case ast::ImageFormat::kRgba16Uint:
|
||||||
return SpvImageFormatRgba16ui;
|
return SpvImageFormatRgba16ui;
|
||||||
case sem::ImageFormat::kRgba16Sint:
|
case ast::ImageFormat::kRgba16Sint:
|
||||||
return SpvImageFormatRgba16i;
|
return SpvImageFormatRgba16i;
|
||||||
case sem::ImageFormat::kRgba16Float:
|
case ast::ImageFormat::kRgba16Float:
|
||||||
return SpvImageFormatRgba16f;
|
return SpvImageFormatRgba16f;
|
||||||
case sem::ImageFormat::kRgba32Uint:
|
case ast::ImageFormat::kRgba32Uint:
|
||||||
return SpvImageFormatRgba32ui;
|
return SpvImageFormatRgba32ui;
|
||||||
case sem::ImageFormat::kRgba32Sint:
|
case ast::ImageFormat::kRgba32Sint:
|
||||||
return SpvImageFormatRgba32i;
|
return SpvImageFormatRgba32i;
|
||||||
case sem::ImageFormat::kRgba32Float:
|
case ast::ImageFormat::kRgba32Float:
|
||||||
return SpvImageFormatRgba32f;
|
return SpvImageFormatRgba32f;
|
||||||
case sem::ImageFormat::kNone:
|
case ast::ImageFormat::kNone:
|
||||||
return SpvImageFormatUnknown;
|
return SpvImageFormatUnknown;
|
||||||
}
|
}
|
||||||
return SpvImageFormatUnknown;
|
return SpvImageFormatUnknown;
|
||||||
|
|
|
@ -473,7 +473,7 @@ class Builder {
|
||||||
/// Converts AST image format to SPIR-V and pushes an appropriate capability.
|
/// Converts AST image format to SPIR-V and pushes an appropriate capability.
|
||||||
/// @param format AST image format type
|
/// @param format AST image format type
|
||||||
/// @returns SPIR-V 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
|
/// Determines if the given type constructor is created from constant values
|
||||||
/// @param expr the expression to check
|
/// @param expr the expression to check
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace spirv {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct TestData {
|
struct TestData {
|
||||||
sem::ImageFormat ast_format;
|
ast::ImageFormat ast_format;
|
||||||
SpvImageFormat_ spv_format;
|
SpvImageFormat_ spv_format;
|
||||||
bool extended_format = false;
|
bool extended_format = false;
|
||||||
};
|
};
|
||||||
|
@ -51,42 +51,42 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
BuilderTest,
|
BuilderTest,
|
||||||
ImageFormatConversionTest,
|
ImageFormatConversionTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
TestData{sem::ImageFormat::kR8Unorm, SpvImageFormatR8, true},
|
TestData{ast::ImageFormat::kR8Unorm, SpvImageFormatR8, true},
|
||||||
TestData{sem::ImageFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
|
TestData{ast::ImageFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
|
||||||
TestData{sem::ImageFormat::kR8Uint, SpvImageFormatR8ui, true},
|
TestData{ast::ImageFormat::kR8Uint, SpvImageFormatR8ui, true},
|
||||||
TestData{sem::ImageFormat::kR8Sint, SpvImageFormatR8i, true},
|
TestData{ast::ImageFormat::kR8Sint, SpvImageFormatR8i, true},
|
||||||
TestData{sem::ImageFormat::kR16Uint, SpvImageFormatR16ui, true},
|
TestData{ast::ImageFormat::kR16Uint, SpvImageFormatR16ui, true},
|
||||||
TestData{sem::ImageFormat::kR16Sint, SpvImageFormatR16i, true},
|
TestData{ast::ImageFormat::kR16Sint, SpvImageFormatR16i, true},
|
||||||
TestData{sem::ImageFormat::kR16Float, SpvImageFormatR16f, true},
|
TestData{ast::ImageFormat::kR16Float, SpvImageFormatR16f, true},
|
||||||
TestData{sem::ImageFormat::kRg8Unorm, SpvImageFormatRg8, true},
|
TestData{ast::ImageFormat::kRg8Unorm, SpvImageFormatRg8, true},
|
||||||
TestData{sem::ImageFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true},
|
TestData{ast::ImageFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true},
|
||||||
TestData{sem::ImageFormat::kRg8Uint, SpvImageFormatRg8ui, true},
|
TestData{ast::ImageFormat::kRg8Uint, SpvImageFormatRg8ui, true},
|
||||||
TestData{sem::ImageFormat::kRg8Sint, SpvImageFormatRg8i, true},
|
TestData{ast::ImageFormat::kRg8Sint, SpvImageFormatRg8i, true},
|
||||||
TestData{sem::ImageFormat::kR32Uint, SpvImageFormatR32ui},
|
TestData{ast::ImageFormat::kR32Uint, SpvImageFormatR32ui},
|
||||||
TestData{sem::ImageFormat::kR32Sint, SpvImageFormatR32i},
|
TestData{ast::ImageFormat::kR32Sint, SpvImageFormatR32i},
|
||||||
TestData{sem::ImageFormat::kR32Float, SpvImageFormatR32f},
|
TestData{ast::ImageFormat::kR32Float, SpvImageFormatR32f},
|
||||||
TestData{sem::ImageFormat::kRg16Uint, SpvImageFormatRg16ui, true},
|
TestData{ast::ImageFormat::kRg16Uint, SpvImageFormatRg16ui, true},
|
||||||
TestData{sem::ImageFormat::kRg16Sint, SpvImageFormatRg16i, true},
|
TestData{ast::ImageFormat::kRg16Sint, SpvImageFormatRg16i, true},
|
||||||
TestData{sem::ImageFormat::kRg16Float, SpvImageFormatRg16f, true},
|
TestData{ast::ImageFormat::kRg16Float, SpvImageFormatRg16f, true},
|
||||||
TestData{sem::ImageFormat::kRgba8Unorm, SpvImageFormatRgba8},
|
TestData{ast::ImageFormat::kRgba8Unorm, SpvImageFormatRgba8},
|
||||||
TestData{sem::ImageFormat::kRgba8UnormSrgb, SpvImageFormatUnknown},
|
TestData{ast::ImageFormat::kRgba8UnormSrgb, SpvImageFormatUnknown},
|
||||||
TestData{sem::ImageFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
|
TestData{ast::ImageFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
|
||||||
TestData{sem::ImageFormat::kRgba8Uint, SpvImageFormatRgba8ui},
|
TestData{ast::ImageFormat::kRgba8Uint, SpvImageFormatRgba8ui},
|
||||||
TestData{sem::ImageFormat::kRgba8Sint, SpvImageFormatRgba8i},
|
TestData{ast::ImageFormat::kRgba8Sint, SpvImageFormatRgba8i},
|
||||||
TestData{sem::ImageFormat::kBgra8Unorm, SpvImageFormatUnknown},
|
TestData{ast::ImageFormat::kBgra8Unorm, SpvImageFormatUnknown},
|
||||||
TestData{sem::ImageFormat::kBgra8UnormSrgb, SpvImageFormatUnknown},
|
TestData{ast::ImageFormat::kBgra8UnormSrgb, SpvImageFormatUnknown},
|
||||||
TestData{sem::ImageFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true},
|
TestData{ast::ImageFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true},
|
||||||
TestData{sem::ImageFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f,
|
TestData{ast::ImageFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f,
|
||||||
true},
|
true},
|
||||||
TestData{sem::ImageFormat::kRg32Uint, SpvImageFormatRg32ui, true},
|
TestData{ast::ImageFormat::kRg32Uint, SpvImageFormatRg32ui, true},
|
||||||
TestData{sem::ImageFormat::kRg32Sint, SpvImageFormatRg32i, true},
|
TestData{ast::ImageFormat::kRg32Sint, SpvImageFormatRg32i, true},
|
||||||
TestData{sem::ImageFormat::kRg32Float, SpvImageFormatRg32f, true},
|
TestData{ast::ImageFormat::kRg32Float, SpvImageFormatRg32f, true},
|
||||||
TestData{sem::ImageFormat::kRgba16Uint, SpvImageFormatRgba16ui},
|
TestData{ast::ImageFormat::kRgba16Uint, SpvImageFormatRgba16ui},
|
||||||
TestData{sem::ImageFormat::kRgba16Sint, SpvImageFormatRgba16i},
|
TestData{ast::ImageFormat::kRgba16Sint, SpvImageFormatRgba16i},
|
||||||
TestData{sem::ImageFormat::kRgba16Float, SpvImageFormatRgba16f},
|
TestData{ast::ImageFormat::kRgba16Float, SpvImageFormatRgba16f},
|
||||||
TestData{sem::ImageFormat::kRgba32Uint, SpvImageFormatRgba32ui},
|
TestData{ast::ImageFormat::kRgba32Uint, SpvImageFormatRgba32ui},
|
||||||
TestData{sem::ImageFormat::kRgba32Sint, SpvImageFormatRgba32i},
|
TestData{ast::ImageFormat::kRgba32Sint, SpvImageFormatRgba32i},
|
||||||
TestData{sem::ImageFormat::kRgba32Float, SpvImageFormatRgba32f}));
|
TestData{ast::ImageFormat::kRgba32Float, SpvImageFormatRgba32f}));
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace spirv
|
} // namespace spirv
|
||||||
|
|
|
@ -532,9 +532,9 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageReadOnly) {
|
||||||
// var<uniform_constant> a : [[access(read)]] texture_storage_2d<r32uint>;
|
// var<uniform_constant> a : [[access(read)]] texture_storage_2d<r32uint>;
|
||||||
|
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Uint, Types());
|
||||||
auto* type = create<sem::StorageTexture>(sem::TextureDimension::k2d,
|
auto* type = create<sem::StorageTexture>(ast::TextureDimension::k2d,
|
||||||
sem::ImageFormat::kR32Uint, subtype);
|
ast::ImageFormat::kR32Uint, subtype);
|
||||||
|
|
||||||
auto* ac = create<sem::AccessControl>(ast::AccessControl::kReadOnly, type);
|
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>;
|
// var<uniform_constant> a : [[access(write)]] texture_storage_2d<r32uint>;
|
||||||
|
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Uint, Types());
|
||||||
auto* type = create<sem::StorageTexture>(sem::TextureDimension::k2d,
|
auto* type = create<sem::StorageTexture>(ast::TextureDimension::k2d,
|
||||||
sem::ImageFormat::kR32Uint, subtype);
|
ast::ImageFormat::kR32Uint, subtype);
|
||||||
Global("test_var", type, ast::StorageClass::kInput);
|
Global("test_var", type, ast::StorageClass::kInput);
|
||||||
|
|
||||||
auto* ac = create<sem::AccessControl>(ast::AccessControl::kWriteOnly, type);
|
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>;
|
// var<uniform_constant> b : [[access(write)]] texture_storage_2d<r32uint>;
|
||||||
|
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Uint, Types());
|
||||||
auto* st = create<sem::StorageTexture>(sem::TextureDimension::k2d,
|
auto* st = create<sem::StorageTexture>(ast::TextureDimension::k2d,
|
||||||
sem::ImageFormat::kR32Uint, subtype);
|
ast::ImageFormat::kR32Uint, subtype);
|
||||||
|
|
||||||
Global("test_var", st, ast::StorageClass::kInput);
|
Global("test_var", st, ast::StorageClass::kInput);
|
||||||
|
|
||||||
|
|
|
@ -370,8 +370,8 @@ TEST_F(IntrinsicBuilderTest, Call_Select) {
|
||||||
|
|
||||||
// This tests that we do not push OpTypeSampledImage and float_0 type twice.
|
// This tests that we do not push OpTypeSampledImage and float_0 type twice.
|
||||||
TEST_F(IntrinsicBuilderTest, Call_TextureSampleCompare_Twice) {
|
TEST_F(IntrinsicBuilderTest, Call_TextureSampleCompare_Twice) {
|
||||||
sem::Sampler s(sem::SamplerKind::kComparisonSampler);
|
sem::Sampler s(ast::SamplerKind::kComparisonSampler);
|
||||||
sem::DepthTexture t(sem::TextureDimension::k2d);
|
sem::DepthTexture t(ast::TextureDimension::k2d);
|
||||||
|
|
||||||
auto* tex = Global("texture", &t, ast::StorageClass::kInput);
|
auto* tex = Global("texture", &t, ast::StorageClass::kInput);
|
||||||
|
|
||||||
|
|
|
@ -617,7 +617,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
PtrData{ast::StorageClass::kFunction, SpvStorageClassFunction}));
|
PtrData{ast::StorageClass::kFunction, SpvStorageClassFunction}));
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) {
|
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();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -631,7 +631,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) {
|
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();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -645,7 +645,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) {
|
TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) {
|
||||||
sem::DepthTexture cube(sem::TextureDimension::kCube);
|
sem::DepthTexture cube(ast::TextureDimension::kCube);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -660,7 +660,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) {
|
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();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -677,7 +677,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
|
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();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -689,7 +689,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
|
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();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -702,7 +702,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
|
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();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -715,7 +715,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
|
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();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -732,7 +732,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
|
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();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -749,7 +749,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
|
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();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -766,7 +766,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
|
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();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -780,7 +780,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
|
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
|
||||||
auto* s =
|
auto* s =
|
||||||
create<sem::SampledTexture>(sem::TextureDimension::k2dArray, ty.f32());
|
create<sem::SampledTexture>(ast::TextureDimension::k2dArray, ty.f32());
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -793,7 +793,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
|
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();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -806,7 +806,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
|
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();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -821,7 +821,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
|
TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
|
||||||
auto* s =
|
auto* s =
|
||||||
create<sem::SampledTexture>(sem::TextureDimension::kCubeArray, ty.f32());
|
create<sem::SampledTexture>(ast::TextureDimension::kCubeArray, ty.f32());
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -838,9 +838,9 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
|
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Float, Types());
|
||||||
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k1d,
|
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k1d,
|
||||||
sem::ImageFormat::kR32Float, subtype);
|
ast::ImageFormat::kR32Float, subtype);
|
||||||
|
|
||||||
Global("test_var", s, ast::StorageClass::kInput);
|
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) {
|
TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Float, Types());
|
||||||
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2d,
|
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k2d,
|
||||||
sem::ImageFormat::kR32Float, subtype);
|
ast::ImageFormat::kR32Float, subtype);
|
||||||
|
|
||||||
Global("test_var", s, ast::StorageClass::kInput);
|
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) {
|
TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Float, Types());
|
||||||
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2dArray,
|
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k2dArray,
|
||||||
sem::ImageFormat::kR32Float, subtype);
|
ast::ImageFormat::kR32Float, subtype);
|
||||||
|
|
||||||
Global("test_var", s, ast::StorageClass::kInput);
|
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) {
|
TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Float, Types());
|
||||||
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k3d,
|
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k3d,
|
||||||
sem::ImageFormat::kR32Float, subtype);
|
ast::ImageFormat::kR32Float, subtype);
|
||||||
|
|
||||||
Global("test_var", s, ast::StorageClass::kInput);
|
Global("test_var", s, ast::StorageClass::kInput);
|
||||||
|
|
||||||
|
@ -907,9 +907,9 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
|
||||||
TEST_F(BuilderTest_Type,
|
TEST_F(BuilderTest_Type,
|
||||||
StorageTexture_Generate_SampledTypeFloat_Format_r32float) {
|
StorageTexture_Generate_SampledTypeFloat_Format_r32float) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Float, Types());
|
||||||
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2d,
|
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k2d,
|
||||||
sem::ImageFormat::kR32Float, subtype);
|
ast::ImageFormat::kR32Float, subtype);
|
||||||
|
|
||||||
Global("test_var", s, ast::StorageClass::kInput);
|
Global("test_var", s, ast::StorageClass::kInput);
|
||||||
|
|
||||||
|
@ -925,9 +925,9 @@ TEST_F(BuilderTest_Type,
|
||||||
TEST_F(BuilderTest_Type,
|
TEST_F(BuilderTest_Type,
|
||||||
StorageTexture_Generate_SampledTypeSint_Format_r32sint) {
|
StorageTexture_Generate_SampledTypeSint_Format_r32sint) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Sint, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Sint, Types());
|
||||||
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2d,
|
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k2d,
|
||||||
sem::ImageFormat::kR32Sint, subtype);
|
ast::ImageFormat::kR32Sint, subtype);
|
||||||
|
|
||||||
Global("test_var", s, ast::StorageClass::kInput);
|
Global("test_var", s, ast::StorageClass::kInput);
|
||||||
|
|
||||||
|
@ -943,9 +943,9 @@ TEST_F(BuilderTest_Type,
|
||||||
TEST_F(BuilderTest_Type,
|
TEST_F(BuilderTest_Type,
|
||||||
StorageTexture_Generate_SampledTypeUint_Format_r32uint) {
|
StorageTexture_Generate_SampledTypeUint_Format_r32uint) {
|
||||||
auto* subtype =
|
auto* subtype =
|
||||||
sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types());
|
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Uint, Types());
|
||||||
auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2d,
|
auto* s = create<sem::StorageTexture>(ast::TextureDimension::k2d,
|
||||||
sem::ImageFormat::kR32Uint, subtype);
|
ast::ImageFormat::kR32Uint, subtype);
|
||||||
|
|
||||||
Global("test_var", s, ast::StorageClass::kInput);
|
Global("test_var", s, ast::StorageClass::kInput);
|
||||||
|
|
||||||
|
@ -959,7 +959,7 @@ TEST_F(BuilderTest_Type,
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, Sampler) {
|
TEST_F(BuilderTest_Type, Sampler) {
|
||||||
sem::Sampler sampler(sem::SamplerKind::kSampler);
|
sem::Sampler sampler(ast::SamplerKind::kSampler);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -969,7 +969,7 @@ TEST_F(BuilderTest_Type, Sampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, ComparisonSampler) {
|
TEST_F(BuilderTest_Type, ComparisonSampler) {
|
||||||
sem::Sampler sampler(sem::SamplerKind::kComparisonSampler);
|
sem::Sampler sampler(ast::SamplerKind::kComparisonSampler);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -979,8 +979,8 @@ TEST_F(BuilderTest_Type, ComparisonSampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, Dedup_Sampler_And_ComparisonSampler) {
|
TEST_F(BuilderTest_Type, Dedup_Sampler_And_ComparisonSampler) {
|
||||||
sem::Sampler comp_sampler(sem::SamplerKind::kComparisonSampler);
|
sem::Sampler comp_sampler(ast::SamplerKind::kComparisonSampler);
|
||||||
sem::Sampler sampler(sem::SamplerKind::kSampler);
|
sem::Sampler sampler(ast::SamplerKind::kSampler);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
|
|
@ -358,9 +358,9 @@ bool GeneratorImpl::EmitFunction(ast::Function* func) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneratorImpl::EmitImageFormat(const sem::ImageFormat fmt) {
|
bool GeneratorImpl::EmitImageFormat(const ast::ImageFormat fmt) {
|
||||||
switch (fmt) {
|
switch (fmt) {
|
||||||
case sem::ImageFormat::kNone:
|
case ast::ImageFormat::kNone:
|
||||||
diagnostics_.add_error("unknown image format");
|
diagnostics_.add_error("unknown image format");
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
|
@ -450,22 +450,22 @@ bool GeneratorImpl::EmitType(sem::Type* type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (texture->dim()) {
|
switch (texture->dim()) {
|
||||||
case sem::TextureDimension::k1d:
|
case ast::TextureDimension::k1d:
|
||||||
out_ << "1d";
|
out_ << "1d";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
out_ << "2d";
|
out_ << "2d";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
out_ << "2d_array";
|
out_ << "2d_array";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::k3d:
|
case ast::TextureDimension::k3d:
|
||||||
out_ << "3d";
|
out_ << "3d";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::kCube:
|
case ast::TextureDimension::kCube:
|
||||||
out_ << "cube";
|
out_ << "cube";
|
||||||
break;
|
break;
|
||||||
case sem::TextureDimension::kCubeArray:
|
case ast::TextureDimension::kCubeArray:
|
||||||
out_ << "cube_array";
|
out_ << "cube_array";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -180,7 +180,7 @@ class GeneratorImpl : public TextGenerator {
|
||||||
/// Handles emitting an image format
|
/// Handles emitting an image format
|
||||||
/// @param fmt the format to generate
|
/// @param fmt the format to generate
|
||||||
/// @returns true if the format is emitted
|
/// @returns true if the format is emitted
|
||||||
bool EmitImageFormat(const sem::ImageFormat fmt);
|
bool EmitImageFormat(const ast::ImageFormat fmt);
|
||||||
/// Handles emitting a type constructor
|
/// Handles emitting a type constructor
|
||||||
/// @param expr the type constructor expression
|
/// @param expr the type constructor expression
|
||||||
/// @returns true if the constructor is emitted
|
/// @returns true if the constructor is emitted
|
||||||
|
|
|
@ -101,7 +101,7 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) {
|
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);
|
ast::StorageClass::kUniformConstant);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -113,7 +113,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WgslGeneratorImplTest, Emit_Global_Texture) {
|
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),
|
Global("t", ty.access(ast::AccessControl::kReadOnly, st),
|
||||||
ast::StorageClass::kUniformConstant);
|
ast::StorageClass::kUniformConstant);
|
||||||
|
|
||||||
|
|
|
@ -314,7 +314,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Vector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TextureData {
|
struct TextureData {
|
||||||
sem::TextureDimension dim;
|
ast::TextureDimension dim;
|
||||||
const char* name;
|
const char* name;
|
||||||
};
|
};
|
||||||
inline std::ostream& operator<<(std::ostream& out, TextureData data) {
|
inline std::ostream& operator<<(std::ostream& out, TextureData data) {
|
||||||
|
@ -338,10 +338,10 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
WgslGeneratorImplTest,
|
WgslGeneratorImplTest,
|
||||||
WgslGenerator_DepthTextureTest,
|
WgslGenerator_DepthTextureTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
TextureData{sem::TextureDimension::k2d, "texture_depth_2d"},
|
TextureData{ast::TextureDimension::k2d, "texture_depth_2d"},
|
||||||
TextureData{sem::TextureDimension::k2dArray, "texture_depth_2d_array"},
|
TextureData{ast::TextureDimension::k2dArray, "texture_depth_2d_array"},
|
||||||
TextureData{sem::TextureDimension::kCube, "texture_depth_cube"},
|
TextureData{ast::TextureDimension::kCube, "texture_depth_cube"},
|
||||||
TextureData{sem::TextureDimension::kCubeArray,
|
TextureData{ast::TextureDimension::kCubeArray,
|
||||||
"texture_depth_cube_array"}));
|
"texture_depth_cube_array"}));
|
||||||
|
|
||||||
using WgslGenerator_SampledTextureTest = TestParamHelper<TextureData>;
|
using WgslGenerator_SampledTextureTest = TestParamHelper<TextureData>;
|
||||||
|
@ -384,12 +384,12 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
WgslGeneratorImplTest,
|
WgslGeneratorImplTest,
|
||||||
WgslGenerator_SampledTextureTest,
|
WgslGenerator_SampledTextureTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
TextureData{sem::TextureDimension::k1d, "texture_1d"},
|
TextureData{ast::TextureDimension::k1d, "texture_1d"},
|
||||||
TextureData{sem::TextureDimension::k2d, "texture_2d"},
|
TextureData{ast::TextureDimension::k2d, "texture_2d"},
|
||||||
TextureData{sem::TextureDimension::k2dArray, "texture_2d_array"},
|
TextureData{ast::TextureDimension::k2dArray, "texture_2d_array"},
|
||||||
TextureData{sem::TextureDimension::k3d, "texture_3d"},
|
TextureData{ast::TextureDimension::k3d, "texture_3d"},
|
||||||
TextureData{sem::TextureDimension::kCube, "texture_cube"},
|
TextureData{ast::TextureDimension::kCube, "texture_cube"},
|
||||||
TextureData{sem::TextureDimension::kCubeArray, "texture_cube_array"}));
|
TextureData{ast::TextureDimension::kCubeArray, "texture_cube_array"}));
|
||||||
|
|
||||||
using WgslGenerator_MultiampledTextureTest = TestParamHelper<TextureData>;
|
using WgslGenerator_MultiampledTextureTest = TestParamHelper<TextureData>;
|
||||||
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) {
|
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) {
|
||||||
|
@ -430,12 +430,12 @@ TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_U32) {
|
||||||
INSTANTIATE_TEST_SUITE_P(WgslGeneratorImplTest,
|
INSTANTIATE_TEST_SUITE_P(WgslGeneratorImplTest,
|
||||||
WgslGenerator_MultiampledTextureTest,
|
WgslGenerator_MultiampledTextureTest,
|
||||||
testing::Values(TextureData{
|
testing::Values(TextureData{
|
||||||
sem::TextureDimension::k2d,
|
ast::TextureDimension::k2d,
|
||||||
"texture_multisampled_2d"}));
|
"texture_multisampled_2d"}));
|
||||||
|
|
||||||
struct StorageTextureData {
|
struct StorageTextureData {
|
||||||
sem::ImageFormat fmt;
|
ast::ImageFormat fmt;
|
||||||
sem::TextureDimension dim;
|
ast::TextureDimension dim;
|
||||||
ast::AccessControl::Access access;
|
ast::AccessControl::Access access;
|
||||||
const char* name;
|
const char* name;
|
||||||
};
|
};
|
||||||
|
@ -460,41 +460,41 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
WgslGeneratorImplTest,
|
WgslGeneratorImplTest,
|
||||||
WgslGenerator_StorageTextureTest,
|
WgslGenerator_StorageTextureTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
StorageTextureData{sem::ImageFormat::kR8Unorm,
|
StorageTextureData{ast::ImageFormat::kR8Unorm,
|
||||||
sem::TextureDimension::k1d,
|
ast::TextureDimension::k1d,
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
"[[access(read)]] texture_storage_1d<r8unorm>"},
|
"[[access(read)]] texture_storage_1d<r8unorm>"},
|
||||||
StorageTextureData{sem::ImageFormat::kR8Unorm,
|
StorageTextureData{ast::ImageFormat::kR8Unorm,
|
||||||
sem::TextureDimension::k2d,
|
ast::TextureDimension::k2d,
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
"[[access(read)]] texture_storage_2d<r8unorm>"},
|
"[[access(read)]] texture_storage_2d<r8unorm>"},
|
||||||
StorageTextureData{
|
StorageTextureData{
|
||||||
sem::ImageFormat::kR8Unorm, sem::TextureDimension::k2dArray,
|
ast::ImageFormat::kR8Unorm, ast::TextureDimension::k2dArray,
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
"[[access(read)]] texture_storage_2d_array<r8unorm>"},
|
"[[access(read)]] texture_storage_2d_array<r8unorm>"},
|
||||||
StorageTextureData{sem::ImageFormat::kR8Unorm,
|
StorageTextureData{ast::ImageFormat::kR8Unorm,
|
||||||
sem::TextureDimension::k3d,
|
ast::TextureDimension::k3d,
|
||||||
ast::AccessControl::kReadOnly,
|
ast::AccessControl::kReadOnly,
|
||||||
"[[access(read)]] texture_storage_3d<r8unorm>"},
|
"[[access(read)]] texture_storage_3d<r8unorm>"},
|
||||||
StorageTextureData{sem::ImageFormat::kR8Unorm,
|
StorageTextureData{ast::ImageFormat::kR8Unorm,
|
||||||
sem::TextureDimension::k1d,
|
ast::TextureDimension::k1d,
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
"[[access(write)]] texture_storage_1d<r8unorm>"},
|
"[[access(write)]] texture_storage_1d<r8unorm>"},
|
||||||
StorageTextureData{sem::ImageFormat::kR8Unorm,
|
StorageTextureData{ast::ImageFormat::kR8Unorm,
|
||||||
sem::TextureDimension::k2d,
|
ast::TextureDimension::k2d,
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
"[[access(write)]] texture_storage_2d<r8unorm>"},
|
"[[access(write)]] texture_storage_2d<r8unorm>"},
|
||||||
StorageTextureData{
|
StorageTextureData{
|
||||||
sem::ImageFormat::kR8Unorm, sem::TextureDimension::k2dArray,
|
ast::ImageFormat::kR8Unorm, ast::TextureDimension::k2dArray,
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
"[[access(write)]] texture_storage_2d_array<r8unorm>"},
|
"[[access(write)]] texture_storage_2d_array<r8unorm>"},
|
||||||
StorageTextureData{sem::ImageFormat::kR8Unorm,
|
StorageTextureData{ast::ImageFormat::kR8Unorm,
|
||||||
sem::TextureDimension::k3d,
|
ast::TextureDimension::k3d,
|
||||||
ast::AccessControl::kWriteOnly,
|
ast::AccessControl::kWriteOnly,
|
||||||
"[[access(write)]] texture_storage_3d<r8unorm>"}));
|
"[[access(write)]] texture_storage_3d<r8unorm>"}));
|
||||||
|
|
||||||
struct ImageFormatData {
|
struct ImageFormatData {
|
||||||
sem::ImageFormat fmt;
|
ast::ImageFormat fmt;
|
||||||
const char* name;
|
const char* name;
|
||||||
};
|
};
|
||||||
inline std::ostream& operator<<(std::ostream& out, ImageFormatData data) {
|
inline std::ostream& operator<<(std::ostream& out, ImageFormatData data) {
|
||||||
|
@ -515,44 +515,44 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
WgslGeneratorImplTest,
|
WgslGeneratorImplTest,
|
||||||
WgslGenerator_ImageFormatTest,
|
WgslGenerator_ImageFormatTest,
|
||||||
testing::Values(
|
testing::Values(
|
||||||
ImageFormatData{sem::ImageFormat::kR8Unorm, "r8unorm"},
|
ImageFormatData{ast::ImageFormat::kR8Unorm, "r8unorm"},
|
||||||
ImageFormatData{sem::ImageFormat::kR8Snorm, "r8snorm"},
|
ImageFormatData{ast::ImageFormat::kR8Snorm, "r8snorm"},
|
||||||
ImageFormatData{sem::ImageFormat::kR8Uint, "r8uint"},
|
ImageFormatData{ast::ImageFormat::kR8Uint, "r8uint"},
|
||||||
ImageFormatData{sem::ImageFormat::kR8Sint, "r8sint"},
|
ImageFormatData{ast::ImageFormat::kR8Sint, "r8sint"},
|
||||||
ImageFormatData{sem::ImageFormat::kR16Uint, "r16uint"},
|
ImageFormatData{ast::ImageFormat::kR16Uint, "r16uint"},
|
||||||
ImageFormatData{sem::ImageFormat::kR16Sint, "r16sint"},
|
ImageFormatData{ast::ImageFormat::kR16Sint, "r16sint"},
|
||||||
ImageFormatData{sem::ImageFormat::kR16Float, "r16float"},
|
ImageFormatData{ast::ImageFormat::kR16Float, "r16float"},
|
||||||
ImageFormatData{sem::ImageFormat::kRg8Unorm, "rg8unorm"},
|
ImageFormatData{ast::ImageFormat::kRg8Unorm, "rg8unorm"},
|
||||||
ImageFormatData{sem::ImageFormat::kRg8Snorm, "rg8snorm"},
|
ImageFormatData{ast::ImageFormat::kRg8Snorm, "rg8snorm"},
|
||||||
ImageFormatData{sem::ImageFormat::kRg8Uint, "rg8uint"},
|
ImageFormatData{ast::ImageFormat::kRg8Uint, "rg8uint"},
|
||||||
ImageFormatData{sem::ImageFormat::kRg8Sint, "rg8sint"},
|
ImageFormatData{ast::ImageFormat::kRg8Sint, "rg8sint"},
|
||||||
ImageFormatData{sem::ImageFormat::kR32Uint, "r32uint"},
|
ImageFormatData{ast::ImageFormat::kR32Uint, "r32uint"},
|
||||||
ImageFormatData{sem::ImageFormat::kR32Sint, "r32sint"},
|
ImageFormatData{ast::ImageFormat::kR32Sint, "r32sint"},
|
||||||
ImageFormatData{sem::ImageFormat::kR32Float, "r32float"},
|
ImageFormatData{ast::ImageFormat::kR32Float, "r32float"},
|
||||||
ImageFormatData{sem::ImageFormat::kRg16Uint, "rg16uint"},
|
ImageFormatData{ast::ImageFormat::kRg16Uint, "rg16uint"},
|
||||||
ImageFormatData{sem::ImageFormat::kRg16Sint, "rg16sint"},
|
ImageFormatData{ast::ImageFormat::kRg16Sint, "rg16sint"},
|
||||||
ImageFormatData{sem::ImageFormat::kRg16Float, "rg16float"},
|
ImageFormatData{ast::ImageFormat::kRg16Float, "rg16float"},
|
||||||
ImageFormatData{sem::ImageFormat::kRgba8Unorm, "rgba8unorm"},
|
ImageFormatData{ast::ImageFormat::kRgba8Unorm, "rgba8unorm"},
|
||||||
ImageFormatData{sem::ImageFormat::kRgba8UnormSrgb, "rgba8unorm_srgb"},
|
ImageFormatData{ast::ImageFormat::kRgba8UnormSrgb, "rgba8unorm_srgb"},
|
||||||
ImageFormatData{sem::ImageFormat::kRgba8Snorm, "rgba8snorm"},
|
ImageFormatData{ast::ImageFormat::kRgba8Snorm, "rgba8snorm"},
|
||||||
ImageFormatData{sem::ImageFormat::kRgba8Uint, "rgba8uint"},
|
ImageFormatData{ast::ImageFormat::kRgba8Uint, "rgba8uint"},
|
||||||
ImageFormatData{sem::ImageFormat::kRgba8Sint, "rgba8sint"},
|
ImageFormatData{ast::ImageFormat::kRgba8Sint, "rgba8sint"},
|
||||||
ImageFormatData{sem::ImageFormat::kBgra8Unorm, "bgra8unorm"},
|
ImageFormatData{ast::ImageFormat::kBgra8Unorm, "bgra8unorm"},
|
||||||
ImageFormatData{sem::ImageFormat::kBgra8UnormSrgb, "bgra8unorm_srgb"},
|
ImageFormatData{ast::ImageFormat::kBgra8UnormSrgb, "bgra8unorm_srgb"},
|
||||||
ImageFormatData{sem::ImageFormat::kRgb10A2Unorm, "rgb10a2unorm"},
|
ImageFormatData{ast::ImageFormat::kRgb10A2Unorm, "rgb10a2unorm"},
|
||||||
ImageFormatData{sem::ImageFormat::kRg11B10Float, "rg11b10float"},
|
ImageFormatData{ast::ImageFormat::kRg11B10Float, "rg11b10float"},
|
||||||
ImageFormatData{sem::ImageFormat::kRg32Uint, "rg32uint"},
|
ImageFormatData{ast::ImageFormat::kRg32Uint, "rg32uint"},
|
||||||
ImageFormatData{sem::ImageFormat::kRg32Sint, "rg32sint"},
|
ImageFormatData{ast::ImageFormat::kRg32Sint, "rg32sint"},
|
||||||
ImageFormatData{sem::ImageFormat::kRg32Float, "rg32float"},
|
ImageFormatData{ast::ImageFormat::kRg32Float, "rg32float"},
|
||||||
ImageFormatData{sem::ImageFormat::kRgba16Uint, "rgba16uint"},
|
ImageFormatData{ast::ImageFormat::kRgba16Uint, "rgba16uint"},
|
||||||
ImageFormatData{sem::ImageFormat::kRgba16Sint, "rgba16sint"},
|
ImageFormatData{ast::ImageFormat::kRgba16Sint, "rgba16sint"},
|
||||||
ImageFormatData{sem::ImageFormat::kRgba16Float, "rgba16float"},
|
ImageFormatData{ast::ImageFormat::kRgba16Float, "rgba16float"},
|
||||||
ImageFormatData{sem::ImageFormat::kRgba32Uint, "rgba32uint"},
|
ImageFormatData{ast::ImageFormat::kRgba32Uint, "rgba32uint"},
|
||||||
ImageFormatData{sem::ImageFormat::kRgba32Sint, "rgba32sint"},
|
ImageFormatData{ast::ImageFormat::kRgba32Sint, "rgba32sint"},
|
||||||
ImageFormatData{sem::ImageFormat::kRgba32Float, "rgba32float"}));
|
ImageFormatData{ast::ImageFormat::kRgba32Float, "rgba32float"}));
|
||||||
|
|
||||||
TEST_F(WgslGeneratorImplTest, EmitType_Sampler) {
|
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));
|
AST().AddConstructedType(ty.alias("make_type_reachable", sampler));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -562,7 +562,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Sampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WgslGeneratorImplTest, EmitType_SamplerComparison) {
|
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));
|
AST().AddConstructedType(ty.alias("make_type_reachable", sampler));
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
Loading…
Reference in New Issue