diff options
author | Michel Dänzer <[email protected]> | 2016-12-16 18:00:33 +0900 |
---|---|---|
committer | Michel Dänzer <[email protected]> | 2016-12-19 17:50:21 +0900 |
commit | 9e142386472e599e70856634e4cbd247114af74a (patch) | |
tree | e453ec8e366863a5dd9db81af7e595449406ae59 /src/gallium/auxiliary | |
parent | 5e70f80c9969c0adc095ba0a874ec87aad676729 (diff) |
cso: Optimize cso_save/restore_fragment_samplers
Only copy/memset the pointers that actually need to be.
v2:
* Cast info->nr_samplers to int for calculating delta (Nicolai)
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/cso_cache/cso_context.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index f52969d3668..0f4a333ab0a 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -1267,8 +1267,10 @@ cso_save_fragment_samplers(struct cso_context *ctx) struct sampler_info *saved = &ctx->fragment_samplers_saved; saved->nr_samplers = info->nr_samplers; - memcpy(saved->cso_samplers, info->cso_samplers, sizeof(info->cso_samplers)); - memcpy(saved->samplers, info->samplers, sizeof(info->samplers)); + memcpy(saved->cso_samplers, info->cso_samplers, info->nr_samplers * + sizeof(*info->cso_samplers)); + memcpy(saved->samplers, info->samplers, info->nr_samplers * + sizeof(*info->samplers)); } @@ -1277,9 +1279,20 @@ cso_restore_fragment_samplers(struct cso_context *ctx) { struct sampler_info *info = &ctx->samplers[PIPE_SHADER_FRAGMENT]; struct sampler_info *saved = &ctx->fragment_samplers_saved; + int delta = (int)info->nr_samplers - saved->nr_samplers; + + memcpy(info->cso_samplers, saved->cso_samplers, + saved->nr_samplers * sizeof(*info->cso_samplers)); + memcpy(info->samplers, saved->samplers, + saved->nr_samplers * sizeof(*info->samplers)); + + if (delta > 0) { + memset(&info->cso_samplers[saved->nr_samplers], 0, + delta * sizeof(*info->cso_samplers)); + memset(&info->samplers[saved->nr_samplers], 0, + delta * sizeof(*info->samplers)); + } - memcpy(info->cso_samplers, saved->cso_samplers, sizeof(info->cso_samplers)); - memcpy(info->samplers, saved->samplers, sizeof(info->samplers)); cso_single_sampler_done(ctx, PIPE_SHADER_FRAGMENT); } |