From fa9afb9de0379d47892eca2ec826c1bdb5caacd2 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 13 May 2019 15:16:23 -0700 Subject: [PATCH] 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 --- src/gallium/drivers/virgl/virgl_encode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); -- 2.30.2