xemu-project / xemu

Original Xbox Emulator for Windows, macOS, and Linux (Active Development)
https://xemu.app
Other
2.71k stars 268 forks source link

Ninja Gaiden Black: Intro video does not render on M1 mac #991

Open abaire opened 2 years ago

abaire commented 2 years ago

Title

https://xemu.app/titles/5443000d/#Ninja-Gaiden-Black

Bug Description

The intro video after selecting a new game does not render on M1 mac. The text overlay is shown, but the video itself is black:

Screen Shot 2022-05-28 at 12 10 23

.

Note that this works fine on other platforms and seems specific to the M1/Monterey

Expected Behavior

The video should display (there's a picture of a sword around that frame)

Screen Shot 2022-05-28 at 12 12 17

xemu Version

Version: 0.7.21-1-g8334f294df Branch: master Commit: 8334f294df46351eaed4d92eb3a264f9e7cc650b Date: Sat May 28 19:07:34 UTC 2022

I don't know if this ever worked on M1, I tested with a branch from the 0.6.x days and it did not work there either.

System Information

CPU:
OS Platform: macOS OS Version: Version 12.4 (Build 21F79) Manufacturer: Apple GPU Model: Apple M1 Max Driver: 4.1 Metal - 76.3 Shader: 4.10

Additional Context

I can fix the issue in renderdoc by clamping the oPos value. As long as the upper value is no higher than 1.0 the video shows up. E.g.,: oPos = clamp(oPos, -2, 1);, oPos = clamp(oPos, -1, 1);

notaturkey commented 1 year ago

i have the same issue using a steam deck

mbriar commented 1 year ago

Same thing happens on linux with radeonsi

GL_RENDERER: AMD Radeon RX 6700 XT (navi22, LLVM 14.0.6, DRM 3.49, 6.1.2-zen1-1-zen)
GL_VERSION: 4.6 (Core Profile) Mesa 22.3.1
mbriar commented 1 year ago

I found that setting vs_position_always_invariant=true as environment variable fixes it on radeonsi, this will most likely also work on Steam Deck, fyi @notaturkey.

mbriar commented 1 year ago

This patch also fixes it for me, I guess it might also work on mac M1

diff --git a/hw/xbox/nv2a/shaders.c b/hw/xbox/nv2a/shaders.c
index 409129e50d..abae6b851b 100644
--- a/hw/xbox/nv2a/shaders.c
+++ b/hw/xbox/nv2a/shaders.c
@@ -803,6 +803,7 @@ GLSL_DEFINE(texMat2, GLSL_C_MAT4(NV_IGRAPH_XF_XFCTX_T2MAT))
 GLSL_DEFINE(texMat3, GLSL_C_MAT4(NV_IGRAPH_XF_XFCTX_T3MAT))

 "\n"
+"invariant gl_Position;\n"
 "vec4 oPos = vec4(0.0,0.0,0.0,1.0);\n"
 "vec4 oD0 = vec4(0.0,0.0,0.0,1.0);\n"
BasicFrag commented 1 year ago

Hi there @mbriar, could you help on how to set up this environment variable and this particular patch in question. Have the exact same setup as yours (as far as gpu goes) but I am very new in the linux space.

I found that setting vs_position_always_invariant=true as environment variable fixes it on radeonsi, this will most likely also work on Steam Deck, fyi @notaturkey.

This patch also fixes it for me, I guess it might also work on mac M1

diff --git a/hw/xbox/nv2a/shaders.c b/hw/xbox/nv2a/shaders.c
index 409129e50d..abae6b851b 100644
--- a/hw/xbox/nv2a/shaders.c
+++ b/hw/xbox/nv2a/shaders.c
@@ -803,6 +803,7 @@ GLSL_DEFINE(texMat2, GLSL_C_MAT4(NV_IGRAPH_XF_XFCTX_T2MAT))
 GLSL_DEFINE(texMat3, GLSL_C_MAT4(NV_IGRAPH_XF_XFCTX_T3MAT))

 "\n"
+"invariant gl_Position;\n"
 "vec4 oPos = vec4(0.0,0.0,0.0,1.0);\n"
 "vec4 oD0 = vec4(0.0,0.0,0.0,1.0);\n"
mbriar commented 1 year ago

Hey @BasicFrag,

if you run xemu from a terminal, setting the environment variable is as easy as:

vs_position_always_invariant=true ./xemu-v0.7.83-x86_64.AppImage

if you use the flatpak you can do

flatpak run --env=vs_position_always_invariant=true app.xemu.xemu
bryanperris commented 1 year ago

It happens for the Steam Deck as well. The intro graphics (and the videos) works on old Radeon R5, using either the radeon driver or the amdgpu driver. The drawback is that emulation is very slow on the old AMD APU processor, but other than that the graphics look pretty accurate. https://www.notebookcheck.net/AMD-Radeon-R5-Beema.122502.0.html

The OS used for the R5 machine is batocera.linux

skunkfox commented 1 year ago

Confirmed that this has been an ongoing issue on the Steam Deck.

Spidy123222 commented 1 year ago

I found adding when using flatpak from using emudeck.

vs_position_always_invariant=true %command%

Was able to fix all of my steamdeck rendering issues. Even allows using burnout 3.

It doesn't work as well as the appimage version though. EDIT: changing resolution to higher gets same effect as flatpak one. But 1x has some issue but helps a little on some games.

Spidy123222 commented 1 year ago

"invariant gl_Position;\n" "vec4 oPos = vec4(0.0,0.0,0.0,1.0);\n" "vec4 oD0 = vec4(0.0,0.0,0.0,1.0);\n"

We're you thinking of adding this as a Pull request to the project? I added it to my GitHub and works on steamdeck.

https://github.com/Spidy123222/xemu/actions/runs/6062740649

mbriar commented 1 year ago

@Spidy123222 i don't know if this change is technically correct, I'm not really a graphics programmer. It just does the same as vs_position_always_invariant=true does on the driver level.

Spidy123222 commented 1 year ago

@Spidy123222 i don't know if this change is technically correct, I'm not really a graphics programmer. It just does the same as vs_position_always_invariant=true does on the driver level.

Maybe a discussion in the discord about it could work out to see if it is correct or not.

Spidy123222 commented 1 year ago

From some discussion with people testing. It breaks some games like super monkey ball. So I'm guessing it's not a proper implementation.