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

OpenGLES 3.2 support #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hyperlogic
Copy link
Contributor

It's understandable that you might not want this, but maybe someone might find it useful.
Also includes ~sorter bug fix in #1

radix_sort.hpp changes

  • warning fixes discovered when building for android NDK.
  • Include gles headers
  • glBufferStorage is not available in gles, implement it with glBufferData()
  • glClearBufferData is not available in gles, implement it with glBufferSubData()
  • Prepend version to shaders, "#version 320 es" and "#version 460"

glsl shader changes

  • Remove "#version 460"
  • In gles exp2 and log2 are available, but not for integers.
    so cast to float before using them.
  • No implicit signed/unsigned conversions are allowed,
    so integer constants have to be explicitly tagged as unsigned.
    This is the bulk of the changes.

call glDeleteBuffers on correct shader storage buffers.
radix_sort.hpp changes
  * Include gles headers
  * glBufferStorage is not available in gles, implement it with glBufferData()
  * glClearBufferData is not available in gles, implement it with glBufferSubData()
  * Prepend version to shaders, "#version 320 es" and "#version 460"
glsl shader changes
  * Remove "#version 460"
  * In gles exp2 and log2 are available, but not for integers.
    so cast to float before using them.
  * No implicit signed/unsigned conversions are allowed,
    so integer constants have to be explicitly tagged as unsigned.
	This is the bulk of the changes.
@loryruta loryruta self-assigned this Dec 6, 2023
@loryruta loryruta added the enhancement New feature or request label Dec 6, 2023
@loryruta
Copy link
Owner

loryruta commented Dec 6, 2023

This is very useful thank you! I actually had plans to support OpenGL ES, Vulkan and other backends.

However this PR replaces OpenGL 4.6 in favor of OpenGL ES (doesn't it?), so no, I can't directly merge this.

It would be ideal to provide a common API with different backends and with eventually different shaders. I wouldn't try to share OpenGL ES and OpenGL glsl code, I would just have "duplicated" shaders for the two backends and exploit the two at their best.

Thank you for your OpenGL ES implementation, when I'll be back on this I'll consider it!

@hyperlogic
Copy link
Contributor Author

At the moment, it will use gles if ANDROID is defined and gl otherwise. Other then the #version the glsl shaders work on both gles and gl. It should be straight forward to change ANDROID to another define like USE_OPENGLES or something.

@loryruta
Copy link
Owner

loryruta commented Dec 7, 2023

Yeah, but I think that to have two different codebases for OpenGL ES and OpenGL 4.6 would be better because OpenGL 4.6 features way more extensions than OpenGL ES and conditionally compiling with #ifdef(s) (both in host code and glsl) would lead to very messy code.

Still the API will be shared between backends, and unit test + benchmark could rely on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants