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

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/nouveau/nouveau_texture.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:
38
38
#include "main/mipmap.h"
39
39
#include "main/texfetch.h"
40
40
#include "main/teximage.h"
 
41
#include "drivers/common/meta.h"
41
42
 
42
43
static struct gl_texture_object *
43
44
nouveau_texture_new(GLcontext *ctx, GLuint name, GLenum target)
177
178
}
178
179
 
179
180
static GLboolean
180
 
teximage_fits(struct gl_texture_object *t, int level,
181
 
              struct gl_texture_image *ti)
 
181
teximage_fits(struct gl_texture_object *t, int level)
182
182
{
183
183
        struct nouveau_surface *s = &to_nouveau_texture(t)->surfaces[level];
 
184
        struct gl_texture_image *ti = t->Image[0][level];
184
185
 
185
 
        return t->Target == GL_TEXTURE_RECTANGLE ||
186
 
                (s->bo && s->width == ti->Width &&
187
 
                 s->height == ti->Height &&
188
 
                 s->format == ti->TexFormat);
 
186
        return ti && to_nouveau_teximage(ti)->surface.bo &&
 
187
                (t->Target == GL_TEXTURE_RECTANGLE ||
 
188
                 (s->bo && s->format == ti->TexFormat &&
 
189
                  s->width == ti->Width && s->height == ti->Height));
189
190
}
190
191
 
191
192
static GLboolean
195
196
{
196
197
        struct gl_texture_image *ti = t->Image[0][level];
197
198
 
198
 
        if (ti && teximage_fits(t, level, ti)) {
 
199
        if (teximage_fits(t, level)) {
199
200
                struct nouveau_surface *ss = to_nouveau_texture(t)->surfaces;
200
201
                struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
201
202
 
283
284
        struct nouveau_texture *nt = to_nouveau_texture(t);
284
285
        int i, last = get_last_level(t);
285
286
 
286
 
        if (!nt->surfaces[last].bo)
 
287
        if (!teximage_fits(t, t->BaseLevel) ||
 
288
            !teximage_fits(t, last))
287
289
                return GL_FALSE;
288
290
 
289
291
        if (nt->dirty) {
296
298
                        validate_teximage(ctx, t, i, 0, 0, 0,
297
299
                                          s->width, s->height, 1);
298
300
                }
 
301
 
 
302
                FIRE_RING(context_chan(ctx));
299
303
        }
300
304
 
301
305
        return GL_TRUE;
304
308
void
305
309
nouveau_texture_reallocate(GLcontext *ctx, struct gl_texture_object *t)
306
310
{
307
 
        texture_dirty(t);
308
 
        relayout_texture(ctx, t);
309
 
        nouveau_texture_validate(ctx, t);
 
311
        if (!teximage_fits(t, t->BaseLevel) ||
 
312
            !teximage_fits(t, get_last_level(t))) {
 
313
                texture_dirty(t);
 
314
                relayout_texture(ctx, t);
 
315
                nouveau_texture_validate(ctx, t);
 
316
        }
310
317
}
311
318
 
312
319
static unsigned
364
371
        }
365
372
 
366
373
        if (level == t->BaseLevel) {
367
 
                if (!teximage_fits(t, level, ti))
 
374
                if (!teximage_fits(t, level))
368
375
                        relayout_texture(ctx, t);
369
376
                nouveau_texture_validate(ctx, t);
370
377
        }
416
423
}
417
424
 
418
425
static void
 
426
nouveau_texsubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
 
427
                    GLint xoffset, GLint yoffset, GLint zoffset,
 
428
                    GLint width, GLint height, GLint depth,
 
429
                    GLenum format, GLenum type, const void *pixels,
 
430
                    const struct gl_pixelstore_attrib *packing,
 
431
                    struct gl_texture_object *t,
 
432
                    struct gl_texture_image *ti)
 
433
{
 
434
        struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
 
435
        int ret;
 
436
 
 
437
        pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, depth,
 
438
                                             format, type, pixels, packing,
 
439
                                             "glTexSubImage");
 
440
        if (pixels) {
 
441
                nouveau_teximage_map(ctx, ti);
 
442
 
 
443
                ret = _mesa_texstore(ctx, 3, ti->_BaseFormat, ti->TexFormat,
 
444
                                     ti->Data, xoffset, yoffset, zoffset,
 
445
                                     s->pitch, ti->ImageOffsets,
 
446
                                     width, height, depth, format, type,
 
447
                                     pixels, packing);
 
448
                assert(ret);
 
449
 
 
450
                nouveau_teximage_unmap(ctx, ti);
 
451
                _mesa_unmap_teximage_pbo(ctx, packing);
 
452
        }
 
453
 
 
454
        if (!to_nouveau_texture(t)->dirty)
 
455
                validate_teximage(ctx, t, level, xoffset, yoffset, zoffset,
 
456
                                  width, height, depth);
 
457
}
 
