[SOLVED] The King of Fighters XIV CBT black screen issue

  • Silent
  • Topic Author
More
6 years 10 months ago #1 by Silent The King of Fighters XIV CBT black screen issue was created by Silent
According to this topic on Steam boards:
steamcommunity.com/app/571260/discussion...1291816569119818972/

injecting any ReShade shader results in black screen and broken GUI. Upon closer inspection, using a Debug build of ReShade with KOF results in KOF being unable to create an OpenGL 4.3 context and throws a tantrum. The faulty call seems to be included in the log file:
2017-05-20T13:51:39:016 [51536] | INFO  | Redirecting 'wglCreateContextAttribsARB(FFFFFFFFB50126F1, 0000000000000000, 0000006E9AEFEFA0)' ...
2017-05-20T13:51:39:016 [51536] | INFO  | > Requesting compatibility OpenGL context for version 4.3 ...
2017-05-20T13:51:39:016 [51536] | WARN  | > 'wglCreateContextAttribsARB' failed with error code 87!

Since the game is in closed beta stage, it's highly likely the game itself, not ReShade, is at fault. However, it would be good to know for sure since the game breaking on generic ReShade hooks implies it's doing something highly nonstandard.

Cheers!

Please Log in or Create an account to join the conversation.

  • crosire
More
6 years 10 months ago - 6 years 10 months ago #2 by crosire Replied by crosire on topic The King of Fighters XIV CBT black screen issue
Code 87 is ERROR_INVALID_PARAMETER. But I don't see anything wrong with the call per se. Provided that the device context handle FFFFFFFFB50126F1 is a valid device context with OpenGL support (it should probably appear earlier in the log at some point). Must be something wrong with the attribute list (third parameter). The only thing that comes to mind is that ReShade does not currently pass on the value of WGL_CONTEXT_FLAGS_ARB unless you build a debug build, which could be a problem. Then again, you mentioned this occurs in a debug build as well.
Last edit: 6 years 10 months ago by crosire.

Please Log in or Create an account to join the conversation.

  • Silent
  • Topic Author
More
6 years 10 months ago #3 by Silent Replied by Silent on topic The King of Fighters XIV CBT black screen issue
Exactly - moreover, the game boots fine in Release (since players have been able to try it out and then find out using any shaders results in black screen) while my attempt to run a debug ReShade results in context not being created correctly.

Probably a good idea to include a full log - you can see that this context indeed appears earlier and thus seems valid:
pastebin.com/ixcjzDqm

Please Log in or Create an account to join the conversation.

  • crosire
More
6 years 10 months ago #4 by crosire Replied by crosire on topic The King of Fighters XIV CBT black screen issue
AH. Then that's two separate issues. The debug builds adds an additional flag to context creation. Appears like your graphics driver doesn't like it.

Please Log in or Create an account to join the conversation.

  • Silent
  • Topic Author
More
6 years 10 months ago - 6 years 10 months ago #5 by Silent Replied by Silent on topic The King of Fighters XIV CBT issues

crosire wrote: AH. Then that's two separate issues. The debug builds adds an additional flag to context creation. Appears like your graphics driver doesn't like it.


I'm testing this on MSI GTX 1070 with 381.65 drivers, so I would consider this fairly unlikely to be a faulty driver. Though maybe it's a good excuse to update to 382.xx...

Is there any way to gather more info about what's failing here?


EDIT:
Updated my drivers to 382.05 - context creation still fails.
Last edit: 6 years 10 months ago by Silent. Reason: Driver update did not help at all

Please Log in or Create an account to join the conversation.

  • crosire
More
6 years 10 months ago #6 by crosire Replied by crosire on topic The King of Fighters XIV CBT issues
I'm not saying it's a bug in the driver, I'm saying the driver doesn't accept the combination of flags, which can have various reasons.

Please Log in or Create an account to join the conversation.

  • Silent
  • Topic Author
More
6 years 10 months ago #7 by Silent Replied by Silent on topic The King of Fighters XIV CBT black screen issue
Yeah, but unless the combination of flags is forbidden by OGL specifications (in which case ReShade would be at fault), it could be consideted an issue with proper OGL implementation?

