*/
struct sampler_info
{
+ struct cso_sampler *cso_samplers[PIPE_MAX_SAMPLERS];
void *samplers[PIPE_MAX_SAMPLERS];
unsigned nr_samplers;
};
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;
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;
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;
}
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));
}
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);
}