diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-16 22:40:37 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-16 22:40:37 +0000 |
commit | 9821d0de8b140ce1cd1917260afad5f803b43ed1 (patch) | |
tree | 748eb7558cd58a8591c1ba92b30a4ddf9605580d /gpu/pgl | |
parent | 8549f5e3dd6e920fd7c72a44ba3d89b15cc03e41 (diff) | |
download | chromium_src-9821d0de8b140ce1cd1917260afad5f803b43ed1.zip chromium_src-9821d0de8b140ce1cd1917260afad5f803b43ed1.tar.gz chromium_src-9821d0de8b140ce1cd1917260afad5f803b43ed1.tar.bz2 |
New experimental Pepper device API.
- makes device contexts opaque to the plugin
- can get / set multiple attributes and flush with a single call (and underlying IPC message exchange)
- currently works in parallel with old API
- adapted pepper test plugin to use new API if use_new_npdevice_api=1
TEST=trybots, visual confirmation that pepper test plugin works with new API
BUG=none
Review URL: http://codereview.chromium.org/1529005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44840 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/pgl')
-rw-r--r-- | gpu/pgl/command_buffer_pepper.cc | 85 | ||||
-rw-r--r-- | gpu/pgl/command_buffer_pepper.h | 2 | ||||
-rw-r--r-- | gpu/pgl/pgl.cc | 10 |
3 files changed, 97 insertions, 0 deletions
diff --git a/gpu/pgl/command_buffer_pepper.cc b/gpu/pgl/command_buffer_pepper.cc index f3f0aff..4a94b9c 100644 --- a/gpu/pgl/command_buffer_pepper.cc +++ b/gpu/pgl/command_buffer_pepper.cc @@ -35,12 +35,49 @@ bool CommandBufferPepper::Initialize(int32 size) { Buffer CommandBufferPepper::GetRingBuffer() { Buffer buffer; +#if defined(ENABLE_NEW_NPDEVICE_API) + NPDeviceBuffer np_buffer; + device_->mapBuffer(npp_, + context_, + NP3DCommandBufferId, + &np_buffer); + buffer.ptr = np_buffer.ptr; + buffer.size = np_buffer.size; +#else buffer.ptr = context_->commandBuffer; buffer.size = context_->commandBufferSize * sizeof(int32); +#endif return buffer; } CommandBuffer::State CommandBufferPepper::GetState() { +#if defined(ENABLE_NEW_NPDEVICE_API) + int32 output_attribs[] = { + NP3DAttrib_CommandBufferSize, 0, + NP3DAttrib_GetOffset, 0, + NP3DAttrib_PutOffset, 0, + NP3DAttrib_Token, 0, + NPAttrib_Error, 0, + NPAttrib_End + }; + device_->synchronizeContext(npp_, + context_, + NPDeviceSynchronizationMode_Immediate, + NULL, + output_attribs, + NULL, + NULL); + + CommandBuffer::State state; + state.size = output_attribs[1]; + state.get_offset = output_attribs[3]; + state.put_offset = output_attribs[5]; + state.token = output_attribs[7]; + state.error = static_cast<gpu::error::Error>( + output_attribs[9]); + + return state; +#else context_->waitForProgress = false; if (NPERR_NO_ERROR != device_->flushContext(npp_, context_, NULL, NULL)) @@ -49,9 +86,41 @@ CommandBuffer::State CommandBufferPepper::GetState() { context_->waitForProgress = true; return ConvertState(); +#endif // ENABLE_NEW_NPDEVICE_API } CommandBuffer::State CommandBufferPepper::Flush(int32 put_offset) { +#if defined(ENABLE_NEW_NPDEVICE_API) + int32 input_attribs[] = { + NP3DAttrib_PutOffset, put_offset, + NPAttrib_End + }; + int32 output_attribs[] = { + NP3DAttrib_CommandBufferSize, 0, + NP3DAttrib_GetOffset, 0, + NP3DAttrib_PutOffset, 0, + NP3DAttrib_Token, 0, + NPAttrib_Error, 0, + NPAttrib_End + }; + device_->synchronizeContext(npp_, + context_, + NPDeviceSynchronizationMode_Flush, + input_attribs, + output_attribs, + NULL, + NULL); + + CommandBuffer::State state; + state.size = output_attribs[1]; + state.get_offset = output_attribs[3]; + state.put_offset = output_attribs[5]; + state.token = output_attribs[7]; + state.error = static_cast<gpu::error::Error>( + output_attribs[9]); + + return state; +#else context_->waitForProgress = true; context_->putOffset = put_offset; @@ -59,6 +128,7 @@ CommandBuffer::State CommandBufferPepper::Flush(int32 put_offset) { context_->error = NPDeviceContext3DError_GenericError; return ConvertState(); +#endif // ENABLE_NEW_NPDEVICE_API } void CommandBufferPepper::SetGetOffset(int32 get_offset) { @@ -100,6 +170,21 @@ void CommandBufferPepper::SetParseError( NOTREACHED(); } +gpu::error::Error CommandBufferPepper::GetCachedError() { + int32 attrib_list[] = { + NPAttrib_Error, 0, + NPAttrib_End + }; + device_->synchronizeContext(npp_, + context_, + NPDeviceSynchronizationMode_Cached, + NULL, + attrib_list, + NULL, + NULL); + return static_cast<gpu::error::Error>(attrib_list[1]); +} + CommandBuffer::State CommandBufferPepper::ConvertState() { CommandBuffer::State state; state.size = context_->commandBufferSize; diff --git a/gpu/pgl/command_buffer_pepper.h b/gpu/pgl/command_buffer_pepper.h index e75d7bf..5d11d98 100644 --- a/gpu/pgl/command_buffer_pepper.h +++ b/gpu/pgl/command_buffer_pepper.h @@ -37,6 +37,8 @@ class CommandBufferPepper : public gpu::CommandBuffer { virtual void SetToken(int32 token); virtual void SetParseError(gpu::error::Error error); + gpu::error::Error GetCachedError(); + private: CommandBuffer::State ConvertState(); diff --git a/gpu/pgl/pgl.cc b/gpu/pgl/pgl.cc index 59c2635..cf32e6a 100644 --- a/gpu/pgl/pgl.cc +++ b/gpu/pgl/pgl.cc @@ -123,8 +123,13 @@ PGLBoolean PGLContextImpl::MakeCurrent(PGLContextImpl* pgl_context) { // TODO(apatrick): I'm not sure if this should actually change the // current context if it fails. For now it gets changed even if it fails // becuase making GL calls with a NULL context crashes. +#if defined(ENABLE_NEW_NPDEVICE_API) + if (pgl_context->command_buffer_->GetCachedError() != gpu::error::kNoError) + return PGL_FALSE; +#else if (pgl_context->device_context_->error != NPDeviceContext3DError_NoError) return PGL_FALSE; +#endif } else { gles2::SetGLContext(NULL); @@ -136,8 +141,13 @@ PGLBoolean PGLContextImpl::MakeCurrent(PGLContextImpl* pgl_context) { PGLBoolean PGLContextImpl::SwapBuffers() { // Don't request latest error status from service. Just use the locally cached // information from the last flush. +#if defined(ENABLE_NEW_NPDEVICE_API) + if (command_buffer_->GetCachedError() != gpu::error::kNoError) + return PGL_FALSE; +#else if (device_context_->error != NPDeviceContext3DError_NoError) return PGL_FALSE; +#endif gles2_implementation_->SwapBuffers(); return PGL_TRUE; |