summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/fbobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/fbobject.c')
-rw-r--r--src/mesa/main/fbobject.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 26fc15de371..ce5eeae048c 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -222,15 +222,21 @@ get_framebuffer_target(struct gl_context *ctx, GLenum target)
* default / window-system FB object.
* If \p attachment is GL_DEPTH_STENCIL_ATTACHMENT, return a pointer to
* the depth buffer attachment point.
+ * Returns if the attachment is a GL_COLOR_ATTACHMENTm_EXT on
+ * is_color_attachment, because several callers would return different errors
+ * if they don't find the attachment.
*/
static struct gl_renderbuffer_attachment *
get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLenum attachment)
+ GLenum attachment, bool *is_color_attachment)
{
GLuint i;
assert(_mesa_is_user_fbo(fb));
+ if (is_color_attachment)
+ *is_color_attachment = false;
+
switch (attachment) {
case GL_COLOR_ATTACHMENT0_EXT:
case GL_COLOR_ATTACHMENT1_EXT:
@@ -248,6 +254,8 @@ get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb,
case GL_COLOR_ATTACHMENT13_EXT:
case GL_COLOR_ATTACHMENT14_EXT:
case GL_COLOR_ATTACHMENT15_EXT:
+ if (is_color_attachment)
+ *is_color_attachment = true;
/* Only OpenGL ES 1.x forbids color attachments other than
* GL_COLOR_ATTACHMENT0. For all other APIs the limit set by the
* hardware is used.
@@ -543,13 +551,13 @@ _mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
mtx_lock(&fb->Mutex);
- att = get_attachment(ctx, fb, attachment);
+ att = get_attachment(ctx, fb, attachment, NULL);
assert(att);
if (rb) {
set_renderbuffer_attachment(ctx, att, rb);
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
/* do stencil attachment here (depth already done above) */
- att = get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT);
+ att = get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT, NULL);
assert(att);
set_renderbuffer_attachment(ctx, att, rb);
}
@@ -559,7 +567,7 @@ _mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
remove_attachment(ctx, att);
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
/* detach stencil (depth was detached above) */
- att = get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT);
+ att = get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT, NULL);
assert(att);
remove_attachment(ctx, att);
}
@@ -1219,7 +1227,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) {
if (fb->ColorDrawBuffer[j] != GL_NONE) {
const struct gl_renderbuffer_attachment *att
- = get_attachment(ctx, fb, fb->ColorDrawBuffer[j]);
+ = get_attachment(ctx, fb, fb->ColorDrawBuffer[j], NULL);
assert(att);
if (att->Type == GL_NONE) {
fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT;
@@ -1232,7 +1240,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
/* Check that the ReadBuffer is present */
if (fb->ColorReadBuffer != GL_NONE) {
const struct gl_renderbuffer_attachment *att
- = get_attachment(ctx, fb, fb->ColorReadBuffer);
+ = get_attachment(ctx, fb, fb->ColorReadBuffer, NULL);
assert(att);
if (att->Type == GL_NONE) {
fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT;
@@ -3151,7 +3159,7 @@ _mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
}
/* Not a hash lookup, so we can afford to get the attachment here. */
- att = get_attachment(ctx, fb, attachment);
+ att = get_attachment(ctx, fb, attachment, NULL);
if (att == NULL) {
_mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid attachment %s)", caller,
_mesa_enum_to_string(attachment));
@@ -3495,7 +3503,7 @@ framebuffer_renderbuffer(struct gl_context *ctx,
return;
}
- att = get_attachment(ctx, fb, attachment);
+ att = get_attachment(ctx, fb, attachment, NULL);
if (att == NULL) {
_mesa_error(ctx, GL_INVALID_ENUM,
"%s(invalid attachment %s)", func,
@@ -3668,7 +3676,7 @@ _mesa_get_framebuffer_attachment_parameter(struct gl_context *ctx,
}
else {
/* user-created framebuffer FBO */
- att = get_attachment(ctx, buffer, attachment);
+ att = get_attachment(ctx, buffer, attachment, NULL);
}
if (att == NULL) {
@@ -3692,8 +3700,8 @@ _mesa_get_framebuffer_attachment_parameter(struct gl_context *ctx,
return;
}
/* the depth and stencil attachments must point to the same buffer */
- depthAtt = get_attachment(ctx, buffer, GL_DEPTH_ATTACHMENT);
- stencilAtt = get_attachment(ctx, buffer, GL_STENCIL_ATTACHMENT);
+ depthAtt = get_attachment(ctx, buffer, GL_DEPTH_ATTACHMENT, NULL);
+ stencilAtt = get_attachment(ctx, buffer, GL_STENCIL_ATTACHMENT, NULL);
if (depthAtt->Renderbuffer != stencilAtt->Renderbuffer) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(DEPTH/STENCIL attachments differ)", caller);