gallium/u_threaded: fix crash in tc_create_image_handle due to resource == NULL

Fixes: 3df9d8ed80 - gallium/u_threaded: implement pipelined partial buffer uploads using CPU storage
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12020

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31651>
(cherry picked from commit 88f057eb53)
This commit is contained in:
Marek Olšák 2024-10-14 19:39:30 -04:00 committed by Eric Engestrom
parent e3d729523a
commit da09a3e97a
2 changed files with 13 additions and 3 deletions

View file

@ -164,7 +164,7 @@
"description": "gallium/u_threaded: fix crash in tc_create_image_handle due to resource == NULL",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "3df9d8ed807a6693d5fc8cbda4faec28af081ff3",
"notes": null

View file

@ -2399,9 +2399,19 @@ tc_create_image_handle(struct pipe_context *_pipe,
{
struct threaded_context *tc = threaded_context(_pipe);
struct pipe_context *pipe = tc->pipe;
struct pipe_resource *resource = image->resource;
if (image->resource->target == PIPE_BUFFER)
tc_buffer_disable_cpu_storage(image->resource);
if (image->access & PIPE_IMAGE_ACCESS_WRITE &&
resource && resource->target == PIPE_BUFFER) {
struct threaded_resource *tres = threaded_resource(resource);
/* The CPU storage doesn't support writable buffer. */
tc_buffer_disable_cpu_storage(resource);
util_range_add(&tres->b, &tres->valid_buffer_range,
image->u.buf.offset,
image->u.buf.offset + image->u.buf.size);
}
tc_sync(tc);
return pipe->create_image_handle(pipe, image);