Upload document frame faces through renderer API

This commit is contained in:
2026-06-05 17:37:21 +02:00
parent 7c6c5f3e36
commit d0e023556b
9 changed files with 278 additions and 17 deletions

View File

@@ -250,12 +250,15 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p
- `pp_paint_renderer_compositor_tests` now covers pure `pp_document` face and
six-face frame compositing by expanding per-layer dirty face payload
rectangles into full renderer-sized RGBA buffers with layer visibility,
opacity, and blend mode applied in document order.
opacity, and blend mode applied in document order, then uploading those six
faces through the renderer-neutral `IRenderDevice` texture API using the
recording backend.
- `pano_cli simulate-document-export` exposes the same pure document-to-PPI
export, asset-level decode, and document reimport path through JSON
automation and is covered by `pano_cli_simulate_document_export_smoke`.
- `pano_cli simulate-document-render` exposes the pure document-to-renderer
frame compositor through JSON automation and is covered by
frame compositor plus renderer texture-upload command stream through JSON
automation and is covered by
`pano_cli_simulate_document_render_smoke`.
- `pano_cli save-document-project` writes that pure document export to a PPI
file and is covered by `pano_cli_save_document_project_roundtrip_smoke`,

View File

@@ -26,7 +26,7 @@ and validation command.
| PNG/JPEG import | `Image`, `Canvas` import paths | `pp_assets`, `pp_document` | Fixture import, malformed file |
| PNG/JPEG export | `Canvas`, `Image`, export dialogs | `pp_assets`, `pp_paint_renderer`, `pp_app_core` | Golden output tolerance, export start/target planning tests |
| Equirectangular import/export | `Canvas`, shaders, RTT, export dialogs | `pp_paint_renderer`, `pp_app_core` | Tiny cube/equirect golden, app-core file target tests |
| Cube face export | `Canvas` | `pp_paint_renderer` | Pure six-face document frame composite, six-face golden set |
| Cube face export | `Canvas` | `pp_paint_renderer` | Pure six-face document frame composite, renderer texture-upload bridge, six-face golden set |
| Depth export | `Canvas`, grid tools | `pp_paint_renderer` | Float/readback validation |
## Brush And Painting
@@ -38,7 +38,7 @@ and validation command.
| PPBR import/export | brush panel/dialog | `pp_assets`, `pp_panopainter_ui` | Round-trip fixture |
| Stroke sampling | `Stroke`, `Canvas` | `pp_paint` | Property tests for spacing, pressure, jitter |
| Dual brush/pattern behavior | `Brush`, shaders | `pp_paint`, `pp_paint_renderer` | Stroke-alpha CPU reference, dual/pattern feedback planning, GPU golden |
| Blend modes | GLSL include files, layer rendering | `pp_paint`, `pp_paint_renderer` | Final RGBA and stroke-alpha CPU reference vectors, pure `pp_document` face and six-face frame compositing, fixed-function/framebuffer-fetch/ping-pong stroke composite planning, live `Canvas`/`NodeCanvas` blend-gate coverage, live canvas stroke/thumbnail/brush-preview destination-copy coverage, and GPU parity |
| Blend modes | GLSL include files, layer rendering | `pp_paint`, `pp_paint_renderer` | Final RGBA and stroke-alpha CPU reference vectors, pure `pp_document` face and six-face frame compositing plus renderer texture upload, fixed-function/framebuffer-fetch/ping-pong stroke composite planning, live `Canvas`/`NodeCanvas` blend-gate coverage, live canvas stroke/thumbnail/brush-preview destination-copy coverage, and GPU parity |
| Erase/flood fill/masks | `Canvas`, modes, shaders | `pp_document`, `pp_paint_renderer` | Edge masks, alpha lock, dirty rects |
## Layers And Animation

View File

