OLD | NEW |
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 Loading... |
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 if (!DoTexImage2DCubeMapPositiveXIfNeeded( | |
1944 texture_state, state->GetErrorState(), framebuffer_state, | |
1945 function_name, texture_ref, args)) { | |
1946 return; | |
1947 } | |
1948 } | |
1949 | |
1950 DoTexImage(texture_state, state->GetErrorState(), framebuffer_state, | 1942 DoTexImage(texture_state, state->GetErrorState(), framebuffer_state, |
1951 function_name, texture_ref, args); | 1943 function_name, texture_ref, args); |
1952 } | 1944 } |
1953 | 1945 |
1954 GLenum TextureManager::AdjustTexFormat(GLenum format) const { | 1946 GLenum TextureManager::AdjustTexFormat(GLenum format) const { |
1955 // TODO(bajones): GLES 3 allows for internal format and format to differ. | 1947 // TODO(bajones): GLES 3 allows for internal format and format to differ. |
1956 // This logic may need to change as a result. | 1948 // This logic may need to change as a result. |
1957 if (gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGL) { | 1949 if (gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGL) { |
1958 if (format == GL_SRGB_EXT) | 1950 if (format == GL_SRGB_EXT) |
1959 return GL_RGB; | 1951 return GL_RGB; |
1960 if (format == GL_SRGB_ALPHA_EXT) | 1952 if (format == GL_SRGB_ALPHA_EXT) |
1961 return GL_RGBA; | 1953 return GL_RGBA; |
1962 } | 1954 } |
1963 return format; | 1955 return format; |
1964 } | 1956 } |
1965 | 1957 |
1966 // Nexus 5 crashes on allocating a cube map texture bound to FBO, if | |
1967 // the CUBE_MAP_POSITIVE_X texture is not allocated yet. | |
1968 bool TextureManager::DoTexImage2DCubeMapPositiveXIfNeeded( | |
1969 DecoderTextureState* texture_state, | |
1970 ErrorState* error_state, | |
1971 DecoderFramebufferState* framebuffer_state, | |
1972 const char* function_name, | |
1973 TextureRef* texture_ref, | |
1974 const DoTexImageArguments& args) { | |
1975 switch (args.target) { | |
1976 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: | |
1977 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: | |
1978 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: | |
1979 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: | |
1980 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: | |
1981 break; | |
1982 default: | |
1983 return true; | |
1984 } | |
1985 | |
1986 // ValidateTexImage is passed already. | |
1987 Texture* texture = texture_ref->texture(); | |
1988 int width = 0; | |
1989 int height = 0; | |
1990 bool positive_x_level_defined = texture->GetLevelSize( | |
1991 GL_TEXTURE_CUBE_MAP_POSITIVE_X, args.level, &width, &height, nullptr); | |
1992 if (!positive_x_level_defined) { | |
1993 DoTexImageArguments positive_x_args = args; | |
1994 positive_x_args.target = GL_TEXTURE_CUBE_MAP_POSITIVE_X; | |
1995 positive_x_args.pixels = nullptr; | |
1996 if (!memory_tracker_managed_->EnsureGPUMemoryAvailable(2 * | |
1997 args.pixels_size)) { | |
1998 ERRORSTATE_SET_GL_ERROR(error_state, GL_OUT_OF_MEMORY, function_name, | |
1999 "out of memory"); | |
2000 return false; | |
2001 } | |
2002 DoTexImage(texture_state, error_state, framebuffer_state, function_name, | |
2003 texture_ref, positive_x_args); | |
2004 } | |
2005 return true; | |
2006 } | |
2007 | |
2008 void TextureManager::DoTexImage( | 1958 void TextureManager::DoTexImage( |
2009 DecoderTextureState* texture_state, | 1959 DecoderTextureState* texture_state, |
2010 ErrorState* error_state, | 1960 ErrorState* error_state, |
2011 DecoderFramebufferState* framebuffer_state, | 1961 DecoderFramebufferState* framebuffer_state, |
2012 const char* function_name, | 1962 const char* function_name, |
2013 TextureRef* texture_ref, | 1963 TextureRef* texture_ref, |
2014 const DoTexImageArguments& args) { | 1964 const DoTexImageArguments& args) { |
2015 Texture* texture = texture_ref->texture(); | 1965 Texture* texture = texture_ref->texture(); |
2016 GLsizei tex_width = 0; | 1966 GLsizei tex_width = 0; |
2017 GLsizei tex_height = 0; | 1967 GLsizei tex_height = 0; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2149 // The link to the memory tracking |client_id| is given a higher importance | 2099 // The link to the memory tracking |client_id| is given a higher importance |
2150 // than other refs. | 2100 // than other refs. |
2151 if (ref == ref->texture()->memory_tracking_ref_) | 2101 if (ref == ref->texture()->memory_tracking_ref_) |
2152 importance = 2; | 2102 importance = 2; |
2153 | 2103 |
2154 pmd->AddOwnershipEdge(client_guid, service_guid, importance); | 2104 pmd->AddOwnershipEdge(client_guid, service_guid, importance); |
2155 } | 2105 } |
2156 | 2106 |
2157 } // namespace gles2 | 2107 } // namespace gles2 |
2158 } // namespace gpu | 2108 } // namespace gpu |
OLD | NEW |