cso: only allow saving and restoring fragment sampler states

This commit is contained in:
Marek Olšák 2015-07-05 16:32:49 +02:00
parent 4e8bbed926
commit b7492a1f45
7 changed files with 28 additions and 24 deletions

View File

@ -58,9 +58,6 @@ struct sampler_info
{
void *samplers[PIPE_MAX_SAMPLERS];
unsigned nr_samplers;
void *samplers_saved[PIPE_MAX_SAMPLERS];
unsigned nr_samplers_saved;
};
@ -80,6 +77,9 @@ 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 samplers[PIPE_SHADER_TYPES];
struct pipe_vertex_buffer aux_vertex_buffer_current;
@ -1229,21 +1229,25 @@ cso_set_samplers(struct cso_context *ctx,
}
void
cso_save_samplers(struct cso_context *ctx, unsigned shader_stage)
cso_save_fragment_samplers(struct cso_context *ctx)
{
struct sampler_info *info = &ctx->samplers[shader_stage];
info->nr_samplers_saved = info->nr_samplers;
memcpy(info->samplers_saved, info->samplers, sizeof(info->samplers));
struct sampler_info *info = &ctx->samplers[PIPE_SHADER_FRAGMENT];
ctx->nr_fragment_samplers_saved = info->nr_samplers;
memcpy(ctx->fragment_samplers_saved, info->samplers,
sizeof(info->samplers));
}
void
cso_restore_samplers(struct cso_context *ctx, unsigned shader_stage)
cso_restore_fragment_samplers(struct cso_context *ctx)
{
struct sampler_info *info = &ctx->samplers[shader_stage];
info->nr_samplers = info->nr_samplers_saved;
memcpy(info->samplers, info->samplers_saved, sizeof(info->samplers));
single_sampler_done(ctx, shader_stage);
struct sampler_info *info = &ctx->samplers[PIPE_SHADER_FRAGMENT];
info->nr_samplers = ctx->nr_fragment_samplers_saved;
memcpy(info->samplers, ctx->fragment_samplers_saved,
sizeof(info->samplers));
single_sampler_done(ctx, PIPE_SHADER_FRAGMENT);
}

View File

@ -72,10 +72,10 @@ cso_set_samplers(struct cso_context *cso,
const struct pipe_sampler_state **states);
void
cso_save_samplers(struct cso_context *cso, unsigned shader_stage);
cso_save_fragment_samplers(struct cso_context *cso);
void
cso_restore_samplers(struct cso_context *cso, unsigned shader_stage);
cso_restore_fragment_samplers(struct cso_context *cso);
/* Alternate interface to support state trackers that like to modify
* samplers one at a time:

View File

@ -438,7 +438,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
cso_save_depth_stencil_alpha(cso);
cso_save_fragment_shader(cso);
cso_save_fragment_sampler_views(cso);
cso_save_samplers(cso, PIPE_SHADER_FRAGMENT);
cso_save_fragment_samplers(cso);
cso_save_rasterizer(cso);
cso_save_viewport(cso);
cso_save_stream_outputs(cso);
@ -568,7 +568,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
cso_restore_depth_stencil_alpha(cso);
cso_restore_fragment_shader(cso);
cso_restore_fragment_sampler_views(cso);
cso_restore_samplers(cso, PIPE_SHADER_FRAGMENT);
cso_restore_fragment_samplers(cso);
cso_restore_rasterizer(cso);
cso_restore_viewport(cso);
cso_restore_stream_outputs(cso);

View File

@ -125,7 +125,7 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
cso_save_rasterizer(cso);
cso_save_sample_mask(cso);
cso_save_min_samples(cso);
cso_save_samplers(cso, PIPE_SHADER_FRAGMENT);
cso_save_fragment_samplers(cso);
cso_save_fragment_sampler_views(cso);
cso_save_stencil_ref(cso);
cso_save_stream_outputs(cso);
@ -196,7 +196,7 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
cso_restore_rasterizer(cso);
cso_restore_sample_mask(cso);
cso_restore_min_samples(cso);
cso_restore_samplers(cso, PIPE_SHADER_FRAGMENT);
cso_restore_fragment_samplers(cso);
cso_restore_fragment_sampler_views(cso);
cso_restore_stencil_ref(cso);
cso_restore_stream_outputs(cso);

View File

@ -546,7 +546,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
cso_save_rasterizer(ctx->cso);
cso_save_sample_mask(ctx->cso);
cso_save_min_samples(ctx->cso);
cso_save_samplers(ctx->cso, PIPE_SHADER_FRAGMENT);
cso_save_fragment_samplers(ctx->cso);
cso_save_fragment_sampler_views(ctx->cso);
cso_save_stream_outputs(ctx->cso);
cso_save_viewport(ctx->cso);
@ -628,7 +628,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
cso_restore_rasterizer(ctx->cso);
cso_restore_sample_mask(ctx->cso);
cso_restore_min_samples(ctx->cso);
cso_restore_samplers(ctx->cso, PIPE_SHADER_FRAGMENT);
cso_restore_fragment_samplers(ctx->cso);
cso_restore_fragment_sampler_views(ctx->cso);
cso_restore_viewport(ctx->cso);
cso_restore_framebuffer(ctx->cso);

View File

@ -446,7 +446,7 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
assert(height <= (GLsizei)maxSize);
cso_save_rasterizer(cso);
cso_save_samplers(cso, PIPE_SHADER_FRAGMENT);
cso_save_fragment_samplers(cso);
cso_save_fragment_sampler_views(cso);
cso_save_viewport(cso);
cso_save_fragment_shader(cso);
@ -535,7 +535,7 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
/* restore state */
cso_restore_rasterizer(cso);
cso_restore_samplers(cso, PIPE_SHADER_FRAGMENT);
cso_restore_fragment_samplers(cso);
cso_restore_fragment_sampler_views(cso);
cso_restore_viewport(cso);
cso_restore_fragment_shader(cso);

View File

@ -689,7 +689,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
cso_save_rasterizer(cso);
cso_save_viewport(cso);
cso_save_samplers(cso, PIPE_SHADER_FRAGMENT);
cso_save_fragment_samplers(cso);
cso_save_fragment_sampler_views(cso);
cso_save_fragment_shader(cso);
cso_save_stream_outputs(cso);
@ -817,7 +817,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
/* restore state */
cso_restore_rasterizer(cso);
cso_restore_viewport(cso);
cso_restore_samplers(cso, PIPE_SHADER_FRAGMENT);
cso_restore_fragment_samplers(cso);
cso_restore_fragment_sampler_views(cso);
cso_restore_fragment_shader(cso);
cso_restore_vertex_shader(cso);