Skip to content

FS hack fixes for Descent 3 #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: proton_9.0
Choose a base branch
from

Conversation

Frogging101
Copy link

A couple of fixes which allow Descent 3's OpenGL renderer to work with the fullscreen hack.

    fshack: Always allocate a depth buffer
    
    Some applications use depth testing but leave the image format depth
    component set to 0. OpenGL drivers always provide a depth buffer for
    framebuffers regardless of whether the image format specifies one, so the
    FS hack texture should too, otherwise such applications will render
    incorrectly.
    fshack: Use texture name hack for Descent 3
    
    Descent 3's OpenGL renderer will use a texture conflicting with the FS
    hack texture, and only a small rectangle in the bottom left corner will
    be rendered.

@Frogging101
Copy link
Author

@gofman Gentle ping

@Frogging101 Frogging101 changed the base branch from proton_8.0 to proton_9.0 May 2, 2024 22:14
Descent 3's OpenGL renderer will use a texture conflicting with the FS
hack texture, and only a small rectangle in the bottom left corner will
be rendered.

Signed-off-by: John Brooks <[email protected]>
@Frogging101 Frogging101 force-pushed the descent3-fshack-fixes branch from 17c2f99 to 1373481 Compare May 2, 2024 22:19
Some applications use depth testing but leave the image format depth
component set to 0. OpenGL drivers always provide a depth buffer for
framebuffers regardless of whether the image format specifies one, so the
FS hack texture should too, otherwise such applications will render
incorrectly.

Signed-off-by: John Brooks <[email protected]>
@gofman
Copy link
Contributor

gofman commented May 2, 2024

Some applications use depth testing but leave the image format depth component set to 0. OpenGL drivers always provide a depth buffer for framebuffers regardless of whether the image format specifies one, so the FS hack texture should too, otherwise such applications will render incorrectly.

Are you sure about that? There are certainly GLX visuals without depth buffers. Why do we get 0 GLX_DEPTH_SIZE then? I suspect that maybe something else is wrong, just e. g., the game does something which we do not handle in fshack or maybe wrong GL format is chosen at once. Does it work with Wine without fshack?

Then, skipping pglFramebufferTexture2D( GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, ctx->fs_hack_ds_texture, 0 ); if we have a stencil looks suspicious, but for now this is secondary, so far I am not yet convinced that the change is correct in general.

Plagman pushed a commit that referenced this pull request May 14, 2024
Descent 3's OpenGL renderer will use a texture conflicting with the FS
hack texture, and only a small rectangle in the bottom left corner will
be rendered.

Signed-off-by: John Brooks <[email protected]>

#211

CW-Bug-Id: #23791
@gofman
Copy link
Contributor

gofman commented May 14, 2024

