diff options
Diffstat (limited to 'retrace')
-rw-r--r-- | retrace/daemon/glframe_metrics.cpp | 56 | ||||
-rw-r--r-- | retrace/daemon/glframe_metrics.hpp | 3 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace.cpp | 47 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace.hpp | 3 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace_interface.hpp | 22 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace_skeleton.cpp | 85 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace_skeleton.hpp | 10 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace_stub.cpp | 55 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace_stub.hpp | 3 | ||||
-rw-r--r-- | retrace/daemon/playback.proto | 26 | ||||
-rw-r--r-- | retrace/daemon/test/retrace_daemon_test.cpp | 8 | ||||
-rw-r--r-- | retrace/daemon/test/retrace_file_transfer_test.cpp | 12 | ||||
-rw-r--r-- | retrace/daemon/test/retrace_metrics_test.cpp | 51 | ||||
-rw-r--r-- | retrace/daemon/ui/glframe_retrace_model.cpp | 3 | ||||
-rw-r--r-- | retrace/daemon/ui/glframe_retrace_model.hpp | 3 |
15 files changed, 314 insertions, 73 deletions
diff --git a/retrace/daemon/glframe_metrics.cpp b/retrace/daemon/glframe_metrics.cpp index 7594577a..be0f1b35 100644 --- a/retrace/daemon/glframe_metrics.cpp +++ b/retrace/daemon/glframe_metrics.cpp @@ -78,7 +78,9 @@ class PerfMetricGroup : public NoCopy, NoAssign { void metrics(std::vector<MetricDescription> *m) const; void begin(RenderId render); void end(RenderId render); - void publish(MetricId metric, ExperimentId experimentCount, + void publish(MetricId metric, + ExperimentId experimentCount, + SelectionId selectionCount, OnFrameRetrace *callback); private: @@ -213,10 +215,22 @@ PerfMetricGroup::begin(RenderId render) { void PerfMetricGroup::publish(MetricId metric, ExperimentId experimentCount, + SelectionId selectionCount, OnFrameRetrace *callback) { - MetricSeries out_data; - out_data.metric = metric; - out_data.data.reserve(m_extant_query_handles.size()); + const bool publish_all = ((metric() | ID_PREFIX_MASK) == -1); + const int publish_count = m_extant_query_handles.size(); + std::map<MetricId, MetricSeries> out_data; + if (publish_all) { + for (auto i : m_metrics) { + out_data[i.first].data.reserve(publish_count); + out_data[i.first].metric = i.first; + } + } else { + assert(m_metrics.find(metric) != m_metrics.end()); + out_data[metric].data.reserve(publish_count); + out_data[metric].metric = metric; + } + for (auto extant_query : m_extant_query_handles) { memset(m_data_buf.data(), 0, m_data_buf.size()); GLuint bytes_written; @@ -225,18 +239,23 @@ PerfMetricGroup::publish(MetricId metric, m_data_size, m_data_buf.data(), &bytes_written); assert(bytes_written == m_data_size); - assert(m_metrics.find(metric) != m_metrics.end()); // TODO(majanes) verify order of m_extant_query_handles is by // RenderId - out_data.data.push_back(m_metrics[metric]->getMetric(m_data_buf)); - + for (auto desired_metric : out_data) { + MetricId m = desired_metric.first; + out_data[m].data.push_back(m_metrics[m]->getMetric(m_data_buf)); + } m_free_query_handles.push_back(extant_query.second); } m_extant_query_handles.clear(); - if (callback) - callback->onMetrics(out_data, experimentCount); - + if (callback) { + for (auto desired_metric : out_data) { + callback->onMetrics(desired_metric.second, + experimentCount, + selectionCount); + } + } for (auto free_query : m_free_query_handles) { GlFunctions::DeletePerfQueryINTEL(free_query); } @@ -329,8 +348,10 @@ PerfMetrics::selectMetric(MetricId metric) { void PerfMetrics::publish(ExperimentId experimentCount, + SelectionId selectionCount, OnFrameRetrace *callback) { - current_group->publish(current_metric, experimentCount, callback); + current_group->publish(current_metric, experimentCount, + selectionCount, callback); } void @@ -343,3 +364,16 @@ void PerfMetrics::end() { current_group->end(current_render); } + +int +PerfMetrics::groupCount() const { + return groups.size(); +} + +void +PerfMetrics::selectGroup(int index) { + current_group = groups[index]; + // choose an invalid metric to represent "all metrics" + current_metric = MetricId(~ID_PREFIX_MASK); +} + diff --git a/retrace/daemon/glframe_metrics.hpp b/retrace/daemon/glframe_metrics.hpp index fb6448f3..3099b2a7 100644 --- a/retrace/daemon/glframe_metrics.hpp +++ b/retrace/daemon/glframe_metrics.hpp @@ -42,10 +42,13 @@ class PerfMetrics : public NoCopy, NoAssign { public: explicit PerfMetrics(OnFrameRetrace *cb); ~PerfMetrics(); + int groupCount() const; void selectMetric(MetricId metric); + void selectGroup(int index); void begin(RenderId render); void end(); void publish(ExperimentId experimentCount, + SelectionId selectionCount, OnFrameRetrace *callback); private: std::vector<PerfMetricGroup *> groups; diff --git a/retrace/daemon/glframe_retrace.cpp b/retrace/daemon/glframe_retrace.cpp index 5ec1e346..52e46fd6 100644 --- a/retrace/daemon/glframe_retrace.cpp +++ b/retrace/daemon/glframe_retrace.cpp @@ -49,6 +49,9 @@ #include "trace_dump.hpp" using glretrace::ExperimentId; +using glretrace::SelectionId; +using glretrace::MetricSeries; +using glretrace::ShaderAssembly; using glretrace::FrameRetrace; using glretrace::FrameState; using glretrace::GlFunctions; @@ -279,7 +282,10 @@ FrameRetrace::retraceMetrics(const std::vector<MetricId> &ids, metricData.metric = nullMetric; for (int i = 0; i < render_count; ++i) metricData.data.push_back(1.0); - callback->onMetrics(metricData, experimentCount); + callback->onMetrics(metricData, experimentCount, + // this use case is not based on render + // selection + SelectionId(0)); continue; } @@ -289,11 +295,46 @@ FrameRetrace::retraceMetrics(const std::vector<MetricId> &ids, m_renders[i]->retrace(m_tracker); m_metrics->end(); } - m_metrics->publish(experimentCount, callback); + m_metrics->publish(experimentCount, + SelectionId(0), // this use case is not based + // on render selection + callback); } } - +void +FrameRetrace::retraceAllMetrics(const RenderSelection &selection, + ExperimentId experimentCount, + OnFrameRetrace *callback) const { + for (int i = 0; i < m_metrics->groupCount(); ++i) { + if (i == 13) + // BUG in skl metrics + continue; + bool query_active = false; + m_metrics->selectGroup(i); + parser->setBookmark(frame_start.start); + // iterate through the RenderSelection, and insert begin/end + // around each RenderSeries + auto currentRenderSequence = selection.series.begin(); + for (int i = 0; i < m_renders.size(); ++i) { + if (currentRenderSequence != selection.series.end()) { + if (RenderId(i) == currentRenderSequence->end) { + m_metrics->end(); + query_active = false; + ++currentRenderSequence; + } + if (RenderId(i) == currentRenderSequence->begin) { + m_metrics->begin(RenderId(i)); + query_active = true; + } + } + m_renders[i]->retrace(m_tracker); + } + if (query_active) + m_metrics->end(); + m_metrics->publish(experimentCount, selection.id, callback); + } +} RenderId FrameRetrace::lastRenderForRTRegion(RenderId render) const { diff --git a/retrace/daemon/glframe_retrace.hpp b/retrace/daemon/glframe_retrace.hpp index a314e1e6..6370b099 100644 --- a/retrace/daemon/glframe_retrace.hpp +++ b/retrace/daemon/glframe_retrace.hpp @@ -75,6 +75,9 @@ class FrameRetrace : public IFrameRetrace { void retraceMetrics(const std::vector<MetricId> &ids, ExperimentId experimentCount, OnFrameRetrace *callback) const; + void retraceAllMetrics(const RenderSelection &selection, + ExperimentId experimentCount, + OnFrameRetrace *callback) const; void replaceShaders(RenderId renderId, ExperimentId experimentCount, const std::string &vs, diff --git a/retrace/daemon/glframe_retrace_interface.hpp b/retrace/daemon/glframe_retrace_interface.hpp index f9a0ebd0..0293522e 100644 --- a/retrace/daemon/glframe_retrace_interface.hpp +++ b/retrace/daemon/glframe_retrace_interface.hpp @@ -81,6 +81,7 @@ class RenderId { uint32_t index() const { return value & (~ID_PREFIX_MASK); } bool operator<(const RenderId &o) const { return value < o.value; } bool operator>(const RenderId &o) const { return value > o.value; } + bool operator==(const RenderId &o) const { return value == o.value; } private: uint32_t value; }; @@ -120,9 +121,10 @@ class SelectionId { ((selectionNumber & ID_PREFIX_MASK) == SELECTION_ID_PREFIX)); value = SELECTION_ID_PREFIX | selectionNumber; } + SelectionId() : value(0) {} uint32_t operator()() const { return value; } - uint32_t index() const { return value & (~ID_PREFIX_MASK); } + uint32_t count() const { return value & (~ID_PREFIX_MASK); } private: uint32_t value; }; @@ -150,6 +152,18 @@ struct MetricSeries { std::vector<float> data; }; +struct RenderSequence { + RenderId begin; + RenderId end; +}; + +typedef std::vector<RenderSequence> RenderSeries; + +struct RenderSelection { + SelectionId id; + RenderSeries series; +}; + struct ShaderAssembly { std::string shader; std::string ir; @@ -176,7 +190,8 @@ class OnFrameRetrace { virtual void onMetricList(const std::vector<MetricId> &ids, const std::vector<std::string> &names) = 0; virtual void onMetrics(const MetricSeries &metricData, - ExperimentId experimentCount) = 0; + ExperimentId experimentCount, + SelectionId selectionCount) = 0; virtual void onShaderCompile(RenderId renderId, ExperimentId experimentCount, bool status, @@ -208,6 +223,9 @@ class IFrameRetrace { virtual void retraceMetrics(const std::vector<MetricId> &ids, ExperimentId experimentCount, OnFrameRetrace *callback) const = 0; + virtual void retraceAllMetrics(const RenderSelection &selection, + ExperimentId experimentCount, + OnFrameRetrace *callback) const = 0; virtual void replaceShaders(RenderId renderId, ExperimentId experimentCount, const std::string &vs, diff --git a/retrace/daemon/glframe_retrace_skeleton.cpp b/retrace/daemon/glframe_retrace_skeleton.cpp index 07db9f44..852db1fe 100644 --- a/retrace/daemon/glframe_retrace_skeleton.cpp +++ b/retrace/daemon/glframe_retrace_skeleton.cpp @@ -60,13 +60,34 @@ FrameRetraceSkeleton::FrameRetraceSkeleton(Socket *sock, IFrameRetrace *frameretrace) : Thread("retrace_skeleton"), m_socket(sock), m_frame(frameretrace), - m_remaining_metrics_requests(0), m_multi_metrics_response(new RetraceResponse) { if (!m_frame) m_frame = new FrameRetrace(); } void +writeResponse(Socket *s, + const RetraceResponse &response, + std::vector<unsigned char> *buf) { + const uint32_t write_size = response.ByteSize(); + // std::cout << "response: writing size: " << write_size << "\n"; + if (!s->Write(write_size)) { + std::cout << "no write: len\n"; + return; + } + + buf->clear(); + buf->resize(write_size); + ArrayOutputStream array_out(buf->data(), write_size); + CodedOutputStream coded_out(&array_out); + response.SerializeToCodedStream(&coded_out); + if (!s->WriteVec(*buf)) { + std::cout << "no write: buf\n"; + return; + } +} + +void FrameRetraceSkeleton::Run() { while (true) { // leading 4 bytes is the message length @@ -159,12 +180,37 @@ FrameRetraceSkeleton::Run() { assert(request.has_metrics()); auto met = request.metrics(); std::vector<MetricId> ids; - m_remaining_metrics_requests = met.metric_ids().size(); for (int i : met.metric_ids()) ids.push_back(MetricId(i)); + m_multi_metrics_response->Clear(); m_frame->retraceMetrics(ids, ExperimentId(met.experiment_count()), this); + // callbacks have accumulated in m_multi_metrics_response + writeResponse(m_socket, *m_multi_metrics_response, &m_buf); + m_multi_metrics_response->Clear(); + break; + } + case ApiTrace::ALL_METRICS_REQUEST: + { + assert(request.has_allmetrics()); + auto met = request.allmetrics(); + auto sel = met.selection(); + RenderSelection selection; + selection.id = SelectionId(sel.selection_count()); + selection.series.resize(sel.render_series_size()); + for (int i = 0; i < sel.render_series_size(); ++i) { + auto sequence = sel.render_series(i); + selection.series[i].begin = RenderId(sequence.begin()); + selection.series[i].end = RenderId(sequence.end()); + } + m_multi_metrics_response->Clear(); + m_frame->retraceAllMetrics(selection, + ExperimentId(met.experiment_count()), + this); + // callbacks have accumulated in m_multi_metrics_response + writeResponse(m_socket, *m_multi_metrics_response, &m_buf); + m_multi_metrics_response->Clear(); break; } case ApiTrace::SHADER_ASSEMBLY_REQUEST: @@ -202,28 +248,6 @@ FrameRetraceSkeleton::Run() { } void -writeResponse(Socket *s, - const RetraceResponse &response, - std::vector<unsigned char> *buf) { - const uint32_t write_size = response.ByteSize(); - // std::cout << "response: writing size: " << write_size << "\n"; - if (!s->Write(write_size)) { - std::cout << "no write: len\n"; - return; - } - - buf->clear(); - buf->resize(write_size); - ArrayOutputStream array_out(buf->data(), write_size); - CodedOutputStream coded_out(&array_out); - response.SerializeToCodedStream(&coded_out); - if (!s->WriteVec(*buf)) { - std::cout << "no write: buf\n"; - return; - } -} - -void FrameRetraceSkeleton::onFileOpening(bool needUpload, bool finished, uint32_t percent_complete) { @@ -327,23 +351,16 @@ FrameRetraceSkeleton::onMetricList(const std::vector<MetricId> &ids, void FrameRetraceSkeleton::onMetrics(const MetricSeries &metricData, - ExperimentId experimentCount) { + ExperimentId experimentCount, + SelectionId selectionCount) { auto metrics_response = m_multi_metrics_response->mutable_metricsdata(); metrics_response->set_experiment_count(experimentCount()); + metrics_response->set_selection_count(selectionCount()); ApiTrace::MetricSeries *s = metrics_response->add_metric_data(); s->set_metric_id(metricData.metric()); for (auto d : metricData.data) { s->add_data(d); } - - --m_remaining_metrics_requests; - if (m_remaining_metrics_requests > 0) - return; - - // else - writeResponse(m_socket, *m_multi_metrics_response, &m_buf); - m_remaining_metrics_requests = 0; - m_multi_metrics_response->Clear(); } void diff --git a/retrace/daemon/glframe_retrace_skeleton.hpp b/retrace/daemon/glframe_retrace_skeleton.hpp index 2b80aca6..d77dffd7 100644 --- a/retrace/daemon/glframe_retrace_skeleton.hpp +++ b/retrace/daemon/glframe_retrace_skeleton.hpp @@ -70,7 +70,8 @@ class FrameRetraceSkeleton : public Thread, virtual void onMetricList(const std::vector<MetricId> &ids, const std::vector<std::string> &names); virtual void onMetrics(const MetricSeries &metricData, - ExperimentId experimentCount); + ExperimentId experimentCount, + SelectionId selectionCount); virtual void onApi(RenderId renderid, const std::vector<std::string> &api_calls); @@ -83,7 +84,12 @@ class FrameRetraceSkeleton : public Thread, IFrameRetrace *m_frame; int m_remaining_metrics_requests; - // for aggregating metrics callbacks on a series of requests + // For aggregating metrics callbacks on a series of requests. + // retraceMetrics is called several times, calling the onMetrics + // callback synchronously in the same thread. Aggregated metrics + // are returned through the socket in a single response. The + // calling stub will call onMetrics several times on the host + // system. ApiTrace::RetraceResponse *m_multi_metrics_response; }; diff --git a/retrace/daemon/glframe_retrace_stub.cpp b/retrace/daemon/glframe_retrace_stub.cpp index 65311d5d..ce5378c9 100644 --- a/retrace/daemon/glframe_retrace_stub.cpp +++ b/retrace/daemon/glframe_retrace_stub.cpp @@ -40,7 +40,9 @@ using ApiTrace::RetraceRequest; using ApiTrace::RetraceResponse; +using glretrace::RenderSelection; using glretrace::ExperimentId; +using glretrace::SelectionId; using glretrace::FrameRetraceStub; using glretrace::MetricId; using glretrace::MetricSeries; @@ -293,7 +295,49 @@ class RetraceMetricsRequest : public IRetraceRequest { for (auto d : data_float_vec) met.data.push_back(d); - m_callback->onMetrics(met, eid); + m_callback->onMetrics(met, eid, SelectionId(0)); + } + } + + private: + RetraceRequest m_proto_msg; + OnFrameRetrace *m_callback; +}; + +class RetraceAllMetricsRequest : public IRetraceRequest { + public: + RetraceAllMetricsRequest(const RenderSelection &selection, + ExperimentId experimentCount, + OnFrameRetrace *cb) + : m_callback(cb) { + auto metricsRequest = m_proto_msg.mutable_allmetrics(); + metricsRequest->set_experiment_count(experimentCount()); + auto selectionRequest = metricsRequest->mutable_selection(); + selectionRequest->set_selection_count(selection.id()); + for (auto sequence : selection.series) { + auto series = selectionRequest->add_render_series(); + series->set_begin(sequence.begin()); + series->set_end(sequence.end()); + } + m_proto_msg.set_requesttype(ApiTrace::ALL_METRICS_REQUEST); + } + virtual void retrace(RetraceSocket *s) { + RetraceResponse response; + s->retrace(m_proto_msg, &response); + assert(response.has_metricsdata()); + auto metrics_response = response.metricsdata(); + + const ExperimentId eid(metrics_response.experiment_count()); + const SelectionId sid(metrics_response.selection_count()); + for (auto &metric_data : metrics_response.metric_data()) { + MetricSeries met; + met.metric = MetricId(metric_data.metric_id()); + auto &data_float_vec = metric_data.data(); + met.data.reserve(data_float_vec.size()); + for (auto d : data_float_vec) + met.data.push_back(d); + + m_callback->onMetrics(met, eid, sid); } } @@ -491,6 +535,15 @@ FrameRetraceStub::retraceMetrics(const std::vector<MetricId> &ids, } void +FrameRetraceStub::retraceAllMetrics(const RenderSelection &selection, + ExperimentId experimentCount, + OnFrameRetrace *callback) const { + m_thread->push(new RetraceAllMetricsRequest(selection, + experimentCount, + callback)); +} + +void FrameRetraceStub::replaceShaders(RenderId renderId, ExperimentId experimentCount, const std::string &vs, diff --git a/retrace/daemon/glframe_retrace_stub.hpp b/retrace/daemon/glframe_retrace_stub.hpp index cfa73184..f8524d1d 100644 --- a/retrace/daemon/glframe_retrace_stub.hpp +++ b/retrace/daemon/glframe_retrace_stub.hpp @@ -60,6 +60,9 @@ class FrameRetraceStub : public IFrameRetrace { virtual void retraceMetrics(const std::vector<MetricId> &ids, ExperimentId experimentCount, OnFrameRetrace *callback) const; + virtual void retraceAllMetrics(const RenderSelection &selection, + ExperimentId experimentCount, + OnFrameRetrace *callback) const; virtual void replaceShaders(RenderId renderId, ExperimentId experimentCount, const std::string &vs, diff --git a/retrace/daemon/playback.proto b/retrace/daemon/playback.proto index edd31a61..4c795ad2 100644 --- a/retrace/daemon/playback.proto +++ b/retrace/daemon/playback.proto @@ -10,8 +10,9 @@ enum RequestType { RENDER_TARGET_REQUEST = 2; SHADER_ASSEMBLY_REQUEST = 3; METRICS_REQUEST = 4; - REPLACE_SHADERS_REQUEST = 5; - API_REQUEST = 6; + ALL_METRICS_REQUEST = 5; + REPLACE_SHADERS_REQUEST = 6; + API_REQUEST = 7; }; message OpenFileRequest { @@ -54,6 +55,21 @@ message MetricsRequest { required uint32 experiment_count = 2; } +message RenderSequence { + required uint32 begin = 1; + required uint32 end = 2; +} + +message RenderSelection { + required uint32 selection_count = 1; + repeated RenderSequence render_series = 2; +} + +message AllMetricsRequest { + required RenderSelection selection = 1; + required uint32 experiment_count = 2; +} + message ShaderAssembly { required string shader = 1; required string ir = 2; @@ -79,6 +95,7 @@ message MetricSeries { message MetricsResponse { repeated MetricSeries metric_data = 1; required uint32 experiment_count = 2; + required uint32 selection_count = 3; } message ReplaceShadersRequest { @@ -113,8 +130,9 @@ message RetraceRequest { optional ShaderAssemblyRequest shaderAssembly = 3; optional OpenFileRequest fileOpen = 4; optional MetricsRequest metrics = 5; - optional ReplaceShadersRequest shaders = 6; - optional ApiResponse api = 7; + optional AllMetricsRequest allMetrics = 6; + optional ReplaceShadersRequest shaders = 7; + optional ApiResponse api = 8; } message RetraceResponse { diff --git a/retrace/daemon/test/retrace_daemon_test.cpp b/retrace/daemon/test/retrace_daemon_test.cpp index ed00163b..581226ec 100644 --- a/retrace/daemon/test/retrace_daemon_test.cpp +++ b/retrace/daemon/test/retrace_daemon_test.cpp @@ -36,14 +36,15 @@ #include "glframe_logger.hpp" using glretrace::ExperimentId; -using glretrace::GlFunctions; using glretrace::FrameRetrace; +using glretrace::GlFunctions; +using glretrace::Logger; using glretrace::MetricId; using glretrace::MetricSeries; using glretrace::OnFrameRetrace; using glretrace::RenderId; -using glretrace::Logger; using glretrace::RenderTargetType; +using glretrace::SelectionId; using glretrace::ShaderAssembly; TEST(Build, Cmake) { @@ -74,7 +75,8 @@ class NullCallback : public OnFrameRetrace { void onMetricList(const std::vector<MetricId> &ids, const std::vector<std::string> &names) {} void onMetrics(const MetricSeries &metricData, - ExperimentId experimentCount) {} + ExperimentId experimentCount, + SelectionId selectionCount) {} void onApi(RenderId renderId, const std::vector<std::string> &api_calls) { calls = api_calls; diff --git a/retrace/daemon/test/retrace_file_transfer_test.cpp b/retrace/daemon/test/retrace_file_transfer_test.cpp index 3666d46b..8400083a 100644 --- a/retrace/daemon/test/retrace_file_transfer_test.cpp +++ b/retrace/daemon/test/retrace_file_transfer_test.cpp @@ -43,14 +43,16 @@ using glretrace::FrameRetraceSkeleton; using glretrace::FrameRetraceStub; using glretrace::IFrameRetrace; using glretrace::MetricId; +using glretrace::MetricSeries; using glretrace::OnFrameRetrace; using glretrace::RenderId; using glretrace::RenderOptions; +using glretrace::RenderSelection; using glretrace::RenderTargetType; +using glretrace::SelectionId; using glretrace::ServerSocket; -using glretrace::Socket; using glretrace::ShaderAssembly; -using glretrace::MetricSeries; +using glretrace::Socket; class FileTransfer : public IFrameRetrace { void openFile(const std::string &filename, @@ -70,6 +72,9 @@ class FileTransfer : public IFrameRetrace { void retraceMetrics(const std::vector<MetricId> &ids, ExperimentId experimentCount, OnFrameRetrace *callback) const {} + virtual void retraceAllMetrics(const RenderSelection &selection, + ExperimentId experimentCount, + OnFrameRetrace *callback) const {} void replaceShaders(RenderId renderId, ExperimentId experimentCount, const std::string &vs, @@ -101,7 +106,8 @@ class FileTransferCB : public OnFrameRetrace { void onMetricList(const std::vector<MetricId> &ids, const std::vector<std::string> &names) {} void onMetrics(const MetricSeries &metricData, - ExperimentId experimentCount) {} + ExperimentId experimentCount, + SelectionId selectionCount) {} void onShaderCompile(RenderId renderId, ExperimentId experimentCount, bool status, diff --git a/retrace/daemon/test/retrace_metrics_test.cpp b/retrace/daemon/test/retrace_metrics_test.cpp index ce958e91..d7411f8f 100644 --- a/retrace/daemon/test/retrace_metrics_test.cpp +++ b/retrace/daemon/test/retrace_metrics_test.cpp @@ -58,16 +58,19 @@ class MetricsCallback : public OnFrameRetrace { names = n; } void onMetrics(const MetricSeries &metricData, - ExperimentId experimentCount) { - data = metricData; + ExperimentId experimentCount, + SelectionId selectionCount) { + data.push_back(metricData); experiment_count = experimentCount; + selection_count = selectionCount; } void onApi(RenderId renderId, const std::vector<std::string> &api_calls) {} std::vector<MetricId> ids; std::vector<std::string> names; - MetricSeries data; + std::vector<MetricSeries> data; ExperimentId experiment_count; + SelectionId selection_count; }; TEST_F(RetraceTest, ReadMetrics) { @@ -110,10 +113,10 @@ TEST_F(RetraceTest, SingleMetricData) { rt.retraceRenderTarget(RenderId(1), 0, glretrace::NORMAL_RENDER, glretrace::STOP_AT_RENDER, &cb); p.end(); - p.publish(ExperimentId(1), &cb); + p.publish(ExperimentId(1), SelectionId(0), &cb); EXPECT_EQ(cb.experiment_count.count(), 1); - for (float d : cb.data.data) { - std::cout << "data: " << d << std::endl; + EXPECT_EQ(cb.data.size(), 1); + for (float d : cb.data[0].data) { EXPECT_GT(d, 0.0); } retrace::cleanUp(); @@ -141,11 +144,43 @@ TEST_F(RetraceTest, FrameMetricData) { const ExperimentId experiment(1); rt.retraceMetrics(mets, experiment, &cb); EXPECT_EQ(cb.experiment_count.count(), 1); - for (float d : cb.data.data) { - std::cout << "data: " << d << std::endl; + EXPECT_EQ(cb.data.size(), 1); + for (float d : cb.data[0].data) { EXPECT_GT(d, 0.0); } retrace::cleanUp(); } +TEST_F(RetraceTest, AllMetricData) { + GlFunctions::Init(); + MetricsCallback cb; + + FrameRetrace rt; + rt.openFile(test_file, md5, fileSize, 7, &cb); + if (!cb.ids.size()) { + retrace::cleanUp(); + return; + } + + // get all metrics for render 0 and 1 + RenderSelection sel; + sel.id = SelectionId(777); + sel.series.resize(2); + sel.series[0].begin = RenderId(0); + sel.series[0].end = RenderId(1); + sel.series[1].begin = RenderId(1); + sel.series[1].end = RenderId(2); + const ExperimentId experiment(1); + rt.retraceAllMetrics(sel, experiment, &cb); + EXPECT_EQ(cb.experiment_count.count(), 1); + EXPECT_EQ(cb.selection_count.count(), 777); + EXPECT_GT(cb.data.size(), 1); // one callback for each metric + for (const MetricSeries s : cb.data) { + for (float d : s.data) { + EXPECT_GT(d, -0.1); + } + } + retrace::cleanUp(); +} + } // namespace glretrace diff --git a/retrace/daemon/ui/glframe_retrace_model.cpp b/retrace/daemon/ui/glframe_retrace_model.cpp index 08be218c..1ffc9fd2 100644 --- a/retrace/daemon/ui/glframe_retrace_model.cpp +++ b/retrace/daemon/ui/glframe_retrace_model.cpp @@ -269,7 +269,8 @@ FrameRetraceModel::onMetricList(const std::vector<MetricId> &ids, void FrameRetraceModel::onMetrics(const MetricSeries &metricData, - ExperimentId experimentCount) { + ExperimentId experimentCount, + SelectionId selectionCount) { ScopedLock s(m_protect); bool vertical_metric = false; if (metricData.metric == m_active_metrics[0]) diff --git a/retrace/daemon/ui/glframe_retrace_model.hpp b/retrace/daemon/ui/glframe_retrace_model.hpp index fdd81d9e..940ad1fc 100644 --- a/retrace/daemon/ui/glframe_retrace_model.hpp +++ b/retrace/daemon/ui/glframe_retrace_model.hpp @@ -155,7 +155,8 @@ class FrameRetraceModel : public QObject, void onMetricList(const std::vector<MetricId> &ids, const std::vector<std::string> &names); void onMetrics(const MetricSeries &metricData, - ExperimentId experimentCount); + ExperimentId experimentCount, + SelectionId selectionCount); void onApi(RenderId renderId, const std::vector<std::string> &api_calls); QString renderTargetImage() const; int openPercent() const { ScopedLock s(m_protect); return m_open_percent; } |