r300g: inline FLUSH_CS
[mesa.git] / src / gallium / drivers / r300 / r300_vs.c
index f3186431e1d170e66fa916b7e401fe9115e422fc..b25c786d6b37faf898d52398c35a38436e61d79e 100644 (file)
@@ -160,11 +160,16 @@ static void set_vertex_inputs_outputs(struct r300_vertex_program_compiler * c)
     c->code->outputs[outputs->wpos] = reg++;
 }
 
+void r300_init_vs_outputs(struct r300_vertex_shader *vs)
+{
+    tgsi_scan_shader(vs->state.tokens, &vs->info);
+    r300_shader_read_vs_outputs(&vs->info, &vs->outputs);
+}
+
 static void r300_dummy_vertex_shader(
     struct r300_context* r300,
     struct r300_vertex_shader* shader)
 {
-    struct pipe_shader_state state;
     struct ureg_program *ureg;
     struct ureg_dst dst;
     struct ureg_src imm;
@@ -178,34 +183,32 @@ static void r300_dummy_vertex_shader(
     ureg_MOV(ureg, dst, imm);
     ureg_END(ureg);
 
-    state.tokens = ureg_finalize(ureg);
+    shader->state.tokens = tgsi_dup_tokens(ureg_finalize(ureg));
+    ureg_destroy(ureg);
 
     shader->dummy = TRUE;
-    r300_translate_vertex_shader(r300, shader, state.tokens);
-
-    ureg_destroy(ureg);
+    r300_init_vs_outputs(shader);
+    r300_translate_vertex_shader(r300, shader);
 }
 
-void r300_translate_vertex_shader(struct r300_context* r300,
-                                  struct r300_vertex_shader* vs,
-                                  const struct tgsi_token *tokens)
+void r300_translate_vertex_shader(struct r300_context *r300,
+                                  struct r300_vertex_shader *vs)
 {
     struct r300_vertex_program_compiler compiler;
     struct tgsi_to_rc ttr;
 
-    tgsi_scan_shader(tokens, &vs->info);
-    r300_shader_read_vs_outputs(&vs->info, &vs->outputs);
-
     /* Setup the compiler */
     rc_init(&compiler.Base);
 
     compiler.Base.Debug = DBG_ON(r300, DBG_VP);
     compiler.code = &vs->code;
     compiler.UserData = vs;
+    compiler.Base.is_r500 = r300->screen->caps.is_r500;
+    compiler.Base.max_temp_regs = 32;
 
     if (compiler.Base.Debug) {
         debug_printf("r300: Initial vertex program\n");
-        tgsi_dump(tokens, 0);
+        tgsi_dump(vs->state.tokens, 0);
     }
 
     /* Translate TGSI to our internal representation */
@@ -213,7 +216,7 @@ void r300_translate_vertex_shader(struct r300_context* r300,
     ttr.info = &vs->info;
     ttr.use_half_swizzles = FALSE;
 
-    r300_tgsi_to_rc(&ttr, tokens);
+    r300_tgsi_to_rc(&ttr, vs->state.tokens);
 
     compiler.RequiredOutputs = ~(~0 << (vs->info.num_outputs + 1));
     compiler.SetHwInputOutput = &set_vertex_inputs_outputs;
@@ -226,7 +229,8 @@ void r300_translate_vertex_shader(struct r300_context* r300,
     if (compiler.Base.Error) {
         /* XXX We should fallback using Draw. */
         fprintf(stderr, "r300 VP: Compiler error:\n%sUsing a dummy shader"
-                " instead.\n", compiler.Base.ErrorMsg);
+                " instead.\nIf there's an 'unknown opcode' message, please"
+                " file a bug report and attach this log.\n", compiler.Base.ErrorMsg);
 
         if (vs->dummy) {
             fprintf(stderr, "r300 VP: Cannot compile the dummy shader! "