libobs: UI: Use graphics debug markers
Add D3D/GL debug markers to make RenderDoc captures easier to tranverse. Also add obs_source_get_name_no_null() to avoid boilerplate for safe string formatting. Closes obsproject/obs-studio#1799
This commit is contained in:
parent
2996a6c06b
commit
21f4dd63d4
@ -1305,6 +1305,8 @@ void OBSBasic::SetPreviewProgramMode(bool enabled)
|
||||
|
||||
void OBSBasic::RenderProgram(void *data, uint32_t cx, uint32_t cy)
|
||||
{
|
||||
GS_DEBUG_MARKER_BEGIN(GS_DEBUG_COLOR_DEFAULT, "RenderProgram");
|
||||
|
||||
OBSBasic *window = static_cast<OBSBasic*>(data);
|
||||
obs_video_info ovi;
|
||||
|
||||
@ -1333,6 +1335,8 @@ void OBSBasic::RenderProgram(void *data, uint32_t cx, uint32_t cy)
|
||||
gs_projection_pop();
|
||||
gs_viewport_pop();
|
||||
|
||||
GS_DEBUG_MARKER_END();
|
||||
|
||||
UNUSED_PARAMETER(cx);
|
||||
UNUSED_PARAMETER(cy);
|
||||
}
|
||||
|
@ -3311,6 +3311,8 @@ void OBSBasic::DrawBackdrop(float cx, float cy)
|
||||
if (!box)
|
||||
return;
|
||||
|
||||
GS_DEBUG_MARKER_BEGIN(GS_DEBUG_COLOR_DEFAULT, "DrawBackdrop");
|
||||
|
||||
gs_effect_t *solid = obs_get_base_effect(OBS_EFFECT_SOLID);
|
||||
gs_eparam_t *color = gs_effect_get_param_by_name(solid, "color");
|
||||
gs_technique_t *tech = gs_effect_get_technique(solid, "Solid");
|
||||
@ -3333,10 +3335,14 @@ void OBSBasic::DrawBackdrop(float cx, float cy)
|
||||
gs_technique_end(tech);
|
||||
|
||||
gs_load_vertexbuffer(nullptr);
|
||||
|
||||
GS_DEBUG_MARKER_END();
|
||||
}
|
||||
|
||||
void OBSBasic::RenderMain(void *data, uint32_t cx, uint32_t cy)
|
||||
{
|
||||
GS_DEBUG_MARKER_BEGIN(GS_DEBUG_COLOR_DEFAULT, "RenderMain");
|
||||
|
||||
OBSBasic *window = static_cast<OBSBasic*>(data);
|
||||
obs_video_info ovi;
|
||||
|
||||
@ -3367,7 +3373,6 @@ void OBSBasic::RenderMain(void *data, uint32_t cx, uint32_t cy)
|
||||
|
||||
window->DrawBackdrop(float(ovi.base_width), float(ovi.base_height));
|
||||
|
||||
|
||||
if (window->IsPreviewProgramMode()) {
|
||||
OBSScene scene = window->GetCurrentScene();
|
||||
obs_source_t *source = obs_scene_get_source(scene);
|
||||
@ -3393,6 +3398,8 @@ void OBSBasic::RenderMain(void *data, uint32_t cx, uint32_t cy)
|
||||
gs_projection_pop();
|
||||
gs_viewport_pop();
|
||||
|
||||
GS_DEBUG_MARKER_END();
|
||||
|
||||
UNUSED_PARAMETER(cx);
|
||||
UNUSED_PARAMETER(cy);
|
||||
}
|
||||
|
@ -1360,6 +1360,8 @@ bool OBSBasicPreview::DrawSelectedOverflow(obs_scene_t *scene,
|
||||
if (!visible)
|
||||
return true;
|
||||
|
||||
GS_DEBUG_MARKER_BEGIN(GS_DEBUG_COLOR_DEFAULT, "DrawSelectedOverflow");
|
||||
|
||||
obs_transform_info info;
|
||||
obs_sceneitem_get_info(item, &info);
|
||||
|
||||
@ -1385,6 +1387,8 @@ bool OBSBasicPreview::DrawSelectedOverflow(obs_scene_t *scene,
|
||||
|
||||
gs_matrix_pop();
|
||||
|
||||
GS_DEBUG_MARKER_END();
|
||||
|
||||
UNUSED_PARAMETER(scene);
|
||||
return true;
|
||||
}
|
||||
@ -1450,6 +1454,8 @@ bool OBSBasicPreview::DrawSelectedItem(obs_scene_t *scene,
|
||||
if (!visible)
|
||||
return true;
|
||||
|
||||
GS_DEBUG_MARKER_BEGIN(GS_DEBUG_COLOR_DEFAULT, "DrawSelectedItem");
|
||||
|
||||
obs_transform_info info;
|
||||
obs_sceneitem_get_info(item, &info);
|
||||
|
||||
@ -1501,6 +1507,8 @@ bool OBSBasicPreview::DrawSelectedItem(obs_scene_t *scene,
|
||||
|
||||
gs_matrix_pop();
|
||||
|
||||
GS_DEBUG_MARKER_END();
|
||||
|
||||
UNUSED_PARAMETER(scene);
|
||||
UNUSED_PARAMETER(param);
|
||||
return true;
|
||||
@ -1517,6 +1525,8 @@ void OBSBasicPreview::DrawOverflow()
|
||||
if (hidden)
|
||||
return;
|
||||
|
||||
GS_DEBUG_MARKER_BEGIN(GS_DEBUG_COLOR_DEFAULT, "DrawOverflow");
|
||||
|
||||
if (!overflow) {
|
||||
std::string path;
|
||||
GetDataFilePath("images/overflow.png", path);
|
||||
@ -1535,6 +1545,8 @@ void OBSBasicPreview::DrawOverflow()
|
||||
}
|
||||
|
||||
gs_load_vertexbuffer(nullptr);
|
||||
|
||||
GS_DEBUG_MARKER_END();
|
||||
}
|
||||
|
||||
void OBSBasicPreview::DrawSceneEditing()
|
||||
@ -1542,6 +1554,8 @@ void OBSBasicPreview::DrawSceneEditing()
|
||||
if (locked)
|
||||
return;
|
||||
|
||||
GS_DEBUG_MARKER_BEGIN(GS_DEBUG_COLOR_DEFAULT, "DrawSceneEditing");
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
||||
|
||||
gs_effect_t *solid = obs_get_base_effect(OBS_EFFECT_SOLID);
|
||||
@ -1567,6 +1581,8 @@ void OBSBasicPreview::DrawSceneEditing()
|
||||
|
||||
gs_technique_end_pass(tech);
|
||||
gs_technique_end(tech);
|
||||
|
||||
GS_DEBUG_MARKER_END();
|
||||
}
|
||||
|
||||
void OBSBasicPreview::ResetScrollingOffset()
|
||||
|
@ -175,7 +175,6 @@ static inline void render_display_begin(struct obs_display *display,
|
||||
static inline void render_display_end()
|
||||
{
|
||||
gs_end_scene();
|
||||
gs_present();
|
||||
}
|
||||
|
||||
void render_display(struct obs_display *display)
|
||||
@ -185,6 +184,8 @@ void render_display(struct obs_display *display)
|
||||
|
||||
if (!display || !display->enabled) return;
|
||||
|
||||
GS_DEBUG_MARKER_BEGIN(GS_DEBUG_COLOR_DISPLAY, "obs_display");
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
pthread_mutex_lock(&display->draw_info_mutex);
|
||||
@ -214,6 +215,10 @@ void render_display(struct obs_display *display)
|
||||
pthread_mutex_unlock(&display->draw_callbacks_mutex);
|
||||
|
||||
render_display_end();
|
||||
|
||||
GS_DEBUG_MARKER_END();
|
||||
|
||||
gs_present();
|
||||
}
|
||||
|
||||
void obs_display_set_enabled(obs_display_t *display, bool enable)
|
||||
|
@ -462,6 +462,8 @@ static inline bool item_texture_enabled(const struct obs_scene_item *item)
|
||||
|
||||
static void render_item_texture(struct obs_scene_item *item)
|
||||
{
|
||||
GS_DEBUG_MARKER_BEGIN(GS_DEBUG_COLOR_ITEM_TEXTURE, "render_item_texture");
|
||||
|
||||
gs_texture_t *tex = gs_texrender_get_texture(item->item_render);
|
||||
gs_effect_t *effect = obs->video.default_effect;
|
||||
enum obs_scale_type type = item->scale_filter;
|
||||
@ -505,16 +507,22 @@ static void render_item_texture(struct obs_scene_item *item)
|
||||
|
||||
while (gs_effect_loop(effect, "Draw"))
|
||||
obs_source_draw(tex, 0, 0, 0, 0, 0);
|
||||
|
||||
GS_DEBUG_MARKER_END();
|
||||
}
|
||||
|
||||
static inline void render_item(struct obs_scene_item *item)
|
||||
{
|
||||
GS_DEBUG_MARKER_BEGIN_FORMAT(GS_DEBUG_COLOR_ITEM, "Item: %s",
|
||||
obs_source_get_name(item->source));
|
||||
|
||||
if (item->item_render) {
|
||||
uint32_t width = obs_source_get_width(item->source);
|
||||
uint32_t height = obs_source_get_height(item->source);
|
||||
|
||||
if (!width || !height)
|
||||
return;
|
||||
if (!width || !height) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
uint32_t cx = calc_cx(item, width);
|
||||
uint32_t cy = calc_cy(item, height);
|
||||
@ -551,6 +559,9 @@ static inline void render_item(struct obs_scene_item *item)
|
||||
obs_source_video_render(item->source);
|
||||
}
|
||||
gs_matrix_pop();
|
||||
|
||||
cleanup:
|
||||
GS_DEBUG_MARKER_END();
|
||||
}
|
||||
|
||||
static void scene_video_tick(void *data, float seconds)
|
||||
|
@ -1544,6 +1544,8 @@ static bool update_async_texrender(struct obs_source *source,
|
||||
const struct obs_source_frame *frame,
|
||||
gs_texture_t *tex, gs_texrender_t *texrender)
|
||||
{
|
||||
GS_DEBUG_MARKER_BEGIN(GS_DEBUG_COLOR_CONVERT_FORMAT, "Convert Format");
|
||||
|
||||
gs_texrender_reset(texrender);
|
||||
|
||||
upload_raw_frame(tex, frame);
|
||||
@ -1557,8 +1559,10 @@ static bool update_async_texrender(struct obs_source *source,
|
||||
gs_technique_t *tech = gs_effect_get_technique(conv,
|
||||
select_conversion_technique(frame->format));
|
||||
|
||||
if (!gs_texrender_begin(texrender, cx, cy))
|
||||
if (!gs_texrender_begin(texrender, cx, cy)) {
|
||||
GS_DEBUG_MARKER_END();
|
||||
return false;
|
||||
}
|
||||
|
||||
gs_technique_begin(tech);
|
||||
gs_technique_begin_pass(tech, 0);
|
||||
@ -1586,6 +1590,7 @@ static bool update_async_texrender(struct obs_source *source,
|
||||
|
||||
gs_texrender_end(texrender);
|
||||
|
||||
GS_DEBUG_MARKER_END();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1785,6 +1790,24 @@ static inline void obs_source_main_render(obs_source_t *source)
|
||||
|
||||
static bool ready_async_frame(obs_source_t *source, uint64_t sys_time);
|
||||
|
||||
#if GS_USE_DEBUG_MARKERS
|
||||
static const char *get_type_format(enum obs_source_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case OBS_SOURCE_TYPE_INPUT:
|
||||
return "Input: %s";
|
||||
case OBS_SOURCE_TYPE_FILTER:
|
||||
return "Filter: %s";
|
||||
case OBS_SOURCE_TYPE_TRANSITION:
|
||||
return "Transition: %s";
|
||||
case OBS_SOURCE_TYPE_SCENE:
|
||||
return "Scene: %s";
|
||||
default:
|
||||
return "[Unknown]: %s";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void render_video(obs_source_t *source)
|
||||
{
|
||||
if (source->info.type != OBS_SOURCE_TYPE_FILTER &&
|
||||
@ -1808,6 +1831,10 @@ static inline void render_video(obs_source_t *source)
|
||||
return;
|
||||
}
|
||||
|
||||
GS_DEBUG_MARKER_BEGIN_FORMAT(GS_DEBUG_COLOR_SOURCE,
|
||||
get_type_format(source->info.type),
|
||||
obs_source_get_name(source));
|
||||
|
||||
if (source->filters.num && !source->rendering_filter)
|
||||
obs_source_render_filters(source);
|
||||
|
||||
@ -1822,6 +1849,8 @@ static inline void render_video(obs_source_t *source)
|
||||
|
||||
else
|
||||
obs_source_render_async_video(source);
|
||||
|
||||
GS_DEBUG_MARKER_END();
|
||||
}
|
||||
|
||||
void obs_source_video_render(obs_source_t *source)
|
||||
|
@ -120,6 +120,8 @@ static inline void render_main_texture(struct obs_core_video *video,
|
||||
int cur_texture)
|
||||
{
|
||||
profile_start(render_main_texture_name);
|
||||
GS_DEBUG_MARKER_BEGIN(GS_DEBUG_COLOR_MAIN_TEXTURE,
|
||||
render_main_texture_name);
|
||||
|
||||
struct vec4 clear_color;
|
||||
vec4_set(&clear_color, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
@ -145,6 +147,7 @@ static inline void render_main_texture(struct obs_core_video *video,
|
||||
|
||||
video->textures_rendered[cur_texture] = true;
|
||||
|
||||
GS_DEBUG_MARKER_END();
|
||||
profile_end(render_main_texture_name);
|
||||
}
|
||||
|
||||
@ -773,7 +776,10 @@ static inline void output_frame(bool raw_active, const bool gpu_active)
|
||||
gs_enter_context(video->graphics);
|
||||
|
||||
profile_start(output_frame_render_video_name);
|
||||
GS_DEBUG_MARKER_BEGIN(GS_DEBUG_COLOR_RENDER_VIDEO,
|
||||
output_frame_render_video_name);
|
||||
render_video(video, raw_active, gpu_active, cur_texture, prev_texture);
|
||||
GS_DEBUG_MARKER_END();
|
||||
profile_end(output_frame_render_video_name);
|
||||
|
||||
if (raw_active) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user