[vulkan] Add length and int color to graph labels

Tracy wants string lengths and uint32_t colors, so set them up
automatically from provided info.
This commit is contained in:
Bill Currie 2023-11-28 14:12:41 +09:00
parent 2a80614273
commit 9e43675c8f
4 changed files with 69 additions and 26 deletions

View file

@ -313,6 +313,8 @@ typedef struct qfv_time_s {
typedef struct qfv_label_s { typedef struct qfv_label_s {
vec4f_t color; vec4f_t color;
uint32_t color32;
uint32_t name_len;
const char *name; const char *name;
} qfv_label_t; } qfv_label_t;

View file

@ -794,16 +794,33 @@ typedef struct {
VkImageView *attachment_views; VkImageView *attachment_views;
} jobptr_t; } jobptr_t;
static uint32_t convert_color (vec4f_t color)
{
uint32_t r = ((int) (color[0] * 255)) & 255;
uint32_t g = ((int) (color[1] * 255)) & 255;
uint32_t b = ((int) (color[2] * 255)) & 255;
return (r << 16) | (g << 8) | b;
}
static qfv_label_t
make_label (const char *name, vec4f_t color)
{
qfv_label_t label = {
.color = color,
.color32 = convert_color (color),
.name_len = name ? strlen (name) : 0,
.name = name ? name : "",
};
return label;
}
static void static void
init_pipeline (qfv_pipeline_t *pl, qfv_pipelineinfo_t *plinfo, init_pipeline (qfv_pipeline_t *pl, qfv_pipelineinfo_t *plinfo,
jobptr_t *jp, objstate_t *s, int is_compute) jobptr_t *jp, objstate_t *s, int is_compute)
{ {
__auto_type li = find_layout (&plinfo->layout, s); __auto_type li = find_layout (&plinfo->layout, s);
*pl = (qfv_pipeline_t) { *pl = (qfv_pipeline_t) {
.label = { .label = make_label (plinfo->name, plinfo->color),
.name = plinfo->name,
.color = plinfo->color,
},
.disabled = plinfo->disabled, .disabled = plinfo->disabled,
.bindPoint = is_compute ? VK_PIPELINE_BIND_POINT_COMPUTE .bindPoint = is_compute ? VK_PIPELINE_BIND_POINT_COMPUTE
: VK_PIPELINE_BIND_POINT_GRAPHICS, : VK_PIPELINE_BIND_POINT_GRAPHICS,
@ -831,10 +848,7 @@ init_subpass (qfv_subpass_t *sp, qfv_subpassinfo_t *isp,
{ {
uint32_t np = s->inds.num_graph_pipelines + s->inds.num_comp_pipelines; uint32_t np = s->inds.num_graph_pipelines + s->inds.num_comp_pipelines;
*sp = (qfv_subpass_t) { *sp = (qfv_subpass_t) {
.label = { .label = make_label (isp->name, isp->color),
.name = isp->name,
.color = isp->color,
},
.inherit = { .inherit = {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,
}, },
@ -859,8 +873,7 @@ init_renderpass (qfv_renderpass_t *rp, qfv_renderpassinfo_t *rpinfo,
{ {
*rp = (qfv_renderpass_t) { *rp = (qfv_renderpass_t) {
.vulkan_ctx = s->ctx, .vulkan_ctx = s->ctx,
.label.name = rpinfo->name, .label = make_label (rpinfo->name, rpinfo->color),
.label.color = rpinfo->color,
.beginInfo = (VkRenderPassBeginInfo) { .beginInfo = (VkRenderPassBeginInfo) {
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
.renderPass = s->ptr.rp[s->inds.num_renderpasses], .renderPass = s->ptr.rp[s->inds.num_renderpasses],
@ -892,8 +905,7 @@ init_render (qfv_render_t *rend, qfv_renderinfo_t *rinfo,
jobptr_t *jp, objstate_t *s) jobptr_t *jp, objstate_t *s)
{ {
*rend = (qfv_render_t) { *rend = (qfv_render_t) {
.label.color = rinfo->color, .label = make_label (rinfo->name, rinfo->color),
.label.name = rinfo->name,
.num_renderpasses = rinfo->num_renderpasses, .num_renderpasses = rinfo->num_renderpasses,
.renderpasses = &jp->renderpasses[s->inds.num_renderpasses], .renderpasses = &jp->renderpasses[s->inds.num_renderpasses],
}; };
@ -911,8 +923,7 @@ init_compute (qfv_compute_t *comp, qfv_computeinfo_t *cinfo,
{ {
uint32_t np = s->inds.num_graph_pipelines + s->inds.num_comp_pipelines; uint32_t np = s->inds.num_graph_pipelines + s->inds.num_comp_pipelines;
*comp = (qfv_compute_t) { *comp = (qfv_compute_t) {
.label.color = cinfo->color, .label = make_label (cinfo->name, cinfo->color),
.label.name = cinfo->name,
.pipelines = &jp->pipelines[np], .pipelines = &jp->pipelines[np],
.pipeline_count = cinfo->num_pipelines, .pipeline_count = cinfo->num_pipelines,
}; };
@ -927,8 +938,7 @@ init_process (qfv_process_t *proc, qfv_processinfo_t *pinfo,
jobptr_t *jp, objstate_t *s) jobptr_t *jp, objstate_t *s)
{ {
*proc = (qfv_process_t) { *proc = (qfv_process_t) {
.label.color = pinfo->color, .label = make_label (pinfo->name, pinfo->color),
.label.name = pinfo->name,
.tasks = &jp->tasks[s->inds.num_tasks], .tasks = &jp->tasks[s->inds.num_tasks],
.task_count = pinfo->num_tasks, .task_count = pinfo->num_tasks,
}; };
@ -945,8 +955,7 @@ init_step (uint32_t ind, jobptr_t *jp, objstate_t *s)
__auto_type sinfo = &s->jinfo->steps[ind]; __auto_type sinfo = &s->jinfo->steps[ind];
*step = (qfv_step_t) { *step = (qfv_step_t) {
.label.name = sinfo->name, .label = make_label (sinfo->name, sinfo->color),
.label.color = sinfo->color,
}; };
if (sinfo->render) { if (sinfo->render) {
step->render = &jp->renders[s->inds.num_render++]; step->render = &jp->renders[s->inds.num_render++];
@ -959,6 +968,7 @@ init_step (uint32_t ind, jobptr_t *jp, objstate_t *s)
if (sinfo->process) { if (sinfo->process) {
step->process = &jp->processes[s->inds.num_process++]; step->process = &jp->processes[s->inds.num_process++];
init_process (step->process, sinfo->process, jp, s); init_process (step->process, sinfo->process, jp, s);
step->process->label = step->label;
} }
} }

View file

@ -2117,6 +2117,7 @@ renderpasses = {
}; };
steps = { steps = {
wait_on_fence = { wait_on_fence = {
color = "[0.6, 0.8, 0.0]";
process = { process = {
tasks = ( tasks = (
{ func = wait_on_fence; }, { func = wait_on_fence; },
@ -2128,6 +2129,7 @@ steps = {
}; };
}; };
particles = { particles = {
color = "[0.6, 0.8, 0.9]";
dependencies = (wait_on_fence); dependencies = (wait_on_fence);
compute = { compute = {
pipelines = { pipelines = {
@ -2157,6 +2159,7 @@ steps = {
}; };
}; };
world = { world = {
color = "[0.3, 0.4, 0.0]";
dependencies = (wait_on_fence); dependencies = (wait_on_fence);
process = { process = {
tasks = ( tasks = (
@ -2169,6 +2172,7 @@ steps = {
}; };
}; };
shadow = { shadow = {
color = "[0.3, 0.3, 0.3]";
dependencies = (world); dependencies = (world);
process = { process = {
tasks = ( tasks = (
@ -2188,6 +2192,7 @@ steps = {
}; };
}; };
setup_main = { setup_main = {
color = "[0.3, 0.8, 0.3]";
dependencies = (wait_on_fence); dependencies = (wait_on_fence);
process = { process = {
tasks = ( tasks = (
@ -2204,6 +2209,7 @@ steps = {
}; };
}; };
main = { main = {
color = "[0.3, 0.8, 0.0]";
dependencies = (setup_main, particles, shadow, world); dependencies = (setup_main, particles, shadow, world);
render = { render = {
renderpasses = { renderpasses = {
@ -2213,6 +2219,7 @@ steps = {
}; };
}; };
preoutput = { preoutput = {
color = "[0.8, 0.8, 0.0]";
dependencies = (wait_on_fence); dependencies = (wait_on_fence);
process = { process = {
tasks = ( tasks = (
@ -2227,6 +2234,7 @@ steps = {
}; };
}; };
output = { output = {
color = "[0.4, 0.8, 0.4]";
dependencies = (main, preoutput); dependencies = (main, preoutput);
render = { render = {
renderpasses = { renderpasses = {
@ -2235,6 +2243,7 @@ steps = {
}; };
}; };
capture = { capture = {
color = "[0.0, 0.8, 0.4]";
dependencies = (output); dependencies = (output);
process = { process = {
tasks = ( tasks = (
@ -2243,6 +2252,7 @@ steps = {
}; };
}; };
mouse_pick = { mouse_pick = {
color = "[0.0, 0.0, 0.8]";
dependencies = (main); dependencies = (main);
process = { process = {
tasks = ( tasks = (

View file

@ -334,11 +334,12 @@ parse = {
}; };
qfv_pipelineinfo_s = { qfv_pipelineinfo_s = {
.name = qfv_pipelineinfo_t; .name = qfv_pipelineinfo_t;
color = auto; .type = (QFDictionary);
name = { .dictionary = {
type = string; .parse = auto;
string = name; name = $name;
}; };
color = auto;
disabled = auto; disabled = auto;
tasks = { tasks = {
type = (array, qfv_taskinfo_t); type = (array, qfv_taskinfo_t);
@ -397,9 +398,10 @@ parse = {
}; };
qfv_subpassinfo_s = { qfv_subpassinfo_s = {
.name = qfv_subpassinfo_t; .name = qfv_subpassinfo_t;
name = { .type = (QFDictionary);
type = string; .dictionary = {
string = name; .parse = auto;
name = $name;
}; };
color = auto; color = auto;
dependencies = { dependencies = {
@ -517,7 +519,11 @@ parse = {
}; };
qfv_computeinfo_s = { qfv_computeinfo_s = {
.name = qfv_computeinfo_t; .name = qfv_computeinfo_t;
color = auto; .type = (QFDictionary);
.dictionary = {
.parse = auto;
name = $name;
};
pipelines = { pipelines = {
type = (labeledarray, qfv_pipelineinfo_t, name); type = (labeledarray, qfv_pipelineinfo_t, name);
size = num_pipelines; size = num_pipelines;
@ -526,6 +532,11 @@ parse = {
}; };
qfv_renderinfo_s = { qfv_renderinfo_s = {
.name = qfv_renderinfo_t; .name = qfv_renderinfo_t;
.type = (QFDictionary);
.dictionary = {
.parse = auto;
name = $name;
};
color = auto; color = auto;
renderpasses = { renderpasses = {
type = (labeledarray, qfv_renderpassinfo_t, name); type = (labeledarray, qfv_renderpassinfo_t, name);
@ -535,6 +546,11 @@ parse = {
}; };
qfv_processinfo_s = { qfv_processinfo_s = {
.name = qfv_processinfo_t; .name = qfv_processinfo_t;
.type = (QFDictionary);
.dictionary = {
.parse = auto;
name = $name;
};
color = auto; color = auto;
tasks = { tasks = {
type = (array, qfv_taskinfo_t); type = (array, qfv_taskinfo_t);
@ -544,6 +560,11 @@ parse = {
}; };
qfv_stepinfo_s = { qfv_stepinfo_s = {
.name = qfv_stepinfo_t; .name = qfv_stepinfo_t;
.type = (QFDictionary);
.dictionary = {
.parse = auto;
name = $name;
};
color = auto; color = auto;
dependencies = { dependencies = {
type = (array, qfv_reference_t); type = (array, qfv_reference_t);