Skip to content

fix(wireframes): only set depth bias when topology is triangles#23782

Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom
kfc35:23772_23774_fix_wireframe_plugins
Apr 13, 2026
Merged

fix(wireframes): only set depth bias when topology is triangles#23782
alice-i-cecile merged 1 commit intobevyengine:mainfrom
kfc35:23772_23774_fix_wireframe_plugins

Conversation

@kfc35
Copy link
Copy Markdown
Contributor

@kfc35 kfc35 commented Apr 13, 2026

Objective

            if (ds.bias.is_enabled() || ds.bias.clamp != 0.0)
                && !desc.primitive.topology.is_triangles()
            {
                return Err(pipeline::CreateRenderPipelineError::DepthStencilState(
                    pipeline::DepthStencilStateError::DepthBiasWithIncompatibleTopology(
                        desc.primitive.topology,
                    ),
                ));
            }

ds.bias.is_enabled() returns true if either constant and slope_scale are non zero values.
This was causing the following error message when running the 2d_shapes and 3d_shapes examples (the following msg is for 3d_shapes)

2026-04-13T05:14:12.638678Z ERROR bevy_render::error_handler: Caught rendering error: Validation Error

Caused by:
  In Device::create_render_pipeline, label = 'wireframe_3d_pipeline'
    Depth/stencil state is invalid
      Depth bias is not compatible with non-triangle topology LineList

Solution

  • Wireframe plugins should only set the depth bias’ slope_scale to a non-zero value if the topology is triangles. This complies with the validation done in wgpu.

Testing

  • I can now turn on the wireframes in cargo run --example 2d_shapes and cargo run --example 3d_shapes

@kfc35 kfc35 added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 13, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering Apr 13, 2026
@kfc35 kfc35 added this to the 0.19 milestone Apr 13, 2026
@kfc35 kfc35 added P-Regression Functionality that used to work but no longer does. Add a test for this! D-Trivial Nice and easy! A great choice to get started with Bevy labels Apr 13, 2026
Copy link
Copy Markdown
Contributor

@atlv24 atlv24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@kfc35 kfc35 added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 13, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Apr 13, 2026
Merged via the queue into bevyengine:main with commit 4329b04 Apr 13, 2026
51 checks passed
@github-project-automation github-project-automation Bot moved this from Needs SME Triage to Done in Rendering Apr 13, 2026
mate-h pushed a commit to mate-h/bevy that referenced this pull request Apr 14, 2026
…engine#23782)

# Objective

- Fixes bevyengine#23772 
- Fixes bevyengine#23774 
- Fixes wireframe plugins. wgpu added some validation around
`DepthBiasState`:
```rust
            if (ds.bias.is_enabled() || ds.bias.clamp != 0.0)
                && !desc.primitive.topology.is_triangles()
            {
                return Err(pipeline::CreateRenderPipelineError::DepthStencilState(
                    pipeline::DepthStencilStateError::DepthBiasWithIncompatibleTopology(
                        desc.primitive.topology,
                    ),
                ));
            }
```
`ds.bias.is_enabled()` returns true if either `constant` and
`slope_scale` are non zero values.
This was causing the following error message when running the
`2d_shapes` and `3d_shapes` examples (the following msg is for
`3d_shapes`)

```
2026-04-13T05:14:12.638678Z ERROR bevy_render::error_handler: Caught rendering error: Validation Error

Caused by:
  In Device::create_render_pipeline, label = 'wireframe_3d_pipeline'
    Depth/stencil state is invalid
      Depth bias is not compatible with non-triangle topology LineList
```

## Solution

- Wireframe plugins should only set the depth bias’ `slope_scale` to a
non-zero value if the topology *is* triangles. This complies with the
validation done in wgpu.

## Testing

- I can now turn on the wireframes in `cargo run --example 2d_shapes`
and `cargo run --example 3d_shapes`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy P-Regression Functionality that used to work but no longer does. Add a test for this! S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2d_shapes example rendering error 3d_shapes example is broken

4 participants