diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-12 17:23:58 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-12 17:23:58 +0000 |
commit | b273e43cebe9f829f9e871bc27ddf5cea4feef28 (patch) | |
tree | 2db79f311c3f080d44dc1f99fc5548b4beaf6112 | |
parent | d382b18cd1dafdadc6e55843e48cb78f0f99a1b9 (diff) | |
download | chromium_src-b273e43cebe9f829f9e871bc27ddf5cea4feef28.zip chromium_src-b273e43cebe9f829f9e871bc27ddf5cea4feef28.tar.gz chromium_src-b273e43cebe9f829f9e871bc27ddf5cea4feef28.tar.bz2 |
Adds stubs for glShaderBinary and glReleaseShaderCompiler.
Also handles certain GLES2 enums passed to glGetXXX that
have no corresponding OpenGL enums
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/1609016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44254 0039d316-1c4b-4281-b951-d872f2087c98
17 files changed, 414 insertions, 14 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index 0173ee0..bae1b5f 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -129,7 +129,7 @@ GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenumRenderBufferTarget target, GLenumRenderBufferFormat internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLidShader* shaders, GLenum binaryformat, const void* binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length); GL_APICALL void GL_APIENTRY glShaderSource (GLidShader shader, GLsizei count, const char** str, const GLint* length); GL_APICALL void GL_APIENTRY glStencilFunc (GLenumCmpFunction func, GLint ref, GLuint mask); GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenumFaceType face, GLenumCmpFunction func, GLint ref, GLuint mask); @@ -364,6 +364,8 @@ _CMD_ID_TABLE = { 'GetUniformLocationBucket': 433, 'GetAttribLocationBucket': 434, 'ShaderSourceBucket': 435, + 'ShaderBinary': 436, + 'ReleaseShaderCompiler': 437, } # This is a list of enum names and their valid values. It is used to map @@ -1065,7 +1067,11 @@ _FUNCTION_INFO = { 'GLidProgram program, const char* name, NonImmediate GLint* location', 'result': ['GLint'], }, - 'GetBooleanv': {'type': 'GETn', 'result': ['SizedResult<GLboolean>']}, + 'GetBooleanv': { + 'type': 'GETn', + 'result': ['SizedResult<GLboolean>'], + 'decoder_func': 'DoGetBooleanv', + }, 'GetBufferParameteriv': {'type': 'GETn', 'result': ['SizedResult<GLint>']}, 'GetError': { 'type': 'Is', @@ -1073,14 +1079,22 @@ _FUNCTION_INFO = { 'impl_func': False, 'result': ['GLenum'], }, - 'GetFloatv': {'type': 'GETn', 'result': ['SizedResult<GLfloat>']}, + 'GetFloatv': { + 'type': 'GETn', + 'result': ['SizedResult<GLfloat>'], + 'decoder_func': 'DoGetFloatv', + }, 'GetFramebufferAttachmentParameteriv': { 'type': 'GETn', 'decoder_func': 'DoGetFramebufferAttachmentParameteriv', 'gl_test_func': 'glGetFramebufferAttachmentParameterivEXT', 'result': ['SizedResult<GLint>'], }, - 'GetIntegerv': {'type': 'GETn', 'result': ['SizedResult<GLint>']}, + 'GetIntegerv': { + 'type': 'GETn', + 'result': ['SizedResult<GLint>'], + 'decoder_func': 'DoGetIntegerv', + }, 'GetProgramiv': {'type': 'GETn', 'result': ['SizedResult<GLint>']}, 'GetProgramInfoLog': { 'type': 'STRn', @@ -1182,8 +1196,11 @@ _FUNCTION_INFO = { 'uint32 result_shm_id, uint32 result_shm_offset', 'result': ['uint32'], }, - 'ReleaseShaderCompiler': {'type': 'Noop'}, - 'ShaderBinary': {'type': 'Noop'}, + 'ReleaseShaderCompiler': { + 'decoder_func': 'DoReleaseShaderCompiler', + 'unit_test': False, + }, + 'ShaderBinary': {'type': 'Custom'}, 'ShaderSource': { 'type': 'Manual', 'immediate': True, diff --git a/gpu/command_buffer/client/gles2_c_lib_autogen.h b/gpu/command_buffer/client/gles2_c_lib_autogen.h index 3aef7b8..777a2d6 100644 --- a/gpu/command_buffer/client/gles2_c_lib_autogen.h +++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h @@ -329,6 +329,9 @@ void GLES2ReadPixels( void* pixels) { gles2::GetGLContext()->ReadPixels(x, y, width, height, format, type, pixels); } +void GLES2ReleaseShaderCompiler() { + gles2::GetGLContext()->ReleaseShaderCompiler(); +} void GLES2RenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { gles2::GetGLContext()->RenderbufferStorage( @@ -340,6 +343,12 @@ void GLES2SampleCoverage(GLclampf value, GLboolean invert) { void GLES2Scissor(GLint x, GLint y, GLsizei width, GLsizei height) { gles2::GetGLContext()->Scissor(x, y, width, height); } +void GLES2ShaderBinary( + GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, + GLsizei length) { + gles2::GetGLContext()->ShaderBinary( + n, shaders, binaryformat, binary, length); +} void GLES2ShaderSource( GLuint shader, GLsizei count, const char** str, const GLint* length) { gles2::GetGLContext()->ShaderSource(shader, count, str, length); diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h index 97b5e25..42f6608 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h +++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h @@ -668,6 +668,12 @@ result_shm_id, result_shm_offset); } + void ReleaseShaderCompiler() { + gles2::ReleaseShaderCompiler& c = + GetCmdSpace<gles2::ReleaseShaderCompiler>(); + c.Init(); + } + void RenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { gles2::RenderbufferStorage& c = GetCmdSpace<gles2::RenderbufferStorage>(); @@ -684,6 +690,16 @@ c.Init(x, y, width, height); } + void ShaderBinary( + GLsizei n, uint32 shaders_shm_id, uint32 shaders_shm_offset, + GLenum binaryformat, uint32 binary_shm_id, uint32 binary_shm_offset, + GLsizei length) { + gles2::ShaderBinary& c = GetCmdSpace<gles2::ShaderBinary>(); + c.Init( + n, shaders_shm_id, shaders_shm_offset, binaryformat, binary_shm_id, + binary_shm_offset, length); + } + void ShaderSource( GLuint shader, uint32 data_shm_id, uint32 data_shm_offset, uint32 data_size) { diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 4eb6577..b3fe538 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -245,6 +245,30 @@ GLint GLES2Implementation::GetUniformLocation( return *result; } + +void GLES2Implementation::ShaderBinary( + GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, + GLsizei length) { + if (n < 0 || length < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } + GLsizei shader_id_size = n * sizeof(*shaders); + void* shader_ids = transfer_buffer_.Alloc(shader_id_size); + void* shader_data = transfer_buffer_.Alloc(length); + memcpy(shader_ids, shaders, shader_id_size); + memcpy(shader_data, binary, length); + helper_->ShaderBinary( + n, + transfer_buffer_id_, transfer_buffer_.GetOffset(shader_ids), + binaryformat, + transfer_buffer_id_, transfer_buffer_.GetOffset(shader_data), + length); + int32 token = helper_->InsertToken(); + transfer_buffer_.FreePendingToken(shader_ids, token); + transfer_buffer_.FreePendingToken(shader_data, token); +} + void GLES2Implementation::PixelStorei(GLenum pname, GLint param) { switch (pname) { case GL_PACK_ALIGNMENT: @@ -287,7 +311,7 @@ void GLES2Implementation::ShaderSource( for (GLsizei ii = 0; ii <= count; ++ii) { const char* src = ii < count ? source[ii] : ""; uint32 size = ii < count ? (length ? length[ii] : strlen(src)) : 1; - while(size) { + while (size) { uint32 part_size = std::min(size, max_size); void* buffer = transfer_buffer_.Alloc(part_size); memcpy(buffer, src, part_size); diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index 3c21aea..04e5d76 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -537,6 +537,10 @@ void ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels); +void ReleaseShaderCompiler() { + helper_->ReleaseShaderCompiler(); +} + void RenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { if (width < 0) { @@ -566,6 +570,10 @@ void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) { helper_->Scissor(x, y, width, height); } +void ShaderBinary( + GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, + GLsizei length); + void ShaderSource( GLuint shader, GLsizei count, const char** str, const GLint* length); diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index 7213e1e..c772b1e 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -4815,6 +4815,36 @@ COMPILE_ASSERT(offsetof(ReadPixels, result_shm_id) == 36, COMPILE_ASSERT(offsetof(ReadPixels, result_shm_offset) == 40, OffsetOf_ReadPixels_result_shm_offset_not_40); +struct ReleaseShaderCompiler { + typedef ReleaseShaderCompiler ValueType; + static const CommandId kCmdId = kReleaseShaderCompiler; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init() { + SetHeader(); + } + + void* Set(void* cmd) { + static_cast<ValueType*>(cmd)->Init(); + return NextCmdAddress<ValueType>(cmd); + } + + gpu::CommandHeader header; +}; + +COMPILE_ASSERT(sizeof(ReleaseShaderCompiler) == 4, + Sizeof_ReleaseShaderCompiler_is_not_4); +COMPILE_ASSERT(offsetof(ReleaseShaderCompiler, header) == 0, + OffsetOf_ReleaseShaderCompiler_header_not_0); + struct RenderbufferStorage { typedef RenderbufferStorage ValueType; static const CommandId kCmdId = kRenderbufferStorage; @@ -4950,6 +4980,73 @@ COMPILE_ASSERT(offsetof(Scissor, width) == 12, COMPILE_ASSERT(offsetof(Scissor, height) == 16, OffsetOf_Scissor_height_not_16); +struct ShaderBinary { + typedef ShaderBinary ValueType; + static const CommandId kCmdId = kShaderBinary; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLsizei _n, uint32 _shaders_shm_id, uint32 _shaders_shm_offset, + GLenum _binaryformat, uint32 _binary_shm_id, uint32 _binary_shm_offset, + GLsizei _length) { + SetHeader(); + n = _n; + shaders_shm_id = _shaders_shm_id; + shaders_shm_offset = _shaders_shm_offset; + binaryformat = _binaryformat; + binary_shm_id = _binary_shm_id; + binary_shm_offset = _binary_shm_offset; + length = _length; + } + + void* Set( + void* cmd, GLsizei _n, uint32 _shaders_shm_id, uint32 _shaders_shm_offset, + GLenum _binaryformat, uint32 _binary_shm_id, uint32 _binary_shm_offset, + GLsizei _length) { + static_cast<ValueType*>( + cmd)->Init( + _n, _shaders_shm_id, _shaders_shm_offset, _binaryformat, + _binary_shm_id, _binary_shm_offset, _length); + return NextCmdAddress<ValueType>(cmd); + } + + gpu::CommandHeader header; + int32 n; + uint32 shaders_shm_id; + uint32 shaders_shm_offset; + uint32 binaryformat; + uint32 binary_shm_id; + uint32 binary_shm_offset; + int32 length; +}; + +COMPILE_ASSERT(sizeof(ShaderBinary) == 32, + Sizeof_ShaderBinary_is_not_32); +COMPILE_ASSERT(offsetof(ShaderBinary, header) == 0, + OffsetOf_ShaderBinary_header_not_0); +COMPILE_ASSERT(offsetof(ShaderBinary, n) == 4, + OffsetOf_ShaderBinary_n_not_4); +COMPILE_ASSERT(offsetof(ShaderBinary, shaders_shm_id) == 8, + OffsetOf_ShaderBinary_shaders_shm_id_not_8); +COMPILE_ASSERT(offsetof(ShaderBinary, shaders_shm_offset) == 12, + OffsetOf_ShaderBinary_shaders_shm_offset_not_12); +COMPILE_ASSERT(offsetof(ShaderBinary, binaryformat) == 16, + OffsetOf_ShaderBinary_binaryformat_not_16); +COMPILE_ASSERT(offsetof(ShaderBinary, binary_shm_id) == 20, + OffsetOf_ShaderBinary_binary_shm_id_not_20); +COMPILE_ASSERT(offsetof(ShaderBinary, binary_shm_offset) == 24, + OffsetOf_ShaderBinary_binary_shm_offset_not_24); +COMPILE_ASSERT(offsetof(ShaderBinary, length) == 28, + OffsetOf_ShaderBinary_length_not_28); + struct ShaderSource { typedef ShaderSource ValueType; static const CommandId kCmdId = kShaderSource; 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 bb13f1d4..5a07409 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h @@ -1776,6 +1776,17 @@ TEST(GLES2FormatTest, ReadPixels) { EXPECT_EQ(static_cast<uint32>(20), cmd.result_shm_offset); } +TEST(GLES2FormatTest, ReleaseShaderCompiler) { + ReleaseShaderCompiler cmd = { { 0 } }; + void* next_cmd = cmd.Set( + &cmd); + EXPECT_EQ(static_cast<uint32>(ReleaseShaderCompiler::kCmdId), + cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); + EXPECT_EQ(static_cast<char*>(next_cmd), + reinterpret_cast<char*>(&cmd) + sizeof(cmd)); +} + TEST(GLES2FormatTest, RenderbufferStorage) { RenderbufferStorage cmd = { { 0 } }; void* next_cmd = cmd.Set( @@ -1829,6 +1840,31 @@ TEST(GLES2FormatTest, Scissor) { EXPECT_EQ(static_cast<GLsizei>(14), cmd.height); } +TEST(GLES2FormatTest, ShaderBinary) { + ShaderBinary cmd = { { 0 } }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + static_cast<uint32>(12), + static_cast<uint32>(13), + static_cast<GLenum>(14), + static_cast<uint32>(15), + static_cast<uint32>(16), + static_cast<GLsizei>(17)); + EXPECT_EQ(static_cast<uint32>(ShaderBinary::kCmdId), + cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); + EXPECT_EQ(static_cast<char*>(next_cmd), + reinterpret_cast<char*>(&cmd) + sizeof(cmd)); + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + EXPECT_EQ(static_cast<uint32>(12), cmd.shaders_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.shaders_shm_offset); + EXPECT_EQ(static_cast<GLenum>(14), cmd.binaryformat); + EXPECT_EQ(static_cast<uint32>(15), cmd.binary_shm_id); + EXPECT_EQ(static_cast<uint32>(16), cmd.binary_shm_offset); + EXPECT_EQ(static_cast<GLsizei>(17), cmd.length); +} + TEST(GLES2FormatTest, ShaderSource) { ShaderSource cmd = { { 0 } }; void* next_cmd = cmd.Set( diff --git a/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h index 4051f25..451b2ff 100644 --- a/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h @@ -233,12 +233,16 @@ TEST(GLES2CommandIdTest, CommandIdsMatch) { GLES2_PolygonOffset_kCmdId_mismatch); COMPILE_ASSERT(ReadPixels::kCmdId == 363, GLES2_ReadPixels_kCmdId_mismatch); + COMPILE_ASSERT(ReleaseShaderCompiler::kCmdId == 437, + GLES2_ReleaseShaderCompiler_kCmdId_mismatch); COMPILE_ASSERT(RenderbufferStorage::kCmdId == 364, GLES2_RenderbufferStorage_kCmdId_mismatch); COMPILE_ASSERT(SampleCoverage::kCmdId == 365, GLES2_SampleCoverage_kCmdId_mismatch); COMPILE_ASSERT(Scissor::kCmdId == 366, GLES2_Scissor_kCmdId_mismatch); + COMPILE_ASSERT(ShaderBinary::kCmdId == 436, + GLES2_ShaderBinary_kCmdId_mismatch); COMPILE_ASSERT(ShaderSource::kCmdId == 367, GLES2_ShaderSource_kCmdId_mismatch); COMPILE_ASSERT(ShaderSourceImmediate::kCmdId == 368, diff --git a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h index 714069d..92699ce 100644 --- a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h @@ -188,6 +188,8 @@ OP(GetUniformLocationBucket) /* 433 */ \ OP(GetAttribLocationBucket) /* 434 */ \ OP(ShaderSourceBucket) /* 435 */ \ + OP(ShaderBinary) /* 436 */ \ + OP(ReleaseShaderCompiler) /* 437 */ \ enum CommandId { kStartPoint = cmd::kLastCommonId, // All GLES2 commands start after this. diff --git a/gpu/command_buffer/docs/gles2_cmd_format_docs.txt b/gpu/command_buffer/docs/gles2_cmd_format_docs.txt index 15fafc4..8d1b360 100644 --- a/gpu/command_buffer/docs/gles2_cmd_format_docs.txt +++ b/gpu/command_buffer/docs/gles2_cmd_format_docs.txt @@ -29,7 +29,7 @@ //! A 3rd way of passing data is through Buckets. Buckets are indentified by //! number. You create a bucket with the command SetBucketSize, you can then //! fill the bucket with SetBucketData commands. Once you've sent all your -//! data you can then issue a command that uses the bucket and takes a bucket +//! data you can then issue a command that uses the bucket and takes a bucket //! id for which bucket to use. //! //! Receiving data works similarly. Some commands return their data to shared @@ -74,7 +74,7 @@ struct CommandHeader { //! Used for some glGetXXX commands that return a result through a pointer. We //! need to know if the command succeeded or not and the size of the result. If -//! the command failed its result size will 0. You must set the size to 0 +//! the command failed its result size will 0. You must set the size to 0 //! before issuing the command. //! //! To retreive the data you might do something like this pseudo code: @@ -1429,6 +1429,13 @@ struct ReadPixels { uint32 result_shm_offset; //!< uint32 }; +//! Command that corresponds to glReleaseShaderCompiler. +struct ReleaseShaderCompiler { + static const CommandId kCmdId = 437; + + CommandHeader header; +}; + //! Command that corresponds to glRenderbufferStorage. struct RenderbufferStorage { static const CommandId kCmdId = 364; @@ -1460,6 +1467,20 @@ struct Scissor { int32 height; //!< GLsizei }; +//! Command that corresponds to glShaderBinary. +struct ShaderBinary { + static const CommandId kCmdId = 436; + + CommandHeader header; + int32 n; //!< GLsizei + uint32 shaders_shm_id; //!< uint32 + uint32 shaders_shm_offset; //!< uint32 + uint32 binaryformat; //!< GLenum + uint32 binary_shm_id; //!< uint32 + uint32 binary_shm_offset; //!< uint32 + int32 length; //!< GLsizei +}; + //! Command that corresponds to glShaderSource. struct ShaderSource { static const CommandId kCmdId = 367; diff --git a/gpu/command_buffer/service/gl_interface.h b/gpu/command_buffer/service/gl_interface.h index 139dff2..0629e20 100644 --- a/gpu/command_buffer/service/gl_interface.h +++ b/gpu/command_buffer/service/gl_interface.h @@ -275,6 +275,8 @@ class GLInterface { GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) = 0; + virtual void ReleaseShaderCompiler(void) = 0; + virtual void RenderbufferStorageEXT( GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = 0; @@ -282,6 +284,10 @@ class GLInterface { virtual void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) = 0; + virtual void ShaderBinary( + GLsizei n, const GLuint* shaders, GLenum binaryformat, + const void* binary, GLsizei length) = 0; + virtual void ShaderSource( GLuint shader, GLsizei count, const char** str, const GLint* length) = 0; diff --git a/gpu/command_buffer/service/gl_mock.h b/gpu/command_buffer/service/gl_mock.h index 1ef66ea..ca038bb 100644 --- a/gpu/command_buffer/service/gl_mock.h +++ b/gpu/command_buffer/service/gl_mock.h @@ -247,6 +247,8 @@ class MockGLInterface : public GLInterface { GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)); + MOCK_METHOD0(ReleaseShaderCompiler, void()); + MOCK_METHOD4(RenderbufferStorageEXT, void( GLenum target, GLenum internalformat, GLsizei width, GLsizei height)); @@ -254,6 +256,10 @@ class MockGLInterface : public GLInterface { MOCK_METHOD4(Scissor, void(GLint x, GLint y, GLsizei width, GLsizei height)); + MOCK_METHOD5(ShaderBinary, void( + GLsizei n, const GLuint* shaders, GLenum binaryformat, + const void* binary, GLsizei length)); + MOCK_METHOD4(ShaderSource, void( GLuint shader, GLsizei count, const char** str, const GLint* length)); diff --git a/gpu/command_buffer/service/gl_utils.h b/gpu/command_buffer/service/gl_utils.h index c5a3c98..ca8c630 100644 --- a/gpu/command_buffer/service/gl_utils.h +++ b/gpu/command_buffer/service/gl_utils.h @@ -69,6 +69,14 @@ #define GL_LOW_INT 0x8DF3 #define GL_MEDIUM_INT 0x8DF4 #define GL_HIGH_INT 0x8DF5 + #define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A + #define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B + #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD + #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB + #define GL_MAX_VARYING_VECTORS 0x8DFC + #define GL_SHADER_BINARY_FORMATS 0x8DF8 + #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 + #define GL_SHADER_COMPILER 0x8DFA #endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 8f9ef4e..706407a 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -606,6 +606,9 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, error::Error ShaderSourceHelper( GLuint shader, const char* data, uint32 data_size); + // Helper for glGetBooleanv, glGetFloatv and glGetIntegerv + bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written); + // Wrapper for glCreateProgram void CreateProgramHelper(GLuint client_id); @@ -663,10 +666,19 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, // Wrapper for glGenerateMipmap void DoGenerateMipmap(GLenum target); + // Wrapper for DoGetBooleanv. + void DoGetBooleanv(GLenum pname, GLboolean* params); + + // Wrapper for DoGetFloatv. + void DoGetFloatv(GLenum pname, GLfloat* params); + // Wrapper for glGetFramebufferAttachmentParameteriv. void DoGetFramebufferAttachmentParameteriv( GLenum target, GLenum attachment, GLenum pname, GLint* params); + // Wrapper for DoGetIntegerv. + void DoGetIntegerv(GLenum pname, GLint* params); + // Wrapper for glRenderbufferParameteriv. void DoGetRenderbufferParameteriv( GLenum target, GLenum pname, GLint* params); @@ -685,6 +697,9 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, void DoRenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + // Wrapper for glReleaseShaderCompiler. + void DoReleaseShaderCompiler() { } + // Wrappers for glTexParameter functions. void DoTexParameterf(GLenum target, GLenum pname, GLfloat param); void DoTexParameteri(GLenum target, GLenum pname, GLint param); @@ -1824,6 +1839,87 @@ void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) { glGenerateMipmapEXT(target); } +bool GLES2DecoderImpl::GetHelper( + GLenum pname, GLint* params, GLsizei* num_written) { + DCHECK(params); + DCHECK(num_written); + switch (pname) { + case GL_IMPLEMENTATION_COLOR_READ_FORMAT: + *num_written = 1; + *params = GL_RGB; // TODO(gman): get correct format. + return true; + case GL_IMPLEMENTATION_COLOR_READ_TYPE: + *num_written = 1; + *params = GL_UNSIGNED_BYTE; // TODO(gman): get correct type. + return true; + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: + *num_written = 1; + *params = 16; // TODO(gman): get correct value. + return true; + case GL_MAX_VARYING_VECTORS: + *num_written = 1; + *params = 8; // TODO(gman): get correct value. + return true; + case GL_MAX_VERTEX_UNIFORM_VECTORS: + *num_written = 1; + *params = 128; // TODO(gman): get correct value. + return true; + case GL_NUM_COMPRESSED_TEXTURE_FORMATS: + *num_written = 1; + *params = 0; // We don't support compressed textures. + return true; + case GL_NUM_SHADER_BINARY_FORMATS: + *num_written = 1; + *params = 0; // We don't support binary shader formats. + return true; + case GL_SHADER_BINARY_FORMATS: + *num_written = 0; + return true; // We don't support binary shader format.s + case GL_SHADER_COMPILER: + *num_written = 1; + *params = GL_TRUE; + return true; + default: + return false; + } +} + +void GLES2DecoderImpl::DoGetBooleanv(GLenum pname, GLboolean* params) { + DCHECK(params); + GLint values[16]; + GLsizei num_written; + if (GetHelper(pname, &values[0], &num_written)) { + DCHECK_LE(static_cast<size_t>(num_written), arraysize(values)); + for (GLsizei ii = 0; ii < num_written; ++ii) { + params[ii] = static_cast<GLboolean>(values[ii]); + } + } else { + glGetBooleanv(pname, params); + } +} + +void GLES2DecoderImpl::DoGetFloatv(GLenum pname, GLfloat* params) { + DCHECK(params); + GLint values[16]; + GLsizei num_written; + if (GetHelper(pname, &values[0], &num_written)) { + DCHECK_LE(static_cast<size_t>(num_written), arraysize(values)); + for (GLsizei ii = 0; ii < num_written; ++ii) { + params[ii] = static_cast<GLfloat>(values[ii]); + } + } else { + glGetFloatv(pname, params); + } +} + +void GLES2DecoderImpl::DoGetIntegerv(GLenum pname, GLint* params) { + DCHECK(params); + GLsizei num_written; + if (!GetHelper(pname, params, &num_written)) { + glGetIntegerv(pname, params); + } +} + error::Error GLES2DecoderImpl::HandleBindAttribLocation( uint32 immediate_data_size, const gles2::BindAttribLocation& c) { GLuint program; @@ -3207,6 +3303,47 @@ error::Error GLES2DecoderImpl::HandleGetActiveAttrib( return error::kNoError; } +error::Error GLES2DecoderImpl::HandleShaderBinary( + uint32 immediate_data_size, const gles2::ShaderBinary& c) { +#if 1 // No binary shader support. + SetGLError(GL_INVALID_OPERATION); + return error::kNoError; +#else + GLsizei n = static_cast<GLsizei>(c.n); + if (n < 0) { + SetGLError(GL_INVALID_VALUE); + return error::kNoError; + } + GLsizei length = static_cast<GLsizei>(c.length); + if (length < 0) { + SetGLError(GL_INVALID_VALUE); + return error::kNoError; + } + uint32 data_size; + if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) { + return error::kOutOfBounds; + } + const GLuint* shaders = GetSharedMemoryAs<const GLuint*>( + c.shaders_shm_id, c.shaders_shm_offset, data_size); + GLenum binaryformat = static_cast<GLenum>(c.binaryformat); + const void* binary = GetSharedMemoryAs<const void*>( + c.binary_shm_id, c.binary_shm_offset, length); + if (shaders == NULL || binary == NULL) { + return error::kOutOfBounds; + } + scoped_array<GLuint> service_ids(new GLuint[n]); + for (GLsizei ii = 0; ii < n; ++ii) { + if (!id_manager()->GetServiceId(shaders[ii], &service_ids[ii])) { + SetGLError(GL_INVALID_VALUE); + return error::kNoError; + } + // TODO(gman): Check that each shader exists. + } + // TODO(gman): call glShaderBinary + return error::kNoError; +#endif +} + error::Error GLES2DecoderImpl::HandleSwapBuffers( uint32 immediate_data_size, const gles2::SwapBuffers& c) { // Check a client created frame buffer is not bound. TODO(apatrick): diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index cc862d1..01e9dd2 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -973,7 +973,7 @@ error::Error GLES2DecoderImpl::HandleGetBooleanv( return error::kInvalidArguments; } CopyRealGLErrorsToWrapper(); - glGetBooleanv(pname, params); + DoGetBooleanv(pname, params); GLenum error = glGetError(); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); @@ -1058,7 +1058,7 @@ error::Error GLES2DecoderImpl::HandleGetFloatv( return error::kInvalidArguments; } CopyRealGLErrorsToWrapper(); - glGetFloatv(pname, params); + DoGetFloatv(pname, params); GLenum error = glGetError(); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); @@ -1137,7 +1137,7 @@ error::Error GLES2DecoderImpl::HandleGetIntegerv( return error::kInvalidArguments; } CopyRealGLErrorsToWrapper(); - glGetIntegerv(pname, params); + DoGetIntegerv(pname, params); GLenum error = glGetError(); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); @@ -1624,6 +1624,12 @@ error::Error GLES2DecoderImpl::HandlePolygonOffset( return error::kNoError; } +error::Error GLES2DecoderImpl::HandleReleaseShaderCompiler( + uint32 immediate_data_size, const gles2::ReleaseShaderCompiler& c) { + DoReleaseShaderCompiler(); + return error::kNoError; +} + error::Error GLES2DecoderImpl::HandleRenderbufferStorage( uint32 immediate_data_size, const gles2::RenderbufferStorage& c) { GLenum target = static_cast<GLenum>(c.target); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h index 33eeb1f..203ec06 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h @@ -1849,5 +1849,7 @@ TEST_F(GLES2DecoderTest1, GetTexParameterivInvalidArgs2_1) { EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(0u, result->size); } +// TODO(gman): GetUniformfv + #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_1_AUTOGEN_H_ 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 3412c4b..bdf34cf 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 @@ -8,8 +8,6 @@ #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_ #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_ -// TODO(gman): GetUniformfv - // TODO(gman): GetUniformiv // TODO(gman): GetUniformLocation @@ -324,6 +322,7 @@ TEST_F(GLES2DecoderTest2, PolygonOffsetValidArgs) { } // TODO(gman): ReadPixels +// TODO(gman): ReleaseShaderCompiler TEST_F(GLES2DecoderTest2, RenderbufferStorageValidArgs) { EXPECT_CALL(*gl_, RenderbufferStorageEXT(GL_RENDERBUFFER, GL_RGBA4, 3, 4)); @@ -396,6 +395,8 @@ TEST_F(GLES2DecoderTest2, ScissorInvalidArgs3_0) { EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); } +// TODO(gman): ShaderBinary + // TODO(gman): ShaderSource // TODO(gman): ShaderSourceImmediate |