Commit 141a88a7 authored by Daniele Castagna's avatar Daniele Castagna Committed by Commit Bot

pappi: TakeFrontBuffer only once in singlebuffer mode

Single buffer mode for pepper relied on TakeFromBuffer associating
different mailboxes to the same texture.
This does not work anymore after https://crrev.com/c/1097696 and
single buffer nacl plugins now sends invalid mailboxes to the compositor.

This CL fixes the issue making sure that Graphics3D is aware of the
single buffer mode and it will associate only one mailbox, only once,
to the front buffer.

Bug: 866643, b/111601347
Test: http://nacl-latency.firebaseapp.com runs without flickering

Change-Id: I8625fbb87bf3e9503068681bed681c88a068a123
Reviewed-on: https://chromium-review.googlesource.com/1144486
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579123}
parent ce260e0a
...@@ -125,11 +125,6 @@ void PPB_Graphics3D_Impl::EnsureWorkVisible() { ...@@ -125,11 +125,6 @@ void PPB_Graphics3D_Impl::EnsureWorkVisible() {
} }
void PPB_Graphics3D_Impl::TakeFrontBuffer() { void PPB_Graphics3D_Impl::TakeFrontBuffer() {
if (!taken_front_buffer_.IsZero()) {
DLOG(ERROR)
<< "TakeFrontBuffer should only be called once before DoSwapBuffers";
return;
}
taken_front_buffer_ = GenerateMailbox(); taken_front_buffer_ = GenerateMailbox();
command_buffer_->TakeFrontBuffer(taken_front_buffer_); command_buffer_->TakeFrontBuffer(taken_front_buffer_);
} }
...@@ -195,7 +190,6 @@ int32_t PPB_Graphics3D_Impl::DoSwapBuffers(const gpu::SyncToken& sync_token, ...@@ -195,7 +190,6 @@ int32_t PPB_Graphics3D_Impl::DoSwapBuffers(const gpu::SyncToken& sync_token,
viz::TransferableResource::MakeGLOverlay(taken_front_buffer_, GL_LINEAR, viz::TransferableResource::MakeGLOverlay(taken_front_buffer_, GL_LINEAR,
target, sync_token, size, target, sync_token, size,
is_overlay_candidate); is_overlay_candidate);
taken_front_buffer_.SetZero();
HostGlobals::Get() HostGlobals::Get()
->GetInstance(pp_instance()) ->GetInstance(pp_instance())
->CommitTransferableResource(resource); ->CommitTransferableResource(resource);
......
...@@ -44,9 +44,10 @@ gpu::CommandBuffer::State GetErrorState() { ...@@ -44,9 +44,10 @@ gpu::CommandBuffer::State GetErrorState() {
} // namespace } // namespace
Graphics3D::Graphics3D(const HostResource& resource, const gfx::Size& size) Graphics3D::Graphics3D(const HostResource& resource,
: PPB_Graphics3D_Shared(resource, size) { const gfx::Size& size,
} const bool single_buffer)
: PPB_Graphics3D_Shared(resource, size), single_buffer(single_buffer) {}
Graphics3D::~Graphics3D() { Graphics3D::~Graphics3D() {
DestroyGLES2Impl(); DestroyGLES2Impl();
...@@ -125,9 +126,11 @@ int32_t Graphics3D::DoSwapBuffers(const gpu::SyncToken& sync_token, ...@@ -125,9 +126,11 @@ int32_t Graphics3D::DoSwapBuffers(const gpu::SyncToken& sync_token,
gpu::gles2::GLES2Implementation* gl = gles2_impl(); gpu::gles2::GLES2Implementation* gl = gles2_impl();
gl->SwapBuffers(swap_id_++); gl->SwapBuffers(swap_id_++);
PluginDispatcher::GetForResource(this)->Send( if (!single_buffer || swap_id_ == 1) {
new PpapiHostMsg_PPBGraphics3D_TakeFrontBuffer(API_ID_PPB_GRAPHICS_3D, PluginDispatcher::GetForResource(this)->Send(
host_resource())); new PpapiHostMsg_PPBGraphics3D_TakeFrontBuffer(API_ID_PPB_GRAPHICS_3D,
host_resource()));
}
gpu::SyncToken new_sync_token; gpu::SyncToken new_sync_token;
gl->GenSyncTokenCHROMIUM(new_sync_token.GetData()); gl->GenSyncTokenCHROMIUM(new_sync_token.GetData());
...@@ -239,7 +242,8 @@ PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( ...@@ -239,7 +242,8 @@ PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource(
return 0; return 0;
scoped_refptr<Graphics3D> graphics_3d( scoped_refptr<Graphics3D> graphics_3d(
new Graphics3D(result, attrib_helper.offscreen_framebuffer_size)); new Graphics3D(result, attrib_helper.offscreen_framebuffer_size,
attrib_helper.single_buffer));
if (!graphics_3d->Init(share_gles2, capabilities, std::move(shared_state), if (!graphics_3d->Init(share_gles2, capabilities, std::move(shared_state),
command_buffer_id)) { command_buffer_id)) {
return 0; return 0;
......
...@@ -37,7 +37,9 @@ class PpapiCommandBufferProxy; ...@@ -37,7 +37,9 @@ class PpapiCommandBufferProxy;
class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared { class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared {
public: public:
Graphics3D(const HostResource& resource, const gfx::Size& size); Graphics3D(const HostResource& resource,
const gfx::Size& size,
const bool single_buffer);
~Graphics3D() override; ~Graphics3D() override;
bool Init(gpu::gles2::GLES2Implementation* share_gles2, bool Init(gpu::gles2::GLES2Implementation* share_gles2,
...@@ -70,6 +72,7 @@ class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared { ...@@ -70,6 +72,7 @@ class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared {
std::unique_ptr<PpapiCommandBufferProxy> command_buffer_; std::unique_ptr<PpapiCommandBufferProxy> command_buffer_;
uint64_t swap_id_ = 0; uint64_t swap_id_ = 0;
bool single_buffer = false;
DISALLOW_COPY_AND_ASSIGN(Graphics3D); DISALLOW_COPY_AND_ASSIGN(Graphics3D);
}; };
...@@ -137,4 +140,3 @@ class PPB_Graphics3D_Proxy : public InterfaceProxy { ...@@ -137,4 +140,3 @@ class PPB_Graphics3D_Proxy : public InterfaceProxy {
} // namespace ppapi } // namespace ppapi
#endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_ #endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_
...@@ -96,7 +96,9 @@ class VideoDecoderResourceTest : public PluginProxyTest { ...@@ -96,7 +96,9 @@ class VideoDecoderResourceTest : public PluginProxyTest {
HostResource host_resource; HostResource host_resource;
host_resource.SetHostResource(pp_instance(), kGraphics3D); host_resource.SetHostResource(pp_instance(), kGraphics3D);
scoped_refptr<ppapi::proxy::Graphics3D> graphics_3d( scoped_refptr<ppapi::proxy::Graphics3D> graphics_3d(
new ppapi::proxy::Graphics3D(host_resource, gfx::Size(640, 480))); new ppapi::proxy::Graphics3D(host_resource, gfx::Size(640, 480),
false));
return graphics_3d->GetReference(); return graphics_3d->GetReference();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment