diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index 93c9f28bee7..7b0a9da7497 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -1225,6 +1225,19 @@ static void si_set_constant_buffer(struct si_context *sctx, struct si_buffer_res sctx->descriptors_dirty |= 1u << descriptors_idx; } +void si_invalidate_inlinable_uniforms(struct si_context *sctx, enum pipe_shader_type shader) +{ + if (shader == PIPE_SHADER_COMPUTE) + return; + + if (sctx->shaders[shader].key.opt.inline_uniforms) { + sctx->shaders[shader].key.opt.inline_uniforms = false; + memset(sctx->shaders[shader].key.opt.inlined_uniform_values, 0, + sizeof(sctx->shaders[shader].key.opt.inlined_uniform_values)); + sctx->do_update_shaders = true; + } +} + static void si_pipe_set_constant_buffer(struct pipe_context *ctx, enum pipe_shader_type shader, uint slot, bool take_ownership, const struct pipe_constant_buffer *input) @@ -1244,10 +1257,8 @@ static void si_pipe_set_constant_buffer(struct pipe_context *ctx, enum pipe_shad si_resource(input->buffer)->bind_history |= PIPE_BIND_CONSTANT_BUFFER; } - if (slot == 0) { - /* Invalidate current inlinable uniforms. */ - sctx->inlinable_uniforms_valid_mask &= ~(1 << shader); - } + if (slot == 0) + si_invalidate_inlinable_uniforms(sctx, shader); } slot = si_get_constbuf_slot(slot); @@ -1262,10 +1273,13 @@ static void si_set_inlinable_constants(struct pipe_context *ctx, { struct si_context *sctx = (struct si_context *)ctx; - if (!(sctx->inlinable_uniforms_valid_mask & BITFIELD_BIT(shader))) { + if (shader == PIPE_SHADER_COMPUTE) + return; + + if (!sctx->shaders[shader].key.opt.inline_uniforms) { /* 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->shaders[shader].key.opt.inline_uniforms = true; + memcpy(sctx->shaders[shader].key.opt.inlined_uniform_values, values, num_values * 4); sctx->do_update_shaders = true; return; } @@ -1273,8 +1287,8 @@ static void si_set_inlinable_constants(struct pipe_context *ctx, /* 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); + if (memcmp(sctx->shaders[shader].key.opt.inlined_uniform_values, values, num_values * 4)) { + memcpy(sctx->shaders[shader].key.opt.inlined_uniform_values, values, num_values * 4); sctx->do_update_shaders = true; } } diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 057fd9aef55..92762bc881a 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -1054,8 +1054,6 @@ struct si_context { unsigned descriptors_dirty; unsigned shader_pointers_dirty; unsigned shader_needs_decompress_mask; - unsigned inlinable_uniforms_valid_mask; - uint32_t inlinable_uniforms[SI_NUM_SHADERS][MAX_INLINABLE_UNIFORMS]; struct si_buffer_resources internal_bindings; struct si_buffer_resources const_and_shader_buffers[SI_NUM_SHADERS]; struct si_samplers samplers[SI_NUM_SHADERS]; diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index 285b74dddc1..c84db4e3add 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -488,6 +488,7 @@ void si_set_mutable_tex_desc_fields(struct si_screen *sscreen, struct si_texture /* restrict decreases overhead of si_set_sampler_view_desc ~8x. */ bool is_stencil, uint16_t access, uint32_t * restrict state); void si_update_ps_colorbuf0_slot(struct si_context *sctx); +void si_invalidate_inlinable_uniforms(struct si_context *sctx, enum pipe_shader_type shader); void si_get_pipe_constant_buffer(struct si_context *sctx, uint shader, uint slot, struct pipe_constant_buffer *cbuf); void si_get_shader_buffers(struct si_context *sctx, enum pipe_shader_type shader, uint start_slot, diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 5d6667e6e57..8c2e91b2ebc 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -2133,17 +2133,6 @@ static inline void si_shader_selector_key(struct pipe_context *ctx, struct si_sh { struct si_context *sctx = (struct si_context *)ctx; -#if 0 /* TODO: enable this */ - unsigned num_inlinable_uniforms = sel->info.base.num_inlinable_uniforms; - if (num_inlinable_uniforms && - sctx->inlinable_uniforms_valid_mask & (1 << sel->pipe_shader_type)) { - key->opt.inline_uniforms = true; - memcpy(key->opt.inlined_uniform_values, - sctx->inlinable_uniforms[sel->pipe_shader_type], - num_inlinable_uniforms * 4); - } -#endif - switch (sel->info.stage) { case MESA_SHADER_VERTEX: if (!sctx->shader.tes.cso && !sctx->shader.gs.cso) @@ -3174,9 +3163,7 @@ static void si_update_common_shader_state(struct si_context *sctx, struct si_sha si_shader_uses_bindless_images(sctx->shader.tcs.cso) || si_shader_uses_bindless_images(sctx->shader.tes.cso); - /* Invalidate inlinable uniforms. */ - sctx->inlinable_uniforms_valid_mask &= ~(1 << type); - + si_invalidate_inlinable_uniforms(sctx, type); sctx->do_update_shaders = true; }