summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.c9
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.h3
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm_sample.c28
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.c39
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.h83
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c74
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi.h4
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c6
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c5
-rw-r--r--src/gallium/drivers/llvmpipe/lp_tex_sample.c28
-rw-r--r--src/gallium/drivers/llvmpipe/lp_tex_sample.h4
11 files changed, 171 insertions, 112 deletions
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 6e1fb407c53..1e6e6993814 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -620,6 +620,7 @@ generate_vs(struct draw_llvm_variant *variant,
system_values,
inputs,
outputs,
+ context_ptr,
draw_sampler,
&llvm->draw->vs.vertex_shader->info,
NULL);
@@ -1630,9 +1631,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,
LLVMBuildStore(builder, lp_build_zero(gallivm, lp_int_type(vs_type)), clipmask_bool_ptr);
/* code generated texture sampling */
- sampler = draw_llvm_sampler_soa_create(
- draw_llvm_variant_key_samplers(key),
- context_ptr);
+ sampler = draw_llvm_sampler_soa_create(draw_llvm_variant_key_samplers(key));
if (elts) {
start = zero;
@@ -2163,8 +2162,7 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
draw_gs_jit_context_num_constants(variant->gallivm, context_ptr);
/* code generated texture sampling */
- sampler = draw_llvm_sampler_soa_create(variant->key.samplers,
- context_ptr);
+ sampler = draw_llvm_sampler_soa_create(variant->key.samplers);
mask_val = generate_mask_value(variant, gs_type);
lp_build_mask_begin(&mask, gallivm, gs_type, mask_val);
@@ -2187,6 +2185,7 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
&system_values,
NULL,
outputs,
+ context_ptr,
sampler,
&llvm->draw->gs.geometry_shader->info,
(const struct lp_build_tgsi_gs_iface *)&gs_iface);
diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h
index af1960e5fe1..9565fc68af9 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.h
+++ b/src/gallium/auxiliary/draw/draw_llvm.h
@@ -526,8 +526,7 @@ void
draw_gs_llvm_dump_variant_key(struct draw_gs_llvm_variant_key *key);
struct lp_build_sampler_soa *
-draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state,
- LLVMValueRef context_ptr);
+draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state);
void
draw_llvm_set_sampler_state(struct draw_context *draw, unsigned shader_stage);
diff --git a/src/gallium/auxiliary/draw/draw_llvm_sample.c b/src/gallium/auxiliary/draw/draw_llvm_sample.c
index a6341fae3cd..16d075cec0a 100644
--- a/src/gallium/auxiliary/draw/draw_llvm_sample.c
+++ b/src/gallium/auxiliary/draw/draw_llvm_sample.c
@@ -59,8 +59,6 @@ struct draw_llvm_sampler_dynamic_state
struct lp_sampler_dynamic_state base;
const struct draw_sampler_static_state *static_state;
-
- LLVMValueRef context_ptr;
};
@@ -86,14 +84,13 @@ struct draw_llvm_sampler_soa
static LLVMValueRef
draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base,
struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
unsigned texture_unit,
unsigned member_index,
const char *member_name,
boolean emit_load)
{
LLVMBuilderRef builder = gallivm->builder;
- struct draw_llvm_sampler_dynamic_state *state =
- (struct draw_llvm_sampler_dynamic_state *)base;
LLVMValueRef indices[4];
LLVMValueRef ptr;
LLVMValueRef res;
@@ -109,7 +106,7 @@ draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base,
/* context[0].textures[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
- ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), "");
+ ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), "");
if (emit_load)
res = LLVMBuildLoad(builder, ptr, "");
@@ -133,14 +130,13 @@ draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base,
static LLVMValueRef
draw_llvm_sampler_member(const struct lp_sampler_dynamic_state *base,
struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
unsigned sampler_unit,
unsigned member_index,
const char *member_name,
boolean emit_load)
{
LLVMBuilderRef builder = gallivm->builder;
- struct draw_llvm_sampler_dynamic_state *state =
- (struct draw_llvm_sampler_dynamic_state *)base;
LLVMValueRef indices[4];
LLVMValueRef ptr;
LLVMValueRef res;
@@ -156,7 +152,7 @@ draw_llvm_sampler_member(const struct lp_sampler_dynamic_state *base,
/* context[0].samplers[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
- ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), "");
+ ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), "");
if (emit_load)
res = LLVMBuildLoad(builder, ptr, "");
@@ -182,9 +178,11 @@ draw_llvm_sampler_member(const struct lp_sampler_dynamic_state *base,
static LLVMValueRef \
draw_llvm_texture_##_name( const struct lp_sampler_dynamic_state *base, \
struct gallivm_state *gallivm, \
+ LLVMValueRef context_ptr, \
unsigned texture_unit) \
{ \
- return draw_llvm_texture_member(base, gallivm, texture_unit, _index, #_name, _emit_load ); \
+ return draw_llvm_texture_member(base, gallivm, context_ptr, \
+ texture_unit, _index, #_name, _emit_load ); \
}
@@ -203,9 +201,11 @@ DRAW_LLVM_TEXTURE_MEMBER(mip_offsets, DRAW_JIT_TEXTURE_MIP_OFFSETS, FALSE)
static LLVMValueRef \
draw_llvm_sampler_##_name( const struct lp_sampler_dynamic_state *base, \
struct gallivm_state *gallivm, \
+ LLVMValueRef context_ptr, \
unsigned sampler_unit) \
{ \
- return draw_llvm_sampler_member(base, gallivm, sampler_unit, _index, #_name, _emit_load ); \
+ return draw_llvm_sampler_member(base, gallivm, context_ptr, \
+ sampler_unit, _index, #_name, _emit_load ); \
}
@@ -233,6 +233,7 @@ draw_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base,
boolean is_fetch,
unsigned texture_index,
unsigned sampler_index,
+ LLVMValueRef context_ptr,
const LLVMValueRef *coords,
const LLVMValueRef *offsets,
const struct lp_derivatives *derivs,
@@ -254,6 +255,7 @@ draw_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base,
is_fetch,
texture_index,
sampler_index,
+ context_ptr,
coords,
offsets,
derivs,
@@ -271,6 +273,7 @@ draw_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
struct lp_type type,
unsigned texture_unit,
unsigned target,
+ LLVMValueRef context_ptr,
boolean is_sviewinfo,
enum lp_sampler_lod_property lod_property,
LLVMValueRef explicit_lod, /* optional */
@@ -286,6 +289,7 @@ draw_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
type,
texture_unit,
target,
+ context_ptr,
is_sviewinfo,
lod_property,
explicit_lod,
@@ -293,8 +297,7 @@ draw_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
}
struct lp_build_sampler_soa *
-draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state,
- LLVMValueRef context_ptr)
+draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state)
{
struct draw_llvm_sampler_soa *sampler;
@@ -319,7 +322,6 @@ draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_stat
sampler->dynamic_state.base.lod_bias = draw_llvm_sampler_lod_bias;
sampler->dynamic_state.base.border_color = draw_llvm_sampler_border_color;
sampler->dynamic_state.static_state = static_state;
- sampler->dynamic_state.context_ptr = context_ptr;
return &sampler->base;
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
index 7d18ee592ba..5b220450bf3 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
@@ -246,8 +246,8 @@ lp_build_rho(struct lp_build_sample_context *bld,
* the messy cube maps for now) when requested.
*/
- first_level = bld->dynamic_state->first_level(bld->dynamic_state,
- bld->gallivm, texture_unit);
+ first_level = bld->dynamic_state->first_level(bld->dynamic_state, bld->gallivm,
+ bld->context_ptr, texture_unit);
first_level_vec = lp_build_broadcast_scalar(int_size_bld, first_level);
int_size = lp_build_minify(int_size_bld, bld->int_size, first_level_vec, TRUE);
float_size = lp_build_int_to_float(float_size_bld, int_size);
@@ -714,6 +714,7 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
{
LLVMBuilderRef builder = bld->gallivm->builder;
+ struct lp_sampler_dynamic_state *dynamic_state = bld->dynamic_state;
struct lp_build_context *lodf_bld = &bld->lodf_bld;
LLVMValueRef lod;
@@ -744,8 +745,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
* This is hit during mipmap generation.
*/
LLVMValueRef min_lod =
- bld->dynamic_state->min_lod(bld->dynamic_state,
- bld->gallivm, sampler_unit);
+ dynamic_state->min_lod(dynamic_state, bld->gallivm,
+ bld->context_ptr, sampler_unit);
lod = lp_build_broadcast_scalar(lodf_bld, min_lod);
}
@@ -835,8 +836,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
/* add sampler lod bias */
if (bld->static_sampler_state->lod_bias_non_zero) {
LLVMValueRef sampler_lod_bias =
- bld->dynamic_state->lod_bias(bld->dynamic_state,
- bld->gallivm, sampler_unit);
+ dynamic_state->lod_bias(dynamic_state, bld->gallivm,
+ bld->context_ptr, sampler_unit);
sampler_lod_bias = lp_build_broadcast_scalar(lodf_bld,
sampler_lod_bias);
lod = LLVMBuildFAdd(builder, lod, sampler_lod_bias, "sampler_lod_bias");
@@ -845,16 +846,16 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
/* clamp lod */
if (bld->static_sampler_state->apply_max_lod) {
LLVMValueRef max_lod =
- bld->dynamic_state->max_lod(bld->dynamic_state,
- bld->gallivm, sampler_unit);
+ dynamic_state->max_lod(dynamic_state, bld->gallivm,
+ bld->context_ptr, sampler_unit);
max_lod = lp_build_broadcast_scalar(lodf_bld, max_lod);
lod = lp_build_min(lodf_bld, lod, max_lod);
}
if (bld->static_sampler_state->apply_min_lod) {
LLVMValueRef min_lod =
- bld->dynamic_state->min_lod(bld->dynamic_state,
- bld->gallivm, sampler_unit);
+ dynamic_state->min_lod(dynamic_state, bld->gallivm,
+ bld->context_ptr, sampler_unit);
min_lod = lp_build_broadcast_scalar(lodf_bld, min_lod);
lod = lp_build_max(lodf_bld, lod, min_lod);
@@ -901,12 +902,13 @@ lp_build_nearest_mip_level(struct lp_build_sample_context *bld,
LLVMValueRef *out_of_bounds)
{
struct lp_build_context *leveli_bld = &bld->leveli_bld;
+ struct lp_sampler_dynamic_state *dynamic_state = bld->dynamic_state;
LLVMValueRef first_level, last_level, level;
- first_level = bld->dynamic_state->first_level(bld->dynamic_state,
- bld->gallivm, texture_unit);
- last_level = bld->dynamic_state->last_level(bld->dynamic_state,
- bld->gallivm, texture_unit);
+ first_level = dynamic_state->first_level(dynamic_state, bld->gallivm,
+ bld->context_ptr, texture_unit);
+ last_level = dynamic_state->last_level(dynamic_state, bld->gallivm,
+ bld->context_ptr, texture_unit);
first_level = lp_build_broadcast_scalar(leveli_bld, first_level);
last_level = lp_build_broadcast_scalar(leveli_bld, last_level);
@@ -956,6 +958,7 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld,
LLVMValueRef *level1_out)
{
LLVMBuilderRef builder = bld->gallivm->builder;
+ struct lp_sampler_dynamic_state *dynamic_state = bld->dynamic_state;
struct lp_build_context *leveli_bld = &bld->leveli_bld;
struct lp_build_context *levelf_bld = &bld->levelf_bld;
LLVMValueRef first_level, last_level;
@@ -964,10 +967,10 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld,
assert(bld->num_lods == bld->num_mips);
- first_level = bld->dynamic_state->first_level(bld->dynamic_state,
- bld->gallivm, texture_unit);
- last_level = bld->dynamic_state->last_level(bld->dynamic_state,
- bld->gallivm, texture_unit);
+ first_level = dynamic_state->first_level(dynamic_state, bld->gallivm,
+ bld->context_ptr, texture_unit);
+ last_level = dynamic_state->last_level(dynamic_state, bld->gallivm,
+ bld->context_ptr, texture_unit);
first_level = lp_build_broadcast_scalar(leveli_bld, first_level);
last_level = lp_build_broadcast_scalar(leveli_bld, last_level);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
index be05b136edb..be41ca02ae8 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
@@ -138,79 +138,96 @@ struct lp_sampler_dynamic_state
/** Obtain the base texture width (or number of elements) (returns int32) */
LLVMValueRef
- (*width)( const struct lp_sampler_dynamic_state *state,
- struct gallivm_state *gallivm,
- unsigned texture_unit);
+ (*width)(const struct lp_sampler_dynamic_state *state,
+ struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
+ unsigned texture_unit);
/** Obtain the base texture height (returns int32) */
LLVMValueRef
- (*height)( const struct lp_sampler_dynamic_state *state,
- struct gallivm_state *gallivm,
- unsigned texture_unit);
+ (*height)(const struct lp_sampler_dynamic_state *state,
+ struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
+ unsigned texture_unit);
/** Obtain the base texture depth (or array size) (returns int32) */
LLVMValueRef
- (*depth)( const struct lp_sampler_dynamic_state *state,
- struct gallivm_state *gallivm,
- unsigned texture_unit);
+ (*depth)(const struct lp_sampler_dynamic_state *state,
+ struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
+ 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 texture_unit);
+ (*first_level)(const struct lp_sampler_dynamic_state *state,
+ struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
+ 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 texture_unit);
+ (*last_level)(const struct lp_sampler_dynamic_state *state,
+ struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
+ 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 texture_unit);
+ (*row_stride)(const struct lp_sampler_dynamic_state *state,
+ struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
+ 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 texture_unit);
+ (*img_stride)(const struct lp_sampler_dynamic_state *state,
+ struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
+ unsigned texture_unit);
/** Obtain pointer to base of texture */
LLVMValueRef
- (*base_ptr)( const struct lp_sampler_dynamic_state *state,
- struct gallivm_state *gallivm,
- unsigned texture_unit);
+ (*base_ptr)(const struct lp_sampler_dynamic_state *state,
+ struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
+ 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 texture_unit);
+ (*mip_offsets)(const struct lp_sampler_dynamic_state *state,
+ struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
+ 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 sampler_unit);
+ struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
+ unsigned sampler_unit);
/** Obtain texture max lod (returns float) */
LLVMValueRef
(*max_lod)(const struct lp_sampler_dynamic_state *state,
- struct gallivm_state *gallivm, unsigned sampler_unit);
+ struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
+ unsigned sampler_unit);
/** Obtain texture lod bias (returns float) */
LLVMValueRef
(*lod_bias)(const struct lp_sampler_dynamic_state *state,
- struct gallivm_state *gallivm, unsigned sampler_unit);
+ struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
+ 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 sampler_unit);
+ struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
+ unsigned sampler_unit);
};
@@ -305,6 +322,8 @@ struct lp_build_sample_context
LLVMValueRef int_size;
LLVMValueRef border_color_clamped;
+
+ LLVMValueRef context_ptr;
};
@@ -520,6 +539,7 @@ lp_build_sample_soa(struct gallivm_state *gallivm,
boolean is_fetch,
unsigned texture_index,
unsigned sampler_index,
+ LLVMValueRef context_ptr,
const LLVMValueRef *coords,
const LLVMValueRef *offsets,
const struct lp_derivatives *derivs,
@@ -545,6 +565,7 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
struct lp_type int_type,
unsigned texture_unit,
unsigned target,
+ LLVMValueRef context_ptr,
boolean is_sviewinfo,
enum lp_sampler_lod_property lod_property,
LLVMValueRef explicit_lod,
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index 99309fe75bd..a90278ea889 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -1678,8 +1678,8 @@ lp_build_layer_coord(struct lp_build_sample_context *bld,
LLVMValueRef num_layers;
struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
- num_layers = bld->dynamic_state->depth(bld->dynamic_state,
- bld->gallivm, texture_unit);
+ num_layers = bld->dynamic_state->depth(bld->dynamic_state, bld->gallivm,
+ bld->context_ptr, texture_unit);
if (out_of_bounds) {
LLVMValueRef out1, out;
@@ -1815,7 +1815,8 @@ lp_build_sample_common(struct lp_build_sample_context *bld,
case PIPE_TEX_MIPFILTER_NONE:
/* always use mip level 0 */
first_level = bld->dynamic_state->first_level(bld->dynamic_state,
- bld->gallivm, texture_index);
+ bld->gallivm, bld->context_ptr,
+ texture_index);
first_level = lp_build_broadcast_scalar(&bld->leveli_bld, first_level);
*ilevel0 = first_level;
break;
@@ -1840,8 +1841,8 @@ lp_build_clamp_border_color(struct lp_build_sample_context *bld,
struct gallivm_state *gallivm = bld->gallivm;
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef border_color_ptr =
- bld->dynamic_state->border_color(bld->dynamic_state,
- gallivm, sampler_unit);
+ bld->dynamic_state->border_color(bld->dynamic_state, gallivm,
+ bld->context_ptr, sampler_unit);
LLVMValueRef border_color;
const struct util_format_description *format_desc = bld->format_desc;
struct lp_type vec4_type = bld->texel_type;
@@ -2246,8 +2247,8 @@ lp_build_fetch_texel(struct lp_build_sample_context *bld,
else {
assert(bld->num_mips == 1);
if (bld->static_texture_state->target != PIPE_BUFFER) {
- ilevel = bld->dynamic_state->first_level(bld->dynamic_state,
- bld->gallivm, texture_unit);
+ ilevel = bld->dynamic_state->first_level(bld->dynamic_state, bld->gallivm,
+ bld->context_ptr, texture_unit);
}
else {
ilevel = lp_build_const_int32(bld->gallivm, 0);
@@ -2372,6 +2373,7 @@ lp_build_sample_soa(struct gallivm_state *gallivm,
boolean is_fetch,
unsigned texture_index,
unsigned sampler_index,
+ LLVMValueRef context_ptr,
const LLVMValueRef *coords,
const LLVMValueRef *offsets,
const struct lp_derivatives *derivs, /* optional */
@@ -2413,6 +2415,7 @@ lp_build_sample_soa(struct gallivm_state *gallivm,
/* Setup our build context */
memset(&bld, 0, sizeof bld);
bld.gallivm = gallivm;
+ bld.context_ptr = context_ptr;
bld.static_sampler_state = &derived_sampler_state;
bld.static_texture_state = static_texture_state;
bld.dynamic_state = dynamic_state;
@@ -2578,11 +2581,16 @@ lp_build_sample_soa(struct gallivm_state *gallivm,
lp_build_context_init(&bld.lodi_bld, gallivm, bld.lodi_type);
/* Get the dynamic state */
- tex_width = dynamic_state->width(dynamic_state, gallivm, texture_index);
- bld.row_stride_array = dynamic_state->row_stride(dynamic_state, gallivm, texture_index);
- bld.img_stride_array = dynamic_state->img_stride(dynamic_state, gallivm, texture_index);
- bld.base_ptr = dynamic_state->base_ptr(dynamic_state, gallivm, texture_index);
- bld.mip_offsets = dynamic_state->mip_offsets(dynamic_state, gallivm, texture_index);
+ tex_width = dynamic_state->width(dynamic_state, gallivm,
+ context_ptr, texture_index);
+ bld.row_stride_array = dynamic_state->row_stride(dynamic_state, gallivm,
+ context_ptr, texture_index);
+ bld.img_stride_array = dynamic_state->img_stride(dynamic_state, gallivm,
+ context_ptr, texture_index);
+ bld.base_ptr = dynamic_state->base_ptr(dynamic_state, gallivm,
+ context_ptr, texture_index);
+ bld.mip_offsets = dynamic_state->mip_offsets(dynamic_state, gallivm,
+ context_ptr, texture_index);
/* Note that mip_offsets is an array[level] of offsets to texture images */
/* width, height, depth as single int vector */
@@ -2591,17 +2599,22 @@ lp_build_sample_soa(struct gallivm_state *gallivm,
}
else {
bld.int_size = LLVMBuildInsertElement(builder, bld.int_size_in_bld.undef,
- tex_width, LLVMConstInt(i32t, 0, 0), "");
+ tex_width,
+ LLVMConstInt(i32t, 0, 0), "");
if (dims >= 2) {
LLVMValueRef tex_height =
- dynamic_state->height(dynamic_state, gallivm, texture_index);
+ dynamic_state->height(dynamic_state, gallivm,
+ context_ptr, texture_index);
bld.int_size = LLVMBuildInsertElement(builder, bld.int_size,
- tex_height, LLVMConstInt(i32t, 1, 0), "");
+ tex_height,
+ LLVMConstInt(i32t, 1, 0), "");
if (dims >= 3) {
LLVMValueRef tex_depth =
- dynamic_state->depth(dynamic_state, gallivm, texture_index);
+ dynamic_state->depth(dynamic_state, gallivm, context_ptr,
+ texture_index);
bld.int_size = LLVMBuildInsertElement(builder, bld.int_size,
- tex_depth, LLVMConstInt(i32t, 2, 0), "");
+ tex_depth,
+ LLVMConstInt(i32t, 2, 0), "");
}
}
}
@@ -2717,6 +2730,7 @@ lp_build_sample_soa(struct gallivm_state *gallivm,
/* Setup our build context */
memset(&bld4, 0, sizeof bld4);
bld4.gallivm = bld.gallivm;
+ bld4.context_ptr = bld.context_ptr;
bld4.static_texture_state = bld.static_texture_state;
bld4.static_sampler_state = bld.static_sampler_state;
bld4.dynamic_state = bld.dynamic_state;
@@ -2876,6 +2890,7 @@ lp_build_sample_soa(struct gallivm_state *gallivm,
}
}
+
void
lp_build_size_query_soa(struct gallivm_state *gallivm,
const struct lp_static_texture_state *static_state,
@@ -2883,6 +2898,7 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
struct lp_type int_type,
unsigned texture_unit,
unsigned target,
+ LLVMValueRef context_ptr,
boolean is_sviewinfo,
enum lp_sampler_lod_property lod_property,
LLVMValueRef explicit_lod,
@@ -2954,8 +2970,10 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
if (explicit_lod) {
/* FIXME: this needs to honor per-element lod */
- lod = LLVMBuildExtractElement(gallivm->builder, explicit_lod, lp_build_const_int32(gallivm, 0), "");
- first_level = dynamic_state->first_level(dynamic_state, gallivm, texture_unit);
+ lod = LLVMBuildExtractElement(gallivm->builder, explicit_lod,
+ lp_build_const_int32(gallivm, 0), "");
+ first_level = dynamic_state->first_level(dynamic_state, gallivm,
+ context_ptr, texture_unit);
level = LLVMBuildAdd(gallivm->builder, lod, first_level, "level");
lod = lp_build_broadcast_scalar(&bld_int_vec4, level);
} else {
@@ -2965,25 +2983,29 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
size = bld_int_vec4.undef;
size = LLVMBuildInsertElement(gallivm->builder, size,
- dynamic_state->width(dynamic_state, gallivm, texture_unit),
+ dynamic_state->width(dynamic_state, gallivm,
+ context_ptr, texture_unit),
lp_build_const_int32(gallivm, 0), "");
if (dims >= 2) {
size = LLVMBuildInsertElement(gallivm->builder, size,
- dynamic_state->height(dynamic_state, gallivm, texture_unit),
+ dynamic_state->height(dynamic_state, gallivm,
+ context_ptr, texture_unit),
lp_build_const_int32(gallivm, 1), "");
}
if (dims >= 3) {
size = LLVMBuildInsertElement(gallivm->builder, size,
- dynamic_state->depth(dynamic_state, gallivm, texture_unit),
+ dynamic_state->depth(dynamic_state, gallivm,
+ context_ptr, texture_unit),
lp_build_const_int32(gallivm, 2), "");
}
size = lp_build_minify(&bld_int_vec4, size, lod, TRUE);
if (has_array) {
- LLVMValueRef layers = dynamic_state->depth(dynamic_state, gallivm, texture_unit);
+ LLVMValueRef layers = dynamic_state->depth(dynamic_state, gallivm,
+ context_ptr, texture_unit);
if (target == PIPE_TEXTURE_CUBE_ARRAY) {
/*
* It looks like GL wants number of cubes, d3d10.1 has it undefined?
@@ -3008,7 +3030,8 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
/* everything is scalar for now */
lp_build_context_init(&leveli_bld, gallivm, lp_type_int_vec(32, 32));
- last_level = dynamic_state->last_level(dynamic_state, gallivm, texture_unit);
+ last_level = dynamic_state->last_level(dynamic_state, gallivm,
+ context_ptr, texture_unit);
out = lp_build_cmp(&leveli_bld, PIPE_FUNC_LESS, level, first_level);
out1 = lp_build_cmp(&leveli_bld, PIPE_FUNC_GREATER, level, last_level);
@@ -3048,7 +3071,8 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
else {
LLVMValueRef last_level;
- last_level = dynamic_state->last_level(dynamic_state, gallivm, texture_unit);
+ last_level = dynamic_state->last_level(dynamic_state, gallivm,
+ context_ptr, texture_unit);
num_levels = lp_build_sub(&bld_int_scalar, last_level, first_level);
num_levels = lp_build_add(&bld_int_scalar, num_levels, bld_int_scalar.one);
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index b411f05674d..8d53607b934 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -188,6 +188,7 @@ struct lp_build_sampler_soa
boolean is_fetch,
unsigned texture_index,
unsigned sampler_index,
+ LLVMValueRef context_ptr,
const LLVMValueRef *coords,
const LLVMValueRef *offsets,
const struct lp_derivatives *derivs,
@@ -202,6 +203,7 @@ struct lp_build_sampler_soa
struct lp_type type,
unsigned unit,
unsigned target,
+ LLVMValueRef context_ptr,
boolean need_nr_mips,
enum lp_sampler_lod_property,
LLVMValueRef explicit_lod, /* optional */
@@ -237,6 +239,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
const struct lp_bld_tgsi_system_values *system_values,
const LLVMValueRef (*inputs)[4],
LLVMValueRef (*outputs)[4],
+ LLVMValueRef context_ptr,
struct lp_build_sampler_soa *sampler,
const struct tgsi_shader_info *info,
const struct lp_build_tgsi_gs_iface *gs_iface);
@@ -449,6 +452,7 @@ struct lp_build_tgsi_soa_context
LLVMValueRef consts_sizes[LP_MAX_TGSI_CONST_BUFFERS];
const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS];
LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS];
+ LLVMValueRef context_ptr;
const struct lp_build_sampler_soa *sampler;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 3b2097f8521..3e82036150b 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -2151,6 +2151,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
bld->bld_base.base.type,
FALSE,
unit, unit,
+ bld->context_ptr,
coords,
offsets,
deriv_ptr,
@@ -2314,6 +2315,7 @@ emit_sample(struct lp_build_tgsi_soa_context *bld,
bld->bld_base.base.type,
FALSE,
texture_unit, sampler_unit,
+ bld->context_ptr,
coords,
offsets,
deriv_ptr,
@@ -2424,6 +2426,7 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld,
bld->bld_base.base.type,
TRUE,
unit, unit,
+ bld->context_ptr,
coords,
offsets,
NULL,
@@ -2498,6 +2501,7 @@ emit_size_query( struct lp_build_tgsi_soa_context *bld,
bld->bld_base.base.gallivm,
bld->bld_base.int_bld.type,
unit, pipe_target,
+ bld->context_ptr,
TRUE,
lod_property,
explicit_lod,
@@ -3656,6 +3660,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
const struct lp_bld_tgsi_system_values *system_values,
const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS],
LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS],
+ LLVMValueRef context_ptr,
struct lp_build_sampler_soa *sampler,
const struct tgsi_shader_info *info,
const struct lp_build_tgsi_gs_iface *gs_iface)
@@ -3684,6 +3689,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
bld.sampler = sampler;
bld.bld_base.info = info;
bld.indirect_files = info->indirect_files;
+ bld.context_ptr = context_ptr;
/*
* If the number of temporaries is rather large then we just
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 14fd6b91063..35fe7b20181 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -417,7 +417,8 @@ generate_fs_loop(struct gallivm_state *gallivm,
lp_build_tgsi_soa(gallivm, tokens, type, &mask,
consts_ptr, num_consts_ptr, &system_values,
interp->inputs,
- outputs, sampler, &shader->info.base, NULL);
+ outputs, context_ptr,
+ sampler, &shader->info.base, NULL);
/* Alpha test */
if (key->alpha.enabled) {
@@ -2302,7 +2303,7 @@ generate_fragment(struct llvmpipe_context *lp,
LLVMPositionBuilderAtEnd(builder, block);
/* code generated texture sampling */
- sampler = lp_llvm_sampler_soa_create(key->state, context_ptr);
+ sampler = lp_llvm_sampler_soa_create(key->state);
num_fs = 16 / fs_type.length; /* number of loops per 4x4 stamp */
/* for 1d resources only run "upper half" of stamp */
diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c
index f0a4a342bc2..1828069bf1a 100644
--- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c
+++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c
@@ -65,8 +65,6 @@ struct llvmpipe_sampler_dynamic_state
struct lp_sampler_dynamic_state base;
const struct lp_sampler_static_state *static_state;
-
- LLVMValueRef context_ptr;
};
@@ -92,13 +90,12 @@ struct lp_llvm_sampler_soa
static LLVMValueRef
lp_llvm_texture_member(const struct lp_sampler_dynamic_state *base,
struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
unsigned texture_unit,
unsigned member_index,
const char *member_name,
boolean emit_load)
{
- struct llvmpipe_sampler_dynamic_state *state =
- (struct llvmpipe_sampler_dynamic_state *)base;
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef indices[4];
LLVMValueRef ptr;
@@ -115,7 +112,7 @@ lp_llvm_texture_member(const struct lp_sampler_dynamic_state *base,
/* context[0].textures[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
- ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), "");
+ ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), "");
if (emit_load)
res = LLVMBuildLoad(builder, ptr, "");
@@ -141,9 +138,11 @@ lp_llvm_texture_member(const struct lp_sampler_dynamic_state *base,
static LLVMValueRef \
lp_llvm_texture_##_name( const struct lp_sampler_dynamic_state *base, \
struct gallivm_state *gallivm, \
+ LLVMValueRef context_ptr, \
unsigned texture_unit) \
{ \
- return lp_llvm_texture_member(base, gallivm, texture_unit, _index, #_name, _emit_load ); \
+ return lp_llvm_texture_member(base, gallivm, context_ptr, \
+ texture_unit, _index, #_name, _emit_load ); \
}
@@ -169,13 +168,12 @@ LP_LLVM_TEXTURE_MEMBER(mip_offsets, LP_JIT_TEXTURE_MIP_OFFSETS, FALSE)
static LLVMValueRef
lp_llvm_sampler_member(const struct lp_sampler_dynamic_state *base,
struct gallivm_state *gallivm,
+ LLVMValueRef context_ptr,
unsigned sampler_unit,
unsigned member_index,
const char *member_name,
boolean emit_load)
{
- struct llvmpipe_sampler_dynamic_state *state =
- (struct llvmpipe_sampler_dynamic_state *)base;
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef indices[4];
LLVMValueRef ptr;
@@ -192,7 +190,7 @@ lp_llvm_sampler_member(const struct lp_sampler_dynamic_state *base,
/* context[0].samplers[unit].member */
indices[3] = lp_build_const_int32(gallivm, member_index);
- ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), "");
+ ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), "");
if (emit_load)
res = LLVMBuildLoad(builder, ptr, "");
@@ -209,9 +207,11 @@ lp_llvm_sampler_member(const struct lp_sampler_dynamic_state *base,
static LLVMValueRef \
lp_llvm_sampler_##_name( const struct lp_sampler_dynamic_state *base, \
struct gallivm_state *gallivm, \
+ LLVMValueRef context_ptr, \
unsigned sampler_unit) \
{ \
- return lp_llvm_sampler_member(base, gallivm, sampler_unit, _index, #_name, _emit_load ); \
+ return lp_llvm_sampler_member(base, gallivm, context_ptr, \
+ sampler_unit, _index, #_name, _emit_load ); \
}
@@ -239,6 +239,7 @@ lp_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base,
boolean is_fetch,
unsigned texture_index,
unsigned sampler_index,
+ LLVMValueRef context_ptr,
const LLVMValueRef *coords,
const LLVMValueRef *offsets,
const struct lp_derivatives *derivs,
@@ -265,6 +266,7 @@ lp_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base,
is_fetch,
texture_index,
sampler_index,
+ context_ptr,
coords,
offsets,
derivs,
@@ -281,6 +283,7 @@ lp_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
struct lp_type type,
unsigned texture_unit,
unsigned target,
+ LLVMValueRef context_ptr,
boolean is_sviewinfo,
enum lp_sampler_lod_property lod_property,
LLVMValueRef explicit_lod, /* optional */
@@ -296,6 +299,7 @@ lp_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
type,
texture_unit,
target,
+ context_ptr,
is_sviewinfo,
lod_property,
explicit_lod,
@@ -304,8 +308,7 @@ lp_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
struct lp_build_sampler_soa *
-lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state,
- LLVMValueRef context_ptr)
+lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state)
{
struct lp_llvm_sampler_soa *sampler;
@@ -331,7 +334,6 @@ lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state,
sampler->dynamic_state.base.border_color = lp_llvm_sampler_border_color;
sampler->dynamic_state.static_state = static_state;
- sampler->dynamic_state.context_ptr = context_ptr;
return &sampler->base;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.h b/src/gallium/drivers/llvmpipe/lp_tex_sample.h
index bca92d974c4..f4aff226ce1 100644
--- a/src/gallium/drivers/llvmpipe/lp_tex_sample.h
+++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.h
@@ -38,11 +38,9 @@ struct lp_sampler_static_state;
/**
* Pure-LLVM texture sampling code generator.
*
- * @param context_ptr LLVM value with the pointer to the struct lp_jit_context.
*/
struct lp_build_sampler_soa *
-lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *key,
- LLVMValueRef context_ptr);
+lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *key);
#endif /* LP_TEX_SAMPLE_H */