Commit b7a307db authored by Vasiliy Telezhnikov's avatar Vasiliy Telezhnikov Committed by Commit Bot

Fixed GL Readback in SkiaRenderer and passthrough

This CL fixes adds path for passthrough gl decoder to
ScopedSurfaceToTexture. It also fixes gl state sync issue between
|gles2_implementation_| and |gles2_decoder_| for the readback.

Bug: 983581
Change-Id: I03a17724326968d57e2f26a558a2e6237aaadc32
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1763432
Commit-Queue: Vasiliy Telezhnikov <vasilyt@chromium.org>
Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689522}
parent 88bd013d
...@@ -155,6 +155,19 @@ void DirectContextProvider::SetGLRendererCopierRequiredState( ...@@ -155,6 +155,19 @@ void DirectContextProvider::SetGLRendererCopierRequiredState(
decoder_->RestoreGlobalState(); decoder_->RestoreGlobalState();
decoder_->RestoreBufferBindings(); decoder_->RestoreBufferBindings();
// At this point |decoder_| cached state (if any, passthrough doesn't cache)
// is synced with GLContext state. But GLES2Implementation caches some state
// too and we need to make sure this are in sync with |decoder_| and context
constexpr static std::initializer_list<GLuint> caps = {
GL_SCISSOR_TEST, GL_STENCIL_TEST, GL_BLEND};
for (auto cap : caps) {
if (gles2_implementation_->IsEnabled(cap))
gles2_cmd_helper_->Enable(cap);
else
gles2_cmd_helper_->Disable(cap);
}
if (texture_client_id) { if (texture_client_id) {
if (!framebuffer_id_) if (!framebuffer_id_)
gles2_implementation_->GenFramebuffers(1, &framebuffer_id_); gles2_implementation_->GenFramebuffers(1, &framebuffer_id_);
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "gpu/command_buffer/common/shared_image_usage.h" #include "gpu/command_buffer/common/shared_image_usage.h"
#include "gpu/command_buffer/common/swap_buffers_complete_params.h" #include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "gpu/command_buffer/service/context_state.h" #include "gpu/command_buffer/service/context_state.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h"
#include "gpu/command_buffer/service/gr_shader_cache.h" #include "gpu/command_buffer/service/gr_shader_cache.h"
#include "gpu/command_buffer/service/mailbox_manager.h" #include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/service/scheduler.h" #include "gpu/command_buffer/service/scheduler.h"
...@@ -260,36 +261,62 @@ class ScopedSurfaceToTexture { ...@@ -260,36 +261,62 @@ class ScopedSurfaceToTexture {
public: public:
ScopedSurfaceToTexture(scoped_refptr<DirectContextProvider> context_provider, ScopedSurfaceToTexture(scoped_refptr<DirectContextProvider> context_provider,
SkSurface* surface) SkSurface* surface)
: context_provider_(context_provider) { : context_provider_(context_provider),
client_id_(context_provider->GenClientTextureId()) {
GrBackendTexture skia_texture = GrBackendTexture skia_texture =
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess); surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess);
GrGLTextureInfo gl_texture_info; GrGLTextureInfo gl_texture_info;
skia_texture.getGLTextureInfo(&gl_texture_info); skia_texture.getGLTextureInfo(&gl_texture_info);
GLuint client_id = context_provider_->GenClientTextureId();
auto* texture_manager = context_provider_->texture_manager(); auto* group = context_provider->decoder()->GetContextGroup();
texture_ref_ = if (group->use_passthrough_cmd_decoder()) {
texture_manager->CreateTexture(client_id, gl_texture_info.fID); group->passthrough_resources()->texture_id_map.SetIDMapping(
texture_manager->SetTarget(texture_ref_.get(), gl_texture_info.fTarget); client_id_, gl_texture_info.fID);
texture_manager->SetLevelInfo(
texture_ref_.get(), gl_texture_info.fTarget, auto texture = base::MakeRefCounted<gpu::gles2::TexturePassthrough>(
/*level=*/0, gl_texture_info.fID, gl_texture_info.fTarget, GL_RGBA,
/*internal_format=*/GL_RGBA, surface->width(), surface->height(), surface->width(), surface->height(),
/*depth=*/1, /*border=*/0, /*depth=*/1, /*border=*/0,
/*format=*/GL_RGBA, /*type=*/GL_UNSIGNED_BYTE, /*format=*/GL_RGBA, /*type=*/GL_UNSIGNED_BYTE);
/*cleared_rect=*/gfx::Rect(surface->width(), surface->height()));
group->passthrough_resources()->texture_object_map.SetIDMapping(
client_id_, texture);
} else {
auto* texture_manager = context_provider_->texture_manager();
texture_ref_ =
texture_manager->CreateTexture(client_id_, gl_texture_info.fID);
texture_manager->SetTarget(texture_ref_.get(), gl_texture_info.fTarget);
texture_manager->SetLevelInfo(
texture_ref_.get(), gl_texture_info.fTarget,
/*level=*/0,
/*internal_format=*/GL_RGBA, surface->width(), surface->height(),
/*depth=*/1, /*border=*/0,
/*format=*/GL_RGBA, /*type=*/GL_UNSIGNED_BYTE,
/*cleared_rect=*/gfx::Rect(surface->width(), surface->height()));
}
} }
~ScopedSurfaceToTexture() { ~ScopedSurfaceToTexture() {
context_provider_->DeleteClientTextureId(client_id()); auto* group = context_provider_->decoder()->GetContextGroup();
// Skia owns the texture. It will delete it when it is done. // Skia owns the texture. It will delete it when it is done.
texture_ref_->ForceContextLost(); if (group->use_passthrough_cmd_decoder()) {
group->passthrough_resources()
->texture_object_map.GetServiceIDOrInvalid(client_id_)
->MarkContextLost();
} else {
texture_ref_->ForceContextLost();
}
context_provider_->DeleteClientTextureId(client_id());
} }
GLuint client_id() { return texture_ref_->client_id(); } GLuint client_id() { return client_id_; }
private: private:
scoped_refptr<DirectContextProvider> context_provider_; scoped_refptr<DirectContextProvider> context_provider_;
const GLuint client_id_;
// This is only used with validating gles cmd decoder
scoped_refptr<gpu::gles2::TextureRef> texture_ref_; scoped_refptr<gpu::gles2::TextureRef> texture_ref_;
DISALLOW_COPY_AND_ASSIGN(ScopedSurfaceToTexture); DISALLOW_COPY_AND_ASSIGN(ScopedSurfaceToTexture);
......
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