r600: handle image/buffer sizes correctly.
authorDave Airlie <airlied@redhat.com>
Mon, 27 Nov 2017 06:12:18 +0000 (16:12 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 6 Dec 2017 23:21:06 +0000 (23:21 +0000)
This adds support to compute for the resq workarounds (buffer/cube sizes)

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/evergreen_compute.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state_common.c

index 0f97bbe3cb0d8859a91b45466da56fb2fc74de5e..b527438b617cf2222bec4519c91ac48ac7485619 100644 (file)
@@ -709,6 +709,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));
index 4028d98d960f27fbeaa80b1e32c5d0220a89c797..65d118564d578dc0f62af5a3a5306020bc97e741 100644 (file)
@@ -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
index 938a85f238735bd74399b7680c02ac5028d90e9b..4d52c08a3d151c9b18166e3300789c2ebb2249ee 100644 (file)
@@ -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)) {