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

Side by Side Diff: gpu/command_buffer/service/texture_manager.cc

Issue 1280163004: gpu: workaround force_cube_map_positive_x_allocation fixes Android crash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bug about cube incomplete fbo 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/texture_manager.h" 5 #include "gpu/command_buffer/service/texture_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 DecoderTextureState* texture_state, 1932 DecoderTextureState* texture_state,
1933 ContextState* state, 1933 ContextState* state,
1934 DecoderFramebufferState* framebuffer_state, 1934 DecoderFramebufferState* framebuffer_state,
1935 const char* function_name, 1935 const char* function_name,
1936 const DoTexImageArguments& args) { 1936 const DoTexImageArguments& args) {
1937 TextureRef* texture_ref; 1937 TextureRef* texture_ref;
1938 if (!ValidateTexImage(state, function_name, args, &texture_ref)) { 1938 if (!ValidateTexImage(state, function_name, args, &texture_ref)) {
1939 return; 1939 return;
1940 } 1940 }
1941 1941
1942 if (texture_state->force_cube_map_positive_x_allocation) {
1943 DoTexImage2DCubeMapPositiveXIfNeeded(texture_state, state->GetErrorState(),
1944 framebuffer_state, function_name,
1945 texture_ref, args);
1946 }
1947
1942 DoTexImage(texture_state, state->GetErrorState(), framebuffer_state, 1948 DoTexImage(texture_state, state->GetErrorState(), framebuffer_state,
1943 function_name, texture_ref, args); 1949 function_name, texture_ref, args);
1944 } 1950 }
1945 1951
1946 GLenum TextureManager::AdjustTexFormat(GLenum format) const { 1952 GLenum TextureManager::AdjustTexFormat(GLenum format) const {
1947 // TODO(bajones): GLES 3 allows for internal format and format to differ. 1953 // TODO(bajones): GLES 3 allows for internal format and format to differ.
1948 // This logic may need to change as a result. 1954 // This logic may need to change as a result.
1949 if (gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGL) { 1955 if (gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGL) {
1950 if (format == GL_SRGB_EXT) 1956 if (format == GL_SRGB_EXT)
1951 return GL_RGB; 1957 return GL_RGB;
1952 if (format == GL_SRGB_ALPHA_EXT) 1958 if (format == GL_SRGB_ALPHA_EXT)
1953 return GL_RGBA; 1959 return GL_RGBA;
1954 } 1960 }
1955 return format; 1961 return format;
1956 } 1962 }
1957 1963
1964 // Nexus 5 crashes on allocating a cube map texture bound to FBO, if
1965 // the CUBE_MAP_POSITIVE_X texture is not allocated yet.
1966 void TextureManager::DoTexImage2DCubeMapPositiveXIfNeeded(
1967 DecoderTextureState* texture_state,
1968 ErrorState* error_state,
1969 DecoderFramebufferState* framebuffer_state,
1970 const char* function_name,
1971 TextureRef* texture_ref,
1972 const DoTexImageArguments& args) {
1973 switch (args.target) {
1974 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1975 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1976 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1977 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1978 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1979 break;
1980 default:
1981 return;
1982 }
1983
1984 // ValidateTexImage is passed already.
1985 Texture* texture = texture_ref->texture();
1986 int width = 0;
1987 int height = 0;
1988 bool positive_x_level_defined = texture->GetLevelSize(
1989 GL_TEXTURE_CUBE_MAP_POSITIVE_X, args.level, &width, &height, nullptr);
1990 if (!positive_x_level_defined) {
1991 DoTexImageArguments positive_x_args = args;
no sievers 2015/08/11 21:07:39 I don't think we should use the pixels passed in w
dshwang 2015/08/12 08:06:09 Good point. I'll reset pixels to nullptr like regu
no sievers 2015/08/12 18:54:05 I don't think it's true that it needs to be comple
dshwang 2015/08/13 09:12:35 Yes, I incorrectly explained the implementation de
1992 positive_x_args.target = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
1993 DoTexImage(texture_state, error_state, framebuffer_state, function_name,
1994 texture_ref, positive_x_args);
1995 }
1996 }
1997
1958 void TextureManager::DoTexImage( 1998 void TextureManager::DoTexImage(
1959 DecoderTextureState* texture_state, 1999 DecoderTextureState* texture_state,
1960 ErrorState* error_state, 2000 ErrorState* error_state,
1961 DecoderFramebufferState* framebuffer_state, 2001 DecoderFramebufferState* framebuffer_state,
1962 const char* function_name, 2002 const char* function_name,
1963 TextureRef* texture_ref, 2003 TextureRef* texture_ref,
1964 const DoTexImageArguments& args) { 2004 const DoTexImageArguments& args) {
1965 Texture* texture = texture_ref->texture(); 2005 Texture* texture = texture_ref->texture();
1966 GLsizei tex_width = 0; 2006 GLsizei tex_width = 0;
1967 GLsizei tex_height = 0; 2007 GLsizei tex_height = 0;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 // The link to the memory tracking |client_id| is given a higher importance 2139 // The link to the memory tracking |client_id| is given a higher importance
2100 // than other refs. 2140 // than other refs.
2101 if (ref == ref->texture()->memory_tracking_ref_) 2141 if (ref == ref->texture()->memory_tracking_ref_)
2102 importance = 2; 2142 importance = 2;
2103 2143
2104 pmd->AddOwnershipEdge(client_guid, service_guid, importance); 2144 pmd->AddOwnershipEdge(client_guid, service_guid, importance);
2105 } 2145 }
2106 2146
2107 } // namespace gles2 2147 } // namespace gles2
2108 } // namespace gpu 2148 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698