summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r600/r600_query.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2012-02-02 14:01:12 +0100
committerMarek Olšák <[email protected]>2012-02-21 21:42:27 +0100
commite2809849ecac69615ece294a55ee355afaac33d3 (patch)
tree6773e21ab0f548157a5dc26580af2a0214a94cfa /src/gallium/drivers/r600/r600_query.c
parent8f5c172c854a52b2a69b8383a55c76f1faa5f704 (diff)
r600g: add a depth misc state which depends on occlusion queries
This is a state which is derived from other states and is actually the first state which doesn't correspond to any gallium state. There are two state flags: bool occlusion_query_enabled bool flush_depthstencil_enabled Additional flags can be added later if needed, e.g. bool hiz_enabled. The emit function will have to figure out the register values by itself. It basically just emits the registers when the state changes. This commit also adds a few helper functions for writing registers directly into a command stream.
Diffstat (limited to 'src/gallium/drivers/r600/r600_query.c')
-rw-r--r--src/gallium/drivers/r600/r600_query.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/gallium/drivers/r600/r600_query.c b/src/gallium/drivers/r600/r600_query.c
index faec99c6a80..f2e6d010659 100644
--- a/src/gallium/drivers/r600/r600_query.c
+++ b/src/gallium/drivers/r600/r600_query.c
@@ -37,11 +37,32 @@ static void r600_destroy_query(struct pipe_context *ctx, struct pipe_query *quer
r600_context_query_destroy(rctx, (struct r600_query *)query);
}
+static void r600_update_occlusion_query_state(struct r600_context *rctx,
+ unsigned type, int diff)
+{
+ if (type == PIPE_QUERY_OCCLUSION_COUNTER ||
+ type == PIPE_QUERY_OCCLUSION_PREDICATE) {
+ bool enable;
+
+ rctx->num_occlusion_queries += diff;
+ assert(rctx->num_occlusion_queries >= 0);
+
+ enable = rctx->num_occlusion_queries != 0;
+
+ if (rctx->atom_db_misc_state.occlusion_query_enabled != enable) {
+ rctx->atom_db_misc_state.occlusion_query_enabled = enable;
+ r600_atom_dirty(rctx, &rctx->atom_db_misc_state.atom);
+ }
+ }
+}
+
static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query)
{
struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_query *rquery = (struct r600_query *)query;
+ r600_update_occlusion_query_state(rctx, rquery->type, 1);
+
memset(&rquery->result, 0, sizeof(rquery->result));
rquery->results_start = rquery->results_end;
r600_query_begin(rctx, (struct r600_query *)query);
@@ -55,6 +76,8 @@ static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query)
r600_query_end(rctx, rquery);
LIST_DELINIT(&rquery->list);
+
+ r600_update_occlusion_query_state(rctx, rquery->type, -1);
}
static boolean r600_get_query_result(struct pipe_context *ctx,