From ccf805046ae3762de0ef44432ba4ce5bcd56ec2a Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Mon, 5 Aug 2019 03:06:22 +0000 Subject: [PATCH] Make Snorm formats non-renderable They aren't guaranteed renderable in Vulkan nor core OpenGL 4.5 without extensions. They happened to work on a lot of our CQ builders but failed on Intel OpenGL Linux which helped understand this was an issue. BUG=dawn:128 Change-Id: I83c4f8116c1125c3bac2f1dd6197976c9063e129 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9682 Commit-Queue: Austin Eng Reviewed-by: Jiawei Shao Reviewed-by: Austin Eng --- src/dawn_native/Format.cpp | 12 +++++----- src/tests/end2end/TextureFormatTests.cpp | 24 +------------------ .../validation/TextureValidationTests.cpp | 15 +++++++++--- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/src/dawn_native/Format.cpp b/src/dawn_native/Format.cpp index 44ae1d85d2..0f904bd1f0 100644 --- a/src/dawn_native/Format.cpp +++ b/src/dawn_native/Format.cpp @@ -112,18 +112,18 @@ namespace dawn_native { // 1 byte color formats AddColorFormat(dawn::TextureFormat::R8Unorm, true, 1); - AddColorFormat(dawn::TextureFormat::R8Snorm, true, 1); + AddColorFormat(dawn::TextureFormat::R8Snorm, false, 1); AddColorFormat(dawn::TextureFormat::R8Uint, true, 1); AddColorFormat(dawn::TextureFormat::R8Sint, true, 1); // 2 bytes color formats AddColorFormat(dawn::TextureFormat::R16Unorm, true, 2); - AddColorFormat(dawn::TextureFormat::R16Snorm, true, 2); + AddColorFormat(dawn::TextureFormat::R16Snorm, false, 2); AddColorFormat(dawn::TextureFormat::R16Uint, true, 2); AddColorFormat(dawn::TextureFormat::R16Sint, true, 2); AddColorFormat(dawn::TextureFormat::R16Float, true, 2); AddColorFormat(dawn::TextureFormat::RG8Unorm, true, 2); - AddColorFormat(dawn::TextureFormat::RG8Snorm, true, 2); + AddColorFormat(dawn::TextureFormat::RG8Snorm, false, 2); AddColorFormat(dawn::TextureFormat::RG8Uint, true, 2); AddColorFormat(dawn::TextureFormat::RG8Sint, true, 2); @@ -132,13 +132,13 @@ namespace dawn_native { AddColorFormat(dawn::TextureFormat::R32Sint, true, 4); AddColorFormat(dawn::TextureFormat::R32Float, true, 4); AddColorFormat(dawn::TextureFormat::RG16Unorm, true, 4); - AddColorFormat(dawn::TextureFormat::RG16Snorm, true, 4); + AddColorFormat(dawn::TextureFormat::RG16Snorm, false, 4); AddColorFormat(dawn::TextureFormat::RG16Uint, true, 4); AddColorFormat(dawn::TextureFormat::RG16Sint, true, 4); AddColorFormat(dawn::TextureFormat::RG16Float, true, 4); AddColorFormat(dawn::TextureFormat::RGBA8Unorm, true, 4); AddColorFormat(dawn::TextureFormat::RGBA8UnormSrgb, true, 4); - AddColorFormat(dawn::TextureFormat::RGBA8Snorm, true, 4); + AddColorFormat(dawn::TextureFormat::RGBA8Snorm, false, 4); AddColorFormat(dawn::TextureFormat::RGBA8Uint, true, 4); AddColorFormat(dawn::TextureFormat::RGBA8Sint, true, 4); AddColorFormat(dawn::TextureFormat::BGRA8Unorm, true, 4); @@ -152,7 +152,7 @@ namespace dawn_native { AddColorFormat(dawn::TextureFormat::RG32Sint, true, 8); AddColorFormat(dawn::TextureFormat::RG32Float, true, 8); AddColorFormat(dawn::TextureFormat::RGBA16Unorm, true, 8); - AddColorFormat(dawn::TextureFormat::RGBA16Snorm, true, 8); + AddColorFormat(dawn::TextureFormat::RGBA16Snorm, false, 8); AddColorFormat(dawn::TextureFormat::RGBA16Uint, true, 8); AddColorFormat(dawn::TextureFormat::RGBA16Sint, true, 8); AddColorFormat(dawn::TextureFormat::RGBA16Float, true, 8); diff --git a/src/tests/end2end/TextureFormatTests.cpp b/src/tests/end2end/TextureFormatTests.cpp index 0abc0a3098..fb69740e71 100644 --- a/src/tests/end2end/TextureFormatTests.cpp +++ b/src/tests/end2end/TextureFormatTests.cpp @@ -394,11 +394,7 @@ class TextureFormatTest : public DawnTest { std::vector uncompressedData = {0.0f, 1.0f / maxValue, 1.0f, -1.0f}; DoFloatFormatSamplingTest(formatInfo, textureData, uncompressedData, 0.0001f / maxValue); - - // It is not possible to render minValue because -1.0f is the minimum and corresponds to - // -maxValue (minValue is - maxValue -1) - textureData[3] = -maxValue; - DoFormatRenderingTest(formatInfo, uncompressedData, textureData); + // Snorm formats aren't renderable because they are not guaranteed renderable in Vulkan } template @@ -507,49 +503,31 @@ TEST_P(TextureFormatTest, BGRA8Unorm) { // Test the R8Snorm format TEST_P(TextureFormatTest, R8Snorm) { - // TODO(cwallez@chromium.org): This fails on the Mesa Intel GL driver, understand why. - DAWN_SKIP_TEST_IF(IsOpenGL() && IsLinux() && IsIntel()); - DoSnormTest({dawn::TextureFormat::R8Snorm, 1, Float, 1}); } // Test the RG8Snorm format TEST_P(TextureFormatTest, RG8Snorm) { - // TODO(cwallez@chromium.org): This fails on the Mesa Intel GL driver, understand why. - DAWN_SKIP_TEST_IF(IsOpenGL() && IsLinux() && IsIntel()); - DoSnormTest({dawn::TextureFormat::RG8Snorm, 2, Float, 2}); } // Test the RGBA8Snorm format TEST_P(TextureFormatTest, RGBA8Snorm) { - // TODO(cwallez@chromium.org): This fails on the Mesa Intel GL driver, understand why. - DAWN_SKIP_TEST_IF(IsOpenGL() && IsLinux() && IsIntel()); - DoSnormTest({dawn::TextureFormat::RGBA8Snorm, 4, Float, 4}); } // Test the R16Snorm format TEST_P(TextureFormatTest, R16Snorm) { - // TODO(cwallez@chromium.org): This fails on the Mesa Intel GL driver, understand why. - DAWN_SKIP_TEST_IF(IsOpenGL() && IsLinux() && IsIntel()); - DoSnormTest({dawn::TextureFormat::R16Snorm, 2, Float, 1}); } // Test the RG16Snorm format TEST_P(TextureFormatTest, RG16Snorm) { - // TODO(cwallez@chromium.org): This fails on the Mesa Intel GL driver, understand why. - DAWN_SKIP_TEST_IF(IsOpenGL() && IsLinux() && IsIntel()); - DoSnormTest({dawn::TextureFormat::RG16Snorm, 4, Float, 2}); } // Test the RGBA16Snorm format TEST_P(TextureFormatTest, RGBA16Snorm) { - // TODO(cwallez@chromium.org): This fails on the Mesa Intel GL driver, understand why. - DAWN_SKIP_TEST_IF(IsOpenGL() && IsLinux() && IsIntel()); - DoSnormTest({dawn::TextureFormat::RGBA16Snorm, 8, Float, 4}); } diff --git a/src/tests/unittests/validation/TextureValidationTests.cpp b/src/tests/unittests/validation/TextureValidationTests.cpp index 75874f8c5b..af783ba024 100644 --- a/src/tests/unittests/validation/TextureValidationTests.cpp +++ b/src/tests/unittests/validation/TextureValidationTests.cpp @@ -245,9 +245,18 @@ TEST_F(TextureValidationTest, NonRenderableAndOutputAttachment) { descriptor.format = dawn::TextureFormat::RGBA8Unorm; device.CreateTexture(&descriptor); - // Fails because RG11B10Float is non-renderable - descriptor.format = dawn::TextureFormat::RG11B10Float; - ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); + dawn::TextureFormat nonRenderableFormats[] = { + dawn::TextureFormat::RG11B10Float, dawn::TextureFormat::R8Snorm, + dawn::TextureFormat::RG8Snorm, dawn::TextureFormat::RGBA8Snorm, + dawn::TextureFormat::R16Snorm, dawn::TextureFormat::RG16Snorm, + dawn::TextureFormat::RGBA16Snorm, + }; + + for (dawn::TextureFormat format : nonRenderableFormats) { + // Fails because `format` is non-renderable + descriptor.format = format; + ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); + } } // TODO(jiawei.shao@intel.com): add tests to verify we cannot create 1D or 3D textures with