Commit 57c1e1ef authored by Dave Airlie's avatar Dave Airlie
Browse files

llvmtexture: code cleanups after rebase

parent 1def348f
Pipeline #719412 waiting for manual action with stages
......@@ -7,6 +7,7 @@
#include "gallivm/lp_bld_bitarit.h"
#include "gallivm/lp_bld_flow.h"
#include "gallivm/lp_bld_printf.h"
#include "gallivm/lp_bld_sample.h"
#include "lp_tex_sample.h"
#include "lp_tex_engine.h"
/*
......@@ -297,16 +298,20 @@ lp_tex_engine_func(struct gallivm_state *gallivm,
view_type,
view_ptr,
indices, 2, "");
bld.row_stride_type = LLVMArrayType(LLVMInt32TypeInContext(gallivm->context), PIPE_MAX_TEXTURE_LEVELS);
indices[1] = lp_build_const_int32(gallivm, LP_TE_VIEW_IMG_STRIDE);
bld.img_stride_array = LLVMBuildGEP2(gallivm->builder,
view_type,
view_ptr,
indices, 2, "");
bld.img_stride_type = LLVMArrayType(LLVMInt32TypeInContext(gallivm->context), PIPE_MAX_TEXTURE_LEVELS);
indices[1] = lp_build_const_int32(gallivm, LP_TE_VIEW_MIP_OFFSETS);
bld.mip_offsets = LLVMBuildGEP2(gallivm->builder,
view_type,
view_ptr,
indices, 2, "");
bld.mip_offsets_type = LLVMArrayType(LLVMInt32TypeInContext(gallivm->context), PIPE_MAX_TEXTURE_LEVELS);
LLVMValueRef out_lod_positive, out_lod_ipart, out_lod_fpart;
LLVMValueRef ilevel0, ilevel1;
......@@ -392,66 +397,66 @@ lp_texture_engine_sample_soa(const struct lp_static_texture_state *static_textur
lp_build_const_int32(gallivm, static_texture_state->target),
LP_TE_VIEW_TARGET, "");
view = LLVMBuildInsertValue(gallivm->builder, view,
dynamic_state->width(gallivm,
dynamic_state->width(gallivm, params->resources_type,
params->resources_ptr, params->texture_index, NULL),
LP_TE_VIEW_WIDTH, "");
view = LLVMBuildInsertValue(gallivm->builder, view,
dynamic_state->height(gallivm,
dynamic_state->height(gallivm, params->resources_type,
params->resources_ptr, params->texture_index, NULL),
LP_TE_VIEW_HEIGHT, "");
view = LLVMBuildInsertValue(gallivm->builder, view,
dynamic_state->depth(gallivm,
dynamic_state->depth(gallivm, params->resources_type,
params->resources_ptr, params->texture_index, NULL),
LP_TE_VIEW_DEPTH, "");
view = LLVMBuildInsertValue(gallivm->builder, view,
dynamic_state->first_level(gallivm,
dynamic_state->first_level(gallivm, params->resources_type,
params->resources_ptr, params->texture_index, NULL),
LP_TE_VIEW_FIRST_LEVEL, "");
view = LLVMBuildInsertValue(gallivm->builder, view,
dynamic_state->last_level(gallivm,
dynamic_state->last_level(gallivm, params->resources_type,
params->resources_ptr, params->texture_index, NULL),
LP_TE_VIEW_LAST_LEVEL, "");
view = LLVMBuildInsertValue(gallivm->builder, view,
dynamic_state->num_samples(gallivm,
dynamic_state->num_samples(gallivm, params->resources_type,
params->resources_ptr, params->texture_index, NULL),
LP_TE_VIEW_NUM_SAMPLES, "");
view = LLVMBuildInsertValue(gallivm->builder, view,
dynamic_state->sample_stride(gallivm,
dynamic_state->sample_stride(gallivm, params->resources_type,
params->resources_ptr, params->texture_index, NULL),
LP_TE_VIEW_SAMPLE_STRIDE, "");
view = LLVMBuildInsertValue(gallivm->builder, view,
LLVMBuildLoad2(gallivm->builder,
LLVMArrayType(LLVMInt32TypeInContext(gallivm->context),
PIPE_MAX_TEXTURE_LEVELS),
dynamic_state->row_stride(gallivm,
dynamic_state->row_stride(gallivm, params->resources_type,
params->resources_ptr,
params->texture_index,
NULL), ""),
NULL, NULL), ""),
LP_TE_VIEW_ROW_STRIDE, "");
view = LLVMBuildInsertValue(gallivm->builder, view,
LLVMBuildLoad2(gallivm->builder,
LLVMArrayType(LLVMInt32TypeInContext(gallivm->context),
PIPE_MAX_TEXTURE_LEVELS),
dynamic_state->img_stride(gallivm,
dynamic_state->img_stride(gallivm, params->resources_type,
params->resources_ptr,
params->texture_index,
NULL), ""),
NULL, NULL), ""),
LP_TE_VIEW_IMG_STRIDE, "");
view = LLVMBuildInsertValue(gallivm->builder, view,
LLVMBuildLoad2(gallivm->builder,
LLVMArrayType(LLVMInt32TypeInContext(gallivm->context),
PIPE_MAX_TEXTURE_LEVELS),
dynamic_state->mip_offsets(gallivm,
dynamic_state->mip_offsets(gallivm, params->resources_type,
params->resources_ptr,
params->texture_index,
NULL), ""),
NULL, NULL), ""),
LP_TE_VIEW_MIP_OFFSETS, "");
view = LLVMBuildInsertValue(gallivm->builder, view,
dynamic_state->base_ptr(gallivm,
dynamic_state->base_ptr(gallivm, params->resources_type,
params->resources_ptr, params->texture_index, NULL),
LP_TE_VIEW_BASE_PTR, "");
view = LLVMBuildInsertValue(gallivm->builder, view,
dynamic_state->format_fn_ptr(gallivm,
dynamic_state->format_fn_ptr(gallivm, params->resources_type,
params->resources_ptr, params->texture_index, NULL),
LP_TE_VIEW_FORMAT_FN_PTR, "");
LLVMBuildStore(gallivm->builder, view, view_ptr);
......@@ -501,21 +506,21 @@ lp_texture_engine_sample_soa(const struct lp_static_texture_state *static_textur
lp_build_const_int32(gallivm, static_sampler_state->reduction_mode),
LP_TE_SAMPLER_REDUCTION_MODE, "");
sampler = LLVMBuildInsertValue(gallivm->builder, sampler,
dynamic_state->min_lod(gallivm,
dynamic_state->min_lod(gallivm, params->resources_type,
params->resources_ptr, params->sampler_index),
LP_TE_SAMPLER_MIN_LOD, "");
sampler = LLVMBuildInsertValue(gallivm->builder, sampler,
dynamic_state->max_lod(gallivm,
dynamic_state->max_lod(gallivm, params->resources_type,
params->resources_ptr, params->sampler_index),
LP_TE_SAMPLER_MAX_LOD, "");
sampler = LLVMBuildInsertValue(gallivm->builder, sampler,
dynamic_state->lod_bias(gallivm,
dynamic_state->lod_bias(gallivm, params->resources_type,
params->resources_ptr, params->sampler_index),
LP_TE_SAMPLER_LOD_BIAS, "");
sampler = LLVMBuildInsertValue(gallivm->builder, sampler,
LLVMBuildLoad2(gallivm->builder,
LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4),
dynamic_state->border_color(gallivm,
dynamic_state->border_color(gallivm, params->resources_type,
params->resources_ptr, params->sampler_index), ""),
LP_TE_SAMPLER_BORDER_COLOR, "");
LLVMBuildStore(gallivm->builder, sampler, sampler_ptr);
......
......@@ -79,6 +79,10 @@ struct lp_texture_engine_context {
void *
lp_texture_engine_create(LLVMContextRef context);
struct lp_sampler_dynamic_state;
struct lp_static_texture_state;
struct lp_static_sampler_state;
/* API to map over to the engine calls */
void
lp_texture_engine_sample_soa(const struct lp_static_texture_state *static_texture_state,
......
......@@ -62,7 +62,7 @@
#include "lp_bld_intr.h"
#include "lp_bld_misc.h"
#include "lp_bld_sample.h"
#include "lp_tex_sample.h"
#include "lp_tex_sample_aos.h"
#include "lp_tex_engine.h"
......@@ -856,40 +856,6 @@ lp_texture_engine_sample_comparefunc(struct lp_texture_engine_context *bld,
return NULL;
}
/**
* Do shadow test/comparison.
* \param p shadow ref value
* \param texel the texel to compare against
*/
static LLVMValueRef
lp_build_sample_comparefunc(struct lp_build_sample_context *bld,
LLVMValueRef p,
LLVMValueRef texel)
{
struct lp_build_context *texel_bld = &bld->texel_bld;
LLVMValueRef res;
if (0) {
//lp_build_print_value(bld->gallivm, "shadow cmp coord", p);
lp_build_print_value(bld->gallivm, "shadow cmp texel", texel);
}
/* result = (p FUNC texel) ? 1 : 0 */
/*
* honor d3d10 floating point rules here, which state that comparisons
* are ordered except NOT_EQUAL which is unordered.
*/
if (bld->static_sampler_state->compare_func != PIPE_FUNC_NOTEQUAL) {
res = lp_build_cmp_ordered(texel_bld, bld->static_sampler_state->compare_func,
p, texel);
}
else {
res = lp_build_cmp(texel_bld, bld->static_sampler_state->compare_func,
p, texel);
}
return res;
}
static void
lp_texture_engine_sample_image_nearest(struct lp_texture_engine_context *bld,
LLVMValueRef size,
......@@ -2158,28 +2124,3 @@ lp_texture_texel_type(struct lp_type texel_type,
return texel_type;
}
#define USE_TEX_FUNC_CALL 1
#define LP_MAX_TEX_FUNC_ARGS 32
static inline void
get_target_info(enum pipe_texture_target target,
unsigned *num_coords, unsigned *num_derivs,
unsigned *num_offsets, unsigned *layer)
{
unsigned dims = texture_dims(target);
*num_coords = dims;
*num_offsets = dims;
*num_derivs = (target == PIPE_TEXTURE_CUBE ||
target == PIPE_TEXTURE_CUBE_ARRAY) ? 3 : dims;
*layer = has_layer_coord(target) ? 2: 0;
if (target == PIPE_TEXTURE_CUBE_ARRAY) {
/*
* dims doesn't include r coord for cubes - this is handled
* by layer instead, but need to fix up for cube arrays...
*/
*layer = 3;
*num_coords = 3;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment