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

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

Issue 2348243002: Force CUBE_MAP_POSITIVE_X texture allocation before CopyTexImage2D on Intel Mac (Closed)
Patch Set: update version Created 4 years, 3 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 2384 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 ERRORSTATE_SET_GL_ERROR(error_state, GL_OUT_OF_MEMORY, function_name, 2395 ERRORSTATE_SET_GL_ERROR(error_state, GL_OUT_OF_MEMORY, function_name,
2396 "out of memory"); 2396 "out of memory");
2397 return false; 2397 return false;
2398 } 2398 }
2399 2399
2400 // Write the TextureReference since this is valid. 2400 // Write the TextureReference since this is valid.
2401 *texture_ref = local_texture_ref; 2401 *texture_ref = local_texture_ref;
2402 return true; 2402 return true;
2403 } 2403 }
2404 2404
2405 void TextureManager::DoCubeMapWorkaround(
2406 DecoderTextureState* texture_state,
2407 ContextState* state,
2408 DecoderFramebufferState* framebuffer_state,
2409 TextureRef* texture_ref,
2410 const char* function_name,
2411 const DoTexImageArguments& args) {
2412 std::vector<GLenum> undefined_faces;
2413 Texture* texture = texture_ref->texture();
2414 if (texture_state->force_cube_complete) {
2415 int width = 0;
2416 int height = 0;
2417 for (unsigned i = 0; i < 6; i++) {
2418 GLenum target = static_cast<GLenum>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i);
2419 bool defined = texture->GetLevelSize(
2420 target, args.level, &width, &height, nullptr);
2421 if (!defined && target != args.target)
2422 undefined_faces.push_back(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i);
2423 }
2424 } else {
piman 2016/09/20 20:51:44 Do we need to restrict this path to if args.target
qiankun 2016/09/21 02:38:16 Add the restriction to WorkaroundCopyTexImageCubeM
2425 int width = 0;
2426 int height = 0;
2427 if (!texture->GetLevelSize(GL_TEXTURE_CUBE_MAP_POSITIVE_X, args.level,
2428 &width, &height, nullptr)) {
2429 undefined_faces.push_back(GL_TEXTURE_CUBE_MAP_POSITIVE_X);
2430 }
2431 }
2432 if (!memory_type_tracker_->EnsureGPUMemoryAvailable(
2433 (undefined_faces.size() + 1) * args.pixels_size)) {
2434 ERRORSTATE_SET_GL_ERROR(state->GetErrorState(), GL_OUT_OF_MEMORY,
2435 function_name, "out of memory");
2436 return;
2437 }
2438 DoTexImageArguments new_args = args;
2439 std::unique_ptr<char[]> zero(new char[args.pixels_size]);
2440 memset(zero.get(), 0, args.pixels_size);
2441 for (GLenum face : undefined_faces) {
2442 new_args.target = face;
2443 new_args.pixels = zero.get();
2444 DoTexImage(texture_state, state, framebuffer_state,
piman 2016/09/20 20:51:44 The comment on l.2472 explains that this code only
qiankun 2016/09/21 02:38:16 I resolved this TODO: reset unpack buffer before t
2445 function_name, texture_ref, new_args);
2446 texture->MarkLevelAsInternalWorkaround(face, args.level);
2447 }
2448 }
2449
2405 void TextureManager::ValidateAndDoTexImage( 2450 void TextureManager::ValidateAndDoTexImage(
2406 DecoderTextureState* texture_state, 2451 DecoderTextureState* texture_state,
2407 ContextState* state, 2452 ContextState* state,
2408 DecoderFramebufferState* framebuffer_state, 2453 DecoderFramebufferState* framebuffer_state,
2409 const char* function_name, 2454 const char* function_name,
2410 const DoTexImageArguments& args) { 2455 const DoTexImageArguments& args) {
2411 TextureRef* texture_ref; 2456 TextureRef* texture_ref;
2412 if (!ValidateTexImage(state, function_name, args, &texture_ref)) { 2457 if (!ValidateTexImage(state, function_name, args, &texture_ref)) {
2413 return; 2458 return;
2414 } 2459 }
2415 2460
2416 Buffer* buffer = state->bound_pixel_unpack_buffer.get(); 2461 Buffer* buffer = state->bound_pixel_unpack_buffer.get();
2417 2462
2418 // ValidateTexImage is passed already. 2463 // ValidateTexImage is passed already.
2419 Texture* texture = texture_ref->texture(); 2464 Texture* texture = texture_ref->texture();
2420 bool need_cube_map_workaround = 2465 bool need_cube_map_workaround =
2421 !feature_info_->IsES3Enabled() && 2466 !feature_info_->IsES3Enabled() &&
2422 texture->target() == GL_TEXTURE_CUBE_MAP && 2467 texture->target() == GL_TEXTURE_CUBE_MAP &&
2423 (texture_state->force_cube_complete || 2468 (texture_state->force_cube_complete ||
2424 (texture_state->force_cube_map_positive_x_allocation && 2469 (texture_state->force_cube_map_positive_x_allocation &&
2425 args.target != GL_TEXTURE_CUBE_MAP_POSITIVE_X)); 2470 args.target != GL_TEXTURE_CUBE_MAP_POSITIVE_X));
2426 if (need_cube_map_workaround && !buffer) { 2471 if (need_cube_map_workaround && !buffer) {
2427 // TODO(zmo): The following code does not work with an unpack buffer bound. 2472 // TODO(zmo): The following code does not work with an unpack buffer bound.
2428 std::vector<GLenum> undefined_faces; 2473 DoCubeMapWorkaround(texture_state, state, framebuffer_state,
2429 if (texture_state->force_cube_complete) { 2474 texture_ref, function_name, args);
2430 int width = 0;
2431 int height = 0;
2432 for (unsigned i = 0; i < 6; i++) {
2433 GLenum target = static_cast<GLenum>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i);
2434 bool defined = texture->GetLevelSize(
2435 target, args.level, &width, &height, nullptr);
2436 if (!defined && target != args.target)
2437 undefined_faces.push_back(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i);
2438 }
2439 } else {
2440 DCHECK(texture_state->force_cube_map_positive_x_allocation &&
2441 args.target != GL_TEXTURE_CUBE_MAP_POSITIVE_X);
2442 int width = 0;
2443 int height = 0;
2444 if (!texture->GetLevelSize(GL_TEXTURE_CUBE_MAP_POSITIVE_X, args.level,
2445 &width, &height, nullptr)) {
2446 undefined_faces.push_back(GL_TEXTURE_CUBE_MAP_POSITIVE_X);
2447 }
2448 }
2449 if (!memory_type_tracker_->EnsureGPUMemoryAvailable(
2450 (undefined_faces.size() + 1) * args.pixels_size)) {
2451 ERRORSTATE_SET_GL_ERROR(state->GetErrorState(), GL_OUT_OF_MEMORY,
2452 function_name, "out of memory");
2453 return;
2454 }
2455 DoTexImageArguments new_args = args;
2456 std::unique_ptr<char[]> zero(new char[args.pixels_size]);
2457 memset(zero.get(), 0, args.pixels_size);
2458 for (GLenum face : undefined_faces) {
2459 new_args.target = face;
2460 new_args.pixels = zero.get();
2461 DoTexImage(texture_state, state, framebuffer_state,
2462 function_name, texture_ref, new_args);
2463 texture->MarkLevelAsInternalWorkaround(face, args.level);
2464 }
2465 } 2475 }
2466 2476
2467 if (texture_state->unpack_overlapping_rows_separately_unpack_buffer && 2477 if (texture_state->unpack_overlapping_rows_separately_unpack_buffer &&
2468 buffer) { 2478 buffer) {
2469 ContextState::Dimension dimension = 2479 ContextState::Dimension dimension =
2470 (args.command_type == DoTexImageArguments::kTexImage3D) 2480 (args.command_type == DoTexImageArguments::kTexImage3D)
2471 ? ContextState::k3D 2481 ? ContextState::k3D
2472 : ContextState::k2D; 2482 : ContextState::k2D;
2473 const PixelStoreParams unpack_params(state->GetUnpackParams(dimension)); 2483 const PixelStoreParams unpack_params(state->GetUnpackParams(dimension));
2474 if (unpack_params.row_length != 0 && 2484 if (unpack_params.row_length != 0 &&
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
3418 uint32_t TextureManager::GetServiceIdGeneration() const { 3428 uint32_t TextureManager::GetServiceIdGeneration() const {
3419 return current_service_id_generation_; 3429 return current_service_id_generation_;
3420 } 3430 }
3421 3431
3422 void TextureManager::IncrementServiceIdGeneration() { 3432 void TextureManager::IncrementServiceIdGeneration() {
3423 current_service_id_generation_++; 3433 current_service_id_generation_++;
3424 } 3434 }
3425 3435
3426 } // namespace gles2 3436 } // namespace gles2
3427 } // namespace gpu 3437 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698