Gfx: Should have a way of telling whether backend is supported

Created on 28 May 2019  路  2Comments  路  Source: gfx-rs/gfx

Using latest cargo release of gfx (0.2)

I'm testing vulkan backend in an old laptop with onboard Intel graphics - therefore no Vulkan support. When calling instance.enumerate_adapters, it will panic with Unable to enumerate adapters: ERROR_INITIALIZATION_FAILED.
The problems are:

  1. There is no way to tell whether the backend is supported (without using any external tools) before calling the function.
  2. The function panics instead of returning a result, therefore one can't recover from the error as easily.

By addressing either one of these issues, an application could switch between backends if it detects that the default backend is unsupported without having to unwind panics (which is slow and not ergonomic), but the best would be having both these issues addressed.

I'm new to gfx so please tell me if there's anything that I'm missing.

Vulkan request contributor-friendly bug

All 2 comments

I think we can get away with simply returning an empty Vec, plus logging the error code in this case. There isn't much value in switching that API entry point to return a Result<>, I think.

Outline for completion:

  1. Check for successful completion of Vulkan's raw enumerate_adapters call here https://github.com/gfx-rs/gfx/blob/129da5cb3b778ba399a02155246cb7d9bb96d83f/src/backend/vulkan/src/lib.rs#L430
  2. If not successful, return an empty Vec
  3. Make sure that this function doesn't have other opportunities for panic that are unrecoverable in this context and instead just returns an empty vec
  4. Look through the other backends' enumerate_adapters implementations and ensure the same thing as in 3

Feel free to ping me on GitHub, Discord, or in our Gitter channel (https://gitter.im/gfx-rs/gfx) if you need help :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kvark picture kvark  路  5Comments

djcsdy picture djcsdy  路  4Comments

seivan picture seivan  路  4Comments

grovesNL picture grovesNL  路  3Comments

Fluci picture Fluci  路  5Comments