bevyengine / bevyengine/bevy

Use transient multisampled textures for `NormalPrepass` and `MotionVectorPrepass`

Open
#22,830 0 comments 0 reactions 0 assignees View on GitHub
A-Rendering C-Feature S-Needs-Review
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

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

Currently if MSAA enables, normal prepass and motion vector prepass are stored in multisampled textures, which wastes many VRAM and bandwidth. And sampling multisampled prepass textures isn't useful as we generally pass 0 as `sample_index` otherwise per-sample fragment shader is less efficient. Using resolved normal and motion vector textures doesn't need `sample_index` and they are anti-aliased.

For desktop that transient attachment doesn't save memory, this uses more VRAM for the unsampled textures.

## What solution would you like?

If MSAA enabled, use transient multisampled textures for `NormalPrepass` and `MotionVectorPrepass` and resolve them to unsampled textures.

## What alternative(s) have you considered?

Alternatively we can choose to always disable multisampling for `NormalPrepass` and `MotionVectorPrepass` as them usually have less visual impact.

## Additional context

Transient attachment is added in wgpu v28 and it is more efficient on TBDR and usually can't save VRAM on desktop.

Contributor guide

Open the contributing guide

Research direction

Start by locating the NormalPrepass and MotionVectorPrepass render entry points and tracing how their MSAA attachments are created. Done means that, when MSAA is enabled, transient multisampled attachments resolve to unsampled normal and motion-vector textures without requiring a sample index, while the desktop trade-off is preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics, game-dev, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.