Add paint feedback strategy planner
This commit is contained in:
@@ -34,6 +34,7 @@ using pp::renderer::IRenderTarget;
|
||||
using pp::renderer::IRenderTrace;
|
||||
using pp::renderer::IShaderProgram;
|
||||
using pp::renderer::MeshDesc;
|
||||
using pp::renderer::PaintFeedbackPath;
|
||||
using pp::renderer::PrimitiveTopology;
|
||||
using pp::renderer::ReadbackRegion;
|
||||
using pp::renderer::RecordedRenderCommandKind;
|
||||
@@ -66,6 +67,8 @@ using pp::renderer::max_texture_dimension;
|
||||
using pp::renderer::max_texture_slots;
|
||||
using pp::renderer::max_trace_label_bytes;
|
||||
using pp::renderer::panopainter_shader_catalog;
|
||||
using pp::renderer::paint_feedback_path_name;
|
||||
using pp::renderer::plan_paint_feedback;
|
||||
using pp::renderer::primitive_topology_name;
|
||||
using pp::renderer::readback_byte_size;
|
||||
using pp::renderer::recorded_render_command_kind_name;
|
||||
@@ -1210,6 +1213,94 @@ void validates_blit_contract(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, blit_filter_name(static_cast<BlitFilter>(255)) == std::string_view("unknown"));
|
||||
}
|
||||
|
||||
void plans_paint_feedback_paths(pp::tests::Harness& h)
|
||||
{
|
||||
const TextureDesc render_target {
|
||||
.extent = Extent2D { .width = 64, .height = 32 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::render_target
|
||||
| TextureUsage::sampled
|
||||
| TextureUsage::copy_source
|
||||
| TextureUsage::copy_destination,
|
||||
.debug_name = "paint-target",
|
||||
};
|
||||
const TextureDesc render_only_target {
|
||||
.extent = Extent2D { .width = 64, .height = 32 },
|
||||
.format = TextureFormat::rgba8,
|
||||
.usage = TextureUsage::render_target,
|
||||
.debug_name = "paint-render-only",
|
||||
};
|
||||
const TextureDesc depth_target {
|
||||
.extent = Extent2D { .width = 64, .height = 32 },
|
||||
.format = TextureFormat::depth24_stencil8,
|
||||
.usage = TextureUsage::render_target
|
||||
| TextureUsage::sampled
|
||||
| TextureUsage::copy_source
|
||||
| TextureUsage::copy_destination,
|
||||
.debug_name = "paint-depth",
|
||||
};
|
||||
const RenderDeviceFeatures framebuffer_fetch_features {
|
||||
.framebuffer_fetch = true,
|
||||
.explicit_texture_transitions = true,
|
||||
};
|
||||
const RenderDeviceFeatures copy_features {
|
||||
.texture_copy = true,
|
||||
};
|
||||
const RenderDeviceFeatures blit_features {
|
||||
.render_target_blit = true,
|
||||
};
|
||||
|
||||
const auto simple = plan_paint_feedback(copy_features, render_only_target, false);
|
||||
PP_EXPECT(h, simple);
|
||||
if (simple) {
|
||||
PP_EXPECT(h, simple.value().path == PaintFeedbackPath::none);
|
||||
PP_EXPECT(h, !simple.value().reads_destination_color);
|
||||
PP_EXPECT(h, simple.value().target_bytes == 8192U);
|
||||
}
|
||||
|
||||
const auto fetch = plan_paint_feedback(framebuffer_fetch_features, render_only_target, true);
|
||||
PP_EXPECT(h, fetch);
|
||||
if (fetch) {
|
||||
PP_EXPECT(h, fetch.value().path == PaintFeedbackPath::framebuffer_fetch);
|
||||
PP_EXPECT(h, fetch.value().reads_destination_color);
|
||||
PP_EXPECT(h, !fetch.value().requires_auxiliary_texture);
|
||||
PP_EXPECT(h, !fetch.value().requires_texture_copy);
|
||||
PP_EXPECT(h, fetch.value().requires_explicit_transition);
|
||||
}
|
||||
|
||||
const auto ping_pong_copy = plan_paint_feedback(copy_features, render_target, true);
|
||||
PP_EXPECT(h, ping_pong_copy);
|
||||
if (ping_pong_copy) {
|
||||
PP_EXPECT(h, ping_pong_copy.value().path == PaintFeedbackPath::ping_pong_textures);
|
||||
PP_EXPECT(h, ping_pong_copy.value().requires_auxiliary_texture);
|
||||
PP_EXPECT(h, ping_pong_copy.value().requires_texture_copy);
|
||||
PP_EXPECT(h, !ping_pong_copy.value().requires_render_target_blit);
|
||||
PP_EXPECT(h, ping_pong_copy.value().auxiliary_desc.extent.width == render_target.extent.width);
|
||||
}
|
||||
|
||||
const auto ping_pong_blit = plan_paint_feedback(blit_features, render_target, true);
|
||||
PP_EXPECT(h, ping_pong_blit);
|
||||
if (ping_pong_blit) {
|
||||
PP_EXPECT(h, ping_pong_blit.value().path == PaintFeedbackPath::ping_pong_textures);
|
||||
PP_EXPECT(h, !ping_pong_blit.value().requires_texture_copy);
|
||||
PP_EXPECT(h, ping_pong_blit.value().requires_render_target_blit);
|
||||
}
|
||||
|
||||
const auto unsupported = plan_paint_feedback(RenderDeviceFeatures {}, render_target, true);
|
||||
const auto missing_usage = plan_paint_feedback(copy_features, render_only_target, true);
|
||||
const auto depth = plan_paint_feedback(copy_features, depth_target, true);
|
||||
|
||||
PP_EXPECT(h, !unsupported.ok());
|
||||
PP_EXPECT(h, unsupported.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !missing_usage.ok());
|
||||
PP_EXPECT(h, missing_usage.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !depth.ok());
|
||||
PP_EXPECT(h, depth.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, paint_feedback_path_name(PaintFeedbackPath::framebuffer_fetch) == std::string_view("framebuffer_fetch"));
|
||||
PP_EXPECT(h, paint_feedback_path_name(PaintFeedbackPath::ping_pong_textures) == std::string_view("ping_pong_textures"));
|
||||
PP_EXPECT(h, paint_feedback_path_name(static_cast<PaintFeedbackPath>(255)) == std::string_view("unknown"));
|
||||
}
|
||||
|
||||
void validates_texture_copy_contract(pp::tests::Harness& h)
|
||||
{
|
||||
const TextureDesc rgba_desc {
|
||||
@@ -2696,6 +2787,7 @@ int main()
|
||||
harness.run("computes_readback_byte_sizes", computes_readback_byte_sizes);
|
||||
harness.run("computes_frame_capture_byte_sizes", computes_frame_capture_byte_sizes);
|
||||
harness.run("validates_blit_contract", validates_blit_contract);
|
||||
harness.run("plans_paint_feedback_paths", plans_paint_feedback_paths);
|
||||
harness.run("validates_texture_copy_contract", validates_texture_copy_contract);
|
||||
harness.run("validates_blend_contract", validates_blend_contract);
|
||||
harness.run("validates_depth_contract", validates_depth_contract);
|
||||
|
||||
Reference in New Issue
Block a user