summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
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
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')
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c8
-rw-r--r--src/gallium/auxiliary/draw/draw_context.h3
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.c19
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.h9
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm_sample.c6
-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
8 files changed, 48 insertions, 25 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 91dd2e1a20a..6980631b365 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -802,17 +802,19 @@ draw_set_mapped_texture(struct draw_context *draw,
unsigned sampler_idx,
uint32_t width, uint32_t height, uint32_t depth,
uint32_t first_level, uint32_t last_level,
+ const void *base_ptr,
uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
- const void *data[PIPE_MAX_TEXTURE_LEVELS])
+ uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS])
{
if (shader_stage == PIPE_SHADER_VERTEX) {
#ifdef HAVE_LLVM
if (draw->llvm)
draw_llvm_set_mapped_texture(draw,
sampler_idx,
- width, height, depth, first_level, last_level,
- row_stride, img_stride, data);
+ width, height, depth, first_level,
+ last_level, base_ptr,
+ row_stride, img_stride, mip_offsets);
#endif
}
}
diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h
index 30633233fb0..a4937b6165f 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -154,9 +154,10 @@ draw_set_mapped_texture(struct draw_context *draw,
unsigned sampler_idx,
uint32_t width, uint32_t height, uint32_t depth,
uint32_t first_level, uint32_t last_level,
+ const void *base,
uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
- const void *data[PIPE_MAX_TEXTURE_LEVELS]);
+ uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS]);
/*
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index ebfe437261c..6f0e1de7481 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -79,12 +79,12 @@ create_jit_texture_type(struct gallivm_state *gallivm, const char *struct_name)
elem_types[DRAW_JIT_TEXTURE_DEPTH] =
elem_types[DRAW_JIT_TEXTURE_FIRST_LEVEL] =
elem_types[DRAW_JIT_TEXTURE_LAST_LEVEL] = int32_type;
+ elem_types[DRAW_JIT_TEXTURE_BASE] =
+ LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0);
elem_types[DRAW_JIT_TEXTURE_ROW_STRIDE] =
elem_types[DRAW_JIT_TEXTURE_IMG_STRIDE] =
+ elem_types[DRAW_JIT_TEXTURE_MIP_OFFSETS] =
LLVMArrayType(int32_type, PIPE_MAX_TEXTURE_LEVELS);
- elem_types[DRAW_JIT_TEXTURE_DATA] =
- LLVMArrayType(LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0),
- PIPE_MAX_TEXTURE_LEVELS);
elem_types[DRAW_JIT_TEXTURE_MIN_LOD] =
elem_types[DRAW_JIT_TEXTURE_MAX_LOD] =
elem_types[DRAW_JIT_TEXTURE_LOD_BIAS] = LLVMFloatTypeInContext(gallivm->context);
@@ -118,15 +118,18 @@ create_jit_texture_type(struct gallivm_state *gallivm, const char *struct_name)
LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, last_level,
target, texture_type,
DRAW_JIT_TEXTURE_LAST_LEVEL);
+ LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, base,
+ target, texture_type,
+ DRAW_JIT_TEXTURE_BASE);
LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, row_stride,
target, texture_type,
DRAW_JIT_TEXTURE_ROW_STRIDE);
LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, img_stride,
target, texture_type,
DRAW_JIT_TEXTURE_IMG_STRIDE);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, data,
+ LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, mip_offsets,
target, texture_type,
- DRAW_JIT_TEXTURE_DATA);
+ DRAW_JIT_TEXTURE_MIP_OFFSETS);
LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, min_lod,
target, texture_type,
DRAW_JIT_TEXTURE_MIN_LOD);
@@ -1364,9 +1367,10 @@ draw_llvm_set_mapped_texture(struct draw_context *draw,
unsigned sampler_idx,
uint32_t width, uint32_t height, uint32_t depth,
uint32_t first_level, uint32_t last_level,
+ const void *base_ptr,
uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
- const void *data[PIPE_MAX_TEXTURE_LEVELS])
+ uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS])
{
unsigned j;
struct draw_jit_texture *jit_tex;
@@ -1380,9 +1384,10 @@ draw_llvm_set_mapped_texture(struct draw_context *draw,
jit_tex->depth = depth;
jit_tex->first_level = first_level;
jit_tex->last_level = last_level;
+ jit_tex->base = base_ptr;
for (j = first_level; j <= last_level; j++) {
- jit_tex->data[j] = data[j];
+ jit_tex->mip_offsets[j] = mip_offsets[j];
jit_tex->row_stride[j] = row_stride[j];
jit_tex->img_stride[j] = img_stride[j];
}
diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h
index 9a291a47627..d7a630eb015 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.h
+++ b/src/gallium/auxiliary/draw/draw_llvm.h
@@ -47,9 +47,10 @@ struct draw_jit_texture
uint32_t depth;
uint32_t first_level;
uint32_t last_level;
+ const void *base;
uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS];
uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS];
- const void *data[PIPE_MAX_TEXTURE_LEVELS];
+ uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS];
float min_lod;
float max_lod;
float lod_bias;
@@ -62,9 +63,10 @@ enum {
DRAW_JIT_TEXTURE_DEPTH,
DRAW_JIT_TEXTURE_FIRST_LEVEL,
DRAW_JIT_TEXTURE_LAST_LEVEL,
+ DRAW_JIT_TEXTURE_BASE,
DRAW_JIT_TEXTURE_ROW_STRIDE,
DRAW_JIT_TEXTURE_IMG_STRIDE,
- DRAW_JIT_TEXTURE_DATA,
+ DRAW_JIT_TEXTURE_MIP_OFFSETS,
DRAW_JIT_TEXTURE_MIN_LOD,
DRAW_JIT_TEXTURE_MAX_LOD,
DRAW_JIT_TEXTURE_LOD_BIAS,
@@ -293,8 +295,9 @@ draw_llvm_set_mapped_texture(struct draw_context *draw,
unsigned sampler_idx,
uint32_t width, uint32_t height, uint32_t depth,
uint32_t first_level, uint32_t last_level,
+ const void *base_ptr,
uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
- const void *data[PIPE_MAX_TEXTURE_LEVELS]);
+ uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS]);
#endif
diff --git a/src/gallium/auxiliary/draw/draw_llvm_sample.c b/src/gallium/auxiliary/draw/draw_llvm_sample.c
index 53317165557..0892d16bd6d 100644
--- a/src/gallium/auxiliary/draw/draw_llvm_sample.c
+++ b/src/gallium/auxiliary/draw/draw_llvm_sample.c
@@ -146,9 +146,10 @@ DRAW_LLVM_TEXTURE_MEMBER(height, DRAW_JIT_TEXTURE_HEIGHT, TRUE)
DRAW_LLVM_TEXTURE_MEMBER(depth, DRAW_JIT_TEXTURE_DEPTH, TRUE)
DRAW_LLVM_TEXTURE_MEMBER(first_level,DRAW_JIT_TEXTURE_FIRST_LEVEL, TRUE)
DRAW_LLVM_TEXTURE_MEMBER(last_level, DRAW_JIT_TEXTURE_LAST_LEVEL, TRUE)
+DRAW_LLVM_TEXTURE_MEMBER(base_ptr, DRAW_JIT_TEXTURE_BASE, TRUE)
DRAW_LLVM_TEXTURE_MEMBER(row_stride, DRAW_JIT_TEXTURE_ROW_STRIDE, FALSE)
DRAW_LLVM_TEXTURE_MEMBER(img_stride, DRAW_JIT_TEXTURE_IMG_STRIDE, FALSE)
-DRAW_LLVM_TEXTURE_MEMBER(data_ptr, DRAW_JIT_TEXTURE_DATA, FALSE)
+DRAW_LLVM_TEXTURE_MEMBER(mip_offsets, DRAW_JIT_TEXTURE_MIP_OFFSETS, FALSE)
DRAW_LLVM_TEXTURE_MEMBER(min_lod, DRAW_JIT_TEXTURE_MIN_LOD, TRUE)
DRAW_LLVM_TEXTURE_MEMBER(max_lod, DRAW_JIT_TEXTURE_MAX_LOD, TRUE)
DRAW_LLVM_TEXTURE_MEMBER(lod_bias, DRAW_JIT_TEXTURE_LOD_BIAS, TRUE)
@@ -238,7 +239,8 @@ draw_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state,
sampler->dynamic_state.base.last_level = draw_llvm_texture_last_level;
sampler->dynamic_state.base.row_stride = draw_llvm_texture_row_stride;
sampler->dynamic_state.base.img_stride = draw_llvm_texture_img_stride;
- sampler->dynamic_state.base.data_ptr = draw_llvm_texture_data_ptr;
+ sampler->dynamic_state.base.base_ptr = draw_llvm_texture_base_ptr;
+ sampler->dynamic_state.base.mip_offsets = draw_llvm_texture_mip_offsets;
sampler->dynamic_state.base.min_lod = draw_llvm_texture_min_lod;
sampler->dynamic_state.base.max_lod = draw_llvm_texture_max_lod;
sampler->dynamic_state.base.lod_bias = draw_llvm_texture_lod_bias;
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);