[Mesa-dev] [PATCH 2/3] vulkan/wsi: Drop the memory field from wsi_image in favor of driver_private

Jason Ekstrand jason at jlekstrand.net
Tue Nov 14 18:40:15 UTC 2017


We don't actually need the memory object for anything, it's entirely
private to the driver.  We're about to have stuff that's even more
private to the driver so we will want a driver_private anyway.
---
 src/amd/vulkan/radv_wsi.c   | 4 ++--
 src/intel/vulkan/anv_wsi.c  | 5 +++--
 src/vulkan/wsi/wsi_common.h | 4 +++-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index 248c1ee..f729ffb 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -233,7 +233,7 @@ radv_wsi_image_create(VkDevice device_h,
 	surface = &image->surface;
 
 	wsi_image->image = image_h;
-	wsi_image->memory = memory_h;
+	wsi_image->driver_private = memory_h;
 	wsi_image->size = image->size;
 	wsi_image->offset = image->offset;
 	if (device->physical_device->rad_info.chip_class >= GFX9)
@@ -260,7 +260,7 @@ radv_wsi_image_free(VkDevice device,
 {
 	radv_DestroyImage(device, wsi_image->image, pAllocator);
 
-	radv_FreeMemory(device, wsi_image->memory, pAllocator);
+	radv_FreeMemory(device, wsi_image->driver_private, pAllocator);
 }
 
 static const struct wsi_image_fns radv_wsi_image_fns = {
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index b7aacd8..154263f 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -259,8 +259,8 @@ anv_wsi_image_create(VkDevice device_h,
       goto fail_alloc_memory;
    }
 
+   wsi_image->driver_private = memory;
    wsi_image->image = image_h;
-   wsi_image->memory = memory_h;
    wsi_image->fd = fd;
    wsi_image->size = image->size;
    wsi_image->offset = 0;
@@ -281,7 +281,8 @@ anv_wsi_image_free(VkDevice device,
 {
    anv_DestroyImage(device, wsi_image->image, pAllocator);
 
-   anv_FreeMemory(device, wsi_image->memory, pAllocator);
+   /* We use the driver_private to keep track of the memory object */
+   anv_FreeMemory(device, wsi_image->driver_private, pAllocator);
 }
 
 static const struct wsi_image_fns anv_wsi_image_fns = {
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 483878f..a6414ef 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -31,8 +31,10 @@
 #include <vulkan/vk_icd.h>
 
 struct wsi_image {
+   /* Private storage for the driver */
+   void *driver_private;
+
    VkImage image;
-   VkDeviceMemory memory;
    uint32_t size;
    uint32_t offset;
    uint32_t row_pitch;
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list