Commit 12efb83a authored by Dave Airlie's avatar Dave Airlie
Browse files

gallivm/sample: refactor multisample offset calcs code.



Just consoldiate this

Reviewed-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
Part-of: <mesa/mesa!18264>
parent b4f132b2
......@@ -458,7 +458,6 @@ struct lp_build_sample_context
LLVMTypeRef mip_offsets_type;
LLVMValueRef mip_offsets;
LLVMValueRef cache;
LLVMValueRef sample_stride;
/** Integer vector with texture width, height, depth */
LLVMValueRef int_size;
......
......@@ -2068,6 +2068,26 @@ lp_build_layer_coord(struct lp_build_sample_context *bld,
}
}
static void
lp_build_sample_ms_offset(struct lp_build_context *int_coord_bld,
LLVMValueRef ms_index,
LLVMValueRef num_samples,
LLVMValueRef sample_stride,
LLVMValueRef *offset,
LLVMValueRef *out_of_bounds)
{
LLVMValueRef out1;
num_samples = lp_build_broadcast_scalar(int_coord_bld, num_samples);
sample_stride = lp_build_broadcast_scalar(int_coord_bld, sample_stride);
out1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_LESS, ms_index, int_coord_bld->zero);
*out_of_bounds = lp_build_or(int_coord_bld, *out_of_bounds, out1);
out1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_GEQUAL, ms_index, num_samples);
*out_of_bounds = lp_build_or(int_coord_bld, *out_of_bounds, out1);
LLVMValueRef sample_offset = lp_build_mul(int_coord_bld,
sample_stride, ms_index);
*offset = lp_build_add(int_coord_bld, *offset, sample_offset);
}
#define WEIGHT_LUT_SIZE 1024
static void
......@@ -3216,16 +3236,17 @@ lp_build_fetch_texel(struct lp_build_sample_context *bld,
}
if (bld->fetch_ms) {
LLVMValueRef num_samples;
num_samples = bld->dynamic_state->num_samples(bld->gallivm,
bld->context_type,
bld->context_ptr, texture_unit, NULL);
out1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_LESS, ms_index, int_coord_bld->zero);
out_of_bounds = lp_build_or(int_coord_bld, out_of_bounds, out1);
out1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_GEQUAL, ms_index, lp_build_broadcast_scalar(int_coord_bld, num_samples));
out_of_bounds = lp_build_or(int_coord_bld, out_of_bounds, out1);
offset = lp_build_add(int_coord_bld, offset,
lp_build_mul(int_coord_bld, bld->sample_stride, ms_index));
LLVMValueRef num_samples = bld->dynamic_state->num_samples(bld->gallivm,
bld->context_type,
bld->context_ptr,
texture_unit, NULL);
LLVMValueRef sample_stride = bld->dynamic_state->sample_stride(bld->gallivm,
bld->context_type,
bld->context_ptr,
texture_unit,
NULL);
lp_build_sample_ms_offset(int_coord_bld, ms_index, num_samples, sample_stride,
&offset, &out_of_bounds);
}
offset = lp_build_andnot(int_coord_bld, offset, out_of_bounds);
......@@ -3599,16 +3620,6 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm,
context_ptr, texture_index, NULL,
&bld.mip_offsets_type);
if (fetch_ms) {
bld.sample_stride =
lp_build_broadcast_scalar(&bld.int_coord_bld,
dynamic_state->sample_stride(gallivm,
context_type,
context_ptr,
texture_index,
NULL));
}
/* Note that mip_offsets is an array[level] of offsets to texture images */
if (dynamic_state->cache_ptr && thread_data_ptr) {
......@@ -4854,20 +4865,6 @@ lp_build_img_op_soa(const struct lp_static_texture_state *static_texture_state,
params->context_type,
params->context_ptr,
params->image_index, NULL);
LLVMValueRef num_samples = NULL, sample_stride = NULL;
LLVMValueRef ms_index = params->ms_index;
if (ms_index) {
num_samples = dynamic_state->num_samples(gallivm,
params->context_type,
params->context_ptr,
params->image_index, NULL);
sample_stride = dynamic_state->sample_stride(gallivm,
params->context_type,
params->context_ptr,
params->image_index, NULL);
}
boolean layer_coord = has_layer_coord(target);
width = lp_build_scale_view_dim(gallivm, width, res_format_desc->block.width,
......@@ -4903,18 +4900,19 @@ lp_build_img_op_soa(const struct lp_static_texture_state *static_texture_state,
x, y, z, row_stride_vec, img_stride_vec,
&offset, &i, &j);
if (ms_index) {
out1 = lp_build_cmp(&int_coord_bld, PIPE_FUNC_GEQUAL, ms_index,
lp_build_broadcast_scalar(&int_coord_bld,
num_samples));
out_of_bounds = lp_build_or(&int_coord_bld, out_of_bounds, out1);
offset =
lp_build_add(&int_coord_bld, offset,
lp_build_mul(&int_coord_bld,
lp_build_broadcast_scalar(&int_coord_bld,
sample_stride),
ms_index));
if (params->ms_index) {
LLVMValueRef num_samples = dynamic_state->num_samples(gallivm,
params->context_type,
params->context_ptr,
params->image_index, NULL);
LLVMValueRef sample_stride = dynamic_state->sample_stride(gallivm,
params->context_type,
params->context_ptr,
params->image_index, NULL);
lp_build_sample_ms_offset(&int_coord_bld,
params->ms_index, num_samples,
sample_stride, &offset,
&out_of_bounds);
}
if (params->img_op == LP_IMG_LOAD) {
struct lp_type texel_type = lp_build_texel_type(params->type, format_desc);
......
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