gallivm/sample: fix lod query on array textures.

The lod query doesn't take a layer, but the code tries to use one,
detect lodq and don't use a layer in those cases.

There appears to be no GL tests for this behaviour, but the vulkan
CTS hits it.

Fixes:
dEQP-VK.glsl.texture_functions.query.texturequerylod.*

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6339>
This commit is contained in:
Dave Airlie 2020-08-17 11:09:19 +10:00
parent da4f2215aa
commit 7893dfa247
1 changed files with 19 additions and 3 deletions

View File

@ -2100,7 +2100,7 @@ lp_build_sample_common(struct lp_build_sample_context *bld,
!explicit_lod);
lp_build_cube_lookup(bld, coords, derivs, &cube_rho, &cube_derivs, need_derivs);
derivs = &cube_derivs;
if (target == PIPE_TEXTURE_CUBE_ARRAY) {
if (target == PIPE_TEXTURE_CUBE_ARRAY && !is_lodq) {
/* calculate cube layer coord now */
LLVMValueRef layer = lp_build_iround(&bld->coord_bld, coords[3]);
LLVMValueRef six = lp_build_const_int_vec(bld->gallivm, bld->int_coord_type, 6);
@ -2109,8 +2109,8 @@ lp_build_sample_common(struct lp_build_sample_context *bld,
/* because of seamless filtering can't add it to face (coords[2]) here. */
}
}
else if (target == PIPE_TEXTURE_1D_ARRAY ||
target == PIPE_TEXTURE_2D_ARRAY) {
else if ((target == PIPE_TEXTURE_1D_ARRAY ||
target == PIPE_TEXTURE_2D_ARRAY) && !is_lodq) {
coords[2] = lp_build_iround(&bld->coord_bld, coords[2]);
coords[2] = lp_build_layer_coord(bld, texture_index, FALSE, coords[2], NULL);
}
@ -3483,14 +3483,22 @@ lp_build_sample_gen_func(struct gallivm_state *gallivm,
unsigned num_param = 0;
unsigned i, num_coords, num_derivs, num_offsets, layer;
enum lp_sampler_lod_control lod_control;
enum lp_sampler_op_type op_type;
boolean need_cache = FALSE;
lod_control = (sample_key & LP_SAMPLER_LOD_CONTROL_MASK) >>
LP_SAMPLER_LOD_CONTROL_SHIFT;
op_type = (sample_key & LP_SAMPLER_OP_TYPE_MASK) >>
LP_SAMPLER_OP_TYPE_SHIFT;
get_target_info(static_texture_state->target,
&num_coords, &num_derivs, &num_offsets, &layer);
/* lod query doesn't take a layer */
if (layer && op_type == LP_SAMPLER_OP_LODQ)
layer = 0;
if (dynamic_state->cache_ptr) {
const struct util_format_description *format_desc;
format_desc = util_format_description(static_texture_state->format);
@ -3601,14 +3609,22 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm,
const LLVMValueRef *offsets = params->offsets;
const struct lp_derivatives *derivs = params->derivs;
enum lp_sampler_lod_control lod_control;
enum lp_sampler_op_type op_type;
boolean need_cache = FALSE;
lod_control = (sample_key & LP_SAMPLER_LOD_CONTROL_MASK) >>
LP_SAMPLER_LOD_CONTROL_SHIFT;
op_type = (sample_key & LP_SAMPLER_OP_TYPE_MASK) >>
LP_SAMPLER_OP_TYPE_SHIFT;
get_target_info(static_texture_state->target,
&num_coords, &num_derivs, &num_offsets, &layer);
/* lod query doesn't take a layer */
if (layer && op_type == LP_SAMPLER_OP_LODQ)
layer = 0;
if (dynamic_state->cache_ptr) {
const struct util_format_description *format_desc;
format_desc = util_format_description(static_texture_state->format);