Move ast/texel_format to type/texel_format.

This CL moves the texel_format code from ast to type to remove the
dependency on ast from type.

Change-Id: Ie075b2315360dc782284a7b4b55a817a9de31d78
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117606
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2023-01-21 23:51:25 +00:00 committed by Dawn LUCI CQ
parent 61c16eb448
commit 57c0bbc2a5
59 changed files with 529 additions and 527 deletions

View File

@ -331,8 +331,6 @@ libtint_source_set("libtint_core_all_src") {
"ast/struct_member_size_attribute.h", "ast/struct_member_size_attribute.h",
"ast/switch_statement.cc", "ast/switch_statement.cc",
"ast/switch_statement.h", "ast/switch_statement.h",
"ast/texel_format.cc",
"ast/texel_format.h",
"ast/texture.cc", "ast/texture.cc",
"ast/texture.h", "ast/texture.h",
"ast/traverse_expressions.h", "ast/traverse_expressions.h",
@ -481,6 +479,7 @@ libtint_source_set("libtint_core_all_src") {
"type/short_name.h", "type/short_name.h",
"type/storage_texture.h", "type/storage_texture.h",
"type/struct.h", "type/struct.h",
"type/texel_format.h",
"type/texture.h", "type/texture.h",
"type/texture_dimension.h", "type/texture_dimension.h",
"type/type.h", "type/type.h",
@ -746,6 +745,8 @@ libtint_source_set("libtint_type_src") {
"type/storage_texture.h", "type/storage_texture.h",
"type/struct.cc", "type/struct.cc",
"type/struct.h", "type/struct.h",
"type/texel_format.cc",
"type/texel_format.h",
"type/texture.cc", "type/texture.cc",
"type/texture.h", "type/texture.h",
"type/texture_dimension.cc", "type/texture_dimension.cc",
@ -1204,7 +1205,6 @@ if (tint_build_unittests) {
"ast/struct_test.cc", "ast/struct_test.cc",
"ast/switch_statement_test.cc", "ast/switch_statement_test.cc",
"ast/test_helper.h", "ast/test_helper.h",
"ast/texel_format_test.cc",
"ast/texture_test.cc", "ast/texture_test.cc",
"ast/traverse_expressions_test.cc", "ast/traverse_expressions_test.cc",
"ast/u32_test.cc", "ast/u32_test.cc",
@ -1343,6 +1343,7 @@ if (tint_build_unittests) {
"type/short_name_test.cc", "type/short_name_test.cc",
"type/storage_texture_test.cc", "type/storage_texture_test.cc",
"type/struct_test.cc", "type/struct_test.cc",
"type/texel_format_test.cc",
"type/texture_test.cc", "type/texture_test.cc",
"type/type_test.cc", "type/type_test.cc",
"type/u32_test.cc", "type/u32_test.cc",

View File

@ -569,13 +569,13 @@ list(APPEND TINT_LIB_SRCS
tint_generated(ast/builtin_value BENCH TEST) tint_generated(ast/builtin_value BENCH TEST)
tint_generated(ast/extension BENCH TEST) tint_generated(ast/extension BENCH TEST)
tint_generated(ast/interpolate_attribute BENCH TEST) tint_generated(ast/interpolate_attribute BENCH TEST)
tint_generated(ast/texel_format BENCH TEST)
tint_generated(resolver/init_conv_intrinsic) tint_generated(resolver/init_conv_intrinsic)
tint_generated(sem/builtin_type) tint_generated(sem/builtin_type)
tint_generated(sem/parameter_usage) tint_generated(sem/parameter_usage)
tint_generated(type/access BENCH TEST) tint_generated(type/access BENCH TEST)
tint_generated(type/address_space BENCH TEST) tint_generated(type/address_space BENCH TEST)
tint_generated(type/short_name BENCH TEST) tint_generated(type/short_name BENCH TEST)
tint_generated(type/texel_format BENCH TEST)
if(UNIX) if(UNIX)
list(APPEND TINT_LIB_SRCS diagnostic/printer_posix.cc) list(APPEND TINT_LIB_SRCS diagnostic/printer_posix.cc)

View File

@ -56,7 +56,7 @@ TextureOverloadCase::TextureOverloadCase(ValidTextureOverload o,
TextureOverloadCase::TextureOverloadCase(ValidTextureOverload o, TextureOverloadCase::TextureOverloadCase(ValidTextureOverload o,
const char* d, const char* d,
type::Access acc, type::Access acc,
ast::TexelFormat fmt, type::TexelFormat fmt,
type::TextureDimension dims, type::TextureDimension dims,
TextureDataType datatype, TextureDataType datatype,
const char* f, const char* f,
@ -405,7 +405,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
ValidTextureOverload::kDimensionsStorageWO1d, ValidTextureOverload::kDimensionsStorageWO1d,
"textureDimensions(t : texture_storage_1d<rgba32float>) -> u32", "textureDimensions(t : texture_storage_1d<rgba32float>) -> u32",
type::Access::kWrite, type::Access::kWrite,
ast::TexelFormat::kRgba32Float, type::TexelFormat::kRgba32Float,
type::TextureDimension::k1d, type::TextureDimension::k1d,
TextureDataType::kF32, TextureDataType::kF32,
"textureDimensions", "textureDimensions",
@ -415,7 +415,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
ValidTextureOverload::kDimensionsStorageWO2d, ValidTextureOverload::kDimensionsStorageWO2d,
"textureDimensions(t : texture_storage_2d<rgba32float>) -> vec2<u32>", "textureDimensions(t : texture_storage_2d<rgba32float>) -> vec2<u32>",
type::Access::kWrite, type::Access::kWrite,
ast::TexelFormat::kRgba32Float, type::TexelFormat::kRgba32Float,
type::TextureDimension::k2d, type::TextureDimension::k2d,
TextureDataType::kF32, TextureDataType::kF32,
"textureDimensions", "textureDimensions",
@ -425,7 +425,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
ValidTextureOverload::kDimensionsStorageWO2dArray, ValidTextureOverload::kDimensionsStorageWO2dArray,
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> vec2<u32>", "textureDimensions(t : texture_storage_2d_array<rgba32float>) -> vec2<u32>",
type::Access::kWrite, type::Access::kWrite,
ast::TexelFormat::kRgba32Float, type::TexelFormat::kRgba32Float,
type::TextureDimension::k2dArray, type::TextureDimension::k2dArray,
TextureDataType::kF32, TextureDataType::kF32,
"textureDimensions", "textureDimensions",
@ -435,7 +435,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
ValidTextureOverload::kDimensionsStorageWO3d, ValidTextureOverload::kDimensionsStorageWO3d,
"textureDimensions(t : texture_storage_3d<rgba32float>) -> vec3<u32>", "textureDimensions(t : texture_storage_3d<rgba32float>) -> vec3<u32>",
type::Access::kWrite, type::Access::kWrite,
ast::TexelFormat::kRgba32Float, type::TexelFormat::kRgba32Float,
type::TextureDimension::k3d, type::TextureDimension::k3d,
TextureDataType::kF32, TextureDataType::kF32,
"textureDimensions", "textureDimensions",
@ -828,7 +828,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
ValidTextureOverload::kNumLayersStorageWO2dArray, ValidTextureOverload::kNumLayersStorageWO2dArray,
"textureNumLayers(t : texture_storage_2d_array<rgba32float>) -> u32", "textureNumLayers(t : texture_storage_2d_array<rgba32float>) -> u32",
type::Access::kWrite, type::Access::kWrite,
ast::TexelFormat::kRgba32Float, type::TexelFormat::kRgba32Float,
type::TextureDimension::k2dArray, type::TextureDimension::k2dArray,
TextureDataType::kF32, TextureDataType::kF32,
"textureNumLayers", "textureNumLayers",
@ -2328,7 +2328,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
" coords : i32,\n" " coords : i32,\n"
" value : vec4<T>)", " value : vec4<T>)",
type::Access::kWrite, type::Access::kWrite,
ast::TexelFormat::kRgba32Float, type::TexelFormat::kRgba32Float,
type::TextureDimension::k1d, type::TextureDimension::k1d,
TextureDataType::kF32, TextureDataType::kF32,
"textureStore", "textureStore",
@ -2344,7 +2344,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
" coords : vec2<i32>,\n" " coords : vec2<i32>,\n"
" value : vec4<T>)", " value : vec4<T>)",
type::Access::kWrite, type::Access::kWrite,
ast::TexelFormat::kRgba32Float, type::TexelFormat::kRgba32Float,
type::TextureDimension::k2d, type::TextureDimension::k2d,
TextureDataType::kF32, TextureDataType::kF32,
"textureStore", "textureStore",
@ -2361,7 +2361,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
" array_index : u32,\n" " array_index : u32,\n"
" value : vec4<T>)", " value : vec4<T>)",
type::Access::kWrite, type::Access::kWrite,
ast::TexelFormat::kRgba32Float, type::TexelFormat::kRgba32Float,
type::TextureDimension::k2dArray, type::TextureDimension::k2dArray,
TextureDataType::kF32, TextureDataType::kF32,
"textureStore", "textureStore",
@ -2378,7 +2378,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
" coords : vec3<u32>,\n" " coords : vec3<u32>,\n"
" value : vec4<T>)", " value : vec4<T>)",
type::Access::kWrite, type::Access::kWrite,
ast::TexelFormat::kRgba32Float, type::TexelFormat::kRgba32Float,
type::TextureDimension::k3d, type::TextureDimension::k3d,
TextureDataType::kF32, TextureDataType::kF32,
"textureStore", "textureStore",

View File

@ -202,7 +202,7 @@ struct TextureOverloadCase {
TextureOverloadCase(ValidTextureOverload, TextureOverloadCase(ValidTextureOverload,
const char*, const char*,
type::Access, type::Access,
ast::TexelFormat, type::TexelFormat,
type::TextureDimension, type::TextureDimension,
TextureDataType, TextureDataType,
const char*, const char*,
@ -242,7 +242,7 @@ struct TextureOverloadCase {
type::Access const access = type::Access::kReadWrite; type::Access const access = type::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::TexelFormat const texel_format = ast::TexelFormat::kUndefined; type::TexelFormat const texel_format = type::TexelFormat::kUndefined;
/// The dimensions of the texture parameter /// The dimensions of the texture parameter
type::TextureDimension const texture_dimension; type::TextureDimension const texture_dimension;
/// The data type of the texture parameter /// The data type of the texture parameter

View File

@ -27,7 +27,7 @@ StorageTexture::StorageTexture(ProgramID pid,
NodeID nid, NodeID nid,
const Source& src, const Source& src,
type::TextureDimension d, type::TextureDimension d,
TexelFormat fmt, type::TexelFormat fmt,
const Type* subtype, const Type* subtype,
type::Access ac) type::Access ac)
: Base(pid, nid, src, d), format(fmt), type(subtype), access(ac) {} : Base(pid, nid, src, d), format(fmt), type(subtype), access(ac) {}
@ -49,35 +49,35 @@ 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(TexelFormat format, ProgramBuilder& builder) { Type* StorageTexture::SubtypeFor(type::TexelFormat format, ProgramBuilder& builder) {
switch (format) { switch (format) {
case TexelFormat::kR32Uint: case type::TexelFormat::kR32Uint:
case TexelFormat::kRgba8Uint: case type::TexelFormat::kRgba8Uint:
case TexelFormat::kRg32Uint: case type::TexelFormat::kRg32Uint:
case TexelFormat::kRgba16Uint: case type::TexelFormat::kRgba16Uint:
case TexelFormat::kRgba32Uint: { case type::TexelFormat::kRgba32Uint: {
return builder.create<U32>(); return builder.create<U32>();
} }
case TexelFormat::kR32Sint: case type::TexelFormat::kR32Sint:
case TexelFormat::kRgba8Sint: case type::TexelFormat::kRgba8Sint:
case TexelFormat::kRg32Sint: case type::TexelFormat::kRg32Sint:
case TexelFormat::kRgba16Sint: case type::TexelFormat::kRgba16Sint:
case TexelFormat::kRgba32Sint: { case type::TexelFormat::kRgba32Sint: {
return builder.create<I32>(); return builder.create<I32>();
} }
case TexelFormat::kBgra8Unorm: case type::TexelFormat::kBgra8Unorm:
case TexelFormat::kRgba8Unorm: case type::TexelFormat::kRgba8Unorm:
case TexelFormat::kRgba8Snorm: case type::TexelFormat::kRgba8Snorm:
case TexelFormat::kR32Float: case type::TexelFormat::kR32Float:
case TexelFormat::kRg32Float: case type::TexelFormat::kRg32Float:
case TexelFormat::kRgba16Float: case type::TexelFormat::kRgba16Float:
case TexelFormat::kRgba32Float: { case type::TexelFormat::kRgba32Float: {
return builder.create<F32>(); return builder.create<F32>();
} }
case TexelFormat::kUndefined: case type::TexelFormat::kUndefined:
break; break;
} }

View File

@ -17,9 +17,9 @@
#include <string> #include <string>
#include "src/tint/ast/texel_format.h"
#include "src/tint/ast/texture.h" #include "src/tint/ast/texture.h"
#include "src/tint/type/access.h" #include "src/tint/type/access.h"
#include "src/tint/type/texel_format.h"
#include "src/tint/type/texture_dimension.h" #include "src/tint/type/texture_dimension.h"
namespace tint::ast { namespace tint::ast {
@ -39,7 +39,7 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
NodeID nid, NodeID nid,
const Source& src, const Source& src,
type::TextureDimension dim, type::TextureDimension dim,
TexelFormat format, type::TexelFormat format,
const Type* subtype, const Type* subtype,
type::Access access_control); type::Access access_control);
@ -59,11 +59,11 @@ class StorageTexture final : 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 TexelFormat /// @returns the storage texture subtype for the given type::TexelFormat
static Type* SubtypeFor(TexelFormat format, ProgramBuilder& builder); static Type* SubtypeFor(type::TexelFormat format, ProgramBuilder& builder);
/// The image format /// The image format
const TexelFormat format; const type::TexelFormat format;
/// The storage subtype /// The storage subtype
const Type* const type; const Type* const type;

View File

@ -22,39 +22,40 @@ namespace {
using AstStorageTextureTest = TestHelper; using AstStorageTextureTest = TestHelper;
TEST_F(AstStorageTextureTest, IsTexture) { TEST_F(AstStorageTextureTest, IsTexture) {
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this); auto* subtype = StorageTexture::SubtypeFor(type::TexelFormat::kRgba32Float, *this);
Texture* ty = create<StorageTexture>(type::TextureDimension::k2dArray, Texture* ty =
TexelFormat::kRgba32Float, subtype, type::Access::kRead); create<StorageTexture>(type::TextureDimension::k2dArray, type::TexelFormat::kRgba32Float,
subtype, type::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(TexelFormat::kRgba32Float, *this); auto* subtype = StorageTexture::SubtypeFor(type::TexelFormat::kRgba32Float, *this);
auto* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float, auto* s = create<StorageTexture>(type::TextureDimension::k2dArray,
subtype, type::Access::kRead); type::TexelFormat::kRgba32Float, subtype, type::Access::kRead);
EXPECT_EQ(s->dim, type::TextureDimension::k2dArray); EXPECT_EQ(s->dim, type::TextureDimension::k2dArray);
} }
TEST_F(AstStorageTextureTest, Format) { TEST_F(AstStorageTextureTest, Format) {
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this); auto* subtype = StorageTexture::SubtypeFor(type::TexelFormat::kRgba32Float, *this);
auto* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float, auto* s = create<StorageTexture>(type::TextureDimension::k2dArray,
subtype, type::Access::kRead); type::TexelFormat::kRgba32Float, subtype, type::Access::kRead);
EXPECT_EQ(s->format, TexelFormat::kRgba32Float); EXPECT_EQ(s->format, type::TexelFormat::kRgba32Float);
} }
TEST_F(AstStorageTextureTest, FriendlyName) { TEST_F(AstStorageTextureTest, FriendlyName) {
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this); auto* subtype = StorageTexture::SubtypeFor(type::TexelFormat::kRgba32Float, *this);
auto* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float, auto* s = create<StorageTexture>(type::TextureDimension::k2dArray,
subtype, type::Access::kRead); type::TexelFormat::kRgba32Float, subtype, type::Access::kRead);
EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array<rgba32float, read>"); EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array<rgba32float, read>");
} }
TEST_F(AstStorageTextureTest, F32) { TEST_F(AstStorageTextureTest, F32) {
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this); auto* subtype = StorageTexture::SubtypeFor(type::TexelFormat::kRgba32Float, *this);
Type* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float, Type* s = create<StorageTexture>(type::TextureDimension::k2dArray,
subtype, type::Access::kRead); type::TexelFormat::kRgba32Float, subtype, type::Access::kRead);
ASSERT_TRUE(s->Is<Texture>()); ASSERT_TRUE(s->Is<Texture>());
ASSERT_TRUE(s->Is<StorageTexture>()); ASSERT_TRUE(s->Is<StorageTexture>());
@ -62,8 +63,8 @@ TEST_F(AstStorageTextureTest, F32) {
} }
TEST_F(AstStorageTextureTest, U32) { TEST_F(AstStorageTextureTest, U32) {
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRg32Uint, *this); auto* subtype = StorageTexture::SubtypeFor(type::TexelFormat::kRg32Uint, *this);
Type* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRg32Uint, Type* s = create<StorageTexture>(type::TextureDimension::k2dArray, type::TexelFormat::kRg32Uint,
subtype, type::Access::kRead); subtype, type::Access::kRead);
ASSERT_TRUE(s->Is<Texture>()); ASSERT_TRUE(s->Is<Texture>());
@ -72,9 +73,9 @@ TEST_F(AstStorageTextureTest, U32) {
} }
TEST_F(AstStorageTextureTest, I32) { TEST_F(AstStorageTextureTest, I32) {
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Sint, *this); auto* subtype = StorageTexture::SubtypeFor(type::TexelFormat::kRgba32Sint, *this);
Type* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Sint, Type* s = create<StorageTexture>(type::TextureDimension::k2dArray,
subtype, type::Access::kRead); type::TexelFormat::kRgba32Sint, subtype, type::Access::kRead);
ASSERT_TRUE(s->Is<Texture>()); ASSERT_TRUE(s->Is<Texture>());
ASSERT_TRUE(s->Is<StorageTexture>()); ASSERT_TRUE(s->Is<StorageTexture>());

View File

@ -112,7 +112,7 @@ class InspectorGetDepthMultisampledTextureResourceBindingsTest : public Inspecto
public testing::Test {}; public testing::Test {};
typedef std::tuple<type::TextureDimension, ResourceBinding::TextureDimension> DimensionParams; typedef std::tuple<type::TextureDimension, ResourceBinding::TextureDimension> DimensionParams;
typedef std::tuple<ast::TexelFormat, ResourceBinding::TexelFormat, ResourceBinding::SampledKind> typedef std::tuple<type::TexelFormat, ResourceBinding::TexelFormat, ResourceBinding::SampledKind>
TexelFormatParams; TexelFormatParams;
typedef std::tuple<DimensionParams, TexelFormatParams> GetStorageTextureTestParams; typedef std::tuple<DimensionParams, TexelFormatParams> GetStorageTextureTestParams;
class InspectorGetStorageTextureResourceBindingsTestWithParam class InspectorGetStorageTextureResourceBindingsTestWithParam
@ -1808,7 +1808,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
}); });
auto* st_type = auto* st_type =
MakeStorageTextureTypes(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint); MakeStorageTextureTypes(type::TextureDimension::k2d, type::TexelFormat::kR32Uint);
AddStorageTexture("st_var", st_type, 4, 0); AddStorageTexture("st_var", st_type, 4, 0);
MakeStorageTextureBodyFunction("st_func", "st_var", ty.vec2<u32>(), utils::Empty); MakeStorageTextureBodyFunction("st_func", "st_var", ty.vec2<u32>(), utils::Empty);
@ -2970,7 +2970,7 @@ TEST_P(InspectorGetStorageTextureResourceBindingsTestWithParam, Simple) {
ResourceBinding::TextureDimension expected_dim; ResourceBinding::TextureDimension expected_dim;
std::tie(dim, expected_dim) = dim_params; std::tie(dim, expected_dim) = dim_params;
ast::TexelFormat format; type::TexelFormat format;
ResourceBinding::TexelFormat 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;
@ -3026,52 +3026,52 @@ INSTANTIATE_TEST_SUITE_P(
ResourceBinding::TextureDimension::k2dArray), ResourceBinding::TextureDimension::k2dArray),
std::make_tuple(type::TextureDimension::k3d, std::make_tuple(type::TextureDimension::k3d,
ResourceBinding::TextureDimension::k3d)), ResourceBinding::TextureDimension::k3d)),
testing::Values(std::make_tuple(ast::TexelFormat::kR32Float, testing::Values(std::make_tuple(type::TexelFormat::kR32Float,
ResourceBinding::TexelFormat::kR32Float, ResourceBinding::TexelFormat::kR32Float,
ResourceBinding::SampledKind::kFloat), ResourceBinding::SampledKind::kFloat),
std::make_tuple(ast::TexelFormat::kR32Sint, std::make_tuple(type::TexelFormat::kR32Sint,
ResourceBinding::TexelFormat::kR32Sint, ResourceBinding::TexelFormat::kR32Sint,
ResourceBinding::SampledKind::kSInt), ResourceBinding::SampledKind::kSInt),
std::make_tuple(ast::TexelFormat::kR32Uint, std::make_tuple(type::TexelFormat::kR32Uint,
ResourceBinding::TexelFormat::kR32Uint, ResourceBinding::TexelFormat::kR32Uint,
ResourceBinding::SampledKind::kUInt), ResourceBinding::SampledKind::kUInt),
std::make_tuple(ast::TexelFormat::kRg32Float, std::make_tuple(type::TexelFormat::kRg32Float,
ResourceBinding::TexelFormat::kRg32Float, ResourceBinding::TexelFormat::kRg32Float,
ResourceBinding::SampledKind::kFloat), ResourceBinding::SampledKind::kFloat),
std::make_tuple(ast::TexelFormat::kRg32Sint, std::make_tuple(type::TexelFormat::kRg32Sint,
ResourceBinding::TexelFormat::kRg32Sint, ResourceBinding::TexelFormat::kRg32Sint,
ResourceBinding::SampledKind::kSInt), ResourceBinding::SampledKind::kSInt),
std::make_tuple(ast::TexelFormat::kRg32Uint, std::make_tuple(type::TexelFormat::kRg32Uint,
ResourceBinding::TexelFormat::kRg32Uint, ResourceBinding::TexelFormat::kRg32Uint,
ResourceBinding::SampledKind::kUInt), ResourceBinding::SampledKind::kUInt),
std::make_tuple(ast::TexelFormat::kRgba16Float, std::make_tuple(type::TexelFormat::kRgba16Float,
ResourceBinding::TexelFormat::kRgba16Float, ResourceBinding::TexelFormat::kRgba16Float,
ResourceBinding::SampledKind::kFloat), ResourceBinding::SampledKind::kFloat),
std::make_tuple(ast::TexelFormat::kRgba16Sint, std::make_tuple(type::TexelFormat::kRgba16Sint,
ResourceBinding::TexelFormat::kRgba16Sint, ResourceBinding::TexelFormat::kRgba16Sint,
ResourceBinding::SampledKind::kSInt), ResourceBinding::SampledKind::kSInt),
std::make_tuple(ast::TexelFormat::kRgba16Uint, std::make_tuple(type::TexelFormat::kRgba16Uint,
ResourceBinding::TexelFormat::kRgba16Uint, ResourceBinding::TexelFormat::kRgba16Uint,
ResourceBinding::SampledKind::kUInt), ResourceBinding::SampledKind::kUInt),
std::make_tuple(ast::TexelFormat::kRgba32Float, std::make_tuple(type::TexelFormat::kRgba32Float,
ResourceBinding::TexelFormat::kRgba32Float, ResourceBinding::TexelFormat::kRgba32Float,
ResourceBinding::SampledKind::kFloat), ResourceBinding::SampledKind::kFloat),
std::make_tuple(ast::TexelFormat::kRgba32Sint, std::make_tuple(type::TexelFormat::kRgba32Sint,
ResourceBinding::TexelFormat::kRgba32Sint, ResourceBinding::TexelFormat::kRgba32Sint,
ResourceBinding::SampledKind::kSInt), ResourceBinding::SampledKind::kSInt),
std::make_tuple(ast::TexelFormat::kRgba32Uint, std::make_tuple(type::TexelFormat::kRgba32Uint,
ResourceBinding::TexelFormat::kRgba32Uint, ResourceBinding::TexelFormat::kRgba32Uint,
ResourceBinding::SampledKind::kUInt), ResourceBinding::SampledKind::kUInt),
std::make_tuple(ast::TexelFormat::kRgba8Sint, std::make_tuple(type::TexelFormat::kRgba8Sint,
ResourceBinding::TexelFormat::kRgba8Sint, ResourceBinding::TexelFormat::kRgba8Sint,
ResourceBinding::SampledKind::kSInt), ResourceBinding::SampledKind::kSInt),
std::make_tuple(ast::TexelFormat::kRgba8Snorm, std::make_tuple(type::TexelFormat::kRgba8Snorm,
ResourceBinding::TexelFormat::kRgba8Snorm, ResourceBinding::TexelFormat::kRgba8Snorm,
ResourceBinding::SampledKind::kFloat), ResourceBinding::SampledKind::kFloat),
std::make_tuple(ast::TexelFormat::kRgba8Uint, std::make_tuple(type::TexelFormat::kRgba8Uint,
ResourceBinding::TexelFormat::kRgba8Uint, ResourceBinding::TexelFormat::kRgba8Uint,
ResourceBinding::SampledKind::kUInt), ResourceBinding::SampledKind::kUInt),
std::make_tuple(ast::TexelFormat::kRgba8Unorm, std::make_tuple(type::TexelFormat::kRgba8Unorm,
ResourceBinding::TexelFormat::kRgba8Unorm, ResourceBinding::TexelFormat::kRgba8Unorm,
ResourceBinding::SampledKind::kFloat)))); ResourceBinding::SampledKind::kFloat))));

