~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/gallium/state_trackers/wgl/stw_pixelformat.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-08-23 15:37:30 UTC
  • mfrom: (1.7.6)
  • Revision ID: package-import@ubuntu.com-20120823153730-c499sefj7btu4386
Tags: 9.0~git20120821.c1114c61-0ubuntu1
* Merge from unreleased debian git.
  - Includes support for ATI Trinity PCI IDs (LP: #1009089)
* rules, control, libgl1-mesa-swx11*: Remove swx11 support.
* Refresh patches:
  - drop 115_llvm_dynamic_linking.diff,
    117_nullptr_check_in_query_version.patch, and
    118_glsl_initialize_samplers.patch, all upstream
  - disable 116_use_shared_galliumcore.diff until it's reviewed and
    reworked to apply
* not-installed, libegl1-mesa-drivers-install.linux.in: Updated to
  match the single-pass build.
* libgl1-mesa-dri.*install.in: Drop libglsl.so, it's included in
  libdricore.so now.
* rules: Don't disable GLU on the common flags, we need to build it
  on the dri target.
* libglu*install.in: Fix the source file paths to match the build target.
  Drop the static lib from -dev since only shared libs get built.
* libgl1-mesa-dev.install.in: Fix the source file paths to match the
  build target.
* libgl1-mesa-dri.install.linux.in: Don't try to install libgallium.so,
  which isn't built yet.
* rules: Enable llvmpipe on armhf to see if it works or not.
* rules: Remove bin/install-sh on clean, and don't create a symlink for
  it.
* control: Add Pre-Depends on dpkg-dev due to the binaries using xz
  compression.

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
   { PIPE_FORMAT_B4G4R4A4_UNORM,    { 4,  4,  4,  4}, {16,  4,  0, 12} }
86
86
};
87
87
 
 
88
static const struct stw_pf_color_info
 
89
stw_pf_color_extended[] = {
 
90
    { PIPE_FORMAT_R32G32B32A32_FLOAT, { 32,  32, 32,  32}, { 0,  32, 64, 96} }
 
91
};
88
92
 
89
93
static const struct stw_pf_depth_info 
90
94
stw_pf_depth_stencil[] = {
116
120
static void
117
121
stw_pixelformat_add(
118
122
   struct stw_device *stw_dev,
 
123
   boolean extended,
119
124
   const struct stw_pf_color_info *color,
120
125
   const struct stw_pf_depth_info *depth,
121
126
   unsigned accum,
122
127
   boolean doublebuffer,
123
128
   unsigned samples )
124
129
{
125
 
   boolean extended = FALSE;
126
130
   struct stw_pixelformat_info *pfi;
127
131
   
128
132
   assert(stw_dev->pixelformat_extended_count < STW_MAX_PIXELFORMATS);
146
150
   pfi->pfd.dwFlags = PFD_SUPPORT_OPENGL;
147
151
   
148
152
   /* TODO: also support non-native pixel formats */
149
 
   pfi->pfd.dwFlags |= PFD_DRAW_TO_WINDOW;
 
153
   if (!extended) {
 
154
      pfi->pfd.dwFlags |= PFD_DRAW_TO_WINDOW;
 
155
   }
150
156
 
151
157
   /* See http://www.opengl.org/pipeline/article/vol003_7/ */
152
158
   pfi->pfd.dwFlags |= PFD_SUPPORT_COMPOSITION;
204
210
   }
205
211
}
206
212
 
 
213
 
 
214
/**
 
215
 * Add the depth/stencil/accum/ms variants for a particular color format.
 
216
 */
 
217
static void
 
218
add_color_format_variants(const struct stw_pf_color_info *color,
 
219
                          boolean extended)
 
220
{
 
221
   struct pipe_screen *screen = stw_dev->screen;
 
222
   unsigned ms, db, ds, acc;
 
223
   unsigned bind_flags = PIPE_BIND_RENDER_TARGET;
 
224
 
 
225
   if (!extended) {
 
226
      bind_flags |= PIPE_BIND_DISPLAY_TARGET;
 
227
   }
 
228
 
 
229
   if (!screen->is_format_supported(screen, color->format,
 
230
                                    PIPE_TEXTURE_2D, 0, bind_flags)) {
 
231
      return;
 
232
   }
 
233
 
 
234
   for (ms = 0; ms < Elements(stw_pf_multisample); ms++) {
 
235
      unsigned samples = stw_pf_multisample[ms];
 
236
 
 
237
      /* FIXME: re-enabled MSAA when we can query it */
 
238
      if (samples)
 
239
         continue;
 
240
 
 
241
      for (db = 0; db < Elements(stw_pf_doublebuffer); db++) {
 
242
         unsigned doublebuffer = stw_pf_doublebuffer[db];
 
243
 
 
244
         for (ds = 0; ds < Elements(stw_pf_depth_stencil); ds++) {
 
245
            const struct stw_pf_depth_info *depth = &stw_pf_depth_stencil[ds];
 
246
 
 
247
            if (!screen->is_format_supported(screen, depth->format,
 
248
                                             PIPE_TEXTURE_2D, 0,
 
249
                                             PIPE_BIND_DEPTH_STENCIL)) {
 
250
               continue;
 
251
            }
 
252
 
 
253
            for (acc = 0; acc < 2; acc++) {
 
254
               stw_pixelformat_add(stw_dev, extended, color, depth,
 
255
                                   acc * 16, doublebuffer, samples);
 
256
            }
 
257
         }
 
258
      }
 
259
   }
 
260
}
 
