2018-08-26 15:11:43 +02:00
|
|
|
#include "common.h"
|
|
|
|
|
2019-09-30 02:13:55 +02:00
|
|
|
#include "declarations.h"
|
|
|
|
|
2018-08-26 15:11:43 +02:00
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#devsandqueues-physical-device-enumeration
|
|
|
|
* If pPhysicalDevices is NULL, then the number of physical devices available is returned in pPhysicalDeviceCount. Otherwise, pPhysicalDeviceCount must point to a
|
|
|
|
* variable set by the user to the number of elements in the pPhysicalDevices array, and on return the variable is overwritten with the number of handles actually
|
|
|
|
* written to pPhysicalDevices. If pPhysicalDeviceCount is less than the number of physical devices available, at most pPhysicalDeviceCount structures will be written.
|
|
|
|
* If pPhysicalDeviceCount is smaller than the number of physical devices available, VK_INCOMPLETE will be returned instead of VK_SUCCESS, to indicate that not all the
|
|
|
|
* available physical devices were returned.
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkEnumeratePhysicalDevices(
|
2018-08-26 15:11:43 +02:00
|
|
|
VkInstance instance,
|
|
|
|
uint32_t* pPhysicalDeviceCount,
|
|
|
|
VkPhysicalDevice* pPhysicalDevices)
|
|
|
|
{
|
|
|
|
assert(instance);
|
|
|
|
|
2018-11-16 20:39:33 +01:00
|
|
|
int numGPUs = 1;
|
2018-08-26 15:11:43 +02:00
|
|
|
|
|
|
|
assert(pPhysicalDeviceCount);
|
|
|
|
|
|
|
|
if(!pPhysicalDevices)
|
|
|
|
{
|
|
|
|
*pPhysicalDeviceCount = numGPUs;
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int arraySize = *pPhysicalDeviceCount;
|
|
|
|
int elementsWritten = min(numGPUs, arraySize);
|
|
|
|
|
|
|
|
for(int c = 0; c < elementsWritten; ++c)
|
|
|
|
{
|
|
|
|
pPhysicalDevices[c] = &instance->dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pPhysicalDeviceCount = elementsWritten;
|
|
|
|
|
2018-11-18 15:21:33 +01:00
|
|
|
if(arraySize < numGPUs)
|
2018-08-26 15:11:43 +02:00
|
|
|
{
|
|
|
|
return VK_INCOMPLETE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkGetPhysicalDeviceProperties
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkGetPhysicalDeviceProperties(
|
2018-08-26 15:11:43 +02:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
VkPhysicalDeviceProperties* pProperties)
|
|
|
|
{
|
|
|
|
assert(physicalDevice);
|
|
|
|
assert(pProperties);
|
|
|
|
|
|
|
|
VkPhysicalDeviceSparseProperties sparseProps =
|
|
|
|
{
|
|
|
|
.residencyStandard2DBlockShape = 1,
|
|
|
|
.residencyStandard2DMultisampleBlockShape = 1,
|
|
|
|
.residencyStandard3DBlockShape = 1,
|
|
|
|
.residencyAlignedMipSize = 1,
|
|
|
|
.residencyNonResidentStrict = 1
|
|
|
|
};
|
|
|
|
|
2018-11-18 15:21:33 +01:00
|
|
|
pProperties->apiVersion = VK_DRIVER_VERSION;
|
2018-08-26 15:11:43 +02:00
|
|
|
pProperties->driverVersion = 1; //we'll simply call this v1
|
|
|
|
pProperties->vendorID = 0x14E4; //Broadcom
|
2019-09-08 00:30:52 +02:00
|
|
|
pProperties->deviceID = 0x5250; //RP in HEX
|
2018-08-26 15:11:43 +02:00
|
|
|
pProperties->deviceType = VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
|
|
|
|
strcpy(pProperties->deviceName, "VideoCore IV HW");
|
|
|
|
pProperties->limits = _limits;
|
|
|
|
pProperties->sparseProperties = sparseProps;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkGetPhysicalDeviceFeatures
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkGetPhysicalDeviceFeatures(
|
2018-08-26 15:11:43 +02:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
VkPhysicalDeviceFeatures* pFeatures)
|
|
|
|
{
|
|
|
|
assert(physicalDevice);
|
|
|
|
assert(pFeatures);
|
|
|
|
|
|
|
|
*pFeatures = _features;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkEnumerateDeviceExtensionProperties
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkEnumerateDeviceExtensionProperties(
|
2018-08-26 15:11:43 +02:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
const char* pLayerName,
|
|
|
|
uint32_t* pPropertyCount,
|
|
|
|
VkExtensionProperties* pProperties)
|
|
|
|
{
|
|
|
|
assert(physicalDevice);
|
|
|
|
assert(pPropertyCount);
|
|
|
|
|
|
|
|
if(!pProperties)
|
|
|
|
{
|
|
|
|
*pPropertyCount = numDeviceExtensions;
|
2018-11-14 20:25:22 +01:00
|
|
|
return VK_SUCCESS;
|
2018-08-26 15:11:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int arraySize = *pPropertyCount;
|
|
|
|
int elementsWritten = min(numDeviceExtensions, arraySize);
|
|
|
|
|
|
|
|
for(int c = 0; c < elementsWritten; ++c)
|
|
|
|
{
|
|
|
|
pProperties[c] = deviceExtensions[c];
|
|
|
|
}
|
|
|
|
|
|
|
|
*pPropertyCount = elementsWritten;
|
|
|
|
|
2019-04-10 22:13:59 +02:00
|
|
|
if(arraySize < numDeviceExtensions)
|
|
|
|
{
|
|
|
|
return VK_INCOMPLETE;
|
|
|
|
}
|
|
|
|
|
2018-08-26 15:11:43 +02:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkGetPhysicalDeviceQueueFamilyProperties
|
|
|
|
* If pQueueFamilyProperties is NULL, then the number of queue families available is returned in pQueueFamilyPropertyCount.
|
|
|
|
* Otherwise, pQueueFamilyPropertyCount must point to a variable set by the user to the number of elements in the pQueueFamilyProperties array,
|
|
|
|
* and on return the variable is overwritten with the number of structures actually written to pQueueFamilyProperties. If pQueueFamilyPropertyCount
|
|
|
|
* is less than the number of queue families available, at most pQueueFamilyPropertyCount structures will be written.
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkGetPhysicalDeviceQueueFamilyProperties(
|
2018-08-26 15:11:43 +02:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
uint32_t* pQueueFamilyPropertyCount,
|
|
|
|
VkQueueFamilyProperties* pQueueFamilyProperties)
|
|
|
|
{
|
|
|
|
assert(physicalDevice);
|
|
|
|
assert(pQueueFamilyPropertyCount);
|
|
|
|
|
|
|
|
if(!pQueueFamilyProperties)
|
|
|
|
{
|
|
|
|
*pQueueFamilyPropertyCount = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int arraySize = *pQueueFamilyPropertyCount;
|
|
|
|
int elementsWritten = min(numQueueFamilies, arraySize);
|
|
|
|
|
|
|
|
for(int c = 0; c < elementsWritten; ++c)
|
|
|
|
{
|
|
|
|
pQueueFamilyProperties[c] = _queueFamilyProperties[c];
|
|
|
|
}
|
|
|
|
|
|
|
|
*pQueueFamilyPropertyCount = elementsWritten;
|
|
|
|
}
|
|
|
|
|
2020-02-23 13:20:32 +01:00
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(
|
2020-02-22 22:50:53 +01:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
uint32_t queueFamilyIndex,
|
|
|
|
uint32_t* pCounterCount,
|
|
|
|
VkPerformanceCounterKHR* pCounters,
|
|
|
|
VkPerformanceCounterDescriptionKHR* pCounterDescriptions)
|
|
|
|
{
|
|
|
|
assert(physicalDevice);
|
|
|
|
assert(pCounterCount);
|
|
|
|
|
|
|
|
if(!pCounters && !pCounterDescriptions)
|
|
|
|
{
|
|
|
|
*pCounterCount = numPerformanceCounterTypes;
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int arraySize = *pCounterCount;
|
|
|
|
int elementsWritten = min(numPerformanceCounterTypes, arraySize);
|
|
|
|
|
|
|
|
for(int c = 0; c < elementsWritten; ++c)
|
|
|
|
{
|
|
|
|
pCounters[c] = performanceCounterTypes[c];
|
|
|
|
pCounterDescriptions[c] = performanceCounterDescriptions[c];
|
|
|
|
}
|
|
|
|
|
|
|
|
*pCounterCount = elementsWritten;
|
|
|
|
|
|
|
|
if(arraySize < numPerformanceCounterTypes)
|
|
|
|
{
|
|
|
|
return VK_INCOMPLETE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2020-02-23 13:20:32 +01:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR(
|
2020-02-22 22:50:53 +01:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
const VkQueryPoolPerformanceCreateInfoKHR* pPerformanceQueryCreateInfo,
|
|
|
|
uint32_t* pNumPasses)
|
|
|
|
{
|
|
|
|
assert(physicalDevice);
|
|
|
|
assert(pPerformanceQueryCreateInfo);
|
|
|
|
assert(pNumPasses);
|
|
|
|
|
2020-02-24 22:45:47 +01:00
|
|
|
*pNumPasses = pPerformanceQueryCreateInfo->counterIndexCount / DRM_VC4_MAX_PERF_COUNTERS + 1;
|
2020-02-22 22:50:53 +01:00
|
|
|
}
|
|
|
|
|
2018-08-26 15:11:43 +02:00
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCreateDevice
|
|
|
|
* vkCreateDevice verifies that extensions and features requested in the ppEnabledExtensionNames and pEnabledFeatures
|
|
|
|
* members of pCreateInfo, respectively, are supported by the implementation. If any requested extension is not supported,
|
|
|
|
* vkCreateDevice must return VK_ERROR_EXTENSION_NOT_PRESENT. If any requested feature is not supported, vkCreateDevice must return
|
|
|
|
* VK_ERROR_FEATURE_NOT_PRESENT. Support for extensions can be checked before creating a device by querying vkEnumerateDeviceExtensionProperties
|
|
|
|
* After verifying and enabling the extensions the VkDevice object is created and returned to the application.
|
|
|
|
* If a requested extension is only supported by a layer, both the layer and the extension need to be specified at vkCreateInstance
|
|
|
|
* time for the creation to succeed. Multiple logical devices can be created from the same physical device. Logical device creation may
|
|
|
|
* fail due to lack of device-specific resources (in addition to the other errors). If that occurs, vkCreateDevice will return VK_ERROR_TOO_MANY_OBJECTS.
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateDevice(
|
2018-08-26 15:11:43 +02:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
const VkDeviceCreateInfo* pCreateInfo,
|
|
|
|
const VkAllocationCallbacks* pAllocator,
|
|
|
|
VkDevice* pDevice)
|
|
|
|
{
|
|
|
|
assert(physicalDevice);
|
|
|
|
assert(pDevice);
|
|
|
|
assert(pCreateInfo);
|
|
|
|
|
2018-11-16 20:39:33 +01:00
|
|
|
//check for enabled extensions
|
|
|
|
for(int c = 0; c < pCreateInfo->enabledExtensionCount; ++c)
|
|
|
|
{
|
|
|
|
int findres = findDeviceExtension(pCreateInfo->ppEnabledExtensionNames[c]);
|
|
|
|
if(findres == -1)
|
|
|
|
{
|
|
|
|
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//check for enabled features
|
|
|
|
VkBool32* requestedFeatures = pCreateInfo->pEnabledFeatures;
|
|
|
|
VkBool32* supportedFeatures = &_features;
|
|
|
|
|
|
|
|
if(requestedFeatures)
|
|
|
|
{
|
|
|
|
for(int c = 0; c < numFeatures; ++c)
|
|
|
|
{
|
|
|
|
if(requestedFeatures[c] && !supportedFeatures[c])
|
|
|
|
{
|
|
|
|
return VK_ERROR_FEATURE_NOT_PRESENT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-17 16:53:13 +01:00
|
|
|
*pDevice = ALLOCATE(sizeof(_device), 1, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
|
|
|
|
if(!*pDevice)
|
2018-08-26 15:11:43 +02:00
|
|
|
{
|
2019-02-10 00:53:32 +01:00
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
2018-08-26 15:11:43 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
set_loader_magic_value(&(*pDevice)->loaderData);
|
|
|
|
|
2018-08-26 15:11:43 +02:00
|
|
|
(*pDevice)->dev = physicalDevice;
|
|
|
|
|
2018-11-14 20:25:22 +01:00
|
|
|
(*pDevice)->numEnabledExtensions = 0;
|
|
|
|
|
2018-08-26 15:11:43 +02:00
|
|
|
for(int c = 0; c < pCreateInfo->enabledExtensionCount; ++c)
|
|
|
|
{
|
|
|
|
int findres = findDeviceExtension(pCreateInfo->ppEnabledExtensionNames[c]);
|
|
|
|
if(findres > -1)
|
|
|
|
{
|
|
|
|
(*pDevice)->enabledExtensions[(*pDevice)->numEnabledExtensions] = findres;
|
|
|
|
(*pDevice)->numEnabledExtensions++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(requestedFeatures)
|
|
|
|
{
|
|
|
|
for(int c = 0; c < numFeatures; ++c)
|
|
|
|
{
|
|
|
|
if(requestedFeatures[c] && !supportedFeatures[c])
|
|
|
|
{
|
|
|
|
return VK_ERROR_FEATURE_NOT_PRESENT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(*pDevice)->enabledFeatures = *pCreateInfo->pEnabledFeatures;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memset(&(*pDevice)->enabledFeatures, 0, sizeof((*pDevice)->enabledFeatures)); //just disable everything
|
|
|
|
}
|
|
|
|
|
|
|
|
//layers ignored per spec
|
|
|
|
//pCreateInfo->enabledLayerCount
|
|
|
|
|
|
|
|
for(int c = 0; c < numQueueFamilies; ++c)
|
|
|
|
{
|
|
|
|
(*pDevice)->queues[c] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pCreateInfo->queueCreateInfoCount > 0)
|
|
|
|
{
|
|
|
|
for(int c = 0; c < pCreateInfo->queueCreateInfoCount; ++c)
|
|
|
|
{
|
2018-11-17 16:53:13 +01:00
|
|
|
(*pDevice)->queues[pCreateInfo->pQueueCreateInfos[c].queueFamilyIndex] = ALLOCATE(sizeof(_queue)*pCreateInfo->pQueueCreateInfos[c].queueCount, 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
2018-08-26 15:11:43 +02:00
|
|
|
|
|
|
|
if(!(*pDevice)->queues[pCreateInfo->pQueueCreateInfos[c].queueFamilyIndex])
|
|
|
|
{
|
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int d = 0; d < pCreateInfo->pQueueCreateInfos[c].queueCount; ++d)
|
|
|
|
{
|
|
|
|
(*pDevice)->queues[pCreateInfo->pQueueCreateInfos[c].queueFamilyIndex][d].lastEmitSeqno = 0;
|
2019-09-30 00:52:21 +02:00
|
|
|
(*pDevice)->queues[pCreateInfo->pQueueCreateInfos[c].queueFamilyIndex][d].dev = *pDevice;
|
|
|
|
set_loader_magic_value(&(*pDevice)->queues[pCreateInfo->pQueueCreateInfos[c].queueFamilyIndex][d].loaderData);
|
2018-08-26 15:11:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
(*pDevice)->numQueues[pCreateInfo->pQueueCreateInfos[c].queueFamilyIndex] = pCreateInfo->pQueueCreateInfos[c].queueCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-14 20:43:52 +01:00
|
|
|
setupEmulationResources(*pDevice);
|
|
|
|
|
2018-08-26 15:11:43 +02:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkGetDeviceQueue
|
|
|
|
* vkGetDeviceQueue must only be used to get queues that were created with the flags parameter of VkDeviceQueueCreateInfo set to zero.
|
|
|
|
* To get queues that were created with a non-zero flags parameter use vkGetDeviceQueue2.
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkGetDeviceQueue(
|
2018-08-26 15:11:43 +02:00
|
|
|
VkDevice device,
|
|
|
|
uint32_t queueFamilyIndex,
|
|
|
|
uint32_t queueIndex,
|
|
|
|
VkQueue* pQueue)
|
|
|
|
{
|
|
|
|
assert(device);
|
|
|
|
assert(pQueue);
|
|
|
|
|
|
|
|
assert(queueFamilyIndex < numQueueFamilies);
|
|
|
|
assert(queueIndex < device->numQueues[queueFamilyIndex]);
|
|
|
|
|
|
|
|
*pQueue = &device->queues[queueFamilyIndex][queueIndex];
|
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkGetDeviceQueue2(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkDevice device,
|
|
|
|
const VkDeviceQueueInfo2* pQueueInfo,
|
|
|
|
VkQueue* pQueue)
|
|
|
|
{
|
|
|
|
assert(device);
|
|
|
|
assert(pQueueInfo);
|
|
|
|
assert(pQueue);
|
|
|
|
|
2019-09-08 00:30:52 +02:00
|
|
|
//TODO handle pNext
|
|
|
|
|
2019-09-30 02:13:55 +02:00
|
|
|
rpi_vkGetDeviceQueue(device, pQueueInfo->queueFamilyIndex, pQueueInfo->queueIndex, pQueue);
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|
|
|
|
|
2018-08-26 15:11:43 +02:00
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkDestroyDevice
|
|
|
|
* To ensure that no work is active on the device, vkDeviceWaitIdle can be used to gate the destruction of the device.
|
|
|
|
* Prior to destroying a device, an application is responsible for destroying/freeing any Vulkan objects that were created using that device as the
|
|
|
|
* first parameter of the corresponding vkCreate* or vkAllocate* command
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkDestroyDevice(
|
2018-08-26 15:11:43 +02:00
|
|
|
VkDevice device,
|
|
|
|
const VkAllocationCallbacks* pAllocator)
|
|
|
|
{
|
2018-10-16 20:34:17 +02:00
|
|
|
_device* dev = device;
|
2019-02-09 17:18:15 +01:00
|
|
|
|
|
|
|
if(dev)
|
2018-10-16 20:34:17 +02:00
|
|
|
{
|
2019-02-09 17:18:15 +01:00
|
|
|
for(int c = 0; c < numQueueFamilies; ++c)
|
2018-10-16 20:34:17 +02:00
|
|
|
{
|
2019-02-09 17:18:15 +01:00
|
|
|
for(int d = 0; d < dev->numQueues[c]; ++d)
|
|
|
|
{
|
|
|
|
FREE(dev->queues[d]);
|
|
|
|
}
|
2018-10-16 20:34:17 +02:00
|
|
|
}
|
2019-02-10 00:53:32 +01:00
|
|
|
FREE(dev);
|
2018-10-16 20:34:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkEnumeratePhysicalDeviceGroups
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkEnumeratePhysicalDeviceGroups(
|
2018-10-16 20:34:17 +02:00
|
|
|
VkInstance instance,
|
|
|
|
uint32_t* pPhysicalDeviceGroupCount,
|
|
|
|
VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties)
|
|
|
|
{
|
|
|
|
assert(instance);
|
|
|
|
assert(pPhysicalDeviceGroupCount);
|
|
|
|
|
|
|
|
if(!pPhysicalDeviceGroupProperties)
|
|
|
|
{
|
|
|
|
*pPhysicalDeviceGroupCount = 1;
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2019-09-08 00:30:52 +02:00
|
|
|
//we don't have any other devices...
|
|
|
|
assert(*pPhysicalDeviceGroupCount == 1);
|
|
|
|
|
2018-10-16 20:34:17 +02:00
|
|
|
uint32_t c = 0;
|
|
|
|
for(; c < *pPhysicalDeviceGroupCount; ++c)
|
|
|
|
{
|
|
|
|
pPhysicalDeviceGroupProperties[c].physicalDeviceCount = 1;
|
2018-10-17 21:56:13 +02:00
|
|
|
pPhysicalDeviceGroupProperties[c].physicalDevices[0] = &instance->dev;
|
2018-10-16 20:34:17 +02:00
|
|
|
pPhysicalDeviceGroupProperties[c].subsetAllocation = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(c < 1)
|
|
|
|
{
|
|
|
|
return VK_INCOMPLETE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return VK_SUCCESS;
|
2018-08-26 15:11:43 +02:00
|
|
|
}
|
2018-11-18 16:11:12 +01:00
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
extern VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL rpi_vkGetInstanceProcAddr(VkInstance instance,
|
|
|
|
const char* pName);
|
|
|
|
|
|
|
|
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL rpi_vkGetDeviceProcAddr(
|
2018-11-18 16:11:12 +01:00
|
|
|
VkDevice device,
|
|
|
|
const char* pName)
|
|
|
|
{
|
|
|
|
if(
|
|
|
|
!strcmp("vkDestroyInstance", pName) ||
|
|
|
|
!strcmp("vkEnumeratePhysicalDevices", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceFeatures", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceFormatProperties", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceImageFormatProperties", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceProperties", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceQueueFamilyProperties", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceMemoryProperties", pName) ||
|
|
|
|
!strcmp("vkCreateDevice", pName) ||
|
|
|
|
!strcmp("vkEnumerateDeviceExtensionProperties", pName) ||
|
|
|
|
!strcmp("vkEnumerateDeviceLayerProperties", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceSparseImageFormatProperties", pName) ||
|
|
|
|
!strcmp("vkEnumeratePhysicalDeviceGroups", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceFeatures2", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceProperties2", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceFormatProperties2", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceImageFormatProperties2", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceQueueFamilyProperties2", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceMemoryProperties2", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceSparseImageFormatProperties2", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceExternalBufferProperties", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceExternalFenceProperties", pName) ||
|
|
|
|
!strcmp("vkGetPhysicalDeviceExternalSemaphoreProperties", pName)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-08 00:30:52 +02:00
|
|
|
//there can't be any other device, so this will do fine...
|
2018-11-18 16:11:12 +01:00
|
|
|
_device* d = device;
|
2019-09-30 00:52:21 +02:00
|
|
|
return rpi_vkGetInstanceProcAddr(d->dev->instance, pName);
|
2018-11-18 16:11:12 +01:00
|
|
|
}
|
2019-04-22 15:58:27 +02:00
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkGetPhysicalDeviceProperties2(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
VkPhysicalDeviceProperties2* pProperties)
|
|
|
|
{
|
|
|
|
assert(physicalDevice);
|
|
|
|
assert(pProperties);
|
2019-09-30 02:13:55 +02:00
|
|
|
rpi_vkGetPhysicalDeviceProperties(physicalDevice, &pProperties->properties);
|
2019-04-22 15:58:27 +02:00
|
|
|
|
|
|
|
if(pProperties->pNext)
|
|
|
|
{
|
|
|
|
VkPhysicalDeviceDriverPropertiesKHR* ptr = pProperties->pNext;
|
|
|
|
if(ptr->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR)
|
|
|
|
{
|
2019-09-08 00:30:52 +02:00
|
|
|
ptr->driverID = 0x525049564b; //RPIVK in hex
|
2019-04-22 15:58:27 +02:00
|
|
|
const char* driverName = "RPi VK";
|
|
|
|
const char* driverInfo = ""; //TODO maybe version number, git info?
|
|
|
|
strcpy(ptr->driverName, driverName);
|
|
|
|
strcpy(ptr->driverInfo, driverInfo);
|
|
|
|
//TODO this is what we are aspiring to pass...
|
|
|
|
ptr->conformanceVersion.major = 1;
|
|
|
|
ptr->conformanceVersion.minor = 1;
|
|
|
|
ptr->conformanceVersion.subminor = 2;
|
|
|
|
ptr->conformanceVersion.patch = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkGetPhysicalDeviceFormatProperties(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
VkFormat format,
|
|
|
|
VkFormatProperties* pFormatProperties)
|
|
|
|
{
|
|
|
|
assert(physicalDevice);
|
|
|
|
assert(pFormatProperties);
|
|
|
|
|
2019-12-14 13:23:42 +01:00
|
|
|
switch(format)
|
|
|
|
{
|
|
|
|
//TODO what formats could we pull off
|
|
|
|
//case VK_FORMAT_D16_UNORM:
|
|
|
|
case VK_FORMAT_X8_D24_UNORM_PACK32:
|
|
|
|
//case VK_FORMAT_D32_SFLOAT:
|
|
|
|
//case VK_FORMAT_S8_UINT:
|
|
|
|
//case VK_FORMAT_D16_UNORM_S8_UINT:
|
|
|
|
case VK_FORMAT_D24_UNORM_S8_UINT:
|
|
|
|
//case VK_FORMAT_D32_SFLOAT_S8_UINT:
|
2019-04-22 15:58:27 +02:00
|
|
|
{
|
|
|
|
pFormatProperties->linearTilingFeatures = 0
|
|
|
|
| VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_BLIT_SRC_BIT
|
|
|
|
| VK_FORMAT_FEATURE_TRANSFER_SRC_BIT
|
2019-09-08 00:30:52 +02:00
|
|
|
| VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT
|
2019-04-22 15:58:27 +02:00
|
|
|
;
|
|
|
|
pFormatProperties->optimalTilingFeatures = 0
|
|
|
|
| VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
|
|
|
|
| VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT
|
2019-09-08 00:30:52 +02:00
|
|
|
| VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT
|
2019-04-22 15:58:27 +02:00
|
|
|
| VK_FORMAT_FEATURE_BLIT_SRC_BIT
|
|
|
|
| VK_FORMAT_FEATURE_BLIT_DST_BIT
|
|
|
|
| VK_FORMAT_FEATURE_TRANSFER_SRC_BIT
|
|
|
|
| VK_FORMAT_FEATURE_TRANSFER_DST_BIT
|
2019-09-08 00:30:52 +02:00
|
|
|
| VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT
|
|
|
|
|
2019-04-22 15:58:27 +02:00
|
|
|
;
|
|
|
|
pFormatProperties->bufferFeatures = 0
|
|
|
|
| VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_TRANSFER_SRC_BIT
|
2019-09-08 00:30:52 +02:00
|
|
|
| VK_FORMAT_FEATURE_BLIT_SRC_BIT
|
2019-04-22 15:58:27 +02:00
|
|
|
;
|
2019-12-14 13:23:42 +01:00
|
|
|
break;
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|
2019-12-14 13:23:42 +01:00
|
|
|
//supported texture formats
|
|
|
|
case VK_FORMAT_R8G8B8_UNORM:
|
|
|
|
case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
|
|
|
|
case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
|
|
|
|
case VK_FORMAT_R8G8_UNORM:
|
|
|
|
case VK_FORMAT_R16_SFLOAT:
|
|
|
|
case VK_FORMAT_R16_SINT:
|
|
|
|
case VK_FORMAT_R8_UNORM:
|
|
|
|
case VK_FORMAT_R8_SINT:
|
|
|
|
case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
|
|
|
|
case VK_FORMAT_G8B8G8R8_422_UNORM:
|
2019-04-22 15:58:27 +02:00
|
|
|
{
|
2019-12-14 13:23:42 +01:00
|
|
|
pFormatProperties->linearTilingFeatures = 0
|
|
|
|
| VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_BLIT_SRC_BIT
|
|
|
|
| VK_FORMAT_FEATURE_TRANSFER_SRC_BIT
|
|
|
|
;
|
|
|
|
pFormatProperties->optimalTilingFeatures = 0
|
|
|
|
| VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
|
|
|
|
| VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT
|
|
|
|
| VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT
|
|
|
|
| VK_FORMAT_FEATURE_BLIT_SRC_BIT
|
|
|
|
| VK_FORMAT_FEATURE_BLIT_DST_BIT
|
|
|
|
| VK_FORMAT_FEATURE_TRANSFER_SRC_BIT
|
|
|
|
| VK_FORMAT_FEATURE_TRANSFER_DST_BIT
|
|
|
|
;
|
|
|
|
pFormatProperties->bufferFeatures = 0
|
|
|
|
| VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_TRANSFER_SRC_BIT
|
|
|
|
| VK_FORMAT_FEATURE_BLIT_SRC_BIT
|
|
|
|
;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//supported render target formats
|
|
|
|
case VK_FORMAT_R16G16B16A16_SFLOAT:
|
|
|
|
case VK_FORMAT_R8G8B8A8_UNORM:
|
|
|
|
case VK_FORMAT_B5G6R5_UNORM_PACK16:
|
|
|
|
{
|
|
|
|
pFormatProperties->linearTilingFeatures = 0
|
|
|
|
| VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_BLIT_SRC_BIT
|
|
|
|
| VK_FORMAT_FEATURE_TRANSFER_SRC_BIT
|
|
|
|
;
|
|
|
|
pFormatProperties->optimalTilingFeatures = 0
|
|
|
|
| VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
|
|
|
|
| VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT
|
|
|
|
| VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT
|
|
|
|
| VK_FORMAT_FEATURE_BLIT_SRC_BIT
|
|
|
|
| VK_FORMAT_FEATURE_BLIT_DST_BIT
|
|
|
|
| VK_FORMAT_FEATURE_TRANSFER_SRC_BIT
|
|
|
|
| VK_FORMAT_FEATURE_TRANSFER_DST_BIT
|
|
|
|
| VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT
|
|
|
|
| VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT
|
|
|
|
;
|
|
|
|
pFormatProperties->bufferFeatures = 0
|
|
|
|
| VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT
|
|
|
|
| VK_FORMAT_FEATURE_TRANSFER_SRC_BIT
|
|
|
|
| VK_FORMAT_FEATURE_BLIT_SRC_BIT
|
|
|
|
;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
pFormatProperties->linearTilingFeatures = 0;
|
|
|
|
pFormatProperties->optimalTilingFeatures = 0;
|
|
|
|
pFormatProperties->bufferFeatures = 0;
|
|
|
|
break;
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkGetPhysicalDeviceFormatProperties2(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
VkFormat format,
|
|
|
|
VkFormatProperties2* pFormatProperties)
|
|
|
|
{
|
|
|
|
assert(physicalDevice);
|
|
|
|
assert(pFormatProperties);
|
2019-09-30 02:13:55 +02:00
|
|
|
rpi_vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &pFormatProperties->formatProperties);
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkGetPhysicalDeviceImageFormatProperties(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
VkFormat format,
|
|
|
|
VkImageType type,
|
|
|
|
VkImageTiling tiling,
|
|
|
|
VkImageUsageFlags usage,
|
|
|
|
VkImageCreateFlags flags,
|
|
|
|
VkImageFormatProperties* pImageFormatProperties)
|
|
|
|
{
|
|
|
|
assert(physicalDevice);
|
|
|
|
assert(pImageFormatProperties);
|
|
|
|
|
2019-09-08 00:30:52 +02:00
|
|
|
//TODO usage, flags tiling etc.
|
|
|
|
//do all this per format...
|
|
|
|
|
|
|
|
|
2019-04-22 15:58:27 +02:00
|
|
|
VkFormat ycbcrConversionRequiredFormats[] =
|
|
|
|
{
|
|
|
|
VK_FORMAT_G8B8G8R8_422_UNORM
|
|
|
|
,VK_FORMAT_B8G8R8G8_422_UNORM
|
|
|
|
,VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM
|
|
|
|
,VK_FORMAT_G8_B8R8_2PLANE_420_UNORM
|
|
|
|
,VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM
|
|
|
|
,VK_FORMAT_G8_B8R8_2PLANE_422_UNORM
|
|
|
|
,VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM
|
|
|
|
,VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16
|
|
|
|
,VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16
|
|
|
|
,VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16
|
|
|
|
,VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16
|
|
|
|
,VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16
|
|
|
|
,VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16
|
|
|
|
,VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16
|
|
|
|
,VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16
|
|
|
|
,VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16
|
|
|
|
,VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16
|
|
|
|
,VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16
|
|
|
|
,VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16
|
|
|
|
,VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16
|
|
|
|
,VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16
|
|
|
|
,VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16
|
|
|
|
,VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16
|
|
|
|
,VK_FORMAT_G16B16G16R16_422_UNORM
|
|
|
|
,VK_FORMAT_B16G16R16G16_422_UNORM
|
|
|
|
,VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM
|
|
|
|
,VK_FORMAT_G16_B16R16_2PLANE_420_UNORM
|
|
|
|
,VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM
|
|
|
|
,VK_FORMAT_G16_B16R16_2PLANE_422_UNORM
|
|
|
|
,VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM
|
|
|
|
};
|
|
|
|
#define numYcbcrConversionRequiredFormats (sizeof(ycbcrConversionRequiredFormats)/sizeof(VkFormat))
|
|
|
|
|
2019-09-29 20:53:08 +02:00
|
|
|
uint32_t supported = 0;
|
|
|
|
for(uint32_t c = 0; c < numSupportedFormats; ++c)
|
2019-04-22 15:58:27 +02:00
|
|
|
{
|
2019-09-29 20:53:08 +02:00
|
|
|
if(format == supportedFormats[c])
|
2019-04-22 15:58:27 +02:00
|
|
|
{
|
2019-09-29 20:53:08 +02:00
|
|
|
supported = 1;
|
|
|
|
break;
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-29 20:53:08 +02:00
|
|
|
if(!supported)
|
|
|
|
{
|
|
|
|
return VK_ERROR_FORMAT_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
2019-04-22 15:58:27 +02:00
|
|
|
pImageFormatProperties->maxArrayLayers = _limits.maxImageArrayLayers;
|
|
|
|
|
|
|
|
pImageFormatProperties->maxExtent.width = 1;
|
|
|
|
pImageFormatProperties->maxExtent.height = 1;
|
|
|
|
pImageFormatProperties->maxExtent.depth = 1;
|
|
|
|
|
|
|
|
pImageFormatProperties->sampleCounts = _limits.framebufferColorSampleCounts;
|
|
|
|
|
|
|
|
if(type == VK_IMAGE_TYPE_1D)
|
|
|
|
{
|
|
|
|
pImageFormatProperties->maxExtent.width = _limits.maxImageDimension1D;
|
|
|
|
pImageFormatProperties->maxMipLevels = ulog2(_limits.maxImageDimension1D) + 1;
|
|
|
|
}
|
|
|
|
else if(type == VK_IMAGE_TYPE_2D)
|
|
|
|
{
|
|
|
|
pImageFormatProperties->maxExtent.width = _limits.maxImageDimension2D;
|
|
|
|
pImageFormatProperties->maxExtent.height = _limits.maxImageDimension2D;
|
|
|
|
pImageFormatProperties->maxMipLevels = ulog2(_limits.maxImageDimension2D) + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pImageFormatProperties->maxExtent.width = _limits.maxImageDimension3D;
|
|
|
|
pImageFormatProperties->maxExtent.height = _limits.maxImageDimension3D;
|
|
|
|
pImageFormatProperties->maxExtent.depth = _limits.maxImageDimension3D;
|
|
|
|
pImageFormatProperties->maxMipLevels = ulog2(_limits.maxImageDimension3D) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ycbcrConversionRequired = 0;
|
|
|
|
|
|
|
|
for(uint32_t c = 0; c < numYcbcrConversionRequiredFormats; ++c)
|
|
|
|
{
|
|
|
|
if(format == ycbcrConversionRequiredFormats[c])
|
|
|
|
{
|
|
|
|
ycbcrConversionRequired = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ycbcrConversionRequired ||
|
|
|
|
tiling == VK_IMAGE_TILING_LINEAR ||
|
|
|
|
type != VK_IMAGE_TYPE_2D ||
|
|
|
|
flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT ||
|
|
|
|
flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT
|
|
|
|
)
|
|
|
|
{
|
|
|
|
pImageFormatProperties->sampleCounts = VK_SAMPLE_COUNT_1_BIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO real max size?
|
|
|
|
//2^31
|
|
|
|
pImageFormatProperties->maxResourceSize = 1<<31;
|
|
|
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkGetPhysicalDeviceImageFormatProperties2(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo,
|
|
|
|
VkImageFormatProperties2* pImageFormatProperties)
|
|
|
|
{
|
|
|
|
assert(physicalDevice);
|
|
|
|
assert(pImageFormatProperties);
|
|
|
|
assert(pImageFormatInfo);
|
|
|
|
|
2019-09-08 00:30:52 +02:00
|
|
|
//TODO handle pNext
|
2019-04-22 15:58:27 +02:00
|
|
|
|
2019-09-30 02:13:55 +02:00
|
|
|
return rpi_vkGetPhysicalDeviceImageFormatProperties(physicalDevice,
|
2019-04-22 15:58:27 +02:00
|
|
|
pImageFormatInfo->format,
|
|
|
|
pImageFormatInfo->type,
|
|
|
|
pImageFormatInfo->tiling,
|
|
|
|
pImageFormatInfo->usage,
|
|
|
|
pImageFormatInfo->flags,
|
|
|
|
&pImageFormatProperties->imageFormatProperties);
|
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkEnumerateDeviceLayerProperties(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
uint32_t* pPropertyCount,
|
|
|
|
VkLayerProperties* pProperties)
|
|
|
|
{
|
|
|
|
//deprecated, just return instance layers
|
2019-09-30 02:13:55 +02:00
|
|
|
return rpi_vkEnumerateInstanceLayerProperties(pPropertyCount, pProperties);
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkGetPhysicalDeviceFeatures2(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
VkPhysicalDeviceFeatures2* pFeatures)
|
|
|
|
{
|
|
|
|
assert(physicalDevice);
|
|
|
|
assert(pFeatures);
|
2019-09-30 02:13:55 +02:00
|
|
|
rpi_vkGetPhysicalDeviceFeatures(physicalDevice, &pFeatures->features);
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkGetPhysicalDeviceQueueFamilyProperties2(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
uint32_t* pQueueFamilyPropertyCount,
|
|
|
|
VkQueueFamilyProperties2* pQueueFamilyProperties)
|
|
|
|
{
|
2019-09-08 00:30:52 +02:00
|
|
|
assert(physicalDevice);
|
2019-09-30 02:13:55 +02:00
|
|
|
rpi_vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|