lots of refactoring
This commit is contained in:
@@ -7,11 +7,11 @@ use std::sync::Arc;
|
||||
use vulkano::swapchain::{Swapchain, PresentMode, SurfaceTransform, Surface, SwapchainCreationError, AcquireError, Capabilities};
|
||||
use vulkano::image::swapchain::SwapchainImage;
|
||||
use winit::{Window};
|
||||
use crate::util::compute_kernel::ComputeKernel;
|
||||
use crate::util::compute_image::ComputeImage;
|
||||
use crate::canvas::{Canvas, CanvasFrame};
|
||||
use crate::compu_wip::{CompuState, ComputeFrame};
|
||||
use crate::canvas::{CanvasState, CanvasFrame, ImageHandle};
|
||||
use crate::compu_state::CompuState;
|
||||
use vulkano::image::ImageUsage;
|
||||
use crate::compu_buffer::CompuBufferHandle;
|
||||
use crate::compu_frame::CompuFrame;
|
||||
|
||||
pub struct VkProcessor<'a> {
|
||||
|
||||
@@ -23,9 +23,6 @@ pub struct VkProcessor<'a> {
|
||||
pub queue: Arc<Queue>,
|
||||
pub dynamic_state: DynamicState,
|
||||
|
||||
pub compute_kernel: Option<ComputeKernel>,
|
||||
pub compute_image: Option<ComputeImage>,
|
||||
|
||||
pub swapchain: Option<Arc<Swapchain<Window>>>,
|
||||
pub swapchain_images: Option<Vec<Arc<SwapchainImage<Window>>>>,
|
||||
|
||||
@@ -34,7 +31,7 @@ pub struct VkProcessor<'a> {
|
||||
compute_state: CompuState,
|
||||
|
||||
capabilities: Capabilities,
|
||||
canvas: Canvas,
|
||||
canvas: CanvasState,
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +71,7 @@ impl<'a> VkProcessor<'a> {
|
||||
swapchain_recreate_needed: false,
|
||||
compute_state: CompuState::new(),
|
||||
capabilities: capabilities.clone(),
|
||||
canvas: Canvas::new(queue, device, physical, capabilities),
|
||||
canvas: CanvasState::new(queue, device, physical, capabilities),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +152,7 @@ impl<'a> VkProcessor<'a> {
|
||||
}
|
||||
|
||||
// Create a new image which has the transfer usage
|
||||
pub fn new_swap_image(&mut self, dimensions: (u32, u32)) -> Arc<u32> {
|
||||
pub fn new_swap_image(&mut self, dimensions: (u32, u32)) -> Arc<ImageHandle> {
|
||||
let mut usage = ImageUsage::none();
|
||||
usage.transfer_destination = true;
|
||||
usage.storage = true;
|
||||
@@ -163,25 +160,25 @@ impl<'a> VkProcessor<'a> {
|
||||
self.canvas.create_image(dimensions, usage)
|
||||
}
|
||||
|
||||
pub fn new_compute_buffer(&mut self, data: Vec<u8>, dimensions: (u32, u32), stride: u32) -> Arc<u32> {
|
||||
pub fn new_compute_buffer(&mut self, data: Vec<u8>, dimensions: (u32, u32), stride: u32) -> Arc<CompuBufferHandle> {
|
||||
self.compute_state.new_compute_buffer(data, dimensions, stride, self.device.clone())
|
||||
}
|
||||
|
||||
pub fn read_compute_buffer(&mut self, handle: Arc<u32>) -> Vec<u8> {
|
||||
pub fn read_compute_buffer(&mut self, handle: Arc<CompuBufferHandle>) -> Vec<u8> {
|
||||
self.compute_state.read_compute_buffer(handle)
|
||||
}
|
||||
|
||||
pub fn write_compute_buffer(&self, handle: Arc<u32>, data: Vec<u8>) {
|
||||
pub fn write_compute_buffer(&self, handle: Arc<CompuBufferHandle>, data: Vec<u8>) {
|
||||
self.compute_state.write_compute_buffer(handle, data)
|
||||
}
|
||||
|
||||
pub fn run(&mut self,
|
||||
surface: &'a Arc<Surface<Window>>,
|
||||
mut frame_future: Box<dyn GpuFuture>,
|
||||
canvas_frame: CanvasFrame,
|
||||
compute_frame: ComputeFrame,
|
||||
surface: &'a Arc<Surface<Window>>,
|
||||
mut frame_future: Box<dyn GpuFuture>,
|
||||
canvas_frame: CanvasFrame,
|
||||
compute_frame: CompuFrame,
|
||||
)
|
||||
-> Box<dyn GpuFuture> {
|
||||
-> Box<dyn GpuFuture> {
|
||||
|
||||
// take the canvas frame and create the vertex buffers
|
||||
// TODO: This performs gpu buffer creation. Shouldn't be in hotpath
|
||||
|
||||
Reference in New Issue
Block a user