@@ -217,8 +217,11 @@ namespace
217
217
bufferDesc.SampleDesc .Count = 1 ;
218
218
219
219
ComPtr<ID3D12Resource> copySource (pSource);
220
+ D3D12_RESOURCE_STATES beforeStateSource = beforeState;
220
221
if (desc.SampleDesc .Count > 1 )
221
222
{
223
+ TransitionResource (commandList.Get (), pSource, beforeState, D3D12_RESOURCE_STATE_RESOLVE_SOURCE);
224
+
222
225
// MSAA content must be resolved before being copied to a staging texture
223
226
auto descCopy = desc;
224
227
descCopy.SampleDesc .Count = 1 ;
@@ -230,7 +233,7 @@ namespace
230
233
&defaultHeapProperties,
231
234
D3D12_HEAP_FLAG_NONE,
232
235
&descCopy,
233
- D3D12_RESOURCE_STATE_COPY_DEST ,
236
+ D3D12_RESOURCE_STATE_RESOLVE_DEST ,
234
237
nullptr ,
235
238
IID_GRAPHICS_PPV_ARGS (pTemp.GetAddressOf ()));
236
239
if (FAILED (hr))
@@ -267,6 +270,11 @@ namespace
267
270
}
268
271
269
272
copySource = pTemp;
273
+ beforeState = D3D12_RESOURCE_STATE_RESOLVE_DEST;
274
+ }
275
+ else
276
+ {
277
+ beforeStateSource = D3D12_RESOURCE_STATE_COPY_SOURCE;
270
278
}
271
279
272
280
// Create a staging texture
@@ -283,7 +291,7 @@ namespace
283
291
assert (*pStaging);
284
292
285
293
// Transition the resource if necessary
286
- TransitionResource (commandList.Get (), pSource , beforeState, D3D12_RESOURCE_STATE_COPY_SOURCE);
294
+ TransitionResource (commandList.Get (), copySource. Get () , beforeState, D3D12_RESOURCE_STATE_COPY_SOURCE);
287
295
288
296
// Get the copy target location
289
297
for (UINT j = 0 ; j < numberOfResources; ++j)
@@ -293,8 +301,8 @@ namespace
293
301
commandList->CopyTextureRegion (©Dest, 0 , 0 , 0 , ©Src, nullptr );
294
302
}
295
303
296
- // Transition the resource to the next state
297
- TransitionResource (commandList.Get (), pSource, D3D12_RESOURCE_STATE_COPY_SOURCE , afterState);
304
+ // Transition the source resource to the next state
305
+ TransitionResource (commandList.Get (), pSource, beforeStateSource , afterState);
298
306
299
307
hr = commandList->Close ();
300
308
if (FAILED (hr))
0 commit comments