diff options
| author | Andre Weissflog <floooh@gmail.com> | 2023-02-15 19:15:35 +0100 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2023-02-15 19:15:35 +0100 |
| commit | 2ca013f4993144f906e641fab15a59b9b7d2ec20 (patch) | |
| tree | 61cb3b6c4f9cf6cbd775f807e750574871d1b7d9 | |
| parent | e6a6d0e833506b4fc4c2517b97ae448d1d558010 (diff) | |
sokol_gfx.h: change _SG_GL_IMAGE_CACHE_SIZE from enum to define, improve some bounds check asserts
| -rw-r--r-- | sokol_gfx.h | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/sokol_gfx.h b/sokol_gfx.h index acee15c7..c799baaa 100644 --- a/sokol_gfx.h +++ b/sokol_gfx.h @@ -4069,9 +4069,7 @@ typedef struct { GLuint texture; } _sg_gl_texture_bind_slot; -enum { - _SG_GL_IMAGE_CACHE_SIZE = SG_MAX_SHADERSTAGE_IMAGES * SG_NUM_SHADER_STAGES, -}; +#define _SG_GL_IMAGE_CACHE_SIZE (SG_MAX_SHADERSTAGE_IMAGES * SG_NUM_SHADER_STAGES) typedef struct { sg_depth_state depth; @@ -6747,7 +6745,7 @@ _SOKOL_PRIVATE void _sg_gl_cache_bind_texture(int slot_index, GLenum target, GLu target=0 will unbind the previous binding, texture=0 will clear the new binding */ - SOKOL_ASSERT(slot_index < _SG_GL_IMAGE_CACHE_SIZE); + SOKOL_ASSERT((slot_index >= 0) && (slot_index < _SG_GL_IMAGE_CACHE_SIZE)); if (slot_index >= _sg.gl.max_combined_texture_image_units) { return; } @@ -6768,12 +6766,12 @@ _SOKOL_PRIVATE void _sg_gl_cache_bind_texture(int slot_index, GLenum target, GLu } _SOKOL_PRIVATE void _sg_gl_cache_store_texture_binding(int slot_index) { - SOKOL_ASSERT(slot_index < _SG_GL_IMAGE_CACHE_SIZE); + SOKOL_ASSERT((slot_index >= 0) && (slot_index < _SG_GL_IMAGE_CACHE_SIZE)); _sg.gl.cache.stored_texture = _sg.gl.cache.textures[slot_index]; } _SOKOL_PRIVATE void _sg_gl_cache_restore_texture_binding(int slot_index) { - SOKOL_ASSERT(slot_index < _SG_GL_IMAGE_CACHE_SIZE); + SOKOL_ASSERT((slot_index >= 0) && (slot_index < _SG_GL_IMAGE_CACHE_SIZE)); _sg_gl_texture_bind_slot* slot = &_sg.gl.cache.stored_texture; if (slot->texture != 0) { /* we only care restoring valid ids */ |