Merge branch 'gallium-edgeflags'
authorRoland Scheidegger <sroland@vmware.com>
Tue, 22 Dec 2009 19:54:26 +0000 (20:54 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 22 Dec 2009 19:54:26 +0000 (20:54 +0100)
Conflicts:
src/mesa/state_tracker/st_draw.c

53 files changed:
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_context.h
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pt.c
src/gallium/auxiliary/draw/draw_pt.h
src/gallium/auxiliary/draw/draw_pt_fetch.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
src/gallium/auxiliary/draw/draw_pt_post_vs.c
src/gallium/auxiliary/draw/draw_vs.c
src/gallium/auxiliary/draw/draw_vs.h
src/gallium/auxiliary/tgsi/tgsi_dump.c
src/gallium/auxiliary/tgsi/tgsi_scan.c
src/gallium/auxiliary/tgsi/tgsi_scan.h
src/gallium/drivers/cell/ppu/cell_draw_arrays.c
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/identity/id_context.c
src/gallium/drivers/llvmpipe/lp_context.c
src/gallium/drivers/llvmpipe/lp_draw_arrays.c
src/gallium/drivers/llvmpipe/lp_state.h
src/gallium/drivers/nv04/nv04_context.c
src/gallium/drivers/nv10/nv10_context.c
src/gallium/drivers/nv20/nv20_context.c
src/gallium/drivers/nv20/nv20_vertprog.c
src/gallium/drivers/nv30/nv30_context.h
src/gallium/drivers/nv30/nv30_state.c
src/gallium/drivers/nv30/nv30_vbo.c
src/gallium/drivers/nv30/nv30_vertprog.c
src/gallium/drivers/nv40/nv40_context.h
src/gallium/drivers/nv40/nv40_state.c
src/gallium/drivers/nv40/nv40_state_emit.c
src/gallium/drivers/nv40/nv40_vbo.c
src/gallium/drivers/nv40/nv40_vertprog.c
src/gallium/drivers/nv50/nv50_context.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_vs.c
src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_draw_arrays.c
src/gallium/drivers/softpipe/sp_state.h
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_pipe_vertex.c
src/gallium/drivers/svga/svga_state_need_swtnl.c
src/gallium/drivers/svga/svga_swtnl_state.c
src/gallium/drivers/trace/tr_context.c
src/gallium/include/pipe/p_context.h
src/gallium/include/pipe/p_shader_tokens.h
src/gallium/state_trackers/python/retrace/interpreter.py
src/mesa/state_tracker/st_atom_shader.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_draw.c
src/mesa/state_tracker/st_mesa_to_tgsi.c
src/mesa/state_tracker/st_mesa_to_tgsi.h
src/mesa/state_tracker/st_program.c
src/mesa/state_tracker/st_program.h

index a4f1fcddc1a0cd6f9de25be4bd0c21c791f5da4e..cc5f7f01059f53b19f381725b5541bc695c008c5 100644 (file)
@@ -366,13 +366,6 @@ void draw_set_render( struct draw_context *draw,
    draw->render = render;
 }
 
-void draw_set_edgeflags( struct draw_context *draw,
-                         const unsigned *edgeflag )
-{
-   draw->pt.user.edgeflag = edgeflag;
-}
-
-
 
 
 /**
index d529e4e9a27f7e3f35c7eb24b0732f6fff1cc722..465b8f10c6c3562d5816beb4d4bf3660444c7a09 100644 (file)
@@ -143,9 +143,6 @@ void draw_set_mapped_constant_buffer(struct draw_context *draw,
                                      const void *buffer,
                                      unsigned size );
 
-void draw_set_edgeflags( struct draw_context *draw,
-                         const unsigned *edgeflag );
-
 
 /***********************************************************************
  * draw_prim.c 
index 41fcb16a0a5a1df71c3de27bbafaec358fd5b61c..3850cede1e87676cf94cc94a959498e9da56e59d 100644 (file)
@@ -142,8 +142,6 @@ struct draw_context
 
       /* user-space vertex data, buffers */
       struct {
-         const unsigned *edgeflag;
-
          /** vertex element/index buffer (ex: glDrawElements) */
          const void *elts;
          /** bytes per index (0, 1, 2 or 4) */
@@ -184,6 +182,7 @@ struct draw_context
       struct draw_vertex_shader *vertex_shader;
       uint num_vs_outputs;  /**< convenience, from vertex_shader */
       uint position_output;
+      uint edgeflag_output;
 
       /** TGSI program interpreter runtime state */
       struct tgsi_exec_machine *machine;
index 4865a2d85421cc28f74fc753629bce7db1503d8c..2801dbafe4735b44246d406b310492b0bb190110 100644 (file)
@@ -314,12 +314,3 @@ draw_arrays(struct draw_context *draw, unsigned prim,
    /* drawing done here: */
    draw_pt_arrays(draw, prim, start, count);
 }
-
-boolean draw_pt_get_edgeflag( struct draw_context *draw,
-                              unsigned idx )
-{
-   if (draw->pt.user.edgeflag)
-      return (draw->pt.user.edgeflag[idx/32] & (1 << (idx%32))) != 0;
-   else
-      return 1;
-}
index 7a17a9fb6b2818013966b6b13c7a78be0849a6a8..20edf7a227ef32f4b8673954ec51b75f9447be3c 100644 (file)
@@ -149,11 +149,6 @@ struct draw_pt_middle_end *draw_pt_middle_fse( struct draw_context *draw );
 struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit(struct draw_context *draw);
 
 
-/* More helpers:
- */
-boolean draw_pt_get_edgeflag( struct draw_context *draw,
-                              unsigned idx );
-
 
 /*******************************************************************************
  * HW vertex emit:
@@ -217,7 +212,8 @@ boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
 void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
                              boolean bypass_clipping,
                              boolean bypass_viewport,
-                             boolean opengl );
+                             boolean opengl,
+                             boolean need_edgeflags );
 
 struct pt_post_vs *draw_pt_post_vs_create( struct draw_context *draw );
 
index 65c3a34c3474a664fbac65042117800174eda9db..305bfef4352b002c60aa06879878d697e20b33b8 100644 (file)
@@ -42,11 +42,11 @@ struct pt_fetch {
    struct translate *translate;
 
    unsigned vertex_size;
-   boolean need_edgeflags;
 
    struct translate_cache *cache;
 };
 
+
 /* Perform the fetch from API vertex elements & vertex buffers, to a
  * contiguous set of float[4] attributes as required for the
  * vertex_shader->run_linear() method.
@@ -120,7 +120,12 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
       fetch->translate = translate_cache_find(fetch->cache, &key);
 
       {
-         static struct vertex_header vh = { 0, 1, 0, UNDEFINED_VERTEX_ID, { .0f, .0f, .0f, .0f } };
+         static struct vertex_header vh = { 0,
+                                            1,
+                                            0,
+                                            UNDEFINED_VERTEX_ID,
+                                            { .0f, .0f, .0f, .0f } };
+
         fetch->translate->set_buffer(fetch->translate,
                                      draw->pt.nr_vertex_buffers,
                                      &vh,
@@ -128,9 +133,6 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
       }
    }
 
-   fetch->need_edgeflags = ((draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
-                             draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL) &&
-                            draw->pt.user.edgeflag);
 }
 
 
@@ -158,17 +160,6 @@ void draw_pt_fetch_run( struct pt_fetch *fetch,
                        count,
                        verts );
 
-   /* Edgeflags are hard to fit into a translate program, populate
-    * them separately if required.  In the setup above they are
-    * defaulted to one, so only need this if there is reason to change
-    * that default:
-    */
-   if (fetch->need_edgeflags) {
-      for (i = 0; i < count; i++) {
-         struct vertex_header *vh = (struct vertex_header *)(verts + i * fetch->vertex_size);
-         vh->edgeflag = draw_pt_get_edgeflag( draw, elts[i] );
-      }
-   }
 }
 
 
@@ -193,18 +184,6 @@ void draw_pt_fetch_run_linear( struct pt_fetch *fetch,
                    start,
                    count,
                    verts );
-
-   /* Edgeflags are hard to fit into a translate program, populate
-    * them separately if required.  In the setup above they are
-    * defaulted to one, so only need this if there is reason to change
-    * that default:
-    */
-   if (fetch->need_edgeflags) {
-      for (i = 0; i < count; i++) {
-         struct vertex_header *vh = (struct vertex_header *)(verts + i * fetch->vertex_size);
-         vh->edgeflag = draw_pt_get_edgeflag( draw, start + i );
-      }
-   }
 }
 
 
