summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
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/drivers
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/drivers')
-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
3 files changed, 19 insertions, 18 deletions
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 */