diff --git a/render/wgpu/shaders/copy_srgb.wgsl b/render/wgpu/shaders/copy_srgb.wgsl deleted file mode 100644 index e41e1bec9235..000000000000 --- a/render/wgpu/shaders/copy_srgb.wgsl +++ /dev/null @@ -1,33 +0,0 @@ -/// Shader used for drawing bitmap fills. - -#import common - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) uv: vec2, -}; - -#if use_push_constants == true - var transforms: common::Transforms; - @group(1) @binding(0) var textureTransforms: common::TextureTransforms; - @group(1) @binding(1) var texture: texture_2d; - @group(1) @binding(2) var texture_sampler: sampler; -#else - @group(1) @binding(0) var transforms: common::Transforms; - @group(2) @binding(0) var textureTransforms: common::TextureTransforms; - @group(2) @binding(1) var texture: texture_2d; - @group(2) @binding(2) var texture_sampler: sampler; -#endif - -@vertex -fn main_vertex(in: common::VertexInput) -> VertexOutput { - let matrix_ = textureTransforms.texture_matrix; - let uv = (mat3x3(matrix_[0].xyz, matrix_[1].xyz, matrix_[2].xyz) * vec3(in.position, 1.0)).xy; - let pos = common::globals.view_matrix * transforms.world_matrix * vec4(in.position.x, in.position.y, 0.0, 1.0); - return VertexOutput(pos, uv); -} - -@fragment -fn main_fragment(in: VertexOutput) -> @location(0) vec4 { - return common::srgb_to_linear(textureSample(texture, texture_sampler, in.uv)); -} diff --git a/render/wgpu/src/backend.rs b/render/wgpu/src/backend.rs index eb45fa719914..01041d1d193e 100644 --- a/render/wgpu/src/backend.rs +++ b/render/wgpu/src/backend.rs @@ -599,7 +599,6 @@ impl RenderBackend for WgpuRenderBackend { run_copy_pipeline( &self.descriptors, target.color_texture().format(), - texture.texture.format(), target.color_texture().size(), &texture.texture.create_view(&Default::default()), target.color_view(), diff --git a/render/wgpu/src/descriptors.rs b/render/wgpu/src/descriptors.rs index 23a64f3dad77..ae02ae4827fc 100644 --- a/render/wgpu/src/descriptors.rs +++ b/render/wgpu/src/descriptors.rs @@ -21,7 +21,6 @@ pub struct Descriptors { pub bind_layouts: BindLayouts, pub quad: Quad, copy_pipeline: Mutex>>, - copy_srgb_pipeline: Mutex>>, pub shaders: Shaders, pipelines: Mutex>>, pub default_color_bind_group: wgpu::BindGroup, @@ -72,7 +71,6 @@ impl Descriptors { bind_layouts, quad, copy_pipeline: Default::default(), - copy_srgb_pipeline: Default::default(), shaders, pipelines: Default::default(), default_color_bind_group, @@ -80,85 +78,6 @@ impl Descriptors { } } - pub fn copy_srgb_pipeline( - &self, - format: wgpu::TextureFormat, - msaa_sample_count: u32, - ) -> Arc { - let mut pipelines = self - .copy_srgb_pipeline - .lock() - .expect("Pipelines should not be already locked"); - pipelines - .entry((msaa_sample_count, format)) - .or_insert_with(|| { - let copy_texture_pipeline_layout = - &self - .device - .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { - label: create_debug_label!("Copy sRGB pipeline layout").as_deref(), - bind_group_layouts: &if self.limits.max_push_constant_size > 0 { - vec![&self.bind_layouts.globals, &self.bind_layouts.bitmap] - } else { - vec![ - &self.bind_layouts.globals, - &self.bind_layouts.transforms, - &self.bind_layouts.bitmap, - ] - }, - push_constant_ranges: if self.device.limits().max_push_constant_size > 0 - { - &[wgpu::PushConstantRange { - stages: wgpu::ShaderStages::VERTEX, - range: 0..(mem::size_of::() as u32), - }] - } else { - &[] - }, - }); - Arc::new( - self.device - .create_render_pipeline(&wgpu::RenderPipelineDescriptor { - label: create_debug_label!("Copy sRGB pipeline").as_deref(), - layout: Some(copy_texture_pipeline_layout), - vertex: wgpu::VertexState { - module: &self.shaders.copy_srgb_shader, - entry_point: "main_vertex", - buffers: &VERTEX_BUFFERS_DESCRIPTION_POS, - }, - fragment: Some(wgpu::FragmentState { - module: &self.shaders.copy_srgb_shader, - entry_point: "main_fragment", - targets: &[Some(wgpu::ColorTargetState { - format, - // All of our blending has been done by now, so we want - // to overwrite the target pixels without any blending - blend: Some(wgpu::BlendState::REPLACE), - write_mask: Default::default(), - })], - }), - primitive: wgpu::PrimitiveState { - topology: wgpu::PrimitiveTopology::TriangleList, - strip_index_format: None, - front_face: wgpu::FrontFace::Ccw, - cull_mode: None, - polygon_mode: wgpu::PolygonMode::default(), - unclipped_depth: false, - conservative: false, - }, - depth_stencil: None, - multisample: wgpu::MultisampleState { - count: msaa_sample_count, - mask: !0, - alpha_to_coverage_enabled: false, - }, - multiview: None, - }), - ) - }) - .clone() - } - pub fn copy_pipeline( &self, format: wgpu::TextureFormat, diff --git a/render/wgpu/src/shaders.rs b/render/wgpu/src/shaders.rs index a8fd7a3f7671..5b535b9a6f15 100644 --- a/render/wgpu/src/shaders.rs +++ b/render/wgpu/src/shaders.rs @@ -18,7 +18,6 @@ pub struct Shaders { /// an out-of-range value). pub bitmap_late_saturate_shader: wgpu::ShaderModule, pub gradient_shader: wgpu::ShaderModule, - pub copy_srgb_shader: wgpu::ShaderModule, pub copy_shader: wgpu::ShaderModule, pub blend_shaders: EnumMap, pub color_matrix_filter: wgpu::ShaderModule, @@ -62,13 +61,6 @@ impl Shaders { "bitmap.wgsl", include_str!("../shaders/bitmap.wgsl"), ); - let copy_srgb_shader = make_shader( - device, - &mut composer, - &shader_defs, - "copy_srgb.wgsl", - include_str!("../shaders/copy_srgb.wgsl"), - ); let copy_shader = make_shader( device, &mut composer, @@ -136,7 +128,6 @@ impl Shaders { bitmap_shader, bitmap_late_saturate_shader, gradient_shader, - copy_srgb_shader, copy_shader, blend_shaders, color_matrix_filter, diff --git a/render/wgpu/src/surface.rs b/render/wgpu/src/surface.rs index f3397b427c20..102d7210fda6 100644 --- a/render/wgpu/src/surface.rs +++ b/render/wgpu/src/surface.rs @@ -30,7 +30,6 @@ pub struct Surface { sample_count: u32, pipelines: Arc, format: wgpu::TextureFormat, - actual_surface_format: wgpu::TextureFormat, } impl Surface { @@ -57,7 +56,6 @@ impl Surface { sample_count, pipelines, format: frame_buffer_format, - actual_surface_format: surface_format, } } @@ -93,7 +91,6 @@ impl Surface { run_copy_pipeline( descriptors, self.format, - self.actual_surface_format, self.size, frame_view, target.color_view(), diff --git a/render/wgpu/src/surface/target.rs b/render/wgpu/src/surface/target.rs index fa5bf1ad39ec..dda0cda1e7b4 100644 --- a/render/wgpu/src/surface/target.rs +++ b/render/wgpu/src/surface/target.rs @@ -287,7 +287,6 @@ impl CommandTarget { run_copy_pipeline( descriptors, format, - format, size, frame_buffer.texture.view(), &texture.create_view(&Default::default()), diff --git a/render/wgpu/src/utils.rs b/render/wgpu/src/utils.rs index 1116579edab2..18197d652736 100644 --- a/render/wgpu/src/utils.rs +++ b/render/wgpu/src/utils.rs @@ -205,7 +205,6 @@ pub fn supported_sample_count( pub fn run_copy_pipeline( descriptors: &Descriptors, format: wgpu::TextureFormat, - actual_surface_format: wgpu::TextureFormat, size: wgpu::Extent3d, frame_view: &wgpu::TextureView, input: &wgpu::TextureView, @@ -237,11 +236,7 @@ pub fn run_copy_pipeline( label: create_debug_label!("Copy sRGB bind group").as_deref(), }); - let pipeline = if actual_surface_format == format { - descriptors.copy_pipeline(format, sample_count) - } else { - descriptors.copy_srgb_pipeline(actual_surface_format, sample_count) - }; + let pipeline = descriptors.copy_pipeline(format, sample_count); // We overwrite the pixels in the target texture (no blending at all), // so this doesn't matter.