index df6c265b7ec9026a95cd6383b1d70adb242efcbb..932113783d09e57b58ede769e24c3fc600f279c7 100644 (file)
@@ -85,9 +85,9 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
    draw_pt_post_vs_prepare( fpme->post_vs,
                            (boolean)draw->bypass_clipping,
                            (boolean)(draw->identity_viewport ||
-                                      draw->rasterizer->bypass_vs_clip_and_viewport),
-                           (boolean)draw->rasterizer->gl_rasterization_rules );
-                           
+                           draw->rasterizer->bypass_vs_clip_and_viewport),
+                           (boolean)draw->rasterizer->gl_rasterization_rules,
+                           (draw->vs.edgeflag_output ? true : false) );    
 
    if (!(opt & PT_PIPELINE)) {
       draw_pt_emit_prepare( fpme->emit, 
index 6c1cb48e8b82202da1638d2a7a9cdf9cbd40c247..9dfb47837e07aa440e709dca5a1092612174724b 100644 (file)
@@ -147,6 +147,39 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs,
 
 
 
+/* As above plus edgeflags
+ */
+static boolean 
+post_vs_cliptest_viewport_gl_edgeflag(struct pt_post_vs *pvs,
+                                      struct vertex_header *vertices,
+                                      unsigned count,
+                                      unsigned stride )
+{
+   unsigned j;
+   boolean needpipe;
+
+   needpipe = post_vs_cliptest_viewport_gl( pvs, vertices, count, stride);
+
+   /* If present, copy edgeflag VS output into vertex header.
+    * Otherwise, leave header as is.
+    */
+   if (pvs->draw->vs.edgeflag_output) {
+      struct vertex_header *out = vertices;
+      int ef = pvs->draw->vs.edgeflag_output;
+
+      for (j = 0; j < count; j++) {
+         const float *edgeflag = out->data[ef];
+         out->edgeflag = !(edgeflag[0] != 1.0f);
+         needpipe |= !out->edgeflag;
+         out = (struct vertex_header *)( (char *)out + stride );
+      }
+   }
+   return needpipe;
+}
+
+
+
+
 /* If bypass_clipping is set, skip cliptest and rhw divide.
  */
 static boolean post_vs_viewport( struct pt_post_vs *pvs,
@@ -201,17 +234,29 @@ boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
 void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
                              boolean bypass_clipping,
                              boolean bypass_viewport,
-                             boolean opengl )
+                             boolean opengl,
+                             boolean need_edgeflags )
 {
-   if (bypass_clipping) {
-      if (bypass_viewport)
-        pvs->run = post_vs_none;
-      else
-        pvs->run = post_vs_viewport;
+   if (!need_edgeflags) {
+      if (bypass_clipping) {
+         if (bypass_viewport)
+            pvs->run = post_vs_none;
+         else
+            pvs->run = post_vs_viewport;
+      }
+      else {
+         /* if (opengl) */
+         pvs->run = post_vs_cliptest_viewport_gl;
+      }
    }
    else {
-      /* if (opengl) */
-      pvs->run = post_vs_cliptest_viewport_gl;
+      /* If we need to copy edgeflags to the vertex header, it should
+       * mean we're running the primitive pipeline.  Hence the bypass
+       * flags should be false.
+       */
+      assert(!bypass_clipping);
+      assert(!bypass_viewport);
+      pvs->run = post_vs_cliptest_viewport_gl_edgeflag;
    }
 }
 
index 790e89ed820af7e7ab8d3c036b8f242a2c31931c..3553689532687ffaa326a5c93863d91f1e7f7c35 100644 (file)
@@ -101,6 +101,9 @@ draw_create_vertex_shader(struct draw_context *draw,
          if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_POSITION &&
              vs->info.output_semantic_index[i] == 0)
             vs->position_output = i;
+         else if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_EDGEFLAG &&
+             vs->info.output_semantic_index[i] == 0)
+            vs->edgeflag_output = i;
       }
    }
 
@@ -120,6 +123,7 @@ draw_bind_vertex_shader(struct draw_context *draw,
       draw->vs.vertex_shader = dvs;
       draw->vs.num_vs_outputs = dvs->info.num_outputs;
       draw->vs.position_output = dvs->position_output;
+      draw->vs.edgeflag_output = dvs->edgeflag_output;
       dvs->prepare( dvs, draw );
    }
    else {
index 89ae158751a931edc5b3c49ed50ebf0dcb3d0b38..e3b807ebd0e1df50ffdf6fa3c4aec523fb9e0b68 100644 (file)
@@ -107,6 +107,7 @@ struct draw_vertex_shader {
 
    struct tgsi_shader_info info;
    unsigned position_output;
+   unsigned edgeflag_output;
 
    /* Extracted from shader:
     */
index ba1357697d1041da2f4ce643804ef41b94caa59c..5e7e5d2ff9c9b31489385a68a3489ad15f82e21f 100644 (file)
@@ -121,7 +121,8 @@ static const char *semantic_names[] =
    "PSIZE",
    "GENERIC",
    "NORMAL",
-   "FACE"
+   "FACE",
+   "EDGEFLAG"
 };
 
 static const char *immediate_type_names[] =
index 5f5c95bfbdb41c2a81f5bed85f0a9b2e9302f8bd..0f48b0dc3a113ff53ad3e5121bd5f5d91f0dd81b 100644 (file)
@@ -139,15 +139,19 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
                   info->output_semantic_name[reg] = (ubyte)fulldecl->Semantic.Name;
                   info->output_semantic_index[reg] = (ubyte)fulldecl->Semantic.Index;
                   info->num_outputs++;
-               }
 
-               /* special case */
-               if (procType == TGSI_PROCESSOR_FRAGMENT &&
-                   file == TGSI_FILE_OUTPUT &&
-                   fulldecl->Semantic.Name == TGSI_SEMANTIC_POSITION) {
-                  info->writes_z = TRUE;
+                  /* extra info for special outputs */
+                  if (procType == TGSI_PROCESSOR_FRAGMENT &&
+                      fulldecl->Semantic.Name == TGSI_SEMANTIC_POSITION) {
+                     info->writes_z = TRUE;
+                  }
+                  if (procType == TGSI_PROCESSOR_VERTEX &&
+                      fulldecl->Semantic.Name == TGSI_SEMANTIC_EDGEFLAG) {
+                     info->writes_edgeflag = TRUE;
+                  }
                }
-            }
+
+             }
          }
          break;
 
index a1e8a4f6bb7c7072c9f9fc636acd099f66177be6..dae5376c24aae63dbebcab6f9d6d2e36adc75ca7 100644 (file)
@@ -57,6 +57,7 @@ struct tgsi_shader_info
    uint opcode_count[TGSI_OPCODE_LAST];  /**< opcode histogram */
 
    boolean writes_z;  /**< does fragment shader write Z value? */
+   boolean writes_edgeflag; /**< vertex shader outputs edgeflag */
    boolean uses_kill;  /**< KIL or KILP instruction used? */
    boolean uses_fogcoord; /**< fragment shader uses fog coord? */
    boolean uses_frontfacing; /**< fragment shader uses front/back-face flag? */
index 644496db40cd8bc6a94682e051e4cf7a9e850f67..5cc1d4ddf81eaf54fed5550e1325a889faec34f5 100644 (file)
@@ -171,21 +171,11 @@ cell_draw_arrays(struct pipe_context *pipe, unsigned mode,
 }
 
 
