From b0f74250e1496d4872fd731b45049868b3efc883 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 8 Aug 2013 03:42:46 +0200 Subject: gallivm: use texture target from shader instead of static state for size query d3d10 has no notion of distinct array resources neither at the resource nor sampler view level. However, shader dcl of resources certainly has, and d3d10 expects resinfo to return the values according to that - in particular a resource might have been a 1d texture with some array layers, then the sampler view might have only used 1 layer so it can be accessed both as 1d or 1d array texture (I think - the former definitely works). resinfo of a resource decleared as array needs to return number of array layers but non-array resource needs to return 0 (and not 1). Hence fix this by passing the target from the shader decl to emit_size_query and use that (in case of OpenGL the target will come from the instruction itself). Could probably do the same for actual sampling, though it may not matter there (as the bogus components will essentially get clamped away), possibly could wreak havoc though if it REALLY doesn't match (which is of course an error but still). Reviewed-by: Zack Rusin --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 32 +++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index b0bb58bdf0b..e403ac83c6a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -1943,6 +1943,7 @@ lp_build_size_query_soa(struct gallivm_state *gallivm, struct lp_sampler_dynamic_state *dynamic_state, struct lp_type int_type, unsigned texture_unit, + unsigned target, boolean need_nr_mips, boolean scalar_lod, LLVMValueRef explicit_lod, @@ -1955,9 +1956,36 @@ lp_build_size_query_soa(struct gallivm_state *gallivm, unsigned num_lods = 1; struct lp_build_context bld_int_vec; - dims = texture_dims(static_state->target); + /* + * Do some sanity verification about bound texture and shader dcl target. + * Not entirely sure what's possible but assume array/non-array + * always compatible (probably not ok for OpenGL but d3d10 has no + * distinction of arrays at the resource level). + * Everything else looks bogus (though not entirely sure about rect/2d). + * Currently disabled because it causes assertion failures if there's + * nothing bound (or rather a dummy texture, not that this case would + * return the right values). + */ + if (0 && static_state->target != target) { + if (static_state->target == PIPE_TEXTURE_1D) + assert(target == PIPE_TEXTURE_1D_ARRAY); + else if (static_state->target == PIPE_TEXTURE_1D_ARRAY) + assert(target == PIPE_TEXTURE_1D); + else if (static_state->target == PIPE_TEXTURE_2D) + assert(target == PIPE_TEXTURE_2D_ARRAY); + else if (static_state->target == PIPE_TEXTURE_2D_ARRAY) + assert(target == PIPE_TEXTURE_2D); + else if (static_state->target == PIPE_TEXTURE_CUBE) + assert(target == PIPE_TEXTURE_CUBE_ARRAY); + else if (static_state->target == PIPE_TEXTURE_CUBE_ARRAY) + assert(target == PIPE_TEXTURE_CUBE); + else + assert(0); + } + + dims = texture_dims(target); - switch (static_state->target) { + switch (target) { case PIPE_TEXTURE_1D_ARRAY: case PIPE_TEXTURE_2D_ARRAY: has_array = TRUE; -- cgit v1.2.3