1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 21:30:03 -04:00

Use software texture filtering in kittest (#7602)

This commit is contained in:
Emil Ernerfeldt
2025-10-08 16:24:02 +02:00
committed by GitHub
parent 718a82b013
commit 47a437403f
26 changed files with 103 additions and 60 deletions

View File

@@ -141,21 +141,16 @@ impl ScreenDescriptor {
}
/// Uniform buffer used when rendering.
#[derive(Clone, Copy, Debug, bytemuck::Pod, bytemuck::Zeroable)]
#[derive(Clone, Copy, Debug, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
#[repr(C)]
struct UniformBuffer {
screen_size_in_points: [f32; 2],
dithering: u32,
// Uniform buffers need to be at least 16 bytes in WebGL.
// See https://github.com/gfx-rs/wgpu/issues/2072
_padding: u32,
}
impl PartialEq for UniformBuffer {
fn eq(&self, other: &Self) -> bool {
self.screen_size_in_points == other.screen_size_in_points
&& self.dithering == other.dithering
}
/// 1 to do manual filtering for more predictable kittest snapshot images.
///
/// See also <https://github.com/emilk/egui/issues/5295>.
predictable_texture_filtering: u32,
}
struct SlicedBuffer {
@@ -204,6 +199,16 @@ pub struct RendererOptions {
///
/// Defaults to true.
pub dithering: bool,
/// Perform texture filtering in software?
///
/// This is useful when you want predictable rendering across
/// different hardware, e.g. for kittest snapshots.
///
/// Default is `false`.
///
/// See also <https://github.com/emilk/egui/issues/5295>.
pub predictable_texture_filtering: bool,
}
impl RendererOptions {
@@ -214,6 +219,7 @@ impl RendererOptions {
msaa_samples: 1,
depth_stencil_format: None,
dithering: false,
predictable_texture_filtering: true,
};
}
@@ -223,6 +229,7 @@ impl Default for RendererOptions {
msaa_samples: 0,
depth_stencil_format: None,
dithering: true,
predictable_texture_filtering: false,
}
}
}
@@ -280,7 +287,7 @@ impl Renderer {
contents: bytemuck::cast_slice(&[UniformBuffer {
screen_size_in_points: [0.0, 0.0],
dithering: u32::from(options.dithering),
_padding: Default::default(),
predictable_texture_filtering: u32::from(options.predictable_texture_filtering),
}]),
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
});
@@ -895,7 +902,7 @@ impl Renderer {
let uniform_buffer_content = UniformBuffer {
screen_size_in_points,
dithering: u32::from(self.options.dithering),
_padding: Default::default(),
predictable_texture_filtering: u32::from(self.options.predictable_texture_filtering),
};
if uniform_buffer_content != self.previous_uniform_buffer_content {
profiling::scope!("update uniforms");