mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 13:48:06 +02:00
zink: avoid hashing states without descriptors
this is unnecessary hashing which decreases the accuracy of the states Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9348>
This commit is contained in:
parent
72a06746bf
commit
929a748401
2 changed files with 39 additions and 19 deletions
|
|
@ -163,9 +163,6 @@ update_descriptor_stage_state(struct zink_context *ctx, enum pipe_shader_type sh
|
||||||
{
|
{
|
||||||
struct zink_shader *zs = shader == PIPE_SHADER_COMPUTE ? ctx->compute_stage : ctx->gfx_stages[shader];
|
struct zink_shader *zs = shader == PIPE_SHADER_COMPUTE ? ctx->compute_stage : ctx->gfx_stages[shader];
|
||||||
|
|
||||||
if (!zink_program_get_descriptor_usage(ctx, shader, type))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
uint32_t hash = 0;
|
uint32_t hash = 0;
|
||||||
for (int i = 0; i < zs->num_bindings[type]; i++) {
|
for (int i = 0; i < zs->num_bindings[type]; i++) {
|
||||||
int idx = zs->bindings[type][i].index;
|
int idx = zs->bindings[type][i].index;
|
||||||
|
|
@ -191,30 +188,50 @@ update_descriptor_stage_state(struct zink_context *ctx, enum pipe_shader_type sh
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_descriptor_state(struct zink_context *ctx, enum zink_descriptor_type type, bool is_compute)
|
update_descriptor_state(struct zink_context *ctx, enum zink_descriptor_type type, bool is_compute)
|
||||||
{
|
{printf("UPDATE\n");
|
||||||
/* we shouldn't be calling this if we don't have to */
|
/* we shouldn't be calling this if we don't have to */
|
||||||
assert(!ctx->descriptor_states[is_compute].valid[type]);
|
assert(!ctx->descriptor_states[is_compute].valid[type]);
|
||||||
|
bool has_any_usage = false;
|
||||||
|
|
||||||
if (is_compute)
|
if (is_compute) {
|
||||||
/* just update compute state */
|
/* just update compute state */
|
||||||
ctx->descriptor_states[is_compute].state[type] = update_descriptor_stage_state(ctx, PIPE_SHADER_COMPUTE, type);
|
bool has_usage = zink_program_get_descriptor_usage(ctx, PIPE_SHADER_COMPUTE, type);
|
||||||
else {
|
if (has_usage)
|
||||||
|
ctx->descriptor_states[is_compute].state[type] = update_descriptor_stage_state(ctx, PIPE_SHADER_COMPUTE, type);
|
||||||
|
else
|
||||||
|
ctx->descriptor_states[is_compute].state[type] = 0;
|
||||||
|
has_any_usage = has_usage;
|
||||||
|
} else {
|
||||||
/* update all gfx states */
|
/* update all gfx states */
|
||||||
|
bool first = true;
|
||||||
for (unsigned i = 0; i < ZINK_SHADER_COUNT; i++) {
|
for (unsigned i = 0; i < ZINK_SHADER_COUNT; i++) {
|
||||||
|
bool has_usage = false;
|
||||||
/* this is the incremental update for the shader stage */
|
/* this is the incremental update for the shader stage */
|
||||||
if (!ctx->gfx_descriptor_states[i].valid[type] && ctx->gfx_stages[i]) {
|
if (!ctx->gfx_descriptor_states[i].valid[type]) {
|
||||||
ctx->gfx_descriptor_states[i].state[type] = update_descriptor_stage_state(ctx, i, type);
|
ctx->gfx_descriptor_states[i].state[type] = 0;
|
||||||
ctx->gfx_descriptor_states[i].valid[type] = true;
|
if (ctx->gfx_stages[i]) {
|
||||||
|
has_usage = zink_program_get_descriptor_usage(ctx, i, type);
|
||||||
|
if (has_usage)
|
||||||
|
ctx->gfx_descriptor_states[i].state[type] = update_descriptor_stage_state(ctx, i, type);
|
||||||
|
ctx->gfx_descriptor_states[i].valid[type] = has_usage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ctx->gfx_descriptor_states[i].valid[type]) {
|
if (ctx->gfx_descriptor_states[i].valid[type]) {
|
||||||
/* this is the overall state update for the descriptor set hash */
|
/* this is the overall state update for the descriptor set hash */
|
||||||
ctx->descriptor_states[is_compute].state[type] = XXH32(&ctx->gfx_descriptor_states[i].state[type],
|
if (first) {
|
||||||
sizeof(uint32_t),
|
/* no need to double hash the first state */
|
||||||
ctx->descriptor_states[is_compute].state[type]);
|
ctx->descriptor_states[is_compute].state[type] = ctx->gfx_descriptor_states[i].state[type];
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
ctx->descriptor_states[is_compute].state[type] = XXH32(&ctx->gfx_descriptor_states[i].state[type],
|
||||||
|
sizeof(uint32_t),
|
||||||
|
ctx->descriptor_states[is_compute].state[type]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
has_any_usage |= has_usage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx->descriptor_states[is_compute].valid[type] = true;
|
ctx->descriptor_states[is_compute].valid[type] = has_any_usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -64,12 +64,15 @@ desc_state_hash(const void *key)
|
||||||
{
|
{
|
||||||
const struct zink_descriptor_state_key *d_key = (void*)key;
|
const struct zink_descriptor_state_key *d_key = (void*)key;
|
||||||
uint32_t hash = 0;
|
uint32_t hash = 0;
|
||||||
/* this is a compute shader */
|
bool first = true;
|
||||||
if (!d_key->exists[PIPE_SHADER_FRAGMENT])
|
|
||||||
return d_key->state[0];
|
|
||||||
for (unsigned i = 0; i < ZINK_SHADER_COUNT; i++) {
|
for (unsigned i = 0; i < ZINK_SHADER_COUNT; i++) {
|
||||||
if (d_key->exists[i])
|
if (d_key->exists[i]) {
|
||||||
hash = XXH32(&d_key->state[i], sizeof(uint32_t), hash);
|
if (!first)
|
||||||
|
hash = XXH32(&d_key->state[i], sizeof(uint32_t), hash);
|
||||||
|
else
|
||||||
|
hash = d_key->state[i];
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue