summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2015-07-05 15:53:10 +0200
committerMarek Olšák <marek.olsak@amd.com>2015-07-22 23:56:00 +0200
commit3639d66a473591e21aa2ec7692c95c827b479632 (patch)
tree9194a39ecac9b60ef11c84eb1b39463ebcf5041f
parent2d8213bfa9023b47a5fd6599596e1b02fdcdd4f6 (diff)
cso: only allow saving and restoring fragment sampler views
Not needed for other shader stages.
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c103
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.h4
-rw-r--r--src/gallium/auxiliary/hud/hud_context.c4
-rw-r--r--src/gallium/auxiliary/postprocess/pp_run.c4
-rw-r--r--src/gallium/auxiliary/util/u_blit.c4
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c4
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c4
7 files changed, 63 insertions, 64 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index 5aef2d5c487..1705175d660 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -66,12 +66,6 @@ struct sampler_info
void *samplers_saved[PIPE_MAX_SAMPLERS];
unsigned nr_samplers_saved;
-
- struct pipe_sampler_view *views[PIPE_MAX_SHADER_SAMPLER_VIEWS];
- unsigned nr_views;
-
- struct pipe_sampler_view *views_saved[PIPE_MAX_SHADER_SAMPLER_VIEWS];
- unsigned nr_views_saved;
};
@@ -85,6 +79,12 @@ struct cso_context {
boolean has_tessellation;
boolean has_streamout;
+ struct pipe_sampler_view *fragment_views[PIPE_MAX_SHADER_SAMPLER_VIEWS];
+ unsigned nr_fragment_views;
+
+ struct pipe_sampler_view *fragment_views_saved[PIPE_MAX_SHADER_SAMPLER_VIEWS];
+ unsigned nr_fragment_views_saved;
+
struct sampler_info samplers[PIPE_SHADER_TYPES];
struct pipe_vertex_buffer aux_vertex_buffer_current;
@@ -297,7 +297,7 @@ out:
*/
void cso_destroy_context( struct cso_context *ctx )
{
- unsigned i, shader;
+ unsigned i;
if (ctx->pipe) {
ctx->pipe->set_index_buffer(ctx->pipe, NULL);
@@ -347,13 +347,9 @@ void cso_destroy_context( struct cso_context *ctx )
ctx->pipe->set_stream_output_targets(ctx->pipe, 0, NULL, NULL);
}
- /* free sampler views for each shader stage */
- for (shader = 0; shader < Elements(ctx->samplers); shader++) {
- struct sampler_info *info = &ctx->samplers[shader];
- for (i = 0; i < PIPE_MAX_SHADER_SAMPLER_VIEWS; i++) {
- pipe_sampler_view_reference(&info->views[i], NULL);
- pipe_sampler_view_reference(&info->views_saved[i], NULL);
- }
+ for (i = 0; i < PIPE_MAX_SHADER_SAMPLER_VIEWS; i++) {
+ pipe_sampler_view_reference(&ctx->fragment_views[i], NULL);
+ pipe_sampler_view_reference(&ctx->fragment_views_saved[i], NULL);
}
util_unreference_framebuffer_state(&ctx->fb);
@@ -1281,71 +1277,74 @@ cso_set_sampler_views(struct cso_context *ctx,
unsigned count,
struct pipe_sampler_view **views)
{
- struct sampler_info *info = &ctx->samplers[shader_stage];
- unsigned i;
- boolean any_change = FALSE;
+ if (shader_stage == PIPE_SHADER_FRAGMENT) {
+ unsigned i;
+ boolean any_change = FALSE;
- /* reference new views */
- for (i = 0; i < count; i++) {
- any_change |= info->views[i] != views[i];
- pipe_sampler_view_reference(&info->views[i], views[i]);
- }
- /* unref extra old views, if any */
- for (; i < info->nr_views; i++) {
- any_change |= info->views[i] != NULL;
- pipe_sampler_view_reference(&info->views[i], NULL);
- }
+ /* reference new views */
+ for (i = 0; i < count; i++) {
+ any_change |= ctx->fragment_views[i] != views[i];
+ pipe_sampler_view_reference(&ctx->fragment_views[i], views[i]);
+ }
+ /* unref extra old views, if any */
+ for (; i < ctx->nr_fragment_views; i++) {
+ any_change |= ctx->fragment_views[i] != NULL;
+ pipe_sampler_view_reference(&ctx->fragment_views[i], NULL);
+ }
- /* bind the new sampler views */
- if (any_change) {
- ctx->pipe->set_sampler_views(ctx->pipe, shader_stage, 0,
- MAX2(info->nr_views, count),
- info->views);
- }
+ /* bind the new sampler views */
+ if (any_change) {
+ ctx->pipe->set_sampler_views(ctx->pipe, shader_stage, 0,
+ MAX2(ctx->nr_fragment_views, count),
+ ctx->fragment_views);
+ }
- info->nr_views = count;
+ ctx->nr_fragment_views = count;
+ }
+ else
+ ctx->pipe->set_sampler_views(ctx->pipe, shader_stage, 0, count, views);
}
void
-cso_save_sampler_views(struct cso_context *ctx, unsigned shader_stage)
+cso_save_fragment_sampler_views(struct cso_context *ctx)
{
- struct sampler_info *info = &ctx->samplers[shader_stage];
unsigned i;
- info->nr_views_saved = info->nr_views;
+ ctx->nr_fragment_views_saved = ctx->nr_fragment_views;
- for (i = 0; i < info->nr_views; i++) {
- assert(!info->views_saved[i]);
- pipe_sampler_view_reference(&info->views_saved[i], info->views[i]);
+ for (i = 0; i < ctx->nr_fragment_views; i++) {
+ assert(!ctx->fragment_views_saved[i]);
+ pipe_sampler_view_reference(&ctx->fragment_views_saved[i],
+ ctx->fragment_views[i]);
}
}
void
-cso_restore_sampler_views(struct cso_context *ctx, unsigned shader_stage)
+cso_restore_fragment_sampler_views(struct cso_context *ctx)
{
- struct sampler_info *info = &ctx->samplers[shader_stage];
- unsigned i, nr_saved = info->nr_views_saved;
+ unsigned i, nr_saved = ctx->nr_fragment_views_saved;
unsigned num;
for (i = 0; i < nr_saved; i++) {
- pipe_sampler_view_reference(&info->views[i], NULL);
+ pipe_sampler_view_reference(&ctx->fragment_views[i], NULL);
/* move the reference from one pointer to another */
- info->views[i] = info->views_saved[i];
- info->views_saved[i] = NULL;
+ ctx->fragment_views[i] = ctx->fragment_views_saved[i];
+ ctx->fragment_views_saved[i] = NULL;
}
- for (; i < info->nr_views; i++) {
- pipe_sampler_view_reference(&info->views[i], NULL);
+ for (; i < ctx->nr_fragment_views; i++) {
+ pipe_sampler_view_reference(&ctx->fragment_views[i], NULL);
}
- num = MAX2(info->nr_views, nr_saved);
+ num = MAX2(ctx->nr_fragment_views, nr_saved);
/* bind the old/saved sampler views */
- ctx->pipe->set_sampler_views(ctx->pipe, shader_stage, 0, num, info->views);
+ ctx->pipe->set_sampler_views(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, num,
+ ctx->fragment_views);
- info->nr_views = nr_saved;
- info->nr_views_saved = 0;
+ ctx->nr_fragment_views = nr_saved;
+ ctx->nr_fragment_views_saved = 0;
}
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h
index cc50b60c6cd..9d12aaf45be 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -210,10 +210,10 @@ cso_set_sampler_views(struct cso_context *cso,
struct pipe_sampler_view **views);
void
-cso_save_sampler_views(struct cso_context *cso, unsigned shader_stage);
+cso_save_fragment_sampler_views(struct cso_context *ctx);
void
-cso_restore_sampler_views(struct cso_context *cso, unsigned shader_stage);
+cso_restore_fragment_sampler_views(struct cso_context *ctx);
/* constant buffers */
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index bd571907f2f..4602b7c23c9 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -437,7 +437,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
cso_save_blend(cso);
cso_save_depth_stencil_alpha(cso);
cso_save_fragment_shader(cso);
- cso_save_sampler_views(cso, PIPE_SHADER_FRAGMENT);
+ cso_save_fragment_sampler_views(cso);
cso_save_samplers(cso, PIPE_SHADER_FRAGMENT);
cso_save_rasterizer(cso);
cso_save_viewport(cso);
@@ -567,7 +567,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
cso_restore_blend(cso);
cso_restore_depth_stencil_alpha(cso);
cso_restore_fragment_shader(cso);
- cso_restore_sampler_views(cso, PIPE_SHADER_FRAGMENT);
+ cso_restore_fragment_sampler_views(cso);
cso_restore_samplers(cso, PIPE_SHADER_FRAGMENT);
cso_restore_rasterizer(cso);
cso_restore_viewport(cso);
diff --git a/src/gallium/auxiliary/postprocess/pp_run.c b/src/gallium/auxiliary/postprocess/pp_run.c
index e76ce854442..04f92c99236 100644
--- a/src/gallium/auxiliary/postprocess/pp_run.c
+++ b/src/gallium/auxiliary/postprocess/pp_run.c
@@ -126,7 +126,7 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
cso_save_sample_mask(cso);
cso_save_min_samples(cso);
cso_save_samplers(cso, PIPE_SHADER_FRAGMENT);
- cso_save_sampler_views(cso, PIPE_SHADER_FRAGMENT);
+ cso_save_fragment_sampler_views(cso);
cso_save_stencil_ref(cso);
cso_save_stream_outputs(cso);
cso_save_vertex_elements(cso);
@@ -197,7 +197,7 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
cso_restore_sample_mask(cso);
cso_restore_min_samples(cso);
cso_restore_samplers(cso, PIPE_SHADER_FRAGMENT);
- cso_restore_sampler_views(cso, PIPE_SHADER_FRAGMENT);
+ cso_restore_fragment_sampler_views(cso);
cso_restore_stencil_ref(cso);
cso_restore_stream_outputs(cso);
cso_restore_vertex_elements(cso);
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index 0ba00a3997a..049ab35955a 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -547,7 +547,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
cso_save_sample_mask(ctx->cso);
cso_save_min_samples(ctx->cso);
cso_save_samplers(ctx->cso, PIPE_SHADER_FRAGMENT);
- cso_save_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT);
+ cso_save_fragment_sampler_views(ctx->cso);
cso_save_stream_outputs(ctx->cso);
cso_save_viewport(ctx->cso);
cso_save_framebuffer(ctx->cso);
@@ -629,7 +629,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
cso_restore_sample_mask(ctx->cso);
cso_restore_min_samples(ctx->cso);
cso_restore_samplers(ctx->cso, PIPE_SHADER_FRAGMENT);
- cso_restore_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT);
+ cso_restore_fragment_sampler_views(ctx->cso);
cso_restore_viewport(ctx->cso);
cso_restore_framebuffer(ctx->cso);
cso_restore_fragment_shader(ctx->cso);
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index c881e194f70..e1445585b53 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -447,7 +447,7 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
cso_save_rasterizer(cso);
cso_save_samplers(cso, PIPE_SHADER_FRAGMENT);
- cso_save_sampler_views(cso, PIPE_SHADER_FRAGMENT);
+ cso_save_fragment_sampler_views(cso);
cso_save_viewport(cso);
cso_save_fragment_shader(cso);
cso_save_stream_outputs(cso);
@@ -536,7 +536,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_sampler_views(cso, PIPE_SHADER_FRAGMENT);
+ cso_restore_fragment_sampler_views(cso);
cso_restore_viewport(cso);
cso_restore_fragment_shader(cso);
cso_restore_vertex_shader(cso);
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index e736d4b5083..9f1a37ff82c 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -690,7 +690,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_sampler_views(cso, PIPE_SHADER_FRAGMENT);
+ cso_save_fragment_sampler_views(cso);
cso_save_fragment_shader(cso);
cso_save_stream_outputs(cso);
cso_save_vertex_shader(cso);
@@ -818,7 +818,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
cso_restore_rasterizer(cso);
cso_restore_viewport(cso);
cso_restore_samplers(cso, PIPE_SHADER_FRAGMENT);
- cso_restore_sampler_views(cso, PIPE_SHADER_FRAGMENT);
+ cso_restore_fragment_sampler_views(cso);
cso_restore_fragment_shader(cso);
cso_restore_vertex_shader(cso);
cso_restore_tessctrl_shader(cso);