gallium: remove dependencies on pipe_shader_state's semantic info
authorBrian <brian@i915.localnet.net>
Wed, 27 Feb 2008 23:02:58 +0000 (16:02 -0700)
committerBrian <brian@i915.localnet.net>
Wed, 27 Feb 2008 23:02:58 +0000 (16:02 -0700)
Use tgsi_scan_shader() to populate a tgsi_shader_info struct and use that instead.

13 files changed:
src/gallium/auxiliary/draw/draw_aaline.c
src/gallium/auxiliary/draw/draw_aapoint.c
src/gallium/auxiliary/draw/draw_clip.c
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_flatshade.c
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pstipple.c
src/gallium/auxiliary/draw/draw_twoside.c
src/gallium/auxiliary/draw/draw_vertex_fetch.c
src/gallium/auxiliary/draw/draw_vertex_shader.c
src/gallium/auxiliary/draw/draw_vs_exec.c
src/gallium/auxiliary/draw/draw_vs_sse.c
src/gallium/auxiliary/draw/draw_wide_prims.c

index be6cfd3b6a37b333e0a41bc52bbe935d95cbd458..51140388f0983771205163cd11fe7ead6639e15d 100644 (file)
@@ -340,9 +340,11 @@ generate_aaline_fs(struct aaline_stage *aaline)
    tgsi_dump(aaline_fs.tokens, 0);
 #endif
 
+#if 1 /* XXX remove */
    aaline_fs.input_semantic_name[aaline_fs.num_inputs] = TGSI_SEMANTIC_GENERIC;
    aaline_fs.input_semantic_index[aaline_fs.num_inputs] = transform.maxGeneric + 1;
    aaline_fs.num_inputs++;
+#endif
 
    aaline->fs->aaline_fs
       = aaline->driver_create_fs_state(aaline->pipe, &aaline_fs);
index d16adb25051118d51035e514795745017a470bba..d48a416899fa4c04b902ceb85909247d0006588c 100644 (file)
@@ -514,9 +514,11 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
    tgsi_dump(aapoint_fs.tokens, 0);
 #endif
 
+#if 1 /* XXX remove */
    aapoint_fs.input_semantic_name[aapoint_fs.num_inputs] = TGSI_SEMANTIC_GENERIC;
    aapoint_fs.input_semantic_index[aapoint_fs.num_inputs] = transform.maxGeneric + 1;
    aapoint_fs.num_inputs++;
+#endif
 
    aapoint->fs->aapoint_fs
       = aapoint->driver_create_fs_state(aapoint->pipe, &aapoint_fs);
@@ -694,8 +696,8 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header)
       /* find PSIZ vertex output */
       const struct draw_vertex_shader *vs = draw->vertex_shader;
       uint i;
