| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // are initialized in the constructor, it should never be modified later. | 265 // are initialized in the constructor, it should never be modified later. |
| 266 std::set<FormatType, FormatTypeCompare> supported_combinations_; | 266 std::set<FormatType, FormatTypeCompare> supported_combinations_; |
| 267 }; | 267 }; |
| 268 | 268 |
| 269 static const Texture::CompatibilitySwizzle kSwizzledFormats[] = { | 269 static const Texture::CompatibilitySwizzle kSwizzledFormats[] = { |
| 270 {GL_ALPHA, GL_RED, GL_ZERO, GL_ZERO, GL_ZERO, GL_RED}, | 270 {GL_ALPHA, GL_RED, GL_ZERO, GL_ZERO, GL_ZERO, GL_RED}, |
| 271 {GL_LUMINANCE, GL_RED, GL_RED, GL_RED, GL_RED, GL_ONE}, | 271 {GL_LUMINANCE, GL_RED, GL_RED, GL_RED, GL_RED, GL_ONE}, |
| 272 {GL_LUMINANCE_ALPHA, GL_RG, GL_RED, GL_RED, GL_RED, GL_GREEN}, | 272 {GL_LUMINANCE_ALPHA, GL_RG, GL_RED, GL_RED, GL_RED, GL_GREEN}, |
| 273 }; | 273 }; |
| 274 | 274 |
| 275 // static |
| 275 const Texture::CompatibilitySwizzle* GetCompatibilitySwizzle(GLenum format) { | 276 const Texture::CompatibilitySwizzle* GetCompatibilitySwizzle(GLenum format) { |
| 276 size_t count = arraysize(kSwizzledFormats); | 277 size_t count = arraysize(kSwizzledFormats); |
| 277 for (size_t i = 0; i < count; ++i) { | 278 for (size_t i = 0; i < count; ++i) { |
| 278 if (kSwizzledFormats[i].format == format) | 279 if (kSwizzledFormats[i].format == format) |
| 279 return &kSwizzledFormats[i]; | 280 return &kSwizzledFormats[i]; |
| 280 } | 281 } |
| 281 return nullptr; | 282 return nullptr; |
| 282 } | 283 } |
| 283 | 284 |
| 284 GLenum GetSwizzleForChannel(GLenum channel, | 285 GLenum GetSwizzleForChannel(GLenum channel, |
| (...skipping 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2642 if (full_image && !texture_state->texsubimage_faster_than_teximage && | 2643 if (full_image && !texture_state->texsubimage_faster_than_teximage && |
| 2643 !texture->IsImmutable() && !texture->HasImages()) { | 2644 !texture->IsImmutable() && !texture->HasImages()) { |
| 2644 ScopedTextureUploadTimer timer(texture_state); | 2645 ScopedTextureUploadTimer timer(texture_state); |
| 2645 GLenum internal_format; | 2646 GLenum internal_format; |
| 2646 GLenum tex_type; | 2647 GLenum tex_type; |
| 2647 texture->GetLevelType(args.target, args.level, &tex_type, &internal_format); | 2648 texture->GetLevelType(args.target, args.level, &tex_type, &internal_format); |
| 2648 // NOTE: In OpenGL ES 2/3 border is always zero. If that changes we'll need | 2649 // NOTE: In OpenGL ES 2/3 border is always zero. If that changes we'll need |
| 2649 // to look it up. | 2650 // to look it up. |
| 2650 if (args.command_type == DoTexSubImageArguments::kTexSubImage3D) { | 2651 if (args.command_type == DoTexSubImageArguments::kTexSubImage3D) { |
| 2651 glTexImage3D(args.target, args.level, internal_format, args.width, | 2652 glTexImage3D(args.target, args.level, internal_format, args.width, |
| 2652 args.height, args.depth, 0, AdjustTexFormat(args.format), | 2653 args.height, args.depth, 0, |
| 2653 args.type, args.pixels); | 2654 AdjustTexFormat(feature_info_.get(), args.format), args.type, |
| 2655 args.pixels); |
| 2654 } else { | 2656 } else { |
| 2655 glTexImage2D(args.target, args.level, | 2657 glTexImage2D( |
| 2656 AdjustTexInternalFormat(internal_format), args.width, | 2658 args.target, args.level, |
| 2657 args.height, 0, AdjustTexFormat(args.format), args.type, | 2659 AdjustTexInternalFormat(feature_info_.get(), internal_format), |
| 2658 args.pixels); | 2660 args.width, args.height, 0, |
| 2661 AdjustTexFormat(feature_info_.get(), args.format), args.type, |
| 2662 args.pixels); |
| 2659 } | 2663 } |
| 2660 } else { | 2664 } else { |
| 2661 ScopedTextureUploadTimer timer(texture_state); | 2665 ScopedTextureUploadTimer timer(texture_state); |
| 2662 if (args.command_type == DoTexSubImageArguments::kTexSubImage3D) { | 2666 if (args.command_type == DoTexSubImageArguments::kTexSubImage3D) { |
| 2663 glTexSubImage3D(args.target, args.level, args.xoffset, args.yoffset, | 2667 glTexSubImage3D(args.target, args.level, args.xoffset, args.yoffset, |
| 2664 args.zoffset, args.width, args.height, args.depth, | 2668 args.zoffset, args.width, args.height, args.depth, |
| 2665 AdjustTexFormat(args.format), args.type, args.pixels); | 2669 AdjustTexFormat(feature_info_.get(), args.format), |
| 2670 args.type, args.pixels); |
| 2666 } else { | 2671 } else { |
| 2667 glTexSubImage2D(args.target, args.level, args.xoffset, args.yoffset, | 2672 glTexSubImage2D(args.target, args.level, args.xoffset, args.yoffset, |
| 2668 args.width, args.height, AdjustTexFormat(args.format), | 2673 args.width, args.height, |
| 2674 AdjustTexFormat(feature_info_.get(), args.format), |
| 2669 args.type, args.pixels); | 2675 args.type, args.pixels); |
| 2670 } | 2676 } |
| 2671 } | 2677 } |
| 2672 } | 2678 } |
| 2673 | 2679 |
| 2674 void TextureManager::DoTexSubImageWithAlignmentWorkaround( | 2680 void TextureManager::DoTexSubImageWithAlignmentWorkaround( |
| 2675 DecoderTextureState* texture_state, | 2681 DecoderTextureState* texture_state, |
| 2676 ContextState* state, | 2682 ContextState* state, |
| 2677 const DoTexSubImageArguments& args) { | 2683 const DoTexSubImageArguments& args) { |
| 2678 DCHECK(state->bound_pixel_unpack_buffer.get()); | 2684 DCHECK(state->bound_pixel_unpack_buffer.get()); |
| 2679 DCHECK(args.width > 0 && args.height > 0 && args.depth > 0); | 2685 DCHECK(args.width > 0 && args.height > 0 && args.depth > 0); |
| 2680 | 2686 |
| 2681 ScopedTextureUploadTimer timer(texture_state); | 2687 ScopedTextureUploadTimer timer(texture_state); |
| 2682 uint32_t offset = ToGLuint(args.pixels); | 2688 uint32_t offset = ToGLuint(args.pixels); |
| 2683 if (args.command_type == DoTexSubImageArguments::kTexSubImage2D) { | 2689 if (args.command_type == DoTexSubImageArguments::kTexSubImage2D) { |
| 2684 PixelStoreParams params = state->GetUnpackParams(ContextState::k2D); | 2690 PixelStoreParams params = state->GetUnpackParams(ContextState::k2D); |
| 2685 if (args.height > 1) { | 2691 if (args.height > 1) { |
| 2686 glTexSubImage2D(args.target, args.level, args.xoffset, args.yoffset, | 2692 glTexSubImage2D(args.target, args.level, args.xoffset, args.yoffset, |
| 2687 args.width, args.height - 1, | 2693 args.width, args.height - 1, |
| 2688 AdjustTexFormat(args.format), args.type, args.pixels); | 2694 AdjustTexFormat(feature_info_.get(), args.format), |
| 2695 args.type, args.pixels); |
| 2689 GLint actual_width = state->unpack_row_length > 0 ? | 2696 GLint actual_width = state->unpack_row_length > 0 ? |
| 2690 state->unpack_row_length : args.width; | 2697 state->unpack_row_length : args.width; |
| 2691 uint32_t size; | 2698 uint32_t size; |
| 2692 uint32_t padding; | 2699 uint32_t padding; |
| 2693 // No need to worry about integer overflow here. | 2700 // No need to worry about integer overflow here. |
| 2694 GLES2Util::ComputeImageDataSizesES3(actual_width, args.height - 1, 1, | 2701 GLES2Util::ComputeImageDataSizesES3(actual_width, args.height - 1, 1, |
| 2695 args.format, args.type, | 2702 args.format, args.type, |
| 2696 params, | 2703 params, |
| 2697 &size, | 2704 &size, |
| 2698 nullptr, nullptr, nullptr, | 2705 nullptr, nullptr, nullptr, |
| 2699 &padding); | 2706 &padding); |
| 2700 DCHECK_EQ(args.padding, padding); | 2707 DCHECK_EQ(args.padding, padding); |
| 2701 // Last row should be padded, not unpadded. | 2708 // Last row should be padded, not unpadded. |
| 2702 offset += size + padding; | 2709 offset += size + padding; |
| 2703 } | 2710 } |
| 2704 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | 2711 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 2705 glTexSubImage2D(args.target, args.level, args.xoffset, | 2712 glTexSubImage2D(args.target, args.level, args.xoffset, |
| 2706 args.yoffset + args.height - 1, | 2713 args.yoffset + args.height - 1, args.width, 1, |
| 2707 args.width, 1, AdjustTexFormat(args.format), args.type, | 2714 AdjustTexFormat(feature_info_.get(), args.format), |
| 2708 reinterpret_cast<const void *>(offset)); | 2715 args.type, reinterpret_cast<const void*>(offset)); |
| 2709 glPixelStorei(GL_UNPACK_ALIGNMENT, state->unpack_alignment); | 2716 glPixelStorei(GL_UNPACK_ALIGNMENT, state->unpack_alignment); |
| 2710 { | 2717 { |
| 2711 uint32_t size; | 2718 uint32_t size; |
| 2712 GLES2Util::ComputeImageDataSizesES3(args.width, 1, 1, | 2719 GLES2Util::ComputeImageDataSizesES3(args.width, 1, 1, |
| 2713 args.format, args.type, | 2720 args.format, args.type, |
| 2714 params, | 2721 params, |
| 2715 &size, | 2722 &size, |
| 2716 nullptr, nullptr, nullptr, nullptr); | 2723 nullptr, nullptr, nullptr, nullptr); |
| 2717 offset += size; | 2724 offset += size; |
| 2718 } | 2725 } |
| 2719 } else { // kTexSubImage3D | 2726 } else { // kTexSubImage3D |
| 2720 PixelStoreParams params = state->GetUnpackParams(ContextState::k3D); | 2727 PixelStoreParams params = state->GetUnpackParams(ContextState::k3D); |
| 2721 GLint actual_width = state->unpack_row_length > 0 ? | 2728 GLint actual_width = state->unpack_row_length > 0 ? |
| 2722 state->unpack_row_length : args.width; | 2729 state->unpack_row_length : args.width; |
| 2723 if (args.depth > 1) { | 2730 if (args.depth > 1) { |
| 2724 glTexSubImage3D(args.target, args.level, args.xoffset, args.yoffset, | 2731 glTexSubImage3D(args.target, args.level, args.xoffset, args.yoffset, |
| 2725 args.zoffset, args.width, args.height, args.depth - 1, | 2732 args.zoffset, args.width, args.height, args.depth - 1, |
| 2726 AdjustTexFormat(args.format), args.type, args.pixels); | 2733 AdjustTexFormat(feature_info_.get(), args.format), |
| 2734 args.type, args.pixels); |
| 2727 GLint actual_height = state->unpack_image_height > 0 ? | 2735 GLint actual_height = state->unpack_image_height > 0 ? |
| 2728 state->unpack_image_height : args.height; | 2736 state->unpack_image_height : args.height; |
| 2729 uint32_t size; | 2737 uint32_t size; |
| 2730 uint32_t padding; | 2738 uint32_t padding; |
| 2731 // No need to worry about integer overflow here. | 2739 // No need to worry about integer overflow here. |
| 2732 GLES2Util::ComputeImageDataSizesES3(actual_width, actual_height, | 2740 GLES2Util::ComputeImageDataSizesES3(actual_width, actual_height, |
| 2733 args.depth - 1, | 2741 args.depth - 1, |
| 2734 args.format, args.type, | 2742 args.format, args.type, |
| 2735 params, | 2743 params, |
| 2736 &size, | 2744 &size, |
| 2737 nullptr, nullptr, nullptr, | 2745 nullptr, nullptr, nullptr, |
| 2738 &padding); | 2746 &padding); |
| 2739 DCHECK_EQ(args.padding, padding); | 2747 DCHECK_EQ(args.padding, padding); |
| 2740 // Last row should be padded, not unpadded. | 2748 // Last row should be padded, not unpadded. |
| 2741 offset += size + padding; | 2749 offset += size + padding; |
| 2742 } | 2750 } |
| 2743 if (args.height > 1) { | 2751 if (args.height > 1) { |
| 2744 glTexSubImage3D(args.target, args.level, args.xoffset, args.yoffset, | 2752 glTexSubImage3D(args.target, args.level, args.xoffset, args.yoffset, |
| 2745 args.zoffset + args.depth - 1, args.width, | 2753 args.zoffset + args.depth - 1, args.width, |
| 2746 args.height - 1, 1, AdjustTexFormat(args.format), | 2754 args.height - 1, 1, |
| 2755 AdjustTexFormat(feature_info_.get(), args.format), |
| 2747 args.type, reinterpret_cast<const void*>(offset)); | 2756 args.type, reinterpret_cast<const void*>(offset)); |
| 2748 uint32_t size; | 2757 uint32_t size; |
| 2749 uint32_t padding; | 2758 uint32_t padding; |
| 2750 // No need to worry about integer overflow here. | 2759 // No need to worry about integer overflow here. |
| 2751 GLES2Util::ComputeImageDataSizesES3(actual_width, args.height - 1, 1, | 2760 GLES2Util::ComputeImageDataSizesES3(actual_width, args.height - 1, 1, |
| 2752 args.format, args.type, | 2761 args.format, args.type, |
| 2753 params, | 2762 params, |
| 2754 &size, | 2763 &size, |
| 2755 nullptr, nullptr, nullptr, | 2764 nullptr, nullptr, nullptr, |
| 2756 &padding); | 2765 &padding); |
| 2757 DCHECK_EQ(args.padding, padding); | 2766 DCHECK_EQ(args.padding, padding); |
| 2758 // Last row should be padded, not unpadded. | 2767 // Last row should be padded, not unpadded. |
| 2759 offset += size + padding; | 2768 offset += size + padding; |
| 2760 } | 2769 } |
| 2761 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | 2770 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 2762 glTexSubImage3D(args.target, args.level, args.xoffset, | 2771 glTexSubImage3D(args.target, args.level, args.xoffset, |
| 2763 args.yoffset + args.height - 1, | 2772 args.yoffset + args.height - 1, |
| 2764 args.zoffset + args.depth - 1, | 2773 args.zoffset + args.depth - 1, args.width, 1, 1, |
| 2765 args.width, 1, 1, AdjustTexFormat(args.format), args.type, | 2774 AdjustTexFormat(feature_info_.get(), args.format), |
| 2766 reinterpret_cast<const void *>(offset)); | 2775 args.type, reinterpret_cast<const void*>(offset)); |
| 2767 glPixelStorei(GL_UNPACK_ALIGNMENT, state->unpack_alignment); | 2776 glPixelStorei(GL_UNPACK_ALIGNMENT, state->unpack_alignment); |
| 2768 { | 2777 { |
| 2769 uint32_t size; | 2778 uint32_t size; |
| 2770 GLES2Util::ComputeImageDataSizesES3(args.width, 1, 1, | 2779 GLES2Util::ComputeImageDataSizesES3(args.width, 1, 1, |
| 2771 args.format, args.type, | 2780 args.format, args.type, |
| 2772 params, | 2781 params, |
| 2773 &size, | 2782 &size, |
| 2774 nullptr, nullptr, nullptr, nullptr); | 2783 nullptr, nullptr, nullptr, nullptr); |
| 2775 offset += size; | 2784 offset += size; |
| 2776 } | 2785 } |
| 2777 } | 2786 } |
| 2778 DCHECK_EQ(ToGLuint(args.pixels) + args.pixels_size, offset); | 2787 DCHECK_EQ(ToGLuint(args.pixels) + args.pixels_size, offset); |
| 2779 } | 2788 } |
| 2780 | 2789 |
| 2781 void TextureManager::DoTexSubImageRowByRowWorkaround( | 2790 void TextureManager::DoTexSubImageRowByRowWorkaround( |
| 2782 DecoderTextureState* texture_state, | 2791 DecoderTextureState* texture_state, |
| 2783 ContextState* state, | 2792 ContextState* state, |
| 2784 const DoTexSubImageArguments& args, | 2793 const DoTexSubImageArguments& args, |
| 2785 const PixelStoreParams& unpack_params) { | 2794 const PixelStoreParams& unpack_params) { |
| 2786 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | 2795 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 2787 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); | 2796 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); |
| 2788 DCHECK_EQ(0, state->unpack_skip_pixels); | 2797 DCHECK_EQ(0, state->unpack_skip_pixels); |
| 2789 DCHECK_EQ(0, state->unpack_skip_rows); | 2798 DCHECK_EQ(0, state->unpack_skip_rows); |
| 2790 DCHECK_EQ(0, state->unpack_skip_images); | 2799 DCHECK_EQ(0, state->unpack_skip_images); |
| 2791 | 2800 |
| 2792 GLenum format = AdjustTexFormat(args.format); | 2801 GLenum format = AdjustTexFormat(feature_info_.get(), args.format); |
| 2793 | 2802 |
| 2794 GLsizei row_bytes = unpack_params.row_length * | 2803 GLsizei row_bytes = unpack_params.row_length * |
| 2795 GLES2Util::ComputeImageGroupSize(format, args.type); | 2804 GLES2Util::ComputeImageGroupSize(format, args.type); |
| 2796 GLsizei alignment_diff = row_bytes % unpack_params.alignment; | 2805 GLsizei alignment_diff = row_bytes % unpack_params.alignment; |
| 2797 if (alignment_diff != 0) { | 2806 if (alignment_diff != 0) { |
| 2798 row_bytes += unpack_params.alignment - alignment_diff; | 2807 row_bytes += unpack_params.alignment - alignment_diff; |
| 2799 } | 2808 } |
| 2800 DCHECK_EQ(0, row_bytes % unpack_params.alignment); | 2809 DCHECK_EQ(0, row_bytes % unpack_params.alignment); |
| 2801 if (args.command_type == DoTexSubImageArguments::kTexSubImage3D) { | 2810 if (args.command_type == DoTexSubImageArguments::kTexSubImage3D) { |
| 2802 GLsizei image_height = args.height; | 2811 GLsizei image_height = args.height; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2823 glTexSubImage2D(args.target, args.level, args.xoffset, row + args.yoffset, | 2832 glTexSubImage2D(args.target, args.level, args.xoffset, row + args.yoffset, |
| 2824 args.width, 1, format, args.type, row_pixels); | 2833 args.width, 1, format, args.type, row_pixels); |
| 2825 } | 2834 } |
| 2826 } | 2835 } |
| 2827 | 2836 |
| 2828 // Restore unpack state | 2837 // Restore unpack state |
| 2829 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_params.alignment); | 2838 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_params.alignment); |
| 2830 glPixelStorei(GL_UNPACK_ROW_LENGTH, unpack_params.row_length); | 2839 glPixelStorei(GL_UNPACK_ROW_LENGTH, unpack_params.row_length); |
| 2831 } | 2840 } |
| 2832 | 2841 |
| 2833 GLenum TextureManager::AdjustTexInternalFormat(GLenum format) const { | 2842 // static |
| 2834 if (feature_info_->gl_version_info().is_desktop_core_profile) { | 2843 GLenum TextureManager::AdjustTexInternalFormat( |
| 2844 const gles2::FeatureInfo* feature_info, |
| 2845 GLenum format) { |
| 2846 if (feature_info->gl_version_info().is_desktop_core_profile) { |
| 2835 const Texture::CompatibilitySwizzle* swizzle = | 2847 const Texture::CompatibilitySwizzle* swizzle = |
| 2836 GetCompatibilitySwizzle(format); | 2848 GetCompatibilitySwizzle(format); |
| 2837 if (swizzle) | 2849 if (swizzle) |
| 2838 return swizzle->dest_format; | 2850 return swizzle->dest_format; |
| 2839 } | 2851 } |
| 2840 return format; | 2852 return format; |
| 2841 } | 2853 } |
| 2842 | 2854 |
| 2843 GLenum TextureManager::AdjustTexFormat(GLenum format) const { | 2855 // static |
| 2856 GLenum TextureManager::AdjustTexFormat(const gles2::FeatureInfo* feature_info, |
| 2857 GLenum format) { |
| 2844 // TODO(bajones): GLES 3 allows for internal format and format to differ. | 2858 // TODO(bajones): GLES 3 allows for internal format and format to differ. |
| 2845 // This logic may need to change as a result. | 2859 // This logic may need to change as a result. |
| 2846 if (gl::GetGLImplementation() == gl::kGLImplementationDesktopGL) { | 2860 if (!feature_info->gl_version_info().is_es) { |
| 2847 if (format == GL_SRGB_EXT) | 2861 if (format == GL_SRGB_EXT) |
| 2848 return GL_RGB; | 2862 return GL_RGB; |
| 2849 if (format == GL_SRGB_ALPHA_EXT) | 2863 if (format == GL_SRGB_ALPHA_EXT) |
| 2850 return GL_RGBA; | 2864 return GL_RGBA; |
| 2851 } | 2865 } |
| 2852 if (feature_info_->gl_version_info().is_desktop_core_profile) { | 2866 if (feature_info->gl_version_info().is_desktop_core_profile) { |
| 2853 const Texture::CompatibilitySwizzle* swizzle = | 2867 const Texture::CompatibilitySwizzle* swizzle = |
| 2854 GetCompatibilitySwizzle(format); | 2868 GetCompatibilitySwizzle(format); |
| 2855 if (swizzle) | 2869 if (swizzle) |
| 2856 return swizzle->dest_format; | 2870 return swizzle->dest_format; |
| 2857 } | 2871 } |
| 2858 return format; | 2872 return format; |
| 2859 } | 2873 } |
| 2860 | 2874 |
| 2861 void TextureManager::DoTexImage( | 2875 void TextureManager::DoTexImage( |
| 2862 DecoderTextureState* texture_state, | 2876 DecoderTextureState* texture_state, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2901 if (texture_state->texsubimage_faster_than_teximage && | 2915 if (texture_state->texsubimage_faster_than_teximage && |
| 2902 level_is_same && args.pixels && !unpack_buffer_bound) { | 2916 level_is_same && args.pixels && !unpack_buffer_bound) { |
| 2903 { | 2917 { |
| 2904 ScopedTextureUploadTimer timer(texture_state); | 2918 ScopedTextureUploadTimer timer(texture_state); |
| 2905 if (args.command_type == DoTexImageArguments::kTexImage3D) { | 2919 if (args.command_type == DoTexImageArguments::kTexImage3D) { |
| 2906 glTexSubImage3D(args.target, args.level, 0, 0, 0, | 2920 glTexSubImage3D(args.target, args.level, 0, 0, 0, |
| 2907 args.width, args.height, args.depth, | 2921 args.width, args.height, args.depth, |
| 2908 args.format, args.type, args.pixels); | 2922 args.format, args.type, args.pixels); |
| 2909 } else { | 2923 } else { |
| 2910 glTexSubImage2D(args.target, args.level, 0, 0, args.width, args.height, | 2924 glTexSubImage2D(args.target, args.level, 0, 0, args.width, args.height, |
| 2911 AdjustTexFormat(args.format), args.type, args.pixels); | 2925 AdjustTexFormat(feature_info_.get(), args.format), |
| 2926 args.type, args.pixels); |
| 2912 } | 2927 } |
| 2913 } | 2928 } |
| 2914 SetLevelInfo(texture_ref, args.target, args.level, args.internal_format, | 2929 SetLevelInfo(texture_ref, args.target, args.level, args.internal_format, |
| 2915 args.width, args.height, args.depth, args.border, args.format, | 2930 args.width, args.height, args.depth, args.border, args.format, |
| 2916 args.type, gfx::Rect(args.width, args.height)); | 2931 args.type, gfx::Rect(args.width, args.height)); |
| 2917 texture_state->tex_image_failed = false; | 2932 texture_state->tex_image_failed = false; |
| 2918 return; | 2933 return; |
| 2919 } | 2934 } |
| 2920 | 2935 |
| 2921 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(error_state, function_name); | 2936 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(error_state, function_name); |
| 2922 { | 2937 { |
| 2923 ScopedTextureUploadTimer timer(texture_state); | 2938 ScopedTextureUploadTimer timer(texture_state); |
| 2924 if (args.command_type == DoTexImageArguments::kTexImage3D) { | 2939 if (args.command_type == DoTexImageArguments::kTexImage3D) { |
| 2925 glTexImage3D(args.target, args.level, args.internal_format, args.width, | 2940 glTexImage3D(args.target, args.level, args.internal_format, args.width, |
| 2926 args.height, args.depth, args.border, args.format, | 2941 args.height, args.depth, args.border, args.format, |
| 2927 args.type, args.pixels); | 2942 args.type, args.pixels); |
| 2928 } else { | 2943 } else { |
| 2929 glTexImage2D(args.target, args.level, | 2944 glTexImage2D( |
| 2930 AdjustTexInternalFormat(args.internal_format), args.width, | 2945 args.target, args.level, |
| 2931 args.height, args.border, AdjustTexFormat(args.format), | 2946 AdjustTexInternalFormat(feature_info_.get(), args.internal_format), |
| 2932 args.type, args.pixels); | 2947 args.width, args.height, args.border, |
| 2948 AdjustTexFormat(feature_info_.get(), args.format), args.type, |
| 2949 args.pixels); |
| 2933 } | 2950 } |
| 2934 } | 2951 } |
| 2935 GLenum error = ERRORSTATE_PEEK_GL_ERROR(error_state, function_name); | 2952 GLenum error = ERRORSTATE_PEEK_GL_ERROR(error_state, function_name); |
| 2936 if (args.command_type == DoTexImageArguments::kTexImage3D) { | 2953 if (args.command_type == DoTexImageArguments::kTexImage3D) { |
| 2937 UMA_HISTOGRAM_CUSTOM_ENUMERATION("GPU.Error.TexImage3D", error, | 2954 UMA_HISTOGRAM_CUSTOM_ENUMERATION("GPU.Error.TexImage3D", error, |
| 2938 GetAllGLErrors()); | 2955 GetAllGLErrors()); |
| 2939 } else { | 2956 } else { |
| 2940 UMA_HISTOGRAM_CUSTOM_ENUMERATION("GPU.Error.TexImage2D", error, | 2957 UMA_HISTOGRAM_CUSTOM_ENUMERATION("GPU.Error.TexImage2D", error, |
| 2941 GetAllGLErrors()); | 2958 GetAllGLErrors()); |
| 2942 } | 2959 } |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3309 uint32_t TextureManager::GetServiceIdGeneration() const { | 3326 uint32_t TextureManager::GetServiceIdGeneration() const { |
| 3310 return current_service_id_generation_; | 3327 return current_service_id_generation_; |
| 3311 } | 3328 } |
| 3312 | 3329 |
| 3313 void TextureManager::IncrementServiceIdGeneration() { | 3330 void TextureManager::IncrementServiceIdGeneration() { |
| 3314 current_service_id_generation_++; | 3331 current_service_id_generation_++; |
| 3315 } | 3332 } |
| 3316 | 3333 |
| 3317 } // namespace gles2 | 3334 } // namespace gles2 |
| 3318 } // namespace gpu | 3335 } // namespace gpu |
| OLD | NEW |