ast: Rename ImageFormat to TexelFormat
This is what its called in the spec. Issue: tint:1361 Change-Id: I512c4224191fd2bbf04522da2093872f79ee02a6 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75581 Reviewed-by: David Neto <dneto@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
c1faee9395
commit
294ce9394f
|
@ -253,80 +253,80 @@ std::string SampledKindToString(
|
|||
return "Unknown";
|
||||
}
|
||||
|
||||
std::string ImageFormatToString(
|
||||
tint::inspector::ResourceBinding::ImageFormat format) {
|
||||
std::string TexelFormatToString(
|
||||
tint::inspector::ResourceBinding::TexelFormat format) {
|
||||
switch (format) {
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kR8Unorm:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kR8Unorm:
|
||||
return "R8Unorm";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kR8Snorm:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kR8Snorm:
|
||||
return "R8Snorm";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kR8Uint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kR8Uint:
|
||||
return "R8Uint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kR8Sint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kR8Sint:
|
||||
return "R8Sint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kR16Uint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kR16Uint:
|
||||
return "R16Uint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kR16Sint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kR16Sint:
|
||||
return "R16Sint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kR16Float:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kR16Float:
|
||||
return "R16Float";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRg8Unorm:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRg8Unorm:
|
||||
return "Rg8Unorm";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRg8Snorm:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRg8Snorm:
|
||||
return "Rg8Snorm";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRg8Uint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRg8Uint:
|
||||
return "Rg8Uint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRg8Sint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRg8Sint:
|
||||
return "Rg8Sint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kR32Uint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kR32Uint:
|
||||
return "R32Uint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kR32Sint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kR32Sint:
|
||||
return "R32Sint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kR32Float:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kR32Float:
|
||||
return "R32Float";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRg16Uint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRg16Uint:
|
||||
return "Rg16Uint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRg16Sint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRg16Sint:
|
||||
return "Rg16Sint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRg16Float:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRg16Float:
|
||||
return "Rg16Float";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRgba8Unorm:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRgba8Unorm:
|
||||
return "Rgba8Unorm";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRgba8UnormSrgb:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRgba8UnormSrgb:
|
||||
return "Rgba8UnormSrgb";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRgba8Snorm:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRgba8Snorm:
|
||||
return "Rgba8Snorm";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRgba8Uint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRgba8Uint:
|
||||
return "Rgba8Uint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRgba8Sint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRgba8Sint:
|
||||
return "Rgba8Sint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kBgra8Unorm:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kBgra8Unorm:
|
||||
return "Bgra8Unorm";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kBgra8UnormSrgb:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kBgra8UnormSrgb:
|
||||
return "Bgra8UnormSrgb";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRgb10A2Unorm:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRgb10A2Unorm:
|
||||
return "Rgb10A2Unorm";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRg11B10Float:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRg11B10Float:
|
||||
return "Rg11B10Float";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRg32Uint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRg32Uint:
|
||||
return "Rg32Uint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRg32Sint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRg32Sint:
|
||||
return "Rg32Sint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRg32Float:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRg32Float:
|
||||
return "Rg32Float";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRgba16Uint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRgba16Uint:
|
||||
return "Rgba16Uint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRgba16Sint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRgba16Sint:
|
||||
return "Rgba16Sint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRgba16Float:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRgba16Float:
|
||||
return "Rgba16Float";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRgba32Uint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRgba32Uint:
|
||||
return "Rgba32Uint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRgba32Sint:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRgba32Sint:
|
||||
return "Rgba32Sint";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kRgba32Float:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kRgba32Float:
|
||||
return "Rgba32Float";
|
||||
case tint::inspector::ResourceBinding::ImageFormat::kNone:
|
||||
case tint::inspector::ResourceBinding::TexelFormat::kNone:
|
||||
return "None";
|
||||
}
|
||||
return "Unknown";
|
||||
|
@ -1162,7 +1162,7 @@ int main(int argc, const char** argv) {
|
|||
std::cout << "\t\t sampled_kind = "
|
||||
<< SampledKindToString(binding.sampled_kind) << std::endl;
|
||||
std::cout << "\t\t image_format = "
|
||||
<< ImageFormatToString(binding.image_format) << std::endl;
|
||||
<< TexelFormatToString(binding.image_format) << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << std::string(80, '-') << std::endl;
|
||||
|
|
|
@ -840,7 +840,6 @@ if(${TINT_BUILD_TESTS})
|
|||
reader/wgsl/parser_impl_global_decl_test.cc
|
||||
reader/wgsl/parser_impl_global_variable_decl_test.cc
|
||||
reader/wgsl/parser_impl_if_stmt_test.cc
|
||||
reader/wgsl/parser_impl_image_storage_type_test.cc
|
||||
reader/wgsl/parser_impl_inclusive_or_expression_test.cc
|
||||
reader/wgsl/parser_impl_logical_and_expression_test.cc
|
||||
reader/wgsl/parser_impl_logical_or_expression_test.cc
|
||||
|
@ -872,6 +871,7 @@ if(${TINT_BUILD_TESTS})
|
|||
reader/wgsl/parser_impl_test.cc
|
||||
reader/wgsl/parser_impl_test_helper.cc
|
||||
reader/wgsl/parser_impl_test_helper.h
|
||||
reader/wgsl/parser_impl_texel_format_test.cc
|
||||
reader/wgsl/parser_impl_texture_sampler_types_test.cc
|
||||
reader/wgsl/parser_impl_type_alias_test.cc
|
||||
reader/wgsl/parser_impl_type_decl_test.cc
|
||||
|
|
|
@ -63,7 +63,7 @@ TextureOverloadCase::TextureOverloadCase(
|
|||
ValidTextureOverload o,
|
||||
const char* d,
|
||||
Access acc,
|
||||
ast::ImageFormat i,
|
||||
ast::TexelFormat fmt,
|
||||
ast::TextureDimension dims,
|
||||
TextureDataType datatype,
|
||||
const char* f,
|
||||
|
@ -72,7 +72,7 @@ TextureOverloadCase::TextureOverloadCase(
|
|||
description(d),
|
||||
texture_kind(TextureKind::kStorage),
|
||||
access(acc),
|
||||
image_format(i),
|
||||
texel_format(fmt),
|
||||
texture_dimension(dims),
|
||||
texture_data_type(datatype),
|
||||
function(f),
|
||||
|
@ -128,7 +128,7 @@ std::ostream& operator<<(std::ostream& out, const TextureOverloadCase& data) {
|
|||
}
|
||||
out << "\n";
|
||||
out << "access: " << data.access << "\n";
|
||||
out << "image_format: " << data.image_format << "\n";
|
||||
out << "texel_format: " << data.texel_format << "\n";
|
||||
out << "texture_dimension: " << data.texture_dimension << "\n";
|
||||
out << "texture_data_type: " << data.texture_data_type << "\n";
|
||||
return out;
|
||||
|
@ -179,7 +179,7 @@ const ast::Variable* TextureOverloadCase::BuildTextureVariable(
|
|||
decos);
|
||||
|
||||
case ast::intrinsic::test::TextureKind::kStorage: {
|
||||
auto* st = b->ty.storage_texture(texture_dimension, image_format, access);
|
||||
auto* st = b->ty.storage_texture(texture_dimension, texel_format, access);
|
||||
return b->Global("texture", st, decos);
|
||||
}
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
ValidTextureOverload::kDimensionsStorageWO1d,
|
||||
"textureDimensions(t : texture_storage_1d<rgba32float>) -> i32",
|
||||
ast::Access::kWrite,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::TextureDimension::k1d,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
|
@ -433,7 +433,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
"textureDimensions(t : texture_storage_2d<rgba32float>) -> "
|
||||
"vec2<i32>",
|
||||
ast::Access::kWrite,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
|
@ -444,7 +444,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> "
|
||||
"vec2<i32>",
|
||||
ast::Access::kWrite,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
|
@ -455,7 +455,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
"textureDimensions(t : texture_storage_3d<rgba32float>) -> "
|
||||
"vec3<i32>",
|
||||
ast::Access::kWrite,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::TextureDimension::k3d,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
|
@ -848,7 +848,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
ValidTextureOverload::kNumLayersStorageWO2dArray,
|
||||
"textureNumLayers(t : texture_storage_2d_array<rgba32float>) -> i32",
|
||||
ast::Access::kWrite,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureNumLayers",
|
||||
|
@ -2205,7 +2205,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : i32,\n"
|
||||
" value : vec4<T>)",
|
||||
ast::Access::kWrite,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::TextureDimension::k1d,
|
||||
TextureDataType::kF32,
|
||||
"textureStore",
|
||||
|
@ -2221,7 +2221,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec2<i32>,\n"
|
||||
" value : vec4<T>)",
|
||||
ast::Access::kWrite,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureStore",
|
||||
|
@ -2238,7 +2238,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" array_index : i32,\n"
|
||||
" value : vec4<T>)",
|
||||
ast::Access::kWrite,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureStore",
|
||||
|
@ -2255,7 +2255,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec3<i32>,\n"
|
||||
" value : vec4<T>)",
|
||||
ast::Access::kWrite,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::TextureDimension::k3d,
|
||||
TextureDataType::kF32,
|
||||
"textureStore",
|
||||
|
|
|
@ -207,7 +207,7 @@ struct TextureOverloadCase {
|
|||
TextureOverloadCase(ValidTextureOverload,
|
||||
const char*,
|
||||
Access,
|
||||
ast::ImageFormat,
|
||||
ast::TexelFormat,
|
||||
ast::TextureDimension,
|
||||
TextureDataType,
|
||||
const char*,
|
||||
|
@ -248,7 +248,7 @@ struct TextureOverloadCase {
|
|||
Access const access = Access::kReadWrite;
|
||||
/// The image format for the storage texture
|
||||
/// Used only when texture_kind is kStorage
|
||||
ast::ImageFormat const image_format = ast::ImageFormat::kNone;
|
||||
ast::TexelFormat const texel_format = ast::TexelFormat::kNone;
|
||||
/// The dimensions of the texture parameter
|
||||
ast::TextureDimension const texture_dimension;
|
||||
/// The data type of the texture parameter
|
||||
|
|
|
@ -26,114 +26,114 @@ namespace ast {
|
|||
|
||||
// Note, these names match the names in the WGSL spec. This behaviour is used
|
||||
// in the WGSL writer to emit the texture format names.
|
||||
std::ostream& operator<<(std::ostream& out, ImageFormat format) {
|
||||
std::ostream& operator<<(std::ostream& out, TexelFormat format) {
|
||||
switch (format) {
|
||||
case ImageFormat::kNone:
|
||||
case TexelFormat::kNone:
|
||||
out << "none";
|
||||
break;
|
||||
case ImageFormat::kR8Unorm:
|
||||
case TexelFormat::kR8Unorm:
|
||||
out << "r8unorm";
|
||||
break;
|
||||
case ImageFormat::kR8Snorm:
|
||||
case TexelFormat::kR8Snorm:
|
||||
out << "r8snorm";
|
||||
break;
|
||||
case ImageFormat::kR8Uint:
|
||||
case TexelFormat::kR8Uint:
|
||||
out << "r8uint";
|
||||
break;
|
||||
case ImageFormat::kR8Sint:
|
||||
case TexelFormat::kR8Sint:
|
||||
out << "r8sint";
|
||||
break;
|
||||
case ImageFormat::kR16Uint:
|
||||
case TexelFormat::kR16Uint:
|
||||
out << "r16uint";
|
||||
break;
|
||||
case ImageFormat::kR16Sint:
|
||||
case TexelFormat::kR16Sint:
|
||||
out << "r16sint";
|
||||
break;
|
||||
case ImageFormat::kR16Float:
|
||||
case TexelFormat::kR16Float:
|
||||
out << "r16float";
|
||||
break;
|
||||
case ImageFormat::kRg8Unorm:
|
||||
case TexelFormat::kRg8Unorm:
|
||||
out << "rg8unorm";
|
||||
break;
|
||||
case ImageFormat::kRg8Snorm:
|
||||
case TexelFormat::kRg8Snorm:
|
||||
out << "rg8snorm";
|
||||
break;
|
||||
case ImageFormat::kRg8Uint:
|
||||
case TexelFormat::kRg8Uint:
|
||||
out << "rg8uint";
|
||||
break;
|
||||
case ImageFormat::kRg8Sint:
|
||||
case TexelFormat::kRg8Sint:
|
||||
out << "rg8sint";
|
||||
break;
|
||||
case ImageFormat::kR32Uint:
|
||||
case TexelFormat::kR32Uint:
|
||||
out << "r32uint";
|
||||
break;
|
||||
case ImageFormat::kR32Sint:
|
||||
case TexelFormat::kR32Sint:
|
||||
out << "r32sint";
|
||||
break;
|
||||
case ImageFormat::kR32Float:
|
||||
case TexelFormat::kR32Float:
|
||||
out << "r32float";
|
||||
break;
|
||||
case ImageFormat::kRg16Uint:
|
||||
case TexelFormat::kRg16Uint:
|
||||
out << "rg16uint";
|
||||
break;
|
||||
case ImageFormat::kRg16Sint:
|
||||
case TexelFormat::kRg16Sint:
|
||||
out << "rg16sint";
|
||||
break;
|
||||
case ImageFormat::kRg16Float:
|
||||
case TexelFormat::kRg16Float:
|
||||
out << "rg16float";
|
||||
break;
|
||||
case ImageFormat::kRgba8Unorm:
|
||||
case TexelFormat::kRgba8Unorm:
|
||||
out << "rgba8unorm";
|
||||
break;
|
||||
case ImageFormat::kRgba8UnormSrgb:
|
||||
case TexelFormat::kRgba8UnormSrgb:
|
||||
out << "rgba8unorm_srgb";
|
||||
break;
|
||||
case ImageFormat::kRgba8Snorm:
|
||||
case TexelFormat::kRgba8Snorm:
|
||||
out << "rgba8snorm";
|
||||
break;
|
||||
case ImageFormat::kRgba8Uint:
|
||||
case TexelFormat::kRgba8Uint:
|
||||
out << "rgba8uint";
|
||||
break;
|
||||
case ImageFormat::kRgba8Sint:
|
||||
case TexelFormat::kRgba8Sint:
|
||||
out << "rgba8sint";
|
||||
break;
|
||||
case ImageFormat::kBgra8Unorm:
|
||||
case TexelFormat::kBgra8Unorm:
|
||||
out << "bgra8unorm";
|
||||
break;
|
||||
case ImageFormat::kBgra8UnormSrgb:
|
||||
case TexelFormat::kBgra8UnormSrgb:
|
||||
out << "bgra8unorm_srgb";
|
||||
break;
|
||||
case ImageFormat::kRgb10A2Unorm:
|
||||
case TexelFormat::kRgb10A2Unorm:
|
||||
out << "rgb10a2unorm";
|
||||
break;
|
||||
case ImageFormat::kRg11B10Float:
|
||||
case TexelFormat::kRg11B10Float:
|
||||
out << "rg11b10float";
|
||||
break;
|
||||
case ImageFormat::kRg32Uint:
|
||||
case TexelFormat::kRg32Uint:
|
||||
out << "rg32uint";
|
||||
break;
|
||||
case ImageFormat::kRg32Sint:
|
||||
case TexelFormat::kRg32Sint:
|
||||
out << "rg32sint";
|
||||
break;
|
||||
case ImageFormat::kRg32Float:
|
||||
case TexelFormat::kRg32Float:
|
||||
out << "rg32float";
|
||||
break;
|
||||
case ImageFormat::kRgba16Uint:
|
||||
case TexelFormat::kRgba16Uint:
|
||||
out << "rgba16uint";
|
||||
break;
|
||||
case ImageFormat::kRgba16Sint:
|
||||
case TexelFormat::kRgba16Sint:
|
||||
out << "rgba16sint";
|
||||
break;
|
||||
case ImageFormat::kRgba16Float:
|
||||
case TexelFormat::kRgba16Float:
|
||||
out << "rgba16float";
|
||||
break;
|
||||
case ImageFormat::kRgba32Uint:
|
||||
case TexelFormat::kRgba32Uint:
|
||||
out << "rgba32uint";
|
||||
break;
|
||||
case ImageFormat::kRgba32Sint:
|
||||
case TexelFormat::kRgba32Sint:
|
||||
out << "rgba32sint";
|
||||
break;
|
||||
case ImageFormat::kRgba32Float:
|
||||
case TexelFormat::kRgba32Float:
|
||||
out << "rgba32float";
|
||||
break;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ std::ostream& operator<<(std::ostream& out, ImageFormat format) {
|
|||
StorageTexture::StorageTexture(ProgramID pid,
|
||||
const Source& src,
|
||||
TextureDimension d,
|
||||
ImageFormat fmt,
|
||||
TexelFormat fmt,
|
||||
const Type* subtype,
|
||||
Access ac)
|
||||
: Base(pid, src, d), format(fmt), type(subtype), access(ac) {}
|
||||
|
@ -165,53 +165,53 @@ const StorageTexture* StorageTexture::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<StorageTexture>(src, dim, format, ty, access);
|
||||
}
|
||||
|
||||
Type* StorageTexture::SubtypeFor(ImageFormat format, ProgramBuilder& builder) {
|
||||
Type* StorageTexture::SubtypeFor(TexelFormat format, ProgramBuilder& builder) {
|
||||
switch (format) {
|
||||
case ImageFormat::kR8Uint:
|
||||
case ImageFormat::kR16Uint:
|
||||
case ImageFormat::kRg8Uint:
|
||||
case ImageFormat::kR32Uint:
|
||||
case ImageFormat::kRg16Uint:
|
||||
case ImageFormat::kRgba8Uint:
|
||||
case ImageFormat::kRg32Uint:
|
||||
case ImageFormat::kRgba16Uint:
|
||||
case ImageFormat::kRgba32Uint: {
|
||||
case TexelFormat::kR8Uint:
|
||||
case TexelFormat::kR16Uint:
|
||||
case TexelFormat::kRg8Uint:
|
||||
case TexelFormat::kR32Uint:
|
||||
case TexelFormat::kRg16Uint:
|
||||
case TexelFormat::kRgba8Uint:
|
||||
case TexelFormat::kRg32Uint:
|
||||
case TexelFormat::kRgba16Uint:
|
||||
case TexelFormat::kRgba32Uint: {
|
||||
return builder.create<U32>();
|
||||
}
|
||||
|
||||
case ImageFormat::kR8Sint:
|
||||
case ImageFormat::kR16Sint:
|
||||
case ImageFormat::kRg8Sint:
|
||||
case ImageFormat::kR32Sint:
|
||||
case ImageFormat::kRg16Sint:
|
||||
case ImageFormat::kRgba8Sint:
|
||||
case ImageFormat::kRg32Sint:
|
||||
case ImageFormat::kRgba16Sint:
|
||||
case ImageFormat::kRgba32Sint: {
|
||||
case TexelFormat::kR8Sint:
|
||||
case TexelFormat::kR16Sint:
|
||||
case TexelFormat::kRg8Sint:
|
||||
case TexelFormat::kR32Sint:
|
||||
case TexelFormat::kRg16Sint:
|
||||
case TexelFormat::kRgba8Sint:
|
||||
case TexelFormat::kRg32Sint:
|
||||
case TexelFormat::kRgba16Sint:
|
||||
case TexelFormat::kRgba32Sint: {
|
||||
return builder.create<I32>();
|
||||
}
|
||||
|
||||
case ImageFormat::kR8Unorm:
|
||||
case ImageFormat::kRg8Unorm:
|
||||
case ImageFormat::kRgba8Unorm:
|
||||
case ImageFormat::kRgba8UnormSrgb:
|
||||
case ImageFormat::kBgra8Unorm:
|
||||
case ImageFormat::kBgra8UnormSrgb:
|
||||
case ImageFormat::kRgb10A2Unorm:
|
||||
case ImageFormat::kR8Snorm:
|
||||
case ImageFormat::kRg8Snorm:
|
||||
case ImageFormat::kRgba8Snorm:
|
||||
case ImageFormat::kR16Float:
|
||||
case ImageFormat::kR32Float:
|
||||
case ImageFormat::kRg16Float:
|
||||
case ImageFormat::kRg11B10Float:
|
||||
case ImageFormat::kRg32Float:
|
||||
case ImageFormat::kRgba16Float:
|
||||
case ImageFormat::kRgba32Float: {
|
||||
case TexelFormat::kR8Unorm:
|
||||
case TexelFormat::kRg8Unorm:
|
||||
case TexelFormat::kRgba8Unorm:
|
||||
case TexelFormat::kRgba8UnormSrgb:
|
||||
case TexelFormat::kBgra8Unorm:
|
||||
case TexelFormat::kBgra8UnormSrgb:
|
||||
case TexelFormat::kRgb10A2Unorm:
|
||||
case TexelFormat::kR8Snorm:
|
||||
case TexelFormat::kRg8Snorm:
|
||||
case TexelFormat::kRgba8Snorm:
|
||||
case TexelFormat::kR16Float:
|
||||
case TexelFormat::kR32Float:
|
||||
case TexelFormat::kRg16Float:
|
||||
case TexelFormat::kRg11B10Float:
|
||||
case TexelFormat::kRg32Float:
|
||||
case TexelFormat::kRgba16Float:
|
||||
case TexelFormat::kRgba32Float: {
|
||||
return builder.create<F32>();
|
||||
}
|
||||
|
||||
case ImageFormat::kNone:
|
||||
case TexelFormat::kNone:
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,10 +23,8 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
class Manager;
|
||||
|
||||
/// The image format in the storage texture
|
||||
enum class ImageFormat {
|
||||
/// The texel format in the storage texture
|
||||
enum class TexelFormat {
|
||||
kNone = -1,
|
||||
kR8Unorm,
|
||||
kR8Snorm,
|
||||
|
@ -66,9 +64,9 @@ enum class ImageFormat {
|
|||
};
|
||||
|
||||
/// @param out the std::ostream to write to
|
||||
/// @param format the ImageFormat
|
||||
/// @param format the TexelFormat
|
||||
/// @return the std::ostream so calls can be chained
|
||||
std::ostream& operator<<(std::ostream& out, ImageFormat format);
|
||||
std::ostream& operator<<(std::ostream& out, TexelFormat format);
|
||||
|
||||
/// A storage texture type.
|
||||
class StorageTexture : public Castable<StorageTexture, Texture> {
|
||||
|
@ -83,7 +81,7 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
|
|||
StorageTexture(ProgramID pid,
|
||||
const Source& src,
|
||||
TextureDimension dim,
|
||||
ImageFormat format,
|
||||
TexelFormat format,
|
||||
const Type* subtype,
|
||||
Access access_control);
|
||||
|
||||
|
@ -103,11 +101,11 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
|
|||
|
||||
/// @param format the storage texture image format
|
||||
/// @param builder the ProgramBuilder used to build the returned type
|
||||
/// @returns the storage texture subtype for the given ImageFormat
|
||||
static Type* SubtypeFor(ImageFormat format, ProgramBuilder& builder);
|
||||
/// @returns the storage texture subtype for the given TexelFormat
|
||||
static Type* SubtypeFor(TexelFormat format, ProgramBuilder& builder);
|
||||
|
||||
/// The image format
|
||||
const ImageFormat format;
|
||||
const TexelFormat format;
|
||||
|
||||
/// The storage subtype
|
||||
const Type* const type;
|
||||
|
|
|
@ -23,45 +23,45 @@ namespace {
|
|||
using AstStorageTextureTest = TestHelper;
|
||||
|
||||
TEST_F(AstStorageTextureTest, IsTexture) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, *this);
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
|
||||
Texture* ty =
|
||||
create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Float, subtype, Access::kRead);
|
||||
TexelFormat::kRgba32Float, subtype, Access::kRead);
|
||||
EXPECT_FALSE(ty->Is<DepthTexture>());
|
||||
EXPECT_FALSE(ty->Is<SampledTexture>());
|
||||
EXPECT_TRUE(ty->Is<StorageTexture>());
|
||||
}
|
||||
|
||||
TEST_F(AstStorageTextureTest, Dim) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, *this);
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
|
||||
auto* s =
|
||||
create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Float, subtype, Access::kRead);
|
||||
TexelFormat::kRgba32Float, subtype, Access::kRead);
|
||||
EXPECT_EQ(s->dim, TextureDimension::k2dArray);
|
||||
}
|
||||
|
||||
TEST_F(AstStorageTextureTest, Format) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, *this);
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
|
||||
auto* s =
|
||||
create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Float, subtype, Access::kRead);
|
||||
EXPECT_EQ(s->format, ImageFormat::kRgba32Float);
|
||||
TexelFormat::kRgba32Float, subtype, Access::kRead);
|
||||
EXPECT_EQ(s->format, TexelFormat::kRgba32Float);
|
||||
}
|
||||
|
||||
TEST_F(AstStorageTextureTest, FriendlyName) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, *this);
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
|
||||
auto* s =
|
||||
create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Float, subtype, Access::kRead);
|
||||
TexelFormat::kRgba32Float, subtype, Access::kRead);
|
||||
EXPECT_EQ(s->FriendlyName(Symbols()),
|
||||
"texture_storage_2d_array<rgba32float, read>");
|
||||
}
|
||||
|
||||
TEST_F(AstStorageTextureTest, F32) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, *this);
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
|
||||
Type* s =
|
||||
create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Float, subtype, Access::kRead);
|
||||
TexelFormat::kRgba32Float, subtype, Access::kRead);
|
||||
|
||||
ASSERT_TRUE(s->Is<Texture>());
|
||||
ASSERT_TRUE(s->Is<StorageTexture>());
|
||||
|
@ -69,9 +69,9 @@ TEST_F(AstStorageTextureTest, F32) {
|
|||
}
|
||||
|
||||
TEST_F(AstStorageTextureTest, U32) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRg32Uint, *this);
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRg32Uint, *this);
|
||||
Type* s =
|
||||
create<StorageTexture>(TextureDimension::k2dArray, ImageFormat::kRg32Uint,
|
||||
create<StorageTexture>(TextureDimension::k2dArray, TexelFormat::kRg32Uint,
|
||||
subtype, Access::kRead);
|
||||
|
||||
ASSERT_TRUE(s->Is<Texture>());
|
||||
|
@ -80,10 +80,10 @@ TEST_F(AstStorageTextureTest, U32) {
|
|||
}
|
||||
|
||||
TEST_F(AstStorageTextureTest, I32) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Sint, *this);
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Sint, *this);
|
||||
Type* s =
|
||||
create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Sint, subtype, Access::kRead);
|
||||
TexelFormat::kRgba32Sint, subtype, Access::kRead);
|
||||
|
||||
ASSERT_TRUE(s->Is<Texture>());
|
||||
ASSERT_TRUE(s->Is<StorageTexture>());
|
||||
|
|
|
@ -757,8 +757,8 @@ std::vector<ResourceBinding> Inspector::GetStorageTextureResourceBindingsImpl(
|
|||
|
||||
auto* base_type = texture_type->type();
|
||||
entry.sampled_kind = BaseTypeToSampledKind(base_type);
|
||||
entry.image_format = TypeImageFormatToResourceBindingImageFormat(
|
||||
texture_type->image_format());
|
||||
entry.image_format = TypeTexelFormatToResourceBindingTexelFormat(
|
||||
texture_type->texel_format());
|
||||
|
||||
result.push_back(entry);
|
||||
}
|
||||
|
|
|
@ -130,11 +130,11 @@ class InspectorGetDepthMultisampledTextureResourceBindingsTest
|
|||
|
||||
typedef std::tuple<ast::TextureDimension, ResourceBinding::TextureDimension>
|
||||
DimensionParams;
|
||||
typedef std::tuple<ast::ImageFormat,
|
||||
ResourceBinding::ImageFormat,
|
||||
typedef std::tuple<ast::TexelFormat,
|
||||
ResourceBinding::TexelFormat,
|
||||
ResourceBinding::SampledKind>
|
||||
ImageFormatParams;
|
||||
typedef std::tuple<DimensionParams, ImageFormatParams>
|
||||
TexelFormatParams;
|
||||
typedef std::tuple<DimensionParams, TexelFormatParams>
|
||||
GetStorageTextureTestParams;
|
||||
class InspectorGetStorageTextureResourceBindingsTestWithParam
|
||||
: public InspectorBuilder,
|
||||
|
@ -1292,7 +1292,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
|||
Func("depth_ms_func", {}, ty.void_(), {Ignore("depth_ms_texture")});
|
||||
|
||||
auto* st_type = MakeStorageTextureTypes(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Uint);
|
||||
ast::TexelFormat::kR32Uint);
|
||||
AddStorageTexture("st_var", st_type, 4, 0);
|
||||
MakeStorageTextureBodyFunction("st_func", "st_var", ty.vec2<i32>(), {});
|
||||
|
||||
|
@ -2379,15 +2379,15 @@ TEST_F(InspectorGetStorageTextureResourceBindingsTest, Empty) {
|
|||
|
||||
TEST_P(InspectorGetStorageTextureResourceBindingsTestWithParam, Simple) {
|
||||
DimensionParams dim_params;
|
||||
ImageFormatParams format_params;
|
||||
TexelFormatParams format_params;
|
||||
std::tie(dim_params, format_params) = GetParam();
|
||||
|
||||
ast::TextureDimension dim;
|
||||
ResourceBinding::TextureDimension expected_dim;
|
||||
std::tie(dim, expected_dim) = dim_params;
|
||||
|
||||
ast::ImageFormat format;
|
||||
ResourceBinding::ImageFormat expected_format;
|
||||
ast::TexelFormat format;
|
||||
ResourceBinding::TexelFormat expected_format;
|
||||
ResourceBinding::SampledKind expected_kind;
|
||||
std::tie(format, expected_format, expected_kind) = format_params;
|
||||
|
||||
|
@ -2445,53 +2445,53 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
std::make_tuple(ast::TextureDimension::k3d,
|
||||
ResourceBinding::TextureDimension::k3d)),
|
||||
testing::Values(
|
||||
std::make_tuple(ast::ImageFormat::kR32Float,
|
||||
ResourceBinding::ImageFormat::kR32Float,
|
||||
std::make_tuple(ast::TexelFormat::kR32Float,
|
||||
ResourceBinding::TexelFormat::kR32Float,
|
||||
ResourceBinding::SampledKind::kFloat),
|
||||
std::make_tuple(ast::ImageFormat::kR32Sint,
|
||||
ResourceBinding::ImageFormat::kR32Sint,
|
||||
std::make_tuple(ast::TexelFormat::kR32Sint,
|
||||
ResourceBinding::TexelFormat::kR32Sint,
|
||||
ResourceBinding::SampledKind::kSInt),
|
||||
std::make_tuple(ast::ImageFormat::kR32Uint,
|
||||
ResourceBinding::ImageFormat::kR32Uint,
|
||||
std::make_tuple(ast::TexelFormat::kR32Uint,
|
||||
ResourceBinding::TexelFormat::kR32Uint,
|
||||
ResourceBinding::SampledKind::kUInt),
|
||||
std::make_tuple(ast::ImageFormat::kRg32Float,
|
||||
ResourceBinding::ImageFormat::kRg32Float,
|
||||
std::make_tuple(ast::TexelFormat::kRg32Float,
|
||||
ResourceBinding::TexelFormat::kRg32Float,
|
||||
ResourceBinding::SampledKind::kFloat),
|
||||
std::make_tuple(ast::ImageFormat::kRg32Sint,
|
||||
ResourceBinding::ImageFormat::kRg32Sint,
|
||||
std::make_tuple(ast::TexelFormat::kRg32Sint,
|
||||
ResourceBinding::TexelFormat::kRg32Sint,
|
||||
ResourceBinding::SampledKind::kSInt),
|
||||
std::make_tuple(ast::ImageFormat::kRg32Uint,
|
||||
ResourceBinding::ImageFormat::kRg32Uint,
|
||||
std::make_tuple(ast::TexelFormat::kRg32Uint,
|
||||
ResourceBinding::TexelFormat::kRg32Uint,
|
||||
ResourceBinding::SampledKind::kUInt),
|
||||
std::make_tuple(ast::ImageFormat::kRgba16Float,
|
||||
ResourceBinding::ImageFormat::kRgba16Float,
|
||||
std::make_tuple(ast::TexelFormat::kRgba16Float,
|
||||
ResourceBinding::TexelFormat::kRgba16Float,
|
||||
ResourceBinding::SampledKind::kFloat),
|
||||
std::make_tuple(ast::ImageFormat::kRgba16Sint,
|
||||
ResourceBinding::ImageFormat::kRgba16Sint,
|
||||
std::make_tuple(ast::TexelFormat::kRgba16Sint,
|
||||
ResourceBinding::TexelFormat::kRgba16Sint,
|
||||
ResourceBinding::SampledKind::kSInt),
|
||||
std::make_tuple(ast::ImageFormat::kRgba16Uint,
|
||||
ResourceBinding::ImageFormat::kRgba16Uint,
|
||||
std::make_tuple(ast::TexelFormat::kRgba16Uint,
|
||||
ResourceBinding::TexelFormat::kRgba16Uint,
|
||||
ResourceBinding::SampledKind::kUInt),
|
||||
std::make_tuple(ast::ImageFormat::kRgba32Float,
|
||||
ResourceBinding::ImageFormat::kRgba32Float,
|
||||
std::make_tuple(ast::TexelFormat::kRgba32Float,
|
||||
ResourceBinding::TexelFormat::kRgba32Float,
|
||||
ResourceBinding::SampledKind::kFloat),
|
||||
std::make_tuple(ast::ImageFormat::kRgba32Sint,
|
||||
ResourceBinding::ImageFormat::kRgba32Sint,
|
||||
std::make_tuple(ast::TexelFormat::kRgba32Sint,
|
||||
ResourceBinding::TexelFormat::kRgba32Sint,
|
||||
ResourceBinding::SampledKind::kSInt),
|
||||
std::make_tuple(ast::ImageFormat::kRgba32Uint,
|
||||
ResourceBinding::ImageFormat::kRgba32Uint,
|
||||
std::make_tuple(ast::TexelFormat::kRgba32Uint,
|
||||
ResourceBinding::TexelFormat::kRgba32Uint,
|
||||
ResourceBinding::SampledKind::kUInt),
|
||||
std::make_tuple(ast::ImageFormat::kRgba8Sint,
|
||||
ResourceBinding::ImageFormat::kRgba8Sint,
|
||||
std::make_tuple(ast::TexelFormat::kRgba8Sint,
|
||||
ResourceBinding::TexelFormat::kRgba8Sint,
|
||||
ResourceBinding::SampledKind::kSInt),
|
||||
std::make_tuple(ast::ImageFormat::kRgba8Snorm,
|
||||
ResourceBinding::ImageFormat::kRgba8Snorm,
|
||||
std::make_tuple(ast::TexelFormat::kRgba8Snorm,
|
||||
ResourceBinding::TexelFormat::kRgba8Snorm,
|
||||
ResourceBinding::SampledKind::kFloat),
|
||||
std::make_tuple(ast::ImageFormat::kRgba8Uint,
|
||||
ResourceBinding::ImageFormat::kRgba8Uint,
|
||||
std::make_tuple(ast::TexelFormat::kRgba8Uint,
|
||||
ResourceBinding::TexelFormat::kRgba8Uint,
|
||||
ResourceBinding::SampledKind::kUInt),
|
||||
std::make_tuple(ast::ImageFormat::kRgba8Unorm,
|
||||
ResourceBinding::ImageFormat::kRgba8Unorm,
|
||||
std::make_tuple(ast::TexelFormat::kRgba8Unorm,
|
||||
ResourceBinding::TexelFormat::kRgba8Unorm,
|
||||
ResourceBinding::SampledKind::kFloat))));
|
||||
|
||||
TEST_P(InspectorGetDepthTextureResourceBindingsTestWithParam,
|
||||
|
|
|
@ -71,83 +71,83 @@ ResourceBinding::SampledKind BaseTypeToSampledKind(const sem::Type* base_type) {
|
|||
}
|
||||
}
|
||||
|
||||
ResourceBinding::ImageFormat TypeImageFormatToResourceBindingImageFormat(
|
||||
const ast::ImageFormat& image_format) {
|
||||
ResourceBinding::TexelFormat TypeTexelFormatToResourceBindingTexelFormat(
|
||||
const ast::TexelFormat& image_format) {
|
||||
switch (image_format) {
|
||||
case ast::ImageFormat::kR8Unorm:
|
||||
return ResourceBinding::ImageFormat::kR8Unorm;
|
||||
case ast::ImageFormat::kR8Snorm:
|
||||
return ResourceBinding::ImageFormat::kR8Snorm;
|
||||
case ast::ImageFormat::kR8Uint:
|
||||
return ResourceBinding::ImageFormat::kR8Uint;
|
||||
case ast::ImageFormat::kR8Sint:
|
||||
return ResourceBinding::ImageFormat::kR8Sint;
|
||||
case ast::ImageFormat::kR16Uint:
|
||||
return ResourceBinding::ImageFormat::kR16Uint;
|
||||
case ast::ImageFormat::kR16Sint:
|
||||
return ResourceBinding::ImageFormat::kR16Sint;
|
||||
case ast::ImageFormat::kR16Float:
|
||||
return ResourceBinding::ImageFormat::kR16Float;
|
||||
case ast::ImageFormat::kRg8Unorm:
|
||||
return ResourceBinding::ImageFormat::kRg8Unorm;
|
||||
case ast::ImageFormat::kRg8Snorm:
|
||||
return ResourceBinding::ImageFormat::kRg8Snorm;
|
||||
case ast::ImageFormat::kRg8Uint:
|
||||
return ResourceBinding::ImageFormat::kRg8Uint;
|
||||
case ast::ImageFormat::kRg8Sint:
|
||||
return ResourceBinding::ImageFormat::kRg8Sint;
|
||||
case ast::ImageFormat::kR32Uint:
|
||||
return ResourceBinding::ImageFormat::kR32Uint;
|
||||
case ast::ImageFormat::kR32Sint:
|
||||
return ResourceBinding::ImageFormat::kR32Sint;
|
||||
case ast::ImageFormat::kR32Float:
|
||||
return ResourceBinding::ImageFormat::kR32Float;
|
||||
case ast::ImageFormat::kRg16Uint:
|
||||
return ResourceBinding::ImageFormat::kRg16Uint;
|
||||
case ast::ImageFormat::kRg16Sint:
|
||||
return ResourceBinding::ImageFormat::kRg16Sint;
|
||||
case ast::ImageFormat::kRg16Float:
|
||||
return ResourceBinding::ImageFormat::kRg16Float;
|
||||
case ast::ImageFormat::kRgba8Unorm:
|
||||
return ResourceBinding::ImageFormat::kRgba8Unorm;
|
||||
case ast::ImageFormat::kRgba8UnormSrgb:
|
||||
return ResourceBinding::ImageFormat::kRgba8UnormSrgb;
|
||||
case ast::ImageFormat::kRgba8Snorm:
|
||||
return ResourceBinding::ImageFormat::kRgba8Snorm;
|
||||
case ast::ImageFormat::kRgba8Uint:
|
||||
return ResourceBinding::ImageFormat::kRgba8Uint;
|
||||
case ast::ImageFormat::kRgba8Sint:
|
||||
return ResourceBinding::ImageFormat::kRgba8Sint;
|
||||
case ast::ImageFormat::kBgra8Unorm:
|
||||
return ResourceBinding::ImageFormat::kBgra8Unorm;
|
||||
case ast::ImageFormat::kBgra8UnormSrgb:
|
||||
return ResourceBinding::ImageFormat::kBgra8UnormSrgb;
|
||||
case ast::ImageFormat::kRgb10A2Unorm:
|
||||
return ResourceBinding::ImageFormat::kRgb10A2Unorm;
|
||||
case ast::ImageFormat::kRg11B10Float:
|
||||
return ResourceBinding::ImageFormat::kRg11B10Float;
|
||||
case ast::ImageFormat::kRg32Uint:
|
||||
return ResourceBinding::ImageFormat::kRg32Uint;
|
||||
case ast::ImageFormat::kRg32Sint:
|
||||
return ResourceBinding::ImageFormat::kRg32Sint;
|
||||
case ast::ImageFormat::kRg32Float:
|
||||
return ResourceBinding::ImageFormat::kRg32Float;
|
||||
case ast::ImageFormat::kRgba16Uint:
|
||||
return ResourceBinding::ImageFormat::kRgba16Uint;
|
||||
case ast::ImageFormat::kRgba16Sint:
|
||||
return ResourceBinding::ImageFormat::kRgba16Sint;
|
||||
case ast::ImageFormat::kRgba16Float:
|
||||
return ResourceBinding::ImageFormat::kRgba16Float;
|
||||
case ast::ImageFormat::kRgba32Uint:
|
||||
return ResourceBinding::ImageFormat::kRgba32Uint;
|
||||
case ast::ImageFormat::kRgba32Sint:
|
||||
return ResourceBinding::ImageFormat::kRgba32Sint;
|
||||
case ast::ImageFormat::kRgba32Float:
|
||||
return ResourceBinding::ImageFormat::kRgba32Float;
|
||||
case ast::ImageFormat::kNone:
|
||||
return ResourceBinding::ImageFormat::kNone;
|
||||
case ast::TexelFormat::kR8Unorm:
|
||||
return ResourceBinding::TexelFormat::kR8Unorm;
|
||||
case ast::TexelFormat::kR8Snorm:
|
||||
return ResourceBinding::TexelFormat::kR8Snorm;
|
||||
case ast::TexelFormat::kR8Uint:
|
||||
return ResourceBinding::TexelFormat::kR8Uint;
|
||||
case ast::TexelFormat::kR8Sint:
|
||||
return ResourceBinding::TexelFormat::kR8Sint;
|
||||
case ast::TexelFormat::kR16Uint:
|
||||
return ResourceBinding::TexelFormat::kR16Uint;
|
||||
case ast::TexelFormat::kR16Sint:
|
||||
return ResourceBinding::TexelFormat::kR16Sint;
|
||||
case ast::TexelFormat::kR16Float:
|
||||
return ResourceBinding::TexelFormat::kR16Float;
|
||||
case ast::TexelFormat::kRg8Unorm:
|
||||
return ResourceBinding::TexelFormat::kRg8Unorm;
|
||||
case ast::TexelFormat::kRg8Snorm:
|
||||
return ResourceBinding::TexelFormat::kRg8Snorm;
|
||||
case ast::TexelFormat::kRg8Uint:
|
||||
return ResourceBinding::TexelFormat::kRg8Uint;
|
||||
case ast::TexelFormat::kRg8Sint:
|
||||
return ResourceBinding::TexelFormat::kRg8Sint;
|
||||
case ast::TexelFormat::kR32Uint:
|
||||
return ResourceBinding::TexelFormat::kR32Uint;
|
||||
case ast::TexelFormat::kR32Sint:
|
||||
return ResourceBinding::TexelFormat::kR32Sint;
|
||||
case ast::TexelFormat::kR32Float:
|
||||
return ResourceBinding::TexelFormat::kR32Float;
|
||||
case ast::TexelFormat::kRg16Uint:
|
||||
return ResourceBinding::TexelFormat::kRg16Uint;
|
||||
case ast::TexelFormat::kRg16Sint:
|
||||
return ResourceBinding::TexelFormat::kRg16Sint;
|
||||
case ast::TexelFormat::kRg16Float:
|
||||
return ResourceBinding::TexelFormat::kRg16Float;
|
||||
case ast::TexelFormat::kRgba8Unorm:
|
||||
return ResourceBinding::TexelFormat::kRgba8Unorm;
|
||||
case ast::TexelFormat::kRgba8UnormSrgb:
|
||||
return ResourceBinding::TexelFormat::kRgba8UnormSrgb;
|
||||
case ast::TexelFormat::kRgba8Snorm:
|
||||
return ResourceBinding::TexelFormat::kRgba8Snorm;
|
||||
case ast::TexelFormat::kRgba8Uint:
|
||||
return ResourceBinding::TexelFormat::kRgba8Uint;
|
||||
case ast::TexelFormat::kRgba8Sint:
|
||||
return ResourceBinding::TexelFormat::kRgba8Sint;
|
||||
case ast::TexelFormat::kBgra8Unorm:
|
||||
return ResourceBinding::TexelFormat::kBgra8Unorm;
|
||||
case ast::TexelFormat::kBgra8UnormSrgb:
|
||||
return ResourceBinding::TexelFormat::kBgra8UnormSrgb;
|
||||
case ast::TexelFormat::kRgb10A2Unorm:
|
||||
return ResourceBinding::TexelFormat::kRgb10A2Unorm;
|
||||
case ast::TexelFormat::kRg11B10Float:
|
||||
return ResourceBinding::TexelFormat::kRg11B10Float;
|
||||
case ast::TexelFormat::kRg32Uint:
|
||||
return ResourceBinding::TexelFormat::kRg32Uint;
|
||||
case ast::TexelFormat::kRg32Sint:
|
||||
return ResourceBinding::TexelFormat::kRg32Sint;
|
||||
case ast::TexelFormat::kRg32Float:
|
||||
return ResourceBinding::TexelFormat::kRg32Float;
|
||||
case ast::TexelFormat::kRgba16Uint:
|
||||
return ResourceBinding::TexelFormat::kRgba16Uint;
|
||||
case ast::TexelFormat::kRgba16Sint:
|
||||
return ResourceBinding::TexelFormat::kRgba16Sint;
|
||||
case ast::TexelFormat::kRgba16Float:
|
||||
return ResourceBinding::TexelFormat::kRgba16Float;
|
||||
case ast::TexelFormat::kRgba32Uint:
|
||||
return ResourceBinding::TexelFormat::kRgba32Uint;
|
||||
case ast::TexelFormat::kRgba32Sint:
|
||||
return ResourceBinding::TexelFormat::kRgba32Sint;
|
||||
case ast::TexelFormat::kRgba32Float:
|
||||
return ResourceBinding::TexelFormat::kRgba32Float;
|
||||
case ast::TexelFormat::kNone:
|
||||
return ResourceBinding::TexelFormat::kNone;
|
||||
}
|
||||
return ResourceBinding::ImageFormat::kNone;
|
||||
return ResourceBinding::TexelFormat::kNone;
|
||||
}
|
||||
|
||||
} // namespace inspector
|
||||
|
|
|
@ -47,8 +47,8 @@ struct ResourceBinding {
|
|||
/// in SPIR-V OpTypeImage.
|
||||
enum class SampledKind { kUnknown = -1, kFloat, kUInt, kSInt };
|
||||
|
||||
/// Enumerator of texture image formats
|
||||
enum class ImageFormat {
|
||||
/// Enumerator of texel image formats
|
||||
enum class TexelFormat {
|
||||
kNone = -1,
|
||||
kR8Unorm,
|
||||
kR8Snorm,
|
||||
|
@ -87,6 +87,9 @@ struct ResourceBinding {
|
|||
kRgba32Float,
|
||||
};
|
||||
|
||||
/// Renamed field [DEPRECATED]
|
||||
using ImageFormat = TexelFormat;
|
||||
|
||||
/// kXXX maps to entries returned by GetXXXResourceBindings call.
|
||||
enum class ResourceType {
|
||||
kUniformBuffer,
|
||||
|
@ -118,7 +121,7 @@ struct ResourceBinding {
|
|||
/// Kind of data being sampled, if defined.
|
||||
SampledKind sampled_kind;
|
||||
/// Format of data, if defined.
|
||||
ImageFormat image_format;
|
||||
TexelFormat image_format;
|
||||
};
|
||||
|
||||
/// Convert from internal ast::TextureDimension to public
|
||||
|
@ -134,12 +137,12 @@ TypeTextureDimensionToResourceBindingTextureDimension(
|
|||
/// @returns the publicly visible equivalent
|
||||
ResourceBinding::SampledKind BaseTypeToSampledKind(const sem::Type* base_type);
|
||||
|
||||
/// Convert from internal ast::ImageFormat to public
|
||||
/// ResourceBinding::ImageFormat
|
||||
/// Convert from internal ast::TexelFormat to public
|
||||
/// ResourceBinding::TexelFormat
|
||||
/// @param image_format internal value to convert from
|
||||
/// @returns the publicly visible equivalent
|
||||
ResourceBinding::ImageFormat TypeImageFormatToResourceBindingImageFormat(
|
||||
const ast::ImageFormat& image_format);
|
||||
ResourceBinding::TexelFormat TypeTexelFormatToResourceBindingTexelFormat(
|
||||
const ast::TexelFormat& image_format);
|
||||
|
||||
} // namespace inspector
|
||||
} // namespace tint
|
||||
|
|
|
@ -321,7 +321,7 @@ const ast::Type* InspectorBuilder::GetCoordsType(ast::TextureDimension dim,
|
|||
|
||||
const ast::Type* InspectorBuilder::MakeStorageTextureTypes(
|
||||
ast::TextureDimension dim,
|
||||
ast::ImageFormat format) {
|
||||
ast::TexelFormat format) {
|
||||
return ty.storage_texture(dim, format, ast::Access::kWrite);
|
||||
}
|
||||
|
||||
|
|
|
@ -332,10 +332,10 @@ class InspectorBuilder : public ProgramBuilder {
|
|||
|
||||
/// Generates appropriate types for a Read-Only StorageTexture
|
||||
/// @param dim the texture dimension of the storage texture
|
||||
/// @param format the image format of the storage texture
|
||||
/// @param format the texel format of the storage texture
|
||||
/// @returns the storage texture type
|
||||
const ast::Type* MakeStorageTextureTypes(ast::TextureDimension dim,
|
||||
ast::ImageFormat format);
|
||||
ast::TexelFormat format);
|
||||
|
||||
/// Adds a storage texture variable to the program
|
||||
/// @param name the name of the variable
|
||||
|
|
|
@ -290,7 +290,7 @@ class OpenNumberMatcher : public NumberMatcher {
|
|||
// TODO(bclayton): See if we can move more of this hand-rolled code to the
|
||||
// template
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
using TexelFormat = ast::ImageFormat;
|
||||
using TexelFormat = ast::TexelFormat;
|
||||
using Access = ast::Access;
|
||||
using StorageClass = ast::StorageClass;
|
||||
using ParameterUsage = sem::ParameterUsage;
|
||||
|
@ -619,7 +619,7 @@ bool match_texture_storage(const sem::Type* ty,
|
|||
}
|
||||
if (auto* v = ty->As<sem::StorageTexture>()) {
|
||||
if (v->dim() == dim) {
|
||||
F = Number(static_cast<uint32_t>(v->image_format()));
|
||||
F = Number(static_cast<uint32_t>(v->texel_format()));
|
||||
A = Number(static_cast<uint32_t>(v->access()));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -394,9 +394,9 @@ TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
|
|||
auto* vec2_i32 = create<sem::Vector>(i32, 2);
|
||||
auto* vec4_f32 = create<sem::Vector>(f32, 4);
|
||||
auto* subtype =
|
||||
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kR32Float, Types());
|
||||
sem::StorageTexture::SubtypeFor(ast::TexelFormat::kR32Float, Types());
|
||||
auto* tex = create<sem::StorageTexture>(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Float,
|
||||
ast::TexelFormat::kR32Float,
|
||||
ast::Access::kWrite, subtype);
|
||||
|
||||
auto* result = table->Lookup(IntrinsicType::kTextureStore,
|
||||
|
|
|
@ -901,11 +901,11 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param dims the dimensionality of the texture
|
||||
/// @param format the image format of the texture
|
||||
/// @param format the texel format of the texture
|
||||
/// @param access the access control of the texture
|
||||
/// @returns the storage texture
|
||||
const ast::StorageTexture* storage_texture(ast::TextureDimension dims,
|
||||
ast::ImageFormat format,
|
||||
ast::TexelFormat format,
|
||||
ast::Access access) const {
|
||||
auto* subtype = ast::StorageTexture::SubtypeFor(format, *builder);
|
||||
return builder->create<ast::StorageTexture>(dims, format, subtype,
|
||||
|
@ -914,12 +914,12 @@ class ProgramBuilder {
|
|||
|
||||
/// @param source the Source of the node
|
||||
/// @param dims the dimensionality of the texture
|
||||
/// @param format the image format of the texture
|
||||
/// @param format the texel format of the texture
|
||||
/// @param access the access control of the texture
|
||||
/// @returns the storage texture
|
||||
const ast::StorageTexture* storage_texture(const Source& source,
|
||||
ast::TextureDimension dims,
|
||||
ast::ImageFormat format,
|
||||
ast::TexelFormat format,
|
||||
ast::Access access) const {
|
||||
auto* subtype = ast::StorageTexture::SubtypeFor(format, *builder);
|
||||
return builder->create<ast::StorageTexture>(source, dims, format, subtype,
|
||||
|
|
|
@ -130,53 +130,53 @@ ast::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
|
|||
return ast::TextureDimension::kNone;
|
||||
}
|
||||
|
||||
ast::ImageFormat EnumConverter::ToImageFormat(SpvImageFormat fmt) {
|
||||
ast::TexelFormat EnumConverter::ToTexelFormat(SpvImageFormat fmt) {
|
||||
switch (fmt) {
|
||||
case SpvImageFormatUnknown:
|
||||
return ast::ImageFormat::kNone;
|
||||
return ast::TexelFormat::kNone;
|
||||
|
||||
// 8 bit channels
|
||||
case SpvImageFormatRgba8:
|
||||
return ast::ImageFormat::kRgba8Unorm;
|
||||
return ast::TexelFormat::kRgba8Unorm;
|
||||
case SpvImageFormatRgba8Snorm:
|
||||
return ast::ImageFormat::kRgba8Snorm;
|
||||
return ast::TexelFormat::kRgba8Snorm;
|
||||
case SpvImageFormatRgba8ui:
|
||||
return ast::ImageFormat::kRgba8Uint;
|
||||
return ast::TexelFormat::kRgba8Uint;
|
||||
case SpvImageFormatRgba8i:
|
||||
return ast::ImageFormat::kRgba8Sint;
|
||||
return ast::TexelFormat::kRgba8Sint;
|
||||
|
||||
// 16 bit channels
|
||||
case SpvImageFormatRgba16ui:
|
||||
return ast::ImageFormat::kRgba16Uint;
|
||||
return ast::TexelFormat::kRgba16Uint;
|
||||
case SpvImageFormatRgba16i:
|
||||
return ast::ImageFormat::kRgba16Sint;
|
||||
return ast::TexelFormat::kRgba16Sint;
|
||||
case SpvImageFormatRgba16f:
|
||||
return ast::ImageFormat::kRgba16Float;
|
||||
return ast::TexelFormat::kRgba16Float;
|
||||
|
||||
// 32 bit channels
|
||||
case SpvImageFormatR32ui:
|
||||
return ast::ImageFormat::kR32Uint;
|
||||
return ast::TexelFormat::kR32Uint;
|
||||
case SpvImageFormatR32i:
|
||||
return ast::ImageFormat::kR32Sint;
|
||||
return ast::TexelFormat::kR32Sint;
|
||||
case SpvImageFormatR32f:
|
||||
return ast::ImageFormat::kR32Float;
|
||||
return ast::TexelFormat::kR32Float;
|
||||
case SpvImageFormatRg32ui:
|
||||
return ast::ImageFormat::kRg32Uint;
|
||||
return ast::TexelFormat::kRg32Uint;
|
||||
case SpvImageFormatRg32i:
|
||||
return ast::ImageFormat::kRg32Sint;
|
||||
return ast::TexelFormat::kRg32Sint;
|
||||
case SpvImageFormatRg32f:
|
||||
return ast::ImageFormat::kRg32Float;
|
||||
return ast::TexelFormat::kRg32Float;
|
||||
case SpvImageFormatRgba32ui:
|
||||
return ast::ImageFormat::kRgba32Uint;
|
||||
return ast::TexelFormat::kRgba32Uint;
|
||||
case SpvImageFormatRgba32i:
|
||||
return ast::ImageFormat::kRgba32Sint;
|
||||
return ast::TexelFormat::kRgba32Sint;
|
||||
case SpvImageFormatRgba32f:
|
||||
return ast::ImageFormat::kRgba32Float;
|
||||
return ast::TexelFormat::kRgba32Float;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Fail() << "invalid image format: " << int(fmt);
|
||||
return ast::ImageFormat::kNone;
|
||||
return ast::TexelFormat::kNone;
|
||||
}
|
||||
|
||||
} // namespace spirv
|
||||
|
|
|
@ -60,11 +60,11 @@ class EnumConverter {
|
|||
/// @returns a Tint AST texture dimension
|
||||
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 TexelFormat
|
||||
/// On failure, logs an error and returns kNone
|
||||
/// @param fmt the SPIR-V format
|
||||
/// @returns a Tint AST format
|
||||
ast::ImageFormat ToImageFormat(SpvImageFormat fmt);
|
||||
ast::TexelFormat ToTexelFormat(SpvImageFormat fmt);
|
||||
|
||||
private:
|
||||
/// Registers a failure and returns a stream for log diagnostics.
|
||||
|
|
|
@ -312,21 +312,21 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
DimCase{SpvDimBuffer, true, false, ast::TextureDimension::kNone},
|
||||
DimCase{SpvDimSubpassData, true, false, ast::TextureDimension::kNone}));
|
||||
|
||||
// ImageFormat
|
||||
// TexelFormat
|
||||
|
||||
struct ImageFormatCase {
|
||||
struct TexelFormatCase {
|
||||
SpvImageFormat format;
|
||||
bool expect_success;
|
||||
ast::ImageFormat expected;
|
||||
ast::TexelFormat expected;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, ImageFormatCase ifc) {
|
||||
out << "ImageFormatCase{ SpvImageFormat:" << int(ifc.format)
|
||||
inline std::ostream& operator<<(std::ostream& out, TexelFormatCase ifc) {
|
||||
out << "TexelFormatCase{ SpvImageFormat:" << int(ifc.format)
|
||||
<< " expect_success?:" << int(ifc.expect_success)
|
||||
<< " expected:" << int(ifc.expected) << "}";
|
||||
return out;
|
||||
}
|
||||
|
||||
class SpvImageFormatTest : public testing::TestWithParam<ImageFormatCase> {
|
||||
class SpvImageFormatTest : public testing::TestWithParam<TexelFormatCase> {
|
||||
public:
|
||||
SpvImageFormatTest()
|
||||
: success_(true),
|
||||
|
@ -345,7 +345,7 @@ class SpvImageFormatTest : public testing::TestWithParam<ImageFormatCase> {
|
|||
TEST_P(SpvImageFormatTest, Samples) {
|
||||
const auto params = GetParam();
|
||||
|
||||
const auto result = converter_.ToImageFormat(params.format);
|
||||
const auto result = converter_.ToTexelFormat(params.format);
|
||||
EXPECT_EQ(success_, params.expect_success) << params;
|
||||
if (params.expect_success) {
|
||||
EXPECT_EQ(result, params.expected);
|
||||
|
@ -361,68 +361,68 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
SpvImageFormatTest,
|
||||
testing::Values(
|
||||
// Unknown. This is used for sampled images.
|
||||
ImageFormatCase{SpvImageFormatUnknown, true, ast::ImageFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatUnknown, true, ast::TexelFormat::kNone},
|
||||
// 8 bit channels
|
||||
ImageFormatCase{SpvImageFormatRgba8, true,
|
||||
ast::ImageFormat::kRgba8Unorm},
|
||||
ImageFormatCase{SpvImageFormatRgba8Snorm, true,
|
||||
ast::ImageFormat::kRgba8Snorm},
|
||||
ImageFormatCase{SpvImageFormatRgba8ui, true,
|
||||
ast::ImageFormat::kRgba8Uint},
|
||||
ImageFormatCase{SpvImageFormatRgba8i, true,
|
||||
ast::ImageFormat::kRgba8Sint},
|
||||
TexelFormatCase{SpvImageFormatRgba8, true,
|
||||
ast::TexelFormat::kRgba8Unorm},
|
||||
TexelFormatCase{SpvImageFormatRgba8Snorm, true,
|
||||
ast::TexelFormat::kRgba8Snorm},
|
||||
TexelFormatCase{SpvImageFormatRgba8ui, true,
|
||||
ast::TexelFormat::kRgba8Uint},
|
||||
TexelFormatCase{SpvImageFormatRgba8i, true,
|
||||
ast::TexelFormat::kRgba8Sint},
|
||||
// 16 bit channels
|
||||
ImageFormatCase{SpvImageFormatRgba16ui, true,
|
||||
ast::ImageFormat::kRgba16Uint},
|
||||
ImageFormatCase{SpvImageFormatRgba16i, true,
|
||||
ast::ImageFormat::kRgba16Sint},
|
||||
ImageFormatCase{SpvImageFormatRgba16f, true,
|
||||
ast::ImageFormat::kRgba16Float},
|
||||
TexelFormatCase{SpvImageFormatRgba16ui, true,
|
||||
ast::TexelFormat::kRgba16Uint},
|
||||
TexelFormatCase{SpvImageFormatRgba16i, true,
|
||||
ast::TexelFormat::kRgba16Sint},
|
||||
TexelFormatCase{SpvImageFormatRgba16f, true,
|
||||
ast::TexelFormat::kRgba16Float},
|
||||
// 32 bit channels
|
||||
// ... 1 channel
|
||||
ImageFormatCase{SpvImageFormatR32ui, true, ast::ImageFormat::kR32Uint},
|
||||
ImageFormatCase{SpvImageFormatR32i, true, ast::ImageFormat::kR32Sint},
|
||||
ImageFormatCase{SpvImageFormatR32f, true, ast::ImageFormat::kR32Float},
|
||||
TexelFormatCase{SpvImageFormatR32ui, true, ast::TexelFormat::kR32Uint},
|
||||
TexelFormatCase{SpvImageFormatR32i, true, ast::TexelFormat::kR32Sint},
|
||||
TexelFormatCase{SpvImageFormatR32f, true, ast::TexelFormat::kR32Float},
|
||||
// ... 2 channels
|
||||
ImageFormatCase{SpvImageFormatRg32ui, true,
|
||||
ast::ImageFormat::kRg32Uint},
|
||||
ImageFormatCase{SpvImageFormatRg32i, true, ast::ImageFormat::kRg32Sint},
|
||||
ImageFormatCase{SpvImageFormatRg32f, true,
|
||||
ast::ImageFormat::kRg32Float},
|
||||
TexelFormatCase{SpvImageFormatRg32ui, true,
|
||||
ast::TexelFormat::kRg32Uint},
|
||||
TexelFormatCase{SpvImageFormatRg32i, true, ast::TexelFormat::kRg32Sint},
|
||||
TexelFormatCase{SpvImageFormatRg32f, true,
|
||||
ast::TexelFormat::kRg32Float},
|
||||
// ... 4 channels
|
||||
ImageFormatCase{SpvImageFormatRgba32ui, true,
|
||||
ast::ImageFormat::kRgba32Uint},
|
||||
ImageFormatCase{SpvImageFormatRgba32i, true,
|
||||
ast::ImageFormat::kRgba32Sint},
|
||||
ImageFormatCase{SpvImageFormatRgba32f, true,
|
||||
ast::ImageFormat::kRgba32Float}));
|
||||
TexelFormatCase{SpvImageFormatRgba32ui, true,
|
||||
ast::TexelFormat::kRgba32Uint},
|
||||
TexelFormatCase{SpvImageFormatRgba32i, true,
|
||||
ast::TexelFormat::kRgba32Sint},
|
||||
TexelFormatCase{SpvImageFormatRgba32f, true,
|
||||
ast::TexelFormat::kRgba32Float}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
EnumConverterBad,
|
||||
SpvImageFormatTest,
|
||||
testing::Values(
|
||||
// Scanning in order from the SPIR-V spec.
|
||||
ImageFormatCase{SpvImageFormatRg16f, false, ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR11fG11fB10f, false,
|
||||
ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR16f, false, ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRgb10A2, false, ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg16, false, ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg8, false, ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR16, false, ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR8, false, ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRgba16Snorm, false,
|
||||
ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg16Snorm, false,
|
||||
ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg8Snorm, false, ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg16i, false, ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg8i, false, ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR8i, false, ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRgb10a2ui, false,
|
||||
ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg16ui, false, ast::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg8ui, false, ast::ImageFormat::kNone}));
|
||||
TexelFormatCase{SpvImageFormatRg16f, false, ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatR11fG11fB10f, false,
|
||||
ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatR16f, false, ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatRgb10A2, false, ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatRg16, false, ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatRg8, false, ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatR16, false, ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatR8, false, ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatRgba16Snorm, false,
|
||||
ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatRg16Snorm, false,
|
||||
ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatRg8Snorm, false, ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatRg16i, false, ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatRg8i, false, ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatR8i, false, ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatRgb10a2ui, false,
|
||||
ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatRg16ui, false, ast::TexelFormat::kNone},
|
||||
TexelFormatCase{SpvImageFormatRg8ui, false, ast::TexelFormat::kNone}));
|
||||
|
||||
} // namespace
|
||||
} // namespace spirv
|
||||
|
|
|
@ -2505,8 +2505,8 @@ const Pointer* ParserImpl::GetTypeForHandleVar(
|
|||
}
|
||||
} else {
|
||||
const auto access = ast::Access::kWrite;
|
||||
const auto format = enum_converter_.ToImageFormat(image_type->format());
|
||||
if (format == ast::ImageFormat::kNone) {
|
||||
const auto format = enum_converter_.ToTexelFormat(image_type->format());
|
||||
if (format == ast::TexelFormat::kNone) {
|
||||
return nullptr;
|
||||
}
|
||||
ast_store_type = ty_.StorageTexture(dim, format, access);
|
||||
|
@ -2526,47 +2526,47 @@ const Pointer* ParserImpl::GetTypeForHandleVar(
|
|||
return result;
|
||||
}
|
||||
|
||||
const Type* ParserImpl::GetComponentTypeForFormat(ast::ImageFormat format) {
|
||||
const Type* ParserImpl::GetComponentTypeForFormat(ast::TexelFormat format) {
|
||||
switch (format) {
|
||||
case ast::ImageFormat::kR8Uint:
|
||||
case ast::ImageFormat::kR16Uint:
|
||||
case ast::ImageFormat::kRg8Uint:
|
||||
case ast::ImageFormat::kR32Uint:
|
||||
case ast::ImageFormat::kRg16Uint:
|
||||
case ast::ImageFormat::kRgba8Uint:
|
||||
case ast::ImageFormat::kRg32Uint:
|
||||
case ast::ImageFormat::kRgba16Uint:
|
||||
case ast::ImageFormat::kRgba32Uint:
|
||||
case ast::TexelFormat::kR8Uint:
|
||||
case ast::TexelFormat::kR16Uint:
|
||||
case ast::TexelFormat::kRg8Uint:
|
||||
case ast::TexelFormat::kR32Uint:
|
||||
case ast::TexelFormat::kRg16Uint:
|
||||
case ast::TexelFormat::kRgba8Uint:
|
||||
case ast::TexelFormat::kRg32Uint:
|
||||
case ast::TexelFormat::kRgba16Uint:
|
||||
case ast::TexelFormat::kRgba32Uint:
|
||||
return ty_.U32();
|
||||
|
||||
case ast::ImageFormat::kR8Sint:
|
||||
case ast::ImageFormat::kR16Sint:
|
||||
case ast::ImageFormat::kRg8Sint:
|
||||
case ast::ImageFormat::kR32Sint:
|
||||
case ast::ImageFormat::kRg16Sint:
|
||||
case ast::ImageFormat::kRgba8Sint:
|
||||
case ast::ImageFormat::kRg32Sint:
|
||||
case ast::ImageFormat::kRgba16Sint:
|
||||
case ast::ImageFormat::kRgba32Sint:
|
||||
case ast::TexelFormat::kR8Sint:
|
||||
case ast::TexelFormat::kR16Sint:
|
||||
case ast::TexelFormat::kRg8Sint:
|
||||
case ast::TexelFormat::kR32Sint:
|
||||
case ast::TexelFormat::kRg16Sint:
|
||||
case ast::TexelFormat::kRgba8Sint:
|
||||
case ast::TexelFormat::kRg32Sint:
|
||||
case ast::TexelFormat::kRgba16Sint:
|
||||
case ast::TexelFormat::kRgba32Sint:
|
||||
return ty_.I32();
|
||||
|
||||
case ast::ImageFormat::kR8Unorm:
|
||||
case ast::ImageFormat::kRg8Unorm:
|
||||
case ast::ImageFormat::kRgba8Unorm:
|
||||
case ast::ImageFormat::kRgba8UnormSrgb:
|
||||
case ast::ImageFormat::kBgra8Unorm:
|
||||
case ast::ImageFormat::kBgra8UnormSrgb:
|
||||
case ast::ImageFormat::kRgb10A2Unorm:
|
||||
case ast::ImageFormat::kR8Snorm:
|
||||
case ast::ImageFormat::kRg8Snorm:
|
||||
case ast::ImageFormat::kRgba8Snorm:
|
||||
case ast::ImageFormat::kR16Float:
|
||||
case ast::ImageFormat::kR32Float:
|
||||
case ast::ImageFormat::kRg16Float:
|
||||
case ast::ImageFormat::kRg11B10Float:
|
||||
case ast::ImageFormat::kRg32Float:
|
||||
case ast::ImageFormat::kRgba16Float:
|
||||
case ast::ImageFormat::kRgba32Float:
|
||||
case ast::TexelFormat::kR8Unorm:
|
||||
case ast::TexelFormat::kRg8Unorm:
|
||||
case ast::TexelFormat::kRgba8Unorm:
|
||||
case ast::TexelFormat::kRgba8UnormSrgb:
|
||||
case ast::TexelFormat::kBgra8Unorm:
|
||||
case ast::TexelFormat::kBgra8UnormSrgb:
|
||||
case ast::TexelFormat::kRgb10A2Unorm:
|
||||
case ast::TexelFormat::kR8Snorm:
|
||||
case ast::TexelFormat::kRg8Snorm:
|
||||
case ast::TexelFormat::kRgba8Snorm:
|
||||
case ast::TexelFormat::kR16Float:
|
||||
case ast::TexelFormat::kR32Float:
|
||||
case ast::TexelFormat::kRg16Float:
|
||||
case ast::TexelFormat::kRg11B10Float:
|
||||
case ast::TexelFormat::kRg32Float:
|
||||
case ast::TexelFormat::kRgba16Float:
|
||||
case ast::TexelFormat::kRgba32Float:
|
||||
return ty_.F32();
|
||||
default:
|
||||
break;
|
||||
|
@ -2575,49 +2575,49 @@ const Type* ParserImpl::GetComponentTypeForFormat(ast::ImageFormat format) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
unsigned ParserImpl::GetChannelCountForFormat(ast::ImageFormat format) {
|
||||
unsigned ParserImpl::GetChannelCountForFormat(ast::TexelFormat format) {
|
||||
switch (format) {
|
||||
case ast::ImageFormat::kR16Float:
|
||||
case ast::ImageFormat::kR16Sint:
|
||||
case ast::ImageFormat::kR16Uint:
|
||||
case ast::ImageFormat::kR32Float:
|
||||
case ast::ImageFormat::kR32Sint:
|
||||
case ast::ImageFormat::kR32Uint:
|
||||
case ast::ImageFormat::kR8Sint:
|
||||
case ast::ImageFormat::kR8Snorm:
|
||||
case ast::ImageFormat::kR8Uint:
|
||||
case ast::ImageFormat::kR8Unorm:
|
||||
case ast::TexelFormat::kR16Float:
|
||||
case ast::TexelFormat::kR16Sint:
|
||||
case ast::TexelFormat::kR16Uint:
|
||||
case ast::TexelFormat::kR32Float:
|
||||
case ast::TexelFormat::kR32Sint:
|
||||
case ast::TexelFormat::kR32Uint:
|
||||
case ast::TexelFormat::kR8Sint:
|
||||
case ast::TexelFormat::kR8Snorm:
|
||||
case ast::TexelFormat::kR8Uint:
|
||||
case ast::TexelFormat::kR8Unorm:
|
||||
// One channel
|
||||
return 1;
|
||||
|
||||
case ast::ImageFormat::kRg11B10Float:
|
||||
case ast::ImageFormat::kRg16Float:
|
||||
case ast::ImageFormat::kRg16Sint:
|
||||
case ast::ImageFormat::kRg16Uint:
|
||||
case ast::ImageFormat::kRg32Float:
|
||||
case ast::ImageFormat::kRg32Sint:
|
||||
case ast::ImageFormat::kRg32Uint:
|
||||
case ast::ImageFormat::kRg8Sint:
|
||||
case ast::ImageFormat::kRg8Snorm:
|
||||
case ast::ImageFormat::kRg8Uint:
|
||||
case ast::ImageFormat::kRg8Unorm:
|
||||
case ast::TexelFormat::kRg11B10Float:
|
||||
case ast::TexelFormat::kRg16Float:
|
||||
case ast::TexelFormat::kRg16Sint:
|
||||
case ast::TexelFormat::kRg16Uint:
|
||||
case ast::TexelFormat::kRg32Float:
|
||||
case ast::TexelFormat::kRg32Sint:
|
||||
case ast::TexelFormat::kRg32Uint:
|
||||
case ast::TexelFormat::kRg8Sint:
|
||||
case ast::TexelFormat::kRg8Snorm:
|
||||
case ast::TexelFormat::kRg8Uint:
|
||||
case ast::TexelFormat::kRg8Unorm:
|
||||
// Two channels
|
||||
return 2;
|
||||
|
||||
case ast::ImageFormat::kBgra8Unorm:
|
||||
case ast::ImageFormat::kBgra8UnormSrgb:
|
||||
case ast::ImageFormat::kRgb10A2Unorm:
|
||||
case ast::ImageFormat::kRgba16Float:
|
||||
case ast::ImageFormat::kRgba16Sint:
|
||||
case ast::ImageFormat::kRgba16Uint:
|
||||
case ast::ImageFormat::kRgba32Float:
|
||||
case ast::ImageFormat::kRgba32Sint:
|
||||
case ast::ImageFormat::kRgba32Uint:
|
||||
case ast::ImageFormat::kRgba8Sint:
|
||||
case ast::ImageFormat::kRgba8Snorm:
|
||||
case ast::ImageFormat::kRgba8Uint:
|
||||
case ast::ImageFormat::kRgba8Unorm:
|
||||
case ast::ImageFormat::kRgba8UnormSrgb:
|
||||
case ast::TexelFormat::kBgra8Unorm:
|
||||
case ast::TexelFormat::kBgra8UnormSrgb:
|
||||
case ast::TexelFormat::kRgb10A2Unorm:
|
||||
case ast::TexelFormat::kRgba16Float:
|
||||
case ast::TexelFormat::kRgba16Sint:
|
||||
case ast::TexelFormat::kRgba16Uint:
|
||||
case ast::TexelFormat::kRgba32Float:
|
||||
case ast::TexelFormat::kRgba32Sint:
|
||||
case ast::TexelFormat::kRgba32Uint:
|
||||
case ast::TexelFormat::kRgba8Sint:
|
||||
case ast::TexelFormat::kRgba8Snorm:
|
||||
case ast::TexelFormat::kRgba8Uint:
|
||||
case ast::TexelFormat::kRgba8Unorm:
|
||||
case ast::TexelFormat::kRgba8UnormSrgb:
|
||||
// Four channels
|
||||
return 4;
|
||||
|
||||
|
@ -2628,7 +2628,7 @@ unsigned ParserImpl::GetChannelCountForFormat(ast::ImageFormat format) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
const Type* ParserImpl::GetTexelTypeForFormat(ast::ImageFormat format) {
|
||||
const Type* ParserImpl::GetTexelTypeForFormat(ast::TexelFormat format) {
|
||||
const auto* component_type = GetComponentTypeForFormat(format);
|
||||
if (!component_type) {
|
||||
return nullptr;
|
||||
|
|
|
@ -637,19 +637,19 @@ class ParserImpl : Reader {
|
|||
/// format.
|
||||
/// @param format image texel format
|
||||
/// @returns the component type, one of f32, i32, u32
|
||||
const Type* GetComponentTypeForFormat(ast::ImageFormat format);
|
||||
const Type* GetComponentTypeForFormat(ast::TexelFormat format);
|
||||
|
||||
/// Returns the number of channels in the given image format.
|
||||
/// @param format image texel format
|
||||
/// @returns the number of channels in the format
|
||||
unsigned GetChannelCountForFormat(ast::ImageFormat format);
|
||||
unsigned GetChannelCountForFormat(ast::TexelFormat format);
|
||||
|
||||
/// Returns the texel type corresponding to the given image format.
|
||||
/// This the WGSL type used for the texel parameter to textureStore.
|
||||
/// It's always a 4-element vector.
|
||||
/// @param format image texel format
|
||||
/// @returns the texel format
|
||||
const Type* GetTexelTypeForFormat(ast::ImageFormat format);
|
||||
const Type* GetTexelTypeForFormat(ast::TexelFormat format);
|
||||
|
||||
/// Returns the SPIR-V instruction with the given ID, or nullptr.
|
||||
/// @param id the SPIR-V result ID
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
#include <utility>
|
||||
|
||||
#include "src/program_builder.h"
|
||||
#include "src/utils/map.h"
|
||||
#include "src/utils/hash.h"
|
||||
#include "src/utils/map.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::reader::spirv::Type);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::reader::spirv::Void);
|
||||
|
@ -237,7 +237,7 @@ const ast::Type* SampledTexture::Build(ProgramBuilder& b) const {
|
|||
}
|
||||
|
||||
StorageTexture::StorageTexture(ast::TextureDimension d,
|
||||
ast::ImageFormat f,
|
||||
ast::TexelFormat f,
|
||||
ast::Access a)
|
||||
: Base(d), format(f), access(a) {}
|
||||
StorageTexture::StorageTexture(const StorageTexture&) = default;
|
||||
|
@ -532,7 +532,7 @@ const spirv::SampledTexture* TypeManager::SampledTexture(
|
|||
|
||||
const spirv::StorageTexture* TypeManager::StorageTexture(
|
||||
ast::TextureDimension dims,
|
||||
ast::ImageFormat fmt,
|
||||
ast::TexelFormat fmt,
|
||||
ast::Access access) {
|
||||
return utils::GetOrCreate(
|
||||
state->storage_textures_, spirv::StorageTexture(dims, fmt, access), [&] {
|
||||
|
|
|
@ -422,7 +422,7 @@ struct StorageTexture : public Castable<StorageTexture, Texture> {
|
|||
/// @param d the texture dimensions
|
||||
/// @param f the storage image format
|
||||
/// @param a the access control
|
||||
StorageTexture(ast::TextureDimension d, ast::ImageFormat f, ast::Access a);
|
||||
StorageTexture(ast::TextureDimension d, ast::TexelFormat f, ast::Access a);
|
||||
|
||||
/// Copy constructor
|
||||
/// @param other the other type to copy
|
||||
|
@ -438,7 +438,7 @@ struct StorageTexture : public Castable<StorageTexture, Texture> {
|
|||
#endif // NDEBUG
|
||||
|
||||
/// the storage image format
|
||||
ast::ImageFormat const format;
|
||||
ast::TexelFormat const format;
|
||||
|
||||
/// the access control
|
||||
ast::Access const access;
|
||||
|
@ -595,7 +595,7 @@ class TypeManager {
|
|||
/// @return a StorageTexture type. Repeated calls with the same arguments will
|
||||
/// return the same pointer.
|
||||
const spirv::StorageTexture* StorageTexture(ast::TextureDimension d,
|
||||
ast::ImageFormat f,
|
||||
ast::TexelFormat f,
|
||||
ast::Access a);
|
||||
|
||||
private:
|
||||
|
|
|
@ -46,9 +46,9 @@ TEST(SpvParserTypeTest, SameArgumentsGivesSamePointer) {
|
|||
EXPECT_EQ(ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()),
|
||||
ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()));
|
||||
EXPECT_EQ(ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR16Sint, ast::Access::kRead),
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kRead),
|
||||
ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR16Sint, ast::Access::kRead));
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kRead));
|
||||
}
|
||||
|
||||
TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
|
||||
|
@ -83,17 +83,17 @@ TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
|
|||
EXPECT_NE(ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()),
|
||||
ty.SampledTexture(ast::TextureDimension::k2d, ty.U32()));
|
||||
EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR16Sint, ast::Access::kRead),
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kRead),
|
||||
ty.StorageTexture(ast::TextureDimension::k3d,
|
||||
ast::ImageFormat::kR16Sint, ast::Access::kRead));
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kRead));
|
||||
EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR16Sint, ast::Access::kRead),
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kRead),
|
||||
ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Sint, ast::Access::kRead));
|
||||
ast::TexelFormat::kR32Sint, ast::Access::kRead));
|
||||
EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR16Sint, ast::Access::kRead),
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kRead),
|
||||
ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR16Sint, ast::Access::kWrite));
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kWrite));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -563,7 +563,7 @@ Maybe<ParserImpl::VarDeclInfo> ParserImpl::variable_decl(bool allow_inferred) {
|
|||
// | depth_texture_type
|
||||
// | sampled_texture_type LESS_THAN type_decl GREATER_THAN
|
||||
// | multisampled_texture_type LESS_THAN type_decl GREATER_THAN
|
||||
// | storage_texture_type LESS_THAN image_storage_type
|
||||
// | storage_texture_type LESS_THAN texel_format
|
||||
// COMMA access GREATER_THAN
|
||||
Maybe<const ast::Type*> ParserImpl::texture_sampler_types() {
|
||||
auto type = sampler_type();
|
||||
|
@ -607,9 +607,9 @@ Maybe<const ast::Type*> ParserImpl::texture_sampler_types() {
|
|||
if (storage.matched) {
|
||||
const char* use = "storage texture type";
|
||||
using StorageTextureInfo =
|
||||
std::pair<tint::ast::ImageFormat, tint::ast::Access>;
|
||||
std::pair<tint::ast::TexelFormat, tint::ast::Access>;
|
||||
auto params = expect_lt_gt_block(use, [&]() -> Expect<StorageTextureInfo> {
|
||||
auto format = expect_image_storage_type(use);
|
||||
auto format = expect_texel_format(use);
|
||||
if (format.errored) {
|
||||
return Failure::kErrored;
|
||||
}
|
||||
|
@ -781,115 +781,115 @@ Maybe<const ast::Type*> ParserImpl::depth_texture_type() {
|
|||
// | RGBA32UINT
|
||||
// | RGBA32SINT
|
||||
// | RGBA32FLOAT
|
||||
Expect<ast::ImageFormat> ParserImpl::expect_image_storage_type(
|
||||
Expect<ast::TexelFormat> ParserImpl::expect_texel_format(
|
||||
const std::string& use) {
|
||||
auto tok = next();
|
||||
if (tok.IsIdentifier()) {
|
||||
auto s = tok.to_str();
|
||||
if (s == "bgra8unorm") {
|
||||
return ast::ImageFormat::kBgra8Unorm;
|
||||
return ast::TexelFormat::kBgra8Unorm;
|
||||
}
|
||||
if (s == "bgra8unorm_srgb") {
|
||||
return ast::ImageFormat::kBgra8UnormSrgb;
|
||||
return ast::TexelFormat::kBgra8UnormSrgb;
|
||||
}
|
||||
if (s == "r16float") {
|
||||
return ast::ImageFormat::kR16Float;
|
||||
return ast::TexelFormat::kR16Float;
|
||||
}
|
||||
if (s == "r16sint") {
|
||||
return ast::ImageFormat::kR16Sint;
|
||||
return ast::TexelFormat::kR16Sint;
|
||||
}
|
||||
if (s == "r16uint") {
|
||||
return ast::ImageFormat::kR16Uint;
|
||||
return ast::TexelFormat::kR16Uint;
|
||||
}
|
||||
if (s == "r32float") {
|
||||
return ast::ImageFormat::kR32Float;
|
||||
return ast::TexelFormat::kR32Float;
|
||||
}
|
||||
if (s == "r32sint") {
|
||||
return ast::ImageFormat::kR32Sint;
|
||||
return ast::TexelFormat::kR32Sint;
|
||||
}
|
||||
if (s == "r32uint") {
|
||||
return ast::ImageFormat::kR32Uint;
|
||||
return ast::TexelFormat::kR32Uint;
|
||||
}
|
||||
if (s == "r8sint") {
|
||||
return ast::ImageFormat::kR8Sint;
|
||||
return ast::TexelFormat::kR8Sint;
|
||||
}
|
||||
if (s == "r8snorm") {
|
||||
return ast::ImageFormat::kR8Snorm;
|
||||
return ast::TexelFormat::kR8Snorm;
|
||||
}
|
||||
if (s == "r8uint") {
|
||||
return ast::ImageFormat::kR8Uint;
|
||||
return ast::TexelFormat::kR8Uint;
|
||||
}
|
||||
if (s == "r8unorm") {
|
||||
return ast::ImageFormat::kR8Unorm;
|
||||
return ast::TexelFormat::kR8Unorm;
|
||||
}
|
||||
if (s == "rg11b10float") {
|
||||
return ast::ImageFormat::kRg11B10Float;
|
||||
return ast::TexelFormat::kRg11B10Float;
|
||||
}
|
||||
if (s == "rg16float") {
|
||||
return ast::ImageFormat::kRg16Float;
|
||||
return ast::TexelFormat::kRg16Float;
|
||||
}
|
||||
if (s == "rg16sint") {
|
||||
return ast::ImageFormat::kRg16Sint;
|
||||
return ast::TexelFormat::kRg16Sint;
|
||||
}
|
||||
if (s == "rg16uint") {
|
||||
return ast::ImageFormat::kRg16Uint;
|
||||
return ast::TexelFormat::kRg16Uint;
|
||||
}
|
||||
if (s == "rg32float") {
|
||||
return ast::ImageFormat::kRg32Float;
|
||||
return ast::TexelFormat::kRg32Float;
|
||||
}
|
||||
if (s == "rg32sint") {
|
||||
return ast::ImageFormat::kRg32Sint;
|
||||
return ast::TexelFormat::kRg32Sint;
|
||||
}
|
||||
if (s == "rg32uint") {
|
||||
return ast::ImageFormat::kRg32Uint;
|
||||
return ast::TexelFormat::kRg32Uint;
|
||||
}
|
||||
if (s == "rg8sint") {
|
||||
return ast::ImageFormat::kRg8Sint;
|
||||
return ast::TexelFormat::kRg8Sint;
|
||||
}
|
||||
if (s == "rg8snorm") {
|
||||
return ast::ImageFormat::kRg8Snorm;
|
||||
return ast::TexelFormat::kRg8Snorm;
|
||||
}
|
||||
if (s == "rg8uint") {
|
||||
return ast::ImageFormat::kRg8Uint;
|
||||
return ast::TexelFormat::kRg8Uint;
|
||||
}
|
||||
if (s == "rg8unorm") {
|
||||
return ast::ImageFormat::kRg8Unorm;
|
||||
return ast::TexelFormat::kRg8Unorm;
|
||||
}
|
||||
if (s == "rgb10a2unorm") {
|
||||
return ast::ImageFormat::kRgb10A2Unorm;
|
||||
return ast::TexelFormat::kRgb10A2Unorm;
|
||||
}
|
||||
if (s == "rgba16float") {
|
||||
return ast::ImageFormat::kRgba16Float;
|
||||
return ast::TexelFormat::kRgba16Float;
|
||||
}
|
||||
if (s == "rgba16sint") {
|
||||
return ast::ImageFormat::kRgba16Sint;
|
||||
return ast::TexelFormat::kRgba16Sint;
|
||||
}
|
||||
if (s == "rgba16uint") {
|
||||
return ast::ImageFormat::kRgba16Uint;
|
||||
return ast::TexelFormat::kRgba16Uint;
|
||||
}
|
||||
if (s == "rgba32float") {
|
||||
return ast::ImageFormat::kRgba32Float;
|
||||
return ast::TexelFormat::kRgba32Float;
|
||||
}
|
||||
if (s == "rgba32sint") {
|
||||
return ast::ImageFormat::kRgba32Sint;
|
||||
return ast::TexelFormat::kRgba32Sint;
|
||||
}
|
||||
if (s == "rgba32uint") {
|
||||
return ast::ImageFormat::kRgba32Uint;
|
||||
return ast::TexelFormat::kRgba32Uint;
|
||||
}
|
||||
if (s == "rgba8sint") {
|
||||
return ast::ImageFormat::kRgba8Sint;
|
||||
return ast::TexelFormat::kRgba8Sint;
|
||||
}
|
||||
if (s == "rgba8snorm") {
|
||||
return ast::ImageFormat::kRgba8Snorm;
|
||||
return ast::TexelFormat::kRgba8Snorm;
|
||||
}
|
||||
if (s == "rgba8uint") {
|
||||
return ast::ImageFormat::kRgba8Uint;
|
||||
return ast::TexelFormat::kRgba8Uint;
|
||||
}
|
||||
if (s == "rgba8unorm") {
|
||||
return ast::ImageFormat::kRgba8Unorm;
|
||||
return ast::TexelFormat::kRgba8Unorm;
|
||||
}
|
||||
if (s == "rgba8unorm_srgb") {
|
||||
return ast::ImageFormat::kRgba8UnormSrgb;
|
||||
return ast::TexelFormat::kRgba8UnormSrgb;
|
||||
}
|
||||
}
|
||||
return add_error(tok.source(), "invalid format", use);
|
||||
|
|
|
@ -469,10 +469,10 @@ class ParserImpl {
|
|||
/// Parses a 'texture_external_type' grammar element
|
||||
/// @returns the parsed Type or nullptr if none matched
|
||||
Maybe<const ast::Type*> external_texture_type();
|
||||
/// Parses a `image_storage_type` grammar element
|
||||
/// Parses a `texel_format` grammar element
|
||||
/// @param use a description of what was being parsed if an error was raised
|
||||
/// @returns returns the image format or kNone if none matched.
|
||||
Expect<ast::ImageFormat> expect_image_storage_type(const std::string& use);
|
||||
/// @returns returns the texel format or kNone if none matched.
|
||||
Expect<ast::TexelFormat> expect_texel_format(const std::string& use);
|
||||
/// Parses a `function_header` grammar element
|
||||
/// @returns the parsed function header
|
||||
Maybe<FunctionHeader> function_header();
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace {
|
|||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Invalid) {
|
||||
auto p = parser("1234");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:1: invalid format for test");
|
||||
|
@ -29,281 +29,281 @@ TEST_F(ParserImplTest, ImageStorageType_Invalid) {
|
|||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R8Unorm) {
|
||||
auto p = parser("r8unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kR8Unorm);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kR8Unorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R8Snorm) {
|
||||
auto p = parser("r8snorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kR8Snorm);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kR8Snorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R8Uint) {
|
||||
auto p = parser("r8uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kR8Uint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kR8Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R8Sint) {
|
||||
auto p = parser("r8sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kR8Sint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kR8Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R16Uint) {
|
||||
auto p = parser("r16uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kR16Uint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kR16Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R16Sint) {
|
||||
auto p = parser("r16sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kR16Sint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kR16Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R16Float) {
|
||||
auto p = parser("r16float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kR16Float);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kR16Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg8Unorm) {
|
||||
auto p = parser("rg8unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRg8Unorm);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRg8Unorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg8Snorm) {
|
||||
auto p = parser("rg8snorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRg8Snorm);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRg8Snorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg8Uint) {
|
||||
auto p = parser("rg8uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRg8Uint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRg8Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg8Sint) {
|
||||
auto p = parser("rg8sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRg8Sint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRg8Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R32Uint) {
|
||||
auto p = parser("r32uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kR32Uint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kR32Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R32Sint) {
|
||||
auto p = parser("r32sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kR32Sint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kR32Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R32Float) {
|
||||
auto p = parser("r32float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kR32Float);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kR32Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg16Uint) {
|
||||
auto p = parser("rg16uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRg16Uint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRg16Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg16Sint) {
|
||||
auto p = parser("rg16sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRg16Sint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRg16Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg16Float) {
|
||||
auto p = parser("rg16float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRg16Float);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRg16Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba8Unorm) {
|
||||
auto p = parser("rgba8unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8Unorm);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRgba8Unorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba8UnormSrgb) {
|
||||
auto p = parser("rgba8unorm_srgb");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8UnormSrgb);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRgba8UnormSrgb);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba8Snorm) {
|
||||
auto p = parser("rgba8snorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8Snorm);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRgba8Snorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba8Uint) {
|
||||
auto p = parser("rgba8uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8Uint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRgba8Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba8Sint) {
|
||||
auto p = parser("rgba8sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRgba8Sint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRgba8Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Bgra8Unorm) {
|
||||
auto p = parser("bgra8unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kBgra8Unorm);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kBgra8Unorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Bgra8UnormSrgb) {
|
||||
auto p = parser("bgra8unorm_srgb");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kBgra8UnormSrgb);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kBgra8UnormSrgb);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgb10A2Unorm) {
|
||||
auto p = parser("rgb10a2unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRgb10A2Unorm);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRgb10A2Unorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg11B10Float) {
|
||||
auto p = parser("rg11b10float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRg11B10Float);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRg11B10Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg32Uint) {
|
||||
auto p = parser("rg32uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRg32Uint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRg32Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg32Sint) {
|
||||
auto p = parser("rg32sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRg32Sint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRg32Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg32Float) {
|
||||
auto p = parser("rg32float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRg32Float);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRg32Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba16Uint) {
|
||||
auto p = parser("rgba16uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRgba16Uint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRgba16Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba16Sint) {
|
||||
auto p = parser("rgba16sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRgba16Sint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRgba16Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba16Float) {
|
||||
auto p = parser("rgba16float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRgba16Float);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRgba16Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba32Uint) {
|
||||
auto p = parser("rgba32uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRgba32Uint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRgba32Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba32Sint) {
|
||||
auto p = parser("rgba32sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRgba32Sint);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRgba32Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba32Float) {
|
||||
auto p = parser("rgba32float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
auto t = p->expect_texel_format("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::ImageFormat::kRgba32Float);
|
||||
EXPECT_EQ(t.value, ast::TexelFormat::kRgba32Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
|
@ -194,7 +194,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) {
|
|||
|
||||
ASSERT_TRUE(t->Is<ast::Texture>());
|
||||
ASSERT_TRUE(t->Is<ast::StorageTexture>());
|
||||
EXPECT_EQ(t->As<ast::StorageTexture>()->format, ast::ImageFormat::kR8Unorm);
|
||||
EXPECT_EQ(t->As<ast::StorageTexture>()->format, ast::TexelFormat::kR8Unorm);
|
||||
EXPECT_EQ(t->As<ast::StorageTexture>()->access, ast::Access::kRead);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k1d);
|
||||
EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 34u}}));
|
||||
|
@ -210,7 +210,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
|
|||
|
||||
ASSERT_TRUE(t->Is<ast::Texture>());
|
||||
ASSERT_TRUE(t->Is<ast::StorageTexture>());
|
||||
EXPECT_EQ(t->As<ast::StorageTexture>()->format, ast::ImageFormat::kR16Float);
|
||||
EXPECT_EQ(t->As<ast::StorageTexture>()->format, ast::TexelFormat::kR16Float);
|
||||
EXPECT_EQ(t->As<ast::StorageTexture>()->access, ast::Access::kWrite);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 36u}}));
|
||||
|
|
|
@ -227,7 +227,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) {
|
|||
|
||||
auto make_type = [&] {
|
||||
return ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kRgba8Unorm,
|
||||
ast::TexelFormat::kRgba8Unorm,
|
||||
ast::Access::kWrite);
|
||||
};
|
||||
|
||||
|
|
|
@ -1316,7 +1316,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
|
|||
Global(Sym(), ty.external_texture());
|
||||
Global(Sym(), ty.multisampled_texture(ast::TextureDimension::k2d, T));
|
||||
Global(Sym(), ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR16Float,
|
||||
ast::TexelFormat::kR16Float,
|
||||
ast::Access::kRead)); //
|
||||
Global(Sym(), ty.sampler(ast::SamplerKind::kSampler));
|
||||
Func(Sym(), {}, ty.void_(), {});
|
||||
|
|
|
@ -222,7 +222,7 @@ inline std::ostream& operator<<(std::ostream& out, Texture data) {
|
|||
struct TextureTestParams {
|
||||
ast::TextureDimension dim;
|
||||
Texture type = Texture::kF32;
|
||||
ast::ImageFormat format = ast::ImageFormat::kR16Float;
|
||||
ast::TexelFormat format = ast::TexelFormat::kR16Float;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, TextureTestParams data) {
|
||||
out << data.dim << "_" << data.type;
|
||||
|
|
|
@ -95,24 +95,24 @@ bool IsValidStorageTextureDimension(ast::TextureDimension dim) {
|
|||
}
|
||||
}
|
||||
|
||||
bool IsValidStorageTextureImageFormat(ast::ImageFormat format) {
|
||||
bool IsValidStorageTextureTexelFormat(ast::TexelFormat format) {
|
||||
switch (format) {
|
||||
case ast::ImageFormat::kR32Uint:
|
||||
case ast::ImageFormat::kR32Sint:
|
||||
case ast::ImageFormat::kR32Float:
|
||||
case ast::ImageFormat::kRg32Uint:
|
||||
case ast::ImageFormat::kRg32Sint:
|
||||
case ast::ImageFormat::kRg32Float:
|
||||
case ast::ImageFormat::kRgba8Unorm:
|
||||
case ast::ImageFormat::kRgba8Snorm:
|
||||
case ast::ImageFormat::kRgba8Uint:
|
||||
case ast::ImageFormat::kRgba8Sint:
|
||||
case ast::ImageFormat::kRgba16Uint:
|
||||
case ast::ImageFormat::kRgba16Sint:
|
||||
case ast::ImageFormat::kRgba16Float:
|
||||
case ast::ImageFormat::kRgba32Uint:
|
||||
case ast::ImageFormat::kRgba32Sint:
|
||||
case ast::ImageFormat::kRgba32Float:
|
||||
case ast::TexelFormat::kR32Uint:
|
||||
case ast::TexelFormat::kR32Sint:
|
||||
case ast::TexelFormat::kR32Float:
|
||||
case ast::TexelFormat::kRg32Uint:
|
||||
case ast::TexelFormat::kRg32Sint:
|
||||
case ast::TexelFormat::kRg32Float:
|
||||
case ast::TexelFormat::kRgba8Unorm:
|
||||
case ast::TexelFormat::kRgba8Snorm:
|
||||
case ast::TexelFormat::kRgba8Uint:
|
||||
case ast::TexelFormat::kRgba8Sint:
|
||||
case ast::TexelFormat::kRgba16Uint:
|
||||
case ast::TexelFormat::kRgba16Sint:
|
||||
case ast::TexelFormat::kRgba16Float:
|
||||
case ast::TexelFormat::kRgba32Uint:
|
||||
case ast::TexelFormat::kRgba32Sint:
|
||||
case ast::TexelFormat::kRgba32Float:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -182,7 +182,7 @@ bool Resolver::ValidateStorageTexture(const ast::StorageTexture* t) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!IsValidStorageTextureImageFormat(t->format)) {
|
||||
if (!IsValidStorageTextureTexelFormat(t->format)) {
|
||||
AddError(
|
||||
"image format must be one of the texel formats specified for storage "
|
||||
"textues in https://gpuweb.github.io/gpuweb/wgsl/#texel-formats",
|
||||
|
|
|
@ -837,7 +837,7 @@ TEST_P(StorageTextureDimensionTest, All) {
|
|||
|
||||
auto* st =
|
||||
ty.storage_texture(Source{{12, 34}}, params.dim,
|
||||
ast::ImageFormat::kR32Uint, ast::Access::kWrite);
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kWrite);
|
||||
|
||||
Global("a", st, ast::StorageClass::kNone,
|
||||
ast::DecorationList{GroupAndBinding(0, 0)});
|
||||
|
@ -856,46 +856,46 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
|
|||
testing::ValuesIn(Dimension_cases));
|
||||
|
||||
struct FormatParams {
|
||||
ast::ImageFormat format;
|
||||
ast::TexelFormat format;
|
||||
bool is_valid;
|
||||
};
|
||||
|
||||
static constexpr FormatParams format_cases[] = {
|
||||
FormatParams{ast::ImageFormat::kBgra8Unorm, false},
|
||||
FormatParams{ast::ImageFormat::kBgra8UnormSrgb, false},
|
||||
FormatParams{ast::ImageFormat::kR16Float, false},
|
||||
FormatParams{ast::ImageFormat::kR16Sint, false},
|
||||
FormatParams{ast::ImageFormat::kR16Uint, false},
|
||||
FormatParams{ast::ImageFormat::kR32Float, true},
|
||||
FormatParams{ast::ImageFormat::kR32Sint, true},
|
||||
FormatParams{ast::ImageFormat::kR32Uint, true},
|
||||
FormatParams{ast::ImageFormat::kR8Sint, false},
|
||||
FormatParams{ast::ImageFormat::kR8Snorm, false},
|
||||
FormatParams{ast::ImageFormat::kR8Uint, false},
|
||||
FormatParams{ast::ImageFormat::kR8Unorm, false},
|
||||
FormatParams{ast::ImageFormat::kRg11B10Float, false},
|
||||
FormatParams{ast::ImageFormat::kRg16Float, false},
|
||||
FormatParams{ast::ImageFormat::kRg16Sint, false},
|
||||
FormatParams{ast::ImageFormat::kRg16Uint, false},
|
||||
FormatParams{ast::ImageFormat::kRg32Float, true},
|
||||
FormatParams{ast::ImageFormat::kRg32Sint, true},
|
||||
FormatParams{ast::ImageFormat::kRg32Uint, true},
|
||||
FormatParams{ast::ImageFormat::kRg8Sint, false},
|
||||
FormatParams{ast::ImageFormat::kRg8Snorm, false},
|
||||
FormatParams{ast::ImageFormat::kRg8Uint, false},
|
||||
FormatParams{ast::ImageFormat::kRg8Unorm, false},
|
||||
FormatParams{ast::ImageFormat::kRgb10A2Unorm, false},
|
||||
FormatParams{ast::ImageFormat::kRgba16Float, true},
|
||||
FormatParams{ast::ImageFormat::kRgba16Sint, true},
|
||||
FormatParams{ast::ImageFormat::kRgba16Uint, true},
|
||||
FormatParams{ast::ImageFormat::kRgba32Float, true},
|
||||
FormatParams{ast::ImageFormat::kRgba32Sint, true},
|
||||
FormatParams{ast::ImageFormat::kRgba32Uint, true},
|
||||
FormatParams{ast::ImageFormat::kRgba8Sint, true},
|
||||
FormatParams{ast::ImageFormat::kRgba8Snorm, true},
|
||||
FormatParams{ast::ImageFormat::kRgba8Uint, true},
|
||||
FormatParams{ast::ImageFormat::kRgba8Unorm, true},
|
||||
FormatParams{ast::ImageFormat::kRgba8UnormSrgb, false}};
|
||||
FormatParams{ast::TexelFormat::kBgra8Unorm, false},
|
||||
FormatParams{ast::TexelFormat::kBgra8UnormSrgb, false},
|
||||
FormatParams{ast::TexelFormat::kR16Float, false},
|
||||
FormatParams{ast::TexelFormat::kR16Sint, false},
|
||||
FormatParams{ast::TexelFormat::kR16Uint, false},
|
||||
FormatParams{ast::TexelFormat::kR32Float, true},
|
||||
FormatParams{ast::TexelFormat::kR32Sint, true},
|
||||
FormatParams{ast::TexelFormat::kR32Uint, true},
|
||||
FormatParams{ast::TexelFormat::kR8Sint, false},
|
||||
FormatParams{ast::TexelFormat::kR8Snorm, false},
|
||||
FormatParams{ast::TexelFormat::kR8Uint, false},
|
||||
FormatParams{ast::TexelFormat::kR8Unorm, false},
|
||||
FormatParams{ast::TexelFormat::kRg11B10Float, false},
|
||||
FormatParams{ast::TexelFormat::kRg16Float, false},
|
||||
FormatParams{ast::TexelFormat::kRg16Sint, false},
|
||||
FormatParams{ast::TexelFormat::kRg16Uint, false},
|
||||
FormatParams{ast::TexelFormat::kRg32Float, true},
|
||||
FormatParams{ast::TexelFormat::kRg32Sint, true},
|
||||
FormatParams{ast::TexelFormat::kRg32Uint, true},
|
||||
FormatParams{ast::TexelFormat::kRg8Sint, false},
|
||||
FormatParams{ast::TexelFormat::kRg8Snorm, false},
|
||||
FormatParams{ast::TexelFormat::kRg8Uint, false},
|
||||
FormatParams{ast::TexelFormat::kRg8Unorm, false},
|
||||
FormatParams{ast::TexelFormat::kRgb10A2Unorm, false},
|
||||
FormatParams{ast::TexelFormat::kRgba16Float, true},
|
||||
FormatParams{ast::TexelFormat::kRgba16Sint, true},
|
||||
FormatParams{ast::TexelFormat::kRgba16Uint, true},
|
||||
FormatParams{ast::TexelFormat::kRgba32Float, true},
|
||||
FormatParams{ast::TexelFormat::kRgba32Sint, true},
|
||||
FormatParams{ast::TexelFormat::kRgba32Uint, true},
|
||||
FormatParams{ast::TexelFormat::kRgba8Sint, true},
|
||||
FormatParams{ast::TexelFormat::kRgba8Snorm, true},
|
||||
FormatParams{ast::TexelFormat::kRgba8Uint, true},
|
||||
FormatParams{ast::TexelFormat::kRgba8Unorm, true},
|
||||
FormatParams{ast::TexelFormat::kRgba8UnormSrgb, false}};
|
||||
|
||||
using StorageTextureFormatTest = ResolverTestWithParam<FormatParams>;
|
||||
TEST_P(StorageTextureFormatTest, All) {
|
||||
|
@ -951,7 +951,7 @@ TEST_F(StorageTextureAccessTest, MissingAccess_Fail) {
|
|||
|
||||
auto* st =
|
||||
ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Uint, ast::Access::kUndefined);
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kUndefined);
|
||||
|
||||
Global("a", st, ast::StorageClass::kNone,
|
||||
ast::DecorationList{GroupAndBinding(0, 0)});
|
||||
|
@ -967,7 +967,7 @@ TEST_F(StorageTextureAccessTest, RWAccess_Fail) {
|
|||
|
||||
auto* st =
|
||||
ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Uint, ast::Access::kReadWrite);
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kReadWrite);
|
||||
|
||||
Global("a", st, ast::StorageClass::kNone, nullptr,
|
||||
ast::DecorationList{GroupAndBinding(0, 0)});
|
||||
|
@ -983,7 +983,7 @@ TEST_F(StorageTextureAccessTest, ReadOnlyAccess_Fail) {
|
|||
// var a : texture_storage_1d<ru32int, read>;
|
||||
|
||||
auto* st = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Uint, ast::Access::kRead);
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kRead);
|
||||
|
||||
Global("a", st, ast::StorageClass::kNone, nullptr,
|
||||
ast::DecorationList{GroupAndBinding(0, 0)});
|
||||
|
@ -999,7 +999,7 @@ TEST_F(StorageTextureAccessTest, WriteOnlyAccess_Pass) {
|
|||
// var a : texture_storage_1d<ru32int, write>;
|
||||
|
||||
auto* st =
|
||||
ty.storage_texture(ast::TextureDimension::k1d, ast::ImageFormat::kR32Uint,
|
||||
ty.storage_texture(ast::TextureDimension::k1d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kWrite);
|
||||
|
||||
Global("a", st, ast::StorageClass::kNone, nullptr,
|
||||
|
|
|
@ -22,10 +22,10 @@ namespace tint {
|
|||
namespace sem {
|
||||
|
||||
StorageTexture::StorageTexture(ast::TextureDimension dim,
|
||||
ast::ImageFormat format,
|
||||
ast::TexelFormat format,
|
||||
ast::Access access,
|
||||
sem::Type* subtype)
|
||||
: Base(dim), image_format_(format), access_(access), subtype_(subtype) {}
|
||||
: Base(dim), texel_format_(format), access_(access), subtype_(subtype) {}
|
||||
|
||||
StorageTexture::StorageTexture(StorageTexture&&) = default;
|
||||
|
||||
|
@ -33,66 +33,66 @@ StorageTexture::~StorageTexture() = default;
|
|||
|
||||
std::string StorageTexture::type_name() const {
|
||||
std::ostringstream out;
|
||||
out << "__storage_texture_" << dim() << "_" << image_format_ << "_"
|
||||
out << "__storage_texture_" << dim() << "_" << texel_format_ << "_"
|
||||
<< access_;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
std::string StorageTexture::FriendlyName(const SymbolTable&) const {
|
||||
std::ostringstream out;
|
||||
out << "texture_storage_" << dim() << "<" << image_format_ << ", " << access_
|
||||
out << "texture_storage_" << dim() << "<" << texel_format_ << ", " << access_
|
||||
<< ">";
|
||||
return out.str();
|
||||
}
|
||||
|
||||
sem::Type* StorageTexture::SubtypeFor(ast::ImageFormat format,
|
||||
sem::Type* StorageTexture::SubtypeFor(ast::TexelFormat format,
|
||||
sem::Manager& type_mgr) {
|
||||
switch (format) {
|
||||
case ast::ImageFormat::kR8Uint:
|
||||
case ast::ImageFormat::kR16Uint:
|
||||
case ast::ImageFormat::kRg8Uint:
|
||||
case ast::ImageFormat::kR32Uint:
|
||||
case ast::ImageFormat::kRg16Uint:
|
||||
case ast::ImageFormat::kRgba8Uint:
|
||||
case ast::ImageFormat::kRg32Uint:
|
||||
case ast::ImageFormat::kRgba16Uint:
|
||||
case ast::ImageFormat::kRgba32Uint: {
|
||||
case ast::TexelFormat::kR8Uint:
|
||||
case ast::TexelFormat::kR16Uint:
|
||||
case ast::TexelFormat::kRg8Uint:
|
||||
case ast::TexelFormat::kR32Uint:
|
||||
case ast::TexelFormat::kRg16Uint:
|
||||
case ast::TexelFormat::kRgba8Uint:
|
||||
case ast::TexelFormat::kRg32Uint:
|
||||
case ast::TexelFormat::kRgba16Uint:
|
||||
case ast::TexelFormat::kRgba32Uint: {
|
||||
return type_mgr.Get<sem::U32>();
|
||||
}
|
||||
|
||||
case ast::ImageFormat::kR8Sint:
|
||||
case ast::ImageFormat::kR16Sint:
|
||||
case ast::ImageFormat::kRg8Sint:
|
||||
case ast::ImageFormat::kR32Sint:
|
||||
case ast::ImageFormat::kRg16Sint:
|
||||
case ast::ImageFormat::kRgba8Sint:
|
||||
case ast::ImageFormat::kRg32Sint:
|
||||
case ast::ImageFormat::kRgba16Sint:
|
||||
case ast::ImageFormat::kRgba32Sint: {
|
||||
case ast::TexelFormat::kR8Sint:
|
||||
case ast::TexelFormat::kR16Sint:
|
||||
case ast::TexelFormat::kRg8Sint:
|
||||
case ast::TexelFormat::kR32Sint:
|
||||
case ast::TexelFormat::kRg16Sint:
|
||||
case ast::TexelFormat::kRgba8Sint:
|
||||
case ast::TexelFormat::kRg32Sint:
|
||||
case ast::TexelFormat::kRgba16Sint:
|
||||
case ast::TexelFormat::kRgba32Sint: {
|
||||
return type_mgr.Get<sem::I32>();
|
||||
}
|
||||
|
||||
case ast::ImageFormat::kR8Unorm:
|
||||
case ast::ImageFormat::kRg8Unorm:
|
||||
case ast::ImageFormat::kRgba8Unorm:
|
||||
case ast::ImageFormat::kRgba8UnormSrgb:
|
||||
case ast::ImageFormat::kBgra8Unorm:
|
||||
case ast::ImageFormat::kBgra8UnormSrgb:
|
||||
case ast::ImageFormat::kRgb10A2Unorm:
|
||||
case ast::ImageFormat::kR8Snorm:
|
||||
case ast::ImageFormat::kRg8Snorm:
|
||||
case ast::ImageFormat::kRgba8Snorm:
|
||||
case ast::ImageFormat::kR16Float:
|
||||
case ast::ImageFormat::kR32Float:
|
||||
case ast::ImageFormat::kRg16Float:
|
||||
case ast::ImageFormat::kRg11B10Float:
|
||||
case ast::ImageFormat::kRg32Float:
|
||||
case ast::ImageFormat::kRgba16Float:
|
||||
case ast::ImageFormat::kRgba32Float: {
|
||||
case ast::TexelFormat::kR8Unorm:
|
||||
case ast::TexelFormat::kRg8Unorm:
|
||||
case ast::TexelFormat::kRgba8Unorm:
|
||||
case ast::TexelFormat::kRgba8UnormSrgb:
|
||||
case ast::TexelFormat::kBgra8Unorm:
|
||||
case ast::TexelFormat::kBgra8UnormSrgb:
|
||||
case ast::TexelFormat::kRgb10A2Unorm:
|
||||
case ast::TexelFormat::kR8Snorm:
|
||||
case ast::TexelFormat::kRg8Snorm:
|
||||
case ast::TexelFormat::kRgba8Snorm:
|
||||
case ast::TexelFormat::kR16Float:
|
||||
case ast::TexelFormat::kR32Float:
|
||||
case ast::TexelFormat::kRg16Float:
|
||||
case ast::TexelFormat::kRg11B10Float:
|
||||
case ast::TexelFormat::kRg32Float:
|
||||
case ast::TexelFormat::kRgba16Float:
|
||||
case ast::TexelFormat::kRgba32Float: {
|
||||
return type_mgr.Get<sem::F32>();
|
||||
}
|
||||
|
||||
case ast::ImageFormat::kNone:
|
||||
case ast::TexelFormat::kNone:
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,11 +31,11 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
|
|||
public:
|
||||
/// Constructor
|
||||
/// @param dim the dimensionality of the texture
|
||||
/// @param format the image format of the texture
|
||||
/// @param format the texel format of the texture
|
||||
/// @param access the access control type of the texture
|
||||
/// @param subtype the storage subtype. Use SubtypeFor() to calculate this.
|
||||
StorageTexture(ast::TextureDimension dim,
|
||||
ast::ImageFormat format,
|
||||
ast::TexelFormat format,
|
||||
ast::Access access,
|
||||
sem::Type* subtype);
|
||||
|
||||
|
@ -46,8 +46,8 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
|
|||
/// @returns the storage subtype
|
||||
Type* type() const { return subtype_; }
|
||||
|
||||
/// @returns the image format
|
||||
ast::ImageFormat image_format() const { return image_format_; }
|
||||
/// @returns the texel format
|
||||
ast::TexelFormat texel_format() const { return texel_format_; }
|
||||
|
||||
/// @returns the access control
|
||||
ast::Access access() const { return access_; }
|
||||
|
@ -62,11 +62,11 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
|
|||
|
||||
/// @param format the storage texture image format
|
||||
/// @param type_mgr the sem::Manager used to build the returned type
|
||||
/// @returns the storage texture subtype for the given ImageFormat
|
||||
static sem::Type* SubtypeFor(ast::ImageFormat format, sem::Manager& type_mgr);
|
||||
/// @returns the storage texture subtype for the given TexelFormat
|
||||
static sem::Type* SubtypeFor(ast::TexelFormat format, sem::Manager& type_mgr);
|
||||
|
||||
private:
|
||||
ast::ImageFormat const image_format_;
|
||||
ast::TexelFormat const texel_format_;
|
||||
ast::Access const access_;
|
||||
Type* const subtype_;
|
||||
};
|
||||
|
|
|
@ -27,27 +27,27 @@ using StorageTextureTest = TestHelper;
|
|||
|
||||
TEST_F(StorageTextureTest, Dim) {
|
||||
auto* subtype =
|
||||
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
|
||||
StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Float, Types());
|
||||
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite, subtype);
|
||||
EXPECT_EQ(s->dim(), ast::TextureDimension::k2dArray);
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, Format) {
|
||||
auto* subtype =
|
||||
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
|
||||
StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Float, Types());
|
||||
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite, subtype);
|
||||
EXPECT_EQ(s->image_format(), ast::ImageFormat::kRgba32Float);
|
||||
EXPECT_EQ(s->texel_format(), ast::TexelFormat::kRgba32Float);
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, TypeName) {
|
||||
auto* subtype =
|
||||
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
|
||||
StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Float, Types());
|
||||
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite, subtype);
|
||||
EXPECT_EQ(s->type_name(),
|
||||
"__storage_texture_2d_array_rgba32float_read_write");
|
||||
|
@ -55,9 +55,9 @@ TEST_F(StorageTextureTest, TypeName) {
|
|||
|
||||
TEST_F(StorageTextureTest, FriendlyName) {
|
||||
auto* subtype =
|
||||
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
|
||||
StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Float, Types());
|
||||
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite, subtype);
|
||||
EXPECT_EQ(s->FriendlyName(Symbols()),
|
||||
"texture_storage_2d_array<rgba32float, read_write>");
|
||||
|
@ -65,9 +65,9 @@ TEST_F(StorageTextureTest, FriendlyName) {
|
|||
|
||||
TEST_F(StorageTextureTest, F32) {
|
||||
auto* subtype =
|
||||
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
|
||||
sem::StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Float, Types());
|
||||
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||
ast::ImageFormat::kRgba32Float,
|
||||
ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite, subtype);
|
||||
|
||||
auto program = Build();
|
||||
|
@ -80,9 +80,9 @@ TEST_F(StorageTextureTest, F32) {
|
|||
|
||||
TEST_F(StorageTextureTest, U32) {
|
||||
auto* subtype =
|
||||
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRg32Uint, Types());
|
||||
sem::StorageTexture::SubtypeFor(ast::TexelFormat::kRg32Uint, Types());
|
||||
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||
ast::ImageFormat::kRg32Uint,
|
||||
ast::TexelFormat::kRg32Uint,
|
||||
ast::Access::kReadWrite, subtype);
|
||||
|
||||
auto program = Build();
|
||||
|
@ -95,9 +95,9 @@ TEST_F(StorageTextureTest, U32) {
|
|||
|
||||
TEST_F(StorageTextureTest, I32) {
|
||||
auto* subtype =
|
||||
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Sint, Types());
|
||||
sem::StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Sint, Types());
|
||||
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
|
||||
ast::ImageFormat::kRgba32Sint,
|
||||
ast::TexelFormat::kRgba32Sint,
|
||||
ast::Access::kReadWrite, subtype);
|
||||
|
||||
auto program = Build();
|
||||
|
|
|
@ -152,7 +152,7 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx,
|
|||
}
|
||||
if (auto* t = ty->As<sem::StorageTexture>()) {
|
||||
return ctx.dst->create<ast::StorageTexture>(
|
||||
t->dim(), t->image_format(), CreateASTTypeFor(ctx, t->type()),
|
||||
t->dim(), t->texel_format(), CreateASTTypeFor(ctx, t->type()),
|
||||
t->access());
|
||||
}
|
||||
if (auto* s = ty->As<sem::Sampler>()) {
|
||||
|
|
|
@ -507,7 +507,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
|||
|
||||
struct GlslStorageTextureData {
|
||||
ast::TextureDimension dim;
|
||||
ast::ImageFormat imgfmt;
|
||||
ast::TexelFormat imgfmt;
|
||||
std::string result;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out,
|
||||
|
@ -539,32 +539,32 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
GlslStorageTexturesTest,
|
||||
testing::Values(
|
||||
GlslStorageTextureData{ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kRgba8Unorm, "image1D tex;"},
|
||||
ast::TexelFormat::kRgba8Unorm, "image1D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kRgba16Float, "image2D tex;"},
|
||||
ast::TexelFormat::kRgba16Float, "image2D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k2dArray,
|
||||
ast::ImageFormat::kR32Float,
|
||||
ast::TexelFormat::kR32Float,
|
||||
"image2DArray tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k3d,
|
||||
ast::ImageFormat::kRg32Float, "image3D tex;"},
|
||||
ast::TexelFormat::kRg32Float, "image3D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kRgba32Float, "image1D tex;"},
|
||||
ast::TexelFormat::kRgba32Float, "image1D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kRgba16Uint, "image2D tex;"},
|
||||
ast::TexelFormat::kRgba16Uint, "image2D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k2dArray,
|
||||
ast::ImageFormat::kR32Uint, "image2DArray tex;"},
|
||||
ast::TexelFormat::kR32Uint, "image2DArray tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k3d,
|
||||
ast::ImageFormat::kRg32Uint, "image3D tex;"},
|
||||
ast::TexelFormat::kRg32Uint, "image3D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kRgba32Uint, "image1D tex;"},
|
||||
ast::TexelFormat::kRgba32Uint, "image1D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kRgba16Sint, "image2D tex;"},
|
||||
ast::TexelFormat::kRgba16Sint, "image2D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k2dArray,
|
||||
ast::ImageFormat::kR32Sint, "image2DArray tex;"},
|
||||
ast::TexelFormat::kR32Sint, "image2DArray tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k3d,
|
||||
ast::ImageFormat::kRg32Sint, "image3D tex;"},
|
||||
ast::TexelFormat::kRg32Sint, "image3D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kRgba32Sint, "image1D tex;"}));
|
||||
ast::TexelFormat::kRgba32Sint, "image1D tex;"}));
|
||||
|
||||
} // namespace
|
||||
} // namespace glsl
|
||||
|
|
|
@ -76,26 +76,26 @@ namespace {
|
|||
const char kTempNamePrefix[] = "tint_tmp";
|
||||
const char kSpecConstantPrefix[] = "WGSL_SPEC_CONSTANT_";
|
||||
|
||||
const char* image_format_to_rwtexture_type(ast::ImageFormat image_format) {
|
||||
const char* image_format_to_rwtexture_type(ast::TexelFormat image_format) {
|
||||
switch (image_format) {
|
||||
case ast::ImageFormat::kRgba8Unorm:
|
||||
case ast::ImageFormat::kRgba8Snorm:
|
||||
case ast::ImageFormat::kRgba16Float:
|
||||
case ast::ImageFormat::kR32Float:
|
||||
case ast::ImageFormat::kRg32Float:
|
||||
case ast::ImageFormat::kRgba32Float:
|
||||
case ast::TexelFormat::kRgba8Unorm:
|
||||
case ast::TexelFormat::kRgba8Snorm:
|
||||
case ast::TexelFormat::kRgba16Float:
|
||||
case ast::TexelFormat::kR32Float:
|
||||
case ast::TexelFormat::kRg32Float:
|
||||
case ast::TexelFormat::kRgba32Float:
|
||||
return "float4";
|
||||
case ast::ImageFormat::kRgba8Uint:
|
||||
case ast::ImageFormat::kRgba16Uint:
|
||||
case ast::ImageFormat::kR32Uint:
|
||||
case ast::ImageFormat::kRg32Uint:
|
||||
case ast::ImageFormat::kRgba32Uint:
|
||||
case ast::TexelFormat::kRgba8Uint:
|
||||
case ast::TexelFormat::kRgba16Uint:
|
||||
case ast::TexelFormat::kR32Uint:
|
||||
case ast::TexelFormat::kRg32Uint:
|
||||
case ast::TexelFormat::kRgba32Uint:
|
||||
return "uint4";
|
||||
case ast::ImageFormat::kRgba8Sint:
|
||||
case ast::ImageFormat::kRgba16Sint:
|
||||
case ast::ImageFormat::kR32Sint:
|
||||
case ast::ImageFormat::kRg32Sint:
|
||||
case ast::ImageFormat::kRgba32Sint:
|
||||
case ast::TexelFormat::kRgba8Sint:
|
||||
case ast::TexelFormat::kRgba16Sint:
|
||||
case ast::TexelFormat::kR32Sint:
|
||||
case ast::TexelFormat::kRg32Sint:
|
||||
case ast::TexelFormat::kRgba32Sint:
|
||||
return "int4";
|
||||
default:
|
||||
return nullptr;
|
||||
|
@ -3623,11 +3623,11 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
|||
}
|
||||
|
||||
if (storage) {
|
||||
auto* component = image_format_to_rwtexture_type(storage->image_format());
|
||||
auto* component = image_format_to_rwtexture_type(storage->texel_format());
|
||||
if (component == nullptr) {
|
||||
TINT_ICE(Writer, diagnostics_)
|
||||
<< "Unsupported StorageTexture ImageFormat: "
|
||||
<< static_cast<int>(storage->image_format());
|
||||
<< "Unsupported StorageTexture TexelFormat: "
|
||||
<< static_cast<int>(storage->texel_format());
|
||||
return false;
|
||||
}
|
||||
out << "<" << component << ">";
|
||||
|
|
|
@ -532,7 +532,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
|||
|
||||
struct HlslStorageTextureData {
|
||||
ast::TextureDimension dim;
|
||||
ast::ImageFormat imgfmt;
|
||||
ast::TexelFormat imgfmt;
|
||||
std::string result;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out,
|
||||
|
@ -561,43 +561,43 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
HlslStorageTexturesTest,
|
||||
testing::Values(
|
||||
HlslStorageTextureData{
|
||||
ast::TextureDimension::k1d, ast::ImageFormat::kRgba8Unorm,
|
||||
ast::TextureDimension::k1d, ast::TexelFormat::kRgba8Unorm,
|
||||
"RWTexture1D<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{
|
||||
ast::TextureDimension::k2d, ast::ImageFormat::kRgba16Float,
|
||||
ast::TextureDimension::k2d, ast::TexelFormat::kRgba16Float,
|
||||
"RWTexture2D<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{
|
||||
ast::TextureDimension::k2dArray, ast::ImageFormat::kR32Float,
|
||||
ast::TextureDimension::k2dArray, ast::TexelFormat::kR32Float,
|
||||
"RWTexture2DArray<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{
|
||||
ast::TextureDimension::k3d, ast::ImageFormat::kRg32Float,
|
||||
ast::TextureDimension::k3d, ast::TexelFormat::kRg32Float,
|
||||
"RWTexture3D<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{
|
||||
ast::TextureDimension::k1d, ast::ImageFormat::kRgba32Float,
|
||||
ast::TextureDimension::k1d, ast::TexelFormat::kRgba32Float,
|
||||
"RWTexture1D<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{
|
||||
ast::TextureDimension::k2d, ast::ImageFormat::kRgba16Uint,
|
||||
ast::TextureDimension::k2d, ast::TexelFormat::kRgba16Uint,
|
||||
"RWTexture2D<uint4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{
|
||||
ast::TextureDimension::k2dArray, ast::ImageFormat::kR32Uint,
|
||||
ast::TextureDimension::k2dArray, ast::TexelFormat::kR32Uint,
|
||||
"RWTexture2DArray<uint4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{
|
||||
ast::TextureDimension::k3d, ast::ImageFormat::kRg32Uint,
|
||||
ast::TextureDimension::k3d, ast::TexelFormat::kRg32Uint,
|
||||
"RWTexture3D<uint4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{
|
||||
ast::TextureDimension::k1d, ast::ImageFormat::kRgba32Uint,
|
||||
ast::TextureDimension::k1d, ast::TexelFormat::kRgba32Uint,
|
||||
"RWTexture1D<uint4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kRgba16Sint,
|
||||
ast::TexelFormat::kRgba16Sint,
|
||||
"RWTexture2D<int4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{
|
||||
ast::TextureDimension::k2dArray, ast::ImageFormat::kR32Sint,
|
||||
ast::TextureDimension::k2dArray, ast::TexelFormat::kR32Sint,
|
||||
"RWTexture2DArray<int4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k3d,
|
||||
ast::ImageFormat::kRg32Sint,
|
||||
ast::TexelFormat::kRg32Sint,
|
||||
"RWTexture3D<int4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{
|
||||
ast::TextureDimension::k1d, ast::ImageFormat::kRgba32Sint,
|
||||
ast::TextureDimension::k1d, ast::TexelFormat::kRgba32Sint,
|
||||
"RWTexture1D<int4> tex : register(u1, space2);"}));
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -852,7 +852,7 @@ using MslStorageTexturesTest = TestParamHelper<MslStorageTextureData>;
|
|||
TEST_P(MslStorageTexturesTest, Emit) {
|
||||
auto params = GetParam();
|
||||
|
||||
auto* s = ty.storage_texture(params.dim, ast::ImageFormat::kR32Float,
|
||||
auto* s = ty.storage_texture(params.dim, ast::TexelFormat::kR32Float,
|
||||
ast::Access::kWrite);
|
||||
Global("test_var", s,
|
||||
ast::DecorationList{
|
||||
|
|
|
@ -3916,17 +3916,17 @@ uint32_t Builder::GenerateTypeIfNeeded(const sem::Type* type) {
|
|||
// the access type. Doing this ensures we de-dupe.
|
||||
type_name_to_id_[builder_
|
||||
.create<sem::StorageTexture>(
|
||||
st->dim(), st->image_format(),
|
||||
st->dim(), st->texel_format(),
|
||||
ast::Access::kRead, st->type())
|
||||
->type_name()] = id;
|
||||
type_name_to_id_[builder_
|
||||
.create<sem::StorageTexture>(
|
||||
st->dim(), st->image_format(),
|
||||
st->dim(), st->texel_format(),
|
||||
ast::Access::kWrite, st->type())
|
||||
->type_name()] = id;
|
||||
type_name_to_id_[builder_
|
||||
.create<sem::StorageTexture>(
|
||||
st->dim(), st->image_format(),
|
||||
st->dim(), st->texel_format(),
|
||||
ast::Access::kReadWrite, st->type())
|
||||
->type_name()] = id;
|
||||
}
|
||||
|
@ -4014,7 +4014,7 @@ bool Builder::GenerateTextureType(const sem::Texture* texture,
|
|||
|
||||
uint32_t format_literal = SpvImageFormat_::SpvImageFormatUnknown;
|
||||
if (auto* t = texture->As<sem::StorageTexture>()) {
|
||||
format_literal = convert_image_format_to_spv(t->image_format());
|
||||
format_literal = convert_texel_format_to_spv(t->texel_format());
|
||||
}
|
||||
|
||||
push_type(spv::Op::OpTypeImage,
|
||||
|
@ -4291,99 +4291,99 @@ void Builder::AddInterpolationDecorations(uint32_t id,
|
|||
}
|
||||
}
|
||||
|
||||
SpvImageFormat Builder::convert_image_format_to_spv(
|
||||
const ast::ImageFormat format) {
|
||||
SpvImageFormat Builder::convert_texel_format_to_spv(
|
||||
const ast::TexelFormat format) {
|
||||
switch (format) {
|
||||
case ast::ImageFormat::kR8Unorm:
|
||||
case ast::TexelFormat::kR8Unorm:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatR8;
|
||||
case ast::ImageFormat::kR8Snorm:
|
||||
case ast::TexelFormat::kR8Snorm:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatR8Snorm;
|
||||
case ast::ImageFormat::kR8Uint:
|
||||
case ast::TexelFormat::kR8Uint:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatR8ui;
|
||||
case ast::ImageFormat::kR8Sint:
|
||||
case ast::TexelFormat::kR8Sint:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatR8i;
|
||||
case ast::ImageFormat::kR16Uint:
|
||||
case ast::TexelFormat::kR16Uint:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatR16ui;
|
||||
case ast::ImageFormat::kR16Sint:
|
||||
case ast::TexelFormat::kR16Sint:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatR16i;
|
||||
case ast::ImageFormat::kR16Float:
|
||||
case ast::TexelFormat::kR16Float:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatR16f;
|
||||
case ast::ImageFormat::kRg8Unorm:
|
||||
case ast::TexelFormat::kRg8Unorm:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg8;
|
||||
case ast::ImageFormat::kRg8Snorm:
|
||||
case ast::TexelFormat::kRg8Snorm:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg8Snorm;
|
||||
case ast::ImageFormat::kRg8Uint:
|
||||
case ast::TexelFormat::kRg8Uint:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg8ui;
|
||||
case ast::ImageFormat::kRg8Sint:
|
||||
case ast::TexelFormat::kRg8Sint:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg8i;
|
||||
case ast::ImageFormat::kR32Uint:
|
||||
case ast::TexelFormat::kR32Uint:
|
||||
return SpvImageFormatR32ui;
|
||||
case ast::ImageFormat::kR32Sint:
|
||||
case ast::TexelFormat::kR32Sint:
|
||||
return SpvImageFormatR32i;
|
||||
case ast::ImageFormat::kR32Float:
|
||||
case ast::TexelFormat::kR32Float:
|
||||
return SpvImageFormatR32f;
|
||||
case ast::ImageFormat::kRg16Uint:
|
||||
case ast::TexelFormat::kRg16Uint:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg16ui;
|
||||
case ast::ImageFormat::kRg16Sint:
|
||||
case ast::TexelFormat::kRg16Sint:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg16i;
|
||||
case ast::ImageFormat::kRg16Float:
|
||||
case ast::TexelFormat::kRg16Float:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg16f;
|
||||
case ast::ImageFormat::kRgba8Unorm:
|
||||
case ast::TexelFormat::kRgba8Unorm:
|
||||
return SpvImageFormatRgba8;
|
||||
case ast::ImageFormat::kRgba8UnormSrgb:
|
||||
case ast::TexelFormat::kRgba8UnormSrgb:
|
||||
return SpvImageFormatUnknown;
|
||||
case ast::ImageFormat::kRgba8Snorm:
|
||||
case ast::TexelFormat::kRgba8Snorm:
|
||||
return SpvImageFormatRgba8Snorm;
|
||||
case ast::ImageFormat::kRgba8Uint:
|
||||
case ast::TexelFormat::kRgba8Uint:
|
||||
return SpvImageFormatRgba8ui;
|
||||
case ast::ImageFormat::kRgba8Sint:
|
||||
case ast::TexelFormat::kRgba8Sint:
|
||||
return SpvImageFormatRgba8i;
|
||||
case ast::ImageFormat::kBgra8Unorm:
|
||||
case ast::TexelFormat::kBgra8Unorm:
|
||||
return SpvImageFormatUnknown;
|
||||
case ast::ImageFormat::kBgra8UnormSrgb:
|
||||
case ast::TexelFormat::kBgra8UnormSrgb:
|
||||
return SpvImageFormatUnknown;
|
||||
case ast::ImageFormat::kRgb10A2Unorm:
|
||||
case ast::TexelFormat::kRgb10A2Unorm:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRgb10A2;
|
||||
case ast::ImageFormat::kRg11B10Float:
|
||||
case ast::TexelFormat::kRg11B10Float:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatR11fG11fB10f;
|
||||
case ast::ImageFormat::kRg32Uint:
|
||||
case ast::TexelFormat::kRg32Uint:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg32ui;
|
||||
case ast::ImageFormat::kRg32Sint:
|
||||
case ast::TexelFormat::kRg32Sint:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg32i;
|
||||
case ast::ImageFormat::kRg32Float:
|
||||
case ast::TexelFormat::kRg32Float:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg32f;
|
||||
case ast::ImageFormat::kRgba16Uint:
|
||||
case ast::TexelFormat::kRgba16Uint:
|
||||
return SpvImageFormatRgba16ui;
|
||||
case ast::ImageFormat::kRgba16Sint:
|
||||
case ast::TexelFormat::kRgba16Sint:
|
||||
return SpvImageFormatRgba16i;
|
||||
case ast::ImageFormat::kRgba16Float:
|
||||
case ast::TexelFormat::kRgba16Float:
|
||||
return SpvImageFormatRgba16f;
|
||||
case ast::ImageFormat::kRgba32Uint:
|
||||
case ast::TexelFormat::kRgba32Uint:
|
||||
return SpvImageFormatRgba32ui;
|
||||
case ast::ImageFormat::kRgba32Sint:
|
||||
case ast::TexelFormat::kRgba32Sint:
|
||||
return SpvImageFormatRgba32i;
|
||||
case ast::ImageFormat::kRgba32Float:
|
||||
case ast::TexelFormat::kRgba32Float:
|
||||
return SpvImageFormatRgba32f;
|
||||
case ast::ImageFormat::kNone:
|
||||
case ast::TexelFormat::kNone:
|
||||
return SpvImageFormatUnknown;
|
||||
}
|
||||
return SpvImageFormatUnknown;
|
||||
|
|
|
@ -555,10 +555,10 @@ class Builder {
|
|||
const sem::Matrix* type,
|
||||
spv::Op op);
|
||||
|
||||
/// Converts AST image format to SPIR-V and pushes an appropriate capability.
|
||||
/// Converts TexelFormat to SPIR-V and pushes an appropriate capability.
|
||||
/// @param format AST image format type
|
||||
/// @returns SPIR-V image format type
|
||||
SpvImageFormat convert_image_format_to_spv(const ast::ImageFormat format);
|
||||
SpvImageFormat convert_texel_format_to_spv(const ast::TexelFormat format);
|
||||
|
||||
/// Determines if the given type constructor is created from constant values
|
||||
/// @param expr the expression to check
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace spirv {
|
|||
namespace {
|
||||
|
||||
struct TestData {
|
||||
ast::ImageFormat ast_format;
|
||||
ast::TexelFormat ast_format;
|
||||
SpvImageFormat_ spv_format;
|
||||
bool extended_format = false;
|
||||
};
|
||||
|
@ -36,7 +36,7 @@ TEST_P(ImageFormatConversionTest, ImageFormatConversion) {
|
|||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
EXPECT_EQ(b.convert_image_format_to_spv(param.ast_format), param.spv_format);
|
||||
EXPECT_EQ(b.convert_texel_format_to_spv(param.ast_format), param.spv_format);
|
||||
|
||||
if (param.extended_format) {
|
||||
EXPECT_EQ(DumpInstructions(b.capabilities()),
|
||||
|
@ -51,42 +51,42 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
BuilderTest,
|
||||
ImageFormatConversionTest,
|
||||
testing::Values(
|
||||
TestData{ast::ImageFormat::kR8Unorm, SpvImageFormatR8, true},
|
||||
TestData{ast::ImageFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
|
||||
TestData{ast::ImageFormat::kR8Uint, SpvImageFormatR8ui, true},
|
||||
TestData{ast::ImageFormat::kR8Sint, SpvImageFormatR8i, true},
|
||||
TestData{ast::ImageFormat::kR16Uint, SpvImageFormatR16ui, true},
|
||||
TestData{ast::ImageFormat::kR16Sint, SpvImageFormatR16i, true},
|
||||
TestData{ast::ImageFormat::kR16Float, SpvImageFormatR16f, true},
|
||||
TestData{ast::ImageFormat::kRg8Unorm, SpvImageFormatRg8, true},
|
||||
TestData{ast::ImageFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true},
|
||||
TestData{ast::ImageFormat::kRg8Uint, SpvImageFormatRg8ui, true},
|
||||
TestData{ast::ImageFormat::kRg8Sint, SpvImageFormatRg8i, true},
|
||||
TestData{ast::ImageFormat::kR32Uint, SpvImageFormatR32ui},
|
||||
TestData{ast::ImageFormat::kR32Sint, SpvImageFormatR32i},
|
||||
TestData{ast::ImageFormat::kR32Float, SpvImageFormatR32f},
|
||||
TestData{ast::ImageFormat::kRg16Uint, SpvImageFormatRg16ui, true},
|
||||
TestData{ast::ImageFormat::kRg16Sint, SpvImageFormatRg16i, true},
|
||||
TestData{ast::ImageFormat::kRg16Float, SpvImageFormatRg16f, true},
|
||||
TestData{ast::ImageFormat::kRgba8Unorm, SpvImageFormatRgba8},
|
||||
TestData{ast::ImageFormat::kRgba8UnormSrgb, SpvImageFormatUnknown},
|
||||
TestData{ast::ImageFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
|
||||
TestData{ast::ImageFormat::kRgba8Uint, SpvImageFormatRgba8ui},
|
||||
TestData{ast::ImageFormat::kRgba8Sint, SpvImageFormatRgba8i},
|
||||
TestData{ast::ImageFormat::kBgra8Unorm, SpvImageFormatUnknown},
|
||||
TestData{ast::ImageFormat::kBgra8UnormSrgb, SpvImageFormatUnknown},
|
||||
TestData{ast::ImageFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true},
|
||||
TestData{ast::ImageFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f,
|
||||
TestData{ast::TexelFormat::kR8Unorm, SpvImageFormatR8, true},
|
||||
TestData{ast::TexelFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
|
||||
TestData{ast::TexelFormat::kR8Uint, SpvImageFormatR8ui, true},
|
||||
TestData{ast::TexelFormat::kR8Sint, SpvImageFormatR8i, true},
|
||||
TestData{ast::TexelFormat::kR16Uint, SpvImageFormatR16ui, true},
|
||||
TestData{ast::TexelFormat::kR16Sint, SpvImageFormatR16i, true},
|
||||
TestData{ast::TexelFormat::kR16Float, SpvImageFormatR16f, true},
|
||||
TestData{ast::TexelFormat::kRg8Unorm, SpvImageFormatRg8, true},
|
||||
TestData{ast::TexelFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true},
|
||||
TestData{ast::TexelFormat::kRg8Uint, SpvImageFormatRg8ui, true},
|
||||
TestData{ast::TexelFormat::kRg8Sint, SpvImageFormatRg8i, true},
|
||||
TestData{ast::TexelFormat::kR32Uint, SpvImageFormatR32ui},
|
||||
TestData{ast::TexelFormat::kR32Sint, SpvImageFormatR32i},
|
||||
TestData{ast::TexelFormat::kR32Float, SpvImageFormatR32f},
|
||||
TestData{ast::TexelFormat::kRg16Uint, SpvImageFormatRg16ui, true},
|
||||
TestData{ast::TexelFormat::kRg16Sint, SpvImageFormatRg16i, true},
|
||||
TestData{ast::TexelFormat::kRg16Float, SpvImageFormatRg16f, true},
|
||||
TestData{ast::TexelFormat::kRgba8Unorm, SpvImageFormatRgba8},
|
||||
TestData{ast::TexelFormat::kRgba8UnormSrgb, SpvImageFormatUnknown},
|
||||
TestData{ast::TexelFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
|
||||
TestData{ast::TexelFormat::kRgba8Uint, SpvImageFormatRgba8ui},
|
||||
TestData{ast::TexelFormat::kRgba8Sint, SpvImageFormatRgba8i},
|
||||
TestData{ast::TexelFormat::kBgra8Unorm, SpvImageFormatUnknown},
|
||||
TestData{ast::TexelFormat::kBgra8UnormSrgb, SpvImageFormatUnknown},
|
||||
TestData{ast::TexelFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true},
|
||||
TestData{ast::TexelFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f,
|
||||
true},
|
||||
TestData{ast::ImageFormat::kRg32Uint, SpvImageFormatRg32ui, true},
|
||||
TestData{ast::ImageFormat::kRg32Sint, SpvImageFormatRg32i, true},
|
||||
TestData{ast::ImageFormat::kRg32Float, SpvImageFormatRg32f, true},
|
||||
TestData{ast::ImageFormat::kRgba16Uint, SpvImageFormatRgba16ui},
|
||||
TestData{ast::ImageFormat::kRgba16Sint, SpvImageFormatRgba16i},
|
||||
TestData{ast::ImageFormat::kRgba16Float, SpvImageFormatRgba16f},
|
||||
TestData{ast::ImageFormat::kRgba32Uint, SpvImageFormatRgba32ui},
|
||||
TestData{ast::ImageFormat::kRgba32Sint, SpvImageFormatRgba32i},
|
||||
TestData{ast::ImageFormat::kRgba32Float, SpvImageFormatRgba32f}));
|
||||
TestData{ast::TexelFormat::kRg32Uint, SpvImageFormatRg32ui, true},
|
||||
TestData{ast::TexelFormat::kRg32Sint, SpvImageFormatRg32i, true},
|
||||
TestData{ast::TexelFormat::kRg32Float, SpvImageFormatRg32f, true},
|
||||
TestData{ast::TexelFormat::kRgba16Uint, SpvImageFormatRgba16ui},
|
||||
TestData{ast::TexelFormat::kRgba16Sint, SpvImageFormatRgba16i},
|
||||
TestData{ast::TexelFormat::kRgba16Float, SpvImageFormatRgba16f},
|
||||
TestData{ast::TexelFormat::kRgba32Uint, SpvImageFormatRgba32ui},
|
||||
TestData{ast::TexelFormat::kRgba32Sint, SpvImageFormatRgba32i},
|
||||
TestData{ast::TexelFormat::kRgba32Float, SpvImageFormatRgba32f}));
|
||||
|
||||
} // namespace
|
||||
} // namespace spirv
|
||||
|
|
|
@ -552,7 +552,7 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) {
|
|||
// var<uniform_constant> a : texture_storage_2d<r32uint, write>;
|
||||
|
||||
auto* type =
|
||||
ty.storage_texture(ast::TextureDimension::k2d, ast::ImageFormat::kR32Uint,
|
||||
ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kWrite);
|
||||
|
||||
auto* var_a = Global("a", type,
|
||||
|
@ -585,7 +585,7 @@ TEST_F(BuilderTest, DISABLED_GlobalVar_TextureStorageWithDifferentAccess) {
|
|||
// var<uniform_constant> b : texture_storage_2d<r32uint, write>;
|
||||
|
||||
auto* type_a =
|
||||
ty.storage_texture(ast::TextureDimension::k2d, ast::ImageFormat::kR32Uint,
|
||||
ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kReadWrite);
|
||||
auto* var_a = Global("a", type_a, ast::StorageClass::kNone,
|
||||
ast::DecorationList{
|
||||
|
@ -594,7 +594,7 @@ TEST_F(BuilderTest, DISABLED_GlobalVar_TextureStorageWithDifferentAccess) {
|
|||
});
|
||||
|
||||
auto* type_b =
|
||||
ty.storage_texture(ast::TextureDimension::k2d, ast::ImageFormat::kR32Uint,
|
||||
ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kWrite);
|
||||
auto* var_b = Global("b", type_b, ast::StorageClass::kNone,
|
||||
ast::DecorationList{
|
||||
|
|
|
@ -791,7 +791,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
|
|||
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
|
||||
auto* s =
|
||||
ty.storage_texture(ast::TextureDimension::k1d,
|
||||
ast::ImageFormat::kR32Float, ast::Access::kWrite);
|
||||
ast::TexelFormat::kR32Float, ast::Access::kWrite);
|
||||
|
||||
Global("test_var", s,
|
||||
ast::DecorationList{
|
||||
|
@ -811,7 +811,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
|
|||
TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
|
||||
auto* s =
|
||||
ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Float, ast::Access::kWrite);
|
||||
ast::TexelFormat::kR32Float, ast::Access::kWrite);
|
||||
|
||||
Global("test_var", s,
|
||||
ast::DecorationList{
|
||||
|
@ -831,7 +831,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
|
|||
TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
|
||||
auto* s =
|
||||
ty.storage_texture(ast::TextureDimension::k2dArray,
|
||||
ast::ImageFormat::kR32Float, ast::Access::kWrite);
|
||||
ast::TexelFormat::kR32Float, ast::Access::kWrite);
|
||||
|
||||
Global("test_var", s,
|
||||
ast::DecorationList{
|
||||
|
@ -851,7 +851,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
|
|||
TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
|
||||
auto* s =
|
||||
ty.storage_texture(ast::TextureDimension::k3d,
|
||||
ast::ImageFormat::kR32Float, ast::Access::kWrite);
|
||||
ast::TexelFormat::kR32Float, ast::Access::kWrite);
|
||||
|
||||
Global("test_var", s,
|
||||
ast::DecorationList{
|
||||
|
@ -872,7 +872,7 @@ TEST_F(BuilderTest_Type,
|
|||
StorageTexture_Generate_SampledTypeFloat_Format_r32float) {
|
||||
auto* s =
|
||||
ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Float, ast::Access::kWrite);
|
||||
ast::TexelFormat::kR32Float, ast::Access::kWrite);
|
||||
|
||||
Global("test_var", s,
|
||||
ast::DecorationList{
|
||||
|
@ -892,7 +892,7 @@ TEST_F(BuilderTest_Type,
|
|||
TEST_F(BuilderTest_Type,
|
||||
StorageTexture_Generate_SampledTypeSint_Format_r32sint) {
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Sint, ast::Access::kWrite);
|
||||
ast::TexelFormat::kR32Sint, ast::Access::kWrite);
|
||||
|
||||
Global("test_var", s,
|
||||
ast::DecorationList{
|
||||
|
@ -912,7 +912,7 @@ TEST_F(BuilderTest_Type,
|
|||
TEST_F(BuilderTest_Type,
|
||||
StorageTexture_Generate_SampledTypeUint_Format_r32uint) {
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Uint, ast::Access::kWrite);
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kWrite);
|
||||
|
||||
Global("test_var", s,
|
||||
ast::DecorationList{
|
||||
|
|
|
@ -336,9 +336,9 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
|
|||
}
|
||||
|
||||
bool GeneratorImpl::EmitImageFormat(std::ostream& out,
|
||||
const ast::ImageFormat fmt) {
|
||||
const ast::TexelFormat fmt) {
|
||||
switch (fmt) {
|
||||
case ast::ImageFormat::kNone:
|
||||
case ast::TexelFormat::kNone:
|
||||
diagnostics_.add_error(diag::System::Writer, "unknown image format");
|
||||
return false;
|
||||
default:
|
||||
|
|
|
@ -176,7 +176,7 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// @param out the output of the expression stream
|
||||
/// @param fmt the format to generate
|
||||
/// @returns true if the format is emitted
|
||||
bool EmitImageFormat(std::ostream& out, const ast::ImageFormat fmt);
|
||||
bool EmitImageFormat(std::ostream& out, const ast::TexelFormat fmt);
|
||||
/// Handles emitting an access control
|
||||
/// @param out the output of the expression stream
|
||||
/// @param access the access to generate
|
||||
|
|
|
@ -423,7 +423,7 @@ INSTANTIATE_TEST_SUITE_P(WgslGeneratorImplTest,
|
|||
"texture_multisampled_2d"}));
|
||||
|
||||
struct StorageTextureData {
|
||||
ast::ImageFormat fmt;
|
||||
ast::TexelFormat fmt;
|
||||
ast::TextureDimension dim;
|
||||
ast::Access access;
|
||||
const char* name;
|
||||
|
@ -453,21 +453,21 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
WgslGeneratorImplTest,
|
||||
WgslGenerator_StorageTextureTest,
|
||||
testing::Values(
|
||||
StorageTextureData{ast::ImageFormat::kRgba8Sint,
|
||||
StorageTextureData{ast::TexelFormat::kRgba8Sint,
|
||||
ast::TextureDimension::k1d, ast::Access::kWrite,
|
||||
"texture_storage_1d<rgba8sint, write>"},
|
||||
StorageTextureData{ast::ImageFormat::kRgba8Sint,
|
||||
StorageTextureData{ast::TexelFormat::kRgba8Sint,
|
||||
ast::TextureDimension::k2d, ast::Access::kWrite,
|
||||
"texture_storage_2d<rgba8sint, write>"},
|
||||
StorageTextureData{ast::ImageFormat::kRgba8Sint,
|
||||
StorageTextureData{ast::TexelFormat::kRgba8Sint,
|
||||
ast::TextureDimension::k2dArray, ast::Access::kWrite,
|
||||
"texture_storage_2d_array<rgba8sint, write>"},
|
||||
StorageTextureData{ast::ImageFormat::kRgba8Sint,
|
||||
StorageTextureData{ast::TexelFormat::kRgba8Sint,
|
||||
ast::TextureDimension::k3d, ast::Access::kWrite,
|
||||
"texture_storage_3d<rgba8sint, write>"}));
|
||||
|
||||
struct ImageFormatData {
|
||||
ast::ImageFormat fmt;
|
||||
ast::TexelFormat fmt;
|
||||
const char* name;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, ImageFormatData data) {
|
||||
|
@ -489,41 +489,41 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
WgslGeneratorImplTest,
|
||||
WgslGenerator_ImageFormatTest,
|
||||
testing::Values(
|
||||
ImageFormatData{ast::ImageFormat::kR8Unorm, "r8unorm"},
|
||||
ImageFormatData{ast::ImageFormat::kR8Snorm, "r8snorm"},
|
||||
ImageFormatData{ast::ImageFormat::kR8Uint, "r8uint"},
|
||||
ImageFormatData{ast::ImageFormat::kR8Sint, "r8sint"},
|
||||
ImageFormatData{ast::ImageFormat::kR16Uint, "r16uint"},
|
||||
ImageFormatData{ast::ImageFormat::kR16Sint, "r16sint"},
|
||||
ImageFormatData{ast::ImageFormat::kR16Float, "r16float"},
|
||||
ImageFormatData{ast::ImageFormat::kRg8Unorm, "rg8unorm"},
|
||||
ImageFormatData{ast::ImageFormat::kRg8Snorm, "rg8snorm"},
|
||||
ImageFormatData{ast::ImageFormat::kRg8Uint, "rg8uint"},
|
||||
ImageFormatData{ast::ImageFormat::kRg8Sint, "rg8sint"},
|
||||
ImageFormatData{ast::ImageFormat::kR32Uint, "r32uint"},
|
||||
ImageFormatData{ast::ImageFormat::kR32Sint, "r32sint"},
|
||||
ImageFormatData{ast::ImageFormat::kR32Float, "r32float"},
|
||||
ImageFormatData{ast::ImageFormat::kRg16Uint, "rg16uint"},
|
||||
ImageFormatData{ast::ImageFormat::kRg16Sint, "rg16sint"},
|
||||
ImageFormatData{ast::ImageFormat::kRg16Float, "rg16float"},
|
||||
ImageFormatData{ast::ImageFormat::kRgba8Unorm, "rgba8unorm"},
|
||||
ImageFormatData{ast::ImageFormat::kRgba8UnormSrgb, "rgba8unorm_srgb"},
|
||||
ImageFormatData{ast::ImageFormat::kRgba8Snorm, "rgba8snorm"},
|
||||
ImageFormatData{ast::ImageFormat::kRgba8Uint, "rgba8uint"},
|
||||
ImageFormatData{ast::ImageFormat::kRgba8Sint, "rgba8sint"},
|
||||
ImageFormatData{ast::ImageFormat::kBgra8Unorm, "bgra8unorm"},
|
||||
ImageFormatData{ast::ImageFormat::kBgra8UnormSrgb, "bgra8unorm_srgb"},
|
||||
ImageFormatData{ast::ImageFormat::kRgb10A2Unorm, "rgb10a2unorm"},
|
||||
ImageFormatData{ast::ImageFormat::kRg11B10Float, "rg11b10float"},
|
||||
ImageFormatData{ast::ImageFormat::kRg32Uint, "rg32uint"},
|
||||
ImageFormatData{ast::ImageFormat::kRg32Sint, "rg32sint"},
|
||||
ImageFormatData{ast::ImageFormat::kRg32Float, "rg32float"},
|
||||
ImageFormatData{ast::ImageFormat::kRgba16Uint, "rgba16uint"},
|
||||
ImageFormatData{ast::ImageFormat::kRgba16Sint, "rgba16sint"},
|
||||
ImageFormatData{ast::ImageFormat::kRgba16Float, "rgba16float"},
|
||||
ImageFormatData{ast::ImageFormat::kRgba32Uint, "rgba32uint"},
|
||||
ImageFormatData{ast::ImageFormat::kRgba32Sint, "rgba32sint"},
|
||||
ImageFormatData{ast::ImageFormat::kRgba32Float, "rgba32float"}));
|
||||
ImageFormatData{ast::TexelFormat::kR8Unorm, "r8unorm"},
|
||||
ImageFormatData{ast::TexelFormat::kR8Snorm, "r8snorm"},
|
||||
ImageFormatData{ast::TexelFormat::kR8Uint, "r8uint"},
|
||||
ImageFormatData{ast::TexelFormat::kR8Sint, "r8sint"},
|
||||
ImageFormatData{ast::TexelFormat::kR16Uint, "r16uint"},
|
||||
ImageFormatData{ast::TexelFormat::kR16Sint, "r16sint"},
|
||||
ImageFormatData{ast::TexelFormat::kR16Float, "r16float"},
|
||||
ImageFormatData{ast::TexelFormat::kRg8Unorm, "rg8unorm"},
|
||||
ImageFormatData{ast::TexelFormat::kRg8Snorm, "rg8snorm"},
|
||||
ImageFormatData{ast::TexelFormat::kRg8Uint, "rg8uint"},
|
||||
ImageFormatData{ast::TexelFormat::kRg8Sint, "rg8sint"},
|
||||
ImageFormatData{ast::TexelFormat::kR32Uint, "r32uint"},
|
||||
ImageFormatData{ast::TexelFormat::kR32Sint, "r32sint"},
|
||||
ImageFormatData{ast::TexelFormat::kR32Float, "r32float"},
|
||||
ImageFormatData{ast::TexelFormat::kRg16Uint, "rg16uint"},
|
||||
ImageFormatData{ast::TexelFormat::kRg16Sint, "rg16sint"},
|
||||
ImageFormatData{ast::TexelFormat::kRg16Float, "rg16float"},
|
||||
ImageFormatData{ast::TexelFormat::kRgba8Unorm, "rgba8unorm"},
|
||||
ImageFormatData{ast::TexelFormat::kRgba8UnormSrgb, "rgba8unorm_srgb"},
|
||||
ImageFormatData{ast::TexelFormat::kRgba8Snorm, "rgba8snorm"},
|
||||
ImageFormatData{ast::TexelFormat::kRgba8Uint, "rgba8uint"},
|
||||
ImageFormatData{ast::TexelFormat::kRgba8Sint, "rgba8sint"},
|
||||
ImageFormatData{ast::TexelFormat::kBgra8Unorm, "bgra8unorm"},
|
||||
ImageFormatData{ast::TexelFormat::kBgra8UnormSrgb, "bgra8unorm_srgb"},
|
||||
ImageFormatData{ast::TexelFormat::kRgb10A2Unorm, "rgb10a2unorm"},
|
||||
ImageFormatData{ast::TexelFormat::kRg11B10Float, "rg11b10float"},
|
||||
ImageFormatData{ast::TexelFormat::kRg32Uint, "rg32uint"},
|
||||
ImageFormatData{ast::TexelFormat::kRg32Sint, "rg32sint"},
|
||||
ImageFormatData{ast::TexelFormat::kRg32Float, "rg32float"},
|
||||
ImageFormatData{ast::TexelFormat::kRgba16Uint, "rgba16uint"},
|
||||
ImageFormatData{ast::TexelFormat::kRgba16Sint, "rgba16sint"},
|
||||
ImageFormatData{ast::TexelFormat::kRgba16Float, "rgba16float"},
|
||||
ImageFormatData{ast::TexelFormat::kRgba32Uint, "rgba32uint"},
|
||||
ImageFormatData{ast::TexelFormat::kRgba32Sint, "rgba32sint"},
|
||||
ImageFormatData{ast::TexelFormat::kRgba32Float, "rgba32float"}));
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Sampler) {
|
||||
auto* sampler = ty.sampler(ast::SamplerKind::kSampler);
|
||||
|
|
|
@ -477,7 +477,6 @@ tint_unittests_source_set("tint_unittests_wgsl_reader_src") {
|
|||
"../src/reader/wgsl/parser_impl_global_decl_test.cc",
|
||||
"../src/reader/wgsl/parser_impl_global_variable_decl_test.cc",
|
||||
"../src/reader/wgsl/parser_impl_if_stmt_test.cc",
|
||||
"../src/reader/wgsl/parser_impl_image_storage_type_test.cc",
|
||||
"../src/reader/wgsl/parser_impl_inclusive_or_expression_test.cc",
|
||||
"../src/reader/wgsl/parser_impl_logical_and_expression_test.cc",
|
||||
"../src/reader/wgsl/parser_impl_logical_or_expression_test.cc",
|
||||
|
@ -509,6 +508,7 @@ tint_unittests_source_set("tint_unittests_wgsl_reader_src") {
|
|||
"../src/reader/wgsl/parser_impl_test.cc",
|
||||
"../src/reader/wgsl/parser_impl_test_helper.cc",
|
||||
"../src/reader/wgsl/parser_impl_test_helper.h",
|
||||
"../src/reader/wgsl/parser_impl_texel_format_test.cc",
|
||||
"../src/reader/wgsl/parser_impl_texture_sampler_types_test.cc",
|
||||
"../src/reader/wgsl/parser_impl_type_alias_test.cc",
|
||||
"../src/reader/wgsl/parser_impl_type_decl_test.cc",
|
||||
|
|
Loading…
Reference in New Issue