ikemen-engine / Ikemen-GO

An open-source fighting game engine that supports MUGEN resources.
https://ikemen-engine.github.io
Other
717 stars 125 forks source link

game not launching - macOS #1062

Closed yagami5846 closed 1 year ago

yagami5846 commented 1 year ago

Describe the bug

Last login: Thu Mar 16 22:30:16 on ttys001 XXX@XXX-MBP ~ % /Users/XXX/XXX/Ikemen_GO_MacOS/Ikemen_GO.command ; exit; 2023/03/16 22:31:26 Using OpenGL 2.1 ATI-4.9.48 (AMD Radeon Pro 5300M OpenGL Engine) panic: Shader compile error: ERROR: 0:1: '' : version '400' is not supported ERROR: 0:2: 'precision' : syntax error: syntax error

goroutine 1 [running, locked to thread]: main.compileShader(0x1bd4c8?, {0x100528c55, 0xe4}) /Users/runner/work/Ikemen-GO/Ikemen-GO/src/render_gl.go:86 +0x14c main.newShaderProgram({0x100528c55?, 0xc000000001?}, {0x100529480, 0x54e}, {0xc0000061a0?, 0xc0001bd578?}) /Users/runner/work/Ikemen-GO/Ikemen-GO/src/render_gl.go:51 +0x3d main.(Renderer).Init(0x10083e700) /Users/runner/work/Ikemen-GO/Ikemen-GO/src/render_gl.go:201 +0x30f main.(System).init(0x10082cae0, 0x18?, 0x0?) /Users/runner/work/Ikemen-GO/Ikemen-GO/src/system.go:417 +0x505 main.main() /Users/runner/work/Ikemen-GO/Ikemen-GO/src/main.go:86 +0x187

Saving session... ...copying shared history... ...saving history...truncating history files... ...completed.

[Process completed]

To Reproduce

i tried to launch IKEMEN GO v0.99.0-rc.1-macos (specifically Ikemen_GO.command) on my Macbook Pro 16-inch 2019 and it gave me this message

Expected behavior

No response

Screenshots / Video

No response

Engine Version (or source code date)

v0.99.0-rc.1-macos

Operating system

macOS 13.3.1

Extra context or search terms

No response

doomjoshuaboy commented 1 year ago
Using OpenGL 2.1 Metal - 83 (Apple M2)
panic: Shader compile error: ERROR: 0:1: '' :  version '400' is not supported
ERROR: 0:2: 'precision' : syntax error: syntax error

goroutine 1 [running, locked to thread]:
main.compileShader(0x2b94c8?, {0x100528c55, 0xe4})
    /Users/runner/work/test-cicd/test-cicd/src/render_gl.go:86 +0x14c
main.newShaderProgram({0x100528c55?, 0xc000000001?}, {0x100529480, 0x54e}, {0x100856940?, 0x1?})
    /Users/runner/work/test-cicd/test-cicd/src/render_gl.go:51 +0x3d
main.(*Renderer).Init(0x10083e6e0)
    /Users/runner/work/test-cicd/test-cicd/src/render_gl.go:201 +0x30f
main.(*System).init(0x10082cac0, 0x18?, 0x0?)
    /Users/runner/work/test-cicd/test-cicd/src/system.go:417 +0x505
main.main()
    /Users/runner/work/test-cicd/test-cicd/src/main.go:86 +0x187

same error but on a newer chip.

lokpro commented 1 year ago

Hi @samhocevar , could you reply this case? looks like their OpenGL 2.1 is too low? Should we add a minimum version requirement to readme? Show verbose message to users if not meet version requirement in Renderer init()?

beterhans commented 1 year ago

Same, can use mac version on Intel Mac

hans@MacMini2018 Ikemen_GO % ./Ikemen_GO.command 2023/04/02 13:54:21 Using OpenGL 2.1 INTEL-16.5.14 (Intel(R) UHD Graphics 630) panic: Shader compile error: ERROR: 0:1: '' : version '400' is not supported ERROR: 0:2: 'precision' : syntax error: syntax error

