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

« back to all changes in this revision

Viewing changes to src/gallium/winsys/drm/intel/gem/intel_drm_api.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
 
#include <stdio.h>
2
 
 
3
 
#include "state_tracker/drm_api.h"
4
 
 
5
 
#include "intel_drm_winsys.h"
6
 
#include "util/u_memory.h"
7
 
 
8
 
#include "i915/i915_context.h"
9
 
#include "i915/i915_screen.h"
10
 
 
11
 
#include "trace/tr_drm.h"
12
 
 
13
 
/*
14
 
 * Helper functions
15
 
 */
16
 
 
17
 
 
18
 
static void
19
 
intel_drm_get_device_id(unsigned int *device_id)
20
 
{
21
 
   char path[512];
22
 
   FILE *file;
23
 
   void *shutup_gcc;
24
 
 
25
 
   /*
26
 
    * FIXME: Fix this up to use a drm ioctl or whatever.
27
 
    */
28
 
 
29
 
   snprintf(path, sizeof(path), "/sys/class/drm/card0/device/device");
30
 
   file = fopen(path, "r");
31
 
   if (!file) {
32
 
      return;
33
 
   }
34
 
 
35
 
   shutup_gcc = fgets(path, sizeof(path), file);
36
 
   (void) shutup_gcc;
37
 
   sscanf(path, "%x", device_id);
38
 
   fclose(file);
39
 
}
40
 
 
41
 
static struct intel_buffer *
42
 
intel_drm_buffer_from_handle(struct intel_drm_winsys *idws,
43
 
                             const char* name, unsigned handle)
44
 
{
45
 
   struct intel_drm_buffer *buf = CALLOC_STRUCT(intel_drm_buffer);
46
 
   uint32_t tile = 0, swizzle = 0;
47
 
 
48
 
   if (!buf)
49
 
      return NULL;
50
 
 
51
 
   buf->magic = 0xDEAD1337;
52
 
   buf->bo = drm_intel_bo_gem_create_from_name(idws->pools.gem, name, handle);
53
 
   buf->flinked = TRUE;
54
 
   buf->flink = handle;
55
 
 
56
 
   if (!buf->bo)
57
 
      goto err;
58
 
 
59
 
   drm_intel_bo_get_tiling(buf->bo, &tile, &swizzle);
60
 
   if (tile != INTEL_TILE_NONE)
61
 
      buf->map_gtt = TRUE;
62
 
 
63
 
   return (struct intel_buffer *)buf;
64
 
 
65
 
err:
66
 
   FREE(buf);
67
 
   return NULL;
68
 
}
69
 
 
70
 
 
71
 
/*
72
 
 * Exported functions
73
 
 */
74
 
 
75
 
 
76
 
static struct pipe_texture *
77
 
intel_drm_texture_from_shared_handle(struct drm_api *api,
78
 
                                     struct pipe_screen *screen,
79
 
                                     struct pipe_texture *templ,
80
 
                                     const char* name,
81
 
                                     unsigned pitch,
82
 
                                     unsigned handle)
83
 
{
84
 
   struct intel_drm_winsys *idws = intel_drm_winsys(i915_screen(screen)->iws);
85
 
   struct intel_buffer *buffer;
86
 
 
87
 
   buffer = intel_drm_buffer_from_handle(idws, name, handle);
88
 
   if (!buffer)
89
 
      return NULL;
90
 
 
91
 
   return i915_texture_blanket_intel(screen, templ, pitch, buffer);
92
 
}
93
 
 
94
 
static boolean
95
 
intel_drm_shared_handle_from_texture(struct drm_api *api,
96
 
                                     struct pipe_screen *screen,
97
 
                                     struct pipe_texture *texture,
98
 
                                     unsigned *pitch,
99
 
                                     unsigned *handle)
100
 
