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

« back to all changes in this revision

Viewing changes to src/gallium/winsys/gdi/gdi_llvmpipe_winsys.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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
 
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17
 
 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18
 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
 
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
 
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21
 
 *
22
 
 * The above copyright notice and this permission notice (including the
23
 
 * next paragraph) shall be included in all copies or substantial portions
24
 
 * of the Software.
25
 
 *
26
 
 *
27
 
 **************************************************************************/
28
 
 
29
 
/**
30
 
 * @file
31
 
 * LLVMpipe support.
32
 
 *
33
 
 * @author Jose Fonseca <jfonseca@vmware.com>
34
 
 */
35
 
 
36
 
 
37
 
#include <windows.h>
38
 
 
39
 
#include "pipe/p_format.h"
40
 
#include "pipe/p_context.h"
41
 
#include "util/u_inlines.h"
42
 
#include "util/u_format.h"
43
 
#include "util/u_math.h"
44
 
#include "util/u_memory.h"
45
 
#include "llvmpipe/lp_winsys.h"
46
 
#include "llvmpipe/lp_texture.h"
47
 
#include "stw_winsys.h"
48
 
 
49
 
 
50
 
struct gdi_llvmpipe_displaytarget
51
 
{
52
 
   enum pipe_format format;
53
 
   unsigned width;
54
 
   unsigned height;
55
 
   unsigned stride;
56
 
 
57
 
   unsigned size;
58
 
 
59
 
   void *data;
60
 
 
61
 
   BITMAPINFO bmi;
62
 
};
63
 
 
64
 
 
65
 
/** Cast wrapper */
66
 
static INLINE struct gdi_llvmpipe_displaytarget *
67
 
gdi_llvmpipe_displaytarget( struct llvmpipe_displaytarget *buf )
68
 
{
69
 
   return (struct gdi_llvmpipe_displaytarget *)buf;
70
 
}
71
 
 
72
 
 
73
 
static boolean
74
 
gdi_llvmpipe_is_displaytarget_format_supported( struct llvmpipe_winsys *ws,
75
 
                                                enum pipe_format format )
76
 
{
77
 
   switch(format) {
78
 
   case PIPE_FORMAT_B8G8R8X8_UNORM:
79
 
   case PIPE_FORMAT_B8G8R8A8_UNORM:
80
 
      return TRUE;
81
 
 
82
 
   /* TODO: Support other formats possible with BMPs, as described in 
83
 
    * http://msdn.microsoft.com/en-us/library/dd183376(VS.85).aspx */
84
 
      
85
 
   default:
86
 
      return FALSE;
87
 
   }
88
 
}
89
 
 
90
 
 
91
 
static void *
92
 
gdi_llvmpipe_displaytarget_map(struct llvmpipe_winsys *ws,
93
 
                               struct llvmpipe_displaytarget *dt,
94
 
                               unsigned flags )
95
 
{
96
 
   struct gdi_llvmpipe_displaytarget *gdt = gdi_llvmpipe_displaytarget(dt);
97
 
 
98
 
   return gdt->data;
99
 
}
100
 
 
101
 
 
102
 
static void
103
 
gdi_llvmpipe_displaytarget_unmap(struct llvmpipe_winsys *ws,
104
 
                                 struct llvmpipe_displaytarget *dt )
105
 
{
106
 
 
107
 
}
108
 
 
109
 
 
110
 
static void
111
 
gdi_llvmpipe_displaytarget_destroy(struct llvmpipe_winsys *winsys,
112
 
                                   struct llvmpipe_displaytarget *dt)
113
 
{
114
 
   struct gdi_llvmpipe_displaytarget *gdt = gdi_llvmpipe_displaytarget(dt);
115
 
 
116
 
   align_free(gdt->data);
117
 
   FREE(gdt);
118
 
}
119
 
 
120
 
 
121
 
static struct llvmpipe_displaytarget *
122
 
gdi_llvmpipe_displaytarget_create(struct llvmpipe_winsys *winsys,
123
 
                                  enum pipe_format format,
124
 
                                  unsigned width, unsigned height,
125
 
                                  unsigned alignment,
126
 
                                  unsigned *stride)
127
 