goroutine 1 [running, locked to thread]: main.compileShader(0x1b94c8?, {0x100528c55, 0xe4}) /Users/runner/work/Ikemen-GO/Ikemen-GO/src/render_gl.go:86 +0x14c main.newShaderProgram({0x100528c55?, 0xc000000001?}, {0x100529480, 0x54e}, {0xc0000061a0?, 0xc0001b9578?}) /Users/runner/work/Ikemen-GO/Ikemen-GO/src/render_gl.go:51 +0x3d main.(Renderer).Init(0x10083e700) /Users/runner/work/Ikemen-GO/Ikemen-GO/src/render_gl.go:201 +0x30f main.(System).init(0x10082cae0, 0x18?, 0x0?) /Users/runner/work/Ikemen-GO/Ikemen-GO/src/system.go:417 +0x505 main.main() /Users/runner/work/Ikemen-GO/Ikemen-GO/src/main.go:86 +0x187 hans@MacMini2018 Ikemen_GO %

Lazin3ss commented 1 year ago

Try modifying the shader version. Go into src\shaders and change the versions on all shaders to the next: #version 130. After that, build the engine and share results here.

romanthekat commented 1 year ago

Fails ±the same way for me w/ intel mac+amd video card, using version 130 didn't help:

2023/05/27 16:54:14 Using OpenGL 2.1 ATI-4.10.12 (AMD Radeon Pro 5300M OpenGL Engine)
panic: Shader compile error: ERROR: 0:1: '' :  version '130' is not supported
ERROR: 0:2: 'precision' : syntax error: syntax error

If I got it right, OpenGL 2.1 corresponds to GLSL version 120. Using this won't help though, w/ different error:

2023/05/27 17:00:23 Using OpenGL 2.1 ATI-4.10.12 (AMD Radeon Pro 5300M OpenGL Engine)
panic: Shader compile error: ERROR: 0:2: '' :   Invalid Directive: precision

Removing precision directive doesn't help either:

2023/05/27 17:04:24 Using OpenGL 2.1 ATI-4.10.12 (AMD Radeon Pro 5300M OpenGL Engine)
panic: Shader compile error: ERROR: 0:6: Invalid storage qualifiers 'in' in global variable context
ERROR: 0:7: Invalid storage qualifiers 'in' in global variable context
ERROR: 0:8: Invalid storage qualifiers 'out' in global variable context
ERROR: 0:11: Use of undeclared identifier 'texcoord'
ERROR: 0:11: Use of undeclared identifier 'uv'
ERROR: 0:12: Use of undeclared identifier 'position'

(probably these are from higher version of GLSL)

It's strange it uses OpenGL 2.1, I believe macos drivers (w/ all the opengl deprecation considered) should be capable of 4.1 at least

upd.: seems like gl-js dependency can be a reason why: macOS, Linux and Windows via OpenGL 2.1 backend. Why does it work fine on other platforms then? :)

upd. 2: found the message

Lazin3ss commented 1 year ago

@romanthekat please, try building from this branch and share the results here:

https://github.com/Lazin3ss/Ikemen-GO/tree/shader-test

In fact, I'm seeing the solution might be easier. Just change #version 400 to #version 300 es on all shaders in the master branch and it should do the trick.

romanthekat commented 1 year ago

@Lazin3ss sadly neither options worked for me.

The shader-test branch failed with:

2023/07/18 09:23:37 Using OpenGL 2.1 ATI-4.12.7 (AMD Radeon Pro 5300M OpenGL Engine)
panic: Shader compile error: ERROR: 0:1: '' :  version '100' is not supported
ERROR: 0:2: 'precision' : syntax error: syntax error

Just changing to unpatched branch with #version 300 es failed with:

