Change StorageTexture::SubTypeFor() signature
So that it takes a type::Manager instead of a ProgramBuilder.
Makes this callable from places that has the former and not the latter.
Change-Id: Ie968617ae944cc6621c17467a4f7caadacba548f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40505
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc
index ebd2ce8..97c2f87 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -1945,7 +1945,8 @@
if (format == type::ImageFormat::kNone) {
return nullptr;
}
- auto* subtype = type::StorageTexture::SubtypeFor(format, &builder_);
+ auto* subtype =
+ type::StorageTexture::SubtypeFor(format, builder_.Types());
ast_store_type = builder_.create<type::AccessControl>(
access, builder_.create<type::StorageTexture>(dim, format, subtype));
}
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc
index 63f15c6..5680c89 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -550,7 +550,8 @@
if (format.errored)
return Failure::kErrored;
- auto* subtype = type::StorageTexture::SubtypeFor(format.value, &builder_);
+ auto* subtype =
+ type::StorageTexture::SubtypeFor(format.value, builder_.Types());
return builder_.create<type::StorageTexture>(storage.value, format.value,
subtype);
}
diff --git a/src/type/storage_texture_type.cc b/src/type/storage_texture_type.cc
index 6dd019a..91be1ad 100644
--- a/src/type/storage_texture_type.cc
+++ b/src/type/storage_texture_type.cc
@@ -162,7 +162,7 @@
}
type::Type* StorageTexture::SubtypeFor(type::ImageFormat format,
- ProgramBuilder* builder) {
+ type::Manager& type_mgr) {
switch (format) {
case type::ImageFormat::kR8Uint:
case type::ImageFormat::kR16Uint:
@@ -173,7 +173,7 @@
case type::ImageFormat::kRg32Uint:
case type::ImageFormat::kRgba16Uint:
case type::ImageFormat::kRgba32Uint: {
- return builder->create<type::U32>();
+ return type_mgr.Get<type::U32>();
}
case type::ImageFormat::kR8Sint:
@@ -185,7 +185,7 @@
case type::ImageFormat::kRg32Sint:
case type::ImageFormat::kRgba16Sint:
case type::ImageFormat::kRgba32Sint: {
- return builder->create<type::I32>();
+ return type_mgr.Get<type::I32>();
}
case type::ImageFormat::kR8Unorm:
@@ -205,7 +205,7 @@
case type::ImageFormat::kRg32Float:
case type::ImageFormat::kRgba16Float:
case type::ImageFormat::kRgba32Float: {
- return builder->create<type::F32>();
+ return type_mgr.Get<type::F32>();
}
case type::ImageFormat::kNone:
diff --git a/src/type/storage_texture_type.h b/src/type/storage_texture_type.h
index 0c769e6..cff03e2 100644
--- a/src/type/storage_texture_type.h
+++ b/src/type/storage_texture_type.h
@@ -22,6 +22,8 @@
namespace tint {
namespace type {
+class Manager;
+
/// The image format in the storage texture
enum class ImageFormat {
kNone = -1,
@@ -91,9 +93,10 @@
StorageTexture* Clone(CloneContext* ctx) const override;
/// @param format the storage texture image format
- /// @param builder the ProgramBuilder used to build the returned type
+ /// @param type_mgr the type::Manager used to build the returned type
/// @returns the storage texture subtype for the given ImageFormat
- static type::Type* SubtypeFor(ImageFormat format, ProgramBuilder* builder);
+ static type::Type* SubtypeFor(type::ImageFormat format,
+ type::Manager& type_mgr);
private:
ImageFormat const image_format_;
diff --git a/src/type/storage_texture_type_test.cc b/src/type/storage_texture_type_test.cc
index 3e2dbb0..95c498a 100644
--- a/src/type/storage_texture_type_test.cc
+++ b/src/type/storage_texture_type_test.cc
@@ -39,7 +39,8 @@
using StorageTextureTest = TestHelper;
TEST_F(StorageTextureTest, Is) {
- auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, this);
+ auto* subtype =
+ StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
Type* ty = s;
@@ -59,7 +60,8 @@
}
TEST_F(StorageTextureTest, IsTexture) {
- auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, this);
+ auto* subtype =
+ StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
Texture* ty = s;
@@ -69,21 +71,24 @@
}
TEST_F(StorageTextureTest, Dim) {
- auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, this);
+ auto* subtype =
+ StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
EXPECT_EQ(s->dim(), TextureDimension::k2dArray);
}
TEST_F(StorageTextureTest, Format) {
- auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, this);
+ auto* subtype =
+ StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
EXPECT_EQ(s->image_format(), ImageFormat::kRgba32Float);
}
TEST_F(StorageTextureTest, TypeName) {
- auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, this);
+ auto* subtype =
+ StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
EXPECT_EQ(s->type_name(), "__storage_texture_2d_array_rgba32float");
@@ -91,7 +96,7 @@
TEST_F(StorageTextureTest, F32) {
auto* subtype =
- type::StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, this);
+ type::StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
TypeDeterminer td(this);
@@ -104,7 +109,7 @@
TEST_F(StorageTextureTest, U32) {
auto* subtype =
- type::StorageTexture::SubtypeFor(ImageFormat::kRg32Uint, this);
+ type::StorageTexture::SubtypeFor(ImageFormat::kRg32Uint, Types());
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRg32Uint, subtype);
TypeDeterminer td(this);
@@ -117,7 +122,7 @@
TEST_F(StorageTextureTest, I32) {
auto* subtype =
- type::StorageTexture::SubtypeFor(ImageFormat::kRgba32Sint, this);
+ type::StorageTexture::SubtypeFor(ImageFormat::kRgba32Sint, Types());
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Sint, subtype);
TypeDeterminer td(this);
@@ -129,7 +134,7 @@
}
TEST_F(StorageTextureTest, MinBufferBindingSize) {
- auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Sint, this);
+ auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Sint, Types());
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Sint, subtype);
EXPECT_EQ(0u, s->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc
index 90c93cb..7a89bc6 100644
--- a/src/type_determiner_test.cc
+++ b/src/type_determiner_test.cc
@@ -1425,7 +1425,7 @@
auto* coords_type = GetCoordsType(dim, ty.i32());
- auto* subtype = type::StorageTexture::SubtypeFor(format, this);
+ auto* subtype = type::StorageTexture::SubtypeFor(format, Types());
type::Type* texture_type = create<type::StorageTexture>(dim, format, subtype);
ast::ExpressionList call_params;
diff --git a/src/writer/hlsl/generator_impl_type_test.cc b/src/writer/hlsl/generator_impl_type_test.cc
index 6ae9478..6f29eed 100644
--- a/src/writer/hlsl/generator_impl_type_test.cc
+++ b/src/writer/hlsl/generator_impl_type_test.cc
@@ -407,7 +407,7 @@
TEST_P(HlslStoragetexturesTest, Emit) {
auto params = GetParam();
- auto* subtype = type::StorageTexture::SubtypeFor(params.imgfmt, this);
+ auto* subtype = type::StorageTexture::SubtypeFor(params.imgfmt, Types());
auto* s = create<type::StorageTexture>(params.dim, params.imgfmt, subtype);
auto* ac =
create<type::AccessControl>(params.ro ? ast::AccessControl::kReadOnly
diff --git a/src/writer/msl/generator_impl_type_test.cc b/src/writer/msl/generator_impl_type_test.cc
index aff333e..c223f0c 100644
--- a/src/writer/msl/generator_impl_type_test.cc
+++ b/src/writer/msl/generator_impl_type_test.cc
@@ -422,7 +422,7 @@
auto params = GetParam();
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types());
auto* s = create<type::StorageTexture>(params.dim,
type::ImageFormat::kR16Float, subtype);
auto* ac =
diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc
index 7067993..4a9517b 100644
--- a/src/writer/spirv/builder_global_variable_test.cc
+++ b/src/writer/spirv/builder_global_variable_test.cc
@@ -543,7 +543,7 @@
// var<uniform_constant> a : [[access(read)]] texture_storage_2d<r32uint>;
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, Types());
auto* type = create<type::StorageTexture>(
type::TextureDimension::k2d, type::ImageFormat::kR32Uint, subtype);
@@ -568,7 +568,7 @@
// var<uniform_constant> a : [[access(write)]] texture_storage_2d<r32uint>;
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, Types());
auto* type = create<type::StorageTexture>(
type::TextureDimension::k2d, type::ImageFormat::kR32Uint, subtype);
Global("test_var", ast::StorageClass::kNone, type);
@@ -597,7 +597,7 @@
// var<uniform_constant> b : [[access(write)]] texture_storage_2d<r32uint>;
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, Types());
auto* st = create<type::StorageTexture>(type::TextureDimension::k2d,
type::ImageFormat::kR32Uint, subtype);
diff --git a/src/writer/spirv/builder_type_test.cc b/src/writer/spirv/builder_type_test.cc
index 33a0bea..2ffa217 100644
--- a/src/writer/spirv/builder_type_test.cc
+++ b/src/writer/spirv/builder_type_test.cc
@@ -875,7 +875,7 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R16Float) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types());
auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
type::ImageFormat::kR16Float, subtype);
@@ -897,7 +897,7 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8SNorm) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Snorm, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Snorm, Types());
auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
type::ImageFormat::kR8Snorm, subtype);
@@ -919,7 +919,7 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8UNorm) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Unorm, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Unorm, Types());
auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
type::ImageFormat::kR8Unorm, subtype);
@@ -941,7 +941,7 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8Uint) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Uint, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Uint, Types());
auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
type::ImageFormat::kR8Uint, subtype);
@@ -958,7 +958,7 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8Sint) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Sint, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Sint, Types());
auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
type::ImageFormat::kR8Sint, subtype);
@@ -975,7 +975,7 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_array) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types());
auto* s = create<type::StorageTexture>(type::TextureDimension::k1dArray,
type::ImageFormat::kR16Float, subtype);
@@ -997,7 +997,7 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types());
auto* s = create<type::StorageTexture>(type::TextureDimension::k2d,
type::ImageFormat::kR16Float, subtype);
@@ -1014,7 +1014,7 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types());
auto* s = create<type::StorageTexture>(type::TextureDimension::k2dArray,
type::ImageFormat::kR16Float, subtype);
@@ -1031,7 +1031,7 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types());
auto* s = create<type::StorageTexture>(type::TextureDimension::k3d,
type::ImageFormat::kR16Float, subtype);
@@ -1049,7 +1049,7 @@
TEST_F(BuilderTest_Type,
StorageTexture_Generate_SampledTypeFloat_Format_r32float) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Float, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Float, Types());
auto* s = create<type::StorageTexture>(type::TextureDimension::k2d,
type::ImageFormat::kR32Float, subtype);
@@ -1067,7 +1067,7 @@
TEST_F(BuilderTest_Type,
StorageTexture_Generate_SampledTypeSint_Format_r32sint) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Sint, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Sint, Types());
auto* s = create<type::StorageTexture>(type::TextureDimension::k2d,
type::ImageFormat::kR32Sint, subtype);
@@ -1085,7 +1085,7 @@
TEST_F(BuilderTest_Type,
StorageTexture_Generate_SampledTypeUint_Format_r32uint) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, this);
+ type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, Types());
auto* s = create<type::StorageTexture>(type::TextureDimension::k2d,
type::ImageFormat::kR32Uint, subtype);
diff --git a/src/writer/wgsl/generator_impl_type_test.cc b/src/writer/wgsl/generator_impl_type_test.cc
index 4308d7f..2c2744f 100644
--- a/src/writer/wgsl/generator_impl_type_test.cc
+++ b/src/writer/wgsl/generator_impl_type_test.cc
@@ -386,7 +386,7 @@
TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) {
auto param = GetParam();
- auto* subtype = type::StorageTexture::SubtypeFor(param.fmt, this);
+ auto* subtype = type::StorageTexture::SubtypeFor(param.fmt, Types());
auto* t = create<type::StorageTexture>(param.dim, param.fmt, subtype);
auto* ac = create<type::AccessControl>(param.access, t);