Skip to content
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

GRIM: Simplify shaders for Raspberry PI #2618

Merged
merged 3 commits into from Nov 13, 2020

Conversation

@lmerckx
Copy link
Contributor

@lmerckx lmerckx commented Nov 11, 2020

The shaders used by the Grim engine are not compatible with old or weak GPU (ex: Raspberry PI).

Here are the list of modifications done to support limitations:

  • glDrawElements doesn't support GL_UNSIGNED_INT on GLES2. So, I replaced it by GL_UNSIGNED_SHORT and updated associated structures (Vector3int, _indexes, ...). This modification has been separated in another pull request: #2617
  • Another limitation is the non-support of array of structures in uniforms. Raspberry's GPU supports arrays, structures but not array of structs. In that case, only the first element of the uniform is initialized.
    It is the explanation of why Manny is so dark in Grim Fandango on the PI. To solve the problem, I splitted the array of Light in 4 distinct arrays in the shader.
  • Finally, the last limitation, which causes an OutOfMemory and only on the PI (I guess) is the complexity of the shaders: conditional branching in shaders seem very badly implemented by the GPU.
    So, the advice is to split a complex shader in multiple simpler ones (ex: one with light, one without, ...).
    Following this recommendation, I split emi_actor.vertex in 3: one for actor with lights enabled, another for actors with lights disabled and the last one is for sprites (on billboard).
    For GRIM: the two first shaders are enough.

Here are my sources for RPI limitations:

For information, I've tested these modifications on Raspberry PI 2, Raspberry PI 3 (both OpenGLES2), Raspberry PI 4, Odroid XU 4 (OpenGLES3), X86-64 (OpenGLES3, OpenGL without shaders and TinyGL) and it works for any platforms.

The same modification must be done for Stark engine but it's more complex because the shaders also reach the number of uniforms limitation. Perhaps also for Wintermute for light structure. There is no problem for Myst3.

This merge has initially been proposed on ResidualVM project.
See residualvm/residualvm#1519 for the corresponding issue and details.

engines/grim/gfx_opengl_shaders.cpp Outdated Show resolved Hide resolved
engines/grim/gfx_opengl_shaders.cpp Outdated Show resolved Hide resolved
engines/grim/gfx_opengl_shaders.cpp Outdated Show resolved Hide resolved
engines/grim/gfx_opengl_shaders.cpp Outdated Show resolved Hide resolved
engines/grim/gfx_opengl_shaders.cpp Outdated Show resolved Hide resolved
engines/grim/gfx_opengl_shaders.cpp Show resolved Hide resolved
@aquadran
Copy link
Member

@aquadran aquadran commented Nov 12, 2020

please update dists/scummvm.rc

@lmerckx lmerckx requested a review from aquadran Nov 12, 2020
@aquadran aquadran merged commit d76faf1 into scummvm:master Nov 13, 2020
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deepcode-ci-bot Well done, no issues found!
Details
@lmerckx lmerckx deleted the lmerckx:grim_simplify_shaders branch Nov 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.