wip
This commit is contained in:
Generated
+589
-700
File diff suppressed because it is too large
Load Diff
+7
-6
@@ -9,7 +9,6 @@ edition = "2021"
|
||||
vulkano = "0.34"
|
||||
vulkano-shaders = "0.34"
|
||||
winit = "0.30"
|
||||
vulkano-win = "0.34"
|
||||
vulkano-util = "0.34"
|
||||
|
||||
obj = "0.10"
|
||||
@@ -35,8 +34,10 @@ rand = "0.8.5"
|
||||
|
||||
# using latest gits
|
||||
[patch.crates-io]
|
||||
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" }
|
||||
vulkano = { git = "https://github.com/Molive-0/vulkano" }
|
||||
vulkano-macros = { git = "https://github.com/Molive-0/vulkano" }
|
||||
vulkano-shaders = { git = "https://github.com/Molive-0/vulkano" }
|
||||
vulkano-taskgraph = { git = "https://github.com/Molive-0/vulkano" }
|
||||
vulkano-util = { git = "https://github.com/Molive-0/vulkano" }
|
||||
vulkano-win = { git = "https://github.com/Molive-0/vulkano" }
|
||||
egui_winit_vulkano = { git = "https://github.com/Molive-0/egui_winit_vulkano" }
|
||||
|
||||
+232
-140
@@ -1,5 +1,5 @@
|
||||
#![feature(variant_count)]
|
||||
use std::{default, io::Cursor, sync::Arc, time::Instant};
|
||||
use std::{default, error::Error, io::Cursor, sync::Arc, time::Instant};
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use cgmath::{Deg, EuclideanSpace, Euler, Matrix3, Matrix4, Point3, Rad, SquareMatrix, Vector3};
|
||||
@@ -8,55 +8,58 @@ use instruction_set::InputTypes;
|
||||
use rayon::prelude::*;
|
||||
use vulkano::{
|
||||
buffer::{
|
||||
allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo}, Buffer, BufferAllocateInfo, BufferCreateInfo, BufferUsage, Subbuffer
|
||||
allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
|
||||
Buffer, BufferCreateInfo, BufferUsage, Subbuffer,
|
||||
},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||
CopyBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, SubpassBeginInfo,
|
||||
SubpassContents, SubpassEndInfo,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
|
||||
SubpassContents,
|
||||
},
|
||||
descriptor_set::{allocator::StandardDescriptorSetAllocator, WriteDescriptorSet},
|
||||
device::{
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, DeviceOwned,
|
||||
Features, Queue, QueueCreateInfo, QueueFlags,
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures,
|
||||
DeviceOwned, Queue, QueueCreateInfo, QueueFlags,
|
||||
},
|
||||
format::Format,
|
||||
image::{
|
||||
view::{ImageView, ImageViewCreateInfo},
|
||||
AttachmentImage, ImageAccess, ImageUsage, SampleCount, SwapchainImage,
|
||||
Image, ImageCreateInfo, ImageType, ImageUsage, SampleCount,
|
||||
},
|
||||
instance::{Instance, InstanceCreateInfo, InstanceExtensions},
|
||||
memory::allocator::{AllocationCreateInfo, MemoryAllocatePreference, MemoryTypeFilter, MemoryUsage, StandardMemoryAllocator},
|
||||
memory::allocator::{
|
||||
AllocationCreateInfo, MemoryAllocatePreference, MemoryTypeFilter, StandardMemoryAllocator,
|
||||
},
|
||||
pipeline::{
|
||||
compute::ComputePipelineCreateInfo,
|
||||
graphics::{
|
||||
depth_stencil::DepthStencilState,
|
||||
color_blend::{ColorBlendAttachmentState, ColorBlendState},
|
||||
depth_stencil::{DepthState, DepthStencilState},
|
||||
input_assembly::InputAssemblyState,
|
||||
multisample::MultisampleState,
|
||||
rasterization::{CullMode, FrontFace::Clockwise, RasterizationState},
|
||||
vertex_input::Vertex,
|
||||
viewport::{Viewport, ViewportState},
|
||||
GraphicsPipelineCreateInfo,
|
||||
},
|
||||
GraphicsPipeline, Pipeline, PipelineBindPoint, PipelineShaderStageCreateFlags,
|
||||
layout::PipelineDescriptorSetLayoutCreateInfo,
|
||||
GraphicsPipeline, Pipeline, PipelineBindPoint, PipelineLayout,
|
||||
PipelineShaderStageCreateInfo,
|
||||
StateMode::Fixed,
|
||||
},
|
||||
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
|
||||
shader::{ShaderModule, SpecializationConstants},
|
||||
shader::ShaderModule,
|
||||
swapchain::{
|
||||
acquire_next_image, AcquireError, PresentMode, Swapchain, SwapchainCreateInfo,
|
||||
SwapchainCreationError, SwapchainPresentInfo,
|
||||
acquire_next_image, PresentMode, Surface, Swapchain, SwapchainCreateInfo,
|
||||
SwapchainPresentInfo,
|
||||
},
|
||||
sync::{self, FlushError, GpuFuture},
|
||||
sync::{self, GpuFuture},
|
||||
Version, VulkanLibrary,
|
||||
};
|
||||
use vulkano_win::VkSurfaceBuild;
|
||||
use winit::{
|
||||
event::{DeviceEvent, ElementState, Event, MouseButton, VirtualKeyCode, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
window::{Window, WindowBuilder},
|
||||
application::ApplicationHandler,
|
||||
event::{DeviceEvent, ElementState, Event, MouseButton, WindowEvent},
|
||||
event_loop::{ActiveEventLoop, ControlFlow, EventLoop},
|
||||
window::{Window, WindowAttributes},
|
||||
};
|
||||
|
||||
mod gui;
|
||||
@@ -73,11 +76,38 @@ use crate::instruction_set::InstructionSet;
|
||||
|
||||
mod interpreter;
|
||||
|
||||
pub(crate) type MemoryAllocator = StandardMemoryAllocator;
|
||||
fn main() -> Result<(), impl Error> {
|
||||
let event_loop = EventLoop::new().unwrap();
|
||||
let mut app = App::new(&event_loop);
|
||||
|
||||
fn main() {
|
||||
event_loop.run_app(&mut app)
|
||||
}
|
||||
|
||||
struct App {
|
||||
instance: Arc<Instance>,
|
||||
device: Arc<Device>,
|
||||
graphics_queue: Arc<Queue>,
|
||||
transfer_queue: Arc<Queue>,
|
||||
memory_allocator: Arc<StandardMemoryAllocator>,
|
||||
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
|
||||
rcx: Option<RenderContext>,
|
||||
}
|
||||
|
||||
struct RenderContext {
|
||||
window: Arc<Window>,
|
||||
swapchain: Arc<Swapchain>,
|
||||
render_pass: Arc<RenderPass>,
|
||||
framebuffers: Vec<Arc<Framebuffer>>,
|
||||
pipeline: Arc<GraphicsPipeline>,
|
||||
viewport: Viewport,
|
||||
recreate_swapchain: bool,
|
||||
previous_frame_end: Option<Box<dyn GpuFuture>>,
|
||||
}
|
||||
|
||||
impl App {
|
||||
fn new(event_loop: &EventLoop<()>) -> Self {
|
||||
let library = VulkanLibrary::new().expect("Vulkan is not installed???");
|
||||
let required_extensions = vulkano_win::required_extensions(&library);
|
||||
let required_extensions = Surface::required_extensions(&library);
|
||||
|
||||
let instance = Instance::new(
|
||||
library,
|
||||
@@ -94,12 +124,6 @@ fn main() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let event_loop = EventLoop::new();
|
||||
let surface = WindowBuilder::new()
|
||||
.with_title("Implicit Surfaces")
|
||||
.build_vk_surface(&event_loop, instance.clone())
|
||||
.unwrap();
|
||||
|
||||
let device_extensions = DeviceExtensions {
|
||||
khr_swapchain: true,
|
||||
ext_mesh_shader: true,
|
||||
@@ -107,7 +131,7 @@ fn main() {
|
||||
..DeviceExtensions::empty()
|
||||
};
|
||||
|
||||
let (physical_device, (queue_family_index, transfer_index)) = instance
|
||||
let (physical_device, (graphics_queue_index, transfer_queue_index)) = instance
|
||||
.enumerate_physical_devices()
|
||||
.unwrap()
|
||||
.filter(|p| p.supported_extensions().contains(&device_extensions))
|
||||
@@ -117,7 +141,8 @@ fn main() {
|
||||
.enumerate()
|
||||
.position(|(i, q)| {
|
||||
q.queue_flags.intersects(QueueFlags::GRAPHICS)
|
||||
&& p.surface_support(i as u32, &surface).unwrap_or(false)
|
||||
&& p.presentation_support(i as u32, event_loop)
|
||||
.unwrap_or(false)
|
||||
})
|
||||
.and_then(|graphics| {
|
||||
p.queue_family_properties()
|
||||
@@ -127,10 +152,9 @@ fn main() {
|
||||
q.queue_flags.intersects(QueueFlags::TRANSFER) && i != graphics
|
||||
})
|
||||
.or_else(|| {
|
||||
p.queue_family_properties()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.position(|(_i, q)| q.queue_flags.intersects(QueueFlags::TRANSFER))
|
||||
p.queue_family_properties().iter().enumerate().position(
|
||||
|(_i, q)| q.queue_flags.intersects(QueueFlags::TRANSFER),
|
||||
)
|
||||
})
|
||||
.map(|i| (graphics as u32, i as u32))
|
||||
})
|
||||
@@ -165,15 +189,15 @@ fn main() {
|
||||
enabled_extensions: device_extensions,
|
||||
queue_create_infos: vec![
|
||||
QueueCreateInfo {
|
||||
queue_family_index,
|
||||
queue_family_index: graphics_queue_index,
|
||||
..Default::default()
|
||||
},
|
||||
QueueCreateInfo {
|
||||
queue_family_index: transfer_index,
|
||||
queue_family_index: transfer_queue_index,
|
||||
..Default::default()
|
||||
},
|
||||
],
|
||||
enabled_features: Features {
|
||||
enabled_features: DeviceFeatures {
|
||||
mesh_shader: true,
|
||||
task_shader: true,
|
||||
sample_rate_shading: true,
|
||||
@@ -183,41 +207,69 @@ fn main() {
|
||||
storage_buffer8_bit_access: true,
|
||||
geometry_shader: true,
|
||||
primitive_fragment_shading_rate: true,
|
||||
..Features::empty()
|
||||
..DeviceFeatures::empty()
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.expect("Unable to initialize device");
|
||||
|
||||
let queue = queues.next().expect("Unable to retrieve queues");
|
||||
let graphics_queue = queues.next().expect("Unable to retrieve queues");
|
||||
let transfer_queue = queues.next().expect("Unable to retrieve queues");
|
||||
|
||||
let memory_allocator = Arc::new(StandardMemoryAllocator::new_default(device.clone()));
|
||||
|
||||
let command_buffer_allocator =
|
||||
StandardCommandBufferAllocator::new(device.clone(), Default::default());
|
||||
|
||||
App {
|
||||
instance,
|
||||
device,
|
||||
graphics_queue,
|
||||
transfer_queue,
|
||||
memory_allocator,
|
||||
command_buffer_allocator,
|
||||
rcx: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ApplicationHandler for App {
|
||||
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
|
||||
let window = Arc::new(
|
||||
event_loop
|
||||
.create_window(WindowAttributes {
|
||||
title: "Implicit Surfaces".to_owned(),
|
||||
..Window::default_attributes()
|
||||
})
|
||||
.unwrap(),
|
||||
);
|
||||
let surface = Surface::from_window(self.instance.clone(), window.clone()).unwrap();
|
||||
let window_size = window.inner_size();
|
||||
|
||||
let (mut swapchain, images) = {
|
||||
let surface_capabilities = device
|
||||
let surface_capabilities = self
|
||||
.device
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
|
||||
let image_format = Some(
|
||||
device
|
||||
let (image_format, _) = self
|
||||
.device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let window = surface.object().unwrap().downcast_ref::<Window>().unwrap();
|
||||
.unwrap()[0];
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
surface.clone(),
|
||||
self.device.clone(),
|
||||
surface,
|
||||
SwapchainCreateInfo {
|
||||
min_image_count: 3
|
||||
.max(surface_capabilities.min_image_count)
|
||||
.min(surface_capabilities.max_image_count.unwrap_or(u32::MAX)),
|
||||
|
||||
image_format,
|
||||
image_extent: window.inner_size().into(),
|
||||
image_extent: window_size.into(),
|
||||
|
||||
image_usage: ImageUsage::COLOR_ATTACHMENT,
|
||||
|
||||
@@ -239,8 +291,8 @@ fn main() {
|
||||
vulkano_shaders::shader! {
|
||||
ty: "vertex",
|
||||
path: "src/triangle.vert.glsl",
|
||||
vulkan_version: "1.2",
|
||||
spirv_version: "1.5",
|
||||
vulkan_version: "1.3",
|
||||
spirv_version: "1.6",
|
||||
custom_derives: [Debug, Clone, Copy],
|
||||
}
|
||||
}
|
||||
@@ -249,8 +301,8 @@ fn main() {
|
||||
vulkano_shaders::shader! {
|
||||
ty: "fragment",
|
||||
path: "src/frag.glsl",
|
||||
vulkan_version: "1.2",
|
||||
spirv_version: "1.5",
|
||||
vulkan_version: "1.3",
|
||||
spirv_version: "1.6",
|
||||
define: [("triangle","1")],
|
||||
custom_derives: [Debug, Clone, Copy],
|
||||
}
|
||||
@@ -260,8 +312,8 @@ fn main() {
|
||||
vulkano_shaders::shader! {
|
||||
ty: "mesh",
|
||||
path: "src/implicit.mesh.glsl",
|
||||
vulkan_version: "1.2",
|
||||
spirv_version: "1.5",
|
||||
vulkan_version: "1.3",
|
||||
spirv_version: "1.6",
|
||||
custom_derives: [Debug, Clone, Copy],
|
||||
}
|
||||
}
|
||||
@@ -270,8 +322,8 @@ fn main() {
|
||||
vulkano_shaders::shader! {
|
||||
ty: "task",
|
||||
path: "src/implicit.task.glsl",
|
||||
vulkan_version: "1.2",
|
||||
spirv_version: "1.5",
|
||||
vulkan_version: "1.3",
|
||||
spirv_version: "1.6",
|
||||
custom_derives: [Debug, Clone, Copy],
|
||||
}
|
||||
}
|
||||
@@ -280,8 +332,8 @@ fn main() {
|
||||
vulkano_shaders::shader! {
|
||||
ty: "fragment",
|
||||
path: "src/frag.glsl",
|
||||
vulkan_version: "1.2",
|
||||
spirv_version: "1.5",
|
||||
vulkan_version: "1.3",
|
||||
spirv_version: "1.6",
|
||||
define: [("implicit","1")],
|
||||
custom_derives: [Debug, Clone, Copy],
|
||||
}
|
||||
@@ -291,8 +343,8 @@ fn main() {
|
||||
vulkano_shaders::shader! {
|
||||
ty: "compute",
|
||||
path: "src/fuzz.comp.glsl",
|
||||
vulkan_version: "1.2",
|
||||
spirv_version: "1.5",
|
||||
vulkan_version: "1.3",
|
||||
spirv_version: "1.6",
|
||||
custom_derives: [Debug, Clone, Copy],
|
||||
}
|
||||
}
|
||||
@@ -302,7 +354,7 @@ fn main() {
|
||||
::std::sync::Arc<::vulkano::device::Device>,
|
||||
) -> Result<
|
||||
::std::sync::Arc<::vulkano::shader::ShaderModule>,
|
||||
::vulkano::shader::ShaderCreationError,
|
||||
::vulkano::Validated<::vulkano::VulkanError>,
|
||||
>,
|
||||
> = vec![
|
||||
((mesh_vs::load)
|
||||
@@ -310,48 +362,48 @@ fn main() {
|
||||
::std::sync::Arc<::vulkano::device::Device>,
|
||||
) -> Result<
|
||||
::std::sync::Arc<::vulkano::shader::ShaderModule>,
|
||||
::vulkano::shader::ShaderCreationError,
|
||||
::vulkano::Validated<::vulkano::VulkanError>,
|
||||
>),
|
||||
((mesh_fs::load)
|
||||
as fn(
|
||||
::std::sync::Arc<::vulkano::device::Device>,
|
||||
) -> Result<
|
||||
::std::sync::Arc<::vulkano::shader::ShaderModule>,
|
||||
::vulkano::shader::ShaderCreationError,
|
||||
::vulkano::Validated<::vulkano::VulkanError>,
|
||||
>),
|
||||
((implicit_ms::load)
|
||||
as fn(
|
||||
::std::sync::Arc<::vulkano::device::Device>,
|
||||
) -> Result<
|
||||
::std::sync::Arc<::vulkano::shader::ShaderModule>,
|
||||
::vulkano::shader::ShaderCreationError,
|
||||
::vulkano::Validated<::vulkano::VulkanError>,
|
||||
>),
|
||||
((implicit_ts::load)
|
||||
as fn(
|
||||
::std::sync::Arc<::vulkano::device::Device>,
|
||||
) -> Result<
|
||||
::std::sync::Arc<::vulkano::shader::ShaderModule>,
|
||||
::vulkano::shader::ShaderCreationError,
|
||||
::vulkano::Validated<::vulkano::VulkanError>,
|
||||
>),
|
||||
((implicit_fs::load)
|
||||
as fn(
|
||||
::std::sync::Arc<::vulkano::device::Device>,
|
||||
) -> Result<
|
||||
::std::sync::Arc<::vulkano::shader::ShaderModule>,
|
||||
::vulkano::shader::ShaderCreationError,
|
||||
::vulkano::Validated<::vulkano::VulkanError>,
|
||||
>),
|
||||
((cs::load)
|
||||
as fn(
|
||||
::std::sync::Arc<::vulkano::device::Device>,
|
||||
) -> Result<
|
||||
::std::sync::Arc<::vulkano::shader::ShaderModule>,
|
||||
::vulkano::shader::ShaderCreationError,
|
||||
::vulkano::Validated<::vulkano::VulkanError>,
|
||||
>),
|
||||
];
|
||||
|
||||
let pariter = loaders
|
||||
.par_iter()
|
||||
.map(|load| load(device.clone()).unwrap())
|
||||
.map(|load| load(self.device.clone()).unwrap())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mesh_vs = pariter[0].clone();
|
||||
@@ -367,30 +419,33 @@ fn main() {
|
||||
|
||||
use vulkano::pipeline::ComputePipeline;
|
||||
|
||||
let compute_layout = PipelineLayout::new(
|
||||
device.clone(),
|
||||
PipelineDescriptorSetLayoutCreateInfo::from_stages(&stages)
|
||||
.into_pipeline_layout_create_info(device.clone())
|
||||
let compute_stage =
|
||||
PipelineShaderStageCreateInfo::new(compute_shader.entry_point("main").unwrap());
|
||||
|
||||
let pipeline_layout = PipelineLayout::new(
|
||||
self.device.clone(),
|
||||
PipelineDescriptorSetLayoutCreateInfo::from_stages([
|
||||
mesh_vs,
|
||||
mesh_fs,
|
||||
implicit_ms,
|
||||
implicit_ts,
|
||||
implicit_fs,
|
||||
compute_stage,
|
||||
])
|
||||
.into_pipeline_layout_create_info(self.device.clone())
|
||||
.unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let compute_pipeline = ComputePipeline::new(
|
||||
device.clone(),
|
||||
self.device.clone(),
|
||||
None,
|
||||
ComputePipelineCreateInfo {
|
||||
stage: PipelineShaderStageCreateInfo::new(compute_shader.entry_point("main").unwrap()),
|
||||
base_pipeline: None,
|
||||
layout: compute_layout,
|
||||
..default::Default()
|
||||
},
|
||||
ComputePipelineCreateInfo::stage_layout(compute_stage, pipeline_layout),
|
||||
)
|
||||
.expect("failed to create compute pipeline");
|
||||
|
||||
let memory_allocator = Arc::new(MemoryAllocator::new_default(device.clone()));
|
||||
|
||||
let render_pass = vulkano::ordered_passes_renderpass!(
|
||||
device.clone(),
|
||||
self.device.clone(),
|
||||
attachments: {
|
||||
intermediary: {
|
||||
format: swapchain.image_format(),
|
||||
@@ -435,7 +490,7 @@ fn main() {
|
||||
//let [RES_X, RES_Y] = images[0].dimensions().width_height();
|
||||
let ([mut mesh_pipeline, mut implicit_pipeline], mut framebuffers) =
|
||||
window_size_dependent_setup(
|
||||
&memory_allocator,
|
||||
&self.memory_allocator,
|
||||
&mesh_vs,
|
||||
&mesh_fs,
|
||||
&implicit_ms,
|
||||
@@ -460,9 +515,6 @@ fn main() {
|
||||
gstate.debug.brute_force,
|
||||
);
|
||||
|
||||
let command_buffer_allocator =
|
||||
StandardCommandBufferAllocator::new(device.clone(), Default::default());
|
||||
|
||||
let mut recreate_swapchain = false;
|
||||
let mut previous_frame_end = Some(sync::now(device.clone()).boxed());
|
||||
|
||||
@@ -550,8 +602,14 @@ fn main() {
|
||||
let mut prevdub = PreviousDebug::default();
|
||||
|
||||
let mut render_start = Instant::now();
|
||||
}
|
||||
|
||||
event_loop.run(move |event, _, control_flow| {
|
||||
fn window_event(
|
||||
&mut self,
|
||||
event_loop: &ActiveEventLoop,
|
||||
window_id: winit::window::WindowId,
|
||||
event: WindowEvent,
|
||||
) {
|
||||
if let Event::WindowEvent { event: we, .. } = &event {
|
||||
if !gui.update(we) {
|
||||
match &we {
|
||||
@@ -642,7 +700,9 @@ fn main() {
|
||||
..swapchain.create_info()
|
||||
}) {
|
||||
Ok(r) => r,
|
||||
Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return,
|
||||
Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => {
|
||||
return;
|
||||
},
|
||||
Err(e) => panic!("Failed to recreate swapchain: {e:?}"),
|
||||
};
|
||||
|
||||
@@ -845,7 +905,8 @@ fn main() {
|
||||
InstructionSet::OPSDFSphere,
|
||||
vec![Inputs::Float(1.2), Inputs::Variable],
|
||||
),
|
||||
//CSGPart::opcode(InstructionSet::OPSDFBox, vec![Inputs::Variable,
|
||||
//CSGPart::opcode(InstructionSet::OPSDFBox,
|
||||
// vec![Inputs::Variable,
|
||||
// Inputs::Vec3([0.7, 0.7, 0.7].into())]),
|
||||
CSGPart::opcode(
|
||||
InstructionSet::OPMinFloat,
|
||||
@@ -899,10 +960,12 @@ fn main() {
|
||||
WriteDescriptorSet::buffer(7, compute_subbuffers.vec4s.clone()),
|
||||
//WriteDescriptorSet::buffer(8, compute_subbuffers.mat2s.clone()),
|
||||
//WriteDescriptorSet::buffer(9, compute_subbuffers.mat3s.clone()),
|
||||
//WriteDescriptorSet::buffer(10, compute_subbuffers.mat4s.clone()),
|
||||
//WriteDescriptorSet::buffer(11, compute_subbuffers.mats.clone()),
|
||||
//WriteDescriptorSet::buffer(10,
|
||||
// compute_subbuffers.mat4s.clone()),
|
||||
// WriteDescriptorSet::buffer(11, compute_subbuffers.mats.clone()),
|
||||
WriteDescriptorSet::buffer(12, compute_subbuffers.deps),
|
||||
//WriteDescriptorSet::buffer(20, compute_subbuffers.masks.clone()),
|
||||
//WriteDescriptorSet::buffer(20,
|
||||
// compute_subbuffers.masks.clone()),
|
||||
WriteDescriptorSet::buffer(30, compute_result_buffer.clone()),
|
||||
],
|
||||
)
|
||||
@@ -1085,7 +1148,7 @@ fn main() {
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// This method is called once during initialization, then again whenever the
|
||||
@@ -1097,8 +1160,8 @@ fn window_size_dependent_setup<Fs, Ms, Ts>(
|
||||
implicit_ms: &ShaderModule,
|
||||
implicit_ts: &ShaderModule,
|
||||
implicit_fs: &ShaderModule,
|
||||
images: &[Arc<SwapchainImage>],
|
||||
render_pass: Arc<RenderPass>,
|
||||
images: &[Arc<Image>],
|
||||
render_pass: &Arc<RenderPass>,
|
||||
viewport: &mut Viewport,
|
||||
implicit_fs_specs: Fs,
|
||||
implicit_ms_specs: Ms,
|
||||
@@ -1110,34 +1173,40 @@ where
|
||||
Ms: SpecializationConstants + Clone,
|
||||
Ts: SpecializationConstants + Clone,
|
||||
{
|
||||
let dimensions = images[0].dimensions().width_height();
|
||||
let dimensions = images[0].extent();
|
||||
viewport.dimensions = [dimensions[0] as f32, dimensions[1] as f32];
|
||||
|
||||
let depth_buffer = ImageView::new_default(
|
||||
AttachmentImage::transient_multisampled(
|
||||
allocator,
|
||||
dimensions,
|
||||
SampleCount::Sample4,
|
||||
Format::D16_UNORM, // D24_UNORM_S8_UINT
|
||||
Image::new(
|
||||
allocator.clone(),
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Format::D16_UNORM,
|
||||
extent: images[0].extent(),
|
||||
usage: ImageUsage::DEPTH_STENCIL_ATTACHMENT | ImageUsage::TRANSIENT_ATTACHMENT,
|
||||
samples: SampleCount::Sample4,
|
||||
..Default::default()
|
||||
},
|
||||
AllocationCreateInfo::default(),
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let intermediary_image = AttachmentImage::transient_multisampled(
|
||||
allocator,
|
||||
dimensions,
|
||||
SampleCount::Sample4,
|
||||
images[0].format(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let intermediary = ImageView::new(
|
||||
intermediary_image.clone(),
|
||||
ImageViewCreateInfo {
|
||||
let intermediary = ImageView::new_default(
|
||||
Image::new(
|
||||
allocator.clone(),
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: images[0].format(),
|
||||
extent: dimensions,
|
||||
usage: ImageUsage::COLOR_ATTACHMENT | ImageUsage::TRANSIENT_ATTACHMENT,
|
||||
..ImageViewCreateInfo::from_image(&intermediary_image)
|
||||
samples: SampleCount::Sample4,
|
||||
..Default::default()
|
||||
},
|
||||
AllocationCreateInfo::default(),
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -1148,7 +1217,7 @@ where
|
||||
image.clone(),
|
||||
ImageViewCreateInfo {
|
||||
usage: ImageUsage::COLOR_ATTACHMENT | ImageUsage::TRANSFER_DST,
|
||||
..ImageViewCreateInfo::from_image(&intermediary_image)
|
||||
..ImageViewCreateInfo::from_image(&image)
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1163,34 +1232,56 @@ where
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mesh_pipeline = GraphicsPipeline::start()
|
||||
.render_pass(Subpass::from(render_pass.clone(), 0).unwrap())
|
||||
.vertex_input_state(OVertex::per_vertex())
|
||||
.input_assembly_state(InputAssemblyState::new())
|
||||
.vertex_shader(mesh_vs.entry_point("main").unwrap(), ())
|
||||
.viewport_state(ViewportState::viewport_fixed_scissor_irrelevant([
|
||||
Viewport {
|
||||
let mesh_pipeline = {
|
||||
let vertex_input_state = OVertex::per_vertex();
|
||||
let stages = [
|
||||
PipelineShaderStageCreateInfo::new(mesh_vs.entry_point("main").unwrap()),
|
||||
PipelineShaderStageCreateInfo::new(mesh_fs.entry_point("main").unwrap()),
|
||||
];
|
||||
let subpass = Subpass::from(render_pass.clone(), 0).unwrap();
|
||||
|
||||
GraphicsPipeline::new(
|
||||
device.clone(),
|
||||
None,
|
||||
GraphicsPipelineCreateInfo {
|
||||
stages: stages.into_iter().collect(),
|
||||
vertex_input_state: Some(vertex_input_state),
|
||||
input_assembly_state: Some(InputAssemblyState::default()),
|
||||
viewport_state: Some(ViewportState {
|
||||
viewports: [Viewport {
|
||||
offset: [0.0, 0.0],
|
||||
extent: [dimensions[0] as f32, dimensions[1] as f32],
|
||||
depth_range: 0.0..1.0,
|
||||
},
|
||||
]))
|
||||
.fragment_shader(mesh_fs.entry_point("main").unwrap(), ())
|
||||
.depth_stencil_state(DepthStencilState::simple_depth_test())
|
||||
.rasterization_state(RasterizationState {
|
||||
front_face: Fixed(Clockwise),
|
||||
cull_mode: Fixed(CullMode::Back),
|
||||
extent: window_size.into(),
|
||||
depth_range: 0.0..=1.0,
|
||||
}]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
..Default::default()
|
||||
}),
|
||||
rasterization_state: Some(RasterizationState {
|
||||
front_face: Clockwise,
|
||||
cull_mode: CullMode::Back,
|
||||
..RasterizationState::default()
|
||||
})
|
||||
.multisample_state(MultisampleState {
|
||||
}),
|
||||
depth_stencil_state: Some(DepthStencilState {
|
||||
depth: Some(DepthState::simple()),
|
||||
..Default::default()
|
||||
}),
|
||||
multisample_state: Some(MultisampleState {
|
||||
rasterization_samples: Subpass::from(render_pass.clone(), 0)
|
||||
.unwrap()
|
||||
.num_samples()
|
||||
.unwrap(),
|
||||
..Default::default()
|
||||
})
|
||||
.build(allocator.device().clone())
|
||||
.unwrap();
|
||||
}),
|
||||
color_blend_state: Some(ColorBlendState::with_attachment_states(
|
||||
subpass.num_color_attachments(),
|
||||
ColorBlendAttachmentState::default(),
|
||||
)),
|
||||
subpass: Some(subpass.into()),
|
||||
..GraphicsPipelineCreateInfo::layout(layout)
|
||||
},
|
||||
)
|
||||
};
|
||||
|
||||
println!("Recompiling implicit pipeline... (may take up to 10 minutes)");
|
||||
|
||||
@@ -1627,7 +1718,7 @@ fn object_size_dependent_setup(
|
||||
let fragment_masks_buffer = Buffer::new_slice(
|
||||
&allocator,
|
||||
BufferCreateInfo {
|
||||
usage:BufferUsage::STORAGE_BUFFER,
|
||||
usage: BufferUsage::STORAGE_BUFFER,
|
||||
..Default::default()
|
||||
},
|
||||
BufferAllocateInfo {
|
||||
@@ -1643,7 +1734,8 @@ fn object_size_dependent_setup(
|
||||
allocator.clone(),
|
||||
SubbufferAllocatorCreateInfo {
|
||||
buffer_usage: BufferUsage::TRANSFER_SRC,
|
||||
memory_type_filter: MemoryTypeFilter::PREFER_HOST | MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
|
||||
memory_type_filter: MemoryTypeFilter::PREFER_HOST
|
||||
| MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user