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:
parent
3cbb136b8a
commit
4d245d9a36
|
@ -31,39 +31,6 @@ std::ostream& operator<<(std::ostream& out, TexelFormat format) {
|
|||
case TexelFormat::kNone:
|
||||
out << "none";
|
||||
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:
|
||||
out << "r32uint";
|
||||
break;
|
||||
|
@ -73,21 +40,9 @@ std::ostream& operator<<(std::ostream& out, TexelFormat format) {
|
|||
case TexelFormat::kR32Float:
|
||||
out << "r32float";
|
||||
break;
|
||||
case TexelFormat::kRg16Uint:
|
||||
out << "rg16uint";
|
||||
break;
|
||||
case TexelFormat::kRg16Sint:
|
||||
out << "rg16sint";
|
||||
break;
|
||||
case TexelFormat::kRg16Float:
|
||||
out << "rg16float";
|
||||
break;
|
||||
case TexelFormat::kRgba8Unorm:
|
||||
out << "rgba8unorm";
|
||||
break;
|
||||
case TexelFormat::kRgba8UnormSrgb:
|
||||
out << "rgba8unorm_srgb";
|
||||
break;
|
||||
case TexelFormat::kRgba8Snorm:
|
||||
out << "rgba8snorm";
|
||||
break;
|
||||
|
@ -97,18 +52,6 @@ std::ostream& operator<<(std::ostream& out, TexelFormat format) {
|
|||
case TexelFormat::kRgba8Sint:
|
||||
out << "rgba8sint";
|
||||
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:
|
||||
out << "rg32uint";
|
||||
break;
|
||||
|
@ -167,11 +110,7 @@ const StorageTexture* StorageTexture::Clone(CloneContext* ctx) const {
|
|||
|
||||
Type* StorageTexture::SubtypeFor(TexelFormat format, ProgramBuilder& builder) {
|
||||
switch (format) {
|
||||
case TexelFormat::kR8Uint:
|
||||
case TexelFormat::kR16Uint:
|
||||
case TexelFormat::kRg8Uint:
|
||||
case TexelFormat::kR32Uint:
|
||||
case TexelFormat::kRg16Uint:
|
||||
case TexelFormat::kRgba8Uint:
|
||||
case TexelFormat::kRg32Uint:
|
||||
case TexelFormat::kRgba16Uint:
|
||||
|
@ -179,11 +118,7 @@ Type* StorageTexture::SubtypeFor(TexelFormat format, ProgramBuilder& builder) {
|
|||
return builder.create<U32>();
|
||||
}
|
||||
|
||||
case TexelFormat::kR8Sint:
|
||||
case TexelFormat::kR16Sint:
|
||||
case TexelFormat::kRg8Sint:
|
||||
case TexelFormat::kR32Sint:
|
||||
case TexelFormat::kRg16Sint:
|
||||
case TexelFormat::kRgba8Sint:
|
||||
case TexelFormat::kRg32Sint:
|
||||
case TexelFormat::kRgba16Sint:
|
||||
|
@ -191,20 +126,9 @@ Type* StorageTexture::SubtypeFor(TexelFormat format, ProgramBuilder& builder) {
|
|||
return builder.create<I32>();
|
||||
}
|
||||
|
||||
case TexelFormat::kR8Unorm:
|
||||
case TexelFormat::kRg8Unorm:
|
||||
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::kR16Float:
|
||||
case TexelFormat::kR32Float:
|
||||
case TexelFormat::kRg16Float:
|
||||
case TexelFormat::kRg11B10Float:
|
||||
case TexelFormat::kRg32Float:
|
||||
case TexelFormat::kRgba16Float:
|
||||
case TexelFormat::kRgba32Float: {
|
||||
|
|
|
@ -26,38 +26,19 @@ namespace ast {
|
|||
/// The texel format in the storage texture
|
||||
enum class TexelFormat {
|
||||
kNone = -1,
|
||||
kR8Unorm,
|
||||
kR8Snorm,
|
||||
kR8Uint,
|
||||
kR8Sint,
|
||||
kR16Uint,
|
||||
kR16Sint,
|
||||
kR16Float,
|
||||
kRg8Unorm,
|
||||
kRg8Snorm,
|
||||
kRg8Uint,
|
||||
kRg8Sint,
|
||||
kR32Uint,
|
||||
kR32Sint,
|
||||
kR32Float,
|
||||
kRg16Uint,
|
||||
kRg16Sint,
|
||||
kRg16Float,
|
||||
kRgba8Unorm,
|
||||
kRgba8UnormSrgb,
|
||||
kRgba8Snorm,
|
||||
kRgba8Uint,
|
||||
kRgba8Sint,
|
||||
kBgra8Unorm,
|
||||
kBgra8UnormSrgb,
|
||||
kRgb10A2Unorm,
|
||||
kRg11B10Float,
|
||||
kRg32Uint,
|
||||
kRg32Sint,
|
||||
kRg32Float,
|
||||
kRgba16Uint,
|
||||
kRgba16Sint,
|
||||
kRgba16Float,
|
||||
kR32Uint,
|
||||
kR32Sint,
|
||||
kR32Float,
|
||||
kRg32Uint,
|
||||
kRg32Sint,
|
||||
kRg32Float,
|
||||
kRgba32Uint,
|
||||
kRgba32Sint,
|
||||
kRgba32Float,
|
||||
|
|
|
@ -74,58 +74,20 @@ ResourceBinding::SampledKind BaseTypeToSampledKind(const sem::Type* base_type) {
|
|||
ResourceBinding::TexelFormat TypeTexelFormatToResourceBindingTexelFormat(
|
||||
const ast::TexelFormat& 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:
|
||||
return ResourceBinding::TexelFormat::kR32Uint;
|
||||
case ast::TexelFormat::kR32Sint:
|
||||
return ResourceBinding::TexelFormat::kR32Sint;
|
||||
case ast::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:
|
||||
return ResourceBinding::TexelFormat::kRgba8Unorm;
|
||||
case ast::TexelFormat::kRgba8UnormSrgb:
|
||||
return ResourceBinding::TexelFormat::kRgba8UnormSrgb;
|
||||
case ast::TexelFormat::kRgba8Snorm:
|
||||
return ResourceBinding::TexelFormat::kRgba8Snorm;
|
||||
case ast::TexelFormat::kRgba8Uint:
|
||||
return ResourceBinding::TexelFormat::kRgba8Uint;
|
||||
case ast::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:
|
||||
return ResourceBinding::TexelFormat::kRg32Uint;
|
||||
case ast::TexelFormat::kRg32Sint:
|
||||
|
|
|
@ -50,6 +50,26 @@ struct ResourceBinding {
|
|||
/// Enumerator of texel image formats
|
||||
enum class TexelFormat {
|
||||
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,
|
||||
kR8Snorm,
|
||||
kR8Uint,
|
||||
|
@ -61,30 +81,14 @@ struct ResourceBinding {
|
|||
kRg8Snorm,
|
||||
kRg8Uint,
|
||||
kRg8Sint,
|
||||
kR32Uint,
|
||||
kR32Sint,
|
||||
kR32Float,
|
||||
kRg16Uint,
|
||||
kRg16Sint,
|
||||
kRg16Float,
|
||||
kRgba8Unorm,
|
||||
kRgba8UnormSrgb,
|
||||
kRgba8Snorm,
|
||||
kRgba8Uint,
|
||||
kRgba8Sint,
|
||||
kBgra8Unorm,
|
||||
kBgra8UnormSrgb,
|
||||
kRgb10A2Unorm,
|
||||
kRg11B10Float,
|
||||
kRg32Uint,
|
||||
kRg32Sint,
|
||||
kRg32Float,
|
||||
kRgba16Uint,
|
||||
kRgba16Sint,
|
||||
kRgba16Float,
|
||||
kRgba32Uint,
|
||||
kRgba32Sint,
|
||||
kRgba32Float,
|
||||
};
|
||||
|
||||
/// Renamed field [DEPRECATED]
|
||||
|
|
|
@ -2528,42 +2528,23 @@ const Pointer* ParserImpl::GetTypeForHandleVar(
|
|||
|
||||
const Type* ParserImpl::GetComponentTypeForFormat(ast::TexelFormat format) {
|
||||
switch (format) {
|
||||
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 ty_.U32();
|
||||
|
||||
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 ty_.I32();
|
||||
|
||||
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:
|
||||
|
@ -2577,36 +2558,18 @@ const Type* ParserImpl::GetComponentTypeForFormat(ast::TexelFormat format) {
|
|||
|
||||
unsigned ParserImpl::GetChannelCountForFormat(ast::TexelFormat format) {
|
||||
switch (format) {
|
||||
case ast::TexelFormat::kR16Float:
|
||||
case ast::TexelFormat::kR16Sint:
|
||||
case ast::TexelFormat::kR16Uint:
|
||||
case ast::TexelFormat::kR32Float:
|
||||
case ast::TexelFormat::kR32Sint:
|
||||
case ast::TexelFormat::kR32Uint:
|
||||
case ast::TexelFormat::kR8Sint:
|
||||
case ast::TexelFormat::kR8Snorm:
|
||||
case ast::TexelFormat::kR8Uint:
|
||||
case ast::TexelFormat::kR8Unorm:
|
||||
// One channel
|
||||
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::kRg32Sint:
|
||||
case ast::TexelFormat::kRg32Uint:
|
||||
case ast::TexelFormat::kRg8Sint:
|
||||
case ast::TexelFormat::kRg8Snorm:
|
||||
case ast::TexelFormat::kRg8Uint:
|
||||
case ast::TexelFormat::kRg8Unorm:
|
||||
// Two channels
|
||||
return 2;
|
||||
|
||||
case ast::TexelFormat::kBgra8Unorm:
|
||||
case ast::TexelFormat::kBgra8UnormSrgb:
|
||||
case ast::TexelFormat::kRgb10A2Unorm:
|
||||
case ast::TexelFormat::kRgba16Float:
|
||||
case ast::TexelFormat::kRgba16Sint:
|
||||
case ast::TexelFormat::kRgba16Uint:
|
||||
|
@ -2617,7 +2580,6 @@ unsigned ParserImpl::GetChannelCountForFormat(ast::TexelFormat format) {
|
|||
case ast::TexelFormat::kRgba8Snorm:
|
||||
case ast::TexelFormat::kRgba8Uint:
|
||||
case ast::TexelFormat::kRgba8Unorm:
|
||||
case ast::TexelFormat::kRgba8UnormSrgb:
|
||||
// Four channels
|
||||
return 4;
|
||||
|
||||
|
|
|
@ -46,9 +46,9 @@ TEST(SpvParserTypeTest, SameArgumentsGivesSamePointer) {
|
|||
EXPECT_EQ(ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()),
|
||||
ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()));
|
||||
EXPECT_EQ(ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kRead),
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kRead),
|
||||
ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kRead));
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kRead));
|
||||
}
|
||||
|
||||
TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
|
||||
|
@ -83,17 +83,17 @@ TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
|
|||
EXPECT_NE(ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()),
|
||||
ty.SampledTexture(ast::TextureDimension::k2d, ty.U32()));
|
||||
EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kRead),
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kRead),
|
||||
ty.StorageTexture(ast::TextureDimension::k3d,
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kRead));
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kRead));
|
||||
EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kRead),
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kRead),
|
||||
ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::TexelFormat::kR32Sint, ast::Access::kRead));
|
||||
EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kRead),
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kRead),
|
||||
ty.StorageTexture(ast::TextureDimension::k2d,
|
||||
ast::TexelFormat::kR16Sint, ast::Access::kWrite));
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kWrite));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -745,139 +745,30 @@ Maybe<const ast::Type*> ParserImpl::depth_texture_type() {
|
|||
return Failure::kNoMatch;
|
||||
}
|
||||
|
||||
// image_storage_type
|
||||
// : R8UNORM
|
||||
// | R8SNORM
|
||||
// | R8UINT
|
||||
// | R8SINT
|
||||
// | R16UINT
|
||||
// | R16SINT
|
||||
// | R16FLOAT
|
||||
// | RG8UNORM
|
||||
// | RG8SNORM
|
||||
// | RG8UINT
|
||||
// | RG8SINT
|
||||
// | R32UINT
|
||||
// | R32SINT
|
||||
// | R32FLOAT
|
||||
// | RG16UINT
|
||||
// | RG16SINT
|
||||
// | RG16FLOAT
|
||||
// | RGBA8UNORM
|
||||
/// | RGBA8UNORM-SRGB
|
||||
// | RGBA8SNORM
|
||||
// | RGBA8UINT
|
||||
// | RGBA8SINT
|
||||
// | BGRA8UNORM
|
||||
// | BGRA8UNORM-SRGB
|
||||
// | RGB10A2UNORM
|
||||
// | RG11B10FLOAT
|
||||
// | RG32UINT
|
||||
// | RG32SINT
|
||||
// | RG32FLOAT
|
||||
// | RGBA16UINT
|
||||
// | RGBA16SINT
|
||||
// | RGBA16FLOAT
|
||||
// | RGBA32UINT
|
||||
// | RGBA32SINT
|
||||
// | RGBA32FLOAT
|
||||
// texel_format
|
||||
// : 'rgba8unorm'
|
||||
// | 'rgba8snorm'
|
||||
// | 'rgba8uint'
|
||||
// | 'rgba8sint'
|
||||
// | 'rgba16uint'
|
||||
// | 'rgba16sint'
|
||||
// | 'rgba16float'
|
||||
// | 'r32uint'
|
||||
// | 'r32sint'
|
||||
// | 'r32float'
|
||||
// | 'rg32uint'
|
||||
// | 'rg32sint'
|
||||
// | 'rg32float'
|
||||
// | 'rgba32uint'
|
||||
// | 'rgba32sint'
|
||||
// | 'rgba32float'
|
||||
Expect<ast::TexelFormat> ParserImpl::expect_texel_format(
|
||||
const std::string& use) {
|
||||
auto tok = next();
|
||||
if (tok.IsIdentifier()) {
|
||||
auto s = tok.to_str();
|
||||
if (s == "bgra8unorm") {
|
||||
return ast::TexelFormat::kBgra8Unorm;
|
||||
}
|
||||
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 == "rgba8unorm") {
|
||||
return ast::TexelFormat::kRgba8Unorm;
|
||||
}
|
||||
if (s == "rgba8snorm") {
|
||||
return ast::TexelFormat::kRgba8Snorm;
|
||||
|
@ -885,11 +776,44 @@ Expect<ast::TexelFormat> ParserImpl::expect_texel_format(
|
|||
if (s == "rgba8uint") {
|
||||
return ast::TexelFormat::kRgba8Uint;
|
||||
}
|
||||
if (s == "rgba8unorm") {
|
||||
return ast::TexelFormat::kRgba8Unorm;
|
||||
if (s == "rgba8sint") {
|
||||
return ast::TexelFormat::kRgba8Sint;
|
||||
}
|
||||
if (s == "rgba8unorm_srgb") {
|
||||
return ast::TexelFormat::kRgba8UnormSrgb;
|
||||
if (s == "rgba16uint") {
|
||||
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);
|
||||
|
|
|
@ -585,9 +585,9 @@ TEST_F(ParserImplErrorTest, GlobalDeclStorageTextureMissingLessThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclStorageTextureMissingGreaterThan) {
|
||||
EXPECT("var x : texture_storage_2d<r8uint, read;",
|
||||
"test.wgsl:1:40 error: expected '>' for storage texture type\n"
|
||||
"var x : texture_storage_2d<r8uint, read;\n"
|
||||
EXPECT("var x : texture_storage_2d<r32uint, read;",
|
||||
"test.wgsl:1:41 error: expected '>' for storage texture type\n"
|
||||
"var x : texture_storage_2d<r32uint, read;\n"
|
||||
" ^\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -27,94 +27,6 @@ TEST_F(ParserImplTest, ImageStorageType_Invalid) {
|
|||
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) {
|
||||
auto p = parser("r32uint");
|
||||
auto t = p->expect_texel_format("test");
|
||||
|
@ -139,30 +51,6 @@ TEST_F(ParserImplTest, ImageStorageType_R32Float) {
|
|||
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) {
|
||||
auto p = parser("rgba8unorm");
|
||||
auto t = p->expect_texel_format("test");
|
||||
|
@ -171,14 +59,6 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Unorm) {
|
|||
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) {
|
||||
auto p = parser("rgba8snorm");
|
||||
auto t = p->expect_texel_format("test");
|
||||
|
@ -203,38 +83,6 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Sint) {
|
|||
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) {
|
||||
auto p = parser("rg32uint");
|
||||
auto t = p->expect_texel_format("test");
|
||||
|
|
|
@ -184,8 +184,8 @@ TEST_F(ParserImplTest,
|
|||
EXPECT_EQ(p->error(), "1:28: expected '>' for multisampled texture type");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) {
|
||||
auto p = parser("texture_storage_1d<r8unorm, read>");
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dRg32Float) {
|
||||
auto p = parser("texture_storage_1d<rg32float, read>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
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::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::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) {
|
||||
auto p = parser("texture_storage_2d<r16float, write>");
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR32Uint) {
|
||||
auto p = parser("texture_storage_2d<r32uint, write>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
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::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::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) {
|
||||
|
@ -226,7 +226,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {
|
|||
}
|
||||
|
||||
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();
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -253,7 +253,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingLessThan) {
|
|||
}
|
||||
|
||||
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();
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
|
|
@ -1316,7 +1316,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
|
|||
Global(Sym(), ty.external_texture());
|
||||
Global(Sym(), ty.multisampled_texture(ast::TextureDimension::k2d, T));
|
||||
Global(Sym(), ty.storage_texture(ast::TextureDimension::k2d,
|
||||
ast::TexelFormat::kR16Float,
|
||||
ast::TexelFormat::kR32Float,
|
||||
ast::Access::kRead)); //
|
||||
Global(Sym(), ty.sampler(ast::SamplerKind::kSampler));
|
||||
Func(Sym(), {}, ty.void_(), {});
|
||||
|
|
|
@ -222,7 +222,7 @@ inline std::ostream& operator<<(std::ostream& out, Texture data) {
|
|||
struct TextureTestParams {
|
||||
ast::TextureDimension dim;
|
||||
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) {
|
||||
out << data.dim << "_" << data.type;
|
||||
|
|
|
@ -861,30 +861,12 @@ struct FormatParams {
|
|||
};
|
||||
|
||||
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::kR32Sint, 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::kRg32Sint, 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::kRgba16Sint, true},
|
||||
FormatParams{ast::TexelFormat::kRgba16Uint, true},
|
||||
|
@ -894,8 +876,7 @@ static constexpr FormatParams format_cases[] = {
|
|||
FormatParams{ast::TexelFormat::kRgba8Sint, true},
|
||||
FormatParams{ast::TexelFormat::kRgba8Snorm, true},
|
||||
FormatParams{ast::TexelFormat::kRgba8Uint, true},
|
||||
FormatParams{ast::TexelFormat::kRgba8Unorm, true},
|
||||
FormatParams{ast::TexelFormat::kRgba8UnormSrgb, false}};
|
||||
FormatParams{ast::TexelFormat::kRgba8Unorm, true}};
|
||||
|
||||
using StorageTextureFormatTest = ResolverTestWithParam<FormatParams>;
|
||||
TEST_P(StorageTextureFormatTest, All) {
|
||||
|
|
|
@ -48,11 +48,7 @@ std::string StorageTexture::FriendlyName(const SymbolTable&) const {
|
|||
sem::Type* StorageTexture::SubtypeFor(ast::TexelFormat format,
|
||||
sem::Manager& type_mgr) {
|
||||
switch (format) {
|
||||
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:
|
||||
|
@ -60,11 +56,7 @@ sem::Type* StorageTexture::SubtypeFor(ast::TexelFormat format,
|
|||
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::kRg16Sint:
|
||||
case ast::TexelFormat::kRgba8Sint:
|
||||
case ast::TexelFormat::kRg32Sint:
|
||||
case ast::TexelFormat::kRgba16Sint:
|
||||
|
@ -72,20 +64,9 @@ sem::Type* StorageTexture::SubtypeFor(ast::TexelFormat format,
|
|||
return type_mgr.Get<sem::I32>();
|
||||
}
|
||||
|
||||
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: {
|
||||
|
|
|
@ -1334,19 +1334,19 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
"ptrdiff_t",
|
||||
"r16snorm",
|
||||
"r16unorm",
|
||||
// "r8unorm", // Also used in WGSL
|
||||
"r8unorm",
|
||||
"reference",
|
||||
"rg11b10f",
|
||||
"rg16snorm",
|
||||
"rg16unorm",
|
||||
// "rg8snorm", // Also used in WGSL
|
||||
// "rg8unorm", // Also used in WGSL
|
||||
"rg8snorm",
|
||||
"rg8unorm",
|
||||
"rgb10a2",
|
||||
"rgb9e5",
|
||||
"rgba16snorm",
|
||||
"rgba16unorm",
|
||||
// "rgba8snorm", // Also used in WGSL
|
||||
// "rgba8unorm", // Also used in WGSL
|
||||
"rgba8snorm",
|
||||
"rgba8unorm",
|
||||
// "sampler", // Also used in WGSL
|
||||
"short2",
|
||||
"short3",
|
||||
|
|
|
@ -4304,74 +4304,20 @@ void Builder::AddInterpolationDecorations(uint32_t id,
|
|||
SpvImageFormat Builder::convert_texel_format_to_spv(
|
||||
const ast::TexelFormat 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:
|
||||
return SpvImageFormatR32ui;
|
||||
case ast::TexelFormat::kR32Sint:
|
||||
return SpvImageFormatR32i;
|
||||
case ast::TexelFormat::kR32Float:
|
||||
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:
|
||||
return SpvImageFormatRgba8;
|
||||
case ast::TexelFormat::kRgba8UnormSrgb:
|
||||
return SpvImageFormatUnknown;
|
||||
case ast::TexelFormat::kRgba8Snorm:
|
||||
return SpvImageFormatRgba8Snorm;
|
||||
case ast::TexelFormat::kRgba8Uint:
|
||||
return SpvImageFormatRgba8ui;
|
||||
case ast::TexelFormat::kRgba8Sint:
|
||||
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:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg32ui;
|
||||
|
|
|
@ -51,6 +51,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
BuilderTest,
|
||||
ImageFormatConversionTest,
|
||||
testing::Values(
|
||||
/* WGSL unsupported formats
|
||||
TestData{ast::TexelFormat::kR8Unorm, SpvImageFormatR8, true},
|
||||
TestData{ast::TexelFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
|
||||
TestData{ast::TexelFormat::kR8Uint, SpvImageFormatR8ui, true},
|
||||
|
@ -62,22 +63,22 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
TestData{ast::TexelFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true},
|
||||
TestData{ast::TexelFormat::kRg8Uint, SpvImageFormatRg8ui, 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::kRg16Sint, SpvImageFormatRg16i, true},
|
||||
TestData{ast::TexelFormat::kRg16Float, SpvImageFormatRg16f, true},
|
||||
TestData{ast::TexelFormat::kRgba8Unorm, SpvImageFormatRgba8},
|
||||
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::kBgra8UnormSrgb, SpvImageFormatUnknown},
|
||||
TestData{ast::TexelFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true},
|
||||
TestData{ast::TexelFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f,
|
||||
true},
|
||||
TestData{ast::TexelFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f, 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::kRg32Sint, SpvImageFormatRg32i, true},
|
||||
TestData{ast::TexelFormat::kRg32Float, SpvImageFormatRg32f, true},
|
||||
|
|
|
@ -489,32 +489,13 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
WgslGeneratorImplTest,
|
||||
WgslGenerator_ImageFormatTest,
|
||||
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::kR32Sint, "r32sint"},
|
||||
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::kRgba8UnormSrgb, "rgba8unorm_srgb"},
|
||||
ImageFormatData{ast::TexelFormat::kRgba8Snorm, "rgba8snorm"},
|
||||
ImageFormatData{ast::TexelFormat::kRgba8Uint, "rgba8uint"},
|
||||
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::kRg32Sint, "rg32sint"},
|
||||
ImageFormatData{ast::TexelFormat::kRg32Float, "rg32float"},
|
||||
|
|
Loading…
Reference in New Issue