radeonsi: rewrite inlinable uniform states for shader keys in si_context
directly update the shader keys in si_context Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12343>
This commit is contained in:
parent
aed93eb991
commit
6d1ab77a8f
|
@ -1225,6 +1225,19 @@ static void si_set_constant_buffer(struct si_context *sctx, struct si_buffer_res
|
||||||
sctx->descriptors_dirty |= 1u << descriptors_idx;
|
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,
|
static void si_pipe_set_constant_buffer(struct pipe_context *ctx, enum pipe_shader_type shader,
|
||||||
uint slot, bool take_ownership,
|
uint slot, bool take_ownership,
|
||||||
const struct pipe_constant_buffer *input)
|
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;
|
si_resource(input->buffer)->bind_history |= PIPE_BIND_CONSTANT_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot == 0) {
|
if (slot == 0)
|
||||||
/* Invalidate current inlinable uniforms. */
|
si_invalidate_inlinable_uniforms(sctx, shader);
|
||||||
sctx->inlinable_uniforms_valid_mask &= ~(1 << shader);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
slot = si_get_constbuf_slot(slot);
|
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;
|
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. */
|
/* It's the first time we set the constants. Always update shaders. */
|
||||||
memcpy(sctx->inlinable_uniforms[shader], values, num_values * 4);
|
sctx->shaders[shader].key.opt.inline_uniforms = true;
|
||||||
sctx->inlinable_uniforms_valid_mask |= BITFIELD_BIT(shader);
|
memcpy(sctx->shaders[shader].key.opt.inlined_uniform_values, values, num_values * 4);
|
||||||
sctx->do_update_shaders = true;
|
sctx->do_update_shaders = true;
|
||||||
return;
|
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
|
/* 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.
|
* the constants are being changed so as not to update shaders needlessly.
|
||||||
*/
|
*/
|
||||||
if (memcmp(sctx->inlinable_uniforms[shader], values, num_values * 4)) {
|
if (memcmp(sctx->shaders[shader].key.opt.inlined_uniform_values, values, num_values * 4)) {
|
||||||
memcpy(sctx->inlinable_uniforms[shader], values, num_values * 4);
|
memcpy(sctx->shaders[shader].key.opt.inlined_uniform_values, values, num_values * 4);
|
||||||
sctx->do_update_shaders = true;
|
sctx->do_update_shaders = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1054,8 +1054,6 @@ struct si_context {
|
||||||
unsigned descriptors_dirty;
|
unsigned descriptors_dirty;
|
||||||
unsigned shader_pointers_dirty;
|
unsigned shader_pointers_dirty;
|
||||||
unsigned shader_needs_decompress_mask;
|
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 internal_bindings;
|
||||||
struct si_buffer_resources const_and_shader_buffers[SI_NUM_SHADERS];
|
struct si_buffer_resources const_and_shader_buffers[SI_NUM_SHADERS];
|
||||||
struct si_samplers samplers[SI_NUM_SHADERS];
|
struct si_samplers samplers[SI_NUM_SHADERS];
|
||||||
|
|
|
@ -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. */
|
/* restrict decreases overhead of si_set_sampler_view_desc ~8x. */
|
||||||
bool is_stencil, uint16_t access, uint32_t * restrict state);
|
bool is_stencil, uint16_t access, uint32_t * restrict state);
|
||||||
void si_update_ps_colorbuf0_slot(struct si_context *sctx);
|
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,
|
void si_get_pipe_constant_buffer(struct si_context *sctx, uint shader, uint slot,
|
||||||
struct pipe_constant_buffer *cbuf);
|
struct pipe_constant_buffer *cbuf);
|
||||||
void si_get_shader_buffers(struct si_context *sctx, enum pipe_shader_type shader, uint start_slot,
|
void si_get_shader_buffers(struct si_context *sctx, enum pipe_shader_type shader, uint start_slot,
|
||||||
|
|
|
@ -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;
|
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) {
|
switch (sel->info.stage) {
|
||||||
case MESA_SHADER_VERTEX:
|
case MESA_SHADER_VERTEX:
|
||||||
if (!sctx->shader.tes.cso && !sctx->shader.gs.cso)
|
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.tcs.cso) ||
|
||||||
si_shader_uses_bindless_images(sctx->shader.tes.cso);
|
si_shader_uses_bindless_images(sctx->shader.tes.cso);
|
||||||
|
|
||||||
/* Invalidate inlinable uniforms. */
|
si_invalidate_inlinable_uniforms(sctx, type);
|
||||||
sctx->inlinable_uniforms_valid_mask &= ~(1 << type);
|
|
||||||
|
|
||||||
sctx->do_update_shaders = true;
|
sctx->do_update_shaders = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue