graphics-hook: Fix D3D11On12 usages

Use D3D12_RESOURCE_STATE_PRESENT for CreateWrappedResource arguments. We
should assume the application will set the backbuffer to PRESENT, and
expect that to be preserved across the Present() call.

Remove unnecessary calls to ReleaseWrappedResources.

Clean up (void**) casts with modern patterns.
master
jpark37 2021-08-15 14:16:02 -07:00 committed by Jim
parent 1d44ace7d0
commit 0f2c1447ab
1 changed files with 6 additions and 14 deletions

View File

@ -89,10 +89,9 @@ static bool create_d3d12_tex(bb_info &bb)
for (UINT i = 0; i < bb.count; i++) {
hr = data.device11on12->CreateWrappedResource(
bb.backbuffer[i], &rf11,
D3D12_RESOURCE_STATE_COPY_SOURCE,
D3D12_RESOURCE_STATE_PRESENT, __uuidof(ID3D11Resource),
(void **)&data.backbuffer11[i]);
bb.backbuffer[i], &rf11, D3D12_RESOURCE_STATE_PRESENT,
D3D12_RESOURCE_STATE_PRESENT,
IID_PPV_ARGS(&data.backbuffer11[i]));
if (FAILED(hr)) {
hlog_hr("create_d3d12_tex: failed to create "
"backbuffer11",
@ -119,14 +118,8 @@ static bool create_d3d12_tex(bb_info &bb)
return false;
}
for (UINT i = 0; i < bb.count; i++) {
data.device11on12->ReleaseWrappedResources(
&data.backbuffer11[i], 1);
}
IDXGIResource *dxgi_res;
hr = data.copy_tex->QueryInterface(__uuidof(IDXGIResource),
(void **)&dxgi_res);
hr = data.copy_tex->QueryInterface(&dxgi_res);
if (FAILED(hr)) {
hlog_hr("create_d3d12_tex: failed to query "
"IDXGIResource interface from texture",
@ -249,7 +242,7 @@ static inline bool d3d12_init_format(IDXGISwapChain *swap, HWND &window,
data.cx = desc.BufferDesc.Width;
data.cy = desc.BufferDesc.Height;
hr = swap->QueryInterface(__uuidof(IDXGISwapChain3), (void **)&swap3);
hr = swap->QueryInterface(&swap3);
if (SUCCEEDED(hr)) {
data.dxgi_1_4 = true;
hlog("We're DXGI1.4 boys!");
@ -274,8 +267,7 @@ static inline bool d3d12_init_format(IDXGISwapChain *swap, HWND &window,
}
for (UINT i = 0; i < bb.count; i++) {
hr = swap->GetBuffer(i, __uuidof(ID3D12Resource),
(void **)&bb.backbuffer[i]);
hr = swap->GetBuffer(i, IID_PPV_ARGS(&bb.backbuffer[i]));
if (SUCCEEDED(hr)) {
bb.backbuffer[i]->Release();
} else {