Terasology
Terasology copied to clipboard
feat(reactor): make separate graphic scheduler/thread
Contains
- Introducing GRAPHICS Scheduler
- wraps calls to GL/GLFW to runBlocking at graphics scheduler ( hopping flow to another thread)
- Splash screen should works at MacOS now. (ref: https://github.com/MovingBlocks/Terasology/issues/4206)
- splitting opengl context between splashscreen and game
- wrapped calls to runBlocking should tracking by ActivityMonitor Ref: https://github.com/MovingBlocks/SplashScreen/pull/7 has macos specific flags for macos (should helps with macos glitches like red window, wring dpi)
How to test
- runs Terasology with splash screen (especial at MacOs)
- start any gameplay
- try to call maximum rendering stuffs 3.1. block digging particles 3.2. different Overlay renderer.
Outstanding before merging
- [x] docs
- [ ] refactor
- [x] cleanup
After merge:
- rethink/refactor reactor usage with LWJGL subsystem, lwjgl's assets and opengl rendering.
TeraED was broken before this PR :( seems splashscreen flag was broken at Pico-cli PR (you cannot disable splashscreen)
I did run gradlew game on Mac OS with this PR. The splash screen is not rendering correctly (it's a flashing, half-transparent red rectangle on screen), but the game starts up fine afterwards.
I could not really play it as I was at 0.6 fps, but that might be related to too much load on my machine...
TeraED was broken before this PR :(
What do you mean by that? I haven't tried to start TeraED for ages, but it at least compiled just fine when running gradlew jar for the whole workspace :thinking:
What do you mean by that? I haven't tried to start TeraED for ages, but it at least compiled just fine when running gradlew jar for the whole workspace 🤔
TeraED hardcrashes with many nullpointers during initializing MainMenuState. This errors not related with rendering code.
I could not really play it as I was at 0.6 fps, but that might be related to too much load on my machine...
Hmm. Which gpu are you using? Seems macbooks have 2 gpus(or not) What about without splash screen?(flag --no-splash not works after picocli(seems)) And how without this pr?
The splash screen is not rendering correctly (it's a flashing, half-transparent red rectangle on screen), but the game starts up fine afterwards.
Sounds familiar. With red rectangle. I will google it.
Ok. Splashscreen Rendering issues at macos should be resolved at splashscreen repo. (I will create issue tomorrow)
@skaldarnar recheck at macos plz. enabled vsync - should helps a bit.
Now I get the following error about my Mac not being able to support the required OpenGL version (I think that's what '330' refers to, right?)... 😕 It should be able to meet this requirement, though (MacBook Pro 15, 2016), listed with support for OpenGL v4.1 on Apple's support site.
java.lang.RuntimeException: ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:1: '' : syntax error: #version
at org.terasology.splash.glfw.graphics.Shader.checkStatus(Shader.java:87)
at org.terasology.splash.glfw.graphics.Shader.compile(Shader.java:78)
at org.terasology.splash.glfw.graphics.Shader.createShader(Shader.java:119)
at org.terasology.splash.glfw.graphics.Shader.loadShader(Shader.java:146)
at org.terasology.splash.glfw.graphics.Renderer.setupShaderProgram(Renderer.java:407)
at org.terasology.splash.glfw.graphics.Renderer.init(Renderer.java:77)
at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:185)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120)
at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:200)
at reactor.core.publisher.FluxSubscribeOnValue$ScheduledScalar.run(FluxSubscribeOnValue.java:180)
at org.terasology.engine.core.schedulers.ThreadCaptureScheduler.start(ThreadCaptureScheduler.java:59)
at org.terasology.engine.Terasology.main(Terasology.java:157)
Suppressed: java.lang.Exception: #block terminated with an error
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
at reactor.core.publisher.Mono.block(Mono.java:1706)
at org.terasology.engine.GLFWSplashScreen.run(GLFWSplashScreen.java:64)
at org.terasology.engine.Terasology.call(Terasology.java:168)
at org.terasology.engine.Terasology.call(Terasology.java:68)
at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
at picocli.CommandLine.access$1200(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
at picocli.CommandLine.execute(CommandLine.java:2058)
at org.terasology.engine.Terasology.lambda$main$0(Terasology.java:146)
at java.base/java.lang.Thread.run(Thread.java:829)
However, glxinfo also just shows "2.1 ATI-4.7.103" while picking up the Radeon GPU...
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: AMD Radeon Pro 455 OpenGL Engine
OpenGL version string: 2.1 ATI-4.7.103
OpenGL shading language version string: 1.20
Edit: Seems related to MC-153714, siumilar error and similar/same detected version
This question on StackOverflow suggests to replace your code from #include <gl.h> to #include <gl3.h>. Maybe that helps? I tried pluggin in the power cord, and also disable the automatic graphis switching, but both did not help with this...
@skaldarnar Welcome to test :) pollend update those shaders to 330.. but don't update splashscreen don't forget https://github.com/MovingBlocks/SplashScreen/pull/7 for resolve graphics glitches at splashscreen (at least several)
The changes seem to help a bit, but it's still not working on (my) Mac :confused:
The splash screen window appears before startup, but is rendered as flickering red triangle. No images or text are shown. I did check this with the https://github.com/MovingBlocks/SplashScreen/pull/7 by doing the following, did not help - do I need to set up/configure anything else?
groovyw lib get SplashScreen
cd libs/SplashScreen
gh pr checkout 7
Eventually, the main menu shows up, but when I try to start/create a world the game crashes before anything is rendered on screen with the following error. The loading bar reaches the end and is "Catching World", it looks like it crashes right before rendering the first in-game frame...
FATAL ERROR in native method: Thread[GRAPHICS,5,main]: No context is current or a function that is not available in the current context was called. The JVM will abort execution.
at org.lwjgl.opengl.EXTFramebufferObject.glBindFramebufferEXT(Native Method)
at org.terasology.engine.rendering.dag.stateChanges.BindFbo.process(BindFbo.java:62)
at org.terasology.engine.rendering.world.WorldRendererImpl$$Lambda$809/0x00000008007e0040.accept(Unknown Source)
at java.util.ArrayList.forEach([email protected]/ArrayList.java:1541)
at org.terasology.engine.rendering.world.WorldRendererImpl.render(WorldRendererImpl.java:351)
at org.terasology.engine.core.modes.StateIngame.render(StateIngame.java:223)
at org.terasology.engine.core.subsystem.lwjgl.LwjglGraphics.lambda$postUpdate$1(LwjglGraphics.java:82)
at org.terasology.engine.core.subsystem.lwjgl.LwjglGraphics$$Lambda$530/0x0000000800699040.run(Unknown Source)
at reactor.core.publisher.MonoRunnable.subscribe(MonoRunnable.java:49)
at reactor.core.publisher.MonoUsing.subscribe(MonoUsing.java:109)
at reactor.core.publisher.Mono.subscribe(Mono.java:4399)
at reactor.core.publisher.MonoSubscribeOn$SubscribeOnSubscriber.run(MonoSubscribeOn.java:126)
at org.terasology.engine.core.schedulers.ThreadCaptureScheduler.start(ThreadCaptureScheduler.java:59)
at org.terasology.engine.Terasology.main(Terasology.java:157)