gl-renderer: Set up debug mode infrastructure

Set up debug mode initial infrastructure using a dedicated key binding
and make shaders debug a debug mode.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit is contained in:
Loïc Molinari 2024-05-06 19:17:24 +02:00 committed by Derek Foreman
parent f22ca6aecc
commit 6634849dd5
4 changed files with 23 additions and 23 deletions

View file

@ -165,8 +165,8 @@ struct gl_renderer {
struct weston_compositor *compositor; struct weston_compositor *compositor;
struct weston_log_scope *renderer_scope; struct weston_log_scope *renderer_scope;
struct weston_binding *fragment_binding; struct weston_binding *debug_mode_binding;
bool fragment_shader_debug; int debug_mode;
struct weston_binding *wireframe_binding; struct weston_binding *wireframe_binding;
bool wireframe_debug; bool wireframe_debug;

View file

@ -66,6 +66,12 @@
#define BUFFER_DAMAGE_COUNT 2 #define BUFFER_DAMAGE_COUNT 2
enum gl_debug_mode {
DEBUG_MODE_NONE = 0,
DEBUG_MODE_SHADERS,
DEBUG_MODE_LAST,
};
enum gl_border_status { enum gl_border_status {
BORDER_STATUS_CLEAN = 0, BORDER_STATUS_CLEAN = 0,
BORDER_TOP_DIRTY = 1 << GL_RENDERER_BORDER_TOP, BORDER_TOP_DIRTY = 1 << GL_RENDERER_BORDER_TOP,
@ -1394,6 +1400,7 @@ draw_mesh(struct gl_renderer *gr,
sconf->req.wireframe = wireframe; sconf->req.wireframe = wireframe;
sconf->wireframe_tex = gr->wireframe_tex; sconf->wireframe_tex = gr->wireframe_tex;
} }
sconf->req.green_tint = gr->debug_mode == DEBUG_MODE_SHADERS;
if (!gl_renderer_use_program(gr, sconf)) if (!gl_renderer_use_program(gr, sconf))
gl_renderer_send_shader_error(pnode); /* Use fallback shader. */ gl_renderer_send_shader_error(pnode); /* Use fallback shader. */
@ -4149,8 +4156,8 @@ gl_renderer_destroy(struct weston_compositor *ec)
wl_array_release(&gr->barycentric_stream); wl_array_release(&gr->barycentric_stream);
wl_array_release(&gr->indices); wl_array_release(&gr->indices);
if (gr->fragment_binding) if (gr->debug_mode_binding)
weston_binding_destroy(gr->fragment_binding); weston_binding_destroy(gr->debug_mode_binding);
if (gr->wireframe_binding) if (gr->wireframe_binding)
weston_binding_destroy(gr->wireframe_binding); weston_binding_destroy(gr->wireframe_binding);
@ -4353,18 +4360,15 @@ fail:
} }
static void static void
fragment_debug_binding(struct weston_keyboard *keyboard, debug_mode_binding(struct weston_keyboard *keyboard,
const struct timespec *time, const struct timespec *time,
uint32_t key, void *data) uint32_t key, void *data)
{ {
struct weston_compositor *ec = data; struct weston_compositor *compositor = data;
struct gl_renderer *gr = get_renderer(ec); struct gl_renderer *gr = get_renderer(compositor);
struct weston_output *output;
gr->fragment_shader_debug = !gr->fragment_shader_debug; gr->debug_mode = (gr->debug_mode + 1) % DEBUG_MODE_LAST;
weston_compositor_damage_all(compositor);
wl_list_for_each(output, &ec->output_list, link)
weston_output_damage(output);
} }
static void static void
@ -4608,10 +4612,9 @@ gl_renderer_setup(struct weston_compositor *ec)
return -1; return -1;
} }
gr->fragment_binding = gr->debug_mode_binding =
weston_compositor_add_debug_binding(ec, KEY_S, weston_compositor_add_debug_binding(ec, KEY_M,
fragment_debug_binding, debug_mode_binding, ec);
ec);
gr->wireframe_binding = gr->wireframe_binding =
weston_compositor_add_debug_binding(ec, KEY_F, weston_compositor_add_debug_binding(ec, KEY_F,
wireframe_debug_repaint_binding, wireframe_debug_repaint_binding,

View file

@ -587,9 +587,6 @@ gl_renderer_get_program(struct gl_renderer *gr,
assert(reqs.pad_bits_ == 0); assert(reqs.pad_bits_ == 0);
if (gr->fragment_shader_debug)
reqs.green_tint = true;
if (gr->current_shader && if (gr->current_shader &&
gl_shader_requirements_cmp(&reqs, &gr->current_shader->key) == 0) gl_shader_requirements_cmp(&reqs, &gr->current_shader->key) == 0)
return gr->current_shader; return gr->current_shader;

View file

@ -145,9 +145,9 @@ Enable/Disable overlay planes.
.RS 4 .RS 4
Start VAAPI recorder. Start VAAPI recorder.
.RE .RE
- KEY_S : - KEY_M :
.RS 4 .RS 4
Enable fragment debugging for gl-renderer. Cycle through gl-renderer debug modes: none, shaders.
.RE .RE
- KEY_F : - KEY_F :
.RS 4 .RS 4