* 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:
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.
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);
}
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);
}
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;
/* 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;
}
/* 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));
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,
}
else {
/* user-created framebuffer FBO */
- att = get_attachment(ctx, buffer, attachment);
+ att = get_attachment(ctx, buffer, attachment, NULL);
}
if (att == NULL) {
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);