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>
* IN THE SOFTWARE.
*/
+#include "state_tracker/st_context.h"
+
#include <egldriver.h>
#include <egllog.h>
#include <eglcurrent.h>
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) {
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);
'-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
#endif
struct cso_context;
-struct st_context_iface;
struct pp_queue_t; /* Forward definition */
struct pp_program;
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 |
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)
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;
}
struct pipe_context;
struct pipe_fence;
-struct st_context_iface;
+struct st_context;
struct dri_drawable;
struct dri_screen;
} dri2;
/* gallium */
- struct st_context_iface *st;
+ struct st_context *st;
struct pp_queue_t *pp;
struct hud_context *hud;
};
#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;
}
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;
* 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;
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;
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
{
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 };
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)
/* 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);
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);
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;
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;
{
__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;
#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
}
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;
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);
#include <GL/glx.h>
+#include "state_tracker/st_context.h"
+
extern struct pipe_screen *
xlib_create_screen(Display *display);
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;
}
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;
# include <X11/Xlibint.h>
# include <X11/Xutil.h>
+struct st_context;
struct hud_context;
typedef struct xmesa_display *XMesaDisplay;
* 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 */
#include "util/u_atomic.h"
#include "util/u_memory.h"
+#include "state_tracker/st_context.h"
+
struct xmesa_st_framebuffer {
XMesaDisplay display;
XMesaBuffer buffer;
*/
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;
* \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,
* 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)
{
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);
// 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;
}
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();
* 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)
{
CALLED();
- context = hgl_st_context(stctxi);
+ context = hgl_st_context(st);
buffer = hgl_st_framebuffer(stfbi);
// Build mask of current attachments
struct hgl_context
{
struct hgl_display* display;
- struct st_context_iface* st;
+ struct st_context* st;
struct st_visual* stVisual;
// Post processing
include_directories : [
inc_include, inc_src, inc_gallium, inc_gallium_aux, inc_mapi, inc_mesa,
],
+ dependencies : [idep_mesautil],
)
#include <stdio.h>
#include <c11/threads.h>
+
+#include "state_tracker/st_context.h"
+
#include "GL/osmesa.h"
#include "glapi/glapi.h" /* for OSMesaGetProcAddress below */
struct osmesa_context
{
- struct st_context_iface *stctx;
+ struct st_context *st;
boolean ever_used; /*< Has this context ever been current? */
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);
* 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)
{
* 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,
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;
int i;
if (sharelist) {
- st_shared = sharelist->stctx;
+ st_shared = sharelist->st;
}
else {
st_shared = NULL;
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;
{
if (osmesa) {
pp_free(osmesa->pp);
- osmesa->stctx->destroy(osmesa->stctx);
+ osmesa->st->destroy(osmesa->st);
free(osmesa->zs);
FREE(osmesa);
}
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
}
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);
}
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;
}
*
**************************************************************************/
+#include "state_tracker/st_context.h"
+
#include <windows.h>
#define WGL_WGLEXT_PROTOTYPES
#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;
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;
/*
* 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.
*
**************************************************************************/
+#include "state_tracker/st_context.h"
+
#include <windows.h>
#include "pipe/p_screen.h"
*/
void
stw_framebuffer_release_locked(struct stw_framebuffer *fb,
- struct st_context_iface *stctx)
+ struct st_context *st)
{
struct stw_framebuffer **link;
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);
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);
}
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.
#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"
* 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)
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);
}
}
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]);
}
}
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,
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;
}
}
struct notify_before_flush_cb_args {
- struct st_context_iface *stctx;
+ struct st_context *st;
struct stw_st_framebuffer *stwfb;
unsigned flags;
};
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) {
}
void
-stw_st_flush(struct st_context_iface *stctx,
+stw_st_flush(struct st_context *st,
struct st_framebuffer_iface *stfb,
unsigned flags)
{
struct pipe_fence_handle **pfence = NULL;
struct pipe_fence_handle *fence = NULL;
- args.stctx = stctx;
+ args.st = st;
args.stwfb = stwfb;
args.flags = flags;
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);
}
/**
*/
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)
{
}
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;
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);
* 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);
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);
}
#include "frontend/api.h"
+struct st_context;
struct stw_framebuffer;
bool
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 *
#include "util/format/u_formats.h"
+struct st_context;
+
/**
* \file API for communication between gallium frontends and supporting
* frontends such as DRI.
};
/**
- * Used in st_context_iface->teximage.
+ * Used in st_context_teximage.
*/
enum st_texture_type {
ST_TEXTURE_1D,
struct st_config_options options;
};
-struct st_context_iface;
struct pipe_frontend_screen;
/**
*
* @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);
* 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);
};
* 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);
/**
/**
* 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.
* 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);
/**
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();
// 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();
{
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;
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);
}
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
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 */
} 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);
};
#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;
}
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;
}
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)
#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);
/* 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;
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);
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)
* 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;
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)
}
-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;
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;
}
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;
* 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 */
if (!stfb || !stfb->iface->flush_swapbuffers)
return;
- stfb->iface->flush_swapbuffers(&st->iface, stfb->iface);
+ stfb->iface->flush_swapbuffers(st, stfb->iface);
}