Coder Social home page Coder Social logo

HDR Support about displaymagician HOT 32 CLOSED

terrymacdonald avatar terrymacdonald commented on May 31, 2024 1
HDR Support

from displaymagician.

Comments (32)

terrymacdonald avatar terrymacdonald commented on May 31, 2024 1

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

Hmmm. Interesting thought, but I'm not sure I'll be able to do it. A thing to note is that DisplayMagician only sets the Display Profile to the display settings that it was when you made the Display Profile. I don't think it records the HDR settings as part of the Soroush's WindowsDisplayAPI library that we use, so it's probably going to be too difficult to add.

I'll add it to my 'things to investigate' list though, and eventually I'll come back to you with an answer once I've had a chance to see how feasible it is.

from displaymagician.

Mobeeuz avatar Mobeeuz commented on May 31, 2024

It does not record unfortunately. I did find an example on GitHub tho: https://github.com/lyckantropen/hdr-switch
The project it is forked from does not work properly, however this one does. I realize I could execute it, and then terminate on exit using your program, but a proper integration would be better imo.

EDIT: Another Example: https://github.com/Codectory/AutoHDR

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

I don't think I'll be able to work on this functionality now. I want to add AMD Eyefinity support before I would look at doing this. It is something I will investigate a bit further in the future though, as it does seem like it could be a useful feature to have for those with HDR monitors. I won't be able to test it when I do develop the functionality as my screens aren't HDR :).

Thanks for the link to AutoHDR. The HDRController DLL looks promising, but it uses the Windows Display functionality to do the manipulations, and it looks like I would need to implement something similar for those people with NVIDIA devices as well as I'm not sure the HDRController implementation would work alongside the NVIDIA one.

The tricky part of all this is that DisplayMagician uses the NVIDIA driver, the AMD driver (when that code is finished being implemented) and the default Windows libraries for getting and setting config. From what I can tell, I'll need to write code to grab that HDR information as part of the Display Profile detection, and then store that in the Display Settings. I'll also need a way of setting the HDR mode in those three different pathways. NvAPIwrapper supports getting HDR information, but I'm not sure it supports setting it yet. AMD ADL seems to support it, but I will have to add that functionality to the AMD ADL C wrapper I'm writing which will take a while. And I might be able to use some default libraries within Windows, but I don't know what they are.

After spending some time reviewing the code you've provided, it seems like it will be quite a bit of work to add this into DisplayMagician. I think other features are more of a priority for me, so I doubt I'll get to this within the next 6 months or so. I will keep this on the back log though, as I think it will become a feature that will be needed more and more.

I'll likely take a look at this after AMD Support is finished, but that in itself is likely to be a while.

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

As I've been developing the code for #21, it's becoming apparent that it will be easiest to also roll in HDR support with the refactoring I need to perform for the video card detection and handling part of DisplayMagician. SO I've added this issue to the v2.0.0 milestone to indicate that HDR support will likely ship with the v2.0.0 release.

from displaymagician.

Mobeeuz avatar Mobeeuz commented on May 31, 2024

Excellent to hear. I'm sure I'm not the only one sick of going through a dance every time I want to toggle HDR.

from displaymagician.

falahati avatar falahati commented on May 31, 2024

Hey @terrymacdonald, HDR is part of the NVAPIWrapper for a while now:
falahati/NvAPIWrapper#19

You can at least add this functionality to NVIDIA GPUs quite easily. SetColorData() and SetHDRColorData() are probably the methods that you are interested in.

If there is any problem with any of the underlying libraries feel free to mention me here or create an issue on the related project.

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

So some good news here I thought you might like to hear @Mobeeuz . Last night I managed to develop some test code in a different test project to test out a new Windows CCD library I put together. The new code does set the display layout and primary monitor correctly, and it also attempts to set the HDR status for each display.

I ran out of time to package it up last night, but if I manage to get that test software ready to go, would you be open to the idea of testing it for me? Do you have an HDR capable screen you can test with?

