moved over to the enum method of drawing. Not flexible, but type safe

This commit is contained in:
2020-02-12 00:42:30 -08:00
parent 80c0d323be
commit 659cd98a1f
23 changed files with 192 additions and 570 deletions

View File

@@ -0,0 +1,45 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2020-02-04T19:34:27-08:00
====== CanvasContainerClasses ======
[[/doc/sfml_rust/canvas/canvas_buffer/index.html|Documentation]]
===== Details =====
The Canvas needs to package certain buffers along with their metadata. These take the form of **Canvas Buffers**.
All buffers will have a coupled handle type stored in the [[/src/canvas/mod.rs|canvas/mod.rs]] and a reference to that handle
===== CanvasImage =====
===== CanvasTexture =====
===== CanvasFont =====
===== Details =====
Container class for
**<notes>**
--------------------
===== Data =====
**Borrowed:**
**Owns:**
--------------------

View File

@@ -0,0 +1,31 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2020-02-03T23:42:36-08:00
====== CanvasFont ======
[[/doc/sfml_rust/canvas/canvas_buffer/struct.CanvasFont.html|Documentation]]
===== Details =====
<details>
**<notes>**
--------------------
===== Data =====
**Borrowed:**
**Owns:**
--------------------

View File

@@ -0,0 +1,69 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2020-02-03T23:57:15-08:00
====== CanvasFrame ======
[[/doc/sfml_rust/canvas/canvas_frame/struct.CanvasFrame.html|Documentation]]
===== Details =====
Canvas frame is at it's core, an accumulator of meta data to draw to the screen.
At the moment it is split up into these groups:
* Colored items like non-textured sprites are just a list of triangles, simple vertices.
@todo
* Textured are grouped by their texture handle. Currently implemented as a list of lists of vertices. I don't think the vertices need to be grouped by sprite as long as they are triangle lists with texture coords included in the definition
* Images are just the same as Textured
* Text is a simple Font->Glyph lookup. XY coords of the font and the ASCII code
{{{code: lang="rust" linenumbers="True"
colored_drawables: Vec<RuntimeVertexDef>
textured_drawables: HashMap<Arc<CanvasTextureHandle>, Vec<Vec<RuntimeVertexDef>>>
image_drawables: HashMap<Arc<CanvasImageHandle>, Vec<Vec<RuntimeVertexDef>>>
text_drawables: HashMap<Arc<CanvasFontHandle>, Vec<GlyphInstance>>
}}}
===== Future =====
I like this immediate interface for this simple style of UI and drawing.
@todo finish this
Now. The CanvasFrame is closely coupled with the Drawable trait, the object which allows CanvasFrame to ingest all drawable object on a single interface
Drawable needs a few things:
Handle to the Texture or Image it is using
Vertices describing it
(vertices will be character data for text)
Instances?
The handle is queiried and then turned into a descriptor set in the draw_commands.
* What if I pass using function params? But then how do I store???
==== Problem ====
I need to store vectors of multiple unequal types in a vec
vec<vec<T>>
Why can't I pass in
--------------------
===== Data =====
**Borrowed:**
**Owns:**
--------------------

View File

@@ -0,0 +1,30 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2020-02-03T23:42:33-08:00
====== CanvasImage ======
[[/doc/sfml_rust/canvas/canvas_buffer/struct.CanvasImage.html|Documentation]]
===== Details =====
Container class for
**<notes>**
--------------------
===== Data =====
**Borrowed:**
**Owns:**
--------------------

View File

@@ -0,0 +1,69 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2020-02-03T23:30:41-08:00
====== CanvasState ======
[[/doc/sfml_rust/canvas/canvas_state/struct.CanvasState.html|Documentation]]
===== Details =====
The gist of this class is basically draw everything 2D and have all the resources to do so. It holds binary buffer blobs for resources, it's own compiled shaders, render_pass, and all of the vertex buffers in order to draw those binary buffer blobs.
**window_size_dependent_setup** is currently hosted inside this class. If a second graphics class is added I will add some shared library for this to live.
**render_pass **the render pass is created with our depth stencil/color data **D32Sfloat_S8Uint **attachment for the render output. This is highly shader dependent. Also depends on the DynamicState
===== Interface =====
Generally there is a get for handle and pointer and a load (or create) for each of the stored items.
The class then interacts with these stored items by taking and executing a list of operations to perform on them.
CanvasFrame
Going to need some interface for getting vertices.
Some interface for getting the texture or image
--------------------
===== Data =====
**Borrowed:**
queue
device
**Owns:**
render_pass
[[CanvasImage]]
[[VKProcessor:CanvasTexture]]
[[CanvasFont]]
CompiledGraphicsPipeline
colored_vertex_buffer
image_vertex_buffer
text_instances
--------------------

