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 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; | |
1992 positive_x_args.target = GL_TEXTURE_CUBE_MAP_POSITIVE_X; | |
1993 positive_x_args.pixels = nullptr; | |
1994 positive_x_args.pixels_size = 0; | |
no sievers
2015/08/13 18:56:38
You actually have to get this from ComputeImageDat
dshwang
2015/08/14 06:22:56
|pixels_size| is used in ValidateTexImage(), not
| |
1995 DoTexImage(texture_state, error_state, framebuffer_state, function_name, | |
1996 texture_ref, positive_x_args); | |
1997 } | |
1998 } | |
1999 | |
1958 void TextureManager::DoTexImage( | 2000 void TextureManager::DoTexImage( |
1959 DecoderTextureState* texture_state, | 2001 DecoderTextureState* texture_state, |
1960 ErrorState* error_state, | 2002 ErrorState* error_state, |
1961 DecoderFramebufferState* framebuffer_state, | 2003 DecoderFramebufferState* framebuffer_state, |
1962 const char* function_name, | 2004 const char* function_name, |
1963 TextureRef* texture_ref, | 2005 TextureRef* texture_ref, |
1964 const DoTexImageArguments& args) { | 2006 const DoTexImageArguments& args) { |
1965 Texture* texture = texture_ref->texture(); | 2007 Texture* texture = texture_ref->texture(); |
1966 GLsizei tex_width = 0; | 2008 GLsizei tex_width = 0; |
1967 GLsizei tex_height = 0; | 2009 GLsizei tex_height = 0; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2099 // The link to the memory tracking |client_id| is given a higher importance | 2141 // The link to the memory tracking |client_id| is given a higher importance |
2100 // than other refs. | 2142 // than other refs. |
2101 if (ref == ref->texture()->memory_tracking_ref_) | 2143 if (ref == ref->texture()->memory_tracking_ref_) |
2102 importance = 2; | 2144 importance = 2; |
2103 | 2145 |
2104 pmd->AddOwnershipEdge(client_guid, service_guid, importance); | 2146 pmd->AddOwnershipEdge(client_guid, service_guid, importance); |
2105 } | 2147 } |
2106 | 2148 |
2107 } // namespace gles2 | 2149 } // namespace gles2 |
2108 } // namespace gpu | 2150 } // namespace gpu |
OLD | NEW |