Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5cbf54d

Browse files
Mohan MaiyaCommit Bot
authored andcommitted
Vulkan: Fix exposure requirements for EXT_texture_format_sRGB_override
Previously we were not checking for the correct format support to expose this extension. This change fixes that, and disables the extension if we do not support the formats we need for our implementation to function. This also adds an end2end test to check each possible format that can be used with this extension. Update GLES major version to 3 for TextureSampling perf benchmark Bug: angleproject:4561 Change-Id: Ic81bb28f02f9f36e1bc83a8eea376169de9e7735 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2359482 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
1 parent 1c53df7 commit 5cbf54d

File tree

3 files changed

+81
-7
lines changed

3 files changed

+81
-7
lines changed

src/libANGLE/Context.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3161,6 +3161,7 @@ Extensions Context::generateSupportedExtensions() const
31613161
supportedExtensions.drawBuffersIndexedEXT = false;
31623162
supportedExtensions.drawBuffersIndexedOES = false;
31633163
supportedExtensions.eglImageArray = false;
3164+
supportedExtensions.textureSRGBOverride = false;
31643165

31653166
// Requires glCompressedTexImage3D
31663167
supportedExtensions.textureCompressionASTCOES = false;

src/libANGLE/renderer/vulkan/vk_caps_utils.cpp

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,77 @@ bool GetTextureSRGBDecodeSupport(const RendererVk *rendererVk)
8383

8484
return true;
8585
}
86+
87+
bool GetTextureSRGBOverrideSupport(const RendererVk *rendererVk,
88+
const gl::Extensions &supportedExtensions)
89+
{
90+
static constexpr bool kNonLinearColorspace = false;
91+
92+
// If the given linear format is supported, we also need to support its corresponding nonlinear
93+
// format. If the given linear format is NOT supported, we don't care about its corresponding
94+
// nonlinear format.
95+
std::vector<GLenum> optionalLinearFormats = {GL_RGB8,
96+
GL_RGBA8,
97+
GL_COMPRESSED_RGB8_ETC2,
98+
GL_COMPRESSED_RGBA8_ETC2_EAC,
99+
GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
100+
GL_COMPRESSED_RGBA_ASTC_4x4,
101+
GL_COMPRESSED_RGBA_ASTC_5x4,
102+
GL_COMPRESSED_RGBA_ASTC_5x5,
103+
GL_COMPRESSED_RGBA_ASTC_6x5,
104+
GL_COMPRESSED_RGBA_ASTC_6x6,
105+
GL_COMPRESSED_RGBA_ASTC_8x5,
106+
GL_COMPRESSED_RGBA_ASTC_8x6,
107+
GL_COMPRESSED_RGBA_ASTC_8x8,
108+
GL_COMPRESSED_RGBA_ASTC_10x5,
109+
GL_COMPRESSED_RGBA_ASTC_10x6,
110+
GL_COMPRESSED_RGBA_ASTC_10x8,
111+
GL_COMPRESSED_RGBA_ASTC_10x10,
112+
GL_COMPRESSED_RGBA_ASTC_12x10,
113+
GL_COMPRESSED_RGBA_ASTC_12x12};
114+
std::vector<GLenum> optionalS3TCLinearFormats = {
115+
GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
116+
GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT};
117+
std::vector<GLenum> optionalR8LinearFormats = {GL_R8};
118+
std::vector<GLenum> optionalBPTCLinearFormats = {GL_COMPRESSED_RGBA_BPTC_UNORM_EXT};
119+
120+
if (!vk::FormatReinterpretationSupported(optionalLinearFormats, rendererVk,
121+
kNonLinearColorspace))
122+
{
123+
return false;
124+
}
125+
126+
if (supportedExtensions.textureCompressionS3TCsRGB == true)
127+
{
128+
if (!vk::FormatReinterpretationSupported(optionalS3TCLinearFormats, rendererVk,
129+
kNonLinearColorspace))
130+
{
131+
return false;
132+
}
133+
}
134+
135+
if (supportedExtensions.sRGBR8EXT == true)
136+
{
137+
if (!vk::FormatReinterpretationSupported(optionalR8LinearFormats, rendererVk,
138+
kNonLinearColorspace))
139+
{
140+
return false;
141+
}
142+
}
143+
144+
// TODO: http://anglebug.com/4932 check EXT_texture_sRGB_RG8
145+
146+
if (supportedExtensions.textureCompressionBPTC == true)
147+
{
148+
if (!vk::FormatReinterpretationSupported(optionalBPTCLinearFormats, rendererVk,
149+
kNonLinearColorspace))
150+
{
151+
return false;
152+
}
153+
}
154+
155+
return true;
156+
}
86157
} // namespace
87158
} // namespace vk
88159

@@ -253,8 +324,9 @@ void RendererVk::ensureCapsInitialized() const
253324

254325
// Vulkan natively supports format reinterpretation, but we still require support for all
255326
// formats we may reinterpret to
256-
mNativeExtensions.textureSRGBOverride = true;
257-
mNativeExtensions.textureSRGBDecode = vk::GetTextureSRGBDecodeSupport(this);
327+
mNativeExtensions.textureSRGBOverride =
328+
vk::GetTextureSRGBOverrideSupport(this, mNativeExtensions);
329+
mNativeExtensions.textureSRGBDecode = vk::GetTextureSRGBDecodeSupport(this);
258330

259331
mNativeExtensions.gpuShader5EXT = vk::CanSupportGPUShader5EXT(mPhysicalDeviceFeatures);
260332

src/tests/perf_tests/TextureSampling.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct TextureSamplingParams final : public RenderTestParams
3131
iterationsPerStep = kIterationsPerStep;
3232

3333
// Common default params
34-
majorVersion = 2;
34+
majorVersion = 3;
3535
minorVersion = 0;
3636
windowWidth = 720;
3737
windowHeight = 720;
@@ -274,12 +274,11 @@ class TextureSamplingMutableFormatBenchmark : public TextureSamplingBenchmark
274274

275275
void TextureSamplingMutableFormatBenchmark::initializeBenchmark()
276276
{
277-
if (!IsGLExtensionEnabled("GL_EXT_texture_sRGB_override"))
277+
if (IsGLExtensionEnabled("GL_EXT_texture_sRGB_override"))
278278
{
279-
FAIL() << "GL_EXT_texture_sRGB_override not supported!" << std::endl;
279+
TextureSamplingBenchmark::initializeBenchmark();
280+
initTextures();
280281
}
281-
TextureSamplingBenchmark::initializeBenchmark();
282-
initTextures();
283282
}
284283

285284
void TextureSamplingMutableFormatBenchmark::initTextures()
@@ -329,11 +328,13 @@ TextureSamplingParams VulkanParams()
329328

330329
TEST_P(TextureSamplingBenchmark, Run)
331330
{
331+
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_sRGB_override"));
332332
run();
333333
}
334334

335335
TEST_P(TextureSamplingMutableFormatBenchmark, Run)
336336
{
337+
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_sRGB_override"));
337338
run();
338339
}
339340

0 commit comments

Comments
 (0)