Upload document frame faces through renderer API
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user