st/mesa: change some function return types
[mesa.git] / src / mesa / state_tracker / st_program.c
index e939ab382182ab8d42eab31bcb1262203e71ab28..7ce3938904b72018224389568fc5b888f43cea39 100644 (file)
@@ -33,7 +33,6 @@
 
 #include "main/imports.h"
 #include "main/mtypes.h"
-#include "shader/prog_parameter.h"
 #include "shader/prog_print.h"
 #include "shader/programopt.h"
 
@@ -69,8 +68,8 @@ st_vp_release_varients( struct st_context *st,
       if (vpv->draw_shader)
          draw_delete_vertex_shader( st->draw, vpv->draw_shader );
       
-      if (vpv->state.tokens)
-         st_free_tokens(vpv->state.tokens);
+      if (vpv->tgsi.tokens)
+         st_free_tokens(vpv->tgsi.tokens);
       
       FREE( vpv );
 
@@ -237,13 +236,13 @@ st_translate_vertex_program(struct st_context *st,
    if (error)
       goto fail;
 
-   vpv->state.tokens = ureg_get_tokens( ureg, NULL );
-   if (!vpv->state.tokens)
+   vpv->tgsi.tokens = ureg_get_tokens( ureg, NULL );
+   if (!vpv->tgsi.tokens)
       goto fail;
 
    ureg_destroy( ureg );
 
-   vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->state);
+   vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->tgsi);
 
    if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
       _mesa_print_program(&stvp->Base.Base);
@@ -251,7 +250,7 @@ st_translate_vertex_program(struct st_context *st,
    }
 
    if (ST_DEBUG & DEBUG_TGSI) {
-      tgsi_dump( vpv->state.tokens, 0 );
+      tgsi_dump( vpv->tgsi.tokens, 0 );
       debug_printf("\n");
    }
 
@@ -279,12 +278,14 @@ st_translate_fragment_program(struct st_context *st,
    struct pipe_context *pipe = st->pipe;
    GLuint outputMapping[FRAG_RESULT_MAX];
    GLuint inputMapping[FRAG_ATTRIB_MAX];
-   GLuint interpMode[16];  /* XXX size? */
+   GLuint interpMode[PIPE_MAX_SHADER_INPUTS];  /* XXX size? */
    GLuint attr;
    enum pipe_error error;
    const GLbitfield inputsRead = stfp->Base.Base.InputsRead;
    struct ureg_program *ureg;
 
+   ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS];
+   ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
    uint fs_num_inputs = 0;
 
    ubyte fs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
@@ -302,28 +303,28 @@ st_translate_fragment_program(struct st_context *st,
 
          switch (attr) {
          case FRAG_ATTRIB_WPOS:
-            stfp->input_semantic_name[slot] = TGSI_SEMANTIC_POSITION;
-            stfp->input_semantic_index[slot] = 0;
+            input_semantic_name[slot] = TGSI_SEMANTIC_POSITION;
+            input_semantic_index[slot] = 0;
             interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
             break;
          case FRAG_ATTRIB_COL0:
-            stfp->input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
-            stfp->input_semantic_index[slot] = 0;
+            input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
+            input_semantic_index[slot] = 0;
             interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
             break;
          case FRAG_ATTRIB_COL1:
-            stfp->input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
-            stfp->input_semantic_index[slot] = 1;
+            input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
+            input_semantic_index[slot] = 1;
             interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
             break;
          case FRAG_ATTRIB_FOGC:
-            stfp->input_semantic_name[slot] = TGSI_SEMANTIC_FOG;
-            stfp->input_semantic_index[slot] = 0;
+            input_semantic_name[slot] = TGSI_SEMANTIC_FOG;
+            input_semantic_index[slot] = 0;
             interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
             break;
          case FRAG_ATTRIB_FACE:
-            stfp->input_semantic_name[slot] = TGSI_SEMANTIC_FACE;
-            stfp->input_semantic_index[slot] = 0;
+            input_semantic_name[slot] = TGSI_SEMANTIC_FACE;
+            input_semantic_index[slot] = 0;
             interpMode[slot] = TGSI_INTERPOLATE_CONSTANT;
             break;
          case FRAG_ATTRIB_PNTC:
@@ -332,8 +333,8 @@ st_translate_fragment_program(struct st_context *st,
              * shader input is the point coord attribute so that it can set
              * up the right vertex attribute values.
              */
-            stfp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
-            stfp->input_semantic_index[slot] = 0;
+            input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
+            input_semantic_index[slot] = 0;
             interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
             break;
 
@@ -366,16 +367,9 @@ st_translate_fragment_program(struct st_context *st,
              * readability of the generated TGSI.
              */
             assert(attr >= FRAG_ATTRIB_TEX0);
-            stfp->input_semantic_index[slot] = (attr - FRAG_ATTRIB_TEX0);
-            stfp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
-
-            /* XXX this test is very temporary */
-            if (stfp->Base.Base.InputFlags[0] & PROG_PARAM_BIT_CYL_WRAP) {
-               interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
-            }
-            else {
-               interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
-            }
+            input_semantic_index[slot] = (attr - FRAG_ATTRIB_TEX0);
+            input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
+            interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
             break;
          }
       }
@@ -436,8 +430,8 @@ st_translate_fragment_program(struct st_context *st,
                                 /* inputs */
                                 fs_num_inputs,
                                 inputMapping,
-                                stfp->input_semantic_name,
-                                stfp->input_semantic_index,
+                                input_semantic_name,
+                                input_semantic_index,
                                 interpMode,
                                 /* outputs */
                                 fs_num_outputs,
@@ -445,9 +439,9 @@ st_translate_fragment_program(struct st_context *st,
                                 fs_output_semantic_name,
                                 fs_output_semantic_index, FALSE );
 
-   stfp->state.tokens = ureg_get_tokens( ureg, NULL );
+   stfp->tgsi.tokens = ureg_get_tokens( ureg, NULL );
    ureg_destroy( ureg );
-   stfp->driver_shader = pipe->create_fs_state(pipe, &stfp->state);
+   stfp->driver_shader = pipe->create_fs_state(pipe, &stfp->tgsi);
 
    if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
       _mesa_print_program(&stfp->Base.Base);
@@ -455,7 +449,7 @@ st_translate_fragment_program(struct st_context *st,
    }
 
    if (ST_DEBUG & DEBUG_TGSI) {
-      tgsi_dump( stfp->state.tokens, 0/*TGSI_DUMP_VERBOSE*/ );
+      tgsi_dump( stfp->tgsi.tokens, 0/*TGSI_DUMP_VERBOSE*/ );
       debug_printf("\n");
    }
 }