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

[vulkano-util] Add option to choose surface by formats #2441

Open
rauba-code opened this issue Dec 31, 2023 · 1 comment
Open

[vulkano-util] Add option to choose surface by formats #2441

rauba-code opened this issue Dec 31, 2023 · 1 comment

Comments

@rauba-code
Copy link
Contributor

rauba-code commented Dec 31, 2023

  • Version of vulkano: master (d08d9f)

Issue

Hello,

I'd like to raise a problem arising when using vulkano-util with window surface creation. Current implementation takes the first surface from the list when creating Window instance (see: https://github.com/vulkano-rs/vulkano/blob/d08d9f587da6d2bbef2f1857e6685c6ba590d5c5/vulkano-util/src/renderer.rs#L91C1-L95C16) which may not be optimal when rendering R8G8B8A8_UNORM-formatted texels to the screen (requires additional format conversions that may produce suboptimal results, especially with color samplers and more complex graphics pipelines).

The list of available surface formats depends on the device and display manager (X, Wayland or other). I tested on 2 Linux machines and an Apple one. All configurations show different surface formats in the list, the first of them being B8G8R8A8_SRGB, R8B8B8A8_SRGB or even HDR-related for Apple ones.

Thus, I am thinking if a user-defined function would help to choose an available surface format. Alternatives might exist, though. Thank you

EDIT 2024-01-04: I have managed to make a workaround in my project with setting mutable swapchain format where the default one is provided by the window (say, {format}_SRGB and the alternative view is {format}_UNORM, while handling all the possible image formats. The graphics pipeline must be handled in {format}_UNORM for correct rendering. Although it needs an unnecessary khr_swapchain_mutable_format device extension and this issue is still relevant.

@hakolao
Copy link
Contributor

hakolao commented Feb 20, 2024

You can set the format using the function swapchain_create_info_modify:

    let _id = windows.create_window(
        &event_loop,
        &context,
        &WindowDescriptor::default(),
        |s| {
            s.image_format = YOUR_FORMAT
        },
    );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants