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>
(cherry picked from commit fe7c3eba33)
This commit is contained in:
Mike Blumenkrantz 2022-03-24 09:04:14 -04:00 committed by Dylan Baker
parent 1928268fb3
commit 59a7dc5a2d
4 changed files with 14 additions and 5 deletions

View file

@ -1684,7 +1684,7 @@
"description": "llvmpipe: handle sampling from 2d views of 3d images",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"because_sha": null
},
{

View file

@ -1035,7 +1035,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
@ -1052,7 +1053,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

@ -985,7 +985,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
@ -1002,7 +1003,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)