feat(wayland): set output refreshrate to i32::MAX and instrument a bunch of functions
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -592,7 +592,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy-dmabuf"
|
name = "bevy-dmabuf"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/Schmarni-Dev/bevy-dmabuf#8c9e3af6fecc62db684130674d48c64ba4adfe1d"
|
source = "git+https://github.com/Schmarni-Dev/bevy-dmabuf#c9f2ebc100f1c9ef74383d35bcdc6c36920d2741"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ash",
|
"ash",
|
||||||
"bevy",
|
"bevy",
|
||||||
@@ -4030,7 +4030,7 @@ version = "0.7.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d"
|
checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate 1.3.1",
|
"proc-macro-crate 3.3.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn 2.0.104",
|
||||||
@@ -6717,7 +6717,7 @@ version = "0.1.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ pub struct Buffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Buffer {
|
impl Buffer {
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn new(client: &mut Client, id: ObjectId, backing: BufferBacking) -> Arc<Self> {
|
pub fn new(client: &mut Client, id: ObjectId, backing: BufferBacking) -> Arc<Self> {
|
||||||
let buffer = client.insert(
|
let buffer = client.insert(
|
||||||
id,
|
id,
|
||||||
@@ -55,6 +56,7 @@ impl Buffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the tex if it was updated
|
/// Returns the tex if it was updated
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn update_tex(
|
pub fn update_tex(
|
||||||
&self,
|
&self,
|
||||||
dmatexes: &ImportedDmatexs,
|
dmatexes: &ImportedDmatexs,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ impl Output {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
self.mode(client, self.0, Mode::Current, 2048, 2048, 0)
|
self.mode(client, self.0, Mode::Current, 2048, 2048, i32::MAX)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
self.done(client, self.0).await
|
self.done(client, self.0).await
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ impl ShmBufferBacking {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn update_tex(&self, images: &mut Assets<Image>) -> Option<Handle<Image>> {
|
pub fn update_tex(&self, images: &mut Assets<Image>) -> Option<Handle<Image>> {
|
||||||
let mut image_handle = self.image.lock();
|
let mut image_handle = self.image.lock();
|
||||||
images.remove(image_handle.id());
|
images.remove(image_handle.id());
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ pub struct ShmPool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ShmPool {
|
impl ShmPool {
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn new(fd: OwnedFd, size: i32) -> Result<Self> {
|
pub fn new(fd: OwnedFd, size: i32) -> Result<Self> {
|
||||||
let map = unsafe {
|
let map = unsafe {
|
||||||
MmapOptions::new()
|
MmapOptions::new()
|
||||||
@@ -30,6 +31,7 @@ impl ShmPool {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn data_lock(&self) -> MappedMutexGuard<RawMutex, [u8]> {
|
pub fn data_lock(&self) -> MappedMutexGuard<RawMutex, [u8]> {
|
||||||
MutexGuard::map(self.inner.lock(), |i| i.as_mut())
|
MutexGuard::map(self.inner.lock(), |i| i.as_mut())
|
||||||
}
|
}
|
||||||
@@ -37,6 +39,7 @@ impl ShmPool {
|
|||||||
|
|
||||||
impl WlShmPool for ShmPool {
|
impl WlShmPool for ShmPool {
|
||||||
/// https://wayland.app/protocols/wayland#wl_shm_pool:request:create_buffer
|
/// https://wayland.app/protocols/wayland#wl_shm_pool:request:create_buffer
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn create_buffer(
|
async fn create_buffer(
|
||||||
&self,
|
&self,
|
||||||
client: &mut Client,
|
client: &mut Client,
|
||||||
@@ -61,6 +64,7 @@ impl WlShmPool for ShmPool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// https://wayland.app/protocols/wayland#wl_shm_pool:request:resize
|
/// https://wayland.app/protocols/wayland#wl_shm_pool:request:resize
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn resize(&self, _client: &mut Client, _sender_id: ObjectId, size: i32) -> Result<()> {
|
async fn resize(&self, _client: &mut Client, _sender_id: ObjectId, size: i32) -> Result<()> {
|
||||||
let mut inner = self.inner.lock();
|
let mut inner = self.inner.lock();
|
||||||
unsafe { inner.remap(size as usize, RemapOptions::new().may_move(true))? };
|
unsafe { inner.remap(size as usize, RemapOptions::new().may_move(true))? };
|
||||||
@@ -68,6 +72,7 @@ impl WlShmPool for ShmPool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// https://wayland.app/protocols/wayland#wl_shm_pool:request:destroy
|
/// https://wayland.app/protocols/wayland#wl_shm_pool:request:destroy
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn destroy(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
|
async fn destroy(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ impl std::fmt::Debug for Surface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Surface {
|
impl Surface {
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn new(client: &Client, id: ObjectId) -> Self {
|
pub fn new(client: &Client, id: ObjectId) -> Self {
|
||||||
Surface {
|
Surface {
|
||||||
id,
|
id,
|
||||||
@@ -98,10 +99,12 @@ impl Surface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn pending_state(&self) -> parking_lot::MutexGuard<'_, DoubleBuffer<SurfaceState>> {
|
pub fn pending_state(&self) -> parking_lot::MutexGuard<'_, DoubleBuffer<SurfaceState>> {
|
||||||
self.state.lock()
|
self.state.lock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn add_commit_handler<F: Fn(&Surface, &SurfaceState) -> bool + Send + Sync + 'static>(
|
pub fn add_commit_handler<F: Fn(&Surface, &SurfaceState) -> bool + Send + Sync + 'static>(
|
||||||
&self,
|
&self,
|
||||||
handler: F,
|
handler: F,
|
||||||
@@ -110,6 +113,7 @@ impl Surface {
|
|||||||
handlers.push(Box::new(handler));
|
handlers.push(Box::new(handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn update_graphics(
|
pub fn update_graphics(
|
||||||
&self,
|
&self,
|
||||||
dmatexes: &ImportedDmatexs,
|
dmatexes: &ImportedDmatexs,
|
||||||
@@ -156,11 +160,13 @@ impl Surface {
|
|||||||
let _ = state_lock.current().clean_lock.set(());
|
let _ = state_lock.current().clean_lock.set(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn apply_material(&self, model_part: &Arc<ModelPart>) {
|
pub fn apply_material(&self, model_part: &Arc<ModelPart>) {
|
||||||
// tracing::info!("uwu applying material");
|
// tracing::info!("uwu applying material");
|
||||||
self.pending_material_applications.add_raw(model_part)
|
self.pending_material_applications.add_raw(model_part)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
fn apply_surface_materials(&self) {
|
fn apply_surface_materials(&self) {
|
||||||
let Some(mat) = self.material.get() else {
|
let Some(mat) = self.material.get() else {
|
||||||
return;
|
return;
|
||||||
@@ -171,12 +177,15 @@ impl Surface {
|
|||||||
}
|
}
|
||||||
self.pending_material_applications.clear();
|
self.pending_material_applications.clear();
|
||||||
}
|
}
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
fn mark_dirty(&self) {
|
fn mark_dirty(&self) {
|
||||||
self.state.lock().pending.clean_lock = Default::default();
|
self.state.lock().pending.clean_lock = Default::default();
|
||||||
}
|
}
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn current_state(&self) -> SurfaceState {
|
pub fn current_state(&self) -> SurfaceState {
|
||||||
self.state.lock().current().clone()
|
self.state.lock().current().clone()
|
||||||
}
|
}
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn frame_event(&self) {
|
pub fn frame_event(&self) {
|
||||||
if let Some(callback_obj) = self.frame_callback_object.lock().take() {
|
if let Some(callback_obj) = self.frame_callback_object.lock().take() {
|
||||||
let _ = self.message_sink.send(Message::Frame(callback_obj));
|
let _ = self.message_sink.send(Message::Frame(callback_obj));
|
||||||
@@ -213,6 +222,7 @@ impl Surface {
|
|||||||
}
|
}
|
||||||
impl WlSurface for Surface {
|
impl WlSurface for Surface {
|
||||||
/// https://wayland.app/protocols/wayland#wl_surface:request:attach
|
/// https://wayland.app/protocols/wayland#wl_surface:request:attach
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn attach(
|
async fn attach(
|
||||||
&self,
|
&self,
|
||||||
client: &mut Client,
|
client: &mut Client,
|
||||||
@@ -226,6 +236,7 @@ impl WlSurface for Surface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// https://wayland.app/protocols/wayland#wl_surface:request:damage
|
/// https://wayland.app/protocols/wayland#wl_surface:request:damage
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn damage(
|
async fn damage(
|
||||||
&self,
|
&self,
|
||||||
_client: &mut Client,
|
_client: &mut Client,
|
||||||
@@ -241,6 +252,7 @@ impl WlSurface for Surface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// https://wayland.app/protocols/wayland#wl_surface:request:frame
|
/// https://wayland.app/protocols/wayland#wl_surface:request:frame
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn frame(
|
async fn frame(
|
||||||
&self,
|
&self,
|
||||||
client: &mut Client,
|
client: &mut Client,
|
||||||
@@ -253,6 +265,7 @@ impl WlSurface for Surface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// https://wayland.app/protocols/wayland#wl_surface:request:set_opaque_region
|
/// https://wayland.app/protocols/wayland#wl_surface:request:set_opaque_region
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn set_opaque_region(
|
async fn set_opaque_region(
|
||||||
&self,
|
&self,
|
||||||
_client: &mut Client,
|
_client: &mut Client,
|
||||||
@@ -264,6 +277,7 @@ impl WlSurface for Surface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// https://wayland.app/protocols/wayland#wl_surface:request:set_input_region
|
/// https://wayland.app/protocols/wayland#wl_surface:request:set_input_region
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn set_input_region(
|
async fn set_input_region(
|
||||||
&self,
|
&self,
|
||||||
_client: &mut Client,
|
_client: &mut Client,
|
||||||
@@ -275,6 +289,7 @@ impl WlSurface for Surface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// https://wayland.app/protocols/wayland#wl_surface:request:commit
|
/// https://wayland.app/protocols/wayland#wl_surface:request:commit
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn commit(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
|
async fn commit(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
|
||||||
{
|
{
|
||||||
let mut lock = self.state.lock();
|
let mut lock = self.state.lock();
|
||||||
@@ -309,6 +324,7 @@ impl WlSurface for Surface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// https://wayland.app/protocols/wayland#wl_surface:request:set_buffer_transform
|
/// https://wayland.app/protocols/wayland#wl_surface:request:set_buffer_transform
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn set_buffer_transform(
|
async fn set_buffer_transform(
|
||||||
&self,
|
&self,
|
||||||
_client: &mut Client,
|
_client: &mut Client,
|
||||||
@@ -320,6 +336,7 @@ impl WlSurface for Surface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// https://wayland.app/protocols/wayland#wl_surface:request:set_buffer_scale
|
/// https://wayland.app/protocols/wayland#wl_surface:request:set_buffer_scale
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn set_buffer_scale(
|
async fn set_buffer_scale(
|
||||||
&self,
|
&self,
|
||||||
_client: &mut Client,
|
_client: &mut Client,
|
||||||
@@ -331,6 +348,7 @@ impl WlSurface for Surface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// https://wayland.app/protocols/wayland#wl_surface:request:damage_buffer
|
/// https://wayland.app/protocols/wayland#wl_surface:request:damage_buffer
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn damage_buffer(
|
async fn damage_buffer(
|
||||||
&self,
|
&self,
|
||||||
_client: &mut Client,
|
_client: &mut Client,
|
||||||
@@ -346,6 +364,7 @@ impl WlSurface for Surface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// https://wayland.app/protocols/wayland#wl_surface:request:offset
|
/// https://wayland.app/protocols/wayland#wl_surface:request:offset
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn offset(
|
async fn offset(
|
||||||
&self,
|
&self,
|
||||||
_client: &mut Client,
|
_client: &mut Client,
|
||||||
@@ -357,6 +376,7 @@ impl WlSurface for Surface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// https://wayland.app/protocols/wayland#wl_surface:request:destroy
|
/// https://wayland.app/protocols/wayland#wl_surface:request:destroy
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn destroy(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
|
async fn destroy(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use bevy_dmabuf::{
|
|||||||
use drm_fourcc::DrmFourcc;
|
use drm_fourcc::DrmFourcc;
|
||||||
use mint::Vector2;
|
use mint::Vector2;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use tracing::info;
|
||||||
use std::sync::{Arc, OnceLock};
|
use std::sync::{Arc, OnceLock};
|
||||||
use waynest::server::protocol::stable::linux_dmabuf_v1::zwp_linux_buffer_params_v1::Flags;
|
use waynest::server::protocol::stable::linux_dmabuf_v1::zwp_linux_buffer_params_v1::Flags;
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ impl std::fmt::Debug for DmabufBacking {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DmabufBacking {
|
impl DmabufBacking {
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
params: Arc<BufferParams>,
|
params: Arc<BufferParams>,
|
||||||
message_sink: Option<MessageSink>,
|
message_sink: Option<MessageSink>,
|
||||||
@@ -74,11 +76,13 @@ impl DmabufBacking {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn update_tex(
|
pub fn update_tex(
|
||||||
&self,
|
&self,
|
||||||
dmatexes: &ImportedDmatexs,
|
dmatexes: &ImportedDmatexs,
|
||||||
images: &mut Assets<Image>,
|
images: &mut Assets<Image>,
|
||||||
) -> Option<Handle<Image>> {
|
) -> Option<Handle<Image>> {
|
||||||
|
info!("updating dmabuf tex");
|
||||||
self.pending_imported_dmatex
|
self.pending_imported_dmatex
|
||||||
.lock()
|
.lock()
|
||||||
.take()
|
.take()
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ pub struct BufferParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BufferParams {
|
impl BufferParams {
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub fn new(id: ObjectId) -> Self {
|
pub fn new(id: ObjectId) -> Self {
|
||||||
tracing::info!("Creating new BufferParams with id {:?}", id);
|
tracing::info!("Creating new BufferParams with id {:?}", id);
|
||||||
Self {
|
Self {
|
||||||
@@ -45,6 +46,7 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn add(
|
async fn add(
|
||||||
&self,
|
&self,
|
||||||
_client: &mut Client,
|
_client: &mut Client,
|
||||||
@@ -89,6 +91,7 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn create(
|
async fn create(
|
||||||
&self,
|
&self,
|
||||||
client: &mut Client,
|
client: &mut Client,
|
||||||
@@ -123,6 +126,7 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
async fn create_immed(
|
async fn create_immed(
|
||||||
&self,
|
&self,
|
||||||
client: &mut Client,
|
client: &mut Client,
|
||||||
@@ -150,6 +154,7 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for BufferParams {
|
impl Drop for BufferParams {
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let planes = self.planes.get_mut();
|
let planes = self.planes.get_mut();
|
||||||
tracing::info!("BufferParams being dropped with {} planes", planes.len());
|
tracing::info!("BufferParams being dropped with {} planes", planes.len());
|
||||||
|
|||||||
@@ -19,8 +19,9 @@ use waynest::{
|
|||||||
#[derive(Debug, Dispatcher)]
|
#[derive(Debug, Dispatcher)]
|
||||||
pub struct DmabufFeedback(pub Arc<Dmabuf>);
|
pub struct DmabufFeedback(pub Arc<Dmabuf>);
|
||||||
impl DmabufFeedback {
|
impl DmabufFeedback {
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub async fn send_params(&self, client: &mut Client, sender_id: ObjectId) -> Result<()> {
|
pub async fn send_params(&self, client: &mut Client, sender_id: ObjectId) -> Result<()> {
|
||||||
let num_formats = self.0.formats.len();
|
let num_formats = dbg!(self.0.formats.len());
|
||||||
// Send format table first
|
// Send format table first
|
||||||
self.send_format_table(client, sender_id).await?;
|
self.send_format_table(client, sender_id).await?;
|
||||||
|
|
||||||
@@ -44,7 +45,6 @@ impl DmabufFeedback {
|
|||||||
self.tranche_target_device(client, sender_id, dev_id)
|
self.tranche_target_device(client, sender_id, dev_id)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// We only have one format at index 0
|
|
||||||
let indices = (0..num_formats).flat_map(|i| i.to_ne_bytes()).collect();
|
let indices = (0..num_formats).flat_map(|i| i.to_ne_bytes()).collect();
|
||||||
self.tranche_formats(client, sender_id, indices).await?;
|
self.tranche_formats(client, sender_id, indices).await?;
|
||||||
|
|
||||||
@@ -60,6 +60,7 @@ impl DmabufFeedback {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument("debug", skip_all)]
|
||||||
pub async fn send_format_table(&self, client: &mut Client, sender_id: ObjectId) -> Result<()> {
|
pub async fn send_format_table(&self, client: &mut Client, sender_id: ObjectId) -> Result<()> {
|
||||||
// Format + modifier pair (16 bytes):
|
// Format + modifier pair (16 bytes):
|
||||||
// - format: u32
|
// - format: u32
|
||||||
@@ -74,7 +75,7 @@ impl DmabufFeedback {
|
|||||||
mfd.as_file().set_len(size as u64)?;
|
mfd.as_file().set_len(size as u64)?;
|
||||||
|
|
||||||
for (format, modifier) in self.0.formats.iter() {
|
for (format, modifier) in self.0.formats.iter() {
|
||||||
let format = format.clone() as u32;
|
let format = *format as u32;
|
||||||
// Write the format+modifier pair
|
// Write the format+modifier pair
|
||||||
mfd.as_file().write_all(&format.to_ne_bytes())?;
|
mfd.as_file().write_all(&format.to_ne_bytes())?;
|
||||||
mfd.as_file().write_all(&0_u32.to_ne_bytes())?;
|
mfd.as_file().write_all(&0_u32.to_ne_bytes())?;
|
||||||
|
|||||||
@@ -2,15 +2,9 @@ pub mod buffer_backing;
|
|||||||
pub mod buffer_params;
|
pub mod buffer_params;
|
||||||
pub mod feedback;
|
pub mod feedback;
|
||||||
|
|
||||||
use super::{
|
use super::{util::ClientExt, vulkano_data::VULKANO_CONTEXT};
|
||||||
util::ClientExt,
|
|
||||||
vulkano_data::{DMA_CAPABLE_FORMATS, VULKANO_CONTEXT},
|
|
||||||
};
|
|
||||||
use crate::core::registry::Registry;
|
use crate::core::registry::Registry;
|
||||||
use bevy_dmabuf::{
|
use bevy_dmabuf::{format_mapping::drm_fourcc_to_vk_format, wgpu_init::vulkan_to_wgpu};
|
||||||
format_mapping::{drm_fourcc_to_vk_format, vk_format_to_drm_fourcc},
|
|
||||||
wgpu_init::vulkan_to_wgpu,
|
|
||||||
};
|
|
||||||
use buffer_params::BufferParams;
|
use buffer_params::BufferParams;
|
||||||
use drm_fourcc::DrmFourcc;
|
use drm_fourcc::DrmFourcc;
|
||||||
use feedback::DmabufFeedback;
|
use feedback::DmabufFeedback;
|
||||||
@@ -52,19 +46,16 @@ impl Dmabuf {
|
|||||||
/// Create a new DMA-BUF interface instance
|
/// Create a new DMA-BUF interface instance
|
||||||
pub async fn new(client: &mut Client, id: ObjectId, version: u32) -> Result<Self> {
|
pub async fn new(client: &mut Client, id: ObjectId, version: u32) -> Result<Self> {
|
||||||
let vk = VULKANO_CONTEXT.wait();
|
let vk = VULKANO_CONTEXT.wait();
|
||||||
let formats: FxHashSet<(DrmFourcc, u64)> = DMA_CAPABLE_FORMATS
|
let formats: FxHashSet<(DrmFourcc, u64)> = ALL_DRM_FOURCCS
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|f| {
|
.copied()
|
||||||
vk_format_to_drm_fourcc((**f).into())
|
.filter_map(|f| Some((f, drm_fourcc_to_vk_format(f)?)))
|
||||||
.and_then(drm_fourcc_to_vk_format)
|
.filter(|(_, vk_format)| vulkan_to_wgpu(*vk_format).is_some())
|
||||||
.and_then(vulkan_to_wgpu)
|
.filter_map(|(f, vk_format)| {
|
||||||
.is_some()
|
|
||||||
})
|
|
||||||
.filter_map(|f| {
|
|
||||||
Some((
|
Some((
|
||||||
vk_format_to_drm_fourcc((*f).into())?,
|
f,
|
||||||
vk.phys_dev
|
vk.phys_dev
|
||||||
.format_properties(*f)
|
.format_properties(vk_format.try_into().unwrap())
|
||||||
.ok()?
|
.ok()?
|
||||||
.drm_format_modifier_properties
|
.drm_format_modifier_properties
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -78,7 +69,6 @@ impl Dmabuf {
|
|||||||
dbg!(&formats);
|
dbg!(&formats);
|
||||||
|
|
||||||
let dmabuf = Self {
|
let dmabuf = Self {
|
||||||
// formats: Mutex::new(formats),
|
|
||||||
active_params: Registry::new(),
|
active_params: Registry::new(),
|
||||||
version,
|
version,
|
||||||
formats,
|
formats,
|
||||||
@@ -166,3 +156,111 @@ impl ZwpLinuxDmabufV1 for Dmabuf {
|
|||||||
self.get_default_feedback(client, sender_id, id).await
|
self.get_default_feedback(client, sender_id, id).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const ALL_DRM_FOURCCS: [DrmFourcc; 105] = [
|
||||||
|
DrmFourcc::Abgr1555,
|
||||||
|
DrmFourcc::Abgr16161616f,
|
||||||
|
DrmFourcc::Abgr2101010,
|
||||||
|
DrmFourcc::Abgr4444,
|
||||||
|
DrmFourcc::Abgr8888,
|
||||||
|
DrmFourcc::Argb1555,
|
||||||
|
DrmFourcc::Argb16161616f,
|
||||||
|
DrmFourcc::Argb2101010,
|
||||||
|
DrmFourcc::Argb4444,
|
||||||
|
DrmFourcc::Argb8888,
|
||||||
|
DrmFourcc::Axbxgxrx106106106106,
|
||||||
|
DrmFourcc::Ayuv,
|
||||||
|
DrmFourcc::Bgr233,
|
||||||
|
DrmFourcc::Bgr565,
|
||||||
|
DrmFourcc::Bgr565_a8,
|
||||||
|
DrmFourcc::Bgr888,
|
||||||
|
DrmFourcc::Bgr888_a8,
|
||||||
|
DrmFourcc::Bgra1010102,
|
||||||
|
DrmFourcc::Bgra4444,
|
||||||
|
DrmFourcc::Bgra5551,
|
||||||
|
DrmFourcc::Bgra8888,
|
||||||
|
DrmFourcc::Bgrx1010102,
|
||||||
|
DrmFourcc::Bgrx4444,
|
||||||
|
DrmFourcc::Bgrx5551,
|
||||||
|
DrmFourcc::Bgrx8888,
|
||||||
|
DrmFourcc::Bgrx8888_a8,
|
||||||
|
DrmFourcc::Big_endian,
|
||||||
|
DrmFourcc::C8,
|
||||||
|
DrmFourcc::Gr1616,
|
||||||
|
DrmFourcc::Gr88,
|
||||||
|
DrmFourcc::Nv12,
|
||||||
|
DrmFourcc::Nv15,
|
||||||
|
DrmFourcc::Nv16,
|
||||||
|
DrmFourcc::Nv21,
|
||||||
|
DrmFourcc::Nv24,
|
||||||
|
DrmFourcc::Nv42,
|
||||||
|
DrmFourcc::Nv61,
|
||||||
|
DrmFourcc::P010,
|
||||||
|
DrmFourcc::P012,
|
||||||
|
DrmFourcc::P016,
|
||||||
|
DrmFourcc::P210,
|
||||||
|
DrmFourcc::Q401,
|
||||||
|
DrmFourcc::Q410,
|
||||||
|
DrmFourcc::R16,
|
||||||
|
DrmFourcc::R8,
|
||||||
|
DrmFourcc::Rg1616,
|
||||||
|
DrmFourcc::Rg88,
|
||||||
|
DrmFourcc::Rgb332,
|
||||||
|
DrmFourcc::Rgb565,
|
||||||
|
DrmFourcc::Rgb565_a8,
|
||||||
|
DrmFourcc::Rgb888,
|
||||||
|
DrmFourcc::Rgb888_a8,
|
||||||
|
DrmFourcc::Rgba1010102,
|
||||||
|
DrmFourcc::Rgba4444,
|
||||||
|
DrmFourcc::Rgba5551,
|
||||||
|
DrmFourcc::Rgba8888,
|
||||||
|
DrmFourcc::Rgbx1010102,
|
||||||
|
DrmFourcc::Rgbx4444,
|
||||||
|
DrmFourcc::Rgbx5551,
|
||||||
|
DrmFourcc::Rgbx8888,
|
||||||
|
DrmFourcc::Rgbx8888_a8,
|
||||||
|
DrmFourcc::Uyvy,
|
||||||
|
DrmFourcc::Vuy101010,
|
||||||
|
DrmFourcc::Vuy888,
|
||||||
|
DrmFourcc::Vyuy,
|
||||||
|
DrmFourcc::X0l0,
|
||||||
|
DrmFourcc::X0l2,
|
||||||
|
DrmFourcc::Xbgr1555,
|
||||||
|
DrmFourcc::Xbgr16161616f,
|
||||||
|
DrmFourcc::Xbgr2101010,
|
||||||
|
DrmFourcc::Xbgr4444,
|
||||||
|
DrmFourcc::Xbgr8888,
|
||||||
|
DrmFourcc::Xbgr8888_a8,
|
||||||
|
DrmFourcc::Xrgb1555,
|
||||||
|
DrmFourcc::Xrgb16161616f,
|
||||||
|
DrmFourcc::Xrgb2101010,
|
||||||
|
DrmFourcc::Xrgb4444,
|
||||||
|
DrmFourcc::Xrgb8888,
|
||||||
|
DrmFourcc::Xrgb8888_a8,
|
||||||
|
DrmFourcc::Xvyu12_16161616,
|
||||||
|
DrmFourcc::Xvyu16161616,
|
||||||
|
DrmFourcc::Xvyu2101010,
|
||||||
|
DrmFourcc::Xyuv8888,
|
||||||
|
DrmFourcc::Y0l0,
|
||||||
|
DrmFourcc::Y0l2,
|
||||||
|
DrmFourcc::Y210,
|
||||||
|
DrmFourcc::Y212,
|
||||||
|
DrmFourcc::Y216,
|
||||||
|
DrmFourcc::Y410,
|
||||||
|
DrmFourcc::Y412,
|
||||||
|
DrmFourcc::Y416,
|
||||||
|
DrmFourcc::Yuv410,
|
||||||
|
DrmFourcc::Yuv411,
|
||||||
|
DrmFourcc::Yuv420,
|
||||||
|
DrmFourcc::Yuv420_10bit,
|
||||||
|
DrmFourcc::Yuv420_8bit,
|
||||||
|
DrmFourcc::Yuv422,
|
||||||
|
DrmFourcc::Yuv444,
|
||||||
|
DrmFourcc::Yuyv,
|
||||||
|
DrmFourcc::Yvu410,
|
||||||
|
DrmFourcc::Yvu411,
|
||||||
|
DrmFourcc::Yvu420,
|
||||||
|
DrmFourcc::Yvu422,
|
||||||
|
DrmFourcc::Yvu444,
|
||||||
|
DrmFourcc::Yvyu,
|
||||||
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user