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

« back to all changes in this revision

Viewing changes to src/gallium/auxiliary/draw/draw_pipe_aaline.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:
40
40
#include "util/u_format.h"
41
41
#include "util/u_math.h"
42
42
#include "util/u_memory.h"
 
43
#include "util/u_sampler.h"
43
44
 
44
45
#include "tgsi/tgsi_transform.h"
45
46
#include "tgsi/tgsi_dump.h"
87
88
   uint pos_slot;
88
89
 
89
90
   void *sampler_cso;
90
 
   struct pipe_texture *texture;
 
91
   struct pipe_resource *texture;
 
92
   struct pipe_sampler_view *sampler_view;
91
93
   uint num_samplers;
92
 
   uint num_textures;
 
94
   uint num_sampler_views;
93
95
 
94
96
 
95
97
   /*
98
100
   struct aaline_fragment_shader *fs;
99
101
   struct {
100
102
      void *sampler[PIPE_MAX_SAMPLERS];
101
 
      struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
 
103
      struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
102
104
   } state;
103
105
 
104
106
   /*
111
113
 
112
114
   void (*driver_bind_sampler_states)(struct pipe_context *, unsigned,
113
115
                                      void **);
114
 
   void (*driver_set_sampler_textures)(struct pipe_context *, unsigned,
115
 
                                       struct pipe_texture **);
 
116
 
 
117
   void (*driver_set_sampler_views)(struct pipe_context *,
 
118
                                    unsigned,
 
119
                                    struct pipe_sampler_view **);
116
120
};
117
121
 
118
122
 
392
396
{
393
397
   struct pipe_context *pipe = aaline->stage.draw->pipe;
394
398
   struct pipe_screen *screen = pipe->screen;
395
 
   struct pipe_texture texTemp;
 
399
   struct pipe_resource texTemp;
 
400
   struct pipe_sampler_view viewTempl;
396
401
   uint level;
397
402
 
398
403
   memset(&texTemp, 0, sizeof(texTemp));
402
407
   texTemp.width0 = 1 << MAX_TEXTURE_LEVEL;
403
408
   texTemp.height0 = 1 << MAX_TEXTURE_LEVEL;
404
409
   texTemp.depth0 = 1;
 
410
   texTemp.bind = PIPE_BIND_SAMPLER_VIEW;
405
411
 
406
 
   aaline->texture = screen->texture_create(screen, &texTemp);
 
412
   aaline->texture = screen->resource_create(screen, &texTemp);
407
413
   if (!aaline->texture)
408
414
      return FALSE;
409
415
 
 
416
   u_sampler_view_default_template(&viewTempl,
 
417
                                   aaline->texture,
 
418
                                   aaline->texture->format);
 
419
   aaline->sampler_view = pipe->create_sampler_view(pipe,
 
420
                                                    aaline->texture,
 
421
                                                    &viewTempl);
 
422
   if (!aaline->sampler_view) {
 
423
      return FALSE;
 
424
   }
 
425
 
410
426
   /* Fill in mipmap images.
411
427
    * Basically each level is solid opaque, except for the outermost
412
 
    * texels which are zero.  Special case the 1x1 and 2x2 levels.
 
428
    * texels which are zero.  Special case the 1x1 and 2x2 levels
 
429
    * (though, those levels shouldn't be used - see the max_lod setting).
413
430
    */
414
431
   for (level = 0; level <= MAX_TEXTURE_LEVEL; level++) {
415
432
      struct pipe_transfer *transfer;
 
433
      struct pipe_box box;
416
434
      const uint size = u_minify(aaline->texture->width0, level);
417
435
      ubyte *data;
418
436
      uint i, j;
419
437
 
420
438
      assert(aaline->texture->width0 == aaline->texture->height0);
421
439
 
 
440
      u_box_origin_2d( size, size, &box );
 
441
 
422
442
      /* This texture is new, no need to flush. 
423
443
       */
424
 
      transfer = screen->get_tex_transfer(screen, aaline->texture, 0, level, 0,
425
 
                                         PIPE_TRANSFER_WRITE, 0, 0, size, size);
426
 
      data = screen->transfer_map(screen, transfer);
 
444
      transfer = pipe->get_transfer(pipe,
 
445
                                    aaline->texture,
 
446
                                    u_subresource(0, level), 
 
447
                                    PIPE_TRANSFER_WRITE,
 
448
                                    &box);
 
449
 
 
450
      data = pipe->transfer_map(pipe, transfer);
427
451
      if (data == NULL)
428
452
         return FALSE;
429
453
 
447
471
      }
