[Mesa-dev] [PATCH] cso: fix incorrect sampler view count in cso_restore_sampler_views()
Jose Fonseca
jfonseca at vmware.com
Wed Oct 16 02:56:47 CEST 2013
Looks good to me. Thanks for looking into this.
Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
Jose
----- Original Message -----
> During the recent bind_sampler_states() interface change in gallium
> we changed the CSO single_sampler_done() function so that if we were
> decreasing the number of sampler states bound in the driver, we'd
> null-out the "extra/old" sampler states to unbind them. See commit
> 1e2fbf265.
>
> However, we didn't make the corresponding fix for sampler views.
> This caused an assertion to fail in the svga driver which checked
> that the number of sampler views matched the number of sampler states.
>
> This patch fixes cso_restore_sampler_views() so that it nulls-out
> the extra/old sampler views if the number of new views is less than
> the number of current/old views.
> ---
> src/gallium/auxiliary/cso_cache/cso_context.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c
> b/src/gallium/auxiliary/cso_cache/cso_context.c
> index 6642c45..4d7c387 100644
> --- a/src/gallium/auxiliary/cso_cache/cso_context.c
> +++ b/src/gallium/auxiliary/cso_cache/cso_context.c
> @@ -1221,6 +1221,7 @@ cso_restore_sampler_views(struct cso_context *ctx,
> unsigned shader_stage)
> {
> struct sampler_info *info = &ctx->samplers[shader_stage];
> unsigned i, nr_saved = info->nr_views_saved;
> + unsigned num;
>
> for (i = 0; i < nr_saved; i++) {
> pipe_sampler_view_reference(&info->views[i], NULL);
> @@ -1232,16 +1233,18 @@ cso_restore_sampler_views(struct cso_context *ctx,
> unsigned shader_stage)
> pipe_sampler_view_reference(&info->views[i], NULL);
> }
>
> + 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, nr_saved,
> info->views);
> + ctx->pipe->set_fragment_sampler_views(ctx->pipe, num, info->views);
> break;
> case PIPE_SHADER_VERTEX:
> - ctx->pipe->set_vertex_sampler_views(ctx->pipe, nr_saved, info->views);
> + ctx->pipe->set_vertex_sampler_views(ctx->pipe, num, info->views);
> break;
> case PIPE_SHADER_GEOMETRY:
> - ctx->pipe->set_geometry_sampler_views(ctx->pipe, nr_saved,
> info->views);
> + ctx->pipe->set_geometry_sampler_views(ctx->pipe, num, info->views);
> break;
> default:
> assert(!"bad shader type in cso_restore_sampler_views()");
> --
> 1.7.10.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
More information about the mesa-dev
mailing list