r300g: add capability bit index_bias_supported
authorMarek Olšák <maraeo@gmail.com>
Fri, 3 Dec 2010 07:01:19 +0000 (08:01 +0100)
committerMarek Olšák <maraeo@gmail.com>
Fri, 3 Dec 2010 19:34:56 +0000 (20:34 +0100)
.. instead of calling r500_index_bias_supported(..) every draw call.

src/gallium/drivers/r300/r300_chipset.h
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_flush.c
src/gallium/drivers/r300/r300_render.c
src/gallium/drivers/r300/r300_screen.c

index 7ea4175dbee57a9197fc67d9b9d90a2f52a61a7d..f2035d2009243733f58548bcf1b153e3d65682c6 100644 (file)
@@ -81,6 +81,8 @@ struct r300_capabilities {
     boolean high_second_pipe;
     /* DXTC texture swizzling. */
     boolean dxtc_swizzle;
+    /* Index bias (AKA index offset). */
+    boolean index_bias_supported;
 };
 
 /* Enumerations for legibility and telling which card we're running on. */
index 93c20a0a6a00c135be5b8678166642ba75349be4..b543ad667ed3c9d8912d7f71745d4bfac6c71c7e 100644 (file)
@@ -673,7 +673,6 @@ void r300_plug_in_stencil_ref_fallback(struct r300_context *r300);
 
 /* r300_render.c */
 void r300_draw_flush_vbuf(struct r300_context *r300);
-boolean r500_index_bias_supported(struct r300_context *r300);
 void r500_emit_index_bias(struct r300_context *r300, int index_bias);
 
 /* r300_state.c */
index 31c7b38adfbfd1181959d2e240d4f222dcaadffb..2b1372717490bd4493776c2163237d5d2acbd352 100644 (file)
@@ -1260,7 +1260,7 @@ unsigned r300_get_num_cs_end_dwords(struct r300_context *r300)
     /* Emitted in flush. */
     dwords += 26; /* emit_query_end */
     dwords += r300->hyperz_state.size + 2; /* emit_hyperz_end + zcache flush */
-    if (r500_index_bias_supported(r300))
+    if (r300->screen->caps.index_bias_supported)
         dwords += 2;
 
     return dwords;
index 1afd27f0938210fb9fdf71cd634d1b07e0ee4c94..16de7fd4130c9e76479f13f5f7e4f2709847396d 100644 (file)
@@ -49,7 +49,7 @@ static void r300_flush(struct pipe_context* pipe,
     if (r300->dirty_hw) {
         r300_emit_hyperz_end(r300);
         r300_emit_query_end(r300);
-        if (r500_index_bias_supported(r300))
+        if (r300->screen->caps.index_bias_supported)
             r500_emit_index_bias(r300, 0);
 
         r300->flush_counter++;
index 2f8b6b83370af0ecc06931f31d98a7e947676347..07581408ab9c733adb9249a5e256d319c84bb921 100644 (file)
@@ -118,12 +118,6 @@ static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300,
     return color_control;
 }
 
-boolean r500_index_bias_supported(struct r300_context *r300)
-{
-    return r300->screen->caps.is_r500 &&
-           r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0);
-}
-
 void r500_emit_index_bias(struct r300_context *r300, int index_bias)
 {
     CS_LOCALS(r300);
@@ -193,13 +187,12 @@ static boolean r300_reserve_cs_dwords(struct r300_context *r300,
     boolean first_draw     = flags & PREP_FIRST_DRAW;
     boolean emit_aos       = flags & PREP_EMIT_AOS;
     boolean emit_aos_swtcl = flags & PREP_EMIT_AOS_SWTCL;
-    boolean hw_index_bias  = r500_index_bias_supported(r300);
 
     /* Add dirty state, index offset, and AOS. */
     if (first_draw) {
         cs_dwords += r300_get_num_dirty_dwords(r300);
 
-        if (hw_index_bias)
+        if (r300->screen->caps.index_bias_supported)
             cs_dwords += 2; /* emit_index_offset */
 
         if (emit_aos)
@@ -537,7 +530,7 @@ static void r300_draw_range_elements(struct pipe_context* pipe,
     int buffer_offset = 0, index_offset = 0; /* for index bias emulation */
     unsigned new_offset;
 
-    if (indexBias && !r500_index_bias_supported(r300)) {
+    if (indexBias && !r300->screen->caps.index_bias_supported) {
         r300_split_index_bias(r300, indexBias, &buffer_offset, &index_offset);
     }
 
index 09981cb26b83372f44dc33a7ec0ef7cb72aef0e3..921d6f1e676f78a14c8d82ef3f124c940e1903fc 100644 (file)
@@ -457,6 +457,10 @@ struct pipe_screen* r300_screen_create(struct r300_winsys_screen *rws)
     r300_init_debug(r300screen);
     r300_parse_chipset(&r300screen->caps);
 
+    r300screen->caps.index_bias_supported =
+            r300screen->caps.is_r500 &&
+            rws->get_value(rws, R300_VID_DRM_2_3_0);
+
     util_slab_create(&r300screen->pool_buffers,
                      sizeof(struct r300_buffer), 64,
                      UTIL_SLAB_SINGLETHREADED);