KhronosGroup / Vulkan-Docs

The Vulkan API Specification and related tools
Other
2.75k stars 462 forks source link

VkLogicOp with floating and sRGB color attachments #2426

Open YaaZ opened 3 weeks ago

YaaZ commented 3 weeks ago

Spec states:

Logical operations are applied only for signed and unsigned integer and normalized integer framebuffers. Logical operations are not applied to floating-point or sRGB format color attachments.

https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#framebuffer-logicop

Although for me they work for much more attachment formats, including SRGB and even SFLOAT. It's nice that they still work, but this is a spec violation and deserves to be caught by validation layers.

spencer-lunarg commented 2 weeks ago

@YaaZ I confirmed with some driver developers, yes, this is telling you that the HW will ignore any logical operations, so there is no "undefined behavior" and it is not a spec violation as it is actually very well specified what will not happen

With that, I think this is a good thing to add as a warning since I was not even aware of this case and assume others might also not as well

YaaZ commented 2 weeks ago

Ok, I got it. So you actually can use logicOp with sRGB attachments, though it must have no effect. Then this is a spec violation by my HW, because clearly, there is an effect 😃

spencer-lunarg commented 2 weeks ago

Can you tell me what driver/gpu you are seeing this effect on? Also which exact format you see an effect? This seems like a lack of CTS coverage as there should be tests that this is ignored

YaaZ commented 2 weeks ago

VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Rembrandt [Radeon 680M] [1002:1681] (rev 11) Subsystem: Lenovo Device [17aa:22f2] Kernel driver in use: amdgpu

No idea about the drivers, something default for Fedora 40, but here are versions from vulkaninfo:

Vulkan Instance Version: 1.3.283 VK_LAYER_KHRONOS_validation (Khronos Validation Layer) Vulkan version 1.3.261, layer version 1 VkPhysicalDeviceProperties: apiVersion = 1.3.278 (4206870) driverVersion = 24.1.5 (100667397)

XOR logicOp worked for me at least with VK_FORMAT_B8G8R8A8_SRGB and VK_FORMAT_R32G32B32A32_SFLOAT.

spencer-lunarg commented 2 weeks ago

created https://gitlab.khronos.org/vulkan/vulkan/-/issues/3981 to track this

spencer-lunarg commented 2 weeks ago

update: was discussed and seems this might just be a driver bug, we are going to create CTS tests and make sure the drivers are doing what the spec says should happen, Thanks again for reporting this btw!

spencer-lunarg commented 2 weeks ago

CTS issue is being tracked here https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/5278

For the time being, moved to a Spec issue, if we decide to add a Validation restriction, will bring back to Validation Layer repo, but for now there is nothing actionable from the Validation Layers point of view