448
472
 
449
473
      /* unmap */
450
 
      screen->transfer_unmap(screen, transfer);
451
 
      screen->tex_transfer_destroy(transfer);
 
474
      pipe->transfer_unmap(pipe, transfer);
 
475
      pipe->transfer_destroy(pipe, transfer);
452
476
   }
453
477
   return TRUE;
454
478
}
474
498
   sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
475
499
   sampler.normalized_coords = 1;
476
500
   sampler.min_lod = 0.0f;
477
 
   sampler.max_lod = MAX_TEXTURE_LEVEL;
 
501
   /* avoid using the 1x1 and 2x2 mipmap levels */
 
502
   sampler.max_lod = MAX_TEXTURE_LEVEL - 2;
478
503
 
479
504
   aaline->sampler_cso = pipe->create_sampler_state(pipe, &sampler);
480
505
   if (aaline->sampler_cso == NULL)
646
671
 
647
672
   assert(draw->rasterizer->line_smooth);
648
673
 
649
 
   if (draw->rasterizer->line_width <= 3.0)
650
 
      aaline->half_line_width = 1.5f;
 
674
   if (draw->rasterizer->line_width <= 2.2)
 
675
      aaline->half_line_width = 1.1f;
651
676
   else
652
677
      aaline->half_line_width = 0.5f * draw->rasterizer->line_width;
653
678
 
671
696
 
672
697
   /* how many samplers? */
673
698
   /* we'll use sampler/texture[pstip->sampler_unit] for the stipple */
674
 
   num_samplers = MAX2(aaline->num_textures, aaline->num_samplers);
 
699
   num_samplers = MAX2(aaline->num_sampler_views, aaline->num_samplers);
675
700
   num_samplers = MAX2(num_samplers, aaline->fs->sampler_unit + 1);
676
701
 
677
702
   aaline->state.sampler[aaline->fs->sampler_unit] = aaline->sampler_cso;
678
 
   pipe_texture_reference(&aaline->state.texture[aaline->fs->sampler_unit],
679
 
                          aaline->texture);
 
703
   pipe_sampler_view_reference(&aaline->state.sampler_views[aaline->fs->sampler_unit],
 
704
                               aaline->sampler_view);
680
705
 
681
706
   draw->suspend_flushing = TRUE;
682
707
   aaline->driver_bind_sampler_states(pipe, num_samplers, aaline->state.sampler);
683
 
   aaline->driver_set_sampler_textures(pipe, num_samplers, aaline->state.texture);
 
708
   aaline->driver_set_sampler_views(pipe, num_samplers, aaline->state.sampler_views);
684
709
 
685
710
   /* Disable triangle culling, stippling, unfilled mode etc. */
686
711
   r = draw_get_rasterizer_no_cull(draw, rast->scissor, rast->flatshade);
709
734
   aaline->driver_bind_fs_state(pipe, aaline->fs->driver_fs);
710
735
   aaline->driver_bind_sampler_states(pipe, aaline->num_samplers,
711
736
                                      aaline->state.sampler);
712
 
   aaline->driver_set_sampler_textures(pipe, aaline->num_textures,
713
 
                                       aaline->state.texture);
 
737
   aaline->driver_set_sampler_views(pipe,
 
738
                                    aaline->num_sampler_views,
 
739
                                    aaline->state.sampler_views);
714
740
 
715
741
   /* restore original rasterizer state */
