On 16.12.2016 10:52, Michel Dänzer wrote:
From: Michel Dänzer <michel.daen...@amd.com>
Preparation for following changes, no functional change intended.
Signed-off-by: Michel Dänzer <michel.daen...@amd.com>
---
src/gallium/auxiliary/cso_cache/cso_context.c | 33 +++++++++++++++------------
1 file 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 2ee87f9184..f52969d366 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));
I now realize the previous patch is fine. This could just memcpy the
entire structure, though if you want to keep it as-is for analogy with
cso_restore_fragment_samplers, that's fine as well.
Nicolai
}
@@ -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);
}
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev