mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-25 08:18:43 -06:00
wip smoverlay
This commit is contained in:
parent
1bf61500b3
commit
34a0c8c648
1
kubi/shaders/c2d.wgsl
Normal file
1
kubi/shaders/c2d.wgsl
Normal file
|
@ -0,0 +1 @@
|
||||||
|
//TODO
|
|
@ -2,7 +2,9 @@ use bytemuck::{Pod, Zeroable};
|
||||||
use shipyard::{IntoWorkload, Workload};
|
use shipyard::{IntoWorkload, Workload};
|
||||||
|
|
||||||
mod cube;
|
mod cube;
|
||||||
|
mod fstri;
|
||||||
pub use cube::CubePrimitive;
|
pub use cube::CubePrimitive;
|
||||||
|
pub use fstri::FstriPrimitive;
|
||||||
|
|
||||||
pub fn init_primitives() -> Workload {
|
pub fn init_primitives() -> Workload {
|
||||||
(
|
(
|
||||||
|
@ -23,3 +25,17 @@ impl PrimitiveVertex {
|
||||||
attributes: &wgpu::vertex_attr_array![0 => Float32x3],
|
attributes: &wgpu::vertex_attr_array![0 => Float32x3],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Default, Pod, Zeroable)]
|
||||||
|
#[repr(C, packed)]
|
||||||
|
pub struct PrimitiveVertex2 {
|
||||||
|
pub position: [f32; 2],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PrimitiveVertex2 {
|
||||||
|
pub const LAYOUT: wgpu::VertexBufferLayout<'static> = wgpu::VertexBufferLayout {
|
||||||
|
array_stride: std::mem::size_of::<PrimitiveVertex2>() as wgpu::BufferAddress,
|
||||||
|
step_mode: wgpu::VertexStepMode::Vertex,
|
||||||
|
attributes: &wgpu::vertex_attr_array![0 => Float32x2],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
24
kubi/src/rendering/primitives/fstri.rs
Normal file
24
kubi/src/rendering/primitives/fstri.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
use shipyard::{AllStoragesView, Unique, UniqueView};
|
||||||
|
use wgpu::util::DeviceExt;
|
||||||
|
use crate::rendering::Renderer;
|
||||||
|
use super::PrimitiveVertex2;
|
||||||
|
|
||||||
|
pub const FSTRI_VERTICES: &[PrimitiveVertex2] = &[
|
||||||
|
PrimitiveVertex2 { position: [0.0, 0.0] },
|
||||||
|
PrimitiveVertex2 { position: [1.0, 0.0] },
|
||||||
|
PrimitiveVertex2 { position: [0.0, 1.0] },
|
||||||
|
PrimitiveVertex2 { position: [1.0, 1.0] },
|
||||||
|
];
|
||||||
|
|
||||||
|
#[derive(Unique)]
|
||||||
|
pub struct FstriPrimitive(wgpu::Buffer);
|
||||||
|
|
||||||
|
pub fn init_fstri_primitive(storages: AllStoragesView) {
|
||||||
|
let renderer = storages.borrow::<UniqueView<Renderer>>().unwrap();
|
||||||
|
let buffer = renderer.device().create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||||
|
label: Some("fstri_vertex_buffer"),
|
||||||
|
contents: bytemuck::cast_slice(FSTRI_VERTICES),
|
||||||
|
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::VERTEX,
|
||||||
|
});
|
||||||
|
storages.add_unique(FstriPrimitive(buffer));
|
||||||
|
}
|
14
kubi/src/rendering/submerge/pipeline.rs
Normal file
14
kubi/src/rendering/submerge/pipeline.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
pub fn create_render_pipeline(
|
||||||
|
ren: UniqueView<Renderer>,
|
||||||
|
stri_primitive: UniqueView<FstriPrimitive>,
|
||||||
|
) -> wgpu::RenderPipeline {
|
||||||
|
let shader = ren.device().create_shader_module(
|
||||||
|
wgpu::include_wgsl!("../../../shaders/c2d.wgsl")
|
||||||
|
);
|
||||||
|
let pipeline_layout = ren.device().create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||||
|
label: Some("smoverlay_pipeline_layout"),
|
||||||
|
bind_group_layouts: &[&ren.bind_group_layout],
|
||||||
|
push_constant_ranges: &[],
|
||||||
|
});
|
||||||
|
//TODO
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
mod pipeline;
|
||||||
|
|
||||||
// use glium::{uniform, Blend, DrawParameters, Surface};
|
// use glium::{uniform, Blend, DrawParameters, Surface};
|
||||||
// use kubi_shared::transform::Transform;
|
// use kubi_shared::transform::Transform;
|
||||||
// use shipyard::{IntoIter, NonSendSync, UniqueView, UniqueViewMut, View};
|
// use shipyard::{IntoIter, NonSendSync, UniqueView, UniqueViewMut, View};
|
||||||
|
|
Loading…
Reference in a new issue