39
39
#include "state_tracker/st_context.h"
42
dri_init_extensions(struct dri_context *ctx)
42
dri_pp_query(struct dri_context *ctx)
44
struct st_context *st = (struct st_context *) ctx->st;
46
/* New extensions should be added in mesa/state_tracker/st_extensions.c
47
* and not in this file. */
48
driInitExtensions(st->ctx, NULL, GL_FALSE);
46
for (i = 0; i < PP_FILTERS; i++) {
47
ctx->pp_enabled[i] = driQueryOptioni(&ctx->optionCache, pp_filters[i].name);
52
52
dri_create_context(gl_api api, const struct gl_config * visual,
53
__DRIcontext * cPriv, void *sharedContextPrivate)
54
unsigned major_version,
55
unsigned minor_version,
58
void *sharedContextPrivate)
55
60
__DRIscreen *sPriv = cPriv->driScreenPriv;
56
61
struct dri_screen *screen = dri_screen(sPriv);
58
63
struct dri_context *ctx = NULL;
59
64
struct st_context_iface *st_share = NULL;
60
65
struct st_context_attribs attribs;
66
enum st_context_error ctx_err = 0;
62
68
memset(&attribs, 0, sizeof(attribs));
67
73
case API_OPENGLES2:
68
74
attribs.profile = ST_PROFILE_OPENGL_ES2;
77
attribs.profile = ST_PROFILE_DEFAULT;
78
attribs.major = major_version;
79
attribs.minor = minor_version;
81
if ((flags & __DRI_CTX_FLAG_DEBUG) != 0)
82
attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
84
if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
85
attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
71
attribs.profile = ST_PROFILE_DEFAULT;
88
*error = __DRI_CTX_ERROR_BAD_API;
75
92
if (sharedContextPrivate) {
79
96
ctx = CALLOC_STRUCT(dri_context);
98
*error = __DRI_CTX_ERROR_NO_MEMORY;
83
102
cPriv->driverPrivate = ctx;
84
103
ctx->cPriv = cPriv;
85
104
ctx->sPriv = sPriv;
86
ctx->lock = screen->drmLock;
88
106
driParseConfigFiles(&ctx->optionCache,
89
107
&screen->optionCache, sPriv->myNum, "dri");
91
109
dri_fill_st_visual(&attribs.visual, screen, visual);
92
ctx->st = stapi->create_context(stapi, &screen->base, &attribs, st_share);
110
ctx->st = stapi->create_context(stapi, &screen->base, &attribs, &ctx_err,
112
if (ctx->st == NULL) {
114
case ST_CONTEXT_SUCCESS:
115
*error = __DRI_CTX_ERROR_SUCCESS;
117
case ST_CONTEXT_ERROR_NO_MEMORY:
118
*error = __DRI_CTX_ERROR_NO_MEMORY;
120
case ST_CONTEXT_ERROR_BAD_API:
121
*error = __DRI_CTX_ERROR_BAD_API;
123
case ST_CONTEXT_ERROR_BAD_VERSION:
124
*error = __DRI_CTX_ERROR_BAD_VERSION;
126
case ST_CONTEXT_ERROR_BAD_FLAG:
127
*error = __DRI_CTX_ERROR_BAD_FLAG;
129
case ST_CONTEXT_ERROR_UNKNOWN_ATTRIBUTE:
130
*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
132
case ST_CONTEXT_ERROR_UNKNOWN_FLAG:
133
*error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
95
138
ctx->st->st_manager_private = (void *) ctx;
96
139
ctx->stapi = stapi;
99
* libmesagallium.a that this state tracker will be linked to expects
100
* OpenGL's _glapi_table. That is, it expects libGL.so instead of
101
* libGLESv1_CM.so or libGLESv2.so. As there is no clean way to know the
102
* shared library the app links to, use the api as a simple check.
103
* It might be as well to simply remove this function call though.
105
if (api == API_OPENGL)
106
dri_init_extensions(ctx);
141
// Context successfully created. See if post-processing is requested.
144
ctx->pp = pp_init(screen->base.screen, ctx->pp_enabled);
146
*error = __DRI_CTX_ERROR_SUCCESS;
143
184
/* dri_util.c ensures cPriv is not null */
144
185
struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
145
186
struct dri_context *ctx = dri_context(cPriv);
146
struct dri_drawable *draw = dri_drawable(ctx->dPriv);
147
struct dri_drawable *read = dri_drawable(ctx->rPriv);
148
187
struct st_api *stapi = screen->st_api;
150
189
if (--ctx->bind_count == 0) {
151
190
if (ctx->st == ctx->stapi->get_current(ctx->stapi)) {
152
191
ctx->st->flush(ctx->st, ST_FLUSH_FRONT, NULL);
153
192
stapi->make_current(stapi, NULL, NULL, NULL);
154
draw->context = NULL;
155
read->context = NULL;
180
217
else if (!driDrawPriv || !driReadPriv)
184
220
if (ctx->dPriv != driDrawPriv) {
185
221
ctx->dPriv = driDrawPriv;
186
222
draw->texture_stamp = driDrawPriv->lastStamp - 1;
189
224
if (ctx->rPriv != driReadPriv) {
190
225
ctx->rPriv = driReadPriv;
191
226
read->texture_stamp = driReadPriv->lastStamp - 1;
194
229
ctx->stapi->make_current(ctx->stapi, ctx->st, &draw->base, &read->base);
231
// This is ok to call here. If they are already init, it's a no-op.
232
if (draw->textures[ST_ATTACHMENT_BACK_LEFT] && draw->textures[ST_ATTACHMENT_DEPTH_STENCIL]
234
pp_init_fbos(ctx->pp, draw->textures[ST_ATTACHMENT_BACK_LEFT]->width0,
235
draw->textures[ST_ATTACHMENT_BACK_LEFT]->height0,
236
draw->textures[ST_ATTACHMENT_DEPTH_STENCIL]);