aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md6
-rw-r--r--sokol_gfx.h37
2 files changed, 33 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3e9043c0..3f15a136 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
## Updates
+### 19-Jan-2026
+
+- sokol_gfx.h gl: merged PR https://github.com/floooh/sokol/pull/1414, this enables
+ per-multiple-render-target color write masks on GLES3.2. Many thanks to
+ @luigi-rosso for the PR!
+
### 18-Jan-2026
Happy New Year!
diff --git a/sokol_gfx.h b/sokol_gfx.h
index 887f08a0..926a04e4 100644
--- a/sokol_gfx.h
+++ b/sokol_gfx.h
@@ -5579,7 +5579,11 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_
#include <GLES3/gl3.h>
#endif
#elif defined(__ANDROID__)
- #include <GLES3/gl31.h>
+ #if __ANDROID_API__ >= 24
+ #include <GLES3/gl32.h>
+ #else
+ #include <GLES3/gl31.h>
+ #endif
#elif defined(__linux__) || defined(__unix__)
#if defined(SOKOL_GLCORE)
#define GL_GLEXT_PROTOTYPES
@@ -5593,6 +5597,7 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_
// broad GL feature availability defines (DON'T merge this into the above ifdef-block!)
#if defined(_WIN32)
+ #define _SOKOL_GL_HAS_COLORMASKI (1)
#if defined(GL_VERSION_4_3) || defined(_SOKOL_USE_WIN32_GL_LOADER)
#define _SOKOL_GL_HAS_COMPUTE (1)
#define _SOKOL_GL_HAS_TEXVIEWS (1)
@@ -5605,6 +5610,7 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_
#define _SOKOL_GL_HAS_BASEVERTEX (1)
#endif
#elif defined(__APPLE__)
+ #define _SOKOL_GL_HAS_COLORMASKI (1)
#if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE
#define _SOKOL_GL_HAS_BASEVERTEX (1)
#else
@@ -5615,7 +5621,11 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_
#elif defined(__ANDROID__)
#define _SOKOL_GL_HAS_COMPUTE (1)
#define _SOKOL_GL_HAS_TEXSTORAGE (1)
+ #if defined(GL_ES_VERSION_3_2)
+ #define _SOKOL_GL_HAS_COLORMASKI (1)
+ #endif
#elif defined(__linux__) || defined(__unix__)
+ #define _SOKOL_GL_HAS_COLORMASKI (1)
#if defined(SOKOL_GLCORE)
#if defined(GL_VERSION_4_3)
#define _SOKOL_GL_HAS_COMPUTE (1)
@@ -9990,7 +10000,11 @@ _SOKOL_PRIVATE void _sg_gl_init_caps_gles3(void) {
_sg.features.origin_top_left = false;
_sg.features.image_clamp_to_border = false;
_sg.features.mrt_independent_blend_state = false;
+ #if defined(_SOKOL_GL_HAS_COLORMASKI)
+ _sg.features.mrt_independent_write_mask = version >= 320;
+ #else
_sg.features.mrt_independent_write_mask = false;
+ #endif
_sg.features.compute = version >= 310;
_sg.features.msaa_texture_bindings = false;
_sg.features.gl_texture_views = version >= 430;
@@ -11709,20 +11723,23 @@ _SOKOL_PRIVATE void _sg_gl_apply_render_pipeline_state(_sg_pipeline_t* pip) {
if (pip->gl.color_write_mask[i] != _sg.gl.cache.color_write_mask[i]) {
const sg_color_mask cm = pip->gl.color_write_mask[i];
_sg.gl.cache.color_write_mask[i] = cm;
- #ifdef SOKOL_GLCORE
+ if (_sg.features.mrt_independent_write_mask) {
+ #if defined(_SOKOL_GL_HAS_COLORMASKI)
glColorMaski(i,
(cm & SG_COLORMASK_R) != 0,
(cm & SG_COLORMASK_G) != 0,
(cm & SG_COLORMASK_B) != 0,
(cm & SG_COLORMASK_A) != 0);
- #else
- if (0 == i) {
- glColorMask((cm & SG_COLORMASK_R) != 0,
- (cm & SG_COLORMASK_G) != 0,
- (cm & SG_COLORMASK_B) != 0,
- (cm & SG_COLORMASK_A) != 0);
- }
- #endif
+ #else
+ // can't happen
+ SOKOL_ASSERT(false);
+ #endif
+ } else if (0 == i) {
+ glColorMask((cm & SG_COLORMASK_R) != 0,
+ (cm & SG_COLORMASK_G) != 0,
+ (cm & SG_COLORMASK_B) != 0,
+ (cm & SG_COLORMASK_A) != 0);
+ }
_sg_stats_inc(gl.num_render_state);
}
}