1
0
Fork 0
forked from wry/wry

render: implement a vulkan renderer

This commit is contained in:
Julian Orth 2024-02-03 15:19:20 +01:00
parent 4ba8550da8
commit cf332e8436
66 changed files with 4287 additions and 239 deletions

View file

@ -15,7 +15,7 @@ use {
timer::Timer,
video::{
connector_type::{ConnectorType, CON_UNKNOWN},
Connector, DrmDevice, Mode,
Connector, DrmDevice, GfxApi, Mode,
},
Axis, Direction, ModifiedKeySym, PciId, Workspace,
},
@ -506,6 +506,10 @@ impl Client {
self.send(&ClientMessage::MakeRenderDevice { device });
}
pub fn set_gfx_api(&self, device: Option<DrmDevice>, api: GfxApi) {
self.send(&ClientMessage::SetGfxApi { device, api });
}
pub fn connector_connected(&self, connector: Connector) -> bool {
let res = self.send_with_response(&ClientMessage::ConnectorConnected { connector });
get_response!(res, false, ConnectorConnected { connected });

View file

@ -5,7 +5,7 @@ use {
logging::LogLevel,
theme::{colors::Colorable, sized::Resizable, Color},
timer::Timer,
video::{connector_type::ConnectorType, Connector, DrmDevice},
video::{connector_type::ConnectorType, Connector, DrmDevice, GfxApi},
Axis, Direction, PciId, Workspace,
},
bincode::{BorrowDecode, Decode, Encode},
@ -334,6 +334,10 @@ pub enum ClientMessage<'a> {
device: InputDevice,
enabled: bool,
},
SetGfxApi {
device: Option<DrmDevice>,
api: GfxApi,
},
}
#[derive(Encode, Decode, Debug)]

View file

@ -362,4 +362,30 @@ impl DrmDevice {
pub fn make_render_device(self) {
get!().make_render_device(self);
}
/// Sets the preferred graphics API for this device.
///
/// If the API cannot be used, the compositor will try other APIs.
pub fn set_gfx_api(self, gfx_api: GfxApi) {
get!().set_gfx_api(Some(self), gfx_api);
}
}
/// A graphics API.
#[non_exhaustive]
#[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub enum GfxApi {
OpenGl,
Vulkan,
}
/// Sets the default graphics API.
///
/// If the API cannot be used, the compositor will try other APIs.
///
/// This setting can be overwritten per-device with [DrmDevice::set_gfx_api].
///
/// This call has no effect on devices that have already been initialized.
pub fn set_gfx_api(gfx_api: GfxApi) {
get!().set_gfx_api(None, gfx_api);
}