Skip to content

Commit

Permalink
Make IDXGISwapChain buffer cast conditional
Browse files Browse the repository at this point in the history
Remove an unconditional cast of the object returned by
IDXGISwapChain::GetBuffer to ID3D12Resource, as this method may return
other resource types.
  • Loading branch information
dgraves committed Aug 30, 2024
1 parent 1ddd493 commit fc05f71
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion framework/decode/dx12_replay_consumer_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2720,7 +2720,15 @@ HRESULT Dx12ReplayConsumerBase::OverrideGetBuffer(DxObjectInfo* r
if (swapchain_info->image_ids[buffer] == format::kNullHandleId)
{
auto object_info = static_cast<DxObjectInfo*>(surface->GetConsumerData(0));
InitialResourceExtraInfo(surface, D3D12_RESOURCE_STATE_PRESENT, false);

// Ensure that the retrieved buffer is a D3D12 resource prior to casting to ID3D12Resource.
const auto& buffer_iid = *riid.decoded_value;
if (IsEqualIID(buffer_iid, __uuidof(ID3D12Resource)) ||
IsEqualIID(buffer_iid, __uuidof(ID3D12Resource1)) ||
IsEqualIID(buffer_iid, __uuidof(ID3D12Resource2)))
{
InitialResourceExtraInfo(surface, D3D12_RESOURCE_STATE_PRESENT, false);
}

// Increment the replay reference to prevent the swapchain image info entry from being removed from the
// object info table while the swapchain is active.
Expand Down

0 comments on commit fc05f71

Please sign in to comment.