OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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, |
| 8619 "glCopyTexImage2D", "source and destination textures are the same"); |
| 8620 return; |
| 8621 } |
| 8622 |
8598 if (!CheckBoundFramebuffersValid("glCopyTexImage2D")) { | 8623 if (!CheckBoundFramebuffersValid("glCopyTexImage2D")) { |
8599 return; | 8624 return; |
8600 } | 8625 } |
8601 | 8626 |
8602 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTexImage2D"); | 8627 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTexImage2D"); |
8603 ScopedResolvedFrameBufferBinder binder(this, false, true); | 8628 ScopedResolvedFrameBufferBinder binder(this, false, true); |
8604 gfx::Size size = GetBoundReadFrameBufferSize(); | 8629 gfx::Size size = GetBoundReadFrameBufferSize(); |
8605 | 8630 |
8606 if (texture->IsAttachedToFramebuffer()) { | 8631 if (texture->IsAttachedToFramebuffer()) { |
8607 framebuffer_state_.clear_state_dirty = true; | 8632 framebuffer_state_.clear_state_dirty = true; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8706 LOCAL_SET_GL_ERROR( | 8731 LOCAL_SET_GL_ERROR( |
8707 GL_INVALID_OPERATION, | 8732 GL_INVALID_OPERATION, |
8708 "glCopySubImage2D", "can not be used with depth or stencil textures"); | 8733 "glCopySubImage2D", "can not be used with depth or stencil textures"); |
8709 return; | 8734 return; |
8710 } | 8735 } |
8711 | 8736 |
8712 if (!CheckBoundReadFramebufferColorAttachment("glCopyTexSubImage2D")) { | 8737 if (!CheckBoundReadFramebufferColorAttachment("glCopyTexSubImage2D")) { |
8713 return; | 8738 return; |
8714 } | 8739 } |
8715 | 8740 |
| 8741 if (FormsTextureCopyingFeedbackLoop(texture_ref, level)) { |
| 8742 LOCAL_SET_GL_ERROR( |
| 8743 GL_INVALID_OPERATION, |
| 8744 "glCopyTexSubImage2D", "source and destination textures are the same"); |
| 8745 return; |
| 8746 } |
| 8747 |
8716 if (!CheckBoundFramebuffersValid("glCopyTexSubImage2D")) { | 8748 if (!CheckBoundFramebuffersValid("glCopyTexSubImage2D")) { |
8717 return; | 8749 return; |
8718 } | 8750 } |
8719 | 8751 |
8720 ScopedResolvedFrameBufferBinder binder(this, false, true); | 8752 ScopedResolvedFrameBufferBinder binder(this, false, true); |
8721 gfx::Size size = GetBoundReadFrameBufferSize(); | 8753 gfx::Size size = GetBoundReadFrameBufferSize(); |
8722 GLint copyX = 0; | 8754 GLint copyX = 0; |
8723 GLint copyY = 0; | 8755 GLint copyY = 0; |
8724 GLint copyWidth = 0; | 8756 GLint copyWidth = 0; |
8725 GLint copyHeight = 0; | 8757 GLint copyHeight = 0; |
(...skipping 2423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11149 } | 11181 } |
11150 } | 11182 } |
11151 | 11183 |
11152 // Include the auto-generated part of this file. We split this because it means | 11184 // 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 | 11185 // 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. | 11186 // instead of having to edit some template or the code generator. |
11155 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11187 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
11156 | 11188 |
11157 } // namespace gles2 | 11189 } // namespace gles2 |
11158 } // namespace gpu | 11190 } // namespace gpu |
OLD | NEW |