1212#include < functional>
1313#include " Framework/DeviceMetricsInfo.h"
1414#include " Framework/DeviceInfo.h"
15+ #include " Framework/DeviceSpec.h"
1516#include " Framework/DataDescriptorMatcher.h"
1617#include " Framework/DataProcessingStates.h"
18+ #include " InspectorHelpers.h"
1719#include " PaletteHelpers.h"
1820#include " Framework/Logger.h"
1921#include < iostream>
@@ -31,6 +33,7 @@ struct HeatMapHelper {
3133 template <typename RECORD, typename ITEM>
3234 static void draw (const char * name,
3335 ImVec2 const & sizeHint,
36+ std::function<size_t ()> const & getNumInputs,
3437 std::function<size_t()> const & getNumRecords,
3538 std::function<RECORD(size_t )> const & getRecord,
3639 std::function<size_t(RECORD const &)> const & getNumItems,
@@ -48,12 +51,13 @@ struct HeatMapHelper {
4851 ImVec2 winPos = ImGui::GetCursorScreenPos () + ImVec2{0 , 7 };
4952 auto records = getNumRecords ();
5053 auto boxSizeX = std::min (size.x / records, MAX_BOX_X_SIZE);
54+ auto numInputs = getNumInputs ();
5155
5256 ImGui::InvisibleButton (" sensible area" , ImVec2 (size.x , size.y ));
5357 if (ImGui::IsItemHovered ()) {
5458 auto pos = ImGui::GetMousePos () - winPos;
5559 auto slot = std::lround (std::trunc (pos.x / size.x * records));
56- auto row = std::lround (std::trunc (pos.y / size.y ));
60+ auto row = std::lround (std::trunc (pos.y / size.y * numInputs ));
5761 describeCell (row, slot);
5862 }
5963
@@ -96,9 +100,20 @@ struct HeatMapHelper {
96100
97101void displayDataRelayer (DeviceMetricsInfo const & metrics,
98102 DeviceInfo const & info,
103+ DeviceSpec const & spec,
99104 DataProcessingStates const & states,
100105 ImVec2 const & size)
101106{
107+ auto getNumInputs = [&states]() -> size_t {
108+ auto & inputsView = states.statesViews [(int )ProcessingStateId::DATA_QUERIES];
109+ std::string_view inputs (states.statesBuffer .data () + inputsView.first , inputsView.size );
110+ if (inputs.size () == 0 ) {
111+ return 0 ;
112+ }
113+ // count the number of semi-colon separators to get number of inputs
114+ int numInputs = std::count (inputs.begin (), inputs.end (), ' ;' );
115+ return numInputs;
116+ };
102117 auto getNumRecords = [&states]() -> size_t {
103118 auto & view = states.statesViews [(int )ProcessingStateId::DATA_RELAYER_BASE];
104119 if (view.size == 0 ) {
@@ -154,8 +169,30 @@ void displayDataRelayer(DeviceMetricsInfo const& metrics,
154169 }
155170 return SLOT_ERROR;
156171 };
157- auto describeCell = [&states](int input , int slot) -> void {
172+ auto describeCell = [&states, &spec ](int row , int slot) -> void {
158173 ImGui::BeginTooltip ();
174+
175+ // display the input (origin/descr/subspec)
176+ auto & inputsView = states.statesViews [(int )ProcessingStateId::DATA_QUERIES];
177+ std::string_view inputs (states.statesBuffer .data () + inputsView.first , inputsView.size );
178+ auto beginInputs = inputs.begin ();
179+ auto endInputs = beginInputs + inputsView.size ;
180+ char const * input = beginInputs;
181+ size_t i = 0 ;
182+ while (input != endInputs) {
183+ auto end = std::find (input, endInputs, ' ;' );
184+ if ((end - input) == 0 ) {
185+ continue ;
186+ }
187+ if (i == row) {
188+ ImGui::Text (" %d %.*s (%s)" , row, int (end - input), input, InspectorHelpers::getLifeTimeStr (spec.inputs [i].matcher .lifetime ).c_str ());
189+ break ;
190+ }
191+ ++i;
192+ input = end + 1 ;
193+ }
194+
195+ // display context variables
159196 ImGui::Text (" Input query matched values for slot: %d" , slot);
160197 auto & view = states.statesViews [(short )ProcessingStateId::CONTEXT_VARIABLES_BASE + (short )slot];
161198 auto begin = view.first ;
@@ -190,6 +227,7 @@ void displayDataRelayer(DeviceMetricsInfo const& metrics,
190227 if (getNumRecords ()) {
191228 HeatMapHelper::draw<int , int8_t >(" DataRelayer" ,
192229 size,
230+ getNumInputs,
193231 getNumRecords,
194232 getRecord,
195233 getNumItems,
0 commit comments