diff options
author | Nicolai Hähnle <[email protected]> | 2016-04-26 19:54:41 -0500 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2016-06-01 22:37:15 +0200 |
commit | d9893feb2c9d86345ea561f84d03e89229faa35d (patch) | |
tree | b6cf80d31fbb17bb56fee22a13965ad6c81b36ee /src/gallium/auxiliary | |
parent | fc0352ff9c5b0f6941b37934ee65c6002acd8144 (diff) |
gallium/cso: allow saving the first fragment shader image slot
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/cso_cache/cso_context.c | 39 | ||||
-rw-r--r-- | src/gallium/auxiliary/cso_cache/cso_context.h | 9 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 5206acae8f4..b84d5997aaa 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -91,6 +91,9 @@ struct cso_context { struct pipe_constant_buffer aux_constbuf_current[PIPE_SHADER_TYPES]; struct pipe_constant_buffer aux_constbuf_saved[PIPE_SHADER_TYPES]; + struct pipe_image_view fragment_image0_current; + struct pipe_image_view fragment_image0_saved; + unsigned nr_so_targets; struct pipe_stream_output_target *so_targets[PIPE_MAX_SO_BUFFERS]; @@ -371,6 +374,9 @@ void cso_destroy_context( struct cso_context *ctx ) pipe_resource_reference(&ctx->aux_constbuf_saved[i].buffer, NULL); } + pipe_resource_reference(&ctx->fragment_image0_current.resource, NULL); + pipe_resource_reference(&ctx->fragment_image0_saved.resource, NULL); + for (i = 0; i < PIPE_MAX_SO_BUFFERS; i++) { pipe_so_target_reference(&ctx->so_targets[i], NULL); pipe_so_target_reference(&ctx->so_targets_saved[i], NULL); @@ -1353,6 +1359,35 @@ cso_restore_fragment_sampler_views(struct cso_context *ctx) void +cso_set_shader_images(struct cso_context *ctx, unsigned shader_stage, + unsigned start, unsigned count, + struct pipe_image_view *images) +{ + if (shader_stage == PIPE_SHADER_FRAGMENT && start == 0 && count >= 1) { + util_copy_image_view(&ctx->fragment_image0_current, &images[0]); + } + + ctx->pipe->set_shader_images(ctx->pipe, shader_stage, start, count, images); +} + + +static void +cso_save_fragment_image0(struct cso_context *ctx) +{ + util_copy_image_view(&ctx->fragment_image0_saved, + &ctx->fragment_image0_current); +} + + +static void +cso_restore_fragment_image0(struct cso_context *ctx) +{ + cso_set_shader_images(ctx, PIPE_SHADER_FRAGMENT, 0, 1, + &ctx->fragment_image0_saved); +} + + +void cso_set_stream_outputs(struct cso_context *ctx, unsigned num_targets, struct pipe_stream_output_target **targets, @@ -1541,6 +1576,8 @@ cso_save_state(struct cso_context *cso, unsigned state_mask) cso_save_viewport(cso); if (state_mask & CSO_BIT_PAUSE_QUERIES) cso->pipe->set_active_query_state(cso->pipe, false); + if (state_mask & CSO_BIT_FRAGMENT_IMAGE0) + cso_save_fragment_image0(cso); } @@ -1594,6 +1631,8 @@ cso_restore_state(struct cso_context *cso) cso_restore_viewport(cso); if (state_mask & CSO_BIT_PAUSE_QUERIES) cso->pipe->set_active_query_state(cso->pipe, true); + if (state_mask & CSO_BIT_FRAGMENT_IMAGE0) + cso_restore_fragment_image0(cso); cso->saved_state = 0; } diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index e27cbe9f721..a4309c7684c 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -171,6 +171,7 @@ void cso_set_render_condition(struct cso_context *cso, #define CSO_BIT_VERTEX_SHADER 0x20000 #define CSO_BIT_VIEWPORT 0x40000 #define CSO_BIT_PAUSE_QUERIES 0x80000 +#define CSO_BIT_FRAGMENT_IMAGE0 0x100000 #define CSO_BITS_ALL_SHADERS (CSO_BIT_VERTEX_SHADER | \ CSO_BIT_FRAGMENT_SHADER | \ @@ -191,6 +192,14 @@ cso_set_sampler_views(struct cso_context *cso, struct pipe_sampler_view **views); +/* shader images */ + +void +cso_set_shader_images(struct cso_context *cso, unsigned shader_stage, + unsigned start, unsigned count, + struct pipe_image_view *views); + + /* constant buffers */ void cso_set_constant_buffer(struct cso_context *cso, unsigned shader_stage, |