-      for (i = 0; i < vs->state->num_outputs; i++) {
-         if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
+      for (i = 0; i < vs->info.num_outputs; i++) {
+         if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
             aapoint->psize_slot = i;
             break;
          }
index e3051507eaf16ebaf0d6203f14dc9148af7e7319..200152ecab9489b9d0feb361d634fe72dd92a635 100644 (file)
@@ -409,13 +409,13 @@ clip_init_state( struct draw_stage *stage )
    clipper->flat = stage->draw->rasterizer->flatshade ? TRUE : FALSE;
 
    if (clipper->flat) {
-      const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
+      const struct draw_vertex_shader *vs = stage->draw->vertex_shader;
       uint i;
 
       clipper->num_color_attribs = 0;
-      for (i = 0; i < vs->num_outputs; i++) {
-        if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
-            vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
+      for (i = 0; i < vs->info.num_outputs; i++) {
+        if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
+            vs->info.output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
            clipper->color_attribs[clipper->num_color_attribs++] = i;
         }
       }
index 48f00946eaeccc6745aee960f7cb0a2273f564c4..64ada8ce047dda5cb85b30f0aa8dd1d7e2288ebe 100644 (file)
@@ -262,11 +262,11 @@ int
 draw_find_vs_output(struct draw_context *draw,
                     uint semantic_name, uint semantic_index)
 {
-   const struct pipe_shader_state *vs = draw->vertex_shader->state;
+   const struct draw_vertex_shader *vs = draw->vertex_shader;
    uint i;
-   for (i = 0; i < vs->num_outputs; i++) {
-      if (vs->output_semantic_name[i] == semantic_name &&
-          vs->output_semantic_index[i] == semantic_index)
+   for (i = 0; i < vs->info.num_outputs; i++) {
+      if (vs->info.output_semantic_name[i] == semantic_name &&
+          vs->info.output_semantic_index[i] == semantic_index)
          return i;
    }
 
index 4398abbc60c953775eb15d61b7775535afb63cae..ccad71d695797b87e3b39482f9a21cc16cd57848 100644 (file)
@@ -128,14 +128,14 @@ static void flatshade_point( struct draw_stage *stage,
 static void flatshade_init_state( struct draw_stage *stage )
 {
    struct flat_stage *flat = flat_stage(stage);
-   const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
+   const struct draw_vertex_shader *vs = stage->draw->vertex_shader;
    uint i;
 
    /* Find which vertex shader outputs are colors, make a list */
    flat->num_color_attribs = 0;
-   for (i = 0; i < vs->num_outputs; i++) {
-      if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
-          vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
+   for (i = 0; i < vs->info.num_outputs; i++) {
+      if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
+          vs->info.output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
          flat->color_attribs[flat->num_color_attribs++] = i;
       }
    }
index 03e3d3a66b6fb452c66f510c056288df3684e6a8..e988e71d23e39c8d4733b6fbc7e654c27ba1c613 100644 (file)
@@ -46,6 +46,7 @@
 
 #include "rtasm/rtasm_x86sse.h"
 #include "tgsi/exec/tgsi_exec.h"
+#include "tgsi/util/tgsi_scan.h"
 
 
 struct pipe_context;
@@ -134,6 +135,8 @@ struct draw_vertex_shader {
     */
    const struct pipe_shader_state   *state;
 
+   struct tgsi_shader_info info;
+
    void (*prepare)( struct draw_vertex_shader *shader,
                    struct draw_context *draw );
 
index efc88bf038b9a755d8d36a55eb7dae8fb6d1b1d3..f6200aa82012fb2914b39b910096f9e41142cf03 100644 (file)
@@ -330,11 +330,13 @@ generate_pstip_fs(struct pstip_stage *pstip)
 
    pstip->sampler_unit = transform.maxSampler + 1;
 
+#if 1 /* XXX remove */
    if (transform.wincoordInput < 0) {
       pstip_fs.input_semantic_name[pstip_fs.num_inputs] = TGSI_SEMANTIC_POSITION;
       pstip_fs.input_semantic_index[pstip_fs.num_inputs] = (ubyte)transform.maxInput;
       pstip_fs.num_inputs++;
    }
+#endif
 
    pstip->fs->pstip_fs = pstip->driver_create_fs_state(pstip->pipe, &pstip_fs);
 }
index 1c3895798713ddac18692f2ecac59508c9022e13..3debaac282273517badcf2ceeb69c6206b3275be 100644 (file)
@@ -119,7 +119,7 @@ static void twoside_first_tri( struct draw_stage *stage,
                               struct prim_header *header )
 {
    struct twoside_stage *twoside = twoside_stage(stage);
-   const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
+   const struct draw_vertex_shader *vs = stage->draw->vertex_shader;
    uint i;
 
    twoside->attrib_front0 = 0;
@@ -128,15 +128,15 @@ static void twoside_first_tri( struct draw_stage *stage,
    twoside->attrib_back1 = 0;
 
    /* Find which vertex shader outputs are front/back colors */
-   for (i = 0; i < vs->num_outputs; i++) {
-      if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR) {
-         if (vs->output_semantic_index[i] == 0)
+   for (i = 0; i < vs->info.num_outputs; i++) {
+      if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_COLOR) {
+         if (vs->info.output_semantic_index[i] == 0)
             twoside->attrib_front0 = i;
          else
             twoside->attrib_front1 = i;
       }
-      if (vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
-         if (vs->output_semantic_index[i] == 0)
+      if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
+         if (vs->info.output_semantic_index[i] == 0)
             twoside->attrib_back0 = i;
          else
             twoside->attrib_back1 = i;
index e13df04605c7639df82fc533066c7505a3e47f2b..cb8cdd04a3ee19748dd697fab242f9629de29a2a 100644 (file)
@@ -473,7 +473,7 @@ void draw_update_vertex_fetch( struct draw_context *draw )
    if (!draw->vertex_shader)
       return;
 
-   nr_attrs = draw->vertex_shader->state->num_inputs;
+   nr_attrs = draw->vertex_shader->info.num_inputs;
 
    for (i = 0; i < nr_attrs; i++) {
       unsigned buf = draw->vertex_element[i].vertex_buffer_index;
index 5d2f5c9c43aee6d2e9b7d18b80fc3ef0af1efc0b..1e9535555549bef2813032a4b73de7cd8ef98998 100644 (file)
@@ -91,15 +91,16 @@ draw_create_vertex_shader(struct draw_context *draw,
    struct draw_vertex_shader *vs;
 
    vs = draw_create_vs_llvm( draw, shader );
-   if (vs)
-      return vs;
+   if (!vs) {
+      vs = draw_create_vs_sse( draw, shader );
+      if (!vs) {
+         vs = draw_create_vs_exec( draw, shader );
+      }
+   }
+   assert(vs);
 
-   vs = draw_create_vs_sse( draw, shader );
-   if (vs)
-      return vs;
+   tgsi_scan_shader(shader->tokens, &vs->info);
 
-   vs = draw_create_vs_exec( draw, shader );
-   assert(vs);
    return vs;
 }
 
@@ -111,7 +112,7 @@ draw_bind_vertex_shader(struct draw_context *draw,
    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
 
    draw->vertex_shader = dvs;
-   draw->num_vs_outputs = dvs->state->num_outputs;
+   draw->num_vs_outputs = dvs->info.num_outputs;
 
    tgsi_exec_machine_init(&draw->machine);
 
index 8588879400a8d45afa69f9d5f8bd755309477901..583812aadd2a90311119e1c165271b9242c3feb0 100644 (file)
@@ -103,7 +103,7 @@ vs_exec_run( struct draw_vertex_shader *shader,
    const float *trans = draw->viewport.translate;
 
    assert(count <= 4);
-   assert(draw->vertex_shader->state->output_semantic_name[0]
+   assert(draw->vertex_shader->info.output_semantic_name[0]
           == TGSI_SEMANTIC_POSITION);
 
    machine->Consts = (float (*)[4]) draw->user.constants;
index 11ef0c503dcf77b15892d1d2e16ea98dbdb2ba31..0b8bc2bf1444c7063c4cb1f4e5e0df7d91429b70 100644 (file)
@@ -119,7 +119,7 @@ vs_sse_run( struct draw_vertex_shader *base,
    const float *trans = draw->viewport.translate;
 
    assert(count <= 4);
-   assert(draw->vertex_shader->state->output_semantic_name[0]
+   assert(draw->vertex_shader->info.output_semantic_name[0]
           == TGSI_SEMANTIC_POSITION);
 
    /* Consts does not require 16 byte alignment. */
index d967810dd498f9752ecbdafc207a2417f0c09ab8..d6bff110b40a8e10595a9be68174b002d4a8a85b 100644 (file)
@@ -278,8 +278,8 @@ static void wide_first_point( struct draw_stage *stage,
       /* find vertex shader texcoord outputs */
       const struct draw_vertex_shader *vs = draw->vertex_shader;
       uint i, j = 0;
-      for (i = 0; i < vs->state->num_outputs; i++) {
-         if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
+      for (i = 0; i < vs->info.num_outputs; i++) {
+         if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
             wide->texcoord_slot[j] = i;
             wide->texcoord_mode[j] = draw->rasterizer->sprite_coord_mode[j];
             j++;
@@ -294,8 +294,8 @@ static void wide_first_point( struct draw_stage *stage,
       /* find PSIZ vertex output */
       const struct draw_vertex_shader *vs = draw->vertex_shader;
       uint i;
-      for (i = 0; i < vs->state->num_outputs; i++) {
-         if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
+      for (i = 0; i < vs->info.num_outputs; i++) {
+         if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
             wide->psize_slot = i;
             break;
          }