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

Commit e33c158

Browse files
shrekshaoCommit Bot
authored andcommitted
Fix EXT_texture_norm16
* Add norm16 format info for OpenGL backend * Add validation for newly introduced norm16 formats * Fix some logic of texture tests Bug: chromium:1000354, angleproject:1365 Change-Id: Ie6d6e5e276da4df4b7c667be28d324d4976b35ec Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1902720 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shrek Shao <shrekshao@google.com> Commit-Queue: Shrek Shao <shrekshao@google.com>
1 parent 82fd254 commit e33c158

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

src/libANGLE/Caps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
875875
map["GL_CHROMIUM_color_buffer_float_rgba"] = enableableExtension(&Extensions::colorBufferFloatRGBA);
876876
map["GL_EXT_multisample_compatibility"] = esOnlyExtension(&Extensions::multisampleCompatibility);
877877
map["GL_CHROMIUM_framebuffer_mixed_samples"] = esOnlyExtension(&Extensions::framebufferMixedSamples);
878-
map["GL_EXT_texture_norm16"] = esOnlyExtension(&Extensions::textureNorm16);
878+
map["GL_EXT_texture_norm16"] = enableableExtension(&Extensions::textureNorm16);
879879
map["GL_CHROMIUM_path_rendering"] = esOnlyExtension(&Extensions::pathRendering);
880880
map["GL_OES_surfaceless_context"] = esOnlyExtension(&Extensions::surfacelessContext);
881881
map["GL_ANGLE_client_arrays"] = esOnlyExtension(&Extensions::clientArrays);

src/libANGLE/renderer/gl/formatutilsgl.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,16 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
209209
InsertFormatMapping(&map, GL_RGBA32I, VersionOrExts(3, 0, "GL_EXT_texture_integer"), NeverSupported(), VersionOrExts(3, 0, "GL_EXT_texture_integer"), VersionOnly(3, 0), NeverSupported(), VersionOnly(3, 0), VersionOnly(3, 0) );
210210
InsertFormatMapping(&map, GL_RGBA32UI, VersionOrExts(3, 0, "GL_EXT_texture_integer"), NeverSupported(), VersionOrExts(3, 0, "GL_EXT_texture_integer"), VersionOnly(3, 0), NeverSupported(), VersionOnly(3, 0), VersionOnly(3, 0) );
211211

212+
InsertFormatMapping(&map, GL_R16, VersionOrExts(3, 0, "GL_ARB_texture_rg"), AlwaysSupported(), VersionOrExts(3, 0, "GL_ARB_texture_rg"), ExtsOnly("GL_EXT_texture_norm16"), AlwaysSupported(), ExtsOnly("GL_EXT_texture_norm16"), ExtsOnly("GL_EXT_texture_norm16") );
213+
InsertFormatMapping(&map, GL_RG16, VersionOrExts(3, 0, "GL_ARB_texture_rg"), AlwaysSupported(), VersionOrExts(3, 0, "GL_ARB_texture_rg"), ExtsOnly("GL_EXT_texture_norm16"), AlwaysSupported(), ExtsOnly("GL_EXT_texture_norm16"), ExtsOnly("GL_EXT_texture_norm16") );
214+
InsertFormatMapping(&map, GL_RGB16, AlwaysSupported(), AlwaysSupported(), NeverSupported(), ExtsOnly("GL_EXT_texture_norm16"), AlwaysSupported(), NeverSupported(), NeverSupported() );
215+
InsertFormatMapping(&map, GL_RGBA16, AlwaysSupported(), AlwaysSupported(), AlwaysSupported(), ExtsOnly("GL_EXT_texture_norm16"), AlwaysSupported(), ExtsOnly("GL_EXT_texture_norm16"), ExtsOnly("GL_EXT_texture_norm16") );
216+
217+
InsertFormatMapping(&map, GL_R16_SNORM, VersionOnly(3, 1), AlwaysSupported(), NeverSupported(), ExtsOnly("GL_EXT_texture_norm16"), AlwaysSupported(), NeverSupported(), NeverSupported() );
218+
InsertFormatMapping(&map, GL_RG16_SNORM, VersionOnly(3, 1), AlwaysSupported(), NeverSupported(), ExtsOnly("GL_EXT_texture_norm16"), AlwaysSupported(), NeverSupported(), NeverSupported() );
219+
InsertFormatMapping(&map, GL_RGB16_SNORM, VersionOnly(3, 1), AlwaysSupported(), NeverSupported(), ExtsOnly("GL_EXT_texture_norm16"), AlwaysSupported(), NeverSupported(), NeverSupported() );
220+
InsertFormatMapping(&map, GL_RGBA16_SNORM, VersionOnly(3, 1), AlwaysSupported(), NeverSupported(), ExtsOnly("GL_EXT_texture_norm16"), AlwaysSupported(), NeverSupported(), NeverSupported() );
221+
212222
// Unsized formats
213223
InsertFormatMapping(&map, GL_ALPHA, NeverSupported(), NeverSupported(), NeverSupported(), AlwaysSupported(), AlwaysSupported(), NeverSupported(), NeverSupported() );
214224
InsertFormatMapping(&map, GL_LUMINANCE, NeverSupported(), NeverSupported(), NeverSupported(), AlwaysSupported(), AlwaysSupported(), NeverSupported(), NeverSupported() );

