static LLVMValueRef
draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base,
struct gallivm_state *gallivm,
- unsigned unit,
+ unsigned texture_unit,
unsigned member_index,
const char *member_name,
boolean emit_load)
LLVMValueRef ptr;
LLVMValueRef res;
- debug_assert(unit < PIPE_MAX_SHADER_SAMPLER_VIEWS);
+ debug_assert(texture_unit < PIPE_MAX_SHADER_SAMPLER_VIEWS);
/* context[0] */
indices[0] = lp_build_const_int32(gallivm, 0);
/* context[0].textures */
indices[1] = lp_build_const_int32(gallivm, DRAW_JIT_CTX_TEXTURES);
/* context[0].textures[unit] */
- indices[2] = lp_build_const_int32(gallivm, unit);
+ indices[2] = lp_build_const_int32(gallivm, texture_unit);
/* context[0].textures[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
else
res = ptr;
- lp_build_name(res, "context.texture%u.%s", unit, member_name);
+ lp_build_name(res, "context.texture%u.%s", texture_unit, member_name);
return res;
}
static LLVMValueRef
draw_llvm_sampler_member(const struct lp_sampler_dynamic_state *base,
struct gallivm_state *gallivm,
- unsigned unit,
+ unsigned sampler_unit,
unsigned member_index,
const char *member_name,
boolean emit_load)
LLVMValueRef ptr;
LLVMValueRef res;
- debug_assert(unit < PIPE_MAX_SAMPLERS);
+ debug_assert(sampler_unit < PIPE_MAX_SAMPLERS);
/* context[0] */
indices[0] = lp_build_const_int32(gallivm, 0);
/* context[0].samplers */
indices[1] = lp_build_const_int32(gallivm, DRAW_JIT_CTX_SAMPLERS);
/* context[0].samplers[unit] */
- indices[2] = lp_build_const_int32(gallivm, unit);
+ indices[2] = lp_build_const_int32(gallivm, sampler_unit);
/* context[0].samplers[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
else
res = ptr;
- lp_build_name(res, "context.sampler%u.%s", unit, member_name);
+ lp_build_name(res, "context.sampler%u.%s", sampler_unit, member_name);
return res;
}
static LLVMValueRef \
draw_llvm_texture_##_name( const struct lp_sampler_dynamic_state *base, \
struct gallivm_state *gallivm, \
- unsigned unit) \
+ unsigned texture_unit) \
{ \
- return draw_llvm_texture_member(base, gallivm, unit, _index, #_name, _emit_load ); \
+ return draw_llvm_texture_member(base, gallivm, texture_unit, _index, #_name, _emit_load ); \
}
static LLVMValueRef \
draw_llvm_sampler_##_name( const struct lp_sampler_dynamic_state *base, \
struct gallivm_state *gallivm, \
- unsigned unit) \
+ unsigned sampler_unit) \
{ \
- return draw_llvm_sampler_member(base, gallivm, unit, _index, #_name, _emit_load ); \
+ return draw_llvm_sampler_member(base, gallivm, sampler_unit, _index, #_name, _emit_load ); \
}
draw_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
struct gallivm_state *gallivm,
struct lp_type type,
- unsigned unit,
+ unsigned texture_unit,
LLVMValueRef explicit_lod, /* optional */
LLVMValueRef *sizes_out)
{
struct draw_llvm_sampler_soa *sampler = (struct draw_llvm_sampler_soa *)base;
- assert(unit < PIPE_MAX_SAMPLERS);
+ assert(texture_unit < PIPE_MAX_SHADER_SAMPLER_VIEWS);
lp_build_size_query_soa(gallivm,
- &sampler->dynamic_state.static_state[unit].texture_state,
+ &sampler->dynamic_state.static_state[texture_unit].texture_state,
&sampler->dynamic_state.base,
type,
- unit,
+ texture_unit,
explicit_lod,
sizes_out);
}
LLVMValueRef
(*width)( const struct lp_sampler_dynamic_state *state,
struct gallivm_state *gallivm,
- unsigned unit);
+ unsigned texture_unit);
/** Obtain the base texture height (returns int32) */
LLVMValueRef
(*height)( const struct lp_sampler_dynamic_state *state,
struct gallivm_state *gallivm,
- unsigned unit);
+ unsigned texture_unit);
/** Obtain the base texture depth (returns int32) */
LLVMValueRef
(*depth)( const struct lp_sampler_dynamic_state *state,
struct gallivm_state *gallivm,
- unsigned unit);
+ unsigned texture_unit);
/** Obtain the first mipmap level (base level) (returns int32) */
LLVMValueRef
(*first_level)( const struct lp_sampler_dynamic_state *state,
struct gallivm_state *gallivm,
- unsigned unit);
+ unsigned texture_unit);
/** Obtain the number of mipmap levels minus one (returns int32) */
LLVMValueRef
(*last_level)( const struct lp_sampler_dynamic_state *state,
struct gallivm_state *gallivm,
- unsigned unit);
+ unsigned texture_unit);
/** Obtain stride in bytes between image rows/blocks (returns int32) */
LLVMValueRef
(*row_stride)( const struct lp_sampler_dynamic_state *state,
struct gallivm_state *gallivm,
- unsigned unit);
+ unsigned texture_unit);
/** Obtain stride in bytes between image slices (returns int32) */
LLVMValueRef
(*img_stride)( const struct lp_sampler_dynamic_state *state,
struct gallivm_state *gallivm,
- unsigned unit);
+ unsigned texture_unit);
/** Obtain pointer to base of texture */
LLVMValueRef
(*base_ptr)( const struct lp_sampler_dynamic_state *state,
struct gallivm_state *gallivm,
- unsigned unit);
+ unsigned texture_unit);
/** Obtain pointer to array of mipmap offsets */
LLVMValueRef
(*mip_offsets)( const struct lp_sampler_dynamic_state *state,
struct gallivm_state *gallivm,
- unsigned unit);
+ unsigned texture_unit);
/* These are callbacks for sampler state */
/** Obtain texture min lod (returns float) */
LLVMValueRef
(*min_lod)(const struct lp_sampler_dynamic_state *state,
- struct gallivm_state *gallivm, unsigned unit);
+ struct gallivm_state *gallivm, unsigned sampler_unit);
/** Obtain texture max lod (returns float) */
LLVMValueRef
(*max_lod)(const struct lp_sampler_dynamic_state *state,
- struct gallivm_state *gallivm, unsigned unit);
+ struct gallivm_state *gallivm, unsigned sampler_unit);
/** Obtain texture lod bias (returns float) */
LLVMValueRef
(*lod_bias)(const struct lp_sampler_dynamic_state *state,
- struct gallivm_state *gallivm, unsigned unit);
+ struct gallivm_state *gallivm, unsigned sampler_unit);
/** Obtain texture border color (returns ptr to float[4]) */
LLVMValueRef
(*border_color)(const struct lp_sampler_dynamic_state *state,
- struct gallivm_state *gallivm, unsigned unit);
+ struct gallivm_state *gallivm, unsigned sampler_unit);
};
void
lp_build_nearest_mip_level(struct lp_build_sample_context *bld,
- unsigned unit,
+ unsigned texture_unit,
LLVMValueRef lod,
LLVMValueRef *level_out);
void
lp_build_linear_mip_levels(struct lp_build_sample_context *bld,
- unsigned unit,
+ unsigned texture_unit,
LLVMValueRef lod_ipart,
LLVMValueRef *lod_fpart_inout,
LLVMValueRef *level0_out,
const struct lp_static_texture_state *static_state,
struct lp_sampler_dynamic_state *dynamic_state,
struct lp_type int_type,
- unsigned unit,
+ unsigned texture_unit,
LLVMValueRef explicit_lod,
LLVMValueRef *sizes_out);
*/
static void
lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
- unsigned unit,
+ unsigned sampler_unit,
LLVMValueRef width,
LLVMValueRef height,
LLVMValueRef depth,
/* select texel color or border color depending on use_border */
LLVMValueRef border_color_ptr =
bld->dynamic_state->border_color(bld->dynamic_state,
- bld->gallivm, unit);
+ bld->gallivm, sampler_unit);
int chan;
for (chan = 0; chan < 4; chan++) {
LLVMValueRef border_chan =
*/
static void
lp_build_sample_image_nearest(struct lp_build_sample_context *bld,
- unsigned unit,
+ unsigned sampler_unit,
LLVMValueRef size,
LLVMValueRef row_stride_vec,
LLVMValueRef img_stride_vec,
/*
* Get texture colors.
*/
- lp_build_sample_texel_soa(bld, unit,
+ lp_build_sample_texel_soa(bld, sampler_unit,
width_vec, height_vec, depth_vec,
x, y, z,
row_stride_vec, img_stride_vec,
*/
static void
lp_build_sample_image_linear(struct lp_build_sample_context *bld,
- unsigned unit,
+ unsigned sampler_unit,
LLVMValueRef size,
LLVMValueRef row_stride_vec,
LLVMValueRef img_stride_vec,
* Get texture colors.
*/
/* get x0/x1 texels */
- lp_build_sample_texel_soa(bld, unit,
+ lp_build_sample_texel_soa(bld, sampler_unit,
width_vec, height_vec, depth_vec,
x0, y0, z0,
row_stride_vec, img_stride_vec,
data_ptr, mipoffsets, neighbors[0][0]);
- lp_build_sample_texel_soa(bld, unit,
+ lp_build_sample_texel_soa(bld, sampler_unit,
width_vec, height_vec, depth_vec,
x1, y0, z0,
row_stride_vec, img_stride_vec,
LLVMValueRef colors0[4];
/* get x0/x1 texels at y1 */
- lp_build_sample_texel_soa(bld, unit,
+ lp_build_sample_texel_soa(bld, sampler_unit,
width_vec, height_vec, depth_vec,
x0, y1, z0,
row_stride_vec, img_stride_vec,
data_ptr, mipoffsets, neighbors[1][0]);
- lp_build_sample_texel_soa(bld, unit,
+ lp_build_sample_texel_soa(bld, sampler_unit,
width_vec, height_vec, depth_vec,
x1, y1, z0,
row_stride_vec, img_stride_vec,
LLVMValueRef colors1[4];
/* get x0/x1/y0/y1 texels at z1 */
- lp_build_sample_texel_soa(bld, unit,
+ lp_build_sample_texel_soa(bld, sampler_unit,
width_vec, height_vec, depth_vec,
x0, y0, z1,
row_stride_vec, img_stride_vec,
data_ptr, mipoffsets, neighbors1[0][0]);
- lp_build_sample_texel_soa(bld, unit,
+ lp_build_sample_texel_soa(bld, sampler_unit,
width_vec, height_vec, depth_vec,
x1, y0, z1,
row_stride_vec, img_stride_vec,
data_ptr, mipoffsets, neighbors1[0][1]);
- lp_build_sample_texel_soa(bld, unit,
+ lp_build_sample_texel_soa(bld, sampler_unit,
width_vec, height_vec, depth_vec,
x0, y1, z1,
row_stride_vec, img_stride_vec,
data_ptr, mipoffsets, neighbors1[1][0]);
- lp_build_sample_texel_soa(bld, unit,
+ lp_build_sample_texel_soa(bld, sampler_unit,
width_vec, height_vec, depth_vec,
x1, y1, z1,
row_stride_vec, img_stride_vec,
*/
static void
lp_build_sample_mipmap(struct lp_build_sample_context *bld,
- unsigned unit,
+ unsigned sampler_unit,
unsigned img_filter,
unsigned mip_filter,
LLVMValueRef s,
mipoff0 = lp_build_get_mip_offsets(bld, ilevel0);
}
if (img_filter == PIPE_TEX_FILTER_NEAREST) {
- lp_build_sample_image_nearest(bld, unit,
+ lp_build_sample_image_nearest(bld, sampler_unit,
size0,
row_stride0_vec, img_stride0_vec,
data_ptr0, mipoff0, s, t, r,
}
else {
assert(img_filter == PIPE_TEX_FILTER_LINEAR);
- lp_build_sample_image_linear(bld, unit,
+ lp_build_sample_image_linear(bld, sampler_unit,
size0,
row_stride0_vec, img_stride0_vec,
data_ptr0, mipoff0, s, t, r,
mipoff1 = lp_build_get_mip_offsets(bld, ilevel1);
}
if (img_filter == PIPE_TEX_FILTER_NEAREST) {
- lp_build_sample_image_nearest(bld, unit,
+ lp_build_sample_image_nearest(bld, sampler_unit,
size1,
row_stride1_vec, img_stride1_vec,
data_ptr1, mipoff1, s, t, r,
colors1);
}
else {
- lp_build_sample_image_linear(bld, unit,
+ lp_build_sample_image_linear(bld, sampler_unit,
size1,
row_stride1_vec, img_stride1_vec,
data_ptr1, mipoff1, s, t, r,
*/
static LLVMValueRef
lp_build_layer_coord(struct lp_build_sample_context *bld,
- unsigned unit,
+ unsigned texture_unit,
LLVMValueRef layer)
{
LLVMValueRef maxlayer;
maxlayer = bld->dynamic_state->depth(bld->dynamic_state,
- bld->gallivm, unit);
+ bld->gallivm, texture_unit);
maxlayer = lp_build_sub(&bld->int_bld, maxlayer, bld->int_bld.one);
maxlayer = lp_build_broadcast_scalar(&bld->int_coord_bld, maxlayer);
return lp_build_clamp(&bld->int_coord_bld, layer,
*/
static void
lp_build_sample_general(struct lp_build_sample_context *bld,
- unsigned unit,
+ unsigned sampler_unit,
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
for (chan = 0; chan < 4; ++chan) {
texels[chan] = lp_build_alloca(bld->gallivm, bld->texel_bld.vec_type, "");
- lp_build_name(texels[chan], "sampler%u_texel_%c_var", unit, "xyzw"[chan]);
+ lp_build_name(texels[chan], "sampler%u_texel_%c_var", sampler_unit, "xyzw"[chan]);
}
if (min_filter == mag_filter) {
/* no need to distinguish between minification and magnification */
- lp_build_sample_mipmap(bld, unit,
+ lp_build_sample_mipmap(bld, sampler_unit,
min_filter, mip_filter,
s, t, r,
ilevel0, ilevel1, lod_fpart,
lp_build_if(&if_ctx, bld->gallivm, minify);
{
/* Use the minification filter */
- lp_build_sample_mipmap(bld, unit,
+ lp_build_sample_mipmap(bld, sampler_unit,
min_filter, mip_filter,
s, t, r,
ilevel0, ilevel1, lod_fpart,
lp_build_else(&if_ctx);
{
/* Use the magnification filter */
- lp_build_sample_mipmap(bld, unit,
+ lp_build_sample_mipmap(bld, sampler_unit,
mag_filter, PIPE_TEX_MIPFILTER_NONE,
s, t, r,
ilevel0, NULL, NULL,
for (chan = 0; chan < 4; ++chan) {
colors_out[chan] = LLVMBuildLoad(builder, texels[chan], "");
- lp_build_name(colors_out[chan], "sampler%u_texel_%c", unit, "xyzw"[chan]);
+ lp_build_name(colors_out[chan], "sampler%u_texel_%c", sampler_unit, "xyzw"[chan]);
}
}
*/
static void
lp_build_fetch_texel(struct lp_build_sample_context *bld,
- unsigned unit,
+ unsigned texture_unit,
const LLVMValueRef *coords,
LLVMValueRef explicit_lod,
const LLVMValueRef *offsets,
if (explicit_lod && bld->static_texture_state->target != PIPE_BUFFER) {
ilevel = lp_build_pack_aos_scalars(bld->gallivm, int_coord_bld->type,
perquadi_bld->type, explicit_lod, 0);
- lp_build_nearest_mip_level(bld, unit, ilevel, &ilevel);
+ lp_build_nearest_mip_level(bld, texture_unit, ilevel, &ilevel);
}
else {
bld->num_lods = 1;
if (target == PIPE_TEXTURE_1D_ARRAY ||
target == PIPE_TEXTURE_2D_ARRAY) {
if (target == PIPE_TEXTURE_1D_ARRAY) {
- z = lp_build_layer_coord(bld, unit, y);
+ z = lp_build_layer_coord(bld, texture_unit, y);
}
else {
- z = lp_build_layer_coord(bld, unit, z);
+ z = lp_build_layer_coord(bld, texture_unit, z);
}
}
const struct lp_static_texture_state *static_state,
struct lp_sampler_dynamic_state *dynamic_state,
struct lp_type int_type,
- unsigned unit,
+ unsigned texture_unit,
LLVMValueRef explicit_lod,
LLVMValueRef *sizes_out)
{
if (explicit_lod) {
LLVMValueRef first_level;
lod = LLVMBuildExtractElement(gallivm->builder, explicit_lod, lp_build_const_int32(gallivm, 0), "");
- first_level = dynamic_state->first_level(dynamic_state, gallivm, unit);
+ first_level = dynamic_state->first_level(dynamic_state, gallivm, texture_unit);
lod = lp_build_broadcast_scalar(&bld_int_vec,
LLVMBuildAdd(gallivm->builder, lod, first_level, "lod"));
size = bld_int_vec.undef;
size = LLVMBuildInsertElement(gallivm->builder, size,
- dynamic_state->width(dynamic_state, gallivm, unit),
+ dynamic_state->width(dynamic_state, gallivm, texture_unit),
lp_build_const_int32(gallivm, 0), "");
if (dims >= 2) {
size = LLVMBuildInsertElement(gallivm->builder, size,
- dynamic_state->height(dynamic_state, gallivm, unit),
+ dynamic_state->height(dynamic_state, gallivm, texture_unit),
lp_build_const_int32(gallivm, 1), "");
}
if (dims >= 3) {
size = LLVMBuildInsertElement(gallivm->builder, size,
- dynamic_state->depth(dynamic_state, gallivm, unit),
+ dynamic_state->depth(dynamic_state, gallivm, texture_unit),
lp_build_const_int32(gallivm, 2), "");
}
if (has_array)
size = LLVMBuildInsertElement(gallivm->builder, size,
- dynamic_state->depth(dynamic_state, gallivm, unit),
+ dynamic_state->depth(dynamic_state, gallivm, texture_unit),
lp_build_const_int32(gallivm, dims), "");
for (i = 0; i < dims + (has_array ? 1 : 0); i++) {
static LLVMValueRef
lp_llvm_texture_member(const struct lp_sampler_dynamic_state *base,
struct gallivm_state *gallivm,
- unsigned unit,
+ unsigned texture_unit,
unsigned member_index,
const char *member_name,
boolean emit_load)
LLVMValueRef ptr;
LLVMValueRef res;
- assert(unit < PIPE_MAX_SHADER_SAMPLER_VIEWS);
+ assert(texture_unit < PIPE_MAX_SHADER_SAMPLER_VIEWS);
/* context[0] */
indices[0] = lp_build_const_int32(gallivm, 0);
/* context[0].textures */
indices[1] = lp_build_const_int32(gallivm, LP_JIT_CTX_TEXTURES);
/* context[0].textures[unit] */
- indices[2] = lp_build_const_int32(gallivm, unit);
+ indices[2] = lp_build_const_int32(gallivm, texture_unit);
/* context[0].textures[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
else
res = ptr;
- lp_build_name(res, "context.texture%u.%s", unit, member_name);
+ lp_build_name(res, "context.texture%u.%s", texture_unit, member_name);
return res;
}
static LLVMValueRef \
lp_llvm_texture_##_name( const struct lp_sampler_dynamic_state *base, \
struct gallivm_state *gallivm, \
- unsigned unit) \
+ unsigned texture_unit) \
{ \
- return lp_llvm_texture_member(base, gallivm, unit, _index, #_name, _emit_load ); \
+ return lp_llvm_texture_member(base, gallivm, texture_unit, _index, #_name, _emit_load ); \
}
static LLVMValueRef
lp_llvm_sampler_member(const struct lp_sampler_dynamic_state *base,
struct gallivm_state *gallivm,
- unsigned unit,
+ unsigned sampler_unit,
unsigned member_index,
const char *member_name,
boolean emit_load)
LLVMValueRef ptr;
LLVMValueRef res;
- assert(unit < PIPE_MAX_SAMPLERS);
+ assert(sampler_unit < PIPE_MAX_SAMPLERS);
/* context[0] */
indices[0] = lp_build_const_int32(gallivm, 0);
/* context[0].samplers */
indices[1] = lp_build_const_int32(gallivm, LP_JIT_CTX_SAMPLERS);
/* context[0].samplers[unit] */
- indices[2] = lp_build_const_int32(gallivm, unit);
+ indices[2] = lp_build_const_int32(gallivm, sampler_unit);
/* context[0].samplers[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
else
res = ptr;
- lp_build_name(res, "context.sampler%u.%s", unit, member_name);
+ lp_build_name(res, "context.sampler%u.%s", sampler_unit, member_name);
return res;
}
static LLVMValueRef \
lp_llvm_sampler_##_name( const struct lp_sampler_dynamic_state *base, \
struct gallivm_state *gallivm, \
- unsigned unit) \
+ unsigned sampler_unit) \
{ \
- return lp_llvm_sampler_member(base, gallivm, unit, _index, #_name, _emit_load ); \
+ return lp_llvm_sampler_member(base, gallivm, sampler_unit, _index, #_name, _emit_load ); \
}
lp_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
struct gallivm_state *gallivm,
struct lp_type type,
- unsigned unit,
+ unsigned texture_unit,
LLVMValueRef explicit_lod, /* optional */
LLVMValueRef *sizes_out)
{
struct lp_llvm_sampler_soa *sampler = (struct lp_llvm_sampler_soa *)base;
- assert(unit < PIPE_MAX_SAMPLERS);
+ assert(texture_unit < PIPE_MAX_SHADER_SAMPLER_VIEWS);
lp_build_size_query_soa(gallivm,
- &sampler->dynamic_state.static_state[unit].texture_state,
+ &sampler->dynamic_state.static_state[texture_unit].texture_state,
&sampler->dynamic_state.base,
type,
- unit,
+ texture_unit,
explicit_lod,
sizes_out);
}