summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/draw
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2015-03-25 03:10:10 +0100
committerRoland Scheidegger <[email protected]>2015-03-27 19:25:53 +0100
commit8dad9455ff748c543635b24908566c3b94cb93a9 (patch)
treefadf8b3b7e08a30fe37e53b4c4ea226db29ad55d /src/gallium/auxiliary/draw
parent787aa26cb7b48504f7770cacfc321324ecafa29a (diff)
gallivm: pass jit_context pointer through to sampling
The callbacks used for getting the dynamic texture/sampler state were using the jit_context from the generated jit function. This works just fine, however that way it's impossible to generate separate functions for texture sampling, as will be done in the next commit. Hence, pass this pointer through all interfaces so it can be passed to a separate function (technically, it would probably be possible to extract this pointer from the current function instead, but this feels hacky and would probably require some more hacks if we'd use real functions instead of inlining all shader functions at some point). There should be no difference in the generated code for now. Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/draw')
-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
3 files changed, 20 insertions, 20 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;
}