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>
(cherry picked from commit 27903abbb6)
This commit is contained in:
Dave Airlie 2021-11-01 14:12:20 +10:00 committed by Dylan Baker
parent 0422749d11
commit d2f9a0e45b
4 changed files with 19 additions and 3 deletions

View file

@ -3172,7 +3172,7 @@
"description": "llvmpipe: fix compressed image sizes.",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -710,7 +710,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

@ -1126,7 +1126,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

@ -457,11 +457,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;