From c2f8c84089f32aac6377c95da14d52153a165b39 Mon Sep 17 00:00:00 2001 From: "kbr@google.com" Date: Mon, 6 Dec 2010 18:07:24 +0000 Subject: Exposed support for dynamically enabling extensions in command buffer implementation via new glGetRequestableExtensionsCHROMIUM and glRequestExtensionCHROMIUM entry points. These entry points are needed in order to allow WebGL to both query the available extensions and enable them individually. Added these entry points to WebGraphicsContext3DCommandBufferImpl. A subsequent WebKit checkin under https://bugs.webkit.org/show_bug.cgi?id=40316 will utilize them and implement the OES_texture_float extension for WebGL. BUG=none TEST=none (ran with new oes-texture-float.html WebGL conformance test) Review URL: http://codereview.chromium.org/5626008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68352 0039d316-1c4b-4281-b951-d872f2087c98 --- gpu/command_buffer/client/gles2_c_lib_autogen.h | 11 ++++++++ .../client/gles2_cmd_helper_autogen.h | 12 +++++++++ gpu/command_buffer/client/gles2_implementation.cc | 31 ++++++++++++++++++++++ gpu/command_buffer/client/gles2_implementation.h | 4 +++ .../client/gles2_implementation_autogen.h | 4 +++ 5 files changed, 62 insertions(+) (limited to 'gpu/command_buffer/client') diff --git a/gpu/command_buffer/client/gles2_c_lib_autogen.h b/gpu/command_buffer/client/gles2_c_lib_autogen.h index ab54997..01cb485 100644 --- a/gpu/command_buffer/client/gles2_c_lib_autogen.h +++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h @@ -844,6 +844,17 @@ void GLES2ResizeCHROMIUM(GLuint width, GLuint height) { GPU_CLIENT_LOG("ResizeCHROMIUM" << "(" << width << ", " << height << ")"); gles2::GetGLContext()->ResizeCHROMIUM(width, height); } +const GLchar* GLES2GetRequestableExtensionsCHROMIUM() { + GPU_CLIENT_LOG("GetRequestableExtensionsCHROMIUM" << "(" << ")"); + const GLchar* result = + gles2::GetGLContext()->GetRequestableExtensionsCHROMIUM(); + GPU_CLIENT_LOG("return:" << result) + return result; +} +void GLES2RequestExtensionCHROMIUM(const char* extension) { + GPU_CLIENT_LOG("RequestExtensionCHROMIUM" << "(" << extension << ")"); + gles2::GetGLContext()->RequestExtensionCHROMIUM(extension); +} #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_C_LIB_AUTOGEN_H_ diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h index 1f2b87b..e69b7ee 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h +++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h @@ -1203,5 +1203,17 @@ c.Init(width, height); } + void GetRequestableExtensionsCHROMIUM(uint32 bucket_id) { + gles2::GetRequestableExtensionsCHROMIUM& c = + GetCmdSpace(); + c.Init(bucket_id); + } + + void RequestExtensionCHROMIUM(uint32 bucket_id) { + gles2::RequestExtensionCHROMIUM& c = + GetCmdSpace(); + c.Init(bucket_id); + } + #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_AUTOGEN_H_ diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 0debcd0..64bcbe2 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -1581,5 +1581,36 @@ void GLES2Implementation::UnmapTexSubImage2DCHROMIUM(const void* mem) { mapped_textures_.erase(it); } +const GLchar* GLES2Implementation::GetRequestableExtensionsCHROMIUM() { + const char* result = NULL; + // Clear the bucket so if the command fails nothing will be in it. + helper_->SetBucketSize(kResultBucketId, 0); + helper_->GetRequestableExtensionsCHROMIUM(kResultBucketId); + std::string str; + if (GetBucketAsString(kResultBucketId, &str)) { + // The set of requestable extensions shrinks as we enable + // them. Because we don't know when the client will stop referring + // to a previous one it queries (see GetString) we need to cache + // the unique results. + std::set::const_iterator sit = + requestable_extensions_set_.find(str); + if (sit != requestable_extensions_set_.end()) { + result = sit->c_str(); + } else { + std::pair::const_iterator, bool> insert_result = + requestable_extensions_set_.insert(str); + GPU_DCHECK(insert_result.second); + result = insert_result.first->c_str(); + } + } + return reinterpret_cast(result); +} + +void GLES2Implementation::RequestExtensionCHROMIUM(const char* extension) { + SetBucketAsCString(kResultBucketId, extension); + helper_->RequestExtensionCHROMIUM(kResultBucketId); + helper_->SetBucketSize(kResultBucketId, 0); +} + } // namespace gles2 } // namespace gpu diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index 0b0e242..d56e32e 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -379,6 +379,10 @@ class GLES2Implementation { typedef std::map > GLStringMap; GLStringMap gl_strings_; + // Similar cache for glGetRequestableExtensionsCHROMIUM. We don't + // have an enum for this so handle it separately. + std::set requestable_extensions_set_; + typedef std::map MappedBufferMap; MappedBufferMap mapped_buffers_; diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index 6bf924e..bb22143 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -888,5 +888,9 @@ void ResizeCHROMIUM(GLuint width, GLuint height) { helper_->ResizeCHROMIUM(width, height); } +const GLchar* GetRequestableExtensionsCHROMIUM(); + +void RequestExtensionCHROMIUM(const char* extension); + #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_AUTOGEN_H_ -- cgit v1.1