aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorMichel Dänzer <[email protected]>2016-12-16 11:13:26 +0900
committerMichel Dänzer <[email protected]>2016-12-19 17:50:17 +0900
commit5e70f80c9969c0adc095ba0a874ec87aad676729 (patch)
tree58af379bbfce869e1dea2cf5aa2b707ad8b98a18 /src/gallium/auxiliary
parent3d661a12be5be95da929b19cf4b5976b3c3fb8e9 (diff)
cso: Store pointers to struct cso_sampler in struct sampler_info
Preparation for following changes, no functional change intended. Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index 2ee87f91848..f52969d3668 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -55,6 +55,7 @@
*/
struct sampler_info
{
+ struct cso_sampler *cso_samplers[PIPE_MAX_SAMPLERS];
void *samplers[PIPE_MAX_SAMPLERS];
unsigned nr_samplers;
};
@@ -79,9 +80,7 @@ struct cso_context {
struct pipe_sampler_view *fragment_views_saved[PIPE_MAX_SHADER_SAMPLER_VIEWS];
unsigned nr_fragment_views_saved;
- void *fragment_samplers_saved[PIPE_MAX_SAMPLERS];
- unsigned nr_fragment_samplers_saved;
-
+ struct sampler_info fragment_samplers_saved;
struct sampler_info samplers[PIPE_SHADER_TYPES];
struct pipe_vertex_buffer aux_vertex_buffer_current;
@@ -1164,18 +1163,17 @@ enum pipe_error
cso_single_sampler(struct cso_context *ctx, unsigned shader_stage,
unsigned idx, const struct pipe_sampler_state *templ)
{
- void *handle = NULL;
-
if (templ) {
unsigned key_size = sizeof(struct pipe_sampler_state);
unsigned hash_key = cso_construct_key((void*)templ, key_size);
+ struct cso_sampler *cso;
struct cso_hash_iter iter =
cso_find_state_template(ctx->cache,
hash_key, CSO_SAMPLER,
(void *) templ, key_size);
if (cso_hash_iter_is_null(iter)) {
- struct cso_sampler *cso = MALLOC(sizeof(struct cso_sampler));
+ cso = MALLOC(sizeof(struct cso_sampler));
if (!cso)
return PIPE_ERROR_OUT_OF_MEMORY;
@@ -1190,15 +1188,18 @@ cso_single_sampler(struct cso_context *ctx, unsigned shader_stage,
FREE(cso);
return PIPE_ERROR_OUT_OF_MEMORY;
}
-
- handle = cso->data;
}
else {
- handle = ((struct cso_sampler *)cso_hash_iter_data(iter))->data;
+ cso = cso_hash_iter_data(iter);
}
+
+ ctx->samplers[shader_stage].cso_samplers[idx] = cso;
+ ctx->samplers[shader_stage].samplers[idx] = cso->data;
+ } else {
+ ctx->samplers[shader_stage].cso_samplers[idx] = NULL;
+ ctx->samplers[shader_stage].samplers[idx] = NULL;
}
- ctx->samplers[shader_stage].samplers[idx] = handle;
return PIPE_OK;
}
@@ -1263,10 +1264,11 @@ static void
cso_save_fragment_samplers(struct cso_context *ctx)
{
struct sampler_info *info = &ctx->samplers[PIPE_SHADER_FRAGMENT];
+ struct sampler_info *saved = &ctx->fragment_samplers_saved;
- ctx->nr_fragment_samplers_saved = info->nr_samplers;
- memcpy(ctx->fragment_samplers_saved, info->samplers,
- sizeof(info->samplers));
+ 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));
}
@@ -1274,9 +1276,10 @@ static void
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;
- memcpy(info->samplers, ctx->fragment_samplers_saved,
- 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);
}