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

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

Issue 1927593005: Fix ReadPixels from float fbo buffer in ES2/WebGL1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 bool SetCapabilityState(GLenum cap, bool enabled); 1276 bool SetCapabilityState(GLenum cap, bool enabled);
1277 1277
1278 // Infer color encoding from internalformat 1278 // Infer color encoding from internalformat
1279 static GLint GetColorEncodingFromInternalFormat(GLenum internalformat); 1279 static GLint GetColorEncodingFromInternalFormat(GLenum internalformat);
1280 1280
1281 // Check that the currently bound read framebuffer's color image 1281 // Check that the currently bound read framebuffer's color image
1282 // isn't the target texture of the glCopyTex{Sub}Image2D. 1282 // isn't the target texture of the glCopyTex{Sub}Image2D.
1283 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level); 1283 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level);
1284 1284
1285 // Check if a framebuffer meets our requirements. 1285 // Check if a framebuffer meets our requirements.
1286 // Generates |gl_error| if the framebuffer is incomplete.
1286 bool CheckFramebufferValid( 1287 bool CheckFramebufferValid(
1287 Framebuffer* framebuffer, 1288 Framebuffer* framebuffer,
1288 GLenum target, 1289 GLenum target,
1289 bool clear_uncleared_images, 1290 bool clear_uncleared_images,
1291 GLenum gl_error,
1290 const char* func_name); 1292 const char* func_name);
1291 1293
1292 bool CheckBoundDrawFramebufferValid( 1294 bool CheckBoundDrawFramebufferValid(
1293 bool clear_uncleared_images, const char* func_name); 1295 bool clear_uncleared_images, const char* func_name);
1294 bool CheckBoundReadFramebufferValid(const char* func_name); 1296 // Generates |gl_error| if the bound read fbo is incomplete.
1297 bool CheckBoundReadFramebufferValid(const char* func_name, GLenum gl_error);
1295 1298
1296 // Checks if the current program exists and is valid. If not generates the 1299 // Checks if the current program exists and is valid. If not generates the
1297 // appropriate GL error. Returns true if the current program is in a usable 1300 // appropriate GL error. Returns true if the current program is in a usable
1298 // state. 1301 // state.
1299 bool CheckCurrentProgram(const char* function_name); 1302 bool CheckCurrentProgram(const char* function_name);
1300 1303
1301 // Checks if the current program exists and is valid and that location is not 1304 // Checks if the current program exists and is valid and that location is not
1302 // -1. If the current program is not valid generates the appropriate GL 1305 // -1. If the current program is not valid generates the appropriate GL
1303 // error. Returns true if the current program is in a usable state and 1306 // error. Returns true if the current program is in a usable state and
1304 // location is not -1. 1307 // location is not -1.
(...skipping 2412 matching lines...) Expand 10 before | Expand all | Expand 10 after
3717 framebuffer_state_.bound_draw_framebuffer.get(), 3720 framebuffer_state_.bound_draw_framebuffer.get(),
3718 GetBackbufferServiceId()); 3721 GetBackbufferServiceId());
3719 } 3722 }
3720 OnFboChanged(); 3723 OnFboChanged();
3721 } 3724 }
3722 3725
3723 bool GLES2DecoderImpl::CheckFramebufferValid( 3726 bool GLES2DecoderImpl::CheckFramebufferValid(
3724 Framebuffer* framebuffer, 3727 Framebuffer* framebuffer,
3725 GLenum target, 3728 GLenum target,
3726 bool clear_uncleared_images, 3729 bool clear_uncleared_images,
3730 GLenum gl_error,
3727 const char* func_name) { 3731 const char* func_name) {
3728 if (!framebuffer) { 3732 if (!framebuffer) {
3729 if (surfaceless_) 3733 if (surfaceless_)
3730 return false; 3734 return false;
3731 if (backbuffer_needs_clear_bits_ && clear_uncleared_images) { 3735 if (backbuffer_needs_clear_bits_ && clear_uncleared_images) {
3732 glClearColor(0, 0, 0, BackBufferHasAlpha() ? 0 : 1.f); 3736 glClearColor(0, 0, 0, BackBufferHasAlpha() ? 0 : 1.f);
3733 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 3737 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
3734 glClearStencil(0); 3738 glClearStencil(0);
3735 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); 3739 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask);
3736 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); 3740 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask);
(...skipping 19 matching lines...) Expand all
3756 } 3760 }
3757 return true; 3761 return true;
3758 } 3762 }
3759 3763
3760 if (framebuffer_manager()->IsComplete(framebuffer)) { 3764 if (framebuffer_manager()->IsComplete(framebuffer)) {
3761 return true; 3765 return true;
3762 } 3766 }
3763 3767
3764 GLenum completeness = framebuffer->IsPossiblyComplete(feature_info_.get()); 3768 GLenum completeness = framebuffer->IsPossiblyComplete(feature_info_.get());
3765 if (completeness != GL_FRAMEBUFFER_COMPLETE) { 3769 if (completeness != GL_FRAMEBUFFER_COMPLETE) {
3766 LOCAL_SET_GL_ERROR( 3770 LOCAL_SET_GL_ERROR(gl_error, func_name, "framebuffer incomplete");
3767 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, "framebuffer incomplete");
3768 return false; 3771 return false;
3769 } 3772 }
3770 3773
3771 // Are all the attachments cleared? 3774 // Are all the attachments cleared?
3772 if (clear_uncleared_images && 3775 if (clear_uncleared_images &&
3773 (renderbuffer_manager()->HaveUnclearedRenderbuffers() || 3776 (renderbuffer_manager()->HaveUnclearedRenderbuffers() ||
3774 texture_manager()->HaveUnclearedMips())) { 3777 texture_manager()->HaveUnclearedMips())) {
3775 if (!framebuffer->IsCleared()) { 3778 if (!framebuffer->IsCleared()) {
3776 // Can we clear them? 3779 // Can we clear them?
3777 if (framebuffer->GetStatus(texture_manager(), target) != 3780 if (framebuffer->GetStatus(texture_manager(), target) !=
3778 GL_FRAMEBUFFER_COMPLETE) { 3781 GL_FRAMEBUFFER_COMPLETE) {
3779 LOCAL_SET_GL_ERROR( 3782 LOCAL_SET_GL_ERROR(
3780 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, 3783 gl_error, func_name, "framebuffer incomplete (clear)");
3781 "framebuffer incomplete (clear)");
3782 return false; 3784 return false;
3783 } 3785 }
3784 ClearUnclearedAttachments(target, framebuffer); 3786 ClearUnclearedAttachments(target, framebuffer);
3785 } 3787 }
3786 } 3788 }
3787 3789
3788 if (!framebuffer_manager()->IsComplete(framebuffer)) { 3790 if (!framebuffer_manager()->IsComplete(framebuffer)) {
3789 if (framebuffer->GetStatus(texture_manager(), target) != 3791 if (framebuffer->GetStatus(texture_manager(), target) !=
3790 GL_FRAMEBUFFER_COMPLETE) { 3792 GL_FRAMEBUFFER_COMPLETE) {
3791 LOCAL_SET_GL_ERROR( 3793 LOCAL_SET_GL_ERROR(
3792 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, 3794 gl_error, func_name, "framebuffer incomplete (check)");
3793 "framebuffer incomplete (check)");
3794 return false; 3795 return false;
3795 } 3796 }
3796 framebuffer_manager()->MarkAsComplete(framebuffer); 3797 framebuffer_manager()->MarkAsComplete(framebuffer);
3797 } 3798 }
3798 return true; 3799 return true;
3799 } 3800 }
3800 3801
3801 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid( 3802 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid(
3802 bool clear_uncleared_images, const char* func_name) { 3803 bool clear_uncleared_images, const char* func_name) {
3803 GLenum target = features().chromium_framebuffer_multisample ? 3804 GLenum target = features().chromium_framebuffer_multisample ?
3804 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; 3805 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER;
3805 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); 3806 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target);
3806 bool valid = CheckFramebufferValid( 3807 bool valid = CheckFramebufferValid(
3807 framebuffer, target, clear_uncleared_images, func_name); 3808 framebuffer, target, clear_uncleared_images,
3809 GL_INVALID_FRAMEBUFFER_OPERATION, func_name);
3808 if (valid && !features().chromium_framebuffer_multisample) 3810 if (valid && !features().chromium_framebuffer_multisample)
3809 OnUseFramebuffer(); 3811 OnUseFramebuffer();
3810 return valid; 3812 return valid;
3811 } 3813 }
3812 3814
3813 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid(const char* func_name) { 3815 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid(
3816 const char* func_name, GLenum gl_error) {
3814 GLenum target = features().chromium_framebuffer_multisample ? 3817 GLenum target = features().chromium_framebuffer_multisample ?
3815 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; 3818 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
3816 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); 3819 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target);
3817 bool valid = CheckFramebufferValid(framebuffer, target, true, func_name); 3820 bool valid = CheckFramebufferValid(
3821 framebuffer, target, true, gl_error, func_name);
3818 return valid; 3822 return valid;
3819 } 3823 }
3820 3824
3821 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( 3825 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat(
3822 GLenum internalformat) { 3826 GLenum internalformat) {
3823 switch (internalformat) { 3827 switch (internalformat) {
3824 case GL_SRGB_EXT: 3828 case GL_SRGB_EXT:
3825 case GL_SRGB_ALPHA_EXT: 3829 case GL_SRGB_ALPHA_EXT:
3826 case GL_SRGB8: 3830 case GL_SRGB8:
3827 case GL_SRGB8_ALPHA8: 3831 case GL_SRGB8_ALPHA8:
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
5247 } 5251 }
5248 GLenum error = LOCAL_PEEK_GL_ERROR("glGenerateMipmap"); 5252 GLenum error = LOCAL_PEEK_GL_ERROR("glGenerateMipmap");
5249 if (error == GL_NO_ERROR) { 5253 if (error == GL_NO_ERROR) {
5250 texture_manager()->MarkMipmapsGenerated(texture_ref); 5254 texture_manager()->MarkMipmapsGenerated(texture_ref);
5251 } 5255 }
5252 } 5256 }
5253 5257
5254 bool GLES2DecoderImpl::GetHelper( 5258 bool GLES2DecoderImpl::GetHelper(
5255 GLenum pname, GLint* params, GLsizei* num_written) { 5259 GLenum pname, GLint* params, GLsizei* num_written) {
5256 DCHECK(num_written); 5260 DCHECK(num_written);
5261 switch (pname) {
5262 case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
5263 case GL_IMPLEMENTATION_COLOR_READ_TYPE:
5264 // They are not supported on Desktop GL until 4.1, but could be exposed
5265 // through GL_OES_read_format extension. However, a conflicting extension
5266 // GL_ARB_ES2_compatibility specifies an error case when requested on
5267 // integer/floating point buffers.
5268 // To simpify the handling, we just query and check for GL errors. If an
5269 // GL error occur, we fall back to our internal implementation.
5270 *num_written = 1;
5271 if (!CheckBoundReadFramebufferValid("glGetIntegerv",
5272 GL_INVALID_OPERATION)) {
5273 if (params) {
5274 *params = 0;
5275 }
5276 return true;
5277 }
5278 if (params) {
5279 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper",
5280 GetErrorState());
5281 glGetIntegerv(pname, params);
5282 if (glGetError() != GL_NO_ERROR) {
5283 if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT) {
5284 *params = GLES2Util::GetGLReadPixelsImplementationFormat(
5285 GetBoundReadFrameBufferInternalFormat(),
5286 GetBoundReadFrameBufferTextureType(),
5287 feature_info_->feature_flags().ext_read_format_bgra);
5288 } else {
5289 *params = GLES2Util::GetGLReadPixelsImplementationType(
5290 GetBoundReadFrameBufferInternalFormat(),
5291 GetBoundReadFrameBufferTextureType());
5292 }
5293 }
5294 if (*params == GL_HALF_FLOAT &&
5295 (feature_info_->context_type() == CONTEXT_TYPE_WEBGL1 ||
5296 feature_info_->context_type() == CONTEXT_TYPE_OPENGLES2)) {
5297 *params = GL_HALF_FLOAT_OES;
5298 }
5299 }
5300 return true;
5301 default:
5302 break;
5303 }
5304
5257 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 5305 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
5258 switch (pname) { 5306 switch (pname) {
5259 case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
5260 *num_written = 1;
5261 // Return the GL implementation's preferred format and (see below type)
5262 // if we have the GL extension that exposes this. This allows the GPU
5263 // client to use the implementation's preferred format for glReadPixels
5264 // for optimisation.
5265 //
5266 // A conflicting extension (GL_ARB_ES2_compatibility) specifies an error
5267 // case when requested on integer/floating point buffers but which is
5268 // acceptable on GLES2 and with the GL_OES_read_format extension.
5269 //
5270 // Therefore if an error occurs we swallow the error and use the
5271 // internal implementation.
5272 if (params) {
5273 if (context_->HasExtension("GL_OES_read_format")) {
5274 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper",
5275 GetErrorState());
5276 glGetIntegerv(pname, params);
5277 if (glGetError() == GL_NO_ERROR)
5278 return true;
5279 }
5280 *params = GLES2Util::GetGLReadPixelsImplementationFormat(
5281 GetBoundReadFrameBufferInternalFormat(),
5282 GetBoundReadFrameBufferTextureType(),
5283 feature_info_->feature_flags().ext_read_format_bgra);
5284 }
5285 return true;
5286 case GL_IMPLEMENTATION_COLOR_READ_TYPE:
5287 *num_written = 1;
5288 if (params) {
5289 if (context_->HasExtension("GL_OES_read_format")) {
5290 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper",
5291 GetErrorState());
5292 glGetIntegerv(pname, params);
5293 if (glGetError() == GL_NO_ERROR)
5294 return true;
5295 }
5296 *params = GLES2Util::GetGLReadPixelsImplementationType(
5297 GetBoundReadFrameBufferInternalFormat(),
5298 GetBoundReadFrameBufferTextureType());
5299 }
5300 return true;
5301 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: 5307 case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
5302 *num_written = 1; 5308 *num_written = 1;
5303 if (params) { 5309 if (params) {
5304 *params = group_->max_fragment_uniform_vectors(); 5310 *params = group_->max_fragment_uniform_vectors();
5305 } 5311 }
5306 return true; 5312 return true;
5307 case GL_MAX_VARYING_VECTORS: 5313 case GL_MAX_VARYING_VECTORS:
5308 *num_written = 1; 5314 *num_written = 1;
5309 if (params) { 5315 if (params) {
5310 *params = group_->max_varying_vectors(); 5316 *params = group_->max_varying_vectors();
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
6666 } 6672 }
6667 } 6673 }
6668 6674
6669 void GLES2DecoderImpl::DoBlitFramebufferCHROMIUM( 6675 void GLES2DecoderImpl::DoBlitFramebufferCHROMIUM(
6670 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, 6676 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
6671 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, 6677 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
6672 GLbitfield mask, GLenum filter) { 6678 GLbitfield mask, GLenum filter) {
6673 DCHECK(!ShouldDeferReads() && !ShouldDeferDraws()); 6679 DCHECK(!ShouldDeferReads() && !ShouldDeferDraws());
6674 6680
6675 if (!CheckBoundDrawFramebufferValid(true, "glBlitFramebufferCHROMIUM") || 6681 if (!CheckBoundDrawFramebufferValid(true, "glBlitFramebufferCHROMIUM") ||
6676 !CheckBoundReadFramebufferValid("glBlitFramebufferCHROMIUM")) { 6682 !CheckBoundReadFramebufferValid("glBlitFramebufferCHROMIUM",
6683 GL_INVALID_FRAMEBUFFER_OPERATION)) {
6677 return; 6684 return;
6678 } 6685 }
6679 6686
6680 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 6687 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
6681 BlitFramebufferHelper( 6688 BlitFramebufferHelper(
6682 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 6689 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
6683 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, 6690 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST,
6684 state_.enable_flags.scissor_test); 6691 state_.enable_flags.scissor_test);
6685 } 6692 }
6686 6693
(...skipping 2769 matching lines...) Expand 10 before | Expand all | Expand 10 after
9456 9463
9457 if (!validators_->read_pixel_format.IsValid(format)) { 9464 if (!validators_->read_pixel_format.IsValid(format)) {
9458 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", format, "format"); 9465 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", format, "format");
9459 return error::kNoError; 9466 return error::kNoError;
9460 } 9467 }
9461 if (!validators_->read_pixel_type.IsValid(type)) { 9468 if (!validators_->read_pixel_type.IsValid(type)) {
9462 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", type, "type"); 9469 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", type, "type");
9463 return error::kNoError; 9470 return error::kNoError;
9464 } 9471 }
9465 9472
9466 if (!CheckBoundReadFramebufferValid("glReadPixels")) { 9473 if (!CheckBoundReadFramebufferValid("glReadPixels",
9474 GL_INVALID_FRAMEBUFFER_OPERATION)) {
9467 return error::kNoError; 9475 return error::kNoError;
9468 } 9476 }
9469 GLenum src_internal_format = GetBoundReadFrameBufferInternalFormat(); 9477 GLenum src_internal_format = GetBoundReadFrameBufferInternalFormat();
9470 if (src_internal_format == 0) { 9478 if (src_internal_format == 0) {
9471 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels", 9479 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels",
9472 "no valid color image"); 9480 "no valid color image");
9473 return error::kNoError; 9481 return error::kNoError;
9474 } 9482 }
9475 std::vector<GLenum> accepted_formats; 9483 std::vector<GLenum> accepted_formats;
9476 std::vector<GLenum> accepted_types; 9484 std::vector<GLenum> accepted_types;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
9510 break; 9518 break;
9511 default: 9519 default:
9512 accepted_formats.push_back(GL_RGBA); 9520 accepted_formats.push_back(GL_RGBA);
9513 { 9521 {
9514 GLenum src_type = GetBoundReadFrameBufferTextureType(); 9522 GLenum src_type = GetBoundReadFrameBufferTextureType();
9515 switch (src_type) { 9523 switch (src_type) {
9516 case GL_HALF_FLOAT: 9524 case GL_HALF_FLOAT:
9517 case GL_HALF_FLOAT_OES: 9525 case GL_HALF_FLOAT_OES:
9518 case GL_FLOAT: 9526 case GL_FLOAT:
9519 case GL_UNSIGNED_INT_10F_11F_11F_REV: 9527 case GL_UNSIGNED_INT_10F_11F_11F_REV:
9520 if (!feature_info_->IsES3Enabled()) { 9528 accepted_types.push_back(GL_FLOAT);
9521 accepted_types.push_back(GL_UNSIGNED_BYTE);
9522 } else {
9523 accepted_types.push_back(GL_FLOAT);
9524 }
9525 break; 9529 break;
9526 default: 9530 default:
9527 accepted_types.push_back(GL_UNSIGNED_BYTE); 9531 accepted_types.push_back(GL_UNSIGNED_BYTE);
9528 break; 9532 break;
9529 } 9533 }
9530 } 9534 }
9531 break; 9535 break;
9532 } 9536 }
9533 if (!feature_info_->IsWebGLContext()) { 9537 if (!feature_info_->IsWebGLContext()) {
9534 accepted_formats.push_back(GL_BGRA_EXT); 9538 accepted_formats.push_back(GL_BGRA_EXT);
(...skipping 17 matching lines...) Expand all
9552 if (format == static_cast<GLenum>(preferred_format) && 9556 if (format == static_cast<GLenum>(preferred_format) &&
9553 type == static_cast<GLenum>(preferred_type)) { 9557 type == static_cast<GLenum>(preferred_type)) {
9554 format_type_acceptable = true; 9558 format_type_acceptable = true;
9555 } 9559 }
9556 } 9560 }
9557 if (!format_type_acceptable) { 9561 if (!format_type_acceptable) {
9558 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels", 9562 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels",
9559 "format and type incompatible with the current read framebuffer"); 9563 "format and type incompatible with the current read framebuffer");
9560 return error::kNoError; 9564 return error::kNoError;
9561 } 9565 }
9566 if (type == GL_HALF_FLOAT_OES &&
9567 !(feature_info_->gl_version_info().is_es2)) {
9568 type = GL_HALF_FLOAT;
9569 }
9562 if (width == 0 || height == 0) { 9570 if (width == 0 || height == 0) {
9563 return error::kNoError; 9571 return error::kNoError;
9564 } 9572 }
9565 9573
9566 // Get the size of the current fbo or backbuffer. 9574 // Get the size of the current fbo or backbuffer.
9567 gfx::Size max_size = GetBoundReadFrameBufferSize(); 9575 gfx::Size max_size = GetBoundReadFrameBufferSize();
9568 9576
9569 int32_t max_x; 9577 int32_t max_x;
9570 int32_t max_y; 9578 int32_t max_y;
9571 if (!SafeAddInt32(x, width, &max_x) || !SafeAddInt32(y, height, &max_y)) { 9579 if (!SafeAddInt32(x, width, &max_x) || !SafeAddInt32(y, height, &max_y)) {
(...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after
11672 GL_INVALID_OPERATION, "glCopyTexImage2D", "texture is immutable"); 11680 GL_INVALID_OPERATION, "glCopyTexImage2D", "texture is immutable");
11673 return; 11681 return;
11674 } 11682 }
11675 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || 11683 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) ||
11676 border != 0) { 11684 border != 0) {
11677 LOCAL_SET_GL_ERROR( 11685 LOCAL_SET_GL_ERROR(
11678 GL_INVALID_VALUE, "glCopyTexImage2D", "dimensions out of range"); 11686 GL_INVALID_VALUE, "glCopyTexImage2D", "dimensions out of range");
11679 return; 11687 return;
11680 } 11688 }
11681 11689
11682 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D")) { 11690 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D",
11691 GL_INVALID_FRAMEBUFFER_OPERATION)) {
11683 return; 11692 return;
11684 } 11693 }
11685 11694
11686 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 11695 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
11687 if (read_format == 0) { 11696 if (read_format == 0) {
11688 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D", 11697 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D",
11689 "no valid color image"); 11698 "no valid color image");
11690 return; 11699 return;
11691 } 11700 }
11692 11701
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
11871 GLenum type = 0; 11880 GLenum type = 0;
11872 GLenum format = 0; 11881 GLenum format = 0;
11873 if (!texture->GetLevelType(target, level, &type, &format) || 11882 if (!texture->GetLevelType(target, level, &type, &format) ||
11874 !texture->ValidForTexture( 11883 !texture->ValidForTexture(
11875 target, level, xoffset, yoffset, 0, width, height, 1)) { 11884 target, level, xoffset, yoffset, 0, width, height, 1)) {
11876 LOCAL_SET_GL_ERROR( 11885 LOCAL_SET_GL_ERROR(
11877 GL_INVALID_VALUE, "glCopyTexSubImage2D", "bad dimensions."); 11886 GL_INVALID_VALUE, "glCopyTexSubImage2D", "bad dimensions.");
11878 return; 11887 return;
11879 } 11888 }
11880 11889
11881 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D")) { 11890 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D",
11891 GL_INVALID_FRAMEBUFFER_OPERATION)) {
11882 return; 11892 return;
11883 } 11893 }
11884 11894
11885 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 11895 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
11886 if (read_format == 0) { 11896 if (read_format == 0) {
11887 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D", 11897 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D",
11888 "no valid color image"); 11898 "no valid color image");
11889 return; 11899 return;
11890 } 11900 }
11891 // Check we have compatible formats. 11901 // Check we have compatible formats.
(...skipping 4495 matching lines...) Expand 10 before | Expand all | Expand 10 after
16387 } 16397 }
16388 16398
16389 // Include the auto-generated part of this file. We split this because it means 16399 // Include the auto-generated part of this file. We split this because it means
16390 // we can easily edit the non-auto generated parts right here in this file 16400 // we can easily edit the non-auto generated parts right here in this file
16391 // instead of having to edit some template or the code generator. 16401 // instead of having to edit some template or the code generator.
16392 #include "base/macros.h" 16402 #include "base/macros.h"
16393 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 16403 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
16394 16404
16395 } // namespace gles2 16405 } // namespace gles2
16396 } // namespace gpu 16406 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698