Commit f1f1d17d authored by Geoff Lang's avatar Geoff Lang Committed by Commit Bot

Report GPU progress while destroying shared GPU resources.

GPU progress would only be reported after destroying all resources in
PassthroughResources but when many objects were allocated the entire process
could cause GPU hangs.  Report progress after each texture, buffer,
renderbuffer or program is destroyed to ensure that no hangs are detected
during this process.

BUG=1027064

Change-Id: I24fe4c89499f642e2137fd4b8b59d007b7690fcd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1934587Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720013}
parent 17bf185d
......@@ -629,7 +629,7 @@ void ContextGroup::Destroy(DecoderContext* decoder, bool have_context) {
if (passthrough_resources_) {
gl::GLApi* api = have_context ? gl::g_current_gl_context : nullptr;
passthrough_resources_->Destroy(api);
passthrough_resources_->Destroy(api, progress_reporter_);
passthrough_resources_.reset();
ReportProgress();
}
......
......@@ -24,6 +24,7 @@
#include "gpu/command_buffer/service/program_cache.h"
#include "gpu/command_buffer/service/shared_image_representation.h"
#include "ui/gl/gl_version_info.h"
#include "ui/gl/progress_reporter.h"
#if defined(OS_WIN)
#include "gpu/command_buffer/service/shared_image_backing_factory_d3d.h"
......@@ -176,32 +177,49 @@ bool PassthroughResources::HasTexturesPendingDestruction() const {
return !textures_pending_destruction.empty();
}
void PassthroughResources::Destroy(gl::GLApi* api) {
void PassthroughResources::Destroy(gl::GLApi* api,
gl::ProgressReporter* progress_reporter) {
bool have_context = !!api;
// Only delete textures that are not referenced by a TexturePassthrough
// object, they handle their own deletion once all references are lost
DeleteServiceObjects(&texture_id_map, have_context,
[this, api](GLuint client_id, GLuint texture) {
if (!texture_object_map.HasClientID(client_id)) {
api->glDeleteTexturesFn(1, &texture);
}
});
DeleteServiceObjects(&buffer_id_map, have_context,
[api](GLuint client_id, GLuint buffer) {
api->glDeleteBuffersARBFn(1, &buffer);
});
DeleteServiceObjects(&renderbuffer_id_map, have_context,
[api](GLuint client_id, GLuint renderbuffer) {
api->glDeleteRenderbuffersEXTFn(1, &renderbuffer);
});
DeleteServiceObjects(
&texture_id_map, have_context,
[this, api, progress_reporter](GLuint client_id, GLuint texture) {
if (!texture_object_map.HasClientID(client_id)) {
api->glDeleteTexturesFn(1, &texture);
if (progress_reporter) {
progress_reporter->ReportProgress();
}
}
});
DeleteServiceObjects(
&buffer_id_map, have_context,
[api, progress_reporter](GLuint client_id, GLuint buffer) {
api->glDeleteBuffersARBFn(1, &buffer);
if (progress_reporter) {
progress_reporter->ReportProgress();
}
});
DeleteServiceObjects(
&renderbuffer_id_map, have_context,
[api, progress_reporter](GLuint client_id, GLuint renderbuffer) {
api->glDeleteRenderbuffersEXTFn(1, &renderbuffer);
if (progress_reporter) {
progress_reporter->ReportProgress();
}
});
DeleteServiceObjects(&sampler_id_map, have_context,
[api](GLuint client_id, GLuint sampler) {
api->glDeleteSamplersFn(1, &sampler);
});
DeleteServiceObjects(&program_id_map, have_context,
[api](GLuint client_id, GLuint program) {
api->glDeleteProgramFn(program);
});
DeleteServiceObjects(
&program_id_map, have_context,
[api, progress_reporter](GLuint client_id, GLuint program) {
api->glDeleteProgramFn(program);
if (progress_reporter) {
progress_reporter->ReportProgress();
}
});
DeleteServiceObjects(&shader_id_map, have_context,
[api](GLuint client_id, GLuint shader) {
api->glDeleteShaderFn(shader);
......
......@@ -38,6 +38,7 @@
namespace gl {
class GLFence;
class ProgressReporter;
}
namespace gpu {
......@@ -64,7 +65,7 @@ struct PassthroughResources {
~PassthroughResources();
// api is null if we don't have a context (e.g. lost).
void Destroy(gl::GLApi* api);
void Destroy(gl::GLApi* api, gl::ProgressReporter* progress_reporter);
// Resources stores a shared list of textures pending deletion.
// If we have don't context when this function is called, we can mark
......
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