Split sphere data API/ABI
This commit is contained in:
parent
186882a7f4
commit
cda5a33dd3
|
|
@ -59,9 +59,7 @@ impl SphereParams {
|
|||
center,
|
||||
radius,
|
||||
emit_color,
|
||||
pad1: 0.0,
|
||||
reflect_color,
|
||||
pad2: 0.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
28
src/trace.rs
28
src/trace.rs
|
|
@ -12,15 +12,13 @@ pub struct Params {
|
|||
pub sphere_count: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Pod, Zeroable)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct Sphere {
|
||||
pub center: Vec3,
|
||||
pub radius: f32,
|
||||
pub emit_color: Vec3,
|
||||
pub pad1: f32,
|
||||
pub reflect_color: Vec3,
|
||||
pub pad2: f32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Pod, Zeroable)]
|
||||
|
|
@ -31,6 +29,17 @@ pub struct Vertex {
|
|||
pub screen: Vec2,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Pod, Zeroable)]
|
||||
#[repr(C)]
|
||||
struct SphereData {
|
||||
center: Vec3,
|
||||
radius: f32,
|
||||
emit_color: Vec3,
|
||||
pad1: f32,
|
||||
reflect_color: Vec3,
|
||||
pad2: f32,
|
||||
}
|
||||
|
||||
pub struct Tracer {
|
||||
view_buf: wgpu::Buffer,
|
||||
params_buf: wgpu::Buffer,
|
||||
|
|
@ -138,9 +147,20 @@ impl Tracer {
|
|||
|
||||
impl TracerData {
|
||||
pub fn new(device: &wgpu::Device, tracer: &Tracer, spheres: &[Sphere]) -> Self {
|
||||
let spheres: Vec<_> = spheres
|
||||
.iter()
|
||||
.map(|s| SphereData {
|
||||
center: s.center,
|
||||
radius: s.radius,
|
||||
emit_color: s.emit_color,
|
||||
pad1: 0.0,
|
||||
reflect_color: s.reflect_color,
|
||||
pad2: 0.0,
|
||||
})
|
||||
.collect();
|
||||
let spheres_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: None,
|
||||
contents: cast_slice(spheres),
|
||||
contents: cast_slice(&spheres),
|
||||
usage: wgpu::BufferUsages::STORAGE,
|
||||
});
|
||||
let bindings = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user