r600g: implement set_active_query_state for pausing occlusion queries
authorMarek Olšák <marek.olsak@amd.com>
Fri, 8 Apr 2016 18:41:52 +0000 (20:41 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 12 Apr 2016 12:29:47 +0000 (14:29 +0200)
Use ZPASS_INCREMENT_DISABLE everywhere.

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/evergreend.h
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/r600/r600d.h
src/gallium/drivers/radeon/r600_query.c

index 077664d068e4f334ca0e0bb790ecf13306cf94ae..c1b0b56ece4948584bcc550a65e736e0bb5f6963 100644 (file)
@@ -1802,12 +1802,15 @@ static void evergreen_emit_db_misc_state(struct r600_context *rctx, struct r600_
                S_02800C_FORCE_HIS_ENABLE0(V_02800C_FORCE_DISABLE) |
                S_02800C_FORCE_HIS_ENABLE1(V_02800C_FORCE_DISABLE);
 
-       if (rctx->b.num_occlusion_queries > 0) {
+       if (rctx->b.num_occlusion_queries > 0 &&
+           !a->occlusion_queries_disabled) {
                db_count_control |= S_028004_PERFECT_ZPASS_COUNTS(1);
                if (rctx->b.chip_class == CAYMAN) {
                        db_count_control |= S_028004_SAMPLE_RATE(a->log_samples);
                }
                db_render_override |= S_02800C_NOOP_CULL_DISABLE(1);
+       } else {
+               db_count_control |= S_028004_ZPASS_INCREMENT_DISABLE(1);
        }
 
        /* This is to fix a lockup when hyperz and alpha test are enabled at
index ebe8c4a65ba92d2b1773b475da3b7703e91d9080..a900458f588473db3ac99787d6c3f538cdbe51dd 100644 (file)
 #define   S_028000_COPY_SAMPLE(x)                      (((x) & 0x7) << 8)
 #define   S_028000_COLOR_DISABLE(x)                    (((x) & 0x1) << 12)
 #define R_028004_DB_COUNT_CONTROL                    0x00028004
-#define   S_028004_ZPASS_INCREMENT_DISABLE        (((x) & 0x1) << 0)
+#define   S_028004_ZPASS_INCREMENT_DISABLE(x)     (((x) & 0x1) << 0)
 #define   S_028004_PERFECT_ZPASS_COUNTS(x)        (((x) & 0x1) << 1)
 #define   S_028004_SAMPLE_RATE(x)                 (((x) & 0x7) << 4) /* cayman only */
 #define R_028008_DB_DEPTH_VIEW                       0x00028008
index de3fd06aac3c51a0b86c57f36327762143f33bef..0102638723b0e5f2a1bfa28edc655131714412f2 100644 (file)
@@ -120,6 +120,7 @@ struct r600_db_state {
 
 struct r600_db_misc_state {
        struct r600_atom                atom;
+       bool                            occlusion_queries_disabled;
        bool                            flush_depthstencil_through_cb;
        bool                            flush_depth_inplace;
        bool                            flush_stencil_inplace;
index 62b46ce52a139afb828ba9725baa5376829d53d4..c4de9639a79b3c6fa67a5483e1facfff8ce3cd1a 100644 (file)
@@ -1644,12 +1644,16 @@ static void r600_emit_db_misc_state(struct r600_context *rctx, struct r600_atom
                }
        }
 
-       if (rctx->b.num_occlusion_queries > 0) {
+       if (rctx->b.num_occlusion_queries > 0 &&
+           !a->occlusion_queries_disabled) {
                if (rctx->b.chip_class >= R700) {
                        db_render_control |= S_028D0C_R700_PERFECT_ZPASS_COUNTS(1);
                }
                db_render_override |= S_028D10_NOOP_CULL_DISABLE(1);
+       } else {
+               db_render_control |= S_028D0C_ZPASS_INCREMENT_DISABLE(1);
        }
+
        if (rctx->db_state.rsurf && rctx->db_state.rsurf->db_htile_surface) {
                /* FORCE_OFF means HiZ/HiS are determined by DB_SHADER_CONTROL */
                db_render_override |= S_028D10_FORCE_HIZ_ENABLE(V_028D10_FORCE_OFF);
index 32a10491e8ba7064938699a57d42e589feef3eab..cdb493dad28cf3b61c99620edc4684a195e28364 100644 (file)
@@ -2860,6 +2860,17 @@ static void r600_invalidate_buffer(struct pipe_context *ctx, struct pipe_resourc
        }
 }
 
+static void r600_set_active_query_state(struct pipe_context *ctx, boolean enable)
+{
+       struct r600_context *rctx = (struct r600_context*)ctx;
+
+       /* Occlusion queries. */
+       if (rctx->db_misc_state.occlusion_queries_disabled != !enable) {
+               rctx->db_misc_state.occlusion_queries_disabled = !enable;
+               r600_mark_atom_dirty(rctx, &rctx->db_misc_state.atom);
+       }
+}
+
 static void r600_set_occlusion_query_state(struct pipe_context *ctx, bool enable)
 {
        struct r600_context *rctx = (struct r600_context*)ctx;
@@ -2914,6 +2925,7 @@ void r600_init_common_state_functions(struct r600_context *rctx)
        rctx->b.b.sampler_view_destroy = r600_sampler_view_destroy;
        rctx->b.b.texture_barrier = r600_texture_barrier;
        rctx->b.b.set_stream_output_targets = r600_set_streamout_targets;
+       rctx->b.b.set_active_query_state = r600_set_active_query_state;
        rctx->b.b.draw_vbo = r600_draw_vbo;
        rctx->b.invalidate_buffer = r600_invalidate_buffer;
        rctx->b.set_occlusion_query_state = r600_set_occlusion_query_state;
index ef99573ebc610fc993f33439890ae07f0e6f99f5..0c18445f015fb8cbef533fbc4c6cf43ad214de00 100644 (file)
 #define   S_028D0C_DEPTH_COMPRESS_DISABLE(x)           (((x) & 0x1) << 6)
 #define   S_028D0C_COPY_CENTROID(x)                    (((x) & 0x1) << 7)
 #define   S_028D0C_COPY_SAMPLE(x)                      (((x) & 0x03) << 8)
+#define   S_028D0C_ZPASS_INCREMENT_DISABLE(x)          (((x) & 0x1) << 11)
 #define   S_028D0C_R700_PERFECT_ZPASS_COUNTS(x)        (((x) & 0x1) << 15)
 #define   S_028D0C_CONSERVATIVE_Z_EXPORT(x)            (((x) & 0x03) << 13)
 #define   G_028D0C_CONSERVATIVE_Z_EXPORT(x)            (((x) >> 13) & 0x03)
index d780b8c182f22ffbb40bc8eedba75c26bde1e31c..7a2d2ee7f316d7e6b9a7e1ea08305fdec882f9fc 100644 (file)
@@ -1261,11 +1261,6 @@ static int r600_get_driver_query_group_info(struct pipe_screen *screen,
        return 1;
 }
 
-static void
-r600_set_active_query_state(struct pipe_context *pipe, boolean enable)
-{
-}
-
 void r600_query_init(struct r600_common_context *rctx)
 {
        rctx->b.create_query = r600_create_query;
@@ -1274,7 +1269,6 @@ void r600_query_init(struct r600_common_context *rctx)
        rctx->b.begin_query = r600_begin_query;
        rctx->b.end_query = r600_end_query;
        rctx->b.get_query_result = r600_get_query_result;
-       rctx->b.set_active_query_state = r600_set_active_query_state;
        rctx->render_cond_atom.emit = r600_emit_query_predication;
 
        if (((struct r600_common_screen*)rctx->b.screen)->info.num_render_backends > 0)