cleanup
This commit is contained in:
@@ -1,2 +1 @@
|
||||
/target
|
||||
Cargo.lock
|
||||
Vendored
+8
-8
@@ -7,15 +7,15 @@
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug executable 'erroccfisumreg'",
|
||||
"name": "Debug executable 'erroccfisuvsc'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--bin=erroccfisumreg",
|
||||
"--package=erroccfisumreg"
|
||||
"--bin=erroccfisuvsc",
|
||||
"--package=erroccfisuvsc"
|
||||
],
|
||||
"filter": {
|
||||
"name": "erroccfisumreg",
|
||||
"name": "erroccfisuvsc",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
@@ -25,16 +25,16 @@
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in executable 'erroccfisumreg'",
|
||||
"name": "Debug unit tests in executable 'erroccfisuvsc'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--bin=erroccfisumreg",
|
||||
"--package=erroccfisumreg"
|
||||
"--bin=erroccfisuvsc",
|
||||
"--package=erroccfisuvsc"
|
||||
],
|
||||
"filter": {
|
||||
"name": "erroccfisumreg",
|
||||
"name": "erroccfisuvsc",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": ".."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
||||
Generated
+1253
-373
File diff suppressed because it is too large
Load Diff
+13
-18
@@ -1,21 +1,16 @@
|
||||
[package]
|
||||
name = "erroccfisumreg"
|
||||
name = "erroccfisuvsc"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
vulkano = "0.32"
|
||||
# Provides the `shader!` macro that is used to generate code for using shaders.
|
||||
vulkano-shaders = "0.32"
|
||||
# The Vulkan library doesn't provide any functionality to create and handle windows, as
|
||||
# this would be out of scope. In order to open a window, we are going to use the `winit` crate.
|
||||
winit = "0.28"
|
||||
# The `vulkano_win` crate is the link between `vulkano` and `winit`. Vulkano doesn't know about winit,
|
||||
# and winit doesn't know about vulkano, so import a crate that will provide a link between the two.
|
||||
vulkano-win = "0.32"
|
||||
vulkano-util = "0.32"
|
||||
vulkano = "0.34"
|
||||
vulkano-shaders = "0.34"
|
||||
winit = "0.30"
|
||||
vulkano-win = "0.34"
|
||||
vulkano-util = "0.34"
|
||||
|
||||
obj = "0.10"
|
||||
bytemuck = { version = "1.13", features = [
|
||||
@@ -26,8 +21,8 @@ bytemuck = { version = "1.13", features = [
|
||||
|
||||
cgmath = "0.18"
|
||||
|
||||
egui = "0.21"
|
||||
egui_winit_vulkano = "0.23"
|
||||
egui = "0.30"
|
||||
egui_winit_vulkano = "0.27"
|
||||
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
@@ -40,8 +35,8 @@ rand = "0.8.5"
|
||||
|
||||
# using latest gits
|
||||
[patch.crates-io]
|
||||
vulkano = { git = "https://github.com/Molive-0/vulkano" }
|
||||
vulkano-shaders = { git = "https://github.com/Molive-0/vulkano" }
|
||||
vulkano-win = { git = "https://github.com/Molive-0/vulkano" }
|
||||
vulkano-util = { git = "https://github.com/Molive-0/vulkano" }
|
||||
egui_winit_vulkano = { git = "https://github.com/Molive-0/egui_winit_vulkano" }
|
||||
vulkano = { git = "https://github.com/vulkano-rs/vulkano" }
|
||||
vulkano-shaders = { git = "https://github.com/vulkano-rs/vulkano" }
|
||||
vulkano-win = { git = "https://github.com/vulkano-rs/vulkano" }
|
||||
vulkano-util = { git = "https://github.com/vulkano-rs/vulkano" }
|
||||
egui_winit_vulkano = { git = "https://github.com/hakolao/egui_winit_vulkano" }
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# Efficient Realtime Rendering of Complex Closed Form Implicit Surfaces Using Modern RTX Enabled GPUs
|
||||
# Efficient Realtime Rendering of Complex Closed Form Implicit Surfaces Using Vulkan Specialisation Constants
|
||||
|
||||
## See the [report](https://mo.molive.live/dump/Final_Report.pdf)
|
||||
"The elites don’t want you to know this but the Specialisation Constants at the Vulkan are free you can take them home I have 458 Specialisation Constants." - Adolphe Vulk, inventor of Vulkan
|
||||
@@ -1,11 +1,10 @@
|
||||
use std::env;
|
||||
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::BufRead;
|
||||
use std::io::BufReader;
|
||||
use std::path::Path;
|
||||
use std::{
|
||||
env, fs,
|
||||
fs::File,
|
||||
io,
|
||||
io::{BufRead, BufReader},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
println!("cargo:rerun-if-changed=src/instructionset.glsl");
|
||||
|
||||
+124
-32
@@ -58,31 +58,61 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
|
||||
.frame(Frame::default().fill(Color32::from_rgba_unmultiplied(50, 50, 50, 200)))
|
||||
.show(&ctx, |ui| {
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.add(egui::widgets::Label::new("Efficient Realtime Rendering of Complex Closed Form Implicit Surfaces Using Modern RTX Enabled GPUs"));
|
||||
ui.add(egui::widgets::Label::new(
|
||||
"Efficient Realtime Rendering of Complex Closed Form Implicit Surfaces \
|
||||
Using Modern RTX Enabled GPUs",
|
||||
));
|
||||
sized_text(ui, "Settings", 32.0);
|
||||
});
|
||||
ui.separator();
|
||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.heading("Camera Control");
|
||||
ui.add(egui::Slider::new(&mut state.cursor_sensitivity, 0.0..=2.0).text("Mouse Sensitivity"));
|
||||
ui.add(egui::Slider::new(&mut state.move_speed, 0.0..=2.0).text("Movement Speed"));
|
||||
ui.add(
|
||||
egui::Slider::new(&mut state.cursor_sensitivity, 0.0..=2.0)
|
||||
.text("Mouse Sensitivity"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut state.move_speed, 0.0..=2.0)
|
||||
.text("Movement Speed"),
|
||||
);
|
||||
ui.heading("Meshes");
|
||||
let mut meshdel = vec![];
|
||||
for mesh in &mut state.meshes {
|
||||
ui.label(mesh.name.clone());
|
||||
meshdel.push(ui.small_button("remove mesh").clicked());
|
||||
ui.add(egui::Slider::new(&mut mesh.pos.x, -100.0..=100.0).text("Position.x"));
|
||||
ui.add(egui::Slider::new(&mut mesh.pos.y, -100.0..=100.0).text("Position.y"));
|
||||
ui.add(egui::Slider::new(&mut mesh.pos.z, -100.0..=100.0).text("Position.z"));
|
||||
ui.add(egui::Slider::new(&mut mesh.rot.x.0, 0.0..=360.0).text("Rotation.x"));
|
||||
ui.add(egui::Slider::new(&mut mesh.rot.y.0, 0.0..=360.0).text("Rotation.y"));
|
||||
ui.add(egui::Slider::new(&mut mesh.rot.z.0, 0.0..=360.0).text("Rotation.z"));
|
||||
ui.add(
|
||||
egui::Slider::new(&mut mesh.pos.x, -100.0..=100.0)
|
||||
.text("Position.x"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut mesh.pos.y, -100.0..=100.0)
|
||||
.text("Position.y"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut mesh.pos.z, -100.0..=100.0)
|
||||
.text("Position.z"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut mesh.rot.x.0, 0.0..=360.0)
|
||||
.text("Rotation.x"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut mesh.rot.y.0, 0.0..=360.0)
|
||||
.text("Rotation.y"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut mesh.rot.z.0, 0.0..=360.0)
|
||||
.text("Rotation.z"),
|
||||
);
|
||||
ui.add(egui::Slider::new(&mut mesh.scale.x, 0.0..=2.0).text("Scale.x"));
|
||||
ui.add(egui::Slider::new(&mut mesh.scale.y, 0.0..=2.0).text("Scale.y"));
|
||||
ui.add(egui::Slider::new(&mut mesh.scale.z, 0.0..=2.0).text("Scale.z"));
|
||||
}
|
||||
for i in meshdel.into_iter().enumerate().filter_map(|(a,b)| if b {Some(a)} else {None})
|
||||
for i in meshdel
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.filter_map(|(a, b)| if b { Some(a) } else { None })
|
||||
{
|
||||
state.meshes.remove(i);
|
||||
}
|
||||
@@ -91,17 +121,35 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
|
||||
for csg in &mut state.csg {
|
||||
ui.label(csg.name.clone());
|
||||
csgdel.push(ui.small_button("remove csg").clicked());
|
||||
ui.add(egui::Slider::new(&mut csg.pos.x, -100.0..=100.0).text("Position.x"));
|
||||
ui.add(egui::Slider::new(&mut csg.pos.y, -100.0..=100.0).text("Position.y"));
|
||||
ui.add(egui::Slider::new(&mut csg.pos.z, -100.0..=100.0).text("Position.z"));
|
||||
ui.add(egui::Slider::new(&mut csg.rot.x.0, 0.0..=360.0).text("Rotation.x"));
|
||||
ui.add(egui::Slider::new(&mut csg.rot.y.0, 0.0..=360.0).text("Rotation.y"));
|
||||
ui.add(egui::Slider::new(&mut csg.rot.z.0, 0.0..=360.0).text("Rotation.z"));
|
||||
ui.add(
|
||||
egui::Slider::new(&mut csg.pos.x, -100.0..=100.0)
|
||||
.text("Position.x"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut csg.pos.y, -100.0..=100.0)
|
||||
.text("Position.y"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut csg.pos.z, -100.0..=100.0)
|
||||
.text("Position.z"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut csg.rot.x.0, 0.0..=360.0).text("Rotation.x"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut csg.rot.y.0, 0.0..=360.0).text("Rotation.y"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut csg.rot.z.0, 0.0..=360.0).text("Rotation.z"),
|
||||
);
|
||||
ui.add(egui::Slider::new(&mut csg.scale.x, 0.0..=2.0).text("Scale.x"));
|
||||
ui.add(egui::Slider::new(&mut csg.scale.y, 0.0..=2.0).text("Scale.y"));
|
||||
ui.add(egui::Slider::new(&mut csg.scale.z, 0.0..=2.0).text("Scale.z"));
|
||||
}
|
||||
for i in csgdel.into_iter().enumerate().filter_map(|(a,b)| if b {Some(a)} else {None})
|
||||
for i in csgdel
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.filter_map(|(a, b)| if b { Some(a) } else { None })
|
||||
{
|
||||
state.csg.remove(i);
|
||||
}
|
||||
@@ -110,14 +158,32 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
|
||||
for light in &mut state.lights {
|
||||
ui.label("Light");
|
||||
lightdel.push(ui.small_button("remove light").clicked());
|
||||
ui.add(egui::Slider::new(&mut light.pos.x, -100.0..=100.0).text("Position.x"));
|
||||
ui.add(egui::Slider::new(&mut light.pos.y, -100.0..=100.0).text("Position.y"));
|
||||
ui.add(egui::Slider::new(&mut light.pos.z, -100.0..=100.0).text("Position.z"));
|
||||
ui.add(egui::Slider::new(&mut light.colour.x, 0.0..=1.0).text("Colour.r"));
|
||||
ui.add(egui::Slider::new(&mut light.colour.y, 0.0..=1.0).text("Colour.g"));
|
||||
ui.add(egui::Slider::new(&mut light.colour.z, 0.0..=1.0).text("Colour.b"));
|
||||
ui.add(
|
||||
egui::Slider::new(&mut light.pos.x, -100.0..=100.0)
|
||||
.text("Position.x"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut light.pos.y, -100.0..=100.0)
|
||||
.text("Position.y"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut light.pos.z, -100.0..=100.0)
|
||||
.text("Position.z"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut light.colour.x, 0.0..=1.0).text("Colour.r"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut light.colour.y, 0.0..=1.0).text("Colour.g"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut light.colour.z, 0.0..=1.0).text("Colour.b"),
|
||||
);
|
||||
}
|
||||
for i in lightdel.into_iter().enumerate().filter_map(|(a,b)| if b {Some(a)} else {None})
|
||||
for i in lightdel
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.filter_map(|(a, b)| if b { Some(a) } else { None })
|
||||
{
|
||||
state.lights.remove(i);
|
||||
}
|
||||
@@ -125,18 +191,44 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
|
||||
state.lights.push(Light::default());
|
||||
}
|
||||
|
||||
let fps: PlotPoints = state.fps.iter().enumerate().map(|(x,y)| [x as f64,*y]).collect::<Vec<_>>().into();
|
||||
let fps: PlotPoints = state
|
||||
.fps
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(x, y)| [x as f64, *y])
|
||||
.collect::<Vec<_>>()
|
||||
.into();
|
||||
let line = Line::new(fps);
|
||||
ui.heading("FPS");
|
||||
Plot::new("fps").view_aspect(2.0).show(ui, |plot_ui| plot_ui.line(line));
|
||||
Plot::new("fps")
|
||||
.view_aspect(2.0)
|
||||
.show(ui, |plot_ui| plot_ui.line(line));
|
||||
|
||||
ui.heading("Debug");
|
||||
ui.toggle_value(&mut state.debug.bounding_boxes, "Render bounding boxes instead");
|
||||
ui.toggle_value(&mut state.debug.disable_meshcull, "Disable mesh shader culling");
|
||||
ui.toggle_value(&mut state.debug.disable_meshscale1, "Disable mesh shader scaling part 1");
|
||||
ui.toggle_value(&mut state.debug.disable_meshscale2, "Disable mesh shader scaling part 2");
|
||||
ui.toggle_value(&mut state.debug.disable_taskcull, "Disable task shader culling");
|
||||
ui.toggle_value(&mut state.debug.brute_force, "Brute force the render (use no new techniques)");
|
||||
ui.toggle_value(
|
||||
&mut state.debug.bounding_boxes,
|
||||
"Render bounding boxes instead",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut state.debug.disable_meshcull,
|
||||
"Disable mesh shader culling",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut state.debug.disable_meshscale1,
|
||||
"Disable mesh shader scaling part 1",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut state.debug.disable_meshscale2,
|
||||
"Disable mesh shader scaling part 2",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut state.debug.disable_taskcull,
|
||||
"Disable task shader culling",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut state.debug.brute_force,
|
||||
"Brute force the render (use no new techniques)",
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+221
-224
File diff suppressed because it is too large
Load Diff
+295
-163
@@ -1,65 +1,58 @@
|
||||
#![feature(variant_count)]
|
||||
use bytemuck::{Zeroable, Pod};
|
||||
use cgmath::{
|
||||
Deg, EuclideanSpace, Euler, Matrix3, Matrix4, Point3, Rad, SquareMatrix,
|
||||
Vector3,
|
||||
};
|
||||
use instruction_set::InputTypes;
|
||||
use vulkano::command_buffer::{CopyBufferInfo, PrimaryCommandBufferAbstract};
|
||||
use std::io::Cursor;
|
||||
use std::{sync::Arc, time::Instant};
|
||||
use vulkano::buffer::allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo};
|
||||
use vulkano::buffer::{Buffer, BufferAllocateInfo, Subbuffer};
|
||||
use vulkano::command_buffer::allocator::StandardCommandBufferAllocator;
|
||||
use vulkano::descriptor_set::allocator::StandardDescriptorSetAllocator;
|
||||
use vulkano::descriptor_set::{PersistentDescriptorSet, WriteDescriptorSet};
|
||||
use vulkano::device::{DeviceOwned, Features, QueueFlags, Queue};
|
||||
use vulkano::format::Format;
|
||||
|
||||
use vulkano::image::view::ImageViewCreateInfo;
|
||||
use vulkano::image::{AttachmentImage, SampleCount};
|
||||
use vulkano::memory::allocator::{MemoryAllocatePreference, MemoryUsage, StandardMemoryAllocator};
|
||||
use vulkano::pipeline::graphics::depth_stencil::DepthStencilState;
|
||||
use vulkano::pipeline::graphics::multisample::MultisampleState;
|
||||
use vulkano::pipeline::graphics::rasterization::CullMode;
|
||||
use vulkano::pipeline::graphics::rasterization::FrontFace::Clockwise;
|
||||
use vulkano::pipeline::graphics::vertex_input::Vertex;
|
||||
use vulkano::pipeline::PipelineBindPoint;
|
||||
use vulkano::shader::{ShaderModule, SpecializationConstants};
|
||||
use vulkano::swapchain::{PresentMode, SwapchainPresentInfo};
|
||||
use vulkano::VulkanLibrary;
|
||||
use winit::event::{DeviceEvent, ElementState, MouseButton, VirtualKeyCode};
|
||||
use std::{io::Cursor, sync::Arc, time::Instant};
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use cgmath::{Deg, EuclideanSpace, Euler, Matrix3, Matrix4, Point3, Rad, SquareMatrix, Vector3};
|
||||
use egui_winit_vulkano::{Gui, GuiConfig};
|
||||
use instruction_set::InputTypes;
|
||||
use rayon::prelude::*;
|
||||
use vulkano::pipeline::StateMode::Fixed;
|
||||
use vulkano::{
|
||||
buffer::BufferUsage,
|
||||
buffer::{
|
||||
allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
|
||||
Buffer, BufferAllocateInfo, BufferUsage, Subbuffer,
|
||||
},
|
||||
command_buffer::{
|
||||
AutoCommandBufferBuilder, CommandBufferUsage, RenderPassBeginInfo, SubpassContents,
|
||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||
CopyBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, SubpassContents,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
|
||||
},
|
||||
device::{
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, DeviceOwned,
|
||||
Features, Queue, QueueCreateInfo, QueueFlags,
|
||||
},
|
||||
format::Format,
|
||||
image::{
|
||||
view::{ImageView, ImageViewCreateInfo},
|
||||
AttachmentImage, ImageAccess, ImageUsage, SampleCount, SwapchainImage,
|
||||
},
|
||||
image::{view::ImageView, ImageAccess, ImageUsage, SwapchainImage},
|
||||
instance::{Instance, InstanceCreateInfo, InstanceExtensions},
|
||||
memory::allocator::{MemoryAllocatePreference, MemoryUsage, StandardMemoryAllocator},
|
||||
pipeline::{
|
||||
graphics::{
|
||||
depth_stencil::DepthStencilState,
|
||||
input_assembly::InputAssemblyState,
|
||||
rasterization::RasterizationState,
|
||||
multisample::MultisampleState,
|
||||
rasterization::{CullMode, FrontFace::Clockwise, RasterizationState},
|
||||
vertex_input::Vertex,
|
||||
viewport::{Viewport, ViewportState},
|
||||
},
|
||||
GraphicsPipeline, Pipeline,
|
||||
GraphicsPipeline, Pipeline, PipelineBindPoint,
|
||||
StateMode::Fixed,
|
||||
},
|
||||
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
|
||||
shader::{ShaderModule, SpecializationConstants},
|
||||
swapchain::{
|
||||
acquire_next_image, AcquireError, Swapchain, SwapchainCreateInfo, SwapchainCreationError,
|
||||
acquire_next_image, AcquireError, PresentMode, Swapchain, SwapchainCreateInfo,
|
||||
SwapchainCreationError, SwapchainPresentInfo,
|
||||
},
|
||||
sync::{self, FlushError, GpuFuture},
|
||||
VulkanLibrary,
|
||||
};
|
||||
use vulkano_win::VkSurfaceBuild;
|
||||
use winit::{
|
||||
event::{Event, WindowEvent},
|
||||
event::{DeviceEvent, ElementState, Event, MouseButton, VirtualKeyCode, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
window::{Window, WindowBuilder},
|
||||
};
|
||||
@@ -67,8 +60,7 @@ use winit::{
|
||||
mod gui;
|
||||
use crate::gui::*;
|
||||
mod objects;
|
||||
use crate::interpreter::Interpreter;
|
||||
use crate::objects::*;
|
||||
use crate::{interpreter::Interpreter, objects::*};
|
||||
mod mcsg_deserialise;
|
||||
|
||||
mod instruction_set {
|
||||
@@ -91,7 +83,8 @@ fn main() {
|
||||
enabled_extensions: InstanceExtensions {
|
||||
..required_extensions
|
||||
},
|
||||
// Enable enumerating devices that use non-conformant vulkan implementations. (ex. MoltenVK)
|
||||
// Enable enumerating devices that use non-conformant vulkan implementations. (ex.
|
||||
// MoltenVK)
|
||||
enumerate_portability: true,
|
||||
..Default::default()
|
||||
},
|
||||
@@ -122,21 +115,23 @@ fn main() {
|
||||
.position(|(i, q)| {
|
||||
q.queue_flags.intersects(QueueFlags::GRAPHICS)
|
||||
&& p.surface_support(i as u32, &surface).unwrap_or(false)
|
||||
}).and_then( | graphics| {
|
||||
})
|
||||
.and_then(|graphics| {
|
||||
p.queue_family_properties()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.position(|(i, q)| {
|
||||
q.queue_flags.intersects(QueueFlags::TRANSFER) && i != graphics
|
||||
}).or_else( || {
|
||||
})
|
||||
.or_else(|| {
|
||||
p.queue_family_properties()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.position(|(_i, q)| {
|
||||
q.queue_flags.intersects(QueueFlags::TRANSFER)
|
||||
})}
|
||||
|
||||
).map(|i| (graphics as u32, i as u32))}).map(|i| (p, i))
|
||||
.position(|(_i, q)| q.queue_flags.intersects(QueueFlags::TRANSFER))
|
||||
})
|
||||
.map(|i| (graphics as u32, i as u32))
|
||||
})
|
||||
.map(|i| (p, i))
|
||||
})
|
||||
.min_by_key(|(p, _)| {
|
||||
// We assign a lower score to device types that are likely to be faster/better.
|
||||
@@ -149,7 +144,10 @@ fn main() {
|
||||
_ => 5,
|
||||
}
|
||||
})
|
||||
.expect("No suitable physical device found. Do you have a Mesh Shader capable GPU and are your drivers up to date?");
|
||||
.expect(
|
||||
"No suitable physical device found. Do you have a Mesh Shader capable GPU and are \
|
||||
your drivers up to date?",
|
||||
);
|
||||
|
||||
// Some little debug infos.
|
||||
println!(
|
||||
@@ -162,14 +160,16 @@ fn main() {
|
||||
physical_device,
|
||||
DeviceCreateInfo {
|
||||
enabled_extensions: device_extensions,
|
||||
queue_create_infos: vec![QueueCreateInfo {
|
||||
queue_create_infos: vec![
|
||||
QueueCreateInfo {
|
||||
queue_family_index,
|
||||
..Default::default()
|
||||
},
|
||||
QueueCreateInfo {
|
||||
queue_family_index: transfer_index,
|
||||
..Default::default()
|
||||
}],
|
||||
},
|
||||
],
|
||||
enabled_features: Features {
|
||||
mesh_shader: true,
|
||||
task_shader: true,
|
||||
@@ -294,7 +294,6 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let loaders: Vec<
|
||||
fn(
|
||||
::std::sync::Arc<::vulkano::device::Device>,
|
||||
@@ -431,14 +430,19 @@ fn main() {
|
||||
&images,
|
||||
render_pass.clone(),
|
||||
&mut viewport,
|
||||
|
||||
implicit_fs::SpecializationConstants {DISABLE_TRACE:gstate.debug.bounding_boxes as u32,
|
||||
BRUTE_FORCE:gstate.debug.brute_force as u32,},
|
||||
implicit_ms::SpecializationConstants {DISABLE_TRACE:gstate.debug.disable_meshcull as u32,
|
||||
implicit_fs::SpecializationConstants {
|
||||
DISABLE_TRACE: gstate.debug.bounding_boxes as u32,
|
||||
BRUTE_FORCE: gstate.debug.brute_force as u32,
|
||||
},
|
||||
implicit_ms::SpecializationConstants {
|
||||
DISABLE_TRACE: gstate.debug.disable_meshcull as u32,
|
||||
DISABLE_SCALING_1: gstate.debug.disable_meshscale1 as u32,
|
||||
DISABLE_SCALING_2: gstate.debug.disable_meshscale2 as u32,
|
||||
BRUTE_FORCE:gstate.debug.brute_force as u32,},
|
||||
implicit_ts::SpecializationConstants {DISABLE_TRACE:gstate.debug.disable_taskcull as u32},
|
||||
BRUTE_FORCE: gstate.debug.brute_force as u32,
|
||||
},
|
||||
implicit_ts::SpecializationConstants {
|
||||
DISABLE_TRACE: gstate.debug.disable_taskcull as u32,
|
||||
},
|
||||
gstate.debug.brute_force,
|
||||
);
|
||||
|
||||
@@ -467,8 +471,8 @@ fn main() {
|
||||
GuiConfig {
|
||||
preferred_format: Some(images[0].format()),
|
||||
is_overlay: true,
|
||||
samples: SampleCount::Sample4
|
||||
}
|
||||
samples: SampleCount::Sample4,
|
||||
},
|
||||
);
|
||||
|
||||
let mut campos = Point3 {
|
||||
@@ -518,7 +522,14 @@ fn main() {
|
||||
.lights
|
||||
.push(Light::new([-4., 6., -8.], [8., 4., 1.], 0.05));
|
||||
|
||||
let subbuffers = object_size_dependent_setup(memory_allocator.clone(), &gstate.csg, &command_buffer_allocator, transfer_queue.clone(), None, false);
|
||||
let subbuffers = object_size_dependent_setup(
|
||||
memory_allocator.clone(),
|
||||
&gstate.csg,
|
||||
&command_buffer_allocator,
|
||||
transfer_queue.clone(),
|
||||
None,
|
||||
false,
|
||||
);
|
||||
|
||||
let mut prevdub = PreviousDebug::default();
|
||||
|
||||
@@ -530,16 +541,16 @@ fn main() {
|
||||
match &we {
|
||||
WindowEvent::CloseRequested => {
|
||||
*control_flow = ControlFlow::Exit;
|
||||
}
|
||||
},
|
||||
WindowEvent::Resized(_) => {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
},
|
||||
WindowEvent::ScaleFactorChanged { .. } => {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
},
|
||||
WindowEvent::DroppedFile(_file) => {
|
||||
todo!()
|
||||
}
|
||||
},
|
||||
WindowEvent::MouseInput {
|
||||
device_id: d,
|
||||
state: s,
|
||||
@@ -550,23 +561,23 @@ fn main() {
|
||||
if b == &MouseButton::Right {
|
||||
looking = s == &ElementState::Pressed;
|
||||
}
|
||||
}
|
||||
},
|
||||
WindowEvent::KeyboardInput { input, .. } => match input.virtual_keycode {
|
||||
Some(VirtualKeyCode::W) => {
|
||||
keys.w = input.state == ElementState::Pressed;
|
||||
}
|
||||
},
|
||||
Some(VirtualKeyCode::S) => {
|
||||
keys.s = input.state == ElementState::Pressed;
|
||||
}
|
||||
},
|
||||
Some(VirtualKeyCode::A) => {
|
||||
keys.a = input.state == ElementState::Pressed;
|
||||
}
|
||||
},
|
||||
Some(VirtualKeyCode::D) => {
|
||||
keys.d = input.state == ElementState::Pressed;
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
_ => {}
|
||||
_ => {},
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -581,7 +592,7 @@ fn main() {
|
||||
camforward.x += Deg(360f32) % Deg(360f32);
|
||||
camforward.y += Deg(360f32) % Deg(360f32);
|
||||
}
|
||||
}
|
||||
},
|
||||
Event::RedrawEventsCleared => {
|
||||
for i in 1..gstate.fps.len() {
|
||||
gstate.fps[i - 1] = gstate.fps[i];
|
||||
@@ -628,13 +639,19 @@ fn main() {
|
||||
&new_images,
|
||||
render_pass.clone(),
|
||||
&mut viewport,
|
||||
implicit_fs::SpecializationConstants {DISABLE_TRACE:gstate.debug.bounding_boxes as u32,
|
||||
BRUTE_FORCE:gstate.debug.brute_force as u32},
|
||||
implicit_ms::SpecializationConstants {DISABLE_TRACE:gstate.debug.disable_meshcull as u32,
|
||||
implicit_fs::SpecializationConstants {
|
||||
DISABLE_TRACE: gstate.debug.bounding_boxes as u32,
|
||||
BRUTE_FORCE: gstate.debug.brute_force as u32,
|
||||
},
|
||||
implicit_ms::SpecializationConstants {
|
||||
DISABLE_TRACE: gstate.debug.disable_meshcull as u32,
|
||||
DISABLE_SCALING_1: gstate.debug.disable_meshscale1 as u32,
|
||||
DISABLE_SCALING_2: gstate.debug.disable_meshscale2 as u32,
|
||||
BRUTE_FORCE:gstate.debug.brute_force as u32},
|
||||
implicit_ts::SpecializationConstants {DISABLE_TRACE:gstate.debug.disable_taskcull as u32},
|
||||
BRUTE_FORCE: gstate.debug.brute_force as u32,
|
||||
},
|
||||
implicit_ts::SpecializationConstants {
|
||||
DISABLE_TRACE: gstate.debug.disable_taskcull as u32,
|
||||
},
|
||||
gstate.debug.brute_force,
|
||||
);
|
||||
recreate_swapchain = false;
|
||||
@@ -774,35 +791,78 @@ fn main() {
|
||||
const COMPUTE_FUZZING: bool = false;
|
||||
|
||||
if COMPUTE_FUZZING {
|
||||
|
||||
let mut fake_csg = vec![];
|
||||
for i in 0..32
|
||||
{
|
||||
fake_csg.push(
|
||||
CSG{ name: format!("fuzz_{i}"), parts: vec![
|
||||
CSGPart::opcode(InstructionSet::OPMulVec3Float, vec![Inputs::Variable, Inputs::Float(0.9)]),
|
||||
for i in 0..32 {
|
||||
fake_csg.push(CSG {
|
||||
name: format!("fuzz_{i}"),
|
||||
parts: vec![
|
||||
CSGPart::opcode(
|
||||
InstructionSet::OPMulVec3Float,
|
||||
vec![Inputs::Variable, Inputs::Float(0.9)],
|
||||
),
|
||||
CSGPart::opcode(InstructionSet::OPDupVec3, vec![Inputs::Variable]),
|
||||
CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![Inputs::Variable, Inputs::Vec3([-0.7, (i as f64), -0.7].into())]),
|
||||
CSGPart::opcode(InstructionSet::OPSDFSphere,vec![Inputs::Float(0.5), Inputs::Variable]),
|
||||
CSGPart::opcode(
|
||||
InstructionSet::OPAddVec3Vec3,
|
||||
vec![
|
||||
Inputs::Variable,
|
||||
Inputs::Vec3([-0.7, (i as f64), -0.7].into()),
|
||||
],
|
||||
),
|
||||
CSGPart::opcode(
|
||||
InstructionSet::OPSDFSphere,
|
||||
vec![Inputs::Float(0.5), Inputs::Variable],
|
||||
),
|
||||
//CSGPart::opcode(InstructionSet::OPNop,vec![]),
|
||||
//CSGPart::opcode(InstructionSet::OPDupVec3, vec![Inputs::Variable]),
|
||||
//CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![Inputs::Variable, Inputs::Vec3([-0.2, -0.2, -0.2].into())]),
|
||||
//CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![Inputs::Variable, Inputs::Vec3([-0.0, -0.0, -0.0].into())]),
|
||||
CSGPart::opcode(InstructionSet::OPSDFSphere,vec![Inputs::Float(1.2), Inputs::Variable]),
|
||||
//CSGPart::opcode(InstructionSet::OPSDFBox, vec![Inputs::Variable, Inputs::Vec3([0.7, 0.7, 0.7].into())]),
|
||||
CSGPart::opcode(InstructionSet::OPMinFloat, vec![Inputs::Variable,Inputs::Variable]),
|
||||
CSGPart::opcode(InstructionSet::OPDivFloatFloat, vec![Inputs::Variable, Inputs::Float(0.9)]),
|
||||
//CSGPart::opcode(InstructionSet::OPDupVec3,
|
||||
// vec![Inputs::Variable]),
|
||||
// CSGPart::opcode(InstructionSet::OPAddVec3Vec3,
|
||||
// vec![Inputs::Variable, Inputs::Vec3([-0.2, -0.2,
|
||||
// -0.2].into())]),
|
||||
// CSGPart::opcode(InstructionSet::OPAddVec3Vec3,
|
||||
// vec![Inputs::Variable, Inputs::Vec3([-0.0, -0.0,
|
||||
// -0.0].into())]),
|
||||
CSGPart::opcode(
|
||||
InstructionSet::OPSDFSphere,
|
||||
vec![Inputs::Float(1.2), Inputs::Variable],
|
||||
),
|
||||
//CSGPart::opcode(InstructionSet::OPSDFBox, vec![Inputs::Variable,
|
||||
// Inputs::Vec3([0.7, 0.7, 0.7].into())]),
|
||||
CSGPart::opcode(
|
||||
InstructionSet::OPMinFloat,
|
||||
vec![Inputs::Variable, Inputs::Variable],
|
||||
),
|
||||
CSGPart::opcode(
|
||||
InstructionSet::OPDivFloatFloat,
|
||||
vec![Inputs::Variable, Inputs::Float(0.9)],
|
||||
),
|
||||
CSGPart::opcode(InstructionSet::OPStop, vec![Inputs::Variable]),
|
||||
], pos: Point3::origin(), rot: Euler { x: Deg(0.), y: Deg(0.), z: Deg(0.) }, scale: Vector3 { x: 1., y: 1., z: 1. } }
|
||||
)
|
||||
],
|
||||
pos: Point3::origin(),
|
||||
rot: Euler {
|
||||
x: Deg(0.),
|
||||
y: Deg(0.),
|
||||
z: Deg(0.),
|
||||
},
|
||||
scale: Vector3 {
|
||||
x: 1.,
|
||||
y: 1.,
|
||||
z: 1.,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
let compute_subbuffers = object_size_dependent_setup(memory_allocator.clone(), &fake_csg, &command_buffer_allocator, transfer_queue.clone(), Some(
|
||||
[1.,1.,1.,1.,5.,1.]
|
||||
),true);
|
||||
|
||||
let compute_result_buffer:Subbuffer<[cs::Results]> = uniform_buffer.allocate_slice((fake_csg.len()+1) as u64).unwrap();
|
||||
let compute_subbuffers = object_size_dependent_setup(
|
||||
memory_allocator.clone(),
|
||||
&fake_csg,
|
||||
&command_buffer_allocator,
|
||||
transfer_queue.clone(),
|
||||
Some([1., 1., 1., 1., 5., 1.]),
|
||||
true,
|
||||
);
|
||||
|
||||
let compute_result_buffer: Subbuffer<[cs::Results]> = uniform_buffer
|
||||
.allocate_slice((fake_csg.len() + 1) as u64)
|
||||
.unwrap();
|
||||
|
||||
let compute_layout = compute_pipeline.layout().set_layouts().get(0).unwrap();
|
||||
let compute_set = PersistentDescriptorSet::new(
|
||||
@@ -823,7 +883,8 @@ fn main() {
|
||||
//WriteDescriptorSet::buffer(11, compute_subbuffers.mats.clone()),
|
||||
WriteDescriptorSet::buffer(12, compute_subbuffers.deps),
|
||||
//WriteDescriptorSet::buffer(20, compute_subbuffers.masks.clone()),
|
||||
WriteDescriptorSet::buffer(30, compute_result_buffer.clone()),],
|
||||
WriteDescriptorSet::buffer(30, compute_result_buffer.clone()),
|
||||
],
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -871,7 +932,7 @@ fn main() {
|
||||
Err(AcquireError::OutOfDate) => {
|
||||
recreate_swapchain = true;
|
||||
return;
|
||||
}
|
||||
},
|
||||
Err(e) => panic!("Failed to acquire next image: {e:?}"),
|
||||
};
|
||||
|
||||
@@ -982,23 +1043,24 @@ fn main() {
|
||||
match future {
|
||||
Ok(future) => {
|
||||
previous_frame_end = Some(future.boxed());
|
||||
}
|
||||
},
|
||||
Err(FlushError::OutOfDate) => {
|
||||
recreate_swapchain = true;
|
||||
previous_frame_end = Some(sync::now(device.clone()).boxed());
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
println!("Failed to flush future: {e:?}");
|
||||
previous_frame_end = Some(sync::now(device.clone()).boxed());
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// This method is called once during initialization, then again whenever the window is resized
|
||||
/// This method is called once during initialization, then again whenever the
|
||||
/// window is resized
|
||||
fn window_size_dependent_setup<Fs, Ms, Ts>(
|
||||
allocator: &StandardMemoryAllocator,
|
||||
mesh_vs: &ShaderModule,
|
||||
@@ -1131,15 +1193,13 @@ where
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
let built_implicit_pipeline =
|
||||
if !brute_force {
|
||||
implicit_pipeline.task_shader(implicit_ts.entry_point("main").unwrap(),implicit_ts_specs)
|
||||
let built_implicit_pipeline = if !brute_force {
|
||||
implicit_pipeline
|
||||
.task_shader(implicit_ts.entry_point("main").unwrap(), implicit_ts_specs)
|
||||
.build(allocator.device().clone())
|
||||
.unwrap()
|
||||
} else {
|
||||
implicit_pipeline
|
||||
.build(allocator.device().clone())
|
||||
.unwrap()
|
||||
implicit_pipeline.build(allocator.device().clone()).unwrap()
|
||||
};
|
||||
|
||||
println!("Implicit pipeline compiled");
|
||||
@@ -1147,7 +1207,6 @@ where
|
||||
([mesh_pipeline, built_implicit_pipeline], framebuffers)
|
||||
}
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Pod, Zeroable, Default, Debug)]
|
||||
struct Description {
|
||||
@@ -1193,7 +1252,7 @@ fn gpu_buffer<T>(
|
||||
transfer_queue: Arc<Queue>,
|
||||
) -> Subbuffer<[T]>
|
||||
where
|
||||
T: bytemuck::Pod + Send + Sync
|
||||
T: bytemuck::Pod + Send + Sync,
|
||||
{
|
||||
let buffer = Buffer::new_slice(
|
||||
allocator,
|
||||
@@ -1216,13 +1275,13 @@ where
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
)
|
||||
.unwrap();
|
||||
builder.copy_buffer(CopyBufferInfo::buffers(
|
||||
staging,
|
||||
buffer.clone())
|
||||
).unwrap();
|
||||
builder
|
||||
.copy_buffer(CopyBufferInfo::buffers(staging, buffer.clone()))
|
||||
.unwrap();
|
||||
let commands = builder.build().unwrap();
|
||||
|
||||
commands.execute(transfer_queue)
|
||||
commands
|
||||
.execute(transfer_queue)
|
||||
.unwrap()
|
||||
.then_signal_fence_and_flush()
|
||||
.unwrap()
|
||||
@@ -1232,13 +1291,10 @@ where
|
||||
buffer
|
||||
}
|
||||
|
||||
fn f64tof32<const A:usize>(input: [[f64;A];A]) -> [[f32;A];A]
|
||||
{
|
||||
fn f64tof32<const A: usize>(input: [[f64; A]; A]) -> [[f32; A]; A] {
|
||||
let mut out = [[0_f32; A]; A];
|
||||
for x in 0..input.len()
|
||||
{
|
||||
for y in 0..input.len()
|
||||
{
|
||||
for x in 0..input.len() {
|
||||
for y in 0..input.len() {
|
||||
out[x][y] = input[x][y] as f32;
|
||||
}
|
||||
}
|
||||
@@ -1280,19 +1336,41 @@ fn object_size_dependent_setup(
|
||||
];
|
||||
|
||||
let example = vec![
|
||||
CSGPart::opcode(InstructionSet::OPMulVec3Float, vec![Inputs::Variable, Inputs::Float(0.9)]),
|
||||
CSGPart::opcode(
|
||||
InstructionSet::OPMulVec3Float,
|
||||
vec![Inputs::Variable, Inputs::Float(0.9)],
|
||||
),
|
||||
CSGPart::opcode(InstructionSet::OPDupVec3, vec![Inputs::Variable]),
|
||||
CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![Inputs::Variable, Inputs::Vec3([-0.7, -1.2, -0.7].into())]),
|
||||
CSGPart::opcode(InstructionSet::OPSDFSphere,vec![Inputs::Float(0.5), Inputs::Variable]),
|
||||
CSGPart::opcode(
|
||||
InstructionSet::OPAddVec3Vec3,
|
||||
vec![Inputs::Variable, Inputs::Vec3([-0.7, -1.2, -0.7].into())],
|
||||
),
|
||||
CSGPart::opcode(
|
||||
InstructionSet::OPSDFSphere,
|
||||
vec![Inputs::Float(0.5), Inputs::Variable],
|
||||
),
|
||||
//CSGPart::opcode(InstructionSet::OPNop,vec![]),
|
||||
//CSGPart::opcode(InstructionSet::OPDupVec3, vec![Inputs::Variable]),
|
||||
//CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![Inputs::Variable, Inputs::Vec3([-0.2, -0.2, -0.2].into())]),
|
||||
//CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![Inputs::Variable, Inputs::Vec3([-0.0, -0.0, -0.0].into())]),
|
||||
//CSGPart::opcode(InstructionSet::OPSDFSphere,vec![Inputs::Float(1.2), Inputs::Variable]),
|
||||
CSGPart::opcode(InstructionSet::OPSDFTorus, vec![Inputs::Vec2([0.7, 0.4].into()), Inputs::Variable]),
|
||||
//CSGPart::opcode(InstructionSet::OPSDFBox, vec![Inputs::Vec3([0.7, 0.4, 0.7].into()), Inputs::Variable]),
|
||||
CSGPart::opcode(InstructionSet::OPMinFloat, vec![Inputs::Variable,Inputs::Variable]),
|
||||
CSGPart::opcode(InstructionSet::OPDivFloatFloat, vec![Inputs::Variable, Inputs::Float(0.9)]),
|
||||
//CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![Inputs::Variable,
|
||||
// Inputs::Vec3([-0.2, -0.2, -0.2].into())]),
|
||||
// CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![Inputs::Variable,
|
||||
// Inputs::Vec3([-0.0, -0.0, -0.0].into())]),
|
||||
// CSGPart::opcode(InstructionSet::OPSDFSphere,vec![Inputs::Float(1.2),
|
||||
// Inputs::Variable]),
|
||||
CSGPart::opcode(
|
||||
InstructionSet::OPSDFTorus,
|
||||
vec![Inputs::Vec2([0.7, 0.4].into()), Inputs::Variable],
|
||||
),
|
||||
//CSGPart::opcode(InstructionSet::OPSDFBox, vec![Inputs::Vec3([0.7, 0.4, 0.7].into()),
|
||||
// Inputs::Variable]),
|
||||
CSGPart::opcode(
|
||||
InstructionSet::OPMinFloat,
|
||||
vec![Inputs::Variable, Inputs::Variable],
|
||||
),
|
||||
CSGPart::opcode(
|
||||
InstructionSet::OPDivFloatFloat,
|
||||
vec![Inputs::Variable, Inputs::Float(0.9)],
|
||||
),
|
||||
CSGPart::opcode(InstructionSet::OPStop, vec![Inputs::Variable]),
|
||||
];
|
||||
|
||||
@@ -1330,11 +1408,11 @@ fn object_size_dependent_setup(
|
||||
} else {
|
||||
dependencies[u][0] = index as u8
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {
|
||||
eprintln!("csg {} underflowed on floats", csg.name);
|
||||
continue 'nextcsg;
|
||||
}
|
||||
},
|
||||
},
|
||||
InputTypes::Vec2 => match runtime_vec2s.pop() {
|
||||
Some(u) => {
|
||||
@@ -1343,11 +1421,11 @@ fn object_size_dependent_setup(
|
||||
} else {
|
||||
dependencies[u][0] = index as u8
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {
|
||||
eprintln!("csg {} underflowed on vec2s", csg.name);
|
||||
continue 'nextcsg;
|
||||
}
|
||||
},
|
||||
},
|
||||
InputTypes::Vec3 => match runtime_vec3s.pop() {
|
||||
Some(u) => {
|
||||
@@ -1358,11 +1436,11 @@ fn object_size_dependent_setup(
|
||||
dependencies[u][0] = index as u8
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {
|
||||
eprintln!("csg {} underflowed on vec3s", csg.name);
|
||||
continue 'nextcsg;
|
||||
}
|
||||
},
|
||||
},
|
||||
InputTypes::Vec4 => match runtime_vec4s.pop() {
|
||||
Some(u) => {
|
||||
@@ -1371,11 +1449,11 @@ fn object_size_dependent_setup(
|
||||
} else {
|
||||
dependencies[u][0] = index as u8
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {
|
||||
eprintln!("csg {} underflowed on vec4s", csg.name);
|
||||
continue 'nextcsg;
|
||||
}
|
||||
},
|
||||
},
|
||||
InputTypes::Mat2 => match runtime_mat2s.pop() {
|
||||
Some(u) => {
|
||||
@@ -1384,11 +1462,11 @@ fn object_size_dependent_setup(
|
||||
} else {
|
||||
dependencies[u][0] = index as u8
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {
|
||||
eprintln!("csg {} underflowed on mat2s", csg.name);
|
||||
continue 'nextcsg;
|
||||
}
|
||||
},
|
||||
},
|
||||
InputTypes::Mat3 => match runtime_mat3s.pop() {
|
||||
Some(u) => {
|
||||
@@ -1397,11 +1475,11 @@ fn object_size_dependent_setup(
|
||||
} else {
|
||||
dependencies[u][0] = index as u8
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {
|
||||
eprintln!("csg {} underflowed on mat3s", csg.name);
|
||||
continue 'nextcsg;
|
||||
}
|
||||
},
|
||||
},
|
||||
InputTypes::Mat4 => match runtime_mat4s.pop() {
|
||||
Some(u) => {
|
||||
@@ -1410,11 +1488,11 @@ fn object_size_dependent_setup(
|
||||
} else {
|
||||
dependencies[u][0] = index as u8
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {
|
||||
eprintln!("csg {} underflowed on mat4s", csg.name);
|
||||
continue 'nextcsg;
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
} else {
|
||||
@@ -1467,7 +1545,17 @@ fn object_size_dependent_setup(
|
||||
}
|
||||
}
|
||||
|
||||
let temp_csg = &CSG { name: "test".to_string(), parts: parts.to_vec(), pos: Point3::origin(), rot: Euler::new(Deg(0.), Deg(0.), Deg(0.)), scale: Vector3 { x: 1., y: 1., z: 1. } };
|
||||
let temp_csg = &CSG {
|
||||
name: "test".to_string(),
|
||||
parts: parts.to_vec(),
|
||||
pos: Point3::origin(),
|
||||
rot: Euler::new(Deg(0.), Deg(0.), Deg(0.)),
|
||||
scale: Vector3 {
|
||||
x: 1.,
|
||||
y: 1.,
|
||||
z: 1.,
|
||||
},
|
||||
};
|
||||
|
||||
let mut interpreter = interpreter::Interpreter::new(temp_csg);
|
||||
const CLIPCHECK: Float = 65536.;
|
||||
@@ -1483,13 +1571,14 @@ fn object_size_dependent_setup(
|
||||
|
||||
//println!("bounds: {:?}",bounds);
|
||||
|
||||
desc.push(Description {pointers:to_push,bounds});
|
||||
desc.push(Description {
|
||||
pointers: to_push,
|
||||
bounds,
|
||||
});
|
||||
|
||||
scene.append(&mut data);
|
||||
|
||||
deps.append(&mut dependencies);
|
||||
|
||||
|
||||
}
|
||||
|
||||
println!("floats: {floats:?}");
|
||||
@@ -1524,15 +1613,58 @@ fn object_size_dependent_setup(
|
||||
},
|
||||
);
|
||||
|
||||
let csg_scene = gpu_buffer(scene, &allocator, &staging, command_allocator, queue.clone());
|
||||
let csg_scene = gpu_buffer(
|
||||
scene,
|
||||
&allocator,
|
||||
&staging,
|
||||
command_allocator,
|
||||
queue.clone(),
|
||||
);
|
||||
let csg_desc = gpu_buffer(desc, &allocator, &staging, command_allocator, queue.clone());
|
||||
let csg_floats = gpu_buffer(floats, &allocator, &staging, command_allocator, queue.clone());
|
||||
let csg_vec2s = gpu_buffer(vec2s, &allocator, &staging, command_allocator, queue.clone());
|
||||
//let csg_vec3s = gpu_buffer(vec3s, &allocator, &staging, command_allocator, queue.clone());
|
||||
let csg_vec4s = gpu_buffer(vec4s, &allocator, &staging, command_allocator, queue.clone());
|
||||
let csg_mat2s = gpu_buffer(mat2s, &allocator, &staging, command_allocator, queue.clone());
|
||||
let csg_mat3s = gpu_buffer(mat3s, &allocator, &staging, command_allocator, queue.clone());
|
||||
let csg_mat4s = gpu_buffer(mat4s, &allocator, &staging, command_allocator, queue.clone());
|
||||
let csg_floats = gpu_buffer(
|
||||
floats,
|
||||
&allocator,
|
||||
&staging,
|
||||
command_allocator,
|
||||
queue.clone(),
|
||||
);
|
||||
let csg_vec2s = gpu_buffer(
|
||||
vec2s,
|
||||
&allocator,
|
||||
&staging,
|
||||
command_allocator,
|
||||
queue.clone(),
|
||||
);
|
||||
//let csg_vec3s = gpu_buffer(vec3s, &allocator, &staging, command_allocator,
|
||||
// queue.clone());
|
||||
let csg_vec4s = gpu_buffer(
|
||||
vec4s,
|
||||
&allocator,
|
||||
&staging,
|
||||
command_allocator,
|
||||
queue.clone(),
|
||||
);
|
||||
let csg_mat2s = gpu_buffer(
|
||||
mat2s,
|
||||
&allocator,
|
||||
&staging,
|
||||
command_allocator,
|
||||
queue.clone(),
|
||||
);
|
||||
let csg_mat3s = gpu_buffer(
|
||||
mat3s,
|
||||
&allocator,
|
||||
&staging,
|
||||
command_allocator,
|
||||
queue.clone(),
|
||||
);
|
||||
let csg_mat4s = gpu_buffer(
|
||||
mat4s,
|
||||
&allocator,
|
||||
&staging,
|
||||
command_allocator,
|
||||
queue.clone(),
|
||||
);
|
||||
let csg_mats = gpu_buffer(mats, &allocator, &staging, command_allocator, queue.clone());
|
||||
let csg_deps = gpu_buffer(deps, &allocator, &staging, command_allocator, queue);
|
||||
|
||||
|
||||
+19
-16
@@ -1,13 +1,16 @@
|
||||
use std::fmt::Display;
|
||||
use std::io::{BufReader, Read};
|
||||
use std::{
|
||||
fmt::Display,
|
||||
io::{BufReader, Read},
|
||||
str::Chars,
|
||||
};
|
||||
|
||||
use std::str::Chars;
|
||||
|
||||
use serde::de::{
|
||||
use serde::{
|
||||
de::{
|
||||
self, DeserializeSeed, EnumAccess, IntoDeserializer, MapAccess, SeqAccess, VariantAccess,
|
||||
Visitor,
|
||||
},
|
||||
forward_to_deserialize_any, Deserialize,
|
||||
};
|
||||
use serde::{forward_to_deserialize_any, Deserialize};
|
||||
use utf8::BufReadDecoder;
|
||||
|
||||
type Result<T> = core::result::Result<T, Error>;
|
||||
@@ -128,16 +131,16 @@ impl<'de> Deserializer<'de> {
|
||||
Ok(c) => {
|
||||
self.peek = Some(c);
|
||||
return Ok(c);
|
||||
}
|
||||
},
|
||||
Err(Error::Eof) => match self.input.next_strict() {
|
||||
Some(e) => {
|
||||
match e {
|
||||
Ok(s) => {
|
||||
s.clone_into(&mut self.read_buf);
|
||||
}
|
||||
},
|
||||
Err(e) => return Err(Error::UTF8(format!("{e}"))),
|
||||
};
|
||||
}
|
||||
},
|
||||
None => return Err(Error::Eof),
|
||||
},
|
||||
Err(e) => return Err(e),
|
||||
@@ -168,16 +171,16 @@ impl<'de> Deserializer<'de> {
|
||||
let out = self.read_buf[..len].to_string();
|
||||
self.read_buf = self.read_buf[len + 1..].to_string();
|
||||
return Ok(out);
|
||||
}
|
||||
},
|
||||
None => match self.input.next_strict() {
|
||||
Some(e) => {
|
||||
match e {
|
||||
Ok(s) => {
|
||||
s.clone_into(&mut self.read_buf);
|
||||
}
|
||||
},
|
||||
Err(e) => return Err(Error::UTF8(format!("{e}"))),
|
||||
};
|
||||
}
|
||||
},
|
||||
None => return Err(Error::Eof),
|
||||
},
|
||||
}
|
||||
@@ -188,6 +191,10 @@ impl<'de> Deserializer<'de> {
|
||||
impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
|
||||
type Error = Error;
|
||||
|
||||
forward_to_deserialize_any! {
|
||||
bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char bytes byte_buf option unit unit_struct
|
||||
}
|
||||
|
||||
// Look at the input data to decide what Serde data model type to
|
||||
// deserialize as. Not all data formats are able to support this operation.
|
||||
// Formats that support `deserialize_any` are known as self-describing.
|
||||
@@ -371,10 +378,6 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
|
||||
{
|
||||
self.deserialize_any(visitor)
|
||||
}
|
||||
|
||||
forward_to_deserialize_any! {
|
||||
bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char bytes byte_buf option unit unit_struct
|
||||
}
|
||||
}
|
||||
|
||||
// In order to handle commas correctly when deserializing a JSON array or map,
|
||||
|
||||
+9
-9
@@ -16,16 +16,16 @@ use vulkano::{
|
||||
pipeline::graphics::vertex_input::Vertex,
|
||||
};
|
||||
|
||||
use crate::instruction_set::InstructionSet;
|
||||
use crate::{mcsg_deserialise::from_reader, MemoryAllocator};
|
||||
use crate::{instruction_set::InstructionSet, mcsg_deserialise::from_reader, MemoryAllocator};
|
||||
|
||||
pub(crate) const PLATONIC_SOLIDS: [(&str, &[u8]); 1] = [("Buny", include_bytes!("bunny.obj"))];
|
||||
pub(crate) const CSG_SOLIDS: [(&str, &[u8]); 1] =
|
||||
[("Primitives", include_bytes!("primitive.mcsg"))];
|
||||
|
||||
// We now create a buffer that will store the shape of our triangle.
|
||||
// We use #[repr(C)] here to force rustc to not do anything funky with our data, although for this
|
||||
// particular example, it doesn't actually change the in-memory representation.
|
||||
// We use #[repr(C)] here to force rustc to not do anything funky with our data,
|
||||
// although for this particular example, it doesn't actually change the
|
||||
// in-memory representation.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Default, Zeroable, Pod, Vertex)]
|
||||
pub(crate) struct OVertex {
|
||||
@@ -130,9 +130,9 @@ pub(crate) fn load_obj(
|
||||
let mut temp_hash_map = HashMap::<(u32, u32), u32>::new();
|
||||
|
||||
// We're gonna have to remap all the indices that OBJ uses. Annoying.
|
||||
// Get each pair of vertex position to vertex normal and assign it a new index. This might duplicate
|
||||
// vertices or normals but each *pair* needs a unique index
|
||||
// Uses the hash map to check that we're not duplicating unnecessarily
|
||||
// Get each pair of vertex position to vertex normal and assign it a new index.
|
||||
// This might duplicate vertices or normals but each *pair* needs a unique
|
||||
// index Uses the hash map to check that we're not duplicating unnecessarily
|
||||
for g in &object.objects[0].groups {
|
||||
for p in &g.polys {
|
||||
for v in &p.0 {
|
||||
@@ -379,8 +379,8 @@ pub(crate) fn load_csg(
|
||||
let _rgb = get_rgb(inpart)?;
|
||||
let _trs = get_trs(inpart)?;
|
||||
let _half = get_half(inpart)?;
|
||||
}
|
||||
_ => {} //return Err("unknown type of csg".to_owned()),
|
||||
},
|
||||
_ => {}, //return Err("unknown type of csg".to_owned()),
|
||||
}
|
||||
Ok(csgpart)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user