@@ -449,6 +449,10 @@ agent or engineer to remove them without reconstructing context from chat.
`pano_cli simulate-document-render` JSON automation, so headless tests can
validate document payloads moving toward renderer/export services without a
GL context.
- 2026-06-05: DEBT-0010 was narrowed again. `pp_paint_renderer` can now upload
a pure document frame's six composited faces through the renderer-neutral
`IRenderDevice` texture API, and the recording backend/CLI smoke validate
six RGBA8 texture uploads plus explicit shader-read transitions.
## Open Debt
@@ -462,7 +466,7 @@ agent or engineer to remove them without reconstructing context from chat.
| DEBT-0007 | Open | Modernization | `vcpkg.json` and `windows-msvc-vcpkg-headless` are validated for the headless Windows component matrix, and root CMake now exposes a focused `panopainter_platform_build_vcpkg_ui_core` target for the vcpkg-backed `pp_ui_core`/tinyxml2 boundary, but app targets still use vendored libraries and Android/Apple triplets are not proven | Dependency migration must stay incremental while SDK/patched/vendor dependencies remain in use | `cmake --preset windows-msvc-vcpkg-headless`; `ctest --preset desktop-fast-vcpkg --build-config Debug`; `cmake --build --preset windows-msvc-default --config Debug --target panopainter_platform_build_vcpkg_ui_core` | Component targets consume vcpkg packages where reliable and desktop app, Android, and Apple triplets are validated or explicitly documented as permanent vendor exceptions |
| DEBT-0008 | Open | Modernization | `windows-msvc-default` and `windows-msvc-vcpkg-headless` explicitly select Visual Studio 18 2026 for local validation, but non-VS2026 CMake executables on PATH may not know that generator | The local machine has VS 2026, but using an older CMake can still default to Ninja or reject the VS 2026 generator | `cmake --preset windows-msvc-default`; `cmake --build --preset windows-msvc-default --config Debug --target PanoPainter`; `ctest --preset desktop-fast --build-config Debug` | The repo automation invokes or locates a CMake executable that supports `Visual Studio 18 2026`, and VS 2026 generator validation is the normal Windows path without manual tool selection |
| DEBT-0009 | Open | Modernization | Android root CMake validation currently builds headless targets only, while retained standard/Quest/Focus package CMake paths now have a refreshed CMake 3.10/C++23 baseline outside root CMake; automation queries `sdkmanager`, installs newer or missing SDK Manager NDK/CMake packages, selects the resulting pair before configure, and reports update decisions; root CMake exposes non-default platform-build and retained native package validation targets | Platform app entrypoints still live in legacy Gradle/CMake projects and need Phase 6 alignment | `powershell -ExecutionPolicy Bypass -File scripts\automation\platform-build.ps1 -Presets android-arm64`; `cmake --build --preset android-x64`; `cmake --build --preset android-quest-arm64`; `cmake --build --preset android-focus-arm64`; `cmake --build --preset windows-msvc-default --config Debug --target panopainter_platform_build_android_assets`; `powershell -ExecutionPolicy Bypass -File scripts\automation\android-legacy-package-build.ps1 -Packages standard`; `powershell -ExecutionPolicy Bypass -File scripts\automation\android-legacy-package-build.ps1 -Packages quest,focus -ConfigureOnly`; `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -ReadinessOnly -AndroidNativeChecks -PackageKinds android-standard-apk,android-quest-apk,android-focus-apk`; `cmake --build --preset windows-msvc-default --config Debug --target panopainter_android_native_package_smoke` | Android standard, Quest, and Focus/Wave package targets consume shared component targets and have package smoke commands |
| DEBT-0010 | Open | Modernization | `pp_document` is a pure layer/frame/document/undo-history model with alpha-lock metadata, snapshot construction, per-layer frame metadata, renderer-free RGBA8 face payload storage, snapshot-embedded face-payload validation, renderer-free alpha8 selection-mask storage, PPI import/export helpers, stroke-script-to-face-payload CLI automation, and `pp_paint_renderer` document face/frame compositors with CLI render automation, but it is not yet wired to legacy `Canvas`, legacy save, or legacy action commands | Keep extraction incremental while preserving app behavior | `ctest --preset desktop-fast --build-config Debug`; `pano_cli create-document --width 64 --height 32 --layers 2`; `pano_cli load-project --path tests\data\projects\minimal-project.ppi`; `pano_cli simulate-document-render --width 64 --height 32`; `pp_document_tests`; `pp_document_ppi_import_tests`; `pp_document_ppi_export_tests`; `pp_paint_renderer_compositor_tests`; `pano_cli_simulate_document_edits_smoke`; `pano_cli_simulate_document_export_smoke`; `pano_cli_simulate_document_render_smoke`; `pano_cli_save_document_project_roundtrip_smoke`; `pano_cli_apply_stroke_script_roundtrip_smoke`; `pano_cli_apply_stroke_script_rejects_tiny_canvas` | Legacy document behavior is represented by `pp_document`/`pp_paint_renderer` tests and the app consumes it through a boundary/facade |
| DEBT-0010 | Open | Modernization | `pp_document` is a pure layer/frame/document/undo-history model with alpha-lock metadata, snapshot construction, per-layer frame metadata, renderer-free RGBA8 face payload storage, snapshot-embedded face-payload validation, renderer-free alpha8 selection-mask storage, PPI import/export helpers, stroke-script-to-face-payload CLI automation, `pp_paint_renderer` document face/frame compositors, and renderer-neutral six-face texture upload with CLI render automation, but it is not yet wired to legacy `Canvas`, legacy save, or legacy action commands | Keep extraction incremental while preserving app behavior | `ctest --preset desktop-fast --build-config Debug`; `pano_cli create-document --width 64 --height 32 --layers 2`; `pano_cli load-project --path tests\data\projects\minimal-project.ppi`; `pano_cli simulate-document-render --width 64 --height 32`; `pp_document_tests`; `pp_document_ppi_import_tests`; `pp_document_ppi_export_tests`; `pp_paint_renderer_compositor_tests`; `pano_cli_simulate_document_edits_smoke`; `pano_cli_simulate_document_export_smoke`; `pano_cli_simulate_document_render_smoke`; `pano_cli_save_document_project_roundtrip_smoke`; `pano_cli_apply_stroke_script_roundtrip_smoke`; `pano_cli_apply_stroke_script_rejects_tiny_canvas` | Legacy document behavior is represented by `pp_document`/`pp_paint_renderer` tests and the app consumes it through a boundary/facade |
| DEBT-0011 | Open | Modernization | `package-smoke` validates the Windows CMake app artifact and launch-folder DLL payload, and reports a structured package readiness matrix for Windows AppX, Android standard/Quest/Focus APKs, Apple bundles, Linux app output, and WebGL output; the Windows app smoke passes the configure-time CMake executable so VS 2026 generator validation does not depend on `cmake` from PATH, retained Android package native CMake paths, and retained Linux/WebGL CMake baseline metadata are reachable from package validation and root CMake package-readiness targets, but Windows AppX/APK/Linux/Apple/WebGL package outputs are still `blocked` because root CMake package targets do not exist yet | Platform package targets are not migrated to root CMake yet | `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -Preset windows-msvc-default -Configuration Debug`; `cmake --build --preset windows-msvc-default --config Debug --target panopainter_windows_app_package_smoke`; `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -ReadinessOnly -AndroidNativeChecks -PackageKinds android-standard-apk,android-quest-apk,android-focus-apk`; `cmake --build --preset windows-msvc-default --config Debug --target panopainter_android_native_package_smoke`; `cmake --build --preset windows-msvc-default --config Debug --target panopainter_linux_webgl_package_readiness`; `python scripts/dev/check_package_smoke_readiness.py`; `bash -n scripts/automation/package-smoke.sh` | Package-smoke builds and validates Windows AppX, Android APK variants, Linux app, Apple bundles, and WebGL output where local toolchains are present |
| DEBT-0012 | Open | Modernization | `pp_ui_core` uses vcpkg tinyxml2 on `windows-msvc-vcpkg-headless`, but retains `pp_vendor_tinyxml2` for default and unproven platform presets | Mobile/AppX/Apple triplets and app packaging still need validation before removing the vendored fallback | `ctest --preset desktop-fast-vcpkg --build-config Debug`; `ctest --preset desktop-fast --build-config Debug`; `powershell -ExecutionPolicy Bypass -File scripts\automation\platform-build.ps1 -Presets android-arm64` | All supported presets consume vcpkg tinyxml2 or document a permanent vendored exception |
| DEBT-0013 | Open | Modernization | `pp_assets`, `pp_document`, `pano_cli inspect-project`, `pano_cli load-project`, and `pano_cli save-project` validate the fixed PPI header, thumbnail/body byte layout, generated multi-layer/multi-frame PPI writing with explicit layer opacity/blend/alpha-lock/visibility metadata, per-layer frame durations, metadata-only and targeted dirty-face-payload save/load round-trips, layer/frame index, dirty-face descriptors, dirty-face PNG payload metadata, asset-level RGBA PNG payload decoding, pure document-to-PPI export, CLI document export automation, file-writing document export automation, stroke-script-generated document payload export, and decoded pixel attachment to `pp_document`, but full legacy PPI round-trip parity is not yet extracted | Full PPI save parity requires staged extraction of legacy `Canvas` serialization and image/layer payload handling | `ctest --preset desktop-fast --build-config Debug`; `pp_assets_image_pixels_tests`; `pp_assets_ppi_header_tests`; `pp_document_ppi_import_tests`; `pp_document_ppi_export_tests`; `pano_cli_inspect_project_layout_smoke`; `pano_cli_load_project_metadata_smoke`; `pano_cli_save_project_roundtrip_smoke`; `pano_cli_save_project_payload_roundtrip_smoke`; `pano_cli_simulate_document_export_smoke`; `pano_cli_save_document_project_roundtrip_smoke`; `pano_cli_apply_stroke_script_roundtrip_smoke`; `pano_cli_apply_stroke_script_rejects_tiny_canvas` | Full PPI load/save fixtures cover thumbnails, decoded layer face payloads attached to documents, frames, corrupt payloads, dirty-face payload saving, arbitrary legacy canvas payload/layout combinations, and legacy app round-trip compatibility |

