llvmpipe: pass color and depth sample strides into fragment shader.

This just adds the interface and passes the depth and sample strides
into the fragment shader, nothing uses them yet.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>
This commit is contained in:
Dave Airlie 2020-04-08 09:49:47 +10:00 committed by Marge Bot
parent 24cf7a2b36
commit a30db60ede
4 changed files with 33 additions and 5 deletions

View file

@ -304,7 +304,9 @@ typedef void
uint32_t mask,
struct lp_jit_thread_data *thread_data,
unsigned *stride,
unsigned depth_stride);
unsigned depth_stride,
unsigned *color_sample_stride,
unsigned depth_sample_stride);
struct lp_jit_cs_thread_data

View file

@ -327,19 +327,23 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
for (x = 0; x < task->width; x += 4) {
uint8_t *color[PIPE_MAX_COLOR_BUFS];
unsigned stride[PIPE_MAX_COLOR_BUFS];
unsigned sample_stride[PIPE_MAX_COLOR_BUFS];
uint8_t *depth = NULL;
unsigned depth_stride = 0;
unsigned depth_sample_stride = 0;
unsigned i;
/* color buffer */
for (i = 0; i < scene->fb.nr_cbufs; i++){
if (scene->fb.cbufs[i]) {
stride[i] = scene->cbufs[i].stride;
sample_stride[i] = 0;
color[i] = lp_rast_get_color_block_pointer(task, i, tile_x + x,
tile_y + y, inputs->layer);
}
else {
stride[i] = 0;
sample_stride[i] = 0;
color[i] = NULL;
}
}
@ -367,7 +371,9 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
0xffff,
&task->thread_data,
stride,
depth_stride);
depth_stride,
sample_stride,
depth_sample_stride);
END_JIT_CALL();
}
}
@ -411,8 +417,10 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
const struct lp_scene *scene = task->scene;
uint8_t *color[PIPE_MAX_COLOR_BUFS];
unsigned stride[PIPE_MAX_COLOR_BUFS];
unsigned sample_stride[PIPE_MAX_COLOR_BUFS];
uint8_t *depth = NULL;
unsigned depth_stride = 0;
unsigned depth_sample_stride = 0;
unsigned i;
assert(state);
@ -430,11 +438,13 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
for (i = 0; i < scene->fb.nr_cbufs; i++) {
if (scene->fb.cbufs[i]) {
stride[i] = scene->cbufs[i].stride;
sample_stride[i] = 0;
color[i] = lp_rast_get_color_block_pointer(task, i, x, y,
inputs->layer);
}
else {
stride[i] = 0;
sample_stride[i] = 0;
color[i] = NULL;
}
}
@ -468,7 +478,9 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
mask,
&task->thread_data,
stride,
depth_stride);
depth_stride,
sample_stride,
depth_sample_stride);
END_JIT_CALL();
}
}

View file

@ -230,19 +230,23 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
struct lp_fragment_shader_variant *variant = state->variant;
uint8_t *color[PIPE_MAX_COLOR_BUFS];
unsigned stride[PIPE_MAX_COLOR_BUFS];
unsigned sample_stride[PIPE_MAX_COLOR_BUFS];
uint8_t *depth = NULL;
unsigned depth_stride = 0;
unsigned depth_sample_stride = 0;
unsigned i;
/* color buffer */
for (i = 0; i < scene->fb.nr_cbufs; i++) {
if (scene->fb.cbufs[i]) {
stride[i] = scene->cbufs[i].stride;
sample_stride[i] = 0;
color[i] = lp_rast_get_color_block_pointer(task, i, x, y,
inputs->layer);
}
else {
stride[i] = 0;
sample_stride[i] = 0;
color[i] = NULL;
}
}
@ -273,7 +277,9 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
0xffff,
&task->thread_data,
stride,
depth_stride);
depth_stride,
sample_stride,
depth_sample_stride);
END_JIT_CALL();
}
}

View file

@ -2447,7 +2447,7 @@ generate_fragment(struct llvmpipe_context *lp,
struct lp_type blend_type;
LLVMTypeRef fs_elem_type;
LLVMTypeRef blend_vec_type;
LLVMTypeRef arg_types[13];
LLVMTypeRef arg_types[15];
LLVMTypeRef func_type;
LLVMTypeRef int32_type = LLVMInt32TypeInContext(gallivm->context);
LLVMTypeRef int8_type = LLVMInt8TypeInContext(gallivm->context);
@ -2459,8 +2459,10 @@ generate_fragment(struct llvmpipe_context *lp,
LLVMValueRef dady_ptr;
LLVMValueRef color_ptr_ptr;
LLVMValueRef stride_ptr;
LLVMValueRef color_sample_stride_ptr;
LLVMValueRef depth_ptr;
LLVMValueRef depth_stride;
LLVMValueRef depth_sample_stride;
LLVMValueRef mask_input;
LLVMValueRef thread_data_ptr;
LLVMBasicBlockRef block;
@ -2540,6 +2542,8 @@ generate_fragment(struct llvmpipe_context *lp,
arg_types[10] = variant->jit_thread_data_ptr_type; /* per thread data */
arg_types[11] = LLVMPointerType(int32_type, 0); /* stride */
arg_types[12] = int32_type; /* depth_stride */
arg_types[13] = LLVMPointerType(int32_type, 0); /* color sample strides */
arg_types[14] = int32_type; /* depth sample stride */
func_type = LLVMFunctionType(LLVMVoidTypeInContext(gallivm->context),
arg_types, ARRAY_SIZE(arg_types), 0);
@ -2569,6 +2573,8 @@ generate_fragment(struct llvmpipe_context *lp,
thread_data_ptr = LLVMGetParam(function, 10);
stride_ptr = LLVMGetParam(function, 11);
depth_stride = LLVMGetParam(function, 12);
color_sample_stride_ptr = LLVMGetParam(function, 13);
depth_sample_stride = LLVMGetParam(function, 14);
lp_build_name(context_ptr, "context");
lp_build_name(x, "x");
@ -2582,6 +2588,8 @@ generate_fragment(struct llvmpipe_context *lp,
lp_build_name(thread_data_ptr, "thread_data");
lp_build_name(stride_ptr, "stride_ptr");
lp_build_name(depth_stride, "depth_stride");
lp_build_name(color_sample_stride_ptr, "color_sample_stride_ptr");
lp_build_name(depth_sample_stride, "depth_sample_stride");
/*
* Function body