#include "dri_screen.h"
#include "dri_drawable.h"
#include "dri_context.h"
-#include "dri_st_api.h"
#include "pipe/p_context.h"
#include "state_tracker/st_context.h"
}
GLboolean
-dri_create_context(const __GLcontextModes * visual,
+dri_create_context(gl_api api, const __GLcontextModes * visual,
__DRIcontext * cPriv, void *sharedContextPrivate)
{
- struct st_api *stapi = dri_get_st_api();
__DRIscreen *sPriv = cPriv->driScreenPriv;
struct dri_screen *screen = dri_screen(sPriv);
+ struct st_api *stapi = screen->st_api;
struct dri_context *ctx = NULL;
struct st_context_iface *st_share = NULL;
struct st_visual stvis;
&screen->optionCache, sPriv->myNum, "dri");
dri_fill_st_visual(&stvis, screen, visual);
- ctx->st = stapi->create_context(stapi, screen->smapi, &stvis, st_share);
+ ctx->st = stapi->create_context(stapi, &screen->base, &stvis, st_share);
if (ctx->st == NULL)
goto fail;
ctx->st->st_manager_private = (void *) ctx;
GLboolean
dri_unbind_context(__DRIcontext * cPriv)
{
- struct st_api *stapi = dri_get_st_api();
-
- if (cPriv) {
- struct dri_context *ctx = dri_context(cPriv);
+ /* dri_util.c ensures cPriv is not null */
+ struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
+ struct dri_context *ctx = dri_context(cPriv);
+ struct st_api *stapi = screen->st_api;
- if (--ctx->bind_count == 0) {
- if (ctx->st == stapi->get_current(stapi)) {
- ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
- stapi->make_current(stapi, NULL, NULL, NULL);
- }
+ if (--ctx->bind_count == 0) {
+ if (ctx->st == stapi->get_current(stapi)) {
+ ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+ stapi->make_current(stapi, NULL, NULL, NULL);
}
}
__DRIdrawable * driDrawPriv,
__DRIdrawable * driReadPriv)
{
- struct st_api *stapi = dri_get_st_api();
-
- if (cPriv) {
- struct dri_context *ctx = dri_context(cPriv);
- struct dri_drawable *draw = dri_drawable(driDrawPriv);
- struct dri_drawable *read = dri_drawable(driReadPriv);
- struct st_context_iface *old_st;
+ /* dri_util.c ensures cPriv is not null */
+ struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
+ struct dri_context *ctx = dri_context(cPriv);
+ struct st_api *stapi = screen->st_api;
+ struct dri_drawable *draw = dri_drawable(driDrawPriv);
+ struct dri_drawable *read = dri_drawable(driReadPriv);
+ struct st_context_iface *old_st = stapi->get_current(stapi);
- old_st = stapi->get_current(stapi);
- if (old_st && old_st != ctx->st)
- ctx->st->flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL);
+ if (old_st && old_st != ctx->st)
+ old_st->flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL);
- ++ctx->bind_count;
+ ++ctx->bind_count;
- if (ctx->dPriv != driDrawPriv) {
- ctx->dPriv = driDrawPriv;
- draw->texture_stamp = driDrawPriv->lastStamp - 1;
- }
- if (ctx->rPriv != driReadPriv) {
- ctx->rPriv = driReadPriv;
- read->texture_stamp = driReadPriv->lastStamp - 1;
- }
-
- stapi->make_current(stapi, ctx->st, draw->stfb, read->stfb);
+ if (ctx->dPriv != driDrawPriv) {
+ ctx->dPriv = driDrawPriv;
+ draw->texture_stamp = driDrawPriv->lastStamp - 1;
}
- else {
- stapi->make_current(stapi, NULL, NULL, NULL);
+ if (ctx->rPriv != driReadPriv) {
+ ctx->rPriv = driReadPriv;
+ read->texture_stamp = driReadPriv->lastStamp - 1;
}
+ stapi->make_current(stapi, ctx->st, &draw->base, &read->base);
+
return GL_TRUE;
}
struct dri_context *
-dri_get_current(void)
+dri_get_current(__DRIscreen *sPriv)
{
- struct st_api *stapi = dri_get_st_api();
+ struct dri_screen *screen = dri_screen(sPriv);
+ struct st_api *stapi = screen->st_api;
struct st_context_iface *st;
st = stapi->get_current(stapi);