From 49130f5ecf143515522c708c3d9ae66fba4e868d Mon Sep 17 00:00:00 2001 From: supersurviveur Date: Mon, 28 Sep 2026 17:22:08 +0200 Subject: [PATCH] perf: remove shader checks --- src/fractal/buddhabrot.rs | 25 +++++---- src/fractal/renderer.rs | 104 +++++++++++++++++++++++--------------- 2 files changed, 77 insertions(+), 52 deletions(-) diff --git a/src/fractal/buddhabrot.rs b/src/fractal/buddhabrot.rs index 339ae5b..84a1329 100644 --- a/src/fractal/buddhabrot.rs +++ b/src/fractal/buddhabrot.rs @@ -126,16 +126,21 @@ pub struct BuddhabrotRenderer { impl BuddhabrotRenderer { pub fn new(device: &wgpu::Device, target_format: wgpu::TextureFormat) -> Self { - let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor { - label: Some("buddhabrot"), - source: wgpu::ShaderSource::Wgsl( - concat!( - include_str!("../shaders/common.wgsl"), - include_str!("../shaders/buddhabrot.wgsl"), - ) - .into(), - ), - }); + let shader = unsafe { + device.create_shader_module_trusted( + wgpu::ShaderModuleDescriptor { + label: Some("buddhabrot"), + source: wgpu::ShaderSource::Wgsl( + concat!( + include_str!("../shaders/common.wgsl"), + include_str!("../shaders/buddhabrot.wgsl"), + ) + .into(), + ), + }, + wgpu::ShaderRuntimeChecks::unchecked(), + ) + }; let uniform_buffer = device.create_buffer(&wgpu::BufferDescriptor { label: Some("buddhabrot uniforms"), diff --git a/src/fractal/renderer.rs b/src/fractal/renderer.rs index 25134ab..a53081c 100644 --- a/src/fractal/renderer.rs +++ b/src/fractal/renderer.rs @@ -197,16 +197,21 @@ struct Lipschitz { impl Lipschitz { fn new(device: &wgpu::Device) -> Self { - let module = device.create_shader_module(wgpu::ShaderModuleDescriptor { - label: Some("lipschitz"), - source: wgpu::ShaderSource::Wgsl( - concat!( - include_str!("../shaders/common.wgsl"), - include_str!("../shaders/lipschitz.wgsl"), - ) - .into(), - ), - }); + let module = unsafe { + device.create_shader_module_trusted( + wgpu::ShaderModuleDescriptor { + label: Some("lipschitz"), + source: wgpu::ShaderSource::Wgsl( + concat!( + include_str!("../shaders/common.wgsl"), + include_str!("../shaders/lipschitz.wgsl"), + ) + .into(), + ), + }, + wgpu::ShaderRuntimeChecks::unchecked(), + ) + }; let texture_entry = |binding| wgpu::BindGroupLayoutEntry { binding, visibility: wgpu::ShaderStages::FRAGMENT, @@ -617,17 +622,22 @@ impl FractalRenderer { } pub fn new(device: &wgpu::Device, target_format: wgpu::TextureFormat) -> Self { - let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor { - label: Some("mandelbrot"), - source: wgpu::ShaderSource::Wgsl( - concat!( - include_str!("../shaders/common.wgsl"), - include_str!("../shaders/iterate_uniforms.wgsl"), - include_str!("../shaders/mandelbrot.wgsl"), - ) - .into(), - ), - }); + let shader = unsafe { + device.create_shader_module_trusted( + wgpu::ShaderModuleDescriptor { + label: Some("mandelbrot"), + source: wgpu::ShaderSource::Wgsl( + concat!( + include_str!("../shaders/common.wgsl"), + include_str!("../shaders/iterate_uniforms.wgsl"), + include_str!("../shaders/mandelbrot.wgsl"), + ) + .into(), + ), + }, + wgpu::ShaderRuntimeChecks::unchecked(), + ) + }; let uniform_buffer = device.create_buffer(&wgpu::BufferDescriptor { label: Some("fractal uniforms"), @@ -748,17 +758,22 @@ impl FractalRenderer { }); // Colourise pass: data texture + colour uniforms → colour texture. - let colorize_shader = device.create_shader_module(wgpu::ShaderModuleDescriptor { - label: Some("colorize"), - source: wgpu::ShaderSource::Wgsl( - concat!( - include_str!("../shaders/common.wgsl"), - include_str!("../shaders/iterate_uniforms.wgsl"), - include_str!("../shaders/colorize.wgsl"), - ) - .into(), - ), - }); + let colorize_shader = unsafe { + device.create_shader_module_trusted( + wgpu::ShaderModuleDescriptor { + label: Some("colorize"), + source: wgpu::ShaderSource::Wgsl( + concat!( + include_str!("../shaders/common.wgsl"), + include_str!("../shaders/iterate_uniforms.wgsl"), + include_str!("../shaders/colorize.wgsl"), + ) + .into(), + ), + }, + wgpu::ShaderRuntimeChecks::unchecked(), + ) + }; let colorize_bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { label: Some("colorize bind group layout"), @@ -829,16 +844,21 @@ impl FractalRenderer { }); // Blit pipeline: samples the cache texture onto egui's surface. - let blit_shader = device.create_shader_module(wgpu::ShaderModuleDescriptor { - label: Some("blit"), - source: wgpu::ShaderSource::Wgsl( - concat!( - include_str!("../shaders/common.wgsl"), - include_str!("../shaders/blit.wgsl"), - ) - .into(), - ), - }); + let blit_shader = unsafe { + device.create_shader_module_trusted( + wgpu::ShaderModuleDescriptor { + label: Some("blit"), + source: wgpu::ShaderSource::Wgsl( + concat!( + include_str!("../shaders/common.wgsl"), + include_str!("../shaders/blit.wgsl"), + ) + .into(), + ), + }, + wgpu::ShaderRuntimeChecks::unchecked(), + ) + }; let blit_bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {