Chromium Code Reviews| Index: gpu/command_buffer/service/gles2_cmd_decoder.cc |
| diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| index 1213e616f2e1638adbfe653b2200607b04e69860..edf835ff0cac292c74b45f39adc682ef1f2e30e2 100644 |
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| @@ -1181,6 +1181,10 @@ class GLES2DecoderImpl : public GLES2Decoder, |
| // attached. Generates GL error if not. |
| bool CheckBoundReadFramebufferColorAttachment(const char* func_name); |
| + // Check that the currently bound read framebuffer's color image |
| + // isn't the target texture of the glCopyTex{Sub}Image2D. |
| + bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level); |
| + |
| // Check if a framebuffer meets our requirements. |
| bool CheckFramebufferValid( |
| Framebuffer* framebuffer, |
| @@ -3232,6 +3236,20 @@ bool GLES2DecoderImpl::CheckBoundReadFramebufferColorAttachment( |
| return true; |
| } |
| +bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop( |
| + TextureRef* texture, GLint level) { |
| + Framebuffer* framebuffer = features().chromium_framebuffer_multisample ? |
| + framebuffer_state_.bound_read_framebuffer.get() : |
| + framebuffer_state_.bound_draw_framebuffer.get(); |
| + if (!framebuffer) |
| + return false; |
| + const Framebuffer::Attachment* attachment = framebuffer->GetAttachment( |
| + GL_COLOR_ATTACHMENT0); |
| + if (!attachment) |
| + return false; |
| + return attachment->FormsFeedbackLoop(texture, level); |
| +} |
| + |
| gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { |
| Framebuffer* framebuffer = |
| GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); |
| @@ -8595,6 +8613,12 @@ void GLES2DecoderImpl::DoCopyTexImage2D( |
| return; |
| } |
| + if (FormsTextureCopyingFeedbackLoop(texture_ref, level)) { |
| + LOCAL_SET_GL_ERROR( |
| + 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.
|
| + return; |
| + } |
| + |
| if (!CheckBoundFramebuffersValid("glCopyTexImage2D")) { |
| return; |
| } |
| @@ -8713,6 +8737,12 @@ void GLES2DecoderImpl::DoCopyTexSubImage2D( |
| return; |
| } |
| + if (FormsTextureCopyingFeedbackLoop(texture_ref, level)) { |
| + LOCAL_SET_GL_ERROR( |
| + GL_INVALID_OPERATION, "glCopyTexSubImage2D", "feedback loops"); |
| + return; |
| + } |
| + |
| if (!CheckBoundFramebuffersValid("glCopyTexSubImage2D")) { |
| return; |
| } |