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

@ -165,9 +165,7 @@ impl JayScreencast {
let mut buffer = self.buffers.borrow_mut();
for (idx, buffer) in buffer.deref_mut().iter_mut().enumerate() {
if buffer.free {
buffer
.fb
.copy_texture(&self.client.state, texture, 0, 0, false);
buffer.fb.copy_texture(texture, 0, 0);
self.client.event(Ready {
self_id: self.id,
idx: idx as _,

View file

@ -198,10 +198,10 @@ impl WlBuffer {
};
match storage {
WlBufferStorage::Shm { mem, stride } => {
self.texture.set(None);
let old = self.texture.take();
if let Some(ctx) = self.client.state.render_ctx.get() {
let tex = mem.access(|mem| {
ctx.shmem_texture(mem, self.format, self.width, self.height, *stride)
ctx.shmem_texture(old, mem, self.format, self.width, self.height, *stride)
})??;
self.texture.set(Some(tex));
}

View file

@ -19,6 +19,7 @@ use {
buffd::{MsgParser, MsgParserError},
clonecell::CloneCell,
copyhashmap::CopyHashMap,
errorfmt::ErrorFmt,
linkedlist::LinkedList,
},
wire::{wl_output::*, WlOutputId, ZxdgOutputV1Id},
@ -220,8 +221,10 @@ impl WlOutputGlobal {
continue;
}
let rect = capture.rect;
if let Some(WlBufferStorage::Shm { mem, .. }) = wl_buffer.storage.borrow_mut().deref() {
let res = mem.access(|mem| {
if let Some(WlBufferStorage::Shm { mem, stride }) =
wl_buffer.storage.borrow_mut().deref()
{
let acc = mem.access(|mem| {
fb.copy_to_shm(
rect.x1(),
rect.y1(),
@ -229,10 +232,39 @@ impl WlOutputGlobal {
rect.height(),
XRGB8888,
mem,
);
)
});
let mut res = match acc {
Ok(res) => res,
Err(e) => {
capture.client.error(e);
continue;
}
};
if res.is_err() {
let acc = mem.access(|mem| {
tex.clone().read_pixels(
capture.rect.x1(),
capture.rect.y1(),
capture.rect.width(),
capture.rect.height(),
*stride,
wl_buffer.format,
mem,
)
});
res = match acc {
Ok(res) => res,
Err(e) => {
capture.client.error(e);
continue;
}
};
}
if let Err(e) = res {
capture.client.error(e);
log::warn!("Could not read texture to memory: {}", ErrorFmt(e));
capture.send_failed();
continue;
}
// capture.send_flags(FLAGS_Y_INVERT);
} else {
@ -244,13 +276,7 @@ impl WlOutputGlobal {
continue;
}
};
fb.copy_texture(
&self.state,
tex,
-capture.rect.x1(),
-capture.rect.y1(),
false,
);
fb.copy_texture(tex, -capture.rect.x1(), -capture.rect.y1());
}
if capture.with_damage.get() {
capture.send_damage();