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

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

Issue 1403483002: Update CopyTexImage2D to do internal format validation in ES3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unsigned integer format Created 5 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 <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 bool SetCapabilityState(GLenum cap, bool enabled); 1560 bool SetCapabilityState(GLenum cap, bool enabled);
1561 1561
1562 // Check that the currently bound framebuffers are valid. 1562 // Check that the currently bound framebuffers are valid.
1563 // Generates GL error if not. 1563 // Generates GL error if not.
1564 bool CheckBoundFramebuffersValid(const char* func_name); 1564 bool CheckBoundFramebuffersValid(const char* func_name);
1565 1565
1566 // Check that the currently bound read framebuffer has a color image 1566 // Check that the currently bound read framebuffer has a color image
1567 // attached. Generates GL error if not. 1567 // attached. Generates GL error if not.
1568 bool CheckBoundReadFramebufferColorAttachment(const char* func_name); 1568 bool CheckBoundReadFramebufferColorAttachment(const char* func_name);
1569 1569
1570 // Get the value of GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the
1571 // framebuffer attachment corresponding to the read buffer.
1572 GLint GetReadFramebufferAttachmentColorEncoding();
1573
1570 // Check that the currently bound read framebuffer's color image 1574 // Check that the currently bound read framebuffer's color image
1571 // isn't the target texture of the glCopyTex{Sub}Image2D. 1575 // isn't the target texture of the glCopyTex{Sub}Image2D.
1572 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level); 1576 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level);
1573 1577
1574 // Check if a framebuffer meets our requirements. 1578 // Check if a framebuffer meets our requirements.
1575 bool CheckFramebufferValid( 1579 bool CheckFramebufferValid(
1576 Framebuffer* framebuffer, 1580 Framebuffer* framebuffer,
1577 GLenum target, 1581 GLenum target,
1578 const char* func_name); 1582 const char* func_name);
1579 1583
(...skipping 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after
4012 if (!framebuffer) 4016 if (!framebuffer)
4013 return true; 4017 return true;
4014 if (framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL) { 4018 if (framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL) {
4015 LOCAL_SET_GL_ERROR( 4019 LOCAL_SET_GL_ERROR(
4016 GL_INVALID_OPERATION, func_name, "no color image attached"); 4020 GL_INVALID_OPERATION, func_name, "no color image attached");
4017 return false; 4021 return false;
4018 } 4022 }
4019 return true; 4023 return true;
4020 } 4024 }
4021 4025
4026 GLint GLES2DecoderImpl::GetReadFramebufferAttachmentColorEncoding() {
4027 GLenum target = features().chromium_framebuffer_multisample ?
4028 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER_EXT;
4029 GLint v = GL_NONE;
4030 glGetFramebufferAttachmentParameterivEXT(
4031 target, GL_COLOR_ATTACHMENT0,
4032 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, &v);
4033 return v;
4034 }
4035
4022 bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop( 4036 bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop(
4023 TextureRef* texture, GLint level) { 4037 TextureRef* texture, GLint level) {
4024 Framebuffer* framebuffer = features().chromium_framebuffer_multisample ? 4038 Framebuffer* framebuffer = features().chromium_framebuffer_multisample ?
4025 framebuffer_state_.bound_read_framebuffer.get() : 4039 framebuffer_state_.bound_read_framebuffer.get() :
4026 framebuffer_state_.bound_draw_framebuffer.get(); 4040 framebuffer_state_.bound_draw_framebuffer.get();
4027 if (!framebuffer) 4041 if (!framebuffer)
4028 return false; 4042 return false;
4029 const Framebuffer::Attachment* attachment = framebuffer->GetAttachment( 4043 const Framebuffer::Attachment* attachment = framebuffer->GetAttachment(
4030 GL_COLOR_ATTACHMENT0); 4044 GL_COLOR_ATTACHMENT0);
4031 if (!attachment) 4045 if (!attachment)
(...skipping 6964 matching lines...) Expand 10 before | Expand all | Expand 10 after
10996 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 11010 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
10997 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); 11011 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format);
10998 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format); 11012 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format);
10999 11013
11000 if ((channels_needed & channels_exist) != channels_needed) { 11014 if ((channels_needed & channels_exist) != channels_needed) {
11001 LOCAL_SET_GL_ERROR( 11015 LOCAL_SET_GL_ERROR(
11002 GL_INVALID_OPERATION, "glCopyTexImage2D", "incompatible format"); 11016 GL_INVALID_OPERATION, "glCopyTexImage2D", "incompatible format");
11003 return; 11017 return;
11004 } 11018 }
11005 11019
11020 if (feature_info_->IsES3Enabled()) {
11021 GLint color_encoding = GetReadFramebufferAttachmentColorEncoding();
11022 if ((GL_LINEAR == color_encoding &&
11023 GLES2Util::IsSRGBFormat(internal_format)) ||
Zhenyao Mo 2015/10/13 01:22:49 One optimization is, instead of asking IsSRGBForma
qiankun 2015/10/13 14:28:01 Thanks for this suggestion! I implemented this opt
11024 (GL_SRGB == color_encoding &&
11025 !GLES2Util::IsSRGBFormat(internal_format)) ||
11026 GLES2Util::IsFloatFormat(internal_format) ||
11027 (GLES2Util::IsSignedIntegerFormat(internal_format) !=
11028 GLES2Util::IsSignedIntegerFormat(read_format)) ||
11029 (GLES2Util::IsUnsignedIntegerFormat(internal_format) !=
11030 GLES2Util::IsUnsignedIntegerFormat(read_format))) {
11031 LOCAL_SET_GL_ERROR(
11032 GL_INVALID_OPERATION, "glCopyTexImage2D", "incompatible format");
11033 return;
11034 }
11035 }
11036
11006 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { 11037 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) {
11007 LOCAL_SET_GL_ERROR( 11038 LOCAL_SET_GL_ERROR(
11008 GL_INVALID_OPERATION, 11039 GL_INVALID_OPERATION,
11009 "glCopyTexImage2D", "can not be used with depth or stencil textures"); 11040 "glCopyTexImage2D", "can not be used with depth or stencil textures");
11010 return; 11041 return;
11011 } 11042 }
11012 11043
11013 uint32 pixels_size = 0; 11044 uint32 pixels_size = 0;
11014 GLenum format = ExtractFormatFromStorageFormat(internal_format); 11045 GLenum format = ExtractFormatFromStorageFormat(internal_format);
11015 GLenum type = ExtractTypeFromStorageFormat(internal_format); 11046 GLenum type = ExtractTypeFromStorageFormat(internal_format);
(...skipping 4050 matching lines...) Expand 10 before | Expand all | Expand 10 after
15066 return error::kNoError; 15097 return error::kNoError;
15067 } 15098 }
15068 15099
15069 // Include the auto-generated part of this file. We split this because it means 15100 // Include the auto-generated part of this file. We split this because it means
15070 // we can easily edit the non-auto generated parts right here in this file 15101 // we can easily edit the non-auto generated parts right here in this file
15071 // instead of having to edit some template or the code generator. 15102 // instead of having to edit some template or the code generator.
15072 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15103 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15073 15104
15074 } // namespace gles2 15105 } // namespace gles2
15075 } // namespace gpu 15106 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698