From 7b615af00c67cf7260ef975ff15233010f1d2a83 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Thu, 21 Jan 2021 14:18:19 +0000 Subject: [PATCH] TextureFormatUtils: Remove unused functions GetColorTextureComponent[GLSL,WGSL]TypePrefix() are no longer used. And also move the two remaining WGSL functions together, and rename for consistency's sake. Change-Id: If70f195b7185fca9337ec5c12c74efa25ae6ce4c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37901 Commit-Queue: Ben Clayton Reviewed-by: Corentin Wallez Reviewed-by: Austin Eng --- src/tests/end2end/StorageTextureTests.cpp | 4 +- src/tests/end2end/TextureFormatTests.cpp | 2 +- src/utils/TextureFormatUtils.cpp | 251 +++------------------- src/utils/TextureFormatUtils.h | 6 +- 4 files changed, 35 insertions(+), 228 deletions(-) diff --git a/src/tests/end2end/StorageTextureTests.cpp b/src/tests/end2end/StorageTextureTests.cpp index b0b09735a6..87f2ae0680 100644 --- a/src/tests/end2end/StorageTextureTests.cpp +++ b/src/tests/end2end/StorageTextureTests.cpp @@ -286,7 +286,7 @@ fn IsEqualTo(pixel : vec4, expected : vec4) -> bool { } std::string CommonReadOnlyTestCode(wgpu::TextureFormat format, bool is2DArray = false) { - std::string componentFmt = utils::GetColorTextureComponentWGSLType(format); + std::string componentFmt = utils::GetWGSLColorTextureComponentType(format); auto texelType = "vec4<" + componentFmt + ">"; auto* layerCount = is2DArray ? "textureNumLayers(storageImage0)" : "1"; auto* textureLoad = is2DArray ? "textureLoad(storageImage0, vec2(x, y), i32(layer))" @@ -320,7 +320,7 @@ fn IsEqualTo(pixel : vec4, expected : vec4) -> bool { std::string CommonWriteOnlyTestCode(const char* stage, wgpu::TextureFormat format, bool is2DArray = false) { - std::string componentFmt = utils::GetColorTextureComponentWGSLType(format); + std::string componentFmt = utils::GetWGSLColorTextureComponentType(format); auto texelType = "vec4<" + componentFmt + ">"; auto* layerCount = is2DArray ? "textureNumLayers(storageImage0)" : "1"; auto* textureStore = is2DArray diff --git a/src/tests/end2end/TextureFormatTests.cpp b/src/tests/end2end/TextureFormatTests.cpp index 4dacc82582..0675cc22a3 100644 --- a/src/tests/end2end/TextureFormatTests.cpp +++ b/src/tests/end2end/TextureFormatTests.cpp @@ -160,7 +160,7 @@ class TextureFormatTest : public DawnTest { })"); // Compute the WGSL type of the texture's data. - const char* type = utils::GetColorTextureComponentWGSLType(sampleFormatInfo.format); + const char* type = utils::GetWGSLColorTextureComponentType(sampleFormatInfo.format); std::ostringstream fsSource; fsSource << "[[group(0), binding(0)]] var myTexture : texture_2d<" << type diff --git a/src/utils/TextureFormatUtils.cpp b/src/utils/TextureFormatUtils.cpp index 098a42fed8..73a22ab805 100644 --- a/src/utils/TextureFormatUtils.cpp +++ b/src/utils/TextureFormatUtils.cpp @@ -15,153 +15,6 @@ #include "TextureFormatUtils.h" namespace utils { - const char* GetColorTextureComponentGLSLTypePrefix(wgpu::TextureFormat textureFormat) { - switch (textureFormat) { - case wgpu::TextureFormat::R8Unorm: - case wgpu::TextureFormat::R8Snorm: - case wgpu::TextureFormat::R16Float: - case wgpu::TextureFormat::RG8Unorm: - case wgpu::TextureFormat::RG8Snorm: - case wgpu::TextureFormat::R32Float: - case wgpu::TextureFormat::RG16Float: - case wgpu::TextureFormat::RGBA8Unorm: - case wgpu::TextureFormat::RGBA8Snorm: - case wgpu::TextureFormat::RGB10A2Unorm: - case wgpu::TextureFormat::RG11B10Ufloat: - case wgpu::TextureFormat::RGB9E5Ufloat: - case wgpu::TextureFormat::RG32Float: - case wgpu::TextureFormat::RGBA16Float: - case wgpu::TextureFormat::RGBA32Float: - case wgpu::TextureFormat::BGRA8Unorm: - case wgpu::TextureFormat::BGRA8UnormSrgb: - case wgpu::TextureFormat::RGBA8UnormSrgb: - return ""; - - case wgpu::TextureFormat::R8Uint: - case wgpu::TextureFormat::R16Uint: - case wgpu::TextureFormat::RG8Uint: - case wgpu::TextureFormat::R32Uint: - case wgpu::TextureFormat::RG16Uint: - case wgpu::TextureFormat::RGBA8Uint: - case wgpu::TextureFormat::RG32Uint: - case wgpu::TextureFormat::RGBA16Uint: - case wgpu::TextureFormat::RGBA32Uint: - return "u"; - - case wgpu::TextureFormat::R8Sint: - case wgpu::TextureFormat::R16Sint: - case wgpu::TextureFormat::RG8Sint: - case wgpu::TextureFormat::R32Sint: - case wgpu::TextureFormat::RG16Sint: - case wgpu::TextureFormat::RGBA8Sint: - case wgpu::TextureFormat::RG32Sint: - case wgpu::TextureFormat::RGBA16Sint: - case wgpu::TextureFormat::RGBA32Sint: - return "i"; - - default: - UNREACHABLE(); - } - } - - const char* GetColorTextureComponentWGSLTypePrefix(wgpu::TextureFormat textureFormat) { - switch (textureFormat) { - case wgpu::TextureFormat::R8Unorm: - case wgpu::TextureFormat::R8Snorm: - case wgpu::TextureFormat::R16Float: - case wgpu::TextureFormat::RG8Unorm: - case wgpu::TextureFormat::RG8Snorm: - case wgpu::TextureFormat::R32Float: - case wgpu::TextureFormat::RG16Float: - case wgpu::TextureFormat::RGBA8Unorm: - case wgpu::TextureFormat::RGBA8Snorm: - case wgpu::TextureFormat::RGB10A2Unorm: - case wgpu::TextureFormat::RG11B10Ufloat: - case wgpu::TextureFormat::RGB9E5Ufloat: - case wgpu::TextureFormat::RG32Float: - case wgpu::TextureFormat::RGBA16Float: - case wgpu::TextureFormat::RGBA32Float: - case wgpu::TextureFormat::BGRA8Unorm: - case wgpu::TextureFormat::BGRA8UnormSrgb: - case wgpu::TextureFormat::RGBA8UnormSrgb: - return "f"; - - case wgpu::TextureFormat::R8Uint: - case wgpu::TextureFormat::R16Uint: - case wgpu::TextureFormat::RG8Uint: - case wgpu::TextureFormat::R32Uint: - case wgpu::TextureFormat::RG16Uint: - case wgpu::TextureFormat::RGBA8Uint: - case wgpu::TextureFormat::RG32Uint: - case wgpu::TextureFormat::RGBA16Uint: - case wgpu::TextureFormat::RGBA32Uint: - return "u"; - - case wgpu::TextureFormat::R8Sint: - case wgpu::TextureFormat::R16Sint: - case wgpu::TextureFormat::RG8Sint: - case wgpu::TextureFormat::R32Sint: - case wgpu::TextureFormat::RG16Sint: - case wgpu::TextureFormat::RGBA8Sint: - case wgpu::TextureFormat::RG32Sint: - case wgpu::TextureFormat::RGBA16Sint: - case wgpu::TextureFormat::RGBA32Sint: - return "i"; - - default: - UNREACHABLE(); - } - } - - const char* GetColorTextureComponentWGSLType(wgpu::TextureFormat textureFormat) { - switch (textureFormat) { - case wgpu::TextureFormat::R8Unorm: - case wgpu::TextureFormat::R8Snorm: - case wgpu::TextureFormat::R16Float: - case wgpu::TextureFormat::RG8Unorm: - case wgpu::TextureFormat::RG8Snorm: - case wgpu::TextureFormat::R32Float: - case wgpu::TextureFormat::RG16Float: - case wgpu::TextureFormat::RGBA8Unorm: - case wgpu::TextureFormat::RGBA8Snorm: - case wgpu::TextureFormat::RGB10A2Unorm: - case wgpu::TextureFormat::RG11B10Ufloat: - case wgpu::TextureFormat::RGB9E5Ufloat: - case wgpu::TextureFormat::RG32Float: - case wgpu::TextureFormat::RGBA16Float: - case wgpu::TextureFormat::RGBA32Float: - case wgpu::TextureFormat::BGRA8Unorm: - case wgpu::TextureFormat::BGRA8UnormSrgb: - case wgpu::TextureFormat::RGBA8UnormSrgb: - return "f32"; - - case wgpu::TextureFormat::R8Uint: - case wgpu::TextureFormat::R16Uint: - case wgpu::TextureFormat::RG8Uint: - case wgpu::TextureFormat::R32Uint: - case wgpu::TextureFormat::RG16Uint: - case wgpu::TextureFormat::RGBA8Uint: - case wgpu::TextureFormat::RG32Uint: - case wgpu::TextureFormat::RGBA16Uint: - case wgpu::TextureFormat::RGBA32Uint: - return "u32"; - - case wgpu::TextureFormat::R8Sint: - case wgpu::TextureFormat::R16Sint: - case wgpu::TextureFormat::RG8Sint: - case wgpu::TextureFormat::R32Sint: - case wgpu::TextureFormat::RG16Sint: - case wgpu::TextureFormat::RGBA8Sint: - case wgpu::TextureFormat::RG32Sint: - case wgpu::TextureFormat::RGBA16Sint: - case wgpu::TextureFormat::RGBA32Sint: - return "i32"; - - default: - UNREACHABLE(); - } - } - bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format) { switch (format) { case wgpu::TextureFormat::R32Uint: @@ -389,95 +242,51 @@ namespace utils { } } - const char* GetGLSLImageFormatQualifier(wgpu::TextureFormat textureFormat) { + const char* GetWGSLColorTextureComponentType(wgpu::TextureFormat textureFormat) { switch (textureFormat) { case wgpu::TextureFormat::R8Unorm: - return "r8"; case wgpu::TextureFormat::R8Snorm: - return "r8_snorm"; - case wgpu::TextureFormat::R8Uint: - return "r8ui"; - case wgpu::TextureFormat::R8Sint: - return "r8i"; - case wgpu::TextureFormat::R16Uint: - return "r16ui"; - case wgpu::TextureFormat::R16Sint: - return "r16i"; case wgpu::TextureFormat::R16Float: - return "r16f"; case wgpu::TextureFormat::RG8Unorm: - return "rg8"; case wgpu::TextureFormat::RG8Snorm: - return "rg8_snorm"; - case wgpu::TextureFormat::RG8Uint: - return "rg8ui"; - case wgpu::TextureFormat::RG8Sint: - return "rg8i"; case wgpu::TextureFormat::R32Float: - return "r32f"; - case wgpu::TextureFormat::R32Uint: - return "r32ui"; - case wgpu::TextureFormat::R32Sint: - return "r32i"; - case wgpu::TextureFormat::RG16Uint: - return "rg16ui"; - case wgpu::TextureFormat::RG16Sint: - return "rg16i"; case wgpu::TextureFormat::RG16Float: - return "rg16f"; case wgpu::TextureFormat::RGBA8Unorm: - return "rgba8"; case wgpu::TextureFormat::RGBA8Snorm: - return "rgba8_snorm"; - case wgpu::TextureFormat::RGBA8Uint: - return "rgba8ui"; - case wgpu::TextureFormat::RGBA8Sint: - return "rgba8i"; case wgpu::TextureFormat::RGB10A2Unorm: - return "rgb10_a2"; case wgpu::TextureFormat::RG11B10Ufloat: - return "r11f_g11f_b10f"; - case wgpu::TextureFormat::RG32Float: - return "rg32f"; - case wgpu::TextureFormat::RG32Uint: - return "rg32ui"; - case wgpu::TextureFormat::RG32Sint: - return "rg32i"; - case wgpu::TextureFormat::RGBA16Uint: - return "rgba16ui"; - case wgpu::TextureFormat::RGBA16Sint: - return "rgba16i"; - case wgpu::TextureFormat::RGBA16Float: - return "rgba16f"; - case wgpu::TextureFormat::RGBA32Float: - return "rgba32f"; - case wgpu::TextureFormat::RGBA32Uint: - return "rgba32ui"; - case wgpu::TextureFormat::RGBA32Sint: - return "rgba32i"; - case wgpu::TextureFormat::RGB9E5Ufloat: - case wgpu::TextureFormat::RGBA8UnormSrgb: + case wgpu::TextureFormat::RG32Float: + case wgpu::TextureFormat::RGBA16Float: + case wgpu::TextureFormat::RGBA32Float: case wgpu::TextureFormat::BGRA8Unorm: case wgpu::TextureFormat::BGRA8UnormSrgb: - case wgpu::TextureFormat::BC1RGBAUnorm: - case wgpu::TextureFormat::BC1RGBAUnormSrgb: - case wgpu::TextureFormat::BC4RUnorm: - case wgpu::TextureFormat::BC4RSnorm: - case wgpu::TextureFormat::BC2RGBAUnorm: - case wgpu::TextureFormat::BC2RGBAUnormSrgb: - case wgpu::TextureFormat::BC3RGBAUnorm: - case wgpu::TextureFormat::BC3RGBAUnormSrgb: - case wgpu::TextureFormat::BC5RGUnorm: - case wgpu::TextureFormat::BC5RGSnorm: - case wgpu::TextureFormat::BC6HRGBUfloat: - case wgpu::TextureFormat::BC6HRGBFloat: - case wgpu::TextureFormat::BC7RGBAUnorm: - case wgpu::TextureFormat::BC7RGBAUnormSrgb: - case wgpu::TextureFormat::Depth32Float: - case wgpu::TextureFormat::Depth24Plus: - case wgpu::TextureFormat::Depth24PlusStencil8: - case wgpu::TextureFormat::Undefined: + case wgpu::TextureFormat::RGBA8UnormSrgb: + return "f32"; + + case wgpu::TextureFormat::R8Uint: + case wgpu::TextureFormat::R16Uint: + case wgpu::TextureFormat::RG8Uint: + case wgpu::TextureFormat::R32Uint: + case wgpu::TextureFormat::RG16Uint: + case wgpu::TextureFormat::RGBA8Uint: + case wgpu::TextureFormat::RG32Uint: + case wgpu::TextureFormat::RGBA16Uint: + case wgpu::TextureFormat::RGBA32Uint: + return "u32"; + + case wgpu::TextureFormat::R8Sint: + case wgpu::TextureFormat::R16Sint: + case wgpu::TextureFormat::RG8Sint: + case wgpu::TextureFormat::R32Sint: + case wgpu::TextureFormat::RG16Sint: + case wgpu::TextureFormat::RGBA8Sint: + case wgpu::TextureFormat::RG32Sint: + case wgpu::TextureFormat::RGBA16Sint: + case wgpu::TextureFormat::RGBA32Sint: + return "i32"; + + default: UNREACHABLE(); } } diff --git a/src/utils/TextureFormatUtils.h b/src/utils/TextureFormatUtils.h index 4fddacef9f..3c437c7005 100644 --- a/src/utils/TextureFormatUtils.h +++ b/src/utils/TextureFormatUtils.h @@ -87,15 +87,13 @@ namespace utils { wgpu::TextureFormat::BC6HRGBUfloat, wgpu::TextureFormat::BC6HRGBFloat, wgpu::TextureFormat::BC7RGBAUnorm, wgpu::TextureFormat::BC7RGBAUnormSrgb}; - const char* GetColorTextureComponentGLSLTypePrefix(wgpu::TextureFormat textureFormat); - const char* GetColorTextureComponentWGSLTypePrefix(wgpu::TextureFormat textureFormat); - const char* GetColorTextureComponentWGSLType(wgpu::TextureFormat textureFormat); bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format); uint32_t GetTexelBlockSizeInBytes(wgpu::TextureFormat textureFormat); uint32_t GetTextureFormatBlockWidth(wgpu::TextureFormat textureFormat); uint32_t GetTextureFormatBlockHeight(wgpu::TextureFormat textureFormat); - const char* GetGLSLImageFormatQualifier(wgpu::TextureFormat textureFormat); + + const char* GetWGSLColorTextureComponentType(wgpu::TextureFormat textureFormat); const char* GetWGSLImageFormatQualifier(wgpu::TextureFormat textureFormat); } // namespace utils