Module: Mesa
Branch: main
Commit: 8a54903a482731aeeda4647337b5e0067dc84182
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8a54903a482731aeeda4647337b5e0067dc84182

Author: Emma Anholt <[email protected]>
Date:   Tue Sep 21 16:42:40 2021 -0700

vulkan: Support PHYSICAL_DEVICE_1_n_ features/properties in the helpers.

Since we have a filled out struct available, just memcpy it over so the
driver doesn't have to fill it out again.

Suggested by Jason, this is code that isn't copy-and-paste from anv.

Reviewed-by: Jason Ekstrand <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12967>

---

 src/vulkan/util/vk_device.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/vulkan/util/vk_device.c b/src/vulkan/util/vk_device.c
index aeed646b6ac..c00a952c3b8 100644
--- a/src/vulkan/util/vk_device.c
+++ b/src/vulkan/util/vk_device.c
@@ -260,6 +260,13 @@ vk_common_GetImageSparseMemoryRequirements(VkDevice 
_device,
    STACK_ARRAY_FINISH(mem_reqs2);
 }
 
+static void
+copy_vk_struct_guts(VkBaseOutStructure *dst, VkBaseInStructure *src, size_t 
struct_size)
+{
+   STATIC_ASSERT(sizeof(*dst) == sizeof(*src));
+   memcpy(dst + 1, src + 1, struct_size - sizeof(VkBaseOutStructure));
+}
+
 #define CORE_FEATURE(feature) features->feature = core->feature
 
 bool
@@ -310,6 +317,10 @@ vk_get_physical_device_core_1_1_feature_ext(struct 
VkBaseOutStructure *ext,
       return true;
    }
 
+   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES:
+      copy_vk_struct_guts(ext, (void *)core, sizeof(*core));
+      return true;
+
    default:
       return false;
    }
@@ -426,6 +437,10 @@ vk_get_physical_device_core_1_2_feature_ext(struct 
VkBaseOutStructure *ext,
       return true;
    }
 
+   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES:
+      copy_vk_struct_guts(ext, (void *)core, sizeof(*core));
+      return true;
+
    default:
       return false;
    }
@@ -490,6 +505,10 @@ vk_get_physical_device_core_1_1_property_ext(struct 
VkBaseOutStructure *ext,
       return true;
    }
 
+   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES:
+      copy_vk_struct_guts(ext, (void *)core, sizeof(*core));
+      return true;
+
    default:
       return false;
    }
@@ -581,6 +600,10 @@ vk_get_physical_device_core_1_2_property_ext(struct 
VkBaseOutStructure *ext,
       return true;
    }
 
+   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES:
+      copy_vk_struct_guts(ext, (void *)core, sizeof(*core));
+      return true;
+
    default:
       return false;
    }
@@ -588,3 +611,4 @@ vk_get_physical_device_core_1_2_property_ext(struct 
VkBaseOutStructure *ext,
 
 #undef CORE_RENAMED_PROPERTY
 #undef CORE_PROPERTY
+

Reply via email to