build,renderer: dispose of gles20's rotting corpse
This commit is contained in:
parent
6a84f1aee3
commit
b48e4e7714
10 changed files with 7 additions and 229 deletions
|
@ -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``).
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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 <laochailan@web.de>.
|
||||
* Copyright (c) 2012-2024, Andrei Alexeyev <akari@taisei-project.org>.
|
||||
*/
|
||||
|
||||
#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,
|
||||
}
|
||||
},
|
||||
};
|
|
@ -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 <laochailan@web.de>.
|
||||
* Copyright (c) 2012-2024, Andrei Alexeyev <akari@taisei-project.org>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "taisei.h"
|
||||
|
||||
#include "../common/backend.h"
|
||||
|
||||
extern RendererBackend _r_backend_gles20;
|
|
@ -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 <laochailan@web.de>.
|
||||
* Copyright (c) 2012-2024, Andrei Alexeyev <akari@taisei-project.org>.
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
|
@ -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 <laochailan@web.de>.
|
||||
* Copyright (c) 2012-2024, Andrei Alexeyev <akari@taisei-project.org>.
|
||||
*/
|
||||
|
||||
#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);
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue