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

« back to all changes in this revision

Viewing changes to src/mesa/state_tracker/st_cb_clear.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:
53
53
#include "util/u_inlines.h"
54
54
#include "util/u_simple_shaders.h"
55
55
#include "util/u_draw_quad.h"
 
56
#include "util/u_upload_mgr.h"
56
57
 
57
58
#include "cso_cache/cso_context.h"
58
59
 
87
88
      cso_delete_vertex_shader(st->cso_context, st->clear.vs);
88
89
      st->clear.vs = NULL;
89
90
   }
90
 
   if (st->clear.vbuf) {
91
 
      pipe_resource_reference(&st->clear.vbuf, NULL);
92
 
      st->clear.vbuf = NULL;
93
 
   }
94
91
}
95
92
 
96
93
 
140
137
          const union pipe_color_union *color)
141
138
{
142
139
   struct pipe_context *pipe = st->pipe;
143
 
 
144
 
   /* XXX: Need to improve buffer_write to allow NO_WAIT (as well as
145
 
    * no_flush) updates to buffers where we know there is no conflict
146
 
    * with previous data.  Currently using max_slots > 1 will cause
147
 
    * synchronous rendering if the driver flushes its command buffers
148
 
    * between one bitmap and the next.  Our flush hook below isn't
149
 
    * sufficient to catch this as the driver doesn't tell us when it
150
 
    * flushes its own command buffers.  Until this gets fixed, pay the
151
 
    * price of allocating a new buffer for each bitmap cache-flush to
152
 
    * avoid synchronous rendering.
153
 
    */
154
 
   const GLuint max_slots = 1; /* 1024 / sizeof(st->clear.vertices); */
155
 
   GLuint i;
156
 
 
157
 
   if (st->clear.vbuf_slot >= max_slots) {
158
 
      pipe_resource_reference(&st->clear.vbuf, NULL);
159
 
      st->clear.vbuf_slot = 0;
160
 
   }
161
 
 
162
 
   if (!st->clear.vbuf) {
163
 
      st->clear.vbuf = pipe_buffer_create(pipe->screen,
164
 
                                          PIPE_BIND_VERTEX_BUFFER,
165
 
                                          PIPE_USAGE_STREAM,
166
 
                                          max_slots * sizeof(st->clear.vertices));
167
 
   }
168
 
 
169
 
   if (!st->clear.vbuf) {
170
 
      /* ran out of memory */
 
140
   struct pipe_resource *vbuf = NULL;
 
141
   GLuint i, offset;
 
142
   float (*vertices)[2][4];  /**< vertex pos + color */
 
143
 
 
144
   u_upload_alloc(st->uploader, 0, 4 * sizeof(vertices[0]), &offset, &vbuf,
 
145
                  (void**)&vertices);
 
146
   if (!vbuf) {
171
147
      return;
172
148
   }
173
149
 
174
150
   /* positions */
175
 
   st->clear.vertices[0][0][0] = x0;
176
 
   st->clear.vertices[0][0][1] = y0;
177
 
 
178
 
   st->clear.vertices[1][0][0] = x1;
179
 
   st->clear.vertices[1][0][1] = y0;
180
 
 
181
 
   st->clear.vertices[2][0][0] = x1;
182
 
   st->clear.vertices[2][0][1] = y1;
183
 
 
184
 
   st->clear.vertices[3][0][0] = x0;
185
 
   st->clear.vertices[3][0][1] = y1;
 
151
   vertices[0][0][0] = x0;
 
152
   vertices[0][0][1] = y0;
 
153
 
 
154
   vertices[1][0][0] = x1;
 
155
   vertices[1][0][1] = y0;
 
156
 
 
157
   vertices[2][0][0] = x1;
 
158
   vertices[2][0][1] = y1;
 
159
 
 
160
   vertices[3][0][0] = x0;
 
161
   vertices[3][0][1] = y1;
186
162
 
187
163
   /* same for all verts: */
188
164
   for (i = 0; i < 4; i++) {
189
 
      st->clear.vertices[i][0][2] = z;
190
 
      st->clear.vertices[i][0][3] = 1.0;
191
 
      st->clear.vertices[i][1][0] = color->f[0];
192
 
      st->clear.vertices[i][1][1] = color->f[1];
193
 
      st->clear.vertices[i][1][2] = color->f[2];
194
 
      st->clear.vertices[i][1][3] = color->f[3];
 
165
      vertices[i][0][2] = z;
 
166
      vertices[i][0][3] = 1.0;
 
167
      vertices[i][1][0] = color->f[0];
 
168
      vertices[i][1][1] = color->f[1];
 
169
      vertices[i][1][2] = color->f[2];
 
170
      vertices[i][1][3] = color->f[3];
195
171
   }
196
172
 
197
 
   /* put vertex data into vbuf */
198
 
   pipe_buffer_write_nooverlap(st->pipe, st->clear.vbuf,
199
 
                                           st->clear.vbuf_slot
200
 
                                             * sizeof(st->clear.vertices),
201
 
                                           sizeof(st->clear.vertices),
202
 
                                           st->clear.vertices);
 
173
   u_upload_unmap(st->uploader);
203
174
 
204
175
   /* draw */
205
176
   util_draw_vertex_buffer(pipe,
206
177
                           st->cso_context,
207
 
                           st->clear.vbuf, 
208
 
                           st->clear.vbuf_slot * sizeof(st->clear.vertices),
 
178
                           vbuf, offset,
209
179
                           PIPE_PRIM_TRIANGLE_FAN,
210
180
                           4,  /* verts */
211
181
                           2); /* attribs/vert */
212
182
 
213
 
   /* Increment slot */
214
 
   st->clear.vbuf_slot++;
 
183
   pipe_resource_reference(&vbuf, NULL);
215
184
}
216
185
 
217
186
 
248
217
   cso_save_stencil_ref(st->cso_context);
249
218
   cso_save_depth_stencil_alpha(st->cso_context);
250
219
   cso_save_rasterizer(st->cso_context);
 
220
   cso_save_sample_mask(st->cso_context);
251
221
   cso_save_viewport(st->cso_context);
252
222
   cso_save_fragment_shader(st->cso_context);
253
223
   cso_save_stream_outputs(st->cso_context);
308
278
 
309
279
   cso_set_vertex_elements(st->cso_context, 2, st->velems_util_draw);
310
280
   cso_set_stream_outputs(st->cso_context, 0, NULL, 0);
311
 
 
 
281
   cso_set_sample_mask(st->cso_context, ~0);
312
282
   cso_set_rasterizer(st->cso_context, &st->clear.raster);
313
283
 
314
284
   /* viewport state: viewport matching window dims */
344
314
   cso_restore_stencil_ref(st->cso_context);
345
315
   cso_restore_depth_stencil_alpha(st->cso_context);
346
316
   cso_restore_rasterizer(st->cso_context);
 
317
   cso_restore_sample_mask(st->cso_context);
347
318
   cso_restore_viewport(st->cso_context);
348
319
   cso_restore_fragment_shader(st->cso_context);
349
320
   cso_restore_vertex_shader(st->cso_context);
388
359
   GLboolean maskStencil
389
360
      = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
390
361
 
391
 
   assert(rb->Format == MESA_FORMAT_S8 ||
392
 
          rb->Format == MESA_FORMAT_Z24_S8 ||
393
 
          rb->Format == MESA_FORMAT_S8_Z24 ||
394
 
          rb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
 
362
   assert(_mesa_get_format_bits(rb->Format, GL_STENCIL_BITS) > 0);
395
363
 
396
364
   if (ctx->Scissor.Enabled &&
397
365
       (ctx->Scissor.X != 0 ||
444
412
   const GLboolean maskStencil
445
413
      = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
446
414
 
447
 
   assert(rb->Format == MESA_FORMAT_S8 ||
448
 
          rb->Format == MESA_FORMAT_Z24_S8 ||
449
 
          rb->Format == MESA_FORMAT_S8_Z24 ||
450
 
          rb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
 
415
   assert(_mesa_get_format_bits(rb->Format, GL_STENCIL_BITS) > 0);
451
416
 
452
417
   if (maskStencil) 
453
418
      return GL_TRUE;
471
436
}
472
437
 
473
438
 
474
 
 
475
 
/**
476
 
 * Called when we need to flush.
477
 
 */
478
 
void
479
 
st_flush_clear(struct st_context *st)
480
 
{
481
 
   /* Release vertex buffer to avoid synchronous rendering if we were
482
 
    * to map it in the next frame.
483
 
    */
484
 
   pipe_resource_reference(&st->clear.vbuf, NULL);
485
 
   st->clear.vbuf_slot = 0;
486
 
}
487
 
 
488
 
 
489
 
 
490
439
/**
491
440
 * Called via ctx->Driver.Clear()
492
441
 */