editor with imgui and sdl->28

This commit is contained in:
Jonas H
2026-03-04 09:04:37 +01:00
parent d037fc4acd
commit 5f8d924a02
13 changed files with 351 additions and 101 deletions

View File

@@ -61,13 +61,13 @@ impl DebugOverlay
let shadow_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Shadow Debug Pipeline Layout"),
bind_group_layouts: &[&shadow_bind_group_layout],
push_constant_ranges: &[],
immediate_size: 0,
});
let snow_light_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Snow Light Debug Pipeline Layout"),
bind_group_layouts: &[&snow_light_bind_group_layout],
push_constant_ranges: &[],
immediate_size: 0,
});
let color_target = wgpu::ColorTargetState {
@@ -98,7 +98,7 @@ impl DebugOverlay
},
depth_stencil: None,
multisample: wgpu::MultisampleState::default(),
multiview: None,
multiview_mask: None,
cache: None,
});
@@ -125,7 +125,7 @@ impl DebugOverlay
},
depth_stencil: None,
multisample: wgpu::MultisampleState::default(),
multiview: None,
multiview_mask: None,
cache: None,
});
@@ -171,6 +171,7 @@ impl DebugOverlay
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
multiview_mask: None,
});
pass.set_pipeline(&self.pipeline_shadow);
@@ -221,6 +222,7 @@ impl DebugOverlay
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
multiview_mask: None,
});
pass.set_pipeline(&self.pipeline_snow_light);

View File

@@ -248,7 +248,7 @@ impl Renderer
address_mode_w: wgpu::AddressMode::ClampToEdge,
mag_filter: wgpu::FilterMode::Linear,
min_filter: wgpu::FilterMode::Linear,
mipmap_filter: wgpu::FilterMode::Nearest,
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
compare: Some(wgpu::CompareFunction::LessEqual),
..Default::default()
});
@@ -546,7 +546,7 @@ impl Renderer
time: f32,
delta_time: f32,
debug_mode: DebugMode,
)
) -> wgpu::SurfaceTexture
{
let light_view_projections = self.calculate_light_view_projections();
@@ -647,6 +647,7 @@ impl Renderer
}),
timestamp_writes: None,
occlusion_query_set: None,
multiview_mask: None,
});
let pipeline = match draw_call.pipeline
@@ -737,6 +738,7 @@ impl Renderer
),
timestamp_writes: None,
occlusion_query_set: None,
multiview_mask: None,
});
wire_pass.set_pipeline(wireframe_pipeline);
@@ -850,6 +852,7 @@ impl Renderer
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
multiview_mask: None,
});
blit_pass.set_pipeline(&self.blit_pipeline);
@@ -860,7 +863,7 @@ impl Renderer
}
self.queue.submit(std::iter::once(blit_encoder.finish()));
frame.present();
frame
}
pub fn render_scale(&self) -> (u32, u32)
@@ -1025,7 +1028,7 @@ pub fn render(
time: f32,
delta_time: f32,
debug_mode: DebugMode,
)
) -> wgpu::SurfaceTexture
{
GLOBAL_RENDERER.with(|r| {
let mut renderer = r.borrow_mut();
@@ -1039,8 +1042,19 @@ pub fn render(
time,
delta_time,
debug_mode,
);
});
)
})
}
pub fn with_surface_format<F, R>(f: F) -> R
where
F: FnOnce(wgpu::TextureFormat) -> R,
{
GLOBAL_RENDERER.with(|r| {
let renderer = r.borrow();
let renderer = renderer.as_ref().expect("Renderer not set");
f(renderer.config.format)
})
}
pub fn set_shadow_bias(bias: f32)

View File

@@ -20,7 +20,7 @@ pub fn create_shadow_pipeline(
let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Shadow Pipeline Layout"),
bind_group_layouts: &[bind_group_layout],
push_constant_ranges: &[],
immediate_size: 0,
});
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
@@ -57,7 +57,7 @@ pub fn create_shadow_pipeline(
mask: !0,
alpha_to_coverage_enabled: false,
},
multiview: None,
multiview_mask: None,
cache: None,
})
}
@@ -85,7 +85,7 @@ pub fn create_main_pipeline(
let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Main Pipeline Layout"),
bind_group_layouts: &[bind_group_layout],
push_constant_ranges: &[],
immediate_size: 0,
});
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
@@ -131,7 +131,7 @@ pub fn create_main_pipeline(
mask: !0,
alpha_to_coverage_enabled: false,
},
multiview: None,
multiview_mask: None,
cache: None,
})
}
@@ -157,7 +157,7 @@ pub fn create_wireframe_pipeline(
let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Wireframe Pipeline Layout"),
bind_group_layouts: &[bind_group_layout],
push_constant_ranges: &[],
immediate_size: 0,
});
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
@@ -203,7 +203,7 @@ pub fn create_wireframe_pipeline(
mask: !0,
alpha_to_coverage_enabled: false,
},
multiview: None,
multiview_mask: None,
cache: None,
})
}
@@ -229,7 +229,7 @@ pub fn create_debug_lines_pipeline(
let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Debug Lines Pipeline Layout"),
bind_group_layouts: &[bind_group_layout],
push_constant_ranges: &[],
immediate_size: 0,
});
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
@@ -275,7 +275,7 @@ pub fn create_debug_lines_pipeline(
mask: !0,
alpha_to_coverage_enabled: false,
},
multiview: None,
multiview_mask: None,
cache: None,
})
}
@@ -340,7 +340,7 @@ pub fn create_snow_clipmap_pipeline(
let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Snow Clipmap Pipeline Layout"),
bind_group_layouts: &[main_bind_group_layout, &displacement_bind_group_layout],
push_constant_ranges: &[],
immediate_size: 0,
});
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
@@ -390,7 +390,7 @@ pub fn create_snow_clipmap_pipeline(
mask: !0,
alpha_to_coverage_enabled: false,
},
multiview: None,
multiview_mask: None,
cache: None,
})
}

View File

@@ -68,6 +68,7 @@ impl Renderer
}),
timestamp_writes: None,
occlusion_query_set: None,
multiview_mask: None,
});
shadow_pass.set_pipeline(