Merge branch 'jit' of github.com:Molive-0/up-to-spec into jit
This commit is contained in:
Generated
+6
-6
@@ -171,9 +171,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "avif-serialize"
|
name = "avif-serialize"
|
||||||
version = "0.8.4"
|
version = "0.8.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "19135c0c7a60bfee564dbe44ab5ce0557c6bf3884e5291a50be76a15640c4fbd"
|
checksum = "2ea8ef51aced2b9191c08197f55450d830876d9933f8f48a429b354f1d496b42"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
]
|
]
|
||||||
@@ -283,9 +283,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.27"
|
version = "1.2.29"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc"
|
checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -2057,9 +2057,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rgb"
|
name = "rgb"
|
||||||
version = "0.8.50"
|
version = "0.8.51"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a"
|
checksum = "a457e416a0f90d246a4c3288bd7a25b2304ca727f253f95be383dd17af56be8f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "roxmltree"
|
name = "roxmltree"
|
||||||
|
|||||||
+23
-5
@@ -1,22 +1,40 @@
|
|||||||
#version 460
|
#version 460
|
||||||
#include "include.glsl"
|
#include "include.glsl"
|
||||||
|
#include "implicit_include.glsl"
|
||||||
|
|
||||||
layout(location = 0) in vec3 position;
|
layout(location = 0) in vec3 position;
|
||||||
|
|
||||||
layout(location = 0) out vec4 pos;
|
layout(location = 0) out vec4 pos;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec3 internal_pos = vec3(float((gl_InstanceIndex >> 6) & 7) / 8.0,
|
vec3 internal_pos = vec3(
|
||||||
float((gl_InstanceIndex >> 3) & 7) / 8.0,
|
float((gl_InstanceIndex >> 10) & 31) / 32.0,
|
||||||
float((gl_InstanceIndex >> 0) & 7) / 8.0);
|
float((gl_InstanceIndex >> 5) & 31) / 32.0,
|
||||||
|
float((gl_InstanceIndex >> 0) & 31) / 32.0
|
||||||
|
);
|
||||||
|
|
||||||
bool enable = (pc.enable[gl_InstanceIndex >> 5] & (1 << (gl_InstanceIndex & 31))) != 0;
|
bool enable;
|
||||||
|
switch ((gl_InstanceIndex >> 5) & 3) {
|
||||||
|
default:
|
||||||
|
case 0:
|
||||||
|
enable = (object_uniforms.enable[gl_InstanceIndex >> 7].x & (1 << (gl_InstanceIndex & 31))) != 0;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
enable = (object_uniforms.enable[gl_InstanceIndex >> 7].y & (1 << (gl_InstanceIndex & 31))) != 0;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
enable = (object_uniforms.enable[gl_InstanceIndex >> 7].z & (1 << (gl_InstanceIndex & 31))) != 0;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
enable = (object_uniforms.enable[gl_InstanceIndex >> 7].w & (1 << (gl_InstanceIndex & 31))) != 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!enable) {
|
if (!enable) {
|
||||||
gl_Position = vec4(0.0 / 0.0);
|
gl_Position = vec4(0.0 / 0.0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = vec4((((position / 8.0) + internal_pos) * pc.dimensions) + pc.lowest_corner, 1.);
|
pos = vec4((((position / 32.0) + internal_pos) * object_uniforms.dimensions) + object_uniforms.lowest_corner, 1.);
|
||||||
gl_Position = camera_uniforms.proj_view * pc.world * pos;
|
gl_Position = camera_uniforms.proj_view * pc.world * pos;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#ifndef implicit_include
|
||||||
|
#define implicit_include
|
||||||
|
|
||||||
|
layout(set = 1, binding = 0) uniform Object {
|
||||||
|
uvec4 enable[32 * 8];
|
||||||
|
vec3 dimensions;
|
||||||
|
vec3 lowest_corner;
|
||||||
|
uint material;
|
||||||
|
} object_uniforms;
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -4,10 +4,6 @@
|
|||||||
layout(push_constant) uniform PushConstantData {
|
layout(push_constant) uniform PushConstantData {
|
||||||
mat4 world;
|
mat4 world;
|
||||||
mat4 inv_world;
|
mat4 inv_world;
|
||||||
vec3 dimensions;
|
|
||||||
vec3 lowest_corner;
|
|
||||||
uint enable[16];
|
|
||||||
uint material;
|
|
||||||
} pc;
|
} pc;
|
||||||
|
|
||||||
layout(set = 0, binding = 0) uniform Lights {
|
layout(set = 0, binding = 0) uniform Lights {
|
||||||
|
|||||||
+62
-18
@@ -188,6 +188,7 @@ struct App {
|
|||||||
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
|
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
|
||||||
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
|
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
|
||||||
uniform_buffer_allocator: SubbufferAllocator,
|
uniform_buffer_allocator: SubbufferAllocator,
|
||||||
|
block_enable_allocator: Arc<Mutex<SubbufferAllocator>>,
|
||||||
pipeline_cache: Arc<PipelineCache>,
|
pipeline_cache: Arc<PipelineCache>,
|
||||||
draw_gui: bool,
|
draw_gui: bool,
|
||||||
gstate: GState,
|
gstate: GState,
|
||||||
@@ -372,6 +373,16 @@ impl App {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let block_enable_allocator = Arc::new(Mutex::new(SubbufferAllocator::new(
|
||||||
|
memory_allocator.clone(),
|
||||||
|
SubbufferAllocatorCreateInfo {
|
||||||
|
buffer_usage: BufferUsage::UNIFORM_BUFFER,
|
||||||
|
memory_type_filter: MemoryTypeFilter::PREFER_DEVICE
|
||||||
|
| MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)));
|
||||||
|
|
||||||
let pipeline_cache = get_pipeline_cache(device.clone());
|
let pipeline_cache = get_pipeline_cache(device.clone());
|
||||||
|
|
||||||
let mut gstate = GState::default();
|
let mut gstate = GState::default();
|
||||||
@@ -438,6 +449,7 @@ impl App {
|
|||||||
descriptor_set_allocator,
|
descriptor_set_allocator,
|
||||||
command_buffer_allocator,
|
command_buffer_allocator,
|
||||||
uniform_buffer_allocator,
|
uniform_buffer_allocator,
|
||||||
|
block_enable_allocator,
|
||||||
pipeline_cache,
|
pipeline_cache,
|
||||||
csg_count: gstate.csg.len(),
|
csg_count: gstate.csg.len(),
|
||||||
draw_gui: true,
|
draw_gui: true,
|
||||||
@@ -462,7 +474,7 @@ mod implicit_vs {
|
|||||||
path: "src/implicit.vert.glsl",
|
path: "src/implicit.vert.glsl",
|
||||||
vulkan_version: "1.3",
|
vulkan_version: "1.3",
|
||||||
spirv_version: "1.6",
|
spirv_version: "1.6",
|
||||||
custom_derives: [Debug, Clone, Copy, Default],
|
custom_derives: [Debug, Clone, Copy],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,7 +484,7 @@ mod fullscreen_vs {
|
|||||||
path: "src/fullscreen.vert.glsl",
|
path: "src/fullscreen.vert.glsl",
|
||||||
vulkan_version: "1.3",
|
vulkan_version: "1.3",
|
||||||
spirv_version: "1.6",
|
spirv_version: "1.6",
|
||||||
custom_derives: [Debug, Clone, Copy, Default],
|
custom_derives: [Debug, Clone, Copy],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,7 +494,7 @@ mod lighting_fs {
|
|||||||
path: "src/lighting.frag.glsl",
|
path: "src/lighting.frag.glsl",
|
||||||
vulkan_version: "1.3",
|
vulkan_version: "1.3",
|
||||||
spirv_version: "1.6",
|
spirv_version: "1.6",
|
||||||
custom_derives: [Debug, Clone, Copy, Default],
|
custom_derives: [Debug, Clone, Copy],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -810,6 +822,9 @@ impl ApplicationHandler for App {
|
|||||||
self.pipeline_cache.clone(),
|
self.pipeline_cache.clone(),
|
||||||
rcx.shader_modules.clone(),
|
rcx.shader_modules.clone(),
|
||||||
self.previous_debug.clone(),
|
self.previous_debug.clone(),
|
||||||
|
self.block_enable_allocator.clone(),
|
||||||
|
self.descriptor_set_allocator.clone(),
|
||||||
|
rcx.swapchain.image_count(),
|
||||||
0,
|
0,
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -945,7 +960,7 @@ impl App {
|
|||||||
Arc<DescriptorSet>,
|
Arc<DescriptorSet>,
|
||||||
Arc<DescriptorSet>,
|
Arc<DescriptorSet>,
|
||||||
) {
|
) {
|
||||||
let implicit_set = if self.csg_count > 0 {
|
let implicit_set1 = if self.csg_count > 0 {
|
||||||
let implicit_layout = &self.gstate.csg[0]
|
let implicit_layout = &self.gstate.csg[0]
|
||||||
.read()
|
.read()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -991,13 +1006,13 @@ impl App {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let normals_set2 = if self.csg_count > 0 {
|
let normals_set3 = if self.csg_count > 0 {
|
||||||
let normals_layout = &self.gstate.csg[0]
|
let normals_layout = &self.gstate.csg[0]
|
||||||
.read()
|
.read()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.normals_pipeline
|
.normals_pipeline
|
||||||
.layout()
|
.layout()
|
||||||
.set_layouts()[1]
|
.set_layouts()[2]
|
||||||
.clone();
|
.clone();
|
||||||
let normals_set = DescriptorSet::new(
|
let normals_set = DescriptorSet::new(
|
||||||
self.descriptor_set_allocator.clone(),
|
self.descriptor_set_allocator.clone(),
|
||||||
@@ -1040,9 +1055,9 @@ impl App {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
(
|
(
|
||||||
implicit_set,
|
implicit_set1,
|
||||||
normals_set1,
|
normals_set1,
|
||||||
normals_set2,
|
normals_set3,
|
||||||
lighting_set1,
|
lighting_set1,
|
||||||
lighting_set2,
|
lighting_set2,
|
||||||
)
|
)
|
||||||
@@ -1083,6 +1098,7 @@ impl App {
|
|||||||
builder: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>,
|
builder: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>,
|
||||||
push_constants: &Vec<PushConstantData>,
|
push_constants: &Vec<PushConstantData>,
|
||||||
implicit_set: Arc<DescriptorSet>,
|
implicit_set: Arc<DescriptorSet>,
|
||||||
|
frame_index: usize,
|
||||||
) {
|
) {
|
||||||
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
||||||
let csg = csg.read().unwrap();
|
let csg = csg.read().unwrap();
|
||||||
@@ -1093,7 +1109,10 @@ impl App {
|
|||||||
PipelineBindPoint::Graphics,
|
PipelineBindPoint::Graphics,
|
||||||
csg.deferred_pipeline.layout().clone(),
|
csg.deferred_pipeline.layout().clone(),
|
||||||
0,
|
0,
|
||||||
|
vec![
|
||||||
implicit_set.clone(),
|
implicit_set.clone(),
|
||||||
|
csg.deferred_descriptor_set[frame_index].clone(),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.bind_vertex_buffers(0, self.vertex_buffer.clone())
|
.bind_vertex_buffers(0, self.vertex_buffer.clone())
|
||||||
@@ -1103,7 +1122,7 @@ impl App {
|
|||||||
.push_constants(csg.deferred_pipeline.layout().clone(), 0, push_constants[i])
|
.push_constants(csg.deferred_pipeline.layout().clone(), 0, push_constants[i])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
unsafe { builder.draw(VERTEX_COUNT as u32, 8 * 8 * 8, 0, 0) }.unwrap();
|
unsafe { builder.draw(VERTEX_COUNT as u32, 32 * 32 * 32, 0, 0) }.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1113,6 +1132,7 @@ impl App {
|
|||||||
push_constants: &Vec<PushConstantData>,
|
push_constants: &Vec<PushConstantData>,
|
||||||
normals_set1: Arc<DescriptorSet>,
|
normals_set1: Arc<DescriptorSet>,
|
||||||
normals_set2: Arc<DescriptorSet>,
|
normals_set2: Arc<DescriptorSet>,
|
||||||
|
frame_index: usize,
|
||||||
) {
|
) {
|
||||||
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
||||||
let csg = csg.read().unwrap();
|
let csg = csg.read().unwrap();
|
||||||
@@ -1123,7 +1143,11 @@ impl App {
|
|||||||
PipelineBindPoint::Graphics,
|
PipelineBindPoint::Graphics,
|
||||||
csg.normals_pipeline.layout().clone(),
|
csg.normals_pipeline.layout().clone(),
|
||||||
0,
|
0,
|
||||||
vec![normals_set1.clone(), normals_set2.clone()],
|
vec![
|
||||||
|
normals_set1.clone(),
|
||||||
|
csg.normals_descriptor_set[frame_index].clone(),
|
||||||
|
normals_set2.clone(),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -1214,21 +1238,24 @@ impl App {
|
|||||||
self.pipeline_cache.clone(),
|
self.pipeline_cache.clone(),
|
||||||
rcx.shader_modules.clone(),
|
rcx.shader_modules.clone(),
|
||||||
self.previous_debug.clone(),
|
self.previous_debug.clone(),
|
||||||
|
self.block_enable_allocator.clone(),
|
||||||
|
self.descriptor_set_allocator.clone(),
|
||||||
|
rcx.swapchain.image_count(),
|
||||||
-1,
|
-1,
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut push_constants = vec![PushConstantData::default(); self.gstate.csg.len()];
|
let mut push_constants = vec![
|
||||||
|
PushConstantData {
|
||||||
|
world: Default::default(),
|
||||||
|
inv_world: Default::default(),
|
||||||
|
};
|
||||||
|
self.gstate.csg.len()
|
||||||
|
];
|
||||||
let mut push_constants_left = self.gstate.csg.len();
|
let mut push_constants_left = self.gstate.csg.len();
|
||||||
|
|
||||||
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
|
||||||
self.thread_work_creation
|
|
||||||
.send(WorkItem::GetPushConstants(csg.clone(), self.time, i))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.previous_debug != self.gstate.debug {
|
if self.previous_debug != self.gstate.debug {
|
||||||
rcx.recreate_pipelines = true;
|
rcx.recreate_pipelines = true;
|
||||||
self.previous_debug = self.gstate.debug;
|
self.previous_debug = self.gstate.debug;
|
||||||
@@ -1291,6 +1318,17 @@ impl App {
|
|||||||
|
|
||||||
let image_index = image_index as usize;
|
let image_index = image_index as usize;
|
||||||
|
|
||||||
|
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
||||||
|
self.thread_work_creation
|
||||||
|
.send(WorkItem::GetPushConstants(
|
||||||
|
csg.clone(),
|
||||||
|
self.time,
|
||||||
|
image_index,
|
||||||
|
i,
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(future) = &mut rcx.previous_frame_end[image_index] {
|
if let Some(future) = &mut rcx.previous_frame_end[image_index] {
|
||||||
future.wait(None).unwrap();
|
future.wait(None).unwrap();
|
||||||
future.cleanup_finished();
|
future.cleanup_finished();
|
||||||
@@ -1345,7 +1383,12 @@ impl App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.gstate.csg.len() > 0 {
|
if self.gstate.csg.len() > 0 {
|
||||||
self.add_commands_depth_pass(&mut builder, &push_constants, implicit_set.unwrap());
|
self.add_commands_depth_pass(
|
||||||
|
&mut builder,
|
||||||
|
&push_constants,
|
||||||
|
implicit_set.unwrap(),
|
||||||
|
image_index,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
self.add_commands_primary_subpass(&mut builder);
|
self.add_commands_primary_subpass(&mut builder);
|
||||||
if self.gstate.csg.len() > 0 {
|
if self.gstate.csg.len() > 0 {
|
||||||
@@ -1354,6 +1397,7 @@ impl App {
|
|||||||
&push_constants,
|
&push_constants,
|
||||||
normals_set1.unwrap(),
|
normals_set1.unwrap(),
|
||||||
normals_set2.unwrap(),
|
normals_set2.unwrap(),
|
||||||
|
image_index,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
self.add_commands_primary_subpass(&mut builder);
|
self.add_commands_primary_subpass(&mut builder);
|
||||||
|
|||||||
@@ -3,11 +3,12 @@
|
|||||||
#version 460
|
#version 460
|
||||||
#extension GL_GOOGLE_include_directive:require
|
#extension GL_GOOGLE_include_directive:require
|
||||||
#include "include.glsl"
|
#include "include.glsl"
|
||||||
|
#include "implicit_include.glsl"
|
||||||
|
|
||||||
layout(location = 0) in vec2 v_pos;
|
layout(location = 0) in vec2 v_pos;
|
||||||
|
|
||||||
layout(input_attachment_index = 0, set = 1, binding = 0) uniform usubpassInput u_material;
|
layout(input_attachment_index = 0, set = 2, binding = 0) uniform usubpassInput u_material;
|
||||||
layout(input_attachment_index = 1, set = 1, binding = 1) uniform subpassInput u_depth;
|
layout(input_attachment_index = 1, set = 2, binding = 1) uniform subpassInput u_depth;
|
||||||
|
|
||||||
layout(location = 0) out vec4 f_color;
|
layout(location = 0) out vec4 f_color;
|
||||||
layout(location = 1) out vec4 f_normal;
|
layout(location = 1) out vec4 f_normal;
|
||||||
@@ -41,7 +42,7 @@ vec3 getNormal(vec3 p) {
|
|||||||
|
|
||||||
//Implicit Surface Entrypoint
|
//Implicit Surface Entrypoint
|
||||||
void main() {
|
void main() {
|
||||||
if (subpassLoad(u_material).x != pc.material) {
|
if (subpassLoad(u_material).x != object_uniforms.material) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -5,13 +5,14 @@ use glam::{self, Vec3};
|
|||||||
use obj::{LoadConfig, ObjData, ObjError};
|
use obj::{LoadConfig, ObjData, ObjError};
|
||||||
use vulkano::{
|
use vulkano::{
|
||||||
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
|
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||||
|
descriptor_set::DescriptorSet,
|
||||||
memory::allocator::{
|
memory::allocator::{
|
||||||
AllocationCreateInfo, MemoryAllocatePreference, MemoryTypeFilter, StandardMemoryAllocator,
|
AllocationCreateInfo, MemoryAllocatePreference, MemoryTypeFilter, StandardMemoryAllocator,
|
||||||
},
|
},
|
||||||
pipeline::{GraphicsPipeline, graphics::vertex_input::Vertex},
|
pipeline::{GraphicsPipeline, graphics::vertex_input::Vertex},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::ssa::SSATape;
|
use crate::{implicit_vs::Object, ssa::SSATape};
|
||||||
|
|
||||||
pub(crate) const PLATONIC_SOLIDS: [(&str, &[u8]); 1] = [("Buny", include_bytes!("bunny.obj"))];
|
pub(crate) const PLATONIC_SOLIDS: [(&str, &[u8]); 1] = [("Buny", include_bytes!("bunny.obj"))];
|
||||||
|
|
||||||
@@ -43,6 +44,9 @@ pub(crate) struct CSG {
|
|||||||
pub(crate) scale: Vec3,
|
pub(crate) scale: Vec3,
|
||||||
pub(crate) deferred_pipeline: Arc<GraphicsPipeline>,
|
pub(crate) deferred_pipeline: Arc<GraphicsPipeline>,
|
||||||
pub(crate) normals_pipeline: Arc<GraphicsPipeline>,
|
pub(crate) normals_pipeline: Arc<GraphicsPipeline>,
|
||||||
|
pub(crate) enable_buffer: Vec<Subbuffer<Object>>,
|
||||||
|
pub(crate) deferred_descriptor_set: Vec<Arc<DescriptorSet>>,
|
||||||
|
pub(crate) normals_descriptor_set: Vec<Arc<DescriptorSet>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn load_obj(
|
pub(crate) fn load_obj(
|
||||||
|
|||||||
+115
-45
@@ -2,7 +2,7 @@ use std::{
|
|||||||
fs::File,
|
fs::File,
|
||||||
io::Write,
|
io::Write,
|
||||||
simd::{StdFloat, cmp::SimdPartialOrd},
|
simd::{StdFloat, cmp::SimdPartialOrd},
|
||||||
sync::{Arc, RwLock, mpmc, mpsc},
|
sync::{Arc, Mutex, RwLock, mpmc, mpsc},
|
||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -11,9 +11,13 @@ use glam::{EulerRot, Mat4, Vec3};
|
|||||||
use log::info;
|
use log::info;
|
||||||
use rspirv::{binary::Assemble, dr::Module};
|
use rspirv::{binary::Assemble, dr::Module};
|
||||||
use vulkano::{
|
use vulkano::{
|
||||||
|
buffer::{Subbuffer, allocator::SubbufferAllocator},
|
||||||
|
descriptor_set::{
|
||||||
|
DescriptorSet, WriteDescriptorSet, allocator::StandardDescriptorSetAllocator,
|
||||||
|
},
|
||||||
device::Device,
|
device::Device,
|
||||||
pipeline::{
|
pipeline::{
|
||||||
DynamicState, GraphicsPipeline, PipelineCreateFlags, PipelineLayout,
|
DynamicState, GraphicsPipeline, Pipeline, PipelineCreateFlags, PipelineLayout,
|
||||||
PipelineShaderStageCreateInfo,
|
PipelineShaderStageCreateInfo,
|
||||||
cache::PipelineCache,
|
cache::PipelineCache,
|
||||||
graphics::{
|
graphics::{
|
||||||
@@ -34,7 +38,7 @@ use vulkano::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
DUMP_SPV_TO_FILE, IVertex, ShaderModules, get_spec_constants,
|
DUMP_SPV_TO_FILE, IVertex, ShaderModules, get_spec_constants,
|
||||||
gui::PreviousDebug,
|
gui::PreviousDebug,
|
||||||
implicit_vs::PushConstantData,
|
implicit_vs::{Object, PushConstantData},
|
||||||
interpreter::{self, IntervalInterpreter, PointInterpreter, VALUE_0},
|
interpreter::{self, IntervalInterpreter, PointInterpreter, VALUE_0},
|
||||||
objects::CSG,
|
objects::CSG,
|
||||||
ssa::{SSAInput, SSAOpcode, SSAOpcodeSized, SSATape},
|
ssa::{SSAInput, SSAOpcode, SSAOpcodeSized, SSATape},
|
||||||
@@ -51,9 +55,12 @@ pub enum WorkItem {
|
|||||||
Arc<PipelineCache>,
|
Arc<PipelineCache>,
|
||||||
ShaderModules,
|
ShaderModules,
|
||||||
PreviousDebug,
|
PreviousDebug,
|
||||||
|
Arc<Mutex<SubbufferAllocator>>,
|
||||||
|
Arc<StandardDescriptorSetAllocator>,
|
||||||
|
u32,
|
||||||
isize,
|
isize,
|
||||||
),
|
),
|
||||||
GetPushConstants(Arc<RwLock<CSG>>, f32, usize),
|
GetPushConstants(Arc<RwLock<CSG>>, f32, usize, usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -73,6 +80,9 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
|||||||
cache,
|
cache,
|
||||||
modules,
|
modules,
|
||||||
debug,
|
debug,
|
||||||
|
block_enable_allocator,
|
||||||
|
descriptor_set_allocator,
|
||||||
|
frames,
|
||||||
index,
|
index,
|
||||||
) => {
|
) => {
|
||||||
let csg_start = Instant::now();
|
let csg_start = Instant::now();
|
||||||
@@ -97,6 +107,51 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
|||||||
debug,
|
debug,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let enable_buffer: Vec<Subbuffer<Object>> = (0..frames)
|
||||||
|
.into_iter()
|
||||||
|
.map(|_| {
|
||||||
|
block_enable_allocator
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.allocate_sized()
|
||||||
|
.unwrap()
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let deferred_layout = deferred_pipeline.layout().set_layouts()[1].clone();
|
||||||
|
let deferred_descriptor_set = (0..frames)
|
||||||
|
.into_iter()
|
||||||
|
.map(|f| {
|
||||||
|
DescriptorSet::new(
|
||||||
|
descriptor_set_allocator.clone(),
|
||||||
|
deferred_layout.clone(),
|
||||||
|
[WriteDescriptorSet::buffer(
|
||||||
|
0,
|
||||||
|
enable_buffer[f as usize].clone(),
|
||||||
|
)],
|
||||||
|
[],
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let normals_layout = normals_pipeline.layout().set_layouts()[1].clone();
|
||||||
|
let normals_descriptor_set = (0..frames)
|
||||||
|
.into_iter()
|
||||||
|
.map(|f| {
|
||||||
|
DescriptorSet::new(
|
||||||
|
descriptor_set_allocator.clone(),
|
||||||
|
normals_layout.clone(),
|
||||||
|
[WriteDescriptorSet::buffer(
|
||||||
|
0,
|
||||||
|
enable_buffer[f as usize].clone(),
|
||||||
|
)],
|
||||||
|
[],
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
let csg = Arc::new(RwLock::new(CSG {
|
let csg = Arc::new(RwLock::new(CSG {
|
||||||
name: "example".to_string(),
|
name: "example".to_string(),
|
||||||
parts,
|
parts,
|
||||||
@@ -105,6 +160,9 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
|||||||
scale: Vec3::ONE,
|
scale: Vec3::ONE,
|
||||||
deferred_pipeline,
|
deferred_pipeline,
|
||||||
normals_pipeline,
|
normals_pipeline,
|
||||||
|
enable_buffer,
|
||||||
|
deferred_descriptor_set,
|
||||||
|
normals_descriptor_set,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
send.send(WorkComplete::CreateCSG(csg, index)).unwrap();
|
send.send(WorkComplete::CreateCSG(csg, index)).unwrap();
|
||||||
@@ -115,14 +173,10 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
|||||||
(csg_end - csg_start).as_secs_f64() * 1000.0
|
(csg_end - csg_start).as_secs_f64() * 1000.0
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
WorkItem::GetPushConstants(csg, time, index) => {
|
WorkItem::GetPushConstants(csg, time, frame_index, index) => {
|
||||||
let mut push_constants = PushConstantData {
|
let mut push_constants = PushConstantData {
|
||||||
world: Mat4::IDENTITY.to_cols_array_2d(),
|
world: Mat4::IDENTITY.to_cols_array_2d(),
|
||||||
inv_world: Mat4::IDENTITY.to_cols_array_2d(),
|
inv_world: Mat4::IDENTITY.to_cols_array_2d(),
|
||||||
dimensions: Vec3::ONE.to_array().into(),
|
|
||||||
lowest_corner: Vec3::ZERO.into(),
|
|
||||||
enable: [0; 16],
|
|
||||||
material: 0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let csg = csg.read().unwrap();
|
let csg = csg.read().unwrap();
|
||||||
@@ -139,9 +193,7 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
|||||||
push_constants.world = world.to_cols_array_2d();
|
push_constants.world = world.to_cols_array_2d();
|
||||||
push_constants.inv_world = world.inverse().to_cols_array_2d();
|
push_constants.inv_world = world.inverse().to_cols_array_2d();
|
||||||
|
|
||||||
interval_check(&csg, &mut push_constants, time);
|
interval_check(&csg, index as u32 + 1, time, frame_index);
|
||||||
|
|
||||||
push_constants.material = index as u32 + 1;
|
|
||||||
|
|
||||||
send.send(WorkComplete::GetPushConstants(push_constants, index))
|
send.send(WorkComplete::GetPushConstants(push_constants, index))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -357,7 +409,7 @@ fn create_csg() -> SSATape {
|
|||||||
tape
|
tape
|
||||||
}
|
}
|
||||||
|
|
||||||
fn interval_check(csg: &CSG, push_constants: &mut PushConstantData, time: f32) {
|
fn interval_check(csg: &CSG, material: u32, time: f32, frame_index: usize) {
|
||||||
const INTERPRET_INPUT_X: interpreter::Value =
|
const INTERPRET_INPUT_X: interpreter::Value =
|
||||||
interpreter::Value::from_array([10000.0, 0.0, 0.0, -10000.0, 0.0, 0.0, 0.0, 0.0]);
|
interpreter::Value::from_array([10000.0, 0.0, 0.0, -10000.0, 0.0, 0.0, 0.0, 0.0]);
|
||||||
const INTERPRET_INPUT_Y: interpreter::Value =
|
const INTERPRET_INPUT_Y: interpreter::Value =
|
||||||
@@ -384,49 +436,64 @@ fn interval_check(csg: &CSG, push_constants: &mut PushConstantData, time: f32) {
|
|||||||
let highest_corner = Vec3::new(interpreter_out[0], interpreter_out[1], interpreter_out[2]);
|
let highest_corner = Vec3::new(interpreter_out[0], interpreter_out[1], interpreter_out[2]);
|
||||||
let lowest_corner = Vec3::new(interpreter_out[3], interpreter_out[4], interpreter_out[5]);
|
let lowest_corner = Vec3::new(interpreter_out[3], interpreter_out[4], interpreter_out[5]);
|
||||||
|
|
||||||
push_constants.dimensions = (highest_corner - lowest_corner).to_array().into();
|
let mut obj = Object {
|
||||||
push_constants.lowest_corner = lowest_corner.into();
|
dimensions: (highest_corner - lowest_corner).to_array().into(),
|
||||||
|
lowest_corner: lowest_corner.into(),
|
||||||
|
enable: [[0; 4]; 32 * 8],
|
||||||
|
material,
|
||||||
|
};
|
||||||
|
|
||||||
push_constants.enable = [0; 16];
|
for x in 0..32 {
|
||||||
|
for y in 0..32 {
|
||||||
for x in 0..8 {
|
for z in 0..4 {
|
||||||
for y in 0..8 {
|
|
||||||
let interval_input_z: Interval = Interval::new_unchecked(
|
let interval_input_z: Interval = Interval::new_unchecked(
|
||||||
interpreter::Value::from_array([
|
interpreter::Value::from_array([
|
||||||
(0.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
((((8.0 / 32.0) * z as f32) + (0.0 / 32.0)) * obj.dimensions[2])
|
||||||
(1.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
+ obj.lowest_corner[2],
|
||||||
(2.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
((((8.0 / 32.0) * z as f32) + (1.0 / 32.0)) * obj.dimensions[2])
|
||||||
(3.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
+ obj.lowest_corner[2],
|
||||||
(4.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
((((8.0 / 32.0) * z as f32) + (2.0 / 32.0)) * obj.dimensions[2])
|
||||||
(5.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
+ obj.lowest_corner[2],
|
||||||
(6.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
((((8.0 / 32.0) * z as f32) + (3.0 / 32.0)) * obj.dimensions[2])
|
||||||
(7.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
+ obj.lowest_corner[2],
|
||||||
|
((((8.0 / 32.0) * z as f32) + (4.0 / 32.0)) * obj.dimensions[2])
|
||||||
|
+ obj.lowest_corner[2],
|
||||||
|
((((8.0 / 32.0) * z as f32) + (5.0 / 32.0)) * obj.dimensions[2])
|
||||||
|
+ obj.lowest_corner[2],
|
||||||
|
((((8.0 / 32.0) * z as f32) + (6.0 / 32.0)) * obj.dimensions[2])
|
||||||
|
+ obj.lowest_corner[2],
|
||||||
|
((((8.0 / 32.0) * z as f32) + (7.0 / 32.0)) * obj.dimensions[2])
|
||||||
|
+ obj.lowest_corner[2],
|
||||||
]),
|
]),
|
||||||
interpreter::Value::from_array([
|
interpreter::Value::from_array([
|
||||||
(1.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
((((8.0 / 32.0) * z as f32) + (1.0 / 32.0)) * obj.dimensions[2])
|
||||||
(2.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
+ obj.lowest_corner[2],
|
||||||
(3.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
((((8.0 / 32.0) * z as f32) + (2.0 / 32.0)) * obj.dimensions[2])
|
||||||
(4.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
+ obj.lowest_corner[2],
|
||||||
(5.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
((((8.0 / 32.0) * z as f32) + (3.0 / 32.0)) * obj.dimensions[2])
|
||||||
(6.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
+ obj.lowest_corner[2],
|
||||||
(7.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
((((8.0 / 32.0) * z as f32) + (4.0 / 32.0)) * obj.dimensions[2])
|
||||||
(8.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
+ obj.lowest_corner[2],
|
||||||
|
((((8.0 / 32.0) * z as f32) + (5.0 / 32.0)) * obj.dimensions[2])
|
||||||
|
+ obj.lowest_corner[2],
|
||||||
|
((((8.0 / 32.0) * z as f32) + (6.0 / 32.0)) * obj.dimensions[2])
|
||||||
|
+ obj.lowest_corner[2],
|
||||||
|
((((8.0 / 32.0) * z as f32) + (7.0 / 32.0)) * obj.dimensions[2])
|
||||||
|
+ obj.lowest_corner[2],
|
||||||
|
((((8.0 / 32.0) * z as f32) + (8.0 / 32.0)) * obj.dimensions[2])
|
||||||
|
+ obj.lowest_corner[2],
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut interpreter = IntervalInterpreter::new(csg);
|
let mut interpreter = IntervalInterpreter::new(csg);
|
||||||
let output = interpreter.scene(
|
let output = interpreter.scene(
|
||||||
Interval::const_splat2(
|
Interval::const_splat2(
|
||||||
(x as f32 / 8.0) * push_constants.dimensions[0]
|
(x as f32 / 32.0) * obj.dimensions[0] + obj.lowest_corner[0],
|
||||||
+ push_constants.lowest_corner[0],
|
((x + 1) as f32 / 32.0) * obj.dimensions[0] + obj.lowest_corner[0],
|
||||||
((x + 1) as f32 / 8.0) * push_constants.dimensions[0]
|
|
||||||
+ push_constants.lowest_corner[0],
|
|
||||||
),
|
),
|
||||||
Interval::const_splat2(
|
Interval::const_splat2(
|
||||||
(y as f32 / 8.0) * push_constants.dimensions[1]
|
(y as f32 / 32.0) * obj.dimensions[1] + obj.lowest_corner[1],
|
||||||
+ push_constants.lowest_corner[1],
|
((y + 1) as f32 / 32.0) * obj.dimensions[1] + obj.lowest_corner[1],
|
||||||
((y + 1) as f32 / 8.0) * push_constants.dimensions[1]
|
|
||||||
+ push_constants.lowest_corner[1],
|
|
||||||
),
|
),
|
||||||
interval_input_z,
|
interval_input_z,
|
||||||
Interval::const_splat(time),
|
Interval::const_splat(time),
|
||||||
@@ -434,12 +501,15 @@ fn interval_check(csg: &CSG, push_constants: &mut PushConstantData, time: f32) {
|
|||||||
|
|
||||||
let output = ((output.lower().simd_le(VALUE_0) & output.upper().simd_ge(VALUE_0))
|
let output = ((output.lower().simd_le(VALUE_0) & output.upper().simd_ge(VALUE_0))
|
||||||
.to_bitmask() as u32)
|
.to_bitmask() as u32)
|
||||||
<< ((y & 0b11) * 8);
|
<< (z * 8);
|
||||||
push_constants.enable[(x << 1) | (y >> 2)] |= output;
|
obj.enable[(x << 3) | (y >> 2)][y & 0b11] |= output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*csg.enable_buffer[frame_index].write().unwrap() = obj;
|
||||||
|
}
|
||||||
|
|
||||||
fn sdf_specialize_module(
|
fn sdf_specialize_module(
|
||||||
device: Arc<Device>,
|
device: Arc<Device>,
|
||||||
parts: &SSATape,
|
parts: &SSATape,
|
||||||
|
|||||||
+3
-2
@@ -3,6 +3,7 @@
|
|||||||
#version 460
|
#version 460
|
||||||
#extension GL_GOOGLE_include_directive:require
|
#extension GL_GOOGLE_include_directive:require
|
||||||
#include "include.glsl"
|
#include "include.glsl"
|
||||||
|
#include "implicit_include.glsl"
|
||||||
|
|
||||||
layout(location = 0) in vec4 pos;
|
layout(location = 0) in vec4 pos;
|
||||||
|
|
||||||
@@ -17,7 +18,7 @@ float scene(vec4 p) {
|
|||||||
const float EPSILON = .0001;
|
const float EPSILON = .0001;
|
||||||
const uint MAX_STEPS = 50;
|
const uint MAX_STEPS = 50;
|
||||||
const float NEARPLANE = 0.;
|
const float NEARPLANE = 0.;
|
||||||
float FARPLANE = length(pc.dimensions / 8.);
|
float FARPLANE = length(object_uniforms.dimensions / 8.);
|
||||||
|
|
||||||
vec2 spheretracing(vec3 ori, vec3 dir, out vec3 p) {
|
vec2 spheretracing(vec3 ori, vec3 dir, out vec3 p) {
|
||||||
vec2 td = vec2(NEARPLANE, 1.);
|
vec2 td = vec2(NEARPLANE, 1.);
|
||||||
@@ -46,7 +47,7 @@ void main() {
|
|||||||
{
|
{
|
||||||
vec4 tpoint = camera_uniforms.proj_view * pc.world * vec4(p, 1);
|
vec4 tpoint = camera_uniforms.proj_view * pc.world * vec4(p, 1);
|
||||||
gl_FragDepth = (tpoint.z / tpoint.w);
|
gl_FragDepth = (tpoint.z / tpoint.w);
|
||||||
material = pc.material;
|
material = object_uniforms.material;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user