{
101
 
   struct intel_drm_buffer *buf = NULL;
102
 
   struct intel_buffer *buffer = NULL;
103
 
   if (!i915_get_texture_buffer_intel(texture, &buffer, pitch))
104
 
      return FALSE;
105
 
 
106
 
   buf = intel_drm_buffer(buffer);
107
 
   if (!buf->flinked) {
108
 
      if (drm_intel_bo_flink(buf->bo, &buf->flink))
109
 
         return FALSE;
110
 
      buf->flinked = TRUE;
111
 
   }
112
 
 
113
 
   *handle = buf->flink;
114
 
 
115
 
   return TRUE;
116
 
}
117
 
 
118
 
static boolean
119
 
intel_drm_local_handle_from_texture(struct drm_api *api,
120
 
                                    struct pipe_screen *screen,
121
 
                                    struct pipe_texture *texture,
122
 
                                    unsigned *pitch,
123
 
                                    unsigned *handle)
124
 
{
125
 
   struct intel_buffer *buffer = NULL;
126
 
   if (!i915_get_texture_buffer_intel(texture, &buffer, pitch))
127
 
      return FALSE;
128
 
 
129
 
   *handle = intel_drm_buffer(buffer)->bo->handle;
130
 
 
131
 
   return TRUE;
132
 
}
133
 
 
134
 
static void
135
 
intel_drm_winsys_destroy(struct intel_winsys *iws)
136
 
{
137
 
   struct intel_drm_winsys *idws = intel_drm_winsys(iws);
138
 
 
139
 
   drm_intel_bufmgr_destroy(idws->pools.gem);
140
 
 
141
 
   FREE(idws);
142
 
}
143
 
 
144
 
static struct pipe_screen *
145
 
intel_drm_create_screen(struct drm_api *api, int drmFD,
146
 
                        struct drm_create_screen_arg *arg)
147
 
{
148
 
   struct intel_drm_winsys *idws;
149
 
   unsigned int deviceID;
150
 
 
151
 
   if (arg != NULL) {
152
 
      switch(arg->mode) {
153
 
      case DRM_CREATE_NORMAL:
154
 
         break;
155
 
      default:
156
 
         return NULL;
157
 
      }
158
 
   }
159
 
 
160
 
   idws = CALLOC_STRUCT(intel_drm_winsys);
161
 
   if (!idws)
162
 
      return NULL;
163
 
 
164
 
   intel_drm_get_device_id(&deviceID);
165
 
 
166
 
   intel_drm_winsys_init_batchbuffer_functions(idws);
167
 
   intel_drm_winsys_init_buffer_functions(idws);
168
 
   intel_drm_winsys_init_fence_functions(idws);
169
 
 
170
 
   idws->fd = drmFD;
171
 
   idws->id = deviceID;
172
 
   idws->max_batch_size = 16 * 4096;
173
 
 
174
 
   idws->base.destroy = intel_drm_winsys_destroy;
175
 
 
176
 
   idws->pools.gem = drm_intel_bufmgr_gem_init(idws->fd, idws->max_batch_size);
177
 
   drm_intel_bufmgr_gem_enable_reuse(idws->pools.gem);
178
 
 
179
 
   idws->dump_cmd = debug_get_bool_option("INTEL_DUMP_CMD", FALSE);
180
 
 
181
 
   return i915_create_screen(&idws->base, deviceID);
182
 
}
183
 
 
184
 
static void
185
 
destroy(struct drm_api *api)
186
 
{
187
 
 
188
 
}
189
 
 
190
 
struct drm_api intel_drm_api =
191
 
{
192
 
   .name = "i915",
193
 
   .driver_name = "i915",
194
 
   .create_screen = intel_drm_create_screen,
195
 
   .texture_from_shared_handle = intel_drm_texture_from_shared_handle,
196
 
   .shared_handle_from_texture = intel_drm_shared_handle_from_texture,
197
 
   .local_handle_from_texture = intel_drm_local_handle_from_texture,
198
 
   .destroy = destroy,
199
 
};
200
 
 
201
 
struct drm_api *
202
 
drm_api_create()
203
 
{
204
 
   return trace_drm_create(&intel_drm_api);
205
 
}