diff options
author | Brian Paul <[email protected]> | 2013-10-07 18:16:22 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2013-10-23 10:15:38 -0600 |
commit | a3ed98f7aa85636579a5696bf036ec13e5c9104a (patch) | |
tree | 104078a2a8b875e5ec7c5524e7797d46d109d7e0 /src/gallium/auxiliary | |
parent | b11fc226e6b106de8eb777a8e62c4f7303c66fbc (diff) |
gallium: new, unified pipe_context::set_sampler_views() function
The new function replaces four old functions: set_fragment/vertex/
geometry/compute_sampler_views().
Note: at this time, it's expected that the 'start' parameter will
always be zero.
Reviewed-by: Roland Scheidegger <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Tested-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/cso_cache/cso_context.c | 35 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_pipe_aaline.c | 37 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_pipe_pstipple.c | 33 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_blitter.c | 12 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_compositor.c | 4 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_idct.c | 6 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_matrix_filter.c | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_mc.c | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_median_filter.c | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_mpeg12_decoder.c | 4 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_zscan.c | 3 |
11 files changed, 67 insertions, 76 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 4d7c3871256..23d3245e881 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -306,6 +306,7 @@ void cso_release_all( struct cso_context *ctx ) ctx->pipe->bind_rasterizer_state( ctx->pipe, NULL ); { + static struct pipe_sampler_view *views[PIPE_MAX_SAMPLERS] = { NULL }; static void *zeros[PIPE_MAX_SAMPLERS] = { NULL }; struct pipe_screen *scr = ctx->pipe->screen; unsigned sh; @@ -315,6 +316,7 @@ void cso_release_all( struct cso_context *ctx ) assert(max <= PIPE_MAX_SAMPLERS); if (max > 0) { ctx->pipe->bind_sampler_states(ctx->pipe, sh, 0, max, zeros); + ctx->pipe->set_sampler_views(ctx->pipe, sh, 0, max, views); } } } @@ -323,9 +325,7 @@ void cso_release_all( struct cso_context *ctx ) ctx->pipe->bind_fs_state( ctx->pipe, NULL ); ctx->pipe->bind_vs_state( ctx->pipe, NULL ); ctx->pipe->bind_vertex_elements_state( ctx->pipe, NULL ); - ctx->pipe->set_fragment_sampler_views(ctx->pipe, 0, NULL); - if (ctx->pipe->set_vertex_sampler_views) - ctx->pipe->set_vertex_sampler_views(ctx->pipe, 0, NULL); + if (ctx->pipe->set_stream_output_targets) ctx->pipe->set_stream_output_targets(ctx->pipe, 0, NULL, 0); } @@ -1185,19 +1185,8 @@ cso_set_sampler_views(struct cso_context *ctx, info->nr_views = count; /* bind the new sampler views */ - switch (shader_stage) { - case PIPE_SHADER_FRAGMENT: - ctx->pipe->set_fragment_sampler_views(ctx->pipe, count, info->views); - break; - case PIPE_SHADER_VERTEX: - ctx->pipe->set_vertex_sampler_views(ctx->pipe, count, info->views); - break; - case PIPE_SHADER_GEOMETRY: - ctx->pipe->set_geometry_sampler_views(ctx->pipe, count, info->views); - break; - default: - assert(!"bad shader type in cso_set_sampler_views()"); - } + ctx->pipe->set_sampler_views(ctx->pipe, shader_stage, 0, count, + info->views); } @@ -1236,19 +1225,7 @@ cso_restore_sampler_views(struct cso_context *ctx, unsigned shader_stage) num = MAX2(info->nr_views, nr_saved); /* bind the old/saved sampler views */ - switch (shader_stage) { - case PIPE_SHADER_FRAGMENT: - ctx->pipe->set_fragment_sampler_views(ctx->pipe, num, info->views); - break; - case PIPE_SHADER_VERTEX: - ctx->pipe->set_vertex_sampler_views(ctx->pipe, num, info->views); - break; - case PIPE_SHADER_GEOMETRY: - ctx->pipe->set_geometry_sampler_views(ctx->pipe, num, info->views); - break; - default: - assert(!"bad shader type in cso_restore_sampler_views()"); - } + ctx->pipe->set_sampler_views(ctx->pipe, shader_stage, 0, num, info->views); info->nr_views = nr_saved; info->nr_views_saved = 0; diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c index 3c93bf7f722..d00b721f190 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c @@ -121,8 +121,8 @@ struct aaline_stage void (*driver_bind_sampler_states)(struct pipe_context *, unsigned, unsigned, unsigned, void **); - void (*driver_set_sampler_views)(struct pipe_context *, - unsigned, + void (*driver_set_sampler_views)(struct pipe_context *, unsigned shader, + unsigned start, unsigned count, struct pipe_sampler_view **); }; @@ -708,7 +708,8 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header) aaline->driver_bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, num_samplers, aaline->state.sampler); - aaline->driver_set_sampler_views(pipe, num_samplers, aaline->state.sampler_views); + aaline->driver_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, + num_samplers, aaline->state.sampler_views); /* Disable triangle culling, stippling, unfilled mode etc. */ r = draw_get_rasterizer_no_cull(draw, rast->scissor, rast->flatshade); @@ -740,8 +741,8 @@ aaline_flush(struct draw_stage *stage, unsigned flags) aaline->num_samplers, aaline->state.sampler); - aaline->driver_set_sampler_views(pipe, - aaline->num_sampler_views, + aaline->driver_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, + aaline->num_samplers, aaline->state.sampler_views); /* restore original rasterizer state */ @@ -791,7 +792,7 @@ aaline_destroy(struct draw_stage *stage) pipe->delete_fs_state = aaline->driver_delete_fs_state; pipe->bind_sampler_states = aaline->driver_bind_sampler_states; - pipe->set_fragment_sampler_views = aaline->driver_set_sampler_views; + pipe->set_sampler_views = aaline->driver_set_sampler_views; FREE( stage ); } @@ -932,8 +933,8 @@ aaline_bind_sampler_states(struct pipe_context *pipe, unsigned shader, static void -aaline_set_sampler_views(struct pipe_context *pipe, - unsigned num, +aaline_set_sampler_views(struct pipe_context *pipe, unsigned shader, + unsigned start, unsigned num, struct pipe_sampler_view **views) { struct aaline_stage *aaline = aaline_stage_from_pipe(pipe); @@ -943,17 +944,17 @@ aaline_set_sampler_views(struct pipe_context *pipe, return; } - /* save current */ - for (i = 0; i < num; i++) { - pipe_sampler_view_reference(&aaline->state.sampler_views[i], views[i]); - } - for ( ; i < PIPE_MAX_SHADER_SAMPLER_VIEWS; i++) { - pipe_sampler_view_reference(&aaline->state.sampler_views[i], NULL); + if (shader == PIPE_SHADER_FRAGMENT) { + /* save current */ + for (i = 0; i < num; i++) { + pipe_sampler_view_reference(&aaline->state.sampler_views[start + i], + views[i]); + } + aaline->num_sampler_views = num; } - aaline->num_sampler_views = num; /* pass-through */ - aaline->driver_set_sampler_views(pipe, num, views); + aaline->driver_set_sampler_views(pipe, shader, start, num, views); } @@ -1008,7 +1009,7 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe) aaline->driver_delete_fs_state = pipe->delete_fs_state; aaline->driver_bind_sampler_states = pipe->bind_sampler_states; - aaline->driver_set_sampler_views = pipe->set_fragment_sampler_views; + aaline->driver_set_sampler_views = pipe->set_sampler_views; /* override the driver's functions */ pipe->create_fs_state = aaline_create_fs_state; @@ -1016,7 +1017,7 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe) pipe->delete_fs_state = aaline_delete_fs_state; pipe->bind_sampler_states = aaline_bind_sampler_states; - pipe->set_fragment_sampler_views = aaline_set_sampler_views; + pipe->set_sampler_views = aaline_set_sampler_views; /* Install once everything is known to be OK: */ diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index e39276a55d3..17b1d3d7039 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -103,7 +103,8 @@ struct pstip_stage unsigned, unsigned, void **); void (*driver_set_sampler_views)(struct pipe_context *, - unsigned, + unsigned shader, unsigned start, + unsigned count, struct pipe_sampler_view **); void (*driver_set_polygon_stipple)(struct pipe_context *, @@ -552,7 +553,9 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header) pstip->driver_bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, num_samplers, pstip->state.samplers); - pstip->driver_set_sampler_views(pipe, num_samplers, pstip->state.sampler_views); + pstip->driver_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, + num_samplers, pstip->state.sampler_views); + draw->suspend_flushing = FALSE; /* now really draw first triangle */ @@ -579,9 +582,10 @@ pstip_flush(struct draw_stage *stage, unsigned flags) pstip->num_samplers, pstip->state.samplers); - pstip->driver_set_sampler_views(pipe, + pstip->driver_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, pstip->num_sampler_views, pstip->state.sampler_views); + draw->suspend_flushing = FALSE; } @@ -732,24 +736,23 @@ pstip_bind_sampler_states(struct pipe_context *pipe, unsigned shader, static void pstip_set_sampler_views(struct pipe_context *pipe, - unsigned num, + unsigned shader, unsigned start, unsigned num, struct pipe_sampler_view **views) { struct pstip_stage *pstip = pstip_stage_from_pipe(pipe); uint i; - /* save current */ - for (i = 0; i < num; i++) { - pipe_sampler_view_reference(&pstip->state.sampler_views[i], views[i]); - } - for (; i < PIPE_MAX_SHADER_SAMPLER_VIEWS; i++) { - pipe_sampler_view_reference(&pstip->state.sampler_views[i], NULL); + if (shader == PIPE_SHADER_FRAGMENT) { + /* save current */ + for (i = 0; i < num; i++) { + pipe_sampler_view_reference(&pstip->state.sampler_views[start + i], + views[i]); + } + pstip->num_sampler_views = num; } - pstip->num_sampler_views = num; - /* pass-through */ - pstip->driver_set_sampler_views(pstip->pipe, num, views); + pstip->driver_set_sampler_views(pstip->pipe, shader, start, num, views); } @@ -804,7 +807,7 @@ draw_install_pstipple_stage(struct draw_context *draw, pstip->driver_delete_fs_state = pipe->delete_fs_state; pstip->driver_bind_sampler_states = pipe->bind_sampler_states; - pstip->driver_set_sampler_views = pipe->set_fragment_sampler_views; + pstip->driver_set_sampler_views = pipe->set_sampler_views; pstip->driver_set_polygon_stipple = pipe->set_polygon_stipple; /* override the driver's functions */ @@ -813,7 +816,7 @@ draw_install_pstipple_stage(struct draw_context *draw, pipe->delete_fs_state = pstip_delete_fs_state; pipe->bind_sampler_states = pstip_bind_sampler_states; - pipe->set_fragment_sampler_views = pstip_set_sampler_views; + pipe->set_sampler_views = pstip_set_sampler_views; pipe->set_polygon_stipple = pstip_set_polygon_stipple; return TRUE; diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index a51b9ef20b3..096d3bc2b98 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -535,9 +535,9 @@ static void blitter_restore_textures(struct blitter_context_priv *ctx) ctx->base.saved_num_sampler_states = ~0; /* Fragment sampler views. */ - pipe->set_fragment_sampler_views(pipe, - ctx->base.saved_num_sampler_views, - ctx->base.saved_sampler_views); + pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, + ctx->base.saved_num_sampler_views, + ctx->base.saved_sampler_views); for (i = 0; i < ctx->base.saved_num_sampler_views; i++) pipe_sampler_view_reference(&ctx->base.saved_sampler_views[i], NULL); @@ -1309,7 +1309,7 @@ void util_blitter_blit_generic(struct blitter_context *blitter, views[0] = src; views[1] = pipe->create_sampler_view(pipe, src->texture, &templ); - pipe->set_fragment_sampler_views(pipe, 2, views); + pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 2, views); pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, 2, samplers); pipe_sampler_view_reference(&views[1], NULL); @@ -1324,13 +1324,13 @@ void util_blitter_blit_generic(struct blitter_context *blitter, view = pipe->create_sampler_view(pipe, src->texture, &templ); - pipe->set_fragment_sampler_views(pipe, 1, &view); + pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &view); pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &sampler_state); pipe_sampler_view_reference(&view, NULL); } else { - pipe->set_fragment_sampler_views(pipe, 1, &src); + pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &src); pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &sampler_state); } diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c index db4c697828f..1c8312e9d06 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.c +++ b/src/gallium/auxiliary/vl/vl_compositor.c @@ -727,7 +727,9 @@ draw_layers(struct vl_compositor *c, struct vl_compositor_state *s, struct u_rec c->pipe->bind_fs_state(c->pipe, layer->fs); c->pipe->bind_sampler_states(c->pipe, PIPE_SHADER_FRAGMENT, 0, num_sampler_views, layer->samplers); - c->pipe->set_fragment_sampler_views(c->pipe, num_sampler_views, samplers); + c->pipe->set_sampler_views(c->pipe, PIPE_SHADER_FRAGMENT, 0, + num_sampler_views, samplers); + util_draw_arrays(c->pipe, PIPE_PRIM_QUADS, vb_index * 4, 4); vb_index++; diff --git a/src/gallium/auxiliary/vl/vl_idct.c b/src/gallium/auxiliary/vl/vl_idct.c index dc14bb71b46..79adb045dad 100644 --- a/src/gallium/auxiliary/vl/vl_idct.c +++ b/src/gallium/auxiliary/vl/vl_idct.c @@ -829,7 +829,8 @@ vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer, unsigned num_ idct->pipe->bind_sampler_states(idct->pipe, PIPE_SHADER_FRAGMENT, 0, 2, idct->samplers); - idct->pipe->set_fragment_sampler_views(idct->pipe, 2, buffer->sampler_views.stage[0]); + idct->pipe->set_sampler_views(idct->pipe, PIPE_SHADER_FRAGMENT, 0, 2, + buffer->sampler_views.stage[0]); /* mismatch control */ idct->pipe->set_framebuffer_state(idct->pipe, &buffer->fb_state_mismatch); @@ -855,6 +856,7 @@ vl_idct_prepare_stage2(struct vl_idct *idct, struct vl_idct_buffer *buffer) idct->pipe->bind_rasterizer_state(idct->pipe, idct->rs_state); idct->pipe->bind_sampler_states(idct->pipe, PIPE_SHADER_FRAGMENT, 0, 2, idct->samplers); - idct->pipe->set_fragment_sampler_views(idct->pipe, 2, buffer->sampler_views.stage[1]); + idct->pipe->set_sampler_views(idct->pipe, PIPE_SHADER_FRAGMENT, + 0, 2, buffer->sampler_views.stage[1]); } diff --git a/src/gallium/auxiliary/vl/vl_matrix_filter.c b/src/gallium/auxiliary/vl/vl_matrix_filter.c index b7c88e776b6..56b7003f0fc 100644 --- a/src/gallium/auxiliary/vl/vl_matrix_filter.c +++ b/src/gallium/auxiliary/vl/vl_matrix_filter.c @@ -308,7 +308,8 @@ vl_matrix_filter_render(struct vl_matrix_filter *filter, filter->pipe->bind_blend_state(filter->pipe, filter->blend); filter->pipe->bind_sampler_states(filter->pipe, PIPE_SHADER_FRAGMENT, 0, 1, &filter->sampler); - filter->pipe->set_fragment_sampler_views(filter->pipe, 1, &src); + filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_FRAGMENT, + 0, 1, &src); filter->pipe->bind_vs_state(filter->pipe, filter->vs); filter->pipe->bind_fs_state(filter->pipe, filter->fs); filter->pipe->set_framebuffer_state(filter->pipe, &fb_state); diff --git a/src/gallium/auxiliary/vl/vl_mc.c b/src/gallium/auxiliary/vl/vl_mc.c index bd75df164ab..7d4aee67c7b 100644 --- a/src/gallium/auxiliary/vl/vl_mc.c +++ b/src/gallium/auxiliary/vl/vl_mc.c @@ -613,7 +613,8 @@ vl_mc_render_ref(struct vl_mc *renderer, struct vl_mc_buffer *buffer, struct pip renderer->pipe->bind_vs_state(renderer->pipe, renderer->vs_ref); renderer->pipe->bind_fs_state(renderer->pipe, renderer->fs_ref); - renderer->pipe->set_fragment_sampler_views(renderer->pipe, 1, &ref); + renderer->pipe->set_sampler_views(renderer->pipe, PIPE_SHADER_FRAGMENT, + 0, 1, &ref); renderer->pipe->bind_sampler_states(renderer->pipe, PIPE_SHADER_FRAGMENT, 0, 1, &renderer->sampler_ref); diff --git a/src/gallium/auxiliary/vl/vl_median_filter.c b/src/gallium/auxiliary/vl/vl_median_filter.c index f5ef117893d..6d98392d6e9 100644 --- a/src/gallium/auxiliary/vl/vl_median_filter.c +++ b/src/gallium/auxiliary/vl/vl_median_filter.c @@ -387,7 +387,8 @@ vl_median_filter_render(struct vl_median_filter *filter, filter->pipe->bind_blend_state(filter->pipe, filter->blend); filter->pipe->bind_sampler_states(filter->pipe, PIPE_SHADER_FRAGMENT, 0, 1, &filter->sampler); - filter->pipe->set_fragment_sampler_views(filter->pipe, 1, &src); + filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_FRAGMENT, + 0, 1, &src); filter->pipe->bind_vs_state(filter->pipe, filter->vs); filter->pipe->bind_fs_state(filter->pipe, filter->fs); filter->pipe->set_framebuffer_state(filter->pipe, &fb_state); diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c index bc207ac725d..ca4eb3ef6aa 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c @@ -746,7 +746,9 @@ vl_mpeg12_end_frame(struct pipe_video_codec *decoder, if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT) vl_idct_prepare_stage2(i ? &dec->idct_c : &dec->idct_y, &buf->idct[plane]); else { - dec->base.context->set_fragment_sampler_views(dec->base.context, 1, &mc_source_sv[plane]); + dec->base.context->set_sampler_views(dec->base.context, + PIPE_SHADER_FRAGMENT, 0, 1, + &mc_source_sv[plane]); dec->base.context->bind_sampler_states(dec->base.context, PIPE_SHADER_FRAGMENT, 0, 1, &dec->sampler_ycbcr); diff --git a/src/gallium/auxiliary/vl/vl_zscan.c b/src/gallium/auxiliary/vl/vl_zscan.c index 2d616d57c7a..40502ae633f 100644 --- a/src/gallium/auxiliary/vl/vl_zscan.c +++ b/src/gallium/auxiliary/vl/vl_zscan.c @@ -578,7 +578,8 @@ vl_zscan_render(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer, unsigned 0, 3, zscan->samplers); zscan->pipe->set_framebuffer_state(zscan->pipe, &buffer->fb_state); zscan->pipe->set_viewport_states(zscan->pipe, 0, 1, &buffer->viewport); - zscan->pipe->set_fragment_sampler_views(zscan->pipe, 3, &buffer->src); + zscan->pipe->set_sampler_views(zscan->pipe, PIPE_SHADER_FRAGMENT, + 0, 3, &buffer->src); zscan->pipe->bind_vs_state(zscan->pipe, zscan->vs); zscan->pipe->bind_fs_state(zscan->pipe, zscan->fs); util_draw_arrays_instanced(zscan->pipe, PIPE_PRIM_QUADS, 0, 4, 0, num_instances); |