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

Improve GLSL renderer compatibility with GLES and older cards. #254

Merged
merged 16 commits into from Apr 27, 2021

Conversation

AliceLR
Copy link
Owner

@AliceLR AliceLR commented Aug 10, 2020

This branch makes some adjustments to the GLSL renderer's texture packing to make it easier for older cards with bad float precision and GLES implementations (which may not have high precision floats in the fragment shader) to not display complete garbage. Requires a minor version increase since it significantly changes the shaders. As a side note, this method of fixing the issue performs a lot better than other (less compatible) solutions I tried like uniform buffers and performing the unpacking step in the vertex shader.

  • Use packing formats that keep each component confined within useful byte boundaries.
  • Unpack the char and SMZX subpalette high and low bytes separately so their values fit comfortably within mediump.
  • Fix char precision issues without highp if possible. Not possible with standard 2^-10 mediump floats; they simply can't accurately represent the texture coordinates required including error (my Nexus 7's Adreno 320 will accumulate too much error with mediump floats as early as the initial texture2D() call to get the layer data!). Instead, MZX will print warnings when highp is unavailable for fragment shaders (and particularly when mediump may not be able to handle the fragment shaders).
  • Use highp floats when available.
  • Enable the GLSL renderer for Android builds.
  • Make softscale the default renderer for Android even when GLSL is enabled.
  • Remove GL4ES from the GLSL blacklist.
  • Changelog:
+ Simplified GLSL renderer texture data packing to improve
  support for OpenGL ES and older OpenGL implementations.
+ The GLSL tilemap fragment shaders will now use highp floats if
  provided by the OpenGL ES driver. If highp is unavailable and
  mediump has inadequate precision, MZX will print a warning.
+ Enabled the GLSL renderer for the Android port. The Android
  port will still use the softscale renderer by default.
- Removed GL4ES from the GLSL blacklist. 

These may be unchecked as changes are added.

  • Testing (GeForce GTX 660, Windows 10).
  • Testing (GeForce 940MX, Windows 10).
  • Testing (Intel HD Graphics 520, Windows 10).
  • Testing (GeForce 940M, Linux/NV118).
  • Testing (Intel HD Graphics 5500, Linux).
  • Testing (Radeon X1600, Snow Leopard).
  • Testing (Radeon X1600, Linux).
  • Testing (Radeon HD 6630M, High Sierra).
  • Testing (Adreno 506, Android 8.1).
  • Testing (Adreno 320, Android 6.0).
  • Testing (Emscripten)

@AliceLR AliceLR merged commit 9198eba into master Apr 27, 2021
@AliceLR AliceLR deleted the glsl-fix-unpacking branch April 27, 2021 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant