| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer_->service_id()); | 388 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer_->service_id()); |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 | 391 |
| 392 private: | 392 private: |
| 393 Buffer* buffer_; | 393 Buffer* buffer_; |
| 394 }; | 394 }; |
| 395 | 395 |
| 396 } // namespace anonymous | 396 } // namespace anonymous |
| 397 | 397 |
| 398 DecoderTextureState::DecoderTextureState( |
| 399 const GpuDriverBugWorkarounds& workarounds) |
| 400 : tex_image_failed(false), |
| 401 texture_upload_count(0), |
| 402 texsubimage_faster_than_teximage( |
| 403 workarounds.texsubimage_faster_than_teximage), |
| 404 force_cube_map_positive_x_allocation( |
| 405 workarounds.force_cube_map_positive_x_allocation), |
| 406 force_cube_complete(workarounds.force_cube_complete), |
| 407 force_int_or_srgb_cube_texture_complete( |
| 408 workarounds.force_int_or_srgb_cube_texture_complete), |
| 409 unpack_alignment_workaround_with_unpack_buffer( |
| 410 workarounds.unpack_alignment_workaround_with_unpack_buffer), |
| 411 unpack_overlapping_rows_separately_unpack_buffer( |
| 412 workarounds.unpack_overlapping_rows_separately_unpack_buffer), |
| 413 unpack_image_height_workaround_with_unpack_buffer( |
| 414 workarounds.unpack_image_height_workaround_with_unpack_buffer) {} |
| 415 |
| 398 TextureManager::DestructionObserver::DestructionObserver() {} | 416 TextureManager::DestructionObserver::DestructionObserver() {} |
| 399 | 417 |
| 400 TextureManager::DestructionObserver::~DestructionObserver() {} | 418 TextureManager::DestructionObserver::~DestructionObserver() {} |
| 401 | 419 |
| 402 TextureManager::~TextureManager() { | 420 TextureManager::~TextureManager() { |
| 403 for (unsigned int i = 0; i < destruction_observers_.size(); i++) | 421 for (unsigned int i = 0; i < destruction_observers_.size(); i++) |
| 404 destruction_observers_[i]->OnTextureManagerDestroying(this); | 422 destruction_observers_[i]->OnTextureManagerDestroying(this); |
| 405 | 423 |
| 406 DCHECK(textures_.empty()); | 424 DCHECK(textures_.empty()); |
| 407 | 425 |
| (...skipping 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2520 ContextState* state, | 2538 ContextState* state, |
| 2521 DecoderFramebufferState* framebuffer_state, | 2539 DecoderFramebufferState* framebuffer_state, |
| 2522 TextureRef* texture_ref, | 2540 TextureRef* texture_ref, |
| 2523 const char* function_name, | 2541 const char* function_name, |
| 2524 const DoTexImageArguments& args) { | 2542 const DoTexImageArguments& args) { |
| 2525 // This workaround code does not work with an unpack buffer bound. | 2543 // This workaround code does not work with an unpack buffer bound. |
| 2526 ScopedResetPixelUnpackBuffer scoped_reset_pbo(state); | 2544 ScopedResetPixelUnpackBuffer scoped_reset_pbo(state); |
| 2527 | 2545 |
| 2528 std::vector<GLenum> undefined_faces; | 2546 std::vector<GLenum> undefined_faces; |
| 2529 Texture* texture = texture_ref->texture(); | 2547 Texture* texture = texture_ref->texture(); |
| 2530 if (texture_state->force_cube_complete) { | 2548 if (texture_state->force_cube_complete || |
| 2549 texture_state->force_int_or_srgb_cube_texture_complete) { |
| 2531 int width = 0; | 2550 int width = 0; |
| 2532 int height = 0; | 2551 int height = 0; |
| 2533 for (unsigned i = 0; i < 6; i++) { | 2552 for (unsigned i = 0; i < 6; i++) { |
| 2534 GLenum target = static_cast<GLenum>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i); | 2553 GLenum target = static_cast<GLenum>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i); |
| 2535 bool defined = texture->GetLevelSize( | 2554 bool defined = texture->GetLevelSize( |
| 2536 target, args.level, &width, &height, nullptr); | 2555 target, args.level, &width, &height, nullptr); |
| 2537 if (!defined && target != args.target) | 2556 if (!defined && target != args.target) |
| 2538 undefined_faces.push_back(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i); | 2557 undefined_faces.push_back(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i); |
| 2539 } | 2558 } |
| 2540 } else { | 2559 } else { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2578 Buffer* buffer = state->bound_pixel_unpack_buffer.get(); | 2597 Buffer* buffer = state->bound_pixel_unpack_buffer.get(); |
| 2579 | 2598 |
| 2580 // ValidateTexImage is passed already. | 2599 // ValidateTexImage is passed already. |
| 2581 Texture* texture = texture_ref->texture(); | 2600 Texture* texture = texture_ref->texture(); |
| 2582 bool need_cube_map_workaround = | 2601 bool need_cube_map_workaround = |
| 2583 !feature_info_->IsWebGL2OrES3Context() && | 2602 !feature_info_->IsWebGL2OrES3Context() && |
| 2584 texture->target() == GL_TEXTURE_CUBE_MAP && | 2603 texture->target() == GL_TEXTURE_CUBE_MAP && |
| 2585 (texture_state->force_cube_complete || | 2604 (texture_state->force_cube_complete || |
| 2586 (texture_state->force_cube_map_positive_x_allocation && | 2605 (texture_state->force_cube_map_positive_x_allocation && |
| 2587 args.target != GL_TEXTURE_CUBE_MAP_POSITIVE_X)); | 2606 args.target != GL_TEXTURE_CUBE_MAP_POSITIVE_X)); |
| 2607 // Force integer or srgb cube map texture complete, see crbug.com/712117. |
| 2608 need_cube_map_workaround = |
| 2609 need_cube_map_workaround || |
| 2610 (texture->target() == GL_TEXTURE_CUBE_MAP && |
| 2611 texture_state->force_int_or_srgb_cube_texture_complete && |
| 2612 (GLES2Util::IsIntegerFormat(args.internal_format) || |
| 2613 GLES2Util::GetColorEncodingFromInternalFormat(args.internal_format) == |
| 2614 GL_SRGB)); |
| 2615 |
| 2588 if (need_cube_map_workaround && !buffer) { | 2616 if (need_cube_map_workaround && !buffer) { |
| 2589 DoCubeMapWorkaround(texture_state, state, framebuffer_state, | 2617 DoCubeMapWorkaround(texture_state, state, framebuffer_state, |
| 2590 texture_ref, function_name, args); | 2618 texture_ref, function_name, args); |
| 2591 } | 2619 } |
| 2592 | 2620 |
| 2593 if (texture_state->unpack_overlapping_rows_separately_unpack_buffer && | 2621 if (texture_state->unpack_overlapping_rows_separately_unpack_buffer && |
| 2594 buffer) { | 2622 buffer) { |
| 2595 ContextState::Dimension dimension = | 2623 ContextState::Dimension dimension = |
| 2596 (args.command_type == DoTexImageArguments::kTexImage3D) | 2624 (args.command_type == DoTexImageArguments::kTexImage3D) |
| 2597 ? ContextState::k3D | 2625 ? ContextState::k3D |
| (...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3656 uint32_t TextureManager::GetServiceIdGeneration() const { | 3684 uint32_t TextureManager::GetServiceIdGeneration() const { |
| 3657 return current_service_id_generation_; | 3685 return current_service_id_generation_; |
| 3658 } | 3686 } |
| 3659 | 3687 |
| 3660 void TextureManager::IncrementServiceIdGeneration() { | 3688 void TextureManager::IncrementServiceIdGeneration() { |
| 3661 current_service_id_generation_++; | 3689 current_service_id_generation_++; |
| 3662 } | 3690 } |
| 3663 | 3691 |
| 3664 } // namespace gles2 | 3692 } // namespace gles2 |
| 3665 } // namespace gpu | 3693 } // namespace gpu |
| OLD | NEW |