From b48e4e7714b1a064b947eabff0bebcfff0f9d330 Mon Sep 17 00:00:00 2001 From: Andrei Alexeyev Date: Mon, 22 Jul 2024 19:29:26 +0200 Subject: [PATCH] build,renderer: dispose of gles20's rotting corpse --- doc/BUILD.rst | 8 +-- doc/ENVIRON.rst | 4 +- meson_options.txt | 10 +--- scripts/setup-devel-build-dir.sh | 1 - src/renderer/gles20/gles20.c | 81 ------------------------------ src/renderer/gles20/gles20.h | 14 ------ src/renderer/gles20/index_buffer.c | 64 ----------------------- src/renderer/gles20/index_buffer.h | 36 ------------- src/renderer/gles20/meson.build | 8 --- src/renderer/meson.build | 10 ++-- 10 files changed, 7 insertions(+), 229 deletions(-) delete mode 100644 src/renderer/gles20/gles20.c delete mode 100644 src/renderer/gles20/gles20.h delete mode 100644 src/renderer/gles20/index_buffer.c delete mode 100644 src/renderer/gles20/index_buffer.h delete mode 100644 src/renderer/gles20/meson.build diff --git a/doc/BUILD.rst b/doc/BUILD.rst index 489f9a9a..1bf24a37 100644 --- a/doc/BUILD.rst +++ b/doc/BUILD.rst @@ -479,8 +479,6 @@ Enable or disable the various renderer backends for Taisei. meson configure build/ -Dr_gl33=enabled # for GL ES 3.0 meson configure build/ -Dr_gles30=enabled - # for GL ES 2.0 (not recommended) - meson configure build/ -Dr_gles20=enabled # No-op backend (nothing displayed). # Disabling this will break the replay-verification mode. meson configure build/ -Dr_null=enabled @@ -501,12 +499,12 @@ Default Renderer (``-Dr_default``) '''''''''''''''''''''''''''''''''' * Default: ``auto`` -* Options: ``auto``, ``gl33``, ``gles30``, ``gles20``, ``null`` +* Options: ``auto``, ``gl33``, ``gles30``, ``null`` Sets the default renderer to use when Taisei launches. When set to ``auto``, defaults to the first enabled backend in this order: -``gl33``, ``gles30``, ``gles20``. +``gl33``, ``gles30``. The chosen backend must not be disabled. @@ -516,8 +514,6 @@ The chosen backend must not be disabled. meson configure build/ -Dr_default=gl33 # for GL ES 3.0 meson configure build/ -Dr_default=gles30 - # for GL ES 2.0 (not recommended) - meson configure build/ -Dr_default=gles20 You can switch the renderer using the ``--renderer`` flag on the ``taisei`` binary. (i.e: ``taisei --renderer gles30``). diff --git a/doc/ENVIRON.rst b/doc/ENVIRON.rst index a69be9bb..7302fc70 100644 --- a/doc/ENVIRON.rst +++ b/doc/ENVIRON.rst @@ -117,12 +117,10 @@ Video and OpenGL - ``gl33``: the OpenGL 3.3 Core renderer - ``gles30``: the OpenGL ES 3.0 renderer - - ``gles20``: the OpenGL ES 2.0 renderer - ``null``: the no-op renderer (nothing is displayed) Note that the actual subset of usable backends, as well as the default - choice, can be controlled by build options. The ``gles`` backends are not - built by default. + choice, can be controlled by build options. **TAISEI_LIBGL** | Default: unset diff --git a/meson_options.txt b/meson_options.txt index c5f9b019..a7583a87 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -127,7 +127,7 @@ option( option( 'r_default', type : 'combo', - choices : ['auto', 'gl33', 'gles20', 'gles30', 'null'], + choices : ['auto', 'gl33', 'gles30', 'null'], description : 'Which rendering backend to use by default' ) @@ -139,14 +139,6 @@ option( description : 'Build the OpenGL 3.3 Core renderer' ) -option( - 'r_gles20', - type : 'feature', - value : 'disabled', - deprecated : {'true' : 'enabled', 'false' : 'disabled'}, - description : 'Build the OpenGL ES 2.0 renderer (incomplete)' -) - option( 'r_gles30', type : 'feature', diff --git a/scripts/setup-devel-build-dir.sh b/scripts/setup-devel-build-dir.sh index bbd20f21..014aa2f9 100755 --- a/scripts/setup-devel-build-dir.sh +++ b/scripts/setup-devel-build-dir.sh @@ -11,7 +11,6 @@ ${MESON:-meson} \ -Db_lto=false \ -Db_ndebug=false \ -Db_sanitize=address,undefined \ - -Dr_gles20=true \ -Dr_gles30=true \ -Dshader_transpiler=true \ -Duse_libcrypto=false \ diff --git a/src/renderer/gles20/gles20.c b/src/renderer/gles20/gles20.c deleted file mode 100644 index e1e2c28a..00000000 --- a/src/renderer/gles20/gles20.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This software is licensed under the terms of the MIT License. - * See COPYING for further information. - * --- - * Copyright (c) 2011-2024, Lukas Weber . - * Copyright (c) 2012-2024, Andrei Alexeyev . - */ - -#include "gles20.h" - -#include "../gl33/gl33.h" -#include "../gl33/vertex_array.h" // IWYU pragma: keep -#include "../glcommon/vtable.h" -#include "../glescommon/gles.h" -#include "index_buffer.h" - -static void gles20_init(void) { - gles_init(&_r_backend_gles20, 2, 0); -} - -static void gles20_init_context(SDL_Window *w) { - gles_init_context(w); - - if(!glext.vertex_array_object) { - log_fatal("GL doesn't support VAOs; no fallback implemented yet, sorry."); - } -} - -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); - - void *state; - gl33_begin_draw(varr, &state); - - IndexBuffer *ibuf = varr->index_attachment; - gles20_ibo_index_t *indices = ibuf->elements + firstidx; - assert(indices < ibuf->elements + ibuf->num_elements); - - if(instances) { - glDrawElementsInstanced(gl_prim, count, GLES20_IBO_GL_DATATYPE, indices, instances); - } else { - glDrawElements(gl_prim, count, GLES20_IBO_GL_DATATYPE, indices); - } - - gl33_end_draw(state); -} - -static void gles20_vertex_array_attach_index_buffer(VertexArray *varr, IndexBuffer *ibuf) { - // We override this function to prevent setting the index buffer dirty bit. - // Otherwise the GL33 VAO code would try to dereference index_attachment as - // another kind of struct (the GL33 IBO implementation). - varr->index_attachment = ibuf; -} - -RendererBackend _r_backend_gles20 = { - .name = "gles20", - .funcs = { - .init = gles20_init, - .texture_dump = gles_texture_dump, - .index_buffer_create = gles20_index_buffer_create, - .index_buffer_get_capacity = gles20_index_buffer_get_capacity, - .index_buffer_get_index_size = gles20_index_buffer_get_index_size, - .index_buffer_get_debug_label = gles20_index_buffer_get_debug_label, - .index_buffer_set_debug_label = gles20_index_buffer_set_debug_label, - .index_buffer_set_offset = gles20_index_buffer_set_offset, - .index_buffer_get_offset = gles20_index_buffer_get_offset, - .index_buffer_add_indices = gles20_index_buffer_add_indices, - .index_buffer_invalidate = gles20_index_buffer_invalidate, - .index_buffer_destroy = gles20_index_buffer_destroy, - .draw_indexed = gles20_draw_indexed, - .vertex_array_attach_index_buffer = gles20_vertex_array_attach_index_buffer, - }, - .custom = &(GLBackendData) { - .vtable = { - .init_context = gles20_init_context, - } - }, -}; diff --git a/src/renderer/gles20/gles20.h b/src/renderer/gles20/gles20.h deleted file mode 100644 index 9d9e3dc7..00000000 --- a/src/renderer/gles20/gles20.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * This software is licensed under the terms of the MIT License. - * See COPYING for further information. - * --- - * Copyright (c) 2011-2024, Lukas Weber . - * Copyright (c) 2012-2024, Andrei Alexeyev . - */ - -#pragma once -#include "taisei.h" - -#include "../common/backend.h" - -extern RendererBackend _r_backend_gles20; diff --git a/src/renderer/gles20/index_buffer.c b/src/renderer/gles20/index_buffer.c deleted file mode 100644 index 9f033dc3..00000000 --- a/src/renderer/gles20/index_buffer.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This software is licensed under the terms of the MIT License. - * See COPYING for further information. - * --- - * Copyright (c) 2011-2024, Lukas Weber . - * Copyright (c) 2012-2024, Andrei Alexeyev . - */ - -#include "index_buffer.h" - -IndexBuffer *gles20_index_buffer_create(uint index_size, size_t max_elements) { - assert(index_size == sizeof(gles20_ibo_index_t)); - auto ibuf = ALLOC_FLEX(IndexBuffer, max_elements * sizeof(gles20_ibo_index_t)); - snprintf(ibuf->debug_label, sizeof(ibuf->debug_label), "Fake IBO at %p", (void*)ibuf); - ibuf->num_elements = max_elements; - return ibuf; -} - -size_t gles20_index_buffer_get_capacity(IndexBuffer *ibuf) { - return ibuf->num_elements; -} - -uint gles20_index_buffer_get_index_size(IndexBuffer *ibuf) { - return sizeof(gles20_ibo_index_t); -} - -const char *gles20_index_buffer_get_debug_label(IndexBuffer *ibuf) { - return ibuf->debug_label; -} - -void gles20_index_buffer_set_debug_label(IndexBuffer *ibuf, const char *label) { - if(label) { - strlcpy(ibuf->debug_label, label, sizeof(ibuf->debug_label)); - } else { - snprintf(ibuf->debug_label, sizeof(ibuf->debug_label), "Fake IBO at %p", (void*)ibuf); - } -} - -void gles20_index_buffer_set_offset(IndexBuffer *ibuf, size_t offset) { - ibuf->offset = offset; -} - -size_t gles20_index_buffer_get_offset(IndexBuffer *ibuf) { - return ibuf->offset; -} - -void gles20_index_buffer_add_indices(IndexBuffer *ibuf, size_t data_size, void *data) { - gles20_ibo_index_t *indices = data; - attr_unused size_t num_indices = data_size / sizeof(gles20_ibo_index_t); - assert(ibuf->offset + num_indices - 1 < ibuf->num_elements); - memcpy(ibuf->elements + ibuf->offset, indices, data_size); - ibuf->offset += num_indices; -} - -void gles20_index_buffer_destroy(IndexBuffer *ibuf) { - mem_free(ibuf); -} - -void gles20_index_buffer_flush(IndexBuffer *ibuf) { -} - -void gles20_index_buffer_invalidate(IndexBuffer *ibuf) { - ibuf->offset = 0; -} diff --git a/src/renderer/gles20/index_buffer.h b/src/renderer/gles20/index_buffer.h deleted file mode 100644 index 405acec0..00000000 --- a/src/renderer/gles20/index_buffer.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This software is licensed under the terms of the MIT License. - * See COPYING for further information. - * --- - * Copyright (c) 2011-2024, Lukas Weber . - * Copyright (c) 2012-2024, Andrei Alexeyev . - */ - -#pragma once -#include "taisei.h" - -#include "../glcommon/opengl.h" -#include "../api.h" - -typedef GLushort gles20_ibo_index_t; -#define GLES20_IBO_MAX_INDEX UINT16_MAX -#define GLES20_IBO_GL_DATATYPE GL_UNSIGNED_SHORT - -typedef struct IndexBuffer { - size_t num_elements; - size_t offset; - char debug_label[R_DEBUG_LABEL_SIZE]; - gles20_ibo_index_t elements[]; -} IndexBuffer; - -IndexBuffer *gles20_index_buffer_create(uint index_size, size_t max_elements); -size_t gles20_index_buffer_get_capacity(IndexBuffer *ibuf); -uint gles20_index_buffer_get_index_size(IndexBuffer *ibuf); -const char *gles20_index_buffer_get_debug_label(IndexBuffer *ibuf); -void gles20_index_buffer_set_debug_label(IndexBuffer *ibuf, const char *label); -void gles20_index_buffer_set_offset(IndexBuffer *ibuf, size_t offset); -size_t gles20_index_buffer_get_offset(IndexBuffer *ibuf); -void gles20_index_buffer_add_indices(IndexBuffer *ibuf, size_t data_size, void *data); -void gles20_index_buffer_destroy(IndexBuffer *ibuf); -void gles20_index_buffer_flush(IndexBuffer *ibuf); -void gles20_index_buffer_invalidate(IndexBuffer *ibuf); diff --git a/src/renderer/gles20/meson.build b/src/renderer/gles20/meson.build deleted file mode 100644 index d5f65244..00000000 --- a/src/renderer/gles20/meson.build +++ /dev/null @@ -1,8 +0,0 @@ - -r_gles20_src = files( - 'gles20.c', - 'index_buffer.c', -) - -r_gles20_deps = ['glescommon'] + r_glescommon_deps -r_gles20_libdeps = r_glescommon_libdeps diff --git a/src/renderer/meson.build b/src/renderer/meson.build index dddd0d69..7bd7b25f 100644 --- a/src/renderer/meson.build +++ b/src/renderer/meson.build @@ -5,14 +5,13 @@ renderer_opts = { 'gl33' : get_option('r_gl33').require( host_machine.system() not in ['nx', 'emscripten'], error_message : 'OpenGL 3.3 is not supported on this platform'), - 'gles20' : get_option('r_gles20').disable_auto_if(not shader_transpiler_enabled), 'gles30' : get_option('r_gles30').disable_auto_if( not (shader_transpiler_enabled or transpile_glsl)), 'null' : get_option('r_null'), } default_renderer = get_option('r_default') -renderers_prio = ['gl33', 'gles30', 'gles20'] +renderers_prio = ['gl33', 'gles30'] if default_renderer == 'auto' foreach renderer : renderers_prio @@ -55,7 +54,6 @@ subdir('null') subdir('glcommon') subdir('gl33') subdir('glescommon') -subdir('gles20') subdir('gles30') included_deps = [] @@ -85,11 +83,9 @@ r_macro = ' '.join(r_macro) config.set('TAISEI_BUILDCONF_RENDERER_BACKENDS', r_macro) config.set_quoted('TAISEI_BUILDCONF_RENDERER_DEFAULT', default_renderer) -have_gles_renderer = ( - renderer_opts['gles30'].allowed() or - renderer_opts['gles20'].allowed()) +have_gles_renderer = renderer_opts['gles30'].allowed() if angle_enabled and not have_gles_renderer error('An OpenGL ES renderer is required to use ANGLE. ' + - 'Enable r_gles30 or r_gles20, or disable install_angle.') + 'Enable r_gles30, or disable install_angle.') endif