diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index c65a4bc5fae..1335b1ed9c4 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -852,10 +852,12 @@ static bool llvmpipe_resource_bind_backing(struct pipe_screen *screen, if (!lpr->backable) return FALSE; + if (llvmpipe_resource_is_texture(&lpr->base)) { + if (lpr->size_required > LP_MAX_TEXTURE_SIZE) + return FALSE; - if (llvmpipe_resource_is_texture(&lpr->base)) lpr->tex_data = (char *)pmem + offset; - else + } else lpr->data = (char *)pmem + offset; lpr->backing_offset = offset; diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c index a153c190ad8..846abcd110d 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -1629,12 +1629,18 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_BindImageMemory2(VkDevice _device, } if (!did_bind) { + if (!device->pscreen->resource_bind_backing(device->pscreen, + image->bo, + mem->pmem, + bind_info->memoryOffset)) { + /* This is probably caused by the texture being too large, so let's + * report this as the *closest* allowed error-code. It's not ideal, + * but it's unlikely that anyone will care too much. + */ + return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY); + } image->pmem = mem->pmem; image->memory_offset = bind_info->memoryOffset; - device->pscreen->resource_bind_backing(device->pscreen, - image->bo, - mem->pmem, - bind_info->memoryOffset); } } return VK_SUCCESS;