diff options
Diffstat (limited to 'gpu')
26 files changed, 941 insertions, 218 deletions
diff --git a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_texture_mailbox.txt b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_texture_mailbox.txt index f3c476b..9cc8c86 100644 --- a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_texture_mailbox.txt +++ b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_texture_mailbox.txt @@ -8,7 +8,7 @@ Name Strings Version - Last Modifed Date: April 25, 2012 + Last Modifed Date: June 2, 2014 Dependencies @@ -18,11 +18,12 @@ Overview This extension defines a way of sharing texture image data between texture objects in different contexts where the contexts would not normally share - texture resources. Three new functions are exported. glGenMailboxCHROMIUM + texture resources. Five new functions are exported. glGenMailboxCHROMIUM generates a name that can be used to identify texture image data outside - the scope of a context group. glProduceMailboxCHROMIUM associates a texture - object with a global mailbox name. glConsumeMailboxCHROMIUM associates the - texture object referenced by a mailbox name to a texture name. + the scope of a context group. glProduceMailboxCHROMIUM and + glProduceTextureDirectCHROMIUM associate a texture object with a global + mailbox name. glConsumeMailboxCHROMIUM and glCreateAndConsumeTextureCHROMIUM + associate the texture object referenced by a mailbox name to a texture name. New Procedures and Functions @@ -62,6 +63,17 @@ New Procedures and Functions INVALID_OPERATION is generated if <mailbox> is invalid. + void glProduceTextureDirectCHROMIUM (GLuint texture, GLenum target, + const GLbyte *mailbox) + + Associates the specified texture object with the mailbox name. Performs + identically to glProduceTextureCHROMIUM except that the texture specified by + <texture> is used instead of the currently bound texture. This operation + does not change the texture bindings or alter the bound texture in any way. + + <texture> Specifies the name of a texture. + + void glConsumeTextureCHROMIUM (GLenum target, const GLbyte *mailbox) <target> uses the same parameters as TexImage2D. @@ -95,6 +107,15 @@ New Procedures and Functions INVALID_OPERATION is generated if the currently bound texture was previously deleted (for example in another context), hence doesn't have a name. + + GLuint glCreateAndConsumeTextureCHROMIUM (GLenum target, + const GLbyte *mailbox) + + Returns a new texture name associated with the given target pointing to the + texture object associated with the mailbox name. Does not alter the texture + bindings or alter the currently bound texture in any way. Otherwise performs + identically to glConsumeTextureCHROMIUM. + New Tokens The size of a mailbox name in bytes. @@ -118,3 +139,5 @@ Revision History 4/25/2011 Documented the extension 5/23/2013 Major revision in Produce/Consume semantics, introducing sharing. + 6/02/2014 Added glProduceTextureDirectCHROMIUM and + glCreateAndConsumeTextureCHROMIUM definitions. diff --git a/gpu/GLES2/gl2chromium_autogen.h b/gpu/GLES2/gl2chromium_autogen.h index db9c6249..7f3bbee 100644 --- a/gpu/GLES2/gl2chromium_autogen.h +++ b/gpu/GLES2/gl2chromium_autogen.h @@ -216,7 +216,11 @@ #define glVertexAttribDivisorANGLE GLES2_GET_FUN(VertexAttribDivisorANGLE) #define glGenMailboxCHROMIUM GLES2_GET_FUN(GenMailboxCHROMIUM) #define glProduceTextureCHROMIUM GLES2_GET_FUN(ProduceTextureCHROMIUM) +#define glProduceTextureDirectCHROMIUM \ + GLES2_GET_FUN(ProduceTextureDirectCHROMIUM) #define glConsumeTextureCHROMIUM GLES2_GET_FUN(ConsumeTextureCHROMIUM) +#define glCreateAndConsumeTextureCHROMIUM \ + GLES2_GET_FUN(CreateAndConsumeTextureCHROMIUM) #define glBindUniformLocationCHROMIUM GLES2_GET_FUN(BindUniformLocationCHROMIUM) #define glBindTexImage2DCHROMIUM GLES2_GET_FUN(BindTexImage2DCHROMIUM) #define glReleaseTexImage2DCHROMIUM GLES2_GET_FUN(ReleaseTexImage2DCHROMIUM) diff --git a/gpu/GLES2/gl2extchromium.h b/gpu/GLES2/gl2extchromium.h index d78f8ef..0671187 100644 --- a/gpu/GLES2/gl2extchromium.h +++ b/gpu/GLES2/gl2extchromium.h @@ -55,14 +55,22 @@ typedef void (GL_APIENTRYP PFNGLTEXIMAGEIOSURFACE2DCHROMIUMPROC) ( GL_APICALL void GL_APIENTRY glGenMailboxCHROMIUM(GLbyte* mailbox); GL_APICALL void GL_APIENTRY glProduceTextureCHROMIUM( GLenum target, const GLbyte* mailbox); +GL_APICALL void GL_APIENTRY glProduceTextureDirectCHROMIUM( + GLuint texture, GLenum target, const GLbyte* mailbox); GL_APICALL void GL_APIENTRY glConsumeTextureCHROMIUM( GLenum target, const GLbyte* mailbox); +GL_APICALL GLuint GL_APIENTRY glCreateAndConsumeTextureCHROMIUM( + GLenum target, const GLbyte* mailbox); #endif typedef void (GL_APIENTRYP PFNGLGENMAILBOXCHROMIUMPROC) (GLbyte* mailbox); typedef void (GL_APIENTRYP PFNGLPRODUCETEXTURECHROMIUMPROC) ( GLenum target, const GLbyte* mailbox); +typedef void (GL_APIENTRYP PFNGLPRODUCETEXTUREDIRECTCHROMIUMPROC) ( + GLuint texture, GLenum target, const GLbyte* mailbox); typedef void (GL_APIENTRYP PFNGLCONSUMETEXTURECHROMIUMPROC) ( GLenum target, const GLbyte* mailbox); +typedef GLuint (GL_APIENTRYP PFNGLCREATEANDCONSUMETEXTURECHROMIUMPROC) ( + GLenum target, const GLbyte* mailbox); #endif /* GL_CHROMIUM_texture_mailbox */ /* GL_CHROMIUM_pixel_transfer_buffer_object */ diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index 23a9b2b..6a99981b 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -1383,6 +1383,15 @@ _FUNCTION_INFO = { 'chromium': True, 'trace_level': 1, }, + 'CreateAndConsumeTextureCHROMIUM': { + 'decoder_func': 'DoCreateAndConsumeTextureCHROMIUM', + 'impl_func': False, + 'type': 'HandWritten', + 'unit_test': False, + 'client_test': False, + 'extension': True, + 'chromium': True, + }, 'ClearStencil': { 'type': 'StateSet', 'state': 'ClearStencil', @@ -1976,6 +1985,17 @@ _FUNCTION_INFO = { 'chromium': True, 'trace_level': 1, }, + 'ProduceTextureDirectCHROMIUM': { + 'decoder_func': 'DoProduceTextureDirectCHROMIUM', + 'impl_func': False, + 'type': 'PUT', + 'count': 64, # GL_MAILBOX_SIZE_CHROMIUM + 'unit_test': False, + 'client_test': False, + 'extension': True, + 'chromium': True, + 'trace_level': 1, + }, 'RenderbufferStorage': { 'decoder_func': 'DoRenderbufferStorage', 'gl_test_func': 'glRenderbufferStorageEXT', diff --git a/gpu/command_buffer/client/gles2_c_lib_autogen.h b/gpu/command_buffer/client/gles2_c_lib_autogen.h index 6ad04d2..e810d53 100644 --- a/gpu/command_buffer/client/gles2_c_lib_autogen.h +++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h @@ -862,9 +862,19 @@ void GLES2GenMailboxCHROMIUM(GLbyte* mailbox) { void GLES2ProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) { gles2::GetGLContext()->ProduceTextureCHROMIUM(target, mailbox); } +void GLES2ProduceTextureDirectCHROMIUM(GLuint texture, + GLenum target, + const GLbyte* mailbox) { + gles2::GetGLContext()->ProduceTextureDirectCHROMIUM(texture, target, mailbox); +} void GLES2ConsumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) { gles2::GetGLContext()->ConsumeTextureCHROMIUM(target, mailbox); } +GLuint GLES2CreateAndConsumeTextureCHROMIUM(GLenum target, + const GLbyte* mailbox) { + return gles2::GetGLContext()->CreateAndConsumeTextureCHROMIUM(target, + mailbox); +} void GLES2BindUniformLocationCHROMIUM(GLuint program, GLint location, const char* name) { @@ -1667,10 +1677,18 @@ extern const NameToFunc g_gles2_function_table[] = { reinterpret_cast<GLES2FunctionPointer>(glProduceTextureCHROMIUM), }, { + "glProduceTextureDirectCHROMIUM", + reinterpret_cast<GLES2FunctionPointer>(glProduceTextureDirectCHROMIUM), + }, + { "glConsumeTextureCHROMIUM", reinterpret_cast<GLES2FunctionPointer>(glConsumeTextureCHROMIUM), }, { + "glCreateAndConsumeTextureCHROMIUM", + reinterpret_cast<GLES2FunctionPointer>(glCreateAndConsumeTextureCHROMIUM), + }, + { "glBindUniformLocationCHROMIUM", reinterpret_cast<GLES2FunctionPointer>(glBindUniformLocationCHROMIUM), }, diff --git a/gpu/command_buffer/client/gles2_cmd_helper.h b/gpu/command_buffer/client/gles2_cmd_helper.h index 72fae31..4e57cce 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper.h +++ b/gpu/command_buffer/client/gles2_cmd_helper.h @@ -70,6 +70,19 @@ class GPU_EXPORT GLES2CmdHelper : public CommandBufferHelper { } } + void CreateAndConsumeTextureCHROMIUMImmediate(GLenum target, + uint32_t client_id, + const GLbyte* _mailbox) { + const uint32_t size = + gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate::ComputeSize(); + gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate* c = + GetImmediateCmdSpaceTotalSize< + gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate>(size); + if (c) { + c->Init(target, client_id, _mailbox); + } + } + private: DISALLOW_COPY_AND_ASSIGN(GLES2CmdHelper); }; diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h index 4491f9b..f56713f 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h +++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h @@ -1725,6 +1725,19 @@ void ProduceTextureCHROMIUMImmediate(GLenum target, const GLbyte* mailbox) { } } +void ProduceTextureDirectCHROMIUMImmediate(GLuint texture, + GLenum target, + const GLbyte* mailbox) { + const uint32_t size = + gles2::cmds::ProduceTextureDirectCHROMIUMImmediate::ComputeSize(); + gles2::cmds::ProduceTextureDirectCHROMIUMImmediate* c = + GetImmediateCmdSpaceTotalSize< + gles2::cmds::ProduceTextureDirectCHROMIUMImmediate>(size); + if (c) { + c->Init(texture, target, mailbox); + } +} + void ConsumeTextureCHROMIUMImmediate(GLenum target, const GLbyte* mailbox) { const uint32_t size = gles2::cmds::ConsumeTextureCHROMIUMImmediate::ComputeSize(); diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 8f2d3f0..d6b6c97 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -3600,6 +3600,19 @@ void GLES2Implementation::ProduceTextureCHROMIUM(GLenum target, CheckGLError(); } +void GLES2Implementation::ProduceTextureDirectCHROMIUM( + GLuint texture, GLenum target, const GLbyte* data) { + GPU_CLIENT_SINGLE_THREAD_CHECK(); + GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glProduceTextureDirectCHROMIUM(" + << static_cast<const void*>(data) << ")"); + const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); + DCHECK(mailbox.Verify()) << "ProduceTextureDirectCHROMIUM was passed a " + "mailbox that was not generated by " + "GenMailboxCHROMIUM."; + helper_->ProduceTextureDirectCHROMIUMImmediate(texture, target, data); + CheckGLError(); +} + void GLES2Implementation::ConsumeTextureCHROMIUM(GLenum target, const GLbyte* data) { GPU_CLIENT_SINGLE_THREAD_CHECK(); @@ -3613,6 +3626,25 @@ void GLES2Implementation::ConsumeTextureCHROMIUM(GLenum target, CheckGLError(); } +GLuint GLES2Implementation::CreateAndConsumeTextureCHROMIUM( + GLenum target, const GLbyte* data) { + GPU_CLIENT_SINGLE_THREAD_CHECK(); + GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCreateAndConsumeTextureCHROMIUM(" + << static_cast<const void*>(data) << ")"); + const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); + DCHECK(mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was passed a " + "mailbox that was not generated by " + "GenMailboxCHROMIUM."; + GLuint client_id; + GetIdHandler(id_namespaces::kTextures)->MakeIds(this, 0, 1, &client_id); + helper_->CreateAndConsumeTextureCHROMIUMImmediate(target, + client_id, data); + if (share_group_->bind_generates_resource()) + helper_->CommandBufferHelper::Flush(); + CheckGLError(); + return client_id; +} + void GLES2Implementation::PushGroupMarkerEXT( GLsizei length, const GLchar* marker) { GPU_CLIENT_SINGLE_THREAD_CHECK(); diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index b24819b..35f1818 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -669,9 +669,16 @@ virtual void GenMailboxCHROMIUM(GLbyte* mailbox) OVERRIDE; virtual void ProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) OVERRIDE; +virtual void ProduceTextureDirectCHROMIUM(GLuint texture, + GLenum target, + const GLbyte* mailbox) OVERRIDE; + virtual void ConsumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) OVERRIDE; +virtual GLuint CreateAndConsumeTextureCHROMIUM(GLenum target, + const GLbyte* mailbox) OVERRIDE; + virtual void BindUniformLocationCHROMIUM(GLuint program, GLint location, const char* name) OVERRIDE; diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc index a35f1f9..a318ab8 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc @@ -3212,6 +3212,20 @@ TEST_F(GLES2ImplementationTest, ConsumeTextureCHROMIUM) { EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); } +TEST_F(GLES2ImplementationTest, CreateAndConsumeTextureCHROMIUM) { + struct Cmds { + cmds::CreateAndConsumeTextureCHROMIUMImmediate cmd; + GLbyte data[64]; + }; + + Mailbox mailbox = Mailbox::Generate(); + Cmds expected; + expected.cmd.Init(GL_TEXTURE_2D, kTexturesStartId, mailbox.name); + GLuint id = gl_->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); + EXPECT_EQ(kTexturesStartId, id); +} + TEST_F(GLES2ImplementationTest, ProduceTextureCHROMIUM) { struct Cmds { cmds::ProduceTextureCHROMIUMImmediate cmd; @@ -3225,6 +3239,20 @@ TEST_F(GLES2ImplementationTest, ProduceTextureCHROMIUM) { EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); } +TEST_F(GLES2ImplementationTest, ProduceTextureDirectCHROMIUM) { + struct Cmds { + cmds::ProduceTextureDirectCHROMIUMImmediate cmd; + GLbyte data[64]; + }; + + Mailbox mailbox = Mailbox::Generate(); + Cmds expected; + expected.cmd.Init(kTexturesStartId, GL_TEXTURE_2D, mailbox.name); + gl_->ProduceTextureDirectCHROMIUM( + kTexturesStartId, GL_TEXTURE_2D, mailbox.name); + EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); +} + TEST_F(GLES2ImplementationTest, LimitSizeAndOffsetTo32Bit) { GLsizeiptr size; GLintptr offset; diff --git a/gpu/command_buffer/client/gles2_interface_autogen.h b/gpu/command_buffer/client/gles2_interface_autogen.h index eee1899..75efd8b 100644 --- a/gpu/command_buffer/client/gles2_interface_autogen.h +++ b/gpu/command_buffer/client/gles2_interface_autogen.h @@ -452,7 +452,12 @@ virtual void DrawElementsInstancedANGLE(GLenum mode, virtual void VertexAttribDivisorANGLE(GLuint index, GLuint divisor) = 0; virtual void GenMailboxCHROMIUM(GLbyte* mailbox) = 0; virtual void ProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) = 0; +virtual void ProduceTextureDirectCHROMIUM(GLuint texture, + GLenum target, + const GLbyte* mailbox) = 0; virtual void ConsumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) = 0; +virtual GLuint CreateAndConsumeTextureCHROMIUM(GLenum target, + const GLbyte* mailbox) = 0; virtual void BindUniformLocationCHROMIUM(GLuint program, GLint location, const char* name) = 0; diff --git a/gpu/command_buffer/client/gles2_interface_stub_autogen.h b/gpu/command_buffer/client/gles2_interface_stub_autogen.h index 3053e3b..4a09911 100644 --- a/gpu/command_buffer/client/gles2_interface_stub_autogen.h +++ b/gpu/command_buffer/client/gles2_interface_stub_autogen.h @@ -484,8 +484,13 @@ virtual void VertexAttribDivisorANGLE(GLuint index, GLuint divisor) OVERRIDE; virtual void GenMailboxCHROMIUM(GLbyte* mailbox) OVERRIDE; virtual void ProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) OVERRIDE; +virtual void ProduceTextureDirectCHROMIUM(GLuint texture, + GLenum target, + const GLbyte* mailbox) OVERRIDE; virtual void ConsumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) OVERRIDE; +virtual GLuint CreateAndConsumeTextureCHROMIUM(GLenum target, + const GLbyte* mailbox) OVERRIDE; virtual void BindUniformLocationCHROMIUM(GLuint program, GLint location, const char* name) OVERRIDE; diff --git a/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h b/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h index 6497717..db4c0c2 100644 --- a/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h +++ b/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h @@ -779,9 +779,19 @@ void GLES2InterfaceStub::GenMailboxCHROMIUM(GLbyte* /* mailbox */) { void GLES2InterfaceStub::ProduceTextureCHROMIUM(GLenum /* target */, const GLbyte* /* mailbox */) { } +void GLES2InterfaceStub::ProduceTextureDirectCHROMIUM( + GLuint /* texture */, + GLenum /* target */, + const GLbyte* /* mailbox */) { +} void GLES2InterfaceStub::ConsumeTextureCHROMIUM(GLenum /* target */, const GLbyte* /* mailbox */) { } +GLuint GLES2InterfaceStub::CreateAndConsumeTextureCHROMIUM( + GLenum /* target */, + const GLbyte* /* mailbox */) { + return 0; +} void GLES2InterfaceStub::BindUniformLocationCHROMIUM(GLuint /* program */, GLint /* location */, const char* /* name */) { diff --git a/gpu/command_buffer/client/gles2_trace_implementation_autogen.h b/gpu/command_buffer/client/gles2_trace_implementation_autogen.h index e05fc00..22df63e 100644 --- a/gpu/command_buffer/client/gles2_trace_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_trace_implementation_autogen.h @@ -484,8 +484,13 @@ virtual void VertexAttribDivisorANGLE(GLuint index, GLuint divisor) OVERRIDE; virtual void GenMailboxCHROMIUM(GLbyte* mailbox) OVERRIDE; virtual void ProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) OVERRIDE; +virtual void ProduceTextureDirectCHROMIUM(GLuint texture, + GLenum target, + const GLbyte* mailbox) OVERRIDE; virtual void ConsumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) OVERRIDE; +virtual GLuint CreateAndConsumeTextureCHROMIUM(GLenum target, + const GLbyte* mailbox) OVERRIDE; virtual void BindUniformLocationCHROMIUM(GLuint program, GLint location, const char* name) OVERRIDE; diff --git a/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h b/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h index 988668e..2d88aee 100644 --- a/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h +++ b/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h @@ -1363,12 +1363,29 @@ void GLES2TraceImplementation::ProduceTextureCHROMIUM(GLenum target, gl_->ProduceTextureCHROMIUM(target, mailbox); } +void GLES2TraceImplementation::ProduceTextureDirectCHROMIUM( + GLuint texture, + GLenum target, + const GLbyte* mailbox) { + TRACE_EVENT_BINARY_EFFICIENT0("gpu", + "GLES2Trace::ProduceTextureDirectCHROMIUM"); + gl_->ProduceTextureDirectCHROMIUM(texture, target, mailbox); +} + void GLES2TraceImplementation::ConsumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) { TRACE_EVENT_BINARY_EFFICIENT0("gpu", "GLES2Trace::ConsumeTextureCHROMIUM"); gl_->ConsumeTextureCHROMIUM(target, mailbox); } +GLuint GLES2TraceImplementation::CreateAndConsumeTextureCHROMIUM( + GLenum target, + const GLbyte* mailbox) { + TRACE_EVENT_BINARY_EFFICIENT0("gpu", + "GLES2Trace::CreateAndConsumeTextureCHROMIUM"); + return gl_->CreateAndConsumeTextureCHROMIUM(target, mailbox); +} + void GLES2TraceImplementation::BindUniformLocationCHROMIUM(GLuint program, GLint location, const char* name) { diff --git a/gpu/command_buffer/cmd_buffer_functions.txt b/gpu/command_buffer/cmd_buffer_functions.txt index 3e38cbd..4c3aa98 100644 --- a/gpu/command_buffer/cmd_buffer_functions.txt +++ b/gpu/command_buffer/cmd_buffer_functions.txt @@ -204,7 +204,9 @@ GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenumDrawMode GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor); GL_APICALL void GL_APIENTRY glGenMailboxCHROMIUM (GLbyte* mailbox); GL_APICALL void GL_APIENTRY glProduceTextureCHROMIUM (GLenumTextureBindTarget target, const GLbyte* mailbox); +GL_APICALL void GL_APIENTRY glProduceTextureDirectCHROMIUM (GLidBindTexture texture, GLenumTextureBindTarget target, const GLbyte* mailbox); GL_APICALL void GL_APIENTRY glConsumeTextureCHROMIUM (GLenumTextureBindTarget target, const GLbyte* mailbox); +GL_APICALL GLuint GL_APIENTRY glCreateAndConsumeTextureCHROMIUM (GLenumTextureBindTarget target, const GLbyte* mailbox); GL_APICALL void GL_APIENTRY glBindUniformLocationCHROMIUM (GLidProgram program, GLint location, const char* name); GL_APICALL void GL_APIENTRY glBindTexImage2DCHROMIUM (GLenumTextureBindTarget target, GLint imageId); GL_APICALL void GL_APIENTRY glReleaseTexImage2DCHROMIUM (GLenumTextureBindTarget target, GLint imageId); diff --git a/gpu/command_buffer/common/gles2_cmd_format.h b/gpu/command_buffer/common/gles2_cmd_format.h index a541cbb..656b4b1 100644 --- a/gpu/command_buffer/common/gles2_cmd_format.h +++ b/gpu/command_buffer/common/gles2_cmd_format.h @@ -461,6 +461,57 @@ struct InsertSyncPointCHROMIUM { CommandHeader header; }; +struct CreateAndConsumeTextureCHROMIUMImmediate { + typedef CreateAndConsumeTextureCHROMIUMImmediate ValueType; + static const CommandId kCmdId = kCreateAndConsumeTextureCHROMIUMImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(1); + + static uint32_t ComputeDataSize() { + return static_cast<uint32_t>(sizeof(GLbyte) * 64); // NOLINT + } + + static uint32_t ComputeSize() { + return static_cast<uint32_t>(sizeof(ValueType) + + ComputeDataSize()); // NOLINT + } + + void SetHeader(uint32_t size_in_bytes) { + header.SetCmdByTotalSize<ValueType>(size_in_bytes); + } + + void Init(GLenum _target, uint32_t _client_id, const GLbyte* _mailbox) { + SetHeader(ComputeSize()); + target = _target; + client_id = _client_id; + memcpy(ImmediateDataAddress(this), _mailbox, ComputeDataSize()); + } + + void* Set(void* cmd, + GLenum _target, + uint32_t _client_id, + const GLbyte* _mailbox) { + static_cast<ValueType*>(cmd)->Init(_target, _client_id, _mailbox); + const uint32_t size = ComputeSize(); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + gpu::CommandHeader header; + uint32_t target; + uint32_t client_id; +}; + +COMPILE_ASSERT(sizeof(CreateAndConsumeTextureCHROMIUMImmediate) == 12, + Sizeof_CreateAndConsumeTextureCHROMIUMImmediate_is_not_12); +COMPILE_ASSERT(offsetof(CreateAndConsumeTextureCHROMIUMImmediate, header) == 0, + OffsetOf_CreateAndConsumeTextureCHROMIUMImmediate_header_not_0); +COMPILE_ASSERT(offsetof(CreateAndConsumeTextureCHROMIUMImmediate, target) == 4, + OffsetOf_CreateAndConsumeTextureCHROMIUMImmediate_target_not_4); +COMPILE_ASSERT( + offsetof(CreateAndConsumeTextureCHROMIUMImmediate, client_id) == 8, + OffsetOf_CreateAndConsumeTextureCHROMIUMImmediate_client_id_not_8); + + #pragma pack(pop) } // namespace cmd diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index c3b62dc..fe03fdf 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -8260,6 +8260,53 @@ COMPILE_ASSERT(offsetof(ProduceTextureCHROMIUMImmediate, header) == 0, COMPILE_ASSERT(offsetof(ProduceTextureCHROMIUMImmediate, target) == 4, OffsetOf_ProduceTextureCHROMIUMImmediate_target_not_4); +struct ProduceTextureDirectCHROMIUMImmediate { + typedef ProduceTextureDirectCHROMIUMImmediate ValueType; + static const CommandId kCmdId = kProduceTextureDirectCHROMIUMImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(1); + + static uint32_t ComputeDataSize() { + return static_cast<uint32_t>(sizeof(GLbyte) * 64); // NOLINT + } + + static uint32_t ComputeSize() { + return static_cast<uint32_t>(sizeof(ValueType) + + ComputeDataSize()); // NOLINT + } + + void SetHeader() { header.SetCmdByTotalSize<ValueType>(ComputeSize()); } + + void Init(GLuint _texture, GLenum _target, const GLbyte* _mailbox) { + SetHeader(); + texture = _texture; + target = _target; + memcpy(ImmediateDataAddress(this), _mailbox, ComputeDataSize()); + } + + void* Set(void* cmd, + GLuint _texture, + GLenum _target, + const GLbyte* _mailbox) { + static_cast<ValueType*>(cmd)->Init(_texture, _target, _mailbox); + const uint32_t size = ComputeSize(); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + gpu::CommandHeader header; + uint32_t texture; + uint32_t target; +}; + +COMPILE_ASSERT(sizeof(ProduceTextureDirectCHROMIUMImmediate) == 12, + Sizeof_ProduceTextureDirectCHROMIUMImmediate_is_not_12); +COMPILE_ASSERT(offsetof(ProduceTextureDirectCHROMIUMImmediate, header) == 0, + OffsetOf_ProduceTextureDirectCHROMIUMImmediate_header_not_0); +COMPILE_ASSERT(offsetof(ProduceTextureDirectCHROMIUMImmediate, texture) == 4, + OffsetOf_ProduceTextureDirectCHROMIUMImmediate_texture_not_4); +COMPILE_ASSERT(offsetof(ProduceTextureDirectCHROMIUMImmediate, target) == 8, + OffsetOf_ProduceTextureDirectCHROMIUMImmediate_target_not_8); + struct ConsumeTextureCHROMIUMImmediate { typedef ConsumeTextureCHROMIUMImmediate ValueType; static const CommandId kCmdId = kConsumeTextureCHROMIUMImmediate; diff --git a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h index e3ccc12..6df2295 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h @@ -3020,6 +3020,90 @@ TEST_F(GLES2FormatTest, ProduceTextureCHROMIUMImmediate) { // TODO(gman): Check that data was inserted; } +TEST_F(GLES2FormatTest, ProduceTextureDirectCHROMIUMImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLbyte data[] = { + static_cast<GLbyte>(kSomeBaseValueToTestWith + 0), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 1), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 2), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 3), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 4), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 5), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 6), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 7), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 8), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 9), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 10), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 11), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 12), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 13), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 14), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 15), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 16), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 17), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 18), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 19), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 20), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 21), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 22), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 23), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 24), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 25), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 26), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 27), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 28), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 29), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 30), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 31), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 32), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 33), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 34), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 35), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 36), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 37), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 38), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 39), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 40), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 41), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 42), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 43), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 44), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 45), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 46), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 47), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 48), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 49), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 50), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 51), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 52), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 53), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 54), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 55), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 56), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 57), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 58), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 59), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 60), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 61), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 62), + static_cast<GLbyte>(kSomeBaseValueToTestWith + 63), + }; + cmds::ProduceTextureDirectCHROMIUMImmediate& cmd = + *GetBufferAs<cmds::ProduceTextureDirectCHROMIUMImmediate>(); + void* next_cmd = + cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLenum>(12), data); + EXPECT_EQ(static_cast<uint32_t>( + cmds::ProduceTextureDirectCHROMIUMImmediate::kCmdId), + cmd.header.command); + EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4u); + EXPECT_EQ(static_cast<GLuint>(11), cmd.texture); + EXPECT_EQ(static_cast<GLenum>(12), cmd.target); + CheckBytesWrittenMatchesExpectedSize( + next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); + // TODO(gman): Check that data was inserted; +} + TEST_F(GLES2FormatTest, ConsumeTextureCHROMIUMImmediate) { const int kSomeBaseValueToTestWith = 51; static GLbyte data[] = { @@ -3102,6 +3186,7 @@ TEST_F(GLES2FormatTest, ConsumeTextureCHROMIUMImmediate) { // TODO(gman): Check that data was inserted; } +// TODO(gman): Write test for CreateAndConsumeTextureCHROMIUMImmediate TEST_F(GLES2FormatTest, BindUniformLocationCHROMIUM) { cmds::BindUniformLocationCHROMIUM& cmd = *GetBufferAs<cmds::BindUniformLocationCHROMIUM>(); diff --git a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h index c10d829..824ceb2 100644 --- a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h @@ -11,209 +11,211 @@ #ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_IDS_AUTOGEN_H_ #define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_IDS_AUTOGEN_H_ -#define GLES2_COMMAND_LIST(OP) \ - OP(ActiveTexture) /* 256 */ \ - OP(AttachShader) /* 257 */ \ - OP(BindAttribLocation) /* 258 */ \ - OP(BindAttribLocationBucket) /* 259 */ \ - OP(BindBuffer) /* 260 */ \ - OP(BindFramebuffer) /* 261 */ \ - OP(BindRenderbuffer) /* 262 */ \ - OP(BindTexture) /* 263 */ \ - OP(BlendColor) /* 264 */ \ - OP(BlendEquation) /* 265 */ \ - OP(BlendEquationSeparate) /* 266 */ \ - OP(BlendFunc) /* 267 */ \ - OP(BlendFuncSeparate) /* 268 */ \ - OP(BufferData) /* 269 */ \ - OP(BufferSubData) /* 270 */ \ - OP(CheckFramebufferStatus) /* 271 */ \ - OP(Clear) /* 272 */ \ - OP(ClearColor) /* 273 */ \ - OP(ClearDepthf) /* 274 */ \ - OP(ClearStencil) /* 275 */ \ - OP(ColorMask) /* 276 */ \ - OP(CompileShader) /* 277 */ \ - OP(CompressedTexImage2D) /* 278 */ \ - OP(CompressedTexImage2DBucket) /* 279 */ \ - OP(CompressedTexSubImage2D) /* 280 */ \ - OP(CompressedTexSubImage2DBucket) /* 281 */ \ - OP(CopyTexImage2D) /* 282 */ \ - OP(CopyTexSubImage2D) /* 283 */ \ - OP(CreateProgram) /* 284 */ \ - OP(CreateShader) /* 285 */ \ - OP(CullFace) /* 286 */ \ - OP(DeleteBuffersImmediate) /* 287 */ \ - OP(DeleteFramebuffersImmediate) /* 288 */ \ - OP(DeleteProgram) /* 289 */ \ - OP(DeleteRenderbuffersImmediate) /* 290 */ \ - OP(DeleteShader) /* 291 */ \ - OP(DeleteTexturesImmediate) /* 292 */ \ - OP(DepthFunc) /* 293 */ \ - OP(DepthMask) /* 294 */ \ - OP(DepthRangef) /* 295 */ \ - OP(DetachShader) /* 296 */ \ - OP(Disable) /* 297 */ \ - OP(DisableVertexAttribArray) /* 298 */ \ - OP(DrawArrays) /* 299 */ \ - OP(DrawElements) /* 300 */ \ - OP(Enable) /* 301 */ \ - OP(EnableVertexAttribArray) /* 302 */ \ - OP(Finish) /* 303 */ \ - OP(Flush) /* 304 */ \ - OP(FramebufferRenderbuffer) /* 305 */ \ - OP(FramebufferTexture2D) /* 306 */ \ - OP(FrontFace) /* 307 */ \ - OP(GenBuffersImmediate) /* 308 */ \ - OP(GenerateMipmap) /* 309 */ \ - OP(GenFramebuffersImmediate) /* 310 */ \ - OP(GenRenderbuffersImmediate) /* 311 */ \ - OP(GenTexturesImmediate) /* 312 */ \ - OP(GetActiveAttrib) /* 313 */ \ - OP(GetActiveUniform) /* 314 */ \ - OP(GetAttachedShaders) /* 315 */ \ - OP(GetAttribLocation) /* 316 */ \ - OP(GetAttribLocationBucket) /* 317 */ \ - OP(GetBooleanv) /* 318 */ \ - OP(GetBufferParameteriv) /* 319 */ \ - OP(GetError) /* 320 */ \ - OP(GetFloatv) /* 321 */ \ - OP(GetFramebufferAttachmentParameteriv) /* 322 */ \ - OP(GetIntegerv) /* 323 */ \ - OP(GetProgramiv) /* 324 */ \ - OP(GetProgramInfoLog) /* 325 */ \ - OP(GetRenderbufferParameteriv) /* 326 */ \ - OP(GetShaderiv) /* 327 */ \ - OP(GetShaderInfoLog) /* 328 */ \ - OP(GetShaderPrecisionFormat) /* 329 */ \ - OP(GetShaderSource) /* 330 */ \ - OP(GetString) /* 331 */ \ - OP(GetTexParameterfv) /* 332 */ \ - OP(GetTexParameteriv) /* 333 */ \ - OP(GetUniformfv) /* 334 */ \ - OP(GetUniformiv) /* 335 */ \ - OP(GetUniformLocation) /* 336 */ \ - OP(GetUniformLocationBucket) /* 337 */ \ - OP(GetVertexAttribfv) /* 338 */ \ - OP(GetVertexAttribiv) /* 339 */ \ - OP(GetVertexAttribPointerv) /* 340 */ \ - OP(Hint) /* 341 */ \ - OP(IsBuffer) /* 342 */ \ - OP(IsEnabled) /* 343 */ \ - OP(IsFramebuffer) /* 344 */ \ - OP(IsProgram) /* 345 */ \ - OP(IsRenderbuffer) /* 346 */ \ - OP(IsShader) /* 347 */ \ - OP(IsTexture) /* 348 */ \ - OP(LineWidth) /* 349 */ \ - OP(LinkProgram) /* 350 */ \ - OP(PixelStorei) /* 351 */ \ - OP(PolygonOffset) /* 352 */ \ - OP(ReadPixels) /* 353 */ \ - OP(ReleaseShaderCompiler) /* 354 */ \ - OP(RenderbufferStorage) /* 355 */ \ - OP(SampleCoverage) /* 356 */ \ - OP(Scissor) /* 357 */ \ - OP(ShaderBinary) /* 358 */ \ - OP(ShaderSource) /* 359 */ \ - OP(ShaderSourceBucket) /* 360 */ \ - OP(StencilFunc) /* 361 */ \ - OP(StencilFuncSeparate) /* 362 */ \ - OP(StencilMask) /* 363 */ \ - OP(StencilMaskSeparate) /* 364 */ \ - OP(StencilOp) /* 365 */ \ - OP(StencilOpSeparate) /* 366 */ \ - OP(TexImage2D) /* 367 */ \ - OP(TexParameterf) /* 368 */ \ - OP(TexParameterfvImmediate) /* 369 */ \ - OP(TexParameteri) /* 370 */ \ - OP(TexParameterivImmediate) /* 371 */ \ - OP(TexSubImage2D) /* 372 */ \ - OP(Uniform1f) /* 373 */ \ - OP(Uniform1fvImmediate) /* 374 */ \ - OP(Uniform1i) /* 375 */ \ - OP(Uniform1ivImmediate) /* 376 */ \ - OP(Uniform2f) /* 377 */ \ - OP(Uniform2fvImmediate) /* 378 */ \ - OP(Uniform2i) /* 379 */ \ - OP(Uniform2ivImmediate) /* 380 */ \ - OP(Uniform3f) /* 381 */ \ - OP(Uniform3fvImmediate) /* 382 */ \ - OP(Uniform3i) /* 383 */ \ - OP(Uniform3ivImmediate) /* 384 */ \ - OP(Uniform4f) /* 385 */ \ - OP(Uniform4fvImmediate) /* 386 */ \ - OP(Uniform4i) /* 387 */ \ - OP(Uniform4ivImmediate) /* 388 */ \ - OP(UniformMatrix2fvImmediate) /* 389 */ \ - OP(UniformMatrix3fvImmediate) /* 390 */ \ - OP(UniformMatrix4fvImmediate) /* 391 */ \ - OP(UseProgram) /* 392 */ \ - OP(ValidateProgram) /* 393 */ \ - OP(VertexAttrib1f) /* 394 */ \ - OP(VertexAttrib1fvImmediate) /* 395 */ \ - OP(VertexAttrib2f) /* 396 */ \ - OP(VertexAttrib2fvImmediate) /* 397 */ \ - OP(VertexAttrib3f) /* 398 */ \ - OP(VertexAttrib3fvImmediate) /* 399 */ \ - OP(VertexAttrib4f) /* 400 */ \ - OP(VertexAttrib4fvImmediate) /* 401 */ \ - OP(VertexAttribPointer) /* 402 */ \ - OP(Viewport) /* 403 */ \ - OP(BlitFramebufferCHROMIUM) /* 404 */ \ - OP(RenderbufferStorageMultisampleCHROMIUM) /* 405 */ \ - OP(RenderbufferStorageMultisampleEXT) /* 406 */ \ - OP(FramebufferTexture2DMultisampleEXT) /* 407 */ \ - OP(TexStorage2DEXT) /* 408 */ \ - OP(GenQueriesEXTImmediate) /* 409 */ \ - OP(DeleteQueriesEXTImmediate) /* 410 */ \ - OP(BeginQueryEXT) /* 411 */ \ - OP(EndQueryEXT) /* 412 */ \ - OP(InsertEventMarkerEXT) /* 413 */ \ - OP(PushGroupMarkerEXT) /* 414 */ \ - OP(PopGroupMarkerEXT) /* 415 */ \ - OP(GenVertexArraysOESImmediate) /* 416 */ \ - OP(DeleteVertexArraysOESImmediate) /* 417 */ \ - OP(IsVertexArrayOES) /* 418 */ \ - OP(BindVertexArrayOES) /* 419 */ \ - OP(SwapBuffers) /* 420 */ \ - OP(GetMaxValueInBufferCHROMIUM) /* 421 */ \ - OP(GenSharedIdsCHROMIUM) /* 422 */ \ - OP(DeleteSharedIdsCHROMIUM) /* 423 */ \ - OP(RegisterSharedIdsCHROMIUM) /* 424 */ \ - OP(EnableFeatureCHROMIUM) /* 425 */ \ - OP(ResizeCHROMIUM) /* 426 */ \ - OP(GetRequestableExtensionsCHROMIUM) /* 427 */ \ - OP(RequestExtensionCHROMIUM) /* 428 */ \ - OP(GetMultipleIntegervCHROMIUM) /* 429 */ \ - OP(GetProgramInfoCHROMIUM) /* 430 */ \ - OP(GetTranslatedShaderSourceANGLE) /* 431 */ \ - OP(PostSubBufferCHROMIUM) /* 432 */ \ - OP(TexImageIOSurface2DCHROMIUM) /* 433 */ \ - OP(CopyTextureCHROMIUM) /* 434 */ \ - OP(DrawArraysInstancedANGLE) /* 435 */ \ - OP(DrawElementsInstancedANGLE) /* 436 */ \ - OP(VertexAttribDivisorANGLE) /* 437 */ \ - OP(GenMailboxCHROMIUM) /* 438 */ \ - OP(ProduceTextureCHROMIUMImmediate) /* 439 */ \ - OP(ConsumeTextureCHROMIUMImmediate) /* 440 */ \ - OP(BindUniformLocationCHROMIUM) /* 441 */ \ - OP(BindUniformLocationCHROMIUMBucket) /* 442 */ \ - OP(BindTexImage2DCHROMIUM) /* 443 */ \ - OP(ReleaseTexImage2DCHROMIUM) /* 444 */ \ - OP(TraceBeginCHROMIUM) /* 445 */ \ - OP(TraceEndCHROMIUM) /* 446 */ \ - OP(AsyncTexSubImage2DCHROMIUM) /* 447 */ \ - OP(AsyncTexImage2DCHROMIUM) /* 448 */ \ - OP(WaitAsyncTexImage2DCHROMIUM) /* 449 */ \ - OP(WaitAllAsyncTexImage2DCHROMIUM) /* 450 */ \ - OP(DiscardFramebufferEXTImmediate) /* 451 */ \ - OP(LoseContextCHROMIUM) /* 452 */ \ - OP(InsertSyncPointCHROMIUM) /* 453 */ \ - OP(WaitSyncPointCHROMIUM) /* 454 */ \ - OP(DrawBuffersEXTImmediate) /* 455 */ \ - OP(DiscardBackbufferCHROMIUM) /* 456 */ \ - OP(ScheduleOverlayPlaneCHROMIUM) /* 457 */ +#define GLES2_COMMAND_LIST(OP) \ + OP(ActiveTexture) /* 256 */ \ + OP(AttachShader) /* 257 */ \ + OP(BindAttribLocation) /* 258 */ \ + OP(BindAttribLocationBucket) /* 259 */ \ + OP(BindBuffer) /* 260 */ \ + OP(BindFramebuffer) /* 261 */ \ + OP(BindRenderbuffer) /* 262 */ \ + OP(BindTexture) /* 263 */ \ + OP(BlendColor) /* 264 */ \ + OP(BlendEquation) /* 265 */ \ + OP(BlendEquationSeparate) /* 266 */ \ + OP(BlendFunc) /* 267 */ \ + OP(BlendFuncSeparate) /* 268 */ \ + OP(BufferData) /* 269 */ \ + OP(BufferSubData) /* 270 */ \ + OP(CheckFramebufferStatus) /* 271 */ \ + OP(Clear) /* 272 */ \ + OP(ClearColor) /* 273 */ \ + OP(ClearDepthf) /* 274 */ \ + OP(ClearStencil) /* 275 */ \ + OP(ColorMask) /* 276 */ \ + OP(CompileShader) /* 277 */ \ + OP(CompressedTexImage2D) /* 278 */ \ + OP(CompressedTexImage2DBucket) /* 279 */ \ + OP(CompressedTexSubImage2D) /* 280 */ \ + OP(CompressedTexSubImage2DBucket) /* 281 */ \ + OP(CopyTexImage2D) /* 282 */ \ + OP(CopyTexSubImage2D) /* 283 */ \ + OP(CreateProgram) /* 284 */ \ + OP(CreateShader) /* 285 */ \ + OP(CullFace) /* 286 */ \ + OP(DeleteBuffersImmediate) /* 287 */ \ + OP(DeleteFramebuffersImmediate) /* 288 */ \ + OP(DeleteProgram) /* 289 */ \ + OP(DeleteRenderbuffersImmediate) /* 290 */ \ + OP(DeleteShader) /* 291 */ \ + OP(DeleteTexturesImmediate) /* 292 */ \ + OP(DepthFunc) /* 293 */ \ + OP(DepthMask) /* 294 */ \ + OP(DepthRangef) /* 295 */ \ + OP(DetachShader) /* 296 */ \ + OP(Disable) /* 297 */ \ + OP(DisableVertexAttribArray) /* 298 */ \ + OP(DrawArrays) /* 299 */ \ + OP(DrawElements) /* 300 */ \ + OP(Enable) /* 301 */ \ + OP(EnableVertexAttribArray) /* 302 */ \ + OP(Finish) /* 303 */ \ + OP(Flush) /* 304 */ \ + OP(FramebufferRenderbuffer) /* 305 */ \ + OP(FramebufferTexture2D) /* 306 */ \ + OP(FrontFace) /* 307 */ \ + OP(GenBuffersImmediate) /* 308 */ \ + OP(GenerateMipmap) /* 309 */ \ + OP(GenFramebuffersImmediate) /* 310 */ \ + OP(GenRenderbuffersImmediate) /* 311 */ \ + OP(GenTexturesImmediate) /* 312 */ \ + OP(GetActiveAttrib) /* 313 */ \ + OP(GetActiveUniform) /* 314 */ \ + OP(GetAttachedShaders) /* 315 */ \ + OP(GetAttribLocation) /* 316 */ \ + OP(GetAttribLocationBucket) /* 317 */ \ + OP(GetBooleanv) /* 318 */ \ + OP(GetBufferParameteriv) /* 319 */ \ + OP(GetError) /* 320 */ \ + OP(GetFloatv) /* 321 */ \ + OP(GetFramebufferAttachmentParameteriv) /* 322 */ \ + OP(GetIntegerv) /* 323 */ \ + OP(GetProgramiv) /* 324 */ \ + OP(GetProgramInfoLog) /* 325 */ \ + OP(GetRenderbufferParameteriv) /* 326 */ \ + OP(GetShaderiv) /* 327 */ \ + OP(GetShaderInfoLog) /* 328 */ \ + OP(GetShaderPrecisionFormat) /* 329 */ \ + OP(GetShaderSource) /* 330 */ \ + OP(GetString) /* 331 */ \ + OP(GetTexParameterfv) /* 332 */ \ + OP(GetTexParameteriv) /* 333 */ \ + OP(GetUniformfv) /* 334 */ \ + OP(GetUniformiv) /* 335 */ \ + OP(GetUniformLocation) /* 336 */ \ + OP(GetUniformLocationBucket) /* 337 */ \ + OP(GetVertexAttribfv) /* 338 */ \ + OP(GetVertexAttribiv) /* 339 */ \ + OP(GetVertexAttribPointerv) /* 340 */ \ + OP(Hint) /* 341 */ \ + OP(IsBuffer) /* 342 */ \ + OP(IsEnabled) /* 343 */ \ + OP(IsFramebuffer) /* 344 */ \ + OP(IsProgram) /* 345 */ \ + OP(IsRenderbuffer) /* 346 */ \ + OP(IsShader) /* 347 */ \ + OP(IsTexture) /* 348 */ \ + OP(LineWidth) /* 349 */ \ + OP(LinkProgram) /* 350 */ \ + OP(PixelStorei) /* 351 */ \ + OP(PolygonOffset) /* 352 */ \ + OP(ReadPixels) /* 353 */ \ + OP(ReleaseShaderCompiler) /* 354 */ \ + OP(RenderbufferStorage) /* 355 */ \ + OP(SampleCoverage) /* 356 */ \ + OP(Scissor) /* 357 */ \ + OP(ShaderBinary) /* 358 */ \ + OP(ShaderSource) /* 359 */ \ + OP(ShaderSourceBucket) /* 360 */ \ + OP(StencilFunc) /* 361 */ \ + OP(StencilFuncSeparate) /* 362 */ \ + OP(StencilMask) /* 363 */ \ + OP(StencilMaskSeparate) /* 364 */ \ + OP(StencilOp) /* 365 */ \ + OP(StencilOpSeparate) /* 366 */ \ + OP(TexImage2D) /* 367 */ \ + OP(TexParameterf) /* 368 */ \ + OP(TexParameterfvImmediate) /* 369 */ \ + OP(TexParameteri) /* 370 */ \ + OP(TexParameterivImmediate) /* 371 */ \ + OP(TexSubImage2D) /* 372 */ \ + OP(Uniform1f) /* 373 */ \ + OP(Uniform1fvImmediate) /* 374 */ \ + OP(Uniform1i) /* 375 */ \ + OP(Uniform1ivImmediate) /* 376 */ \ + OP(Uniform2f) /* 377 */ \ + OP(Uniform2fvImmediate) /* 378 */ \ + OP(Uniform2i) /* 379 */ \ + OP(Uniform2ivImmediate) /* 380 */ \ + OP(Uniform3f) /* 381 */ \ + OP(Uniform3fvImmediate) /* 382 */ \ + OP(Uniform3i) /* 383 */ \ + OP(Uniform3ivImmediate) /* 384 */ \ + OP(Uniform4f) /* 385 */ \ + OP(Uniform4fvImmediate) /* 386 */ \ + OP(Uniform4i) /* 387 */ \ + OP(Uniform4ivImmediate) /* 388 */ \ + OP(UniformMatrix2fvImmediate) /* 389 */ \ + OP(UniformMatrix3fvImmediate) /* 390 */ \ + OP(UniformMatrix4fvImmediate) /* 391 */ \ + OP(UseProgram) /* 392 */ \ + OP(ValidateProgram) /* 393 */ \ + OP(VertexAttrib1f) /* 394 */ \ + OP(VertexAttrib1fvImmediate) /* 395 */ \ + OP(VertexAttrib2f) /* 396 */ \ + OP(VertexAttrib2fvImmediate) /* 397 */ \ + OP(VertexAttrib3f) /* 398 */ \ + OP(VertexAttrib3fvImmediate) /* 399 */ \ + OP(VertexAttrib4f) /* 400 */ \ + OP(VertexAttrib4fvImmediate) /* 401 */ \ + OP(VertexAttribPointer) /* 402 */ \ + OP(Viewport) /* 403 */ \ + OP(BlitFramebufferCHROMIUM) /* 404 */ \ + OP(RenderbufferStorageMultisampleCHROMIUM) /* 405 */ \ + OP(RenderbufferStorageMultisampleEXT) /* 406 */ \ + OP(FramebufferTexture2DMultisampleEXT) /* 407 */ \ + OP(TexStorage2DEXT) /* 408 */ \ + OP(GenQueriesEXTImmediate) /* 409 */ \ + OP(DeleteQueriesEXTImmediate) /* 410 */ \ + OP(BeginQueryEXT) /* 411 */ \ + OP(EndQueryEXT) /* 412 */ \ + OP(InsertEventMarkerEXT) /* 413 */ \ + OP(PushGroupMarkerEXT) /* 414 */ \ + OP(PopGroupMarkerEXT) /* 415 */ \ + OP(GenVertexArraysOESImmediate) /* 416 */ \ + OP(DeleteVertexArraysOESImmediate) /* 417 */ \ + OP(IsVertexArrayOES) /* 418 */ \ + OP(BindVertexArrayOES) /* 419 */ \ + OP(SwapBuffers) /* 420 */ \ + OP(GetMaxValueInBufferCHROMIUM) /* 421 */ \ + OP(GenSharedIdsCHROMIUM) /* 422 */ \ + OP(DeleteSharedIdsCHROMIUM) /* 423 */ \ + OP(RegisterSharedIdsCHROMIUM) /* 424 */ \ + OP(EnableFeatureCHROMIUM) /* 425 */ \ + OP(ResizeCHROMIUM) /* 426 */ \ + OP(GetRequestableExtensionsCHROMIUM) /* 427 */ \ + OP(RequestExtensionCHROMIUM) /* 428 */ \ + OP(GetMultipleIntegervCHROMIUM) /* 429 */ \ + OP(GetProgramInfoCHROMIUM) /* 430 */ \ + OP(GetTranslatedShaderSourceANGLE) /* 431 */ \ + OP(PostSubBufferCHROMIUM) /* 432 */ \ + OP(TexImageIOSurface2DCHROMIUM) /* 433 */ \ + OP(CopyTextureCHROMIUM) /* 434 */ \ + OP(DrawArraysInstancedANGLE) /* 435 */ \ + OP(DrawElementsInstancedANGLE) /* 436 */ \ + OP(VertexAttribDivisorANGLE) /* 437 */ \ + OP(GenMailboxCHROMIUM) /* 438 */ \ + OP(ProduceTextureCHROMIUMImmediate) /* 439 */ \ + OP(ProduceTextureDirectCHROMIUMImmediate) /* 440 */ \ + OP(ConsumeTextureCHROMIUMImmediate) /* 441 */ \ + OP(CreateAndConsumeTextureCHROMIUMImmediate) /* 442 */ \ + OP(BindUniformLocationCHROMIUM) /* 443 */ \ + OP(BindUniformLocationCHROMIUMBucket) /* 444 */ \ + OP(BindTexImage2DCHROMIUM) /* 445 */ \ + OP(ReleaseTexImage2DCHROMIUM) /* 446 */ \ + OP(TraceBeginCHROMIUM) /* 447 */ \ + OP(TraceEndCHROMIUM) /* 448 */ \ + OP(AsyncTexSubImage2DCHROMIUM) /* 449 */ \ + OP(AsyncTexImage2DCHROMIUM) /* 450 */ \ + OP(WaitAsyncTexImage2DCHROMIUM) /* 451 */ \ + OP(WaitAllAsyncTexImage2DCHROMIUM) /* 452 */ \ + OP(DiscardFramebufferEXTImmediate) /* 453 */ \ + OP(LoseContextCHROMIUM) /* 454 */ \ + OP(InsertSyncPointCHROMIUM) /* 455 */ \ + OP(WaitSyncPointCHROMIUM) /* 456 */ \ + OP(DrawBuffersEXTImmediate) /* 457 */ \ + OP(DiscardBackbufferCHROMIUM) /* 458 */ \ + OP(ScheduleOverlayPlaneCHROMIUM) /* 459 */ enum CommandId { kStartPoint = cmd::kLastCommonId, // All GLES2 commands start after this. diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index f954189..f14058d 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -937,7 +937,14 @@ class GLES2DecoderImpl : public GLES2Decoder, GLsizei height); void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); + void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, + const GLbyte* key); + void ProduceTextureRef(std::string func_name, TextureRef* texture_ref, + GLenum target, const GLbyte* data); + void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); + void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key, + GLuint client_id); void DoBindTexImage2DCHROMIUM( GLenum target, @@ -10197,25 +10204,44 @@ void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, "context", logger_.GetLogPrefix(), "mailbox[0]", static_cast<unsigned char>(data[0])); + TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( + &state_, target); + ProduceTextureRef("glProduceTextureCHROMIUM", texture_ref, target, data); +} + +void GLES2DecoderImpl::DoProduceTextureDirectCHROMIUM(GLuint client_id, + GLenum target, const GLbyte* data) { + TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureDirectCHROMIUM", + "context", logger_.GetLogPrefix(), + "mailbox[0]", static_cast<unsigned char>(data[0])); + + ProduceTextureRef("glProduceTextureDirectCHROMIUM", GetTexture(client_id), + target, data); +} + +void GLES2DecoderImpl::ProduceTextureRef(std::string func_name, + TextureRef* texture_ref, GLenum target, const GLbyte* data) { const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); - DLOG_IF(ERROR, !mailbox.Verify()) << "ProduceTextureCHROMIUM was passed a " + DLOG_IF(ERROR, !mailbox.Verify()) << func_name << " was passed a " "mailbox that was not generated by " "GenMailboxCHROMIUM."; - TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( - &state_, target); if (!texture_ref) { LOCAL_SET_GL_ERROR( - GL_INVALID_OPERATION, - "glProduceTextureCHROMIUM", "unknown texture for target"); + GL_INVALID_OPERATION, func_name.c_str(), "unknown texture for target"); return; } Texture* produced = texture_manager()->Produce(texture_ref); if (!produced) { LOCAL_SET_GL_ERROR( - GL_INVALID_OPERATION, - "glProduceTextureCHROMIUM", "invalid texture"); + GL_INVALID_OPERATION, func_name.c_str(), "invalid texture"); + return; + } + + if (produced->target() != target) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, func_name.c_str(), "invalid target"); return; } @@ -10286,6 +10312,70 @@ void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, } } +error::Error GLES2DecoderImpl::HandleCreateAndConsumeTextureCHROMIUMImmediate( + uint32_t immediate_data_size, + const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate& c) { + GLenum target = static_cast<GLenum>(c.target); + uint32_t data_size; + if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) { + return error::kOutOfBounds; + } + if (data_size > immediate_data_size) { + return error::kOutOfBounds; + } + const GLbyte* mailbox = + GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size); + if (!validators_->texture_bind_target.IsValid(target)) { + LOCAL_SET_GL_ERROR_INVALID_ENUM( + "glCreateAndConsumeTextureCHROMIUM", target, "target"); + return error::kNoError; + } + if (mailbox == NULL) { + return error::kOutOfBounds; + } + uint32_t client_id = c.client_id; + DoCreateAndConsumeTextureCHROMIUM(target, mailbox, client_id); + return error::kNoError; +} + +void GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM(GLenum target, + const GLbyte* data, GLuint client_id) { + TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM", + "context", logger_.GetLogPrefix(), + "mailbox[0]", static_cast<unsigned char>(data[0])); + const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); + DLOG_IF(ERROR, !mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was " + "passed a mailbox that was not " + "generated by GenMailboxCHROMIUM."; + + TextureRef* texture_ref = GetTexture(client_id); + if (texture_ref) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, + "glCreateAndConsumeTextureCHROMIUM", "client id already in use"); + return; + } + Texture* texture = group_->mailbox_manager()->ConsumeTexture(target, mailbox); + if (!texture) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, + "glCreateAndConsumeTextureCHROMIUM", "invalid mailbox name"); + return; + } + if (texture->target() != target) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, + "glCreateAndConsumeTextureCHROMIUM", "invalid target"); + return; + } + + IdAllocatorInterface* id_allocator = + group_->GetIdAllocator(id_namespaces::kTextures); + id_allocator->MarkAsUsed(client_id); + + texture_ref = texture_manager()->Consume(client_id, texture); +} + void GLES2DecoderImpl::DoInsertEventMarkerEXT( GLsizei length, const GLchar* marker) { if (!marker) { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index edf5a57..8011ab1 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -2694,6 +2694,32 @@ error::Error GLES2DecoderImpl::HandleProduceTextureCHROMIUMImmediate( return error::kNoError; } +error::Error GLES2DecoderImpl::HandleProduceTextureDirectCHROMIUMImmediate( + uint32_t immediate_data_size, + const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate& c) { + GLuint texture = c.texture; + GLenum target = static_cast<GLenum>(c.target); + uint32_t data_size; + if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) { + return error::kOutOfBounds; + } + if (data_size > immediate_data_size) { + return error::kOutOfBounds; + } + const GLbyte* mailbox = + GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size); + if (!validators_->texture_bind_target.IsValid(target)) { + LOCAL_SET_GL_ERROR_INVALID_ENUM( + "glProduceTextureDirectCHROMIUM", target, "target"); + return error::kNoError; + } + if (mailbox == NULL) { + return error::kOutOfBounds; + } + DoProduceTextureDirectCHROMIUM(texture, target, mailbox); + return error::kNoError; +} + error::Error GLES2DecoderImpl::HandleConsumeTextureCHROMIUMImmediate( uint32_t immediate_data_size, const gles2::cmds::ConsumeTextureCHROMIUMImmediate& c) { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h index 80dc8f7..cbff801 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h @@ -746,7 +746,9 @@ TEST_P(GLES2DecoderTest2, PopGroupMarkerEXTValidArgs) { // TODO(gman): GenMailboxCHROMIUM // TODO(gman): ProduceTextureCHROMIUMImmediate +// TODO(gman): ProduceTextureDirectCHROMIUMImmediate // TODO(gman): ConsumeTextureCHROMIUMImmediate +// TODO(gman): CreateAndConsumeTextureCHROMIUMImmediate // TODO(gman): BindUniformLocationCHROMIUM // TODO(gman): BindUniformLocationCHROMIUMBucket @@ -761,7 +763,4 @@ TEST_P(GLES2DecoderTest2, PopGroupMarkerEXTValidArgs) { // TODO(gman): WaitAsyncTexImage2DCHROMIUM -// TODO(gman): WaitAllAsyncTexImage2DCHROMIUM - -// TODO(gman): DiscardFramebufferEXTImmediate #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_ diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h index 1c98b68..ce869a4 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h @@ -12,6 +12,9 @@ #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_3_AUTOGEN_H_ #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_3_AUTOGEN_H_ +// TODO(gman): WaitAllAsyncTexImage2DCHROMIUM + +// TODO(gman): DiscardFramebufferEXTImmediate // TODO(gman): LoseContextCHROMIUM // TODO(gman): InsertSyncPointCHROMIUM diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc index 5e6a0d4..6761813 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc @@ -1931,6 +1931,106 @@ TEST_P(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) { EXPECT_EQ(kServiceTextureId, texture->service_id()); } +TEST_P(GLES2DecoderTest, ProduceAndConsumeDirectTextureCHROMIUM) { + Mailbox mailbox = Mailbox::Generate(); + + DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); + DoTexImage2D( + GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); + DoTexImage2D( + GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); + TextureRef* texture_ref = + group().texture_manager()->GetTexture(client_texture_id_); + ASSERT_TRUE(texture_ref != NULL); + Texture* texture = texture_ref->texture(); + EXPECT_EQ(kServiceTextureId, texture->service_id()); + + ProduceTextureDirectCHROMIUMImmediate& produce_cmd = + *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>(); + produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name); + EXPECT_EQ(error::kNoError, + ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + + // Texture didn't change. + GLsizei width; + GLsizei height; + GLenum type; + GLenum internal_format; + + EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); + EXPECT_EQ(3, width); + EXPECT_EQ(1, height); + EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); + EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); + EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); + + EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); + EXPECT_EQ(2, width); + EXPECT_EQ(4, height); + EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); + EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); + EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); + + // Service ID has not changed. + EXPECT_EQ(kServiceTextureId, texture->service_id()); + + // Consume the texture into a new client ID. + GLuint new_texture_id = kNewClientId; + CreateAndConsumeTextureCHROMIUMImmediate& consume_cmd = + *GetImmediateAs<CreateAndConsumeTextureCHROMIUMImmediate>(); + consume_cmd.Init(GL_TEXTURE_2D, new_texture_id, mailbox.name); + EXPECT_EQ(error::kNoError, + ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name))); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + + // Make sure the new client ID is associated with the produced service ID. + texture_ref = group().texture_manager()->GetTexture(new_texture_id); + ASSERT_TRUE(texture_ref != NULL); + texture = texture_ref->texture(); + EXPECT_EQ(kServiceTextureId, texture->service_id()); + + DoBindTexture(GL_TEXTURE_2D, kNewClientId, kServiceTextureId); + + // Texture is redefined. + EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); + EXPECT_EQ(3, width); + EXPECT_EQ(1, height); + EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); + EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); + EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); + + EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); + EXPECT_EQ(2, width); + EXPECT_EQ(4, height); + EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); + EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); + EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); +} + +TEST_P(GLES2DecoderTest, ProduceTextureCHROMIUMInvalidTarget) { + Mailbox mailbox = Mailbox::Generate(); + + DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); + DoTexImage2D( + GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 3, 1, 0, GL_RGBA, + GL_UNSIGNED_BYTE, 0, 0); + TextureRef* texture_ref = + group().texture_manager()->GetTexture(client_texture_id_); + ASSERT_TRUE(texture_ref != NULL); + Texture* texture = texture_ref->texture(); + EXPECT_EQ(kServiceTextureId, texture->service_id()); + + ProduceTextureDirectCHROMIUMImmediate& produce_cmd = + *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>(); + produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name); + EXPECT_EQ(error::kNoError, + ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); + + // ProduceTexture should fail it the texture and produce targets don't match. + EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); +} + TEST_P(GLES2DecoderManualInitTest, DepthTextureBadArgs) { InitState init; init.extensions = "GL_ANGLE_depth_texture"; diff --git a/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc b/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc index ba3324d..1ce8303 100644 --- a/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc +++ b/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc @@ -42,6 +42,7 @@ uint32 ReadTexel(GLuint id, GLint x, GLint y) { uint32 texel = 0; glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &texel); + EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); glBindFramebuffer(GL_FRAMEBUFFER, old_fbo); @@ -113,6 +114,91 @@ TEST_F(GLTextureMailboxTest, ProduceAndConsumeTexture) { EXPECT_EQ(source_pixel, ReadTexel(tex1, 0, 0)); } +TEST_F(GLTextureMailboxTest, ProduceAndConsumeTextureRGB) { + gl1_.MakeCurrent(); + + GLbyte mailbox1[GL_MAILBOX_SIZE_CHROMIUM]; + glGenMailboxCHROMIUM(mailbox1); + + GLbyte mailbox2[GL_MAILBOX_SIZE_CHROMIUM]; + glGenMailboxCHROMIUM(mailbox2); + + GLuint tex1; + glGenTextures(1, &tex1); + + glBindTexture(GL_TEXTURE_2D, tex1); + uint32 source_pixel = 0xFF000000; + glTexImage2D(GL_TEXTURE_2D, + 0, + GL_RGB, + 1, 1, + 0, + GL_RGB, + GL_UNSIGNED_BYTE, + &source_pixel); + + glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox1); + glFlush(); + + gl2_.MakeCurrent(); + + GLuint tex2; + glGenTextures(1, &tex2); + + glBindTexture(GL_TEXTURE_2D, tex2); + glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox1); + EXPECT_EQ(source_pixel, ReadTexel(tex2, 0, 0)); + glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox2); + glFlush(); + + gl1_.MakeCurrent(); + + glBindTexture(GL_TEXTURE_2D, tex1); + glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox2); + EXPECT_EQ(source_pixel, ReadTexel(tex1, 0, 0)); +} + +TEST_F(GLTextureMailboxTest, ProduceAndConsumeTextureDirect) { + gl1_.MakeCurrent(); + + GLbyte mailbox1[GL_MAILBOX_SIZE_CHROMIUM]; + glGenMailboxCHROMIUM(mailbox1); + + GLbyte mailbox2[GL_MAILBOX_SIZE_CHROMIUM]; + glGenMailboxCHROMIUM(mailbox2); + + GLuint tex1; + glGenTextures(1, &tex1); + + glBindTexture(GL_TEXTURE_2D, tex1); + uint32 source_pixel = 0xFF0000FF; + glTexImage2D(GL_TEXTURE_2D, + 0, + GL_RGBA, + 1, 1, + 0, + GL_RGBA, + GL_UNSIGNED_BYTE, + &source_pixel); + + glProduceTextureDirectCHROMIUM(tex1, GL_TEXTURE_2D, mailbox1); + glFlush(); + + gl2_.MakeCurrent(); + + GLuint tex2 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox1); + glBindTexture(GL_TEXTURE_2D, tex2); + EXPECT_EQ(source_pixel, ReadTexel(tex2, 0, 0)); + glProduceTextureDirectCHROMIUM(tex2, GL_TEXTURE_2D, mailbox2); + glFlush(); + + gl1_.MakeCurrent(); + + GLuint tex3 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox2); + glBindTexture(GL_TEXTURE_2D, tex3); + EXPECT_EQ(source_pixel, ReadTexel(tex3, 0, 0)); +} + TEST_F(GLTextureMailboxTest, ConsumeTextureValidatesKey) { GLuint tex; glGenTextures(1, &tex); @@ -288,6 +374,30 @@ TEST_F(GLTextureMailboxTest, ProduceFrontBuffer) { glDeleteTextures(1, &tex1); } +TEST_F(GLTextureMailboxTest, ProduceTextureDirectInvalidTarget) { + gl1_.MakeCurrent(); + + GLbyte mailbox1[GL_MAILBOX_SIZE_CHROMIUM]; + glGenMailboxCHROMIUM(mailbox1); + + GLuint tex1; + glGenTextures(1, &tex1); + + glBindTexture(GL_TEXTURE_CUBE_MAP, tex1); + uint32 source_pixel = 0xFF0000FF; + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, + 0, + GL_RGBA, + 1, 1, + 0, + GL_RGBA, + GL_UNSIGNED_BYTE, + &source_pixel); + + glProduceTextureDirectCHROMIUM(tex1, GL_TEXTURE_2D, mailbox1); + EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); +} + // http://crbug.com/281565 #if !defined(OS_ANDROID) TEST_F(GLTextureMailboxTest, ProduceFrontBufferMultipleContexts) { |