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

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

Issue 656613002: Generate INVALID_OPERATION if feedback loops exist in CopyTex{Sub}Image2D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 <list> 10 #include <list>
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 bool SetCapabilityState(GLenum cap, bool enabled); 1174 bool SetCapabilityState(GLenum cap, bool enabled);
1175 1175
1176 // Check that the currently bound framebuffers are valid. 1176 // Check that the currently bound framebuffers are valid.
1177 // Generates GL error if not. 1177 // Generates GL error if not.
1178 bool CheckBoundFramebuffersValid(const char* func_name); 1178 bool CheckBoundFramebuffersValid(const char* func_name);
1179 1179
1180 // Check that the currently bound read framebuffer has a color image 1180 // Check that the currently bound read framebuffer has a color image
1181 // attached. Generates GL error if not. 1181 // attached. Generates GL error if not.
1182 bool CheckBoundReadFramebufferColorAttachment(const char* func_name); 1182 bool CheckBoundReadFramebufferColorAttachment(const char* func_name);
1183 1183
1184 // Check that the currently bound read framebuffer's color image
1185 // isn't the target texture of the glCopyTex{Sub}Image2D.
1186 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level);
1187
1184 // Check if a framebuffer meets our requirements. 1188 // Check if a framebuffer meets our requirements.
1185 bool CheckFramebufferValid( 1189 bool CheckFramebufferValid(
1186 Framebuffer* framebuffer, 1190 Framebuffer* framebuffer,
1187 GLenum target, 1191 GLenum target,
1188 const char* func_name); 1192 const char* func_name);
1189 1193
1190 // Checks if the current program exists and is valid. If not generates the 1194 // Checks if the current program exists and is valid. If not generates the
1191 // appropriate GL error. Returns true if the current program is in a usable 1195 // appropriate GL error. Returns true if the current program is in a usable
1192 // state. 1196 // state.
1193 bool CheckCurrentProgram(const char* function_name); 1197 bool CheckCurrentProgram(const char* function_name);
(...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after
3225 if (!framebuffer) 3229 if (!framebuffer)
3226 return true; 3230 return true;
3227 if (framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL) { 3231 if (framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL) {
3228 LOCAL_SET_GL_ERROR( 3232 LOCAL_SET_GL_ERROR(
3229 GL_INVALID_OPERATION, func_name, "no color image attached"); 3233 GL_INVALID_OPERATION, func_name, "no color image attached");
3230 return false; 3234 return false;
3231 } 3235 }
3232 return true; 3236 return true;
3233 } 3237 }
3234 3238
3239 bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop(
3240 TextureRef* texture, GLint level) {
3241 Framebuffer* framebuffer = features().chromium_framebuffer_multisample ?
3242 framebuffer_state_.bound_read_framebuffer.get() :
3243 framebuffer_state_.bound_draw_framebuffer.get();
3244 if (!framebuffer)
3245 return false;
3246 const Framebuffer::Attachment* attachment = framebuffer->GetAttachment(
3247 GL_COLOR_ATTACHMENT0);
3248 if (!attachment)
3249 return false;
3250 return attachment->FormsFeedbackLoop(texture, level);
3251 }
3252
3235 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { 3253 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() {
3236 Framebuffer* framebuffer = 3254 Framebuffer* framebuffer =
3237 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); 3255 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
3238 if (framebuffer != NULL) { 3256 if (framebuffer != NULL) {
3239 const Framebuffer::Attachment* attachment = 3257 const Framebuffer::Attachment* attachment =
3240 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0); 3258 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0);
3241 if (attachment) { 3259 if (attachment) {
3242 return gfx::Size(attachment->width(), attachment->height()); 3260 return gfx::Size(attachment->width(), attachment->height());
3243 } 3261 }
3244 return gfx::Size(0, 0); 3262 return gfx::Size(0, 0);
(...skipping 5343 matching lines...) Expand 10 before | Expand all | Expand 10 after
8588 8606
8589 if (!EnsureGPUMemoryAvailable(estimated_size)) { 8607 if (!EnsureGPUMemoryAvailable(estimated_size)) {
8590 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTexImage2D", "out of memory"); 8608 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTexImage2D", "out of memory");
8591 return; 8609 return;
8592 } 8610 }
8593 8611
8594 if (!CheckBoundReadFramebufferColorAttachment("glCopyTexImage2D")) { 8612 if (!CheckBoundReadFramebufferColorAttachment("glCopyTexImage2D")) {
8595 return; 8613 return;
8596 } 8614 }
8597 8615
8616 if (FormsTextureCopyingFeedbackLoop(texture_ref, level)) {
8617 LOCAL_SET_GL_ERROR(
8618 GL_INVALID_OPERATION, "glCopyTexImage2D", "feedback loops");
bajones 2014/10/13 22:22:09 I feel like the error message here and below could
Zhenyao Mo 2014/10/13 22:31:40 Done.
8619 return;
8620 }
8621
8598 if (!CheckBoundFramebuffersValid("glCopyTexImage2D")) { 8622 if (!CheckBoundFramebuffersValid("glCopyTexImage2D")) {
8599 return; 8623 return;
8600 } 8624 }
8601 8625
8602 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTexImage2D"); 8626 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTexImage2D");
8603 ScopedResolvedFrameBufferBinder binder(this, false, true); 8627 ScopedResolvedFrameBufferBinder binder(this, false, true);
8604 gfx::Size size = GetBoundReadFrameBufferSize(); 8628 gfx::Size size = GetBoundReadFrameBufferSize();
8605 8629
8606 if (texture->IsAttachedToFramebuffer()) { 8630 if (texture->IsAttachedToFramebuffer()) {
8607 framebuffer_state_.clear_state_dirty = true; 8631 framebuffer_state_.clear_state_dirty = true;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
8706 LOCAL_SET_GL_ERROR( 8730 LOCAL_SET_GL_ERROR(
8707 GL_INVALID_OPERATION, 8731 GL_INVALID_OPERATION,
8708 "glCopySubImage2D", "can not be used with depth or stencil textures"); 8732 "glCopySubImage2D", "can not be used with depth or stencil textures");
8709 return; 8733 return;
8710 } 8734 }
8711 8735
8712 if (!CheckBoundReadFramebufferColorAttachment("glCopyTexSubImage2D")) { 8736 if (!CheckBoundReadFramebufferColorAttachment("glCopyTexSubImage2D")) {
8713 return; 8737 return;
8714 } 8738 }
8715 8739
8740 if (FormsTextureCopyingFeedbackLoop(texture_ref, level)) {
8741 LOCAL_SET_GL_ERROR(
8742 GL_INVALID_OPERATION, "glCopyTexSubImage2D", "feedback loops");
8743 return;
8744 }
8745
8716 if (!CheckBoundFramebuffersValid("glCopyTexSubImage2D")) { 8746 if (!CheckBoundFramebuffersValid("glCopyTexSubImage2D")) {
8717 return; 8747 return;
8718 } 8748 }
8719 8749
8720 ScopedResolvedFrameBufferBinder binder(this, false, true); 8750 ScopedResolvedFrameBufferBinder binder(this, false, true);
8721 gfx::Size size = GetBoundReadFrameBufferSize(); 8751 gfx::Size size = GetBoundReadFrameBufferSize();
8722 GLint copyX = 0; 8752 GLint copyX = 0;
8723 GLint copyY = 0; 8753 GLint copyY = 0;
8724 GLint copyWidth = 0; 8754 GLint copyWidth = 0;
8725 GLint copyHeight = 0; 8755 GLint copyHeight = 0;
(...skipping 2423 matching lines...) Expand 10 before | Expand all | Expand 10 after
11149 } 11179 }
11150 } 11180 }
11151 11181
11152 // Include the auto-generated part of this file. We split this because it means 11182 // Include the auto-generated part of this file. We split this because it means
11153 // we can easily edit the non-auto generated parts right here in this file 11183 // we can easily edit the non-auto generated parts right here in this file
11154 // instead of having to edit some template or the code generator. 11184 // instead of having to edit some template or the code generator.
11155 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 11185 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
11156 11186
11157 } // namespace gles2 11187 } // namespace gles2
11158 } // namespace gpu 11188 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698