Expose renderer mipmap command in CLI

This commit is contained in:
2026-06-02 17:06:31 +02:00
parent a5dbf05ab5
commit 56cb9eaacb
4 changed files with 33 additions and 6 deletions

View File

@@ -2216,18 +2216,26 @@ 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",
.debug_name = "record-render-texture",
});
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",
.debug_name = "record-render-target",
});
const auto blit_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 mip_texture = device.create_texture(pp::renderer::TextureDesc {
.extent = pp::renderer::Extent2D { .width = 4, .height = 4 },
.format = pp::renderer::TextureFormat::rgba8,
.mip_levels = 3,
.usage = pp::renderer::TextureUsage::sampled | pp::renderer::TextureUsage::copy_source | pp::renderer::TextureUsage::copy_destination,
.debug_name = "record-render-mip-texture",
});
const auto readback_buffer = device.create_readback_buffer(
static_cast<std::uint64_t>(args.width) * args.height * 4U);
@@ -2269,6 +2277,10 @@ int record_render(int argc, char** argv)
print_error("record-render", blit_target.status().message);
return 2;
}
if (!mip_texture.ok()) {
print_error("record-render", mip_texture.status().message);
return 2;
}
if (!readback_buffer.ok()) {
print_error("record-render", readback_buffer.status().message);
return 2;
@@ -2281,7 +2293,7 @@ int record_render(int argc, char** argv)
print_error("record-render", mesh.status().message);
return 2;
}
constexpr std::size_t created_resources = 6;
constexpr std::size_t created_resources = 7;
auto* trace = device.trace();
const auto trace_begin_status = trace->begin_scope("renderer", "pano_cli_record_render");
@@ -2315,6 +2327,12 @@ int record_render(int argc, char** argv)
return 2;
}
const auto mipmap_status = context.generate_mipmaps(*mip_texture.value());
if (!mipmap_status.ok()) {
print_error("record-render", mipmap_status.message);
return 2;
}
const auto begin_status = context.begin_render_pass(
*target.value(),
pp::renderer::RenderPassDesc {
@@ -2478,6 +2496,7 @@ int record_render(int argc, char** argv)
std::size_t bind_texture_commands = 0;
std::size_t bind_sampler_commands = 0;
std::size_t upload_commands = 0;
std::size_t mipmap_commands = 0;
std::size_t copy_commands = 0;
std::size_t readback_commands = 0;
std::size_t capture_commands = 0;
@@ -2492,6 +2511,8 @@ int record_render(int argc, char** argv)
std::uint64_t draw_indices = 0;
std::uint64_t uniform_bytes = 0;
std::uint64_t upload_bytes = 0;
std::uint64_t mipmap_levels = 0;
std::uint64_t mipmap_bytes = 0;
std::uint64_t copy_source_bytes = 0;
std::uint64_t copy_destination_bytes = 0;
std::uint64_t bound_texture_bytes = 0;
@@ -2542,7 +2563,10 @@ int record_render(int argc, char** argv)
} 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) {
++mipmap_commands;
count_label(command.texture_desc.debug_name);
mipmap_levels += command.generated_mip_levels;
mipmap_bytes += command.generated_mip_bytes;
} else if (command.kind == pp::renderer::RecordedRenderCommandKind::upload_texture) {
++upload_commands;
count_label(command.texture_desc.debug_name);
@@ -2600,6 +2624,9 @@ int record_render(int argc, char** argv)
<< ",\"boundTextureBytes\":" << bound_texture_bytes
<< ",\"uploadCommands\":" << upload_commands
<< ",\"uploadBytes\":" << upload_bytes
<< ",\"mipmapCommands\":" << mipmap_commands
<< ",\"mipmapLevels\":" << mipmap_levels
<< ",\"mipmapBytes\":" << mipmap_bytes
<< ",\"copyCommands\":" << copy_commands
<< ",\"copySourceBytes\":" << copy_source_bytes
<< ",\"copyDestinationBytes\":" << copy_destination_bytes