llvmpipe: fix compressed image sizes.

VK CTS just added some new tests to write to a compressed image
from a compute shader, which was overrunning memory.

The image width/height need to be sized according to the block
sizes to avoid overwriting memory.

dEQP-VK.image.sample_texture.*bit_compressed*

Cc: mesa-stable

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13618>
This commit is contained in:
Dave Airlie 2021-11-01 14:12:20 +10:00
parent 53a8faafc1
commit 27903abbb6
3 changed files with 18 additions and 2 deletions

View File

@ -732,7 +732,11 @@ lp_setup_set_fs_images(struct lp_setup_context *setup,
if (llvmpipe_resource_is_texture(res)) {
uint32_t mip_offset = lp_res->mip_offsets[image->u.tex.level];
const uint32_t bw = util_format_get_blockwidth(image->resource->format);
const uint32_t bh = util_format_get_blockheight(image->resource->format);
jit_image->width = DIV_ROUND_UP(jit_image->width, bw);
jit_image->height = DIV_ROUND_UP(jit_image->height, bh);
jit_image->width = u_minify(jit_image->width, image->u.tex.level);
jit_image->height = u_minify(jit_image->height, image->u.tex.level);

View File

@ -1150,7 +1150,11 @@ lp_csctx_set_cs_images(struct lp_cs_context *csctx,
if (llvmpipe_resource_is_texture(res)) {
uint32_t mip_offset = lp_res->mip_offsets[image->u.tex.level];
const uint32_t bw = util_format_get_blockwidth(image->resource->format);
const uint32_t bh = util_format_get_blockheight(image->resource->format);
jit_image->width = DIV_ROUND_UP(jit_image->width, bw);
jit_image->height = DIV_ROUND_UP(jit_image->height, bh);
jit_image->width = u_minify(jit_image->width, image->u.tex.level);
jit_image->height = u_minify(jit_image->height, image->u.tex.level);

View File

@ -469,11 +469,19 @@ prepare_shader_images(
if (!img)
continue;
unsigned width = u_minify(img->width0, view->u.tex.level);
unsigned height = u_minify(img->height0, view->u.tex.level);
unsigned width = img->width0;
unsigned height = img->height0;
unsigned num_layers = img->depth0;
unsigned num_samples = img->nr_samples;
const uint32_t bw = util_format_get_blockwidth(view->resource->format);
const uint32_t bh = util_format_get_blockheight(view->resource->format);
width = DIV_ROUND_UP(width, bw);
height = DIV_ROUND_UP(height, bh);
width = u_minify(width, view->u.tex.level);
height = u_minify(height, view->u.tex.level);
if (!lp_img->dt) {
/* regular texture - setup array of mipmap level offsets */
struct pipe_resource *res = view->resource;