st/mesa: remove st_context callbacks for dri/glx/wgl frontends
Use direct calls. Other changes: - kopper called thread_finish twice in the same function. Remove the second call. - Context creation had no-op initializations of cso_context and pipe. Reviewed-by: Emma Anholt <emma@anholt.net> Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Yonggang Luo <luoyonggang@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20027>
This commit is contained in:
@@ -772,7 +772,7 @@ wgl_bind_tex_image(_EGLDisplay *disp, _EGLSurface *surf, EGLint buffer)
|
||||
assert(!"Unexpected texture target in wgl_bind_tex_image()");
|
||||
}
|
||||
|
||||
wgl_ctx->ctx->st->teximage(wgl_ctx->ctx->st, target, 0, format, pres, false);
|
||||
st_context_teximage(wgl_ctx->ctx->st, target, 0, format, pres, false);
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
@@ -803,7 +803,7 @@ wgl_wait_client(_EGLDisplay *disp, _EGLContext *ctx)
|
||||
{
|
||||
struct wgl_egl_context *wgl_ctx = wgl_egl_context(ctx);
|
||||
struct pipe_fence_handle *fence = NULL;
|
||||
wgl_ctx->ctx->st->flush(wgl_ctx->ctx->st, ST_FLUSH_END_OF_FRAME | ST_FLUSH_WAIT, &fence, NULL, NULL);
|
||||
st_context_flush(wgl_ctx->ctx->st, ST_FLUSH_END_OF_FRAME | ST_FLUSH_WAIT, &fence, NULL, NULL);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
@@ -995,7 +995,7 @@ wgl_create_sync_khr(_EGLDisplay *disp, EGLenum type, const EGLAttrib *attrib_lis
|
||||
|
||||
switch (type) {
|
||||
case EGL_SYNC_FENCE_KHR:
|
||||
st->flush(st, 0, &wgl_sync->fence, NULL, NULL);
|
||||
st_context_flush(st, 0, &wgl_sync->fence, NULL, NULL);
|
||||
if (!wgl_sync->fence) {
|
||||
_eglError(EGL_BAD_ALLOC, "eglCreateSyncKHR");
|
||||
free(wgl_sync);
|
||||
|
@@ -481,8 +481,7 @@ dri2_allocate_textures(struct dri_context *ctx,
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
/* First get the buffers from the loader */
|
||||
if (image) {
|
||||
@@ -785,8 +784,7 @@ dri2_flush_frontbuffer(struct dri_context *ctx,
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
if (drawable->stvis.samples > 1) {
|
||||
/* Resolve the buffer used for front rendering. */
|
||||
@@ -1797,8 +1795,7 @@ dri2_blit_image(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
handle_in_fence(ctx, dst);
|
||||
|
||||
@@ -1824,11 +1821,11 @@ dri2_blit_image(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
|
||||
|
||||
if (flush_flag == __BLIT_FLAG_FLUSH) {
|
||||
pipe->flush_resource(pipe, dst->texture);
|
||||
ctx->st->flush(ctx->st, 0, NULL, NULL, NULL);
|
||||
st_context_flush(ctx->st, 0, NULL, NULL, NULL);
|
||||
} else if (flush_flag == __BLIT_FLAG_FINISH) {
|
||||
screen = ctx->screen->base.screen;
|
||||
pipe->flush_resource(pipe, dst->texture);
|
||||
ctx->st->flush(ctx->st, 0, &fence, NULL, NULL);
|
||||
st_context_flush(ctx->st, 0, &fence, NULL, NULL);
|
||||
(void) screen->fence_finish(screen, NULL, fence, PIPE_TIMEOUT_INFINITE);
|
||||
screen->fence_reference(screen, &fence, NULL);
|
||||
}
|
||||
@@ -1855,8 +1852,7 @@ dri2_map_image(__DRIcontext *context, __DRIimage *image,
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
handle_in_fence(ctx, image);
|
||||
|
||||
@@ -1888,8 +1884,7 @@ dri2_unmap_image(__DRIcontext *context, __DRIimage *image, void *data)
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
pipe_texture_unmap(pipe, (struct pipe_transfer *)data);
|
||||
}
|
||||
|
@@ -201,15 +201,14 @@ dri_create_context(struct dri_screen *screen,
|
||||
|
||||
if (ctx->st->cso_context) {
|
||||
ctx->pp = pp_init(ctx->st->pipe, screen->pp_enabled, ctx->st->cso_context,
|
||||
ctx->st, (void*)ctx->st->invalidate_state);
|
||||
ctx->st, (void*)st_context_invalidate_state);
|
||||
ctx->hud = hud_create(ctx->st->cso_context,
|
||||
share_ctx ? share_ctx->hud : NULL,
|
||||
ctx->st, (void*)ctx->st->invalidate_state);
|
||||
ctx->st, (void*)st_context_invalidate_state);
|
||||
}
|
||||
|
||||
/* Do this last. */
|
||||
if (ctx->st->start_thread &&
|
||||
driQueryOptionb(&screen->dev->option_cache, "mesa_glthread")) {
|
||||
if (driQueryOptionb(&screen->dev->option_cache, "mesa_glthread")) {
|
||||
bool safe = true;
|
||||
|
||||
/* This is only needed by X11/DRI2, which can be unsafe. */
|
||||
@@ -220,7 +219,7 @@ dri_create_context(struct dri_screen *screen,
|
||||
safe = false;
|
||||
|
||||
if (safe)
|
||||
ctx->st->start_thread(ctx->st);
|
||||
_mesa_glthread_init(ctx->st->ctx);
|
||||
}
|
||||
|
||||
*error = __DRI_CTX_ERROR_SUCCESS;
|
||||
@@ -228,7 +227,7 @@ dri_create_context(struct dri_screen *screen,
|
||||
|
||||
fail:
|
||||
if (ctx && ctx->st)
|
||||
ctx->st->destroy(ctx->st);
|
||||
st_destroy_context(ctx->st);
|
||||
|
||||
free(ctx);
|
||||
return NULL;
|
||||
@@ -240,8 +239,7 @@ dri_destroy_context(struct dri_context *ctx)
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
if (ctx->hud) {
|
||||
hud_destroy(ctx->hud, ctx->st->cso_context);
|
||||
@@ -255,8 +253,8 @@ dri_destroy_context(struct dri_context *ctx)
|
||||
* to avoid having to add code elsewhere to cope with flushing a
|
||||
* partially destroyed context.
|
||||
*/
|
||||
ctx->st->flush(ctx->st, 0, NULL, NULL, NULL);
|
||||
ctx->st->destroy(ctx->st);
|
||||
st_context_flush(ctx->st, 0, NULL, NULL, NULL);
|
||||
st_destroy_context(ctx->st);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
@@ -268,8 +266,7 @@ dri_unbind_context(struct dri_context *ctx)
|
||||
struct st_context *st = ctx->st;
|
||||
|
||||
if (st == st_api_get_current()) {
|
||||
if (st->thread_finish)
|
||||
st->thread_finish(st);
|
||||
_mesa_glthread_finish(st->ctx);
|
||||
|
||||
/* Record HUD queries for the duration the context was "current". */
|
||||
if (ctx->hud)
|
||||
@@ -310,8 +307,7 @@ dri_make_current(struct dri_context *ctx,
|
||||
/* Wait for glthread to finish because we can't use st_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
/* There are 2 cases that can occur here. Either we bind drawables, or we
|
||||
* bind NULL for configless and surfaceless contexts.
|
||||
|
@@ -258,8 +258,7 @@ dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
|
||||
struct dri_drawable *drawable = dri_drawable(dPriv);
|
||||
struct pipe_resource *pt;
|
||||
|
||||
if (st->thread_finish)
|
||||
st->thread_finish(st);
|
||||
_mesa_glthread_finish(st->ctx);
|
||||
|
||||
dri_drawable_validate_att(ctx, drawable, ST_ATTACHMENT_FRONT_LEFT);
|
||||
|
||||
@@ -294,7 +293,7 @@ dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
|
||||
|
||||
drawable->update_tex_buffer(drawable, ctx, pt);
|
||||
|
||||
ctx->st->teximage(ctx->st,
|
||||
st_context_teximage(ctx->st,
|
||||
(target == GL_TEXTURE_2D) ? ST_TEXTURE_2D : ST_TEXTURE_RECT,
|
||||
0, internal_format, pt, false);
|
||||
}
|
||||
@@ -426,8 +425,7 @@ notify_before_flush_cb(void* _args)
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (st->thread_finish)
|
||||
st->thread_finish(st);
|
||||
_mesa_glthread_finish(st->ctx);
|
||||
|
||||
if (args->drawable->stvis.samples > 1 &&
|
||||
(args->reason == __DRI2_THROTTLE_SWAPBUFFER ||
|
||||
@@ -490,8 +488,7 @@ dri_flush(__DRIcontext *cPriv,
|
||||
}
|
||||
|
||||
st = ctx->st;
|
||||
if (st->thread_finish)
|
||||
st->thread_finish(st);
|
||||
_mesa_glthread_finish(st->ctx);
|
||||
|
||||
if (drawable) {
|
||||
/* prevent recursion */
|
||||
@@ -533,7 +530,7 @@ dri_flush(__DRIcontext *cPriv,
|
||||
struct pipe_screen *screen = drawable->screen->base.screen;
|
||||
struct pipe_fence_handle *new_fence = NULL;
|
||||
|
||||
st->flush(st, flush_flags, &new_fence, args.ctx ? notify_before_flush_cb : NULL, &args);
|
||||
st_context_flush(st, flush_flags, &new_fence, args.ctx ? notify_before_flush_cb : NULL, &args);
|
||||
|
||||
/* throttle on the previous fence */
|
||||
if (drawable->throttle_fence) {
|
||||
@@ -543,7 +540,7 @@ dri_flush(__DRIcontext *cPriv,
|
||||
drawable->throttle_fence = new_fence;
|
||||
}
|
||||
else if (flags & (__DRI2_FLUSH_DRAWABLE | __DRI2_FLUSH_CONTEXT)) {
|
||||
st->flush(st, flush_flags, NULL, args.ctx ? notify_before_flush_cb : NULL, &args);
|
||||
st_context_flush(st, flush_flags, NULL, args.ctx ? notify_before_flush_cb : NULL, &args);
|
||||
}
|
||||
|
||||
if (drawable) {
|
||||
@@ -568,7 +565,7 @@ dri_flush(__DRIcontext *cPriv,
|
||||
p_atomic_inc(&drawable->base.stamp);
|
||||
}
|
||||
|
||||
st->invalidate_state(st, ST_INVALIDATE_FB_STATE);
|
||||
st_context_invalidate_state(st, ST_INVALIDATE_FB_STATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -100,10 +100,9 @@ dri2_create_fence(__DRIcontext *_ctx)
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (st->thread_finish)
|
||||
st->thread_finish(st);
|
||||
_mesa_glthread_finish(st->ctx);
|
||||
|
||||
st->flush(st, 0, &fence->pipe_fence, NULL, NULL);
|
||||
st_context_flush(st, 0, &fence->pipe_fence, NULL, NULL);
|
||||
|
||||
if (!fence->pipe_fence) {
|
||||
FREE(fence);
|
||||
@@ -125,12 +124,11 @@ dri2_create_fence_fd(__DRIcontext *_ctx, int fd)
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (st->thread_finish)
|
||||
st->thread_finish(st);
|
||||
_mesa_glthread_finish(st->ctx);
|
||||
|
||||
if (fd == -1) {
|
||||
/* exporting driver created fence, flush: */
|
||||
st->flush(st, ST_FLUSH_FENCE_FD, &fence->pipe_fence, NULL, NULL);
|
||||
st_context_flush(st, ST_FLUSH_FENCE_FD, &fence->pipe_fence, NULL, NULL);
|
||||
} else {
|
||||
/* importing a foreign fence fd: */
|
||||
ctx->create_fence_fd(ctx, &fence->pipe_fence, fd, PIPE_FD_TYPE_NATIVE_SYNC);
|
||||
@@ -238,8 +236,7 @@ dri2_server_wait_sync(__DRIcontext *_ctx, void *_fence, unsigned flags)
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (st->thread_finish)
|
||||
st->thread_finish(st);
|
||||
_mesa_glthread_finish(st->ctx);
|
||||
|
||||
if (ctx->fence_server_sync)
|
||||
ctx->fence_server_sync(ctx, fence->pipe_fence);
|
||||
@@ -303,8 +300,7 @@ dri2_create_image_from_renderbuffer2(__DRIcontext *context,
|
||||
__DRIimage *img;
|
||||
|
||||
/* Wait for glthread to finish to get up-to-date GL object lookups. */
|
||||
if (st->thread_finish)
|
||||
st->thread_finish(st);
|
||||
_mesa_glthread_finish(st->ctx);
|
||||
|
||||
/* Section 3.9 (EGLImage Specification and Management) of the EGL 1.5
|
||||
* specification says:
|
||||
@@ -404,8 +400,7 @@ dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture,
|
||||
GLuint face = 0;
|
||||
|
||||
/* Wait for glthread to finish to get up-to-date GL object lookups. */
|
||||
if (st->thread_finish)
|
||||
st->thread_finish(st);
|
||||
_mesa_glthread_finish(st->ctx);
|
||||
|
||||
obj = _mesa_lookup_texture(ctx, texture);
|
||||
if (!obj || obj->Target != target) {
|
||||
|
@@ -231,8 +231,7 @@ drisw_swap_buffers(struct dri_drawable *drawable)
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
ptex = drawable->textures[ST_ATTACHMENT_BACK_LEFT];
|
||||
|
||||
@@ -244,7 +243,7 @@ drisw_swap_buffers(struct dri_drawable *drawable)
|
||||
if (ctx->hud)
|
||||
hud_run(ctx->hud, ctx->st->cso_context, ptex);
|
||||
|
||||
ctx->st->flush(ctx->st, ST_FLUSH_FRONT, &fence, NULL, NULL);
|
||||
st_context_flush(ctx->st, ST_FLUSH_FRONT, &fence, NULL, NULL);
|
||||
|
||||
if (drawable->stvis.samples > 1) {
|
||||
/* Resolve the back buffer. */
|
||||
@@ -259,7 +258,7 @@ drisw_swap_buffers(struct dri_drawable *drawable)
|
||||
drisw_copy_to_front(ctx->st->pipe, drawable, ptex);
|
||||
|
||||
/* TODO: remove this if the framebuffer state doesn't change. */
|
||||
ctx->st->invalidate_state(ctx->st, ST_INVALIDATE_FB_STATE);
|
||||
st_context_invalidate_state(ctx->st, ST_INVALIDATE_FB_STATE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,14 +279,13 @@ drisw_copy_sub_buffer(struct dri_drawable *drawable, int x, int y,
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
struct pipe_fence_handle *fence = NULL;
|
||||
if (ctx->pp && drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL])
|
||||
pp_run(ctx->pp, ptex, ptex, drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL]);
|
||||
|
||||
ctx->st->flush(ctx->st, ST_FLUSH_FRONT, &fence, NULL, NULL);
|
||||
st_context_flush(ctx->st, ST_FLUSH_FRONT, &fence, NULL, NULL);
|
||||
|
||||
screen->base.screen->fence_finish(screen->base.screen, ctx->st->pipe,
|
||||
fence, PIPE_TIMEOUT_INFINITE);
|
||||
@@ -318,8 +316,7 @@ drisw_flush_frontbuffer(struct dri_context *ctx,
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
if (drawable->stvis.samples > 1) {
|
||||
/* Resolve the front buffer. */
|
||||
@@ -359,8 +356,7 @@ drisw_allocate_textures(struct dri_context *stctx,
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (stctx->st->thread_finish)
|
||||
stctx->st->thread_finish(stctx->st);
|
||||
_mesa_glthread_finish(stctx->st->ctx);
|
||||
|
||||
width = drawable->w;
|
||||
height = drawable->h;
|
||||
@@ -449,8 +445,7 @@ drisw_update_tex_buffer(struct dri_drawable *drawable,
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
get_drawable_info(drawable, &x, &y, &w, &h);
|
||||
|
||||
|
@@ -472,8 +472,7 @@ kopper_allocate_textures(struct dri_context *ctx,
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
/* First get the buffers from the loader */
|
||||
if (image) {
|
||||
@@ -683,8 +682,7 @@ kopper_flush_frontbuffer(struct dri_context *ctx,
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
if (drawable) {
|
||||
/* prevent recursion */
|
||||
@@ -709,10 +707,8 @@ kopper_flush_frontbuffer(struct dri_context *ctx,
|
||||
struct pipe_fence_handle *new_fence = NULL;
|
||||
|
||||
st = ctx->st;
|
||||
if (st->thread_finish)
|
||||
st->thread_finish(st);
|
||||
|
||||
st->flush(st, ST_FLUSH_FRONT, &new_fence, NULL, NULL);
|
||||
st_context_flush(st, ST_FLUSH_FRONT, &new_fence, NULL, NULL);
|
||||
if (drawable) {
|
||||
drawable->flushing = false;
|
||||
}
|
||||
@@ -779,8 +775,7 @@ kopper_update_tex_buffer(struct dri_drawable *drawable,
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
get_drawable_info(drawable, &x, &y, &w, &h);
|
||||
|
||||
@@ -863,8 +858,7 @@ kopperSwapBuffers(__DRIdrawable *dPriv)
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
drawable->texture_stamp = drawable->lastStamp - 1;
|
||||
|
||||
@@ -938,8 +932,7 @@ kopperQueryBufferAge(__DRIdrawable *dPriv)
|
||||
/* Wait for glthread to finish because we can't use pipe_context from
|
||||
* multiple threads.
|
||||
*/
|
||||
if (ctx->st->thread_finish)
|
||||
ctx->st->thread_finish(ctx->st);
|
||||
_mesa_glthread_finish(ctx->st->ctx);
|
||||
|
||||
return zink_kopper_query_buffer_age(ctx->st->pipe, ptex);
|
||||
}
|
||||
|
@@ -76,6 +76,7 @@
|
||||
#include <GL/glx.h>
|
||||
|
||||
#include "state_tracker/st_context.h"
|
||||
#include "main/context.h"
|
||||
|
||||
extern struct pipe_screen *
|
||||
xlib_create_screen(Display *display);
|
||||
@@ -1014,7 +1015,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list,
|
||||
c->st->frontend_context = (void *) c;
|
||||
|
||||
c->hud = hud_create(c->st->cso_context, NULL, c->st,
|
||||
(void*)c->st->invalidate_state);
|
||||
(void*)st_context_invalidate_state);
|
||||
|
||||
return c;
|
||||
|
||||
@@ -1033,7 +1034,7 @@ void XMesaDestroyContext( XMesaContext c )
|
||||
hud_destroy(c->hud, NULL);
|
||||
}
|
||||
|
||||
c->st->destroy(c->st);
|
||||
st_destroy_context(c->st);
|
||||
|
||||
/* FIXME: We should destroy the screen here, but if we do so, surfaces may
|
||||
* outlive it, causing segfaults
|
||||
@@ -1343,13 +1344,13 @@ void XMesaSwapBuffers( XMesaBuffer b )
|
||||
}
|
||||
|
||||
if (xmctx && xmctx->xm_buffer == b) {
|
||||
xmctx->st->flush( xmctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
|
||||
st_context_flush(xmctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
xmesa_swap_st_framebuffer(b->stfb);
|
||||
|
||||
/* TODO: remove this if the framebuffer state doesn't change. */
|
||||
xmctx->st->invalidate_state(xmctx->st, ST_INVALIDATE_FB_STATE);
|
||||
st_context_invalidate_state(xmctx->st, ST_INVALIDATE_FB_STATE);
|
||||
}
|
||||
|
||||
|
||||
@@ -1361,7 +1362,7 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
|
||||
{
|
||||
XMesaContext xmctx = XMesaGetCurrentContext();
|
||||
|
||||
xmctx->st->flush( xmctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
|
||||
st_context_flush(xmctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
|
||||
|
||||
xmesa_copy_st_framebuffer(b->stfb,
|
||||
ST_ATTACHMENT_BACK_LEFT, ST_ATTACHMENT_FRONT_LEFT,
|
||||
@@ -1376,7 +1377,7 @@ void XMesaFlush( XMesaContext c )
|
||||
XMesaDisplay xmdpy = xmesa_init_display(c->xm_visual->display);
|
||||
struct pipe_fence_handle *fence = NULL;
|
||||
|
||||
c->st->flush(c->st, ST_FLUSH_FRONT, &fence, NULL, NULL);
|
||||
st_context_flush(c->st, ST_FLUSH_FRONT, &fence, NULL, NULL);
|
||||
if (fence) {
|
||||
xmdpy->screen->fence_finish(xmdpy->screen, NULL, fence,
|
||||
PIPE_TIMEOUT_INFINITE);
|
||||
@@ -1523,12 +1524,8 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
|
||||
|
||||
pipe_texture_unmap(pipe, tex_xfer);
|
||||
|
||||
st->teximage(st,
|
||||
ST_TEXTURE_2D,
|
||||
0, /* level */
|
||||
internal_format,
|
||||
res,
|
||||
FALSE /* no mipmap */);
|
||||
st_context_teximage(st, ST_TEXTURE_2D, 0 /* level */, internal_format,
|
||||
res, FALSE /* no mipmap */);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1544,6 +1541,5 @@ XMesaReleaseTexImage(Display *dpy, XMesaBuffer drawable, int buffer)
|
||||
void
|
||||
XMesaCopyContext(XMesaContext src, XMesaContext dst, unsigned long mask)
|
||||
{
|
||||
if (dst->st->copy)
|
||||
dst->st->copy(dst->st, src->st, mask);
|
||||
_mesa_copy_context(src->st->ctx, dst->st->ctx, mask);
|
||||
}
|
||||
|
@@ -710,7 +710,7 @@ OSMesaDestroyContext(OSMesaContext osmesa)
|
||||
{
|
||||
if (osmesa) {
|
||||
pp_free(osmesa->pp);
|
||||
osmesa->st->destroy(osmesa->st);
|
||||
st_destroy_context(osmesa->st);
|
||||
free(osmesa->zs);
|
||||
FREE(osmesa);
|
||||
}
|
||||
@@ -809,7 +809,7 @@ OSMesaMakeCurrent(OSMesaContext osmesa, void *buffer, GLenum type,
|
||||
osmesa->pp_enabled,
|
||||
osmesa->st->cso_context,
|
||||
osmesa->st,
|
||||
(void*)osmesa->st->invalidate_state);
|
||||
(void*)st_context_invalidate_state);
|
||||
|
||||
pp_init_fbos(osmesa->pp, width, height);
|
||||
}
|
||||
|
@@ -107,8 +107,8 @@ DrvShareLists(DHGLRC dhglrc1, DHGLRC dhglrc2)
|
||||
ctx1 = stw_lookup_context_locked( dhglrc1 );
|
||||
ctx2 = stw_lookup_context_locked( dhglrc2 );
|
||||
|
||||
if (ctx1 && ctx2 && ctx2->st->share) {
|
||||
ret = ctx2->st->share(ctx2->st, ctx1->st);
|
||||
if (ctx1 && ctx2) {
|
||||
ret = _mesa_share_state(ctx2->st->ctx, ctx1->st->ctx);
|
||||
ctx1->shared = TRUE;
|
||||
ctx2->shared = TRUE;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, struct stw_context *shareCt
|
||||
|
||||
if (ctx->st->cso_context) {
|
||||
ctx->hud = hud_create(ctx->st->cso_context, NULL, ctx->st,
|
||||
(void*)ctx->st->invalidate_state);
|
||||
(void*)st_context_invalidate_state);
|
||||
}
|
||||
|
||||
return ctx;
|
||||
@@ -302,7 +302,7 @@ stw_destroy_context(struct stw_context *ctx)
|
||||
hud_destroy(ctx->hud, NULL);
|
||||
}
|
||||
|
||||
ctx->st->destroy(ctx->st);
|
||||
st_destroy_context(ctx->st);
|
||||
FREE(ctx);
|
||||
}
|
||||
|
||||
@@ -448,16 +448,16 @@ stw_make_current(struct stw_framebuffer *fb, struct stw_framebuffer *fbRead, str
|
||||
ST_FLUSH_FRONT | ST_FLUSH_WAIT);
|
||||
} else {
|
||||
struct pipe_fence_handle *fence = NULL;
|
||||
old_ctx->st->flush(old_ctx->st,
|
||||
ST_FLUSH_FRONT | ST_FLUSH_WAIT, &fence,
|
||||
NULL, NULL);
|
||||
st_context_flush(old_ctx->st,
|
||||
ST_FLUSH_FRONT | ST_FLUSH_WAIT, &fence,
|
||||
NULL, NULL);
|
||||
}
|
||||
} else {
|
||||
if (old_ctx->current_framebuffer)
|
||||
stw_st_flush(old_ctx->st, old_ctx->current_framebuffer->stfb,
|
||||
ST_FLUSH_FRONT);
|
||||
else
|
||||
old_ctx->st->flush(old_ctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
|
||||
st_context_flush(old_ctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -411,10 +411,10 @@ stw_st_flush(struct st_context *st,
|
||||
|
||||
if (flags & ST_FLUSH_WAIT)
|
||||
pfence = &fence;
|
||||
st->flush(st, flags, pfence, notify_before_flush_cb, &args);
|
||||
st_context_flush(st, flags, pfence, notify_before_flush_cb, &args);
|
||||
|
||||
/* TODO: remove this if the framebuffer state doesn't change. */
|
||||
st->invalidate_state(st, ST_INVALIDATE_FB_STATE);
|
||||
st_context_invalidate_state(st, ST_INVALIDATE_FB_STATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -222,7 +222,7 @@ GalliumContext::CreateContext(HGLWinsysContext *wsContext)
|
||||
// TODO: no pp filters are enabled yet through postProcessEnable
|
||||
context->postProcess = pp_init(stContext->pipe, context->postProcessEnable,
|
||||
stContext->cso_context, stContext,
|
||||
(void*)stContext->invalidate_state);
|
||||
(void*)st_context_invalidate_state);
|
||||
|
||||
context_id contextNext = -1;
|
||||
Lock();
|
||||
@@ -261,8 +261,8 @@ GalliumContext::DestroyContext(context_id contextID)
|
||||
return;
|
||||
|
||||
if (fContext[contextID]->st) {
|
||||
fContext[contextID]->st->flush(fContext[contextID]->st, 0, NULL, NULL, NULL);
|
||||
fContext[contextID]->st->destroy(fContext[contextID]->st);
|
||||
st_context_flush(fContext[contextID]->st, 0, NULL, NULL, NULL);
|
||||
st_destroy_context(fContext[contextID]->st);
|
||||
}
|
||||
|
||||
if (fContext[contextID]->postProcess)
|
||||
@@ -310,7 +310,7 @@ GalliumContext::SetCurrentContext(bool set, context_id contextID)
|
||||
fCurrentContext = contextID;
|
||||
|
||||
if (oldContextID > 0 && oldContextID != contextID) {
|
||||
fContext[oldContextID]->st->flush(fContext[oldContextID]->st,
|
||||
st_context_flush(fContext[oldContextID]->st,
|
||||
ST_FLUSH_FRONT, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ GalliumContext::SwapBuffers(context_id contextID)
|
||||
}
|
||||
|
||||
// will flush front buffer if no double buffering is used
|
||||
context->st->flush(context->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
|
||||
st_context_flush(context->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
|
||||
|
||||
struct hgl_buffer* buffer = context->buffer;
|
||||
|
||||
@@ -351,7 +351,7 @@ GalliumContext::SwapBuffers(context_id contextID)
|
||||
}
|
||||
|
||||
/* TODO: remove this if the framebuffer state doesn't change. */
|
||||
context->st->invalidate_state(context->st, ST_INVALIDATE_FB_STATE);
|
||||
st_context_invalidate_state(context->st, ST_INVALIDATE_FB_STATE);
|
||||
|
||||
Unlock();
|
||||
return B_OK;
|
||||
|
@@ -20,6 +20,8 @@ DrvSwapLayerBuffers@8
|
||||
DrvValidateVersion@4
|
||||
|
||||
; __cdecl calling convention have no @number suffix
|
||||
st_context_flush
|
||||
st_context_teximage
|
||||
stw_get_device
|
||||
stw_init_screen
|
||||
stw_get_current_context
|
||||
|
@@ -393,62 +393,6 @@ struct st_context
|
||||
} zombie_shaders;
|
||||
|
||||
struct hash_table *hw_select_shaders;
|
||||
|
||||
/* TODO: Burn these callbacks to the ground: */
|
||||
|
||||
/**
|
||||
* Destroy the context.
|
||||
*/
|
||||
void (*destroy)(struct st_context *st);
|
||||
|
||||
/**
|
||||
* Flush all drawing from context to the pipe also flushes the pipe.
|
||||
*/
|
||||
void (*flush)(struct st_context *st, unsigned flags,
|
||||
struct pipe_fence_handle **fence,
|
||||
void (*notify_before_flush_cb) (void*),
|
||||
void* notify_before_flush_cb_args);
|
||||
|
||||
/**
|
||||
* Replace the texture image of a texture object at the specified level.
|
||||
*
|
||||
* This function is optional.
|
||||
*/
|
||||
bool (*teximage)(struct st_context *st,
|
||||
enum st_texture_type target,
|
||||
int level, enum pipe_format internal_format,
|
||||
struct pipe_resource *tex, bool mipmap);
|
||||
|
||||
/**
|
||||
* Used to implement glXCopyContext.
|
||||
*/
|
||||
void (*copy)(struct st_context *st,
|
||||
struct st_context *src, unsigned mask);
|
||||
|
||||
/**
|
||||
* Used to implement wglShareLists.
|
||||
*/
|
||||
bool (*share)(struct st_context *st,
|
||||
struct st_context *src);
|
||||
|
||||
/**
|
||||
* Start the thread if the API has a worker thread.
|
||||
* Called after the context has been created and fully initialized on both
|
||||
* sides (e.g. st/mesa and st/dri).
|
||||
*/
|
||||
void (*start_thread)(struct st_context *st);
|
||||
|
||||
/**
|
||||
* If the API is multithreaded, wait for all queued commands to complete.
|
||||
* Called from the main thread.
|
||||
*/
|
||||
void (*thread_finish)(struct st_context *st);
|
||||
|
||||
/**
|
||||
* Invalidate states to notify the frontend that states have been changed
|
||||
* behind its back.
|
||||
*/
|
||||
void (*invalidate_state)(struct st_context *st, unsigned flags);
|
||||
};
|
||||
|
||||
|
||||
@@ -472,6 +416,19 @@ st_create_context(gl_api api, struct pipe_context *pipe,
|
||||
extern void
|
||||
st_destroy_context(struct st_context *st);
|
||||
|
||||
extern void
|
||||
st_context_flush(struct st_context *st, unsigned flags,
|
||||
struct pipe_fence_handle **fence,
|
||||
void (*before_flush_cb) (void*), void* args);
|
||||
|
||||
extern bool
|
||||
st_context_teximage(struct st_context *st,
|
||||
enum st_texture_type tex_type,
|
||||
int level, enum pipe_format pipe_format,
|
||||
struct pipe_resource *tex, bool mipmap);
|
||||
|
||||
extern void
|
||||
st_context_invalidate_state(struct st_context *st, unsigned flags);
|
||||
|
||||
extern void
|
||||
st_invalidate_buffers(struct st_context *st);
|
||||
|
@@ -254,8 +254,7 @@ st_interop_export_object(struct st_context *st,
|
||||
return MESA_GLINTEROP_INVALID_VERSION;
|
||||
|
||||
/* Wait for glthread to finish to get up-to-date GL object lookups. */
|
||||
if (st->thread_finish)
|
||||
st->thread_finish(st);
|
||||
_mesa_glthread_finish(st->ctx);
|
||||
|
||||
/* Validate the OpenGL object and get pipe_resource. */
|
||||
simple_mtx_lock(&ctx->Shared->Mutex);
|
||||
@@ -348,8 +347,7 @@ st_interop_flush_objects(struct st_context *st,
|
||||
struct gl_context *ctx = st->ctx;
|
||||
|
||||
/* Wait for glthread to finish to get up-to-date GL object lookups. */
|
||||
if (st->thread_finish)
|
||||
st->thread_finish(st);
|
||||
_mesa_glthread_finish(st->ctx);
|
||||
|
||||
simple_mtx_lock(&ctx->Shared->Mutex);
|
||||
|
||||
|
@@ -786,11 +786,10 @@ st_framebuffers_purge(struct st_context *st)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
void
|
||||
st_context_flush(struct st_context *st, unsigned flags,
|
||||
struct pipe_fence_handle **fence,
|
||||
void (*before_flush_cb) (void*),
|
||||
void* args)
|
||||
void (*before_flush_cb) (void*), void* args)
|
||||
{
|
||||
unsigned pipe_flags = 0;
|
||||
|
||||
@@ -820,10 +819,13 @@ st_context_flush(struct st_context *st, unsigned flags,
|
||||
st_manager_flush_frontbuffer(st);
|
||||
}
|
||||
|
||||
/* This is only for GLX_EXT_texture_from_pixmap and equivalent features
|
||||
/**
|
||||
* Replace the texture image of a texture object at the specified level.
|
||||
*
|
||||
* This is only for GLX_EXT_texture_from_pixmap and equivalent features
|
||||
* in EGL and WGL.
|
||||
*/
|
||||
static bool
|
||||
bool
|
||||
st_context_teximage(struct st_context *st,
|
||||
enum st_texture_type tex_type,
|
||||
int level, enum pipe_format pipe_format,
|
||||
@@ -912,46 +914,12 @@ st_context_teximage(struct st_context *st,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
st_context_copy(struct st_context *st,
|
||||
struct st_context *src, unsigned mask)
|
||||
{
|
||||
_mesa_copy_context(src->ctx, st->ctx, mask);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
st_context_share(struct st_context *st,
|
||||
struct st_context *src)
|
||||
{
|
||||
return _mesa_share_state(st->ctx, src->ctx);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
st_context_destroy(struct st_context *st)
|
||||
{
|
||||
st_destroy_context(st);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
st_start_thread(struct st_context *st)
|
||||
{
|
||||
_mesa_glthread_init(st->ctx);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
st_thread_finish(struct st_context *st)
|
||||
{
|
||||
_mesa_glthread_finish(st->ctx);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
st_context_invalidate_state(struct st_context *st,
|
||||
unsigned flags)
|
||||
/**
|
||||
* Invalidate states to notify the frontend that driver states have been
|
||||
* changed behind its back.
|
||||
*/
|
||||
void
|
||||
st_context_invalidate_state(struct st_context *st, unsigned flags)
|
||||
{
|
||||
if (flags & ST_INVALIDATE_FS_SAMPLER_VIEWS)
|
||||
st->dirty |= ST_NEW_FS_SAMPLER_VIEWS;
|
||||
@@ -1111,16 +1079,6 @@ st_api_create_context(struct pipe_frontend_screen *fscreen,
|
||||
st->ctx->invalidate_on_gl_viewport =
|
||||
fscreen->get_param(fscreen, ST_MANAGER_BROKEN_INVALIDATE);
|
||||
|
||||
st->destroy = st_context_destroy;
|
||||
st->flush = st_context_flush;
|
||||
st->teximage = st_context_teximage;
|
||||
st->copy = st_context_copy;
|
||||
st->share = st_context_share;
|
||||
st->start_thread = st_start_thread;
|
||||
st->thread_finish = st_thread_finish;
|
||||
st->invalidate_state = st_context_invalidate_state;
|
||||
st->cso_context = st->cso_context;
|
||||
st->pipe = st->pipe;
|
||||
st->frontend_screen = fscreen;
|
||||
|
||||
if (st->ctx->IntelBlackholeRender &&
|
||||
|
Reference in New Issue
Block a user