1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 10:54:16 +01:00

[dxgi] Add dxgi.enableHDR option

This commit is contained in:
Joshua Ashton 2023-01-06 14:41:30 +00:00 committed by Philip Rebohle
parent 3375cdf1fa
commit c10b53ed3e
7 changed files with 29 additions and 9 deletions

View File

@ -1,3 +1,15 @@
# Expose the HDR10 ColorSpace (DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020)
# to the application by default.
# This shows to the game that the global Windows 'HDR Mode' is enabled.
# Many (broken) games will need this to be set to consider exposing HDR output
# as determine it based on the DXGIOutput's current ColorSpace instead of
# using CheckColorSpaceSupport.
# This defaults to the value of the DXVK_HDR environment variable.
#
# Supported values: True, False
# dxgi.enableHDR = True
# Create the VkSurface on the first call to IDXGISwapChain::Present,
# rather than when creating the swap chain. Some games that start
# rendering with a different graphics API may require this option,

View File

@ -8,7 +8,7 @@ namespace dxvk {
DxgiFactory::DxgiFactory(UINT Flags)
: m_instance (new DxvkInstance()),
m_options (m_instance->config()),
m_monitorInfo (this),
m_monitorInfo (this, m_options),
m_flags (Flags) {
for (uint32_t i = 0; m_instance->enumAdapters(i) != nullptr; i++)
m_instance->enumAdapters(i)->logAdapterInfo();

View File

@ -2,8 +2,9 @@
namespace dxvk {
DxgiMonitorInfo::DxgiMonitorInfo(IUnknown* pParent)
DxgiMonitorInfo::DxgiMonitorInfo(IUnknown* pParent, const DxgiOptions& options)
: m_parent(pParent)
, m_options(options)
, m_globalColorSpace(DefaultColorSpace()) {
}
@ -80,8 +81,8 @@ namespace dxvk {
}
DXGI_COLOR_SPACE_TYPE DxgiMonitorInfo::DefaultColorSpace() {
return env::getEnvVar("DXVK_HDR") == "1"
DXGI_COLOR_SPACE_TYPE DxgiMonitorInfo::DefaultColorSpace() const {
return m_options.enableHDR
? DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
: DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
}

View File

@ -4,6 +4,7 @@
#include <unordered_map>
#include "dxgi_interfaces.h"
#include "dxgi_options.h"
#include "../wsi/wsi_monitor.h"
@ -15,7 +16,7 @@ namespace dxvk {
public:
DxgiMonitorInfo(IUnknown* pParent);
DxgiMonitorInfo(IUnknown* pParent, const DxgiOptions& options);
~DxgiMonitorInfo();
@ -41,11 +42,12 @@ namespace dxvk {
DXGI_COLOR_SPACE_TYPE STDMETHODCALLTYPE CurrentColorSpace() const;
static DXGI_COLOR_SPACE_TYPE DefaultColorSpace();
DXGI_COLOR_SPACE_TYPE DefaultColorSpace() const;
private:
IUnknown* m_parent;
const DxgiOptions& m_options;
dxvk::mutex m_monitorMutex;
std::unordered_map<HMONITOR, DXGI_VK_MONITOR_DATA> m_monitorData;

View File

@ -45,6 +45,8 @@ namespace dxvk {
this->nvapiHack = false;
else
this->nvapiHack = config.getOption<bool>("dxgi.nvapiHack", true);
this->enableHDR = config.getOption<bool>("dxgi.enableHDR", env::getEnvVar("DXVK_HDR") == "1");
}
}

View File

@ -35,6 +35,9 @@ namespace dxvk {
/// Enables nvapi workaround
bool nvapiHack;
/// Enable HDR
bool enableHDR;
};
}

View File

@ -20,7 +20,7 @@
namespace dxvk {
static void NormalizeDisplayMetadata(wsi::WsiDisplayMetadata& metadata) {
static void NormalizeDisplayMetadata(const DxgiMonitorInfo *pMonitorInfo, wsi::WsiDisplayMetadata& metadata) {
// Use some dummy info when we have no hdr static metadata for the
// display or we were unable to obtain an EDID.
//
@ -49,7 +49,7 @@ namespace dxvk {
&& metadata.greenPrimary[0] == 0.0f && metadata.greenPrimary[1] == 0.0f
&& metadata.bluePrimary[0] == 0.0f && metadata.bluePrimary[1] == 0.0f
&& metadata.whitePoint[0] == 0.0f && metadata.whitePoint[1] == 0.0f) {
if (DxgiMonitorInfo::DefaultColorSpace() == DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709) {
if (pMonitorInfo->DefaultColorSpace() == DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709) {
// sRGB ColorSpace -> Rec.709 Primaries
metadata.redPrimary[0] = 0.640f;
metadata.redPrimary[1] = 0.330f;
@ -722,7 +722,7 @@ namespace dxvk {
// Normalize either the display metadata we got back, or our
// blank one to get something sane here.
NormalizeDisplayMetadata(m_metadata);
NormalizeDisplayMetadata(m_monitorInfo, m_metadata);
monitorData.FrameStats.SyncQPCTime.QuadPart = dxvk::high_resolution_clock::get_counter();
monitorData.GammaCurve.Scale = { 1.0f, 1.0f, 1.0f };