Either way, probably easiest to check what params ReShade receives and forwards from the game and then build upon that... will handle it later. And then there is an issue with UI being completely broken (even with no reshade shaders) and black screen upon injecting any shaders, but let me handle the context issue first.

Please Log in or Create an account to join the conversation.

  • Silent
  • Topic Author
More
6 years 10 months ago - 6 years 10 months ago #8 by Silent Replied by Silent on topic The King of Fighters XIV CBT black screen issue
Alright, I think I found the issue!

In wglCreateContextAttribsARB the attribs array is 7 entries long - ReShade checks for 5 attribs passed from the application (in the case of KOF, from SDL2), adds the 6th by itself and 7th in debug compilations. There seem to be two problems surfacing from it:

1) KOF passes 5 parameters, so in debug builds all 7 entries get filled. Doesn't this list need to be null terminated? An 8th null entry might have to be added.
2) KOF already passes WGL_CONTEXT_FLAGS_ARB and debug code adds yet another one - I don't know what requirements wglCreateContextAttribsARB has, but it feels fishy to pass the same parameter twice. ReShade should instead post this parameter only if the app doesn't do it - and if it does, add it in the first entry earlier.

I'm not familiar with OGL like at all - is there any place with docs for wgl* functions?


EDIT:
Yep, debug builds launch fine with these two changes now - black screen issue still persists, but this is indeed a different issue. A main one, actually.


EDIT2:

That's how the game looks with no shaders injected - notice broken HUD:



When any shader gets injected, screen goes black (except the HUD). Ctrl+F'ing the log file for "error" gives no results. Any ideas?
Last edit: 6 years 10 months ago by Silent.

Please Log in or Create an account to join the conversation.

  • crosire
More
6 years 10 months ago #9 by crosire Replied by crosire on topic The King of Fighters XIV CBT black screen issue

Silent wrote: 1) KOF passes 5 parameters, so in debug builds all 7 entries get filled. Doesn't this list need to be null terminated? An 8th null entry might have to be added.
2) KOF already passes WGL_CONTEXT_FLAGS_ARB and debug code adds yet another one - I don't know what requirements wglCreateContextAttribsARB has, but it feels fishy to pass the same parameter twice. ReShade should instead post this parameter only if the app doesn't do it - and if it does, add it in the first entry earlier.

I'm not familiar with OGL like at all - is there any place with docs for wgl* functions?

The problem was 1) most likely. The list indeed has to be null-terminated.
See my comment on github.com/crosire/reshade/pull/12 . You can pass attributes multiple times and only the last one should be used.

Silent wrote: When any shader gets injected, screen goes black (except the HUD). Ctrl+F'ing the log file for "error" gives no results. Any ideas?

Might be useful to get some debug output from OpenGL via www.khronos.org/registry/OpenGL/extensio...ARB_debug_output.txt . Maybe that gives a hint. But a black screen usually means ReShade does not draw its fullscreen pass correctly. This is because before drawing, ReShade clears the backbuffer to zero (black). You can verify that by changing the clear color at github.com/crosire/reshade/blob/master/s...ngl_runtime.cpp#L773 to something like red.

Please Log in or Create an account to join the conversation.

  • Silent
  • Topic Author
More
6 years 10 months ago - 6 years 10 months ago #10 by Silent Replied by Silent on topic The King of Fighters XIV CBT black screen issue
Looks like there is no clearing going on at all (this is even after I changed glClearBufferfv colour).



About debug outputs, I presume ReShade doesn't hook those up already?

Actually, some shaders do seem to work but they have to be activated after the game's already started.
Last edit: 6 years 10 months ago by Silent.

Please Log in or Create an account to join the conversation.

  • Silent
  • Topic Author
More
6 years 10 months ago - 6 years 10 months ago #11 by Silent Replied by Silent on topic The King of Fighters XIV CBT black screen issue
That's intriguing... I cheched different ReShade forks and stumbled upon this change which never made it to master:
github.com/bacondither/reshade/commit/81...2f494b62de0e9a9d9463

Apparently it fixes GUI issues and movies not showing in KoF! It might be a more common issue after all, since the commit is dated Apr 26 and KoF CBT debuted on May 15.