So I took a look at the second issue with depth buffer. On an AMD machine I could see rendering glitches related to Z testing in the first (Pilot Training) mission when moving left from initial position. That is not related to fshack, the game works with upstream Wine and shows the same. Indeed, the game calls ChoosePixelFormat() without explicitly requesting depth bits in PIXELFORMATDESCRIPTOR. That happens to have depth on one Nvidia machine with Wine / Proton here, but not on AMD. On the same AMD machine the same ChoosePixelFormat ends up with 32 / 8 depth / stencil on Windows 11. Frankly I am not sure that with every possible GPU and driver it will get a depth buffer (and the game warns about "buggy drivers" when selecting OpenGL option which suggests that it doesn't necessarily work very well on arbitrary instance). I suppose it is nothing wrong in matching current Windows / AMD behaviour here instead of depending on unspecified format order. But that should be done in opengl32/wglChoosePixelFormat, not by adding some depth buffers in fshack.

So I pulled the first patch from this PR ("fshack: Use texture name hack for Descent 3 ") and made another patch for depth issue (also sent upstream: https://gitlab.winehq.org/wine/wine/-/merge_requests/5636

Those are in the just updated Proton Experimental ([bleeding-edge] branch): https://github.com/ValveSoftware/wine/commits/experimental-wine-bleeding-edge-9.0-96562-20240514-p230721-we36c29-d6259e8-vf6d390/

Does that fix the issues?

Plagman pushed a commit that referenced this pull request Jun 6, 2024
Descent 3's OpenGL renderer will use a texture conflicting with the FS
hack texture, and only a small rectangle in the bottom left corner will
be rendered.

Signed-off-by: John Brooks <[email protected]>

#211

CW-Bug-Id: #23791
bylaws pushed a commit to bylaws/wine that referenced this pull request Sep 6, 2024
Descent 3's OpenGL renderer will use a texture conflicting with the FS
hack texture, and only a small rectangle in the bottom left corner will
be rendered.

Signed-off-by: John Brooks <[email protected]>

ValveSoftware/wine#211

CW-Bug-Id: #23791
bylaws pushed a commit to bylaws/wine that referenced this pull request Apr 30, 2025
Based on work by Zhiyi Zhang, includes work by Giovanni Mascellani, Rémi
Bernon, Arkadiusz Hiler, Kai Krakow, Joshua Ashton, Zebediah Figura, and
Matteo Bruni.

fshack: winex11: Protect fshack framebuffer from glFramebufferTexture2D().

glFramebufferTexture2D() just fails with default framebuffer. But when we have
substitued fshack framebuffer setting the texture destroys it instead.

CW-Bug-Id: #20669

fshack: winex11: Clear fs hack depth / stencil attachment.

fshack: winex11: Support adjusting gamma in the fshack

CW-Bug-Id: 16421

fshack: winex11: Setup gamma shader only once per context.

Fixes GL objects leak and avoids unneccessary shader recreation
when the fs_hack_setup_context() is called due to switching GL
drawable.

For Star Wars - Knights of the Old Republic blank screen.

CW-Bug-Id: #19002

fshack: winex11: Track if multisample resolve is needed in gl_drawable.

As that changes per drawable and not per context.

fshack: winex11: Destroy fshack GL objects only at GL context destroy.

fshack: winex11: Set viewport in fs_hack_setup_context().

For Star Wars - Knights of the Old Republic blank screen.

CW-Bug-Id: #19002

fshack: winex11: Also enable fshack for drawable due to gamma in create_gl_drawable().

For Star Wars - Knights of the Old Republic blank screen.

CW-Bug-Id: #19002

fshack: winex11: Use window dimensions in GL if fshack is enabled for gamma only.

For Star Wars - Knights of the Old Republic blank screen.

CW-Bug-Id: #19002

fshack: winex11: Use window size for texture and framebuffers in fs_hack_setup_context().

For Star Wars - Knights of the Old Republic blank screen.

CW-Bug-Id: #19002

fshack: winex11: Blit the contents of current framebuffer to the fshack's framebuffer in fs_hack_setup_context().

CW-Bug-Id: #20102

Some games might not clear the framebuffer on each frame and rely on the data
in framebuffer to persist through glFlush(), glFinish() etc.
That is currently not the case if the fshack is getting turned on after
some drawing was performed already.

fshack: winex11: Use specific names for textures for SWJKJA.

CW-Bug-Id: #20102

fshack: winex11: Interpolate looked up colour in gamma shader.

CW-Bug-Id: #20400

fshack: winex11: Enable specific names for textures for Quake III Arena.

CW-Bug-Id: #21474

fshack: winex11: Enable specific names for textures for Quake III Team Arena.

CW-Bug-Id: #21474

fshack: winex11: Use linear colour internal format for GL fshack buffer.

CW-Bug-Id: #22260

fshack: winex11: Always blit fs_hack in wglFlush and wglFinish when drawing to front buffer.

CW-Bug-Id: #22608

fshack: winex11: Resolve fbo for glCopyTexSubImage2D.

Based on a patch by Illia Polishchuk <[email protected]> from
ValveSoftware/wine#189

GL_INVALID_OPERATION is generated if: the effective value of GL_SAMPLE_BUFFERS
for the read framebuffer is one.

CW-Bug-Id: #22662

fshack: winex11: Resolve fbo for glCopyTexImage2D.

CW-Bug-Id: #22662

fshack: winex11: Resolve fbo for glReadPixels.

CW-Bug-Id: #22662

fshack: winex11: Save and restore GL_PIXEL_UNPACK_BUFFER_BINDING too.

CW-Bug-Id: #23257

fshack: Use texture name hack for Descent 3

Descent 3's OpenGL renderer will use a texture conflicting with the FS
hack texture, and only a small rectangle in the bottom left corner will
be rendered.

Signed-off-by: John Brooks <[email protected]>

ValveSoftware/wine#211

CW-Bug-Id: #23791

fshack: winex11.drv: Enable GL fshack blitting to GL_FRONT for Arcanum (500810).

CW-Bug-Id: #23916
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants