Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan CTS test crash because of invalid dimensions for PVRTC texture #1760

Closed
spnda opened this issue Nov 6, 2022 · 14 comments
Closed

Vulkan CTS test crash because of invalid dimensions for PVRTC texture #1760

spnda opened this issue Nov 6, 2022 · 14 comments
Labels
Bug Completed Issue has been fixed, or enhancement implemented. Metal improvement required An improvement to Metal is required to resolve this issue.

Comments

@spnda
Copy link
Collaborator

spnda commented Nov 6, 2022

This happens with MoltenVK from master and VK-GL-CTS from master on macOS 13.1 with a M1. Looks like MoltenVK reports a lot of image formats as supported in the vkGetPhysicalDeviceImageFormatProperties call even though they're not supported. Though the reason for the crash, namely Metal asserting because PVRTC_RGBA_4BPP did not have a compatible size.

From the CTS source it seems like the test generates a random image width and height, ranging somewhere between 2 and 18. It does not look like the Vulkan spec makes a requirement for the size of a PVRTC image dimensions needing to be a power of 2 or be a perfect square. The Metal docs also don't note any requirement either, though it seems like Apple GPUs have these implicit requirements in their PVRTC implementation.

Test case 'dEQP-VK.api.invariance.random'..
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G16B16G16R16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G16B16G16R16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G16B16G16R16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G16B16G16R16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G16B16G16R16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G16B16G16R16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_MEMORY_MAP_FAILED: Memory is not mapped. Call vkMapMemory() first.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B16G16R16G16_422_UNORM is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_FORMAT_NOT_SUPPORTED: VkFormat VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 is not supported on this device.
[mvk-error] VK_ERROR_MEMORY_MAP_FAILED: Memory is not mapped. Call vkMapMemory() first.
-[MTLTextureDescriptorInternal validateWithDevice:]:1344: failed assertion `Texture Descriptor Validation
MTLTextureDescriptor has a PVRTC pixel format (MTLPixelFormatPVRTC_RGBA_4BPP) set with non-square and/or non-power of two dimensions.
'
zsh: abort      ./deqp-vk
@lexaknyazev
Copy link
Member

  • Textures of all VK_FORMAT_PVRTC1_* formats must have power of two dimensions - it's an intrinsic requirement that does not depend on API used.

  • Additionally, Apple platforms require such textures to be squares.

@billhollings
Copy link
Contributor

billhollings commented Nov 17, 2022

Hmmm. I guess we should at least review what MoltenVK is reporting as supported.

We may then have to add a flag to the Vulkan portability extension to indicate whether square PVRTC dimensions is a requirement.

@spnda
Copy link
Collaborator Author

spnda commented Nov 17, 2022

  • Textures of all VK_FORMAT_PVRTC1_* formats must have power of two dimensions - it's an intrinsic requirement that does not depend on API used.

Hmm, now that I google that seems like it is true, though I'm finding conflicting information online about this. The only properly credible sources that say that PVRTC1 is power-of-two are Skia and the PVRTC2 announcement by the fact that PVRTC2 does not require power-of-two sizes. Should this maybe be raised as an issue to the Vulkan-Docs repository so that the Vulkan spec might add this requirement? Then I'd also make the change to the CTS so that it never uses a non power of two size for PVRTC1.

@billhollings
Copy link
Contributor

properly credible sources

Yeah. It's hard to find. There is surprisingly little documentation on that fact, considering it's such a definitive user restriction.

The PVRTC1 section of the Khronos Data Format Specification includes the line:

PVRTC1 images must have dimensions that are power of two values.

@lexaknyazev
Copy link
Member

This restriction is mentioned in the original OpenGL ES extension and is also present in the KDFS (as quoted above), which is normatively referenced by Vulkan. For completeness, the Vulkan extension should mention that as well.

@lexaknyazev
Copy link
Member

Another Metal restriction that applies to all PVRTC1 formats:

The compressed pixel format MTLPixelFormatPVRTC_RGB_4BPP cannot be used with MTLTextureType3D. PVRTC 3D textures are not supported.

@billhollings
Copy link
Contributor

Hmmm. I guess we should at least review what MoltenVK is reporting as supported.

This part is fixed in #1780.

@billhollings billhollings added the Metal improvement required An improvement to Metal is required to resolve this issue. label Nov 30, 2022
@spnda
Copy link
Collaborator Author

spnda commented Mar 2, 2024

With 1.3.279 the power-of-two requirement has been added as a VUID to the Vulkan specification. Would you prefer to catch the invalid usage to avoid Metal throwing an assertion, or do we just keep that as an error for anyone who uses it? I think this issue can now be closed. I have sent a PR to the conformance tests to fix the validation.

@billhollings billhollings added the Completed Issue has been fixed, or enhancement implemented. label Mar 6, 2024
@billhollings
Copy link
Contributor

With 1.3.279 the power-of-two requirement has been added as a VUID to the Vulkan specification. Would you prefer to catch the invalid usage to avoid Metal throwing an assertion, or do we just keep that as an error for anyone who uses it?

Thanks for the intel.

With Vulkan, implementations are deliberately not tasked with enforcing validation. That's the job of the Validation Layer. This approach allows implementations to avoid the extra effort and time to check everything. So, we can ignore it, and let Metal validation take care of spanking the app for not following the validation rules.

I think this issue can now be closed.

Great. Doing so now!

I have sent a PR to the conformance tests to fix the validation.

Thanks for taking care of that!

@billhollings billhollings closed this as not planned Won't fix, can't repro, duplicate, stale Mar 6, 2024
@lexaknyazev
Copy link
Member

@billhollings I suggest keeping this issue open a bit longer because:

  • The new VUIDs haven't been implemented in VVL yet.
  • Apple GPUs have an extra requirement that PVRTC1 textures must be squares. Attempting to upload a non-square PVRTC1 texture would lead to a Metal runtime failure. Ideally, this limitation should be documented as a part of Vulkan Portability initialive.

@billhollings billhollings added Completed Issue has been fixed, or enhancement implemented. and removed Completed Issue has been fixed, or enhancement implemented. labels Mar 6, 2024
@billhollings
Copy link
Contributor

@billhollings I suggest keeping this issue open a bit longer because:

  • The new VUIDs haven't been implemented in VVL yet.
  • Apple GPUs have an extra requirement that PVRTC1 textures must be squares. Attempting to upload a non-square PVRTC1 texture would lead to a Metal runtime failure. Ideally, this limitation should be documented as a part of Vulkan Portability initialive.

I'm not too bothered about the VUID implementation, because either way we have nothing to track or do for MoltenVK.

Good point about portability. We don't include VK_IMG_format_pvrtc in the current Vulkan 1.0 effort, but we will definitely have to address it in a later portability extension, which will include all MoltenVK functionality. That will show up and be tracked and addressed in CTS testing then.

So I think we're okay to leave this closed for now.

@spnda
Copy link
Collaborator Author

spnda commented Mar 14, 2024

@billhollings I had an idea about the requirement of square issues imposed by the Metal driver. What if MoltenVK would just extend the image size internally to be square to make the Metal driver happy? Or would that be too large a memory overhead to justify?

@lexaknyazev
Copy link
Member

@spnda There are multiple major issues with implicit padding:

  • Texture dimensions must be powers of 2 so, for example, 32x64 would be padded to 64x64.
  • Such padding would be incompatible with pre-existing texture coordinates unless shaders are patched at runtime.
  • PVRTC1 blocks are stored in Morton order, which makes any dimension changes non-trivial.
  • PVRTC1 blocks are not self-contained, i.e., the decoder uses information from multiple adjacent blocks to reconstruct the image.

@billhollings
Copy link
Contributor

billhollings commented Mar 19, 2024

There are multiple major issues with implicit padding

  • Presumably it would also get in the way of VkSamplerAddressMode interpretation, since the repeat, edge, and border extrapolation would be different with a different size.

@spnda Good "out of the box" thinking, nevertheless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Completed Issue has been fixed, or enhancement implemented. Metal improvement required An improvement to Metal is required to resolve this issue.
Projects
None yet
Development

No branches or pull requests

3 participants