r300-gallium: Moar vert shader emit.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 1 Apr 2009 03:04:56 +0000 (20:04 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 1 Apr 2009 03:23:55 +0000 (20:23 -0700)
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_reg.h
src/gallium/drivers/r300/r300_state_invariant.c
src/gallium/drivers/r300/r300_state_tcl.h
src/gallium/drivers/r300/r300_surface.c

index 4032eac1337bc3ff938bbee3a1deef0741b68efd..989fba74df030b3e9f6ca55a8ec3f6f0071c6fe1 100644 (file)
@@ -329,10 +329,26 @@ void r300_emit_vertex_shader(struct r300_context* r300,
                              struct r300_vertex_shader* vs)
 {
     CS_LOCALS(r300);
+    struct r300_screen* r300screen = r300_screen(r300->context.screen);
     int i;
 
-    BEGIN_CS(1 + (vs->instruction_count * 4));
+    if (!r300screen->caps->has_tcl) {
+        debug_printf("r300: Implementation error: emit_vertex_shader called,"
+                " but has_tcl is FALSE!\n");
+        return;
+    }
+
+    BEGIN_CS(13 + (vs->instruction_count * 4));
+    OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);
 
+    OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, R300_PVS_FIRST_INST(0) |
+            R300_PVS_LAST_INST(vs->instruction_count - 1));
+    OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_1, vs->instruction_count - 1);
+
+    /* XXX */
+    OUT_CS_REG(R300_VAP_PVS_CONST_CNTL, 0x0);
+
+    OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, 0);
     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);
@@ -340,6 +356,11 @@ void r300_emit_vertex_shader(struct r300_context* r300,
         OUT_CS(vs->instructions[i].inst2);
         OUT_CS(vs->instructions[i].inst3);
     }
+
+    OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(10) |
+            R300_PVS_NUM_CNTLRS(5) |
+            R300_PVS_NUM_FPUS(r300screen->caps->num_vert_fpus) |
+            R300_PVS_VF_MAX_VTX_NUM(12));
     END_CS;
 
 }
index c9a195a6ce434399e19809058e9e94586e5f7372..660816e1da158e8139c20e3ba58a9c60370ac69a 100644 (file)
@@ -73,6 +73,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_PVS_NUM_CNTLRS_SHIFT                4
 #       define R300_PVS_NUM_FPUS_SHIFT                  8
 #       define R300_VF_MAX_VTX_NUM_SHIFT                18
+#       define R300_PVS_NUM_SLOTS(x)                    ((x) << 0)
+#       define R300_PVS_NUM_CNTLRS(x)                   ((x) << 4)
+#       define R300_PVS_NUM_FPUS(x)                     ((x) << 8)
+#       define R300_PVS_VF_MAX_VTX_NUM(x)               ((x) << 18)
 #       define R300_GL_CLIP_SPACE_DEF                   (0 << 22)
 #       define R300_DX_CLIP_SPACE_DEF                   (1 << 22)
 #       define R500_TCL_STATE_OPTIMIZATION              (1 << 23)
@@ -506,6 +510,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_PVS_FIRST_INST_SHIFT         0
 #       define R300_PVS_XYZW_VALID_INST_SHIFT    10
 #       define R300_PVS_LAST_INST_SHIFT          20
+#       define R300_PVS_FIRST_INST(x)            ((x) << 0)
+#       define R300_PVS_LAST_INST(x)             ((x) << 20)
 /* Addresses are relative the the vertex program parameters area. */
 #define R300_VAP_PVS_CONST_CNTL             0x22D4
 #       define R300_PVS_CONST_BASE_OFFSET_SHIFT  0
index f4bd5b6c4b5dfbc35aa71ff05519581038b156bc..8bd9b41bd74d12119dd95c0cf99b2311ec58308f 100644 (file)
@@ -86,7 +86,7 @@ void r300_emit_invariant_state(struct r300_context* r300)
     END_CS;
 
     /* XXX unsorted stuff from surface_fill */
-    BEGIN_CS(81 + (caps->has_tcl ? 26 : 0));
+    BEGIN_CS(79 + (caps->has_tcl ? 7 : 0));
     /* Flush PVS. */
     OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);
 
index 1b44b9bb04ed8e890dbdde8fb0827a8bdadc0dae..bc22cd984dd3bff6cfe12dd8566846c99d99dbc7 100644 (file)
@@ -67,6 +67,7 @@ struct r300_vs_asm {
 };
 
 static struct r300_vertex_shader r300_passthrough_vertex_shader = {
+        /* XXX translate these back into normal instructions */
     .instruction_count = 2,
     .instructions[0].inst0 = 0xF00203,
     .instructions[0].inst1 = 0xD10001,
index e524b5bf3efd61372c5b14a3fe348ab3b04ff226..8cafe7d10455946be15fd721f871560405f8d857 100644 (file)
@@ -42,22 +42,12 @@ static void r300_surface_setup(struct pipe_context* pipe,
     /* 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));
+        OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(5) |
+                R300_PVS_NUM_CNTLRS(5) |
+                R300_PVS_NUM_FPUS(caps->num_vert_fpus) |
+                R300_PVS_VF_MAX_VTX_NUM(12));
     }
 
     BEGIN_CS(15);