[Mesa-dev] [PATCH 18/21] r600: handle image/buffer sizes correctly.

Dave Airlie airlied at gmail.com
Wed Nov 29 04:36:27 UTC 2017


From: Dave Airlie <airlied at redhat.com>

This adds support to compute for the resq workarounds (buffer/cube sizes)

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/gallium/drivers/r600/evergreen_compute.c |  7 +++++++
 src/gallium/drivers/r600/r600_pipe.h         |  2 ++
 src/gallium/drivers/r600/r600_state_common.c | 16 ++++++++++++----
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c
index c9e649e..cf86440 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -721,6 +721,13 @@ static void compute_emit_cs(struct r600_context *rctx,
 			r600_set_atom_dirty(rctx, &rctx->cs_shader_state.atom, true);
 		}
 
+		bool need_buf_const = current->shader.uses_tex_buffers ||
+			current->shader.has_txq_cube_array_z_comp;
+
+		if (need_buf_const) {
+			eg_setup_buffer_constants(rctx, PIPE_SHADER_COMPUTE);
+			r600_update_driver_const_buffers(rctx, true);
+		}
 		if (evergreen_emit_atomic_buffer_setup(rctx, current, combined_atomics, &atomic_used_mask)) {
 			radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 0, 0));
 			radeon_emit(cs, EVENT_TYPE(EVENT_TYPE_CS_PARTIAL_FLUSH) | EVENT_INDEX(4));
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index 4028d98..65d1185 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -1044,4 +1044,6 @@ void evergreen_emit_atomic_buffer_save(struct r600_context *rctx,
 				       uint8_t *atomic_used_mask_p);
 void r600_update_compressed_resource_state(struct r600_context *rctx, bool compute_only);
 
+void eg_setup_buffer_constants(struct r600_context *rctx, int shader_type);
+void r600_update_driver_const_buffers(struct r600_context *rctx, bool compute_only);
 #endif
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index 0464a8e..bddda6b 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -1216,12 +1216,17 @@ static void r600_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask
 	r600_mark_atom_dirty(rctx, &rctx->sample_mask.atom);
 }
 
-static void r600_update_driver_const_buffers(struct r600_context *rctx)
+void r600_update_driver_const_buffers(struct r600_context *rctx, bool compute_only)
 {
 	int sh, size;
 	void *ptr;
 	struct pipe_constant_buffer cb;
-	for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) {
+	int start, end;
+
+	start = compute_only ? PIPE_SHADER_COMPUTE : 0;
+	end = compute_only ? PIPE_SHADER_TYPES : PIPE_SHADER_COMPUTE;
+
+	for (sh = start; sh < end; sh++) {
 		struct r600_shader_driver_constants_info *info = &rctx->driver_consts[sh];
 		if (!info->vs_ucp_dirty &&
 		    !info->texture_const_dirty &&
@@ -1341,7 +1346,7 @@ static void r600_setup_buffer_constants(struct r600_context *rctx, int shader_ty
  * 1. buffer size for TXQ
  * 2. number of cube layers in a cube map array.
  */
-static void eg_setup_buffer_constants(struct r600_context *rctx, int shader_type)
+void eg_setup_buffer_constants(struct r600_context *rctx, int shader_type)
 {
 	struct r600_textures_info *samplers = &rctx->samplers[shader_type];
 	struct r600_image_state *images = NULL;
@@ -1355,6 +1360,9 @@ static void eg_setup_buffer_constants(struct r600_context *rctx, int shader_type
 	if (shader_type == PIPE_SHADER_FRAGMENT) {
 		images = &rctx->fragment_images;
 		buffers = &rctx->fragment_buffers;
+	} else if (shader_type == PIPE_SHADER_COMPUTE) {
+		images = &rctx->compute_images;
+		buffers = &rctx->compute_buffers;
 	}
 
 	if (!samplers->views.dirty_buffer_constants &&
@@ -1781,7 +1789,7 @@ static bool r600_update_derived_state(struct r600_context *rctx)
 		}
 	}
 
-	r600_update_driver_const_buffers(rctx);
+	r600_update_driver_const_buffers(rctx, false);
 
 	if (rctx->b.chip_class < EVERGREEN && rctx->ps_shader && rctx->vs_shader) {
 		if (!r600_adjust_gprs(rctx)) {
-- 
2.9.5



More information about the mesa-dev mailing list