Error from validation layers in vulkan backend in vk_utils_caps_builder
ilyachastikov opened this issue · comments
I've got the error [VUID-vkGetPhysicalDeviceFormatProperties-format-parameter] from validation layers in the vulkan backend in vk_utils_caps_builder function. After this issue investigating I've found out that source of this problem is checking VK_FORMAT_PVRTC1 formats. Thay are treated as invalid. I've wrote the request to https://github.com/KhronosGroup/Vulkan-ValidationLayers and got the answer:
this error occurs because you don't have the VK_IMG_format_pvrtc enabled. Without enabling an extensions, the use of extended enums (such as VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG) are invalid according the spec
Because VK_IMG_format_pvrtc is not used in The Forge I think that fixed version of vk_utils_caps_builder should be:
inline void vk_utils_caps_builder(Renderer* pRenderer)
{
pRenderer->pCapBits = (GPUCapBits*)tf_calloc(1, sizeof(GPUCapBits));
for (uint32_t i = 0; i < TinyImageFormat_Count; ++i) {
VkFormatProperties formatSupport;
VkFormat fmt = (VkFormat) TinyImageFormat_ToVkFormat((TinyImageFormat)i);
if(fmt == VK_FORMAT_UNDEFINED) continue;
//This code is needed because VK_IMG_format_pvrtc extension is not enabled
if (fmt >= VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG && fmt <= VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG) {
pRenderer->pCapBits->canShaderReadFrom[i] = false;
pRenderer->pCapBits->canShaderWriteTo[i] = false;
pRenderer->pCapBits->canRenderTargetWriteTo[i] = false;
continue;
}
vkGetPhysicalDeviceFormatProperties(pRenderer->mVulkan.pVkActiveGPU, fmt, &formatSupport);
pRenderer->pCapBits->canShaderReadFrom[i] =
(formatSupport.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0;
pRenderer->pCapBits->canShaderWriteTo[i] =
(formatSupport.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0;
pRenderer->pCapBits->canRenderTargetWriteTo[i] =
(formatSupport.optimalTilingFeatures &
(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) != 0;
}
}
Fixed with latest release