-static void
-cell_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags)
-{
-   struct cell_context *cell = cell_context(pipe);
-   draw_set_edgeflags(cell->draw, edgeflags);
-}
-
-
-
 void
 cell_init_draw_functions(struct cell_context *cell)
 {
    cell->pipe.draw_arrays = cell_draw_arrays;
    cell->pipe.draw_elements = cell_draw_elements;
    cell->pipe.draw_range_elements = cell_draw_range_elements;
-   cell->pipe.set_edgeflags = cell_set_edgeflags;
 }
 
index 9103847f1c53681ee80576f9241b40f67e18ccb9..e580b6c0f7fb6a0c2ecb62adbd2b7272dfee77f8 100644 (file)
@@ -752,16 +752,9 @@ static void i915_set_vertex_elements(struct pipe_context *pipe,
 }
 
 
-static void i915_set_edgeflags(struct pipe_context *pipe,
-                               const unsigned *bitfield)
-{
-   /* TODO do something here */
-}
-
 void
 i915_init_state_functions( struct i915_context *i915 )
 {
-   i915->base.set_edgeflags = i915_set_edgeflags;
    i915->base.create_blend_state = i915_create_blend_state;
    i915->base.bind_blend_state = i915_bind_blend_state;
    i915->base.delete_blend_state = i915_delete_blend_state;
index bedab56f59ebe144bb3df76367db5cceb2b189b7..bdbaae59875b3e94d4ca6ded65433c541fd47ce0 100644 (file)
@@ -45,17 +45,6 @@ identity_destroy(struct pipe_context *_pipe)
    free(id_pipe);
 }
 
-static void
-identity_set_edgeflags(struct pipe_context *_pipe,
-                       const unsigned *bitfield)
-{
-   struct identity_context *id_pipe = identity_context(_pipe);
-   struct pipe_context *pipe = id_pipe->pipe;
-
-   pipe->set_edgeflags(pipe,
-                       bitfield);
-}
-
 static boolean
 identity_draw_arrays(struct pipe_context *_pipe,
                      unsigned prim,
@@ -707,7 +696,6 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    id_pipe->base.draw = NULL;
 
    id_pipe->base.destroy = identity_destroy;
-   id_pipe->base.set_edgeflags = identity_set_edgeflags;
    id_pipe->base.draw_arrays = identity_draw_arrays;
    id_pipe->base.draw_elements = identity_draw_elements;
    id_pipe->base.draw_range_elements = identity_draw_range_elements;
index 679e244274330e6da4c15e52863ac141876d3e22..001311e7031a11bbf63d301ab2360fd1ffc66342 100644 (file)
@@ -226,8 +226,6 @@ llvmpipe_create( struct pipe_screen *screen )
    llvmpipe->pipe.draw_arrays = llvmpipe_draw_arrays;
    llvmpipe->pipe.draw_elements = llvmpipe_draw_elements;
    llvmpipe->pipe.draw_range_elements = llvmpipe_draw_range_elements;
-   llvmpipe->pipe.set_edgeflags = llvmpipe_set_edgeflags;
-
 
    llvmpipe->pipe.clear = llvmpipe_clear;
    llvmpipe->pipe.flush = llvmpipe_flush;
index 0aa13a1fc679d282e7606a42007d36855a7cf005..2299566c665ea78d21da369f57a6665b9e95055c 100644 (file)
@@ -133,10 +133,3 @@ llvmpipe_draw_elements(struct pipe_context *pipe,
                                         mode, start, count );
 }
 
-
-void
-llvmpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags)
-{
-   struct llvmpipe_context *lp = llvmpipe_context(pipe);
-   draw_set_edgeflags(lp->draw, edgeflags);
-}
index d1c74ab07b510cd8b3f48adc98b4ee101185672e..5cee7bf74b6aa5a1d4d6053286bc0b818a4b7a81 100644 (file)
@@ -212,10 +212,6 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe,
                              unsigned max_index,
                              unsigned mode, unsigned start, unsigned count);
 
-void
-llvmpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags);
-
-
 void
 llvmpipe_map_transfers(struct llvmpipe_context *lp);
 
index 10d984ace9b6a556d3be85a1cd19932e3a6b7123..4b33636b2eb5b258e474bdbd20191d7740b63153 100644 (file)
@@ -27,11 +27,6 @@ nv04_destroy(struct pipe_context *pipe)
        FREE(nv04);
 }
 
-static void
-nv04_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
-{
-}
-
 static boolean
 nv04_init_hwctx(struct nv04_context *nv04)
 {
@@ -83,7 +78,6 @@ nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
        nv04->pipe.winsys = ws;
        nv04->pipe.screen = pscreen;
        nv04->pipe.destroy = nv04_destroy;
-       nv04->pipe.set_edgeflags = nv04_set_edgeflags;
        nv04->pipe.draw_arrays = nv04_draw_arrays;
        nv04->pipe.draw_elements = nv04_draw_elements;
        nv04->pipe.clear = nv04_clear;
index 65a22b175e11ee373970c984aacf131cb91c6ede..0dadeb03dd3a752993c615fd460c51c3dfc4c9ea 100644 (file)
@@ -252,11 +252,6 @@ static void nv10_init_hwctx(struct nv10_context *nv10)
        FIRE_RING (NULL);
 }
 
-static void
-nv10_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
-{
-}
-
 struct pipe_context *
 nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
 {
@@ -276,7 +271,6 @@ nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
        nv10->pipe.winsys = ws;
        nv10->pipe.screen = pscreen;
        nv10->pipe.destroy = nv10_destroy;
-       nv10->pipe.set_edgeflags = nv10_set_edgeflags;
        nv10->pipe.draw_arrays = nv10_draw_arrays;
        nv10->pipe.draw_elements = nv10_draw_elements;
        nv10->pipe.clear = nv10_clear;
index 276db8b57b695886cd74373edd5eb16fc1c275ae..6a147a4159cebc38685a1d1389871e92901dba01 100644 (file)
@@ -375,11 +375,6 @@ static void nv20_init_hwctx(struct nv20_context *nv20)
        FIRE_RING (NULL);
 }
 
-static void
-nv20_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
-{
-}
-
 struct pipe_context *
 nv20_create(struct pipe_screen *pscreen, unsigned pctx_id)
 {
@@ -399,7 +394,6 @@ nv20_create(struct pipe_screen *pscreen, unsigned pctx_id)
        nv20->pipe.winsys = ws;
        nv20->pipe.screen = pscreen;
        nv20->pipe.destroy = nv20_destroy;
-       nv20->pipe.set_edgeflags = nv20_set_edgeflags;
        nv20->pipe.draw_arrays = nv20_draw_arrays;
        nv20->pipe.draw_elements = nv20_draw_elements;
        nv20->pipe.clear = nv20_clear;
index 9e8aab9754a19e55ddf16cfcf74adf7e21377f50..7886c2af7e62d75d66deb3d61824d013358c7ddf 100644 (file)
@@ -530,6 +530,9 @@ nv20_vertprog_parse_decl_output(struct nv20_vpc *vpc,
                        return FALSE;
                }
                break;
+       case TGSI_SEMANTIC_EDGEFLAG:
+               NOUVEAU_ERR("cannot handle edgeflag output\n");
+               return FALSE;
        default:
                NOUVEAU_ERR("bad output semantic\n");
                return FALSE;
index 6f44b1c7fe1a42cc07c73c459411f58325c0cfff..864ddaeb598eefb937c2bc7e1ddb482ecba99098 100644 (file)
@@ -144,7 +144,6 @@ struct nv30_context {
        unsigned vtxbuf_nr;
        struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
        unsigned vtxelt_nr;
-       const unsigned *edgeflags;
 };
 
 static INLINE struct nv30_context *
index 3f802d924166383db5cfc786a4a4e90d70c513e6..e6321b480f6f55cc96d3082da5d40493404cf3a3 100644 (file)
@@ -672,16 +672,6 @@ nv30_set_vertex_elements(struct pipe_context *pipe, unsigned count,
        /*nv30->draw_dirty |= NV30_NEW_ARRAYS;*/
 }
 
-static void
-nv30_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
-{
-       struct nv30_context *nv30 = nv30_context(pipe);
-
-       nv30->edgeflags = bitfield;
-       nv30->dirty |= NV30_NEW_ARRAYS;
-       /*nv30->draw_dirty |= NV30_NEW_ARRAYS;*/
-}
-
 void
 nv30_init_state_functions(struct nv30_context *nv30)
 {
@@ -721,7 +711,6 @@ nv30_init_state_functions(struct nv30_context *nv30)
        nv30->pipe.set_scissor_state = nv30_set_scissor_state;
        nv30->pipe.set_viewport_state = nv30_set_viewport_state;
 
-       nv30->pipe.set_edgeflags = nv30_set_edgeflags;
        nv30->pipe.set_vertex_buffers = nv30_set_vertex_buffers;
        nv30->pipe.set_vertex_elements = nv30_set_vertex_elements;
 }
index 189656ec817aadb637c83b47fe31614400ab3d45..e32b8141af85022abd998a1f89dbb580203684c9 100644 (file)
@@ -485,11 +485,6 @@ nv30_vbo_validate(struct nv30_context *nv30)
        unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
        int hw;
 
-       if (nv30->edgeflags) {
-               /*nv30->fallback_swtnl |= NV30_NEW_ARRAYS;*/
-               return FALSE;
-       }
-
        vtxbuf = so_new(20, 18);
        so_method(vtxbuf, rankine, NV34TCL_VTXBUF_ADDRESS(0), nv30->vtxelt_nr);
        vtxfmt = so_new(17, 0);
index 36ac8299f0c5f576dd20a6d181554757e6828700..5d6098462295f3b5cb52f3b75c8b895cb18c2fed 100644 (file)
@@ -530,6 +530,9 @@ nv30_vertprog_parse_decl_output(struct nv30_vpc *vpc,
                        return FALSE;
                }
                break;
+       case TGSI_SEMANTIC_EDGEFLAG:
+               NOUVEAU_ERR("cannot handle edgeflag output\n");
+               return FALSE;
        default:
                NOUVEAU_ERR("bad output semantic\n");
                return FALSE;
index cf33b64a86dbb91b058bafce61522e0ffcbbbe54..83fcf1785d9f0187655d415b8a3914701df00f3f 100644 (file)
@@ -159,7 +159,6 @@ struct nv40_context {
        unsigned vtxbuf_nr;
        struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
        unsigned vtxelt_nr;
-       const unsigned *edgeflags;
 };
 
 static INLINE struct nv40_context *
index bc34e32a4b9a2c07474a8ee1d3214af5f9bd0255..ed55d29affde8565541fcb077400424a98a2418f 100644 (file)
@@ -687,16 +687,6 @@ nv40_set_vertex_elements(struct pipe_context *pipe, unsigned count,
        nv40->draw_dirty |= NV40_NEW_ARRAYS;
 }
 
-static void
-nv40_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
-{
-       struct nv40_context *nv40 = nv40_context(pipe);
-
-       nv40->edgeflags = bitfield;
-       nv40->dirty |= NV40_NEW_ARRAYS;
-       nv40->draw_dirty |= NV40_NEW_ARRAYS;
-}
-
 void
 nv40_init_state_functions(struct nv40_context *nv40)
 {
@@ -736,7 +726,6 @@ nv40_init_state_functions(struct nv40_context *nv40)
        nv40->pipe.set_scissor_state = nv40_set_scissor_state;
        nv40->pipe.set_viewport_state = nv40_set_viewport_state;
 
-       nv40->pipe.set_edgeflags = nv40_set_edgeflags;
        nv40->pipe.set_vertex_buffers = nv40_set_vertex_buffers;
        nv40->pipe.set_vertex_elements = nv40_set_vertex_elements;
 }
index ba0fbcb26a995585914ea7dafd4679e823f1a1e1..789ed16126a330499100a580bcdfe57284ef5611 100644 (file)
@@ -168,7 +168,6 @@ nv40_state_validate_swtnl(struct nv40_context *nv40)
                draw_set_viewport_state(draw, &nv40->viewport);
 
        if (nv40->draw_dirty & NV40_NEW_ARRAYS) {
-               draw_set_edgeflags(draw, nv40->edgeflags);
                draw_set_vertex_buffers(draw, nv40->vtxbuf_nr, nv40->vtxbuf);
                draw_set_vertex_elements(draw, nv40->vtxelt_nr, nv40->vtxelt);  
        }
index b2753b8e2e052a655a7f89c28e5d3243ec5c84ed..af3fcf6a3487adc109bb7bc7e3cd8596afd03802 100644 (file)
@@ -484,11 +484,6 @@ nv40_vbo_validate(struct nv40_context *nv40)
        unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
        int hw;
 
-       if (nv40->edgeflags) {
-               nv40->fallback_swtnl |= NV40_NEW_ARRAYS;
-               return FALSE;
-       }
-
        vtxbuf = so_new(20, 18);
        so_method(vtxbuf, curie, NV40TCL_VTXBUF_ADDRESS(0), nv40->vtxelt_nr);
        vtxfmt = so_new(17, 0);
index 55835ee644c3bdfd55503f39c57411f0e2afebe5..d9fc31006f5aff7562c4204a828a3efa4e2cb07f 100644 (file)
@@ -621,6 +621,10 @@ nv40_vertprog_parse_decl_output(struct nv40_vpc *vpc,
                        return FALSE;
                }
                break;
+       case TGSI_SEMANTIC_EDGEFLAG:
+               /* not really an error just a fallback */
+               NOUVEAU_ERR("cannot handle edgeflag output\n");
+               return FALSE;
        default:
                NOUVEAU_ERR("bad output semantic\n");
                return FALSE;
index 219e7a7862321f2ede5eeabbcbce52785b3d4b30..d21b80eab8d476ea14679673d180bc5b76d7176e 100644 (file)
@@ -48,11 +48,6 @@ nv50_destroy(struct pipe_context *pipe)
 }
 
 
-static void
-nv50_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
-{
-}
-
 struct pipe_context *
 nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
 {
@@ -71,7 +66,6 @@ nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
 
        nv50->pipe.destroy = nv50_destroy;
 
-       nv50->pipe.set_edgeflags = nv50_set_edgeflags;
        nv50->pipe.draw_arrays = nv50_draw_arrays;
        nv50->pipe.draw_elements = nv50_draw_elements;
        nv50->pipe.clear = nv50_clear;
index 8bcd6c5060808950c82843e456bf1cb22468989b..49072462ec3ff0e27ddd2d7a3fd80a9099ecdd4f 100644 (file)
@@ -283,13 +283,6 @@ static void r300_delete_dsa_state(struct pipe_context* pipe,
     FREE(state);
 }
 
-static void r300_set_edgeflags(struct pipe_context* pipe,
-                               const unsigned* bitfield)
-{
-    /* XXX you know it's bad when i915 has this blank too */
-    /* XXX and even worse, I have no idea WTF the bitfield is */
-}
-
 static void r300_set_scissor_regs(const struct pipe_scissor_state* state,
                                   struct r300_scissor_regs *scissor,
                                   boolean is_r500)
@@ -850,8 +843,6 @@ void r300_init_state_functions(struct r300_context* r300)
     r300->context.bind_depth_stencil_alpha_state = r300_bind_dsa_state;
     r300->context.delete_depth_stencil_alpha_state = r300_delete_dsa_state;
 
-    r300->context.set_edgeflags = r300_set_edgeflags;
-
     r300->context.set_framebuffer_state = r300_set_framebuffer_state;
 
     r300->context.create_fs_state = r300_create_fs_state;
index fa207c939ca8a65b4b470808c878442eb0da8456..c4ed0d712f9cb84c6e3d15b5ed33f1207f27ceee 100644 (file)
@@ -77,6 +77,11 @@ static void r300_shader_read_vs_outputs(
                 vs_outputs->fog = i;
                 break;
 
+            case TGSI_SEMANTIC_EDGEFLAG:
+                assert(index == 0);
+                fprintf(stderr, "r300 VP: cannot handle edgeflag output\n");
+                assert(0);
+                break;
             default:
                 assert(0);
         }
index f8bf3e9974e0a88a08490b0cf6fb740a137653dd..2a33587b5a7fa4e9ee64a1c0a7ad0f884123eae3 100644 (file)
@@ -238,8 +238,6 @@ softpipe_create( struct pipe_screen *screen )
    softpipe->pipe.draw_arrays = softpipe_draw_arrays;
    softpipe->pipe.draw_elements = softpipe_draw_elements;
    softpipe->pipe.draw_range_elements = softpipe_draw_range_elements;
-   softpipe->pipe.set_edgeflags = softpipe_set_edgeflags;
-
 
    softpipe->pipe.clear = softpipe_clear;
    softpipe->pipe.flush = softpipe_flush;
index d4045816d03ed7a428d8ea6849d057ad84c3b956..518ef8806e5681ff3eebf61b109618bd1e7354d4 100644 (file)
@@ -184,11 +184,3 @@ softpipe_draw_elements(struct pipe_context *pipe,
                                         0, 0xffffffff,
                                         mode, start, count );
 }
