mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 15:10:12 +01:00
gallium/cso: allow saving the first fragment shader image slot
Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
parent
fc0352ff9c
commit
d9893feb2c
3 changed files with 53 additions and 4 deletions
|
|
@ -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);
|
||||
|
|
@ -1352,6 +1358,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,
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue