Commit 74e816bf by Cody Northrop Committed by Commit Bot

Vulkan: Expose extension for ETC1 usage with subimage updates

This CL implements the GL_EXT_compressed_ETC1_RGB8_sub_texture extension, which was added to relax restrictions on using ETC1_RGB8_OES for subimage updates. Test: Temple Run on Android Bug: b:152512564 Change-Id: I78cfd7dfd54fab36dee59a93b3ec3bfce17e73e4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2123232 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 617cb015
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"scripts/gl_angle_ext.xml": "scripts/gl_angle_ext.xml":
"079cc4829de7ce638faf7bbf66e141ad", "079cc4829de7ce638faf7bbf66e141ad",
"scripts/registry_xml.py": "scripts/registry_xml.py":
"06c837b395c8cd0c4fc937b193365042", "439dd95a9f118a64e8745f97963efa4a",
"scripts/wgl.xml": "scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4", "aa96419c582af2f6673430e2847693f4",
"src/libEGL/egl_loader_autogen.cpp": "src/libEGL/egl_loader_autogen.cpp":
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"scripts/gl_angle_ext.xml": "scripts/gl_angle_ext.xml":
"079cc4829de7ce638faf7bbf66e141ad", "079cc4829de7ce638faf7bbf66e141ad",
"scripts/registry_xml.py": "scripts/registry_xml.py":
"06c837b395c8cd0c4fc937b193365042", "439dd95a9f118a64e8745f97963efa4a",
"scripts/wgl.xml": "scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4", "aa96419c582af2f6673430e2847693f4",
"src/libANGLE/Context_gl_1_0_autogen.h": "src/libANGLE/Context_gl_1_0_autogen.h":
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
"src/libANGLE/Context_gles_3_2_autogen.h": "src/libANGLE/Context_gles_3_2_autogen.h":
"e26f7ee7b59a89a4f5337171816b8336", "e26f7ee7b59a89a4f5337171816b8336",
"src/libANGLE/Context_gles_ext_autogen.h": "src/libANGLE/Context_gles_ext_autogen.h":
"572006fa4493a901e879f6df3cb4eee8", "470d459798aff6d0315a0c95134d9524",
"src/libANGLE/capture_gles_1_0_autogen.cpp": "src/libANGLE/capture_gles_1_0_autogen.cpp":
"96fc0f501e2e696ab911dad8b400dfb2", "96fc0f501e2e696ab911dad8b400dfb2",
"src/libANGLE/capture_gles_1_0_autogen.h": "src/libANGLE/capture_gles_1_0_autogen.h":
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"scripts/gl_angle_ext.xml": "scripts/gl_angle_ext.xml":
"079cc4829de7ce638faf7bbf66e141ad", "079cc4829de7ce638faf7bbf66e141ad",
"scripts/registry_xml.py": "scripts/registry_xml.py":
"06c837b395c8cd0c4fc937b193365042", "439dd95a9f118a64e8745f97963efa4a",
"src/libANGLE/gl_enum_utils_autogen.cpp": "src/libANGLE/gl_enum_utils_autogen.cpp":
"cfc52f413272c061ee4a037876792726", "cfc52f413272c061ee4a037876792726",
"src/libANGLE/gl_enum_utils_autogen.h": "src/libANGLE/gl_enum_utils_autogen.h":
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"scripts/gl_angle_ext.xml": "scripts/gl_angle_ext.xml":
"079cc4829de7ce638faf7bbf66e141ad", "079cc4829de7ce638faf7bbf66e141ad",
"scripts/registry_xml.py": "scripts/registry_xml.py":
"06c837b395c8cd0c4fc937b193365042", "439dd95a9f118a64e8745f97963efa4a",
"scripts/wgl.xml": "scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4", "aa96419c582af2f6673430e2847693f4",
"src/libGL/proc_table_wgl_autogen.cpp": "src/libGL/proc_table_wgl_autogen.cpp":
......
...@@ -92,6 +92,7 @@ gles_extensions = [ ...@@ -92,6 +92,7 @@ gles_extensions = [
"GL_KHR_parallel_shader_compile", "GL_KHR_parallel_shader_compile",
"GL_NV_fence", "GL_NV_fence",
"GL_OES_compressed_ETC1_RGB8_texture", "GL_OES_compressed_ETC1_RGB8_texture",
"GL_EXT_compressed_ETC1_RGB8_sub_texture",
"GL_OES_depth32", "GL_OES_depth32",
"GL_OES_draw_buffers_indexed", "GL_OES_draw_buffers_indexed",
"GL_OES_draw_elements_base_vertex", "GL_OES_draw_elements_base_vertex",
......
...@@ -877,6 +877,7 @@ const ExtensionInfoMap &GetExtensionInfoMap() ...@@ -877,6 +877,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_EXT_texture_compression_bptc"] = enableableExtension(&Extensions::textureCompressionBPTC); map["GL_EXT_texture_compression_bptc"] = enableableExtension(&Extensions::textureCompressionBPTC);
map["GL_EXT_texture_compression_rgtc"] = enableableExtension(&Extensions::textureCompressionRGTC); map["GL_EXT_texture_compression_rgtc"] = enableableExtension(&Extensions::textureCompressionRGTC);
map["GL_OES_compressed_ETC1_RGB8_texture"] = enableableExtension(&Extensions::compressedETC1RGB8TextureOES); map["GL_OES_compressed_ETC1_RGB8_texture"] = enableableExtension(&Extensions::compressedETC1RGB8TextureOES);
map["GL_EXT_compressed_ETC1_RGB8_sub_texture"] = enableableExtension(&Extensions::compressedETC1RGB8SubTexture);
map["GL_OES_compressed_ETC2_RGB8_texture"] = enableableExtension(&Extensions::compressedETC2RGB8TextureOES); map["GL_OES_compressed_ETC2_RGB8_texture"] = enableableExtension(&Extensions::compressedETC2RGB8TextureOES);
map["GL_OES_compressed_ETC2_sRGB8_texture"] = enableableExtension(&Extensions::compressedETC2sRGB8TextureOES); map["GL_OES_compressed_ETC2_sRGB8_texture"] = enableableExtension(&Extensions::compressedETC2sRGB8TextureOES);
map["GL_OES_compressed_ETC2_punchthroughA_RGBA8_texture"] = enableableExtension(&Extensions::compressedETC2PunchthroughARGB8TextureOES); map["GL_OES_compressed_ETC2_punchthroughA_RGBA8_texture"] = enableableExtension(&Extensions::compressedETC2PunchthroughARGB8TextureOES);
......
...@@ -226,6 +226,9 @@ struct Extensions ...@@ -226,6 +226,9 @@ struct Extensions
// Implies that TextureCaps for GL_ETC1_RGB8_OES exist // Implies that TextureCaps for GL_ETC1_RGB8_OES exist
bool compressedETC1RGB8TextureOES = false; bool compressedETC1RGB8TextureOES = false;
// GL_EXT_compressed_ETC1_RGB8_sub_texture
bool compressedETC1RGB8SubTexture = false;
// OES_compressed_ETC2_RGB8_texture // OES_compressed_ETC2_RGB8_texture
bool compressedETC2RGB8TextureOES = false; bool compressedETC2RGB8TextureOES = false;
......
...@@ -280,6 +280,7 @@ ...@@ -280,6 +280,7 @@
GLint getFragDataIndex(ShaderProgramID programPacked, const GLchar *name); \ GLint getFragDataIndex(ShaderProgramID programPacked, const GLchar *name); \
GLint getProgramResourceLocationIndex(ShaderProgramID programPacked, GLenum programInterface, \ GLint getProgramResourceLocationIndex(ShaderProgramID programPacked, GLenum programInterface, \
const GLchar *name); \ const GLchar *name); \
/* GL_EXT_compressed_ETC1_RGB8_sub_texture */ \
/* GL_EXT_debug_marker */ \ /* GL_EXT_debug_marker */ \
void insertEventMarker(GLsizei length, const GLchar *marker); \ void insertEventMarker(GLsizei length, const GLchar *marker); \
void popGroupMarker(); \ void popGroupMarker(); \
......
...@@ -1569,6 +1569,7 @@ void GenerateCaps(ID3D11Device *device, ...@@ -1569,6 +1569,7 @@ void GenerateCaps(ID3D11Device *device,
// Explicitly disable GL_OES_compressed_ETC1_RGB8_texture because it's emulated and never // Explicitly disable GL_OES_compressed_ETC1_RGB8_texture because it's emulated and never
// becomes core. WebGL doesn't want to expose it unless there is native support. // becomes core. WebGL doesn't want to expose it unless there is native support.
extensions->compressedETC1RGB8TextureOES = false; extensions->compressedETC1RGB8TextureOES = false;
extensions->compressedETC1RGB8SubTexture = false;
extensions->elementIndexUintOES = true; extensions->elementIndexUintOES = true;
extensions->getProgramBinaryOES = true; extensions->getProgramBinaryOES = true;
......
...@@ -1304,6 +1304,12 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -1304,6 +1304,12 @@ void GenerateCaps(const FunctionsGL *functions,
extensions->textureSRGBDecode = functions->hasGLExtension("GL_EXT_texture_sRGB_decode") || extensions->textureSRGBDecode = functions->hasGLExtension("GL_EXT_texture_sRGB_decode") ||
functions->hasGLESExtension("GL_EXT_texture_sRGB_decode"); functions->hasGLESExtension("GL_EXT_texture_sRGB_decode");
// ANGLE treats ETC1 as ETC2 for ES 3.0 and higher because it becomes a core format, and they
// are backwards compatible.
extensions->compressedETC1RGB8SubTexture =
functions->isAtLeastGLES(gl::Version(3, 0)) ||
functions->hasGLESExtension("GL_EXT_compressed_ETC1_RGB8_sub_texture");
#if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST) #if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
VendorID vendor = GetVendorID(functions); VendorID vendor = GetVendorID(functions);
if ((IsAMD(vendor) || IsIntel(vendor)) && *maxSupportedESVersion >= gl::Version(3, 0)) if ((IsAMD(vendor) || IsIntel(vendor)) && *maxSupportedESVersion >= gl::Version(3, 0))
......
...@@ -92,6 +92,7 @@ ContextNULL::ContextNULL(const gl::State &state, ...@@ -92,6 +92,7 @@ ContextNULL::ContextNULL(const gl::State &state,
mExtensions.textureCompressionASTCLDRKHR = true; mExtensions.textureCompressionASTCLDRKHR = true;
mExtensions.textureCompressionASTCOES = true; mExtensions.textureCompressionASTCOES = true;
mExtensions.compressedETC1RGB8TextureOES = true; mExtensions.compressedETC1RGB8TextureOES = true;
mExtensions.compressedETC1RGB8SubTexture = true;
mExtensions.lossyETCDecode = true; mExtensions.lossyETCDecode = true;
mExtensions.geometryShader = true; mExtensions.geometryShader = true;
......
...@@ -66,6 +66,9 @@ void RendererVk::ensureCapsInitialized() const ...@@ -66,6 +66,9 @@ void RendererVk::ensureCapsInitialized() const
mNativeExtensions.textureCompressionSliced3dASTCKHR = mNativeExtensions.textureCompressionSliced3dASTCKHR =
mNativeExtensions.textureCompressionASTCLDRKHR; mNativeExtensions.textureCompressionASTCLDRKHR;
// Enable EXT_compressed_ETC1_RGB8_sub_texture
mNativeExtensions.compressedETC1RGB8SubTexture = mNativeExtensions.compressedETC1RGB8TextureOES;
// Enable this for simple buffer readback testing, but some functionality is missing. // Enable this for simple buffer readback testing, but some functionality is missing.
// TODO(jmadill): Support full mapBufferRange extension. // TODO(jmadill): Support full mapBufferRange extension.
mNativeExtensions.mapBufferOES = true; mNativeExtensions.mapBufferOES = true;
......
...@@ -1192,10 +1192,14 @@ bool ValidateES2TexImageParametersBase(const Context *context, ...@@ -1192,10 +1192,14 @@ bool ValidateES2TexImageParametersBase(const Context *context,
if (isSubImage) if (isSubImage)
{ {
// From the OES_compressed_ETC1_RGB8_texture spec: // From the OES_compressed_ETC1_RGB8_texture spec:
//
// INVALID_OPERATION is generated by CompressedTexSubImage2D, TexSubImage2D, or // INVALID_OPERATION is generated by CompressedTexSubImage2D, TexSubImage2D, or
// CopyTexSubImage2D if the texture image <level> bound to <target> has internal format // CopyTexSubImage2D if the texture image <level> bound to <target> has internal format
// ETC1_RGB8_OES. // ETC1_RGB8_OES.
if (actualInternalFormat == GL_ETC1_RGB8_OES) //
// This is relaxed if GL_EXT_compressed_ETC1_RGB8_sub_texture is supported.
if (actualInternalFormat == GL_ETC1_RGB8_OES &&
!context->getExtensions().compressedETC1RGB8SubTexture)
{ {
context->validationError(GL_INVALID_OPERATION, kInvalidInternalFormat); context->validationError(GL_INVALID_OPERATION, kInvalidInternalFormat);
return false; return false;
......
...@@ -557,7 +557,9 @@ bool ValidateES3TexImageParametersBase(const Context *context, ...@@ -557,7 +557,9 @@ bool ValidateES3TexImageParametersBase(const Context *context,
return false; return false;
} }
if (actualInternalFormat == GL_ETC1_RGB8_OES) // GL_EXT_compressed_ETC1_RGB8_sub_texture allows this format
if (actualInternalFormat == GL_ETC1_RGB8_OES &&
!context->getExtensions().compressedETC1RGB8SubTexture)
{ {
context->validationError(GL_INVALID_OPERATION, kInvalidInternalFormat); context->validationError(GL_INVALID_OPERATION, kInvalidInternalFormat);
return false; return false;
......
...@@ -1448,6 +1448,24 @@ class PBOCompressedTextureTest : public Texture2DTest ...@@ -1448,6 +1448,24 @@ class PBOCompressedTextureTest : public Texture2DTest
GLuint mPBO; GLuint mPBO;
}; };
class ETC1CompressedTextureTest : public Texture2DTest
{
protected:
ETC1CompressedTextureTest() : Texture2DTest() {}
void testSetUp() override
{
TexCoordDrawTest::testSetUp();
glGenTextures(1, &mTexture2D);
glBindTexture(GL_TEXTURE_2D, mTexture2D);
EXPECT_GL_NO_ERROR();
setUpProgram();
}
void testTearDown() override { Texture2DTest::testTearDown(); }
};
TEST_P(Texture2DTest, NegativeAPISubImage) TEST_P(Texture2DTest, NegativeAPISubImage)
{ {
glBindTexture(GL_TEXTURE_2D, mTexture2D); glBindTexture(GL_TEXTURE_2D, mTexture2D);
...@@ -6083,6 +6101,50 @@ TEST_P(PBOCompressedTextureTest, PBOCompressedSubImage) ...@@ -6083,6 +6101,50 @@ TEST_P(PBOCompressedTextureTest, PBOCompressedSubImage)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
} }
// Test using ETC1_RGB8 with subimage updates
TEST_P(ETC1CompressedTextureTest, ETC1CompressedSubImage)
{
// ETC texture formats are not supported on Mac OpenGL. http://anglebug.com/3853
ANGLE_SKIP_TEST_IF(IsOSX() && IsDesktopOpenGL());
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 &&
!IsGLExtensionEnabled("GL_EXT_texture_storage"));
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_compressed_ETC1_RGB8_sub_texture"));
const GLuint width = 4u;
const GLuint height = 4u;
setWindowWidth(width);
setWindowHeight(height);
// Setup primary Texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
if (getClientMajorVersion() < 3)
{
glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_ETC1_RGB8_OES, width, height);
}
else
{
glTexStorage2D(GL_TEXTURE_2D, 1, GL_ETC1_RGB8_OES, width, height);
}
ASSERT_GL_NO_ERROR();
// Populate a subimage of the texture
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_ETC1_RGB8_OES,
width * height / 2u, kCompressedImageETC2);
ASSERT_GL_NO_ERROR();
// Render and ensure we get red
glUseProgram(mProgram);
drawQuad(mProgram, "position", 0.5f);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 2, getWindowHeight() / 2, GLColor::red);
ASSERT_GL_NO_ERROR();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these // Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against. // tests should be run against.
ANGLE_INSTANTIATE_TEST_ES2(Texture2DTest); ANGLE_INSTANTIATE_TEST_ES2(Texture2DTest);
...@@ -6122,5 +6184,6 @@ ANGLE_INSTANTIATE_TEST_ES3(Texture2DArrayIntegerTestES3); ...@@ -6122,5 +6184,6 @@ ANGLE_INSTANTIATE_TEST_ES3(Texture2DArrayIntegerTestES3);
ANGLE_INSTANTIATE_TEST_ES3(Texture3DIntegerTestES3); ANGLE_INSTANTIATE_TEST_ES3(Texture3DIntegerTestES3);
ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(Texture2DDepthTest); ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(Texture2DDepthTest);
ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(PBOCompressedTextureTest); ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(PBOCompressedTextureTest);
ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(ETC1CompressedTextureTest);
} // anonymous namespace } // anonymous namespace
...@@ -4669,8 +4669,9 @@ TEST_P(WebGLCompatibilityTest, EnableCompressedTextureExtensionDXT5SRGBA) ...@@ -4669,8 +4669,9 @@ TEST_P(WebGLCompatibilityTest, EnableCompressedTextureExtensionDXT5SRGBA)
// Test enabling GL_OES_compressed_ETC1_RGB8_texture // Test enabling GL_OES_compressed_ETC1_RGB8_texture
TEST_P(WebGLCompatibilityTest, EnableCompressedTextureExtensionETC1) TEST_P(WebGLCompatibilityTest, EnableCompressedTextureExtensionETC1)
{ {
validateCompressedTexImageExtensionFormat(GL_ETC1_RGB8_OES, 4, 4, 8, validateCompressedTexImageExtensionFormat(
"GL_OES_compressed_ETC1_RGB8_texture", false); GL_ETC1_RGB8_OES, 4, 4, 8, "GL_OES_compressed_ETC1_RGB8_texture",
IsGLExtensionEnabled("GL_EXT_compressed_ETC1_RGB8_sub_texture"));
} }
// Test enabling GL_ANGLE_lossy_etc_decode // Test enabling GL_ANGLE_lossy_etc_decode
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment