struct gallivm_state *gallivm,
struct lp_type type,
unsigned texture_unit,
+ unsigned target,
boolean need_nr_mips,
boolean scalar_lod,
LLVMValueRef explicit_lod, /* optional */
&sampler->dynamic_state.base,
type,
texture_unit,
+ target,
need_nr_mips,
scalar_lod,
explicit_lod,
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,
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,
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;
struct gallivm_state *gallivm,
struct lp_type type,
unsigned unit,
+ unsigned target,
boolean need_nr_mips,
boolean scalar_lod,
LLVMValueRef explicit_lod, /* optional */
}
}
+static unsigned
+tgsi_to_pipe_tex_target(unsigned tgsi_target)
+{
+ switch (tgsi_target) {
+ case TGSI_TEXTURE_BUFFER:
+ return PIPE_BUFFER;
+ case TGSI_TEXTURE_1D:
+ case TGSI_TEXTURE_SHADOW1D:
+ return PIPE_TEXTURE_1D;
+ case TGSI_TEXTURE_2D:
+ case TGSI_TEXTURE_SHADOW2D:
+ case TGSI_TEXTURE_2D_MSAA:
+ return PIPE_TEXTURE_2D;
+ case TGSI_TEXTURE_3D:
+ return PIPE_TEXTURE_3D;
+ case TGSI_TEXTURE_CUBE:
+ case TGSI_TEXTURE_SHADOWCUBE:
+ return PIPE_TEXTURE_CUBE;
+ case TGSI_TEXTURE_RECT:
+ case TGSI_TEXTURE_SHADOWRECT:
+ return PIPE_TEXTURE_RECT;
+ case TGSI_TEXTURE_1D_ARRAY:
+ case TGSI_TEXTURE_SHADOW1D_ARRAY:
+ return PIPE_TEXTURE_1D_ARRAY;
+ case TGSI_TEXTURE_2D_ARRAY:
+ case TGSI_TEXTURE_SHADOW2D_ARRAY:
+ case TGSI_TEXTURE_2D_ARRAY_MSAA:
+ return PIPE_TEXTURE_2D_ARRAY;
+ case TGSI_TEXTURE_CUBE_ARRAY:
+ case TGSI_TEXTURE_SHADOWCUBE_ARRAY:
+ return PIPE_TEXTURE_CUBE_ARRAY;
+ default:
+ assert(0);
+ return PIPE_BUFFER;
+ }
+}
+
/**
* High-level instruction translators.
*/
unsigned has_lod;
unsigned i;
unsigned unit = inst->Src[1].Register.Index;
- unsigned target;
+ unsigned target, pipe_target;
if (is_sviewinfo) {
target = bld->sv[unit].Resource;
else
explicit_lod = NULL;
+ pipe_target = tgsi_to_pipe_tex_target(target);
+
/* TODO: use scalar lod if explicit_lod is broadcasted scalar */
scalar_lod = bld->bld_base.info->processor == TGSI_PROCESSOR_FRAGMENT;
bld->sampler->emit_size_query(bld->sampler,
bld->bld_base.base.gallivm,
bld->bld_base.int_bld.type,
- unit,
+ unit, pipe_target,
is_sviewinfo,
scalar_lod,
explicit_lod,
struct gallivm_state *gallivm,
struct lp_type type,
unsigned texture_unit,
+ unsigned target,
boolean need_nr_mips,
boolean scalar_lod,
LLVMValueRef explicit_lod, /* optional */
&sampler->dynamic_state.base,
type,
texture_unit,
+ target,
need_nr_mips,
scalar_lod,
explicit_lod,