-
-
-void
-softpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags)
-{
-   struct softpipe_context *sp = softpipe_context(pipe);
-   draw_set_edgeflags(sp->draw, edgeflags);
-}
index d488fb8710bd3bae17b8f7652e4bbcd8eb1a2d7f..26d5c3fbb2fb0bd3bb3d62c03ffd52dcbfe248e2 100644 (file)
@@ -189,10 +189,6 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
                              unsigned max_index,
                              unsigned mode, unsigned start, unsigned count);
 
-void
-softpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags);
-
-
 void
 softpipe_map_transfers(struct softpipe_context *sp);
 
index 8e7b5b3da11898986b6a4c1324bcd269ac826b7f..0885d9ca74101d3f1872b49772c0ecd22608276f 100644 (file)
@@ -202,8 +202,6 @@ struct svga_state
    struct pipe_clip_state clip;
    struct pipe_viewport_state viewport;
 
-   const unsigned *edgeflags;
-
    unsigned num_samplers;
    unsigned num_textures;
    unsigned num_vertex_elements;
@@ -380,9 +378,8 @@ struct svga_context
 #define SVGA_NEW_NEED_SWTNL          0x400000
 #define SVGA_NEW_FS_RESULT           0x800000
 #define SVGA_NEW_VS_RESULT           0x1000000
-#define SVGA_NEW_EDGEFLAGS           0x2000000
-#define SVGA_NEW_ZERO_STRIDE         0x4000000
-#define SVGA_NEW_TEXTURE_FLAGS       0x8000000
+#define SVGA_NEW_ZERO_STRIDE         0x2000000
+#define SVGA_NEW_TEXTURE_FLAGS       0x4000000
 
 
 
index 28e2787e0d3d77c2f20c57f6ff0c223789524466..42f290d162af4def6327f2fbcb1badcd887cb59b 100644 (file)
@@ -84,18 +84,6 @@ static void svga_set_vertex_elements(struct pipe_context *pipe,
 }
 
 
-static void svga_set_edgeflags(struct pipe_context *pipe,
-                               const unsigned *bitfield)
-{
-   struct svga_context *svga = svga_context(pipe);
-
-   if (bitfield != NULL || svga->curr.edgeflags != NULL) {
-      svga->curr.edgeflags = bitfield;
-      svga->dirty |= SVGA_NEW_EDGEFLAGS;
-   }
-}
-
-
 void svga_cleanup_vertex_state( struct svga_context *svga )
 {
    unsigned i;
@@ -109,7 +97,6 @@ void svga_init_vertex_functions( struct svga_context *svga )
 {
    svga->pipe.set_vertex_buffers = svga_set_vertex_buffers;
    svga->pipe.set_vertex_elements = svga_set_vertex_elements;
-   svga->pipe.set_edgeflags = svga_set_edgeflags;
 }
 
 
index 00201b8091d9bba23b79489e1c24e79d6fb96ccf..3c35a8579f714f0826f33b45472a56ad482b00c0 100644 (file)
@@ -108,6 +108,7 @@ static int update_need_pipeline( struct svga_context *svga,
 {
    
    boolean need_pipeline = FALSE;
+   struct svga_vertex_shader *vs = svga->curr.vs;
 
    /* SVGA_NEW_RAST, SVGA_NEW_REDUCED_PRIMITIVE
     */
@@ -119,11 +120,9 @@ static int update_need_pipeline( struct svga_context *svga,
       need_pipeline = TRUE;
    }
 
-   /* SVGA_NEW_EDGEFLAGS
+   /* EDGEFLAGS
     */
-   if (svga->curr.rast->hw_unfilled != PIPE_POLYGON_MODE_FILL &&
-       svga->curr.reduced_prim == PIPE_PRIM_TRIANGLES && 
-       svga->curr.edgeflags != NULL) {
+    if (vs->base.info.writes_edgeflag) {
       SVGA_DBG(DEBUG_SWTNL, "%s: edgeflags\n", __FUNCTION__);
       need_pipeline = TRUE;
    }
@@ -150,6 +149,7 @@ struct svga_tracked_state svga_update_need_pipeline =
    "need pipeline",
    (SVGA_NEW_RAST |
     SVGA_NEW_CLIP |
+    SVGA_NEW_VS |
     SVGA_NEW_REDUCED_PRIMITIVE),
    update_need_pipeline
 };
index 161631211310298304bfd7ffd13e91f29166062d..25b8c2af3a0a3d5cffff9d74adf2dc7a86d78414 100644 (file)
@@ -120,10 +120,6 @@ static int update_swtnl_draw( struct svga_context *svga,
       draw_set_mrd(svga->swtnl.draw, 
                    svga->curr.depthscale);
 
-   if (dirty & SVGA_NEW_EDGEFLAGS)
-      draw_set_edgeflags( svga->swtnl.draw, 
-                          svga->curr.edgeflags );
-
    return 0;
 }
 
@@ -138,8 +134,7 @@ struct svga_tracked_state svga_update_swtnl_draw =
     SVGA_NEW_VIEWPORT |
     SVGA_NEW_RAST |
     SVGA_NEW_FRAME_BUFFER |
-    SVGA_NEW_REDUCED_PRIMITIVE |
-    SVGA_NEW_EDGEFLAGS),
+    SVGA_NEW_REDUCED_PRIMITIVE),
    update_swtnl_draw
 };
 
index 2f0f063d2de9fdcacdb3f33de9b1a3ce480bf059..80f4874b78050ec48ef34375c31b3987c20da865 100644 (file)
@@ -94,25 +94,6 @@ trace_surface_unwrap(struct trace_context *tr_ctx,
 }
 
 
