diff options
| author | Andre Weissflog <floooh@gmail.com> | 2025-10-04 14:57:31 +0200 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2025-10-04 14:57:31 +0200 |
| commit | f34f3b4edfe59a24efddd775baee2b974a7be98a (patch) | |
| tree | dcc7f8381e0ccc4419795304b46784fe8def5305 | |
| parent | 36890e9a430dcda234dfe29f5851bd70ea43e37a (diff) | |
sokol_gfx.h: remove sg_features.draw_base_vertex_base_index, add inline docs for sg_draw_ex
| -rw-r--r-- | sokol_gfx.h | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/sokol_gfx.h b/sokol_gfx.h index dede5306..48d66f18 100644 --- a/sokol_gfx.h +++ b/sokol_gfx.h @@ -206,6 +206,23 @@ containing per-instance data must be bound, and the num_instances parameter must be > 1. + Alternatively, call: + + sg_draw_ex(...) + + to provide a base-vertex and/or base-instance which allows to render + from different sections of a vertex buffer without rebinding the + vertex buffer with a different offset. Note that the `sg_draw_ex()` + only has limited portability on OpenGL, check the sg_limits struct + members .draw_base_vertex and .draw_base_instance for runtime support, + those are generally true on non-GL-backends, and on GL the feature + flags are set according to the GL version: + + - on GL base_instance != 0 is only supported since GL 4.2 + - on GLES3.x, base_instance != 0 is not supported + - on GLES3.x, base_vertex is only supported since GLES3.2 + (e.g. not supported on WebGL2) + --- ...or kick of a dispatch call to invoke a compute shader workload: sg_dispatch(int num_groups_x, int num_groups_y, int num_groups_z) @@ -2193,8 +2210,7 @@ typedef struct sg_features { bool msaa_texture_bindings; // if true, multisampled images can be bound as textures bool separate_buffer_types; // cannot use the same buffer for vertex and indices (only WebGL2) bool draw_base_vertex; // draw with (base vertex > 0) && (base_instance == 0) supported - bool draw_base_instance; // draw with (base instance > 0) && (base_vertex == 0) supported - bool draw_base_vertex_base_instance; // draw with (base vertex > 0) && (base_instance > 0) supported + bool draw_base_instance; // draw with (base instance > 0) supported bool gl_texture_views; // supports 'proper' texture views (GL 4.3+) } sg_features; @@ -4671,7 +4687,6 @@ typedef struct sg_frame_stats { _SG_LOGITEM_XMACRO(VALIDATE_DRAW_EX_BASEINSTANCE_VS_INSTANCED, "sg_draw_ex(): base_instance must be == 0 for non-instanced rendering") \ _SG_LOGITEM_XMACRO(VALIDATE_DRAW_EX_BASEVERTEX_NOT_SUPPORTED, "sg_draw_ex(): base_vertex > 0 not supported on this backend (sg_features.draw_base_vertex)") \ _SG_LOGITEM_XMACRO(VALIDATE_DRAW_EX_BASEINSTANCE_NOT_SUPPORTED, "sg_draw_ex(): base_instance > 0 not supported on this backend (sg_features.draw_base_instance)") \ - _SG_LOGITEM_XMACRO(VALIDATE_DRAW_EX_BASEVERTEXINSTANCE_NOT_SUPPORTED, "sg_draw_ex(): (base_vertex > 0) && (base_instance > 0) not supported on this backend (sg_features.draw_base_vertex_base_instance)") \ _SG_LOGITEM_XMACRO(VALIDATE_DRAW_REQUIRED_BINDINGS_OR_UNIFORMS_MISSING, "sg_draw: call to sg_apply_bindings() and/or sg_apply_uniforms() missing after sg_apply_pipeline()") \ _SG_LOGITEM_XMACRO(VALIDATE_DISPATCH_COMPUTEPASS_EXPECTED, "sg_dispatch: must be called in a compute pass") \ _SG_LOGITEM_XMACRO(VALIDATE_DISPATCH_NUMGROUPSX, "sg_dispatch: num_groups_x must be >=0 and <65536") \ @@ -8610,7 +8625,6 @@ _SOKOL_PRIVATE void _sg_dummy_update_image(_sg_image_t* img, const sg_image_data _SG_XMACRO(glTextureView, void, (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers)) \ _SG_XMACRO(glDrawElementsBaseVertex, void, (GLenum mode, GLsizei count, GLenum type, const void* indices, GLint basevertex)) \ _SG_XMACRO(glDrawElementsInstancedBaseVertex, void, (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei instancecount, GLint basevertex)) \ - _SG_XMACRO(glDrawElementsInstancedBaseInstance, void, (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei instancecount, GLuint baseinstance)) \ _SG_XMACRO(glDrawElementsInstancedBaseVertexBaseInstance, void, (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance)) \ _SG_XMACRO(glDrawArraysInstancedBaseInstance, void, (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance)) @@ -9428,7 +9442,6 @@ _SOKOL_PRIVATE void _sg_gl_init_caps_glcore(void) { #endif _sg.features.draw_base_vertex = version >= 320; _sg.features.draw_base_instance = version >= 420; - _sg.features.draw_base_vertex_base_instance = version >= 420; // scan extensions bool has_s3tc = false; // BC1..BC3 @@ -9513,7 +9526,6 @@ _SOKOL_PRIVATE void _sg_gl_init_caps_gles3(void) { #endif _sg.features.draw_base_vertex = version >= 320; _sg.features.draw_base_instance = false; - _sg.features.draw_base_vertex_base_instance = false; bool has_s3tc = false; // BC1..BC3 bool has_rgtc = false; // BC4 and BC5 @@ -11499,11 +11511,7 @@ _SOKOL_PRIVATE void _sg_gl_draw(int base_element, int num_elements, int num_inst #if defined(_SOKOL_GL_HAS_BASEVERTEX) glDrawElementsInstancedBaseVertex(p_type, num_elements, i_type, indices, num_instances, base_vertex); #endif - } else if ((base_vertex == 0) && (base_instance != 0) && _sg.features.draw_base_instance) { - #if defined(_SOKOL_GL_HAS_BASEINSTANCE) - glDrawElementsInstancedBaseInstance(p_type, num_elements, i_type, indices, num_instances, (GLuint)base_instance); - #endif - } else if ((base_vertex != 0) && (base_instance != 0) && _sg.features.draw_base_vertex_base_instance) { + } else if ((base_instance != 0) && _sg.features.draw_base_instance) { #if defined(_SOKOL_GL_HAS_BASEINSTANCE) glDrawElementsInstancedBaseVertexBaseInstance(p_type, num_elements, i_type, indices, num_instances, base_vertex, (GLuint)base_instance); #endif @@ -12493,7 +12501,6 @@ _SOKOL_PRIVATE void _sg_d3d11_init_caps(void) { _sg.features.msaa_texture_bindings = true; _sg.features.draw_base_vertex = true; _sg.features.draw_base_instance = true; - _sg.features.draw_base_vertex_base_instance = true; _sg.limits.max_image_size_2d = 16 * 1024; _sg.limits.max_image_size_cube = 16 * 1024; @@ -14470,7 +14477,6 @@ _SOKOL_PRIVATE void _sg_mtl_init_caps(void) { _sg.features.msaa_texture_bindings = true; _sg.features.draw_base_vertex = true; _sg.features.draw_base_instance = true; - _sg.features.draw_base_vertex_base_instance = true; _sg.features.image_clamp_to_border = false; #if (MAC_OS_X_VERSION_MAX_ALLOWED >= 120000) || (__IPHONE_OS_VERSION_MAX_ALLOWED >= 140000) @@ -16484,7 +16490,6 @@ _SOKOL_PRIVATE void _sg_wgpu_init_caps(void) { _sg.features.msaa_texture_bindings = true; _sg.features.draw_base_vertex = true; _sg.features.draw_base_instance = true; - _sg.features.draw_base_vertex_base_instance = true; wgpuDeviceGetLimits(_sg.wgpu.dev, &_sg.wgpu.limits); @@ -19973,9 +19978,6 @@ _SOKOL_PRIVATE bool _sg_validate_draw_ex(int base_element, int num_elements, int if (base_instance > 0) { _SG_VALIDATE(_sg.features.draw_base_instance, VALIDATE_DRAW_EX_BASEINSTANCE_NOT_SUPPORTED); } - if ((base_vertex > 0) && (base_instance > 0)) { - _SG_VALIDATE(_sg.features.draw_base_vertex_base_instance, VALIDATE_DRAW_EX_BASEVERTEXINSTANCE_NOT_SUPPORTED); - } if (!_sg.use_indexed_draw) { _SG_VALIDATE(base_vertex == 0, VALIDATE_DRAW_EX_BASEVERTEX_VS_INDEXED); } |