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 be6cfd3..5114038 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 d16adb2..d48a416 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 e305150..200152e 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 48f0094..64ada8c 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 4398abb..ccad71d 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 03e3d3a..e988e71 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 efc88bf..f6200aa 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 1c38957..3debaac 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 e13df04..cb8cdd0 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 5d2f5c9..1e95355 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 8588879..583812a 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 11ef0c5..0b8bc2b 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 d967810..d6bff11 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;
          }