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>
This commit is contained in:
parent
3b4f3d2860
commit
b57c19d450
|
@ -1945,7 +1945,8 @@ type::Pointer* ParserImpl::GetTypeForHandleVar(
|
|||
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));
|
||||
}
|
||||
|
|
|
@ -550,7 +550,8 @@ Maybe<type::Type*> ParserImpl::texture_sampler_types() {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ StorageTexture* StorageTexture::Clone(CloneContext* ctx) const {
|
|||
}
|
||||
|
||||
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 @@ type::Type* StorageTexture::SubtypeFor(type::ImageFormat format,
|
|||
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 @@ type::Type* StorageTexture::SubtypeFor(type::ImageFormat format,
|
|||
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 @@ type::Type* StorageTexture::SubtypeFor(type::ImageFormat format,
|
|||
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:
|
||||
|
|
|
@ -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 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
|
|||
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_;
|
||||
|
|
|
@ -39,7 +39,8 @@ namespace {
|
|||
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, Is) {
|
|||
}
|
||||
|
||||
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, IsTexture) {
|
|||
}
|
||||
|
||||
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, TypeName) {
|
|||
|
||||
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, F32) {
|
|||
|
||||
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, U32) {
|
|||
|
||||
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, I32) {
|
|||
}
|
||||
|
||||
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));
|
||||
|
|
|
@ -1425,7 +1425,7 @@ TEST_P(Intrinsic_StorageTextureOperation, TextureLoadRo) {
|
|||
|
||||
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;
|
||||
|
|
|
@ -407,7 +407,7 @@ using HlslStoragetexturesTest = TestParamHelper<HlslStorageTextureData>;
|
|||
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
|
||||
|
|
|
@ -422,7 +422,7 @@ TEST_P(MslStorageTexturesTest, Emit) {
|
|||
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 =
|
||||
|
|
|
@ -543,7 +543,7 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageReadOnly) {
|
|||
// 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 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) {
|
|||
// 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 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWithDifferentAccess) {
|
|||
// 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);
|
||||
|
||||
|
|
|
@ -875,7 +875,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
|
|||
|
||||
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 @@ OpCapability StorageImageExtendedFormats
|
|||
|
||||
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 @@ OpCapability StorageImageExtendedFormats
|
|||
|
||||
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 @@ OpCapability StorageImageExtendedFormats
|
|||
|
||||
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_R8Uint) {
|
|||
|
||||
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_R8Sint) {
|
|||
|
||||
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 @@ OpCapability StorageImageExtendedFormats
|
|||
|
||||
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_2d) {
|
|||
|
||||
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_2dArray) {
|
|||
|
||||
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_3d) {
|
|||
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,
|
|||
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,
|
|||
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);
|
||||
|
||||
|
|
|
@ -386,7 +386,7 @@ using WgslGenerator_StorageTextureTest = TestParamHelper<StorageTextureData>;
|
|||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue