radeonsi: properly set cmask_buffer in si_reallocate_texture_inplace
authorMarek Olšák <marek.olsak@amd.com>
Fri, 22 Jun 2018 04:00:11 +0000 (00:00 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 25 Jun 2018 22:33:58 +0000 (18:33 -0400)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/gallium/drivers/radeonsi/si_texture.c

index a577778a9f14e1b2ade7c00c77612318b1f56a75..ac50103a74b021736ca727d0af8345c205cc067c 100644 (file)
@@ -574,7 +574,17 @@ static void si_reallocate_texture_inplace(struct si_context *sctx,
        tex->fmask_offset = new_tex->fmask_offset;
        tex->cmask_offset = new_tex->cmask_offset;
        tex->cmask_base_address_reg = new_tex->cmask_base_address_reg;
-       r600_resource_reference(&tex->cmask_buffer, new_tex->cmask_buffer);
+
+       if (tex->cmask_buffer == &tex->buffer)
+               tex->cmask_buffer = NULL;
+       else
+               r600_resource_reference(&tex->cmask_buffer, NULL);
+
+       if (new_tex->cmask_buffer == &new_tex->buffer)
+               tex->cmask_buffer = &tex->buffer;
+       else
+               r600_resource_reference(&tex->cmask_buffer, new_tex->cmask_buffer);
+
        tex->dcc_offset = new_tex->dcc_offset;
        tex->cb_color_info = new_tex->cb_color_info;
        memcpy(tex->color_clear_value, new_tex->color_clear_value,