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

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

Issue 2318313004: emulate srgb format for generateMipmap (Closed)
Patch Set: rebase code Created 4 years, 2 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/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 6093 matching lines...) Expand 10 before | Expand all | Expand 10 after
6104 target == GL_TEXTURE_2D) { 6104 target == GL_TEXTURE_2D) {
6105 if (base_level != 0 && 6105 if (base_level != 0 &&
6106 !tex->GetLevelType(target, 0, &type, &internal_format) && 6106 !tex->GetLevelType(target, 0, &type, &internal_format) &&
6107 tex->GetLevelType(target, tex->base_level(), &type, &internal_format)) { 6107 tex->GetLevelType(target, tex->base_level(), &type, &internal_format)) {
6108 format = TextureManager::ExtractFormatFromStorageFormat(internal_format); 6108 format = TextureManager::ExtractFormatFromStorageFormat(internal_format);
6109 glTexImage2D(target, 0, internal_format, 1, 1, 0, format, type, nullptr); 6109 glTexImage2D(target, 0, internal_format, 1, 1, 0, format, type, nullptr);
6110 texture_zero_level_set = true; 6110 texture_zero_level_set = true;
6111 } 6111 }
6112 } 6112 }
6113 6113
6114 glGenerateMipmapEXT(target); 6114 bool enable_srgb = 0;
6115 if (target == GL_TEXTURE_2D) {
6116 tex->GetLevelType(target, tex->base_level(), &type, &internal_format);
6117 enable_srgb =
6118 GetColorEncodingFromInternalFormat(internal_format) == GL_SRGB;
6119 }
6120 if (!enable_srgb || !feature_info_->feature_flags().desktop_srgb_support ||
6121 !workarounds().decode_encode_srgb_for_generatemipmap) {
6122 if (feature_info_->feature_flags().desktop_srgb_support) {
6123 state_.EnableDisableFramebufferSRGB(enable_srgb);
6124 }
6125 glGenerateMipmapEXT(target);
6126 } else {
6127 if (target == GL_TEXTURE_2D) {
6128 state_.EnableDisableFramebufferSRGB(true);
6129 if (!InitializeSRGBConverter("generateMipmap")) {
6130 return;
6131 }
6132 srgb_converter_->GenerateMipmap(this, tex, target);
6133 } else {
6134 // TODO(yizhou): If the target is GL_TEXTURE_3D or GL_TEXTURE_2D_ARRAY,
6135 // this change can not generate correct mipmap.
6136 glGenerateMipmapEXT(target);
6137 }
6138 }
6115 6139
6116 if (texture_zero_level_set) { 6140 if (texture_zero_level_set) {
6117 // This may have some unwanted side effects, but we expect command buffer 6141 // This may have some unwanted side effects, but we expect command buffer
6118 // validation to prevent you from doing anything weird with the texture 6142 // validation to prevent you from doing anything weird with the texture
6119 // after this, like calling texSubImage2D sucessfully. 6143 // after this, like calling texSubImage2D sucessfully.
6120 glTexImage2D(target, 0, internal_format, 0, 0, 0, format, type, nullptr); 6144 glTexImage2D(target, 0, internal_format, 0, 0, 0, format, type, nullptr);
6121 } 6145 }
6122 6146
6123 if (workarounds().set_texture_filter_before_generating_mipmap) { 6147 if (workarounds().set_texture_filter_before_generating_mipmap) {
6124 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, 6148 glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
(...skipping 12383 matching lines...) Expand 10 before | Expand all | Expand 10 after
18508 } 18532 }
18509 18533
18510 // Include the auto-generated part of this file. We split this because it means 18534 // Include the auto-generated part of this file. We split this because it means
18511 // we can easily edit the non-auto generated parts right here in this file 18535 // we can easily edit the non-auto generated parts right here in this file
18512 // instead of having to edit some template or the code generator. 18536 // instead of having to edit some template or the code generator.
18513 #include "base/macros.h" 18537 #include "base/macros.h"
18514 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18538 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18515 18539
18516 } // namespace gles2 18540 } // namespace gles2
18517 } // namespace gpu 18541 } // namespace gpu
OLDNEW
« no previous file with comments | « content/test/gpu/gpu_tests/webgl2_conformance_expectations.py ('k') | gpu/command_buffer/service/gles2_cmd_srgb_converter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698