458
 
 
459
static void
419
460
nouveau_texsubimage_3d(GLcontext *ctx, GLenum target, GLint level,
420
461
                       GLint xoffset, GLint yoffset, GLint zoffset,
421
462
                       GLint width, GLint height, GLint depth,
424
465
                       struct gl_texture_object *t,
425
466
                       struct gl_texture_image *ti)
426
467
{
427
 
        nouveau_teximage_map(ctx, ti);
428
 
        _mesa_store_texsubimage3d(ctx, target, level, xoffset, yoffset, zoffset,
429
 
                                  width, height, depth, format, type, pixels,
430
 
                                  packing, t, ti);
431
 
        nouveau_teximage_unmap(ctx, ti);
432
 
 
433
 
        if (!to_nouveau_texture(t)->dirty)
434
 
                validate_teximage(ctx, t, level, xoffset, yoffset, zoffset,
435
 
                                  width, height, depth);
 
468
        nouveau_texsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset,
 
469
                            width, height, depth, format, type, pixels,
 
470
                            packing, t, ti);
436
471
}
437
472
 
438
473
static void
444
479
                       struct gl_texture_object *t,
445
480
                       struct gl_texture_image *ti)
446
481
{
447
 
        nouveau_teximage_map(ctx, ti);
448
 
        _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset,
449
 
                                  width, height, format, type, pixels,
450
 
                                  packing, t, ti);
451
 
        nouveau_teximage_unmap(ctx, ti);
452
 
 
453
 
        if (!to_nouveau_texture(t)->dirty)
454
 
                validate_teximage(ctx, t, level, xoffset, yoffset, 0,
455
 
                                  width, height, 1);
 
482
        nouveau_texsubimage(ctx, 2, target, level, xoffset, yoffset, 0,
 
483
                            width, height, 1, format, type, pixels,
 
484
                            packing, t, ti);
456
485
}
457
486
 
458
487
static void
463
492
                       struct gl_texture_object *t,
464
493
                       struct gl_texture_image *ti)
465
494
{
466
 
        nouveau_teximage_map(ctx, ti);
467
 
        _mesa_store_texsubimage1d(ctx, target, level, xoffset,
468
 
                                  width, format, type, pixels,
469
 
                                  packing, t, ti);
470
 
        nouveau_teximage_unmap(ctx, ti);
471
 
 
472
 
        if (!to_nouveau_texture(t)->dirty)
473
 
                validate_teximage(ctx, t, level, xoffset, 0, 0,
474
 
                                  width, 1, 1);
 
495
        nouveau_texsubimage(ctx, 1, target, level, xoffset, 0, 0,
 
496
                            width, 1, 1, format, type, pixels,
 
497
                            packing, t, ti);
475
498
}
476
499
 
477
500
static void
567
590
        }
568
591
}
569
592
 
 
593
static void
 
594
store_mipmap(GLcontext *ctx, GLenum target, int first, int last,
 
595
             struct gl_texture_object *t)
 
596
{
 
597
        struct gl_pixelstore_attrib packing = {
 
598
                .BufferObj = ctx->Shared->NullBufferObj,
 
599
                .Alignment = 1
 
600
        };
 
601
        GLenum format = t->Image[0][first]->TexFormat;
 
602
        unsigned base_format, type, comps;
 
603
        int i;
 
604
 
 
605
        base_format = _mesa_get_format_base_format(format);
 
606
        _mesa_format_to_type_and_comps(format, &type, &comps);
 
607
 
 
608
        for (i = first; i <= last; i++) {
 
609
                struct gl_texture_image *ti = t->Image[0][i];
 
610
                void *data = ti->Data;
 
611
 
 
612
                nouveau_teximage(ctx, 3, target, i, ti->InternalFormat,
 
613
                                 ti->Width, ti->Height, ti->Depth,
 
614
                                 ti->Border, base_format, type, data,
 
615
                                 &packing, t, ti);
 
616
 
 
617
                _mesa_free_texmemory(data);
 
618
        }
 
619
}
 
620
 
 
621
static void
 
622
nouveau_generate_mipmap(GLcontext *ctx, GLenum target,
 
623
                        struct gl_texture_object *t)
 
624
{
 
625
        if (_mesa_meta_check_generate_mipmap_fallback(ctx, target, t)) {
 
626
                struct gl_texture_image *base = t->Image[0][t->BaseLevel];
 
627
 
 
628
                nouveau_teximage_map(ctx, base);
 
629
                _mesa_generate_mipmap(ctx, target, t);
 
630
                nouveau_teximage_unmap(ctx, base);
 
631
 
 
632
                store_mipmap(ctx, target, t->BaseLevel + 1,
 
633
                             get_last_level(t), t);
 
634
 
 
635
        } else {
 
636
                _mesa_meta_GenerateMipmap(ctx, target, t);
 
637
        }
 
638
}
 
639
 
570
640
void
571
641
nouveau_texture_functions_init(struct dd_function_table *functions)
572
642
{
585
655
        functions->BindTexture = nouveau_bind_texture;
586
656
        functions->MapTexture = nouveau_texture_map;
587
657
        functions->UnmapTexture = nouveau_texture_unmap;
 
658
        functions->GenerateMipmap = nouveau_generate_mipmap;
588
659
}