From 1b02eb1a4c99b1268da2c17420ece6f341b42789 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 10 Mar 2020 10:30:13 +1000 Subject: [PATCH] llvmpipe: add multisample support to texture allocator. This adds a sample stride field and allocates enough memory for each sample storage. Hook up the sample_stride field to draw and jit textures and images Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/drivers/llvmpipe/lp_setup.c | 4 +++- src/gallium/drivers/llvmpipe/lp_state_cs.c | 3 ++- src/gallium/drivers/llvmpipe/lp_state_sampler.c | 4 +++- src/gallium/drivers/llvmpipe/lp_texture.c | 5 +++++ src/gallium/drivers/llvmpipe/lp_texture.h | 1 + 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index a52f6bbb9c5..eaa759bdab9 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -726,7 +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->sample_stride = lp_res->sample_stride; jit_image->base = (uint8_t *)jit_image->base + mip_offset; } else { @@ -943,6 +943,8 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup, jit_tex->img_stride[j] = lp_tex->img_stride[j]; } + jit_tex->sample_stride = lp_tex->sample_stride; + if (res->target == PIPE_TEXTURE_1D_ARRAY || res->target == PIPE_TEXTURE_2D_ARRAY || res->target == PIPE_TEXTURE_CUBE || diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c index 1d33d5314d6..38210d444f5 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_cs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c @@ -880,6 +880,7 @@ lp_csctx_set_sampler_views(struct lp_cs_context *csctx, jit_tex->row_stride[j] = lp_tex->row_stride[j]; jit_tex->img_stride[j] = lp_tex->img_stride[j]; } + jit_tex->sample_stride = lp_tex->sample_stride; if (res->target == PIPE_TEXTURE_1D_ARRAY || res->target == PIPE_TEXTURE_2D_ARRAY || @@ -1076,7 +1077,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->sample_stride = lp_res->sample_stride; 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 9ddfc37864f..0851213a798 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c +++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c @@ -283,6 +283,8 @@ prepare_shader_sampling( assert(last_level <= res->last_level); addr = lp_tex->tex_data; + sample_stride = lp_tex->sample_stride; + for (j = first_level; j <= last_level; j++) { mip_offsets[j] = lp_tex->mip_offsets[j]; row_stride[j] = lp_tex->row_stride[j]; @@ -443,7 +445,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; + sample_stride = lp_img->sample_stride; addr = (uint8_t *)addr + mip_offset; } else { diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 0d5c4ac544d..47491ac4604 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -76,6 +76,8 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen, unsigned depth = pt->depth0; uint64_t total_size = 0; unsigned layers = pt->array_size; + unsigned num_samples = util_res_sample_count(pt); + /* XXX: * This alignment here (same for displaytarget) was added for the purpose of * ARB_map_buffer_alignment. I am not convinced it's needed for non-buffer @@ -166,6 +168,9 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen, depth = u_minify(depth, 1); } + lpr->sample_stride = total_size; + total_size *= num_samples; + if (allocate) { lpr->tex_data = align_malloc(total_size, mip_align); if (!lpr->tex_data) { diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h index 3d315bb9a73..03cf5a749d5 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.h +++ b/src/gallium/drivers/llvmpipe/lp_texture.h @@ -90,6 +90,7 @@ struct llvmpipe_resource unsigned id; /**< temporary, for debugging */ + unsigned sample_stride; #ifdef DEBUG /** for linked list */ struct llvmpipe_resource *prev, *next; -- 2.30.2