summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2022-11-27 12:59:22 -0500
committerMarge Bot <emma+marge@anholt.net>2022-12-09 13:14:03 +0000
commit263dc7b6056e660b9f1b69194538428b53192c1f (patch)
tree50d631e7e3cca19071719e372c2e543c9268043f
parentc61aa8fa816cc06771053ecd72864d5381d2f624 (diff)
downloadmesa-263dc7b6056e660b9f1b69194538428b53192c1f.tar.gz
mesa-263dc7b6056e660b9f1b69194538428b53192c1f.tar.bz2
mesa-263dc7b6056e660b9f1b69194538428b53192c1f.zip
gallium: remove st_context_iface, use st_context directly
st_context_iface was the base class that st_context inherited. Just use st_context. 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>
-rw-r--r--src/egl/drivers/wgl/egl_wgl.c6
-rw-r--r--src/egl/meson.build2
-rw-r--r--src/gallium/auxiliary/postprocess/postprocess.h1
-rw-r--r--src/gallium/frontends/dri/dri_context.c6
-rw-r--r--src/gallium/frontends/dri/dri_context.h4
-rw-r--r--src/gallium/frontends/dri/dri_drawable.c20
-rw-r--r--src/gallium/frontends/dri/dri_helpers.c34
-rw-r--r--src/gallium/frontends/dri/dri_screen.c4
-rw-r--r--src/gallium/frontends/dri/kopper.c3
-rw-r--r--src/gallium/frontends/glx/xlib/xm_api.c6
-rw-r--r--src/gallium/frontends/glx/xlib/xm_api.h3
-rw-r--r--src/gallium/frontends/glx/xlib/xm_st.c12
-rw-r--r--src/gallium/frontends/hgl/hgl.c12
-rw-r--r--src/gallium/frontends/hgl/hgl_context.h2
-rw-r--r--src/gallium/frontends/osmesa/meson.build1
-rw-r--r--src/gallium/frontends/osmesa/osmesa.c35
-rw-r--r--src/gallium/frontends/wgl/stw_context.c5
-rw-r--r--src/gallium/frontends/wgl/stw_context.h4
-rw-r--r--src/gallium/frontends/wgl/stw_ext_rendertexture.c2
-rw-r--r--src/gallium/frontends/wgl/stw_framebuffer.c10
-rw-r--r--src/gallium/frontends/wgl/stw_framebuffer.h2
-rw-r--r--src/gallium/frontends/wgl/stw_st.c38
-rw-r--r--src/gallium/frontends/wgl/stw_st.h5
-rw-r--r--src/gallium/include/frontend/api.h106
-rw-r--r--src/gallium/targets/haiku-softpipe/GalliumContext.cpp6
-rw-r--r--src/mesa/state_tracker/st_cb_eglimage.c4
-rw-r--r--src/mesa/state_tracker/st_context.c4
-rw-r--r--src/mesa/state_tracker/st_context.h61
-rw-r--r--src/mesa/state_tracker/st_interop.c10
-rw-r--r--src/mesa/state_tracker/st_interop.h6
-rw-r--r--src/mesa/state_tracker/st_manager.c81
31 files changed, 236 insertions, 259 deletions
diff --git a/src/egl/drivers/wgl/egl_wgl.c b/src/egl/drivers/wgl/egl_wgl.c
index dffba013ed9..9a243a308d3 100644
--- a/src/egl/drivers/wgl/egl_wgl.c
+++ b/src/egl/drivers/wgl/egl_wgl.c
@@ -21,6 +21,8 @@
* IN THE SOFTWARE.
*/
+#include "state_tracker/st_context.h"
+
#include <egldriver.h>
#include <egllog.h>
#include <eglcurrent.h>
@@ -978,7 +980,7 @@ wgl_create_sync_khr(_EGLDisplay *disp, EGLenum type, const EGLAttrib *attrib_lis
struct wgl_egl_context *wgl_ctx = wgl_egl_context(ctx);
struct wgl_egl_sync *wgl_sync;
- struct st_context_iface *st_ctx = wgl_ctx ? wgl_ctx->ctx->st : NULL;
+ struct st_context *st = wgl_ctx ? wgl_ctx->ctx->st : NULL;
wgl_sync = calloc(1, sizeof(struct wgl_egl_sync));
if (!wgl_sync) {
@@ -993,7 +995,7 @@ wgl_create_sync_khr(_EGLDisplay *disp, EGLenum type, const EGLAttrib *attrib_lis
switch (type) {
case EGL_SYNC_FENCE_KHR:
- st_ctx->flush(st_ctx, 0, &wgl_sync->fence, NULL, NULL);
+ st->flush(st, 0, &wgl_sync->fence, NULL, NULL);
if (!wgl_sync->fence) {
_eglError(EGL_BAD_ALLOC, "eglCreateSyncKHR");
free(wgl_sync);
diff --git a/src/egl/meson.build b/src/egl/meson.build
index 5b4644940a5..6aeb42f48b9 100644
--- a/src/egl/meson.build
+++ b/src/egl/meson.build
@@ -154,7 +154,7 @@ elif with_platform_windows
'-DEGLAPI=', '-DPUBLIC='
]
files_egl += files('drivers/wgl/egl_wgl.c')
- incs_for_egl += [inc_wgl, inc_gallium, inc_gallium_aux]
+ incs_for_egl += [inc_wgl, inc_gallium, inc_gallium_aux, inc_mesa, inc_mapi]
link_for_egl += libgallium_wgl
endif
diff --git a/src/gallium/auxiliary/postprocess/postprocess.h b/src/gallium/auxiliary/postprocess/postprocess.h
index d19bcd03093..e6f3c826e23 100644
--- a/src/gallium/auxiliary/postprocess/postprocess.h
+++ b/src/gallium/auxiliary/postprocess/postprocess.h
@@ -35,7 +35,6 @@ extern "C" {
#endif
struct cso_context;
-struct st_context_iface;
struct pp_queue_t; /* Forward definition */
struct pp_program;
diff --git a/src/gallium/frontends/dri/dri_context.c b/src/gallium/frontends/dri/dri_context.c
index fdc66244c05..c628d8748c9 100644
--- a/src/gallium/frontends/dri/dri_context.c
+++ b/src/gallium/frontends/dri/dri_context.c
@@ -50,7 +50,7 @@ dri_create_context(struct dri_screen *screen,
void *loaderPrivate)
{
struct dri_context *ctx = NULL;
- struct st_context_iface *st_share = NULL;
+ struct st_context *st_share = NULL;
struct st_context_attribs attribs;
enum st_context_error ctx_err = 0;
unsigned allowed_flags = __DRI_CTX_FLAG_DEBUG |
@@ -265,7 +265,7 @@ GLboolean
dri_unbind_context(struct dri_context *ctx)
{
/* dri_util.c ensures cPriv is not null */
- struct st_context_iface *st = ctx->st;
+ struct st_context *st = ctx->st;
if (st == st_api_get_current()) {
if (st->thread_finish)
@@ -344,7 +344,7 @@ dri_make_current(struct dri_context *ctx,
struct dri_context *
dri_get_current(void)
{
- struct st_context_iface *st = st_api_get_current();
+ struct st_context *st = st_api_get_current();
return (struct dri_context *) st ? st->frontend_context : NULL;
}
diff --git a/src/gallium/frontends/dri/dri_context.h b/src/gallium/frontends/dri/dri_context.h
index 3063f4c7fa2..c52370877f7 100644
--- a/src/gallium/frontends/dri/dri_context.h
+++ b/src/gallium/frontends/dri/dri_context.h
@@ -38,7 +38,7 @@
struct pipe_context;
struct pipe_fence;
-struct st_context_iface;
+struct st_context;
struct dri_drawable;
struct dri_screen;
@@ -74,7 +74,7 @@ struct dri_context
} dri2;
/* gallium */
- struct st_context_iface *st;
+ struct st_context *st;
struct pp_queue_t *pp;
struct hud_context *hud;
};
diff --git a/src/gallium/frontends/dri/dri_drawable.c b/src/gallium/frontends/dri/dri_drawable.c
index 2de80ac2ca5..d33e4c27db1 100644
--- a/src/gallium/frontends/dri/dri_drawable.c
+++ b/src/gallium/frontends/dri/dri_drawable.c
@@ -38,16 +38,18 @@
#include "util/u_memory.h"
#include "util/u_inlines.h"
+#include "state_tracker/st_context.h"
+
static uint32_t drifb_ID = 0;
static bool
-dri_st_framebuffer_validate(struct st_context_iface *stctx,
+dri_st_framebuffer_validate(struct st_context *st,
struct st_framebuffer_iface *stfbi,
const enum st_attachment_type *statts,
unsigned count,
struct pipe_resource **out)
{
- struct dri_context *ctx = (struct dri_context *)stctx->frontend_context;
+ struct dri_context *ctx = (struct dri_context *)st->frontend_context;
struct dri_drawable *drawable =
(struct dri_drawable *) stfbi->st_manager_private;
struct dri_screen *screen = drawable->screen;
@@ -110,11 +112,11 @@ dri_st_framebuffer_validate(struct st_context_iface *stctx,
}
static bool
-dri_st_framebuffer_flush_front(struct st_context_iface *stctx,
+dri_st_framebuffer_flush_front(struct st_context *st,
struct st_framebuffer_iface *stfbi,
enum st_attachment_type statt)
{
- struct dri_context *ctx = (struct dri_context *)stctx->frontend_context;
+ struct dri_context *ctx = (struct dri_context *)st->frontend_context;
struct dri_drawable *drawable =
(struct dri_drawable *) stfbi->st_manager_private;
@@ -126,10 +128,10 @@ dri_st_framebuffer_flush_front(struct st_context_iface *stctx,
* The gallium frontend framebuffer interface flush_swapbuffers callback
*/
static bool
-dri_st_framebuffer_flush_swapbuffers(struct st_context_iface *stctx,
+dri_st_framebuffer_flush_swapbuffers(struct st_context *st,
struct st_framebuffer_iface *stfbi)
{
- struct dri_context *ctx = (struct dri_context *)stctx->frontend_context;
+ struct dri_context *ctx = (struct dri_context *)st->frontend_context;
struct dri_drawable *drawable =
(struct dri_drawable *) stfbi->st_manager_private;
@@ -252,7 +254,7 @@ dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
GLint format, __DRIdrawable *dPriv)
{
struct dri_context *ctx = dri_context(pDRICtx);
- struct st_context_iface *st = ctx->st;
+ struct st_context *st = ctx->st;
struct dri_drawable *drawable = dri_drawable(dPriv);
struct pipe_resource *pt;
@@ -418,7 +420,7 @@ static void
notify_before_flush_cb(void* _args)
{
struct notify_before_flush_cb_args *args = (struct notify_before_flush_cb_args *) _args;
- struct st_context_iface *st = args->ctx->st;
+ struct st_context *st = args->ctx->st;
struct pipe_context *pipe = st->pipe;
/* Wait for glthread to finish because we can't use pipe_context from
@@ -478,7 +480,7 @@ dri_flush(__DRIcontext *cPriv,
{
struct dri_context *ctx = dri_context(cPriv);
struct dri_drawable *drawable = dri_drawable(dPriv);
- struct st_context_iface *st;
+ struct st_context *st;
unsigned flush_flags;
struct notify_before_flush_cb_args args = { 0 };
diff --git a/src/gallium/frontends/dri/dri_helpers.c b/src/gallium/frontends/dri/dri_helpers.c
index ec78607efdf..dcfee218417 100644
--- a/src/gallium/frontends/dri/dri_helpers.c
+++ b/src/gallium/frontends/dri/dri_helpers.c
@@ -91,7 +91,7 @@ static void *
dri2_create_fence(__DRIcontext *_ctx)
{
struct dri_context *ctx = dri_context(_ctx);
- struct st_context_iface *stapi = ctx->st;
+ struct st_context *st = ctx->st;
struct dri2_fence *fence = CALLOC_STRUCT(dri2_fence);
if (!fence)
@@ -100,10 +100,10 @@ dri2_create_fence(__DRIcontext *_ctx)
/* Wait for glthread to finish because we can't use pipe_context from
* multiple threads.
*/
- if (stapi->thread_finish)
- stapi->thread_finish(stapi);
+ if (st->thread_finish)
+ st->thread_finish(st);
- stapi->flush(stapi, 0, &fence->pipe_fence, NULL, NULL);
+ st->flush(st, 0, &fence->pipe_fence, NULL, NULL);
if (!fence->pipe_fence) {
FREE(fence);
@@ -118,19 +118,19 @@ static void *
dri2_create_fence_fd(__DRIcontext *_ctx, int fd)
{
struct dri_context *dri_ctx = dri_context(_ctx);
- struct st_context_iface *stapi = dri_ctx->st;
- struct pipe_context *ctx = stapi->pipe;
+ struct st_context *st = dri_ctx->st;
+ struct pipe_context *ctx = st->pipe;
struct dri2_fence *fence = CALLOC_STRUCT(dri2_fence);
/* Wait for glthread to finish because we can't use pipe_context from
* multiple threads.
*/
- if (stapi->thread_finish)
- stapi->thread_finish(stapi);
+ if (st->thread_finish)
+ st->thread_finish(st);
if (fd == -1) {
/* exporting driver created fence, flush: */
- stapi->flush(stapi, ST_FLUSH_FENCE_FD, &fence->pipe_fence, NULL, NULL);
+ st->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);
@@ -225,7 +225,7 @@ dri2_client_wait_sync(__DRIcontext *_ctx, void *_fence, unsigned flags,
static void
dri2_server_wait_sync(__DRIcontext *_ctx, void *_fence, unsigned flags)
{
- struct st_context_iface *st = dri_context(_ctx)->st;
+ struct st_context *st = dri_context(_ctx)->st;
struct pipe_context *ctx = st->pipe;
struct dri2_fence *fence = (struct dri2_fence*)_fence;
@@ -295,10 +295,9 @@ dri2_create_image_from_renderbuffer2(__DRIcontext *context,
unsigned *error)
{
struct dri_context *dri_ctx = dri_context(context);
- struct st_context_iface *st = dri_ctx->st;
- struct st_context *st_ctx = (struct st_context *)st;
- struct gl_context *ctx = st_ctx->ctx;
- struct pipe_context *p_ctx = st_ctx->pipe;
+ struct st_context *st = dri_ctx->st;
+ struct gl_context *ctx = st->ctx;
+ struct pipe_context *p_ctx = st->pipe;
struct gl_renderbuffer *rb;
struct pipe_resource *tex;
__DRIimage *img;
@@ -397,10 +396,9 @@ dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture,
{
__DRIimage *img;
struct dri_context *dri_ctx = dri_context(context);
- struct st_context_iface *st = dri_ctx->st;
- struct st_context *st_ctx = (struct st_context *)st;
- struct gl_context *ctx = st_ctx->ctx;
- struct pipe_context *p_ctx = st_ctx->pipe;
+ struct st_context *st = dri_ctx->st;
+ struct gl_context *ctx = st->ctx;
+ struct pipe_context *p_ctx = st->pipe;
struct gl_texture_object *obj;
struct pipe_resource *tex;
GLuint face = 0;
diff --git a/src/gallium/frontends/dri/dri_screen.c b/src/gallium/frontends/dri/dri_screen.c
index 16c32806bfd..8cf0e8b4027 100644
--- a/src/gallium/frontends/dri/dri_screen.c
+++ b/src/gallium/frontends/dri/dri_screen.c
@@ -43,6 +43,8 @@
#include "util/u_driconf.h"
#include "util/format/u_format_s3tc.h"
+#include "state_tracker/st_context.h"
+
#define MSAA_VISUAL_MAX_SAMPLES 32
#undef false
@@ -808,7 +810,7 @@ dri_postprocessing_init(struct dri_screen *screen)
}
static void
-dri_set_background_context(struct st_context_iface *st,
+dri_set_background_context(struct st_context *st,
struct util_queue_monitoring *queue_info)
{
struct dri_context *ctx = (struct dri_context *)st->frontend_context;
diff --git a/src/gallium/frontends/dri/kopper.c b/src/gallium/frontends/dri/kopper.c
index 61c5dc22c21..1334a6e46bf 100644
--- a/src/gallium/frontends/dri/kopper.c
+++ b/src/gallium/frontends/dri/kopper.c
@@ -705,8 +705,9 @@ kopper_flush_frontbuffer(struct dri_context *ctx,
if (ptex) {
ctx->st->pipe->flush_resource(ctx->st->pipe, drawable->textures[ST_ATTACHMENT_FRONT_LEFT]);
struct pipe_screen *screen = drawable->screen->base.screen;
- struct st_context_iface *st;
+ struct st_context *st;
struct pipe_fence_handle *new_fence = NULL;
+
st = ctx->st;
if (st->thread_finish)
st->thread_finish(st);
diff --git a/src/gallium/frontends/glx/xlib/xm_api.c b/src/gallium/frontends/glx/xlib/xm_api.c
index 48b41052824..683b8afde1f 100644
--- a/src/gallium/frontends/glx/xlib/xm_api.c
+++ b/src/gallium/frontends/glx/xlib/xm_api.c
@@ -75,6 +75,8 @@
#include <GL/glx.h>
+#include "state_tracker/st_context.h"
+
extern struct pipe_screen *
xlib_create_screen(Display *display);
@@ -1318,7 +1320,7 @@ GLboolean XMesaUnbindContext( XMesaContext c )
XMesaContext XMesaGetCurrentContext( void )
{
- struct st_context_iface *st = st_api_get_current();
+ struct st_context *st = st_api_get_current();
return (XMesaContext) (st) ? st->frontend_context : NULL;
}
@@ -1464,7 +1466,7 @@ PUBLIC void
XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
const int *attrib_list)
{
- struct st_context_iface *st = st_api_get_current();
+ struct st_context *st = st_api_get_current();
struct st_framebuffer_iface* stfbi = drawable->stfb;
struct pipe_resource *res;
int x, y, w, h;
diff --git a/src/gallium/frontends/glx/xlib/xm_api.h b/src/gallium/frontends/glx/xlib/xm_api.h
index 2975e8d5da4..fa531c48843 100644
--- a/src/gallium/frontends/glx/xlib/xm_api.h
+++ b/src/gallium/frontends/glx/xlib/xm_api.h
@@ -68,6 +68,7 @@ and create a window, you must do the following to use the X/Mesa interface:
# include <X11/Xlibint.h>
# include <X11/Xutil.h>
+struct st_context;
struct hud_context;
typedef struct xmesa_display *XMesaDisplay;
@@ -304,7 +305,7 @@ struct xmesa_visual {
* Basically corresponds to a GLXContext.
*/
struct xmesa_context {
- struct st_context_iface *st;
+ struct st_context *st;
XMesaVisual xm_visual; /** pixel format info */
XMesaBuffer xm_buffer; /** current drawbuffer */
XMesaBuffer xm_read_buffer; /** current readbuffer */
diff --git a/src/gallium/frontends/glx/xlib/xm_st.c b/src/gallium/frontends/glx/xlib/xm_st.c
index f3cf5b8ba8a..cc637f03bdf 100644
--- a/src/gallium/frontends/glx/xlib/xm_st.c
+++ b/src/gallium/frontends/glx/xlib/xm_st.c
@@ -32,6 +32,8 @@
#include "util/u_atomic.h"
#include "util/u_memory.h"
+#include "state_tracker/st_context.h"
+
struct xmesa_st_framebuffer {
XMesaDisplay display;
XMesaBuffer buffer;
@@ -59,14 +61,14 @@ xmesa_st_framebuffer(struct st_framebuffer_iface *stfbi)
*/
static bool
xmesa_st_framebuffer_display(struct st_framebuffer_iface *stfbi,
- struct st_context_iface *stctx,
+ struct st_context *st,
enum st_attachment_type statt,
struct pipe_box *box)
{
struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
struct pipe_resource *ptex = xstfb->textures[statt];
struct pipe_resource *pres;
- struct pipe_context *pctx = stctx ? stctx->pipe : NULL;
+ struct pipe_context *pctx = st ? st->pipe : NULL;
if (!ptex)
return true;
@@ -200,7 +202,7 @@ xmesa_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi,
* \param out returns resources for each of the attachments
*/
static bool
-xmesa_st_framebuffer_validate(struct st_context_iface *stctx,
+xmesa_st_framebuffer_validate(struct st_context *st,
struct st_framebuffer_iface *stfbi,
const enum st_attachment_type *statts,
unsigned count,
@@ -261,7 +263,7 @@ xmesa_st_framebuffer_validate(struct st_context_iface *stctx,
* Called via st_framebuffer_iface::flush_front()
*/
static bool
-xmesa_st_framebuffer_flush_front(struct st_context_iface *stctx,
+xmesa_st_framebuffer_flush_front(struct st_context *st,
struct st_framebuffer_iface *stfbi,
enum st_attachment_type statt)
{
@@ -271,7 +273,7 @@ xmesa_st_framebuffer_flush_front(struct st_context_iface *stctx,
if (statt != ST_ATTACHMENT_FRONT_LEFT)
return false;
- ret = xmesa_st_framebuffer_display(stfbi, stctx, statt, NULL);
+ ret = xmesa_st_framebuffer_display(stfbi, st, statt, NULL);
if (ret && xmesa_strict_invalidate())
xmesa_check_buffer_size(xstfb->buffer);
diff --git a/src/gallium/frontends/hgl/hgl.c b/src/gallium/frontends/hgl/hgl.c
index c3b1cbd9b0c..eeb78179dda 100644
--- a/src/gallium/frontends/hgl/hgl.c
+++ b/src/gallium/frontends/hgl/hgl.c
@@ -32,11 +32,11 @@
// Perform a safe void to hgl_context cast
static inline struct hgl_context*
-hgl_st_context(struct st_context_iface *stctxi)
+hgl_st_context(struct st_context *st)
{
struct hgl_context* context;
- assert(stctxi);
- context = (struct hgl_context*)stctxi->frontend_context;
+ assert(st);
+ context = (struct hgl_context*)st->frontend_context;
assert(context);
return context;
}
@@ -56,7 +56,7 @@ hgl_st_framebuffer(struct st_framebuffer_iface *stfbi)
static bool
-hgl_st_framebuffer_flush_front(struct st_context_iface* stctxi,
+hgl_st_framebuffer_flush_front(struct st_context *st,
struct st_framebuffer_iface* stfbi, enum st_attachment_type statt)
{
CALLED();
@@ -153,7 +153,7 @@ hgl_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi,
* its resources).
*/
static bool
-hgl_st_framebuffer_validate(struct st_context_iface *stctxi,
+hgl_st_framebuffer_validate(struct st_context *st,
struct st_framebuffer_iface *stfbi, const enum st_attachment_type *statts,
unsigned count, struct pipe_resource **out)
{
@@ -165,7 +165,7 @@ hgl_st_framebuffer_validate(struct st_context_iface *stctxi,
CALLED();
- context = hgl_st_context(stctxi);
+ context = hgl_st_context(st);
buffer = hgl_st_framebuffer(stfbi);
// Build mask of current attachments
diff --git a/src/gallium/frontends/hgl/hgl_context.h b/src/gallium/frontends/hgl/hgl_context.h
index d5871d4cd5c..04baa748fd6 100644
--- a/src/gallium/frontends/hgl/hgl_context.h
+++ b/src/gallium/frontends/hgl/hgl_context.h
@@ -59,7 +59,7 @@ struct hgl_display
struct hgl_context
{
struct hgl_display* display;
- struct st_context_iface* st;
+ struct st_context* st;
struct st_visual* stVisual;
// Post processing
diff --git a/src/gallium/frontends/osmesa/meson.build b/src/gallium/frontends/osmesa/meson.build
index 8abf55c02e4..721ecd6f9c6 100644
--- a/src/gallium/frontends/osmesa/meson.build
+++ b/src/gallium/frontends/osmesa/meson.build
@@ -32,4 +32,5 @@ libosmesa_st = static_library(
include_directories : [
inc_include, inc_src, inc_gallium, inc_gallium_aux, inc_mapi, inc_mesa,
],
+ dependencies : [idep_mesautil],
)
diff --git a/src/gallium/frontends/osmesa/osmesa.c b/src/gallium/frontends/osmesa/osmesa.c
index 4f12c944f63..554c194828a 100644
--- a/src/gallium/frontends/osmesa/osmesa.c
+++ b/src/gallium/frontends/osmesa/osmesa.c
@@ -51,6 +51,9 @@
#include <stdio.h>
#include <c11/threads.h>
+
+#include "state_tracker/st_context.h"
+
#include "GL/osmesa.h"
#include "glapi/glapi.h" /* for OSMesaGetProcAddress below */
@@ -94,7 +97,7 @@ struct osmesa_buffer
struct osmesa_context
{
- struct st_context_iface *stctx;
+ struct st_context *st;
boolean ever_used; /*< Has this context ever been current? */
@@ -176,7 +179,7 @@ static void
osmesa_read_buffer(OSMesaContext osmesa, struct pipe_resource *res, void *dst,
int dst_stride, bool y_up)
{
- struct pipe_context *pipe = osmesa->stctx->pipe;
+ struct pipe_context *pipe = osmesa->st->pipe;
struct pipe_box box;
u_box_2d(0, 0, res->width0, res->height0, &box);
@@ -338,7 +341,7 @@ stfbi_to_osbuffer(struct st_framebuffer_iface *stfbi)
* of the driver's color buffer into the user-specified buffer.
*/
static bool
-osmesa_st_framebuffer_flush_front(struct st_context_iface *stctx,
+osmesa_st_framebuffer_flush_front(struct st_context *st,
struct st_framebuffer_iface *stfbi,
enum st_attachment_type statt)
{
@@ -397,7 +400,7 @@ osmesa_st_framebuffer_flush_front(struct st_context_iface *stctx,
* its resources).
*/
static bool
-osmesa_st_framebuffer_validate(struct st_context_iface *stctx,
+osmesa_st_framebuffer_validate(struct st_context *st,
struct st_framebuffer_iface *stfbi,
const enum st_attachment_type *statts,
unsigned count,
@@ -566,7 +569,7 @@ GLAPI OSMesaContext GLAPIENTRY
OSMesaCreateContextAttribs(const int *attribList, OSMesaContext sharelist)
{
OSMesaContext osmesa;
- struct st_context_iface *st_shared;
+ struct st_context *st_shared;
enum st_context_error st_error = 0;
struct st_context_attribs attribs;
GLenum format = GL_RGBA;
@@ -575,7 +578,7 @@ OSMesaCreateContextAttribs(const int *attribList, OSMesaContext sharelist)
int i;
if (sharelist) {
- st_shared = sharelist->stctx;
+ st_shared = sharelist->st;
}
else {
st_shared = NULL;
@@ -679,14 +682,14 @@ OSMesaCreateContextAttribs(const int *attribList, OSMesaContext sharelist)
osmesa->depth_stencil_format,
osmesa->accum_format);
- osmesa->stctx = st_api_create_context(get_st_manager(),
+ osmesa->st = st_api_create_context(get_st_manager(),
&attribs, &st_error, st_shared);
- if (!osmesa->stctx) {
+ if (!osmesa->st) {
FREE(osmesa);
return NULL;
}
- osmesa->stctx->frontend_context = osmesa;
+ osmesa->st->frontend_context = osmesa;
osmesa->format = format;
osmesa->user_row_length = 0;
@@ -707,7 +710,7 @@ OSMesaDestroyContext(OSMesaContext osmesa)
{
if (osmesa) {
pp_free(osmesa->pp);
- osmesa->stctx->destroy(osmesa->stctx);
+ osmesa->st->destroy(osmesa->st);
free(osmesa->zs);
FREE(osmesa);
}
@@ -782,7 +785,7 @@ OSMesaMakeCurrent(OSMesaContext osmesa, void *buffer, GLenum type,
osmesa->type = type;
- st_api_make_current(osmesa->stctx, osbuffer->stfb, osbuffer->stfb);
+ st_api_make_current(osmesa->st, osbuffer->stfb, osbuffer->stfb);
/* XXX: We should probably load the current color value into the buffer here
* to match classic swrast behavior (context's fb starts with the contents of
@@ -802,11 +805,11 @@ OSMesaMakeCurrent(OSMesaContext osmesa, void *buffer, GLenum type,
}
if (any_pp_enabled) {
- osmesa->pp = pp_init(osmesa->stctx->pipe,
+ osmesa->pp = pp_init(osmesa->st->pipe,
osmesa->pp_enabled,
- osmesa->stctx->cso_context,
- osmesa->stctx,
- (void*)osmesa->stctx->invalidate_state);
+ osmesa->st->cso_context,
+ osmesa->st,
+ (void*)osmesa->st->invalidate_state);
pp_init_fbos(osmesa->pp, width, height);
}
@@ -822,7 +825,7 @@ OSMesaMakeCurrent(OSMesaContext osmesa, void *buffer, GLenum type,
GLAPI OSMesaContext GLAPIENTRY
OSMesaGetCurrentContext(void)
{
- struct st_context_iface *st = st_api_get_current();
+ struct st_context *st = st_api_get_current();
return st ? (OSMesaContext) st->frontend_context : NULL;
}
diff --git a/src/gallium/frontends/wgl/stw_context.c b/src/gallium/frontends/wgl/stw_context.c
index 4d06c86e4e7..30d1d63bfe6 100644
--- a/src/gallium/frontends/wgl/stw_context.c
+++ b/src/gallium/frontends/wgl/stw_context.c
@@ -25,6 +25,8 @@
*
**************************************************************************/
+#include "state_tracker/st_context.h"
+
#include <windows.h>
#define WGL_WGLEXT_PROTOTYPES
@@ -48,11 +50,12 @@
#include "stw_context.h"
#include "stw_tls.h"
+#include "main/context.h"
struct stw_context *
stw_current_context(void)
{
- struct st_context_iface *st;
+ struct st_context *st;
st = (stw_dev) ? st_api_get_current() : NULL;
diff --git a/src/gallium/frontends/wgl/stw_context.h b/src/gallium/frontends/wgl/stw_context.h
index 8932805a968..f3203b37b07 100644
--- a/src/gallium/frontends/wgl/stw_context.h
+++ b/src/gallium/frontends/wgl/stw_context.h
@@ -34,12 +34,12 @@
struct hud_context;
struct stw_framebuffer;
-struct st_context_iface;
+struct st_context;
struct pipe_frontend_screen;
struct stw_context
{
- struct st_context_iface *st;
+ struct st_context *st;
DHGLRC dhglrc;
const struct stw_pixelformat_info *pfi;
HDC hDrawDC;
diff --git a/src/gallium/frontends/wgl/stw_ext_rendertexture.c b/src/gallium/frontends/wgl/stw_ext_rendertexture.c
index 746727ec40e..b19c8f15e3f 100644
--- a/src/gallium/frontends/wgl/stw_ext_rendertexture.c
+++ b/src/gallium/frontends/wgl/stw_ext_rendertexture.c
@@ -112,7 +112,7 @@ wglBindTexImageARB(HPBUFFERARB hPbuffer, int iBuffer)
/*
* Implementation notes:
* Ideally, we'd implement this function with the
- * st_context_iface::teximage() function which replaces a specific
+ * st_context_teximage() function which replaces a specific
* texture image with a different resource (the pbuffer).
* The main problem however, is the pbuffer image is upside down relative
* to the texture image.
diff --git a/src/gallium/frontends/wgl/stw_framebuffer.c b/src/gallium/frontends/wgl/stw_framebuffer.c
index 4dbe70c6ad9..ebd14f90a47 100644
--- a/src/gallium/frontends/wgl/stw_framebuffer.c
+++ b/src/gallium/frontends/wgl/stw_framebuffer.c
@@ -25,6 +25,8 @@
*
**************************************************************************/
+#include "state_tracker/st_context.h"
+
#include <windows.h>
#include "pipe/p_screen.h"
@@ -83,7 +85,7 @@ stw_framebuffer_from_hwnd_locked(HWND hwnd)
*/
void
stw_framebuffer_release_locked(struct stw_framebuffer *fb,
- struct st_context_iface *stctx)
+ struct st_context *st)
{
struct stw_framebuffer **link;
@@ -113,7 +115,7 @@ stw_framebuffer_release_locked(struct stw_framebuffer *fb,
fb->shared_surface);
if (fb->winsys_framebuffer)
- fb->winsys_framebuffer->destroy(fb->winsys_framebuffer, stctx ? stctx->pipe : NULL);
+ fb->winsys_framebuffer->destroy(fb->winsys_framebuffer, st ? st->pipe : NULL);
stw_st_destroy_framebuffer_locked(fb->stfb);
@@ -251,9 +253,9 @@ stw_call_window_proc(int nCode, WPARAM wParam, LPARAM lParam)
fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd );
if (fb) {
struct stw_context *current_context = stw_current_context();
- struct st_context_iface *ctx_iface = current_context &&
+ struct st_context *st = current_context &&
current_context->current_framebuffer == fb ? current_context->st : NULL;
- stw_framebuffer_release_locked(fb, ctx_iface);
+ stw_framebuffer_release_locked(fb, st);
}
stw_unlock_framebuffers(stw_dev);
}
diff --git a/src/gallium/frontends/wgl/stw_framebuffer.h b/src/gallium/frontends/wgl/stw_framebuffer.h
index 1fc407961a1..3536d779874 100644
--- a/src/gallium/frontends/wgl/stw_framebuffer.h
+++ b/src/gallium/frontends/wgl/stw_framebuffer.h
@@ -171,7 +171,7 @@ stw_framebuffer_reference_locked(struct stw_framebuffer *fb);
void
stw_framebuffer_release_locked(struct stw_framebuffer *fb,
- struct st_context_iface *stctx);
+ struct st_context *st);
/**
* Search a framebuffer with a matching HWND.
diff --git a/src/gallium/frontends/wgl/stw_st.c b/src/gallium/frontends/wgl/stw_st.c
index 39ae3ea4549..11bd103b4f9 100644
--- a/src/gallium/frontends/wgl/stw_st.c
+++ b/src/gallium/frontends/wgl/stw_st.c
@@ -30,6 +30,8 @@
#include "util/u_atomic.h"
#include "pipe/p_state.h"
+#include "state_tracker/st_context.h"
+
#include "stw_st.h"
#include "stw_device.h"
#include "stw_framebuffer.h"
@@ -145,7 +147,7 @@ stw_st_fill_private_loader_data(struct stw_st_framebuffer *stwfb, struct kopper_
* Remove outdated textures and create the requested ones.
*/
static void
-stw_st_framebuffer_validate_locked(struct st_context_iface *stctx,
+stw_st_framebuffer_validate_locked(struct st_context *st,
struct st_framebuffer_iface *stfb,
unsigned width, unsigned height,
unsigned mask)
@@ -186,7 +188,7 @@ stw_st_framebuffer_validate_locked(struct st_context_iface *stctx,
if (stwfb->fb->winsys_framebuffer) {
templ.nr_samples = templ.nr_storage_samples = 1;
templ.format = stwfb->stvis.color_format;
- stwfb->fb->winsys_framebuffer->resize(stwfb->fb->winsys_framebuffer, stctx->pipe, &templ);
+ stwfb->fb->winsys_framebuffer->resize(stwfb->fb->winsys_framebuffer, st->pipe, &templ);
}
}
@@ -298,13 +300,13 @@ stw_st_framebuffer_validate_locked(struct st_context_iface *stctx,
stw_dev->screen->resource_create(stw_dev->screen, &templ);
/* TODO Only blit if there is something currently drawn on the back buffer */
- stw_pipe_blit(stctx->pipe,
+ stw_pipe_blit(st->pipe,
stwfb->back_texture,
stwfb->textures[ST_ATTACHMENT_BACK_LEFT]);
}
/* Copying front texture content to fake front texture (back texture) */
- stw_pipe_blit(stctx->pipe,
+ stw_pipe_blit(st->pipe,
stwfb->textures[ST_ATTACHMENT_BACK_LEFT],
stwfb->textures[ST_ATTACHMENT_FRONT_LEFT]);
}
@@ -315,7 +317,7 @@ stw_st_framebuffer_validate_locked(struct st_context_iface *stctx,
}
static bool
-stw_st_framebuffer_validate(struct st_context_iface *stctx,
+stw_st_framebuffer_validate(struct st_context *st,
struct st_framebuffer_iface *stfb,
const enum st_attachment_type *statts,
unsigned count,
@@ -331,7 +333,7 @@ stw_st_framebuffer_validate(struct st_context_iface *stctx,
stw_framebuffer_lock(stwfb->fb);
if (stwfb->fb->must_resize || stwfb->needs_fake_front || (statt_mask & ~stwfb->texture_mask)) {
- stw_st_framebuffer_validate_locked(stctx, &stwfb->base,
+ stw_st_framebuffer_validate_locked(st, &stwfb->base,
stwfb->fb->width, stwfb->fb->height, statt_mask);
stwfb->fb->must_resize = FALSE;
}
@@ -360,7 +362,7 @@ stw_st_framebuffer_validate(struct st_context_iface *stctx,
}
struct notify_before_flush_cb_args {
- struct st_context_iface *stctx;
+ struct st_context *st;
struct stw_st_framebuffer *stwfb;
unsigned flags;
};
@@ -369,7 +371,7 @@ static void
notify_before_flush_cb(void* _args)
{
struct notify_before_flush_cb_args *args = (struct notify_before_flush_cb_args *) _args;
- struct st_context_iface *st = args->stctx;
+ struct st_context *st = args->st;
struct pipe_context *pipe = st->pipe;
if (args->stwfb->stvis.samples > 1) {
@@ -391,7 +393,7 @@ notify_before_flush_cb(void* _args)
}
void
-stw_st_flush(struct st_context_iface *stctx,
+stw_st_flush(struct st_context *st,
struct st_framebuffer_iface *stfb,
unsigned flags)
{
@@ -400,7 +402,7 @@ stw_st_flush(struct st_context_iface *stctx,
struct pipe_fence_handle **pfence = NULL;
struct pipe_fence_handle *fence = NULL;
- args.stctx = stctx;
+ args.st = st;
args.stwfb = stwfb;
args.flags = flags;
@@ -409,10 +411,10 @@ stw_st_flush(struct st_context_iface *stctx,
if (flags & ST_FLUSH_WAIT)
pfence = &fence;
- stctx->flush(stctx, flags, pfence, notify_before_flush_cb, &args);
+ st->flush(st, flags, pfence, notify_before_flush_cb, &args);
/* TODO: remove this if the framebuffer state doesn't change. */
- stctx->invalidate_state(stctx, ST_INVALIDATE_FB_STATE);
+ st->invalidate_state(st, ST_INVALIDATE_FB_STATE);
}
/**
@@ -420,7 +422,7 @@ stw_st_flush(struct st_context_iface *stctx,
*/
static bool
stw_st_framebuffer_present_locked(HDC hdc,
- struct st_context_iface *stctx,
+ struct st_context *st,
struct st_framebuffer_iface *stfb,
enum st_attachment_type statt)
{
@@ -443,12 +445,12 @@ stw_st_framebuffer_present_locked(HDC hdc,
}
static bool
-stw_st_framebuffer_flush_front(struct st_context_iface *stctx,
+stw_st_framebuffer_flush_front(struct st_context *st,
struct st_framebuffer_iface *stfb,
enum st_attachment_type statt)
{
struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
- struct pipe_context *pipe = stctx->pipe;
+ struct pipe_context *pipe = st->pipe;
bool ret;
HDC hDC;
bool need_swap_textures = false;
@@ -490,7 +492,7 @@ stw_st_framebuffer_flush_front(struct st_context_iface *stctx,
hDC = GetDC(stwfb->fb->hWnd);
- ret = stw_st_framebuffer_present_locked(hDC, stctx, &stwfb->base, statt);
+ ret = stw_st_framebuffer_present_locked(hDC, st, &stwfb->base, statt);
ReleaseDC(stwfb->fb->hWnd, hDC);
@@ -549,7 +551,7 @@ stw_st_destroy_framebuffer_locked(struct st_framebuffer_iface *stfb)
* Swap the buffers of the given framebuffer.
*/
bool
-stw_st_swap_framebuffer_locked(HDC hdc, struct st_context_iface *stctx,
+stw_st_swap_framebuffer_locked(HDC hdc, struct st_context *st,
struct st_framebuffer_iface *stfb)
{
struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
@@ -585,7 +587,7 @@ stw_st_swap_framebuffer_locked(HDC hdc, struct st_context_iface *stctx,
stwfb->texture_mask = mask;
front = ST_ATTACHMENT_FRONT_LEFT;
- return stw_st_framebuffer_present_locked(hdc, stctx, &stwfb->base, front);
+ return stw_st_framebuffer_present_locked(hdc, st, &stwfb->base, front);
}
diff --git a/src/gallium/frontends/wgl/stw_st.h b/src/gallium/frontends/wgl/stw_st.h
index e383c3795ff..774c1844d3f 100644
--- a/src/gallium/frontends/wgl/stw_st.h
+++ b/src/gallium/frontends/wgl/stw_st.h
@@ -32,6 +32,7 @@
#include "frontend/api.h"
+struct st_context;
struct stw_framebuffer;
bool
@@ -44,11 +45,11 @@ void
stw_st_destroy_framebuffer_locked(struct st_framebuffer_iface *stfb);
void
-stw_st_flush(struct st_context_iface *st, struct st_framebuffer_iface *stfb,
+stw_st_flush(struct st_context *st, struct st_framebuffer_iface *stfb,
unsigned flags);
bool
-stw_st_swap_framebuffer_locked(HDC hdc, struct st_context_iface *stctx,
+stw_st_swap_framebuffer_locked(HDC hdc, struct st_context *st,
struct st_framebuffer_iface *stfb);
struct pipe_resource *
diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h
index 693ea83a071..91b2b73a3a5 100644
--- a/src/gallium/include/frontend/api.h
+++ b/src/gallium/include/frontend/api.h
@@ -29,6 +29,8 @@
#include "util/format/u_formats.h"
+struct st_context;
+
/**
* \file API for communication between gallium frontends and supporting
* frontends such as DRI.
@@ -88,7 +90,7 @@ enum st_context_error {
};
/**
- * Used in st_context_iface->teximage.
+ * Used in st_context_teximage.
*/
enum st_texture_type {
ST_TEXTURE_1D,
@@ -271,7 +273,6 @@ struct st_context_attribs
struct st_config_options options;
};
-struct st_context_iface;
struct pipe_frontend_screen;
/**
@@ -328,7 +329,7 @@ struct st_framebuffer_iface
*
* @att is one of the front buffer attachments.
*/
- bool (*flush_front)(struct st_context_iface *stctx,
+ bool (*flush_front)(struct st_context *st,
struct st_framebuffer_iface *stfbi,
enum st_attachment_type statt);
@@ -349,96 +350,13 @@ struct st_framebuffer_iface
* the last call might be destroyed. This behavior might change in the
* future.
*/
- bool (*validate)(struct st_context_iface *stctx,
+ bool (*validate)(struct st_context *st,
struct st_framebuffer_iface *stfbi,
const enum st_attachment_type *statts,
unsigned count,
struct pipe_resource **out);
- bool (*flush_swapbuffers) (struct st_context_iface *stctx,
- struct st_framebuffer_iface *stfbi);
-};
-
-/**
- * Represent a rendering context.
- *
- * This entity is created from st_api and used by the frontend manager.
- */
-struct st_context_iface
-{
- /**
- * The frontend context. (such as dri_context)
- */
- void *frontend_context;
-
- /**
- * The frontend screen. (such as dri_screen)
- */
- struct pipe_frontend_screen *frontend_screen;
-
- /**
- * The CSO context associated with this context in case we need to draw
- * something before swap buffers.
- */
- struct cso_context *cso_context;
-
- /**
- * The gallium context.
- */
- struct pipe_context *pipe;
-
- /**
- * Destroy the context.
- */
- void (*destroy)(struct st_context_iface *stctxi);
-
- /**
- * Flush all drawing from context to the pipe also flushes the pipe.
- */
- void (*flush)(struct st_context_iface *stctxi, 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_iface *stctxi,
- 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_iface *stctxi,
- struct st_context_iface *stsrci, unsigned mask);
-
- /**
- * Used to implement wglShareLists.
- */
- bool (*share)(struct st_context_iface *stctxi,
- struct st_context_iface *stsrci);
-
- /**
- * 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_iface *stctxi);
-
- /**
- * If the API is multithreaded, wait for all queued commands to complete.
- * Called from the main thread.
- */
- void (*thread_finish)(struct st_context_iface *stctxi);
-
- /**
- * Invalidate states to notify the frontend that states have been changed
- * behind its back.
- */
- void (*invalidate_state)(struct st_context_iface *stctxi, unsigned flags);
+ bool (*flush_swapbuffers)(struct st_context *st,
+ struct st_framebuffer_iface *stfbi);
};
@@ -484,7 +402,7 @@ struct pipe_frontend_screen
* Call the loader function setBackgroundContext. Called from the worker
* thread.
*/
- void (*set_background_context)(struct st_context_iface *stctxi,
+ void (*set_background_context)(struct st_context *st,
struct util_queue_monitoring *queue_info);
/**
@@ -519,11 +437,11 @@ st_api_query_versions(struct pipe_frontend_screen *fscreen,
/**
* Create a rendering context.
*/
-struct st_context_iface *
+struct st_context *
st_api_create_context(struct pipe_frontend_screen *fscreen,
const struct st_context_attribs *attribs,
enum st_context_error *error,
- struct st_context_iface *stsharei);
+ struct st_context *shared_ctx);
/**
* Bind the context to the calling thread with draw and read as drawables.
@@ -532,14 +450,14 @@ st_api_create_context(struct pipe_frontend_screen *fscreen,
* context does.
*/
bool
-st_api_make_current(struct st_context_iface *stctxi,
+st_api_make_current(struct st_context *st,
struct st_framebuffer_iface *stdrawi,
struct st_framebuffer_iface *streadi);
/**
* Get the currently bound context in the calling thread.
*/
-struct st_context_iface *
+struct st_context *
st_api_get_current(void);
/**
diff --git a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp
index 39cee4705f1..1d5c2f1ff30 100644
--- a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp
+++ b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp
@@ -169,7 +169,7 @@ GalliumContext::CreateContext(HGLWinsysContext *wsContext)
attribs.minor = 0;
//attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
- struct st_context_iface* shared = NULL;
+ struct st_context *shared = NULL;
if (fOptions & BGL_SHARE_CONTEXT) {
shared = st_api_get_current();
@@ -221,8 +221,8 @@ GalliumContext::CreateContext(HGLWinsysContext *wsContext)
// Init Gallium3D Post Processing
// TODO: no pp filters are enabled yet through postProcessEnable
context->postProcess = pp_init(stContext->pipe, context->postProcessEnable,
- stContext->cso_context, &stContext->iface,
- (void*)stContext->iface.invalidate_state);
+ stContext->cso_context, stContext,
+ (void*)stContext->invalidate_state);
context_id contextNext = -1;
Lock();
diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c
index 70712166148..b23269979ff 100644
--- a/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/src/mesa/state_tracker/st_cb_eglimage.c
@@ -171,7 +171,7 @@ st_get_egl_image(struct gl_context *ctx, GLeglImageOES image_handle,
{
struct st_context *st = st_context(ctx);
struct pipe_screen *screen = st->screen;
- struct pipe_frontend_screen *fscreen = st->iface.frontend_screen;
+ struct pipe_frontend_screen *fscreen = st->frontend_screen;
if (!fscreen || !fscreen->get_egl_image)
return false;
@@ -421,7 +421,7 @@ static GLboolean
st_validate_egl_image(struct gl_context *ctx, GLeglImageOES image_handle)
{
struct st_context *st = st_context(ctx);
- struct pipe_frontend_screen *fscreen = st->iface.frontend_screen;
+ struct pipe_frontend_screen *fscreen = st->frontend_screen;
return fscreen->validate_egl_image(fscreen, (void *)image_handle);
}
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index b4d7e5746a4..93cdba2519d 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -775,10 +775,10 @@ st_set_background_context(struct gl_context *ctx,
struct util_queue_monitoring *queue_info)
{
struct st_context *st = ctx->st;
- struct pipe_frontend_screen *fscreen = st->iface.frontend_screen;
+ struct pipe_frontend_screen *fscreen = st->frontend_screen;
assert(fscreen->set_background_context);
- fscreen->set_background_context(&st->iface, queue_info);
+ fscreen->set_background_context(st, queue_info);
}
static void
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 2a70cd0182d..647b4aafd7c 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -123,13 +123,14 @@ struct st_zombie_shader_node
struct st_context
{
- struct st_context_iface iface;
-
struct gl_context *ctx;
struct pipe_screen *screen;
struct pipe_context *pipe;
struct cso_context *cso_context;
+ struct pipe_frontend_screen *frontend_screen; /* e.g. dri_screen */
+ void *frontend_context; /* e.g. dri_context */
+
struct draw_context *draw; /**< For selection/feedback/rastpos only */
struct draw_stage *feedback_stage; /**< For GL_FEEDBACK rendermode */
struct draw_stage *selection_stage; /**< For GL_SELECT rendermode */
@@ -392,6 +393,62 @@ 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);
};
diff --git a/src/mesa/state_tracker/st_interop.c b/src/mesa/state_tracker/st_interop.c
index a8f870952b4..288b755cfcd 100644
--- a/src/mesa/state_tracker/st_interop.c
+++ b/src/mesa/state_tracker/st_interop.c
@@ -32,7 +32,7 @@
#include "syncobj.h"
int
-st_interop_query_device_info(struct st_context_iface *st,
+st_interop_query_device_info(struct st_context *st,
struct mesa_glinterop_device_info *out)
{
struct pipe_screen *screen = st->pipe->screen;
@@ -237,12 +237,12 @@ lookup_object(struct gl_context *ctx,
}
int
-st_interop_export_object(struct st_context_iface *st,
+st_interop_export_object(struct st_context *st,
struct mesa_glinterop_export_in *in,
struct mesa_glinterop_export_out *out)
{
struct pipe_screen *screen = st->pipe->screen;
- struct gl_context *ctx = ((struct st_context *)st)->ctx;
+ struct gl_context *ctx = st->ctx;
struct pipe_resource *res = NULL;
struct winsys_handle whandle;
unsigned usage;
@@ -341,11 +341,11 @@ flush_object(struct gl_context *ctx,
}
int
-st_interop_flush_objects(struct st_context_iface *st,
+st_interop_flush_objects(struct st_context *st,
unsigned count, struct mesa_glinterop_export_in *objects,
GLsync *sync)
{
- struct gl_context *ctx = ((struct st_context *)st)->ctx;
+ struct gl_context *ctx = st->ctx;
/* Wait for glthread to finish to get up-to-date GL object lookups. */
if (st->thread_finish)
diff --git a/src/mesa/state_tracker/st_interop.h b/src/mesa/state_tracker/st_interop.h
index 633fd433f36..70bae553ec3 100644
--- a/src/mesa/state_tracker/st_interop.h
+++ b/src/mesa/state_tracker/st_interop.h
@@ -30,16 +30,16 @@
#include "st_context.h"
int
-st_interop_query_device_info(struct st_context_iface *st,
+st_interop_query_device_info(struct st_context *st,
struct mesa_glinterop_device_info *out);
int
-st_interop_export_object(struct st_context_iface *st,
+st_interop_export_object(struct st_context *st,
struct mesa_glinterop_export_in *in,
struct mesa_glinterop_export_out *out);
int
-st_interop_flush_objects(struct st_context_iface *st,
+st_interop_flush_objects(struct st_context *st,
unsigned count, struct mesa_glinterop_export_in *objects,
GLsync *sync);
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index fda524646b4..aeef2495cdb 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -233,7 +233,7 @@ st_framebuffer_validate(struct gl_framebuffer *stfb,
/* validate the fb */
do {
- if (!stfb->iface->validate(&st->iface, stfb->iface, stfb->statts,
+ if (!stfb->iface->validate(st, stfb->iface, stfb->statts,
stfb->num_statts, textures))
return;
@@ -762,8 +762,7 @@ st_api_destroy_drawable(struct st_framebuffer_iface *stfbi)
static void
st_framebuffers_purge(struct st_context *st)
{
- struct st_context_iface *st_iface = &st->iface;
- struct pipe_frontend_screen *fscreen = st_iface->frontend_screen;
+ struct pipe_frontend_screen *fscreen = st->frontend_screen;
struct gl_framebuffer *stfb, *next;
assert(fscreen);
@@ -788,12 +787,11 @@ st_framebuffers_purge(struct st_context *st)
static void
-st_context_flush(struct st_context_iface *stctxi, unsigned flags,
+st_context_flush(struct st_context *st, unsigned flags,
struct pipe_fence_handle **fence,
void (*before_flush_cb) (void*),
void* args)
{
- struct st_context *st = (struct st_context *) stctxi;
unsigned pipe_flags = 0;
if (flags & ST_FLUSH_END_OF_FRAME)
@@ -826,12 +824,11 @@ st_context_flush(struct st_context_iface *stctxi, unsigned flags,
* in EGL and WGL.
*/
static bool
-st_context_teximage(struct st_context_iface *stctxi,
+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)
{
- struct st_context *st = (struct st_context *) stctxi;
struct gl_context *ctx = st->ctx;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
@@ -916,59 +913,46 @@ st_context_teximage(struct st_context_iface *stctxi,
static void
-st_context_copy(struct st_context_iface *stctxi,
- struct st_context_iface *stsrci, unsigned mask)
+st_context_copy(struct st_context *st,
+ struct st_context *src, unsigned mask)
{
- struct st_context *st = (struct st_context *) stctxi;
- struct st_context *src = (struct st_context *) stsrci;
-
_mesa_copy_context(src->ctx, st->ctx, mask);
}
static bool
-st_context_share(struct st_context_iface *stctxi,
- struct st_context_iface *stsrci)
+st_context_share(struct st_context *st,
+ struct st_context *src)
{
- struct st_context *st = (struct st_context *) stctxi;
- struct st_context *src = (struct st_context *) stsrci;
-
return _mesa_share_state(st->ctx, src->ctx);
}
static void
-st_context_destroy(struct st_context_iface *stctxi)
+st_context_destroy(struct st_context *st)
{
- struct st_context *st = (struct st_context *) stctxi;
st_destroy_context(st);
}
static void
-st_start_thread(struct st_context_iface *stctxi)
+st_start_thread(struct st_context *st)
{
- struct st_context *st = (struct st_context *) stctxi;
-
_mesa_glthread_init(st->ctx);
}
static void
-st_thread_finish(struct st_context_iface *stctxi)
+st_thread_finish(struct st_context *st)
{
- struct st_context *st = (struct st_context *) stctxi;
-
_mesa_glthread_finish(st->ctx);
}
static void
-st_context_invalidate_state(struct st_context_iface *stctxi,
+st_context_invalidate_state(struct st_context *st,
unsigned flags)
{
- struct st_context *st = (struct st_context *) stctxi;
-
if (flags & ST_INVALIDATE_FS_SAMPLER_VIEWS)
st->dirty |= ST_NEW_FS_SAMPLER_VIEWS;
if (flags & ST_INVALIDATE_FS_CONSTBUF0)
@@ -998,13 +982,12 @@ st_manager_destroy(struct pipe_frontend_screen *fscreen)
}
-struct st_context_iface *
+struct st_context *
st_api_create_context(struct pipe_frontend_screen *fscreen,
const struct st_context_attribs *attribs,
enum st_context_error *error,
- struct st_context_iface *shared_stctxi)
+ struct st_context *shared_ctx)
{
- struct st_context *shared_ctx = (struct st_context *) shared_stctxi;
struct st_context *st;
struct pipe_context *pipe;
struct gl_config mode, *mode_ptr = &mode;
@@ -1128,34 +1111,33 @@ st_api_create_context(struct pipe_frontend_screen *fscreen,
st->ctx->invalidate_on_gl_viewport =
fscreen->get_param(fscreen, ST_MANAGER_BROKEN_INVALIDATE);
- st->iface.destroy = st_context_destroy;
- st->iface.flush = st_context_flush;
- st->iface.teximage = st_context_teximage;
- st->iface.copy = st_context_copy;
- st->iface.share = st_context_share;
- st->iface.start_thread = st_start_thread;
- st->iface.thread_finish = st_thread_finish;
- st->iface.invalidate_state = st_context_invalidate_state;
- st->iface.cso_context = st->cso_context;
- st->iface.pipe = st->pipe;
- st->iface.frontend_screen = fscreen;
+ 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 &&
st->screen->get_param(st->screen, PIPE_CAP_FRONTEND_NOOP))
st->pipe->set_frontend_noop(st->pipe, st->ctx->IntelBlackholeRender);
*error = ST_CONTEXT_SUCCESS;
- return &st->iface;
+ return st;
}
-struct st_context_iface *
+struct st_context *
st_api_get_current(void)
{
GET_CURRENT_CONTEXT(ctx);
- struct st_context *st = ctx ? ctx->st : NULL;
- return st ? &st->iface : NULL;
+ return ctx ? ctx->st : NULL;
}
@@ -1204,11 +1186,10 @@ st_framebuffer_reuse_or_create(struct st_context *st,
bool
-st_api_make_current(struct st_context_iface *stctxi,
+st_api_make_current(struct st_context *st,
struct st_framebuffer_iface *stdrawi,
struct st_framebuffer_iface *streadi)
{
- struct st_context *st = (struct st_context *) stctxi;
struct gl_framebuffer *stdraw, *stread;
bool ret;
@@ -1309,7 +1290,7 @@ st_manager_flush_frontbuffer(struct st_context *st)
* frontbuffer flush?
*/
if (rb && rb->defined &&
- stfb->iface->flush_front(&st->iface, stfb->iface, statt)) {
+ stfb->iface->flush_front(st, stfb->iface, statt)) {
rb->defined = GL_FALSE;
/* Trigger an update of rb->defined on next draw */
@@ -1353,7 +1334,7 @@ st_manager_flush_swapbuffers(void)
if (!stfb || !stfb->iface->flush_swapbuffers)
return;
- stfb->iface->flush_swapbuffers(&st->iface, stfb->iface);
+ stfb->iface->flush_swapbuffers(st, stfb->iface);
}