type_determiner: use f32 as the subtype for u/norm storage texture.

Fixes: tint:367
Change-Id: I311f5b9524d6251c88ae774dc8dc80f6d52e457d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33922
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Corentin Wallez 2020-11-25 13:58:47 +00:00 committed by Commit Bot service account
parent 12ed862c7e
commit bed7a32b3b
4 changed files with 44 additions and 18 deletions

View File

@ -96,7 +96,7 @@ TEST_F(StorageTextureTypeTest, U32Type) {
ast::Module mod;
ast::type::Type* s = mod.create<StorageTextureType>(
TextureDimension::k2dArray, AccessControl::kReadOnly,
ImageFormat::kRgba8Unorm);
ImageFormat::kRg32Uint);
TypeDeterminer td(&ctx, &mod);
ASSERT_TRUE(td.Determine()) << td.error();

View File

@ -1166,13 +1166,6 @@ bool TypeDeterminer::DetermineStorageTextureSubtype(
}
switch (tex->image_format()) {
case ast::type::ImageFormat::kR8Unorm:
case ast::type::ImageFormat::kRg8Unorm:
case ast::type::ImageFormat::kRgba8Unorm:
case ast::type::ImageFormat::kRgba8UnormSrgb:
case ast::type::ImageFormat::kBgra8Unorm:
case ast::type::ImageFormat::kBgra8UnormSrgb:
case ast::type::ImageFormat::kRgb10A2Unorm:
case ast::type::ImageFormat::kR8Uint:
case ast::type::ImageFormat::kR16Uint:
case ast::type::ImageFormat::kRg8Uint:
@ -1186,9 +1179,6 @@ bool TypeDeterminer::DetermineStorageTextureSubtype(
return true;
}
case ast::type::ImageFormat::kR8Snorm:
case ast::type::ImageFormat::kRg8Snorm:
case ast::type::ImageFormat::kRgba8Snorm:
case ast::type::ImageFormat::kR8Sint:
case ast::type::ImageFormat::kR16Sint:
case ast::type::ImageFormat::kRg8Sint:
@ -1202,6 +1192,16 @@ bool TypeDeterminer::DetermineStorageTextureSubtype(
return true;
}
case ast::type::ImageFormat::kR8Unorm:
case ast::type::ImageFormat::kRg8Unorm:
case ast::type::ImageFormat::kRgba8Unorm:
case ast::type::ImageFormat::kRgba8UnormSrgb:
case ast::type::ImageFormat::kBgra8Unorm:
case ast::type::ImageFormat::kBgra8UnormSrgb:
case ast::type::ImageFormat::kRgb10A2Unorm:
case ast::type::ImageFormat::kR8Snorm:
case ast::type::ImageFormat::kRg8Snorm:
case ast::type::ImageFormat::kRgba8Snorm:
case ast::type::ImageFormat::kR16Float:
case ast::type::ImageFormat::kR32Float:
case ast::type::ImageFormat::kRg16Float:

View File

@ -1821,31 +1821,31 @@ INSTANTIATE_TEST_SUITE_P(
ast::type::ImageFormat::kR16Float},
TextureTestParams{ast::type::TextureDimension::k1d, TextureType::kI32,
ast::type::ImageFormat::kR16Sint},
TextureTestParams{ast::type::TextureDimension::k1d, TextureType::kU32,
TextureTestParams{ast::type::TextureDimension::k1d, TextureType::kF32,
ast::type::ImageFormat::kR8Unorm},
TextureTestParams{ast::type::TextureDimension::k1dArray,
TextureType::kF32, ast::type::ImageFormat::kR16Float},
TextureTestParams{ast::type::TextureDimension::k1dArray,
TextureType::kI32, ast::type::ImageFormat::kR16Sint},
TextureTestParams{ast::type::TextureDimension::k1dArray,
TextureType::kU32, ast::type::ImageFormat::kR8Unorm},
TextureType::kF32, ast::type::ImageFormat::kR8Unorm},
TextureTestParams{ast::type::TextureDimension::k2d, TextureType::kF32,
ast::type::ImageFormat::kR16Float},
TextureTestParams{ast::type::TextureDimension::k2d, TextureType::kI32,
ast::type::ImageFormat::kR16Sint},
TextureTestParams{ast::type::TextureDimension::k2d, TextureType::kU32,
TextureTestParams{ast::type::TextureDimension::k2d, TextureType::kF32,
ast::type::ImageFormat::kR8Unorm},
TextureTestParams{ast::type::TextureDimension::k2dArray,
TextureType::kF32, ast::type::ImageFormat::kR16Float},
TextureTestParams{ast::type::TextureDimension::k2dArray,
TextureType::kI32, ast::type::ImageFormat::kR16Sint},
TextureTestParams{ast::type::TextureDimension::k2dArray,
TextureType::kU32, ast::type::ImageFormat::kR8Unorm},
TextureType::kF32, ast::type::ImageFormat::kR8Unorm},
TextureTestParams{ast::type::TextureDimension::k3d, TextureType::kF32,
ast::type::ImageFormat::kR16Float},
TextureTestParams{ast::type::TextureDimension::k3d, TextureType::kI32,
ast::type::ImageFormat::kR16Sint},
TextureTestParams{ast::type::TextureDimension::k3d, TextureType::kU32,
TextureTestParams{ast::type::TextureDimension::k3d, TextureType::kF32,
ast::type::ImageFormat::kR8Unorm}));
using Intrinsic_SampledTextureOperation = Intrinsic_TextureOperation;

View File

@ -845,7 +845,7 @@ TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8SNorm) {
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeInt 32 1
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeImage %2 1D 0 0 0 2 R8Snorm
)");
}
@ -858,11 +858,37 @@ TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8UNorm) {
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeInt 32 0
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeImage %2 1D 0 0 0 2 R8
)");
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8Uint) {
ast::type::StorageTextureType s(ast::type::TextureDimension::k1d,
ast::AccessControl::kReadOnly,
ast::type::ImageFormat::kR8Uint);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeInt 32 0
%1 = OpTypeImage %2 1D 0 0 0 2 R8ui
)");
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8Sint) {
ast::type::StorageTextureType s(ast::type::TextureDimension::k1d,
ast::AccessControl::kReadOnly,
ast::type::ImageFormat::kR8Sint);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeInt 32 1
%1 = OpTypeImage %2 1D 0 0 0 2 R8i
)");
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_array) {
ast::type::StorageTextureType s(ast::type::TextureDimension::k1dArray,
ast::AccessControl::kReadOnly,