anv: fix how NULL buffer_view is handled in anv_descriptor_set_write_buffer_view
authorMarcin Ślusarz <marcin.slusarz@intel.com>
Tue, 11 Jul 2023 08:12:49 +0000 (10:12 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 12 Jul 2023 12:00:09 +0000 (12:00 +0000)
CID: 1531855

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24109>

src/intel/vulkan/anv_descriptor_set.c

index 2c1bf9d..989d930 100644 (file)
@@ -1783,7 +1783,10 @@ anv_descriptor_set_write_buffer_view(struct anv_device *device,
                     element * bind_layout->descriptor_stride;
 
    if (buffer_view == NULL) {
-      memset(desc_map, 0, bind_layout->descriptor_stride);
+      if (data & ANV_DESCRIPTOR_SURFACE)
+         memcpy(desc_map, device->null_surface_state.map, ANV_SURFACE_STATE_SIZE);
+      else
+         memset(desc_map, 0, bind_layout->descriptor_stride);
       return;
    }
 
@@ -1804,13 +1807,9 @@ anv_descriptor_set_write_buffer_view(struct anv_device *device,
    }
 
    if (data & ANV_DESCRIPTOR_SURFACE) {
-      if (buffer_view != NULL) {
-         memcpy(desc_map,
-                anv_buffer_view_surface_data(buffer_view, type),
-                ANV_SURFACE_STATE_SIZE);
-      } else {
-         memcpy(desc_map, device->null_surface_state.map, ANV_SURFACE_STATE_SIZE);
-      }
+      memcpy(desc_map,
+             anv_buffer_view_surface_data(buffer_view, type),
+             ANV_SURFACE_STATE_SIZE);
    }
 }