gl-renderer: Add damage debug mode

The damage debug mode highlights damaged surfaces with a red tint.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit is contained in:
Loïc Molinari 2024-05-07 16:45:48 +02:00 committed by Derek Foreman
parent a97307b19b
commit a804ef00ee
2 changed files with 10 additions and 6 deletions

View file

@ -71,6 +71,7 @@ enum gl_debug_mode {
DEBUG_MODE_SHADERS, DEBUG_MODE_SHADERS,
DEBUG_MODE_WIREFRAME, DEBUG_MODE_WIREFRAME,
DEBUG_MODE_BATCHES, DEBUG_MODE_BATCHES,
DEBUG_MODE_DAMAGE,
DEBUG_MODE_LAST, DEBUG_MODE_LAST,
}; };
@ -1388,10 +1389,11 @@ draw_mesh(struct gl_renderer *gr,
* tints are meant to be premultiplied, debug modes can have * tints are meant to be premultiplied, debug modes can have
* invalid colors in order to create visual effects. */ * invalid colors in order to create visual effects. */
static const float tints[DEBUG_MODE_LAST][4] = { static const float tints[DEBUG_MODE_LAST][4] = {
{}, /* DEBUG_MODE_NONE */ {}, /* DEBUG_MODE_NONE */
{ 0.0f, 0.3f, 0.0f, 0.2f }, /* DEBUG_MODE_SHADERS */ { 0.0f, 0.3f, 0.0f, 0.2f }, /* DEBUG_MODE_SHADERS */
{ 0.0f, 0.0f, 0.0f, 0.3f }, /* DEBUG_MODE_WIREFRAME */ { 0.0f, 0.0f, 0.0f, 0.3f }, /* DEBUG_MODE_WIREFRAME */
{}, /* DEBUG_MODE_BATCHES */ {}, /* DEBUG_MODE_BATCHES */
{ 0.4f, -0.4f, -0.4f, 0.0f }, /* DEBUG_MODE_DAMAGE */
}; };
static const float batch_tints[][4] = { static const float batch_tints[][4] = {
{ 0.9f, 0.0f, 0.0f, 0.9f }, { 0.9f, 0.0f, 0.0f, 0.9f },
@ -1420,6 +1422,7 @@ draw_mesh(struct gl_renderer *gr,
FALLTHROUGH; FALLTHROUGH;
case DEBUG_MODE_SHADERS: case DEBUG_MODE_SHADERS:
case DEBUG_MODE_DAMAGE:
copy_uniform4f(sconf->tint, tints[gr->debug_mode]); copy_uniform4f(sconf->tint, tints[gr->debug_mode]);
break; break;
@ -4394,7 +4397,8 @@ debug_mode_binding(struct weston_keyboard *keyboard,
mode = (gr->debug_mode + 1) % DEBUG_MODE_LAST; mode = (gr->debug_mode + 1) % DEBUG_MODE_LAST;
gr->debug_mode = mode; gr->debug_mode = mode;
gr->debug_clear = mode == DEBUG_MODE_WIREFRAME || gr->debug_clear = mode == DEBUG_MODE_WIREFRAME ||
mode == DEBUG_MODE_BATCHES; mode == DEBUG_MODE_BATCHES ||
mode == DEBUG_MODE_DAMAGE;
gr->wireframe_dirty = mode == DEBUG_MODE_WIREFRAME; gr->wireframe_dirty = mode == DEBUG_MODE_WIREFRAME;
weston_compositor_damage_all(compositor); weston_compositor_damage_all(compositor);

View file

@ -147,7 +147,7 @@ Start VAAPI recorder.
.RE .RE
- KEY_M : - KEY_M :
.RS 4 .RS 4
Cycle through gl-renderer debug modes: none, shaders, wireframe, batches. Cycle through gl-renderer debug modes: none, shaders, wireframe, batches, damage.
.RE .RE
- KEY_R : - KEY_R :
.RS 4 .RS 4