From: Chia-I Wu Date: Mon, 13 May 2019 22:16:23 +0000 (-0700) Subject: virgl: handle NULL shader resource explicitly X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fa9afb9de0379d47892eca2ec826c1bdb5caacd2;p=mesa.git virgl: handle NULL shader resource explicitly When shader images/buffers are set, do not rely on virgl_encoder_write_res and virgl_resource_dirty to do the implicit NULL check. Signed-off-by: Chia-I Wu Reviewed-by: Alexandros Frantzis Reviewed-by: Gurchetan Singh --- diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c index a0da36cdb89..72fecf43d02 100644 --- a/src/gallium/drivers/virgl/virgl_encode.c +++ b/src/gallium/drivers/virgl/virgl_encode.c @@ -963,7 +963,7 @@ int virgl_encode_set_shader_buffers(struct virgl_context *ctx, virgl_encoder_write_dword(ctx->cbuf, shader); virgl_encoder_write_dword(ctx->cbuf, start_slot); for (i = 0; i < count; i++) { - if (buffers) { + if (buffers && buffers[i].buffer) { struct virgl_resource *res = virgl_resource(buffers[i].buffer); virgl_encoder_write_dword(ctx->cbuf, buffers[i].buffer_offset); virgl_encoder_write_dword(ctx->cbuf, buffers[i].buffer_size); @@ -987,7 +987,7 @@ int virgl_encode_set_hw_atomic_buffers(struct virgl_context *ctx, virgl_encoder_write_dword(ctx->cbuf, start_slot); for (i = 0; i < count; i++) { - if (buffers) { + if (buffers && buffers[i].buffer) { struct virgl_resource *res = virgl_resource(buffers[i].buffer); virgl_encoder_write_dword(ctx->cbuf, buffers[i].buffer_offset); virgl_encoder_write_dword(ctx->cbuf, buffers[i].buffer_size); @@ -1013,7 +1013,7 @@ int virgl_encode_set_shader_images(struct virgl_context *ctx, virgl_encoder_write_dword(ctx->cbuf, shader); virgl_encoder_write_dword(ctx->cbuf, start_slot); for (i = 0; i < count; i++) { - if (images) { + if (images && images[i].resource) { struct virgl_resource *res = virgl_resource(images[i].resource); virgl_encoder_write_dword(ctx->cbuf, images[i].format); virgl_encoder_write_dword(ctx->cbuf, images[i].access);