2023/07/18 09:25:39 Using OpenGL 2.1 ATI-4.12.7 (AMD Radeon Pro 5300M OpenGL Engine)
panic: Shader compile error: ERROR: 0:1: '' :  version '300' is not supported
ERROR: 0:1: '' : syntax error: #version
ERROR: 0:2: 'precision' : syntax error: syntax error
Lazin3ss commented 1 year ago

Alright, I think this is the reason why shaders stopped working on OS X: https://stackoverflow.com/a/20278658

You see, in the past, shaders used to be compiled under GLSL 1.10 (as shader version wasn't declared in the original shaders), so statements like in and out used to be varying and attribute, and precision couldn't be used. This changed in these commits: e7915ca9b6ba2b8370d751e9be0af682869cb10d a8bbb637a617367a7ea2c82827140ac99ab62b4a

In e7915ca9b6ba2b8370d751e9be0af682869cb10d, version 1.00 ES started to be mandatory and precision was added, as can be seen here: https://github.com/ikemen-engine/Ikemen-GO/blob/e7915ca9b6ba2b8370d751e9be0af682869cb10d/src/render.go#L145-L156

This already started to affect OS X systems, but in a8bbb637a617367a7ea2c82827140ac99ab62b4a, version was also changed to 4.00, and all deprecated statements were replaced.

So, possible solutions to this (that I can't properly test since I don't have an OS X-based system):

1 - Rewrite the shaders so they're GLSL 1.20-compliant. This might come at a loss of improved float precision, which could create artifacts and break stages such as Endless Stairs. In that case, we can write a GLSL 1.20-compliant alternative for each current shader we have and, if the system doesn't support 4.00 version, use 1.20 instead. That would improve float precision on all systems except those that don't support it, but we would also have to mantain both shader versions. Hopefully, we won't have to do any of that.

2 - Add a new "Render" parameter in config.json from which OpenGL context can be changed (maybe this parameter can accept "OpenGL 2" or "OpenGL 3" as values). This way, we can force a OpenGL 3.2 context on OS X, which should make the shaders work again. This seems like the best solution, the only thing is, I don't know if this will work, but we can test.

So, to help with testing, I will ask to build and test two branches, and share the results here:

OpenGL 2.1 with GLSL 1.20-compliant shaders: https://github.com/Lazin3ss/Ikemen-GO/tree/osx-opengl2

OpenGL 3.2 branch: https://github.com/Lazin3ss/Ikemen-GO/tree/osx-opengl3

Also, some info regarding OpenGL and GLSL versions will be parsed in the command line. If you can share this, I will be grateful.

romanthekat commented 1 year ago

OpenGL 2.1 did work, but with classic thing "I'm rendering only a quarter":

2023/07/18 21:08:22 Using OpenGL 2.1 ATI-4.12.7 (AMD Radeon Pro 5300M OpenGL Engine)
Using OpenGL  2.1 ATI-4.12.7  ( AMD Radeon Pro 5300M OpenGL Engine )
Shader ver:  1.20
image

OpenGL 3.2 did not work, with:

panic: failed to create window: VersionUnavailable: NSGL: The targeted version of macOS only supports forward-compatible core profile contexts for OpenGL 3.2 and above

goroutine 1 [running, locked to thread]:
main.chk({0x100577ec0, 0xc00006a260})
    github.com/ikemen-engine/Ikemen-GO/src/main.go:28 +0x5f
main.(*System).init(0x1007c8c20, 0x18?, 0x0?)
    github.com/ikemen-engine/Ikemen-GO/src/system.go:378 +0x8e
main.main()
    github.com/ikemen-engine/Ikemen-GO/src/main.go:86 +0x19f
Lazin3ss commented 1 year ago

Well, at least the engine can be run again. Personally, I didn't find problems with the endless stairs stage using the first solution, so we can go with it as it is. Ikemen GO command file already has -AppleMagnifiedMode YES flag declared, so the engine might have to be run from there for now.

https://github.com/ikemen-engine/Ikemen-GO/blob/master/build/Ikemen_GO.command#L7