st/mesa: add new driver function DrawBufferAllocate

Unlike some of the classic drivers the st was only using DrawBuffer()
to allocated some buffers on-demand. Creating a separate function
will allow us to call it from update_framebuffer() in the following
patch without regressing some of the older classic drivers.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Timothy Arceri 2018-04-24 14:19:48 +10:00
parent 2554b8cb00
commit 6ca09f3a60
3 changed files with 11 additions and 7 deletions

View File

@ -306,6 +306,8 @@ draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
if (fb == ctx->DrawBuffer) {
if (ctx->Driver.DrawBuffer)
ctx->Driver.DrawBuffer(ctx, buffer);
if (ctx->Driver.DrawBufferAllocate)
ctx->Driver.DrawBufferAllocate(ctx);
}
}
@ -587,6 +589,8 @@ draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb, GLsizei n,
if (fb == ctx->DrawBuffer) {
if (ctx->Driver.DrawBuffer)
ctx->Driver.DrawBuffer(ctx, n > 0 ? buffers[0] : GL_NONE);
if (ctx->Driver.DrawBufferAllocate)
ctx->Driver.DrawBufferAllocate(ctx);
}
}

View File

@ -611,7 +611,9 @@ struct dd_function_table {
/** Specify mapping of depth values from NDC to window coordinates */
void (*DepthRange)(struct gl_context *ctx);
/** Specify the current buffer for writing */
void (*DrawBuffer)( struct gl_context *ctx, GLenum buffer );
void (*DrawBuffer)(struct gl_context *ctx, GLenum buffer);
/** Used to allocated any buffers with on-demand creation */
void (*DrawBufferAllocate)(struct gl_context *ctx);
/** Enable or disable server-side gl capabilities */
void (*Enable)(struct gl_context *ctx, GLenum cap, GLboolean state);
/** Specify fog parameters */

View File

@ -714,13 +714,11 @@ st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
* created FBOs.
*/
static void
st_DrawBuffer(struct gl_context *ctx, GLenum buffer)
st_DrawBufferAllocate(struct gl_context *ctx)
{
struct st_context *st = st_context(ctx);
struct gl_framebuffer *fb = ctx->DrawBuffer;
(void) buffer;
if (_mesa_is_winsys_fbo(fb)) {
GLuint i;
/* add the renderbuffers on demand */
@ -736,8 +734,8 @@ st_DrawBuffer(struct gl_context *ctx, GLenum buffer)
/**
* Called via glReadBuffer. As with st_DrawBuffer, we use this function
* to check if we need to allocate a renderbuffer on demand.
* Called via glReadBuffer. As with st_DrawBufferAllocate, we use this
* function to check if we need to allocate a renderbuffer on demand.
*/
static void
st_ReadBuffer(struct gl_context *ctx, GLenum buffer)
@ -868,7 +866,7 @@ st_init_fbo_functions(struct dd_function_table *functions)
functions->FinishRenderTexture = st_finish_render_texture;
functions->ValidateFramebuffer = st_validate_framebuffer;
functions->DrawBuffer = st_DrawBuffer;
functions->DrawBufferAllocate = st_DrawBufferAllocate;
functions->ReadBuffer = st_ReadBuffer;
functions->MapRenderbuffer = st_MapRenderbuffer;