{
128
 
   struct gdi_llvmpipe_displaytarget *gdt;
129
 
   unsigned cpp;
130
 
   unsigned bpp;
131
 
   
132
 
   gdt = CALLOC_STRUCT(gdi_llvmpipe_displaytarget);
133
 
   if(!gdt)
134
 
      goto no_gdt;
135
 
 
136
 
   gdt->format = format;
137
 
   gdt->width = width;
138
 
   gdt->height = height;
139
 
 
140
 
   bpp = util_format_get_blocksizebits(format);
141
 
   cpp = util_format_get_blocksize(format);
142
 
   
143
 
   gdt->stride = align(width * cpp, alignment);
144
 
   gdt->size = gdt->stride * height;
145
 
   
146
 
   gdt->data = align_malloc(gdt->size, alignment);
147
 
   if(!gdt->data)
148
 
      goto no_data;
149
 
 
150
 
   gdt->bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
151
 
   gdt->bmi.bmiHeader.biWidth = gdt->stride / cpp;
152
 
   gdt->bmi.bmiHeader.biHeight= -(long)height;
153
 
   gdt->bmi.bmiHeader.biPlanes = 1;
154
 
   gdt->bmi.bmiHeader.biBitCount = bpp;
155
 
   gdt->bmi.bmiHeader.biCompression = BI_RGB;
156
 
   gdt->bmi.bmiHeader.biSizeImage = 0;
157
 
   gdt->bmi.bmiHeader.biXPelsPerMeter = 0;
158
 
   gdt->bmi.bmiHeader.biYPelsPerMeter = 0;
159
 
   gdt->bmi.bmiHeader.biClrUsed = 0;
160
 
   gdt->bmi.bmiHeader.biClrImportant = 0;
161
 
 
162
 
   *stride = gdt->stride;
163
 
   return (struct llvmpipe_displaytarget *)gdt;
164
 
 
165
 
no_data:
166
 
   FREE(gdt);
167
 
no_gdt:
168
 
   return NULL;
169
 
}
170
 
 
171
 
 
172
 
static void
173
 
gdi_llvmpipe_displaytarget_display(struct llvmpipe_winsys *winsys, 
174
 
                                   struct llvmpipe_displaytarget *dt,
175
 
                                   void *context_private)
176
 
{
177
 
   assert(0);
178
 
}
179
 
 
180
 
 
181
 
static void
182
 
gdi_llvmpipe_destroy(struct llvmpipe_winsys *winsys)
183
 
{
184
 
   FREE(winsys);
185
 
}
186
 
 
187
 
 
188
 
static struct pipe_screen *
189
 
gdi_llvmpipe_screen_create(void)
190
 
{
191
 
   static struct llvmpipe_winsys *winsys;
192
 
   struct pipe_screen *screen;
193
 
 
194
 
   winsys = CALLOC_STRUCT(llvmpipe_winsys);
195
 
   if(!winsys)
196
 
      goto no_winsys;
197
 
 
198
 
   winsys->destroy = gdi_llvmpipe_destroy;
199
 
   winsys->is_displaytarget_format_supported = gdi_llvmpipe_is_displaytarget_format_supported;
200
 
   winsys->displaytarget_create = gdi_llvmpipe_displaytarget_create;
201
 
   winsys->displaytarget_map = gdi_llvmpipe_displaytarget_map;
202
 
   winsys->displaytarget_unmap = gdi_llvmpipe_displaytarget_unmap;
203
 
   winsys->displaytarget_display = gdi_llvmpipe_displaytarget_display;
204
 
   winsys->displaytarget_destroy = gdi_llvmpipe_displaytarget_destroy;
205
 
 
206
 
   screen = llvmpipe_create_screen(winsys);
207
 
   if(!screen)
208
 
      goto no_screen;
209
 
 
210
 
   return screen;
211
 
   
212
 
no_screen:
213
 
   FREE(winsys);
214
 
no_winsys:
215
 
   return NULL;
216
 
}
217
 
 
218
 
 
219
 
 
220
 
 
221
 
static void
222
 
gdi_llvmpipe_present(struct pipe_screen *screen,
223
 
                     struct pipe_surface *surface,
224
 
                     HDC hDC)
225
 
{
226
 
    struct llvmpipe_texture *texture;
227
 
    struct gdi_llvmpipe_displaytarget *gdt;
228
 
 
229
 
    texture = llvmpipe_texture(surface->texture);
230
 
    gdt = gdi_llvmpipe_displaytarget(texture->dt);
231
 
 
232
 
    StretchDIBits(hDC,
233
 
                  0, 0, gdt->width, gdt->height,
234
 
                  0, 0, gdt->width, gdt->height,
235
 
                  gdt->data, &gdt->bmi, 0, SRCCOPY);
236
 
}
237
 
 
238
 
 
239
 
static const struct stw_winsys stw_winsys = {
240
 
   &gdi_llvmpipe_screen_create,
241
 
   &gdi_llvmpipe_present,
242
 
   NULL, /* get_adapter_luid */
243
 
   NULL, /* shared_surface_open */
244
 
   NULL, /* shared_surface_close */
245
 
   NULL  /* compose */
246
 
};
247
 
 
248
 
 
249
 
BOOL WINAPI
250
 
DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
251
 
{
252
 
   switch (fdwReason) {
253
 
   case DLL_PROCESS_ATTACH:
254
 
      stw_init(&stw_winsys);
255
 
      stw_init_thread();
256
 
      break;
257
 
 
258
 
   case DLL_THREAD_ATTACH:
259
 
      stw_init_thread();
260
 
      break;
261
 
 
262
 
   case DLL_THREAD_DETACH:
263
 
      stw_cleanup_thread();
264
 
      break;
265
 
 
266
 
   case DLL_PROCESS_DETACH:
267
 
      stw_cleanup_thread();
268
 
      stw_cleanup();
269
 
      break;
270
 
   }
271
 
   return TRUE;
272
 
}