r300-gallium: A bit more vertex format fixup.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sat, 7 Mar 2009 08:42:12 +0000 (00:42 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Sat, 7 Mar 2009 08:42:12 +0000 (00:42 -0800)
src/gallium/drivers/r300/r300_reg.h
src/gallium/drivers/r300/r300_state_derived.c
src/gallium/drivers/r300/r300_state_derived.h
src/gallium/drivers/r300/r300_state_inlines.h
src/gallium/drivers/r300/r300_surface.c

index b0394f80c8884dd6e0f9ebe9f2baaf3ab17b6e71..321f5873744462eaf328a9597c3b4430bd7cc765 100644 (file)
@@ -326,6 +326,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_WRITE_ENA_Z                         4
 #       define R300_WRITE_ENA_W                         8
 #       define R300_SWIZZLE1_SHIFT                      16
+
+#       define R300_VAP_SWIZZLE_XYZW \
+        ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \
+         (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \
+         (R300_SWIZZLE_SELECT_Z << R300_SWIZZLE_SELECT_Z_SHIFT) | \
+         (R300_SWIZZLE_SELECT_W << R300_SWIZZLE_SELECT_W_SHIFT) | \
+         (0xf << R300_WRITE_ENA_SHIFT))
+
 #define R300_VAP_PROG_STREAM_CNTL_EXT_1                 0x21e4
 #define R300_VAP_PROG_STREAM_CNTL_EXT_2                 0x21e8
 #define R300_VAP_PROG_STREAM_CNTL_EXT_3                 0x21ec
index b7fb36f6f98b983c4458966700c05b9efaa0fefe..d15b4ff2e1ab5aee57167716b99f5d324b018047 100644 (file)
 /* r300_state_derived: Various bits of state which are dependent upon
  * currently bound CSO data. */
 
-static uint32_t translate_vertex_data_type(int type) {
-    switch (type) {
-        case EMIT_1F:
-        case EMIT_1F_PSIZE:
-            return R300_DATA_TYPE_FLOAT_1;
-            break;
-        case EMIT_2F:
-            return R300_DATA_TYPE_FLOAT_2;
-            break;
-        case EMIT_3F:
-            return R300_DATA_TYPE_FLOAT_3;
-            break;
-        case EMIT_4F:
-            return R300_DATA_TYPE_FLOAT_4;
-            break;
-        default:
-            debug_printf("r300: Implementation error: "
-                    "Bad vertex data type!\n");
-            break;
-    }
-
-    return 0;
-}
-
 /* Update the vertex_info struct in our r300_context.
  *
  * The vertex_info struct describes the post-TCL format of vertices. It is
@@ -156,42 +132,31 @@ static void r300_update_vertex_layout(struct r300_context* r300)
 
     if (memcmp(&r300->vertex_info, &vinfo, sizeof(struct vertex_info))) {
         uint32_t temp;
-
-#define BORING_SWIZZLE \
-        ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \
-         (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \
-         (R300_SWIZZLE_SELECT_Z << R300_SWIZZLE_SELECT_Z_SHIFT) | \
-         (R300_SWIZZLE_SELECT_W << R300_SWIZZLE_SELECT_W_SHIFT) | \
-         (0xf << R300_WRITE_ENA_SHIFT))
+        debug_printf("attrib count: %d, fp input count: %d\n",
+                vinfo.num_attribs, info->num_inputs);
+        for (i = 0; i < vinfo.num_attribs; i++) {
+            debug_printf("attrib: offset %d, interp %d, size %d,"
+                   " tab %d\n", vinfo.attrib[i].src_index,
+                   vinfo.attrib[i].interp_mode, vinfo.attrib[i].emit,
+                   tab[i]);
+        }
 
         for (i = 0; i < vinfo.num_attribs; i++) {
             /* Make sure we have a proper destination for our attribute */
-            if (tab[i] == -1) {
-                debug_printf("attrib count: %d, fp input count: %d\n",
-                        vinfo.num_attribs, info->num_inputs);
-                for (i = 0; i < vinfo.num_attribs; i++) {
-                    debug_printf("attrib: offset %d, interp %d, size %d,"
-                           " tab %d\n", vinfo.attrib[i].src_index,
-                           vinfo.attrib[i].interp_mode, vinfo.attrib[i].emit,
-                           tab[i]);
-                }
-                assert(0);
-            }
+            assert(tab[i] == -1);
 
             temp = translate_vertex_data_type(vinfo.attrib[i].emit) |
-                (tab[i] << R300_DST_VEC_LOC_SHIFT) | R300_SIGNED;
+                (tab[i] << R300_DST_VEC_LOC_SHIFT);
             if (i & 1) {
-                r300->vertex_info.vap_prog_stream_cntl[i >> 1] &= 0xffff;
-                r300->vertex_info.vap_prog_stream_cntl[i >> 1] |=
-                        temp << 16;
+                r300->vertex_info.vap_prog_stream_cntl[i >> 1] &= 0x0000ffff;
+                r300->vertex_info.vap_prog_stream_cntl[i >> 1] |= temp << 16;
             } else {
                 r300->vertex_info.vap_prog_stream_cntl[i >> 1] &= 0xffff0000;
-                r300->vertex_info.vap_prog_stream_cntl[i >> 1] |=
-                    temp;
+                r300->vertex_info.vap_prog_stream_cntl[i >> 1] |= temp;
             }
 
             r300->vertex_info.vap_prog_stream_cntl_ext[i >> 1] |=
-                (BORING_SWIZZLE << (i & 1 ? 16 : 0));
+                (R300_VAP_SWIZZLE_XYZW << (i & 1 ? 16 : 0));
         }
         r300->vertex_info.vap_prog_stream_cntl[i >> 1] |= (R300_LAST_VEC <<
                 (i & 1 ? 16 : 0));
index 72ba6b928d6ea93df885ba6c71b13faf8893bc73..63ae8eb8d08af1981bc4056546dd99af5ed91735 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "r300_context.h"
 #include "r300_reg.h"
+#include "r300_state_inlines.h"
 
 void r300_update_derived_state(struct r300_context* r300);
 
index 630ac3b2fc48cd837275777a35c6936fd490e6bc..8d8b74dfc1d09bb3da84aa416186982b477d8198 100644 (file)
@@ -344,4 +344,32 @@ static INLINE uint32_t r300_translate_gb_pipes(int pipe_count)
     return 0;
 }
 
+static uint32_t translate_vertex_data_type(int type) {
+    switch (type) {
+        case EMIT_1F:
+        case EMIT_1F_PSIZE:
+            return R300_DATA_TYPE_FLOAT_1 | R300_SIGNED;
+            break;
+        case EMIT_2F:
+            return R300_DATA_TYPE_FLOAT_2 | R300_SIGNED;
+            break;
+        case EMIT_3F:
+            return R300_DATA_TYPE_FLOAT_3 | R300_SIGNED;
+            break;
+        case EMIT_4F:
+            return R300_DATA_TYPE_FLOAT_4 | R300_SIGNED;
+            break;
+        case EMIT_4UB:
+            return R300_DATA_TYPE_BYTE;
+            break;
+        default:
+            debug_printf("r300: Implementation error: "
+                    "Bad vertex data type!\n");
+            assert(0);
+            break;
+    }
+
+    return 0;
+}
+
 #endif /* R300_STATE_INLINES_H */
index 9f81e2e730c3a53c9938385e7d4ca8f63351ab48..2040967253f830a358c27536e7178631fe8ae91c 100644 (file)
@@ -72,7 +72,7 @@ static void r300_surface_fill(struct pipe_context* pipe,
         r300_emit_rs_block_state(r300, &r300_rs_block_clear_state);
     }
 
-    BEGIN_CS(112 + (caps->has_tcl ? 2 : 0));
+    BEGIN_CS(106 + (caps->has_tcl ? 2 : 0));
     /* Flush PVS. */
     OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);
 
@@ -80,8 +80,6 @@ static void r300_surface_fill(struct pipe_context* pipe,
         R300_VPORT_X_OFFSET_ENA | R300_VPORT_Y_SCALE_ENA |
         R300_VPORT_Y_OFFSET_ENA | R300_VPORT_Z_SCALE_ENA |
         R300_VPORT_Z_OFFSET_ENA | R300_VTX_W0_FMT);
-    /* Vertex size. */
-    OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8);
     /* Max and min vertex index clamp. */
     OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, 0xFFFFFF);
     OUT_CS_REG(R300_VAP_VF_MIN_VTX_INDX, 0x0);
@@ -145,11 +143,14 @@ static void r300_surface_fill(struct pipe_context* pipe,
             ((R300_LAST_VEC | (2 << R300_DST_VEC_LOC_SHIFT) |
                 R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT));
     }
-    OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_EXT_0, 0xF688F688);
+    OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_EXT_0,
+            (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE0_SHIFT) |
+            (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE1_SHIFT));
     OUT_CS_REG(R300_VAP_VTX_STATE_CNTL, 0x1);
     OUT_CS_REG(R300_VAP_VSM_VTX_ASSM, 0x405);
     OUT_CS_REG(R300_SE_VTE_CNTL, 0x0000043F);
-    OUT_CS_REG(R300_VAP_VTX_SIZE, 0x00000008);
+    /* Vertex size. */
+    OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8);
     OUT_CS_REG(R300_VAP_PSC_SGN_NORM_CNTL, 0xAAAAAAAA);
     OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_0, 0x00000003);
     OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x00000000);