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

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/intel/intel_mipmap_tree.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:
29
29
#include "intel_mipmap_tree.h"
30
30
#include "intel_regions.h"
31
31
#include "intel_tex_layout.h"
32
 
#ifndef I915
33
 
#include "brw_state.h"
34
 
#endif
35
32
#include "main/enums.h"
 
33
#include "main/formats.h"
36
34
 
37
35
#define FILE_DEBUG_FLAG DEBUG_MIPTREE
38
36
 
83
81
   mt->cpp = compress_byte ? compress_byte : cpp;
84
82
   mt->compressed = compress_byte ? 1 : 0;
85
83
   mt->refcount = 1; 
86
 
   mt->pitch = 0;
87
84
 
88
85
#ifdef I915
89
86
   if (intel->is_945)
135
132
   /*
136
133
    * pitch == 0 || height == 0  indicates the null texture
137
134
    */
138
 
   if (!mt || !mt->pitch || !mt->total_height) {
 
135
   if (!mt || !mt->total_height) {
139
136
      free(mt);
140
137
      return NULL;
141
138
   }
142
139
 
143
 
   mt->region = intel_region_alloc(intel,
 
140
   mt->region = intel_region_alloc(intel->intelScreen,
144
141
                                   tiling,
145
142
                                   mt->cpp,
146
 
                                   mt->pitch,
 
143
                                   mt->total_width,
147
144
                                   mt->total_height,
148
145
                                   expect_accelerated_upload);
149
 
   mt->pitch = mt->region->pitch;
150
146
 
151
147
   if (!mt->region) {
152
148
       free(mt);
177
173
   if (!mt)
178
174
      return mt;
179
175
 
180
 
   /* The mipmap tree pitch is aligned to 64 bytes to make sure render
181
 
    * to texture works, but we don't need that for texturing from a
182
 
    * pixmap.  Just override it here. */
183
 
   mt->pitch = region->pitch;
184
 
 
185
176
   intel_region_reference(&mt->region, region);
186
177
 
187
178
   return mt;
188
179
}
189
180
 
190
 
 
191
 
/**
192
 
 * intel_miptree_pitch_align:
193
 
 *
194
 
 * @intel: intel context pointer
195
 
 *
196
 
 * @mt: the miptree to compute pitch alignment for
197
 
 *
198
 
 * @pitch: the natural pitch value
199
 
 *
200
 
 * Given @pitch, compute a larger value which accounts for
201
 
 * any necessary alignment required by the device
202
 
 */
203
 
int intel_miptree_pitch_align (struct intel_context *intel,
204
 
                               struct intel_mipmap_tree *mt,
205
 
                               uint32_t tiling,
206
 
                               int pitch)
207
 
{
208
 
#ifdef I915
209
 
   GLcontext *ctx = &intel->ctx;
210
 
#endif
211
 
 
212
 
   if (!mt->compressed) {
213
 
      int pitch_align;
214
 
 
215
 
      /* XXX: Align pitch to multiple of 64 bytes for now to allow
216
 
       * render-to-texture to work in all cases. This should probably be
217
 
       * replaced at some point by some scheme to only do this when really
218
 
       * necessary.
219
 
       */
220
 
      pitch_align = 64;
221
 
 
222
 
      if (tiling == I915_TILING_X)
223
 
         pitch_align = 512;
224
 
      else if (tiling == I915_TILING_Y)
225
 
         pitch_align = 128;
226
 
 
227
 
      pitch = ALIGN(pitch * mt->cpp, pitch_align);
228
 
 
229
 
#ifdef I915
230
 
      /* Do a little adjustment to linear allocations so that we avoid
231
 
       * hitting the same channel of memory for 2 different pages when
232
 
       * reading a 2x2 subspan or doing bilinear filtering.
233
 
       */
234
 
      if (tiling == I915_TILING_NONE && !(pitch & 511) &&
235
 
         (pitch + pitch_align) < (1 << ctx->Const.MaxTextureLevels))
236
 
         pitch += pitch_align;
237
 
#endif
238
 
 
239
 
      pitch /= mt->cpp;
240
 
   }
241
 
   return pitch;
242
 
}
243
 
 
244
 
 
245
181
void
246
182
intel_miptree_reference(struct intel_mipmap_tree **dst,
247
183
                        struct intel_mipmap_tree *src)
265
201
 
266
202
      DBG("%s deleting %p\n", __FUNCTION__, *mt);
267
203
 
268
 
#ifndef I915
269
 
      /* Free up cached binding tables holding a reference on our buffer, to
270
 
       * avoid excessive memory consumption.
271
 
       *
272
 
       * This isn't as aggressive as we could be, as we'd like to do
273
 
       * it from any time we free the last ref on a region.  But intel_region.c
274
 
       * is context-agnostic.  Perhaps our constant state cache should be, as
275
 
       * well.
276
 
       */
277
 
      brw_state_cache_bo_delete(&brw_context(&intel->ctx)->surface_cache,
278
 
                                (*mt)->region->buffer);
279
 
#endif
280
 
 
281
204
      intel_region_release(&((*mt)->region));
282
205
 
283
206
      for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
341
264
   mt->level[level].width = w;
342
265
   mt->level[level].height = h;
343
266
   mt->level[level].depth = d;
344
 
   mt->level[level].level_offset = (x + y * mt->pitch) * mt->cpp;
345
267
   mt->level[level].level_x = x;
346
268
   mt->level[level].level_y = y;
347
269
   mt->level[level].nr_images = nr_images;
348
270
 
349
 
   DBG("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
350
 
       level, w, h, d, x, y, mt->level[level].level_offset);
 
271
   DBG("%s level %d size: %d,%d,%d offset %d,%d\n", __FUNCTION__,
 
272
       level, w, h, d, x, y);
351
273
 
352
274
   assert(nr_images);
353
275
   assert(!mt->level[level].x_offset);
414
336
   DBG("%s \n", __FUNCTION__);
415
337
 
416
338
   if (row_stride)
417
 
      *row_stride = mt->pitch * mt->cpp;
 
339
      *row_stride = mt->region->pitch * mt->cpp;
418
340
 
419
341
   if (mt->target == GL_TEXTURE_3D) {
420
342
      int i;
423
345
 
424
346
         intel_miptree_get_image_offset(mt, level, face, i,
425
347
                                        &x, &y);
426
 
         image_offsets[i] = x + y * mt->pitch;
 
348
         image_offsets[i] = x + y * mt->region->pitch;
427
349
      }
428
350
 
429
351
      return intel_region_map(intel, mt->region);
434
356
      image_offsets[0] = 0;
435
357
 
436
358
      return intel_region_map(intel, mt->region) +
437
 
         (x + y * mt->pitch) * mt->cpp;
 
359
         (x + y * mt->region->pitch) * mt->cpp;
438
360
   }
439
361
}
440
362
 
526
448
         src_ptr = intel_region_map(intel, src->region);
527
449
         dst_ptr = intel_region_map(intel, dst->region);
528
450
 
529
 
         _mesa_copy_rect(dst_ptr + dst->cpp * (dst_x + dst_y * dst->pitch),
 
451
         _mesa_copy_rect(dst_ptr,
530
452
                         dst->cpp,
531
 
                         dst->pitch,
532
 
                         0, 0, width, height,
533
 
                         src_ptr + src->cpp * (src_x + src_y * src->pitch),
534
 
                         src->pitch,
535
 
                         0, 0);
 
453
                         dst->region->pitch,
 
454
                         dst_x, dst_y, width, height,
 
455
                         src_ptr,
 
456
                         src->region->pitch,
 
457
                         src_x, src_y);
536
458
         intel_region_unmap(intel, src->region);
537
459
         intel_region_unmap(intel, dst->region);
538
460
      }