diff --git a/libobs-d3d11/d3d11-subsystem.cpp b/libobs-d3d11/d3d11-subsystem.cpp index 15815a9b2..567d883ad 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp +++ b/libobs-d3d11/d3d11-subsystem.cpp @@ -1310,6 +1310,12 @@ static void PopulateMonitorIds(HMONITOR handle, char *id, char *alt_id, } } +static constexpr double DoubleTriangleArea(double ax, double ay, double bx, + double by, double cx, double cy) +{ + return ax * (by - cy) + bx * (cy - ay) + cx * (ay - by); +} + static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter) { UINT i; @@ -1351,6 +1357,8 @@ static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter) UINT bits_per_color = 8; DXGI_COLOR_SPACE_TYPE type = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709; + FLOAT primaries[4][2]{}; + double gamut_size = 0.; FLOAT min_luminance = 0.f; FLOAT max_luminance = 0.f; FLOAT max_full_frame_luminance = 0.f; @@ -1358,6 +1366,18 @@ static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter) if (GetOutputDesc1(output, &desc1)) { bits_per_color = desc1.BitsPerColor; type = desc1.ColorSpace; + primaries[0][0] = desc1.RedPrimary[0]; + primaries[0][1] = desc1.RedPrimary[1]; + primaries[1][0] = desc1.GreenPrimary[0]; + primaries[1][1] = desc1.GreenPrimary[1]; + primaries[2][0] = desc1.BluePrimary[0]; + primaries[2][1] = desc1.BluePrimary[1]; + primaries[3][0] = desc1.WhitePoint[0]; + primaries[3][1] = desc1.WhitePoint[1]; + gamut_size = DoubleTriangleArea( + desc1.RedPrimary[0], desc1.RedPrimary[1], + desc1.GreenPrimary[0], desc1.GreenPrimary[1], + desc1.BluePrimary[0], desc1.BluePrimary[1]); min_luminance = desc1.MinLuminance; max_luminance = desc1.MaxLuminance; max_full_frame_luminance = desc1.MaxFullFrameLuminance; @@ -1388,7 +1408,7 @@ static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter) } const RECT &rect = desc.DesktopCoordinates; - const ULONG nits = GetSdrMaxNits(desc.Monitor); + const ULONG sdr_white_nits = GetSdrMaxNits(desc.Monitor); char *friendly_name; os_wcs_to_utf8_ptr(target.monitorFriendlyDeviceName, 0, @@ -1403,6 +1423,8 @@ static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter) "\t refresh=%u\n" "\t bits_per_color=%u\n" "\t space=%s\n" + "\t primaries=[r=(%f, %f), g=(%f, %f), b=(%f, %f), wp=(%f, %f)]\n" + "\t relative_gamut_area=[709=%f, P3=%f, 2020=%f]\n" "\t sdr_white_nits=%lu\n" "\t nit_range=[min=%f, max=%f, max_full_frame=%f]\n" "\t dpi=%u (%u%%)\n" @@ -1411,7 +1433,16 @@ static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter) i, friendly_name, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, desc.AttachedToDesktop ? "true" : "false", refresh, - bits_per_color, space, nits, min_luminance, max_luminance, + bits_per_color, space, primaries[0][0], primaries[0][1], + primaries[1][0], primaries[1][1], primaries[2][0], + primaries[2][1], primaries[3][0], primaries[3][1], + gamut_size / + DoubleTriangleArea(.64, .33, .3, .6, .15, .06), + gamut_size / + DoubleTriangleArea(.68, .32, .265, .69, .15, .060), + gamut_size / DoubleTriangleArea(.708, .292, .17, .797, + .131, .046), + sdr_white_nits, min_luminance, max_luminance, max_full_frame_luminance, dpiX, scaling, id, alt_id); bfree(friendly_name); }