~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**************************************************************************
2
 
 *
3
 
 * Copyright 2009, VMware, Inc.
4
 
 * All Rights Reserved.
5
 
 *
6
 
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 
 * copy of this software and associated documentation files (the
8
 
 * "Software"), to deal in the Software without restriction, including
9
 
 * without limitation the rights to use, copy, modify, merge, publish,
10
 
 * distribute, sub license, and/or sell copies of the Software, and to
11
 
 * permit persons to whom the Software is furnished to do so, subject to
12
 
 * the following conditions:
13
 
 *
14
 
 * The above copyright notice and this permission notice (including the
15
 
 * next paragraph) shall be included in all copies or substantial portions
16
 
 * of the Software.
17
 
 *
18
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
 
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
 
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21
 
 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22
 
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
 
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
 
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
 
 *
26
 
 **************************************************************************/
27
 
/*
28
 
 * Author: Keith Whitwell <keithw@vmware.com>
29
 
 * Author: Jakob Bornecrantz <wallbraker@gmail.com>
30
 
 */
31
 
 
32
 
#include "dri_screen.h"
33
 
 
34
 
#include "dri_drawable.h"
35
 
#include "state_tracker/drm_api.h"
36
 
#include "state_tracker/dri1_api.h"
37
 
#include "state_tracker/st_public.h"
38
 
#include "state_tracker/st_context.h"
39
 
#include "pipe/p_context.h"
40
 
 
41
 
#include "dri_context.h"
42
 
 
43
 
#include "util/u_memory.h"
44
 
 
45
 
GLboolean
46
 
dri_create_context(const __GLcontextModes * visual,
47
 
                   __DRIcontext * cPriv, void *sharedContextPrivate)
48
 
{
49
 
   __DRIscreen *sPriv = cPriv->driScreenPriv;
50
 
   struct dri_screen *screen = dri_screen(sPriv);
51
 
   struct dri_context *ctx = NULL;
52
 
   struct st_context *st_share = NULL;
53
 
 
54
 
   if (sharedContextPrivate) {
55
 
      st_share = ((struct dri_context *)sharedContextPrivate)->st;
56
 
   }
57
 
 
58
 
   ctx = CALLOC_STRUCT(dri_context);
59
 
   if (ctx == NULL)
60
 
      goto fail;
61
 
 
62
 
   cPriv->driverPrivate = ctx;
63
 
   ctx->cPriv = cPriv;
64
 
   ctx->sPriv = sPriv;
65
 
   ctx->lock = screen->drmLock;
66
 
   ctx->d_stamp = -1;
67
 
   ctx->r_stamp = -1;
68
 
 
69
 
   driParseConfigFiles(&ctx->optionCache,
70
 
                       &screen->optionCache, sPriv->myNum, "dri");
71
 
 
72
 
   ctx->pipe = screen->pipe_screen->context_create( screen->pipe_screen,
73
 
                                                    ctx );
74
 
 
75
 
   if (ctx->pipe == NULL)
76
 
      goto fail;
77
 
 
78
 
   ctx->st = st_create_context(ctx->pipe, visual, st_share);
79
 
   if (ctx->st == NULL)
80
 
      goto fail;
81
 
 
82
 
   dri_init_extensions(ctx);
83
 
 
84
 
   return GL_TRUE;
85
 
 
86
 
 fail:
87
 
   if (ctx && ctx->st)
88
 
      st_destroy_context(ctx->st);
89
 
 
90
 
   if (ctx && ctx->pipe)
91
 
      ctx->pipe->destroy(ctx->pipe);
92
 
 
93
 
   FREE(ctx);
94
 
   return FALSE;
95
 
}
96
 
 
97
 
void
98
 
dri_destroy_context(__DRIcontext * cPriv)
99
 
{
100
 
   struct dri_context *ctx = dri_context(cPriv);
101
 
 
102
 
   /* note: we are freeing values and nothing more because
103
 
    * driParseConfigFiles allocated values only - the rest
104
 
    * is owned by screen optionCache.
105
 
    */
106
 
   FREE(ctx->optionCache.values);
107
 
 
108
 
   /* No particular reason to wait for command completion before
109
 
    * destroying a context, but it is probably worthwhile flushing it
110
 
    * to avoid having to add code elsewhere to cope with flushing a
111
 
    * partially destroyed context.
112
 
    */
113
 
   st_flush(ctx->st, 0, NULL);
114
 
 
115
 
   /* Also frees ctx->pipe?
116
 
    */
117
 
   st_destroy_context(ctx->st);
118
 
 
119
 
   FREE(ctx);
120
 
}
121
 
 
122
 
