mirror of
https://github.com/VirtualDrivers/Virtual-Display-Driver.git
synced 2026-10-19 05:10:04 -05:00
Added support for changing colour format
- Added support for changing colour format in xml Supported formats: RGB YCbCr444 YCbCr422 YCbCr420 - XML Grouped
This commit is contained in:
1 parent
e4bc40252a
commit
e3f58b629a
2 files changed
+166
-24
No files matched your search
@@ -110,22 +110,28 @@ IDDCX_XOR_CURSOR_SUPPORT XorCursorSupportLevel = IDDCX_XOR_CURSOR_SUPPORT_FULL;
|
||||
IDDCX_BITS_PER_COMPONENT SDRCOLOUR = IDDCX_BITS_PER_COMPONENT_8;
|
||||
IDDCX_BITS_PER_COMPONENT HDRCOLOUR = IDDCX_BITS_PER_COMPONENT_10;
|
||||
|
||||
wstring ColourFormat = L"RGB";
|
||||
|
||||
std::map<std::wstring, std::pair<std::wstring, std::wstring>> SettingsQueryMap = {
|
||||
{L"LoggingEnabled", {L"LOGS", L"logging"}},
|
||||
{L"DebugLoggingEnabled", {L"DEBUGLOGS", L"debuglogging"}},
|
||||
{L"HDRPlusEnabled", {L"HDRPLUS", L"HDRPlus"}},
|
||||
{L"SDR10Enabled", {L"SDR10BIT", L"SDR10bit"}},
|
||||
{L"CustomEdidEnabled", {L"CUSTOMEDID", L"CustomEdid"}},
|
||||
{L"HardwareCursorEnabled", {L"HARDWARECURSOR", L"HardwareCursor"}},
|
||||
|
||||
{L"PreventMonitorSpoof", {L"PREVENTMONITORSPOOF", L"PreventSpoof"}},
|
||||
{L"EdidCeaOverride", {L"EDIDCEAOVERRIDE", L"EdidCeaOverride"}},
|
||||
{L"SendLogsThroughPipe", {L"SENDLOGSTHROUGHPIPE", L"SendLogsThroughPipe"}},
|
||||
//Cursor
|
||||
//Cursor Begin
|
||||
{L"HardwareCursorEnabled", {L"HARDWARECURSOR", L"HardwareCursor"}},
|
||||
{L"AlphaCursorSupport", {L"ALPHACURSORSUPPORT", L"AlphaCursorSupport"}},
|
||||
{L"CursorMaxX", {L"CURSORMAXX", L"CursorMaxX"}},
|
||||
{L"CursorMaxY", {L"CURSORMAXY", L"CursorMaxY"}},
|
||||
{L"XorCursorSupportLevel", {L"XORCURSORSUPPORTLEVEL", L"XorCursorSupportLevel"}},
|
||||
|
||||
///Cursor End
|
||||
//Colour Begin
|
||||
{L"HDRPlusEnabled", {L"HDRPLUS", L"HDRPlus"}},
|
||||
{L"SDR10Enabled", {L"SDR10BIT", L"SDR10bit"}},
|
||||
{L"ColourFormat", {L"COLOURFORMAT", L"ColourFormat"}},
|
||||
//Colour End
|
||||
};
|
||||
|
||||
const char* XorCursorSupportLevelToString(IDDCX_XOR_CURSOR_SUPPORT level) {
|
||||
@@ -167,6 +173,14 @@ void LogQueries(const char* severity, const std::wstring& xmlName) {
|
||||
}
|
||||
}
|
||||
|
||||
string WStringToString(const wstring& wstr) { //basically just a function for converting strings since codecvt is depricated in c++ 17
|
||||
if (wstr.empty()) return "";
|
||||
|
||||
int size_needed = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), (int)wstr.size(), NULL, 0, NULL, NULL);
|
||||
string str(size_needed, 0);
|
||||
WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), (int)wstr.size(), &str[0], size_needed, NULL, NULL);
|
||||
return str;
|
||||
}
|
||||
|
||||
bool EnabledQuery(const std::wstring& settingKey) {
|
||||
auto it = SettingsQueryMap.find(settingKey);
|
||||
@@ -351,16 +365,79 @@ int GetIntegerSetting(const std::wstring& settingKey) {
|
||||
return xmlLoggingValue;
|
||||
}
|
||||
|
||||
std::wstring GetStringSetting(const std::wstring& settingKey) {
|
||||
auto it = SettingsQueryMap.find(settingKey);
|
||||
if (it == SettingsQueryMap.end()) {
|
||||
vddlog("e", "requested data not found in xml, consider updating xml!");
|
||||
return L"";
|
||||
}
|
||||
|
||||
string WStringToString(const wstring& wstr) { //basically just a function for converting strings since codecvt is depricated in c++ 17
|
||||
if (wstr.empty()) return "";
|
||||
std::wstring regName = it->second.first;
|
||||
std::wstring xmlName = it->second.second;
|
||||
|
||||
int size_needed = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), (int)wstr.size(), NULL, 0, NULL, NULL);
|
||||
string str(size_needed, 0);
|
||||
WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), (int)wstr.size(), &str[0], size_needed, NULL, NULL);
|
||||
return str;
|
||||
std::wstring settingsname = confpath + L"\\vdd_settings.xml";
|
||||
HKEY hKey;
|
||||
DWORD dwBufferSize = MAX_PATH;
|
||||
wchar_t buffer[MAX_PATH];
|
||||
|
||||
LONG lResult = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\MikeTheTech\\VirtualDisplayDriver", 0, KEY_READ, &hKey);
|
||||
if (lResult == ERROR_SUCCESS) {
|
||||
lResult = RegQueryValueExW(hKey, regName.c_str(), NULL, NULL, (LPBYTE)buffer, &dwBufferSize);
|
||||
RegCloseKey(hKey);
|
||||
|
||||
if (lResult == ERROR_SUCCESS) {
|
||||
LogQueries("d", xmlName + L" - Retrieved string value from registry: " + buffer);
|
||||
return std::wstring(buffer);
|
||||
}
|
||||
else {
|
||||
LogQueries("d", xmlName + L" - Failed to retrieve string value from registry. Attempting to read as XML.");
|
||||
}
|
||||
}
|
||||
|
||||
CComPtr<IStream> pFileStream;
|
||||
HRESULT hr = SHCreateStreamOnFileEx(settingsname.c_str(), STGM_READ, FILE_ATTRIBUTE_NORMAL, FALSE, nullptr, &pFileStream);
|
||||
if (FAILED(hr)) {
|
||||
LogQueries("d", xmlName + L" - Failed to create file stream for XML settings.");
|
||||
return L"";
|
||||
}
|
||||
|
||||
CComPtr<IXmlReader> pReader;
|
||||
hr = CreateXmlReader(__uuidof(IXmlReader), (void**)&pReader, nullptr);
|
||||
if (FAILED(hr)) {
|
||||
LogQueries("d", xmlName + L" - Failed to create XML reader.");
|
||||
return L"";
|
||||
}
|
||||
|
||||
hr = pReader->SetInput(pFileStream);
|
||||
if (FAILED(hr)) {
|
||||
LogQueries("d", xmlName + L" - Failed to set input for XML reader.");
|
||||
return L"";
|
||||
}
|
||||
|
||||
XmlNodeType nodeType;
|
||||
const wchar_t* pwszLocalName;
|
||||
std::wstring xmlLoggingValue = L"";
|
||||
|
||||
while (S_OK == pReader->Read(&nodeType)) {
|
||||
if (nodeType == XmlNodeType_Element) {
|
||||
pReader->GetLocalName(&pwszLocalName, nullptr);
|
||||
if (wcscmp(pwszLocalName, xmlName.c_str()) == 0) {
|
||||
pReader->Read(&nodeType);
|
||||
if (nodeType == XmlNodeType_Text) {
|
||||
const wchar_t* pwszValue;
|
||||
pReader->GetValue(&pwszValue, nullptr);
|
||||
xmlLoggingValue = pwszValue;
|
||||
LogQueries("i", xmlName + L" - Retrieved from XML: " + xmlLoggingValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return xmlLoggingValue;
|
||||
}
|
||||
|
||||
|
||||
int gcd(int a, int b) {
|
||||
while (b != 0) {
|
||||
int temp = b;
|
||||
@@ -1346,16 +1423,20 @@ extern "C" NTSTATUS DriverEntry(
|
||||
initpath();
|
||||
logsEnabled = EnabledQuery(L"LoggingEnabled");
|
||||
debugLogs = EnabledQuery(L"DebugLoggingEnabled");
|
||||
HDRPlus = EnabledQuery(L"HDRPlusEnabled");
|
||||
SDR10 = EnabledQuery(L"SDR10Enabled");
|
||||
HDRCOLOUR = HDRPlus ? IDDCX_BITS_PER_COMPONENT_12 : IDDCX_BITS_PER_COMPONENT_10;
|
||||
SDRCOLOUR = SDR10 ? IDDCX_BITS_PER_COMPONENT_10 : IDDCX_BITS_PER_COMPONENT_8;
|
||||
|
||||
customEdid = EnabledQuery(L"CustomEdidEnabled");
|
||||
preventManufacturerSpoof = EnabledQuery(L"PreventMonitorSpoof");
|
||||
edidCeaOverride = EnabledQuery(L"EdidCeaOverride");
|
||||
sendLogsThroughPipe = EnabledQuery(L"SendLogsThroughPipe");
|
||||
|
||||
|
||||
//colour
|
||||
HDRPlus = EnabledQuery(L"HDRPlusEnabled");
|
||||
SDR10 = EnabledQuery(L"SDR10Enabled");
|
||||
HDRCOLOUR = HDRPlus ? IDDCX_BITS_PER_COMPONENT_12 : IDDCX_BITS_PER_COMPONENT_10;
|
||||
SDRCOLOUR = SDR10 ? IDDCX_BITS_PER_COMPONENT_10 : IDDCX_BITS_PER_COMPONENT_8;
|
||||
ColourFormat = GetStringSetting(L"ColourFormat");
|
||||
|
||||
//Cursor
|
||||
hardwareCursor = EnabledQuery(L"HardwareCursorEnabled");
|
||||
alphaCursorSupport = EnabledQuery(L"AlphaCursorSupport");
|
||||
@@ -2820,14 +2901,31 @@ void CreateTargetMode2(IDDCX_TARGET_MODE2& Mode, UINT Width, UINT Height, UINT V
|
||||
vddlog("d", logStream.str().c_str());
|
||||
|
||||
Mode.Size = sizeof(Mode);
|
||||
Mode.BitsPerComponent.Rgb = SDRCOLOUR | HDRCOLOUR;
|
||||
|
||||
|
||||
if (ColourFormat == L"RGB") {
|
||||
Mode.BitsPerComponent.Rgb = SDRCOLOUR | HDRCOLOUR;
|
||||
}
|
||||
else if (ColourFormat == L"YCbCr444") {
|
||||
Mode.BitsPerComponent.YCbCr444 = SDRCOLOUR | HDRCOLOUR;
|
||||
}
|
||||
else if (ColourFormat == L"YCbCr422") {
|
||||
Mode.BitsPerComponent.YCbCr422 = SDRCOLOUR | HDRCOLOUR;
|
||||
}
|
||||
else if (ColourFormat == L"YCbCr420") {
|
||||
Mode.BitsPerComponent.YCbCr420 = SDRCOLOUR | HDRCOLOUR;
|
||||
}
|
||||
else {
|
||||
Mode.BitsPerComponent.Rgb = SDRCOLOUR | HDRCOLOUR; // Default to RGB
|
||||
}
|
||||
|
||||
|
||||
logStream.str("");
|
||||
logStream << "IDDCX_TARGET_MODE2 configured with Size: " << Mode.Size
|
||||
<< " and BitsPerComponent.Rgb: " << Mode.BitsPerComponent.Rgb;
|
||||
<< " and colour format " << WStringToString(ColourFormat);
|
||||
vddlog("d", logStream.str().c_str());
|
||||
|
||||
|
||||
CreateTargetMode(Mode.TargetVideoSignalInfo.targetVideoSignalInfo, Width, Height, VSyncNum, VSyncDen);
|
||||
}
|
||||
|
||||
@@ -2920,11 +3018,26 @@ NTSTATUS VirtualDisplayDriverEvtIddCxAdapterQueryTargetInfo(
|
||||
UNREFERENCED_PARAMETER(pInArgs);
|
||||
|
||||
pOutArgs->TargetCaps = IDDCX_TARGET_CAPS_HIGH_COLOR_SPACE | IDDCX_TARGET_CAPS_WIDE_COLOR_SPACE;
|
||||
pOutArgs->DitheringSupport.Rgb = HDRCOLOUR;
|
||||
|
||||
if (ColourFormat == L"RGB") {
|
||||
pOutArgs->DitheringSupport.Rgb = SDRCOLOUR | HDRCOLOUR;
|
||||
}
|
||||
else if (ColourFormat == L"YCbCr444") {
|
||||
pOutArgs->DitheringSupport.YCbCr444 = SDRCOLOUR | HDRCOLOUR;
|
||||
}
|
||||
else if (ColourFormat == L"YCbCr422") {
|
||||
pOutArgs->DitheringSupport.YCbCr422 = SDRCOLOUR | HDRCOLOUR;
|
||||
}
|
||||
else if (ColourFormat == L"YCbCr420") {
|
||||
pOutArgs->DitheringSupport.YCbCr420 = SDRCOLOUR | HDRCOLOUR;
|
||||
}
|
||||
else {
|
||||
pOutArgs->DitheringSupport.Rgb = SDRCOLOUR | HDRCOLOUR; // Default to RGB
|
||||
}
|
||||
|
||||
logStream.str("");
|
||||
logStream << "Target capabilities set to: " << pOutArgs->TargetCaps
|
||||
<< "\nDithering support set to: " << pOutArgs->DitheringSupport.Rgb;
|
||||
<< "\nDithering support colour format set to: " << WStringToString(ColourFormat);
|
||||
vddlog("d", logStream.str().c_str());
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
@@ -2995,13 +3108,30 @@ NTSTATUS VirtualDisplayDriverEvtIddCxParseMonitorDescription2(
|
||||
pInArgs->pMonitorModes[ModeIndex].Origin = IDDCX_MONITOR_MODE_ORIGIN_MONITORDESCRIPTOR;
|
||||
pInArgs->pMonitorModes[ModeIndex].MonitorVideoSignalInfo = s_KnownMonitorModes2[ModeIndex];
|
||||
|
||||
pInArgs->pMonitorModes[ModeIndex].BitsPerComponent.Rgb = SDRCOLOUR | HDRCOLOUR;
|
||||
|
||||
if (ColourFormat == L"RGB") {
|
||||
pInArgs->pMonitorModes[ModeIndex].BitsPerComponent.Rgb = SDRCOLOUR | HDRCOLOUR;
|
||||
|
||||
}
|
||||
else if (ColourFormat == L"YCbCr444") {
|
||||
pInArgs->pMonitorModes[ModeIndex].BitsPerComponent.YCbCr444 = SDRCOLOUR | HDRCOLOUR;
|
||||
}
|
||||
else if (ColourFormat == L"YCbCr422") {
|
||||
pInArgs->pMonitorModes[ModeIndex].BitsPerComponent.YCbCr422 = SDRCOLOUR | HDRCOLOUR;
|
||||
}
|
||||
else if (ColourFormat == L"YCbCr420") {
|
||||
pInArgs->pMonitorModes[ModeIndex].BitsPerComponent.YCbCr420 = SDRCOLOUR | HDRCOLOUR;
|
||||
}
|
||||
else {
|
||||
pInArgs->pMonitorModes[ModeIndex].BitsPerComponent.Rgb = SDRCOLOUR | HDRCOLOUR; // Default to RGB
|
||||
}
|
||||
|
||||
|
||||
|
||||
logStream << "\n ModeIndex: " << ModeIndex
|
||||
<< "\n Size: " << pInArgs->pMonitorModes[ModeIndex].Size
|
||||
<< "\n Origin: " << pInArgs->pMonitorModes[ModeIndex].Origin
|
||||
<< "\n BitsPerComponent.Rgb: " << pInArgs->pMonitorModes[ModeIndex].BitsPerComponent.Rgb;
|
||||
<< "\n Colour Format: " << WStringToString(ColourFormat);
|
||||
}
|
||||
|
||||
vddlog("d", logStream.str().c_str());
|
||||
@@ -3062,7 +3192,7 @@ NTSTATUS VirtualDisplayDriverEvtIddCxMonitorQueryTargetModes2(
|
||||
{
|
||||
logStream << "\n TargetModeIndex: " << i
|
||||
<< "\n Size: " << TargetModes[i].Size
|
||||
<< "\n BitsPerComponent.Rgb: " << TargetModes[i].BitsPerComponent.Rgb;
|
||||
<< "\n ColourFormat: " << WStringToString(ColourFormat);
|
||||
}
|
||||
vddlog("d", logStream.str().c_str());
|
||||
}
|
||||
|
||||
@@ -48,8 +48,6 @@
|
||||
<CustomEdid>false</CustomEdid> <!-- Custom Edid should be named "user_edid.bin"! This does not support emulating resolutions!-->
|
||||
<PreventSpoof>false</PreventSpoof> <!--Enable this to prevent manufacturer spoofing when using custom edid. Please only do so if you need to!-->
|
||||
<EdidCeaOverride>false</EdidCeaOverride> <!--Enable this to override or add hard coded cea-extension block to custom Edid support allowing you to enable HDR-->
|
||||
<SDR10bit>false</SDR10bit>
|
||||
<HDRPlus>false</HDRPlus> <!-- If you have SDR10 bit enabled, HDRPlus wont work - there’s a conflict because the display system cannot simultaneously handle both high dynamic range 12-bit and standard dynamic range 10-bit settings. -->
|
||||
<logging>false</logging>
|
||||
<!-- DEBUG LOGGING FOR EXPERTS ONLY!-->
|
||||
<debuglogging>false</debuglogging>
|
||||
@@ -72,4 +70,18 @@
|
||||
3 = IDDCX_XOR_CURSOR_SUPPORT_EMULATION
|
||||
-->
|
||||
</cursor>
|
||||
<colour>
|
||||
<SDR10bit>false</SDR10bit>
|
||||
<HDRPlus>false</HDRPlus> <!-- If you have SDR10 bit enabled, HDRPlus wont work - there’s a conflict because the display system cannot simultaneously handle both high dynamic range 12-bit and standard dynamic range 10-bit settings. -->
|
||||
<ColourFormat>RGB</ColourFormat>
|
||||
<!--
|
||||
Supported colour formats:
|
||||
RGB
|
||||
YCbCr444
|
||||
YCbCr422
|
||||
YCbCr420
|
||||
|
||||
Any invalid colour formats which are used will default to use RGB
|
||||
-->
|
||||
</colour>
|
||||
</vdd_settings>
|
||||
Reference in new issue
Block a user