Chromium Code Reviews| 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 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1933 DecoderTextureState* texture_state, | 1933 DecoderTextureState* texture_state, |
| 1934 ContextState* state, | 1934 ContextState* state, |
| 1935 DecoderFramebufferState* framebuffer_state, | 1935 DecoderFramebufferState* framebuffer_state, |
| 1936 const char* function_name, | 1936 const char* function_name, |
| 1937 const DoTexImageArguments& args) { | 1937 const DoTexImageArguments& args) { |
| 1938 TextureRef* texture_ref; | 1938 TextureRef* texture_ref; |
| 1939 if (!ValidateTexImage(state, function_name, args, &texture_ref)) { | 1939 if (!ValidateTexImage(state, function_name, args, &texture_ref)) { |
| 1940 return; | 1940 return; |
| 1941 } | 1941 } |
| 1942 | 1942 |
| 1943 // ValidateTexImage is passed already. | |
| 1944 Texture* texture = texture_ref->texture(); | |
| 1945 if (texture->target() == GL_TEXTURE_CUBE_MAP) { | |
|
no sievers
2015/08/21 19:30:30
This breaks all cubemap uploads that don't go thro
dshwang
2015/08/27 06:09:53
yes, I made a mistake. Fixed.
| |
| 1946 std::vector<GLenum> undefined_faces; | |
| 1947 if (texture_state->force_cube_complete) { | |
| 1948 int width = 0; | |
| 1949 int height = 0; | |
| 1950 for (unsigned i = 0; i < 6; i++) { | |
| 1951 if (!texture->GetLevelSize(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, | |
|
no sievers
2015/08/21 19:30:30
Can't GetLevelSize() return true even though width
dshwang
2015/08/27 06:09:53
this routine check if the face is defined, not siz
| |
| 1952 args.level, &width, &height, nullptr)) | |
| 1953 undefined_faces.push_back(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i); | |
| 1954 } | |
| 1955 } else if (texture_state->force_cube_map_positive_x_allocation && | |
| 1956 args.target != GL_TEXTURE_CUBE_MAP_POSITIVE_X) { | |
| 1957 int width = 0; | |
| 1958 int height = 0; | |
| 1959 if (!texture->GetLevelSize(GL_TEXTURE_CUBE_MAP_POSITIVE_X, args.level, | |
| 1960 &width, &height, nullptr)) | |
| 1961 undefined_faces.push_back(GL_TEXTURE_CUBE_MAP_POSITIVE_X); | |
| 1962 undefined_faces.push_back(args.target); | |
| 1963 } | |
| 1964 | |
| 1965 if (!memory_tracker_managed_->EnsureGPUMemoryAvailable( | |
| 1966 undefined_faces.size() * args.pixels_size)) { | |
| 1967 ERRORSTATE_SET_GL_ERROR(state->GetErrorState(), GL_OUT_OF_MEMORY, | |
| 1968 function_name, "out of memory"); | |
| 1969 return; | |
| 1970 } | |
| 1971 DoTexImageArguments new_args = args; | |
| 1972 scoped_ptr<char[]> zero(new char[args.pixels_size]); | |
| 1973 memset(zero.get(), 0, args.pixels_size); | |
| 1974 for (GLenum face : undefined_faces) { | |
| 1975 new_args.target = face; | |
| 1976 if (face == args.target) { | |
| 1977 new_args.pixels = args.pixels; | |
| 1978 } else { | |
| 1979 new_args.pixels = zero.get(); | |
| 1980 } | |
| 1981 DoTexImage(texture_state, state->GetErrorState(), framebuffer_state, | |
| 1982 function_name, texture_ref, new_args); | |
| 1983 } | |
| 1984 return; | |
| 1985 } | |
| 1986 | |
| 1943 DoTexImage(texture_state, state->GetErrorState(), framebuffer_state, | 1987 DoTexImage(texture_state, state->GetErrorState(), framebuffer_state, |
| 1944 function_name, texture_ref, args); | 1988 function_name, texture_ref, args); |
| 1945 } | 1989 } |
| 1946 | 1990 |
| 1947 GLenum TextureManager::AdjustTexFormat(GLenum format) const { | 1991 GLenum TextureManager::AdjustTexFormat(GLenum format) const { |
| 1948 // TODO(bajones): GLES 3 allows for internal format and format to differ. | 1992 // TODO(bajones): GLES 3 allows for internal format and format to differ. |
| 1949 // This logic may need to change as a result. | 1993 // This logic may need to change as a result. |
| 1950 if (gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGL) { | 1994 if (gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGL) { |
| 1951 if (format == GL_SRGB_EXT) | 1995 if (format == GL_SRGB_EXT) |
| 1952 return GL_RGB; | 1996 return GL_RGB; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2100 // The link to the memory tracking |client_id| is given a higher importance | 2144 // The link to the memory tracking |client_id| is given a higher importance |
| 2101 // than other refs. | 2145 // than other refs. |
| 2102 if (ref == ref->texture()->memory_tracking_ref_) | 2146 if (ref == ref->texture()->memory_tracking_ref_) |
| 2103 importance = 2; | 2147 importance = 2; |
| 2104 | 2148 |
| 2105 pmd->AddOwnershipEdge(client_guid, service_guid, importance); | 2149 pmd->AddOwnershipEdge(client_guid, service_guid, importance); |
| 2106 } | 2150 } |
| 2107 | 2151 |
| 2108 } // namespace gles2 | 2152 } // namespace gles2 |
| 2109 } // namespace gpu | 2153 } // namespace gpu |
| OLD | NEW |