261
 
 
262
 
207
263
void
208
264
stw_pixelformat_init( void )
209
265
{
210
 
   struct pipe_screen *screen = stw_dev->screen;
211
 
   unsigned i, j, k, l;
212
 
   
 
266
   unsigned i;
 
267
 
213
268
   assert( !stw_dev->pixelformat_count );
214
269
   assert( !stw_dev->pixelformat_extended_count );
215
270
 
216
 
   for(i = 0; i < Elements(stw_pf_multisample); ++i) {
217
 
      unsigned samples = stw_pf_multisample[i];
218
 
      
219
 
      /* FIXME: re-enabled MSAA when we can query it */
220
 
      if(samples)
221
 
         continue;
222
 
 
223
 
      for(j = 0; j < Elements(stw_pf_color); ++j) {
224
 
         const struct stw_pf_color_info *color = &stw_pf_color[j];
225
 
         
226
 
         if(!screen->is_format_supported(screen, color->format, PIPE_TEXTURE_2D,
227
 
                                         0, PIPE_BIND_RENDER_TARGET |
228
 
                                         PIPE_BIND_DISPLAY_TARGET))
229
 
            continue;
230
 
         
231
 
         for(k = 0; k < Elements(stw_pf_doublebuffer); ++k) {
232
 
            unsigned doublebuffer = stw_pf_doublebuffer[k];
233
 
            
234
 
            for(l = 0; l < Elements(stw_pf_depth_stencil); ++l) {
235
 
               const struct stw_pf_depth_info *depth = &stw_pf_depth_stencil[l];
236
 
               
237
 
               if(!screen->is_format_supported(screen, depth->format, PIPE_TEXTURE_2D, 
238
 
                                               0, PIPE_BIND_DEPTH_STENCIL))
239
 
                  continue;
240
 
 
241
 
               stw_pixelformat_add( stw_dev, color, depth,  0, doublebuffer, samples );
242
 
               stw_pixelformat_add( stw_dev, color, depth, 16, doublebuffer, samples );
243
 
            }
244
 
         }
245
 
      }
246
 
   }
247
 
   
 
271
   /* normal, displayable formats */
 
272
   for (i = 0; i < Elements(stw_pf_color); i++) {
 
273
      add_color_format_variants(&stw_pf_color[i], FALSE);
 
274
   }
 
275
 
 
276
   /* extended, pbuffer-only formats */
 
277
   for (i = 0; i < Elements(stw_pf_color_extended); i++) {
 
278
      add_color_format_variants(&stw_pf_color_extended[i], TRUE);
 
279
   }
 
280
 
248
281
   assert( stw_dev->pixelformat_count <= stw_dev->pixelformat_extended_count );
249
282
   assert( stw_dev->pixelformat_extended_count <= STW_MAX_PIXELFORMATS );
250
283
}
262
295
}
263
296
 
264
297
const struct stw_pixelformat_info *
265
 
stw_pixelformat_get_info( uint index )
 
298
stw_pixelformat_get_info( int iPixelFormat )
266
299
{
267
 
   assert( index < stw_dev->pixelformat_extended_count );
 
300
   int index;
 
301
 
 
302
   if (iPixelFormat <= 0) {
 
303
      return NULL;
 
304
   }
 
305
 
 
306
   index = iPixelFormat - 1;
 
307
   if (index >= stw_dev->pixelformat_extended_count) {
 
308
      return NULL;
 
309
   }
268
310
 
269
311
   return &stw_dev->pixelformats[index];
270
312
}
278
320
   PIXELFORMATDESCRIPTOR *ppfd )
279
321
{
280
322
   uint count;
281
 
   uint index;
282
323
   const struct stw_pixelformat_info *pfi;
283
324
 
284
325
   (void) hdc;
286
327
   if (!stw_dev)
287
328
      return 0;
288
329
 
289
 
   count = stw_pixelformat_get_extended_count();
290
 
   index = (uint) iPixelFormat - 1;
 
330
   count = stw_pixelformat_get_count();
291
331
 
292
332
   if (ppfd == NULL)
293
333
      return count;
294
 
   if (index >= count || cjpfd != sizeof( PIXELFORMATDESCRIPTOR ))
 
334
   if (cjpfd != sizeof( PIXELFORMATDESCRIPTOR ))
295
335
      return 0;
296
336
 
297
 
   pfi = stw_pixelformat_get_info( index );
 
337
   pfi = stw_pixelformat_get_info( iPixelFormat );
 
338
   if (!pfi) {
 
339
      return 0;
 
340
   }
298
341
   
299
342
   memcpy(ppfd, &pfi->pfd, sizeof( PIXELFORMATDESCRIPTOR ));
300
343
 
360
403
 
361
404
   (void) hdc;
362
405
 
363
 
   count = stw_pixelformat_get_count();
364
 
   bestindex = count;
 
406
   count = stw_pixelformat_get_extended_count();
 
407
   bestindex = 0;
365
408
   bestdelta = ~0U;
366
409
 
367
 
   for (index = 0; index < count; index++) {
 
410
   for (index = 1; index <= count; index++) {
368
411
      uint delta = 0;
369
412
      const struct stw_pixelformat_info *pfi = stw_pixelformat_get_info( index );
370
413
 
394
437
      }
395
438
   }
396
439
 
397
 
   if (bestindex == count)
398
 
      return 0;
399
 
 
400
 
   return bestindex + 1;
 
440
   return bestindex;
401
441
}