[Mesa-dev] [PATCH 2/2] radeonsi: set sampler state and view functions for compute-only contexts

Marek Olšák maraeo at gmail.com
Fri Apr 26 20:41:47 UTC 2019


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/drivers/radeonsi/si_pipe.c  |  2 +-
 src/gallium/drivers/radeonsi/si_state.c | 17 ++++++++++-------
 src/gallium/drivers/radeonsi/si_state.h |  2 +-
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index aaf5138a3a2..b0e0ca7af05 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -496,30 +496,30 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen,
 	if (!sctx->border_color_map)
 		goto fail;
 
 	/* Initialize context functions used by graphics and compute. */
 	sctx->b.emit_string_marker = si_emit_string_marker;
 	sctx->b.set_debug_callback = si_set_debug_callback;
 	sctx->b.set_log_context = si_set_log_context;
 	sctx->b.set_context_param = si_set_context_param;
 	sctx->b.get_device_reset_status = si_get_reset_status;
 	sctx->b.set_device_reset_callback = si_set_device_reset_callback;
-	sctx->b.memory_barrier = si_memory_barrier;
 
 	si_init_all_descriptors(sctx);
 	si_init_buffer_functions(sctx);
 	si_init_clear_functions(sctx);
 	si_init_blit_functions(sctx);
 	si_init_compute_functions(sctx);
 	si_init_compute_blit_functions(sctx);
 	si_init_debug_functions(sctx);
 	si_init_fence_functions(sctx);
+	si_init_state_compute_functions(sctx);
 
 	if (sscreen->debug_flags & DBG(FORCE_DMA))
 		sctx->b.resource_copy_region = sctx->dma_copy;
 
 	/* Initialize graphics-only context functions. */
 	if (sctx->has_graphics) {
 		si_init_context_texture_functions(sctx);
 		si_init_query_functions(sctx);
 		si_init_msaa_functions(sctx);
 		si_init_shader_functions(sctx);
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 2266b0a0824..876a993b158 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -4713,21 +4713,21 @@ static void si_texture_barrier(struct pipe_context *ctx, unsigned flags)
 
 	/* Multisample surfaces are flushed in si_decompress_textures. */
 	if (sctx->framebuffer.uncompressed_cb_mask) {
 		si_make_CB_shader_coherent(sctx, sctx->framebuffer.nr_samples,
 					   sctx->framebuffer.CB_has_shader_readable_metadata,
 					   sctx->framebuffer.all_DCC_pipe_aligned);
 	}
 }
 
 /* This only ensures coherency for shader image/buffer stores. */
-void si_memory_barrier(struct pipe_context *ctx, unsigned flags)
+static void si_memory_barrier(struct pipe_context *ctx, unsigned flags)
 {
 	struct si_context *sctx = (struct si_context *)ctx;
 
 	if (!(flags & ~PIPE_BARRIER_UPDATE))
 		return;
 
 	/* Subsequent commands must wait for all shader invocations to
 	 * complete. */
 	sctx->flags |= SI_CONTEXT_PS_PARTIAL_FLUSH |
 	                 SI_CONTEXT_CS_PARTIAL_FLUSH;
@@ -4778,20 +4778,29 @@ static void *si_create_blend_custom(struct si_context *sctx, unsigned mode)
 	struct pipe_blend_state blend;
 
 	memset(&blend, 0, sizeof(blend));
 	blend.independent_blend_enable = true;
 	blend.rt[0].colormask = 0xf;
 	return si_create_blend_state_mode(&sctx->b, &blend, mode);
 }
 
 static void si_init_config(struct si_context *sctx);
 
+void si_init_state_compute_functions(struct si_context *sctx)
+{
+	sctx->b.create_sampler_state = si_create_sampler_state;
+	sctx->b.delete_sampler_state = si_delete_sampler_state;
+	sctx->b.create_sampler_view = si_create_sampler_view;
+	sctx->b.sampler_view_destroy = si_sampler_view_destroy;
+	sctx->b.memory_barrier = si_memory_barrier;
+}
+
 void si_init_state_functions(struct si_context *sctx)
 {
 	sctx->atoms.s.framebuffer.emit = si_emit_framebuffer_state;
 	sctx->atoms.s.msaa_sample_locs.emit = si_emit_msaa_sample_locs;
 	sctx->atoms.s.db_render_state.emit = si_emit_db_render_state;
 	sctx->atoms.s.dpbb_state.emit = si_emit_dpbb_state;
 	sctx->atoms.s.msaa_config.emit = si_emit_msaa_config;
 	sctx->atoms.s.sample_mask.emit = si_emit_sample_mask;
 	sctx->atoms.s.cb_render_state.emit = si_emit_cb_render_state;
 	sctx->atoms.s.blend_color.emit = si_emit_blend_color;
@@ -4816,26 +4825,20 @@ void si_init_state_functions(struct si_context *sctx)
 	sctx->custom_blend_resolve = si_create_blend_custom(sctx, V_028808_CB_RESOLVE);
 	sctx->custom_blend_fmask_decompress = si_create_blend_custom(sctx, V_028808_CB_FMASK_DECOMPRESS);
 	sctx->custom_blend_eliminate_fastclear = si_create_blend_custom(sctx, V_028808_CB_ELIMINATE_FAST_CLEAR);
 	sctx->custom_blend_dcc_decompress = si_create_blend_custom(sctx, V_028808_CB_DCC_DECOMPRESS);
 
 	sctx->b.set_clip_state = si_set_clip_state;
 	sctx->b.set_stencil_ref = si_set_stencil_ref;
 
 	sctx->b.set_framebuffer_state = si_set_framebuffer_state;
 
-	sctx->b.create_sampler_state = si_create_sampler_state;
-	sctx->b.delete_sampler_state = si_delete_sampler_state;
-
-	sctx->b.create_sampler_view = si_create_sampler_view;
-	sctx->b.sampler_view_destroy = si_sampler_view_destroy;
-
 	sctx->b.set_sample_mask = si_set_sample_mask;
 
 	sctx->b.create_vertex_elements_state = si_create_vertex_elements;
 	sctx->b.bind_vertex_elements_state = si_bind_vertex_elements;
 	sctx->b.delete_vertex_elements_state = si_delete_vertex_element;
 	sctx->b.set_vertex_buffers = si_set_vertex_buffers;
 
 	sctx->b.texture_barrier = si_texture_barrier;
 	sctx->b.set_min_samples = si_set_min_samples;
 	sctx->b.set_tess_state = si_set_tess_state;
diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h
index c15ce5cdf1f..6df24f9648a 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -483,21 +483,21 @@ void si_set_active_descriptors_for_shader(struct si_context *sctx,
 					  struct si_shader_selector *sel);
 bool si_bindless_descriptor_can_reclaim_slab(void *priv,
 					     struct pb_slab_entry *entry);
 struct pb_slab *si_bindless_descriptor_slab_alloc(void *priv, unsigned heap,
 						  unsigned entry_size,
 						  unsigned group_index);
 void si_bindless_descriptor_slab_free(void *priv, struct pb_slab *pslab);
 void si_rebind_buffer(struct si_context *sctx, struct pipe_resource *buf,
 		      uint64_t old_va);
 /* si_state.c */
-void si_memory_barrier(struct pipe_context *ctx, unsigned flags);
+void si_init_state_compute_functions(struct si_context *sctx);
 void si_init_state_functions(struct si_context *sctx);
 void si_init_screen_state_functions(struct si_screen *sscreen);
 void
 si_make_buffer_descriptor(struct si_screen *screen, struct si_resource *buf,
 			  enum pipe_format format,
 			  unsigned offset, unsigned size,
 			  uint32_t *state);
 void
 si_make_texture_descriptor(struct si_screen *screen,
 			   struct si_texture *tex,
-- 
2.17.1



More information about the mesa-dev mailing list