Add renderer resource label contract

This commit is contained in:
2026-06-02 17:01:10 +02:00
parent bbe3db1747
commit a5dbf05ab5
7 changed files with 132 additions and 14 deletions

View File

@@ -1643,6 +1643,7 @@ pp::foundation::Status parse_simulate_document_edits_args(
.extent = pp::renderer::Extent2D { .width = args.width, .height = args.height },
.format = pp::renderer::TextureFormat::rgba8,
.usage = pp::renderer::TextureUsage::render_target | pp::renderer::TextureUsage::sampled | pp::renderer::TextureUsage::upload_destination | pp::renderer::TextureUsage::readback_source | pp::renderer::TextureUsage::copy_source | pp::renderer::TextureUsage::copy_destination,
.debug_name = "record-render-texture",
});
if (!render_target_size) {
return render_target_size.status();
@@ -2215,11 +2216,13 @@ int record_render(int argc, char** argv)
.extent = pp::renderer::Extent2D { .width = args.width, .height = args.height },
.format = pp::renderer::TextureFormat::rgba8,
.usage = pp::renderer::TextureUsage::render_target | pp::renderer::TextureUsage::sampled | pp::renderer::TextureUsage::upload_destination | pp::renderer::TextureUsage::readback_source | pp::renderer::TextureUsage::copy_source | pp::renderer::TextureUsage::copy_destination,
.debug_name = "record-render-target",
});
const auto target = device.create_render_target(pp::renderer::TextureDesc {
.extent = pp::renderer::Extent2D { .width = args.width, .height = args.height },
.format = pp::renderer::TextureFormat::rgba8,
.usage = pp::renderer::TextureUsage::render_target | pp::renderer::TextureUsage::sampled | pp::renderer::TextureUsage::upload_destination | pp::renderer::TextureUsage::readback_source | pp::renderer::TextureUsage::copy_source | pp::renderer::TextureUsage::copy_destination,
.debug_name = "record-render-blit-target",
});
const auto blit_target = device.create_render_target(pp::renderer::TextureDesc {
.extent = pp::renderer::Extent2D { .width = args.width, .height = args.height },
@@ -2251,6 +2254,7 @@ int record_render(int argc, char** argv)
.vertex_count = 3,
.index_count = 3,
.topology = pp::renderer::PrimitiveTopology::triangles,
.debug_name = "record-render-mesh",
});
if (!texture.ok()) {
@@ -2495,10 +2499,17 @@ int record_render(int argc, char** argv)
std::uint64_t capture_bytes = 0;
std::uint64_t blit_source_bytes = 0;
std::uint64_t blit_destination_bytes = 0;
std::size_t labeled_command_descriptors = 0;
const auto count_label = [&labeled_command_descriptors](const char* label) {
if (label != nullptr && label[0] != '\0') {
++labeled_command_descriptors;
}
};
const auto commands = device.commands();
for (const auto& command : commands) {
if (command.kind == pp::renderer::RecordedRenderCommandKind::begin_render_pass) {
++render_passes;
count_label(command.target_desc.debug_name);
if (command.clear_depth_enabled) {
++depth_clears;
}
@@ -2507,6 +2518,7 @@ int record_render(int argc, char** argv)
}
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::draw) {
++draw_commands;
count_label(command.mesh_desc.debug_name);
draw_vertices += command.draw_desc.vertex_count;
draw_indices += command.draw_desc.index_count;
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::set_scissor) {
@@ -2520,27 +2532,39 @@ int record_render(int argc, char** argv)
uniform_bytes += command.uniform_bytes;
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::bind_texture) {
++bind_texture_commands;
count_label(command.texture_desc.debug_name);
const auto bound_bytes = pp::renderer::texture_byte_size(command.texture_desc);
if (bound_bytes.ok()) {
bound_texture_bytes += bound_bytes.value();
}
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::bind_sampler) {
++bind_sampler_commands;
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::bind_mesh) {
count_label(command.mesh_desc.debug_name);
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::generate_mipmaps) {
count_label(command.texture_desc.debug_name);
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::upload_texture) {
++upload_commands;
count_label(command.texture_desc.debug_name);
upload_bytes += command.upload_bytes;
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::copy_texture) {
++copy_commands;
count_label(command.source_desc.debug_name);
count_label(command.destination_desc.debug_name);
copy_source_bytes += command.copy_source_bytes;
copy_destination_bytes += command.copy_destination_bytes;
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::read_texture) {
++readback_commands;
count_label(command.texture_desc.debug_name);
readback_bytes += command.readback_bytes;
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::capture_frame) {
++capture_commands;
count_label(command.target_desc.debug_name);
capture_bytes += command.capture_bytes;
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::blit_render_target) {
++blit_commands;
count_label(command.source_desc.debug_name);
count_label(command.destination_desc.debug_name);
blit_source_bytes += command.blit_source_bytes;
blit_destination_bytes += command.blit_destination_bytes;
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::trace_marker) {
@@ -2558,6 +2582,7 @@ int record_render(int argc, char** argv)
<< ",\"height\":" << args.height
<< ",\"format\":\"rgba8\"}"
<< ",\"createdResources\":" << created_resources
<< ",\"labeledCommandDescriptors\":" << labeled_command_descriptors
<< ",\"commands\":" << commands.size()
<< ",\"renderPasses\":" << render_passes
<< ",\"depthClears\":" << depth_clears