View File

@ -71,43 +71,43 @@ ResourceBinding::SampledKind BaseTypeToSampledKind(const type::Type* base_type)
} }
ResourceBinding::TexelFormat TypeTexelFormatToResourceBindingTexelFormat( ResourceBinding::TexelFormat TypeTexelFormatToResourceBindingTexelFormat(
const ast::TexelFormat& image_format) { const type::TexelFormat& image_format) {
switch (image_format) { switch (image_format) {
case ast::TexelFormat::kBgra8Unorm: case type::TexelFormat::kBgra8Unorm:
return ResourceBinding::TexelFormat::kBgra8Unorm; return ResourceBinding::TexelFormat::kBgra8Unorm;
case ast::TexelFormat::kR32Uint: case type::TexelFormat::kR32Uint:
return ResourceBinding::TexelFormat::kR32Uint; return ResourceBinding::TexelFormat::kR32Uint;
case ast::TexelFormat::kR32Sint: case type::TexelFormat::kR32Sint:
return ResourceBinding::TexelFormat::kR32Sint; return ResourceBinding::TexelFormat::kR32Sint;
case ast::TexelFormat::kR32Float: case type::TexelFormat::kR32Float:
return ResourceBinding::TexelFormat::kR32Float; return ResourceBinding::TexelFormat::kR32Float;
case ast::TexelFormat::kRgba8Unorm: case type::TexelFormat::kRgba8Unorm:
return ResourceBinding::TexelFormat::kRgba8Unorm; return ResourceBinding::TexelFormat::kRgba8Unorm;
case ast::TexelFormat::kRgba8Snorm: case type::TexelFormat::kRgba8Snorm:
return ResourceBinding::TexelFormat::kRgba8Snorm; return ResourceBinding::TexelFormat::kRgba8Snorm;
case ast::TexelFormat::kRgba8Uint: case type::TexelFormat::kRgba8Uint:
return ResourceBinding::TexelFormat::kRgba8Uint; return ResourceBinding::TexelFormat::kRgba8Uint;
case ast::TexelFormat::kRgba8Sint: case type::TexelFormat::kRgba8Sint:
return ResourceBinding::TexelFormat::kRgba8Sint; return ResourceBinding::TexelFormat::kRgba8Sint;
case ast::TexelFormat::kRg32Uint: case type::TexelFormat::kRg32Uint:
return ResourceBinding::TexelFormat::kRg32Uint; return ResourceBinding::TexelFormat::kRg32Uint;
case ast::TexelFormat::kRg32Sint: case type::TexelFormat::kRg32Sint:
return ResourceBinding::TexelFormat::kRg32Sint; return ResourceBinding::TexelFormat::kRg32Sint;
case ast::TexelFormat::kRg32Float: case type::TexelFormat::kRg32Float:
return ResourceBinding::TexelFormat::kRg32Float; return ResourceBinding::TexelFormat::kRg32Float;
case ast::TexelFormat::kRgba16Uint: case type::TexelFormat::kRgba16Uint:
return ResourceBinding::TexelFormat::kRgba16Uint; return ResourceBinding::TexelFormat::kRgba16Uint;
case ast::TexelFormat::kRgba16Sint: case type::TexelFormat::kRgba16Sint:
return ResourceBinding::TexelFormat::kRgba16Sint; return ResourceBinding::TexelFormat::kRgba16Sint;
case ast::TexelFormat::kRgba16Float: case type::TexelFormat::kRgba16Float:
return ResourceBinding::TexelFormat::kRgba16Float; return ResourceBinding::TexelFormat::kRgba16Float;
case ast::TexelFormat::kRgba32Uint: case type::TexelFormat::kRgba32Uint:
return ResourceBinding::TexelFormat::kRgba32Uint; return ResourceBinding::TexelFormat::kRgba32Uint;
case ast::TexelFormat::kRgba32Sint: case type::TexelFormat::kRgba32Sint:
return ResourceBinding::TexelFormat::kRgba32Sint; return ResourceBinding::TexelFormat::kRgba32Sint;
case ast::TexelFormat::kRgba32Float: case type::TexelFormat::kRgba32Float:
return ResourceBinding::TexelFormat::kRgba32Float; return ResourceBinding::TexelFormat::kRgba32Float;
case ast::TexelFormat::kUndefined: case type::TexelFormat::kUndefined:
return ResourceBinding::TexelFormat::kNone; return ResourceBinding::TexelFormat::kNone;
} }
return ResourceBinding::TexelFormat::kNone; return ResourceBinding::TexelFormat::kNone;

View File

@ -116,12 +116,12 @@ ResourceBinding::TextureDimension TypeTextureDimensionToResourceBindingTextureDi
/// @returns the publicly visible equivalent /// @returns the publicly visible equivalent
ResourceBinding::SampledKind BaseTypeToSampledKind(const type::Type* base_type); ResourceBinding::SampledKind BaseTypeToSampledKind(const type::Type* base_type);
/// Convert from internal ast::TexelFormat to public /// Convert from internal type::TexelFormat to public
/// ResourceBinding::TexelFormat /// 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::TexelFormat TypeTexelFormatToResourceBindingTexelFormat( ResourceBinding::TexelFormat TypeTexelFormatToResourceBindingTexelFormat(
const ast::TexelFormat& image_format); const type::TexelFormat& image_format);
} // namespace tint::inspector } // namespace tint::inspector

