fix(viewport): clip text to stencil

This commit is contained in:
Hakan Seven 2026-08-04 11:34:32 +03:00
commit 1955e022bf
2 changed files with 10 additions and 2 deletions

View file

@ -1473,7 +1473,14 @@ impl Pipeline {
// ── Text (SDF glyph quads) ─────────────────────────────────────────
let text_atlas_bgl = text_gpu::TextAtlasGpu::bind_group_layout(device);
let (text_pipeline, text_highlight_pipeline) =
text_gpu::create_pipelines(device, &frame_bgl, &text_atlas_bgl, format, MSAA_SAMPLES);
text_gpu::create_pipelines(
device,
&frame_bgl,
&text_atlas_bgl,
format,
MSAA_SAMPLES,
&content_stencil,
);
let viewcube = ViewCubePipeline::new(device, queue, format);

View file

@ -260,6 +260,7 @@ pub fn create_pipelines(
atlas_bgl: &wgpu::BindGroupLayout,
color_format: wgpu::TextureFormat,
sample_count: u32,
content_stencil: &wgpu::StencilState,
) -> (wgpu::RenderPipeline, wgpu::RenderPipeline) {
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("text.wgsl"),
@ -298,7 +299,7 @@ pub fn create_pipelines(
format: wgpu::TextureFormat::Depth24PlusStencil8,
depth_write_enabled,
depth_compare,
stencil: wgpu::StencilState::default(),
stencil: content_stencil.clone(),
bias: wgpu::DepthBiasState::default(),
}),
multisample: wgpu::MultisampleState {