ast: Remove unsupported texel formats

Fixed: tint:1361
Change-Id: Idcf98713d9a380e56811bea6419913714d602103
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75582
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 18:37:01 +00:00 committed by Tint LUCI CQ
parent 3cbb136b8a
commit 4d245d9a36
18 changed files with 132 additions and 637 deletions

View File

@ -31,39 +31,6 @@ std::ostream& operator<<(std::ostream& out, TexelFormat format) {
case TexelFormat::kNone: case TexelFormat::kNone:
out << "none"; out << "none";
break; break;
case TexelFormat::kR8Unorm:
out << "r8unorm";
break;
case TexelFormat::kR8Snorm:
out << "r8snorm";
break;
case TexelFormat::kR8Uint:
out << "r8uint";
break;
case TexelFormat::kR8Sint:
out << "r8sint";
break;
case TexelFormat::kR16Uint:
out << "r16uint";
break;
case TexelFormat::kR16Sint:
out << "r16sint";
break;
case TexelFormat::kR16Float:
out << "r16float";
break;
case TexelFormat::kRg8Unorm:
out << "rg8unorm";
break;
case TexelFormat::kRg8Snorm:
out << "rg8snorm";
break;
case TexelFormat::kRg8Uint:
out << "rg8uint";
break;
case TexelFormat::kRg8Sint:
out << "rg8sint";
break;
case TexelFormat::kR32Uint: case TexelFormat::kR32Uint:
out << "r32uint"; out << "r32uint";
break; break;
@ -73,21 +40,9 @@ std::ostream& operator<<(std::ostream& out, TexelFormat format) {
case TexelFormat::kR32Float: case TexelFormat::kR32Float:
out << "r32float"; out << "r32float";
break; break;
case TexelFormat::kRg16Uint:
out << "rg16uint";
break;
case TexelFormat::kRg16Sint:
out << "rg16sint";
break;
case TexelFormat::kRg16Float:
out << "rg16float";
break;
case TexelFormat::kRgba8Unorm: case TexelFormat::kRgba8Unorm:
out << "rgba8unorm"; out << "rgba8unorm";
break; break;
case TexelFormat::kRgba8UnormSrgb:
out << "rgba8unorm_srgb";
break;
case TexelFormat::kRgba8Snorm: case TexelFormat::kRgba8Snorm:
out << "rgba8snorm"; out << "rgba8snorm";
break; break;
@ -97,18 +52,6 @@ std::ostream& operator<<(std::ostream& out, TexelFormat format) {
case TexelFormat::kRgba8Sint: case TexelFormat::kRgba8Sint:
out << "rgba8sint"; out << "rgba8sint";
break; break;
case TexelFormat::kBgra8Unorm:
out << "bgra8unorm";
break;
case TexelFormat::kBgra8UnormSrgb:
out << "bgra8unorm_srgb";
break;
case TexelFormat::kRgb10A2Unorm:
out << "rgb10a2unorm";
break;
case TexelFormat::kRg11B10Float:
out << "rg11b10float";
break;
case TexelFormat::kRg32Uint: case TexelFormat::kRg32Uint:
out << "rg32uint"; out << "rg32uint";
break; break;
@ -167,11 +110,7 @@ const StorageTexture* StorageTexture::Clone(CloneContext* ctx) const {
Type* StorageTexture::SubtypeFor(TexelFormat format, ProgramBuilder& builder) { Type* StorageTexture::SubtypeFor(TexelFormat format, ProgramBuilder& builder) {
switch (format) { switch (format) {
case TexelFormat::kR8Uint:
case TexelFormat::kR16Uint:
case TexelFormat::kRg8Uint:
case TexelFormat::kR32Uint: case TexelFormat::kR32Uint:
case TexelFormat::kRg16Uint:
case TexelFormat::kRgba8Uint: case TexelFormat::kRgba8Uint:
case TexelFormat::kRg32Uint: case TexelFormat::kRg32Uint:
case TexelFormat::kRgba16Uint: case TexelFormat::kRgba16Uint:
@ -179,11 +118,7 @@ Type* StorageTexture::SubtypeFor(TexelFormat format, ProgramBuilder& builder) {
return builder.create<U32>(); return builder.create<U32>();
} }
case TexelFormat::kR8Sint:
case TexelFormat::kR16Sint:
case TexelFormat::kRg8Sint:
case TexelFormat::kR32Sint: case TexelFormat::kR32Sint:
case TexelFormat::kRg16Sint:
case TexelFormat::kRgba8Sint: case TexelFormat::kRgba8Sint:
case TexelFormat::kRg32Sint: case TexelFormat::kRg32Sint:
case TexelFormat::kRgba16Sint: case TexelFormat::kRgba16Sint:
@ -191,20 +126,9 @@ Type* StorageTexture::SubtypeFor(TexelFormat format, ProgramBuilder& builder) {
return builder.create<I32>(); return builder.create<I32>();
} }
case TexelFormat::kR8Unorm:
case TexelFormat::kRg8Unorm:
case TexelFormat::kRgba8Unorm: case TexelFormat::kRgba8Unorm:
case TexelFormat::kRgba8UnormSrgb:
case TexelFormat::kBgra8Unorm:
case TexelFormat::kBgra8UnormSrgb:
case TexelFormat::kRgb10A2Unorm:
case TexelFormat::kR8Snorm:
case TexelFormat::kRg8Snorm:
case TexelFormat::kRgba8Snorm: case TexelFormat::kRgba8Snorm:
case TexelFormat::kR16Float:
case TexelFormat::kR32Float: case TexelFormat::kR32Float:
case TexelFormat::kRg16Float:
case TexelFormat::kRg11B10Float:
case TexelFormat::kRg32Float: case TexelFormat::kRg32Float:
case TexelFormat::kRgba16Float: case TexelFormat::kRgba16Float:
case TexelFormat::kRgba32Float: { case TexelFormat::kRgba32Float: {

View File

@ -26,38 +26,19 @@ namespace ast {
/// The texel format in the storage texture /// The texel format in the storage texture
enum class TexelFormat { enum class TexelFormat {
kNone = -1, kNone = -1,
kR8Unorm,
kR8Snorm,
kR8Uint,
kR8Sint,
kR16Uint,
kR16Sint,
kR16Float,
kRg8Unorm,
kRg8Snorm,
kRg8Uint,
kRg8Sint,
kR32Uint,
kR32Sint,
kR32Float,
kRg16Uint,
kRg16Sint,
kRg16Float,
kRgba8Unorm, kRgba8Unorm,
kRgba8UnormSrgb,
kRgba8Snorm, kRgba8Snorm,
kRgba8Uint, kRgba8Uint,
kRgba8Sint, kRgba8Sint,
kBgra8Unorm,
kBgra8UnormSrgb,
kRgb10A2Unorm,
kRg11B10Float,
kRg32Uint,
kRg32Sint,
kRg32Float,
kRgba16Uint, kRgba16Uint,
kRgba16Sint, kRgba16Sint,
kRgba16Float, kRgba16Float,
kR32Uint,
kR32Sint,
kR32Float,
kRg32Uint,
kRg32Sint,
kRg32Float,
kRgba32Uint, kRgba32Uint,
kRgba32Sint, kRgba32Sint,
kRgba32Float, kRgba32Float,

View File

@ -74,58 +74,20 @@ ResourceBinding::SampledKind BaseTypeToSampledKind(const sem::Type* base_type) {
ResourceBinding::TexelFormat TypeTexelFormatToResourceBindingTexelFormat( ResourceBinding::TexelFormat TypeTexelFormatToResourceBindingTexelFormat(
const ast::TexelFormat& image_format) { const ast::TexelFormat& image_format) {
switch (image_format) { switch (image_format) {
case ast::TexelFormat::kR8Unorm:
return ResourceBinding::TexelFormat::kR8Unorm;
case ast::TexelFormat::kR8Snorm:
return ResourceBinding::TexelFormat::kR8Snorm;
case ast::TexelFormat::kR8Uint:
return ResourceBinding::TexelFormat::kR8Uint;
case ast::TexelFormat::kR8Sint:
return ResourceBinding::TexelFormat::kR8Sint;
case ast::TexelFormat::kR16Uint:
return ResourceBinding::TexelFormat::kR16Uint;
case ast::TexelFormat::kR16Sint:
return ResourceBinding::TexelFormat::kR16Sint;
case ast::TexelFormat::kR16Float:
return ResourceBinding::TexelFormat::kR16Float;
case ast::TexelFormat::kRg8Unorm:
return ResourceBinding::TexelFormat::kRg8Unorm;
case ast::TexelFormat::kRg8Snorm:
return ResourceBinding::TexelFormat::kRg8Snorm;
case ast::TexelFormat::kRg8Uint:
return ResourceBinding::TexelFormat::kRg8Uint;
case ast::TexelFormat::kRg8Sint:
return ResourceBinding::TexelFormat::kRg8Sint;
case ast::TexelFormat::kR32Uint: case ast::TexelFormat::kR32Uint:
return ResourceBinding::TexelFormat::kR32Uint; return ResourceBinding::TexelFormat::kR32Uint;
case ast::TexelFormat::kR32Sint: case ast::TexelFormat::kR32Sint:
return ResourceBinding::TexelFormat::kR32Sint; return ResourceBinding::TexelFormat::kR32Sint;
case ast::TexelFormat::kR32Float: case ast::TexelFormat::kR32Float:
return ResourceBinding::TexelFormat::kR32Float; return ResourceBinding::TexelFormat::kR32Float;
case ast::TexelFormat::kRg16Uint:
return ResourceBinding::TexelFormat::kRg16Uint;
case ast::TexelFormat::kRg16Sint:
return ResourceBinding::TexelFormat::kRg16Sint;
case ast::TexelFormat::kRg16Float:
return ResourceBinding::TexelFormat::kRg16Float;
case ast::TexelFormat::kRgba8Unorm: case ast::TexelFormat::kRgba8Unorm:
return ResourceBinding::TexelFormat::kRgba8Unorm; return ResourceBinding::TexelFormat::kRgba8Unorm;
case ast::TexelFormat::kRgba8UnormSrgb:
return ResourceBinding::TexelFormat::kRgba8UnormSrgb;
case ast::TexelFormat::kRgba8Snorm: case ast::TexelFormat::kRgba8Snorm:
return ResourceBinding::TexelFormat::kRgba8Snorm; return ResourceBinding::TexelFormat::kRgba8Snorm;
case ast::TexelFormat::kRgba8Uint: case ast::TexelFormat::kRgba8Uint:
return ResourceBinding::TexelFormat::kRgba8Uint; return ResourceBinding::TexelFormat::kRgba8Uint;
case ast::TexelFormat::kRgba8Sint: case ast::TexelFormat::kRgba8Sint:
return ResourceBinding::TexelFormat::kRgba8Sint; return ResourceBinding::TexelFormat::kRgba8Sint;
case ast::TexelFormat::kBgra8Unorm:
return ResourceBinding::TexelFormat::kBgra8Unorm;
case ast::TexelFormat::kBgra8UnormSrgb:
return ResourceBinding::TexelFormat::kBgra8UnormSrgb;
case ast::TexelFormat::kRgb10A2Unorm:
return ResourceBinding::TexelFormat::kRgb10A2Unorm;
case ast::TexelFormat::kRg11B10Float:
return ResourceBinding::TexelFormat::kRg11B10Float;
case ast::TexelFormat::kRg32Uint: case ast::TexelFormat::kRg32Uint:
return ResourceBinding::TexelFormat::kRg32Uint; return ResourceBinding::TexelFormat::kRg32Uint;
case ast::TexelFormat::kRg32Sint: case ast::TexelFormat::kRg32Sint:

View File

@ -50,6 +50,26 @@ struct ResourceBinding {
/// Enumerator of texel image formats /// Enumerator of texel image formats
enum class TexelFormat { enum class TexelFormat {
kNone = -1, kNone = -1,
kRgba8Unorm,
kRgba8Snorm,
kRgba8Uint,
kRgba8Sint,
kRgba16Uint,
kRgba16Sint,
kRgba16Float,
kR32Uint,
kR32Sint,
kR32Float,
kRg32Uint,
kRg32Sint,
kRg32Float,
kRgba32Uint,
kRgba32Sint,
kRgba32Float,
// [DEPRECATED]
// The below are all deprecated, and will be removed.
kR8Unorm, kR8Unorm,
kR8Snorm, kR8Snorm,
kR8Uint, kR8Uint,
@ -61,30 +81,14 @@ struct ResourceBinding {
kRg8Snorm, kRg8Snorm,
kRg8Uint, kRg8Uint,
kRg8Sint, kRg8Sint,
kR32Uint,
kR32Sint,
kR32Float,
kRg16Uint, kRg16Uint,
kRg16Sint, kRg16Sint,
kRg16Float, kRg16Float,
kRgba8Unorm,
kRgba8UnormSrgb, kRgba8UnormSrgb,
kRgba8Snorm,
kRgba8Uint,
kRgba8Sint,
kBgra8Unorm, kBgra8Unorm,
kBgra8UnormSrgb, kBgra8UnormSrgb,
kRgb10A2Unorm, kRgb10A2Unorm,
kRg11B10Float, kRg11B10Float,
kRg32Uint,
kRg32Sint,
kRg32Float,
kRgba16Uint,
kRgba16Sint,
kRgba16Float,
kRgba32Uint,
kRgba32Sint,
kRgba32Float,
}; };
/// Renamed field [DEPRECATED] /// Renamed field [DEPRECATED]

View File

@ -2528,42 +2528,23 @@ const Pointer* ParserImpl::GetTypeForHandleVar(
const Type* ParserImpl::GetComponentTypeForFormat(ast::TexelFormat format) { const Type* ParserImpl::GetComponentTypeForFormat(ast::TexelFormat format) {
switch (format) { switch (format) {
case ast::TexelFormat::kR8Uint:
case ast::TexelFormat::kR16Uint:
case ast::TexelFormat::kRg8Uint:
case ast::TexelFormat::kR32Uint: case ast::TexelFormat::kR32Uint:
case ast::TexelFormat::kRg16Uint:
case ast::TexelFormat::kRgba8Uint: case ast::TexelFormat::kRgba8Uint:
case ast::TexelFormat::kRg32Uint: case ast::TexelFormat::kRg32Uint:
case ast::TexelFormat::kRgba16Uint: case ast::TexelFormat::kRgba16Uint:
case ast::TexelFormat::kRgba32Uint: case ast::TexelFormat::kRgba32Uint:
return ty_.U32(); return ty_.U32();
case ast::TexelFormat::kR8Sint:
case ast::TexelFormat::kR16Sint:
case ast::TexelFormat::kRg8Sint:
case ast::TexelFormat::kR32Sint: case ast::TexelFormat::kR32Sint:
case ast::TexelFormat::kRg16Sint:
case ast::TexelFormat::kRgba8Sint: case ast::TexelFormat::kRgba8Sint:
case ast::TexelFormat::kRg32Sint: case ast::TexelFormat::kRg32Sint:
case ast::TexelFormat::kRgba16Sint: case ast::TexelFormat::kRgba16Sint:
case ast::TexelFormat::kRgba32Sint: case ast::TexelFormat::kRgba32Sint:
return ty_.I32(); return ty_.I32();
case ast::TexelFormat::kR8Unorm:
case ast::TexelFormat::kRg8Unorm:
case ast::TexelFormat::kRgba8Unorm: 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::kRgba8Snorm:
case ast::TexelFormat::kR16Float:
case ast::TexelFormat::kR32Float: case ast::TexelFormat::kR32Float:
case ast::TexelFormat::kRg16Float:
case ast::TexelFormat::kRg11B10Float:
case ast::TexelFormat::kRg32Float: case ast::TexelFormat::kRg32Float:
case ast::TexelFormat::kRgba16Float: case ast::TexelFormat::kRgba16Float:
case ast::TexelFormat::kRgba32Float: case ast::TexelFormat::kRgba32Float:
@ -2577,36 +2558,18 @@ const Type* ParserImpl::GetComponentTypeForFormat(ast::TexelFormat format) {
unsigned ParserImpl::GetChannelCountForFormat(ast::TexelFormat format) { unsigned ParserImpl::GetChannelCountForFormat(ast::TexelFormat format) {
switch (format) { switch (format) {
case ast::TexelFormat::kR16Float:
case ast::TexelFormat::kR16Sint:
case ast::TexelFormat::kR16Uint:
case ast::TexelFormat::kR32Float: case ast::TexelFormat::kR32Float:
case ast::TexelFormat::kR32Sint: case ast::TexelFormat::kR32Sint:
case ast::TexelFormat::kR32Uint: case ast::TexelFormat::kR32Uint:
case ast::TexelFormat::kR8Sint:
case ast::TexelFormat::kR8Snorm:
case ast::TexelFormat::kR8Uint:
case ast::TexelFormat::kR8Unorm:
// One channel // One channel
return 1; return 1;
case ast::TexelFormat::kRg11B10Float:
case ast::TexelFormat::kRg16Float:
case ast::TexelFormat::kRg16Sint:
case ast::TexelFormat::kRg16Uint:
case ast::TexelFormat::kRg32Float: case ast::TexelFormat::kRg32Float:
case ast::TexelFormat::kRg32Sint: case ast::TexelFormat::kRg32Sint:
case ast::TexelFormat::kRg32Uint: case ast::TexelFormat::kRg32Uint:
case ast::TexelFormat::kRg8Sint:
case ast::TexelFormat::kRg8Snorm:
case ast::TexelFormat::kRg8Uint:
case ast::TexelFormat::kRg8Unorm:
// Two channels // Two channels
return 2; return 2;
case ast::TexelFormat::kBgra8Unorm:
case ast::TexelFormat::kBgra8UnormSrgb:
case ast::TexelFormat::kRgb10A2Unorm:
case ast::TexelFormat::kRgba16Float: case ast::TexelFormat::kRgba16Float:
case ast::TexelFormat::kRgba16Sint: case ast::TexelFormat::kRgba16Sint:
case ast::TexelFormat::kRgba16Uint: case ast::TexelFormat::kRgba16Uint:
@ -2617,7 +2580,6 @@ unsigned ParserImpl::GetChannelCountForFormat(ast::TexelFormat format) {
case ast::TexelFormat::kRgba8Snorm: case ast::TexelFormat::kRgba8Snorm:
case ast::TexelFormat::kRgba8Uint: case ast::TexelFormat::kRgba8Uint:
case ast::TexelFormat::kRgba8Unorm: case ast::TexelFormat::kRgba8Unorm:
case ast::TexelFormat::kRgba8UnormSrgb:
// Four channels // Four channels
return 4; return 4;

View File

@ -46,9 +46,9 @@ TEST(SpvParserTypeTest, SameArgumentsGivesSamePointer) {
EXPECT_EQ(ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()), EXPECT_EQ(ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()),
ty.SampledTexture(ast::TextureDimension::k2d, ty.I32())); ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()));
EXPECT_EQ(ty.StorageTexture(ast::TextureDimension::k2d, EXPECT_EQ(ty.StorageTexture(ast::TextureDimension::k2d,
ast::TexelFormat::kR16Sint, ast::Access::kRead), ast::TexelFormat::kR32Uint, ast::Access::kRead),
ty.StorageTexture(ast::TextureDimension::k2d, ty.StorageTexture(ast::TextureDimension::k2d,
ast::TexelFormat::kR16Sint, ast::Access::kRead)); ast::TexelFormat::kR32Uint, ast::Access::kRead));
} }
TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) { TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
@ -83,17 +83,17 @@ TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
EXPECT_NE(ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()), EXPECT_NE(ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()),
ty.SampledTexture(ast::TextureDimension::k2d, ty.U32())); ty.SampledTexture(ast::TextureDimension::k2d, ty.U32()));
EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d, EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d,
ast::TexelFormat::kR16Sint, ast::Access::kRead), ast::TexelFormat::kR32Uint, ast::Access::kRead),
ty.StorageTexture(ast::TextureDimension::k3d, ty.StorageTexture(ast::TextureDimension::k3d,
ast::TexelFormat::kR16Sint, ast::Access::kRead)); ast::TexelFormat::kR32Uint, ast::Access::kRead));
EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d, EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d,
ast::TexelFormat::kR16Sint, ast::Access::kRead), ast::TexelFormat::kR32Uint, ast::Access::kRead),
ty.StorageTexture(ast::TextureDimension::k2d, ty.StorageTexture(ast::TextureDimension::k2d,
ast::TexelFormat::kR32Sint, ast::Access::kRead)); ast::TexelFormat::kR32Sint, ast::Access::kRead));
EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d, EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d,
ast::TexelFormat::kR16Sint, ast::Access::kRead), ast::TexelFormat::kR32Uint, ast::Access::kRead),
ty.StorageTexture(ast::TextureDimension::k2d, ty.StorageTexture(ast::TextureDimension::k2d,
ast::TexelFormat::kR16Sint, ast::Access::kWrite)); ast::TexelFormat::kR32Uint, ast::Access::kWrite));
} }
} // namespace } // namespace

View File

@ -745,139 +745,30 @@ Maybe<const ast::Type*> ParserImpl::depth_texture_type() {
return Failure::kNoMatch; return Failure::kNoMatch;
} }
// image_storage_type // texel_format
// : R8UNORM // : 'rgba8unorm'
// | R8SNORM // | 'rgba8snorm'
// | R8UINT // | 'rgba8uint'
// | R8SINT // | 'rgba8sint'
// | R16UINT // | 'rgba16uint'
// | R16SINT // | 'rgba16sint'
// | R16FLOAT // | 'rgba16float'
// | RG8UNORM // | 'r32uint'
// | RG8SNORM // | 'r32sint'
// | RG8UINT // | 'r32float'
// | RG8SINT // | 'rg32uint'
// | R32UINT // | 'rg32sint'
// | R32SINT // | 'rg32float'
// | R32FLOAT // | 'rgba32uint'
// | RG16UINT // | 'rgba32sint'
// | RG16SINT // | 'rgba32float'
// | RG16FLOAT
// | RGBA8UNORM
/// | RGBA8UNORM-SRGB
// | RGBA8SNORM
// | RGBA8UINT
// | RGBA8SINT
// | BGRA8UNORM
// | BGRA8UNORM-SRGB
// | RGB10A2UNORM
// | RG11B10FLOAT
// | RG32UINT
// | RG32SINT
// | RG32FLOAT
// | RGBA16UINT
// | RGBA16SINT
// | RGBA16FLOAT
// | RGBA32UINT
// | RGBA32SINT
// | RGBA32FLOAT
Expect<ast::TexelFormat> ParserImpl::expect_texel_format( Expect<ast::TexelFormat> ParserImpl::expect_texel_format(
const std::string& use) { const std::string& use) {
auto tok = next(); auto tok = next();
if (tok.IsIdentifier()) { if (tok.IsIdentifier()) {
auto s = tok.to_str(); auto s = tok.to_str();
if (s == "bgra8unorm") { if (s == "rgba8unorm") {
return ast::TexelFormat::kBgra8Unorm; return ast::TexelFormat::kRgba8Unorm;
}
if (s == "bgra8unorm_srgb") {
return ast::TexelFormat::kBgra8UnormSrgb;
}
if (s == "r16float") {
return ast::TexelFormat::kR16Float;
}
if (s == "r16sint") {
return ast::TexelFormat::kR16Sint;
}
if (s == "r16uint") {
return ast::TexelFormat::kR16Uint;
}
if (s == "r32float") {
return ast::TexelFormat::kR32Float;
}
if (s == "r32sint") {
return ast::TexelFormat::kR32Sint;
}
if (s == "r32uint") {
return ast::TexelFormat::kR32Uint;
}
if (s == "r8sint") {
return ast::TexelFormat::kR8Sint;
}
if (s == "r8snorm") {
return ast::TexelFormat::kR8Snorm;
}
if (s == "r8uint") {
return ast::TexelFormat::kR8Uint;
}
if (s == "r8unorm") {
return ast::TexelFormat::kR8Unorm;
}
if (s == "rg11b10float") {
return ast::TexelFormat::kRg11B10Float;
}
if (s == "rg16float") {
return ast::TexelFormat::kRg16Float;
}
if (s == "rg16sint") {
return ast::TexelFormat::kRg16Sint;
}
if (s == "rg16uint") {
return ast::TexelFormat::kRg16Uint;
}
if (s == "rg32float") {
return ast::TexelFormat::kRg32Float;
}
if (s == "rg32sint") {
return ast::TexelFormat::kRg32Sint;
}
if (s == "rg32uint") {
return ast::TexelFormat::kRg32Uint;
}
if (s == "rg8sint") {
return ast::TexelFormat::kRg8Sint;
}
if (s == "rg8snorm") {
return ast::TexelFormat::kRg8Snorm;
}
if (s == "rg8uint") {
return ast::TexelFormat::kRg8Uint;
}
if (s == "rg8unorm") {
return ast::TexelFormat::kRg8Unorm;
}
if (s == "rgb10a2unorm") {
return ast::TexelFormat::kRgb10A2Unorm;
}
if (s == "rgba16float") {
return ast::TexelFormat::kRgba16Float;
}
if (s == "rgba16sint") {
return ast::TexelFormat::kRgba16Sint;
}
if (s == "rgba16uint") {
return ast::TexelFormat::kRgba16Uint;
}
if (s == "rgba32float") {
return ast::TexelFormat::kRgba32Float;
}
if (s == "rgba32sint") {
return ast::TexelFormat::kRgba32Sint;
}
if (s == "rgba32uint") {
return ast::TexelFormat::kRgba32Uint;
}
if (s == "rgba8sint") {
return ast::TexelFormat::kRgba8Sint;
} }
if (s == "rgba8snorm") { if (s == "rgba8snorm") {
return ast::TexelFormat::kRgba8Snorm; return ast::TexelFormat::kRgba8Snorm;
@ -885,11 +776,44 @@ Expect<ast::TexelFormat> ParserImpl::expect_texel_format(
if (s == "rgba8uint") { if (s == "rgba8uint") {
return ast::TexelFormat::kRgba8Uint; return ast::TexelFormat::kRgba8Uint;
} }
if (s == "rgba8unorm") { if (s == "rgba8sint") {
return ast::TexelFormat::kRgba8Unorm; return ast::TexelFormat::kRgba8Sint;
} }
if (s == "rgba8unorm_srgb") { if (s == "rgba16uint") {
return ast::TexelFormat::kRgba8UnormSrgb; return ast::TexelFormat::kRgba16Uint;
}
if (s == "rgba16sint") {
return ast::TexelFormat::kRgba16Sint;
}
if (s == "rgba16float") {
return ast::TexelFormat::kRgba16Float;
}
if (s == "r32uint") {
return ast::TexelFormat::kR32Uint;
}
if (s == "r32sint") {
return ast::TexelFormat::kR32Sint;
}
if (s == "r32float") {
return ast::TexelFormat::kR32Float;
}
if (s == "rg32uint") {
return ast::TexelFormat::kRg32Uint;
}
if (s == "rg32sint") {
return ast::TexelFormat::kRg32Sint;
}
if (s == "rg32float") {
return ast::TexelFormat::kRg32Float;
}
if (s == "rgba32uint") {
return ast::TexelFormat::kRgba32Uint;
}
if (s == "rgba32sint") {
return ast::TexelFormat::kRgba32Sint;
}
if (s == "rgba32float") {
return ast::TexelFormat::kRgba32Float;
} }
} }
return add_error(tok.source(), "invalid format", use); return add_error(tok.source(), "invalid format", use);

View File

@ -585,9 +585,9 @@ TEST_F(ParserImplErrorTest, GlobalDeclStorageTextureMissingLessThan) {
} }
TEST_F(ParserImplErrorTest, GlobalDeclStorageTextureMissingGreaterThan) { TEST_F(ParserImplErrorTest, GlobalDeclStorageTextureMissingGreaterThan) {
EXPECT("var x : texture_storage_2d<r8uint, read;", EXPECT("var x : texture_storage_2d<r32uint, read;",
"test.wgsl:1:40 error: expected '>' for storage texture type\n" "test.wgsl:1:41 error: expected '>' for storage texture type\n"
"var x : texture_storage_2d<r8uint, read;\n" "var x : texture_storage_2d<r32uint, read;\n"
" ^\n"); " ^\n");
} }

View File

@ -27,94 +27,6 @@ TEST_F(ParserImplTest, ImageStorageType_Invalid) {
EXPECT_EQ(p->error(), "1:1: invalid format for test"); EXPECT_EQ(p->error(), "1:1: invalid format for test");
} }
TEST_F(ParserImplTest, ImageStorageType_R8Unorm) {
auto p = parser("r8unorm");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kR8Unorm);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_R8Snorm) {
auto p = parser("r8snorm");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kR8Snorm);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_R8Uint) {
auto p = parser("r8uint");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kR8Uint);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_R8Sint) {
auto p = parser("r8sint");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kR8Sint);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_R16Uint) {
auto p = parser("r16uint");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kR16Uint);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_R16Sint) {
auto p = parser("r16sint");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kR16Sint);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_R16Float) {
auto p = parser("r16float");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kR16Float);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_Rg8Unorm) {
auto p = parser("rg8unorm");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRg8Unorm);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_Rg8Snorm) {
auto p = parser("rg8snorm");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRg8Snorm);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_Rg8Uint) {
auto p = parser("rg8uint");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRg8Uint);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_Rg8Sint) {
auto p = parser("rg8sint");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRg8Sint);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_R32Uint) { TEST_F(ParserImplTest, ImageStorageType_R32Uint) {
auto p = parser("r32uint"); auto p = parser("r32uint");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
@ -139,30 +51,6 @@ TEST_F(ParserImplTest, ImageStorageType_R32Float) {
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
TEST_F(ParserImplTest, ImageStorageType_Rg16Uint) {
auto p = parser("rg16uint");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRg16Uint);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_Rg16Sint) {
auto p = parser("rg16sint");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRg16Sint);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_Rg16Float) {
auto p = parser("rg16float");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRg16Float);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_Rgba8Unorm) { TEST_F(ParserImplTest, ImageStorageType_Rgba8Unorm) {
auto p = parser("rgba8unorm"); auto p = parser("rgba8unorm");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
@ -171,14 +59,6 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Unorm) {
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
TEST_F(ParserImplTest, ImageStorageType_Rgba8UnormSrgb) {
auto p = parser("rgba8unorm_srgb");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRgba8UnormSrgb);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_Rgba8Snorm) { TEST_F(ParserImplTest, ImageStorageType_Rgba8Snorm) {
auto p = parser("rgba8snorm"); auto p = parser("rgba8snorm");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");
@ -203,38 +83,6 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Sint) {
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
} }
TEST_F(ParserImplTest, ImageStorageType_Bgra8Unorm) {
auto p = parser("bgra8unorm");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kBgra8Unorm);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_Bgra8UnormSrgb) {
auto p = parser("bgra8unorm_srgb");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kBgra8UnormSrgb);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_Rgb10A2Unorm) {
auto p = parser("rgb10a2unorm");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRgb10A2Unorm);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_Rg11B10Float) {
auto p = parser("rg11b10float");
auto t = p->expect_texel_format("test");
EXPECT_FALSE(t.errored);
EXPECT_EQ(t.value, ast::TexelFormat::kRg11B10Float);
EXPECT_FALSE(p->has_error());
}
TEST_F(ParserImplTest, ImageStorageType_Rg32Uint) { TEST_F(ParserImplTest, ImageStorageType_Rg32Uint) {
auto p = parser("rg32uint"); auto p = parser("rg32uint");
auto t = p->expect_texel_format("test"); auto t = p->expect_texel_format("test");

View File

@ -184,8 +184,8 @@ TEST_F(ParserImplTest,
EXPECT_EQ(p->error(), "1:28: expected '>' for multisampled texture type"); EXPECT_EQ(p->error(), "1:28: expected '>' for multisampled texture type");
} }
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) { TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dRg32Float) {
auto p = parser("texture_storage_1d<r8unorm, read>"); auto p = parser("texture_storage_1d<rg32float, read>");
auto t = p->texture_sampler_types(); auto t = p->texture_sampler_types();
ASSERT_FALSE(p->has_error()) << p->error(); ASSERT_FALSE(p->has_error()) << p->error();
EXPECT_TRUE(t.matched); EXPECT_TRUE(t.matched);
@ -194,14 +194,14 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) {
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::kR8Unorm); EXPECT_EQ(t->As<ast::StorageTexture>()->format, ast::TexelFormat::kRg32Float);
EXPECT_EQ(t->As<ast::StorageTexture>()->access, ast::Access::kRead); EXPECT_EQ(t->As<ast::StorageTexture>()->access, ast::Access::kRead);
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k1d); EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k1d);
EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 34u}})); EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 36u}}));
} }
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) { TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR32Uint) {
auto p = parser("texture_storage_2d<r16float, write>"); auto p = parser("texture_storage_2d<r32uint, write>");
auto t = p->texture_sampler_types(); auto t = p->texture_sampler_types();
ASSERT_FALSE(p->has_error()) << p->error(); ASSERT_FALSE(p->has_error()) << p->error();
EXPECT_TRUE(t.matched); EXPECT_TRUE(t.matched);
@ -210,10 +210,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
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::kR16Float); EXPECT_EQ(t->As<ast::StorageTexture>()->format, ast::TexelFormat::kR32Uint);
EXPECT_EQ(t->As<ast::StorageTexture>()->access, ast::Access::kWrite); EXPECT_EQ(t->As<ast::StorageTexture>()->access, ast::Access::kWrite);
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k2d); EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k2d);
EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 36u}})); EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 35u}}));
} }
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) { TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {
@ -226,7 +226,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {
} }
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidAccess) { TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidAccess) {
auto p = parser("texture_storage_1d<r16float, abc>"); auto p = parser("texture_storage_1d<r32float, abc>");
auto t = p->texture_sampler_types(); auto t = p->texture_sampler_types();
EXPECT_EQ(t.value, nullptr); EXPECT_EQ(t.value, nullptr);
EXPECT_FALSE(t.matched); EXPECT_FALSE(t.matched);
@ -253,7 +253,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingLessThan) {
} }
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingGreaterThan) { TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingGreaterThan) {
auto p = parser("texture_storage_1d<r8unorm, read"); auto p = parser("texture_storage_1d<r32uint, read");
auto t = p->texture_sampler_types(); auto t = p->texture_sampler_types();
EXPECT_EQ(t.value, nullptr); EXPECT_EQ(t.value, nullptr);
EXPECT_FALSE(t.matched); EXPECT_FALSE(t.matched);

View File

@ -1316,7 +1316,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
Global(Sym(), ty.external_texture()); Global(Sym(), ty.external_texture());
Global(Sym(), ty.multisampled_texture(ast::TextureDimension::k2d, T)); Global(Sym(), ty.multisampled_texture(ast::TextureDimension::k2d, T));
Global(Sym(), ty.storage_texture(ast::TextureDimension::k2d, Global(Sym(), ty.storage_texture(ast::TextureDimension::k2d,
ast::TexelFormat::kR16Float, ast::TexelFormat::kR32Float,
ast::Access::kRead)); // ast::Access::kRead)); //
Global(Sym(), ty.sampler(ast::SamplerKind::kSampler)); Global(Sym(), ty.sampler(ast::SamplerKind::kSampler));
Func(Sym(), {}, ty.void_(), {}); Func(Sym(), {}, ty.void_(), {});

View File

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

@ -861,30 +861,12 @@ struct FormatParams {
}; };
static constexpr FormatParams format_cases[] = { static constexpr FormatParams format_cases[] = {
FormatParams{ast::TexelFormat::kBgra8Unorm, false},
FormatParams{ast::TexelFormat::kBgra8UnormSrgb, false},
FormatParams{ast::TexelFormat::kR16Float, false},
FormatParams{ast::TexelFormat::kR16Sint, false},
FormatParams{ast::TexelFormat::kR16Uint, false},
FormatParams{ast::TexelFormat::kR32Float, true}, FormatParams{ast::TexelFormat::kR32Float, true},
FormatParams{ast::TexelFormat::kR32Sint, true}, FormatParams{ast::TexelFormat::kR32Sint, true},
FormatParams{ast::TexelFormat::kR32Uint, true}, FormatParams{ast::TexelFormat::kR32Uint, true},
FormatParams{ast::TexelFormat::kR8Sint, false},
FormatParams{ast::TexelFormat::kR8Snorm, false},
FormatParams{ast::TexelFormat::kR8Uint, false},
FormatParams{ast::TexelFormat::kR8Unorm, false},
FormatParams{ast::TexelFormat::kRg11B10Float, false},
FormatParams{ast::TexelFormat::kRg16Float, false},
FormatParams{ast::TexelFormat::kRg16Sint, false},
FormatParams{ast::TexelFormat::kRg16Uint, false},
FormatParams{ast::TexelFormat::kRg32Float, true}, FormatParams{ast::TexelFormat::kRg32Float, true},
FormatParams{ast::TexelFormat::kRg32Sint, true}, FormatParams{ast::TexelFormat::kRg32Sint, true},
FormatParams{ast::TexelFormat::kRg32Uint, true}, FormatParams{ast::TexelFormat::kRg32Uint, true},
FormatParams{ast::TexelFormat::kRg8Sint, false},
FormatParams{ast::TexelFormat::kRg8Snorm, false},
FormatParams{ast::TexelFormat::kRg8Uint, false},
FormatParams{ast::TexelFormat::kRg8Unorm, false},
FormatParams{ast::TexelFormat::kRgb10A2Unorm, false},
FormatParams{ast::TexelFormat::kRgba16Float, true}, FormatParams{ast::TexelFormat::kRgba16Float, true},
FormatParams{ast::TexelFormat::kRgba16Sint, true}, FormatParams{ast::TexelFormat::kRgba16Sint, true},
FormatParams{ast::TexelFormat::kRgba16Uint, true}, FormatParams{ast::TexelFormat::kRgba16Uint, true},
@ -894,8 +876,7 @@ static constexpr FormatParams format_cases[] = {
FormatParams{ast::TexelFormat::kRgba8Sint, true}, FormatParams{ast::TexelFormat::kRgba8Sint, true},
FormatParams{ast::TexelFormat::kRgba8Snorm, true}, FormatParams{ast::TexelFormat::kRgba8Snorm, true},
FormatParams{ast::TexelFormat::kRgba8Uint, true}, FormatParams{ast::TexelFormat::kRgba8Uint, true},
FormatParams{ast::TexelFormat::kRgba8Unorm, true}, FormatParams{ast::TexelFormat::kRgba8Unorm, true}};
FormatParams{ast::TexelFormat::kRgba8UnormSrgb, false}};
using StorageTextureFormatTest = ResolverTestWithParam<FormatParams>; using StorageTextureFormatTest = ResolverTestWithParam<FormatParams>;
TEST_P(StorageTextureFormatTest, All) { TEST_P(StorageTextureFormatTest, All) {

View File

@ -48,11 +48,7 @@ std::string StorageTexture::FriendlyName(const SymbolTable&) const {
sem::Type* StorageTexture::SubtypeFor(ast::TexelFormat format, sem::Type* StorageTexture::SubtypeFor(ast::TexelFormat format,
sem::Manager& type_mgr) { sem::Manager& type_mgr) {
switch (format) { switch (format) {
case ast::TexelFormat::kR8Uint:
case ast::TexelFormat::kR16Uint:
case ast::TexelFormat::kRg8Uint:
case ast::TexelFormat::kR32Uint: case ast::TexelFormat::kR32Uint:
case ast::TexelFormat::kRg16Uint:
case ast::TexelFormat::kRgba8Uint: case ast::TexelFormat::kRgba8Uint:
case ast::TexelFormat::kRg32Uint: case ast::TexelFormat::kRg32Uint:
case ast::TexelFormat::kRgba16Uint: case ast::TexelFormat::kRgba16Uint:
@ -60,11 +56,7 @@ sem::Type* StorageTexture::SubtypeFor(ast::TexelFormat format,
return type_mgr.Get<sem::U32>(); return type_mgr.Get<sem::U32>();
} }
case ast::TexelFormat::kR8Sint:
case ast::TexelFormat::kR16Sint:
case ast::TexelFormat::kRg8Sint:
case ast::TexelFormat::kR32Sint: case ast::TexelFormat::kR32Sint:
case ast::TexelFormat::kRg16Sint:
case ast::TexelFormat::kRgba8Sint: case ast::TexelFormat::kRgba8Sint:
case ast::TexelFormat::kRg32Sint: case ast::TexelFormat::kRg32Sint:
case ast::TexelFormat::kRgba16Sint: case ast::TexelFormat::kRgba16Sint:
@ -72,20 +64,9 @@ sem::Type* StorageTexture::SubtypeFor(ast::TexelFormat format,
return type_mgr.Get<sem::I32>(); return type_mgr.Get<sem::I32>();
} }
case ast::TexelFormat::kR8Unorm:
case ast::TexelFormat::kRg8Unorm:
case ast::TexelFormat::kRgba8Unorm: 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::kRgba8Snorm:
case ast::TexelFormat::kR16Float:
case ast::TexelFormat::kR32Float: case ast::TexelFormat::kR32Float:
case ast::TexelFormat::kRg16Float:
case ast::TexelFormat::kRg11B10Float:
case ast::TexelFormat::kRg32Float: case ast::TexelFormat::kRg32Float:
case ast::TexelFormat::kRgba16Float: case ast::TexelFormat::kRgba16Float:
case ast::TexelFormat::kRgba32Float: { case ast::TexelFormat::kRgba32Float: {

View File

@ -1334,19 +1334,19 @@ INSTANTIATE_TEST_SUITE_P(
"ptrdiff_t", "ptrdiff_t",
"r16snorm", "r16snorm",
"r16unorm", "r16unorm",
// "r8unorm", // Also used in WGSL "r8unorm",
"reference", "reference",
"rg11b10f", "rg11b10f",
"rg16snorm", "rg16snorm",
"rg16unorm", "rg16unorm",
// "rg8snorm", // Also used in WGSL "rg8snorm",
// "rg8unorm", // Also used in WGSL "rg8unorm",
"rgb10a2", "rgb10a2",
"rgb9e5", "rgb9e5",
"rgba16snorm", "rgba16snorm",
"rgba16unorm", "rgba16unorm",
// "rgba8snorm", // Also used in WGSL "rgba8snorm",
// "rgba8unorm", // Also used in WGSL "rgba8unorm",
// "sampler", // Also used in WGSL // "sampler", // Also used in WGSL
"short2", "short2",
"short3", "short3",

View File

@ -4304,74 +4304,20 @@ void Builder::AddInterpolationDecorations(uint32_t id,
SpvImageFormat Builder::convert_texel_format_to_spv( SpvImageFormat Builder::convert_texel_format_to_spv(
const ast::TexelFormat format) { const ast::TexelFormat format) {
switch (format) { switch (format) {
case ast::TexelFormat::kR8Unorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8;
case ast::TexelFormat::kR8Snorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8Snorm;
case ast::TexelFormat::kR8Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8ui;
case ast::TexelFormat::kR8Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8i;
case ast::TexelFormat::kR16Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR16ui;
case ast::TexelFormat::kR16Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR16i;
case ast::TexelFormat::kR16Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR16f;
case ast::TexelFormat::kRg8Unorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8;
case ast::TexelFormat::kRg8Snorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8Snorm;
case ast::TexelFormat::kRg8Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8ui;
case ast::TexelFormat::kRg8Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8i;
case ast::TexelFormat::kR32Uint: case ast::TexelFormat::kR32Uint:
return SpvImageFormatR32ui; return SpvImageFormatR32ui;
case ast::TexelFormat::kR32Sint: case ast::TexelFormat::kR32Sint:
return SpvImageFormatR32i; return SpvImageFormatR32i;
case ast::TexelFormat::kR32Float: case ast::TexelFormat::kR32Float:
return SpvImageFormatR32f; return SpvImageFormatR32f;
case ast::TexelFormat::kRg16Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg16ui;
case ast::TexelFormat::kRg16Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg16i;
case ast::TexelFormat::kRg16Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg16f;
case ast::TexelFormat::kRgba8Unorm: case ast::TexelFormat::kRgba8Unorm:
return SpvImageFormatRgba8; return SpvImageFormatRgba8;
case ast::TexelFormat::kRgba8UnormSrgb:
return SpvImageFormatUnknown;
case ast::TexelFormat::kRgba8Snorm: case ast::TexelFormat::kRgba8Snorm:
return SpvImageFormatRgba8Snorm; return SpvImageFormatRgba8Snorm;
case ast::TexelFormat::kRgba8Uint: case ast::TexelFormat::kRgba8Uint:
return SpvImageFormatRgba8ui; return SpvImageFormatRgba8ui;
case ast::TexelFormat::kRgba8Sint: case ast::TexelFormat::kRgba8Sint:
return SpvImageFormatRgba8i; return SpvImageFormatRgba8i;
case ast::TexelFormat::kBgra8Unorm:
return SpvImageFormatUnknown;
case ast::TexelFormat::kBgra8UnormSrgb:
return SpvImageFormatUnknown;
case ast::TexelFormat::kRgb10A2Unorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRgb10A2;
case ast::TexelFormat::kRg11B10Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR11fG11fB10f;
case ast::TexelFormat::kRg32Uint: case ast::TexelFormat::kRg32Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats); push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg32ui; return SpvImageFormatRg32ui;

View File

@ -51,6 +51,7 @@ INSTANTIATE_TEST_SUITE_P(
BuilderTest, BuilderTest,
ImageFormatConversionTest, ImageFormatConversionTest,
testing::Values( testing::Values(
/* WGSL unsupported formats
TestData{ast::TexelFormat::kR8Unorm, SpvImageFormatR8, true}, TestData{ast::TexelFormat::kR8Unorm, SpvImageFormatR8, true},
TestData{ast::TexelFormat::kR8Snorm, SpvImageFormatR8Snorm, true}, TestData{ast::TexelFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
TestData{ast::TexelFormat::kR8Uint, SpvImageFormatR8ui, true}, TestData{ast::TexelFormat::kR8Uint, SpvImageFormatR8ui, true},
@ -62,22 +63,22 @@ INSTANTIATE_TEST_SUITE_P(
TestData{ast::TexelFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true}, TestData{ast::TexelFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true},
TestData{ast::TexelFormat::kRg8Uint, SpvImageFormatRg8ui, true}, TestData{ast::TexelFormat::kRg8Uint, SpvImageFormatRg8ui, true},
TestData{ast::TexelFormat::kRg8Sint, SpvImageFormatRg8i, true}, TestData{ast::TexelFormat::kRg8Sint, SpvImageFormatRg8i, true},
TestData{ast::TexelFormat::kR32Uint, SpvImageFormatR32ui},
TestData{ast::TexelFormat::kR32Sint, SpvImageFormatR32i},
TestData{ast::TexelFormat::kR32Float, SpvImageFormatR32f},
TestData{ast::TexelFormat::kRg16Uint, SpvImageFormatRg16ui, true}, TestData{ast::TexelFormat::kRg16Uint, SpvImageFormatRg16ui, true},
TestData{ast::TexelFormat::kRg16Sint, SpvImageFormatRg16i, true}, TestData{ast::TexelFormat::kRg16Sint, SpvImageFormatRg16i, true},
TestData{ast::TexelFormat::kRg16Float, SpvImageFormatRg16f, true}, TestData{ast::TexelFormat::kRg16Float, SpvImageFormatRg16f, true},
TestData{ast::TexelFormat::kRgba8Unorm, SpvImageFormatRgba8},
TestData{ast::TexelFormat::kRgba8UnormSrgb, SpvImageFormatUnknown}, TestData{ast::TexelFormat::kRgba8UnormSrgb, SpvImageFormatUnknown},
TestData{ast::TexelFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
TestData{ast::TexelFormat::kRgba8Uint, SpvImageFormatRgba8ui},
TestData{ast::TexelFormat::kRgba8Sint, SpvImageFormatRgba8i},
TestData{ast::TexelFormat::kBgra8Unorm, SpvImageFormatUnknown}, TestData{ast::TexelFormat::kBgra8Unorm, SpvImageFormatUnknown},
TestData{ast::TexelFormat::kBgra8UnormSrgb, SpvImageFormatUnknown}, TestData{ast::TexelFormat::kBgra8UnormSrgb, SpvImageFormatUnknown},
TestData{ast::TexelFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true}, TestData{ast::TexelFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true},
TestData{ast::TexelFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f, TestData{ast::TexelFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f, true},
true}, */
TestData{ast::TexelFormat::kR32Uint, SpvImageFormatR32ui},
TestData{ast::TexelFormat::kR32Sint, SpvImageFormatR32i},
TestData{ast::TexelFormat::kR32Float, SpvImageFormatR32f},
TestData{ast::TexelFormat::kRgba8Unorm, SpvImageFormatRgba8},
TestData{ast::TexelFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
TestData{ast::TexelFormat::kRgba8Uint, SpvImageFormatRgba8ui},
TestData{ast::TexelFormat::kRgba8Sint, SpvImageFormatRgba8i},
TestData{ast::TexelFormat::kRg32Uint, SpvImageFormatRg32ui, true}, TestData{ast::TexelFormat::kRg32Uint, SpvImageFormatRg32ui, true},
TestData{ast::TexelFormat::kRg32Sint, SpvImageFormatRg32i, true}, TestData{ast::TexelFormat::kRg32Sint, SpvImageFormatRg32i, true},
TestData{ast::TexelFormat::kRg32Float, SpvImageFormatRg32f, true}, TestData{ast::TexelFormat::kRg32Float, SpvImageFormatRg32f, true},

View File

@ -489,32 +489,13 @@ INSTANTIATE_TEST_SUITE_P(
WgslGeneratorImplTest, WgslGeneratorImplTest,
WgslGenerator_ImageFormatTest, WgslGenerator_ImageFormatTest,
testing::Values( testing::Values(
ImageFormatData{ast::TexelFormat::kR8Unorm, "r8unorm"},
ImageFormatData{ast::TexelFormat::kR8Snorm, "r8snorm"},
ImageFormatData{ast::TexelFormat::kR8Uint, "r8uint"},
ImageFormatData{ast::TexelFormat::kR8Sint, "r8sint"},
ImageFormatData{ast::TexelFormat::kR16Uint, "r16uint"},
ImageFormatData{ast::TexelFormat::kR16Sint, "r16sint"},
ImageFormatData{ast::TexelFormat::kR16Float, "r16float"},
ImageFormatData{ast::TexelFormat::kRg8Unorm, "rg8unorm"},
ImageFormatData{ast::TexelFormat::kRg8Snorm, "rg8snorm"},
ImageFormatData{ast::TexelFormat::kRg8Uint, "rg8uint"},
ImageFormatData{ast::TexelFormat::kRg8Sint, "rg8sint"},
ImageFormatData{ast::TexelFormat::kR32Uint, "r32uint"}, ImageFormatData{ast::TexelFormat::kR32Uint, "r32uint"},
ImageFormatData{ast::TexelFormat::kR32Sint, "r32sint"}, ImageFormatData{ast::TexelFormat::kR32Sint, "r32sint"},
ImageFormatData{ast::TexelFormat::kR32Float, "r32float"}, ImageFormatData{ast::TexelFormat::kR32Float, "r32float"},
ImageFormatData{ast::TexelFormat::kRg16Uint, "rg16uint"},
ImageFormatData{ast::TexelFormat::kRg16Sint, "rg16sint"},
ImageFormatData{ast::TexelFormat::kRg16Float, "rg16float"},
ImageFormatData{ast::TexelFormat::kRgba8Unorm, "rgba8unorm"}, ImageFormatData{ast::TexelFormat::kRgba8Unorm, "rgba8unorm"},
ImageFormatData{ast::TexelFormat::kRgba8UnormSrgb, "rgba8unorm_srgb"},
ImageFormatData{ast::TexelFormat::kRgba8Snorm, "rgba8snorm"}, ImageFormatData{ast::TexelFormat::kRgba8Snorm, "rgba8snorm"},
ImageFormatData{ast::TexelFormat::kRgba8Uint, "rgba8uint"}, ImageFormatData{ast::TexelFormat::kRgba8Uint, "rgba8uint"},
ImageFormatData{ast::TexelFormat::kRgba8Sint, "rgba8sint"}, ImageFormatData{ast::TexelFormat::kRgba8Sint, "rgba8sint"},
ImageFormatData{ast::TexelFormat::kBgra8Unorm, "bgra8unorm"},
ImageFormatData{ast::TexelFormat::kBgra8UnormSrgb, "bgra8unorm_srgb"},
ImageFormatData{ast::TexelFormat::kRgb10A2Unorm, "rgb10a2unorm"},
ImageFormatData{ast::TexelFormat::kRg11B10Float, "rg11b10float"},
ImageFormatData{ast::TexelFormat::kRg32Uint, "rg32uint"}, ImageFormatData{ast::TexelFormat::kRg32Uint, "rg32uint"},
ImageFormatData{ast::TexelFormat::kRg32Sint, "rg32sint"}, ImageFormatData{ast::TexelFormat::kRg32Sint, "rg32sint"},
ImageFormatData{ast::TexelFormat::kRg32Float, "rg32float"}, ImageFormatData{ast::TexelFormat::kRg32Float, "rg32float"},