meta: Add infrastructure for saving/restoring the DrawBuffers state.
Sometimes we need to configure what draw buffers we render to, without creating a new FBO. This path will make that possible. Cc: "10.2" <mesa-stable@lists.freedesktop.org> Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
@@ -392,6 +392,24 @@ _mesa_meta_init(struct gl_context *ctx)
|
|||||||
ctx->Meta = CALLOC_STRUCT(gl_meta_state);
|
ctx->Meta = CALLOC_STRUCT(gl_meta_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GLenum
|
||||||
|
gl_buffer_index_to_drawbuffers_enum(gl_buffer_index bufindex)
|
||||||
|
{
|
||||||
|
assert(bufindex < BUFFER_COUNT);
|
||||||
|
|
||||||
|
if (bufindex >= BUFFER_COLOR0)
|
||||||
|
return GL_COLOR_ATTACHMENT0 + bufindex - BUFFER_COLOR0;
|
||||||
|
else if (bufindex == BUFFER_FRONT_LEFT)
|
||||||
|
return GL_FRONT_LEFT;
|
||||||
|
else if (bufindex == BUFFER_FRONT_RIGHT)
|
||||||
|
return GL_FRONT_RIGHT;
|
||||||
|
else if (bufindex == BUFFER_BACK_LEFT)
|
||||||
|
return GL_BACK_LEFT;
|
||||||
|
else if (bufindex == BUFFER_BACK_RIGHT)
|
||||||
|
return GL_BACK_RIGHT;
|
||||||
|
|
||||||
|
return GL_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free context meta-op state.
|
* Free context meta-op state.
|
||||||
@@ -778,6 +796,23 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
|
|||||||
_mesa_set_framebuffer_srgb(ctx, GL_FALSE);
|
_mesa_set_framebuffer_srgb(ctx, GL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state & MESA_META_DRAW_BUFFERS) {
|
||||||
|
int buf, real_color_buffers = 0;
|
||||||
|
memset(save->ColorDrawBuffers, 0, sizeof(save->ColorDrawBuffers));
|
||||||
|
|
||||||
|
for (buf = 0; buf < MAX_DRAW_BUFFERS; buf++) {
|
||||||
|
int buf_index = ctx->DrawBuffer->_ColorDrawBufferIndexes[buf];
|
||||||
|
if (buf_index == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
save->ColorDrawBuffers[buf] =
|
||||||
|
gl_buffer_index_to_drawbuffers_enum(buf_index);
|
||||||
|
|
||||||
|
if (++real_color_buffers >= ctx->DrawBuffer->_NumColorDrawBuffers)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* misc */
|
/* misc */
|
||||||
{
|
{
|
||||||
save->Lighting = ctx->Light.Enabled;
|
save->Lighting = ctx->Light.Enabled;
|
||||||
@@ -1176,6 +1211,10 @@ _mesa_meta_end(struct gl_context *ctx)
|
|||||||
ctx->CurrentRenderbuffer->Name != save->RenderbufferName)
|
ctx->CurrentRenderbuffer->Name != save->RenderbufferName)
|
||||||
_mesa_BindRenderbuffer(GL_RENDERBUFFER, save->RenderbufferName);
|
_mesa_BindRenderbuffer(GL_RENDERBUFFER, save->RenderbufferName);
|
||||||
|
|
||||||
|
if (state & MESA_META_DRAW_BUFFERS) {
|
||||||
|
_mesa_DrawBuffers(MAX_DRAW_BUFFERS, save->ColorDrawBuffers);
|
||||||
|
}
|
||||||
|
|
||||||
ctx->Meta->SaveStackDepth--;
|
ctx->Meta->SaveStackDepth--;
|
||||||
|
|
||||||
ctx->API = save->API;
|
ctx->API = save->API;
|
||||||
|
|||||||
@@ -181,6 +181,9 @@ struct save_state
|
|||||||
GLboolean TransformFeedbackNeedsResume;
|
GLboolean TransformFeedbackNeedsResume;
|
||||||
|
|
||||||
GLuint DrawBufferName, ReadBufferName, RenderbufferName;
|
GLuint DrawBufferName, ReadBufferName, RenderbufferName;
|
||||||
|
|
||||||
|
/** MESA_META_DRAW_BUFFERS */
|
||||||
|
GLenum ColorDrawBuffers[MAX_DRAW_BUFFERS];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user