View File

@ -278,7 +278,7 @@ const ast::Type* InspectorBuilder::GetCoordsType(type::TextureDimension dim,
} }
const ast::Type* InspectorBuilder::MakeStorageTextureTypes(type::TextureDimension dim, const ast::Type* InspectorBuilder::MakeStorageTextureTypes(type::TextureDimension dim,
ast::TexelFormat format) { type::TexelFormat format) {
return ty.storage_texture(dim, format, type::Access::kWrite); return ty.storage_texture(dim, format, type::Access::kWrite);
} }

View File

@ -294,7 +294,7 @@ class InspectorBuilder : public ProgramBuilder {
/// @param dim the texture dimension of the storage texture /// @param dim the texture dimension of the storage texture
/// @param format the texel 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(type::TextureDimension dim, ast::TexelFormat format); const ast::Type* MakeStorageTextureTypes(type::TextureDimension dim, type::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

View File

@ -1082,7 +1082,7 @@ class ProgramBuilder {
/// @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(type::TextureDimension dims, const ast::StorageTexture* storage_texture(type::TextureDimension dims,
ast::TexelFormat format, type::TexelFormat format,
type::Access access) const { type::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, access); return builder->create<ast::StorageTexture>(dims, format, subtype, access);
@ -1095,7 +1095,7 @@ class ProgramBuilder {
/// @returns the storage texture /// @returns the storage texture
const ast::StorageTexture* storage_texture(const Source& source, const ast::StorageTexture* storage_texture(const Source& source,
type::TextureDimension dims, type::TextureDimension dims,
ast::TexelFormat format, type::TexelFormat format,
type::Access access) const { type::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, access); return builder->create<ast::StorageTexture>(source, dims, format, subtype, access);

View File

@ -130,53 +130,53 @@ type::TextureDimension EnumConverter::ToDim(spv::Dim dim, bool arrayed) {
return type::TextureDimension::kNone; return type::TextureDimension::kNone;
} }
ast::TexelFormat EnumConverter::ToTexelFormat(spv::ImageFormat fmt) { type::TexelFormat EnumConverter::ToTexelFormat(spv::ImageFormat fmt) {
switch (fmt) { switch (fmt) {
case spv::ImageFormat::Unknown: case spv::ImageFormat::Unknown:
return ast::TexelFormat::kUndefined; return type::TexelFormat::kUndefined;
// 8 bit channels // 8 bit channels
case spv::ImageFormat::Rgba8: case spv::ImageFormat::Rgba8:
return ast::TexelFormat::kRgba8Unorm; return type::TexelFormat::kRgba8Unorm;
case spv::ImageFormat::Rgba8Snorm: case spv::ImageFormat::Rgba8Snorm:
return ast::TexelFormat::kRgba8Snorm; return type::TexelFormat::kRgba8Snorm;
case spv::ImageFormat::Rgba8ui: case spv::ImageFormat::Rgba8ui:
return ast::TexelFormat::kRgba8Uint; return type::TexelFormat::kRgba8Uint;
case spv::ImageFormat::Rgba8i: case spv::ImageFormat::Rgba8i:
return ast::TexelFormat::kRgba8Sint; return type::TexelFormat::kRgba8Sint;
// 16 bit channels // 16 bit channels
case spv::ImageFormat::Rgba16ui: case spv::ImageFormat::Rgba16ui:
return ast::TexelFormat::kRgba16Uint; return type::TexelFormat::kRgba16Uint;
case spv::ImageFormat::Rgba16i: case spv::ImageFormat::Rgba16i:
return ast::TexelFormat::kRgba16Sint; return type::TexelFormat::kRgba16Sint;
case spv::ImageFormat::Rgba16f: case spv::ImageFormat::Rgba16f:
return ast::TexelFormat::kRgba16Float; return type::TexelFormat::kRgba16Float;
// 32 bit channels // 32 bit channels
case spv::ImageFormat::R32ui: case spv::ImageFormat::R32ui:
return ast::TexelFormat::kR32Uint; return type::TexelFormat::kR32Uint;
case spv::ImageFormat::R32i: case spv::ImageFormat::R32i:
return ast::TexelFormat::kR32Sint; return type::TexelFormat::kR32Sint;
case spv::ImageFormat::R32f: case spv::ImageFormat::R32f:
return ast::TexelFormat::kR32Float; return type::TexelFormat::kR32Float;
case spv::ImageFormat::Rg32ui: case spv::ImageFormat::Rg32ui:
return ast::TexelFormat::kRg32Uint; return type::TexelFormat::kRg32Uint;
case spv::ImageFormat::Rg32i: case spv::ImageFormat::Rg32i:
return ast::TexelFormat::kRg32Sint; return type::TexelFormat::kRg32Sint;
case spv::ImageFormat::Rg32f: case spv::ImageFormat::Rg32f:
return ast::TexelFormat::kRg32Float; return type::TexelFormat::kRg32Float;
case spv::ImageFormat::Rgba32ui: case spv::ImageFormat::Rgba32ui:
return ast::TexelFormat::kRgba32Uint; return type::TexelFormat::kRgba32Uint;
case spv::ImageFormat::Rgba32i: case spv::ImageFormat::Rgba32i:
return ast::TexelFormat::kRgba32Sint; return type::TexelFormat::kRgba32Sint;
case spv::ImageFormat::Rgba32f: case spv::ImageFormat::Rgba32f:
return ast::TexelFormat::kRgba32Float; return type::TexelFormat::kRgba32Float;
default: default:
break; break;
} }
Fail() << "invalid image format: " << int(fmt); Fail() << "invalid image format: " << int(fmt);
return ast::TexelFormat::kUndefined; return type::TexelFormat::kUndefined;
} }
} // namespace tint::reader::spirv } // namespace tint::reader::spirv

View File

@ -73,13 +73,13 @@ class EnumConverter {
/// 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::TexelFormat ToTexelFormat(spv::ImageFormat fmt); type::TexelFormat ToTexelFormat(spv::ImageFormat fmt);
/// Converts a SPIR-V Image Format to a TexelFormat /// 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::TexelFormat ToTexelFormat(SpvImageFormat fmt) { type::TexelFormat ToTexelFormat(SpvImageFormat fmt) {
return ToTexelFormat(static_cast<spv::ImageFormat>(fmt)); return ToTexelFormat(static_cast<spv::ImageFormat>(fmt));
} }

View File

@ -288,7 +288,7 @@ INSTANTIATE_TEST_SUITE_P(
struct TexelFormatCase { struct TexelFormatCase {
spv::ImageFormat format; spv::ImageFormat format;
bool expect_success; bool expect_success;
ast::TexelFormat expected; type::TexelFormat expected;
}; };
inline std::ostream& operator<<(std::ostream& out, TexelFormatCase ifc) { inline std::ostream& operator<<(std::ostream& out, TexelFormatCase ifc) {
out << "TexelFormatCase{ spv::ImageFormat:::" << int(ifc.format) out << "TexelFormatCase{ spv::ImageFormat:::" << int(ifc.format)
@ -330,52 +330,52 @@ INSTANTIATE_TEST_SUITE_P(
SpvImageFormatTest, SpvImageFormatTest,
testing::Values( testing::Values(
// Unknown. This is used for sampled images. // Unknown. This is used for sampled images.
TexelFormatCase{spv::ImageFormat::Unknown, true, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::Unknown, true, type::TexelFormat::kUndefined},
// 8 bit channels // 8 bit channels
TexelFormatCase{spv::ImageFormat::Rgba8, true, ast::TexelFormat::kRgba8Unorm}, TexelFormatCase{spv::ImageFormat::Rgba8, true, type::TexelFormat::kRgba8Unorm},
TexelFormatCase{spv::ImageFormat::Rgba8Snorm, true, ast::TexelFormat::kRgba8Snorm}, TexelFormatCase{spv::ImageFormat::Rgba8Snorm, true, type::TexelFormat::kRgba8Snorm},
TexelFormatCase{spv::ImageFormat::Rgba8ui, true, ast::TexelFormat::kRgba8Uint}, TexelFormatCase{spv::ImageFormat::Rgba8ui, true, type::TexelFormat::kRgba8Uint},
TexelFormatCase{spv::ImageFormat::Rgba8i, true, ast::TexelFormat::kRgba8Sint}, TexelFormatCase{spv::ImageFormat::Rgba8i, true, type::TexelFormat::kRgba8Sint},
// 16 bit channels // 16 bit channels
TexelFormatCase{spv::ImageFormat::Rgba16ui, true, ast::TexelFormat::kRgba16Uint}, TexelFormatCase{spv::ImageFormat::Rgba16ui, true, type::TexelFormat::kRgba16Uint},
TexelFormatCase{spv::ImageFormat::Rgba16i, true, ast::TexelFormat::kRgba16Sint}, TexelFormatCase{spv::ImageFormat::Rgba16i, true, type::TexelFormat::kRgba16Sint},
TexelFormatCase{spv::ImageFormat::Rgba16f, true, ast::TexelFormat::kRgba16Float}, TexelFormatCase{spv::ImageFormat::Rgba16f, true, type::TexelFormat::kRgba16Float},
// 32 bit channels // 32 bit channels
// ... 1 channel // ... 1 channel
TexelFormatCase{spv::ImageFormat::R32ui, true, ast::TexelFormat::kR32Uint}, TexelFormatCase{spv::ImageFormat::R32ui, true, type::TexelFormat::kR32Uint},
TexelFormatCase{spv::ImageFormat::R32i, true, ast::TexelFormat::kR32Sint}, TexelFormatCase{spv::ImageFormat::R32i, true, type::TexelFormat::kR32Sint},
TexelFormatCase{spv::ImageFormat::R32f, true, ast::TexelFormat::kR32Float}, TexelFormatCase{spv::ImageFormat::R32f, true, type::TexelFormat::kR32Float},
// ... 2 channels // ... 2 channels
TexelFormatCase{spv::ImageFormat::Rg32ui, true, ast::TexelFormat::kRg32Uint}, TexelFormatCase{spv::ImageFormat::Rg32ui, true, type::TexelFormat::kRg32Uint},
TexelFormatCase{spv::ImageFormat::Rg32i, true, ast::TexelFormat::kRg32Sint}, TexelFormatCase{spv::ImageFormat::Rg32i, true, type::TexelFormat::kRg32Sint},
TexelFormatCase{spv::ImageFormat::Rg32f, true, ast::TexelFormat::kRg32Float}, TexelFormatCase{spv::ImageFormat::Rg32f, true, type::TexelFormat::kRg32Float},
// ... 4 channels // ... 4 channels
TexelFormatCase{spv::ImageFormat::Rgba32ui, true, ast::TexelFormat::kRgba32Uint}, TexelFormatCase{spv::ImageFormat::Rgba32ui, true, type::TexelFormat::kRgba32Uint},
TexelFormatCase{spv::ImageFormat::Rgba32i, true, ast::TexelFormat::kRgba32Sint}, TexelFormatCase{spv::ImageFormat::Rgba32i, true, type::TexelFormat::kRgba32Sint},
TexelFormatCase{spv::ImageFormat::Rgba32f, true, ast::TexelFormat::kRgba32Float})); TexelFormatCase{spv::ImageFormat::Rgba32f, true, type::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.
TexelFormatCase{spv::ImageFormat::Rg16f, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::Rg16f, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::R11fG11fB10f, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::R11fG11fB10f, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::R16f, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::R16f, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::Rgb10A2, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::Rgb10A2, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::Rg16, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::Rg16, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::Rg8, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::Rg8, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::R16, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::R16, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::R8, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::R8, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::Rgba16Snorm, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::Rgba16Snorm, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::Rg16Snorm, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::Rg16Snorm, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::Rg8Snorm, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::Rg8Snorm, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::Rg16i, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::Rg16i, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::Rg8i, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::Rg8i, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::R8i, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::R8i, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::Rgb10a2ui, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::Rgb10a2ui, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::Rg16ui, false, ast::TexelFormat::kUndefined}, TexelFormatCase{spv::ImageFormat::Rg16ui, false, type::TexelFormat::kUndefined},
TexelFormatCase{spv::ImageFormat::Rg8ui, false, ast::TexelFormat::kUndefined})); TexelFormatCase{spv::ImageFormat::Rg8ui, false, type::TexelFormat::kUndefined}));
} // namespace } // namespace
} // namespace tint::reader::spirv } // namespace tint::reader::spirv

View File

