summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/gallivm
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2012-11-12 20:35:04 +0100
committerRoland Scheidegger <[email protected]>2012-11-12 21:02:59 +0100
commit26097c4855b97ee6e362c19df11d51fb7fd42192 (patch)
treedbc5018aa4b3a2c2fb2e1e0464be4776610cc044 /src/gallium/auxiliary/gallivm
parent8257bb963f0b21c0c35da479707b5cacbc1c2824 (diff)
gallivm,draw,llvmpipe: use base ptr + mip offsets instead of mip pointers
This might have a slight overhead but handling mip offsets more like the width (and image) strides should make some things easier (mip level being just part of the offset calculation) later. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/gallivm')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.c7
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.h13
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c8
3 files changed, 19 insertions, 9 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
index 63cf610ecad..0727fd2b91a 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
@@ -733,12 +733,13 @@ lp_build_get_mipmap_level(struct lp_build_sample_context *bld,
LLVMValueRef level)
{
LLVMBuilderRef builder = bld->gallivm->builder;
- LLVMValueRef indexes[2], data_ptr;
+ LLVMValueRef indexes[2], data_ptr, mip_offset;
indexes[0] = lp_build_const_int32(bld->gallivm, 0);
indexes[1] = level;
- data_ptr = LLVMBuildGEP(builder, bld->data_array, indexes, 2, "");
- data_ptr = LLVMBuildLoad(builder, data_ptr, "");
+ mip_offset = LLVMBuildGEP(builder, bld->mip_offsets, indexes, 2, "");
+ mip_offset = LLVMBuildLoad(builder, mip_offset, "");
+ data_ptr = LLVMBuildGEP(builder, bld->base_ptr, &mip_offset, 1, "");
return data_ptr;
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
index 0f3d8ae6cb5..d8a068d5497 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
@@ -157,12 +157,18 @@ struct lp_sampler_dynamic_state
struct gallivm_state *gallivm,
unsigned unit);
- /** Obtain pointer to array of pointers to mimpap levels */
+ /** Obtain pointer to base of texture */
LLVMValueRef
- (*data_ptr)( const struct lp_sampler_dynamic_state *state,
+ (*base_ptr)( const struct lp_sampler_dynamic_state *state,
struct gallivm_state *gallivm,
unsigned unit);
+ /** Obtain pointer to array of mipmap offsets */
+ LLVMValueRef
+ (*mip_offsets)( const struct lp_sampler_dynamic_state *state,
+ struct gallivm_state *gallivm,
+ unsigned unit);
+
/** Obtain texture min lod (returns float) */
LLVMValueRef
(*min_lod)(const struct lp_sampler_dynamic_state *state,
@@ -246,7 +252,8 @@ struct lp_build_sample_context
/* Common dynamic state values */
LLVMValueRef row_stride_array;
LLVMValueRef img_stride_array;
- LLVMValueRef data_array;
+ LLVMValueRef base_ptr;
+ LLVMValueRef mip_offsets;
/** Integer vector with texture width, height, depth */
LLVMValueRef int_size;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index aaef7970635..00a5b187bcb 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -1298,8 +1298,9 @@ lp_build_sample_soa(struct gallivm_state *gallivm,
tex_depth = dynamic_state->depth(dynamic_state, gallivm, unit);
bld.row_stride_array = dynamic_state->row_stride(dynamic_state, gallivm, unit);
bld.img_stride_array = dynamic_state->img_stride(dynamic_state, gallivm, unit);
- bld.data_array = dynamic_state->data_ptr(dynamic_state, gallivm, unit);
- /* Note that data_array is an array[level] of pointers to texture images */
+ bld.base_ptr = dynamic_state->base_ptr(dynamic_state, gallivm, unit);
+ bld.mip_offsets = dynamic_state->mip_offsets(dynamic_state, gallivm, unit);
+ /* Note that mip_offsets is an array[level] of offsets to texture images */
s = coords[0];
t = coords[1];
@@ -1439,7 +1440,8 @@ lp_build_sample_soa(struct gallivm_state *gallivm,
bld4.dims = bld.dims;
bld4.row_stride_array = bld.row_stride_array;
bld4.img_stride_array = bld.img_stride_array;
- bld4.data_array = bld.data_array;
+ bld4.base_ptr = bld.base_ptr;
+ bld4.mip_offsets = bld.mip_offsets;
bld4.int_size = bld.int_size;
bld4.vector_width = lp_type_width(type4);