Skip to content

MSAA for textures #3254

@HackerFoo

Description

@HackerFoo

What problem does this solve or what need does it fill?

MSAA is implemented when rendering to a window, but not when rendering to a texture.

What solution would you like?

To be able to render to a texture with MSAA enabled.

What alternative(s) have you considered?

I tried following the render_to_texture example to render a second camera to a texture, but it failed due to MSAA being enabled in my app.

Adding .insert_resource(Msaa { samples: 4 }) to the example will cause this error:

2021-12-05T10:27:57.789110Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In a RenderPass
      note: encoder = `<CommandBuffer-(1, 2, Metal)>`
    In a set_pipeline command
      note: render pipeline = `<RenderPipeline-(0, 1, Metal)>`
    Render pipeline targets are incompatible with render pass
    Incompatible sample count: 1 != 4

I tried to mimic render graph setup code elsewhere that inserts a resolve target node, but have been unsuccessful, because Bevy doesn't seem to support multisampled textures:

https://github.com/bevyengine/bevy/blob/main/crates/bevy_render/src/shader/shader_reflect.rs#L135

which will cause this validation failure:

https://github.com/gfx-rs/wgpu/blob/master/wgpu-core/src/device/mod.rs#L1793-L1799

Additional context

In addition to the texture not being antialiased, I can't find a good way to use MSAA at all when rendering to a texture.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-FeatureA new feature, making something new possible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions