Using a reshade black frame insertion shader fx?

Talk to software developers and aspiring geeks. Programming tips. Improve motion fluidity. Reduce input lag. Come Present() yourself!
deama
Posts: 9
Joined: 07 Aug 2019, 12:00

Re: Using a reshade black frame insertion shader fx?

Post by deama » 21 Aug 2019, 23:55

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.

squeaksci
Posts: 6
Joined: 19 Aug 2019, 12:04

Re: Using a reshade black frame insertion shader fx?

Post by squeaksci » 22 Aug 2019, 12:07

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!

squeaksci
Posts: 6
Joined: 19 Aug 2019, 12:04

Re: Using a reshade black frame insertion shader fx?

Post by squeaksci » 22 Aug 2019, 15:40

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

deama
Posts: 9
Joined: 07 Aug 2019, 12:00

Re: Using a reshade black frame insertion shader fx?

Post by deama » 22 Aug 2019, 15:43

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?

squeaksci
Posts: 6
Joined: 19 Aug 2019, 12:04

Re: Using a reshade black frame insertion shader fx?

Post by squeaksci » 22 Aug 2019, 15:50

That one was just 60hz, sadly, I don't have a second high-refresh monitor. This one is 120hz.

Kheri
Posts: 59
Joined: 29 Sep 2018, 13:39

Re: Using a reshade black frame insertion shader fx?

Post by Kheri » 22 Aug 2019, 16:40

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?

squeaksci
Posts: 6
Joined: 19 Aug 2019, 12:04

Re: Using a reshade black frame insertion shader fx?

Post by squeaksci » 22 Aug 2019, 17:56

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!

deama
Posts: 9
Joined: 07 Aug 2019, 12:00

Re: Using a reshade black frame insertion shader fx?

Post by deama » 22 Aug 2019, 23:55

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.

Kheri
Posts: 59
Joined: 29 Sep 2018, 13:39

Re: Using a reshade black frame insertion shader fx?

Post by Kheri » 23 Aug 2019, 02:45

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)

Kheri
Posts: 59
Joined: 29 Sep 2018, 13:39

Re: Using a reshade black frame insertion shader fx?

Post by Kheri » 24 Aug 2019, 02:36

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);
Last edited by Kheri on 24 Aug 2019, 17:03, edited 1 time in total.

Post Reply