mesa/st: move DrawBufferAllocate into mesa.
Little bit of refactoring here. Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14675>
This commit is contained in:
parent
57dcaac31d
commit
f88fb21885
|
@ -35,6 +35,7 @@
|
|||
#include "context.h"
|
||||
#include "enums.h"
|
||||
#include "fbobject.h"
|
||||
#include "framebuffer.h"
|
||||
#include "hash.h"
|
||||
#include "mtypes.h"
|
||||
#include "state.h"
|
||||
|
@ -321,7 +322,8 @@ draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
|
|||
|
||||
/* Call device driver function only if fb is the bound draw buffer */
|
||||
if (fb == ctx->DrawBuffer) {
|
||||
st_DrawBufferAllocate(ctx);
|
||||
if (_mesa_is_winsys_fbo(ctx->DrawBuffer))
|
||||
_mesa_draw_buffer_allocate(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -627,7 +629,8 @@ draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb, GLsizei n,
|
|||
* may not be valid.
|
||||
*/
|
||||
if (fb == ctx->DrawBuffer) {
|
||||
st_DrawBufferAllocate(ctx);
|
||||
if (_mesa_is_winsys_fbo(ctx->DrawBuffer))
|
||||
_mesa_draw_buffer_allocate(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "util/u_memory.h"
|
||||
|
||||
#include "state_tracker/st_cb_fbo.h"
|
||||
#include "state_tracker/st_manager.h"
|
||||
|
||||
/**
|
||||
* Compute/set the _DepthMax field for the given framebuffer.
|
||||
|
@ -581,6 +582,29 @@ update_color_read_buffer(struct gl_framebuffer *fb)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called via glDrawBuffer. We only provide this driver function so that we
|
||||
* can check if we need to allocate a new renderbuffer. Specifically, we
|
||||
* don't usually allocate a front color buffer when using a double-buffered
|
||||
* visual. But if the app calls glDrawBuffer(GL_FRONT) we need to allocate
|
||||
* that buffer. Note, this is only for window system buffers, not user-
|
||||
* created FBOs.
|
||||
*/
|
||||
void
|
||||
_mesa_draw_buffer_allocate(struct gl_context *ctx)
|
||||
{
|
||||
struct gl_framebuffer *fb = ctx->DrawBuffer;
|
||||
assert(_mesa_is_winsys_fbo(fb));
|
||||
GLuint i;
|
||||
/* add the renderbuffers on demand */
|
||||
for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
|
||||
gl_buffer_index idx = fb->_ColorDrawBufferIndexes[i];
|
||||
|
||||
if (idx != BUFFER_NONE) {
|
||||
st_manager_add_color_renderbuffer(st_context(ctx), fb, idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a gl_framebuffer's derived state.
|
||||
|
@ -611,7 +635,7 @@ update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
|
|||
|
||||
/* Call device driver function if fb is the bound draw buffer. */
|
||||
if (fb == ctx->DrawBuffer) {
|
||||
st_DrawBufferAllocate(ctx);
|
||||
_mesa_draw_buffer_allocate(ctx);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -143,4 +143,7 @@ _mesa_is_multisample_enabled(const struct gl_context *ctx);
|
|||
extern bool
|
||||
_mesa_is_alpha_test_enabled(const struct gl_context *ctx);
|
||||
|
||||
void
|
||||
_mesa_draw_buffer_allocate(struct gl_context *ctx);
|
||||
|
||||
#endif /* FRAMEBUFFER_H */
|
||||
|
|
|
@ -536,33 +536,6 @@ st_update_renderbuffer_surface(struct st_context *st,
|
|||
rb->surface = *psurf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called via glDrawBuffer. We only provide this driver function so that we
|
||||
* can check if we need to allocate a new renderbuffer. Specifically, we
|
||||
* don't usually allocate a front color buffer when using a double-buffered
|
||||
* visual. But if the app calls glDrawBuffer(GL_FRONT) we need to allocate
|
||||
* that buffer. Note, this is only for window system buffers, not user-
|
||||
* created FBOs.
|
||||
*/
|
||||
void
|
||||
st_DrawBufferAllocate(struct gl_context *ctx)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct gl_framebuffer *fb = ctx->DrawBuffer;
|
||||
|
||||
if (_mesa_is_winsys_fbo(fb)) {
|
||||
GLuint i;
|
||||
/* add the renderbuffers on demand */
|
||||
for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
|
||||
gl_buffer_index idx = fb->_ColorDrawBufferIndexes[i];
|
||||
|
||||
if (idx != BUFFER_NONE) {
|
||||
st_manager_add_color_renderbuffer(st, fb, idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called via ctx->Driver.MapRenderbuffer.
|
||||
*/
|
||||
|
|
|
@ -78,7 +78,6 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
|
|||
struct gl_renderbuffer *rb,
|
||||
GLenum internalFormat,
|
||||
GLuint width, GLuint height);
|
||||
void st_DrawBufferAllocate(struct gl_context *ctx);
|
||||
|
||||
void st_MapRenderbuffer(struct gl_context *ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
|
|
Loading…
Reference in New Issue