diff --git a/src/renderer/common/sprite_batch.c b/src/renderer/common/sprite_batch.c index c957bd42f9..2940a4f3cd 100644 --- a/src/renderer/common/sprite_batch.c +++ b/src/renderer/common/sprite_batch.c @@ -89,13 +89,7 @@ void _r_sprite_batch_init(void) { #undef VERTEX_OFS #undef INSTANCE_OFS - uint capacity; - - if(r_supports(RFEAT_DRAW_INSTANCED_BASE_INSTANCE)) { - capacity = 1 << 15; - } else { - capacity = 1 << 11; - } + uint capacity = 1 << 11; _r_sprite_batch.vbuf = r_vertex_buffer_create(sz_attr * capacity, NULL); r_vertex_buffer_set_debug_label(_r_sprite_batch.vbuf, "Sprite batch vertex buffer"); @@ -165,22 +159,8 @@ void r_flush_sprites(void) { r_cull(_r_sprite_batch.cull_mode); } - if(_r_sprite_batch.renderer_features & r_feature_bit(RFEAT_DRAW_INSTANCED_BASE_INSTANCE)) { - r_draw_model_ptr(&_r_sprite_batch.quad, pending, _r_sprite_batch.base_instance); - _r_sprite_batch.base_instance += pending; - - SDL_RWops *stream = r_vertex_buffer_get_stream(_r_sprite_batch.vbuf); - size_t remaining = SDL_RWsize(stream) - SDL_RWtell(stream); - - if(remaining < SIZEOF_SPRITE_ATTRIBS) { - // log_debug("Invalidating after %u sprites", _r_sprite_batch.base_instance); - r_vertex_buffer_invalidate(_r_sprite_batch.vbuf); - _r_sprite_batch.base_instance = 0; - } - } else { - r_draw_model_ptr(&_r_sprite_batch.quad, pending, 0); - r_vertex_buffer_invalidate(_r_sprite_batch.vbuf); - } + r_draw_model_ptr(&_r_sprite_batch.quad, pending, 0); + r_vertex_buffer_invalidate(_r_sprite_batch.vbuf); r_mat_proj_pop(); r_state_pop(); @@ -365,11 +345,7 @@ static SDL_RWops *_r_sprite_batch_prepare_buffer(void) { if(remaining < SIZEOF_SPRITE_ATTRIBS) { // TODO: maybe it is better to grow the buffer instead? - - if(!r_supports(RFEAT_DRAW_INSTANCED_BASE_INSTANCE)) { - log_warn("Vertex buffer exhausted (%zu needed for next sprite, %zu remaining), flush forced", SIZEOF_SPRITE_ATTRIBS, remaining); - } - + log_warn("Vertex buffer exhausted (%zu needed for next sprite, %zu remaining), flush forced", SIZEOF_SPRITE_ATTRIBS, remaining); r_flush_sprites(); } diff --git a/src/renderer/gl33/gl33.c b/src/renderer/gl33/gl33.c index ae4386febe..6c1ee4635e 100644 --- a/src/renderer/gl33/gl33.c +++ b/src/renderer/gl33/gl33.c @@ -292,10 +292,6 @@ static void gl33_init_context(SDL_Window *window) { if(glext.instanced_arrays) { R.features |= r_feature_bit(RFEAT_DRAW_INSTANCED); - - if(glext.base_instance) { - R.features |= r_feature_bit(RFEAT_DRAW_INSTANCED_BASE_INSTANCE); - } } if(glext.depth_texture) { @@ -985,21 +981,14 @@ void gl33_end_draw(void *state) { static void gl33_draw(VertexArray *varr, Primitive prim, uint firstvert, uint count, uint instances, uint base_instance) { assert(count > 0); + assert(base_instance == 0); GLuint gl_prim = gl33_prim_to_gl_prim(prim); void *state; gl33_begin_draw(varr, &state); if(instances) { - if(base_instance) { - #ifdef STATIC_GLES3 - log_fatal("base_instance is not supported"); - #else - glDrawArraysInstancedBaseInstance(gl_prim, firstvert, count, instances, base_instance); - #endif - } else { - glDrawArraysInstanced(gl_prim, firstvert, count, instances); - } + glDrawArraysInstanced(gl_prim, firstvert, count, instances); } else { glDrawArrays(gl_prim, firstvert, count); } @@ -1009,6 +998,7 @@ static void gl33_draw(VertexArray *varr, Primitive prim, uint firstvert, uint co static void gl33_draw_indexed(VertexArray *varr, Primitive prim, uint firstidx, uint count, uint instances, uint base_instance) { assert(count > 0); + assert(base_instance == 0); assert(varr->index_attachment != NULL); GLuint gl_prim = gl33_prim_to_gl_prim(prim); @@ -1018,15 +1008,7 @@ static void gl33_draw_indexed(VertexArray *varr, Primitive prim, uint firstidx, uintptr_t iofs = firstidx * sizeof(gl33_ibo_index_t); if(instances) { - if(base_instance) { - #ifdef STATIC_GLES3 - log_fatal("base_instance is not supported"); - #else - glDrawElementsInstancedBaseInstance(gl_prim, count, GL33_IBO_GL_DATATYPE, (void*)iofs, instances, base_instance); - #endif - } else { - glDrawElementsInstanced(gl_prim, count, GL33_IBO_GL_DATATYPE, (void*)iofs, instances); - } + glDrawElementsInstanced(gl_prim, count, GL33_IBO_GL_DATATYPE, (void*)iofs, instances); } else { glDrawElements(gl_prim, count, GL33_IBO_GL_DATATYPE, (void*)iofs); } diff --git a/src/renderer/glcommon/opengl.c b/src/renderer/glcommon/opengl.c index 23d3cdb296..3538799fad 100644 --- a/src/renderer/glcommon/opengl.c +++ b/src/renderer/glcommon/opengl.c @@ -37,24 +37,6 @@ struct glext_s glext; typedef void (*glad_glproc_ptr)(void); -#ifndef STATIC_GLES3 -// -// Extension not yet handled by glad -// - -// GL_ANGLE_base_vertex_base_instance -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEANGLEPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount, GLuint baseInstance); -static PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEANGLEPROC glad_glDrawArraysInstancedBaseInstanceANGLE; -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEANGLEPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -static PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEANGLEPROC glad_glDrawElementsInstancedBaseVertexBaseInstanceANGLE; - -APIENTRY -static void glad_glDrawElementsInstancedBaseInstanceANGLE(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance) { - // shim - glad_glDrawElementsInstancedBaseVertexBaseInstanceANGLE(mode, count, type, indices, instancecount, 0, baseinstance); -} -#endif - // WEBGL_debug_renderer_info const GLenum GL_UNMASKED_VENDOR_WEBGL = 0x9245; const GLenum GL_UNMASKED_RENDERER_WEBGL = 0x9246; @@ -235,47 +217,6 @@ static void glcommon_ext_debug_output(void) { log_warn("Extension not supported"); } -static void glcommon_ext_base_instance(void) { -#ifndef STATIC_GLES3 - if( - GL_ATLEAST(4, 2) - && (glext.DrawArraysInstancedBaseInstance = GL_FUNC(DrawArraysInstancedBaseInstance)) - && (glext.DrawElementsInstancedBaseInstance = GL_FUNC(DrawElementsInstancedBaseInstance)) - ) { - glext.base_instance = TSGL_EXTFLAG_NATIVE; - log_info("Using core functionality"); - return; - } - - if((glext.base_instance = glcommon_check_extension("GL_ARB_base_instance")) - && (glext.DrawArraysInstancedBaseInstance = GL_FUNC(DrawArraysInstancedBaseInstance)) - && (glext.DrawElementsInstancedBaseInstance = GL_FUNC(DrawElementsInstancedBaseInstance)) - ) { - log_info("Using GL_ARB_base_instance"); - return; - } - - if((glext.base_instance = glcommon_check_extension("GL_EXT_base_instance")) - && (glext.DrawArraysInstancedBaseInstance = GL_FUNC(DrawArraysInstancedBaseInstanceEXT)) - && (glext.DrawElementsInstancedBaseInstance = GL_FUNC(DrawElementsInstancedBaseInstanceEXT)) - ) { - log_info("Using GL_EXT_base_instance"); - return; - } - - if((glext.base_instance = glcommon_check_extension("GL_ANGLE_base_vertex_base_instance")) - && (glext.DrawArraysInstancedBaseInstance = GL_FUNC(DrawArraysInstancedBaseInstanceANGLE)) - && (glext.DrawElementsInstancedBaseInstance = GL_FUNC(DrawElementsInstancedBaseInstanceANGLE)) - ) { - log_info("Using GL_ANGLE_base_vertex_base_instance"); - return; - } -#endif - - glext.base_instance = 0; - log_warn("Extension not supported"); -} - static void glcommon_ext_pixel_buffer_object(void) { #ifdef STATIC_GLES3 glext.pixel_buffer_object = TSGL_EXTFLAG_NATIVE; @@ -913,7 +854,6 @@ void glcommon_check_capabilities(void) { SDL_RWclose(writer); } - glcommon_ext_base_instance(); glcommon_ext_clear_texture(); glcommon_ext_color_buffer_float(); glcommon_ext_debug_output(); @@ -996,9 +936,6 @@ void glcommon_load_functions(void) { log_fatal("Failed to load OpenGL functions"); } } - - glad_glDrawArraysInstancedBaseInstanceANGLE = (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEANGLEPROC)load_func("glDrawArraysInstancedBaseInstanceANGLE"); - glad_glDrawElementsInstancedBaseVertexBaseInstanceANGLE = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEANGLEPROC)load_func("glDrawElementsInstancedBaseVertexBaseInstanceANGLE"); #endif } diff --git a/src/renderer/glcommon/opengl.h b/src/renderer/glcommon/opengl.h index 96a12f260e..b7c11a65c4 100644 --- a/src/renderer/glcommon/opengl.h +++ b/src/renderer/glcommon/opengl.h @@ -119,7 +119,6 @@ struct glext_s { uchar avoid_sampler_uniform_updates : 1; } issues; - ext_flag_t base_instance; ext_flag_t clear_texture; ext_flag_t color_buffer_float; ext_flag_t debug_output; diff --git a/src/renderer/gles20/gles20.c b/src/renderer/gles20/gles20.c index 0c92bf6022..e3eb418d49 100644 --- a/src/renderer/gles20/gles20.c +++ b/src/renderer/gles20/gles20.c @@ -29,6 +29,7 @@ static void gles20_init_context(SDL_Window *w) { static void gles20_draw_indexed(VertexArray *varr, Primitive prim, uint firstidx, uint count, uint instances, uint base_instance) { assert(count > 0); + assert(base_instance == 0); assert(varr->index_attachment != NULL); GLuint gl_prim = gl33_prim_to_gl_prim(prim); @@ -40,11 +41,7 @@ static void gles20_draw_indexed(VertexArray *varr, Primitive prim, uint firstidx assert(indices < ibuf->elements + ibuf->num_elements); if(instances) { - if(base_instance) { - glDrawElementsInstancedBaseInstance(gl_prim, count, GLES20_IBO_GL_DATATYPE, indices, instances, base_instance); - } else { - glDrawElementsInstanced(gl_prim, count, GLES20_IBO_GL_DATATYPE, indices, instances); - } + glDrawElementsInstanced(gl_prim, count, GLES20_IBO_GL_DATATYPE, indices, instances); } else { glDrawElements(gl_prim, count, GLES20_IBO_GL_DATATYPE, indices); }