From a30db60edeb7814415b04537cee8cc306ad11fd7 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 8 Apr 2020 09:49:47 +1000 Subject: [PATCH] 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 Part-of: --- src/gallium/drivers/llvmpipe/lp_jit.h | 4 +++- src/gallium/drivers/llvmpipe/lp_rast.c | 16 ++++++++++++++-- src/gallium/drivers/llvmpipe/lp_rast_priv.h | 8 +++++++- src/gallium/drivers/llvmpipe/lp_state_fs.c | 10 +++++++++- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index fbf33116e1c..61f4b9b650b 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -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 diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index f9b368597d0..5309f306109 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -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(); } } diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h index 4b5ca81926a..95454782977 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h +++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h @@ -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(); } } diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 425bb87df27..6c34ab98453 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -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 -- 2.30.2