-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Description
virtio-drivers/src/device/gpu.rs
Lines 118 to 124 in 0d59b01
// SAFETY: `Dma::new` guarantees that the pointer returned from | |
// `raw_slice` is non-null, aligned, and the allocation is zeroed. We | |
// store the `Dma` object in `self.frame_buffer_dma`, which prevents the | |
// allocation from being freed while `self` exists. The returned ptr | |
// borrows `self` mutably, which prevents other code from getting | |
// another reference to `frame_buffer_dma` while the returned slice is | |
// still in use. |
This is accurate, but this also prevents me from reusing the framebuffer that was set up. From the example:
let fb = gpu.setup_framebuffer().expect("failed to get fb");
for y in 0..height {
for x in 0..width {
let idx = (y * width + x) * 4;
fb[idx] = x as u8;
fb[idx + 1] = y as u8;
fb[idx + 2] = (x + y) as u8;
}
}
gpu.flush().expect("failed to flush");
I can't update the framebuffer once I've flushed, but the only way to get another framebuffer is to call setup_framebuffer
again, which does a full framebuffer allocation again.
(so the following wouldn't compile)
let fb = gpu.setup_framebuffer()?;
fb.fill(0xaa);
gpu.flush()?;
fb.fill(0xbb);
gpu.flush()?;
How was the framebuffer intended to be used? Am I missing something? Do I need to manually track the allocations from the Hal
?
Metadata
Metadata
Assignees
Labels
No labels