View File

@@ -455,7 +455,10 @@ texture/readback descriptors and validation tests. `pp_paint_renderer` has
started with deterministic CPU layer compositing over renderer extents using
the paint blend reference, and now exposes pure `pp_document` face and
six-face frame compositors that expand per-layer dirty face payload rectangles
into full renderer-sized RGBA buffers for a requested document frame.
into full renderer-sized RGBA buffers for a requested document frame. It can
also upload those six composited faces through the renderer-neutral
`IRenderDevice` texture API, with the recording backend validating upload and
explicit-transition command streams.
`pp_ui_core` has started with XML-layout-facing
length parsing, color parsing, tinyxml-backed layout XML parsing, and invalid
input tests.
@@ -483,7 +486,8 @@ bytes using that writer, including PNG-encoded layer/frame face payloads.
decodes the generated PPI bytes, reimports them, and emits JSON round-trip
metadata.
`pano_cli simulate-document-render` exercises the pure document-to-renderer
frame compositor and emits six-face render summaries for headless automation.
frame compositor and renderer texture-upload bridge, emitting six-face render
and upload-command summaries for headless automation.
`pano_cli save-document-project` writes the same pure document export to a PPI
file for inspect/load round-trip automation.
`pano_cli create-document` can create simple animation documents with explicit
@@ -1707,7 +1711,8 @@ Results:
depth-target rejection.
- `pp_paint_renderer_compositor_tests` passed, including pure
`pp_document` face and six-face frame compositing over per-layer dirty face
payloads.
payloads plus renderer-neutral six-face texture upload through the recording
backend.
The suite now covers fixed-function stroke composite planning,
framebuffer-fetch planning, ping-pong texture-copy/blit fallback planning,
dual/pattern blend feedback detection, invalid blend mode rejection,
@@ -1727,8 +1732,8 @@ Results:
`pp_document` export to PPI bytes, asset-level decode, and document reimport
round-trip state as JSON.
- `pano_cli_simulate_document_render_smoke` passed and reports pure
`pp_document` to `pp_paint_renderer` six-face frame compositing summaries as
JSON.
`pp_document` to `pp_paint_renderer` six-face frame compositing and
renderer texture-upload command summaries as JSON.
- `pano_cli_simulate_image_import_smoke` passed and reports embedded PNG decode
plus `pp_document` face-payload attachment state as JSON.
- `pano_cli_inspect_image_rejects_unsupported` passed as an expected failure

View File

@@ -1,5 +1,6 @@
#include "paint_renderer/compositor.h"
#include <algorithm>
#include <limits>
#include <utility>
@@ -105,6 +106,24 @@ namespace {
};
}
[[nodiscard]] std::byte rgba8_channel(float value) noexcept
{
const auto clamped = std::clamp(value, 0.0F, 1.0F);
return static_cast<std::byte>(static_cast<std::uint8_t>(clamped * 255.0F + 0.5F));
}
void append_rgba8_bytes(std::vector<std::byte>& bytes, std::span<const pp::paint::Rgba> pixels)
{
bytes.clear();
bytes.reserve(pixels.size() * pp::document::rgba8_components);
for (const auto& pixel : pixels) {
bytes.push_back(rgba8_channel(pixel.r));
bytes.push_back(rgba8_channel(pixel.g));
bytes.push_back(rgba8_channel(pixel.b));
bytes.push_back(rgba8_channel(pixel.a));
}
}
[[nodiscard]] pp::foundation::Status composite_face_payload(
std::span<pp::paint::Rgba> destination,
pp::renderer::Extent2D extent,
@@ -327,6 +346,72 @@ pp::foundation::Result<DocumentFrameCompositeResult> composite_document_frame(
return pp::foundation::Result<DocumentFrameCompositeResult>::success(std::move(result));
}
pp::foundation::Result<DocumentFrameUploadResult> upload_document_frame_faces(
pp::renderer::IRenderDevice& device,
DocumentFrameUploadRequest request)
{
auto composite = composite_document_frame(DocumentFrameCompositeRequest {
.document = request.document,
.frame_index = request.frame_index,
.clear_color = request.clear_color,
});
if (!composite) {
return pp::foundation::Result<DocumentFrameUploadResult>::failure(composite.status());
}
DocumentFrameUploadResult result;
result.composite = std::move(composite.value());
std::vector<std::byte> upload_bytes;
for (std::size_t face_index = 0; face_index < result.composite.faces.size(); ++face_index) {
const pp::renderer::TextureDesc desc {
.extent = result.composite.extent,
.format = pp::renderer::TextureFormat::rgba8,
.usage = pp::renderer::TextureUsage::sampled
| pp::renderer::TextureUsage::upload_destination
| pp::renderer::TextureUsage::readback_source
| pp::renderer::TextureUsage::copy_source,
.debug_name = "document-frame-face",
};
auto texture = device.create_texture(desc);
if (!texture) {
return pp::foundation::Result<DocumentFrameUploadResult>::failure(texture.status());
}
append_rgba8_bytes(upload_bytes, result.composite.faces[face_index].pixels);
auto& context = device.immediate_context();
const auto upload_status = context.upload_texture(
*texture.value(),
pp::renderer::ReadbackRegion {
.x = 0,
.y = 0,
.width = result.composite.extent.width,
.height = result.composite.extent.height,
},
upload_bytes);
if (!upload_status.ok()) {
return pp::foundation::Result<DocumentFrameUploadResult>::failure(upload_status);
}
result.uploaded_bytes += static_cast<std::uint64_t>(upload_bytes.size());
if (request.transition_to_shader_read && device.features().explicit_texture_transitions) {
const auto transition_status = context.transition_texture(
*texture.value(),
pp::renderer::TextureState::upload_destination,
pp::renderer::TextureState::shader_read);
if (!transition_status.ok()) {
return pp::foundation::Result<DocumentFrameUploadResult>::failure(transition_status);
}
++result.transition_count;
}
result.face_textures[face_index] = std::move(texture.value());
++result.texture_count;
}
return pp::foundation::Result<DocumentFrameUploadResult>::success(std::move(result));
}
bool stroke_composite_requires_feedback(
pp::paint::BlendMode layer_blend_mode,
pp::paint::StrokeBlendMode stroke_blend_mode,

View File

@@ -8,6 +8,7 @@
#include <array>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <span>
#include <vector>
@@ -116,6 +117,21 @@ struct DocumentFrameCompositeResult {
std::size_t face_payload_count = 0;
};
struct DocumentFrameUploadRequest {
const pp::document::CanvasDocument* document = nullptr;
std::size_t frame_index = 0;
pp::paint::Rgba clear_color {};
bool transition_to_shader_read = true;
};
struct DocumentFrameUploadResult {
DocumentFrameCompositeResult composite {};
std::array<std::unique_ptr<pp::renderer::ITexture2D>, pp::document::cube_face_count> face_textures {};
std::size_t texture_count = 0;
std::size_t transition_count = 0;
std::uint64_t uploaded_bytes = 0;
};
[[nodiscard]] pp::foundation::Status composite_layer(
std::span<pp::paint::Rgba> destination,
pp::renderer::Extent2D extent,
@@ -127,6 +143,10 @@ struct DocumentFrameCompositeResult {
[[nodiscard]] pp::foundation::Result<DocumentFrameCompositeResult> composite_document_frame(
DocumentFrameCompositeRequest request);
[[nodiscard]] pp::foundation::Result<DocumentFrameUploadResult> upload_document_frame_faces(
pp::renderer::IRenderDevice& device,
DocumentFrameUploadRequest request);
[[nodiscard]] bool stroke_composite_requires_feedback(
pp::paint::BlendMode layer_blend_mode,
pp::paint::StrokeBlendMode stroke_blend_mode,

View File

@@ -2452,7 +2452,7 @@ if(TARGET pano_cli)
COMMAND pano_cli simulate-document-render --width 64 --height 32)
set_tests_properties(pano_cli_simulate_document_render_smoke PROPERTIES
LABELS "document;renderer;integration;desktop-fast"
PASS_REGULAR_EXPRESSION "\"command\":\"simulate-document-render\".*\"source\":\\{\"width\":64,\"height\":32,\"layers\":2,\"frames\":2,\"facePayloads\":2\\}.*\"render\":\\{\"frame\":0,\"width\":64,\"height\":32,\"faces\":6,\"visitedLayers\":2,\"compositedLayerFaces\":1,\"facePayloads\":1.*\\{\"face\":0,\"pixels\":2048,\"payloads\":1,\"nonClearPixels\":1,\"firstNonClear\":\\{\"index\":194,\"x\":2,\"y\":3,\"r\":1,\"g\":0,\"b\":0,\"a\":1\\}\\}.*\\{\"face\":5,\"pixels\":2048,\"payloads\":0,\"nonClearPixels\":0\\}")
PASS_REGULAR_EXPRESSION "\"command\":\"simulate-document-render\".*\"source\":\\{\"width\":64,\"height\":32,\"layers\":2,\"frames\":2,\"facePayloads\":2\\}.*\"render\":\\{\"frame\":0,\"width\":64,\"height\":32,\"faces\":6,\"visitedLayers\":2,\"compositedLayerFaces\":1,\"facePayloads\":1.*\\{\"face\":0,\"pixels\":2048,\"payloads\":1,\"nonClearPixels\":1,\"firstNonClear\":\\{\"index\":194,\"x\":2,\"y\":3,\"r\":1,\"g\":0,\"b\":0,\"a\":1\\}\\}.*\\{\"face\":5,\"pixels\":2048,\"payloads\":0,\"nonClearPixels\":0\\}.*\"upload\":\\{\"backend\":\"recording\",\"textures\":6,\"bytes\":49152,\"commands\":12,\"uploadCommands\":6,\"transitionCommands\":6,\"transitions\":6\\}")
add_test(NAME pano_cli_simulate_image_import_smoke
COMMAND pano_cli simulate-image-import --width 64 --height 32)

View File

@@ -1,4 +1,5 @@
#include "paint_renderer/compositor.h"
#include "renderer_api/recording_renderer.h"
#include "test_harness.h"
#include <cmath>
@@ -26,6 +27,8 @@ using pp::paint_renderer::plan_stroke_composite;
using pp::paint_renderer::stroke_composite_path_name;
using pp::paint_renderer::stroke_composite_requires_feedback;
using pp::renderer::Extent2D;
using pp::renderer::RecordedRenderCommandKind;
using pp::renderer::RecordingRenderDevice;
using pp::renderer::RenderDeviceFeatures;
using pp::renderer::TextureFormat;
using pp::renderer::TextureUsage;
@@ -456,6 +459,124 @@ void document_frame_composite_rejects_invalid_requests(pp::tests::Harness& h)
PP_EXPECT(h, bad_frame.status().code == StatusCode::out_of_range);
}
void uploads_document_frame_faces_to_renderer_api(pp::tests::Harness& h)
{
const AnimationFrame root_frames[] {
{ .duration_ms = 100, .face_pixels = {} },
};
const AnimationFrame layer_frames[] {
{
.duration_ms = 100,
.face_pixels = {
LayerFacePixels {
.face_index = 0,
.x = 0,
.y = 0,
.width = 1,
.height = 1,
.rgba8 = { 255, 0, 0, 255 },
},
LayerFacePixels {
.face_index = 3,
.x = 0,
.y = 0,
.width = 1,
.height = 1,
.rgba8 = { 0, 255, 0, 128 },
},
},
},
};
const DocumentLayerConfig layers[] {
{
.name = "Paint",
.frames = std::span<const AnimationFrame>(layer_frames, 1),
},
};
const auto document = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig {
.width = 1,
.height = 1,
.layers = std::span<const DocumentLayerConfig>(layers, 1),
.frames = std::span<const AnimationFrame>(root_frames, 1),
.selection_masks = {},
});
PP_EXPECT(h, document);
RecordingRenderDevice device;
const auto result = pp::paint_renderer::upload_document_frame_faces(
device,
pp::paint_renderer::DocumentFrameUploadRequest {
.document = &document.value(),
.frame_index = 0,
});
PP_EXPECT(h, result);
if (result) {
PP_EXPECT(h, result.value().texture_count == pp::document::cube_face_count);
PP_EXPECT(h, result.value().transition_count == pp::document::cube_face_count);
PP_EXPECT(h, result.value().uploaded_bytes == 24U);
PP_EXPECT(h, result.value().composite.face_payload_count == 2U);
PP_EXPECT(h, result.value().face_textures[0] != nullptr);
PP_EXPECT(h, result.value().face_textures[0]->desc().extent.width == 1U);
PP_EXPECT(h, result.value().face_textures[0]->desc().format == TextureFormat::rgba8);
}
std::size_t upload_count = 0;
std::size_t transition_count = 0;
for (const auto& command : device.commands()) {
if (command.kind == RecordedRenderCommandKind::upload_texture) {
++upload_count;
PP_EXPECT(h, command.upload_bytes == 4U);
PP_EXPECT(h, command.readback_region.width == 1U);
PP_EXPECT(h, command.texture_desc.format == TextureFormat::rgba8);
}
if (command.kind == RecordedRenderCommandKind::transition_texture) {
++transition_count;
PP_EXPECT(h, command.before_state == pp::renderer::TextureState::upload_destination);
PP_EXPECT(h, command.after_state == pp::renderer::TextureState::shader_read);
}
}
PP_EXPECT(h, device.commands().size() == 12U);
PP_EXPECT(h, upload_count == pp::document::cube_face_count);
PP_EXPECT(h, transition_count == pp::document::cube_face_count);
}
void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
{
RecordingRenderDevice device;
const auto no_document = pp::paint_renderer::upload_document_frame_faces(
device,
pp::paint_renderer::DocumentFrameUploadRequest {});
const AnimationFrame root_frames[] {
{ .duration_ms = 100, .face_pixels = {} },
};
const DocumentLayerConfig layers[] {
{ .name = "Layer", .frames = {} },
};
const auto document = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig {
.width = 1,
.height = 1,
.layers = std::span<const DocumentLayerConfig>(layers, 1),
.frames = std::span<const AnimationFrame>(root_frames, 1),
.selection_masks = {},
});
PP_EXPECT(h, document);
const auto bad_frame = pp::paint_renderer::upload_document_frame_faces(
device,
pp::paint_renderer::DocumentFrameUploadRequest {
.document = &document.value(),
.frame_index = 1,
});
PP_EXPECT(h, !no_document.ok());
PP_EXPECT(h, no_document.status().code == StatusCode::invalid_argument);
PP_EXPECT(h, !bad_frame.ok());
PP_EXPECT(h, bad_frame.status().code == StatusCode::out_of_range);
PP_EXPECT(h, device.commands().empty());
}
void detects_feedback_requirements(pp::tests::Harness& h)
{
PP_EXPECT(h, !stroke_composite_requires_feedback(
@@ -800,6 +921,8 @@ int main()
harness.run("document_face_composite_rejects_invalid_requests", document_face_composite_rejects_invalid_requests);
harness.run("composites_document_frame_cube_faces", composites_document_frame_cube_faces);
harness.run("document_frame_composite_rejects_invalid_requests", document_frame_composite_rejects_invalid_requests);
harness.run("uploads_document_frame_faces_to_renderer_api", uploads_document_frame_faces_to_renderer_api);
harness.run("document_frame_upload_rejects_invalid_requests", document_frame_upload_rejects_invalid_requests);
harness.run("detects_feedback_requirements", detects_feedback_requirements);
harness.run("plans_stroke_composite_paths", plans_stroke_composite_paths);
harness.run("rejects_bad_stroke_composite_plans", rejects_bad_stroke_composite_plans);

View File

@@ -10668,19 +10668,33 @@ int simulate_document_render(int argc, char** argv)
}
constexpr pp::paint::Rgba clear_color {};
const auto composited = pp::paint_renderer::composite_document_frame(
pp::paint_renderer::DocumentFrameCompositeRequest {
pp::renderer::RecordingRenderDevice render_device;
const auto uploaded = pp::paint_renderer::upload_document_frame_faces(
render_device,
pp::paint_renderer::DocumentFrameUploadRequest {
.document = &document_result.value(),
.frame_index = args.frame,
.clear_color = clear_color,
});
if (!composited) {
print_error("simulate-document-render", composited.status().message);
if (!uploaded) {
print_error("simulate-document-render", uploaded.status().message);
return 2;
}
const auto& document = document_result.value();
const auto& result = composited.value();
const auto& uploaded_value = uploaded.value();
const auto& result = uploaded_value.composite;
std::size_t upload_command_count = 0;
std::size_t transition_command_count = 0;
for (const auto& command : render_device.commands()) {
if (command.kind == pp::renderer::RecordedRenderCommandKind::upload_texture) {
++upload_command_count;
}
if (command.kind == pp::renderer::RecordedRenderCommandKind::transition_texture) {
++transition_command_count;
}
}
std::cout << "{\"ok\":true,\"command\":\"simulate-document-render\""
<< ",\"source\":{\"width\":" << document.width()
<< ",\"height\":" << document.height()
@@ -10729,7 +10743,14 @@ int simulate_document_render(int argc, char** argv)
}
std::cout << "}";
}
std::cout << "]}}\n";
std::cout << "],\"upload\":{\"backend\":\"" << render_device.backend_name()
<< "\",\"textures\":" << uploaded_value.texture_count
<< ",\"bytes\":" << uploaded_value.uploaded_bytes
<< ",\"commands\":" << render_device.commands().size()
<< ",\"uploadCommands\":" << upload_command_count
<< ",\"transitionCommands\":" << transition_command_count
<< ",\"transitions\":" << uploaded_value.transition_count
<< "}}}\n";
return 0;
}