Skip to content

Commit

Permalink
Add glCompressedCopySubTextureCHROMIUM
Browse files Browse the repository at this point in the history
This CL adds a GPU command for copying sub regions of compressed textures.
The implementation is based on glCopySubTextureCHROMIUM.

BUG=434699

Review URL: https://codereview.chromium.org/1272153004

Cr-Commit-Position: refs/heads/master@{#344220}
  • Loading branch information
christiank authored and Commit bot committed Aug 19, 2015
1 parent c7da89f commit 00b2180
Show file tree
Hide file tree
Showing 26 changed files with 1,019 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Name Strings

Version

Last Modifed Date: Jun 15, 2015
Last Modifed Date: August 5, 2015

Dependencies

Expand Down Expand Up @@ -71,6 +71,48 @@ New Procedures and Functions

INVALID_VALUE is generated if level 0 of the source texture is not defined.

The command

void glCompressedCopySubTextureCHROMIUM (GLenum target,
GLenum source_id,
GLenum dest_id,
GLint xoffset, GLint yoffset,
GLint x, GLint y,
GLsizei width, GLsizei height)

Copies the sub contents of texture referred to by <source_id> to <dest_id>
texture without redefining <dest_id> texture.

<target> uses the same parameters as TexImage2D.

<xoffset> and <yoffset> specify a texel offset in the x and y direction
respectively within the destination texture.

<x> and <y> specify a texel offset in the x and y direction respectively
within the source texture.

<width> specifies the width of the texture subimage.

<height> specifies the width of the texture subimage.

INVALID_OPERATION is generated if internal format of source texture is not
one of the following: GL_ATC_RGB_AMD, GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD,
GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
GL_ETC1_RGB8_OES

INVALID_VALUE is generated if <target> is not GL_TEXTURE_2D.

INVALID_OPERATION is generated if the destination texture has not been
defined.

INVALID_VALUE is generated if level 0 of the source texture or
the destination texture is not defined.

INVALID_VALUE is generated if <xoffset> < 0 , or <yoffset> < 0.

INVALID_VALUE is generated if (<xoffset> + <width>) > dest_width,
or (<yoffset> + <height>) > dest_height.

Errors

None.
Expand All @@ -86,3 +128,4 @@ New State
Revision History

15/6/2015 Documented the extension.
5/8/2015 Added glCompressedCopySubTextureCHROMIUM.
4 changes: 2 additions & 2 deletions gpu/GLES2/extensions/CHROMIUM/CHROMIUM_copy_texture.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ New Procedures and Functions

INVALID_VALUE is generated if <xoffset> < 0 , or <yoffset> < 0.

INVALID_VALUE is generated if (<xoffset> + source_width) > dest_width,
or (<yoffset> + source_height) > dest_height.
INVALID_VALUE is generated if (<xoffset> + <width>) > dest_width,
or (<yoffset> + <height>) > dest_height.

Dependencies on ARB_texture_rg

Expand Down
2 changes: 2 additions & 0 deletions gpu/GLES2/gl2chromium_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@
#define glCopySubTextureCHROMIUM GLES2_GET_FUN(CopySubTextureCHROMIUM)
#define glCompressedCopyTextureCHROMIUM \
GLES2_GET_FUN(CompressedCopyTextureCHROMIUM)
#define glCompressedCopySubTextureCHROMIUM \
GLES2_GET_FUN(CompressedCopySubTextureCHROMIUM)
#define glDrawArraysInstancedANGLE GLES2_GET_FUN(DrawArraysInstancedANGLE)
#define glDrawElementsInstancedANGLE GLES2_GET_FUN(DrawElementsInstancedANGLE)
#define glVertexAttribDivisorANGLE GLES2_GET_FUN(VertexAttribDivisorANGLE)
Expand Down
22 changes: 22 additions & 0 deletions gpu/GLES2/gl2extchromium.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,31 @@ typedef void(GL_APIENTRYP PFNGLCOPYSUBTEXTURECHROMIUMPROC)(
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glCompressedCopyTextureCHROMIUM(
GLenum target, GLenum source_id, GLenum dest_id);

GL_APICALL void GL_APIENTRY glCompressedCopySubTextureCHROMIUM(
GLenum target,
GLenum source_id,
GLenum dest_id,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height);
#endif
typedef void(GL_APIENTRYP PFNGLCOMPRESSEDCOPYTEXTURECHROMIUMPROC)(
GLenum target, GLenum source_id, GLenum dest_id);

typedef void(GL_APIENTRYP PFNGLCOMPRESSEDCOPYSUBTEXTURECHROMIUMPROC)(
GLenum target,
GLenum source_id,
GLenum dest_id,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height);
#endif /* GL_CHROMIUM_compressed_copy_texture */

/* GL_CHROMIUM_lose_context */
Expand Down
6 changes: 6 additions & 0 deletions gpu/command_buffer/build_gles2_cmd_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3760,6 +3760,12 @@
'extension': True,
'chromium': True,
},
'CompressedCopySubTextureCHROMIUM': {
'decoder_func': 'DoCompressedCopySubTextureCHROMIUM',
'unit_test': False,
'extension': True,
'chromium': True,
},
'TexStorage2DEXT': {
'unit_test': False,
'extension': True,
Expand Down
17 changes: 17 additions & 0 deletions gpu/command_buffer/client/gles2_c_lib_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,18 @@ void GL_APIENTRY GLES2CompressedCopyTextureCHROMIUM(GLenum target,
gles2::GetGLContext()->CompressedCopyTextureCHROMIUM(target, source_id,
dest_id);
}
void GL_APIENTRY GLES2CompressedCopySubTextureCHROMIUM(GLenum target,
GLenum source_id,
GLenum dest_id,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height) {
gles2::GetGLContext()->CompressedCopySubTextureCHROMIUM(
target, source_id, dest_id, xoffset, yoffset, x, y, width, height);
}
void GL_APIENTRY GLES2DrawArraysInstancedANGLE(GLenum mode,
GLint first,
GLsizei count,
Expand Down Expand Up @@ -2640,6 +2652,11 @@ extern const NameToFunc g_gles2_function_table[] = {
"glCompressedCopyTextureCHROMIUM",
reinterpret_cast<GLES2FunctionPointer>(glCompressedCopyTextureCHROMIUM),
},
{
"glCompressedCopySubTextureCHROMIUM",
reinterpret_cast<GLES2FunctionPointer>(
glCompressedCopySubTextureCHROMIUM),
},
{
"glDrawArraysInstancedANGLE",
reinterpret_cast<GLES2FunctionPointer>(glDrawArraysInstancedANGLE),
Expand Down
16 changes: 16 additions & 0 deletions gpu/command_buffer/client/gles2_cmd_helper_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -2537,6 +2537,22 @@ void CompressedCopyTextureCHROMIUM(GLenum target,
}
}

void CompressedCopySubTextureCHROMIUM(GLenum target,
GLenum source_id,
GLenum dest_id,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height) {
gles2::cmds::CompressedCopySubTextureCHROMIUM* c =
GetCmdSpace<gles2::cmds::CompressedCopySubTextureCHROMIUM>();
if (c) {
c->Init(target, source_id, dest_id, xoffset, yoffset, x, y, width, height);
}
}

void DrawArraysInstancedANGLE(GLenum mode,
GLint first,
GLsizei count,
Expand Down
10 changes: 10 additions & 0 deletions gpu/command_buffer/client/gles2_implementation_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,16 @@ void CompressedCopyTextureCHROMIUM(GLenum target,
GLenum source_id,
GLenum dest_id) override;

void CompressedCopySubTextureCHROMIUM(GLenum target,
GLenum source_id,
GLenum dest_id,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height) override;

void DrawArraysInstancedANGLE(GLenum mode,
GLint first,
GLsizei count,
Expand Down
32 changes: 32 additions & 0 deletions gpu/command_buffer/client/gles2_implementation_impl_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -3254,6 +3254,38 @@ void GLES2Implementation::CompressedCopyTextureCHROMIUM(GLenum target,
CheckGLError();
}

void GLES2Implementation::CompressedCopySubTextureCHROMIUM(GLenum target,
GLenum source_id,
GLenum dest_id,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG("[" << GetLogPrefix()
<< "] glCompressedCopySubTextureCHROMIUM("
<< GLES2Util::GetStringEnum(target) << ", "
<< GLES2Util::GetStringEnum(source_id) << ", "
<< GLES2Util::GetStringEnum(dest_id) << ", " << xoffset
<< ", " << yoffset << ", " << x << ", " << y << ", "
<< width << ", " << height << ")");
if (width < 0) {
SetGLError(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM",
"width < 0");
return;
}
if (height < 0) {
SetGLError(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM",
"height < 0");
return;
}
helper_->CompressedCopySubTextureCHROMIUM(target, source_id, dest_id, xoffset,
yoffset, x, y, width, height);
CheckGLError();
}

void GLES2Implementation::GenValuebuffersCHROMIUM(GLsizei n, GLuint* buffers) {
GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGenValuebuffersCHROMIUM(" << n
<< ", " << static_cast<const void*>(buffers) << ")");
Expand Down
11 changes: 11 additions & 0 deletions gpu/command_buffer/client/gles2_implementation_unittest_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -2893,6 +2893,17 @@ TEST_F(GLES2ImplementationTest, CompressedCopyTextureCHROMIUM) {
EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
}

TEST_F(GLES2ImplementationTest, CompressedCopySubTextureCHROMIUM) {
struct Cmds {
cmds::CompressedCopySubTextureCHROMIUM cmd;
};
Cmds expected;
expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9);

gl_->CompressedCopySubTextureCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9);
EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
}

TEST_F(GLES2ImplementationTest, DrawArraysInstancedANGLE) {
struct Cmds {
cmds::DrawArraysInstancedANGLE cmd;
Expand Down
9 changes: 9 additions & 0 deletions gpu/command_buffer/client/gles2_interface_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,15 @@ virtual void CopySubTextureCHROMIUM(GLenum target,
virtual void CompressedCopyTextureCHROMIUM(GLenum target,
GLenum source_id,
GLenum dest_id) = 0;
virtual void CompressedCopySubTextureCHROMIUM(GLenum target,
GLenum source_id,
GLenum dest_id,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height) = 0;
virtual void DrawArraysInstancedANGLE(GLenum mode,
GLint first,
GLsizei count,
Expand Down
9 changes: 9 additions & 0 deletions gpu/command_buffer/client/gles2_interface_stub_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,15 @@ void CopySubTextureCHROMIUM(GLenum target,
void CompressedCopyTextureCHROMIUM(GLenum target,
GLenum source_id,
GLenum dest_id) override;
void CompressedCopySubTextureCHROMIUM(GLenum target,
GLenum source_id,
GLenum dest_id,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height) override;
void DrawArraysInstancedANGLE(GLenum mode,
GLint first,
GLsizei count,
Expand Down
10 changes: 10 additions & 0 deletions gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,16 @@ void GLES2InterfaceStub::CopySubTextureCHROMIUM(
void GLES2InterfaceStub::CompressedCopyTextureCHROMIUM(GLenum /* target */,
GLenum /* source_id */,
GLenum /* dest_id */) {}
void GLES2InterfaceStub::CompressedCopySubTextureCHROMIUM(
GLenum /* target */,
GLenum /* source_id */,
GLenum /* dest_id */,
GLint /* xoffset */,
GLint /* yoffset */,
GLint /* x */,
GLint /* y */,
GLsizei /* width */,
GLsizei /* height */) {}
void GLES2InterfaceStub::DrawArraysInstancedANGLE(GLenum /* mode */,
GLint /* first */,
GLsizei /* count */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,15 @@ void CopySubTextureCHROMIUM(GLenum target,
void CompressedCopyTextureCHROMIUM(GLenum target,
GLenum source_id,
GLenum dest_id) override;
void CompressedCopySubTextureCHROMIUM(GLenum target,
GLenum source_id,
GLenum dest_id,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height) override;
void DrawArraysInstancedANGLE(GLenum mode,
GLint first,
GLsizei count,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,22 @@ void GLES2TraceImplementation::CompressedCopyTextureCHROMIUM(GLenum target,
gl_->CompressedCopyTextureCHROMIUM(target, source_id, dest_id);
}

void GLES2TraceImplementation::CompressedCopySubTextureCHROMIUM(
GLenum target,
GLenum source_id,
GLenum dest_id,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height) {
TRACE_EVENT_BINARY_EFFICIENT0("gpu",
"GLES2Trace::CompressedCopySubTextureCHROMIUM");
gl_->CompressedCopySubTextureCHROMIUM(target, source_id, dest_id, xoffset,
yoffset, x, y, width, height);
}

void GLES2TraceImplementation::DrawArraysInstancedANGLE(GLenum mode,
GLint first,
GLsizei count,
Expand Down
1 change: 1 addition & 0 deletions gpu/command_buffer/cmd_buffer_functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ GL_APICALL void GL_APIENTRY glTexImageIOSurface2DCHROMIUM (GLenumTexture
GL_APICALL void GL_APIENTRY glCopyTextureCHROMIUM (GLenum target, GLenum source_id, GLenum dest_id, GLintTextureInternalFormat internalformat, GLenumPixelType dest_type, GLboolean unpack_flip_y, GLboolean unpack_premultiply_alpha, GLboolean unpack_unmultiply_alpha);
GL_APICALL void GL_APIENTRY glCopySubTextureCHROMIUM (GLenum target, GLenum source_id, GLenum dest_id, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, GLboolean unpack_flip_y, GLboolean unpack_premultiply_alpha, GLboolean unpack_unmultiply_alpha);
GL_APICALL void GL_APIENTRY glCompressedCopyTextureCHROMIUM (GLenum target, GLenum source_id, GLenum dest_id);
GL_APICALL void GL_APIENTRY glCompressedCopySubTextureCHROMIUM (GLenum target, GLenum source_id, GLenum dest_id, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenumDrawMode mode, GLint first, GLsizei count, GLsizei primcount);
GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenumDrawMode mode, GLsizei count, GLenumIndexType type, const void* indices, GLsizei primcount);
GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor);
Expand Down
Loading

0 comments on commit 00b2180

Please sign in to comment.