From: Dave Airlie Date: Mon, 23 Mar 2020 05:11:37 +0000 (+1000) Subject: llvmpipe: add samples support to image jit X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=19703900260d51b709111206caebbad3a9578f7b;p=mesa.git llvmpipe: add samples support to image jit Reviewed-by: Roland Scheidegger Part-of: --- diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 39910c66837..4ec83480c05 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -146,7 +146,9 @@ create_jit_image_type(struct gallivm_state *gallivm) elem_types[LP_JIT_IMAGE_DEPTH] = LLVMInt32TypeInContext(lc); elem_types[LP_JIT_IMAGE_BASE] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0); elem_types[LP_JIT_IMAGE_ROW_STRIDE] = - elem_types[LP_JIT_IMAGE_IMG_STRIDE] = LLVMInt32TypeInContext(lc); + elem_types[LP_JIT_IMAGE_IMG_STRIDE] = + elem_types[LP_JIT_IMAGE_NUM_SAMPLES] = + elem_types[LP_JIT_IMAGE_SAMPLE_STRIDE] = LLVMInt32TypeInContext(lc); image_type = LLVMStructTypeInContext(lc, elem_types, ARRAY_SIZE(elem_types), 0); @@ -168,6 +170,12 @@ create_jit_image_type(struct gallivm_state *gallivm) LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, img_stride, gallivm->target, image_type, LP_JIT_IMAGE_IMG_STRIDE); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, num_samples, + gallivm->target, image_type, + LP_JIT_IMAGE_NUM_SAMPLES); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, sample_stride, + gallivm->target, image_type, + LP_JIT_IMAGE_SAMPLE_STRIDE); return image_type; } diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index b89f25b8dba..d7960e21d30 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -89,6 +89,8 @@ struct lp_jit_image const void *base; uint32_t row_stride; uint32_t img_stride; + uint32_t num_samples; + uint32_t sample_stride; }; enum { @@ -129,6 +131,8 @@ enum { LP_JIT_IMAGE_BASE, LP_JIT_IMAGE_ROW_STRIDE, LP_JIT_IMAGE_IMG_STRIDE, + LP_JIT_IMAGE_NUM_SAMPLES, + LP_JIT_IMAGE_SAMPLE_STRIDE, LP_JIT_IMAGE_NUM_FIELDS /* number of fields above */ }; /** diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index e67392059a3..a52f6bbb9c5 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -700,6 +700,7 @@ lp_setup_set_fs_images(struct lp_setup_context *setup, jit_image->width = res->width0; jit_image->height = res->height0; jit_image->depth = res->depth0; + jit_image->num_samples = res->nr_samples; if (llvmpipe_resource_is_texture(res)) { uint32_t mip_offset = lp_res->mip_offsets[image->u.tex.level]; @@ -725,6 +726,7 @@ lp_setup_set_fs_images(struct lp_setup_context *setup, jit_image->row_stride = lp_res->row_stride[image->u.tex.level]; jit_image->img_stride = lp_res->img_stride[image->u.tex.level]; + jit_image->sample_stride = 0; jit_image->base = (uint8_t *)jit_image->base + mip_offset; } else { diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c index da5eed7abd3..1d33d5314d6 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_cs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c @@ -1050,6 +1050,7 @@ lp_csctx_set_cs_images(struct lp_cs_context *csctx, jit_image->width = res->width0; jit_image->height = res->height0; jit_image->depth = res->depth0; + jit_image->num_samples = res->nr_samples; if (llvmpipe_resource_is_texture(res)) { uint32_t mip_offset = lp_res->mip_offsets[image->u.tex.level]; @@ -1075,6 +1076,7 @@ lp_csctx_set_cs_images(struct lp_cs_context *csctx, jit_image->row_stride = lp_res->row_stride[image->u.tex.level]; jit_image->img_stride = lp_res->img_stride[image->u.tex.level]; + jit_image->sample_stride = 0; jit_image->base = (uint8_t *)jit_image->base + mip_offset; } else { unsigned view_blocksize = util_format_get_blocksize(image->format); diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c index 723e472720e..9ddfc37864f 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c +++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c @@ -402,6 +402,7 @@ prepare_shader_images( unsigned i; uint32_t row_stride; uint32_t img_stride; + uint32_t sample_stride; const void *addr; assert(num <= PIPE_MAX_SHADER_SAMPLER_VIEWS); @@ -420,6 +421,7 @@ prepare_shader_images( unsigned width = u_minify(img->width0, view->u.tex.level); unsigned height = u_minify(img->height0, view->u.tex.level); unsigned num_layers = img->depth0; + unsigned num_samples = img->nr_samples; if (!lp_img->dt) { /* regular texture - setup array of mipmap level offsets */ @@ -441,6 +443,7 @@ prepare_shader_images( row_stride = lp_img->row_stride[view->u.tex.level]; img_stride = lp_img->img_stride[view->u.tex.level]; + sample_stride = 0; addr = (uint8_t *)addr + mip_offset; } else { @@ -449,6 +452,7 @@ prepare_shader_images( /* probably don't really need to fill that out */ row_stride = 0; img_stride = 0; + sample_stride = 0; /* everything specified in number of elements here. */ width = view->u.buf.size / view_blocksize; @@ -467,6 +471,7 @@ prepare_shader_images( PIPE_TRANSFER_READ); row_stride = lp_img->row_stride[0]; img_stride = lp_img->img_stride[0]; + sample_stride = 0; assert(addr); } draw_set_mapped_image(lp->draw, @@ -474,7 +479,8 @@ prepare_shader_images( i, width, height, num_layers, addr, - row_stride, img_stride, 0, 0); + row_stride, img_stride, + num_samples, sample_stride); } } } diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c index 326fde79f94..e0285c70e5b 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c @@ -313,6 +313,8 @@ LP_LLVM_IMAGE_MEMBER(depth, LP_JIT_IMAGE_DEPTH, TRUE) LP_LLVM_IMAGE_MEMBER(base_ptr, LP_JIT_IMAGE_BASE, TRUE) LP_LLVM_IMAGE_MEMBER(row_stride, LP_JIT_IMAGE_ROW_STRIDE, TRUE) LP_LLVM_IMAGE_MEMBER(img_stride, LP_JIT_IMAGE_IMG_STRIDE, TRUE) +LP_LLVM_IMAGE_MEMBER(num_samples, LP_JIT_IMAGE_NUM_SAMPLES, TRUE) +LP_LLVM_IMAGE_MEMBER(sample_stride, LP_JIT_IMAGE_SAMPLE_STRIDE, TRUE) #if LP_USE_TEXTURE_CACHE static LLVMValueRef @@ -477,6 +479,8 @@ lp_llvm_image_soa_create(const struct lp_image_static_state *static_state) image->dynamic_state.base.base_ptr = lp_llvm_image_base_ptr; image->dynamic_state.base.row_stride = lp_llvm_image_row_stride; image->dynamic_state.base.img_stride = lp_llvm_image_img_stride; + image->dynamic_state.base.num_samples = lp_llvm_image_num_samples; + image->dynamic_state.base.sample_stride = lp_llvm_image_sample_stride; image->dynamic_state.static_state = static_state;