Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: gpu/command_buffer/service/texture_manager.cc

Issue 1286193008: Reland of "gpu: workaround force_cube_map_positive_x_allocation fixes Android crash." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update the version Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/texture_manager.cc
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
index 84cc266494ce81dd5ac8bf0dcc19a4e3bc3dfd11..e4b6e03ba00d17fedb261e8ea8d6c741dc179882 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -1972,6 +1972,59 @@ void TextureManager::ValidateAndDoTexImage(
return;
}
+ // ValidateTexImage is passed already.
+ Texture* texture = texture_ref->texture();
+ bool need_cube_map_workaround =
+ texture->target() == GL_TEXTURE_CUBE_MAP &&
+ (texture_state->force_cube_complete ||
+ (texture_state->force_cube_map_positive_x_allocation &&
+ args.target != GL_TEXTURE_CUBE_MAP_POSITIVE_X));
+ if (need_cube_map_workaround) {
+ std::vector<GLenum> undefined_faces;
+ if (texture_state->force_cube_complete) {
+ int width = 0;
+ int height = 0;
+ for (unsigned i = 0; i < 6; i++) {
+ bool defined =
+ texture->GetLevelSize(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
+ args.level, &width, &height, nullptr);
+ if (!defined || GL_TEXTURE_CUBE_MAP_POSITIVE_X + i == args.target)
+ undefined_faces.push_back(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i);
+ }
+ } else if (texture_state->force_cube_map_positive_x_allocation &&
+ args.target != GL_TEXTURE_CUBE_MAP_POSITIVE_X) {
+ int width = 0;
+ int height = 0;
+ if (!texture->GetLevelSize(GL_TEXTURE_CUBE_MAP_POSITIVE_X, args.level,
+ &width, &height, nullptr)) {
+ undefined_faces.push_back(GL_TEXTURE_CUBE_MAP_POSITIVE_X);
+ }
+ undefined_faces.push_back(args.target);
+ }
+
+ DCHECK(undefined_faces.size());
+ if (!memory_tracker_managed_->EnsureGPUMemoryAvailable(
+ undefined_faces.size() * args.pixels_size)) {
+ ERRORSTATE_SET_GL_ERROR(state->GetErrorState(), GL_OUT_OF_MEMORY,
+ function_name, "out of memory");
+ return;
+ }
+ DoTexImageArguments new_args = args;
+ scoped_ptr<char[]> zero(new char[args.pixels_size]);
+ memset(zero.get(), 0, args.pixels_size);
+ for (GLenum face : undefined_faces) {
+ new_args.target = face;
+ if (face == args.target) {
+ new_args.pixels = args.pixels;
+ } else {
+ new_args.pixels = zero.get();
+ }
+ DoTexImage(texture_state, state->GetErrorState(), framebuffer_state,
+ function_name, texture_ref, new_args);
+ }
+ return;
+ }
+
DoTexImage(texture_state, state->GetErrorState(), framebuffer_state,
function_name, texture_ref, args);
}
« no previous file with comments | « gpu/command_buffer/service/texture_manager.h ('k') | gpu/command_buffer/tests/gl_cube_map_texture_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698