r300-gallium: Add vertex shader emit.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 1 Apr 2009 01:58:03 +0000 (18:58 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 1 Apr 2009 01:58:03 +0000 (18:58 -0700)
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_emit.h
src/gallium/drivers/r300/r300_state_invariant.c
src/gallium/drivers/r300/r300_state_tcl.h
src/gallium/drivers/r300/r300_surface.c
src/gallium/drivers/r300/r300_surface.h

index a2e9cca39ba8d8652c9a2bddfe92336348dd7176..4032eac1337bc3ff938bbee3a1deef0741b68efd 100644 (file)
@@ -325,9 +325,29 @@ void r300_emit_vertex_format_state(struct r300_context* r300)
     END_CS;
 }
 
+void r300_emit_vertex_shader(struct r300_context* r300,
+                             struct r300_vertex_shader* vs)
+{
+    CS_LOCALS(r300);
+    int i;
+
+    BEGIN_CS(1 + (vs->instruction_count * 4));
+
+    OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, vs->instruction_count * 4);
+    for (i = 0; i < vs->instruction_count; i++) {
+        OUT_CS(vs->instructions[i].inst0);
+        OUT_CS(vs->instructions[i].inst1);
+        OUT_CS(vs->instructions[i].inst2);
+        OUT_CS(vs->instructions[i].inst3);
+    }
+    END_CS;
+
+}
+
 void r300_emit_viewport_state(struct r300_context* r300,
                               struct r300_viewport_state* viewport)
 {
+    /* XXX has_tcl */
     return;
     CS_LOCALS(r300);
 
index 9d92b090aced24383bf14203befebd450376595c..31dbc7ab8531315029a299aa5f46f598ab34f50c 100644 (file)
@@ -64,6 +64,9 @@ void r300_emit_texture(struct r300_context* r300,
 
 void r300_emit_vertex_format_state(struct r300_context* r300);
 
+void r300_emit_vertex_shader(struct r300_context* r300,
+                             struct r300_vertex_shader* vs);
+
 void r300_emit_viewport_state(struct r300_context* r300,
                               struct r300_viewport_state* viewport);
 
index 421f01e62ecfd028fb7c93d65f88720b802bac02..f4bd5b6c4b5dfbc35aa71ff05519581038b156bc 100644 (file)
@@ -156,33 +156,5 @@ void r300_emit_invariant_state(struct r300_context* r300)
     OUT_CS(R300_US_OUT_FMT_UNUSED);
     OUT_CS(R300_US_OUT_FMT_UNUSED);
     OUT_CS_REG(R300_US_W_FMT, R300_W_FMT_W0);
-    /* XXX these magic numbers should be explained when
-     * this becomes a cached state object */
-    if (caps->has_tcl) {
-        OUT_CS_REG(R300_VAP_CNTL, 0xA |
-            (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) |
-            (0xB << R300_VF_MAX_VTX_NUM_SHIFT) |
-            (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT));
-        OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, 0x00100000);
-        OUT_CS_REG(R300_VAP_PVS_CONST_CNTL, 0x00000000);
-        OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_1, 0x00000001);
-        /* XXX translate these back into normal instructions */
-        OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x1);
-        OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, 0x0);
-        OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, 8);
-        OUT_CS(0x00F00203);
-        OUT_CS(0x00D10001);
-        OUT_CS(0x01248001);
-        OUT_CS(0x00000000);
-        OUT_CS(0x00F02203);
-        OUT_CS(0x00D10021);
-        OUT_CS(0x01248021);
-        OUT_CS(0x00000000);
-    } else {
-        OUT_CS_REG(R300_VAP_CNTL, 0xA |
-            (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) |
-            (0x5 << R300_VF_MAX_VTX_NUM_SHIFT) |
-            (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT));
-    }
     END_CS;
 }
index 54900cc191aa97c813efbae4faa3adc9d6ec5046..1b44b9bb04ed8e890dbdde8fb0827a8bdadc0dae 100644 (file)
@@ -66,6 +66,18 @@ struct r300_vs_asm {
     unsigned imm_count;
 };
 
+static struct r300_vertex_shader r300_passthrough_vertex_shader = {
+    .instruction_count = 2,
+    .instructions[0].inst0 = 0xF00203,
+    .instructions[0].inst1 = 0xD10001,
+    .instructions[0].inst2 = 0x1248001,
+    .instructions[0].inst3 = 0x0,
+    .instructions[1].inst0 = 0xF00203,
+    .instructions[1].inst1 = 0xD10021,
+    .instructions[1].inst2 = 0x1248021,
+    .instructions[1].inst3 = 0x0,
+};
+
 void r300_translate_vertex_shader(struct r300_context* r300,
                                   struct r300_vertex_shader* vs);
 
index 9c4f3065a7f6149e493af5e7e140ba90e9e9e303..e524b5bf3efd61372c5b14a3fe348ab3b04ff226 100644 (file)
@@ -39,6 +39,27 @@ static void r300_surface_setup(struct pipe_context* pipe,
     r300_emit_dsa_state(r300, &dsa_clear_state);
     r300_emit_rs_state(r300, &rs_clear_state);
 
+    /* XXX these magic numbers should be explained when
+     * this becomes a cached state object */
+    if (caps->has_tcl) {
+        OUT_CS_REG(R300_VAP_CNTL, 0xA |
+            (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) |
+            (0xB << R300_VF_MAX_VTX_NUM_SHIFT) |
+            (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT));
+        OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, 0x00100000);
+        OUT_CS_REG(R300_VAP_PVS_CONST_CNTL, 0x00000000);
+        OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_1, 0x00000001);
+        /* XXX translate these back into normal instructions */
+        OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x1);
+        OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, 0x0);
+        r300_emit_vertex_shader(r300, &r300_passthrough_vertex_shader);
+    } else {
+        OUT_CS_REG(R300_VAP_CNTL, 0xA |
+            (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) |
+            (0x5 << R300_VF_MAX_VTX_NUM_SHIFT) |
+            (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT));
+    }
+
     BEGIN_CS(15);
 
     /* Pixel scissors. */
index 465b8476edfe17205f0919b41ad50668cc8e7a75..aa34054326c324f8bb75d2be327a85c3ffff24e5 100644 (file)
@@ -32,6 +32,7 @@
 #include "r300_cs.h"
 #include "r300_emit.h"
 #include "r300_state_shader.h"
+#include "r300_state_tcl.h"
 #include "r300_state_inlines.h"
 
 const struct r300_blend_state blend_clear_state = {