summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-05-15 23:50:32 +0200
committerSamuel Pitoiset <[email protected]>2017-06-14 10:04:36 +0200
commite1813a8635fb9775791721cf421de05803c3fcb5 (patch)
treec385c556e0b5b5ddbb28157330443c7c089b33fc
parentd7e1a66bb5582f594bdd05a1110dc40abc3371dc (diff)
radeonsi: decompress resident textures/images before graphics/compute
Similar to the existing decompression code path except that it loops over the list of resident textures/images. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
-rw-r--r--src/gallium/drivers/radeonsi/si_blit.c59
-rw-r--r--src/gallium/drivers/radeonsi/si_descriptors.c52
-rw-r--r--src/gallium/drivers/radeonsi/si_pipe.h3
3 files changed, 114 insertions, 0 deletions
diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c
index 520797a7236..8fdc3f268b1 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -22,6 +22,7 @@
*/
#include "si_pipe.h"
+#include "si_compute.h"
#include "util/u_format.h"
#include "util/u_surface.h"
@@ -706,6 +707,61 @@ static void si_check_render_feedback(struct si_context *sctx)
sctx->need_check_render_feedback = false;
}
+static void si_decompress_resident_textures(struct si_context *sctx)
+{
+ unsigned num_resident_tex_handles;
+ unsigned i;
+
+ num_resident_tex_handles = sctx->resident_tex_handles.size /
+ sizeof(struct si_texture_handle *);
+
+ for (i = 0; i < num_resident_tex_handles; i++) {
+ struct si_texture_handle *tex_handle =
+ *util_dynarray_element(&sctx->resident_tex_handles,
+ struct si_texture_handle *, i);
+ struct pipe_sampler_view *view = tex_handle->view;
+ struct si_sampler_view *sview = (struct si_sampler_view *)view;
+ struct r600_texture *tex = (struct r600_texture *)view->texture;
+
+ if (view->texture->target == PIPE_BUFFER)
+ continue;
+
+ if (tex_handle->needs_color_decompress)
+ si_decompress_color_texture(sctx, tex, view->u.tex.first_level,
+ view->u.tex.last_level);
+
+ if (tex_handle->needs_depth_decompress)
+ si_decompress_depth(sctx, tex,
+ sview->is_stencil_sampler ? PIPE_MASK_S : PIPE_MASK_Z,
+ view->u.tex.first_level, view->u.tex.last_level,
+ 0, util_max_layer(&tex->resource.b.b, view->u.tex.first_level));
+ }
+}
+
+static void si_decompress_resident_images(struct si_context *sctx)
+{
+ unsigned num_resident_img_handles;
+ unsigned i;
+
+ num_resident_img_handles = sctx->resident_img_handles.size /
+ sizeof(struct si_image_handle *);
+
+ for (i = 0; i < num_resident_img_handles; i++) {
+ struct si_image_handle *img_handle =
+ *util_dynarray_element(&sctx->resident_img_handles,
+ struct si_image_handle *, i);
+ struct pipe_image_view *view = &img_handle->view;
+ struct r600_texture *tex = (struct r600_texture *)view->resource;
+
+ if (view->resource->target == PIPE_BUFFER)
+ continue;
+
+ if (img_handle->needs_color_decompress)
+ si_decompress_color_texture(sctx, tex, view->u.tex.level,
+ view->u.tex.level);
+ }
+}
+
static void si_decompress_textures(struct si_context *sctx, unsigned shader_mask)
{
unsigned compressed_colortex_counter, mask;
@@ -736,6 +792,9 @@ static void si_decompress_textures(struct si_context *sctx, unsigned shader_mask
}
}
+ si_decompress_resident_textures(sctx);
+ si_decompress_resident_images(sctx);
+
si_check_render_feedback(sctx);
}
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index b3fb16f320b..9b1a0f8901e 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1614,6 +1614,48 @@ static void si_set_polygon_stipple(struct pipe_context *ctx,
/* TEXTURE METADATA ENABLE/DISABLE */
+static void
+si_resident_handles_update_needs_color_decompress(struct si_context *sctx)
+{
+ unsigned num_resident_tex_handles, num_resident_img_handles;
+ unsigned i;
+
+ num_resident_tex_handles = sctx->resident_tex_handles.size /
+ sizeof(struct si_texture_handle *);
+
+ for (i = 0; i < num_resident_tex_handles; i++) {
+ struct si_texture_handle *tex_handle =
+ *util_dynarray_element(&sctx->resident_tex_handles,
+ struct si_texture_handle *, i);
+ struct pipe_resource *res = tex_handle->view->texture;
+
+ if (res && res->target != PIPE_BUFFER) {
+ struct r600_texture *rtex = (struct r600_texture *)res;
+
+ tex_handle->needs_color_decompress =
+ color_needs_decompression(rtex);
+ }
+ }
+
+ num_resident_img_handles = sctx->resident_img_handles.size /
+ sizeof(struct si_image_handle *);
+
+ for (i = 0; i < num_resident_img_handles; i++) {
+ struct si_image_handle *img_handle =
+ *util_dynarray_element(&sctx->resident_img_handles,
+ struct si_image_handle *, i);
+ struct pipe_image_view *view = &img_handle->view;
+ struct pipe_resource *res = view->resource;
+
+ if (res && res->target != PIPE_BUFFER) {
+ struct r600_texture *rtex = (struct r600_texture *)res;
+
+ img_handle->needs_color_decompress =
+ color_needs_decompression(rtex);
+ }
+ }
+}
+
/* CMASK can be enabled (for fast clear) and disabled (for texture export)
* while the texture is bound, possibly by a different context. In that case,
* call this function to update needs_*_decompress_masks.
@@ -1625,6 +1667,8 @@ void si_update_needs_color_decompress_masks(struct si_context *sctx)
si_images_update_needs_color_decompress_mask(&sctx->images[i]);
si_update_shader_needs_decompress_mask(sctx, i);
}
+
+ si_resident_handles_update_needs_color_decompress(sctx);
}
/* BUFFER DISCARD/INVALIDATION */
@@ -2241,6 +2285,11 @@ static void si_make_texture_handle_resident(struct pipe_context *ctx,
struct r600_texture *rtex =
(struct r600_texture *)sview->base.texture;
+ tex_handle->needs_depth_decompress =
+ depth_needs_decompression(rtex, sview);
+ tex_handle->needs_color_decompress =
+ color_needs_decompression(rtex);
+
if (rtex->dcc_offset &&
p_atomic_read(&rtex->framebuffers_bound))
sctx->need_check_render_feedback = true;
@@ -2355,6 +2404,9 @@ static void si_make_image_handle_resident(struct pipe_context *ctx,
struct r600_texture *rtex = (struct r600_texture *)res;
unsigned level = view->u.tex.level;
+ img_handle->needs_color_decompress =
+ color_needs_decompression(rtex);
+
if (vi_dcc_enabled(rtex, level) &&
p_atomic_read(&rtex->framebuffers_bound))
sctx->need_check_render_feedback = true;
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index 19685ae1979..64be428943c 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -241,12 +241,15 @@ struct si_texture_handle
{
struct si_bindless_descriptor *desc;
struct pipe_sampler_view *view;
+ bool needs_color_decompress;
+ bool needs_depth_decompress;
};
struct si_image_handle
{
struct si_bindless_descriptor *desc;
struct pipe_image_view view;
+ bool needs_color_decompress;
};
struct si_context {