[host] dxgi: add configurable sleep before D3D12 copy

This commit is contained in:
Quantum 2022-01-09 22:34:44 -05:00 committed by Geoffrey McRae
parent c69b19e68f
commit 042a7d0925
2 changed files with 15 additions and 0 deletions

View File

@ -23,6 +23,7 @@
#include <assert.h>
#include <d3d12.h>
#include "common/debug.h"
#include "common/option.h"
#include "common/windebug.h"
#define ALIGN_TO(value, align) (((value) + (align) - 1) & -(align))
@ -40,6 +41,7 @@ struct D3D12Texture
struct D3D12Backend
{
int copySleep;
ID3D12Device * device;
ID3D12CommandQueue * commandQueue;
ID3D12Resource * src;
@ -84,6 +86,9 @@ static bool d3d12_create(struct DXGIInterface * intf)
return false;
}
this->copySleep = option_get_int("dxgi", "d3d12CopySleep");
DEBUG_INFO("Sleep before copy : %d ms", this->copySleep);
status = D3D12CreateDevice((IUnknown *) dxgi->adapter, D3D_FEATURE_LEVEL_11_0,
&IID_ID3D12Device, (void **)&this->device);
@ -277,6 +282,9 @@ static bool d3d12_copyFrame(Texture * parent, ID3D11Texture2D * src)
IDXGIResource1 * res1 = NULL;
HRESULT status;
if (this->copySleep > 0)
Sleep(this->copySleep);
status = ID3D11Texture2D_QueryInterface(src, &IID_IDXGIResource1, (void **)&res1);
if (FAILED(status))
{

View File

@ -120,6 +120,13 @@ static void dxgi_initOptions(void)
.type = OPTION_TYPE_BOOL,
.value.x_bool = false
},
{
.module = "dxgi",
.name = "d3d12CopySleep",
.description = "Milliseconds to sleep before copying frame with d3d12",
.type = OPTION_TYPE_INT,
.value.x_int = 5
},
{0}
};