From 6ca09f3a608c10f6d2a9f80d2497ac1628188ac9 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Tue, 24 Apr 2018 14:19:48 +1000 Subject: st/mesa: add new driver function DrawBufferAllocate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/mesa/main/buffers.c | 4 ++++ src/mesa/main/dd.h | 4 +++- src/mesa/state_tracker/st_cb_fbo.c | 10 ++++------ 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 7bb5725d085..ba970d87dad 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -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); } } diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index d85d89ef50c..5ee6902d3fb 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -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 */ diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 696a08fd65b..5eeec08655d 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -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; -- cgit v1.2.3