Mesa (main): radeonsi: optimize set_inlinable_constants when they don't change
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jun 24 03:17:07 UTC 2021
Module: Mesa
Branch: main
Commit: 888b7ba33822dafea1ec19bda6d9ea06c8c5adad
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=888b7ba33822dafea1ec19bda6d9ea06c8c5adad
Author: Marek Olšák <marek.olsak at amd.com>
Date: Mon Jun 21 19:25:08 2021 -0400
radeonsi: optimize set_inlinable_constants when they don't change
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11509>
---
src/gallium/drivers/radeonsi/si_descriptors.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index 29178035deb..afa22d3ba0e 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1231,9 +1231,21 @@ static void si_set_inlinable_constants(struct pipe_context *ctx,
{
struct si_context *sctx = (struct si_context *)ctx;
- memcpy(sctx->inlinable_uniforms[shader], values, num_values * 4);
- sctx->inlinable_uniforms_valid_mask |= 1 << shader;
- sctx->do_update_shaders = true;
+ if (!(sctx->inlinable_uniforms_valid_mask & BITFIELD_BIT(shader))) {
+ /* It's the first time we set the constants. Always update shaders. */
+ memcpy(sctx->inlinable_uniforms[shader], values, num_values * 4);
+ sctx->inlinable_uniforms_valid_mask |= BITFIELD_BIT(shader);
+ sctx->do_update_shaders = true;
+ return;
+ }
+
+ /* We have already set inlinable constants for this shader. Update the shader only if
+ * the constants are being changed so as not to update shaders needlessly.
+ */
+ if (memcmp(sctx->inlinable_uniforms[shader], values, num_values * 4)) {
+ memcpy(sctx->inlinable_uniforms[shader], values, num_values * 4);
+ sctx->do_update_shaders = true;
+ }
}
void si_get_pipe_constant_buffer(struct si_context *sctx, uint shader, uint slot,
More information about the mesa-commit
mailing list