What do you think? What's the reason behind these extra checks on your end? Is it working around some game issues and KoF is using those improperly?


EDIT:
Well damn, it fixes the other issue too!!!



There is one issue left and it may concern a depth buffer - when some shaders are enabled (Adaptive Fog, DOF...) I can see an artifact which looks like one of the shadows from the scene. DisplayDepth shader shows it best:
Last edit: 6 years 10 months ago by Silent.

Please Log in or Create an account to join the conversation.

  • crosire
More
6 years 10 months ago #12 by crosire Replied by crosire on topic The King of Fighters XIV CBT black screen issue

Silent wrote: What do you think? What's the reason behind these extra checks on your end? Is it working around some game issues and KoF is using those improperly?

ReShade calls "glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE)" a few lines above that for internal usage, so theoretically there should be no need to call it with the same arguments again later, which is why those extra checks are there (prevent driver overhead). No idea why removing those fixes things.

Silent wrote: There is one issue left and it may concern a depth buffer - when some shaders are enabled (Adaptive Fog, DOF...) I can see an artifact which looks like one of the shadows from the scene.

Just the wrong buffer chosen here. Probably some shadow depth buffer, that was picked up instead of the one containing the scene from main camera perspective.

Please Log in or Create an account to join the conversation.

  • Silent
  • Topic Author
More
6 years 10 months ago - 6 years 10 months ago #13 by Silent Replied by Silent on topic The King of Fighters XIV CBT black screen issue

crosire wrote: ReShade calls "glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE)" a few lines above that for internal usage, so theoretically there should be no need to call it with the same arguments again later, which is why those extra checks are there (prevent driver overhead). No idea why removing those fixes things.

There's quite a lot going on between these calls though - maybe state blocks modify those?

crosire wrote: Just the wrong buffer chosen here. Probably some shadow depth buffer, that was picked up instead of the one containing the scene from main camera perspective.

Sounds game specific... I reckon there is no obvious way to fix it then?

EDIT:
Erm... this
(clip_origin != GL_LOWER_LEFT && clip_depthmode != GL_ZERO_TO_ONE)

probably needs to be this
(clip_origin != GL_LOWER_LEFT || clip_depthmode != GL_ZERO_TO_ONE)

=)

EDIT:
Yep! Works fine now, heh. That only leaves depth buffer, any idea if anything can be done with it? Either from reshade or the game.


EDIT2:
github.com/crosire/reshade/pull/13
Last edit: 6 years 10 months ago by Silent.

Please Log in or Create an account to join the conversation.

  • crosire
More
6 years 10 months ago #14 by crosire Replied by crosire on topic The King of Fighters XIV CBT black screen issue

Silent wrote: Erm... this

probably needs to be this

Ouch. Good catch.

Please Log in or Create an account to join the conversation.

  • Silent
  • Topic Author
More
6 years 10 months ago #15 by Silent Replied by Silent on topic The King of Fighters XIV CBT black screen issue
So with the major issue out of the way, can anything be done with wrong depth buffer being picked?

Please Log in or Create an account to join the conversation.

  • crosire
More
6 years 10 months ago - 6 years 10 months ago #16 by crosire Replied by crosire on topic The King of Fighters XIV CBT black screen issue
The heuristic that does the detection can be modified: github.com/crosire/reshade/blob/master/s...ngl_runtime.cpp#L888 (warning, ugly code ahead, never got around cleaning that up).

EDIT: What I usually do is attach a debugger and check each entry in the "_depth_source_table" list manually, then check out its properties and see what numbers I have to tweak for the branch to pick it up.
Last edit: 6 years 10 months ago by crosire.

Please Log in or Create an account to join the conversation.

  • docer
More
6 years 10 months ago #17 by docer Replied by docer on topic The King of Fighters XIV CBT black screen issue
How do I make it work?

Please Log in or Create an account to join the conversation.

  • Silent
  • Topic Author
More
6 years 10 months ago #18 by Silent Replied by Silent on topic The King of Fighters XIV CBT black screen issue
For now you should either compile the newest ReShade from source or grab this binary:

steamcommunity.com/app/571260/discussion...c1291817208502486360

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.