升级
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
#include "../render/Blend2D_Cache.h"
|
||||
#include "../renderable/Render_Partition.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
@@ -25,7 +24,7 @@ struct Spectrum_Interaction {
|
||||
using Spectrum_Interaction_State = Double_State_Strategy<Spectrum_Interaction_Base, Spectrum_Interaction>;
|
||||
struct Spectrum_Render_Frame {
|
||||
Adaptive_Render_Partitioner partitioner;
|
||||
std::array<Blend2D_Color_Cache, maximum_render_partitions> layers;
|
||||
std::vector<Blend2D_Color_Cache> layers;
|
||||
int active_partitions{1};
|
||||
std::size_t work_size{};
|
||||
bool valid{};
|
||||
@@ -244,17 +243,24 @@ void Spectrum_Control::publish() {
|
||||
}
|
||||
|
||||
void Spectrum_Control::build_paint_task_graph(Renderable_Task_Graph& graph) {
|
||||
const auto prepare = graph.emplace([this](const Scene_Render_Context&) {
|
||||
prepare_render_frame(render_state_view());
|
||||
auto& output = impl_->render_frame;
|
||||
const int partition_count = output.partitioner.graph_partition_count(
|
||||
render_properties(render_state_view()).partition_count.get(),
|
||||
static_cast<int>(Scene_Base::task_executor_worker_count()));
|
||||
output.layers.resize(static_cast<std::size_t>(partition_count));
|
||||
const auto prepare = graph.emplace([this, partition_count](const Scene_Render_Context&) {
|
||||
prepare_render_frame(render_state_view(), partition_count);
|
||||
}, "prepare spectrum");
|
||||
std::array<Renderable_Task_Graph::Task, maximum_render_partitions> partitions;
|
||||
for (int index = 0; index < maximum_render_partitions; ++index) {
|
||||
partitions[static_cast<std::size_t>(index)] = graph.emplace(
|
||||
std::vector<Renderable_Task_Graph::Task> partitions;
|
||||
partitions.reserve(static_cast<std::size_t>(partition_count));
|
||||
for (int index = 0; index < partition_count; ++index) {
|
||||
const auto partition = graph.emplace(
|
||||
[this, index](const Scene_Render_Context&) {
|
||||
render_partition(render_state_view(), index);
|
||||
},
|
||||
"paint spectrum partition");
|
||||
graph.precede(prepare, partitions[static_cast<std::size_t>(index)]);
|
||||
"paint spectrum partition " + std::to_string(index + 1));
|
||||
graph.precede(prepare, partition);
|
||||
partitions.push_back(partition);
|
||||
}
|
||||
const auto compose = add_paint_task(
|
||||
graph, "compose spectrum",
|
||||
@@ -263,7 +269,8 @@ void Spectrum_Control::build_paint_task_graph(Renderable_Task_Graph& graph) {
|
||||
graph.precede(task, compose);
|
||||
}
|
||||
|
||||
void Spectrum_Control::prepare_render_frame(const Render_State_View& view) {
|
||||
void Spectrum_Control::prepare_render_frame(const Render_State_View& view,
|
||||
int graph_partition_count) {
|
||||
const auto& state = render_properties(view);
|
||||
const auto& published_frame = view.get(impl_->frame);
|
||||
auto& output = impl_->render_frame;
|
||||
@@ -271,8 +278,8 @@ void Spectrum_Control::prepare_render_frame(const Render_State_View& view) {
|
||||
const Axis_Transform power_axis = impl_->power_axis->transform(view);
|
||||
output.valid = axes_are_orthogonal(frequency_axis, power_axis);
|
||||
output.work_size = published_frame ? published_frame->samples.size() : 0;
|
||||
output.active_partitions =
|
||||
output.partitioner.begin(state.partition_count.get(), output.work_size);
|
||||
output.active_partitions = output.partitioner.begin(graph_partition_count,
|
||||
output.work_size);
|
||||
for (int index = 0; index < output.active_partitions; ++index)
|
||||
output.layers[static_cast<std::size_t>(index)].clear();
|
||||
}
|
||||
@@ -380,7 +387,11 @@ void Spectrum_Control::paint(Painter& painter, const Render_State_View& view) {
|
||||
painter.text({box.x + 4.0, box.y + 3.0}, text.str(), state.tooltip_font, state.tooltip_text_pen);
|
||||
}
|
||||
}
|
||||
output.partitioner.finish(output.work_size);
|
||||
if (output.partitioner.finish(
|
||||
state.partition_count.get(), output.active_partitions,
|
||||
static_cast<int>(Scene_Base::task_executor_worker_count()),
|
||||
output.work_size))
|
||||
task_graph_changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user