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.
This commit is contained in:
Kristian Høgsberg
2015-05-17 19:22:52 -07:00
parent b4b3bd1c51
commit 783e6217fc
+22 -7
View File
@@ -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)));