1
0
Fork 0
forked from wry/wry

vulkan: implement software rendering

This commit is contained in:
Julian Orth 2025-07-27 21:03:18 +02:00
parent bb29303c98
commit 0a5ee8fa36
10 changed files with 140 additions and 31 deletions

View file

@ -25,13 +25,21 @@ pub fn create_gfx_context(
let mut apis = [GfxApi::OpenGl, GfxApi::Vulkan];
apis.sort_by_key(|&a| if a == api { -1 } else { a as i32 });
let mut last_err = None;
for api in apis {
let res = create_gfx_context_(eng, ring, drm, api, caps_thread);
match res {
Ok(_) => return res,
Err(e) => {
log::warn!("Could not create {:?} API: {}", api, ErrorFmt(&e));
last_err = Some(e);
for software in [false, true] {
for api in apis {
let res = create_gfx_context_(eng, ring, drm, api, caps_thread, software);
match res {
Ok(_) => {
log::info!("Created a {api:?} renderer");
if software {
log::warn!("Renderer uses software rendering");
}
return res;
}
Err(e) => {
log::warn!("Could not create {:?} API: {}", api, ErrorFmt(&e));
last_err = Some(e);
}
}
}
}
@ -44,10 +52,11 @@ fn create_gfx_context_(
drm: &Drm,
api: GfxApi,
caps_thread: Option<&PrCapsThread>,
software: bool,
) -> Result<Rc<dyn GfxContext>, GfxError> {
match api {
GfxApi::OpenGl => gl::create_gfx_context(drm),
GfxApi::Vulkan => vulkan::create_graphics_context(eng, ring, drm, caps_thread),
GfxApi::OpenGl => gl::create_gfx_context(drm, software),
GfxApi::Vulkan => vulkan::create_graphics_context(eng, ring, drm, caps_thread, software),
_ => unreachable!(),
}
}