~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/gallium/state_trackers/dri/common/dri_context.c

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include "state_tracker/st_context.h"
40
40
 
41
41
static void
42
 
dri_init_extensions(struct dri_context *ctx)
 
42
dri_pp_query(struct dri_context *ctx)
43
43
{
44
 
   struct st_context *st = (struct st_context *) ctx->st;
 
44
   unsigned int i;
45
45
 
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);
 
48
   }
49
49
}
50
50
 
51
51
GLboolean
52
52
dri_create_context(gl_api api, const struct gl_config * visual,
53
 
                   __DRIcontext * cPriv, void *sharedContextPrivate)
 
53
                   __DRIcontext * cPriv,
 
54
                   unsigned major_version,
 
55
                   unsigned minor_version,
 
56
                   uint32_t flags,
 
57
                   unsigned *error,
 
58
                   void *sharedContextPrivate)
54
59
{
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;
61
67
 
62
68
   memset(&attribs, 0, sizeof(attribs));
63
69
   switch (api) {
67
73
   case API_OPENGLES2:
68
74
      attribs.profile = ST_PROFILE_OPENGL_ES2;
69
75
      break;
 
76
   case API_OPENGL:
 
77
      attribs.profile = ST_PROFILE_DEFAULT;
 
78
      attribs.major = major_version;
 
79
      attribs.minor = minor_version;
 
80
 
 
81
      if ((flags & __DRI_CTX_FLAG_DEBUG) != 0)
 
82
         attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
 
83
 
 
84
      if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
 
85
         attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
 
86
      break;
70
87
   default:
71
 
      attribs.profile = ST_PROFILE_DEFAULT;
72
 
      break;
 
88
      *error = __DRI_CTX_ERROR_BAD_API;
 
89
      goto fail;
73
90
   }
74
91
 
75
92
   if (sharedContextPrivate) {
77
94
   }
78
95
 
79
96
   ctx = CALLOC_STRUCT(dri_context);
80
 
   if (ctx == NULL)
 
97
   if (ctx == NULL) {
 
98
      *error = __DRI_CTX_ERROR_NO_MEMORY;
81
99
      goto fail;
 
100
   }
82
101
 
83
102
   cPriv->driverPrivate = ctx;
84
103
   ctx->cPriv = cPriv;
85
104
   ctx->sPriv = sPriv;
86
 
   ctx->lock = screen->drmLock;
87
105
 
88
106
   driParseConfigFiles(&ctx->optionCache,
89
107
                       &screen->optionCache, sPriv->myNum, "dri");
90
108
 
91
109
   dri_fill_st_visual(&attribs.visual, screen, visual);
92
 
   ctx->st = stapi->create_context(stapi, &screen->base, &attribs, st_share);
93
 
   if (ctx->st == NULL)
 
110
   ctx->st = stapi->create_context(stapi, &screen->base, &attribs, &ctx_err,
 
111
                                   st_share);
 
112
   if (ctx->st == NULL) {
 
113
      switch (ctx_err) {
 
114
      case ST_CONTEXT_SUCCESS:
 
115
         *error = __DRI_CTX_ERROR_SUCCESS;
 
116
         break;
 
117
      case ST_CONTEXT_ERROR_NO_MEMORY:
 
118
         *error = __DRI_CTX_ERROR_NO_MEMORY;
 
119
         break;
 
120
      case ST_CONTEXT_ERROR_BAD_API:
 
121
         *error = __DRI_CTX_ERROR_BAD_API;
 
122
         break;
 
123
      case ST_CONTEXT_ERROR_BAD_VERSION:
 
124
         *error = __DRI_CTX_ERROR_BAD_VERSION;
 
125
         break;
 
126
      case ST_CONTEXT_ERROR_BAD_FLAG:
 
127
         *error = __DRI_CTX_ERROR_BAD_FLAG;
 
128
         break;
 
129
      case ST_CONTEXT_ERROR_UNKNOWN_ATTRIBUTE:
 
130
         *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
 
131
         break;
 
132
      case ST_CONTEXT_ERROR_UNKNOWN_FLAG:
 
133
         *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
 
134
         break;
 
135
      }
94
136
      goto fail;
 
137
   }
95
138
   ctx->st->st_manager_private = (void *) ctx;
96
139
   ctx->stapi = stapi;
97
140
 
98
 
   /*
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.
104
 
    */
105
 
   if (api == API_OPENGL)
106
 
      dri_init_extensions(ctx);
107
 
 
 
141
   // Context successfully created. See if post-processing is requested.
 
142
   dri_pp_query(ctx);
 
143
 
 
144
   ctx->pp = pp_init(screen->base.screen, ctx->pp_enabled);
 
145
 
 
146
   *error = __DRI_CTX_ERROR_SUCCESS;
108
147
   return GL_TRUE;
109
148
 
110
149
 fail:
134
173
   ctx->st->flush(ctx->st, 0, NULL);
135
174
   ctx->st->destroy(ctx->st);
136
175
 
 
176
   if (ctx->pp) pp_free(ctx->pp);
 
177
 
137
178
   FREE(ctx);
138
179
}
139
180
 
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;
149
188
 
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;
156
193
      }
157
194
   }
158
195
 
180
217
   else if (!driDrawPriv || !driReadPriv)
181
218
      return GL_FALSE;
182
219
 
183
 
   draw->context = ctx;
184
220
   if (ctx->dPriv != driDrawPriv) {
185
221
      ctx->dPriv = driDrawPriv;
186
222
      draw->texture_stamp = driDrawPriv->lastStamp - 1;
187
223
   }
188
 
   read->context = ctx;
189
224
   if (ctx->rPriv != driReadPriv) {
190
225
      ctx->rPriv = driReadPriv;
191
226
      read->texture_stamp = driReadPriv->lastStamp - 1;
193
228
 
194
229
   ctx->stapi->make_current(ctx->stapi, ctx->st, &draw->base, &read->base);
195
230
 
 
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]
 
233
      && ctx->pp)
 
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]);
 
237
 
196
238
   return GL_TRUE;
197
239
}
198
240