diff --git a/driver/common.c b/driver/common.c index b4a4eee..62ec662 100644 --- a/driver/common.c +++ b/driver/common.c @@ -46,8 +46,6 @@ uint32_t getFormatBpp(VkFormat f) case VK_FORMAT_R64_SINT: case VK_FORMAT_R64_SFLOAT: case VK_FORMAT_D32_SFLOAT_S8_UINT: //padded to 64 - case VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16: - case VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16: return 64; case VK_FORMAT_R8G8B8_UNORM: //padded to 32 case VK_FORMAT_R8G8B8A8_UNORM: @@ -112,8 +110,6 @@ uint32_t getFormatBpp(VkFormat f) case VK_FORMAT_X8_D24_UNORM_PACK32: case VK_FORMAT_D16_UNORM_S8_UINT: //padded to 32 case VK_FORMAT_D24_UNORM_S8_UINT: - case VK_FORMAT_R10X6G10X6_UNORM_2PACK16: - case VK_FORMAT_R12X4G12X4_UNORM_2PACK16: return 32; case VK_FORMAT_R5G5B5A1_UNORM_PACK16: case VK_FORMAT_R4G4B4A4_UNORM_PACK16: @@ -137,8 +133,6 @@ uint32_t getFormatBpp(VkFormat f) case VK_FORMAT_R16_USCALED: case VK_FORMAT_R16_SSCALED: case VK_FORMAT_R16_UINT: - case VK_FORMAT_R10X6_UNORM_PACK16: - case VK_FORMAT_R12X4_UNORM_PACK16: return 16; case VK_FORMAT_R8_UNORM: case VK_FORMAT_R8_SINT: @@ -717,6 +711,41 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties( assert(physicalDevice); assert(pImageFormatProperties); + 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)) + for(uint32_t c = 0; c < numUnsupportedFormats; ++c) { if(format == unsupportedFormats[c]) @@ -731,30 +760,51 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties( 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); + 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); + 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); + 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 = 0x7fffffff; - - pImageFormatProperties->sampleCounts = _limits.framebufferColorSampleCounts; + pImageFormatProperties->maxResourceSize = 1<<31; return VK_SUCCESS; } @@ -1236,6 +1286,26 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2( assert(physicalDevice); assert(pProperties); vkGetPhysicalDeviceProperties(physicalDevice, &pProperties->properties); + + if(pProperties->pNext) + { + VkPhysicalDeviceDriverPropertiesKHR* ptr = pProperties->pNext; + if(ptr->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR) + { + //TODO apparently can't expose my own ID :( + //has to be "known" + ptr->driverID = VK_DRIVER_ID_MESA_RADV_KHR; + 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; + } + } } VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2( diff --git a/driver/device.c b/driver/device.c index 9c8cd9c..2d31682 100644 --- a/driver/device.c +++ b/driver/device.c @@ -117,6 +117,11 @@ VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties( *pPropertyCount = elementsWritten; + if(arraySize < numDeviceExtensions) + { + return VK_INCOMPLETE; + } + return VK_SUCCESS; } diff --git a/driver/sync.c b/driver/sync.c index ab2aafa..a27c7bb 100644 --- a/driver/sync.c +++ b/driver/sync.c @@ -148,7 +148,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier( { _image* i = pImageMemoryBarriers[c].image; - assert(i->layout == pImageMemoryBarriers[c].oldLayout || i->layout == VK_IMAGE_LAYOUT_UNDEFINED); + //assert(i->layout == pImageMemoryBarriers[c].oldLayout || i->layout == VK_IMAGE_LAYOUT_UNDEFINED); if(srcStageMask & VK_PIPELINE_STAGE_TRANSFER_BIT && pImageMemoryBarriers[c].srcAccessMask & VK_ACCESS_TRANSFER_WRITE_BIT && diff --git a/driver/vkCaps.h b/driver/vkCaps.h index a4387f4..f8c5dfd 100644 --- a/driver/vkCaps.h +++ b/driver/vkCaps.h @@ -254,6 +254,10 @@ static VkExtensionProperties deviceExtensions[] = { .extensionName = "VK_EXT_debug_marker", .specVersion = 4 + }, + { + .extensionName = "VK_KHR_driver_properties", + .specVersion = 1 } }; #define numDeviceExtensions (sizeof(deviceExtensions) / sizeof(VkExtensionProperties)) @@ -364,6 +368,12 @@ static VkFormat unsupportedFormats[] = VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM, VK_FORMAT_G16_B16R16_2PLANE_422_UNORM, VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM, + VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16, + VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16, + VK_FORMAT_R10X6G10X6_UNORM_2PACK16, + VK_FORMAT_R12X4G12X4_UNORM_2PACK16, + VK_FORMAT_R10X6_UNORM_PACK16, + VK_FORMAT_R12X4_UNORM_PACK16, VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG, //pvrtc formats VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG, VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG,