cso: don't look up a sampler CSO if the last one is identical
This is benefical when sampler states are identical often, and detrimental if they are not. The average case seems to be in favor of this. Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11428>
This commit is contained in:
parent
1cb35d058f
commit
f3d331a5e3
|
@ -1258,7 +1258,31 @@ cso_set_samplers(struct cso_context *ctx,
|
|||
if (!templates[i])
|
||||
continue;
|
||||
|
||||
cso_single_sampler(ctx, shader_stage, i, templates[i]);
|
||||
/* Reuse the same sampler state CSO if 2 consecutive sampler states
|
||||
* are identical.
|
||||
*
|
||||
* The trivial case where both pointers are equal doesn't occur in
|
||||
* frequented codepaths.
|
||||
*
|
||||
* Reuse rate:
|
||||
* - Borderlands 2: 55%
|
||||
* - Hitman: 65%
|
||||
* - Rocket League: 75%
|
||||
* - Tomb Raider: 50-65%
|
||||
* - XCOM 2: 55%
|
||||
*/
|
||||
if (last >= 0 &&
|
||||
!memcmp(templates[i], templates[last],
|
||||
sizeof(struct pipe_sampler_state))) {
|
||||
ctx->samplers[shader_stage].cso_samplers[i] =
|
||||
ctx->samplers[shader_stage].cso_samplers[last];
|
||||
ctx->samplers[shader_stage].samplers[i] =
|
||||
ctx->samplers[shader_stage].samplers[last];
|
||||
} else {
|
||||
/* Look up the sampler state CSO. */
|
||||
cso_set_sampler(ctx, shader_stage, i, templates[i]);
|
||||
}
|
||||
|
||||
last = i;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue