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

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 *params = GLES2Util::GetGLReadPixelsImplementationFormat(
5070 GetBoundReadFrameBufferInternalFormat()); 5070 GetBoundReadFrameBufferInternalFormat());
5071 } 5071 }
5072 return true; 5072 return true;
5073 case GL_IMPLEMENTATION_COLOR_READ_TYPE: 5073 case GL_IMPLEMENTATION_COLOR_READ_TYPE:
5074 *num_written = 1; 5074 *num_written = 1;
5075 if (params) { 5075 if (params) {
5076 if (context_->HasExtension("GL_OES_read_format")) { 5076 if (context_->HasExtension("GL_OES_read_format")) {
5077 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper", 5077 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper",
5078 GetErrorState()); 5078 GetErrorState());
5079 glGetIntegerv(pname, params); 5079 glGetIntegerv(pname, params);
5080 if (glGetError() == GL_NO_ERROR) 5080 if (glGetError() == GL_NO_ERROR)
5081 return true; 5081 return true;
5082 } 5082 }
5083 *params = GLES2Util::GetPreferredGLReadPixelsType( 5083 *params = GLES2Util::GetGLReadPixelsImplementationType(
5084 GetBoundReadFrameBufferInternalFormat(), 5084 GetBoundReadFrameBufferInternalFormat(),
5085 GetBoundReadFrameBufferTextureType()); 5085 GetBoundReadFrameBufferTextureType());
5086 } 5086 }
5087 return true; 5087 return true;
5088 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: 5088 case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
5089 *num_written = 1; 5089 *num_written = 1;
5090 if (params) { 5090 if (params) {
5091 *params = group_->max_fragment_uniform_vectors(); 5091 *params = group_->max_fragment_uniform_vectors();
5092 } 5092 }
5093 return true; 5093 return true;
(...skipping 3651 matching lines...) Expand 10 before | Expand all | Expand 10 after
8745 8745
8746 GLenum src_internal_format = GetBoundReadFrameBufferInternalFormat(); 8746 GLenum src_internal_format = GetBoundReadFrameBufferInternalFormat();
8747 if (src_internal_format == 0) { 8747 if (src_internal_format == 0) {
8748 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels", 8748 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels",
8749 "no valid read buffer source"); 8749 "no valid read buffer source");
8750 return error::kNoError; 8750 return error::kNoError;
8751 } 8751 }
8752 std::vector<GLenum> accepted_formats; 8752 std::vector<GLenum> accepted_formats;
8753 std::vector<GLenum> accepted_types; 8753 std::vector<GLenum> accepted_types;
8754 switch (src_internal_format) { 8754 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: 8755 case GL_R8UI:
8759 case GL_R16UI: 8756 case GL_R16UI:
8760 case GL_R32UI: 8757 case GL_R32UI:
8761 case GL_RG8UI: 8758 case GL_RG8UI:
8762 case GL_RG16UI: 8759 case GL_RG16UI:
8763 case GL_RG32UI: 8760 case GL_RG32UI:
8764 // All the RGB_INTEGER formats are not renderable. 8761 // All the RGB_INTEGER formats are not renderable.
8765 case GL_RGBA8UI: 8762 case GL_RGBA8UI:
8763 case GL_RGB10_A2UI:
8766 case GL_RGBA16UI: 8764 case GL_RGBA16UI:
8767 case GL_RGBA32UI: 8765 case GL_RGBA32UI:
8768 accepted_formats.push_back(GL_RGBA_INTEGER); 8766 accepted_formats.push_back(GL_RGBA_INTEGER);
8769 accepted_types.push_back(GL_UNSIGNED_INT); 8767 accepted_types.push_back(GL_UNSIGNED_INT);
8770 break; 8768 break;
8771 case GL_R8I: 8769 case GL_R8I:
8772 case GL_R16I: 8770 case GL_R16I:
8773 case GL_R32I: 8771 case GL_R32I:
8774 case GL_RG8I: 8772 case GL_RG8I:
8775 case GL_RG16I: 8773 case GL_RG16I:
8776 case GL_RG32I: 8774 case GL_RG32I:
8777 case GL_RGBA8I: 8775 case GL_RGBA8I:
8778 case GL_RGBA16I: 8776 case GL_RGBA16I:
8779 case GL_RGBA32I: 8777 case GL_RGBA32I:
8780 accepted_formats.push_back(GL_RGBA_INTEGER); 8778 accepted_formats.push_back(GL_RGBA_INTEGER);
8781 accepted_types.push_back(GL_INT); 8779 accepted_types.push_back(GL_INT);
8782 break; 8780 break;
8781 case GL_RGB10_A2:
8782 accepted_formats.push_back(GL_RGBA);
8783 accepted_types.push_back(GL_UNSIGNED_BYTE);
8784 // Special case with an extra supported format/type.
8785 accepted_formats.push_back(GL_RGBA);
8786 accepted_types.push_back(GL_UNSIGNED_INT_2_10_10_10_REV);
8787 break;
8783 default: 8788 default:
8784 accepted_formats.push_back(GL_RGBA); 8789 accepted_formats.push_back(GL_RGBA);
8785 { 8790 {
8786 GLenum src_type = GetBoundReadFrameBufferTextureType(); 8791 GLenum src_type = GetBoundReadFrameBufferTextureType();
8787 switch (src_type) { 8792 switch (src_type) {
8788 case GL_HALF_FLOAT: 8793 case GL_HALF_FLOAT:
8789 case GL_HALF_FLOAT_OES: 8794 case GL_HALF_FLOAT_OES:
8790 case GL_FLOAT: 8795 case GL_FLOAT:
8791 case GL_UNSIGNED_INT_10F_11F_11F_REV: 8796 case GL_UNSIGNED_INT_10F_11F_11F_REV:
8792 accepted_types.push_back(GL_FLOAT); 8797 accepted_types.push_back(GL_FLOAT);
(...skipping 6261 matching lines...) Expand 10 before | Expand all | Expand 10 after
15054 return error::kNoError; 15059 return error::kNoError;
15055 } 15060 }
15056 15061
15057 // Include the auto-generated part of this file. We split this because it means 15062 // 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 15063 // 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. 15064 // instead of having to edit some template or the code generator.
15060 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15065 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15061 15066
15062 } // namespace gles2 15067 } // namespace gles2
15063 } // namespace gpu 15068 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698