vk: move internal frame count to common
This commit is contained in:
parent
a6b1e0a412
commit
af6f58981e
|
@ -14,9 +14,7 @@ impl SamplerSet {
|
|||
pub fn get(&self, wrap: WrapMode, filter: FilterMode) -> &ID3D11SamplerState {
|
||||
// SAFETY: the sampler set is complete for the matrix
|
||||
// wrap x filter
|
||||
unsafe {
|
||||
self.samplers.get(&(wrap, filter)).unwrap_unchecked()
|
||||
}
|
||||
unsafe { self.samplers.get(&(wrap, filter)).unwrap_unchecked() }
|
||||
}
|
||||
|
||||
pub fn new(device: &ID3D11Device) -> Result<SamplerSet> {
|
||||
|
|
|
@ -22,9 +22,7 @@ impl SamplerSet {
|
|||
) -> &D3D12DescriptorHeapSlot<SamplerPaletteHeap> {
|
||||
// SAFETY: the sampler set is complete for the matrix
|
||||
// wrap x filter
|
||||
unsafe {
|
||||
self.samplers.get(&(wrap, filter)).unwrap_unchecked()
|
||||
}
|
||||
unsafe { self.samplers.get(&(wrap, filter)).unwrap_unchecked() }
|
||||
}
|
||||
pub fn new(device: &ID3D12Device) -> error::Result<SamplerSet> {
|
||||
let mut samplers = FxHashMap::default();
|
||||
|
|
|
@ -288,9 +288,8 @@ pub mod d3d12_hello_triangle {
|
|||
}
|
||||
}
|
||||
|
||||
let filter = unsafe {
|
||||
FilterChainD3D12::load_from_path(filter, &device, None).unwrap()
|
||||
};
|
||||
let filter =
|
||||
unsafe { FilterChainD3D12::load_from_path(filter, &device, None).unwrap() };
|
||||
|
||||
Ok(Sample {
|
||||
dxgi_factory,
|
||||
|
|
|
@ -13,7 +13,10 @@ impl SamplerSet {
|
|||
// SAFETY: the sampler set is complete for the matrix
|
||||
// wrap x filter x mipmap
|
||||
unsafe {
|
||||
*self.samplers.get(&(wrap, filter, mipmap)).unwrap_unchecked()
|
||||
*self
|
||||
.samplers
|
||||
.get(&(wrap, filter, mipmap))
|
||||
.unwrap_unchecked()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,17 +48,9 @@ impl SamplerSet {
|
|||
let mut sampler = 0;
|
||||
unsafe {
|
||||
gl::GenSamplers(1, &mut sampler);
|
||||
SamplerSet::make_sampler(
|
||||
sampler,
|
||||
*wrap_mode,
|
||||
*filter_mode,
|
||||
*mip_filter,
|
||||
);
|
||||
SamplerSet::make_sampler(sampler, *wrap_mode, *filter_mode, *mip_filter);
|
||||
|
||||
samplers.insert(
|
||||
(*wrap_mode, *filter_mode, *mip_filter),
|
||||
sampler,
|
||||
);
|
||||
samplers.insert((*wrap_mode, *filter_mode, *mip_filter), sampler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,6 +142,7 @@ pub(crate) struct FilterCommon {
|
|||
pub history_textures: Box<[Option<InputImage>]>,
|
||||
pub config: FilterMutable,
|
||||
pub device: Arc<ash::Device>,
|
||||
pub(crate) internal_frame_count: usize,
|
||||
}
|
||||
|
||||
/// Contains residual intermediate `VkImageView` and `VkImage` objects created
|
||||
|
@ -380,6 +381,7 @@ impl FilterChainVulkan {
|
|||
output_textures,
|
||||
feedback_textures,
|
||||
history_textures,
|
||||
internal_frame_count: 0,
|
||||
},
|
||||
passes: filters,
|
||||
vulkan: device,
|
||||
|
@ -454,7 +456,6 @@ impl FilterChainVulkan {
|
|||
graphics_pipeline,
|
||||
// ubo_ring,
|
||||
frames_in_flight,
|
||||
internal_frame_count: 0,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
@ -482,12 +483,7 @@ impl FilterChainVulkan {
|
|||
}
|
||||
|
||||
// image must be in SHADER_READ_OPTIMAL
|
||||
fn push_history(
|
||||
&mut self,
|
||||
input: &VulkanImage,
|
||||
cmd: vk::CommandBuffer,
|
||||
count: usize,
|
||||
) -> error::Result<()> {
|
||||
fn push_history(&mut self, input: &VulkanImage, cmd: vk::CommandBuffer) -> error::Result<()> {
|
||||
if let Some(mut back) = self.history_framebuffers.pop_back() {
|
||||
if back.image.size != input.size
|
||||
|| (input.format != vk::Format::UNDEFINED && input.format != back.image.format)
|
||||
|
@ -498,7 +494,8 @@ impl FilterChainVulkan {
|
|||
&mut back,
|
||||
OwnedImage::new(&self.vulkan, input.size, input.format.into(), 1)?,
|
||||
);
|
||||
self.residuals[count % self.residuals.len()].dispose_owned(old_back);
|
||||
self.residuals[self.common.internal_frame_count % self.residuals.len()]
|
||||
.dispose_owned(old_back);
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
@ -556,7 +553,8 @@ impl FilterChainVulkan {
|
|||
frame_count: usize,
|
||||
options: Option<&FrameOptionsVulkan>,
|
||||
) -> error::Result<()> {
|
||||
let intermediates = &mut self.residuals[frame_count % self.residuals.len()];
|
||||
let intermediates =
|
||||
&mut self.residuals[self.common.internal_frame_count % self.residuals.len()];
|
||||
intermediates.dispose();
|
||||
|
||||
// limit number of passes to those enabled.
|
||||
|
@ -725,7 +723,8 @@ impl FilterChainVulkan {
|
|||
intermediates.dispose_framebuffers(residual_fb);
|
||||
}
|
||||
|
||||
self.push_history(input, cmd, frame_count)?;
|
||||
self.push_history(input, cmd)?;
|
||||
self.common.internal_frame_count = self.common.internal_frame_count.wrapping_add(1);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ pub struct FilterPass {
|
|||
pub graphics_pipeline: VulkanGraphicsPipeline,
|
||||
// pub ubo_ring: VkUboRing,
|
||||
pub frames_in_flight: u32,
|
||||
pub internal_frame_count: usize,
|
||||
}
|
||||
|
||||
impl TextureInput for InputImage {
|
||||
|
@ -100,7 +99,7 @@ impl FilterPass {
|
|||
vbo_type: QuadType,
|
||||
) -> error::Result<Option<vk::Framebuffer>> {
|
||||
let mut descriptor = self.graphics_pipeline.layout.descriptor_sets
|
||||
[self.internal_frame_count % self.frames_in_flight as usize];
|
||||
[parent.internal_frame_count % self.frames_in_flight as usize];
|
||||
|
||||
self.build_semantics(
|
||||
pass_index,
|
||||
|
@ -181,7 +180,6 @@ impl FilterPass {
|
|||
parent.draw_quad.draw_quad(cmd, vbo_type);
|
||||
self.graphics_pipeline.end_rendering(&parent.device, cmd);
|
||||
}
|
||||
self.internal_frame_count = self.internal_frame_count.wrapping_add(1);
|
||||
Ok(residual)
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,9 @@ impl SamplerSet {
|
|||
// SAFETY: the sampler set is complete for the matrix
|
||||
// wrap x filter x mipmap
|
||||
unsafe {
|
||||
self.samplers.get(&(wrap, filter, mipmap)).unwrap_unchecked()
|
||||
self.samplers
|
||||
.get(&(wrap, filter, mipmap))
|
||||
.unwrap_unchecked()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue