clippy
This commit is contained in:
+177
-149
@@ -1,7 +1,7 @@
|
|||||||
#![feature(variant_count)]
|
#![feature(variant_count)]
|
||||||
use std::{
|
use std::{
|
||||||
error::Error,
|
error::Error,
|
||||||
fs::{File, remove_file, rename},
|
fs::{remove_file, rename, File},
|
||||||
io::{Cursor, Read, Write},
|
io::{Cursor, Read, Write},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
@@ -19,42 +19,38 @@ const MSAA_SAMPLES_ACTUAL: u32 = if MSAA_ENABLE { MSAA_SAMPLES } else { 1 };
|
|||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use egui_winit_vulkano::{Gui, GuiConfig};
|
use egui_winit_vulkano::{Gui, GuiConfig};
|
||||||
use foldhash::{HashMap, HashMapExt, HashSet};
|
use foldhash::{HashMap, HashMapExt, HashSet};
|
||||||
use glam::{self, EulerRot, Mat3, Mat4, Vec3, vec3};
|
use glam::{self, vec3, EulerRot, Mat3, Mat4, Vec3};
|
||||||
use instruction_set::InputTypes;
|
use instruction_set::InputTypes;
|
||||||
use log::{error, info, trace};
|
use log::{error, info, trace};
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use simplelog::{CombinedLogger, Config, TermLogger, WriteLogger};
|
use simplelog::{CombinedLogger, Config, TermLogger, WriteLogger};
|
||||||
use vulkano::{
|
use vulkano::{
|
||||||
Validated, Version, VulkanError, VulkanLibrary,
|
|
||||||
buffer::{
|
buffer::{
|
||||||
Buffer, BufferCreateInfo, BufferUsage, Subbuffer,
|
|
||||||
allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
|
allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
|
||||||
|
Buffer, BufferCreateInfo, BufferUsage, Subbuffer,
|
||||||
},
|
},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
AutoCommandBufferBuilder, CommandBufferUsage, CopyBufferInfo, PrimaryCommandBufferAbstract,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
RenderPassBeginInfo, SubpassBeginInfo, SubpassContents,
|
CopyBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, SubpassBeginInfo,
|
||||||
allocator::StandardCommandBufferAllocator,
|
SubpassContents,
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
DescriptorSet, WriteDescriptorSet, allocator::StandardDescriptorSetAllocator,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
},
|
},
|
||||||
device::{
|
device::{
|
||||||
Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures, DeviceOwned, Queue,
|
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures,
|
||||||
QueueCreateInfo, QueueFlags, physical::PhysicalDeviceType,
|
DeviceOwned, Queue, QueueCreateInfo, QueueFlags,
|
||||||
},
|
},
|
||||||
format::Format,
|
format::Format,
|
||||||
image::{Image, ImageCreateInfo, ImageType, ImageUsage, view::ImageView},
|
image::{view::ImageView, Image, ImageCreateInfo, ImageType, ImageUsage},
|
||||||
instance::{Instance, InstanceCreateInfo, InstanceExtensions},
|
instance::{Instance, InstanceCreateInfo, InstanceExtensions},
|
||||||
memory::allocator::{
|
memory::allocator::{
|
||||||
AllocationCreateInfo, MemoryAllocatePreference, MemoryTypeFilter, StandardMemoryAllocator,
|
AllocationCreateInfo, MemoryAllocatePreference, MemoryTypeFilter, StandardMemoryAllocator,
|
||||||
},
|
},
|
||||||
pipeline::{
|
pipeline::{
|
||||||
ComputePipeline, DynamicState, GraphicsPipeline, Pipeline, PipelineBindPoint,
|
|
||||||
PipelineLayout, PipelineShaderStageCreateInfo,
|
|
||||||
cache::{PipelineCache, PipelineCacheCreateInfo},
|
cache::{PipelineCache, PipelineCacheCreateInfo},
|
||||||
compute::ComputePipelineCreateInfo,
|
compute::ComputePipelineCreateInfo,
|
||||||
graphics::{
|
graphics::{
|
||||||
GraphicsPipelineCreateInfo,
|
|
||||||
color_blend::{ColorBlendAttachmentState, ColorBlendState},
|
color_blend::{ColorBlendAttachmentState, ColorBlendState},
|
||||||
depth_stencil::{DepthState, DepthStencilState},
|
depth_stencil::{DepthState, DepthStencilState},
|
||||||
input_assembly::InputAssemblyState,
|
input_assembly::InputAssemblyState,
|
||||||
@@ -62,16 +58,20 @@ use vulkano::{
|
|||||||
rasterization::{CullMode, FrontFace, RasterizationState},
|
rasterization::{CullMode, FrontFace, RasterizationState},
|
||||||
vertex_input::{Vertex, VertexDefinition},
|
vertex_input::{Vertex, VertexDefinition},
|
||||||
viewport::{Viewport, ViewportState},
|
viewport::{Viewport, ViewportState},
|
||||||
|
GraphicsPipelineCreateInfo,
|
||||||
},
|
},
|
||||||
layout::PipelineDescriptorSetLayoutCreateInfo,
|
layout::PipelineDescriptorSetLayoutCreateInfo,
|
||||||
|
ComputePipeline, DynamicState, GraphicsPipeline, Pipeline, PipelineBindPoint,
|
||||||
|
PipelineLayout, PipelineShaderStageCreateInfo,
|
||||||
},
|
},
|
||||||
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
|
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
|
||||||
shader::{ShaderModule, SpecializationConstant},
|
shader::{ShaderModule, SpecializationConstant},
|
||||||
swapchain::{
|
swapchain::{
|
||||||
PresentMode, Surface, SurfaceInfo, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo,
|
acquire_next_image, PresentMode, Surface, SurfaceInfo, Swapchain, SwapchainCreateInfo,
|
||||||
acquire_next_image,
|
SwapchainPresentInfo,
|
||||||
},
|
},
|
||||||
sync::{self, GpuFuture},
|
sync::{self, GpuFuture},
|
||||||
|
Validated, Version, VulkanError, VulkanLibrary,
|
||||||
};
|
};
|
||||||
use winit::{
|
use winit::{
|
||||||
application::ApplicationHandler,
|
application::ApplicationHandler,
|
||||||
@@ -204,17 +204,20 @@ impl App {
|
|||||||
let library = VulkanLibrary::new().expect("Vulkan is not installed???");
|
let library = VulkanLibrary::new().expect("Vulkan is not installed???");
|
||||||
let required_extensions = Surface::required_extensions(event_loop).unwrap();
|
let required_extensions = Surface::required_extensions(event_loop).unwrap();
|
||||||
|
|
||||||
let instance = Instance::new(library, InstanceCreateInfo {
|
let instance = Instance::new(
|
||||||
enabled_extensions: InstanceExtensions {
|
library,
|
||||||
ext_surface_maintenance1: true,
|
InstanceCreateInfo {
|
||||||
..required_extensions
|
enabled_extensions: InstanceExtensions {
|
||||||
|
ext_surface_maintenance1: true,
|
||||||
|
..required_extensions
|
||||||
|
},
|
||||||
|
engine_name: Some("ImplEng".to_owned()),
|
||||||
|
engine_version: Version::major_minor(0, 1),
|
||||||
|
application_name: Some(env!("CARGO_PKG_NAME").to_owned()),
|
||||||
|
application_version: app_version(),
|
||||||
|
..Default::default()
|
||||||
},
|
},
|
||||||
engine_name: Some("ImplEng".to_owned()),
|
)
|
||||||
engine_version: Version::major_minor(0, 1),
|
|
||||||
application_name: Some(env!("CARGO_PKG_NAME").to_owned()),
|
|
||||||
application_version: app_version(),
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let mut device_extensions = DeviceExtensions {
|
let mut device_extensions = DeviceExtensions {
|
||||||
@@ -288,34 +291,37 @@ impl App {
|
|||||||
device_extensions.khr_dynamic_rendering = true;
|
device_extensions.khr_dynamic_rendering = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (device, mut queues) = Device::new(physical_device, DeviceCreateInfo {
|
let (device, mut queues) = Device::new(
|
||||||
enabled_extensions: device_extensions,
|
physical_device,
|
||||||
queue_create_infos: vec![
|
DeviceCreateInfo {
|
||||||
QueueCreateInfo {
|
enabled_extensions: device_extensions,
|
||||||
queue_family_index: graphics_queue_index,
|
queue_create_infos: vec![
|
||||||
..Default::default()
|
QueueCreateInfo {
|
||||||
|
queue_family_index: graphics_queue_index,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
QueueCreateInfo {
|
||||||
|
queue_family_index: transfer_queue_index,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
],
|
||||||
|
enabled_features: DeviceFeatures {
|
||||||
|
mesh_shader: true,
|
||||||
|
task_shader: true,
|
||||||
|
sample_rate_shading: true,
|
||||||
|
//shader_float16: true,
|
||||||
|
shader_int16: true,
|
||||||
|
shader_int8: true,
|
||||||
|
storage_buffer8_bit_access: true,
|
||||||
|
geometry_shader: true,
|
||||||
|
primitive_fragment_shading_rate: true,
|
||||||
|
maintenance4: true,
|
||||||
|
dynamic_rendering: DYNAMIC_STATE,
|
||||||
|
..DeviceFeatures::empty()
|
||||||
},
|
},
|
||||||
QueueCreateInfo {
|
..Default::default()
|
||||||
queue_family_index: transfer_queue_index,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
],
|
|
||||||
enabled_features: DeviceFeatures {
|
|
||||||
mesh_shader: true,
|
|
||||||
task_shader: true,
|
|
||||||
sample_rate_shading: true,
|
|
||||||
//shader_float16: true,
|
|
||||||
shader_int16: true,
|
|
||||||
shader_int8: true,
|
|
||||||
storage_buffer8_bit_access: true,
|
|
||||||
geometry_shader: true,
|
|
||||||
primitive_fragment_shading_rate: true,
|
|
||||||
maintenance4: true,
|
|
||||||
dynamic_rendering: DYNAMIC_STATE,
|
|
||||||
..DeviceFeatures::empty()
|
|
||||||
},
|
},
|
||||||
..Default::default()
|
)
|
||||||
})
|
|
||||||
.expect("Unable to initialize device");
|
.expect("Unable to initialize device");
|
||||||
|
|
||||||
let graphics_queue = queues.next().expect("Unable to retrieve queues");
|
let graphics_queue = queues.next().expect("Unable to retrieve queues");
|
||||||
@@ -331,13 +337,15 @@ impl App {
|
|||||||
Default::default(),
|
Default::default(),
|
||||||
));
|
));
|
||||||
|
|
||||||
let uniform_buffer_allocator =
|
let uniform_buffer_allocator = SubbufferAllocator::new(
|
||||||
SubbufferAllocator::new(memory_allocator.clone(), SubbufferAllocatorCreateInfo {
|
memory_allocator.clone(),
|
||||||
|
SubbufferAllocatorCreateInfo {
|
||||||
buffer_usage: BufferUsage::UNIFORM_BUFFER | BufferUsage::STORAGE_BUFFER,
|
buffer_usage: BufferUsage::UNIFORM_BUFFER | BufferUsage::STORAGE_BUFFER,
|
||||||
memory_type_filter: MemoryTypeFilter::PREFER_DEVICE
|
memory_type_filter: MemoryTypeFilter::PREFER_DEVICE
|
||||||
| MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
|
| MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let pipeline_cache = get_pipeline_cache(device.clone());
|
let pipeline_cache = get_pipeline_cache(device.clone());
|
||||||
|
|
||||||
@@ -487,10 +495,13 @@ impl ApplicationHandler for App {
|
|||||||
let surface_capabilities = self
|
let surface_capabilities = self
|
||||||
.device
|
.device
|
||||||
.physical_device()
|
.physical_device()
|
||||||
.surface_capabilities(&surface, SurfaceInfo {
|
.surface_capabilities(
|
||||||
present_mode: Some(present_mode),
|
&surface,
|
||||||
..Default::default()
|
SurfaceInfo {
|
||||||
})
|
present_mode: Some(present_mode),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let (image_format, _) = self
|
let (image_format, _) = self
|
||||||
@@ -499,26 +510,30 @@ impl ApplicationHandler for App {
|
|||||||
.surface_formats(&surface, Default::default())
|
.surface_formats(&surface, Default::default())
|
||||||
.unwrap()[0];
|
.unwrap()[0];
|
||||||
|
|
||||||
Swapchain::new(self.device.clone(), surface.clone(), SwapchainCreateInfo {
|
Swapchain::new(
|
||||||
min_image_count: 3
|
self.device.clone(),
|
||||||
.max(surface_capabilities.min_image_count)
|
surface.clone(),
|
||||||
.min(surface_capabilities.max_image_count.unwrap_or(u32::MAX)),
|
SwapchainCreateInfo {
|
||||||
|
min_image_count: 3
|
||||||
|
.max(surface_capabilities.min_image_count)
|
||||||
|
.min(surface_capabilities.max_image_count.unwrap_or(u32::MAX)),
|
||||||
|
|
||||||
image_format,
|
image_format,
|
||||||
image_extent: window_size.into(),
|
image_extent: window_size.into(),
|
||||||
|
|
||||||
image_usage: ImageUsage::COLOR_ATTACHMENT | ImageUsage::TRANSFER_DST,
|
image_usage: ImageUsage::COLOR_ATTACHMENT | ImageUsage::TRANSFER_DST,
|
||||||
|
|
||||||
composite_alpha: surface_capabilities
|
composite_alpha: surface_capabilities
|
||||||
.supported_composite_alpha
|
.supported_composite_alpha
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.next()
|
.next()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
|
||||||
present_mode,
|
present_mode,
|
||||||
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
},
|
||||||
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1034,19 +1049,19 @@ impl App {
|
|||||||
fake_csg.push(CSG {
|
fake_csg.push(CSG {
|
||||||
name: format!("fuzz_{i}"),
|
name: format!("fuzz_{i}"),
|
||||||
parts: vec![
|
parts: vec![
|
||||||
CSGPart::opcode(InstructionSet::OPMulVec3Float, vec![
|
CSGPart::opcode(
|
||||||
Inputs::Variable,
|
InstructionSet::OPMulVec3Float,
|
||||||
Inputs::Float(0.9),
|
vec![Inputs::Variable, Inputs::Float(0.9)],
|
||||||
]),
|
),
|
||||||
CSGPart::opcode(InstructionSet::OPDupVec3, vec![Inputs::Variable]),
|
CSGPart::opcode(InstructionSet::OPDupVec3, vec![Inputs::Variable]),
|
||||||
CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![
|
CSGPart::opcode(
|
||||||
Inputs::Variable,
|
InstructionSet::OPAddVec3Vec3,
|
||||||
Inputs::Vec3(vec3(-0.7, i as f32, -0.7)),
|
vec![Inputs::Variable, Inputs::Vec3(vec3(-0.7, i as f32, -0.7))],
|
||||||
]),
|
),
|
||||||
CSGPart::opcode(InstructionSet::OPSDFSphere, vec![
|
CSGPart::opcode(
|
||||||
Inputs::Float(0.5),
|
InstructionSet::OPSDFSphere,
|
||||||
Inputs::Variable,
|
vec![Inputs::Float(0.5), Inputs::Variable],
|
||||||
]),
|
),
|
||||||
//CSGPart::opcode(InstructionSet::OPNop,vec![]),
|
//CSGPart::opcode(InstructionSet::OPNop,vec![]),
|
||||||
//CSGPart::opcode(InstructionSet::OPDupVec3,
|
//CSGPart::opcode(InstructionSet::OPDupVec3,
|
||||||
// vec![Inputs::Variable]),
|
// vec![Inputs::Variable]),
|
||||||
@@ -1056,21 +1071,21 @@ impl App {
|
|||||||
// CSGPart::opcode(InstructionSet::OPAddVec3Vec3,
|
// CSGPart::opcode(InstructionSet::OPAddVec3Vec3,
|
||||||
// vec![Inputs::Variable, Inputs::Vec3([-0.0, -0.0,
|
// vec![Inputs::Variable, Inputs::Vec3([-0.0, -0.0,
|
||||||
// -0.0].into())]),
|
// -0.0].into())]),
|
||||||
CSGPart::opcode(InstructionSet::OPSDFSphere, vec![
|
CSGPart::opcode(
|
||||||
Inputs::Float(1.2),
|
InstructionSet::OPSDFSphere,
|
||||||
Inputs::Variable,
|
vec![Inputs::Float(1.2), Inputs::Variable],
|
||||||
]),
|
),
|
||||||
//CSGPart::opcode(InstructionSet::OPSDFBox,
|
//CSGPart::opcode(InstructionSet::OPSDFBox,
|
||||||
// vec![Inputs::Variable,
|
// vec![Inputs::Variable,
|
||||||
// Inputs::Vec3([0.7, 0.7, 0.7].into())]),
|
// Inputs::Vec3([0.7, 0.7, 0.7].into())]),
|
||||||
CSGPart::opcode(InstructionSet::OPMinFloat, vec![
|
CSGPart::opcode(
|
||||||
Inputs::Variable,
|
InstructionSet::OPMinFloat,
|
||||||
Inputs::Variable,
|
vec![Inputs::Variable, Inputs::Variable],
|
||||||
]),
|
),
|
||||||
CSGPart::opcode(InstructionSet::OPDivFloatFloat, vec![
|
CSGPart::opcode(
|
||||||
Inputs::Variable,
|
InstructionSet::OPDivFloatFloat,
|
||||||
Inputs::Float(0.9),
|
vec![Inputs::Variable, Inputs::Float(0.9)],
|
||||||
]),
|
),
|
||||||
CSGPart::opcode(InstructionSet::OPStop, vec![Inputs::Variable]),
|
CSGPart::opcode(InstructionSet::OPStop, vec![Inputs::Variable]),
|
||||||
],
|
],
|
||||||
pos: Vec3::ZERO,
|
pos: Vec3::ZERO,
|
||||||
@@ -1106,7 +1121,7 @@ impl App {
|
|||||||
for (i, val) in scene.iter().skip(1).take(32).enumerate() {
|
for (i, val) in scene.iter().skip(1).take(32).enumerate() {
|
||||||
for (y, code) in val.iter().enumerate() {
|
for (y, code) in val.iter().enumerate() {
|
||||||
spec_constants.insert(
|
spec_constants.insert(
|
||||||
(1000 + (i * 8) + (y * 2) + 0) as u32,
|
(1000 + (i * 8) + (y * 2)) as u32,
|
||||||
SpecializationConstant::U32(code & 0xFFFF),
|
SpecializationConstant::U32(code & 0xFFFF),
|
||||||
);
|
);
|
||||||
spec_constants.insert(
|
spec_constants.insert(
|
||||||
@@ -1324,10 +1339,13 @@ impl App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.next_subpass(Default::default(), SubpassBeginInfo {
|
.next_subpass(
|
||||||
contents: SubpassContents::SecondaryCommandBuffers,
|
Default::default(),
|
||||||
..Default::default()
|
SubpassBeginInfo {
|
||||||
})
|
contents: SubpassContents::SecondaryCommandBuffers,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.execute_commands(guicb)
|
.execute_commands(guicb)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -1420,18 +1438,21 @@ fn framebuffer_generation(
|
|||||||
.map(|image| {
|
.map(|image| {
|
||||||
let view = ImageView::new_default(image.clone()).unwrap();
|
let view = ImageView::new_default(image.clone()).unwrap();
|
||||||
|
|
||||||
Framebuffer::new(render_pass.clone(), FramebufferCreateInfo {
|
Framebuffer::new(
|
||||||
attachments: if MSAA_ENABLE {
|
render_pass.clone(),
|
||||||
vec![
|
FramebufferCreateInfo {
|
||||||
intermediary.as_ref().unwrap().clone(),
|
attachments: if MSAA_ENABLE {
|
||||||
view,
|
vec![
|
||||||
depth_buffer.clone(),
|
intermediary.as_ref().unwrap().clone(),
|
||||||
]
|
view,
|
||||||
} else {
|
depth_buffer.clone(),
|
||||||
vec![view, depth_buffer.clone()]
|
]
|
||||||
|
} else {
|
||||||
|
vec![view, depth_buffer.clone()]
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
},
|
},
|
||||||
..Default::default()
|
)
|
||||||
})
|
|
||||||
.unwrap()
|
.unwrap()
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
@@ -1444,7 +1465,7 @@ fn pipeline_recompile(
|
|||||||
cache: &Arc<PipelineCache>,
|
cache: &Arc<PipelineCache>,
|
||||||
shader_modules: &ShaderModules,
|
shader_modules: &ShaderModules,
|
||||||
debug: &PreviousDebug,
|
debug: &PreviousDebug,
|
||||||
scene: &Vec<[u32; 4]>,
|
scene: &[[u32; 4]],
|
||||||
viewport: Option<&Viewport>,
|
viewport: Option<&Viewport>,
|
||||||
) -> (Arc<GraphicsPipeline>, Arc<GraphicsPipeline>) {
|
) -> (Arc<GraphicsPipeline>, Arc<GraphicsPipeline>) {
|
||||||
let device = cache.device();
|
let device = cache.device();
|
||||||
@@ -1494,7 +1515,7 @@ fn pipeline_recompile(
|
|||||||
for (i, val) in scene.iter().skip(1).take(32).enumerate() {
|
for (i, val) in scene.iter().skip(1).take(32).enumerate() {
|
||||||
for (y, code) in val.iter().enumerate() {
|
for (y, code) in val.iter().enumerate() {
|
||||||
spec_constants.insert(
|
spec_constants.insert(
|
||||||
(1000 + (i * 8) + (y * 2) + 0) as u32,
|
(1000 + (i * 8) + (y * 2)) as u32,
|
||||||
SpecializationConstant::U32(code & 0xFFFF),
|
SpecializationConstant::U32(code & 0xFFFF),
|
||||||
);
|
);
|
||||||
spec_constants.insert(
|
spec_constants.insert(
|
||||||
@@ -1799,19 +1820,19 @@ fn object_size_dependent_setup(
|
|||||||
];
|
];
|
||||||
|
|
||||||
let example = vec![
|
let example = vec![
|
||||||
CSGPart::opcode(InstructionSet::OPMulVec3Float, vec![
|
CSGPart::opcode(
|
||||||
Inputs::Variable,
|
InstructionSet::OPMulVec3Float,
|
||||||
Inputs::Float(0.9),
|
vec![Inputs::Variable, Inputs::Float(0.9)],
|
||||||
]),
|
),
|
||||||
CSGPart::opcode(InstructionSet::OPDupVec3, vec![Inputs::Variable]),
|
CSGPart::opcode(InstructionSet::OPDupVec3, vec![Inputs::Variable]),
|
||||||
CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![
|
CSGPart::opcode(
|
||||||
Inputs::Variable,
|
InstructionSet::OPAddVec3Vec3,
|
||||||
Inputs::Vec3([-0.7, -1.2, -0.7].into()),
|
vec![Inputs::Variable, Inputs::Vec3([-0.7, -1.2, -0.7].into())],
|
||||||
]),
|
),
|
||||||
CSGPart::opcode(InstructionSet::OPSDFSphere, vec![
|
CSGPart::opcode(
|
||||||
Inputs::Float(0.5),
|
InstructionSet::OPSDFSphere,
|
||||||
Inputs::Variable,
|
vec![Inputs::Float(0.5), Inputs::Variable],
|
||||||
]),
|
),
|
||||||
//CSGPart::opcode(InstructionSet::OPNop,vec![]),
|
//CSGPart::opcode(InstructionSet::OPNop,vec![]),
|
||||||
//CSGPart::opcode(InstructionSet::OPDupVec3, vec![Inputs::Variable]),
|
//CSGPart::opcode(InstructionSet::OPDupVec3, vec![Inputs::Variable]),
|
||||||
//CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![Inputs::Variable,
|
//CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![Inputs::Variable,
|
||||||
@@ -1820,20 +1841,20 @@ fn object_size_dependent_setup(
|
|||||||
// Inputs::Vec3([-0.0, -0.0, -0.0].into())]),
|
// Inputs::Vec3([-0.0, -0.0, -0.0].into())]),
|
||||||
// CSGPart::opcode(InstructionSet::OPSDFSphere,vec![Inputs::Float(1.2),
|
// CSGPart::opcode(InstructionSet::OPSDFSphere,vec![Inputs::Float(1.2),
|
||||||
// Inputs::Variable]),
|
// Inputs::Variable]),
|
||||||
CSGPart::opcode(InstructionSet::OPSDFTorus, vec![
|
CSGPart::opcode(
|
||||||
Inputs::Vec2([0.7, 0.4].into()),
|
InstructionSet::OPSDFTorus,
|
||||||
Inputs::Variable,
|
vec![Inputs::Vec2([0.7, 0.4].into()), Inputs::Variable],
|
||||||
]),
|
),
|
||||||
//CSGPart::opcode(InstructionSet::OPSDFBox, vec![Inputs::Vec3([0.7, 0.4, 0.7].into()),
|
//CSGPart::opcode(InstructionSet::OPSDFBox, vec![Inputs::Vec3([0.7, 0.4, 0.7].into()),
|
||||||
// Inputs::Variable]),
|
// Inputs::Variable]),
|
||||||
CSGPart::opcode(InstructionSet::OPMinFloat, vec![
|
CSGPart::opcode(
|
||||||
Inputs::Variable,
|
InstructionSet::OPMinFloat,
|
||||||
Inputs::Variable,
|
vec![Inputs::Variable, Inputs::Variable],
|
||||||
]),
|
),
|
||||||
CSGPart::opcode(InstructionSet::OPDivFloatFloat, vec![
|
CSGPart::opcode(
|
||||||
Inputs::Variable,
|
InstructionSet::OPDivFloatFloat,
|
||||||
Inputs::Float(0.9),
|
vec![Inputs::Variable, Inputs::Float(0.9)],
|
||||||
]),
|
),
|
||||||
CSGPart::opcode(InstructionSet::OPStop, vec![Inputs::Variable]),
|
CSGPart::opcode(InstructionSet::OPStop, vec![Inputs::Variable]),
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -2066,11 +2087,15 @@ fn object_size_dependent_setup(
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let staging = SubbufferAllocator::new(allocator.clone(), SubbufferAllocatorCreateInfo {
|
let staging = SubbufferAllocator::new(
|
||||||
buffer_usage: BufferUsage::TRANSFER_SRC,
|
allocator.clone(),
|
||||||
memory_type_filter: MemoryTypeFilter::PREFER_HOST | MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
|
SubbufferAllocatorCreateInfo {
|
||||||
..Default::default()
|
buffer_usage: BufferUsage::TRANSFER_SRC,
|
||||||
});
|
memory_type_filter: MemoryTypeFilter::PREFER_HOST
|
||||||
|
| MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let csg_scene = gpu_buffer(
|
let csg_scene = gpu_buffer(
|
||||||
scene.clone(),
|
scene.clone(),
|
||||||
@@ -2197,10 +2222,13 @@ fn get_pipeline_cache(device: Arc<Device>) -> Arc<PipelineCache> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
PipelineCache::new(device, PipelineCacheCreateInfo {
|
PipelineCache::new(
|
||||||
initial_data,
|
device,
|
||||||
..Default::default()
|
PipelineCacheCreateInfo {
|
||||||
})
|
initial_data,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-10
@@ -346,16 +346,13 @@ pub(crate) fn load_csg(
|
|||||||
.map(|inpart| {
|
.map(|inpart| {
|
||||||
let ty = inpart.get("type").ok_or("no type!")?.as_str();
|
let ty = inpart.get("type").ok_or("no type!")?.as_str();
|
||||||
let csgpart = CSGPart::opcode(InstructionSet::OPNop, vec![]);
|
let csgpart = CSGPart::opcode(InstructionSet::OPNop, vec![]);
|
||||||
match ty {
|
if ty == "sphere" {
|
||||||
"sphere" => {
|
let _blend = get_f32(inpart, "blend")?;
|
||||||
let _blend = get_f32(inpart, "blend")?;
|
let _shell = get_percentage(inpart, "shell%")?;
|
||||||
let _shell = get_percentage(inpart, "shell%")?;
|
let _power = get_f32_default(inpart, "power", 2.)?;
|
||||||
let _power = get_f32_default(inpart, "power", 2.)?;
|
let _rgb = get_rgb(inpart)?;
|
||||||
let _rgb = get_rgb(inpart)?;
|
let _trs = get_trs(inpart)?;
|
||||||
let _trs = get_trs(inpart)?;
|
let _half = get_half(inpart)?;
|
||||||
let _half = get_half(inpart)?;
|
|
||||||
},
|
|
||||||
_ => {}, //return Err("unknown type of csg".to_owned()),
|
|
||||||
}
|
}
|
||||||
Ok(csgpart)
|
Ok(csgpart)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user