GLboolean
123
 
dri_unbind_context(__DRIcontext * cPriv)
124
 
{
125
 
   if (cPriv) {
126
 
      struct dri_context *ctx = dri_context(cPriv);
127
 
 
128
 
      if (--ctx->bind_count == 0) {
129
 
         if (ctx->st && ctx->st == st_get_current()) {
130
 
            st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
131
 
            st_make_current(NULL, NULL, NULL);
132
 
         }
133
 
      }
134
 
   }
135
 
 
136
 
   return GL_TRUE;
137
 
}
138
 
 
139
 
GLboolean
140
 
dri_make_current(__DRIcontext * cPriv,
141
 
                 __DRIdrawable * driDrawPriv,
142
 
                 __DRIdrawable * driReadPriv)
143
 
{
144
 
   if (cPriv) {
145
 
      struct dri_context *ctx = dri_context(cPriv);
146
 
      struct dri_drawable *draw = dri_drawable(driDrawPriv);
147
 
      struct dri_drawable *read = dri_drawable(driReadPriv);
148
 
      struct st_context *old_st = st_get_current();
149
 
 
150
 
      if (old_st && old_st != ctx->st)
151
 
         st_flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL);
152
 
 
153
 
      ++ctx->bind_count;
154
 
 
155
 
      if (ctx->dPriv != driDrawPriv) {
156
 
         ctx->dPriv = driDrawPriv;
157
 
         ctx->d_stamp = driDrawPriv->lastStamp - 1;
158
 
      }
159
 
      if (ctx->rPriv != driReadPriv) {
160
 
         ctx->rPriv = driReadPriv;
161
 
         ctx->r_stamp = driReadPriv->lastStamp - 1;
162
 
      }
163
 
 
164
 
      st_make_current(ctx->st, draw->stfb, read->stfb);
165
 
 
166
 
      if (__dri1_api_hooks) {
167
 
         dri1_update_drawables(ctx, draw, read);
168
 
      } else {
169
 
         dri_update_buffer(ctx->pipe->screen,
170
 
                           ctx->pipe->priv);
171
 
      }
172
 
   } else {
173
 
      st_make_current(NULL, NULL, NULL);
174
 
   }
175
 
 
176
 
   return GL_TRUE;
177
 
}
178
 
 
179
 
static void
180
 
st_dri_lock(struct pipe_context *pipe)
181
 
{
182
 
   dri_lock((struct dri_context *)pipe->priv);
183
 
}
184
 
 
185
 
static void
186
 
st_dri_unlock(struct pipe_context *pipe)
187
 
{
188
 
   dri_unlock((struct dri_context *)pipe->priv);
189
 
}
190
 
 
191
 
static boolean
192
 
st_dri_is_locked(struct pipe_context *pipe)
193
 
{
194
 
   return ((struct dri_context *)pipe->priv)->isLocked;
195
 
}
196
 
 
197
 
static boolean
198
 
st_dri_lost_lock(struct pipe_context *pipe)
199
 
{
200
 
   return ((struct dri_context *)pipe->priv)->wsLostLock;
201
 
}
202
 
 
203
 
static void
204
 
st_dri_clear_lost_lock(struct pipe_context *pipe)
205
 
{
206
 
   ((struct dri_context *)pipe->priv)->wsLostLock = FALSE;
207
 
}
208
 
 
209
 
struct dri1_api_lock_funcs dri1_lf = {
210
 
   .lock = st_dri_lock,
211
 
   .unlock = st_dri_unlock,
212
 
   .is_locked = st_dri_is_locked,
213
 
   .is_lock_lost = st_dri_lost_lock,
214
 
   .clear_lost_lock = st_dri_clear_lost_lock
215
 
};
216
 
 
217
 
/* vim: set sw=3 ts=8 sts=3 expandtab: */