gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
12.54k stars 918 forks source link

Enable bgra8unorm-storage on mac with motenvk #4235

Closed nical closed 1 year ago

nical commented 1 year ago

Description

bgra8unorm for storage buffers is always supported on metal, so it should be possible for moltenvk to support it well. Unfortunately it looks like querying the necessary vulkan extensions causes some side effects that break the occlusion query test.

Repro steps

Remove the following branch in supports_bgra8unorm_storage in vulkan/adapter.rs:

    if cfg!(any(target_os = "macos", target_os = "ios")) {
        return false;
    }

And run the tests on CI.

Expected vs observed behavior

Expected: test occlusion_query::occlusion_query should succeed.

Observed:

--- STDOUT:              wgpu-test::wgpu-tests occlusion_query::occlusion_query ---

running 1 test
test occlusion_query::occlusion_query ... FAILED

failures:

failures:
    occlusion_query::occlusion_query

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 62 filtered out; finished in 0.12s

--- STDERR:              wgpu-test::wgpu-tests occlusion_query::occlusion_query ---
[2023-10-12T14:48:18Z INFO  wgpu_hal::vulkan::instance] Instance version: 0x4030fa
[2023-10-12T14:48:18Z INFO  wgpu_hal::vulkan::instance] Enabling debug utils
[2023-10-12T14:48:18Z INFO  wgpu_hal::vulkan::instance] Enabling device properties2
[2023-10-12T14:48:18Z INFO  wgpu_core::instance] Adapter Vulkan AdapterInfo { name: "Apple M1", vendor: 4203, device: 201327599, device_type: IntegratedGpu, driver: "MoltenVK", driver_info: "1.2.4", backend: Vulkan }
[2023-10-12T14:48:18Z INFO  wgpu_hal::vulkan::instance] GENERAL [Loader Message (0x0)]
        Inserted device layer "VK_LAYER_KHRONOS_validation" (/Users/connor/VulkanSDK/1.3.250.1/macOS/share/vulkan/explicit_layer.d/../../../lib/libVkLayer_khronos_validation.dylib)
[2023-10-12T14:48:18Z INFO  wgpu_hal::vulkan::instance]     objects: (type: INSTANCE, hndl: 0x12e80a200, name: ?)
[2023-10-12T14:48:18Z INFO  wgpu_hal::vulkan::instance] GENERAL [Loader Message (0x0)]
               Using "Apple M1" with driver: "/Users/connor/VulkanSDK/1.3.250.1/macOS/share/vulkan/icd.d/../../../lib/libMoltenVK.dylib"
[2023-10-12T14:48:18Z INFO  wgpu_hal::vulkan::instance]     objects: (type: INSTANCE, hndl: 0x12e80a200, name: ?)
[2023-10-12T14:48:18Z INFO  wgpu_hal::vulkan::instance] GENERAL [ (0x0)]
        Vulkan semaphores using MTLEvent.
[2023-10-12T14:48:18Z INFO  wgpu_hal::vulkan::instance]     objects: (type: DEVICE, hndl: 0x1518ea018, name: ?)
[2023-10-12T14:48:18Z INFO  wgpu_hal::vulkan::instance] GENERAL [ (0x0)]
        Created VkDevice to run on GPU Apple M1 with the following 5 Vulkan extensions enabled:
            VK_KHR_portability_subset v1
            VK_KHR_swapchain v70
            VK_KHR_swapchain_mutable_format v1
            VK_EXT_image_robustness v1
            VK_EXT_robustness2 v1
[2023-10-12T14:48:18Z INFO  wgpu_hal::vulkan::instance]     objects: (type: DEVICE, hndl: 0x1518ea018, name: ?)
thread 'occlusion_query::occlusion_query' panicked at 'assertion failed: `(left != right)`
  left: `0`,
 right: `0`', tests/tests/occlusion_query/mod.rs:124:9

Extra materials Screenshots to help explain your problem. Validation logs can be attached in case there are warnings and errors. Zip-compressed API traces and GPU captures can also land here.

Platform

Mac aarch64 with moltenvk (vulkan backend)

teoxoy commented 1 year ago

Is this consistently reproducible? I remember occlusion_query::occlusion_query being flakey on MoltenVK.

nical commented 1 year ago

I retriggered it only a few times in the bgra8unorm-storage PR but it failed consistently, while I didn't see it fail on a couple of currently other open PRs.

nical commented 1 year ago

The failure was indeed flacky and maybe not related to bgra8unorm-storage so it was reenabled with moltenvk before landing #4228.