Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSAA for textures #3254

Closed
HackerFoo opened this issue Dec 5, 2021 · 3 comments
Closed

MSAA for textures #3254

HackerFoo opened this issue Dec 5, 2021 · 3 comments
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible

Comments

@HackerFoo
Copy link
Contributor

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.

@HackerFoo HackerFoo added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Dec 5, 2021
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Dec 5, 2021
@preetishkakkar
Copy link

As per discussion on discord, this should be supported in bevy (as per information provided by cwfitzgerald). We may need to add an example, happy to look into this & add an example.

@MForster
Copy link

MForster commented Dec 6, 2021

FWIW, I'm hitting the same with Vulkan:

2021-12-06T13:01:59.954821Z 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, Vulkan)>`
    In a set_pipeline command
      note: render pipeline = `<RenderPipeline-(0, 1, Vulkan)>`
    Render pipeline targets are incompatible with render pass
    Incompatible sample count: 1 != 4

bors bot pushed a commit that referenced this issue Feb 24, 2022
# Objective

Will fix #3377 and #3254

## Solution

Use an enum to represent either a `WindowId` or `Handle<Image>` in place of `Camera::window`.


Co-authored-by: Carter Anderson <mcanders1@gmail.com>
kurtkuehnert pushed a commit to kurtkuehnert/bevy that referenced this issue Mar 6, 2022
# Objective

Will fix bevyengine#3377 and bevyengine#3254

## Solution

Use an enum to represent either a `WindowId` or `Handle<Image>` in place of `Camera::window`.


Co-authored-by: Carter Anderson <mcanders1@gmail.com>
@alice-i-cecile
Copy link
Member

Closing due to #3412.

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-Feature A new feature, making something new possible
Projects
None yet
Development

No branches or pull requests

4 participants