From 56cb9eaacb16faf948595aa454dbbf767f7fb5c5 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Tue, 2 Jun 2026 17:06:31 +0200 Subject: [PATCH] Expose renderer mipmap command in CLI --- docs/modernization/build-inventory.md | 2 +- docs/modernization/roadmap.md | 2 +- tests/CMakeLists.txt | 2 +- tools/pano_cli/main.cpp | 33 ++++++++++++++++++++++++--- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index ee216ef..678561e 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -298,7 +298,7 @@ Known local toolchain state: records trace markers and scopes without a window or GL context. - `pano_cli record-render` exposes the recording renderer through JSON automation, including render-pass/depth-clear counts, scissor/depth/blend/ - shader-uniform/texture-bind/sampler-bind/upload/texture-copy/readback/ + shader-uniform/texture-bind/sampler-bind/upload/mipmap-generation/texture-copy/readback/ frame-capture/blit command and byte totals, trace marker/scope counts, labeled descriptor counts, backend resource creation counts, plus draw descriptor vertex/index totals, and is covered by diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index cd2448c..48a6654 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -847,7 +847,7 @@ Results: name, trace marker/scope and draw summary, labeled descriptor counts, render-pass/depth-clear counts, and draw descriptor vertex/index totals, scissor/depth/blend-state plus - shader-uniform/texture/sampler-bind/upload/texture-copy/readback/ + shader-uniform/texture/sampler-bind/upload/mipmap-generation/texture-copy/readback/ frame-capture/blit command/byte totals for agent automation, with an expected-failure smoke for oversized render/readback targets. - `pano_cli simulate-document-history` exercises pure document history diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4de1208..c9503aa 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -365,7 +365,7 @@ if(TARGET pano_cli) COMMAND pano_cli record-render --width 32 --height 16) set_tests_properties(pano_cli_record_render_smoke PROPERTIES LABELS "renderer;integration;desktop-fast" - PASS_REGULAR_EXPRESSION "\"backend\":\"recording\".*\"width\":32.*\"height\":16.*\"createdResources\":6.*\"labeledCommandDescriptors\":10.*\"commands\":20.*\"renderPasses\":1.*\"depthClears\":1.*\"stencilClears\":0.*\"drawCommands\":1.*\"drawVertices\":3.*\"drawIndices\":3.*\"scissorCommands\":1.*\"blendCommands\":1.*\"depthCommands\":1.*\"uniformCommands\":1.*\"uniformBytes\":64.*\"bindTextureCommands\":1.*\"bindSamplerCommands\":1.*\"boundTextureBytes\":2048.*\"uploadCommands\":1.*\"uploadBytes\":4.*\"copyCommands\":1.*\"copySourceBytes\":2048.*\"copyDestinationBytes\":2048.*\"readbackCommands\":1.*\"readbackBytes\":2048.*\"captureCommands\":1.*\"captureBytes\":2048.*\"blitCommands\":1.*\"blitSourceBytes\":2048.*\"blitDestinationBytes\":2048.*\"traceMarkers\":1.*\"traceBeginScopes\":1.*\"traceEndScopes\":1") + PASS_REGULAR_EXPRESSION "\"backend\":\"recording\".*\"width\":32.*\"height\":16.*\"createdResources\":7.*\"labeledCommandDescriptors\":12.*\"commands\":21.*\"renderPasses\":1.*\"depthClears\":1.*\"stencilClears\":0.*\"drawCommands\":1.*\"drawVertices\":3.*\"drawIndices\":3.*\"scissorCommands\":1.*\"blendCommands\":1.*\"depthCommands\":1.*\"uniformCommands\":1.*\"uniformBytes\":64.*\"bindTextureCommands\":1.*\"bindSamplerCommands\":1.*\"boundTextureBytes\":2048.*\"uploadCommands\":1.*\"uploadBytes\":4.*\"mipmapCommands\":1.*\"mipmapLevels\":3.*\"mipmapBytes\":84.*\"copyCommands\":1.*\"copySourceBytes\":2048.*\"copyDestinationBytes\":2048.*\"readbackCommands\":1.*\"readbackBytes\":2048.*\"captureCommands\":1.*\"captureBytes\":2048.*\"blitCommands\":1.*\"blitSourceBytes\":2048.*\"blitDestinationBytes\":2048.*\"traceMarkers\":1.*\"traceBeginScopes\":1.*\"traceEndScopes\":1") add_test(NAME pano_cli_record_render_rejects_oversized_target COMMAND "${CMAKE_COMMAND}" diff --git a/tools/pano_cli/main.cpp b/tools/pano_cli/main.cpp index a9c0352..aa17129 100644 --- a/tools/pano_cli/main.cpp +++ b/tools/pano_cli/main.cpp @@ -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(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