Skip to content

Commit

Permalink
GL: Implement GL_EXT_clear_texture.
Browse files Browse the repository at this point in the history
This extension is useful because it allows clearing textures without
changing the framebuffer. Chrome uses this on Android when it's
available.

Bug: angleproject:347047859
Change-Id: I765d9991c4549b3655446d9f51847d1095792dbd
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5631810
Reviewed-by: Cody Northrop <[email protected]>
Reviewed-by: Shahbaz Youssefi <[email protected]>
Commit-Queue: Geoff Lang <[email protected]>
  • Loading branch information
vonture authored and Angle LUCI CQ committed Jun 19, 2024
1 parent 1160fda commit 92148c2
Show file tree
Hide file tree
Showing 53 changed files with 1,105 additions and 67 deletions.
1 change: 1 addition & 0 deletions doc/ExtensionSupport.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ using data from registry_xml.py and gl.xml.
| [GL_EXT_blend_func_extended](https://khronos.org/registry/OpenGL/extensions/EXT/EXT_blend_func_extended.txt) | &#x2714; | &#x2714; | &#x2714; | &#x2714; | | &#x2714; | |
| [GL_EXT_blend_minmax](https://khronos.org/registry/OpenGL/extensions/EXT/EXT_blend_minmax.txt) | &#x2714; | &#x2714; | &#x2714; | &#x2714; | &#x2714; | &#x2714; | &#x2714; |
| [GL_EXT_buffer_storage](https://khronos.org/registry/OpenGL/extensions/EXT/EXT_buffer_storage.txt) | &#x2714; | &#x2714; | &#x2714; | &#x2714; | &#x2714; | &#x2714; | &#x2714; |
| [GL_EXT_clear_texture](https://khronos.org/registry/OpenGL/extensions/EXT/EXT_clear_texture.txt) | | | | | | | |
| [GL_EXT_clip_control](https://khronos.org/registry/OpenGL/extensions/EXT/EXT_clip_control.txt) | &#x2714; | &#x2714; | &#x2714; | &#x2714; | &#x2714; | &#x2714; | &#x2714; |
| [GL_EXT_clip_cull_distance](https://khronos.org/registry/OpenGL/extensions/EXT/EXT_clip_cull_distance.txt) | &#x2714; | &#x2714; | &#x2714; | &#x2714; | &#x2714; | &#x2714; | |
| [GL_APPLE_clip_distance](https://khronos.org/registry/OpenGL/extensions/APPLE/APPLE_clip_distance.txt) | &#x2714; | &#x2714; | &#x2714; | &#x2714; | &#x2714; | &#x2714; | |
Expand Down
8 changes: 4 additions & 4 deletions scripts/code_generation_hashes/Extension_files.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"doc/ExtensionSupport.md":
"df7772da1d6452363cf08e2f11264063",
"7c18af60c24e643600cd266e4391b864",
"scripts/egl_angle_ext.xml":
"bdd2dcfaa4b6d82e12b6004f1435946d",
"scripts/extension_data/intel_630_linux.json":
Expand All @@ -22,13 +22,13 @@
"scripts/gl_angle_ext.xml":
"197e07a917d5bba6dfa2840fb1b58e7e",
"scripts/registry_xml.py":
"29b215b053179dd171371115ea4566ef",
"007d3348fec58f58b86a02380d3609c9",
"src/libANGLE/gen_extensions.py":
"6ea1cb1733c4df98b527bbf2752e118b",
"src/libANGLE/gles_extensions_autogen.cpp":
"b6b722565d2442b59b5229730c8d9b17",
"62418d61f119bc1b9a18579eddb7fd7c",
"src/libANGLE/gles_extensions_autogen.h":
"e47a996de19c0543560467079c975409",
"0de4310a3f9ce1b0f3f003fb402d7174",
"third_party/EGL-Registry/src/api/egl.xml":
"2056d54ea07156f1988ca1366bdee21a",
"third_party/OpenCL-Docs/src/xml/cl.xml":
Expand Down
10 changes: 5 additions & 5 deletions scripts/code_generation_hashes/GL_EGL_WGL_loader.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts/gl_angle_ext.xml":
"197e07a917d5bba6dfa2840fb1b58e7e",
"scripts/registry_xml.py":
"29b215b053179dd171371115ea4566ef",
"007d3348fec58f58b86a02380d3609c9",
"src/libEGL/egl_loader_autogen.cpp":
"9ed54b9c0801cbe9b81746e79baa09bd",
"src/libEGL/egl_loader_autogen.h":
Expand All @@ -26,17 +26,17 @@
"util/capture/trace_egl_loader_autogen.h":
"73215d434682b07aefbeba782ff32fe4",
"util/capture/trace_gles_loader_autogen.cpp":
"5d2094c64350da39d97550dbebd765d9",
"9863bc015545fde9cca5d308a4843ff4",
"util/capture/trace_gles_loader_autogen.h":
"528771f9025fe420be5488ddbf1c18a3",
"7de6f3f9b79e5904c630e12be2106e7f",
"util/egl_loader_autogen.cpp":
"f79641342b64356e121cff5659c41c55",
"util/egl_loader_autogen.h":
"6a9a0a41347d85c566418d772cbb9d66",
"util/gles_loader_autogen.cpp":
"d95578214c7d5ab14bd56373f1e8ce6e",
"683d3c537e082b9780e158242acfe8d1",
"util/gles_loader_autogen.h":
"8061bfc0f6b903fa8535337d573d1e09",
"053abf470d8d066a35a8fdcf64d3a62d",
"util/windows/wgl_loader_autogen.cpp":
"373b062587eab8a163121255f54597dc",
"util/windows/wgl_loader_autogen.h":
Expand Down
30 changes: 15 additions & 15 deletions scripts/code_generation_hashes/GL_EGL_entry_points.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"scripts/gl_angle_ext.xml":
"197e07a917d5bba6dfa2840fb1b58e7e",
"scripts/registry_xml.py":
"29b215b053179dd171371115ea4566ef",
"007d3348fec58f58b86a02380d3609c9",
"src/common/entry_points_enum_autogen.cpp":
"bdd2d6760f80f719ea3e273b45975c4c",
"e28de3dde40d2fa27a34447cbe03c648",
"src/common/entry_points_enum_autogen.h":
"46c4393622a963c3edce9365cf69e15a",
"7c6b803d2e7fc8464c8fc8706a36e14d",
"src/common/frame_capture_utils_autogen.cpp":
"1984fe7b49b4d8fce4decbca540f71e0",
"src/common/frame_capture_utils_autogen.h":
Expand All @@ -26,7 +26,7 @@
"src/libANGLE/Context_gl_3_autogen.h":
"b62001f26c3877022a0f6be7e25d990f",
"src/libANGLE/Context_gl_4_autogen.h":
"b4d43e03bb0705969da5b88ee0c821ee",
"b1d56798b232e63575539023b88c8a38",
"src/libANGLE/Context_gles_1_0_autogen.h":
"cb1cfe652972d301a5a98b4f233fcc4f",
"src/libANGLE/Context_gles_2_0_autogen.h":
Expand All @@ -38,7 +38,7 @@
"src/libANGLE/Context_gles_3_2_autogen.h":
"cf9900e0067812fc6773e8ae4664da33",
"src/libANGLE/Context_gles_ext_autogen.h":
"e3739b3623f9ea1656406d6a8df5c7a3",
"bc10d315bb3d027bde38f39f27d2b898",
"src/libANGLE/capture/capture_egl_autogen.cpp":
"330861bd692183c0973402af31adbcd6",
"src/libANGLE/capture/capture_egl_autogen.h":
Expand Down Expand Up @@ -80,9 +80,9 @@
"src/libANGLE/capture/capture_gles_3_2_autogen.h":
"74ed7366af3a46c0661397cfa29ec6fc",
"src/libANGLE/capture/capture_gles_ext_autogen.cpp":
"8244b530221f21a09dcc4341868780cc",
"585e68f2c08ab3c0e2a73653b49ba99f",
"src/libANGLE/capture/capture_gles_ext_autogen.h":
"4f9ebb5eb2698f90a3f761eac091fc0c",
"1d2c99666240cbebbc6b86bbd420e175",
"src/libANGLE/context_private_call_gl_autogen.h":
"40c4fa88e0947ed35a04f2b112b6d708",
"src/libANGLE/context_private_call_gles_autogen.h":
Expand All @@ -102,7 +102,7 @@
"src/libANGLE/validationES3_autogen.h":
"29b3f384a582a4ffd45a898a481839fd",
"src/libANGLE/validationESEXT_autogen.h":
"65e6d919e1fe791f295e9b314867870f",
"6956518f7c5a49eb05d02672df123831",
"src/libANGLE/validationGL1_autogen.h":
"6024574ab4afbee4462d4a1f0c897c9a",
"src/libANGLE/validationGL2_autogen.h":
Expand Down Expand Up @@ -174,17 +174,17 @@
"src/libGLESv2/entry_points_gles_3_2_autogen.h":
"647f932a299cdb4726b60bbba059f0d2",
"src/libGLESv2/entry_points_gles_ext_autogen.cpp":
"17261ff7aad347adace70478ab52e461",
"87345c43f9f5d748fd6cf21c6606ab49",
"src/libGLESv2/entry_points_gles_ext_autogen.h":
"1839c46ea0c0a0ff8fc6e4c32923af69",
"75d2a87854c2933243970961cf905b5d",
"src/libGLESv2/libGLESv2_autogen.cpp":
"1eb79f960d4366a7366ba7dc8fb142a5",
"b482dbc4e812291ceb9ba1d7b3883128",
"src/libGLESv2/libGLESv2_autogen.def":
"efb93b465627c7f85f122e250f27d2d5",
"bf20dce99c8fe10912d07bbf803ed17d",
"src/libGLESv2/libGLESv2_no_capture_autogen.def":
"d349a186f70fd2cc2368dc68a8fb1f31",
"7a1cc5fff04c90361e253bfaf4d66cc7",
"src/libGLESv2/libGLESv2_with_capture_autogen.def":
"f9ab4473d1b990d7916523b27b2f5a2c",
"e7db2a41f0ac48f0fddeb9070900580a",
"src/libOpenCL/libOpenCL_autogen.cpp":
"10849978c910dc1af5dd4f0c815d1581",
"third_party/EGL-Registry/src/api/egl.xml":
Expand All @@ -198,5 +198,5 @@
"third_party/OpenGL-Registry/src/xml/wgl.xml":
"eae784bf4d1b983a42af5671b140b7c4",
"util/capture/frame_capture_replay_autogen.cpp":
"23d9338f0c58b3f68651da28293bf5ba"
"0f04240955957598d8b3fc367828eb0d"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts/gl_angle_ext.xml":
"197e07a917d5bba6dfa2840fb1b58e7e",
"scripts/registry_xml.py":
"29b215b053179dd171371115ea4566ef",
"007d3348fec58f58b86a02380d3609c9",
"src/common/gl_enum_utils_autogen.cpp":
"bdfa08de18d31e4c6321a8e433988347",
"src/common/gl_enum_utils_autogen.h":
Expand Down
4 changes: 2 additions & 2 deletions scripts/code_generation_hashes/interpreter_utils.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts/gl_angle_ext.xml":
"197e07a917d5bba6dfa2840fb1b58e7e",
"scripts/registry_xml.py":
"29b215b053179dd171371115ea4566ef",
"007d3348fec58f58b86a02380d3609c9",
"third_party/EGL-Registry/src/api/egl.xml":
"2056d54ea07156f1988ca1366bdee21a",
"third_party/OpenCL-Docs/src/xml/cl.xml":
Expand All @@ -20,5 +20,5 @@
"util/capture/trace_fixture.h":
"372cc40f90f5bd5d2fa1c7a8d9d5db0d",
"util/capture/trace_interpreter_autogen.cpp":
"85f4b9d01a5d84bb9f991ec51ef77080"
"9d077452900f665d4494cf900dbadc8d"
}
8 changes: 4 additions & 4 deletions scripts/code_generation_hashes/proc_table.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"scripts/gl_angle_ext.xml":
"197e07a917d5bba6dfa2840fb1b58e7e",
"scripts/registry_xml.py":
"29b215b053179dd171371115ea4566ef",
"007d3348fec58f58b86a02380d3609c9",
"src/libGLESv2/proc_table_cl_autogen.cpp":
"ed003b0f041aaaa35b67d3fe07e61f91",
"src/libGLESv2/proc_table_egl_autogen.cpp":
"5faa905014f06942f2c9edb2c65470ac",
"8748416397046b11ad8ae7c673fb67d7",
"src/libGLESv2/proc_table_glx_autogen.cpp":
"61e3bb4d2761641c0a935e4c99e1be68",
"c821796c108efce61b40565560e1f3e6",
"src/libGLESv2/proc_table_wgl_autogen.cpp":
"e5660aa0b436ea51adddc29775cce79a",
"6a595550cadbbabd22e266b5b017c6ff",
"src/libOpenCL/libOpenCL_autogen.map":
"bc5f5cf48227149ed321258a16eff1d7",
"third_party/EGL-Registry/src/api/egl.xml":
Expand Down
1 change: 1 addition & 0 deletions scripts/registry_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"GL_EXT_blend_func_extended",
"GL_EXT_blend_minmax",
"GL_EXT_buffer_storage",
"GL_EXT_clear_texture",
"GL_EXT_clip_control",
"GL_EXT_clip_cull_distance",
"GL_EXT_color_buffer_float",
Expand Down
4 changes: 4 additions & 0 deletions src/common/entry_points_enum_autogen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,12 @@ const char *GetEntryPointName(EntryPoint ep)
return "glClearStencil";
case EntryPoint::GLClearTexImage:
return "glClearTexImage";
case EntryPoint::GLClearTexImageEXT:
return "glClearTexImageEXT";
case EntryPoint::GLClearTexSubImage:
return "glClearTexSubImage";
case EntryPoint::GLClearTexSubImageEXT:
return "glClearTexSubImageEXT";
case EntryPoint::GLClientActiveTexture:
return "glClientActiveTexture";
case EntryPoint::GLClientWaitSync:
Expand Down
2 changes: 2 additions & 0 deletions src/common/entry_points_enum_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ enum class EntryPoint
GLClearNamedFramebufferuiv,
GLClearStencil,
GLClearTexImage,
GLClearTexImageEXT,
GLClearTexSubImage,
GLClearTexSubImageEXT,
GLClientActiveTexture,
GLClientWaitSync,
GLClipControl,
Expand Down
45 changes: 45 additions & 0 deletions src/libANGLE/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9947,6 +9947,51 @@ void Context::startTiling(GLuint x, GLuint y, GLuint width, GLuint height, GLbit
UNIMPLEMENTED();
}

void Context::clearTexImage(TextureID texturePacked,
GLint level,
GLenum format,
GLenum type,
const void *data)
{
Texture *texture = getTexture(texturePacked);

// Sync the texture's state directly. EXT_clear_texture does not require that the texture is
// bound.
if (texture->hasAnyDirtyBit())
{
ANGLE_CONTEXT_TRY(texture->syncState(this, Command::Other));
}

ANGLE_CONTEXT_TRY(
texture->clearImage(this, level, format, type, static_cast<const uint8_t *>(data)));
}

void Context::clearTexSubImage(TextureID texturePacked,
GLint level,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLsizei width,
GLsizei height,
GLsizei depth,
GLenum format,
GLenum type,
const void *data)
{
Texture *texture = getTexture(texturePacked);

// Sync the texture's state directly. EXT_clear_texture does not require that the texture is
// bound.
if (texture->hasAnyDirtyBit())
{
ANGLE_CONTEXT_TRY(texture->syncState(this, Command::Other));
}

Box area(xoffset, yoffset, zoffset, width, height, depth);
ANGLE_CONTEXT_TRY(texture->clearSubImage(this, level, area, format, type,
static_cast<const uint8_t *>(data)));
}

// ErrorSet implementation.
ErrorSet::ErrorSet(Debug *debug,
const angle::FrontendFeatures &frontendFeatures,
Expand Down
24 changes: 0 additions & 24 deletions src/libANGLE/Context_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2472,30 +2472,6 @@ void Context::bindVertexBuffers(GLuint first,
UNIMPLEMENTED();
}

void Context::clearTexImage(TextureID texture,
GLint level,
GLenum format,
GLenum type,
const void *data)
{
UNIMPLEMENTED();
}

void Context::clearTexSubImage(TextureID texture,
GLint level,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLsizei width,
GLsizei height,
GLsizei depth,
GLenum format,
GLenum type,
const void *data)
{
UNIMPLEMENTED();
}

void Context::bindTextureUnit(GLuint unit, TextureID texture)
{
UNIMPLEMENTED();
Expand Down
5 changes: 0 additions & 5 deletions src/libANGLE/Context_gl_4_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@
void bindTextures(GLuint first, GLsizei count, const GLuint *textures); \
void bindVertexBuffers(GLuint first, GLsizei count, const BufferID *buffersPacked, \
const GLintptr *offsets, const GLsizei *strides); \
void clearTexImage(TextureID texturePacked, GLint level, GLenum format, GLenum type, \
const void *data); \
void clearTexSubImage(TextureID texturePacked, GLint level, GLint xoffset, GLint yoffset, \
GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, \
GLenum format, GLenum type, const void *data); \
void bindTextureUnit(GLuint unit, TextureID texturePacked); \
void blitNamedFramebuffer(GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, \
GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, \
Expand Down
6 changes: 6 additions & 0 deletions src/libANGLE/Context_gles_ext_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@
/* GL_EXT_buffer_storage */ \
void bufferStorage(BufferBinding targetPacked, GLsizeiptr size, const void *data, \
GLbitfield flags); \
/* GL_EXT_clear_texture */ \
void clearTexImage(TextureID texturePacked, GLint level, GLenum format, GLenum type, \
const void *data); \
void clearTexSubImage(TextureID texturePacked, GLint level, GLint xoffset, GLint yoffset, \
GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, \
GLenum format, GLenum type, const void *data); \
/* GL_EXT_clip_control */ \
/* GL_EXT_clip_cull_distance */ \
/* GL_EXT_color_buffer_float */ \
Expand Down
2 changes: 2 additions & 0 deletions src/libANGLE/ErrorStrings.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ MSG kBufferNotMapped = "Buffer is not mapped.";
MSG kBufferNotUpdatable = "Buffer is not updatable.";
MSG kBufferOffsetOverflow = "Buffer offset overflow.";
MSG kBufferPointerNotAvailable = "Can not get pointer for reserved buffer name zero.";
MSG kBufferTextureNotAllowed = "Buffer textures are not allowed.";
MSG kCannotPopDefaultDebugGroup = "Cannot pop the default debug group.";
MSG kClientBufferInvalid = "Size must not exceed the size of clientbuffer";
MSG kClientDataInVertexArray = "Client data cannot be used with a non-default vertex array object.";
Expand Down Expand Up @@ -587,6 +588,7 @@ MSG kTextureBufferInternalFormat = "Internal format is not an accepted sized int
MSG kTextureBufferInvalidBuffer = "If buffer is nonzero, it must match the name of an existing buffer object.";
MSG kTextureFormatMismatch = "Passed in texture target and format must match the one originally used to define the texture.";
MSG kTextureFoveationNotEnabled = "glTextureFoveationParametersQCOM called on a texture that does not support GL_FOVEATION_ENABLE_BIT_QCOM";
MSG kTextureIsCompressed = "Texture is compressed.";
MSG kTextureIsImmutable = "Texture is immutable.";
MSG kTextureIsNotImmutable = "Texture is not immutable.";
MSG kTextureIsNeitherImmutableNorTextureBuffer = "Texture is not the name of an immutable texture object or a buffer texture.";
Expand Down
3 changes: 2 additions & 1 deletion src/libANGLE/ImageIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ ImageIndexIterator ImageIndexIterator::MakeGeneric(TextureType type,
GLint minLayer,
GLint maxLayer)
{
if (type == TextureType::CubeMap)
if (type == TextureType::CubeMap && minLayer == ImageIndex::kEntireLevel &&
maxLayer == ImageIndex::kEntireLevel)
{
return MakeCube(minMip, maxMip);
}
Expand Down
Loading

0 comments on commit 92148c2

Please sign in to comment.