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

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

Issue 1308313008: Fix ReadPixels implementation specific read format/type on desktop GL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clear
Patch Set: Created 5 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/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 5048 matching lines...) Expand 10 before | Expand all | Expand 10 after
5059 // Therefore if an error occurs we swallow the error and use the 5059 // Therefore if an error occurs we swallow the error and use the
5060 // internal implementation. 5060 // internal implementation.
5061 if (params) { 5061 if (params) {
5062 if (context_->HasExtension("GL_OES_read_format")) { 5062 if (context_->HasExtension("GL_OES_read_format")) {
5063 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper", 5063 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper",
5064 GetErrorState()); 5064 GetErrorState());
5065 glGetIntegerv(pname, params); 5065 glGetIntegerv(pname, params);
5066 if (glGetError() == GL_NO_ERROR) 5066 if (glGetError() == GL_NO_ERROR)
5067 return true; 5067 return true;
5068 } 5068 }
5069 *params = GLES2Util::GetPreferredGLReadPixelsFormat( 5069 GLES2Util::TargetESVersion target_es_version =
5070 GetBoundReadFrameBufferInternalFormat()); 5070 feature_info_->IsES3Enabled() ? GLES2Util::kES3 : GLES2Util::kES2;
5071 *params = GLES2Util::GetGLReadPixelsImplementationFormat(
5072 GetBoundReadFrameBufferInternalFormat(), target_es_version);
5071 } 5073 }
5072 return true; 5074 return true;
5073 case GL_IMPLEMENTATION_COLOR_READ_TYPE: 5075 case GL_IMPLEMENTATION_COLOR_READ_TYPE:
5074 *num_written = 1; 5076 *num_written = 1;
5075 if (params) { 5077 if (params) {
5076 if (context_->HasExtension("GL_OES_read_format")) { 5078 if (context_->HasExtension("GL_OES_read_format")) {
5077 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper", 5079 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper",
5078 GetErrorState()); 5080 GetErrorState());
5079 glGetIntegerv(pname, params); 5081 glGetIntegerv(pname, params);
5080 if (glGetError() == GL_NO_ERROR) 5082 if (glGetError() == GL_NO_ERROR)
5081 return true; 5083 return true;
5082 } 5084 }
5083 *params = GLES2Util::GetPreferredGLReadPixelsType( 5085 GLES2Util::TargetESVersion target_es_version =
5086 feature_info_->IsES3Enabled() ? GLES2Util::kES3 : GLES2Util::kES2;
5087 *params = GLES2Util::GetGLReadPixelsImplementationType(
5084 GetBoundReadFrameBufferInternalFormat(), 5088 GetBoundReadFrameBufferInternalFormat(),
5085 GetBoundReadFrameBufferTextureType()); 5089 GetBoundReadFrameBufferTextureType(),
5090 target_es_version);
5086 } 5091 }
5087 return true; 5092 return true;
5088 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: 5093 case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
5089 *num_written = 1; 5094 *num_written = 1;
5090 if (params) { 5095 if (params) {
5091 *params = group_->max_fragment_uniform_vectors(); 5096 *params = group_->max_fragment_uniform_vectors();
5092 } 5097 }
5093 return true; 5098 return true;
5094 case GL_MAX_VARYING_VECTORS: 5099 case GL_MAX_VARYING_VECTORS:
5095 *num_written = 1; 5100 *num_written = 1;
(...skipping 3649 matching lines...) Expand 10 before | Expand all | Expand 10 after
8745 8750
8746 GLenum src_internal_format = GetBoundReadFrameBufferInternalFormat(); 8751 GLenum src_internal_format = GetBoundReadFrameBufferInternalFormat();
8747 if (src_internal_format == 0) { 8752 if (src_internal_format == 0) {
8748 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels", 8753 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels",
8749 "no valid read buffer source"); 8754 "no valid read buffer source");
8750 return error::kNoError; 8755 return error::kNoError;
8751 } 8756 }
8752 std::vector<GLenum> accepted_formats; 8757 std::vector<GLenum> accepted_formats;
8753 std::vector<GLenum> accepted_types; 8758 std::vector<GLenum> accepted_types;
8754 switch (src_internal_format) { 8759 switch (src_internal_format) {
8755 case GL_RGB10_A2UI:
8756 accepted_formats.push_back(GL_RGBA);
8757 accepted_types.push_back(GL_UNSIGNED_INT_2_10_10_10_REV);
8758 case GL_R8UI: 8760 case GL_R8UI:
8759 case GL_R16UI: 8761 case GL_R16UI:
8760 case GL_R32UI: 8762 case GL_R32UI:
8761 case GL_RG8UI: 8763 case GL_RG8UI:
8762 case GL_RG16UI: 8764 case GL_RG16UI:
8763 case GL_RG32UI: 8765 case GL_RG32UI:
8764 // All the RGB_INTEGER formats are not renderable. 8766 // All the RGB_INTEGER formats are not renderable.
8765 case GL_RGBA8UI: 8767 case GL_RGBA8UI:
8768 case GL_RGB10_A2UI:
8766 case GL_RGBA16UI: 8769 case GL_RGBA16UI:
8767 case GL_RGBA32UI: 8770 case GL_RGBA32UI:
8768 accepted_formats.push_back(GL_RGBA_INTEGER); 8771 accepted_formats.push_back(GL_RGBA_INTEGER);
8769 accepted_types.push_back(GL_UNSIGNED_INT); 8772 accepted_types.push_back(GL_UNSIGNED_INT);
8770 break; 8773 break;
8771 case GL_R8I: 8774 case GL_R8I:
8772 case GL_R16I: 8775 case GL_R16I:
8773 case GL_R32I: 8776 case GL_R32I:
8774 case GL_RG8I: 8777 case GL_RG8I:
8775 case GL_RG16I: 8778 case GL_RG16I:
8776 case GL_RG32I: 8779 case GL_RG32I:
8777 case GL_RGBA8I: 8780 case GL_RGBA8I:
8778 case GL_RGBA16I: 8781 case GL_RGBA16I:
8779 case GL_RGBA32I: 8782 case GL_RGBA32I:
8780 accepted_formats.push_back(GL_RGBA_INTEGER); 8783 accepted_formats.push_back(GL_RGBA_INTEGER);
8781 accepted_types.push_back(GL_INT); 8784 accepted_types.push_back(GL_INT);
8782 break; 8785 break;
8786 case GL_RGB10_A2:
8787 accepted_formats.push_back(GL_RGBA);
8788 accepted_types.push_back(GL_UNSIGNED_BYTE);
8789 // Special case with an extra supported format/type.
8790 accepted_formats.push_back(GL_RGBA);
8791 accepted_types.push_back(GL_UNSIGNED_INT_2_10_10_10_REV);
8792 break;
8783 default: 8793 default:
8784 accepted_formats.push_back(GL_RGBA); 8794 accepted_formats.push_back(GL_RGBA);
8785 { 8795 {
8786 GLenum src_type = GetBoundReadFrameBufferTextureType(); 8796 GLenum src_type = GetBoundReadFrameBufferTextureType();
8787 switch (src_type) { 8797 switch (src_type) {
8788 case GL_HALF_FLOAT: 8798 case GL_HALF_FLOAT:
8789 case GL_HALF_FLOAT_OES: 8799 case GL_HALF_FLOAT_OES:
8790 case GL_FLOAT: 8800 case GL_FLOAT:
8791 case GL_UNSIGNED_INT_10F_11F_11F_REV: 8801 case GL_UNSIGNED_INT_10F_11F_11F_REV:
8792 accepted_types.push_back(GL_FLOAT); 8802 if (!feature_info_->IsES3Enabled()) {
8803 accepted_types.push_back(GL_UNSIGNED_BYTE);
8804 } else {
8805 accepted_types.push_back(GL_FLOAT);
8806 }
Ken Russell (switch to Gerrit) 2015/08/27 01:45:45 I'm having difficulty understanding how the earlie
Zhenyao Mo 2015/08/27 03:13:31 It turned out we never tested RGBA/UNSIGNED_BYTE r
8793 break; 8807 break;
8794 default: 8808 default:
8795 accepted_types.push_back(GL_UNSIGNED_BYTE); 8809 accepted_types.push_back(GL_UNSIGNED_BYTE);
8796 break; 8810 break;
8797 } 8811 }
8798 } 8812 }
8799 break; 8813 break;
8800 } 8814 }
8801 if (!IsWebGLContext()) { 8815 if (!IsWebGLContext()) {
8802 accepted_formats.push_back(GL_BGRA_EXT); 8816 accepted_formats.push_back(GL_BGRA_EXT);
(...skipping 6251 matching lines...) Expand 10 before | Expand all | Expand 10 after
15054 return error::kNoError; 15068 return error::kNoError;
15055 } 15069 }
15056 15070
15057 // Include the auto-generated part of this file. We split this because it means 15071 // Include the auto-generated part of this file. We split this because it means
15058 // we can easily edit the non-auto generated parts right here in this file 15072 // we can easily edit the non-auto generated parts right here in this file
15059 // instead of having to edit some template or the code generator. 15073 // instead of having to edit some template or the code generator.
15060 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15074 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15061 15075
15062 } // namespace gles2 15076 } // namespace gles2
15063 } // namespace gpu 15077 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698