716
742
   if (draw->rast_handle) {
738
764
   uint i;
739
765
 
740
766
   for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
741
 
      pipe_texture_reference(&aaline->state.texture[i], NULL);
 
767
      pipe_sampler_view_reference(&aaline->state.sampler_views[i], NULL);
742
768
   }
743
769
 
744
770
   if (aaline->sampler_cso)
745
771
      pipe->delete_sampler_state(pipe, aaline->sampler_cso);
746
772
 
747
773
   if (aaline->texture)
748
 
      pipe_texture_reference(&aaline->texture, NULL);
 
774
      pipe_resource_reference(&aaline->texture, NULL);
 
775
 
 
776
   if (aaline->sampler_view) {
 
777
      pipe_sampler_view_reference(&aaline->sampler_view, NULL);
 
778
   }
749
779
 
750
780
   draw_free_temp_verts( stage );
751
781
 
760
790
   if (aaline == NULL)
761
791
      return NULL;
762
792
 
763
 
   if (!draw_alloc_temp_verts( &aaline->stage, 8 ))
764
 
      goto fail;
765
 
 
766
793
   aaline->stage.draw = draw;
767
794
   aaline->stage.name = "aaline";
768
795
   aaline->stage.next = NULL;
773
800
   aaline->stage.reset_stipple_counter = aaline_reset_stipple_counter;
774
801
   aaline->stage.destroy = aaline_destroy;
775
802
 
 
803
   if (!draw_alloc_temp_verts( &aaline->stage, 8 ))
 
804
      goto fail;
 
805
 
776
806
   return aaline;
777
807
 
778
808
 fail:
779
809
   if (aaline)
780
 
      aaline_destroy(&aaline->stage);
 
810
      aaline->stage.destroy(&aaline->stage);
781
811
 
782
812
   return NULL;
783
813
}
859
889
 
860
890
 
861
891
static void
862
 
aaline_set_sampler_textures(struct pipe_context *pipe,
863
 
                            unsigned num, struct pipe_texture **texture)
 
892
aaline_set_sampler_views(struct pipe_context *pipe,
 
893
                         unsigned num,
 
894
                         struct pipe_sampler_view **views)
864
895
{
865
896
   struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
866
897
   uint i;
867
898
 
868
899
   /* save current */
869
900
   for (i = 0; i < num; i++) {
870
 
      pipe_texture_reference(&aaline->state.texture[i], texture[i]);
 
901
      pipe_sampler_view_reference(&aaline->state.sampler_views[i], views[i]);
871
902
   }
872
903
   for ( ; i < PIPE_MAX_SAMPLERS; i++) {
873
 
      pipe_texture_reference(&aaline->state.texture[i], NULL);
 
904
      pipe_sampler_view_reference(&aaline->state.sampler_views[i], NULL);
874
905
   }
875
 
   aaline->num_textures = num;
 
906
   aaline->num_sampler_views = num;
876
907
 
877
908
   /* pass-through */
878
 
   aaline->driver_set_sampler_textures(pipe, num, texture);
 
909
   aaline->driver_set_sampler_views(pipe, num, views);
879
910
}
880
911
 
881
912
 
911
942
   aaline->driver_delete_fs_state = pipe->delete_fs_state;
912
943
 
913
944
   aaline->driver_bind_sampler_states = pipe->bind_fragment_sampler_states;
914
 
   aaline->driver_set_sampler_textures = pipe->set_fragment_sampler_textures;
 
945
   aaline->driver_set_sampler_views = pipe->set_fragment_sampler_views;
915
946
 
916
947
   /* override the driver's functions */
917
948
   pipe->create_fs_state = aaline_create_fs_state;
919
950
   pipe->delete_fs_state = aaline_delete_fs_state;
920
951
 
921
952
   pipe->bind_fragment_sampler_states = aaline_bind_sampler_states;
922
 
   pipe->set_fragment_sampler_textures = aaline_set_sampler_textures;
 
953
   pipe->set_fragment_sampler_views = aaline_set_sampler_views;
923
954
   
924
955
   /* Install once everything is known to be OK:
925
956
    */