Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/doitsujin/dxvk.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Ashton <joshua@froggi.es>2023-01-06 17:41:30 +0300
committerJoshua Ashton <joshua@froggi.es>2023-01-06 17:45:55 +0300
commit11b98bad52b2b22de3a940d268b17cbe9d4a19ae (patch)
treed7ccd76d4f77a9184997a6803cbe78acf26bc722
parent170c493ada9eb97ff65ef8650a131eb8167071d1 (diff)
[dxgi] Add dxgi.enableHDR optionjosh-hdr-test
-rw-r--r--dxvk.conf12
-rw-r--r--src/dxgi/dxgi_factory.cpp2
-rw-r--r--src/dxgi/dxgi_monitor.cpp7
-rw-r--r--src/dxgi/dxgi_monitor.h6
-rw-r--r--src/dxgi/dxgi_options.cpp2
-rw-r--r--src/dxgi/dxgi_options.h3
-rw-r--r--src/dxgi/dxgi_output.cpp6
7 files changed, 29 insertions, 9 deletions
diff --git a/dxvk.conf b/dxvk.conf
index 5c274652..b5635a6e 100644
--- a/dxvk.conf
+++ b/dxvk.conf
@@ -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,
diff --git a/src/dxgi/dxgi_factory.cpp b/src/dxgi/dxgi_factory.cpp
index c7f3c302..cd548db5 100644
--- a/src/dxgi/dxgi_factory.cpp
+++ b/src/dxgi/dxgi_factory.cpp
@@ -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();
diff --git a/src/dxgi/dxgi_monitor.cpp b/src/dxgi/dxgi_monitor.cpp
index c0e25a7a..0cac3c45 100644
--- a/src/dxgi/dxgi_monitor.cpp
+++ b/src/dxgi/dxgi_monitor.cpp
@@ -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;
}
diff --git a/src/dxgi/dxgi_monitor.h b/src/dxgi/dxgi_monitor.h
index 4ab6c1b3..3a31a23c 100644
--- a/src/dxgi/dxgi_monitor.h
+++ b/src/dxgi/dxgi_monitor.h
@@ -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;
diff --git a/src/dxgi/dxgi_options.cpp b/src/dxgi/dxgi_options.cpp
index 469692d1..1d9c9614 100644
--- a/src/dxgi/dxgi_options.cpp
+++ b/src/dxgi/dxgi_options.cpp
@@ -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");
}
}
diff --git a/src/dxgi/dxgi_options.h b/src/dxgi/dxgi_options.h
index 8eb19d08..02f5c323 100644
--- a/src/dxgi/dxgi_options.h
+++ b/src/dxgi/dxgi_options.h
@@ -35,6 +35,9 @@ namespace dxvk {
/// Enables nvapi workaround
bool nvapiHack;
+
+ /// Enable HDR
+ bool enableHDR;
};
}
diff --git a/src/dxgi/dxgi_output.cpp b/src/dxgi/dxgi_output.cpp
index 1ad9b49e..f1787bb7 100644
--- a/src/dxgi/dxgi_output.cpp
+++ b/src/dxgi/dxgi_output.cpp
@@ -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 };