llvmpipe: handle sampling from 2d views of 3d images

this is seldom used but is required by KHR_gl_texture_3D_image

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15583>
This commit is contained in:
Mike Blumenkrantz 2022-03-24 09:04:14 -04:00 committed by Marge Bot
parent d415c28e64
commit fe7c3eba33
3 changed files with 13 additions and 4 deletions

View file

@ -1061,7 +1061,8 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
if (res->target == PIPE_TEXTURE_1D_ARRAY ||
res->target == PIPE_TEXTURE_2D_ARRAY ||
res->target == PIPE_TEXTURE_CUBE ||
res->target == PIPE_TEXTURE_CUBE_ARRAY) {
res->target == PIPE_TEXTURE_CUBE_ARRAY ||
(res->target == PIPE_TEXTURE_3D && view->target == PIPE_TEXTURE_2D)) {
/*
* For array textures, we don't have first_layer, instead
* adjust last_layer (stored as depth) plus the mip level offsets
@ -1078,7 +1079,10 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
assert(jit_tex->depth % 6 == 0);
}
assert(view->u.tex.first_layer <= view->u.tex.last_layer);
assert(view->u.tex.last_layer < res->array_size);
if (res->target == PIPE_TEXTURE_3D)
assert(view->u.tex.last_layer < res->depth0);
else
assert(view->u.tex.last_layer < res->array_size);
}
}
else {

View file

@ -1011,7 +1011,8 @@ lp_csctx_set_sampler_views(struct lp_cs_context *csctx,
if (res->target == PIPE_TEXTURE_1D_ARRAY ||
res->target == PIPE_TEXTURE_2D_ARRAY ||
res->target == PIPE_TEXTURE_CUBE ||
res->target == PIPE_TEXTURE_CUBE_ARRAY) {
res->target == PIPE_TEXTURE_CUBE_ARRAY ||
(res->target == PIPE_TEXTURE_3D && view->target == PIPE_TEXTURE_2D)) {
/*
* For array textures, we don't have first_layer, instead
* adjust last_layer (stored as depth) plus the mip level offsets
@ -1028,7 +1029,10 @@ lp_csctx_set_sampler_views(struct lp_cs_context *csctx,
assert(jit_tex->depth % 6 == 0);
}
assert(view->u.tex.first_layer <= view->u.tex.last_layer);
assert(view->u.tex.last_layer < res->array_size);
if (res->target == PIPE_TEXTURE_3D)
assert(view->u.tex.last_layer < res->depth0);
else
assert(view->u.tex.last_layer < res->array_size);
}
}
else {

View file

@ -231,6 +231,7 @@ llvmpipe_create_sampler_view(struct pipe_context *pipe,
assert(texture->target == PIPE_TEXTURE_1D);
else if (view->target == PIPE_TEXTURE_2D)
assert(texture->target == PIPE_TEXTURE_2D_ARRAY ||
texture->target == PIPE_TEXTURE_3D ||
texture->target == PIPE_TEXTURE_CUBE ||
texture->target == PIPE_TEXTURE_CUBE_ARRAY);
else if (view->target == PIPE_TEXTURE_2D_ARRAY)