[Mesa-dev] [PATCH] gallivm: fix up out-of-bounds level when using conformant out-of-bound behavior

Jose Fonseca jfonseca at vmware.com
Wed Jul 30 04:16:57 PDT 2014


On 30/07/14 04:08, sroland at vmware.com wrote:
> From: Roland Scheidegger <sroland at vmware.com>
>
> When using (d3d10) conformant out-of-bound behavior for texel fetching
> (currently always enabled) the level still needs to be set to a safe value
> even though the offset in the end won't get used because the level is used
> to look up the mip offset itself and the actual strides, which might otherwise
> crash.
> For simplicity, we'll use level 0 in this case (this ought to be safe, llvmpipe
> does not actually fill in level 0 information if first_level is larger, but
> some random strides / offsets shouldn't hurt as ultimately we always use
> offset 0 in this case).
> Fixes a crash in some in-house test where random huge levels appear in
> lp_build_fetch_texel() despite the test always using a fixed 0 for level
> actually... But in any case the value comes from the shader and thus can
> easily be outside max mip level.
>
> CC: <mesa-stable at lists.freedesktop.org>
> ---
>   src/gallium/auxiliary/gallivm/lp_bld_sample.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
> index aeecba8..f1bf285 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
> @@ -927,6 +927,7 @@ lp_build_nearest_mip_level(struct lp_build_sample_context *bld,
>                                                                   bld->int_coord_bld.type,
>                                                                   out);
>         }
> +      level = lp_build_andnot(&bld->int_coord_bld, level, *out_of_bounds);
>         *level_out = level;
>      }
>      else {
>

Looks good.

Jose


More information about the mesa-dev mailing list