interval bounding box
This commit is contained in:
+12
-1
@@ -6,7 +6,18 @@ layout(location = 0) in vec3 position;
|
|||||||
layout(location = 0) out vec4 pos;
|
layout(location = 0) out vec4 pos;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
pos = vec4((position * pc.dimensions) + pc.lowest_corner, 1.);
|
vec3 internal_pos = vec3(float((gl_InstanceIndex >> 6) & 7) / 8.0,
|
||||||
|
float((gl_InstanceIndex >> 3) & 7) / 8.0,
|
||||||
|
float((gl_InstanceIndex >> 0) & 7) / 8.0);
|
||||||
|
|
||||||
|
bool enable = (pc.enable[gl_InstanceIndex >> 5] & (1 << (gl_InstanceIndex & 31))) != 0;
|
||||||
|
|
||||||
|
if (!enable) {
|
||||||
|
gl_Position = vec4(0.0 / 0.0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos = vec4((((position / 8.0) + internal_pos) * pc.dimensions) + pc.lowest_corner, 1.);
|
||||||
vec4 worldview = camera_uniforms.view * pc.world * pos;
|
vec4 worldview = camera_uniforms.view * pc.world * pos;
|
||||||
gl_Position = camera_uniforms.proj * worldview;
|
gl_Position = camera_uniforms.proj * worldview;
|
||||||
}
|
}
|
||||||
|
|||||||
+44
-24
@@ -65,7 +65,7 @@ use vulkano::{
|
|||||||
depth_stencil::{DepthState, DepthStencilState},
|
depth_stencil::{DepthState, DepthStencilState},
|
||||||
input_assembly::InputAssemblyState,
|
input_assembly::InputAssemblyState,
|
||||||
multisample::MultisampleState,
|
multisample::MultisampleState,
|
||||||
rasterization::{CullMode, FrontFace, RasterizationState},
|
rasterization::{CullMode, FrontFace, PolygonMode, RasterizationState},
|
||||||
vertex_input::{Vertex, VertexDefinition},
|
vertex_input::{Vertex, VertexDefinition},
|
||||||
viewport::{Viewport, ViewportState},
|
viewport::{Viewport, ViewportState},
|
||||||
},
|
},
|
||||||
@@ -97,7 +97,7 @@ mod ssa;
|
|||||||
mod instruction_set;
|
mod instruction_set;
|
||||||
|
|
||||||
mod interpreter;
|
mod interpreter;
|
||||||
use crate::interpreter::{IntervalInterpreter, PointInterpreter};
|
use crate::interpreter::{IntervalInterpreter, PointInterpreter, VALUE_0};
|
||||||
|
|
||||||
mod types;
|
mod types;
|
||||||
mod vm;
|
mod vm;
|
||||||
@@ -319,39 +319,54 @@ fn interval_check(csg: &CSG, push_constants: &mut PushConstantData) {
|
|||||||
push_constants.dimensions = (highest_corner - lowest_corner).to_array().into();
|
push_constants.dimensions = (highest_corner - lowest_corner).to_array().into();
|
||||||
push_constants.lowest_corner = lowest_corner.into();
|
push_constants.lowest_corner = lowest_corner.into();
|
||||||
|
|
||||||
|
push_constants.enable = [0; 16];
|
||||||
|
|
||||||
for x in 0..8 {
|
for x in 0..8 {
|
||||||
for y in 0..8 {
|
for y in 0..8 {
|
||||||
const INTERVAL_INPUT_Z: interpreter::Value = Interval::new(
|
let interval_input_z: Interval = Interval::new_unchecked(
|
||||||
interpreter::Value::from_array([
|
interpreter::Value::from_array([
|
||||||
0.0 / 8.0,
|
(0.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
1.0 / 8.0,
|
(1.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
2.0 / 8.0,
|
(2.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
3.0 / 8.0,
|
(3.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
4.0 / 8.0,
|
(4.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
5.0 / 8.0,
|
(5.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
6.0 / 8.0,
|
(6.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
7.0 / 8.0,
|
(7.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
]),
|
]),
|
||||||
interpreter::Value::from_array([
|
interpreter::Value::from_array([
|
||||||
1.0 / 8.0,
|
(1.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
2.0 / 8.0,
|
(2.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
3.0 / 8.0,
|
(3.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
4.0 / 8.0,
|
(4.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
5.0 / 8.0,
|
(5.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
6.0 / 8.0,
|
(6.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
7.0 / 8.0,
|
(7.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||||
8.0 / 8.0,
|
(8.0 / 8.0) * push_constants.dimensions[2] + push_constants.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(x as f32 / 8.0, (x + 1) as f32 / 8.0),
|
Interval::const_splat2(
|
||||||
Interval::const_splat2(y as f32 / 8.0, (y + 1) as f32 / 8.0),
|
(x as f32 / 8.0) * push_constants.dimensions[0]
|
||||||
INTERPRET_INPUT_Z,
|
+ push_constants.lowest_corner[0],
|
||||||
|
((x + 1) as f32 / 8.0) * push_constants.dimensions[0]
|
||||||
|
+ push_constants.lowest_corner[0],
|
||||||
|
),
|
||||||
|
Interval::const_splat2(
|
||||||
|
(y as f32 / 8.0) * push_constants.dimensions[1]
|
||||||
|
+ push_constants.lowest_corner[1],
|
||||||
|
((y + 1) as f32 / 8.0) * push_constants.dimensions[1]
|
||||||
|
+ push_constants.lowest_corner[1],
|
||||||
|
),
|
||||||
|
interval_input_z,
|
||||||
);
|
);
|
||||||
|
|
||||||
(output.lower().simd_le(VALUE_0) & output.lower().simd_ge(VALUE_0)).to_bitmask()
|
let output = ((output.lower().simd_le(VALUE_0) & output.upper().simd_ge(VALUE_0))
|
||||||
|
.to_bitmask() as u32)
|
||||||
|
<< ((y & 0b11) * 8);
|
||||||
|
push_constants.enable[(x << 1) | (y >> 2)] |= output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -462,6 +477,7 @@ impl App {
|
|||||||
geometry_shader: true,
|
geometry_shader: true,
|
||||||
primitive_fragment_shading_rate: SAMPLE_RATE_SHADING.is_some(),
|
primitive_fragment_shading_rate: SAMPLE_RATE_SHADING.is_some(),
|
||||||
maintenance4: true,
|
maintenance4: true,
|
||||||
|
fill_mode_non_solid: true,
|
||||||
..DeviceFeatures::empty()
|
..DeviceFeatures::empty()
|
||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@@ -1093,6 +1109,7 @@ impl App {
|
|||||||
world: Mat4::IDENTITY.to_cols_array_2d(),
|
world: Mat4::IDENTITY.to_cols_array_2d(),
|
||||||
dimensions: Vec3::ONE.to_array().into(),
|
dimensions: Vec3::ONE.to_array().into(),
|
||||||
lowest_corner: Vec3::ZERO.into(),
|
lowest_corner: Vec3::ZERO.into(),
|
||||||
|
enable: [0; 16],
|
||||||
};
|
};
|
||||||
|
|
||||||
let uniform_data = implicit_vs::Camera {
|
let uniform_data = implicit_vs::Camera {
|
||||||
@@ -1236,7 +1253,9 @@ impl App {
|
|||||||
.push_constants(rcx.implicit_pipeline.layout().clone(), 0, push_constants)
|
.push_constants(rcx.implicit_pipeline.layout().clone(), 0, push_constants)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
unsafe { builder.draw(VERTEX_COUNT as u32, 1, 0, 0) }.unwrap();
|
for i in 0..(8 * 8 * 8) {
|
||||||
|
unsafe { builder.draw(VERTEX_COUNT as u32, 1, 0, i) }.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder
|
builder
|
||||||
@@ -1477,6 +1496,7 @@ fn pipeline_recompile(
|
|||||||
rasterization_state: Some(RasterizationState {
|
rasterization_state: Some(RasterizationState {
|
||||||
front_face: FrontFace::Clockwise,
|
front_face: FrontFace::Clockwise,
|
||||||
cull_mode: CullMode::Back,
|
cull_mode: CullMode::Back,
|
||||||
|
polygon_mode: PolygonMode::Fill,
|
||||||
..RasterizationState::default()
|
..RasterizationState::default()
|
||||||
}),
|
}),
|
||||||
depth_stencil_state: Some(DepthStencilState {
|
depth_stencil_state: Some(DepthStencilState {
|
||||||
|
|||||||
@@ -59,6 +59,11 @@ impl Interval {
|
|||||||
Self { lower, upper }
|
Self { lower, upper }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub const fn new_unchecked(lower: Value, upper: Value) -> Self {
|
||||||
|
Self { lower, upper }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn splat(value: f32) -> Interval {
|
pub fn splat(value: f32) -> Interval {
|
||||||
Interval::new(Value::splat(value), Value::splat(value))
|
Interval::new(Value::splat(value), Value::splat(value))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user