The program is called CCDInfo, and when I finish packaging a release zip file it will be here: https://github.com/terrymacdonald/CCDInfo/releases

The idea would be that you would step through the following steps:

  • set up a display configuration with HDR enabled on at least one display, and one screen as the primary.
  • then you would run 'CCDInfo save ' to generate a config file that would capture the display config, (e.g. CCDInfo save config1.cfg)
  • then you would change your display configuration to turn off HDR on that one display, and to set a different screen as the primary monito/main display.
  • then you would run 'CCDInfo save ' to generate a different config file that would capture the display config as it is (e.g. CCDInfo save config2.cfg)

Then the idea is that you would test the ability of CCDInfo to change between those two settings by running the following commands after each other:

  • Run CCDInfo by itself to list the output, and check that the HDR is on for the one display/
  • Change back to the original display configuration using CCDInfo load config1.cfg
  • Check the output of CCDInfo to check that the HDR state is now off for all displays.
  • Open up Windows Display Settings to confirm the settings have changed back. (You will need to close it completely after you make a change, as it doesn't detect the screen change otherwise and things look the same)
  • Change back to the different display configuration using CCDInfo load config2.cfg
  • Check the output of CCDInfo to check that the HDR state is now back on off that single display.
  • Close, then reopen Windows Display Settings to confirm the settings have changed back. (You will need to close it completely after you make a change, as it doesn't detect the screen change otherwise and things look the same)

Is that something you can do for me? It will help me confirm the library is working before I then start to build it into DisplayMagician v2.0.0.

Thanks
Terry

from displaymagician.

Mobeeuz avatar Mobeeuz commented on May 31, 2024

I have 2 screens - one HDR, one not. I can certainly test out the code for you.

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

@Mobeeuz CCDInfo is now released. Please download the release, extract the zip and then run the test that I described in the post above. And then please paste the screen grab of the output too so I can read the bits I need to.

https://github.com/terrymacdonald/CCDInfo/releases/tag/v1.0.0

And thanks for your help!

from displaymagician.

Mobeeuz avatar Mobeeuz commented on May 31, 2024

So, resolution and primary display changed accordingly, complete with refresh rate. Howerever, HDR did not activate when switching. A copy of the CFG and console outputs are here.

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

@Mobeeuz I've uploaded a working version of CCDInfo (v1.0.1) and have tested it myself. I managed to borrow an HDR monitor and I have validated that CCDInfo will move screen, change the primary screen, change the Windows HDR settings etc. I've tested that it works across reboots and it seems to work ok.

https://github.com/terrymacdonald/CCDInfo/releases/tag/v1.0.1

This little programme should be able to fix your problem temporarily while I rewrite DisplayMagician. You can setup a Desktop icon for each of the Display Configs you want (CCDInfo load nameofconfig.cfg) and then run them that way, at least until I get DisplayMagician v2.0.0 completed.

The good thing is that I've now fully tested the logic and library functionality that I needed to, so it should make it far easier to update DisplayMagician now!

NOTE: CCDInfo only sets the Windows HDR settings, so won't affect the NVIDIA HDR settings or AMD HDR settings. Those will be handled by their own libraries that I'll be writing soon.

from displaymagician.

Mobeeuz avatar Mobeeuz commented on May 31, 2024

@terrymacdonald Works like a charm! Looking forward to streamlining the hot mess that is the Windows Display function.

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

from displaymagician.

Mobeeuz avatar Mobeeuz commented on May 31, 2024

@terrymacdonald So, strangely, today I tried using yesterday's config and I get this:

ProfileRepository/LoadProfiles: Testing whether the display configuration is valid.
ProfileRepository/LoadProfiles: ERROR white testing that the Display COnfiguration is valid

Unhandled Exception: System.ComponentModel.Win32Exception: The parameter is incorrect
   at CCDInfo.Program.loadFromFile(String filename) in H:\vscode-projects\CCDInfo\CCDInfo\CCDInfo\Program.cs:line 367
   at CCDInfo.Program.Main(String[] args) in H:\vscode-projects\CCDInfo\CCDInfo\CCDInfo\Program.cs:line 67

Creating another CFG (which now works) and comparing, these lines have different values:

          "LowPart": 52034,
          "Value": 52034

These values change on every reboot

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

Hmmmmm, That one is odd. It's in the LUID part, which after a quick lookup I just found this: https://docs.microsoft.com/en-us/uwp/api/windows.devices.display.core.displayadapter.id?view=winrt-20348

The key part is: "Gets a numeric locally unique ID (LUID) that refers to the runtime instance of the display adapter. This ID changes if the adapter's PnP device is stopped/started, or if the system reboots."

Gah! I may need to 'patch' the config each time I go to apply it. That will be annoying if that has to happen, as I need to find out what the current adapter LUID is, and then update it with the new LUID available during this run :(.

Thanks for the error report though. It was very useful.

from displaymagician.

falahati avatar falahati commented on May 31, 2024

With Helios, I am using the monitor device path to find the display. Then finding the right LUID by device path. It works better but is still not immune to change.
You can also try to extract a unique id from the monitor's EDID to identify a display. But make sure to handle this correctly as EDID is not always available; can be changed or worse, two monitors might share the same info.

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

@Mobeeuz I'd like you to try CCDInfo v1.0.2 tweak please. It's available here: https://github.com/terrymacdonald/CCDInfo/releases/tag/v1.0.2

I've tweaked the flags provided to the SetDisplayConfig function in wingdi.dll to allow a little variation to happen in the config in order to make the display show correctly. I'm hoping that the library will ignore the differences in LUID, and will see that everything else matches, and just use that display config without complaining.

Can you please test it again, and especially test it after a couple of reboots? I'm hoping it will work, but there are a few other tweaks I can make if it doesn't. We'll hopefully hit the right combination at some stage soon!

thanks
Terry

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

from displaymagician.

Mobeeuz avatar Mobeeuz commented on May 31, 2024

@terrymacdonald Same issue...

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

@Mobeeuz I found another bug. I forgot to make a change to a flag passed to the function. Can you please try this one?

https://github.com/terrymacdonald/CCDInfo/releases/tag/v1.0.3

I have tested this and I know it works after a reboot, but I did have some weird issue after the next reboot where my new display config wouldn't show correctly. I ended up having to press the Windows Graphics Display Reset hotkey (Windows Key + Ctrl + Shift + B) to make the display show correctly.

So can you please test v1.0.3 and reboot then make sure it still works after a reboot? And then reboot again and make sure it works after that? If it survives 2 reboots then I think we've cracked the problem. If You get the same issue as I did, then I'll have to try a different set of flags.

At the moment we use the flags SDC_APPLY | SDC_USE_SUPPLIED_DISPLAY_CONFIG | SDC_ALLOW_CHANGES | SDC_SAVE_TO_DATABASE, all of which combined apply the new display config, use the display config we supplied, allow the function to make changes to get it to work, and we save the new settings. This should work fine.

My only concern is that settings may not work properly after a reboot. If that's the case then it might be better to only use the topology we supply, and then use the paths stored in the database. That may give us what we need without the issues after a reboot. So if this current version doesn't work then that's the next test.

from displaymagician.

Mobeeuz avatar Mobeeuz commented on May 31, 2024

@terrymacdonald Afraid not, even after 1 reboot :(

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

OK. I think this might be it. I have tested successfully after 4 reboots on my local system and CCDInfo v1.0.4 appears to work.

https://github.com/terrymacdonald/CCDInfo/releases/latest

@Mobeeuz can I ask one more favour please? Can you please delete the saved cfg files you have used before, and recreate 2 new configurations using different display settings for each config.

And then please try again to swap between them.

Once you've confirmed that works, please reboot and try to swap between the two different config files again. If you have any error messages please copy them nd paste them into this issue so I can see them.

And then, just to really make doubly sure, please reboot a second time, and try the two different config files again.

What I've done is quite a bit of a rewrite based on Soroush's suggestions to patch the LUID each time we apply the config. It appears to have worked, at least for me, so I'm really keen to find out if it does for you too!

Thanks
Terry

from displaymagician.

Mobeeuz avatar Mobeeuz commented on May 31, 2024

@terrymacdonald After a reboot - new config:

ProfileRepository/LoadProfiles: Checking whether the display configuration is already being used.
ProfileRepository/LoadProfiles: The requested display configuration is different to the one in use at present. We need to change to the new one.
ProfileRepository/LoadProfiles: Testing whether the display configuration is valid (allowing tweaks).
ERROR - SetDisplayConfig returned WIN32STATUS ERROR_INVALID_PARAMETER while testing that the Display Configuration is valid

Unhandled Exception: System.ComponentModel.Win32Exception: The parameter is incorrect
   at CCDInfo.Program.loadFromFile(String filename) in H:\vscode-projects\CCDInfo\CCDInfo\CCDInfo\Program.cs:line 483
   at CCDInfo.Program.Main(String[] args) in H:\vscode-projects\CCDInfo\CCDInfo\CCDInfo\Program.cs:line 87

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

Great news. I went back to the drawing board a bit, and took Souroush's wise words into consideration, and came up with a solution. I'm pretty happy with the way it turned out, but I am still tweaking CCDInfo to iron out a few little details. I should be releasing the next version of the CCDInfo, and that should work. I just need to fix some of the rough edges to make it more usable.

The good news is that it does keep HDR settings, primary display, layout and everything as it should. I've even managed to find what seems like a bug in CCD that I've been able to work around, and I've greatly extended the CCD structure within the CCD library I've made. It's been pretty fun, but I want to hurry up and complete the CCD implementation so that I can work on the AMDLibrary :).

Anyway - expect a new CCDInfo to test in the next few days!

from displaymagician.

Mobeeuz avatar Mobeeuz commented on May 31, 2024

Sounds great, I look forward to testing. Should make Display Magician an invaluable tool.

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

\o/ I've done it!

CCDInfo v1.0.5 changes the primary display properly, as well as display layout, resolution, and HDR color settings. Hopefully this is an acceptable workaround until DisplayMagician v2.0.0 is completed.

You can download CCDInfo from here: https://github.com/terrymacdonald/CCDInfo/releases/latest

Some caveats on all the above though; this will only work for Windows Display Settings. CCDInfo will not save or load NVIDIA or AMD settings at all. Those will be coming in some other additional test programs later on as I carry on with the AMD development (AMDInfo first, then NVIDIAInfo next). Once those are tested fully, then they'll be integrated into DisplayMagician v2.0.0.

Now that I have competed the first library for DisplayMagician (WinLibrary), and I'll be back working on the AMD one shortly (AMDLibrary).

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

Please test CCDInfo 1.0.5 @Mobeeuz and if this is now working, please close this issue. I am working to add HDR support to DisplayMagician as part of v2.0.0 and that will be released as part of the normal release cycle. Current ETA is just under 2 months at a guess.

Terry

from displaymagician.

Mobeeuz avatar Mobeeuz commented on May 31, 2024

Huzzah! Working great. Thanks for all your hard work, looking forward to the next Display Magician release 👍

from displaymagician.

terrymacdonald avatar terrymacdonald commented on May 31, 2024

Great news! DisplayMagician v2.0.1 has been released, and it should fix this very issue. Please test it out, and if you still have any issues please log a new issue. You can get DisplayMagician v2.0.1 from here: https://github.com/terrymacdonald/DisplayMagician/releases/tag/v2.0.1

I'm closing this issue as the fix is in DisplayMagician v2.0.1, and I need to clear out the completed issues so I am able to work on the new issues that come in.

Thanks
Terry

from displaymagician.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.