@ -2520,7 +2520,7 @@ const Type* ParserImpl::GetHandleTypeForSpirvHandle(const spvtools::opt::Instruc
} else { } else {
const auto access = type::Access::kWrite; const auto access = type::Access::kWrite;
const auto format = enum_converter_.ToTexelFormat(image_type->format()); const auto format = enum_converter_.ToTexelFormat(image_type->format());
if (format == ast::TexelFormat::kUndefined) { if (format == type::TexelFormat::kUndefined) {
return nullptr; return nullptr;
} }
ast_handle_type = ty_.StorageTexture(dim, format, access); ast_handle_type = ty_.StorageTexture(dim, format, access);
@ -2537,28 +2537,28 @@ const Type* ParserImpl::GetHandleTypeForSpirvHandle(const spvtools::opt::Instruc
return ast_handle_type; return ast_handle_type;
} }
const Type* ParserImpl::GetComponentTypeForFormat(ast::TexelFormat format) { const Type* ParserImpl::GetComponentTypeForFormat(type::TexelFormat format) {
switch (format) { switch (format) {
case ast::TexelFormat::kR32Uint: case type::TexelFormat::kR32Uint:
case ast::TexelFormat::kRgba8Uint: case type::TexelFormat::kRgba8Uint:
case ast::TexelFormat::kRg32Uint: case type::TexelFormat::kRg32Uint:
case ast::TexelFormat::kRgba16Uint: case type::TexelFormat::kRgba16Uint:
case ast::TexelFormat::kRgba32Uint: case type::TexelFormat::kRgba32Uint:
return ty_.U32(); return ty_.U32();
case ast::TexelFormat::kR32Sint: case type::TexelFormat::kR32Sint:
case ast::TexelFormat::kRgba8Sint: case type::TexelFormat::kRgba8Sint:
case ast::TexelFormat::kRg32Sint: case type::TexelFormat::kRg32Sint:
case ast::TexelFormat::kRgba16Sint: case type::TexelFormat::kRgba16Sint:
case ast::TexelFormat::kRgba32Sint: case type::TexelFormat::kRgba32Sint:
return ty_.I32(); return ty_.I32();
case ast::TexelFormat::kRgba8Unorm: case type::TexelFormat::kRgba8Unorm:
case ast::TexelFormat::kRgba8Snorm: case type::TexelFormat::kRgba8Snorm:
case ast::TexelFormat::kR32Float: case type::TexelFormat::kR32Float:
case ast::TexelFormat::kRg32Float: case type::TexelFormat::kRg32Float:
case ast::TexelFormat::kRgba16Float: case type::TexelFormat::kRgba16Float:
case ast::TexelFormat::kRgba32Float: case type::TexelFormat::kRgba32Float:
return ty_.F32(); return ty_.F32();
default: default:
break; break;
@ -2567,30 +2567,30 @@ const Type* ParserImpl::GetComponentTypeForFormat(ast::TexelFormat format) {
return nullptr; return nullptr;
} }
unsigned ParserImpl::GetChannelCountForFormat(ast::TexelFormat format) { unsigned ParserImpl::GetChannelCountForFormat(type::TexelFormat format) {
switch (format) { switch (format) {
case ast::TexelFormat::kR32Float: case type::TexelFormat::kR32Float:
case ast::TexelFormat::kR32Sint: case type::TexelFormat::kR32Sint:
case ast::TexelFormat::kR32Uint: case type::TexelFormat::kR32Uint:
// One channel // One channel
return 1; return 1;
case ast::TexelFormat::kRg32Float: case type::TexelFormat::kRg32Float:
case ast::TexelFormat::kRg32Sint: case type::TexelFormat::kRg32Sint:
case ast::TexelFormat::kRg32Uint: case type::TexelFormat::kRg32Uint:
// Two channels // Two channels
return 2; return 2;
case ast::TexelFormat::kRgba16Float: case type::TexelFormat::kRgba16Float:
case ast::TexelFormat::kRgba16Sint: case type::TexelFormat::kRgba16Sint:
case ast::TexelFormat::kRgba16Uint: case type::TexelFormat::kRgba16Uint:
case ast::TexelFormat::kRgba32Float: case type::TexelFormat::kRgba32Float:
case ast::TexelFormat::kRgba32Sint: case type::TexelFormat::kRgba32Sint:
case ast::TexelFormat::kRgba32Uint: case type::TexelFormat::kRgba32Uint:
case ast::TexelFormat::kRgba8Sint: case type::TexelFormat::kRgba8Sint:
case ast::TexelFormat::kRgba8Snorm: case type::TexelFormat::kRgba8Snorm:
case ast::TexelFormat::kRgba8Uint: case type::TexelFormat::kRgba8Uint:
case ast::TexelFormat::kRgba8Unorm: case type::TexelFormat::kRgba8Unorm:
// Four channels // Four channels
return 4; return 4;
@ -2601,7 +2601,7 @@ unsigned ParserImpl::GetChannelCountForFormat(ast::TexelFormat format) {
return 0; return 0;
} }
const Type* ParserImpl::GetTexelTypeForFormat(ast::TexelFormat format) { const Type* ParserImpl::GetTexelTypeForFormat(type::TexelFormat format) {
const auto* component_type = GetComponentTypeForFormat(format); const auto* component_type = GetComponentTypeForFormat(format);
if (!component_type) { if (!component_type) {
return nullptr; return nullptr;

View File

@ -672,19 +672,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::TexelFormat format); const Type* GetComponentTypeForFormat(type::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::TexelFormat format); unsigned GetChannelCountForFormat(type::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::TexelFormat format); const Type* GetTexelTypeForFormat(type::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

View File

@ -255,7 +255,7 @@ const ast::Type* SampledTexture::Build(ProgramBuilder& b) const {
return b.ty.sampled_texture(dims, type->Build(b)); return b.ty.sampled_texture(dims, type->Build(b));
} }
StorageTexture::StorageTexture(type::TextureDimension d, ast::TexelFormat f, type::Access a) StorageTexture::StorageTexture(type::TextureDimension d, type::TexelFormat f, type::Access a)
: Base(d), format(f), access(a) {} : Base(d), format(f), access(a) {}
StorageTexture::StorageTexture(const StorageTexture&) = default; StorageTexture::StorageTexture(const StorageTexture&) = default;
@ -515,7 +515,7 @@ const spirv::SampledTexture* TypeManager::SampledTexture(type::TextureDimension
} }
const spirv::StorageTexture* TypeManager::StorageTexture(type::TextureDimension dims, const spirv::StorageTexture* TypeManager::StorageTexture(type::TextureDimension dims,
ast::TexelFormat fmt, type::TexelFormat fmt,
type::Access access) { type::Access access) {
return state->storage_textures_.Get(dims, fmt, access); return state->storage_textures_.Get(dims, fmt, access);
} }

View File

@ -435,7 +435,7 @@ struct StorageTexture final : 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(type::TextureDimension d, ast::TexelFormat f, type::Access a); StorageTexture(type::TextureDimension d, type::TexelFormat f, type::Access a);
/// Copy constructor /// Copy constructor
/// @param other the other type to copy /// @param other the other type to copy
@ -451,7 +451,7 @@ struct StorageTexture final : public Castable<StorageTexture, Texture> {
#endif // NDEBUG #endif // NDEBUG
/// the storage image format /// the storage image format
ast::TexelFormat const format; type::TexelFormat const format;
/// the access control /// the access control
type::Access const access; type::Access const access;
@ -616,7 +616,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(type::TextureDimension d, const spirv::StorageTexture* StorageTexture(type::TextureDimension d,
ast::TexelFormat f, type::TexelFormat f,
type::Access a); type::Access a);
private: private:

View File

@ -43,9 +43,9 @@ TEST(SpvParserTypeTest, SameArgumentsGivesSamePointer) {
ty.MultisampledTexture(type::TextureDimension::k2d, ty.I32())); ty.MultisampledTexture(type::TextureDimension::k2d, ty.I32()));
EXPECT_EQ(ty.SampledTexture(type::TextureDimension::k2d, ty.I32()), EXPECT_EQ(ty.SampledTexture(type::TextureDimension::k2d, ty.I32()),
ty.SampledTexture(type::TextureDimension::k2d, ty.I32())); ty.SampledTexture(type::TextureDimension::k2d, ty.I32()));
EXPECT_EQ(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, EXPECT_EQ(ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
type::Access::kRead), type::Access::kRead),
ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
type::Access::kRead)); type::Access::kRead));
} }
@ -80,17 +80,17 @@ TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
ty.SampledTexture(type::TextureDimension::k3d, ty.I32())); ty.SampledTexture(type::TextureDimension::k3d, ty.I32()));
EXPECT_NE(ty.SampledTexture(type::TextureDimension::k2d, ty.I32()), EXPECT_NE(ty.SampledTexture(type::TextureDimension::k2d, ty.I32()),
ty.SampledTexture(type::TextureDimension::k2d, ty.U32())); ty.SampledTexture(type::TextureDimension::k2d, ty.U32()));
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
type::Access::kRead), type::Access::kRead),
ty.StorageTexture(type::TextureDimension::k3d, ast::TexelFormat::kR32Uint, ty.StorageTexture(type::TextureDimension::k3d, type::TexelFormat::kR32Uint,
type::Access::kRead)); type::Access::kRead));
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
type::Access::kRead), type::Access::kRead),
ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Sint, ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Sint,
type::Access::kRead)); type::Access::kRead));
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
type::Access::kRead), type::Access::kRead),
ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
type::Access::kWrite)); type::Access::kWrite));
} }

View File

@ -754,7 +754,7 @@ Maybe<const ast::Type*> ParserImpl::texture_and_sampler_types() {
auto storage = storage_texture_type(); auto storage = storage_texture_type();
if (storage.matched) { if (storage.matched) {
const char* use = "storage texture type"; const char* use = "storage texture type";
using StorageTextureInfo = std::pair<tint::ast::TexelFormat, tint::type::Access>; using StorageTextureInfo = std::pair<tint::type::TexelFormat, tint::type::Access>;
auto params = expect_lt_gt_block(use, [&]() -> Expect<StorageTextureInfo> { auto params = expect_lt_gt_block(use, [&]() -> Expect<StorageTextureInfo> {
auto format = expect_texel_format(use); auto format = expect_texel_format(use);
if (format.errored) { if (format.errored) {
@ -921,8 +921,8 @@ Maybe<const ast::Type*> ParserImpl::depth_texture_type() {
// | 'rgba32uint' // | 'rgba32uint'
// | 'rgba32sint' // | 'rgba32sint'
// | 'rgba32float' // | 'rgba32float'
Expect<ast::TexelFormat> ParserImpl::expect_texel_format(std::string_view use) { Expect<type::TexelFormat> ParserImpl::expect_texel_format(std::string_view use) {
return expect_enum("texel format", ast::ParseTexelFormat, ast::kTexelFormatStrings, use); return expect_enum("texel format", type::ParseTexelFormat, type::kTexelFormatStrings, use);
} }
Expect<ParserImpl::TypedIdentifier> ParserImpl::expect_ident_with_optional_type_specifier( Expect<ParserImpl::TypedIdentifier> ParserImpl::expect_ident_with_optional_type_specifier(

View File

@ -504,7 +504,7 @@ class ParserImpl {
/// Parses a `texel_format` 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 texel format or kNone if none matched. /// @returns returns the texel format or kNone if none matched.
Expect<ast::TexelFormat> expect_texel_format(std::string_view use); Expect<type::TexelFormat> expect_texel_format(std::string_view use);
/// Parses a `static_assert_statement` grammar element /// Parses a `static_assert_statement` grammar element
/// @returns returns the static assert, if it matched. /// @returns returns the static assert, if it matched.
Maybe<const ast::StaticAssert*> static_assert_statement(); Maybe<const ast::StaticAssert*> static_assert_statement();

View File

@ -30,7 +30,7 @@ TEST_F(ParserImplTest, TexelFormat_R32Uint) {
auto p = parser("r32uint"); auto p = parser("r32uint");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kR32Uint); EXPECT_EQ(t.value, type::TexelFormat::kR32Uint);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -38,7 +38,7 @@ TEST_F(ParserImplTest, TexelFormat_R32Sint) {
auto p = parser("r32sint"); auto p = parser("r32sint");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kR32Sint); EXPECT_EQ(t.value, type::TexelFormat::kR32Sint);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -46,7 +46,7 @@ TEST_F(ParserImplTest, TexelFormat_R32Float) {
auto p = parser("r32float"); auto p = parser("r32float");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kR32Float); EXPECT_EQ(t.value, type::TexelFormat::kR32Float);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -54,7 +54,7 @@ TEST_F(ParserImplTest, TexelFormat_Rgba8Unorm) {
auto p = parser("rgba8unorm"); auto p = parser("rgba8unorm");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRgba8Unorm); EXPECT_EQ(t.value, type::TexelFormat::kRgba8Unorm);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -62,7 +62,7 @@ TEST_F(ParserImplTest, TexelFormat_Rgba8Snorm) {
auto p = parser("rgba8snorm"); auto p = parser("rgba8snorm");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRgba8Snorm); EXPECT_EQ(t.value, type::TexelFormat::kRgba8Snorm);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -70,7 +70,7 @@ TEST_F(ParserImplTest, TexelFormat_Rgba8Uint) {
auto p = parser("rgba8uint"); auto p = parser("rgba8uint");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRgba8Uint); EXPECT_EQ(t.value, type::TexelFormat::kRgba8Uint);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -78,7 +78,7 @@ TEST_F(ParserImplTest, TexelFormat_Rgba8Sint) {
auto p = parser("rgba8sint"); auto p = parser("rgba8sint");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRgba8Sint); EXPECT_EQ(t.value, type::TexelFormat::kRgba8Sint);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -86,7 +86,7 @@ TEST_F(ParserImplTest, TexelFormat_Rg32Uint) {
auto p = parser("rg32uint"); auto p = parser("rg32uint");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRg32Uint); EXPECT_EQ(t.value, type::TexelFormat::kRg32Uint);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -94,7 +94,7 @@ TEST_F(ParserImplTest, TexelFormat_Rg32Sint) {
auto p = parser("rg32sint"); auto p = parser("rg32sint");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRg32Sint); EXPECT_EQ(t.value, type::TexelFormat::kRg32Sint);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -102,7 +102,7 @@ TEST_F(ParserImplTest, TexelFormat_Rg32Float) {
auto p = parser("rg32float"); auto p = parser("rg32float");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRg32Float); EXPECT_EQ(t.value, type::TexelFormat::kRg32Float);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -110,7 +110,7 @@ TEST_F(ParserImplTest, TexelFormat_Rgba16Uint) {
auto p = parser("rgba16uint"); auto p = parser("rgba16uint");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRgba16Uint); EXPECT_EQ(t.value, type::TexelFormat::kRgba16Uint);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -118,7 +118,7 @@ TEST_F(ParserImplTest, TexelFormat_Rgba16Sint) {
auto p = parser("rgba16sint"); auto p = parser("rgba16sint");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRgba16Sint); EXPECT_EQ(t.value, type::TexelFormat::kRgba16Sint);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -126,7 +126,7 @@ TEST_F(ParserImplTest, TexelFormat_Rgba16Float) {
auto p = parser("rgba16float"); auto p = parser("rgba16float");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRgba16Float); EXPECT_EQ(t.value, type::TexelFormat::kRgba16Float);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -134,7 +134,7 @@ TEST_F(ParserImplTest, TexelFormat_Rgba32Uint) {
auto p = parser("rgba32uint"); auto p = parser("rgba32uint");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRgba32Uint); EXPECT_EQ(t.value, type::TexelFormat::kRgba32Uint);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -142,7 +142,7 @@ TEST_F(ParserImplTest, TexelFormat_Rgba32Sint) {
auto p = parser("rgba32sint"); auto p = parser("rgba32sint");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRgba32Sint); EXPECT_EQ(t.value, type::TexelFormat::kRgba32Sint);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
@ -150,7 +150,7 @@ TEST_F(ParserImplTest, TexelFormat_Rgba32Float) {
auto p = parser("rgba32float"); auto p = parser("rgba32float");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored); EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRgba32Float); EXPECT_EQ(t.value, type::TexelFormat::kRgba32Float);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }

View File

@ -191,7 +191,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dRg32Float) {
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::TexelFormat::kRg32Float); EXPECT_EQ(t->As<ast::StorageTexture>()->format, type::TexelFormat::kRg32Float);
EXPECT_EQ(t->As<ast::StorageTexture>()->access, type::Access::kRead); EXPECT_EQ(t->As<ast::StorageTexture>()->access, type::Access::kRead);
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k1d); EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k1d);
EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 36u}})); EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 36u}}));
@ -207,7 +207,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR32Uint) {
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::TexelFormat::kR32Uint); EXPECT_EQ(t->As<ast::StorageTexture>()->format, type::TexelFormat::kR32Uint);
EXPECT_EQ(t->As<ast::StorageTexture>()->access, type::Access::kWrite); EXPECT_EQ(t->As<ast::StorageTexture>()->access, type::Access::kWrite);
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2d); EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2d);
EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 35u}})); EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 35u}}));

