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