radeonsi: add save_qbo_state
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 14 Sep 2016 07:46:36 +0000 (09:46 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 29 Sep 2016 09:14:37 +0000 (11:14 +0200)
Save compute shader state that will be used for the ARB_query_buffer_object
implementation.

Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/r600_query.h
src/gallium/drivers/radeonsi/si_state.c

index 96b23b23b25b89a10d9b62d29bc3d9b59d828824..32acca5ce05fe6455743f6aa32c352f945b5f3fe 100644 (file)
@@ -120,6 +120,7 @@ enum r600_coherency {
 struct r600_common_context;
 struct r600_perfcounters;
 struct tgsi_shader_info;
+struct r600_qbo_state;
 
 struct radeon_shader_reloc {
        char name[32];
@@ -650,6 +651,8 @@ struct r600_common_context {
        /* Enable or disable occlusion queries. */
        void (*set_occlusion_query_state)(struct pipe_context *ctx, bool enable);
 
+       void (*save_qbo_state)(struct pipe_context *ctx, struct r600_qbo_state *st);
+
        /* This ensures there is enough space in the command stream. */
        void (*need_gfx_cs_space)(struct pipe_context *ctx, unsigned num_dw,
                                  bool include_draw_vbo);
index 0cd1a02402826d7f4e1a9800276f80d82baae35f..4f5aa3ac1bfb67d55ef35b55655d8a6d4f8bc734 100644 (file)
@@ -29,6 +29,7 @@
 #define R600_QUERY_H
 
 #include "pipe/p_defines.h"
+#include "pipe/p_state.h"
 #include "util/list.h"
 
 struct pipe_context;
@@ -267,4 +268,10 @@ void r600_perfcounters_do_destroy(struct r600_perfcounters *);
 void r600_query_hw_reset_buffers(struct r600_common_context *rctx,
                                 struct r600_query_hw *query);
 
+struct r600_qbo_state {
+       void *saved_compute;
+       struct pipe_constant_buffer saved_const0;
+       struct pipe_shader_buffer saved_ssbo[3];
+};
+
 #endif /* R600_QUERY_H */
index 1703e42e9b2425db51f4e56796465eac512ab53a..443dc37078b28dcdea828e0ca294d7a24ff78222 100644 (file)
@@ -28,6 +28,7 @@
 #include "si_shader.h"
 #include "sid.h"
 #include "radeon/r600_cs.h"
+#include "radeon/r600_query.h"
 
 #include "util/u_dual_blend.h"
 #include "util/u_format.h"
@@ -1074,6 +1075,16 @@ static void si_set_occlusion_query_state(struct pipe_context *ctx, bool enable)
        si_mark_atom_dirty(sctx, &sctx->db_render_state);
 }
 
+static void si_save_qbo_state(struct pipe_context *ctx, struct r600_qbo_state *st)
+{
+       struct si_context *sctx = (struct si_context*)ctx;
+
+       st->saved_compute = sctx->cs_shader_state.program;
+
+       si_get_pipe_constant_buffer(sctx, PIPE_SHADER_COMPUTE, 0, &st->saved_const0);
+       si_get_shader_buffers(sctx, PIPE_SHADER_COMPUTE, 0, 3, st->saved_ssbo);
+}
+
 static void si_emit_db_render_state(struct si_context *sctx, struct r600_atom *state)
 {
        struct radeon_winsys_cs *cs = sctx->b.gfx.cs;
@@ -3498,6 +3509,7 @@ void si_init_state_functions(struct si_context *sctx)
 
        sctx->b.b.set_active_query_state = si_set_active_query_state;
        sctx->b.set_occlusion_query_state = si_set_occlusion_query_state;
+       sctx->b.save_qbo_state = si_save_qbo_state;
        sctx->b.need_gfx_cs_space = si_need_gfx_cs_space;
 
        sctx->b.b.draw_vbo = si_draw_vbo;