vulkan: de-duplicate used textures
This commit is contained in:
parent
cf6016f61f
commit
8a3a377f61
3 changed files with 9 additions and 3 deletions
|
|
@ -66,6 +66,7 @@ pub struct VulkanImage {
|
|||
pub(super) shader_read_only_optimal_descriptor: Box<[u8]>,
|
||||
pub(super) descriptor_buffer_version: Cell<u64>,
|
||||
pub(super) descriptor_buffer_offset: Cell<DeviceSize>,
|
||||
pub(super) execution_version: Cell<u64>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
|
|
@ -452,6 +453,7 @@ impl VulkanDmaBufImageTemplate {
|
|||
.sampler_read_only_descriptor(texture_view),
|
||||
descriptor_buffer_version: Cell::new(0),
|
||||
descriptor_buffer_offset: Cell::new(0),
|
||||
execution_version: Cell::new(0),
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ pub struct VulkanRenderer {
|
|||
pub(super) shm_allocator: Rc<VulkanThreadedAllocator>,
|
||||
pub(super) sampler: Rc<VulkanSampler>,
|
||||
pub(super) tex_sampler_descriptor_buffer_cache: Rc<VulkanDescriptorBufferCache>,
|
||||
pub(super) descriptor_buffer_version: NumCell<u64>,
|
||||
pub(super) tex_descriptor_buffer_writer: RefCell<VulkanDescriptorBufferWriter>,
|
||||
}
|
||||
|
||||
|
|
@ -254,7 +253,6 @@ impl VulkanDevice {
|
|||
shm_allocator,
|
||||
sampler,
|
||||
tex_sampler_descriptor_buffer_cache: tex_descriptor_buffer_cache,
|
||||
descriptor_buffer_version: Default::default(),
|
||||
tex_descriptor_buffer_writer,
|
||||
});
|
||||
render.get_or_create_pipelines(XRGB8888.vk_format)?;
|
||||
|
|
@ -327,7 +325,7 @@ impl VulkanRenderer {
|
|||
return Ok(());
|
||||
};
|
||||
zone!("create_descriptor_buffer");
|
||||
let version = self.descriptor_buffer_version.add_fetch(1);
|
||||
let version = self.allocate_point();
|
||||
let memory = &mut *self.memory.borrow_mut();
|
||||
let writer = &mut *self.tex_descriptor_buffer_writer.borrow_mut();
|
||||
writer.clear();
|
||||
|
|
@ -368,12 +366,16 @@ impl VulkanRenderer {
|
|||
let mut memory = self.memory.borrow_mut();
|
||||
memory.dmabuf_sample.clear();
|
||||
memory.queue_transfer.clear();
|
||||
let execution = self.allocate_point();
|
||||
for cmd in opts {
|
||||
if let GfxApiOpt::CopyTexture(c) = cmd {
|
||||
let tex = c.tex.clone().into_vk(&self.device.device);
|
||||
if tex.contents_are_undefined.get() {
|
||||
continue;
|
||||
}
|
||||
if tex.execution_version.replace(execution) == execution {
|
||||
continue;
|
||||
}
|
||||
match tex.queue_state.get().acquire(QueueFamily::Gfx) {
|
||||
QueueTransfer::Unnecessary => {}
|
||||
QueueTransfer::Possible => memory.queue_transfer.push(tex.clone()),
|
||||
|
|
@ -1055,6 +1057,7 @@ impl VulkanRenderer {
|
|||
memory.queue_transfer.clear();
|
||||
memory.wait_semaphores.clear();
|
||||
memory.release_fence.take();
|
||||
memory.descriptor_buffer.take();
|
||||
memory.release_sync_file.take()
|
||||
};
|
||||
res.map(|_| sync_file)
|
||||
|
|
|
|||
|
|
@ -462,6 +462,7 @@ impl VulkanRenderer {
|
|||
shader_read_only_optimal_descriptor: self.sampler_read_only_descriptor(view),
|
||||
descriptor_buffer_version: Cell::new(0),
|
||||
descriptor_buffer_offset: Cell::new(0),
|
||||
execution_version: Cell::new(0),
|
||||
});
|
||||
let shm = match &img.ty {
|
||||
VulkanImageMemory::DmaBuf(_) => unreachable!(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue