ast: Rename ImageFormat to TexelFormat

This is what its called in the spec.

Issue: tint:1361
Change-Id: I512c4224191fd2bbf04522da2093872f79ee02a6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75581
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2022-01-06 17:20:22 +00:00
committed by Tint LUCI CQ
parent c1faee9395
commit 294ce9394f
50 changed files with 887 additions and 886 deletions

View File

@@ -22,10 +22,10 @@ namespace tint {
namespace sem {
StorageTexture::StorageTexture(ast::TextureDimension dim,
ast::ImageFormat format,
ast::TexelFormat format,
ast::Access access,
sem::Type* subtype)
: Base(dim), image_format_(format), access_(access), subtype_(subtype) {}
: Base(dim), texel_format_(format), access_(access), subtype_(subtype) {}
StorageTexture::StorageTexture(StorageTexture&&) = default;
@@ -33,66 +33,66 @@ StorageTexture::~StorageTexture() = default;
std::string StorageTexture::type_name() const {
std::ostringstream out;
out << "__storage_texture_" << dim() << "_" << image_format_ << "_"
out << "__storage_texture_" << dim() << "_" << texel_format_ << "_"
<< access_;
return out.str();
}
std::string StorageTexture::FriendlyName(const SymbolTable&) const {
std::ostringstream out;
out << "texture_storage_" << dim() << "<" << image_format_ << ", " << access_
out << "texture_storage_" << dim() << "<" << texel_format_ << ", " << access_
<< ">";
return out.str();
}
sem::Type* StorageTexture::SubtypeFor(ast::ImageFormat format,
sem::Type* StorageTexture::SubtypeFor(ast::TexelFormat format,
sem::Manager& type_mgr) {
switch (format) {
case ast::ImageFormat::kR8Uint:
case ast::ImageFormat::kR16Uint:
case ast::ImageFormat::kRg8Uint:
case ast::ImageFormat::kR32Uint:
case ast::ImageFormat::kRg16Uint:
case ast::ImageFormat::kRgba8Uint:
case ast::ImageFormat::kRg32Uint:
case ast::ImageFormat::kRgba16Uint:
case ast::ImageFormat::kRgba32Uint: {
case ast::TexelFormat::kR8Uint:
case ast::TexelFormat::kR16Uint:
case ast::TexelFormat::kRg8Uint:
case ast::TexelFormat::kR32Uint:
case ast::TexelFormat::kRg16Uint:
case ast::TexelFormat::kRgba8Uint:
case ast::TexelFormat::kRg32Uint:
case ast::TexelFormat::kRgba16Uint:
case ast::TexelFormat::kRgba32Uint: {
return type_mgr.Get<sem::U32>();
}
case ast::ImageFormat::kR8Sint:
case ast::ImageFormat::kR16Sint:
case ast::ImageFormat::kRg8Sint:
case ast::ImageFormat::kR32Sint:
case ast::ImageFormat::kRg16Sint:
case ast::ImageFormat::kRgba8Sint:
case ast::ImageFormat::kRg32Sint:
case ast::ImageFormat::kRgba16Sint:
case ast::ImageFormat::kRgba32Sint: {
case ast::TexelFormat::kR8Sint:
case ast::TexelFormat::kR16Sint:
case ast::TexelFormat::kRg8Sint:
case ast::TexelFormat::kR32Sint:
case ast::TexelFormat::kRg16Sint:
case ast::TexelFormat::kRgba8Sint:
case ast::TexelFormat::kRg32Sint:
case ast::TexelFormat::kRgba16Sint:
case ast::TexelFormat::kRgba32Sint: {
return type_mgr.Get<sem::I32>();
}
case ast::ImageFormat::kR8Unorm:
case ast::ImageFormat::kRg8Unorm:
case ast::ImageFormat::kRgba8Unorm:
case ast::ImageFormat::kRgba8UnormSrgb:
case ast::ImageFormat::kBgra8Unorm:
case ast::ImageFormat::kBgra8UnormSrgb:
case ast::ImageFormat::kRgb10A2Unorm:
case ast::ImageFormat::kR8Snorm:
case ast::ImageFormat::kRg8Snorm:
case ast::ImageFormat::kRgba8Snorm:
case ast::ImageFormat::kR16Float:
case ast::ImageFormat::kR32Float:
case ast::ImageFormat::kRg16Float:
case ast::ImageFormat::kRg11B10Float:
case ast::ImageFormat::kRg32Float:
case ast::ImageFormat::kRgba16Float:
case ast::ImageFormat::kRgba32Float: {
case ast::TexelFormat::kR8Unorm:
case ast::TexelFormat::kRg8Unorm:
case ast::TexelFormat::kRgba8Unorm:
case ast::TexelFormat::kRgba8UnormSrgb:
case ast::TexelFormat::kBgra8Unorm:
case ast::TexelFormat::kBgra8UnormSrgb:
case ast::TexelFormat::kRgb10A2Unorm:
case ast::TexelFormat::kR8Snorm:
case ast::TexelFormat::kRg8Snorm:
case ast::TexelFormat::kRgba8Snorm:
case ast::TexelFormat::kR16Float:
case ast::TexelFormat::kR32Float:
case ast::TexelFormat::kRg16Float:
case ast::TexelFormat::kRg11B10Float:
case ast::TexelFormat::kRg32Float:
case ast::TexelFormat::kRgba16Float:
case ast::TexelFormat::kRgba32Float: {
return type_mgr.Get<sem::F32>();
}
case ast::ImageFormat::kNone:
case ast::TexelFormat::kNone:
break;
}

View File

@@ -31,11 +31,11 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
public:
/// Constructor
/// @param dim the dimensionality of the texture
/// @param format the image format of the texture
/// @param format the texel format of the texture
/// @param access the access control type of the texture
/// @param subtype the storage subtype. Use SubtypeFor() to calculate this.
StorageTexture(ast::TextureDimension dim,
ast::ImageFormat format,
ast::TexelFormat format,
ast::Access access,
sem::Type* subtype);
@@ -46,8 +46,8 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
/// @returns the storage subtype
Type* type() const { return subtype_; }
/// @returns the image format
ast::ImageFormat image_format() const { return image_format_; }
/// @returns the texel format
ast::TexelFormat texel_format() const { return texel_format_; }
/// @returns the access control
ast::Access access() const { return access_; }
@@ -62,11 +62,11 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
/// @param format the storage texture image format
/// @param type_mgr the sem::Manager used to build the returned type
/// @returns the storage texture subtype for the given ImageFormat
static sem::Type* SubtypeFor(ast::ImageFormat format, sem::Manager& type_mgr);
/// @returns the storage texture subtype for the given TexelFormat
static sem::Type* SubtypeFor(ast::TexelFormat format, sem::Manager& type_mgr);
private:
ast::ImageFormat const image_format_;
ast::TexelFormat const texel_format_;
ast::Access const access_;
Type* const subtype_;
};

View File

@@ -27,27 +27,27 @@ using StorageTextureTest = TestHelper;
TEST_F(StorageTextureTest, Dim) {
auto* subtype =
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Float,
ast::TexelFormat::kRgba32Float,
ast::Access::kReadWrite, subtype);
EXPECT_EQ(s->dim(), ast::TextureDimension::k2dArray);
}
TEST_F(StorageTextureTest, Format) {
auto* subtype =
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Float,
ast::TexelFormat::kRgba32Float,
ast::Access::kReadWrite, subtype);
EXPECT_EQ(s->image_format(), ast::ImageFormat::kRgba32Float);
EXPECT_EQ(s->texel_format(), ast::TexelFormat::kRgba32Float);
}
TEST_F(StorageTextureTest, TypeName) {
auto* subtype =
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Float,
ast::TexelFormat::kRgba32Float,
ast::Access::kReadWrite, subtype);
EXPECT_EQ(s->type_name(),
"__storage_texture_2d_array_rgba32float_read_write");
@@ -55,9 +55,9 @@ TEST_F(StorageTextureTest, TypeName) {
TEST_F(StorageTextureTest, FriendlyName) {
auto* subtype =
StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Float,
ast::TexelFormat::kRgba32Float,
ast::Access::kReadWrite, subtype);
EXPECT_EQ(s->FriendlyName(Symbols()),
"texture_storage_2d_array<rgba32float, read_write>");
@@ -65,9 +65,9 @@ TEST_F(StorageTextureTest, FriendlyName) {
TEST_F(StorageTextureTest, F32) {
auto* subtype =
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Float, Types());
sem::StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Float, Types());
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Float,
ast::TexelFormat::kRgba32Float,
ast::Access::kReadWrite, subtype);
auto program = Build();
@@ -80,9 +80,9 @@ TEST_F(StorageTextureTest, F32) {
TEST_F(StorageTextureTest, U32) {
auto* subtype =
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRg32Uint, Types());
sem::StorageTexture::SubtypeFor(ast::TexelFormat::kRg32Uint, Types());
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRg32Uint,
ast::TexelFormat::kRg32Uint,
ast::Access::kReadWrite, subtype);
auto program = Build();
@@ -95,9 +95,9 @@ TEST_F(StorageTextureTest, U32) {
TEST_F(StorageTextureTest, I32) {
auto* subtype =
sem::StorageTexture::SubtypeFor(ast::ImageFormat::kRgba32Sint, Types());
sem::StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Sint, Types());
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray,
ast::ImageFormat::kRgba32Sint,
ast::TexelFormat::kRgba32Sint,
ast::Access::kReadWrite, subtype);
auto program = Build();