View File

@@ -0,0 +1,30 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2020-02-03T23:43:28-08:00
====== CanvasTexture ======
< Link to Documentation > [[~/source/Trac3r-rust/doc/sfml_rust/vkprocessor/struct.VkProcessor.html|Documentation]]
===== Details =====
<details>
**<notes>**
--------------------
===== Data =====
**Borrowed:**
**Owns:**
--------------------

View File

@@ -0,0 +1,30 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2020-02-03T22:18:20-08:00
====== CompuState ======
[[~/source/Trac3r-rust/doc/sfml_rust/compu_state/struct.CompuState.html|Documentation]]
===== Details =====
Compustate is a very simplified sibling to the CanvasState. We only hold the binary [[~/source/Trac3r-rust/doc/sfml_rust/compu_buffer/struct.CompuBuffers.html|CompuBuffers]] and the compiled kernels to compute them.
--------------------
===== Data =====
**Borrowed:**
device
**Owns:**
[[~/source/Trac3r-rust/doc/sfml_rust/compu_buffer/struct.CompuBuffers.html|CompuBuffers]]
CompuKernel
--------------------

View File

@@ -0,0 +1,96 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2020-02-04T23:22:14-08:00
====== DynamicVertex ======
[[/doc/sfml_rust/canvas/managed/shader/dynamic_vertex/index.html|Documentation]]
[[https://vulkan-tutorial.com/Vertex_buffers/Vertex_input_description|Vulkan C++ binding equivilent]]
===== Details =====
So, the **pipeline** we create over in the **shader** needs to know about the vertex data it will be using. This lines up pretty well because the Shader is precisely the mechanism which would know about this data.
--------------------
===== Data =====
**Borrowed:**
**Owns:**
--------------------
{{{code: lang="rust" linenumbers="True"
#[derive(Default, Debug, Clone)]
pub struct RuntimeVertexDef {
buffers: Vec<(u32, usize, InputRate)>, // (attribute id, stride, Vertex or Instance data)
vertex_buffer_ids: Vec<(usize, usize)>,//
attributes: Vec<(String, u32, AttributeInfo)>,
num_vertices: u32,
}
impl RuntimeVertexDef {
/// primitive is an input value or struct which can then describe
/// these damn values that are required for inputting them into vulkan
pub fn from_primitive(primitive: u32) -> RuntimeVertexDef {
}
/// Returns the indices of the buffers to bind as vertex buffers and the byte offset, when
/// drawing the primitive.
pub fn vertex_buffer_ids(&self) -> &[(usize, usize)] {
&self.vertex_buffer_ids
}
}
unsafe impl<I> VertexDefinition<I> for RuntimeVertexDef
where I: ShaderInterfaceDef
/// Iterator that returns the offset, the stride (in bytes) and input rate of each buffer.
type BuffersIter = VecIntoIter<(u32, usize, InputRate)>;
/// Iterator that returns the attribute location, buffer id, and infos.
type AttribsIter = VecIntoIter<(u32, u32, AttributeInfo)>;
fn definition(&self, interface: &I) ->
<(Self::BuffersIter, Self::AttribsIter), IncompatibleVertexDefinitionError>{
let buffers = vec![
(0, mem::size_of::<T>(), InputRate::Vertex),
(1, mem::size_of::<U>(), InputRate::Instance),
]_iter();
}
}
unsafe impl VertexSource<Vec<Arc<dyn BufferAccess + Send + Sync>>> for RuntimeVertexDef {
fn decode(&self, bufs: Vec<Arc<dyn BufferAccess + Send + Sync>>)
-> (Vec<Box<dyn BufferAccess + Send + Sync>>, usize, usize)
{
(
bufs.into_iter().map(|b| Box::new(b) as Box<_>).collect(), // Box up the buffers
self.num_vertices as usize, // Number of vertices
1 // Number of instances
)
}
}
}}}