[Mesa-dev] [PATCH 1/2] radeonsi: use a bitfield for tracking which shaders use bindless
Samuel Pitoiset
samuel.pitoiset at gmail.com
Thu Jun 29 19:59:36 UTC 2017
This will allow to skip few partial flushes when bindless
descriptors have to be re-uploaded.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/gallium/drivers/radeonsi/si_blit.c | 4 +--
src/gallium/drivers/radeonsi/si_pipe.h | 4 +--
src/gallium/drivers/radeonsi/si_state_shaders.c | 38 +++++++++++++++++--------
3 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c
index 631676bcd79..45a023d4e2c 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -795,9 +795,9 @@ static void si_decompress_textures(struct si_context *sctx, unsigned shader_mask
}
if (shader_mask & u_bit_consecutive(0, SI_NUM_GRAPHICS_SHADERS)) {
- if (sctx->uses_bindless_samplers)
+ if (sctx->shader_uses_bindless_samplers_mask)
si_decompress_resident_textures(sctx);
- if (sctx->uses_bindless_images)
+ if (sctx->shader_uses_bindless_images_mask)
si_decompress_resident_images(sctx);
} else if (shader_mask & (1 << PIPE_SHADER_COMPUTE)) {
if (sctx->cs_shader_state.program->uses_bindless_samplers)
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index bd724e80a06..507635e7576 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -439,8 +439,8 @@ struct si_context {
struct util_dynarray resident_tex_needs_depth_decompress;
/* Bindless state */
- bool uses_bindless_samplers;
- bool uses_bindless_images;
+ unsigned shader_uses_bindless_samplers_mask;
+ unsigned shader_uses_bindless_images_mask;
};
/* cik_sdma.c */
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index af3f2a90e2a..1dd01b36c8f 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -2221,20 +2221,34 @@ static void si_update_clip_regs(struct si_context *sctx,
si_mark_atom_dirty(sctx, &sctx->clip_regs);
}
+static void si_update_shader_uses_bindless_masks(struct si_context *sctx,
+ struct si_shader_selector *sel,
+ enum pipe_shader_type type)
+{
+ if (si_shader_uses_bindless_samplers(sel))
+ sctx->shader_uses_bindless_samplers_mask |= 1u << type;
+ else
+ sctx->shader_uses_bindless_samplers_mask &= ~(1u << type);
+
+ if (si_shader_uses_bindless_images(sel))
+ sctx->shader_uses_bindless_images_mask |= 1u << type;
+ else
+ sctx->shader_uses_bindless_images_mask &= ~(1u << type);
+}
+
static void si_update_common_shader_state(struct si_context *sctx)
{
- sctx->uses_bindless_samplers =
- si_shader_uses_bindless_samplers(sctx->vs_shader.cso) ||
- si_shader_uses_bindless_samplers(sctx->gs_shader.cso) ||
- si_shader_uses_bindless_samplers(sctx->ps_shader.cso) ||
- si_shader_uses_bindless_samplers(sctx->tcs_shader.cso) ||
- si_shader_uses_bindless_samplers(sctx->tes_shader.cso);
- sctx->uses_bindless_images =
- si_shader_uses_bindless_images(sctx->vs_shader.cso) ||
- si_shader_uses_bindless_images(sctx->gs_shader.cso) ||
- si_shader_uses_bindless_images(sctx->ps_shader.cso) ||
- si_shader_uses_bindless_images(sctx->tcs_shader.cso) ||
- si_shader_uses_bindless_images(sctx->tes_shader.cso);
+ si_update_shader_uses_bindless_masks(sctx, sctx->vs_shader.cso,
+ PIPE_SHADER_VERTEX);
+ si_update_shader_uses_bindless_masks(sctx, sctx->ps_shader.cso,
+ PIPE_SHADER_FRAGMENT);
+ si_update_shader_uses_bindless_masks(sctx, sctx->gs_shader.cso,
+ PIPE_SHADER_GEOMETRY);
+ si_update_shader_uses_bindless_masks(sctx, sctx->tcs_shader.cso,
+ PIPE_SHADER_TESS_CTRL);
+ si_update_shader_uses_bindless_masks(sctx, sctx->tes_shader.cso,
+ PIPE_SHADER_TESS_EVAL);
+
sctx->do_update_shaders = true;
}
--
2.13.2
More information about the mesa-dev
mailing list