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

sokol_gfx.h: add support for half-float vertex attributes #745

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

darkuranium
Copy link
Contributor

@darkuranium darkuranium commented Nov 15, 2022

I had a need for half-float vertex attributes to save on memory, and figured this would be a useful addition upstream. Feel free to ignore this pull request if you disagree.

From my own research, it should be available on nearly all GLES2 devices (94.5% coverage according to http://opengles.gpuinfo.org/listextensions.php), and all WebGL2/GLES3 devices.

Note: A useful addition would be a uint16_t sg_half_from_float(float) / float sg_float_from_half(uint16_t) utility function pair, to help with float16⇔float32 conversion.
It is not part of this pull request (mainly since it's not strictly speaking part of sokol_gfx's core purpose), but I do have code available, if needed.

The SG_VERTEXFORMAT_HALF{2,4} enums are positioned at the end of the existing enum list, for integer-backwards-compatibility reasons. Feel free to reshuffle these if desired.

@floooh
Copy link
Owner

floooh commented Jan 16, 2023

Checking this out now. I think the helper functions to convert between float16 and float32 are out of the scope of sokol-gfx though. If there ever would be a sokol_math.h header, it would better fit in there ;)

@floooh floooh merged commit 86f5523 into floooh:master Jan 16, 2023
@floooh
Copy link
Owner

floooh commented Jan 16, 2023

...and merged. Many thanks!

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

Successfully merging this pull request may close these issues.

2 participants