Commit 2ea5950d authored by zmo@chromium.org's avatar zmo@chromium.org

Read framebuffer should have color image attached for ReadPixels/Copy{Sub}TexImage2D

Apparently some desktop drivers do not generate an INVALID_OPERATION, so we
should enforce it in GPU command buffer.

BUG=391953
TEST=conformance_renderbuffers_framebuffer_object_attachment passing on all GPU bots
R=kbr@chromium.org,bajones@chromium.org
NOTRY=true

Review URL: https://codereview.chromium.org/379623002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282085 0039d316-1c4b-4281-b951-d872f2087c98
parent 4829dd90
...@@ -1188,6 +1188,10 @@ class GLES2DecoderImpl : public GLES2Decoder, ...@@ -1188,6 +1188,10 @@ class GLES2DecoderImpl : public GLES2Decoder,
// Generates GL error if not. // Generates GL error if not.
bool CheckBoundFramebuffersValid(const char* func_name); bool CheckBoundFramebuffersValid(const char* func_name);
// Check that the currently bound read framebuffer has a color image
// attached. Generates GL error if not.
bool CheckBoundReadFramebufferColorAttachment(const char* func_name);
// Check if a framebuffer meets our requirements. // Check if a framebuffer meets our requirements.
bool CheckFramebufferValid( bool CheckFramebufferValid(
Framebuffer* framebuffer, Framebuffer* framebuffer,
...@@ -3197,6 +3201,21 @@ bool GLES2DecoderImpl::CheckBoundFramebuffersValid(const char* func_name) { ...@@ -3197,6 +3201,21 @@ bool GLES2DecoderImpl::CheckBoundFramebuffersValid(const char* func_name) {
func_name); func_name);
} }
bool GLES2DecoderImpl::CheckBoundReadFramebufferColorAttachment(
const char* func_name) {
Framebuffer* framebuffer = features().chromium_framebuffer_multisample ?
framebuffer_state_.bound_read_framebuffer.get() :
framebuffer_state_.bound_draw_framebuffer.get();
if (!framebuffer)
return true;
if (framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL) {
LOCAL_SET_GL_ERROR(
GL_INVALID_OPERATION, func_name, "no color image attached");
return false;
}
return true;
}
gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() {
Framebuffer* framebuffer = Framebuffer* framebuffer =
GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
...@@ -7439,6 +7458,10 @@ error::Error GLES2DecoderImpl::HandleReadPixels( ...@@ -7439,6 +7458,10 @@ error::Error GLES2DecoderImpl::HandleReadPixels(
return error::kNoError; return error::kNoError;
} }
if (!CheckBoundReadFramebufferColorAttachment("glReadPixels")) {
return error::kNoError;
}
if (!CheckBoundFramebuffersValid("glReadPixels")) { if (!CheckBoundFramebuffersValid("glReadPixels")) {
return error::kNoError; return error::kNoError;
} }
...@@ -8490,6 +8513,10 @@ void GLES2DecoderImpl::DoCopyTexImage2D( ...@@ -8490,6 +8513,10 @@ void GLES2DecoderImpl::DoCopyTexImage2D(
return; return;
} }
if (!CheckBoundReadFramebufferColorAttachment("glCopyTexImage2D")) {
return;
}
if (!CheckBoundFramebuffersValid("glCopyTexImage2D")) { if (!CheckBoundFramebuffersValid("glCopyTexImage2D")) {
return; return;
} }
...@@ -8600,6 +8627,10 @@ void GLES2DecoderImpl::DoCopyTexSubImage2D( ...@@ -8600,6 +8627,10 @@ void GLES2DecoderImpl::DoCopyTexSubImage2D(
return; return;
} }
if (!CheckBoundReadFramebufferColorAttachment("glCopyTexSubImage2D")) {
return;
}
if (!CheckBoundFramebuffersValid("glCopyTexSubImage2D")) { if (!CheckBoundFramebuffersValid("glCopyTexSubImage2D")) {
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment