summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2016-04-26 19:54:41 -0500
committerNicolai Hähnle <[email protected]>2016-06-01 22:37:15 +0200
commitd9893feb2c9d86345ea561f84d03e89229faa35d (patch)
treeb6cf80d31fbb17bb56fee22a13965ad6c81b36ee /src
parentfc0352ff9c5b0f6941b37934ee65c6002acd8144 (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')
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c39
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.h9
-rw-r--r--src/mesa/state_tracker/st_atom_image.c9
3 files changed, 53 insertions, 4 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,
diff --git a/src/mesa/state_tracker/st_atom_image.c b/src/mesa/state_tracker/st_atom_image.c
index e96d10a196c..9b8f5059ac0 100644
--- a/src/mesa/state_tracker/st_atom_image.c
+++ b/src/mesa/state_tracker/st_atom_image.c
@@ -34,6 +34,7 @@
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
#include "util/u_surface.h"
+#include "cso_cache/cso_context.h"
#include "st_cb_texture.h"
#include "st_debug.h"
@@ -122,12 +123,12 @@ st_bind_images(struct st_context *st, struct gl_shader *shader,
}
}
}
- st->pipe->set_shader_images(st->pipe, shader_type, 0, shader->NumImages,
- images);
+ cso_set_shader_images(st->cso_context, shader_type, 0, shader->NumImages,
+ images);
/* clear out any stale shader images */
if (shader->NumImages < c->MaxImageUniforms)
- st->pipe->set_shader_images(
- st->pipe, shader_type,
+ cso_set_shader_images(
+ st->cso_context, shader_type,
shader->NumImages,
c->MaxImageUniforms - shader->NumImages,
NULL);