D3D12 Updates:

- Relocated 'd3d12_gfx_sync()'
- Fixed swap interval option
- Cleanups
This commit is contained in:
sonninnos 2021-06-18 02:28:45 +03:00
parent 81075aa5fa
commit 917fb1f796
3 changed files with 13 additions and 11 deletions

View File

@ -294,6 +294,7 @@ bool d3d12_init_swapchain(d3d12_video_t* d3d12,
#endif
desc.BufferCount = countof(d3d12->chain.renderTargets);
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
#ifdef __WINRT__
desc.Width = width;
desc.Height = height;
@ -302,14 +303,11 @@ bool d3d12_init_swapchain(d3d12_video_t* d3d12,
desc.BufferDesc.Width = width;
desc.BufferDesc.Height = height;
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.BufferDesc.RefreshRate.Numerator = 0;
desc.BufferDesc.RefreshRate.Denominator = 1;
#endif
desc.SampleDesc.Count = 1;
#if 0
desc.BufferDesc.RefreshRate.Numerator = 60;
desc.BufferDesc.RefreshRate.Denominator = 1;
desc.SampleDesc.Quality = 0;
#endif
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.SampleDesc.Quality = 0;
#ifdef HAVE_WINDOW
desc.OutputWindow = hwnd;
desc.Windowed = TRUE;

View File

@ -1391,6 +1391,7 @@ typedef struct
float clearcolor[4];
int frame_index;
bool vsync;
unsigned swap_interval;
} chain;
struct

View File

@ -1170,6 +1170,7 @@ static bool d3d12_gfx_frame(
d3d12_texture_t* texture = NULL;
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
bool vsync = d3d12->chain.vsync;
unsigned sync_interval = (vsync) ? d3d12->chain.swap_interval : 0;
unsigned present_flags = (vsync) ? 0 : DXGI_PRESENT_ALLOW_TEARING;
const char *stat_text = video_info->stat_text;
bool statistics_show = video_info->statistics_show;
@ -1182,8 +1183,6 @@ static bool d3d12_gfx_frame(
bool widgets_active = video_info->widgets_active;
#endif
d3d12_gfx_sync(d3d12);
if (d3d12->resize_chain)
{
unsigned i;
@ -1601,12 +1600,15 @@ static bool d3d12_gfx_frame(
win32_update_title();
#endif
#if 1
DXGIPresent(d3d12->chain.handle, !!vsync, present_flags);
DXGIPresent(d3d12->chain.handle, sync_interval, present_flags);
#else
DXGI_PRESENT_PARAMETERS pp = { 0 };
DXGIPresent1(d3d12->swapchain, 0, 0, &pp);
#endif
/* Sync after Present for minimal delay */
d3d12_gfx_sync(d3d12);
return true;
}
@ -1614,8 +1616,9 @@ static void d3d12_gfx_set_nonblock_state(void* data, bool toggle,
bool adaptive_vsync_enabled,
unsigned swap_interval)
{
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
d3d12->chain.vsync = !toggle;
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
d3d12->chain.vsync = !toggle;
d3d12->chain.swap_interval = swap_interval;
}
static bool d3d12_gfx_alive(void* data)