mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
(D3D12) Use flags instead of boolean variables
This commit is contained in:
parent
3b300f395b
commit
bba1fdca30
@ -135,6 +135,25 @@ typedef struct ALIGN(16)
|
||||
float time;
|
||||
} d3d12_uniform_t;
|
||||
|
||||
enum d3d12_video_flags
|
||||
{
|
||||
D3D12_ST_FLAG_RESIZE_CHAIN = (1 << 0),
|
||||
D3D12_ST_FLAG_KEEP_ASPECT = (1 << 1),
|
||||
D3D12_ST_FLAG_RESIZE_VIEWPORT = (1 << 2),
|
||||
D3D12_ST_FLAG_RESIZE_RTS = (1 << 3),
|
||||
D3D12_ST_FLAG_INIT_HISTORY = (1 << 4),
|
||||
D3D12_ST_FLAG_OVERLAYS_ENABLE = (1 << 5),
|
||||
D3D12_ST_FLAG_OVERLAYS_FULLSCREEN = (1 << 6),
|
||||
D3D12_ST_FLAG_SPRITES_ENABLE = (1 << 7),
|
||||
D3D12_ST_FLAG_MENU_ENABLE = (1 << 8),
|
||||
D3D12_ST_FLAG_MENU_FULLSCREEN = (1 << 9),
|
||||
D3D12_ST_FLAG_HDR_SUPPORT = (1 << 10),
|
||||
D3D12_ST_FLAG_HDR_ENABLE = (1 << 11),
|
||||
D3D12_ST_FLAG_VSYNC = (1 << 12),
|
||||
D3D12_ST_FLAG_WAITABLE_SWAPCHAINS = (1 << 13),
|
||||
D3D12_ST_FLAG_WAIT_FOR_VBLANK = (1 << 14)
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned cur_mon_id;
|
||||
@ -182,9 +201,6 @@ typedef struct
|
||||
D3D12_RECT scissorRect;
|
||||
float clearcolor[4];
|
||||
int frame_index;
|
||||
bool vsync;
|
||||
bool waitable_swapchains;
|
||||
bool wait_for_vblank;
|
||||
unsigned swap_interval;
|
||||
#ifdef HAVE_DXGI_HDR
|
||||
enum dxgi_swapchain_bit_depth bit_depth;
|
||||
@ -216,8 +232,6 @@ typedef struct
|
||||
float min_output_nits;
|
||||
float max_cll;
|
||||
float max_fall;
|
||||
bool support;
|
||||
bool enable;
|
||||
} hdr;
|
||||
#endif
|
||||
|
||||
@ -228,8 +242,6 @@ typedef struct
|
||||
d3d12_texture_t texture;
|
||||
|
||||
float alpha;
|
||||
bool enabled;
|
||||
bool fullscreen;
|
||||
} menu;
|
||||
|
||||
struct
|
||||
@ -242,7 +254,6 @@ typedef struct
|
||||
D3D12_VERTEX_BUFFER_VIEW vbo_view;
|
||||
int offset;
|
||||
int capacity;
|
||||
bool enabled;
|
||||
} sprites;
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
@ -251,8 +262,6 @@ typedef struct
|
||||
D3D12Resource vbo;
|
||||
D3D12_VERTEX_BUFFER_VIEW vbo_view;
|
||||
d3d12_texture_t* textures;
|
||||
bool enabled;
|
||||
bool fullscreen;
|
||||
int count;
|
||||
} overlays;
|
||||
#endif
|
||||
@ -286,17 +295,13 @@ typedef struct
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE samplers[RARCH_FILTER_MAX][RARCH_WRAP_MAX];
|
||||
math_matrix_4x4 mvp, mvp_no_rot;
|
||||
struct video_viewport vp;
|
||||
bool resize_chain;
|
||||
bool keep_aspect;
|
||||
bool resize_viewport;
|
||||
bool resize_render_targets;
|
||||
bool init_history;
|
||||
D3D12Resource menu_pipeline_vbo;
|
||||
D3D12_VERTEX_BUFFER_VIEW menu_pipeline_vbo_view;
|
||||
|
||||
#ifdef DEBUG
|
||||
D3D12Debug debugController;
|
||||
#endif
|
||||
uint16_t flags;
|
||||
} d3d12_video_t;
|
||||
|
||||
typedef enum
|
||||
|
@ -258,7 +258,10 @@ static void d3d12_overlay_enable(void* data, bool state)
|
||||
if (!d3d12)
|
||||
return;
|
||||
|
||||
d3d12->overlays.enabled = state;
|
||||
if (state)
|
||||
d3d12->flags |= D3D12_ST_FLAG_OVERLAYS_ENABLE;
|
||||
else
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_OVERLAYS_ENABLE;
|
||||
win32_show_cursor(d3d12, state);
|
||||
}
|
||||
|
||||
@ -266,10 +269,13 @@ static void d3d12_overlay_full_screen(void* data, bool enable)
|
||||
{
|
||||
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
|
||||
|
||||
if (!d3d12)
|
||||
return;
|
||||
|
||||
d3d12->overlays.fullscreen = enable;
|
||||
if (d3d12)
|
||||
{
|
||||
if (enable)
|
||||
d3d12->flags |= D3D12_ST_FLAG_OVERLAYS_FULLSCREEN;
|
||||
else
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_OVERLAYS_FULLSCREEN;
|
||||
}
|
||||
}
|
||||
|
||||
static void d3d12_get_overlay_interface(void* data, const video_overlay_interface_t** iface)
|
||||
@ -286,7 +292,7 @@ static void d3d12_render_overlay(d3d12_video_t *d3d12)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (d3d12->overlays.fullscreen)
|
||||
if (d3d12->flags & D3D12_ST_FLAG_OVERLAYS_FULLSCREEN)
|
||||
{
|
||||
D3D12RSSetViewports(d3d12->queue.cmd, 1,
|
||||
&d3d12->chain.viewport);
|
||||
@ -342,7 +348,7 @@ static void d3d12_set_hdr_max_nits(void* data, float max_nits)
|
||||
|
||||
dxgi_set_hdr_metadata(
|
||||
d3d12->chain.handle,
|
||||
d3d12->hdr.support,
|
||||
d3d12->flags & D3D12_ST_FLAG_HDR_SUPPORT,
|
||||
d3d12->chain.bit_depth,
|
||||
d3d12->chain.color_space,
|
||||
d3d12->hdr.max_output_nits,
|
||||
@ -476,7 +482,8 @@ static void d3d12_gfx_set_rotation(void* data, unsigned rotation)
|
||||
|
||||
static void d3d12_update_viewport(d3d12_video_t *d3d12, bool force_full)
|
||||
{
|
||||
video_driver_update_viewport(&d3d12->vp, force_full, d3d12->keep_aspect);
|
||||
video_driver_update_viewport(&d3d12->vp, force_full,
|
||||
d3d12->flags & D3D12_ST_FLAG_KEEP_ASPECT);
|
||||
|
||||
d3d12->frame.viewport.TopLeftX = d3d12->vp.x;
|
||||
d3d12->frame.viewport.TopLeftY = d3d12->vp.y;
|
||||
@ -493,14 +500,14 @@ static void d3d12_update_viewport(d3d12_video_t *d3d12, bool force_full)
|
||||
|
||||
if (d3d12->shader_preset && (d3d12->frame.output_size.x != d3d12->vp.width ||
|
||||
d3d12->frame.output_size.y != d3d12->vp.height))
|
||||
d3d12->resize_render_targets = true;
|
||||
d3d12->flags |= D3D12_ST_FLAG_RESIZE_RTS;
|
||||
|
||||
d3d12->frame.output_size.x = d3d12->vp.width;
|
||||
d3d12->frame.output_size.y = d3d12->vp.height;
|
||||
d3d12->frame.output_size.z = 1.0f / d3d12->vp.width;
|
||||
d3d12->frame.output_size.w = 1.0f / d3d12->vp.height;
|
||||
|
||||
d3d12->resize_viewport = false;
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_RESIZE_VIEWPORT;
|
||||
}
|
||||
|
||||
static void d3d12_free_shader_preset(d3d12_video_t* d3d12)
|
||||
@ -549,8 +556,8 @@ static void d3d12_free_shader_preset(d3d12_video_t* d3d12)
|
||||
|
||||
free(d3d12->shader_preset);
|
||||
d3d12->shader_preset = NULL;
|
||||
d3d12->init_history = false;
|
||||
d3d12->resize_render_targets = false;
|
||||
d3d12->flags &= ~(D3D12_ST_FLAG_INIT_HISTORY
|
||||
| D3D12_ST_FLAG_RESIZE_RTS);
|
||||
}
|
||||
|
||||
static void d3d12_init_pipeline(
|
||||
@ -758,21 +765,21 @@ static bool d3d12_gfx_set_shader(void* data, enum rarch_shader_type type, const
|
||||
}
|
||||
|
||||
#ifdef HAVE_DXGI_HDR
|
||||
if (d3d12->hdr.enable)
|
||||
if (d3d12->flags & D3D12_ST_FLAG_HDR_ENABLE)
|
||||
{
|
||||
if(d3d12->shader_preset && d3d12->shader_preset->passes && (d3d12->pass[d3d12->shader_preset->passes - 1].semantics.format == SLANG_FORMAT_A2B10G10R10_UNORM_PACK32))
|
||||
if (d3d12->shader_preset && d3d12->shader_preset->passes && (d3d12->pass[d3d12->shader_preset->passes - 1].semantics.format == SLANG_FORMAT_A2B10G10R10_UNORM_PACK32))
|
||||
{
|
||||
/* If the last shader pass uses a RGB10A2 back buffer and hdr has been enabled assume we want to skip the inverse tonemapper and hdr10 conversion */
|
||||
d3d12_set_hdr_inverse_tonemap(d3d12, false);
|
||||
d3d12_set_hdr10(d3d12, false);
|
||||
d3d12->resize_chain = true;
|
||||
d3d12->flags |= D3D12_ST_FLAG_RESIZE_CHAIN;
|
||||
}
|
||||
else if(d3d12->shader_preset && d3d12->shader_preset->passes && (d3d12->pass[d3d12->shader_preset->passes - 1].semantics.format == SLANG_FORMAT_R16G16B16A16_SFLOAT))
|
||||
else if (d3d12->shader_preset && d3d12->shader_preset->passes && (d3d12->pass[d3d12->shader_preset->passes - 1].semantics.format == SLANG_FORMAT_R16G16B16A16_SFLOAT))
|
||||
{
|
||||
/* If the last shader pass uses a RGBA16 back buffer and hdr has been enabled assume we want to skip the inverse tonemapper */
|
||||
d3d12_set_hdr_inverse_tonemap(d3d12, false);
|
||||
d3d12_set_hdr10(d3d12, true);
|
||||
d3d12->resize_chain = true;
|
||||
d3d12->flags |= D3D12_ST_FLAG_RESIZE_CHAIN;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -808,9 +815,8 @@ static bool d3d12_gfx_set_shader(void* data, enum rarch_shader_type type, const
|
||||
image_texture_free(&image);
|
||||
}
|
||||
|
||||
d3d12->resize_render_targets = true;
|
||||
d3d12->init_history = true;
|
||||
|
||||
d3d12->flags |= (D3D12_ST_FLAG_INIT_HISTORY
|
||||
| D3D12_ST_FLAG_RESIZE_RTS);
|
||||
return true;
|
||||
|
||||
error:
|
||||
@ -1225,13 +1231,16 @@ static bool d3d12_init_swapchain(d3d12_video_t* d3d12,
|
||||
d3d12->chain.formats[DXGI_SWAPCHAIN_BIT_DEPTH_10] = DXGI_FORMAT_R10G10B10A2_UNORM;
|
||||
d3d12->chain.formats[DXGI_SWAPCHAIN_BIT_DEPTH_16] = DXGI_FORMAT_R16G16B16A16_UNORM;
|
||||
|
||||
if (!(d3d12->hdr.support =
|
||||
dxgi_check_display_hdr_support(d3d12->factory, hwnd)))
|
||||
d3d12->hdr.enable = false;
|
||||
if (dxgi_check_display_hdr_support(d3d12->factory, hwnd))
|
||||
d3d12->flags |= D3D12_ST_FLAG_HDR_SUPPORT;
|
||||
else
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_HDR_SUPPORT;
|
||||
|
||||
d3d12->chain.bit_depth = d3d12->hdr.enable
|
||||
? DXGI_SWAPCHAIN_BIT_DEPTH_10
|
||||
: DXGI_SWAPCHAIN_BIT_DEPTH_8;
|
||||
if (!(d3d12->flags & D3D12_ST_FLAG_HDR_SUPPORT))
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_HDR_ENABLE;
|
||||
|
||||
d3d12->chain.bit_depth = (d3d12->flags & D3D12_ST_FLAG_HDR_ENABLE)
|
||||
? DXGI_SWAPCHAIN_BIT_DEPTH_10 : DXGI_SWAPCHAIN_BIT_DEPTH_8;
|
||||
#endif
|
||||
|
||||
desc.BufferCount = countof(d3d12->chain.renderTargets);
|
||||
@ -1268,7 +1277,7 @@ static bool d3d12_init_swapchain(d3d12_video_t* d3d12,
|
||||
#endif
|
||||
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;
|
||||
if (d3d12->chain.waitable_swapchains)
|
||||
if (d3d12->flags & D3D12_ST_FLAG_WAITABLE_SWAPCHAINS)
|
||||
desc.Flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
|
||||
|
||||
#ifdef __WINRT__
|
||||
@ -1282,8 +1291,8 @@ static bool d3d12_init_swapchain(d3d12_video_t* d3d12,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (d3d12->chain.waitable_swapchains &&
|
||||
(d3d12->chain.frameLatencyWaitableObject = DXGIGetFrameLatencyWaitableObject(d3d12->chain.handle)))
|
||||
if ( (d3d12->flags & D3D12_ST_FLAG_WAITABLE_SWAPCHAINS)
|
||||
&& (d3d12->chain.frameLatencyWaitableObject = DXGIGetFrameLatencyWaitableObject(d3d12->chain.handle)))
|
||||
{
|
||||
settings_t* settings = config_get_ptr();
|
||||
UINT max_latency = settings->uints.video_max_frame_latency;
|
||||
@ -1291,11 +1300,11 @@ static bool d3d12_init_swapchain(d3d12_video_t* d3d12,
|
||||
|
||||
if (max_latency == 0)
|
||||
{
|
||||
d3d12->chain.wait_for_vblank = true;
|
||||
d3d12->flags |= D3D12_ST_FLAG_WAIT_FOR_VBLANK;
|
||||
max_latency = 1;
|
||||
}
|
||||
else
|
||||
d3d12->chain.wait_for_vblank = false;
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_WAIT_FOR_VBLANK;
|
||||
|
||||
DXGISetMaximumFrameLatency(d3d12->chain.handle, max_latency);
|
||||
DXGIGetMaximumFrameLatency(d3d12->chain.handle, &cur_latency);
|
||||
@ -1312,7 +1321,7 @@ static bool d3d12_init_swapchain(d3d12_video_t* d3d12,
|
||||
initialize ST.2084 support to match
|
||||
the display's support. */
|
||||
color_space =
|
||||
d3d12->hdr.enable
|
||||
(d3d12->flags & D3D12_ST_FLAG_HDR_ENABLE)
|
||||
? DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
|
||||
: DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
|
||||
|
||||
@ -1320,7 +1329,7 @@ static bool d3d12_init_swapchain(d3d12_video_t* d3d12,
|
||||
&d3d12->chain.color_space, color_space);
|
||||
dxgi_set_hdr_metadata(
|
||||
d3d12->chain.handle,
|
||||
d3d12->hdr.support,
|
||||
d3d12->flags & D3D12_ST_FLAG_HDR_SUPPORT,
|
||||
d3d12->chain.bit_depth,
|
||||
d3d12->chain.color_space,
|
||||
d3d12->hdr.max_output_nits,
|
||||
@ -1778,14 +1787,20 @@ static void *d3d12_gfx_init(const video_info_t* video,
|
||||
}
|
||||
|
||||
#ifdef HAVE_DXGI_HDR
|
||||
d3d12->hdr.enable = settings->bools.video_hdr_enable;
|
||||
if (settings->bools.video_hdr_enable)
|
||||
d3d12->flags |= D3D12_ST_FLAG_HDR_ENABLE;
|
||||
else
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_HDR_ENABLE;
|
||||
d3d12->hdr.max_output_nits = settings->floats.video_hdr_max_nits;
|
||||
d3d12->hdr.min_output_nits = 0.001f;
|
||||
d3d12->hdr.max_cll = 0.0f;
|
||||
d3d12->hdr.max_fall = 0.0f;
|
||||
#endif
|
||||
|
||||
d3d12->chain.waitable_swapchains = settings->bools.video_waitable_swapchains;
|
||||
if (settings->bools.video_waitable_swapchains)
|
||||
d3d12->flags |= D3D12_ST_FLAG_WAITABLE_SWAPCHAINS;
|
||||
else
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_WAITABLE_SWAPCHAINS;
|
||||
|
||||
d3d_input_driver(settings->arrays.input_driver, settings->arrays.input_joypad_driver, input, input_data);
|
||||
|
||||
@ -1869,10 +1884,16 @@ static void *d3d12_gfx_init(const video_info_t* video,
|
||||
video_driver_set_size(d3d12->vp.full_width, d3d12->vp.full_height);
|
||||
d3d12->chain.viewport.Width = d3d12->vp.full_width;
|
||||
d3d12->chain.viewport.Height = d3d12->vp.full_height;
|
||||
d3d12->resize_viewport = true;
|
||||
d3d12->keep_aspect = video->force_aspect;
|
||||
d3d12->chain.vsync = video->vsync;
|
||||
d3d12->format = video->rgb32 ? DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM;
|
||||
d3d12->flags |= D3D12_ST_FLAG_RESIZE_VIEWPORT;
|
||||
if (video->force_aspect)
|
||||
d3d12->flags |= D3D12_ST_FLAG_KEEP_ASPECT;
|
||||
else
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_KEEP_ASPECT;
|
||||
if (video->vsync)
|
||||
d3d12->flags |= D3D12_ST_FLAG_VSYNC;
|
||||
else
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_VSYNC;
|
||||
d3d12->format = (video->rgb32) ? DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM;
|
||||
d3d12->frame.texture[0].desc.Format = d3d12->format;
|
||||
d3d12->frame.texture[0].desc.Width = 4;
|
||||
d3d12->frame.texture[0].desc.Height = 4;
|
||||
@ -1923,8 +1944,9 @@ static void d3d12_init_history(d3d12_video_t* d3d12, unsigned width, unsigned he
|
||||
d3d12_init_texture(d3d12->device, &d3d12->frame.texture[i]);
|
||||
/* TODO/FIXME: clear texture ? */
|
||||
}
|
||||
d3d12->init_history = false;
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_INIT_HISTORY;
|
||||
}
|
||||
|
||||
static void d3d12_init_render_targets(d3d12_video_t* d3d12, unsigned width, unsigned height)
|
||||
{
|
||||
unsigned i;
|
||||
@ -2024,7 +2046,7 @@ static void d3d12_init_render_targets(d3d12_video_t* d3d12, unsigned width, unsi
|
||||
d3d12->pass[i].sampler = d3d12->samplers[pass->filter][pass->wrap];
|
||||
}
|
||||
|
||||
d3d12->resize_render_targets = false;
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_RESIZE_RTS;
|
||||
}
|
||||
|
||||
static bool d3d12_gfx_frame(
|
||||
@ -2040,8 +2062,8 @@ static bool d3d12_gfx_frame(
|
||||
unsigned i;
|
||||
d3d12_texture_t* texture = NULL;
|
||||
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
|
||||
bool vsync = d3d12->chain.vsync;
|
||||
bool wait_for_vblank = d3d12->chain.wait_for_vblank;
|
||||
bool vsync = d3d12->flags & D3D12_ST_FLAG_VSYNC;
|
||||
bool wait_for_vblank = d3d12->flags & D3D12_ST_FLAG_WAIT_FOR_VBLANK;
|
||||
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;
|
||||
@ -2056,6 +2078,7 @@ static bool d3d12_gfx_frame(
|
||||
bool widgets_active = video_info->widgets_active;
|
||||
#endif
|
||||
#ifdef HAVE_DXGI_HDR
|
||||
bool d3d12_hdr_enable = false;
|
||||
bool video_hdr_enable = video_info->hdr_enable;
|
||||
DXGI_FORMAT back_buffer_format = d3d12->shader_preset && d3d12->shader_preset->passes ? glslang_format_to_dxgi(d3d12->pass[d3d12->shader_preset->passes - 1].semantics.format) : DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
bool use_back_buffer = back_buffer_format != d3d12->chain.formats[d3d12->chain.bit_depth];
|
||||
@ -2064,20 +2087,24 @@ static bool d3d12_gfx_frame(
|
||||
d3d12_gfx_sync(d3d12);
|
||||
|
||||
#ifdef HAVE_DXGI_HDR
|
||||
if (d3d12->resize_chain || (d3d12->hdr.enable != video_hdr_enable))
|
||||
d3d12_hdr_enable = d3d12->flags & D3D12_ST_FLAG_HDR_ENABLE;
|
||||
if ((d3d12->flags & D3D12_ST_FLAG_RESIZE_CHAIN) || (d3d12_hdr_enable != video_hdr_enable))
|
||||
#else
|
||||
if (d3d12->resize_chain)
|
||||
if (d3d12->flags & D3D12_ST_FLAG_RESIZE_CHAIN)
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_DXGI_HDR
|
||||
d3d12->hdr.enable = video_hdr_enable;
|
||||
if (video_hdr_enable)
|
||||
d3d12->flags |= D3D12_ST_FLAG_HDR_ENABLE;
|
||||
else
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_HDR_ENABLE;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < countof(d3d12->chain.renderTargets); i++)
|
||||
Release(d3d12->chain.renderTargets[i]);
|
||||
|
||||
#ifdef HAVE_DXGI_HDR
|
||||
if (d3d12->hdr.enable)
|
||||
if (d3d12->flags & D3D12_ST_FLAG_HDR_ENABLE)
|
||||
{
|
||||
d3d12_release_texture(&d3d12->chain.back_buffer);
|
||||
d3d12->chain.back_buffer.handle = NULL;
|
||||
@ -2110,8 +2137,8 @@ static bool d3d12_gfx_frame(
|
||||
d3d12->chain.viewport.Height = video_height;
|
||||
d3d12->chain.scissorRect.right = video_width;
|
||||
d3d12->chain.scissorRect.bottom = video_height;
|
||||
d3d12->resize_chain = false;
|
||||
d3d12->resize_viewport = true;
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_RESIZE_CHAIN;
|
||||
d3d12->flags |= D3D12_ST_FLAG_RESIZE_VIEWPORT;
|
||||
|
||||
d3d12->ubo_values.OutputSize.width = d3d12->chain.viewport.Width;
|
||||
d3d12->ubo_values.OutputSize.height = d3d12->chain.viewport.Height;
|
||||
@ -2120,16 +2147,22 @@ static bool d3d12_gfx_frame(
|
||||
|
||||
#ifdef HAVE_DXGI_HDR
|
||||
#ifdef __WINRT__
|
||||
if (!(d3d12->hdr.support =
|
||||
dxgi_check_display_hdr_support(d3d12->factory, uwp_get_corewindow())))
|
||||
d3d12->hdr.enable = false;
|
||||
if (dxgi_check_display_hdr_support(d3d12->factory, uwp_get_corewindow()))
|
||||
d3d12->flags |= D3D12_ST_FLAG_HDR_SUPPORT;
|
||||
else
|
||||
d3d12->flags &= ~(D3D12_ST_FLAG_HDR_SUPPORT
|
||||
| D3D12_ST_FLAG_HDR_ENABLE
|
||||
);
|
||||
#else
|
||||
if (!(d3d12->hdr.support =
|
||||
dxgi_check_display_hdr_support(d3d12->factory, main_window.hwnd)))
|
||||
d3d12->hdr.enable = false;
|
||||
if (dxgi_check_display_hdr_support(d3d12->factory, main_window.hwnd))
|
||||
d3d12->flags |= D3D12_ST_FLAG_HDR_SUPPORT;
|
||||
else
|
||||
d3d12->flags &= ~(D3D12_ST_FLAG_HDR_SUPPORT
|
||||
| D3D12_ST_FLAG_HDR_ENABLE
|
||||
);
|
||||
#endif
|
||||
|
||||
if(d3d12->hdr.enable)
|
||||
if (d3d12->flags & D3D12_ST_FLAG_HDR_ENABLE)
|
||||
{
|
||||
memset(&d3d12->chain.back_buffer,
|
||||
0, sizeof(d3d12->chain.back_buffer));
|
||||
@ -2163,7 +2196,7 @@ static bool d3d12_gfx_frame(
|
||||
|
||||
dxgi_set_hdr_metadata(
|
||||
d3d12->chain.handle,
|
||||
d3d12->hdr.support,
|
||||
d3d12->flags & D3D12_ST_FLAG_HDR_SUPPORT,
|
||||
d3d12->chain.bit_depth,
|
||||
d3d12->chain.color_space,
|
||||
d3d12->hdr.max_output_nits,
|
||||
@ -2172,7 +2205,7 @@ static bool d3d12_gfx_frame(
|
||||
d3d12->hdr.max_fall);
|
||||
#endif
|
||||
}
|
||||
else if (d3d12->chain.waitable_swapchains)
|
||||
else if (d3d12->flags & D3D12_ST_FLAG_WAITABLE_SWAPCHAINS)
|
||||
{
|
||||
WaitForSingleObjectEx(
|
||||
d3d12->chain.frameLatencyWaitableObject,
|
||||
@ -2212,11 +2245,11 @@ static bool d3d12_gfx_frame(
|
||||
d3d12_upload_texture(d3d12->queue.cmd, &d3d12->luts[i],
|
||||
d3d12);
|
||||
|
||||
if (d3d12->frame.texture[0].desc.Width != width ||
|
||||
d3d12->frame.texture[0].desc.Height != height)
|
||||
d3d12->resize_render_targets = true;
|
||||
if ( (d3d12->frame.texture[0].desc.Width != width)
|
||||
|| (d3d12->frame.texture[0].desc.Height != height))
|
||||
d3d12->flags |= D3D12_ST_FLAG_RESIZE_RTS;
|
||||
|
||||
if (d3d12->resize_render_targets)
|
||||
if (d3d12->flags & D3D12_ST_FLAG_RESIZE_RTS)
|
||||
{
|
||||
/* Release all render targets first
|
||||
to avoid memory fragmentation */
|
||||
@ -2231,7 +2264,7 @@ static bool d3d12_gfx_frame(
|
||||
|
||||
if (d3d12->shader_preset->history_size)
|
||||
{
|
||||
if (d3d12->init_history)
|
||||
if (d3d12->flags & D3D12_ST_FLAG_INIT_HISTORY)
|
||||
d3d12_init_history(d3d12, width, height);
|
||||
else
|
||||
{
|
||||
@ -2259,7 +2292,7 @@ static bool d3d12_gfx_frame(
|
||||
d3d12_init_texture(d3d12->device, &d3d12->frame.texture[0]);
|
||||
}
|
||||
|
||||
if (d3d12->resize_render_targets)
|
||||
if (d3d12->flags & D3D12_ST_FLAG_RESIZE_RTS)
|
||||
d3d12_init_render_targets(d3d12, width, height);
|
||||
|
||||
d3d12_update_texture(width, height, pitch, d3d12->format,
|
||||
@ -2473,7 +2506,7 @@ static bool d3d12_gfx_frame(
|
||||
d3d12->chain.handle);
|
||||
|
||||
#ifdef HAVE_DXGI_HDR
|
||||
if(d3d12->hdr.enable && use_back_buffer)
|
||||
if ((d3d12->flags & D3D12_ST_FLAG_HDR_ENABLE) && use_back_buffer)
|
||||
{
|
||||
d3d12_resource_transition(
|
||||
d3d12->queue.cmd, d3d12->chain.back_buffer.handle,
|
||||
@ -2521,7 +2554,8 @@ static bool d3d12_gfx_frame(
|
||||
d3d12->pipes[VIDEO_SHADER_STOCK_BLEND]);
|
||||
D3D12SetGraphicsRootSignature(d3d12->queue.cmd, d3d12->desc.rootSignature);
|
||||
|
||||
if (d3d12->menu.enabled && d3d12->menu.texture.handle)
|
||||
if ( (d3d12->flags & D3D12_ST_FLAG_MENU_ENABLE)
|
||||
&& d3d12->menu.texture.handle)
|
||||
{
|
||||
if (d3d12->menu.texture.dirty)
|
||||
d3d12_upload_texture(d3d12->queue.cmd, &d3d12->menu.texture,
|
||||
@ -2530,7 +2564,7 @@ static bool d3d12_gfx_frame(
|
||||
D3D12SetGraphicsRootConstantBufferView(
|
||||
d3d12->queue.cmd, ROOT_ID_UBO, d3d12->ubo_view.BufferLocation);
|
||||
|
||||
if (d3d12->menu.fullscreen)
|
||||
if (d3d12->flags & D3D12_ST_FLAG_MENU_FULLSCREEN)
|
||||
{
|
||||
D3D12RSSetViewports(d3d12->queue.cmd, 1, &d3d12->chain.viewport);
|
||||
D3D12RSSetScissorRects(d3d12->queue.cmd, 1, &d3d12->chain.scissorRect);
|
||||
@ -2546,16 +2580,16 @@ static bool d3d12_gfx_frame(
|
||||
D3D12IASetPrimitiveTopology(d3d12->queue.cmd,
|
||||
D3D_PRIMITIVE_TOPOLOGY_POINTLIST);
|
||||
|
||||
d3d12->sprites.enabled = true;
|
||||
d3d12->flags |= D3D12_ST_FLAG_SPRITES_ENABLE;
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (d3d12->overlays.enabled && overlay_behind_menu)
|
||||
if ((d3d12->flags & D3D12_ST_FLAG_OVERLAYS_ENABLE) && overlay_behind_menu)
|
||||
d3d12_render_overlay(d3d12);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
#ifndef HAVE_GFX_WIDGETS
|
||||
if (d3d12->menu.enabled)
|
||||
if (d3d12->flags & D3D12_ST_FLAG_MENU_ENABLE)
|
||||
#endif
|
||||
{
|
||||
D3D12RSSetViewports(d3d12->queue.cmd, 1,
|
||||
@ -2568,7 +2602,7 @@ static bool d3d12_gfx_frame(
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (d3d12->menu.enabled)
|
||||
if (d3d12->flags & D3D12_ST_FLAG_MENU_ENABLE)
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
else
|
||||
#endif
|
||||
@ -2589,7 +2623,7 @@ static bool d3d12_gfx_frame(
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (d3d12->overlays.enabled && !overlay_behind_menu)
|
||||
if ((d3d12->flags & D3D12_ST_FLAG_OVERLAYS_ENABLE) && !overlay_behind_menu)
|
||||
d3d12_render_overlay(d3d12);
|
||||
#endif
|
||||
|
||||
@ -2611,11 +2645,11 @@ static bool d3d12_gfx_frame(
|
||||
|
||||
font_driver_render_msg(d3d12, msg, NULL, NULL);
|
||||
}
|
||||
d3d12->sprites.enabled = false;
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_SPRITES_ENABLE;
|
||||
|
||||
#ifdef HAVE_DXGI_HDR
|
||||
/* Copy over back buffer to swap chain render targets */
|
||||
if (d3d12->hdr.enable && use_back_buffer)
|
||||
if ((d3d12->flags & D3D12_ST_FLAG_HDR_ENABLE) && use_back_buffer)
|
||||
{
|
||||
d3d12_resource_transition(
|
||||
d3d12->queue.cmd,
|
||||
@ -2693,24 +2727,33 @@ static void d3d12_gfx_set_nonblock_state(void* data, bool toggle,
|
||||
unsigned swap_interval)
|
||||
{
|
||||
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
|
||||
d3d12->chain.vsync = !toggle;
|
||||
if (toggle)
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_VSYNC;
|
||||
else
|
||||
d3d12->flags |= D3D12_ST_FLAG_VSYNC;
|
||||
d3d12->chain.swap_interval = swap_interval;
|
||||
}
|
||||
|
||||
static bool d3d12_gfx_alive(void* data)
|
||||
{
|
||||
bool quit;
|
||||
bool resize_chain = false;
|
||||
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
|
||||
|
||||
win32_check_window(NULL,
|
||||
&quit,
|
||||
&d3d12->resize_chain,
|
||||
&resize_chain,
|
||||
&d3d12->vp.full_width,
|
||||
&d3d12->vp.full_height);
|
||||
|
||||
if ( d3d12->resize_chain
|
||||
&& d3d12->vp.full_width != 0
|
||||
&& d3d12->vp.full_height != 0)
|
||||
if (resize_chain)
|
||||
d3d12->flags |= D3D12_ST_FLAG_RESIZE_CHAIN;
|
||||
else
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_RESIZE_CHAIN;
|
||||
|
||||
if ( (d3d12->flags & D3D12_ST_FLAG_RESIZE_CHAIN)
|
||||
&& (d3d12->vp.full_width != 0)
|
||||
&& (d3d12->vp.full_height != 0))
|
||||
video_driver_set_size(d3d12->vp.full_width, d3d12->vp.full_height);
|
||||
|
||||
return !quit;
|
||||
@ -2784,35 +2827,36 @@ static void d3d12_set_menu_texture_frame(
|
||||
}
|
||||
|
||||
static void d3d12_set_menu_texture_enable(void* data,
|
||||
bool state, bool full_screen)
|
||||
bool state, bool fullscreen)
|
||||
{
|
||||
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
|
||||
|
||||
if (!d3d12)
|
||||
return;
|
||||
|
||||
d3d12->menu.enabled = state;
|
||||
d3d12->menu.fullscreen = full_screen;
|
||||
if (state)
|
||||
d3d12->flags |= D3D12_ST_FLAG_MENU_ENABLE;
|
||||
else
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_MENU_ENABLE;
|
||||
if (fullscreen)
|
||||
d3d12->flags |= D3D12_ST_FLAG_MENU_FULLSCREEN;
|
||||
else
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_MENU_FULLSCREEN;
|
||||
}
|
||||
|
||||
static void d3d12_gfx_set_aspect_ratio(
|
||||
void* data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
|
||||
|
||||
if (!d3d12)
|
||||
return;
|
||||
|
||||
d3d12->keep_aspect = true;
|
||||
d3d12->resize_viewport = true;
|
||||
if (d3d12)
|
||||
d3d12->flags |= D3D12_ST_FLAG_KEEP_ASPECT | D3D12_ST_FLAG_RESIZE_VIEWPORT;
|
||||
}
|
||||
|
||||
static void d3d12_gfx_apply_state_changes(void* data)
|
||||
{
|
||||
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
|
||||
|
||||
if (d3d12)
|
||||
d3d12->resize_viewport = true;
|
||||
d3d12->flags |= D3D12_ST_FLAG_RESIZE_VIEWPORT;
|
||||
}
|
||||
|
||||
static void d3d12_gfx_set_osd_msg(
|
||||
@ -2822,12 +2866,9 @@ static void d3d12_gfx_set_osd_msg(
|
||||
void* font)
|
||||
{
|
||||
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
|
||||
|
||||
if (!d3d12 || !d3d12->sprites.enabled)
|
||||
return;
|
||||
|
||||
font_driver_render_msg(d3d12, msg,
|
||||
(const struct font_params*)params, font);
|
||||
if (d3d12 && (d3d12->flags & D3D12_ST_FLAG_SPRITES_ENABLE))
|
||||
font_driver_render_msg(d3d12, msg,
|
||||
(const struct font_params*)params, font);
|
||||
}
|
||||
|
||||
static uintptr_t d3d12_gfx_load_texture(
|
||||
|
@ -70,7 +70,8 @@ static void gfx_display_d3d12_draw(gfx_display_ctx_draw_t *draw,
|
||||
if (draw->coords->vertex && draw->coords->tex_coord && draw->coords->color)
|
||||
vertex_count = draw->coords->vertices;
|
||||
|
||||
if (!d3d12->sprites.enabled || vertex_count > d3d12->sprites.capacity)
|
||||
if ( (!(d3d12->flags & D3D12_ST_FLAG_SPRITES_ENABLE))
|
||||
|| (vertex_count > d3d12->sprites.capacity))
|
||||
return;
|
||||
|
||||
if (d3d12->sprites.offset + vertex_count > d3d12->sprites.capacity)
|
||||
|
@ -249,7 +249,7 @@ static void d3d12_font_render_message(
|
||||
|
||||
if (!msg || !*msg)
|
||||
return;
|
||||
if (!d3d12 || !d3d12->sprites.enabled)
|
||||
if (!d3d12 || (!(d3d12->flags & D3D12_ST_FLAG_SPRITES_ENABLE)))
|
||||
return;
|
||||
|
||||
/* If font line metrics are not supported just draw as usual */
|
||||
|
Loading…
x
Reference in New Issue
Block a user