gfx-api: add GfxApi
This commit is contained in:
parent
b604192bf0
commit
ca6e3891af
15 changed files with 72 additions and 61 deletions
|
|
@ -9,7 +9,7 @@ use {
|
||||||
drm_feedback::DrmFeedback,
|
drm_feedback::DrmFeedback,
|
||||||
fixed::Fixed,
|
fixed::Fixed,
|
||||||
format::Format,
|
format::Format,
|
||||||
gfx_api::{GfxFramebuffer, SyncFile},
|
gfx_api::{GfxApi, GfxFramebuffer, SyncFile},
|
||||||
ifs::{
|
ifs::{
|
||||||
wl_output::OutputId,
|
wl_output::OutputId,
|
||||||
wl_seat::{
|
wl_seat::{
|
||||||
|
|
@ -28,7 +28,7 @@ use {
|
||||||
HDMI_EOTF_TRADITIONAL_GAMMA_SDR,
|
HDMI_EOTF_TRADITIONAL_GAMMA_SDR,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
jay_config::{input::SwitchEvent, video::GfxApi},
|
jay_config::input::SwitchEvent,
|
||||||
linearize::Linearize,
|
linearize::Linearize,
|
||||||
std::{
|
std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ use {
|
||||||
drm_feedback::DrmFeedback,
|
drm_feedback::DrmFeedback,
|
||||||
edid::{CtaDataBlock, Descriptor, EdidExtension},
|
edid::{CtaDataBlock, Descriptor, EdidExtension},
|
||||||
format::{Format, XRGB8888},
|
format::{Format, XRGB8888},
|
||||||
gfx_api::{GfxContext, GfxFramebuffer, SyncFile},
|
gfx_api::{GfxApi, GfxContext, GfxFramebuffer, SyncFile},
|
||||||
ifs::{
|
ifs::{
|
||||||
wl_output::OutputId,
|
wl_output::OutputId,
|
||||||
wp_presentation_feedback::{KIND_HW_COMPLETION, KIND_VSYNC, KIND_ZERO_COPY},
|
wp_presentation_feedback::{KIND_HW_COMPLETION, KIND_VSYNC, KIND_ZERO_COPY},
|
||||||
|
|
@ -57,7 +57,6 @@ use {
|
||||||
bstr::{BString, ByteSlice},
|
bstr::{BString, ByteSlice},
|
||||||
indexmap::{IndexSet, indexset},
|
indexmap::{IndexSet, indexset},
|
||||||
isnt::std_1::collections::IsntHashMapExt,
|
isnt::std_1::collections::IsntHashMapExt,
|
||||||
jay_config::video::GfxApi,
|
|
||||||
std::{
|
std::{
|
||||||
cell::{Cell, OnceCell, RefCell},
|
cell::{Cell, OnceCell, RefCell},
|
||||||
collections::hash_map::Entry,
|
collections::hash_map::Entry,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@ use {
|
||||||
cmm::cmm_primaries::Primaries,
|
cmm::cmm_primaries::Primaries,
|
||||||
fixed::Fixed,
|
fixed::Fixed,
|
||||||
format::{Format, XRGB8888},
|
format::{Format, XRGB8888},
|
||||||
gfx_api::{AcquireSync, GfxContext, GfxError, GfxFramebuffer, GfxTexture, ReleaseSync},
|
gfx_api::{
|
||||||
|
AcquireSync, GfxApi, GfxContext, GfxError, GfxFramebuffer, GfxTexture, ReleaseSync,
|
||||||
|
},
|
||||||
ifs::wl_output::OutputId,
|
ifs::wl_output::OutputId,
|
||||||
state::State,
|
state::State,
|
||||||
time::Time,
|
time::Time,
|
||||||
|
|
@ -57,7 +59,6 @@ use {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ahash::AHashMap,
|
ahash::AHashMap,
|
||||||
jay_config::video::GfxApi,
|
|
||||||
std::{
|
std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ use {
|
||||||
ei::ei_client::EiClients,
|
ei::ei_client::EiClients,
|
||||||
forker,
|
forker,
|
||||||
format::XRGB8888,
|
format::XRGB8888,
|
||||||
|
gfx_api::GfxApi,
|
||||||
globals::Globals,
|
globals::Globals,
|
||||||
ifs::{
|
ifs::{
|
||||||
head_management::{
|
head_management::{
|
||||||
|
|
@ -81,11 +82,7 @@ use {
|
||||||
},
|
},
|
||||||
ahash::AHashSet,
|
ahash::AHashSet,
|
||||||
forker::ForkerProxy,
|
forker::ForkerProxy,
|
||||||
jay_config::{
|
jay_config::{_private::DEFAULT_SEAT_NAME, video::Transform, workspace::WorkspaceDisplayOrder},
|
||||||
_private::DEFAULT_SEAT_NAME,
|
|
||||||
video::{GfxApi, Transform},
|
|
||||||
workspace::WorkspaceDisplayOrder,
|
|
||||||
},
|
|
||||||
std::{
|
std::{
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
env,
|
env,
|
||||||
|
|
|
||||||
|
|
@ -954,6 +954,9 @@ impl ConfigProxyHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_set_gfx_api(&self, device: Option<DrmDevice>, api: GfxApi) -> Result<(), CphError> {
|
fn handle_set_gfx_api(&self, device: Option<DrmDevice>, api: GfxApi) -> Result<(), CphError> {
|
||||||
|
let Ok(api) = api.try_into() else {
|
||||||
|
return Err(CphError::UnknownGfxApi(api));
|
||||||
|
};
|
||||||
match device {
|
match device {
|
||||||
Some(dev) => self.get_drm_device(dev)?.dev.set_gfx_api(api),
|
Some(dev) => self.get_drm_device(dev)?.dev.set_gfx_api(api),
|
||||||
_ => self.state.default_gfx_api.set(api),
|
_ => self.state.default_gfx_api.set(api),
|
||||||
|
|
@ -3532,6 +3535,8 @@ enum CphError {
|
||||||
UnknownBlendSpace(ConfigBlendSpace),
|
UnknownBlendSpace(ConfigBlendSpace),
|
||||||
#[error("Unknown bar position {0:?}")]
|
#[error("Unknown bar position {0:?}")]
|
||||||
UnknownBarPosition(BarPosition),
|
UnknownBarPosition(BarPosition),
|
||||||
|
#[error("Unknown gfx API {0:?}")]
|
||||||
|
UnknownGfxApi(GfxApi),
|
||||||
}
|
}
|
||||||
|
|
||||||
trait WithRequestName {
|
trait WithRequestName {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@ use {
|
||||||
},
|
},
|
||||||
ahash::AHashMap,
|
ahash::AHashMap,
|
||||||
indexmap::{IndexMap, IndexSet},
|
indexmap::{IndexMap, IndexSet},
|
||||||
jay_config::video::{GfxApi, Transform},
|
jay_config::video::{GfxApi as ConfigGfxApi, Transform},
|
||||||
|
linearize::Linearize,
|
||||||
std::{
|
std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
cell::Cell,
|
cell::Cell,
|
||||||
|
|
@ -33,6 +34,51 @@ use {
|
||||||
uapi::OwnedFd,
|
uapi::OwnedFd,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Linearize)]
|
||||||
|
pub enum GfxApi {
|
||||||
|
OpenGl,
|
||||||
|
Vulkan,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<ConfigGfxApi> for GfxApi {
|
||||||
|
type Error = ();
|
||||||
|
|
||||||
|
fn try_from(value: ConfigGfxApi) -> Result<Self, Self::Error> {
|
||||||
|
let v = match value {
|
||||||
|
ConfigGfxApi::OpenGl => GfxApi::OpenGl,
|
||||||
|
ConfigGfxApi::Vulkan => GfxApi::Vulkan,
|
||||||
|
_ => return Err(()),
|
||||||
|
};
|
||||||
|
Ok(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<ConfigGfxApi> for GfxApi {
|
||||||
|
fn into(self) -> ConfigGfxApi {
|
||||||
|
match self {
|
||||||
|
GfxApi::OpenGl => ConfigGfxApi::OpenGl,
|
||||||
|
GfxApi::Vulkan => ConfigGfxApi::Vulkan,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GfxApi {
|
||||||
|
pub fn to_str(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
GfxApi::OpenGl => "OpenGl",
|
||||||
|
GfxApi::Vulkan => "Vulkan",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_str_lossy(s: &str) -> Option<Self> {
|
||||||
|
match &*s.to_ascii_lowercase() {
|
||||||
|
"opengl" => Some(Self::OpenGl),
|
||||||
|
"vulkan" => Some(Self::Vulkan),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub enum GfxApiOpt {
|
pub enum GfxApiOpt {
|
||||||
Sync,
|
Sync,
|
||||||
FillRect(FillRect),
|
FillRect(FillRect),
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,12 @@ pub use vulkan::create_vulkan_allocator;
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
async_engine::AsyncEngine,
|
async_engine::AsyncEngine,
|
||||||
gfx_api::{GfxContext, GfxError},
|
gfx_api::{GfxApi, GfxContext, GfxError},
|
||||||
io_uring::IoUring,
|
io_uring::IoUring,
|
||||||
pr_caps::PrCapsThread,
|
pr_caps::PrCapsThread,
|
||||||
utils::errorfmt::ErrorFmt,
|
utils::errorfmt::ErrorFmt,
|
||||||
video::drm::Drm,
|
video::drm::Drm,
|
||||||
},
|
},
|
||||||
jay_config::video::GfxApi,
|
|
||||||
std::rc::Rc,
|
std::rc::Rc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -57,6 +56,5 @@ fn create_gfx_context_(
|
||||||
match api {
|
match api {
|
||||||
GfxApi::OpenGl => gl::create_gfx_context(drm, software),
|
GfxApi::OpenGl => gl::create_gfx_context(drm, software),
|
||||||
GfxApi::Vulkan => vulkan::create_graphics_context(eng, ring, drm, caps_thread, software),
|
GfxApi::Vulkan => vulkan::create_graphics_context(eng, ring, drm, caps_thread, software),
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ use {
|
||||||
cpu_worker::CpuWorker,
|
cpu_worker::CpuWorker,
|
||||||
format::{Format, XRGB8888},
|
format::{Format, XRGB8888},
|
||||||
gfx_api::{
|
gfx_api::{
|
||||||
AsyncShmGfxTexture, BufferResvUser, GfxBlendBuffer, GfxContext, GfxError, GfxFormat,
|
AsyncShmGfxTexture, BufferResvUser, GfxApi, GfxBlendBuffer, GfxContext, GfxError,
|
||||||
GfxFramebuffer, GfxImage, GfxInternalFramebuffer, ResetStatus, ShmGfxTexture,
|
GfxFormat, GfxFramebuffer, GfxImage, GfxInternalFramebuffer, ResetStatus,
|
||||||
|
ShmGfxTexture,
|
||||||
},
|
},
|
||||||
gfx_apis::gl::{
|
gfx_apis::gl::{
|
||||||
GfxGlState, RenderError, Texture,
|
GfxGlState, RenderError, Texture,
|
||||||
|
|
@ -24,7 +25,6 @@ use {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ahash::AHashMap,
|
ahash::AHashMap,
|
||||||
jay_config::video::GfxApi,
|
|
||||||
linearize::{Linearize, StaticMap, static_map},
|
linearize::{Linearize, StaticMap, static_map},
|
||||||
std::{
|
std::{
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ use {
|
||||||
cpu_worker::{CpuWorker, jobs::read_write::ReadWriteJobError},
|
cpu_worker::{CpuWorker, jobs::read_write::ReadWriteJobError},
|
||||||
format::Format,
|
format::Format,
|
||||||
gfx_api::{
|
gfx_api::{
|
||||||
AsyncShmGfxTexture, GfxBlendBuffer, GfxBuffer, GfxContext, GfxError, GfxFormat,
|
AsyncShmGfxTexture, GfxApi, GfxBlendBuffer, GfxBuffer, GfxContext, GfxError, GfxFormat,
|
||||||
GfxImage, GfxInternalFramebuffer, GfxStagingBuffer, GfxTexture, ResetStatus,
|
GfxImage, GfxInternalFramebuffer, GfxStagingBuffer, GfxTexture, ResetStatus,
|
||||||
STAGING_DOWNLOAD, STAGING_UPLOAD, ShmGfxTexture, StagingBufferUsecase,
|
STAGING_DOWNLOAD, STAGING_UPLOAD, ShmGfxTexture, StagingBufferUsecase,
|
||||||
},
|
},
|
||||||
|
|
@ -51,7 +51,6 @@ use {
|
||||||
ahash::AHashMap,
|
ahash::AHashMap,
|
||||||
ash::vk,
|
ash::vk,
|
||||||
gpu_alloc::{AllocationError, MapError},
|
gpu_alloc::{AllocationError, MapError},
|
||||||
jay_config::video::GfxApi,
|
|
||||||
log::Level,
|
log::Level,
|
||||||
std::{
|
std::{
|
||||||
cell::Cell,
|
cell::Cell,
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,17 @@ use {
|
||||||
client::{Client, ClientError},
|
client::{Client, ClientError},
|
||||||
compositor::MAX_EXTENTS,
|
compositor::MAX_EXTENTS,
|
||||||
format::named_formats,
|
format::named_formats,
|
||||||
|
gfx_api::GfxApi,
|
||||||
ifs::wl_output,
|
ifs::wl_output,
|
||||||
leaks::Tracker,
|
leaks::Tracker,
|
||||||
object::{Object, Version},
|
object::{Object, Version},
|
||||||
scale::Scale,
|
scale::Scale,
|
||||||
state::{ConnectorData, DrmDevData, OutputData, State},
|
state::{ConnectorData, DrmDevData, OutputData, State},
|
||||||
tree::{OutputNode, TearingMode, VrrMode},
|
tree::{OutputNode, TearingMode, VrrMode},
|
||||||
utils::{errorfmt::ErrorFmt, gfx_api_ext::GfxApiExt, transform_ext::TransformExt},
|
utils::{errorfmt::ErrorFmt, transform_ext::TransformExt},
|
||||||
wire::{JayRandrId, jay_randr::*},
|
wire::{JayRandrId, jay_randr::*},
|
||||||
},
|
},
|
||||||
jay_config::video::{
|
jay_config::video::{TearingMode as ConfigTearingMode, Transform, VrrMode as ConfigVrrMode},
|
||||||
GfxApi, TearingMode as ConfigTearingMode, Transform, VrrMode as ConfigVrrMode,
|
|
||||||
},
|
|
||||||
linearize::LinearizeExt,
|
linearize::LinearizeExt,
|
||||||
std::rc::Rc,
|
std::rc::Rc,
|
||||||
thiserror::Error,
|
thiserror::Error,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use {
|
||||||
format::{ARGB8888, Format, XRGB8888},
|
format::{ARGB8888, Format, XRGB8888},
|
||||||
gfx_api::{
|
gfx_api::{
|
||||||
AcquireSync, AsyncShmGfxTexture, AsyncShmGfxTextureCallback, CopyTexture, FillRect,
|
AcquireSync, AsyncShmGfxTexture, AsyncShmGfxTextureCallback, CopyTexture, FillRect,
|
||||||
FramebufferRect, GfxApiOpt, GfxBlendBuffer, GfxContext, GfxError, GfxFormat,
|
FramebufferRect, GfxApi, GfxApiOpt, GfxBlendBuffer, GfxContext, GfxError, GfxFormat,
|
||||||
GfxFramebuffer, GfxImage, GfxInternalFramebuffer, GfxStagingBuffer, GfxTexture,
|
GfxFramebuffer, GfxImage, GfxInternalFramebuffer, GfxStagingBuffer, GfxTexture,
|
||||||
GfxWriteModifier, PendingShmTransfer, ReleaseSync, ResetStatus, ShmGfxTexture,
|
GfxWriteModifier, PendingShmTransfer, ReleaseSync, ResetStatus, ShmGfxTexture,
|
||||||
ShmMemory, SyncFile,
|
ShmMemory, SyncFile,
|
||||||
|
|
@ -17,7 +17,6 @@ use {
|
||||||
},
|
},
|
||||||
ahash::AHashMap,
|
ahash::AHashMap,
|
||||||
indexmap::IndexSet,
|
indexmap::IndexSet,
|
||||||
jay_config::video::GfxApi,
|
|
||||||
std::{
|
std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
gfx_api::{GfxFormat, cross_intersect_formats},
|
gfx_api::{GfxApi, GfxFormat, cross_intersect_formats},
|
||||||
gfx_apis::create_gfx_context,
|
gfx_apis::create_gfx_context,
|
||||||
ifs::wl_seat::POINTER,
|
ifs::wl_seat::POINTER,
|
||||||
object::Version,
|
object::Version,
|
||||||
|
|
@ -46,7 +46,6 @@ use {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ahash::AHashMap,
|
ahash::AHashMap,
|
||||||
jay_config::video::GfxApi,
|
|
||||||
std::{
|
std::{
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
ops::Deref,
|
ops::Deref,
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ use {
|
||||||
forker::ForkerProxy,
|
forker::ForkerProxy,
|
||||||
format::Format,
|
format::Format,
|
||||||
gfx_api::{
|
gfx_api::{
|
||||||
AcquireSync, AlphaMode, BufferResv, GfxBlendBuffer, GfxContext, GfxError,
|
AcquireSync, AlphaMode, BufferResv, GfxApi, GfxBlendBuffer, GfxContext, GfxError,
|
||||||
GfxFramebuffer, GfxTexture, PendingShmTransfer, ReleaseSync, STAGING_DOWNLOAD,
|
GfxFramebuffer, GfxTexture, PendingShmTransfer, ReleaseSync, STAGING_DOWNLOAD,
|
||||||
SampleRect, SyncFile,
|
SampleRect, SyncFile,
|
||||||
},
|
},
|
||||||
|
|
@ -135,12 +135,7 @@ use {
|
||||||
},
|
},
|
||||||
ahash::AHashMap,
|
ahash::AHashMap,
|
||||||
bstr::ByteSlice,
|
bstr::ByteSlice,
|
||||||
jay_config::{
|
jay_config::{PciId, video::Transform, window::TileState, workspace::WorkspaceDisplayOrder},
|
||||||
PciId,
|
|
||||||
video::{GfxApi, Transform},
|
|
||||||
window::TileState,
|
|
||||||
workspace::WorkspaceDisplayOrder,
|
|
||||||
},
|
|
||||||
std::{
|
std::{
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
fmt::{Debug, Formatter},
|
fmt::{Debug, Formatter},
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ pub mod event_listener;
|
||||||
pub mod fdcloser;
|
pub mod fdcloser;
|
||||||
pub mod free_list;
|
pub mod free_list;
|
||||||
pub mod geometric_decay;
|
pub mod geometric_decay;
|
||||||
pub mod gfx_api_ext;
|
|
||||||
pub mod hash_map_ext;
|
pub mod hash_map_ext;
|
||||||
pub mod line_logger;
|
pub mod line_logger;
|
||||||
pub mod linkedlist;
|
pub mod linkedlist;
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
use jay_config::video::GfxApi;
|
|
||||||
|
|
||||||
pub trait GfxApiExt: Sized {
|
|
||||||
fn to_str(&self) -> &'static str;
|
|
||||||
|
|
||||||
fn from_str_lossy(s: &str) -> Option<Self>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GfxApiExt for GfxApi {
|
|
||||||
fn to_str(&self) -> &'static str {
|
|
||||||
match self {
|
|
||||||
GfxApi::OpenGl => "OpenGl",
|
|
||||||
GfxApi::Vulkan => "Vulkan",
|
|
||||||
_ => "unknown",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn from_str_lossy(s: &str) -> Option<Self> {
|
|
||||||
match &*s.to_ascii_lowercase() {
|
|
||||||
"opengl" => Some(Self::OpenGl),
|
|
||||||
"vulkan" => Some(Self::Vulkan),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue