Skip to content

Commit 1742d72

Browse files
optimize shaders by removing runtime checks
1 parent aa64d27 commit 1742d72

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

src/app.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,12 @@ impl ParticleApp {
129129
}
130130
};
131131

132-
// Create renderer
133-
let particle_shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
134-
label: Some("Particle Shader"),
135-
source: wgpu::ShaderSource::Wgsl(include_str!("shaders/particle.wgsl").into()),
136-
});
132+
let particle_shader = unsafe {
133+
device.create_shader_module_trusted(
134+
wgpu::include_wgsl!("shaders/particle.wgsl"),
135+
wgpu::ShaderRuntimeChecks::unchecked(),
136+
)
137+
};
137138

138139
let surface_format = wgpu_render_state.target_format;
139140
let renderer = ParticleRenderer::new(device, &camera, &surface_format, &particle_shader);

src/simulation/compute.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ impl ParticleSimulation for ComputeParticleSimulation {
4040
});
4141

4242
// Create compute shader
43-
let compute_shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
44-
label: Some("Compute Shader"),
45-
source: wgpu::ShaderSource::Wgsl(include_str!("../shaders/compute.wgsl").into()),
46-
});
43+
let compute_shader = unsafe {
44+
device.create_shader_module_trusted(
45+
wgpu::include_wgsl!("../shaders/compute.wgsl"),
46+
wgpu::ShaderRuntimeChecks::unchecked(),
47+
)
48+
};
4749

4850
// Create bind group layout
4951
let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {

src/simulation/transform_feedback.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ impl ParticleSimulation for TransformFeedbackSimulation {
7676
let dummy_texture_view = dummy_texture.create_view(&wgpu::TextureViewDescriptor::default());
7777

7878
// --- Shader and Pipeline Setup ---
79-
let shader_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
80-
label: Some("TF Simulation Shader"),
81-
source: wgpu::ShaderSource::Wgsl(
82-
include_str!("../shaders/transform_feedback.wgsl").into(),
83-
),
84-
});
79+
let shader_module = unsafe {
80+
device.create_shader_module_trusted(
81+
wgpu::include_wgsl!("../shaders/transform_feedback.wgsl"),
82+
wgpu::ShaderRuntimeChecks::unchecked(),
83+
)
84+
};
8585

8686
// Bind group layout for uniforms
8787
let uniform_bind_group_layout =

0 commit comments

Comments
 (0)