src/libANGLE/validationES2.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,14 @@ bool ValidateES2TexImageParametersBase(Context *context,
14291429
return false;
14301430
}
14311431
break;
1432+
case GL_SHORT:
1433+
case GL_UNSIGNED_SHORT:
1434+
if (!context->getExtensions().textureNorm16)
1435+
{
1436+
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
1437+
return false;
1438+
}
1439+
break;
14321440
default:
14331441
context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
14341442
return false;
@@ -1443,6 +1451,15 @@ bool ValidateES2TexImageParametersBase(Context *context,
14431451
case GL_FLOAT:
14441452
case GL_HALF_FLOAT_OES:
14451453
break;
1454+
case GL_SHORT:
1455+
case GL_UNSIGNED_SHORT:
1456+
if (!context->getExtensions().textureNorm16)
1457+
{
1458+
context->validationError(GL_INVALID_OPERATION,
1459+
kMismatchedTypeAndFormat);
1460+
return false;
1461+
}
1462+
break;
14461463
default:
14471464
context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
14481465
return false;
@@ -1458,6 +1475,15 @@ bool ValidateES2TexImageParametersBase(Context *context,
14581475
case GL_HALF_FLOAT_OES:
14591476
case GL_UNSIGNED_INT_2_10_10_10_REV_EXT:
14601477
break;
1478+
case GL_SHORT:
1479+
case GL_UNSIGNED_SHORT:
1480+
if (!context->getExtensions().textureNorm16)
1481+
{
1482+
context->validationError(GL_INVALID_OPERATION,
1483+
kMismatchedTypeAndFormat);
1484+
return false;
1485+
}
1486+
break;
14611487
default:
14621488
context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
14631489
return false;
@@ -1780,6 +1806,20 @@ bool ValidateES2TexImageParametersBase(Context *context,
17801806

17811807
break;
17821808

1809+
case GL_R16_EXT:
1810+
case GL_RG16_EXT:
1811+
case GL_RGB16_EXT:
1812+
case GL_RGBA16_EXT:
1813+
case GL_R16_SNORM_EXT:
1814+
case GL_RG16_SNORM_EXT:
1815+
case GL_RGB16_SNORM_EXT:
1816+
case GL_RGBA16_SNORM_EXT:
1817+
if (!context->getExtensions().textureNorm16)
1818+
{
1819+
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
1820+
return false;
1821+
}
1822+
break;
17831823
default:
17841824
context->validationError(GL_INVALID_VALUE, kInvalidInternalFormat);
17851825
return false;

src/tests/gl_tests/TextureTest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4014,8 +4014,13 @@ class Texture2DNorm16TestES3 : public Texture2DTestES3
40144014
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
40154015
glClear(GL_COLOR_BUFFER_BIT);
40164016

4017+
EXPECT_PIXEL_COLOR_EQ(0, 0, SliceFormatColor(format, GLColor::white));
4018+
4019+
glBindTexture(GL_TEXTURE_2D, mTextures[1]);
40174020
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1);
40184021

4022+
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextures[1],
4023+
0);
40194024
EXPECT_PIXEL_COLOR_EQ(0, 0, SliceFormatColor(format, GLColor::white));
40204025

40214026
glBindFramebuffer(GL_FRAMEBUFFER, 0);
@@ -4031,6 +4036,11 @@ class Texture2DNorm16TestES3 : public Texture2DTestES3
40314036
// Test texture formats enabled by the GL_EXT_texture_norm16 extension.
40324037
TEST_P(Texture2DNorm16TestES3, TextureNorm16Test)
40334038
{
4039+
// TODO(crbug.com/angleproject/4089) Fails on Nexus5X Adreno
4040+
ANGLE_SKIP_TEST_IF(IsNexus5X());
4041+
// TODO(crbug.com/angleproject/4089) Fails on Win Intel OpenGL driver
4042+
ANGLE_SKIP_TEST_IF(IsIntel() && IsOpenGL());
4043+
40344044
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_norm16"));
40354045

40364046
testNorm16Texture(GL_R16_EXT, GL_RED, GL_UNSIGNED_SHORT);

0 commit comments

Comments
 (0)