View File

@ -231,7 +231,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) {
// a = b; // a = b;
auto make_type = [&] { auto make_type = [&] {
return ty.storage_texture(type::TextureDimension::k1d, ast::TexelFormat::kRgba8Unorm, return ty.storage_texture(type::TextureDimension::k1d, type::TexelFormat::kRgba8Unorm,
type::Access::kWrite); type::Access::kWrite);
}; };

View File

@ -2105,7 +2105,7 @@ inline std::ostream& operator<<(std::ostream& out, Texture data) {
struct TextureTestParams { struct TextureTestParams {
type::TextureDimension dim; type::TextureDimension dim;
Texture type = Texture::kF32; Texture type = Texture::kF32;
ast::TexelFormat format = ast::TexelFormat::kR32Float; type::TexelFormat format = type::TexelFormat::kR32Float;
}; };
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;

View File

@ -1296,7 +1296,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
GlobalVar(Sym(), ty.depth_multisampled_texture(type::TextureDimension::k2d)); GlobalVar(Sym(), ty.depth_multisampled_texture(type::TextureDimension::k2d));
GlobalVar(Sym(), ty.external_texture()); GlobalVar(Sym(), ty.external_texture());
GlobalVar(Sym(), ty.multisampled_texture(type::TextureDimension::k2d, T)); GlobalVar(Sym(), ty.multisampled_texture(type::TextureDimension::k2d, T));
GlobalVar(Sym(), ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float, GlobalVar(Sym(), ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
type::Access::kRead)); // type::Access::kRead)); //
GlobalVar(Sym(), ty.sampler(ast::SamplerKind::kSampler)); GlobalVar(Sym(), ty.sampler(ast::SamplerKind::kSampler));

View File

@ -328,7 +328,7 @@ class TemplateNumberMatcher : 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::TexelFormat; using TexelFormat = type::TexelFormat;
using Access = type::Access; using Access = type::Access;
using AddressSpace = type::AddressSpace; using AddressSpace = type::AddressSpace;
using ParameterUsage = sem::ParameterUsage; using ParameterUsage = sem::ParameterUsage;

View File

@ -414,9 +414,9 @@ TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
auto* i32 = create<type::I32>(); auto* i32 = create<type::I32>();
auto* vec2_i32 = create<type::Vector>(i32, 2u); auto* vec2_i32 = create<type::Vector>(i32, 2u);
auto* vec4_f32 = create<type::Vector>(f32, 4u); auto* vec4_f32 = create<type::Vector>(f32, 4u);
auto* subtype = type::StorageTexture::SubtypeFor(ast::TexelFormat::kR32Float, Types()); auto* subtype = type::StorageTexture::SubtypeFor(type::TexelFormat::kR32Float, Types());
auto* tex = create<type::StorageTexture>( auto* tex = create<type::StorageTexture>(
type::TextureDimension::k2d, ast::TexelFormat::kR32Float, type::Access::kWrite, subtype); type::TextureDimension::k2d, type::TexelFormat::kR32Float, type::Access::kWrite, subtype);
auto result = table->Lookup(BuiltinType::kTextureStore, utils::Vector{tex, vec2_i32, vec4_f32}, auto result = table->Lookup(BuiltinType::kTextureStore, utils::Vector{tex, vec2_i32, vec4_f32},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});

View File

@ -190,7 +190,7 @@ TEST_P(SideEffectsBuiltinTest, Test) {
GlobalVar("t2d_multi", ty.multisampled_texture(type::TextureDimension::k2d, ty.f32()), GlobalVar("t2d_multi", ty.multisampled_texture(type::TextureDimension::k2d, ty.f32()),
Group(0_a), Binding(AInt(next_binding++))); Group(0_a), Binding(AInt(next_binding++)));
GlobalVar("tstorage2d", GlobalVar("tstorage2d",
ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float, ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
type::Access::kWrite), type::Access::kWrite),
Group(0_a), Binding(AInt(next_binding++))); Group(0_a), Binding(AInt(next_binding++)));
GlobalVar("s2d", ty.sampler(ast::SamplerKind::kSampler), Group(0_a), GlobalVar("s2d", ty.sampler(ast::SamplerKind::kSampler), Group(0_a),

View File

@ -1113,7 +1113,7 @@ TEST_P(StorageTextureDimensionTest, All) {
// var a : texture_storage_*<ru32int, write>; // var a : texture_storage_*<ru32int, write>;
auto& params = GetParam(); auto& params = GetParam();
auto* st = ty.storage_texture(Source{{12, 34}}, params.dim, ast::TexelFormat::kR32Uint, auto* st = ty.storage_texture(Source{{12, 34}}, params.dim, type::TexelFormat::kR32Uint,
type::Access::kWrite); type::Access::kWrite);
GlobalVar("a", st, Group(0_a), Binding(0_a)); GlobalVar("a", st, Group(0_a), Binding(0_a));
@ -1131,27 +1131,27 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
testing::ValuesIn(Dimension_cases)); testing::ValuesIn(Dimension_cases));
struct FormatParams { struct FormatParams {
ast::TexelFormat format; type::TexelFormat format;
bool is_valid; bool is_valid;
}; };
static constexpr FormatParams format_cases[] = {FormatParams{ast::TexelFormat::kBgra8Unorm, true}, static constexpr FormatParams format_cases[] = {FormatParams{type::TexelFormat::kBgra8Unorm, true},
FormatParams{ast::TexelFormat::kR32Float, true}, FormatParams{type::TexelFormat::kR32Float, true},
FormatParams{ast::TexelFormat::kR32Sint, true}, FormatParams{type::TexelFormat::kR32Sint, true},
FormatParams{ast::TexelFormat::kR32Uint, true}, FormatParams{type::TexelFormat::kR32Uint, true},
FormatParams{ast::TexelFormat::kRg32Float, true}, FormatParams{type::TexelFormat::kRg32Float, true},
FormatParams{ast::TexelFormat::kRg32Sint, true}, FormatParams{type::TexelFormat::kRg32Sint, true},
FormatParams{ast::TexelFormat::kRg32Uint, true}, FormatParams{type::TexelFormat::kRg32Uint, true},
FormatParams{ast::TexelFormat::kRgba16Float, true}, FormatParams{type::TexelFormat::kRgba16Float, true},
FormatParams{ast::TexelFormat::kRgba16Sint, true}, FormatParams{type::TexelFormat::kRgba16Sint, true},
FormatParams{ast::TexelFormat::kRgba16Uint, true}, FormatParams{type::TexelFormat::kRgba16Uint, true},
FormatParams{ast::TexelFormat::kRgba32Float, true}, FormatParams{type::TexelFormat::kRgba32Float, true},
FormatParams{ast::TexelFormat::kRgba32Sint, true}, FormatParams{type::TexelFormat::kRgba32Sint, true},
FormatParams{ast::TexelFormat::kRgba32Uint, true}, FormatParams{type::TexelFormat::kRgba32Uint, true},
FormatParams{ast::TexelFormat::kRgba8Sint, true}, FormatParams{type::TexelFormat::kRgba8Sint, true},
FormatParams{ast::TexelFormat::kRgba8Snorm, true}, FormatParams{type::TexelFormat::kRgba8Snorm, true},
FormatParams{ast::TexelFormat::kRgba8Uint, true}, FormatParams{type::TexelFormat::kRgba8Uint, true},
FormatParams{ast::TexelFormat::kRgba8Unorm, true}}; FormatParams{type::TexelFormat::kRgba8Unorm, true}};
using StorageTextureFormatTest = ResolverTestWithParam<FormatParams>; using StorageTextureFormatTest = ResolverTestWithParam<FormatParams>;
TEST_P(StorageTextureFormatTest, All) { TEST_P(StorageTextureFormatTest, All) {
@ -1201,7 +1201,7 @@ TEST_F(StorageTextureAccessTest, MissingAccess_Fail) {
// var a : texture_storage_1d<ru32int>; // var a : texture_storage_1d<ru32int>;
auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d, auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d,
ast::TexelFormat::kR32Uint, type::Access::kUndefined); type::TexelFormat::kR32Uint, type::Access::kUndefined);
GlobalVar("a", st, Group(0_a), Binding(0_a)); GlobalVar("a", st, Group(0_a), Binding(0_a));
@ -1214,7 +1214,7 @@ TEST_F(StorageTextureAccessTest, RWAccess_Fail) {
// var a : texture_storage_1d<ru32int, read_write>; // var a : texture_storage_1d<ru32int, read_write>;
auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d, auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d,
ast::TexelFormat::kR32Uint, type::Access::kReadWrite); type::TexelFormat::kR32Uint, type::Access::kReadWrite);
GlobalVar("a", st, Group(0_a), Binding(0_a)); GlobalVar("a", st, Group(0_a), Binding(0_a));
@ -1228,7 +1228,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}}, type::TextureDimension::k1d, auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d,
ast::TexelFormat::kR32Uint, type::Access::kRead); type::TexelFormat::kR32Uint, type::Access::kRead);
GlobalVar("a", st, Group(0_a), Binding(0_a)); GlobalVar("a", st, Group(0_a), Binding(0_a));
@ -1241,7 +1241,7 @@ TEST_F(StorageTextureAccessTest, WriteOnlyAccess_Pass) {
// @group(0) @binding(0) // @group(0) @binding(0)
// var a : texture_storage_1d<ru32int, write>; // var a : texture_storage_1d<ru32int, write>;
auto* st = ty.storage_texture(type::TextureDimension::k1d, ast::TexelFormat::kR32Uint, auto* st = ty.storage_texture(type::TextureDimension::k1d, type::TexelFormat::kR32Uint,
type::Access::kWrite); type::Access::kWrite);
GlobalVar("a", st, Group(0_a), Binding(0_a)); GlobalVar("a", st, Group(0_a), Binding(0_a));

View File

@ -97,25 +97,25 @@ bool IsValidStorageTextureDimension(type::TextureDimension dim) {
} }
} }
bool IsValidStorageTextureTexelFormat(ast::TexelFormat format) { bool IsValidStorageTextureTexelFormat(type::TexelFormat format) {
switch (format) { switch (format) {
case ast::TexelFormat::kBgra8Unorm: case type::TexelFormat::kBgra8Unorm:
case ast::TexelFormat::kR32Uint: case type::TexelFormat::kR32Uint:
case ast::TexelFormat::kR32Sint: case type::TexelFormat::kR32Sint:
case ast::TexelFormat::kR32Float: case type::TexelFormat::kR32Float:
case ast::TexelFormat::kRg32Uint: case type::TexelFormat::kRg32Uint:
case ast::TexelFormat::kRg32Sint: case type::TexelFormat::kRg32Sint:
case ast::TexelFormat::kRg32Float: case type::TexelFormat::kRg32Float:
case ast::TexelFormat::kRgba8Unorm: case type::TexelFormat::kRgba8Unorm:
case ast::TexelFormat::kRgba8Snorm: case type::TexelFormat::kRgba8Snorm:
case ast::TexelFormat::kRgba8Uint: case type::TexelFormat::kRgba8Uint:
case ast::TexelFormat::kRgba8Sint: case type::TexelFormat::kRgba8Sint:
case ast::TexelFormat::kRgba16Uint: case type::TexelFormat::kRgba16Uint:
case ast::TexelFormat::kRgba16Sint: case type::TexelFormat::kRgba16Sint:
case ast::TexelFormat::kRgba16Float: case type::TexelFormat::kRgba16Float:
case ast::TexelFormat::kRgba32Uint: case type::TexelFormat::kRgba32Uint:
case ast::TexelFormat::kRgba32Sint: case type::TexelFormat::kRgba32Sint:
case ast::TexelFormat::kRgba32Float: case type::TexelFormat::kRgba32Float:
return true; return true;
default: default:
return false; return false;

View File

@ -946,7 +946,7 @@ Transform::ApplyResult BuiltinPolyfill::Apply(const Program* src,
auto& sig = builtin->Signature(); auto& sig = builtin->Signature();
auto* tex = sig.Parameter(sem::ParameterUsage::kTexture); auto* tex = sig.Parameter(sem::ParameterUsage::kTexture);
if (auto* stex = tex->Type()->As<type::StorageTexture>()) { if (auto* stex = tex->Type()->As<type::StorageTexture>()) {
if (stex->texel_format() == ast::TexelFormat::kBgra8Unorm) { if (stex->texel_format() == type::TexelFormat::kBgra8Unorm) {
size_t value_idx = static_cast<size_t>( size_t value_idx = static_cast<size_t>(
sig.IndexOf(sem::ParameterUsage::kValue)); sig.IndexOf(sem::ParameterUsage::kValue));
ctx.Replace(expr, [&ctx, expr, value_idx] { ctx.Replace(expr, [&ctx, expr, value_idx] {
@ -1026,9 +1026,9 @@ Transform::ApplyResult BuiltinPolyfill::Apply(const Program* src,
} }
}, },
[&](const ast::StorageTexture* tex) { [&](const ast::StorageTexture* tex) {
if (polyfill.bgra8unorm && tex->format == ast::TexelFormat::kBgra8Unorm) { if (polyfill.bgra8unorm && tex->format == type::TexelFormat::kBgra8Unorm) {
ctx.Replace(tex, [&ctx, tex] { ctx.Replace(tex, [&ctx, tex] {
return ctx.dst->ty.storage_texture(tex->dim, ast::TexelFormat::kRgba8Unorm, return ctx.dst->ty.storage_texture(tex->dim, type::TexelFormat::kRgba8Unorm,
tex->access); tex->access);
}); });
made_changes = true; made_changes = true;

View File

@ -22,7 +22,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::StorageTexture);
namespace tint::type { namespace tint::type {
StorageTexture::StorageTexture(TextureDimension dim, StorageTexture::StorageTexture(TextureDimension dim,
ast::TexelFormat format, type::TexelFormat format,
type::Access access, type::Access access,
Type* subtype) Type* subtype)
: Base(utils::Hash(TypeInfo::Of<StorageTexture>().full_hashcode, dim, format, access), dim), : Base(utils::Hash(TypeInfo::Of<StorageTexture>().full_hashcode, dim, format, access), dim),
@ -45,35 +45,35 @@ std::string StorageTexture::FriendlyName(const SymbolTable&) const {
return out.str(); return out.str();
} }
Type* StorageTexture::SubtypeFor(ast::TexelFormat format, Manager& type_mgr) { Type* StorageTexture::SubtypeFor(type::TexelFormat format, Manager& type_mgr) {
switch (format) { switch (format) {
case ast::TexelFormat::kR32Uint: case type::TexelFormat::kR32Uint:
case ast::TexelFormat::kRgba8Uint: case type::TexelFormat::kRgba8Uint:
case ast::TexelFormat::kRg32Uint: case type::TexelFormat::kRg32Uint:
case ast::TexelFormat::kRgba16Uint: case type::TexelFormat::kRgba16Uint:
case ast::TexelFormat::kRgba32Uint: { case type::TexelFormat::kRgba32Uint: {
return type_mgr.Get<U32>(); return type_mgr.Get<U32>();
} }
case ast::TexelFormat::kR32Sint: case type::TexelFormat::kR32Sint:
case ast::TexelFormat::kRgba8Sint: case type::TexelFormat::kRgba8Sint:
case ast::TexelFormat::kRg32Sint: case type::TexelFormat::kRg32Sint:
case ast::TexelFormat::kRgba16Sint: case type::TexelFormat::kRgba16Sint:
case ast::TexelFormat::kRgba32Sint: { case type::TexelFormat::kRgba32Sint: {
return type_mgr.Get<I32>(); return type_mgr.Get<I32>();
} }
case ast::TexelFormat::kBgra8Unorm: case type::TexelFormat::kBgra8Unorm:
case ast::TexelFormat::kRgba8Unorm: case type::TexelFormat::kRgba8Unorm:
case ast::TexelFormat::kRgba8Snorm: case type::TexelFormat::kRgba8Snorm:
case ast::TexelFormat::kR32Float: case type::TexelFormat::kR32Float:
case ast::TexelFormat::kRg32Float: case type::TexelFormat::kRg32Float:
case ast::TexelFormat::kRgba16Float: case type::TexelFormat::kRgba16Float:
case ast::TexelFormat::kRgba32Float: { case type::TexelFormat::kRgba32Float: {
return type_mgr.Get<F32>(); return type_mgr.Get<F32>();
} }
case ast::TexelFormat::kUndefined: case type::TexelFormat::kUndefined:
break; break;
} }

View File

@ -17,8 +17,8 @@
#include <string> #include <string>
#include "src/tint/ast/storage_texture.h"
#include "src/tint/type/access.h" #include "src/tint/type/access.h"
#include "src/tint/type/texel_format.h"
#include "src/tint/type/texture.h" #include "src/tint/type/texture.h"
#include "src/tint/type/texture_dimension.h" #include "src/tint/type/texture_dimension.h"
@ -38,7 +38,7 @@ class StorageTexture final : public Castable<StorageTexture, 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(TextureDimension dim, StorageTexture(TextureDimension dim,
ast::TexelFormat format, type::TexelFormat format,
type::Access access, type::Access access,
Type* subtype); Type* subtype);
@ -53,7 +53,7 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
Type* type() const { return subtype_; } Type* type() const { return subtype_; }
/// @returns the texel format /// @returns the texel format
ast::TexelFormat texel_format() const { return texel_format_; } type::TexelFormat texel_format() const { return texel_format_; }
/// @returns the access control /// @returns the access control
type::Access access() const { return access_; } type::Access access() const { return access_; }
@ -66,14 +66,14 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
/// @param format the storage texture image format /// @param format the storage texture image format
/// @param type_mgr the Manager used to build the returned type /// @param type_mgr the Manager used to build the returned type
/// @returns the storage texture subtype for the given TexelFormat /// @returns the storage texture subtype for the given TexelFormat
static Type* SubtypeFor(ast::TexelFormat format, Manager& type_mgr); static Type* SubtypeFor(type::TexelFormat format, Manager& type_mgr);
/// @param ctx the clone context /// @param ctx the clone context
/// @returns a clone of this type /// @returns a clone of this type
StorageTexture* Clone(CloneContext& ctx) const override; StorageTexture* Clone(CloneContext& ctx) const override;
private: private:
ast::TexelFormat const texel_format_; type::TexelFormat const texel_format_;
type::Access const access_; type::Access const access_;
Type* const subtype_; Type* const subtype_;
}; };

View File

@ -24,7 +24,7 @@ namespace tint::type {
namespace { namespace {
struct StorageTextureTest : public TestHelper { struct StorageTextureTest : public TestHelper {
StorageTexture* Create(TextureDimension dims, ast::TexelFormat fmt, type::Access access) { StorageTexture* Create(TextureDimension dims, type::TexelFormat fmt, type::Access access) {
auto* subtype = StorageTexture::SubtypeFor(fmt, Types()); auto* subtype = StorageTexture::SubtypeFor(fmt, Types());
return create<StorageTexture>(dims, fmt, access, subtype); return create<StorageTexture>(dims, fmt, access, subtype);
} }
@ -32,14 +32,14 @@ struct StorageTextureTest : public TestHelper {
TEST_F(StorageTextureTest, Creation) { TEST_F(StorageTextureTest, Creation) {
auto* a = auto* a =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* b = auto* b =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* c = auto* c =
Create(TextureDimension::k2d, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); Create(TextureDimension::k2d, type::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* d = auto* d =
Create(TextureDimension::kCube, ast::TexelFormat::kR32Float, type::Access::kReadWrite); Create(TextureDimension::kCube, type::TexelFormat::kR32Float, type::Access::kReadWrite);
auto* e = Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kRead); auto* e = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kRead);
EXPECT_TRUE(a->type()->Is<F32>()); EXPECT_TRUE(a->type()->Is<F32>());
EXPECT_EQ(a->dim(), TextureDimension::kCube); EXPECT_EQ(a->dim(), TextureDimension::kCube);
@ -52,23 +52,23 @@ TEST_F(StorageTextureTest, Creation) {
TEST_F(StorageTextureTest, Hash) { TEST_F(StorageTextureTest, Hash) {
auto* a = auto* a =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* b = auto* b =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite);
EXPECT_EQ(a->unique_hash, b->unique_hash); EXPECT_EQ(a->unique_hash, b->unique_hash);
} }
TEST_F(StorageTextureTest, Equals) { TEST_F(StorageTextureTest, Equals) {
auto* a = auto* a =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* b = auto* b =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* c = auto* c =
Create(TextureDimension::k2d, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); Create(TextureDimension::k2d, type::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* d = auto* d =
Create(TextureDimension::kCube, ast::TexelFormat::kR32Float, type::Access::kReadWrite); Create(TextureDimension::kCube, type::TexelFormat::kR32Float, type::Access::kReadWrite);
auto* e = Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kRead); auto* e = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kRead);
EXPECT_TRUE(a->Equals(*b)); EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*c));
@ -78,25 +78,25 @@ TEST_F(StorageTextureTest, Equals) {
} }
TEST_F(StorageTextureTest, Dim) { TEST_F(StorageTextureTest, Dim) {
auto* s = Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, auto* s = Create(TextureDimension::k2dArray, type::TexelFormat::kRgba32Float,
type::Access::kReadWrite); type::Access::kReadWrite);
EXPECT_EQ(s->dim(), TextureDimension::k2dArray); EXPECT_EQ(s->dim(), TextureDimension::k2dArray);
} }
TEST_F(StorageTextureTest, Format) { TEST_F(StorageTextureTest, Format) {
auto* s = Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, auto* s = Create(TextureDimension::k2dArray, type::TexelFormat::kRgba32Float,
type::Access::kReadWrite); type::Access::kReadWrite);
EXPECT_EQ(s->texel_format(), ast::TexelFormat::kRgba32Float); EXPECT_EQ(s->texel_format(), type::TexelFormat::kRgba32Float);
} }
TEST_F(StorageTextureTest, FriendlyName) { TEST_F(StorageTextureTest, FriendlyName) {
auto* s = Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, auto* s = Create(TextureDimension::k2dArray, type::TexelFormat::kRgba32Float,
type::Access::kReadWrite); type::Access::kReadWrite);
EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array<rgba32float, read_write>"); EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array<rgba32float, read_write>");
} }
TEST_F(StorageTextureTest, F32) { TEST_F(StorageTextureTest, F32) {
Type* s = Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, Type* s = Create(TextureDimension::k2dArray, type::TexelFormat::kRgba32Float,
type::Access::kReadWrite); type::Access::kReadWrite);
auto program = Build(); auto program = Build();
@ -108,8 +108,8 @@ TEST_F(StorageTextureTest, F32) {
} }
TEST_F(StorageTextureTest, U32) { TEST_F(StorageTextureTest, U32) {
auto* subtype = StorageTexture::SubtypeFor(ast::TexelFormat::kRg32Uint, Types()); auto* subtype = StorageTexture::SubtypeFor(type::TexelFormat::kRg32Uint, Types());
Type* s = create<StorageTexture>(TextureDimension::k2dArray, ast::TexelFormat::kRg32Uint, Type* s = create<StorageTexture>(TextureDimension::k2dArray, type::TexelFormat::kRg32Uint,
type::Access::kReadWrite, subtype); type::Access::kReadWrite, subtype);
auto program = Build(); auto program = Build();
@ -121,8 +121,8 @@ TEST_F(StorageTextureTest, U32) {
} }
TEST_F(StorageTextureTest, I32) { TEST_F(StorageTextureTest, I32) {
auto* subtype = StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Sint, Types()); auto* subtype = StorageTexture::SubtypeFor(type::TexelFormat::kRgba32Sint, Types());
Type* s = create<StorageTexture>(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Sint, Type* s = create<StorageTexture>(TextureDimension::k2dArray, type::TexelFormat::kRgba32Sint,
type::Access::kReadWrite, subtype); type::Access::kReadWrite, subtype);
auto program = Build(); auto program = Build();
@ -135,14 +135,14 @@ TEST_F(StorageTextureTest, I32) {
TEST_F(StorageTextureTest, Clone) { TEST_F(StorageTextureTest, Clone) {
auto* a = auto* a =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite);
type::Manager mgr; type::Manager mgr;
type::CloneContext ctx{{nullptr}, {nullptr, &mgr}}; type::CloneContext ctx{{nullptr}, {nullptr, &mgr}};
auto* mt = a->Clone(ctx); auto* mt = a->Clone(ctx);
EXPECT_EQ(mt->dim(), TextureDimension::kCube); EXPECT_EQ(mt->dim(), TextureDimension::kCube);
EXPECT_EQ(mt->texel_format(), ast::TexelFormat::kRgba32Float); EXPECT_EQ(mt->texel_format(), type::TexelFormat::kRgba32Float);
EXPECT_TRUE(mt->type()->Is<F32>()); EXPECT_TRUE(mt->type()->Is<F32>());
} }

View File

@ -15,14 +15,14 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen // File generated by tools/src/cmd/gen
// using the template: // using the template:
// src/tint/ast/texel_format.cc.tmpl // src/tint/type/texel_format.cc.tmpl
// //
// Do not modify this file directly // Do not modify this file directly
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include "src/tint/ast/texel_format.h" #include "src/tint/type/texel_format.h"
namespace tint::ast { namespace tint::type {
/// ParseTexelFormat parses a TexelFormat from a string. /// ParseTexelFormat parses a TexelFormat from a string.
/// @param str the string to parse /// @param str the string to parse
@ -124,4 +124,4 @@ std::ostream& operator<<(std::ostream& out, TexelFormat value) {
return out << "<unknown>"; return out << "<unknown>";
} }
} // namespace tint::ast } // namespace tint::type

View File

@ -11,12 +11,12 @@ See:
{{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "texel_format") -}} {{- $enum := (Sem.Enum "texel_format") -}}
#include "src/tint/ast/texel_format.h" #include "src/tint/type/texel_format.h"
namespace tint::ast { namespace tint::type {
{{ Eval "ParseEnum" $enum}} {{ Eval "ParseEnum" $enum}}
{{ Eval "EnumOStream" $enum}} {{ Eval "EnumOStream" $enum}}
} // namespace tint::ast } // namespace tint::type

View File

@ -15,17 +15,17 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen // File generated by tools/src/cmd/gen
// using the template: // using the template:
// src/tint/ast/texel_format.h.tmpl // src/tint/type/texel_format.h.tmpl
// //
// Do not modify this file directly // Do not modify this file directly
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef SRC_TINT_AST_TEXEL_FORMAT_H_ #ifndef SRC_TINT_TYPE_TEXEL_FORMAT_H_
#define SRC_TINT_AST_TEXEL_FORMAT_H_ #define SRC_TINT_TYPE_TEXEL_FORMAT_H_
#include <ostream> #include <ostream>
namespace tint::ast { namespace tint::type {
/// Enumerator of texel formats /// Enumerator of texel formats
enum class TexelFormat { enum class TexelFormat {
@ -65,6 +65,6 @@ constexpr const char* kTexelFormatStrings[] = {
"rgba32uint", "rgba8sint", "rgba8snorm", "rgba8uint", "rgba8unorm", "rgba32uint", "rgba8sint", "rgba8snorm", "rgba8uint", "rgba8unorm",
}; };
} // namespace tint::ast } // namespace tint::type
#endif // SRC_TINT_AST_TEXEL_FORMAT_H_ #endif // SRC_TINT_TYPE_TEXEL_FORMAT_H_

View File

@ -11,16 +11,16 @@ See:
{{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "texel_format") -}} {{- $enum := (Sem.Enum "texel_format") -}}
#ifndef SRC_TINT_AST_TEXEL_FORMAT_H_ #ifndef SRC_TINT_TYPE_TEXEL_FORMAT_H_
#define SRC_TINT_AST_TEXEL_FORMAT_H_ #define SRC_TINT_TYPE_TEXEL_FORMAT_H_
#include <ostream> #include <ostream>
namespace tint::ast { namespace tint::type {
/// Enumerator of texel formats /// Enumerator of texel formats
{{ Eval "DeclareEnum" $enum}} {{ Eval "DeclareEnum" $enum}}
} // namespace tint::ast } // namespace tint::type
#endif // SRC_TINT_AST_TEXEL_FORMAT_H_ #endif // SRC_TINT_TYPE_TEXEL_FORMAT_H_

View File

@ -15,18 +15,18 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen // File generated by tools/src/cmd/gen
// using the template: // using the template:
// src/tint/ast/texel_format_bench.cc.tmpl // src/tint/type/texel_format_bench.cc.tmpl
// //
// Do not modify this file directly // Do not modify this file directly
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include "src/tint/ast/texel_format.h" #include "src/tint/type/texel_format.h"
#include <array> #include <array>
#include "benchmark/benchmark.h" #include "benchmark/benchmark.h"
namespace tint::ast { namespace tint::type {
namespace { namespace {
void TexelFormatParser(::benchmark::State& state) { void TexelFormatParser(::benchmark::State& state) {
@ -67,4 +67,4 @@ void TexelFormatParser(::benchmark::State& state) {
BENCHMARK(TexelFormatParser); BENCHMARK(TexelFormatParser);
} // namespace } // namespace
} // namespace tint::ast } // namespace tint::type

View File

@ -11,16 +11,16 @@ See:
{{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "texel_format") -}} {{- $enum := (Sem.Enum "texel_format") -}}
#include "src/tint/ast/texel_format.h" #include "src/tint/type/texel_format.h"
#include <array> #include <array>
#include "benchmark/benchmark.h" #include "benchmark/benchmark.h"
namespace tint::ast { namespace tint::type {
namespace { namespace {
{{ Eval "BenchmarkParseEnum" $enum }} {{ Eval "BenchmarkParseEnum" $enum }}
} // namespace } // namespace
} // namespace tint::ast } // namespace tint::type

View File

@ -15,19 +15,19 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen // File generated by tools/src/cmd/gen
// using the template: // using the template:
// src/tint/ast/texel_format_test.cc.tmpl // src/tint/type/texel_format_test.cc.tmpl
// //
// Do not modify this file directly // Do not modify this file directly
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include "src/tint/ast/texel_format.h" #include "src/tint/type/texel_format.h"
#include <string> #include <string>
#include "src/tint/ast/test_helper.h" #include "src/tint/type/test_helper.h"
#include "src/tint/utils/string.h" #include "src/tint/utils/string.h"
namespace tint::ast { namespace tint::type {
namespace { namespace {
namespace parse_print_tests { namespace parse_print_tests {
@ -106,4 +106,4 @@ INSTANTIATE_TEST_SUITE_P(ValidCases, TexelFormatPrintTest, testing::ValuesIn(kVa
} // namespace parse_print_tests } // namespace parse_print_tests
} // namespace } // namespace
} // namespace tint::ast } // namespace tint::type

View File

@ -11,17 +11,17 @@ See:
{{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "texel_format") -}} {{- $enum := (Sem.Enum "texel_format") -}}
#include "src/tint/ast/texel_format.h" #include "src/tint/type/texel_format.h"
#include <string> #include <string>
#include "src/tint/ast/test_helper.h" #include "src/tint/type/test_helper.h"
#include "src/tint/utils/string.h" #include "src/tint/utils/string.h"
namespace tint::ast { namespace tint::type {
namespace { namespace {
{{ Eval "TestParsePrintEnum" $enum}} {{ Eval "TestParsePrintEnum" $enum}}
} // namespace } // namespace
} // namespace tint::ast } // namespace tint::type

View File

@ -101,7 +101,7 @@ TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) {
b.GlobalVar("texture2", b.ty.multisampled_texture(type::TextureDimension::k2d, b.ty.f32()), b.GlobalVar("texture2", b.ty.multisampled_texture(type::TextureDimension::k2d, b.ty.f32()),
b.Group(6_a), b.Binding(6_a)); b.Group(6_a), b.Binding(6_a));
b.GlobalVar("texture3", b.GlobalVar("texture3",
b.ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float, b.ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
type::Access::kWrite), type::Access::kWrite),
b.Group(7_a), b.Binding(7_a)); b.Group(7_a), b.Binding(7_a));
b.GlobalVar("texture4", b.ty.depth_texture(type::TextureDimension::k2d), b.Group(8_a), b.GlobalVar("texture4", b.ty.depth_texture(type::TextureDimension::k2d), b.Group(8_a),

View File

@ -2033,59 +2033,59 @@ bool GeneratorImpl::EmitHandleVariable(const ast::Var* var, const sem::Variable*
if (auto* storage = type->As<type::StorageTexture>()) { if (auto* storage = type->As<type::StorageTexture>()) {
out << "layout("; out << "layout(";
switch (storage->texel_format()) { switch (storage->texel_format()) {
case ast::TexelFormat::kBgra8Unorm: case type::TexelFormat::kBgra8Unorm:
TINT_ICE(Writer, diagnostics_) TINT_ICE(Writer, diagnostics_)
<< "bgra8unorm should have been polyfilled to rgba8unorm"; << "bgra8unorm should have been polyfilled to rgba8unorm";
break; break;
case ast::TexelFormat::kR32Uint: case type::TexelFormat::kR32Uint:
out << "r32ui"; out << "r32ui";
break; break;
case ast::TexelFormat::kR32Sint: case type::TexelFormat::kR32Sint:
out << "r32i"; out << "r32i";
break; break;
case ast::TexelFormat::kR32Float: case type::TexelFormat::kR32Float:
out << "r32f"; out << "r32f";
break; break;
case ast::TexelFormat::kRgba8Unorm: case type::TexelFormat::kRgba8Unorm:
out << "rgba8"; out << "rgba8";
break; break;
case ast::TexelFormat::kRgba8Snorm: case type::TexelFormat::kRgba8Snorm:
out << "rgba8_snorm"; out << "rgba8_snorm";
break; break;
case ast::TexelFormat::kRgba8Uint: case type::TexelFormat::kRgba8Uint:
out << "rgba8ui"; out << "rgba8ui";
break; break;
case ast::TexelFormat::kRgba8Sint: case type::TexelFormat::kRgba8Sint:
out << "rgba8i"; out << "rgba8i";
break; break;
case ast::TexelFormat::kRg32Uint: case type::TexelFormat::kRg32Uint:
out << "rg32ui"; out << "rg32ui";
break; break;
case ast::TexelFormat::kRg32Sint: case type::TexelFormat::kRg32Sint:
out << "rg32i"; out << "rg32i";
break; break;
case ast::TexelFormat::kRg32Float: case type::TexelFormat::kRg32Float:
out << "rg32f"; out << "rg32f";
break; break;
case ast::TexelFormat::kRgba16Uint: case type::TexelFormat::kRgba16Uint:
out << "rgba16ui"; out << "rgba16ui";
break; break;
case ast::TexelFormat::kRgba16Sint: case type::TexelFormat::kRgba16Sint:
out << "rgba16i"; out << "rgba16i";
break; break;
case ast::TexelFormat::kRgba16Float: case type::TexelFormat::kRgba16Float:
out << "rgba16f"; out << "rgba16f";
break; break;
case ast::TexelFormat::kRgba32Uint: case type::TexelFormat::kRgba32Uint:
out << "rgba32ui"; out << "rgba32ui";
break; break;
case ast::TexelFormat::kRgba32Sint: case type::TexelFormat::kRgba32Sint:
out << "rgba32i"; out << "rgba32i";
break; break;
case ast::TexelFormat::kRgba32Float: case type::TexelFormat::kRgba32Float:
out << "rgba32f"; out << "rgba32f";
break; break;
case ast::TexelFormat::kUndefined: case type::TexelFormat::kUndefined:
TINT_ICE(Writer, diagnostics_) << "invalid texel format"; TINT_ICE(Writer, diagnostics_) << "invalid texel format";
return false; return false;
} }

View File

@ -510,7 +510,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) {
struct GlslStorageTextureData { struct GlslStorageTextureData {
type::TextureDimension dim; type::TextureDimension dim;
ast::TexelFormat imgfmt; type::TexelFormat imgfmt;
std::string result; std::string result;
}; };
inline std::ostream& operator<<(std::ostream& out, GlslStorageTextureData data) { inline std::ostream& operator<<(std::ostream& out, GlslStorageTextureData data) {
@ -541,31 +541,31 @@ INSTANTIATE_TEST_SUITE_P(
GlslGeneratorImplTest_Type, GlslGeneratorImplTest_Type,
GlslStorageTexturesTest, GlslStorageTexturesTest,
testing::Values(GlslStorageTextureData{type::TextureDimension::k1d, testing::Values(GlslStorageTextureData{type::TextureDimension::k1d,
ast::TexelFormat::kRgba8Unorm, "image1D tex;"}, type::TexelFormat::kRgba8Unorm, "image1D tex;"},
GlslStorageTextureData{type::TextureDimension::k2d, GlslStorageTextureData{type::TextureDimension::k2d,
ast::TexelFormat::kRgba16Float, "image2D tex;"}, type::TexelFormat::kRgba16Float, "image2D tex;"},
GlslStorageTextureData{type::TextureDimension::k2dArray, GlslStorageTextureData{type::TextureDimension::k2dArray,
ast::TexelFormat::kR32Float, "image2DArray tex;"}, type::TexelFormat::kR32Float, "image2DArray tex;"},
GlslStorageTextureData{type::TextureDimension::k3d, GlslStorageTextureData{type::TextureDimension::k3d,
ast::TexelFormat::kRg32Float, "image3D tex;"}, type::TexelFormat::kRg32Float, "image3D tex;"},
GlslStorageTextureData{type::TextureDimension::k1d, GlslStorageTextureData{type::TextureDimension::k1d,
ast::TexelFormat::kRgba32Float, "image1D tex;"}, type::TexelFormat::kRgba32Float, "image1D tex;"},
GlslStorageTextureData{type::TextureDimension::k2d, GlslStorageTextureData{type::TextureDimension::k2d,
ast::TexelFormat::kRgba16Uint, "image2D tex;"}, type::TexelFormat::kRgba16Uint, "image2D tex;"},
GlslStorageTextureData{type::TextureDimension::k2dArray, GlslStorageTextureData{type::TextureDimension::k2dArray,
ast::TexelFormat::kR32Uint, "image2DArray tex;"}, type::TexelFormat::kR32Uint, "image2DArray tex;"},
GlslStorageTextureData{type::TextureDimension::k3d, ast::TexelFormat::kRg32Uint, GlslStorageTextureData{type::TextureDimension::k3d,
"image3D tex;"}, type::TexelFormat::kRg32Uint, "image3D tex;"},
GlslStorageTextureData{type::TextureDimension::k1d, GlslStorageTextureData{type::TextureDimension::k1d,
ast::TexelFormat::kRgba32Uint, "image1D tex;"}, type::TexelFormat::kRgba32Uint, "image1D tex;"},
GlslStorageTextureData{type::TextureDimension::k2d, GlslStorageTextureData{type::TextureDimension::k2d,
ast::TexelFormat::kRgba16Sint, "image2D tex;"}, type::TexelFormat::kRgba16Sint, "image2D tex;"},
GlslStorageTextureData{type::TextureDimension::k2dArray, GlslStorageTextureData{type::TextureDimension::k2dArray,
ast::TexelFormat::kR32Sint, "image2DArray tex;"}, type::TexelFormat::kR32Sint, "image2DArray tex;"},
GlslStorageTextureData{type::TextureDimension::k3d, ast::TexelFormat::kRg32Sint, GlslStorageTextureData{type::TextureDimension::k3d,
"image3D tex;"}, type::TexelFormat::kRg32Sint, "image3D tex;"},
GlslStorageTextureData{type::TextureDimension::k1d, GlslStorageTextureData{type::TextureDimension::k1d,
ast::TexelFormat::kRgba32Sint, "image1D tex;"})); type::TexelFormat::kRgba32Sint, "image1D tex;"}));
} // namespace } // namespace
} // namespace tint::writer::glsl } // namespace tint::writer::glsl

View File

@ -87,27 +87,27 @@ namespace {
const char kTempNamePrefix[] = "tint_tmp"; const char kTempNamePrefix[] = "tint_tmp";
const char* image_format_to_rwtexture_type(ast::TexelFormat image_format) { const char* image_format_to_rwtexture_type(type::TexelFormat image_format) {
switch (image_format) { switch (image_format) {
case ast::TexelFormat::kBgra8Unorm: case type::TexelFormat::kBgra8Unorm:
case ast::TexelFormat::kRgba8Unorm: case type::TexelFormat::kRgba8Unorm:
case ast::TexelFormat::kRgba8Snorm: case type::TexelFormat::kRgba8Snorm:
case ast::TexelFormat::kRgba16Float: case type::TexelFormat::kRgba16Float:
case ast::TexelFormat::kR32Float: case type::TexelFormat::kR32Float:
case ast::TexelFormat::kRg32Float: case type::TexelFormat::kRg32Float:
case ast::TexelFormat::kRgba32Float: case type::TexelFormat::kRgba32Float:
return "float4"; return "float4";
case ast::TexelFormat::kRgba8Uint: case type::TexelFormat::kRgba8Uint:
case ast::TexelFormat::kRgba16Uint: case type::TexelFormat::kRgba16Uint:
case ast::TexelFormat::kR32Uint: case type::TexelFormat::kR32Uint:
case ast::TexelFormat::kRg32Uint: case type::TexelFormat::kRg32Uint:
case ast::TexelFormat::kRgba32Uint: case type::TexelFormat::kRgba32Uint:
return "uint4"; return "uint4";
case ast::TexelFormat::kRgba8Sint: case type::TexelFormat::kRgba8Sint:
case ast::TexelFormat::kRgba16Sint: case type::TexelFormat::kRgba16Sint:
case ast::TexelFormat::kR32Sint: case type::TexelFormat::kR32Sint:
case ast::TexelFormat::kRg32Sint: case type::TexelFormat::kRg32Sint:
case ast::TexelFormat::kRgba32Sint: case type::TexelFormat::kRgba32Sint:
return "int4"; return "int4";
default: default:
return nullptr; return nullptr;

View File

@ -507,7 +507,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
struct HlslStorageTextureData { struct HlslStorageTextureData {
type::TextureDimension dim; type::TextureDimension dim;
ast::TexelFormat imgfmt; type::TexelFormat imgfmt;
std::string result; std::string result;
}; };
inline std::ostream& operator<<(std::ostream& out, HlslStorageTextureData data) { inline std::ostream& operator<<(std::ostream& out, HlslStorageTextureData data) {
@ -543,31 +543,31 @@ INSTANTIATE_TEST_SUITE_P(
HlslGeneratorImplTest_Type, HlslGeneratorImplTest_Type,
HlslStorageTexturesTest, HlslStorageTexturesTest,
testing::Values( testing::Values(
HlslStorageTextureData{type::TextureDimension::k1d, ast::TexelFormat::kRgba8Unorm, HlslStorageTextureData{type::TextureDimension::k1d, type::TexelFormat::kRgba8Unorm,
"RWTexture1D<float4> tex : register(u1, space2);"}, "RWTexture1D<float4> tex : register(u1, space2);"},
HlslStorageTextureData{type::TextureDimension::k2d, ast::TexelFormat::kRgba16Float, HlslStorageTextureData{type::TextureDimension::k2d, type::TexelFormat::kRgba16Float,
"RWTexture2D<float4> tex : register(u1, space2);"}, "RWTexture2D<float4> tex : register(u1, space2);"},
HlslStorageTextureData{type::TextureDimension::k2dArray, ast::TexelFormat::kR32Float, HlslStorageTextureData{type::TextureDimension::k2dArray, type::TexelFormat::kR32Float,
"RWTexture2DArray<float4> tex : register(u1, space2);"}, "RWTexture2DArray<float4> tex : register(u1, space2);"},
HlslStorageTextureData{type::TextureDimension::k3d, ast::TexelFormat::kRg32Float, HlslStorageTextureData{type::TextureDimension::k3d, type::TexelFormat::kRg32Float,
"RWTexture3D<float4> tex : register(u1, space2);"}, "RWTexture3D<float4> tex : register(u1, space2);"},
HlslStorageTextureData{type::TextureDimension::k1d, ast::TexelFormat::kRgba32Float, HlslStorageTextureData{type::TextureDimension::k1d, type::TexelFormat::kRgba32Float,
"RWTexture1D<float4> tex : register(u1, space2);"}, "RWTexture1D<float4> tex : register(u1, space2);"},
HlslStorageTextureData{type::TextureDimension::k2d, ast::TexelFormat::kRgba16Uint, HlslStorageTextureData{type::TextureDimension::k2d, type::TexelFormat::kRgba16Uint,
"RWTexture2D<uint4> tex : register(u1, space2);"}, "RWTexture2D<uint4> tex : register(u1, space2);"},
HlslStorageTextureData{type::TextureDimension::k2dArray, ast::TexelFormat::kR32Uint, HlslStorageTextureData{type::TextureDimension::k2dArray, type::TexelFormat::kR32Uint,
"RWTexture2DArray<uint4> tex : register(u1, space2);"}, "RWTexture2DArray<uint4> tex : register(u1, space2);"},
HlslStorageTextureData{type::TextureDimension::k3d, ast::TexelFormat::kRg32Uint, HlslStorageTextureData{type::TextureDimension::k3d, type::TexelFormat::kRg32Uint,
"RWTexture3D<uint4> tex : register(u1, space2);"}, "RWTexture3D<uint4> tex : register(u1, space2);"},
HlslStorageTextureData{type::TextureDimension::k1d, ast::TexelFormat::kRgba32Uint, HlslStorageTextureData{type::TextureDimension::k1d, type::TexelFormat::kRgba32Uint,
"RWTexture1D<uint4> tex : register(u1, space2);"}, "RWTexture1D<uint4> tex : register(u1, space2);"},
HlslStorageTextureData{type::TextureDimension::k2d, ast::TexelFormat::kRgba16Sint, HlslStorageTextureData{type::TextureDimension::k2d, type::TexelFormat::kRgba16Sint,
"RWTexture2D<int4> tex : register(u1, space2);"}, "RWTexture2D<int4> tex : register(u1, space2);"},
HlslStorageTextureData{type::TextureDimension::k2dArray, ast::TexelFormat::kR32Sint, HlslStorageTextureData{type::TextureDimension::k2dArray, type::TexelFormat::kR32Sint,
"RWTexture2DArray<int4> tex : register(u1, space2);"}, "RWTexture2DArray<int4> tex : register(u1, space2);"},
HlslStorageTextureData{type::TextureDimension::k3d, ast::TexelFormat::kRg32Sint, HlslStorageTextureData{type::TextureDimension::k3d, type::TexelFormat::kRg32Sint,
"RWTexture3D<int4> tex : register(u1, space2);"}, "RWTexture3D<int4> tex : register(u1, space2);"},
HlslStorageTextureData{type::TextureDimension::k1d, ast::TexelFormat::kRgba32Sint, HlslStorageTextureData{type::TextureDimension::k1d, type::TexelFormat::kRgba32Sint,
"RWTexture1D<int4> tex : register(u1, space2);"})); "RWTexture1D<int4> tex : register(u1, space2);"}));
} // namespace } // namespace

View File

@ -847,7 +847,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::TexelFormat::kR32Float, type::Access::kWrite); auto* s = ty.storage_texture(params.dim, type::TexelFormat::kR32Float, type::Access::kWrite);
GlobalVar("test_var", s, Binding(0_a), Group(0_a)); GlobalVar("test_var", s, Binding(0_a), Group(0_a));
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();

View File

@ -4078,48 +4078,48 @@ void Builder::AddInterpolationDecorations(uint32_t id,
} }
} }
SpvImageFormat Builder::convert_texel_format_to_spv(const ast::TexelFormat format) { SpvImageFormat Builder::convert_texel_format_to_spv(const type::TexelFormat format) {
switch (format) { switch (format) {
case ast::TexelFormat::kBgra8Unorm: case type::TexelFormat::kBgra8Unorm:
TINT_ICE(Writer, builder_.Diagnostics()) TINT_ICE(Writer, builder_.Diagnostics())
<< "bgra8unorm should have been polyfilled to rgba8unorm"; << "bgra8unorm should have been polyfilled to rgba8unorm";
return SpvImageFormatUnknown; return SpvImageFormatUnknown;
case ast::TexelFormat::kR32Uint: case type::TexelFormat::kR32Uint:
return SpvImageFormatR32ui; return SpvImageFormatR32ui;
case ast::TexelFormat::kR32Sint: case type::TexelFormat::kR32Sint:
return SpvImageFormatR32i; return SpvImageFormatR32i;
case ast::TexelFormat::kR32Float: case type::TexelFormat::kR32Float:
return SpvImageFormatR32f; return SpvImageFormatR32f;
case ast::TexelFormat::kRgba8Unorm: case type::TexelFormat::kRgba8Unorm:
return SpvImageFormatRgba8; return SpvImageFormatRgba8;
case ast::TexelFormat::kRgba8Snorm: case type::TexelFormat::kRgba8Snorm:
return SpvImageFormatRgba8Snorm; return SpvImageFormatRgba8Snorm;
case ast::TexelFormat::kRgba8Uint: case type::TexelFormat::kRgba8Uint:
return SpvImageFormatRgba8ui; return SpvImageFormatRgba8ui;
case ast::TexelFormat::kRgba8Sint: case type::TexelFormat::kRgba8Sint:
return SpvImageFormatRgba8i; return SpvImageFormatRgba8i;
case ast::TexelFormat::kRg32Uint: case type::TexelFormat::kRg32Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats); push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg32ui; return SpvImageFormatRg32ui;
case ast::TexelFormat::kRg32Sint: case type::TexelFormat::kRg32Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats); push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg32i; return SpvImageFormatRg32i;
case ast::TexelFormat::kRg32Float: case type::TexelFormat::kRg32Float:
push_capability(SpvCapabilityStorageImageExtendedFormats); push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg32f; return SpvImageFormatRg32f;
case ast::TexelFormat::kRgba16Uint: case type::TexelFormat::kRgba16Uint:
return SpvImageFormatRgba16ui; return SpvImageFormatRgba16ui;
case ast::TexelFormat::kRgba16Sint: case type::TexelFormat::kRgba16Sint:
return SpvImageFormatRgba16i; return SpvImageFormatRgba16i;
case ast::TexelFormat::kRgba16Float: case type::TexelFormat::kRgba16Float:
return SpvImageFormatRgba16f; return SpvImageFormatRgba16f;
case ast::TexelFormat::kRgba32Uint: case type::TexelFormat::kRgba32Uint:
return SpvImageFormatRgba32ui; return SpvImageFormatRgba32ui;
case ast::TexelFormat::kRgba32Sint: case type::TexelFormat::kRgba32Sint:
return SpvImageFormatRgba32i; return SpvImageFormatRgba32i;
case ast::TexelFormat::kRgba32Float: case type::TexelFormat::kRgba32Float:
return SpvImageFormatRgba32f; return SpvImageFormatRgba32f;
case ast::TexelFormat::kUndefined: case type::TexelFormat::kUndefined:
return SpvImageFormatUnknown; return SpvImageFormatUnknown;
} }
return SpvImageFormatUnknown; return SpvImageFormatUnknown;

View File

@ -535,7 +535,7 @@ class Builder {
/// Converts TexelFormat 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_texel_format_to_spv(const ast::TexelFormat format); SpvImageFormat convert_texel_format_to_spv(const type::TexelFormat format);
/// Determines if the given type initializer is created from constant values /// Determines if the given type initializer is created from constant values
/// @param expr the expression to check /// @param expr the expression to check

View File

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

View File

@ -472,7 +472,7 @@ OpName %9 "unused_entry_point"
TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) { 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 = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, auto* type = ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
type::Access::kWrite); type::Access::kWrite);
auto* var_a = GlobalVar("a", type, Binding(0_a), Group(0_a)); auto* var_a = GlobalVar("a", type, Binding(0_a), Group(0_a));

View File

@ -860,7 +860,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
} }
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) { TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
auto* s = ty.storage_texture(type::TextureDimension::k1d, ast::TexelFormat::kR32Float, auto* s = ty.storage_texture(type::TextureDimension::k1d, type::TexelFormat::kR32Float,
type::Access::kWrite); type::Access::kWrite);
GlobalVar("test_var", s, Binding(0_a), Group(0_a)); GlobalVar("test_var", s, Binding(0_a), Group(0_a));
@ -875,7 +875,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
} }
TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) { TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
auto* s = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float, auto* s = ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
type::Access::kWrite); type::Access::kWrite);
GlobalVar("test_var", s, Binding(0_a), Group(0_a)); GlobalVar("test_var", s, Binding(0_a), Group(0_a));
@ -890,7 +890,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
} }
TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) { TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
auto* s = ty.storage_texture(type::TextureDimension::k2dArray, ast::TexelFormat::kR32Float, auto* s = ty.storage_texture(type::TextureDimension::k2dArray, type::TexelFormat::kR32Float,
type::Access::kWrite); type::Access::kWrite);
GlobalVar("test_var", s, Binding(0_a), Group(0_a)); GlobalVar("test_var", s, Binding(0_a), Group(0_a));
@ -905,7 +905,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
} }
TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) { TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
auto* s = ty.storage_texture(type::TextureDimension::k3d, ast::TexelFormat::kR32Float, auto* s = ty.storage_texture(type::TextureDimension::k3d, type::TexelFormat::kR32Float,
type::Access::kWrite); type::Access::kWrite);
GlobalVar("test_var", s, Binding(0_a), Group(0_a)); GlobalVar("test_var", s, Binding(0_a), Group(0_a));
@ -920,7 +920,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
} }
TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32float) { TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32float) {
auto* s = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float, auto* s = ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
type::Access::kWrite); type::Access::kWrite);
GlobalVar("test_var", s, Binding(0_a), Group(0_a)); GlobalVar("test_var", s, Binding(0_a), Group(0_a));
@ -935,7 +935,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32floa
} }
TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint) { TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint) {
auto* s = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Sint, auto* s = ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Sint,
type::Access::kWrite); type::Access::kWrite);
GlobalVar("test_var", s, Binding(0_a), Group(0_a)); GlobalVar("test_var", s, Binding(0_a), Group(0_a));
@ -950,7 +950,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint)
} }
TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeUint_Format_r32uint) { TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeUint_Format_r32uint) {
auto* s = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, auto* s = ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
type::Access::kWrite); type::Access::kWrite);
GlobalVar("test_var", s, Binding(0_a), Group(0_a)); GlobalVar("test_var", s, Binding(0_a), Group(0_a));

View File

@ -350,9 +350,9 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
return true; return true;
} }
bool GeneratorImpl::EmitImageFormat(std::ostream& out, const ast::TexelFormat fmt) { bool GeneratorImpl::EmitImageFormat(std::ostream& out, const type::TexelFormat fmt) {
switch (fmt) { switch (fmt) {
case ast::TexelFormat::kUndefined: case type::TexelFormat::kUndefined:
diagnostics_.add_error(diag::System::Writer, "unknown image format"); diagnostics_.add_error(diag::System::Writer, "unknown image format");
return false; return false;
default: default:

View File

@ -198,7 +198,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::TexelFormat fmt); bool EmitImageFormat(std::ostream& out, const type::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

View File

@ -453,7 +453,7 @@ INSTANTIATE_TEST_SUITE_P(WgslGeneratorImplTest,
"texture_multisampled_2d"})); "texture_multisampled_2d"}));
struct StorageTextureData { struct StorageTextureData {
ast::TexelFormat fmt; type::TexelFormat fmt;
type::TextureDimension dim; type::TextureDimension dim;
type::Access access; type::Access access;
const char* name; const char* name;
@ -479,17 +479,17 @@ INSTANTIATE_TEST_SUITE_P(
WgslGeneratorImplTest, WgslGeneratorImplTest,
WgslGenerator_StorageTextureTest, WgslGenerator_StorageTextureTest,
testing::Values( testing::Values(
StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k1d, StorageTextureData{type::TexelFormat::kRgba8Sint, type::TextureDimension::k1d,
type::Access::kWrite, "texture_storage_1d<rgba8sint, write>"}, type::Access::kWrite, "texture_storage_1d<rgba8sint, write>"},
StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k2d, StorageTextureData{type::TexelFormat::kRgba8Sint, type::TextureDimension::k2d,
type::Access::kWrite, "texture_storage_2d<rgba8sint, write>"}, type::Access::kWrite, "texture_storage_2d<rgba8sint, write>"},
StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k2dArray, StorageTextureData{type::TexelFormat::kRgba8Sint, type::TextureDimension::k2dArray,
type::Access::kWrite, "texture_storage_2d_array<rgba8sint, write>"}, type::Access::kWrite, "texture_storage_2d_array<rgba8sint, write>"},
StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k3d, StorageTextureData{type::TexelFormat::kRgba8Sint, type::TextureDimension::k3d,
type::Access::kWrite, "texture_storage_3d<rgba8sint, write>"})); type::Access::kWrite, "texture_storage_3d<rgba8sint, write>"}));
struct ImageFormatData { struct ImageFormatData {
ast::TexelFormat fmt; type::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) {
@ -510,22 +510,22 @@ TEST_P(WgslGenerator_ImageFormatTest, EmitType_StorageTexture_ImageFormat) {
INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(
WgslGeneratorImplTest, WgslGeneratorImplTest,
WgslGenerator_ImageFormatTest, WgslGenerator_ImageFormatTest,
testing::Values(ImageFormatData{ast::TexelFormat::kR32Uint, "r32uint"}, testing::Values(ImageFormatData{type::TexelFormat::kR32Uint, "r32uint"},
ImageFormatData{ast::TexelFormat::kR32Sint, "r32sint"}, ImageFormatData{type::TexelFormat::kR32Sint, "r32sint"},
ImageFormatData{ast::TexelFormat::kR32Float, "r32float"}, ImageFormatData{type::TexelFormat::kR32Float, "r32float"},
ImageFormatData{ast::TexelFormat::kRgba8Unorm, "rgba8unorm"}, ImageFormatData{type::TexelFormat::kRgba8Unorm, "rgba8unorm"},
ImageFormatData{ast::TexelFormat::kRgba8Snorm, "rgba8snorm"}, ImageFormatData{type::TexelFormat::kRgba8Snorm, "rgba8snorm"},
ImageFormatData{ast::TexelFormat::kRgba8Uint, "rgba8uint"}, ImageFormatData{type::TexelFormat::kRgba8Uint, "rgba8uint"},
ImageFormatData{ast::TexelFormat::kRgba8Sint, "rgba8sint"}, ImageFormatData{type::TexelFormat::kRgba8Sint, "rgba8sint"},
ImageFormatData{ast::TexelFormat::kRg32Uint, "rg32uint"}, ImageFormatData{type::TexelFormat::kRg32Uint, "rg32uint"},
ImageFormatData{ast::TexelFormat::kRg32Sint, "rg32sint"}, ImageFormatData{type::TexelFormat::kRg32Sint, "rg32sint"},
ImageFormatData{ast::TexelFormat::kRg32Float, "rg32float"}, ImageFormatData{type::TexelFormat::kRg32Float, "rg32float"},
ImageFormatData{ast::TexelFormat::kRgba16Uint, "rgba16uint"}, ImageFormatData{type::TexelFormat::kRgba16Uint, "rgba16uint"},
ImageFormatData{ast::TexelFormat::kRgba16Sint, "rgba16sint"}, ImageFormatData{type::TexelFormat::kRgba16Sint, "rgba16sint"},
ImageFormatData{ast::TexelFormat::kRgba16Float, "rgba16float"}, ImageFormatData{type::TexelFormat::kRgba16Float, "rgba16float"},
ImageFormatData{ast::TexelFormat::kRgba32Uint, "rgba32uint"}, ImageFormatData{type::TexelFormat::kRgba32Uint, "rgba32uint"},
ImageFormatData{ast::TexelFormat::kRgba32Sint, "rgba32sint"}, ImageFormatData{type::TexelFormat::kRgba32Sint, "rgba32sint"},
ImageFormatData{ast::TexelFormat::kRgba32Float, "rgba32float"})); ImageFormatData{type::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);