@@ -103,24 +103,38 @@ InlinePassContext::RenderPassResult InlinePassContext::GetRenderPass(
103
103
" Count=" + std::to_string (pass_count_));
104
104
105
105
RenderPassResult result;
106
-
107
- if (pass_count_ > 0 ) {
108
- result.backdrop_texture =
109
- pass_target_.Flip (*context_->GetResourceAllocator ());
110
- if (!result.backdrop_texture ) {
111
- VALIDATION_LOG << " Could not flip the EntityPass render target." ;
106
+ {
107
+ // If the pass target has a resolve texture, then we're using MSAA.
108
+ bool is_msaa = pass_target_.GetRenderTarget ()
109
+ .GetColorAttachments ()
110
+ .find (0 )
111
+ ->second .resolve_texture != nullptr ;
112
+ if (pass_count_ > 0 && is_msaa) {
113
+ result.backdrop_texture =
114
+ pass_target_.Flip (*context_->GetResourceAllocator ());
115
+ if (!result.backdrop_texture ) {
116
+ VALIDATION_LOG << " Could not flip the EntityPass render target." ;
117
+ }
112
118
}
113
119
}
114
120
121
+ // Find the color attachment a second time, since the target may have just
122
+ // flipped.
115
123
auto color0 =
116
124
pass_target_.GetRenderTarget ().GetColorAttachments ().find (0 )->second ;
125
+ bool is_msaa = color0.resolve_texture != nullptr ;
117
126
118
- color0.load_action =
119
- pass_count_ > 0 ? LoadAction::kDontCare : LoadAction::kClear ;
127
+ if (pass_count_ > 0 ) {
128
+ // When MSAA is being used, we end up overriding the entire backdrop by
129
+ // drawing the previous pass texture, and so we don't have to clear it and
130
+ // can use kDontCare.
131
+ color0.load_action = is_msaa ? LoadAction::kDontCare : LoadAction::kLoad ;
132
+ } else {
133
+ color0.load_action = LoadAction::kClear ;
134
+ }
120
135
121
- color0.store_action = color0.resolve_texture
122
- ? StoreAction::kMultisampleResolve
123
- : StoreAction::kStore ;
136
+ color0.store_action =
137
+ is_msaa ? StoreAction::kMultisampleResolve : StoreAction::kStore ;
124
138
125
139
auto stencil = pass_target_.GetRenderTarget ().GetStencilAttachment ();
126
140
if (!stencil.has_value ()) {
0 commit comments