r300/compiler: generalize depth texture mode to support arbitrary swizzles
[mesa.git] / src / gallium / drivers / r300 / r300_context.c
index 490f77341fc0ddd04fd509d6854f3fba48ea5389..e84bce0010f453b88d6d3f205b778a87844b2140 100644 (file)
 #include "r300_screen.h"
 #include "r300_screen_buffer.h"
 #include "r300_state_invariant.h"
-#include "r300_transfer.h"
 #include "r300_winsys.h"
 
+#include <inttypes.h>
+
 static void r300_destroy_context(struct pipe_context* context)
 {
     struct r300_context* r300 = r300_context(context);
     struct r300_query* query, * temp;
+    struct r300_atom *atom;
 
     util_blitter_destroy(r300->blitter);
     draw_destroy(r300->draw);
 
+    /* Print stats, if enabled. */
+    if (SCREEN_DBG_ON(r300->screen, DBG_STATS)) {
+        fprintf(stderr, "r300: Stats for context %p:\n", r300);
+        fprintf(stderr, "    : Flushes: %" PRIu64 "\n", r300->flush_counter);
+        foreach(atom, &r300->atom_list) {
+            fprintf(stderr, "    : %s: %" PRIu64 " emits\n",
+                atom->name, atom->counter);
+        }
+    }
+
     /* Free the OQ BO. */
     context->screen->resource_destroy(context->screen, r300->oqbo);
 
@@ -64,13 +76,13 @@ static void r300_destroy_context(struct pipe_context* context)
     FREE(r300->rs_block_state.state);
     FREE(r300->scissor_state.state);
     FREE(r300->textures_state.state);
-    FREE(r300->vap_output_state.state);
     FREE(r300->viewport_state.state);
     FREE(r300->ztop_state.state);
+    FREE(r300->fs_constants.state);
+    FREE(r300->vs_constants.state);
     FREE(r300);
 }
 
-
 static void r300_flush_cb(void *data)
 {
     struct r300_context* const cs_context_copy = data;
@@ -100,6 +112,7 @@ static void r300_setup_atoms(struct r300_context* r300)
      * the size of 0 here. */
     make_empty_list(&r300->atom_list);
     R300_INIT_ATOM(invariant_state, 71);
+    R300_INIT_ATOM(query_start, 4);
     R300_INIT_ATOM(ztop_state, 2);
     R300_INIT_ATOM(blend_state, 8);
     R300_INIT_ATOM(blend_color_state, is_r500 ? 3 : 2);
@@ -111,11 +124,21 @@ static void r300_setup_atoms(struct r300_context* r300)
     R300_INIT_ATOM(viewport_state, 9);
     R300_INIT_ATOM(rs_block_state, 0);
     R300_INIT_ATOM(vertex_stream_state, 0);
-    R300_INIT_ATOM(vap_output_state, 6);
     R300_INIT_ATOM(pvs_flush, 2);
     R300_INIT_ATOM(vs_state, 0);
+    R300_INIT_ATOM(vs_constants, 0);
     R300_INIT_ATOM(texture_cache_inval, 2);
     R300_INIT_ATOM(textures_state, 0);
+    R300_INIT_ATOM(fs, 0);
+    R300_INIT_ATOM(fs_rc_constant_state, 0);
+    R300_INIT_ATOM(fs_constants, 0);
+
+    /* Replace emission functions for r500. */
+    if (r300->screen->caps.is_r500) {
+        r300->fs.emit = r500_emit_fs;
+        r300->fs_rc_constant_state.emit = r500_emit_fs_rc_constant_state;
+        r300->fs_constants.emit = r500_emit_fs_constants;
+    }
 
     /* Some non-CSO atoms need explicit space to store the state locally. */
     r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state);
@@ -124,9 +147,10 @@ static void r300_setup_atoms(struct r300_context* r300)
     r300->rs_block_state.state = CALLOC_STRUCT(r300_rs_block);
     r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state);
     r300->textures_state.state = CALLOC_STRUCT(r300_textures_state);
-    r300->vap_output_state.state = CALLOC_STRUCT(r300_vap_output_state);
     r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state);
     r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state);
+    r300->fs_constants.state = CALLOC_STRUCT(r300_constant_buffer);
+    r300->vs_constants.state = CALLOC_STRUCT(r300_constant_buffer);
 }
 
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
@@ -172,7 +196,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
         r300->context.draw_range_elements = r300_swtcl_draw_range_elements;
 
         /* Create a Draw. This is used for SW TCL. */
-        r300->draw = draw_create();
+        r300->draw = draw_create(&r300->context);
         /* Enable our renderer. */
         draw_set_rasterize_stage(r300->draw, r300_draw_stage(r300));
         /* Enable Draw's clipping. */