Skip to content

Commit 333e39f

Browse files
Major update to the HDR system of RetroArch (#18616)
* Major update to the HDR system of RetroArch * Fix compilation error in SPIRV enabled versions of d3d12 * Fixed incorrect comment syntax for linux builds etc
1 parent 59e4fc7 commit 333e39f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3463
-1387
lines changed

config.def.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,14 @@
505505
/* The number of nits that paper white is at */
506506
#define DEFAULT_VIDEO_HDR_PAPER_WHITE_NITS 200.0f
507507

508-
/* The contrast setting for hdr used to calculate the display gamma by dividing this value by gamma 2.2 */
509-
#define DEFAULT_VIDEO_HDR_CONTRAST 5.0f
510-
511508
/* Should we expand the colour gamut when using hdr */
512-
#define DEFAULT_VIDEO_HDR_EXPAND_GAMUT true
509+
#define DEFAULT_VIDEO_HDR_EXPAND_GAMUT false
510+
511+
/* Enable a basic HDR scanline implementation which is the main reason for using HDR in RetroArch */
512+
#define DEFAULT_VIDEO_HDR_SCANLINES true
513+
514+
/* Default to the largely standard RGB layout */
515+
#define DEFAULT_VIDEO_HDR_SUBPIXEL_LAYOUT 0
513516

514517
/* When presets are saved they will be saved using the #reference
515518
* directive by default */

configuration.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1919,6 +1919,7 @@ static struct config_bool_setting *populate_settings_bool(
19191919
SETTING_BOOL("video_fullscreen", &settings->bools.video_fullscreen, true, DEFAULT_FULLSCREEN, false);
19201920
SETTING_BOOL("video_hdr_enable", &settings->bools.video_hdr_enable, true, DEFAULT_VIDEO_HDR_ENABLE, false);
19211921
SETTING_BOOL("video_hdr_expand_gamut", &settings->bools.video_hdr_expand_gamut, true, DEFAULT_VIDEO_HDR_EXPAND_GAMUT, false);
1922+
SETTING_BOOL("video_hdr_scanlines", &settings->bools.video_hdr_scanlines, true, DEFAULT_VIDEO_HDR_SCANLINES, false);
19221923
SETTING_BOOL("video_vsync", &settings->bools.video_vsync, true, DEFAULT_VSYNC, false);
19231924
SETTING_BOOL("video_adaptive_vsync", &settings->bools.video_adaptive_vsync, true, DEFAULT_ADAPTIVE_VSYNC, false);
19241925
SETTING_BOOL("video_hard_sync", &settings->bools.video_hard_sync, true, DEFAULT_HARD_SYNC, false);
@@ -2366,7 +2367,6 @@ static struct config_float_setting *populate_settings_float(
23662367
SETTING_FLOAT("video_msg_bgcolor_opacity", &settings->floats.video_msg_bgcolor_opacity, true, DEFAULT_MESSAGE_BGCOLOR_OPACITY, false);
23672368
SETTING_FLOAT("video_hdr_max_nits", &settings->floats.video_hdr_max_nits, true, DEFAULT_VIDEO_HDR_MAX_NITS, false);
23682369
SETTING_FLOAT("video_hdr_paper_white_nits", &settings->floats.video_hdr_paper_white_nits, true, DEFAULT_VIDEO_HDR_PAPER_WHITE_NITS, false);
2369-
SETTING_FLOAT("video_hdr_display_contrast", &settings->floats.video_hdr_display_contrast, true, DEFAULT_VIDEO_HDR_CONTRAST, false);
23702370

23712371
SETTING_FLOAT("input_axis_threshold", &settings->floats.input_axis_threshold, true, DEFAULT_AXIS_THRESHOLD, false);
23722372
SETTING_FLOAT("input_analog_deadzone", &settings->floats.input_analog_deadzone, true, DEFAULT_ANALOG_DEADZONE, false);
@@ -2558,6 +2558,7 @@ static struct config_uint_setting *populate_settings_uint(
25582558
SETTING_UINT("video_record_scale_factor", &settings->uints.video_record_scale_factor, true, 1, false);
25592559
SETTING_UINT("video_stream_scale_factor", &settings->uints.video_stream_scale_factor, true, 1, false);
25602560

2561+
SETTING_UINT("video_hdr_subpixel_layout", &settings->uints.video_hdr_subpixel_layout, true, DEFAULT_VIDEO_HDR_SUBPIXEL_LAYOUT, false);
25612562
#ifdef HAVE_NETWORKING
25622563
SETTING_UINT("streaming_mode", &settings->uints.streaming_mode, true, STREAMING_MODE_TWITCH, false);
25632564
#endif

configuration.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ typedef struct settings
382382
unsigned video_bfi_dark_frames;
383383
unsigned video_shader_subframes;
384384
unsigned video_autoswitch_refresh_rate;
385+
unsigned video_hdr_subpixel_layout;
386+
385387
unsigned quit_on_close_content;
386388

387389
#ifdef HAVE_LAKKA
@@ -426,7 +428,6 @@ typedef struct settings
426428
float video_msg_bgcolor_opacity;
427429
float video_hdr_max_nits;
428430
float video_hdr_paper_white_nits;
429-
float video_hdr_display_contrast;
430431

431432
float menu_scale_factor;
432433
float menu_widget_scale_factor;
@@ -688,6 +689,7 @@ typedef struct settings
688689
bool video_notch_write_over_enable;
689690
bool video_hdr_enable;
690691
bool video_hdr_expand_gamut;
692+
bool video_hdr_scanlines;
691693
bool video_use_metal_arg_buffers;
692694

693695
/* Accessibility */

gfx/common/dxgi_common.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,23 @@ RETRO_BEGIN_DECLS
2424
typedef struct ALIGN(16)
2525
{
2626
math_matrix_4x4 mvp;
27-
float contrast; /* 2.0f */
28-
float paper_white_nits; /* 200.0f */
29-
float max_nits; /* 1000.0f */
30-
float expand_gamut; /* 1.0f */
31-
float inverse_tonemap; /* 1.0f */
32-
float hdr10; /* 1.0f */
27+
struct
28+
{
29+
float width;
30+
float height;
31+
} source_size;
32+
struct
33+
{
34+
float width;
35+
float height;
36+
} output_size;
37+
float paper_white_nits; /* 200.0f */
38+
float max_nits; /* 1000.0f */
39+
unsigned subpixel_layout; /* 0 */
40+
float scanlines; /* 1.0f */
41+
float expand_gamut; /* 0.0f */
42+
float inverse_tonemap; /* 1.0f */
43+
float hdr10; /* 1.0f */
3344
} dxgi_hdr_uniform_t;
3445

3546
enum dxgi_swapchain_bit_depth

gfx/common/vulkan_common.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232
#define VULKAN_DIRTY_DYNAMIC_BIT 0x0001
3333

34-
#define VULKAN_HDR_SWAPCHAIN
35-
3634
#include "vksym.h"
3735

3836
#include <boolean.h>

gfx/drivers/caca_gfx.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,9 @@ static const video_poke_interface_t caca_poke_interface = {
418418
NULL, /* get_hw_render_interface */
419419
NULL, /* set_hdr_max_nits */
420420
NULL, /* set_hdr_paper_white_nits */
421-
NULL, /* set_hdr_contrast */
422-
NULL /* set_hdr_expand_gamut */
421+
NULL, /* set_hdr_expand_gamut */
422+
NULL, /* set_hdr_scanlines */
423+
NULL /* set_hdr_subpixel_layout */
423424
};
424425

425426
static void caca_get_poke_interface(void *data,

gfx/drivers/ctr_gfx.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,8 +2988,9 @@ static const video_poke_interface_t ctr_poke_interface = {
29882988
NULL, /* get_hw_render_interface */
29892989
NULL, /* set_hdr_max_nits */
29902990
NULL, /* set_hdr_paper_white_nits */
2991-
NULL, /* set_hdr_contrast */
2992-
NULL /* set_hdr_expand_gamut */
2991+
NULL, /* set_hdr_expand_gamut */
2992+
NULL, /* set_hdr_scanlines */
2993+
NULL /* set_hdr_subpixel_layout */
29932994
};
29942995

29952996
static void ctr_get_poke_interface(void* data,

gfx/drivers/d3d10.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3276,8 +3276,9 @@ static const video_poke_interface_t d3d10_poke_interface = {
32763276
#endif
32773277
NULL, /* set_hdr_max_nits */
32783278
NULL, /* set_hdr_paper_white_nits */
3279-
NULL, /* set_hdr_contrast */
3280-
NULL /* set_hdr_expand_gamut */
3279+
NULL, /* set_hdr_expand_gamut */
3280+
NULL, /* set_hdr_scanlines */
3281+
NULL /* set_hdr_subpixel_layout */
32813282
};
32823283

32833284
static void d3d10_gfx_get_poke_interface(void* data, const video_poke_interface_t** iface)

0 commit comments

Comments
 (0)