Page 2 of 8

Re: Using a reshade black frame insertion shader fx?

Posted: 21 Aug 2019, 23:55
by deama
squeaksci wrote:I got it to work! It's a tiny C++ program, if you want to compile it, it uses the Windows Driver Kit for a v-sync function.
Github page: https://github.com/squeaksci/desktopbfi
Download, if you're comfortable running a program from a stranger: https://github.com/squeaksci/desktopbfi/releases
Problems are likely, I'm not a great programmer. Let me know how it goes!
I tried yours but I get a lot of flickering?

I also tried my own attempt but with autohotkey, same result.

I have a 144hz monitor, so this shouldn't be a problem? The flickering problem is the same as in that video I uploaded, although I get that even on just a desktop.

Re: Using a reshade black frame insertion shader fx?

Posted: 22 Aug 2019, 12:07
by squeaksci
Thanks, that means a lot to me! I was lucky to find good code examples to borrow from.
The blanking inverval event was the hardest part for sure, I've wondered for a long time how you're supposed to do that without a library like SDL. I used DwmFlush() at first, then only found D3DKMTWaitForVerticalBlankEvent() after googling for more info on DwmFlush(), and it definitely works better.
I'll try D3DKMTGetScanLine()! I noticed it's flickering during some games' loading screens, I've been guessing the Sleep(2) might be causing that.
I noticed for one game that a white moving object was leaving a pretty extreme "echo" in its wake, I'm guessing that's what the image retention is? I'll try out your suggestion for that too.
That makes me wonder if a virtualized monitor driver could sleep for periods shorter than 1 ms? That always seemed like a strange limitation to me. I wasn't sure if doing a busyloop on a thread with really high priority was okay to do or not, since as far as I know it can't sleep for 0.1 ms.
Thanks for peeking at my code, this stuff's pretty fun!
deama wrote:I tried yours but I get a lot of flickering?
I tried it on another computer and also saw that same nasty flickering. I think the program is basically tuned for my monitor right now. With luck Chief's suggestion will make it work well, I'll try.

EDIT: I got an e-mail saying I got a private message here from someone, but my account is too new to view it. Whoever it was, I wanted to let you know!

Re: Using a reshade black frame insertion shader fx?

Posted: 22 Aug 2019, 15:40
by squeaksci
Alright, I updated with Chief's polling suggestion, it fixed the flickering on my other computer, though I couldn't test any games on it. I hope it works! Same download link: https://github.com/squeaksci/desktopbfi/releases

Re: Using a reshade black frame insertion shader fx?

Posted: 22 Aug 2019, 15:43
by deama
squeaksci wrote:Thanks, that means a lot to me! I was lucky to find good code examples to borrow from.
The blanking inverval event was the hardest part for sure, I've wondered for a long time how you're supposed to do that without a library like SDL. I used DwmFlush() at first, then only found D3DKMTWaitForVerticalBlankEvent() after googling for more info on DwmFlush(), and it definitely works better.
I'll try D3DKMTGetScanLine()! I noticed it's flickering during some games' loading screens, I've been guessing the Sleep(2) might be causing that.
I noticed for one game that a white moving object was leaving a pretty extreme "echo" in its wake, I'm guessing that's what the image retention is? I'll try out your suggestion for that too.
That makes me wonder if a virtualized monitor driver could sleep for periods shorter than 1 ms? That always seemed like a strange limitation to me. I wasn't sure if doing a busyloop on a thread with really high priority was okay to do or not, since as far as I know it can't sleep for 0.1 ms.
Thanks for peeking at my code, this stuff's pretty fun!
deama wrote:I tried yours but I get a lot of flickering?
I tried it on another computer and also saw that same nasty flickering. I think the program is basically tuned for my monitor right now. With luck Chief's suggestion will make it work well, I'll try.

EDIT: I got an e-mail saying I got a private message here from someone, but my account is too new to view it. Whoever it was, I wanted to let you know!
Do you know what computer type it was tested for? Like what hertz? What was the monitor you didn't get flickering on from just viewing the desktop?

Re: Using a reshade black frame insertion shader fx?

Posted: 22 Aug 2019, 15:50
by squeaksci
That one was just 60hz, sadly, I don't have a second high-refresh monitor. This one is 120hz.

Re: Using a reshade black frame insertion shader fx?

Posted: 22 Aug 2019, 16:40
by Kheri
I'm amazed just to see you made a working solution for BFI. But the program doesn't seem to work for me. "D3DKMTOpenAdapterFromHdc function received an invalid parameter."

Edit: I'm using a dual-monitor setup. Took a look at the code.

..Are there instructions I need to follow?

Re: Using a reshade black frame insertion shader fx?

Posted: 22 Aug 2019, 17:56
by squeaksci
No instructions, either the program applies BFI to the primary monitor or it fails. My code definitely isn't working with multi-monitors, and I'm not able to hook up a 2nd monitor to this computer so I'm flying a little blind trying to fix that. I made a small change that might make it work, but I'm not confident - let me know if it works!

Re: Using a reshade black frame insertion shader fx?

Posted: 22 Aug 2019, 23:55
by deama
squeaksci wrote:Alright, I updated with Chief's polling suggestion, it fixed the flickering on my other computer, though I couldn't test any games on it. I hope it works! Same download link: https://github.com/squeaksci/desktopbfi/releases
Hmm nope, still doesn't work, I think it's slightly better.

Re: Using a reshade black frame insertion shader fx?

Posted: 23 Aug 2019, 02:45
by Kheri
squeaksci wrote:No instructions, either the program applies BFI to the primary monitor or it fails. My code definitely isn't working with multi-monitors, and I'm not able to hook up a 2nd monitor to this computer so I'm flying a little blind trying to fix that. I made a small change that might make it work, but I'm not confident - let me know if it works!
Didn't help.
I tried to create my own project, even downloaded some windows SDK, but can't seem to get past the simplest of things (cannot find D3dkmthk.h)

Re: Using a reshade black frame insertion shader fx?

Posted: 24 Aug 2019, 02:36
by Kheri
Well, I haven't had much luck with the program yet -- it just flickers like mad.

I did something like this to get it working on the primary display:
https://docs.microsoft.com/en-us/window ... terfromhdc

Code: Select all

	DISPLAY_DEVICE dd;
	memset(&dd, 0, sizeof(dd));
	dd.cb = sizeof dd;
	int i;
	for (i = 0; EnumDisplayDevicesA(NULL, i, &dd, 0); ++i) {
		if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
			break;
		}
	}

	oa.hDc = CreateDC(NULL, dd.DeviceName, NULL, NULL);