vk: use ubo ring
This commit is contained in:
parent
9dbe031ce8
commit
88db9220c4
|
@ -21,6 +21,7 @@ use std::error::Error;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use crate::samplers::SamplerSet;
|
use crate::samplers::SamplerSet;
|
||||||
use crate::texture::VulkanImage;
|
use crate::texture::VulkanImage;
|
||||||
|
use crate::ubo_ring::VkUboRing;
|
||||||
|
|
||||||
pub struct Vulkan {
|
pub struct Vulkan {
|
||||||
// physical_device: vk::PhysicalDevice,
|
// physical_device: vk::PhysicalDevice,
|
||||||
|
@ -253,12 +254,12 @@ impl FilterChainVulkan {
|
||||||
let reflection = reflect.reflect(index, semantics)?;
|
let reflection = reflect.reflect(index, semantics)?;
|
||||||
let spirv_words = reflect.compile(None)?;
|
let spirv_words = reflect.compile(None)?;
|
||||||
|
|
||||||
let uniform_storage = UniformStorage::new(
|
let ubo_size = reflection
|
||||||
reflection
|
|
||||||
.ubo
|
.ubo
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|ubo| ubo.size as usize)
|
.map(|ubo| ubo.size as usize)
|
||||||
.unwrap_or(0),
|
.unwrap_or(0);
|
||||||
|
let uniform_storage = UniformStorage::new(ubo_size,
|
||||||
reflection
|
reflection
|
||||||
.push_constant
|
.push_constant
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -294,6 +295,7 @@ impl FilterChainVulkan {
|
||||||
images,
|
images,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
let ubo_ring = VkUboRing::new(&vulkan.device, &vulkan.memory_properties, images as usize, ubo_size)?;
|
||||||
// shader_vulkan: 2026
|
// shader_vulkan: 2026
|
||||||
filters.push(FilterPass {
|
filters.push(FilterPass {
|
||||||
device: vulkan.device.clone(),
|
device: vulkan.device.clone(),
|
||||||
|
@ -304,6 +306,7 @@ impl FilterChainVulkan {
|
||||||
source,
|
source,
|
||||||
config,
|
config,
|
||||||
graphics_pipeline,
|
graphics_pipeline,
|
||||||
|
ubo_ring,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ use crate::filter_chain::FilterCommon;
|
||||||
use crate::rendertarget::RenderTarget;
|
use crate::rendertarget::RenderTarget;
|
||||||
use crate::texture::Texture;
|
use crate::texture::Texture;
|
||||||
use crate::samplers::{SamplerSet, VulkanSampler};
|
use crate::samplers::{SamplerSet, VulkanSampler};
|
||||||
|
use crate::ubo_ring::VkUboRing;
|
||||||
|
|
||||||
pub struct FilterPass {
|
pub struct FilterPass {
|
||||||
pub device: ash::Device,
|
pub device: ash::Device,
|
||||||
|
@ -22,6 +23,7 @@ pub struct FilterPass {
|
||||||
pub source: ShaderSource,
|
pub source: ShaderSource,
|
||||||
pub config: ShaderPassConfig,
|
pub config: ShaderPassConfig,
|
||||||
pub graphics_pipeline: VulkanGraphicsPipeline,
|
pub graphics_pipeline: VulkanGraphicsPipeline,
|
||||||
|
pub ubo_ring: VkUboRing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,6 +72,7 @@ impl FilterPass {
|
||||||
|
|
||||||
if let Some(ubo) = &self.reflection.ubo {
|
if let Some(ubo) = &self.reflection.ubo {
|
||||||
// shader_vulkan: 2554 (ra uses uses one big buffer)
|
// shader_vulkan: 2554 (ra uses uses one big buffer)
|
||||||
|
// itll be simpler for us if we just use a RingBuffer<vk::Buffer> tbh.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ mod vulkan_state;
|
||||||
mod samplers;
|
mod samplers;
|
||||||
mod texture;
|
mod texture;
|
||||||
mod rendertarget;
|
mod rendertarget;
|
||||||
|
mod ubo_ring;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
21
librashader-runtime-vk/src/ubo_ring.rs
Normal file
21
librashader-runtime-vk/src/ubo_ring.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
use ash::vk;
|
||||||
|
use librashader_runtime::ringbuffer::{BoxRingBuffer, InlineRingBuffer};
|
||||||
|
use crate::error;
|
||||||
|
use crate::vulkan_primitives::VulkanBuffer;
|
||||||
|
|
||||||
|
pub struct VkUboRing {
|
||||||
|
ring: BoxRingBuffer<VulkanBuffer>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl VkUboRing {
|
||||||
|
pub fn new(device: &ash::Device, mem_props: &vk::PhysicalDeviceMemoryProperties, ring_size: usize, buffer_size: usize) -> error::Result<Self> {
|
||||||
|
let mut ring = Vec::new();
|
||||||
|
for _ in 0..ring_size {
|
||||||
|
ring.push(VulkanBuffer::new(device, mem_props, vk::BufferUsageFlags::UNIFORM_BUFFER, buffer_size)?);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(VkUboRing {
|
||||||
|
ring: BoxRingBuffer::from_vec(ring)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue