more refactoring, compiles.

This commit is contained in:
2019-08-29 22:22:10 -07:00
parent 1737319fc5
commit 0357296771
12 changed files with 361 additions and 275 deletions

View File

@@ -19,13 +19,13 @@ use winit::{EventsLoop, WindowBuilder, WindowEvent, Event, DeviceEvent, VirtualK
use winit::dpi::LogicalSize;
use vulkano_win::VkSurfaceBuild;
use sprite::Sprite;
use crate::canvas::{CanvasFrame, CanvasImage};
use crate::compu_state::CompuState;
use crate::compu_frame::CompuFrame;
use crate::compu_sprite::CompuSprite;
use crate::compu_kernel::CompuKernel;
use crate::compu_buffer::CompuBuffers;
use crate::util::load_raw;
use crate::canvas_frame::CanvasFrame;
mod util;
mod slider;
@@ -36,8 +36,11 @@ mod button;
mod vertex_2d;
mod vertex_3d;
mod sprite;
mod canvas;
mod canvas_frame;
mod canvas_shader;
mod compu_state;
mod compu_frame;
mod compu_sprite;
@@ -50,137 +53,6 @@ Alright, what the hell do I do next...
Canvas works, but I want to use CPU accessible buffer instead of immutable buffer
I think it would be faster if we reuse fewer oversized buffers than vis versa
Texturing is broken
8/13 :
Okay. So I've decided to keep compute image and compute kernel in their own 'canvas'
Canvas still needs to be cleaned up. I would like a contract type of thing going on
with the loaded textures. Where you need to request a texture_handle from vkprocessor
to attach to a Sprite. The problem is kinda what I do with the swap image. I only need
a reference to it and the general buffer coming back from the compute kernel. I could
continue to hold the image in the Canvas, and just give out an ID when a Sprite wants it.
The issue here is that kinda muddles the API a bit. I would need to do something like
8/27 :
But I dont always want to draw a computable...
Which I guess is fine. I could have another datatype implement computable
CompuSprite
-> Drawable, Computable
TxturSprite
-> Drawable
ColorSprite
-> Drawable
Computable
-> get pipeline id (need to assoc. compiled kernel)
->
Drawable
-> get texture id
-> get image id
-> get color
-> get vertices
Computable
get data
set data?
set settings?
get swap image id
Drawable:
get vertices
get color
get texture id
get descriptor set
need some sort of computable interface for the Sprite. It already has drawable
so why not computable
Pipeline is the compiled kernel/shader
in the shaders case, it has the vertex definition, constants, and the compiled code
in kernel, its just constants and compiled code
Descriptor set holds the buffers which we will pass to the pipeline
rw and settings buffers for the compu
texture buffer for the textured
image buffer for the image (swap)
Need to have certain stages in the building of the command buffer.
(Z level????)
1.) computes
2.) compute swaps
3.) render images
4.) render textures
5.) render solids
So to start with we need to know the compute data which we want to run and the kernel we want to run it on. We combine the buffers along with the pipeline generated from the compiled kernel and get
the descriptor set. We also need the XY for the compute run
CompuSprite
holds the image handle
impl's drawable
CompuBuffers
holds the buffer handles
creates the descriptor set?
CompuState
holds the compute buffers
holds the compute kernels
ComputeFrame
preserves order of entered elements
holds compute buffer ids and their tied kernel ids
holds compute buffer ids, their swap image ids and their kernel ids
holds compute buffer ids, their swap buffer ids, and their kernel ids
// Creates the compu sprite with an associated image stored in canvas
let compu_sprite = CompuSprite::new(&mut canvas)
// Compiles and stores the kernel in CompuState
// Returns the handle to the stored kernel (immutable at this state probably)
let KernelID = ComputeState.new_kernel(kernel_path)
// Pushes the data to the GPU and returns a handle
let ComputeBuffer_1 = ComputeState.new_compute_buffer(input_data, input_settings)
// One by one, assign the buffers to their kernels for run
ComputeFrame.add(ComputeBuffer_1, KernelID)
// If the buffer needs to be swapped in first
ComputeFrame.add_with_buffer_swap(ComputeBuffer_1, ComputeBuffer_2, KernelID)
// If the buffer should be swappd out to an image after it computes
ComputeFrame.add_with_image_swap(ComputeBuffer_1, compu_sprite, KernelID)
CompuState.compute()
// Full example if API:
CompuFrame.add(ComputeBuffer1ID, Kernel1ID)
CompuFrame.add(ComputeBuffer2ID, Kernel2ID)
CompuFrame.add_with_image_swap(ComputeBuffer1ID, CompuSprite, KernelID)
CanvasFrame.draw(Sprite1)
CanvasFrame.draw(Sprite2)
CanvasFrame.draw(CompuSprite)
vkprocessor.run(CanvasFrame, CompuFrame)
*/
fn main() {
@@ -197,9 +69,6 @@ fn main() {
let mut window = surface.window();
let mut processor = vkprocessor::VkProcessor::new(&instance, &surface);
// processor.compile_kernel(String::from("simple-edge.compute"));
// processor.load_compute_image(String::from("background.jpg"));
// processor.load_textures(String::from("funky-bird.jpg"));
processor.create_swapchain(&surface);
let mut timer = Timer::new();
@@ -232,11 +101,6 @@ fn main() {
while let Some(p) = window.get_position() {
elapsed_time = timer.elap_time();