From: Kristian Høgsberg Date: Mon, 18 May 2015 02:22:52 +0000 (-0700) Subject: vk: Change pData/pDataSize semantics X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=783e6217fcd5f7dc4125c16d47a985f63a2ab486;p=mesa.git vk: Change pData/pDataSize semantics We now always copy the entire struct unless pData is NULL and unconditionally write back the struct size. It's not clear this is useful if the structs may grow over time, but it seems to be the expected behaviour for now. --- diff --git a/src/vulkan/device.c b/src/vulkan/device.c index 1191682ffe3..c76a8f73c4e 100644 --- a/src/vulkan/device.c +++ b/src/vulkan/device.c @@ -190,8 +190,10 @@ VkResult anv_GetPhysicalDeviceInfo( switch (infoType) { case VK_PHYSICAL_DEVICE_INFO_TYPE_PROPERTIES: properties = pData; - assert(*pDataSize >= sizeof(*properties)); - *pDataSize = sizeof(*properties); /* Assuming we have to return the size of our struct. */ + + *pDataSize = sizeof(*properties); + if (pData == NULL) + return VK_SUCCESS; properties->apiVersion = 1; properties->driverVersion = 1; @@ -211,8 +213,10 @@ VkResult anv_GetPhysicalDeviceInfo( case VK_PHYSICAL_DEVICE_INFO_TYPE_PERFORMANCE: performance = pData; - assert(*pDataSize >= sizeof(*performance)); - *pDataSize = sizeof(*performance); /* Assuming we have to return the size of our struct. */ + + *pDataSize = sizeof(*performance); + if (pData == NULL) + return VK_SUCCESS; performance->maxDeviceClock = 1.0; performance->aluPerClock = 1.0; @@ -223,8 +227,10 @@ VkResult anv_GetPhysicalDeviceInfo( case VK_PHYSICAL_DEVICE_INFO_TYPE_QUEUE_PROPERTIES: queue_properties = pData; - assert(*pDataSize >= sizeof(*queue_properties)); + *pDataSize = sizeof(*queue_properties); + if (pData == NULL) + return VK_SUCCESS; queue_properties->queueFlags = 0; queue_properties->queueCount = 1; @@ -235,8 +241,10 @@ VkResult anv_GetPhysicalDeviceInfo( case VK_PHYSICAL_DEVICE_INFO_TYPE_MEMORY_PROPERTIES: memory_properties = pData; - assert(*pDataSize >= sizeof(*memory_properties)); + *pDataSize = sizeof(*memory_properties); + if (pData == NULL) + return VK_SUCCESS; memory_properties->supportsMigration = false; memory_properties->supportsPinning = false; @@ -392,8 +400,11 @@ VkResult anv_GetPhysicalDeviceExtensionInfo( switch (infoType) { case VK_EXTENSION_INFO_TYPE_COUNT: + *pDataSize = 4; + if (pData == NULL) + return VK_SUCCESS; + count = pData; - assert(*pDataSize == 4); *count = 0; return VK_SUCCESS; @@ -1000,6 +1011,10 @@ VkResult anv_GetObjectInfo( switch (infoType) { case VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS: + *pDataSize = sizeof(memory_requirements); + if (pData == NULL) + return VK_SUCCESS; + fill_memory_requirements(objType, object, &memory_requirements); memcpy(pData, &memory_requirements, MIN2(*pDataSize, sizeof(memory_requirements)));