gl-renderer: Move debug mode setup to dedicated func

This moves debug mode setup to a dedicated function because the
addition of new modes made it bigger.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit is contained in:
Loïc Molinari 2024-06-06 18:37:25 +02:00 committed by Derek Foreman
parent e512f5482d
commit dbf408791c

View File

@ -1374,21 +1374,14 @@ store_indices(size_t count,
}
static void
draw_mesh(struct gl_renderer *gr,
struct weston_paint_node *pnode,
set_debug_mode(struct gl_renderer *gr,
struct gl_shader_config *sconf,
const struct clipper_vertex *positions,
const uint32_t *barycentrics,
const uint16_t *indices,
int nidx,
bool opaque)
{
assert(nidx > 0);
if (gr->debug_mode) {
/* Debug mode tints indexed by gl_debug_mode enumeration. While
* tints are meant to be premultiplied, debug modes can have
* invalid colors in order to create visual effects. */
/* Debug mode tints indexed by gl_debug_mode enumeration. While tints
* are meant to be premultiplied, debug modes can have invalid colors in
* order to create visual effects. */
static const float tints[DEBUG_MODE_LAST][4] = {
{}, /* DEBUG_MODE_NONE */
{ 0.0f, 0.0f, 0.0f, 0.3f }, /* DEBUG_MODE_WIREFRAME */
@ -1409,9 +1402,8 @@ draw_mesh(struct gl_renderer *gr,
switch (gr->debug_mode) {
case DEBUG_MODE_WIREFRAME:
/* Wireframe rendering is based on Celes & Abraham's
* "Fast and versatile texture-based wireframe
* rendering", 2011. */
/* Wireframe rendering is based on Celes & Abraham's "Fast and
* versatile texture-based wireframe rendering", 2011. */
sconf->req.wireframe = true;
sconf->wireframe_tex = gr->wireframe_tex;
glEnableVertexAttribArray(SHADER_ATTRIB_LOC_BARYCENTRIC);
@ -1441,6 +1433,21 @@ draw_mesh(struct gl_renderer *gr,
}
}
static void
draw_mesh(struct gl_renderer *gr,
struct weston_paint_node *pnode,
struct gl_shader_config *sconf,
const struct clipper_vertex *positions,
const uint32_t *barycentrics,
const uint16_t *indices,
int nidx,
bool opaque)
{
assert(nidx > 0);
if (gr->debug_mode)
set_debug_mode(gr, sconf, barycentrics, opaque);
if (!gl_renderer_use_program(gr, sconf))
gl_renderer_send_shader_error(pnode); /* Use fallback shader. */