r300g: Don't pass hw_prim around in the context.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sat, 7 Nov 2009 17:47:01 +0000 (09:47 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Sat, 7 Nov 2009 19:53:14 +0000 (11:53 -0800)
And some other fixes.

src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_emit.h
src/gallium/drivers/r300/r300_render.c
src/gallium/drivers/r300/r300_vbo.c

index a6748852d83a2ae124c48381ed6b9c98f9a4cefc..8d14c53f492be1f003c72f206fb56b93ca738325 100644 (file)
@@ -299,7 +299,6 @@ struct r300_context {
     /* Vertex elements for Gallium. */
     struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
     int aos_count;
-    unsigned hw_prim;
 
     /* Bitmask of dirty state objects. */
     uint32_t dirty_state;
index 92e6ec606ca79b4d9ee3d90fbea9289cb3462d5c..ec1d521800cac0f1082246eae13132b40e6ec922 100644 (file)
@@ -647,64 +647,6 @@ void r300_emit_draw_packet(struct r300_context* r300)
     END_CS;
 }
 #endif
-void r300_emit_draw_arrays(struct r300_context *r300,
-                           unsigned count)
-{
-    CS_LOCALS(r300);
-    assert(count < 65536);
-
-    BEGIN_CS(4);
-    OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, count);
-    OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2, 0);
-    OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (count << 16) |
-           r300->hw_prim);
-    END_CS;
-}
-
-void r300_emit_draw_elements(struct r300_context *r300,
-                             struct pipe_buffer* indexBuffer,
-                             unsigned indexSize,
-                             unsigned minIndex,
-                             unsigned maxIndex,
-                             unsigned start,
-                             unsigned count)
-{
-    CS_LOCALS(r300);
-    assert(indexSize == 4 || indexSize == 2);
-    assert(count < 65536);
-    assert((start * indexSize)  % 4 == 0);
-
-    uint32_t size_dwords;
-    uint32_t skip_dwords = indexSize * start / sizeof(uint32_t);
-    assert(skip_dwords == 0);
-
-    BEGIN_CS(10);
-    OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, maxIndex);
-    OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, 0);
-    if (indexSize == 4) {
-        size_dwords = count + start;
-        OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
-               R300_VAP_VF_CNTL__INDEX_SIZE_32bit | r300->hw_prim);
-    } else {
-        size_dwords = (count + start + 1) / 2;
-        OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES |
-               (count << 16) | r300->hw_prim);
-    }
-
-    OUT_CS_PKT3(R300_PACKET3_INDX_BUFFER, 2);
-    OUT_CS(R300_INDX_BUFFER_ONE_REG_WR | (R300_VAP_PORT_IDX0 >> 2) |
-           (0 << R300_INDX_BUFFER_SKIP_SHIFT));
-    OUT_CS(skip_dwords);
-    OUT_CS(size_dwords);
-    cs_winsys->write_cs_reloc(cs_winsys,
-                              indexBuffer,
-                              RADEON_GEM_DOMAIN_GTT,
-                              0,
-                              0);
-    cs_count -= 2;
-
-    END_CS;
-}
 
 void r300_emit_vertex_format_state(struct r300_context* r300)
 {
index b4fdfecde019dc012b9971ef46ee8ebcc87bf88f..7c83c5166de9d8d17e7bc2458a4bc4719fb2537c 100644 (file)
@@ -40,16 +40,6 @@ void r300_emit_blend_color_state(struct r300_context* r300,
 void r300_emit_clip_state(struct r300_context* r300,
                           struct pipe_clip_state* clip);
 
-void r300_emit_draw_arrays(struct r300_context *r300, unsigned count);
-
-void r300_emit_draw_elements(struct r300_context *r300,
-                             struct pipe_buffer* indexBuffer,
-                             unsigned indexSize,
-                             unsigned minIndex,
-                             unsigned maxIndex,
-                             unsigned start,
-                             unsigned count);
-
 void r300_emit_dsa_state(struct r300_context* r300,
                          struct r300_dsa_state* dsa);
 
index cbda30227da0c9870e34ada2d48e9bdd92faf215..6f7c6453342a4eee4ed0b01ad647c47f10585cac 100644 (file)
 #include "util/u_memory.h"
 #include "util/u_prim.h"
 
-#include "r300_vbo.h"
 #include "r300_cs.h"
 #include "r300_context.h"
 #include "r300_emit.h"
 #include "r300_reg.h"
 #include "r300_render.h"
 #include "r300_state_derived.h"
+#include "r300_vbo.h"
 
 /* r300_render: Vertex and index buffer primitive emission. */
 #define R300_MAX_VBO_SIZE  (1024 * 1024)
@@ -70,6 +70,70 @@ uint32_t r300_translate_primitive(unsigned prim)
     }
 }
 
+static void r300_emit_draw_arrays(struct r300_context *r300,
+                                  unsigned mode,
+                                  unsigned count)
+{
+    CS_LOCALS(r300);
+    assert(count < 65536);
+
+    BEGIN_CS(4);
+    OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, count);
+    OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2, 0);
+    OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (count << 16) |
+           r300_translate_primitive(mode));
+    END_CS;
+}
+
+static void r300_emit_draw_elements(struct r300_context *r300,
+                                    struct pipe_buffer* indexBuffer,
+                                    unsigned indexSize,
+                                    unsigned minIndex,
+                                    unsigned maxIndex,
+                                    unsigned mode,
+                                    unsigned start,
+                                    unsigned count)
+{
+    CS_LOCALS(r300);
+    assert(indexSize == 4 || indexSize == 2);
+    assert(count < 65536);
+    assert((start * indexSize)  % 4 == 0);
+
+    uint32_t size_dwords;
+    uint32_t skip_dwords = indexSize * start / sizeof(uint32_t);
+    assert(skip_dwords == 0);
+
+    BEGIN_CS(10);
+    OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, maxIndex);
+    OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, 0);
+    if (indexSize == 4) {
+        size_dwords = count + start;
+        OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
+               R300_VAP_VF_CNTL__INDEX_SIZE_32bit |
+               r300_translate_primitive(mode));
+    } else {
+        size_dwords = (count + start + 1) / 2;
+        OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
+               r300_translate_primitive(mode));
+    }
+
+    OUT_CS_PKT3(R300_PACKET3_INDX_BUFFER, 2);
+    OUT_CS(R300_INDX_BUFFER_ONE_REG_WR | (R300_VAP_PORT_IDX0 >> 2) |
+           (0 << R300_INDX_BUFFER_SKIP_SHIFT));
+    OUT_CS(skip_dwords);
+    OUT_CS(size_dwords);
+    /* XXX hax */
+    cs_winsys->write_cs_reloc(cs_winsys,
+                              indexBuffer,
+                              RADEON_GEM_DOMAIN_GTT,
+                              0,
+                              0);
+    cs_count -= 2;
+
+    END_CS;
+}
+
+
 static boolean setup_vertex_buffers(struct r300_context *r300)
 {
     unsigned vbuf_count = r300->aos_count;
@@ -123,14 +187,12 @@ boolean r300_draw_range_elements(struct pipe_context* pipe,
 
     setup_index_buffer(r300, indexBuffer, indexSize);
 
-    r300->hw_prim = r300_translate_primitive(mode);
-
     r300_emit_dirty_state(r300);
 
     r300_emit_aos(r300, 0);
 
     r300_emit_draw_elements(r300, indexBuffer, indexSize, minIndex, maxIndex,
-                            start, count);
+                            mode, start, count);
 
     return TRUE;
 }
@@ -159,13 +221,11 @@ boolean r300_draw_arrays(struct pipe_context* pipe, unsigned mode,
 
     setup_vertex_attributes(r300);
 
-    r300->hw_prim = r300_translate_primitive(mode);
-
     r300_emit_dirty_state(r300);
 
     r300_emit_aos(r300, start);
 
-    r300_emit_draw_arrays(r300, count);
+    r300_emit_draw_arrays(r300, mode, count);
 
     return TRUE;
 }
@@ -186,8 +246,8 @@ boolean r300_swtcl_draw_range_elements(struct pipe_context* pipe,
                                        unsigned count)
 {
     assert(0);
-    struct r300_context* r300 = r300_context(pipe);
 #if 0
+    struct r300_context* r300 = r300_context(pipe);
     int i;
 
     if (!u_trim_pipe_prim(mode, &count)) {
index 37b5c9224fc7344c5794e498bf7a3ff88e13594b..ab6f5c59426b3471efb508f391b55492992b2ae3 100644 (file)
@@ -56,7 +56,8 @@ static INLINE void setup_vertex_attribute(struct r300_vertex_info *vinfo,
 static void finish_vertex_attribs_setup(struct r300_vertex_info *vinfo,
                                         unsigned attribs_num)
 {
-    uint32_t last_vec_bit = (attribs_num % 2 == 0) ? (R300_LAST_VEC << 16) : R300_LAST_VEC;
+    uint32_t last_vec_bit = (attribs_num % 2 == 0) ?
+        (R300_LAST_VEC << 16) : R300_LAST_VEC;
 
     assert(attribs_num > 0 && attribs_num <= 16);
     vinfo->vap_prog_stream_cntl[(attribs_num - 1) >> 1] |= last_vec_bit;
@@ -64,10 +65,11 @@ static void finish_vertex_attribs_setup(struct r300_vertex_info *vinfo,
 
 void setup_vertex_attributes(struct r300_context *r300)
 {
-    for (int i=0; i<r300->aos_count; i++)
-    {
-        struct pipe_vertex_element *vert_elem = &r300->vertex_element[i];
+    struct pipe_vertex_element *vert_elem;
+    int i;
 
+    for (i = 0; i < r300->aos_count; i++) {
+        vert_elem = &r300->vertex_element[i];
         setup_vertex_attribute(r300->vertex_info, vert_elem, i);
     }