-static INLINE void
-trace_context_set_edgeflags(struct pipe_context *_pipe,
-                            const unsigned *bitfield)
-{
-   struct trace_context *tr_ctx = trace_context(_pipe);
-   struct pipe_context *pipe = tr_ctx->pipe;
-
-   trace_dump_call_begin("pipe_context", "set_edgeflags");
-
-   trace_dump_arg(ptr, pipe);
-   /* FIXME: we don't know how big this array is */
-   trace_dump_arg(ptr, bitfield);
-
-   pipe->set_edgeflags(pipe, bitfield);
-
-   trace_dump_call_end();
-}
-
-
 static INLINE void
 trace_context_draw_block(struct trace_context *tr_ctx, int flag)
 {
@@ -1298,7 +1279,6 @@ trace_context_create(struct pipe_screen *_screen,
    tr_ctx->base.winsys = _screen->winsys;
    tr_ctx->base.screen = _screen;
    tr_ctx->base.destroy = trace_context_destroy;
-   tr_ctx->base.set_edgeflags = trace_context_set_edgeflags;
    tr_ctx->base.draw_arrays = trace_context_draw_arrays;
    tr_ctx->base.draw_elements = trace_context_draw_elements;
    tr_ctx->base.draw_range_elements = trace_context_draw_range_elements;
index f896001eb12091d3d7035eb908731e42ca4258ab..11bcdc0a24c2ae69992eb129e774eda7ae7774e3 100644 (file)
@@ -57,14 +57,6 @@ struct pipe_context {
 
    void (*destroy)( struct pipe_context * );
 
-   
-   /* Possible interface for setting edgeflags.  These aren't really
-    * vertex elements, so don't fit there.
-    */
-   void (*set_edgeflags)( struct pipe_context *,
-                          const unsigned *bitfield );
-
-
    /**
     * VBO drawing (return false on fallbacks (temporary??))
     */
index 79f3d3f056677e286c73ed9ea9762a49b3cd90d1..5da85bbbc24451b026c3aaf19862030cbec4fd4e 100644 (file)
@@ -129,7 +129,8 @@ struct tgsi_declaration_range
 #define TGSI_SEMANTIC_GENERIC  5
 #define TGSI_SEMANTIC_NORMAL   6
 #define TGSI_SEMANTIC_FACE     7
-#define TGSI_SEMANTIC_COUNT    8 /**< number of semantic values */
+#define TGSI_SEMANTIC_EDGEFLAG 8
+#define TGSI_SEMANTIC_COUNT    9 /**< number of semantic values */
 
 struct tgsi_declaration_semantic
 {
index b32eafe23fb4cd12de0d8a4918484045315696b1..110b3d0ec11a0a05c98090995b2700ce74fa7399 100755 (executable)
@@ -507,10 +507,6 @@ class Context(Object):
             self.real.set_vertex_element(i, elements[i])
         self.real.set_vertex_elements(num_elements)
 
-    def set_edgeflags(self, bitfield):
-        # FIXME
-        pass
-    
     def dump_vertices(self, start, count):
         if not self.interpreter.verbosity(2):
             return
index 09baff875bc1e7f9d58877935a89a52091be18ce..46c8cbb30987596c3269b7c4b39854eb97a9cb36 100644 (file)
@@ -106,7 +106,18 @@ find_translated_vp(struct st_context *st,
    /* Nothing in our key yet.  This will change:
     */
    memset(&key, 0, sizeof key);
-   key.dummy = 0;
+
+   /* When this is true, we will add an extra input to the vertex
+    * shader translation (for edgeflags), an extra output with
+    * edgeflag semantics, and extend the vertex shader to pass through
+    * the input to the output.  We'll need to use similar logic to set
+    * up the extra vertex_element input for edgeflags.
+    * _NEW_POLYGON, ST_NEW_EDGEFLAGS_DATA
+    */
+   key.passthrough_edgeflags = (st->vertdata_edgeflags && (
+                                st->ctx->Polygon.FrontMode != GL_FILL ||
+                                st->ctx->Polygon.BackMode != GL_FILL));
+
 
    /* Do we need to throw away old translations after a change in the
     * GL program string?
@@ -218,8 +229,8 @@ update_vp( struct st_context *st )
 const struct st_tracked_state st_update_vp = {
    "st_update_vp",                                     /* name */
    {                                                   /* dirty */
-      0,                                               /* mesa */
-      ST_NEW_VERTEX_PROGRAM                             /* st */
+      _NEW_POLYGON,                                    /* mesa */
+      ST_NEW_VERTEX_PROGRAM | ST_NEW_EDGEFLAGS_DATA    /* st */
    },
    update_vp                                   /* update */
 };
index b760728658319e556645e317390922a156f1bf74..831909a3f8fb6e07acd56239952cdb2a72eb6e6d 100644 (file)
@@ -55,6 +55,7 @@ struct bitmap_cache;
 #define ST_NEW_FRAGMENT_PROGRAM        0x2
 #define ST_NEW_VERTEX_PROGRAM          0x4
 #define ST_NEW_FRAMEBUFFER             0x8
+#define ST_NEW_EDGEFLAGS_DATA          0x10
 
 
 struct st_state_flags {
@@ -120,6 +121,7 @@ struct st_context
    struct st_state_flags dirty;
 
    GLboolean missing_textures;
+   GLboolean vertdata_edgeflags;
 
    /** Mapping from VERT_RESULT_x to post-transformed vertex slot */
    const GLuint *vertex_result_to_slot;
index ec8092d7e9e78af5c8f79740cab998dc47c7adda..e54f21be6009c7a1051127df9aeb68f1843c7a61 100644 (file)
@@ -217,59 +217,7 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
 }
 
 
-/*
- * If edge flags are needed, setup an bitvector of flags and call
- * pipe->set_edgeflags().
- * XXX memleak: need to free the returned pointer at some point
- */
-static void *
-setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count,
-                const struct gl_client_array *array)
-{
-   struct pipe_context *pipe = ctx->st->pipe;
-
-   if ((primMode == GL_TRIANGLES ||
-        primMode == GL_QUADS ||
-        primMode == GL_POLYGON) &&
-       (ctx->Polygon.FrontMode != GL_FILL ||
-        ctx->Polygon.BackMode != GL_FILL)) {
-      /* need edge flags */
-      GLint i;
-      unsigned *vec;
-      struct st_buffer_object *stobj = st_buffer_object(array->BufferObj);
-      ubyte *map;
-
-      if (!stobj || stobj->Base.Name == 0) {
-         /* edge flags are not in a VBO */
-         return NULL;
-      }
-
-      vec = (unsigned *) _mesa_calloc(sizeof(unsigned) * ((count + 31) / 32));
-      if (!vec)
-         return NULL;
-
-      map = pipe_buffer_map(pipe->screen, stobj->buffer, PIPE_BUFFER_USAGE_CPU_READ);
-      map = ADD_POINTERS(map, array->Ptr);
-
-      for (i = 0; i < count; i++) {
-         if (*((float *) map))
-            vec[i/32] |= 1 << (i % 32);
-
-         map += array->StrideB;
-      }
 
-      pipe_buffer_unmap(pipe->screen, stobj->buffer);
-
-      pipe->set_edgeflags(pipe, vec);
-
-      return vec;
-   }
-   else {
-      /* edge flags not needed */
-      pipe->set_edgeflags(pipe, NULL);
-      return NULL;
-   }
-}
 
 
 /**
@@ -279,6 +227,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count,
  */
 static GLboolean
 is_interleaved_arrays(const struct st_vertex_program *vp,
+                      const struct st_vp_varient *vpv,
                       const struct gl_client_array **arrays,
                       GLboolean *userSpace)
 {
@@ -288,7 +237,7 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
    GLuint num_client_arrays = 0;
    const GLubyte *client_addr = NULL;
 
-   for (attr = 0; attr < vp->num_inputs; attr++) {
+   for (attr = 0; attr < vpv->num_inputs; attr++) {
       const GLuint mesaAttr = vp->index_to_input[attr];
       const struct gl_buffer_object *bufObj = arrays[mesaAttr]->BufferObj;
       const GLsizei stride = arrays[mesaAttr]->StrideB; /* in bytes */
@@ -321,7 +270,7 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
       }
    }
 
-   *userSpace = (num_client_arrays == vp->num_inputs);
+   *userSpace = (num_client_arrays == vpv->num_inputs);
    /* printf("user space: %d (%d %d)\n", (int) *userSpace,num_client_arrays,vp->num_inputs); */
 
    return GL_TRUE;
@@ -333,15 +282,16 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
  */
 static void
 get_arrays_bounds(const struct st_vertex_program *vp,
-                       const struct gl_client_array **arrays,
-                       GLuint max_index,
-                       const GLubyte **low, const GLubyte **high)
+                  const struct st_vp_varient *vpv,
+                  const struct gl_client_array **arrays,
+                  GLuint max_index,
+                  const GLubyte **low, const GLubyte **high)
 {
    const GLubyte *low_addr = NULL;
    const GLubyte *high_addr = NULL;
    GLuint attr;
 
-   for (attr = 0; attr < vp->num_inputs; attr++) {
+   for (attr = 0; attr < vpv->num_inputs; attr++) {
       const GLuint mesaAttr = vp->index_to_input[attr];
       const GLint stride = arrays[mesaAttr]->StrideB;
       const GLubyte *start = arrays[mesaAttr]->Ptr;
@@ -373,6 +323,7 @@ get_arrays_bounds(const struct st_vertex_program *vp,
 static void
 setup_interleaved_attribs(GLcontext *ctx,
                           const struct st_vertex_program *vp,
+                          const struct st_vp_varient *vpv,
                           const struct gl_client_array **arrays,
                           GLuint max_index,
                           GLboolean userSpace,
@@ -383,7 +334,7 @@ setup_interleaved_attribs(GLcontext *ctx,
    GLuint attr;
    const GLubyte *offset0 = NULL;
 
-   for (attr = 0; attr < vp->num_inputs; attr++) {
+   for (attr = 0; attr < vpv->num_inputs; attr++) {
       const GLuint mesaAttr = vp->index_to_input[attr];
       struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj;
       struct st_buffer_object *stobj = st_buffer_object(bufobj);
@@ -394,7 +345,7 @@ setup_interleaved_attribs(GLcontext *ctx,
       if (attr == 0) {
          const GLubyte *low, *high;
 
-         get_arrays_bounds(vp, arrays, max_index, &low, &high);
+         get_arrays_bounds(vp, vpv, arrays, max_index, &low, &high);
          /*printf("buffer range: %p %p  %d\n", low, high, high-low);*/
 
          offset0 = low;
@@ -435,6 +386,7 @@ setup_interleaved_attribs(GLcontext *ctx,
 static void
 setup_non_interleaved_attribs(GLcontext *ctx,
                               const struct st_vertex_program *vp,
+                              const struct st_vp_varient *vpv,
                               const struct gl_client_array **arrays,
                               GLuint max_index,
                               GLboolean *userSpace,
@@ -444,7 +396,7 @@ setup_non_interleaved_attribs(GLcontext *ctx,
    struct pipe_context *pipe = ctx->st->pipe;
    GLuint attr;
 
-   for (attr = 0; attr < vp->num_inputs; attr++) {
+   for (attr = 0; attr < vpv->num_inputs; attr++) {
       const GLuint mesaAttr = vp->index_to_input[attr];
       struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj;
       GLsizei stride = arrays[mesaAttr]->StrideB;
@@ -569,12 +521,14 @@ st_draw_vbo(GLcontext *ctx,
 {
    struct pipe_context *pipe = ctx->st->pipe;
    const struct st_vertex_program *vp;
+   const struct st_vp_varient *vpv;
    const struct pipe_shader_state *vs;
    struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS];
    GLuint attr;
    struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
    unsigned num_vbuffers, num_velements;
    GLboolean userSpace = GL_FALSE;
+   GLboolean vertDataEdgeFlags;
 
    /* Gallium probably doesn't want this in some cases. */
    if (!index_bounds_valid)
@@ -584,11 +538,19 @@ st_draw_vbo(GLcontext *ctx,
    /* sanity check for pointer arithmetic below */
    assert(sizeof(arrays[0]->Ptr[0]) == 1);
 
+   vertDataEdgeFlags = arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj &&
+                       arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj->Name;
+   if (vertDataEdgeFlags != ctx->st->vertdata_edgeflags) {
+      ctx->st->vertdata_edgeflags = vertDataEdgeFlags;
+      ctx->st->dirty.st |= ST_NEW_EDGEFLAGS_DATA;
+   }
+
    st_validate_state(ctx->st);
 
    /* must get these after state validation! */
    vp = ctx->st->vp;
-   vs = &ctx->st->vp_varient->state;
+   vpv = ctx->st->vp_varient;
+   vs = &vpv->state;
 
 #if 0
    if (MESA_VERBOSE & VERBOSE_GLSL) {
@@ -601,21 +563,21 @@ st_draw_vbo(GLcontext *ctx,
    /*
     * Setup the vbuffer[] and velements[] arrays.
     */
-   if (is_interleaved_arrays(vp, arrays, &userSpace)) {
+   if (is_interleaved_arrays(vp, vpv, arrays, &userSpace)) {
       /*printf("Draw interleaved\n");*/
-      setup_interleaved_attribs(ctx, vp, arrays, max_index, userSpace,
+      setup_interleaved_attribs(ctx, vp, vpv, arrays, max_index, userSpace,
                                 vbuffer, velements);
       num_vbuffers = 1;
-      num_velements = vp->num_inputs;
+      num_velements = vpv->num_inputs;
       if (num_velements == 0)
          num_vbuffers = 0;
    }
    else {
       /*printf("Draw non-interleaved\n");*/
-      setup_non_interleaved_attribs(ctx, vp, arrays, max_index,
+      setup_non_interleaved_attribs(ctx, vp, vpv, arrays, max_index,
                                     &userSpace, vbuffer, velements);
-      num_vbuffers = vp->num_inputs;
-      num_velements = vp->num_inputs;
+      num_vbuffers = vpv->num_inputs;
+      num_velements = vpv->num_inputs;
    }
 
 #if 0
@@ -687,10 +649,6 @@ st_draw_vbo(GLcontext *ctx,
           * through to driver & draw module.  These interfaces still
           * need a bit of work...
           */
-         setup_edgeflags(ctx, prims[i].mode,
-                         prims[i].start + indexOffset, prims[i].count,
-                         arrays[VERT_ATTRIB_EDGEFLAG]);
-
          prim = translate_prim( ctx, prims[i].mode );
 
          pipe->draw_range_elements(pipe, indexBuf, indexSize,
@@ -701,10 +659,6 @@ st_draw_vbo(GLcontext *ctx,
       }
       else {
          for (i = 0; i < nr_prims; i++) {
-            setup_edgeflags(ctx, prims[i].mode,
-                            prims[i].start + indexOffset, prims[i].count,
-                            arrays[VERT_ATTRIB_EDGEFLAG]);
-
             prim = translate_prim( ctx, prims[i].mode );
             
             pipe->draw_elements(pipe, indexBuf, indexSize,
@@ -721,10 +675,6 @@ st_draw_vbo(GLcontext *ctx,
       GLuint prim;
 
       for (i = 0; i < nr_prims; i++) {
-         setup_edgeflags(ctx, prims[i].mode,
-                         prims[i].start, prims[i].count,
-                         arrays[VERT_ATTRIB_EDGEFLAG]);
-
          prim = translate_prim( ctx, prims[i].mode );
 
          pipe->draw_arrays(pipe, prim, prims[i].start, prims[i].count);
index 1611d53e2fe644fc981217aa2b129868152074e1..5c9be46a776fffe6fe02f320e73577b8742ba091 100644 (file)
@@ -718,6 +718,16 @@ emit_face_var( struct st_translate *t,
    t->inputs[t->inputMapping[FRAG_ATTRIB_FACE]] = ureg_src(face_temp);
 }
 
+static void
+emit_edgeflags( struct st_translate *t,
+                 const struct gl_program *program )
+{
+   struct ureg_program *ureg = t->ureg;
+   struct ureg_dst edge_dst = t->outputs[t->outputMapping[VERT_RESULT_EDGE]];
+   struct ureg_src edge_src = t->inputs[t->inputMapping[VERT_ATTRIB_EDGEFLAG]];
+
+   ureg_MOV( ureg, edge_dst, edge_src );
+}
 
 /**
  * Translate Mesa program to TGSI format.
@@ -738,10 +748,11 @@ emit_face_var( struct st_translate *t,
  *
  * \return  array of translated tokens, caller's responsibility to free
  */
-const struct tgsi_token *
+enum pipe_error
 st_translate_mesa_program(
    GLcontext *ctx,
    uint procType,
+   struct ureg_program *ureg,
    const struct gl_program *program,
    GLuint numInputs,
    const GLuint inputMapping[],
@@ -751,11 +762,10 @@ st_translate_mesa_program(
    GLuint numOutputs,
    const GLuint outputMapping[],
    const ubyte outputSemanticName[],
-   const ubyte outputSemanticIndex[] )
+   const ubyte outputSemanticIndex[],
+   boolean passthrough_edgeflags )
 {
    struct st_translate translate, *t;
-   struct ureg_program *ureg;
-   const struct tgsi_token *tokens = NULL;
    unsigned i;
 
    t = &translate;
@@ -764,11 +774,7 @@ st_translate_mesa_program(
    t->procType = procType;
    t->inputMapping = inputMapping;
    t->outputMapping = outputMapping;
-   t->ureg = ureg_create( procType );
-   if (t->ureg == NULL)
-      return NULL;
-
-   ureg = t->ureg;
+   t->ureg = ureg;
 
    /*_mesa_print_program(program);*/
 
@@ -828,6 +834,8 @@ st_translate_mesa_program(
                                            outputSemanticName[i],
                                            outputSemanticIndex[i] );
       }
+      if (passthrough_edgeflags)
+         emit_edgeflags( t, program );
    }
 
    /* Declare address register.
@@ -899,8 +907,7 @@ st_translate_mesa_program(
                         t->insn[t->labels[i].branch_target] );
    }
 
-   tokens = ureg_get_tokens( ureg, NULL );
-   ureg_destroy( ureg );
+   return PIPE_OK;
 
 out:
    FREE(t->insn);
@@ -909,17 +916,9 @@ out:
 
    if (t->error) {
       debug_printf("%s: translate error flag set\n", __FUNCTION__);
-      FREE((void *)tokens);
-      tokens = NULL;
-   }
-
-   if (!tokens) {
-      debug_printf("%s: failed to translate Mesa program:\n", __FUNCTION__);
-      _mesa_print_program(program);
-      debug_assert(0);
    }
 
-   return tokens;
+   return PIPE_ERROR_OUT_OF_MEMORY;
 }
 
 
index dc0362fe790618dd9ca22235c040cb63b08af416..e3c5bd1d94db6e3d6f2e78cab0306e2146d9ac88 100644 (file)
@@ -30,6 +30,7 @@
 #define ST_MESA_TO_TGSI_H
 
 #include "main/mtypes.h"
+#include "tgsi/tgsi_ureg.h"
 
 
 #if defined __cplusplus
@@ -39,10 +40,11 @@ extern "C" {
 struct tgsi_token;
 struct gl_program;
 
-const struct tgsi_token *
+enum pipe_error
 st_translate_mesa_program(
    GLcontext *ctx,
    uint procType,
+   struct ureg_program *ureg,
    const struct gl_program *program,
    GLuint numInputs,
    const GLuint inputMapping[],
@@ -52,7 +54,8 @@ st_translate_mesa_program(
    GLuint numOutputs,
    const GLuint outputMapping[],
    const ubyte outputSemanticName[],
-   const ubyte outputSemanticIndex[] );
+   const ubyte outputSemanticIndex[],
+   boolean passthrough_edgeflags );
 
 void
 st_free_tokens(const struct tgsi_token *tokens);
index d91ed6806dcc11f7ece5133808861e8a07d4a307..6a869fae90443455d20b01c90ecc96b43838629e 100644 (file)
@@ -115,6 +115,9 @@ st_prepare_vertex_program(struct st_context *st,
          stvp->num_inputs++;
       }
    }
+   /* bit of a hack, presetup potentially unused edgeflag input */
+   stvp->input_to_index[VERT_ATTRIB_EDGEFLAG] = stvp->num_inputs;
+   stvp->index_to_input[stvp->num_inputs] = VERT_ATTRIB_EDGEFLAG;
 
    /* Compute mapping of vertex program outputs to slots.
     */
@@ -184,6 +187,10 @@ st_prepare_vertex_program(struct st_context *st,
          }
       }
    }
+   /* similar hack to above, presetup potentially unused edgeflag output */
+   stvp->result_to_output[VERT_RESULT_EDGE] = stvp->num_outputs;
+   stvp->output_semantic_name[stvp->num_outputs] = TGSI_SEMANTIC_EDGEFLAG;
+   stvp->output_semantic_index[stvp->num_outputs] = 0;
 }
 
 
@@ -194,22 +201,47 @@ st_translate_vertex_program(struct st_context *st,
 {
    struct st_vp_varient *vpv = CALLOC_STRUCT(st_vp_varient);
    struct pipe_context *pipe = st->pipe;
+   struct ureg_program *ureg;
+   enum pipe_error error;
+   unsigned num_outputs;
+
+   ureg = ureg_create( TGSI_PROCESSOR_VERTEX );
+   if (ureg == NULL)
+      return NULL;
+
+   vpv->num_inputs = stvp->num_inputs;
+   num_outputs = stvp->num_outputs;
+   if (key->passthrough_edgeflags) {
+      vpv->num_inputs++;
+      num_outputs++;
+   }
 
-   vpv->state.tokens = 
+   error = 
       st_translate_mesa_program(st->ctx,
                                 TGSI_PROCESSOR_VERTEX,
+                                ureg,
                                 &stvp->Base.Base,
                                 /* inputs */
-                                stvp->num_inputs,
+                                vpv->num_inputs,
                                 stvp->input_to_index,
                                 NULL, /* input semantic name */
                                 NULL, /* input semantic index */
                                 NULL,
                                 /* outputs */
-                                stvp->num_outputs,
+                                num_outputs,
                                 stvp->result_to_output,
                                 stvp->output_semantic_name,
-                                stvp->output_semantic_index );
+                                stvp->output_semantic_index,
+                                key->passthrough_edgeflags );
+
+   if (error)
+      goto fail;
+
+   vpv->state.tokens = ureg_get_tokens( ureg, NULL );
+   if (!vpv->state.tokens)
+      goto fail;
+
+   ureg_destroy( ureg );
 
    vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->state);
 
@@ -224,6 +256,14 @@ st_translate_vertex_program(struct st_context *st,
    }
 
    return vpv;
+
+fail:
+   debug_printf("%s: failed to translate Mesa program:\n", __FUNCTION__);
+   _mesa_print_program(&stvp->Base.Base);
+   debug_assert(0);
+
+   ureg_destroy( ureg );
+   return NULL;
 }
 
 
@@ -244,7 +284,9 @@ st_translate_fragment_program(struct st_context *st,
    GLuint defaultInputMapping[FRAG_ATTRIB_MAX];
    GLuint interpMode[16];  /* XXX size? */
    GLuint attr;
+   enum pipe_error error;
    const GLbitfield inputsRead = stfp->Base.Base.InputsRead;
+   struct ureg_program *ureg;
    GLuint vslot = 0;
 
    uint fs_num_inputs = 0;
@@ -379,9 +421,15 @@ st_translate_fragment_program(struct st_context *st,
    if (!inputMapping)
       inputMapping = defaultInputMapping;
 
-   stfp->state.tokens = 
+   ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
+   if (ureg == NULL)
+      return;
+
+
+   error = 
       st_translate_mesa_program(st->ctx,
                                 TGSI_PROCESSOR_FRAGMENT,
+                                ureg,
                                 &stfp->Base.Base,
                                 /* inputs */
                                 fs_num_inputs,
@@ -393,8 +441,10 @@ st_translate_fragment_program(struct st_context *st,
                                 fs_num_outputs,
                                 outputMapping,
                                 fs_output_semantic_name,
-                                fs_output_semantic_index );
+                                fs_output_semantic_index, FALSE );
 
+   stfp->state.tokens = ureg_get_tokens( ureg, NULL );
+   ureg_destroy( ureg );
    stfp->driver_shader = pipe->create_fs_state(pipe, &stfp->state);
 
    if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
index 88aadbd75102a5e01a1591695a946045819829e3..6b9a9226df583b0de95b340d1ab59a5dacafd384 100644 (file)
@@ -73,7 +73,7 @@ struct st_fragment_program
 
 struct st_vp_varient_key
 {
-   char dummy;                  /* currently unused */
+   boolean passthrough_edgeflags;
 };
 
 
@@ -100,6 +100,9 @@ struct st_vp_varient
 
    /** Next in linked list */
    struct st_vp_varient *next;  
+
+   /** similar to that in st_vertex_program, but with information about edgeflags too */
+   GLuint num_inputs;
 };