Skip to content

Commit 3dea35d

Browse files
committed
GPU Display: Cleanup: remove dummy variale and string comparisons for transient check
1 parent 49ad60f commit 3dea35d

14 files changed

Lines changed: 119 additions & 118 deletions

‎GPU/GPUTracking/display/GPUDisplay.cxx‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(bool suspended, float animateTim
263263
mFrontend->mMouseWheel = 0;
264264
bool lookOrigin = mCfgR.camLookOrigin ^ mFrontend->mKeys[mFrontend->mKeyDownMap[mFrontend->KEY_MAP_FOCUS_ORIGIN]];
265265
bool yUp = mCfgR.camYUp ^ mFrontend->mKeys[mFrontend->mKeyDownMap[mFrontend->KEY_MAP_FOCUS_ORIENT_UP]] ^ lookOrigin;
266-
bool rotateModelTPC = mCfgC.rotateAroundZ || mFrontend->mKeys[mFrontend->mKeyDownMap[mFrontend->KEY_MAP_ROTATE_AROUND_Z]];
267-
bool rotateModel = rotateModelTPC || mCfgC.rotateModel || mFrontend->mKeys[mFrontend->mKeyDownMap[mFrontend->KEY_MAP_ROTATE_MODEL]];
266+
bool rotateModelTPC = mCfgO.rotateAroundZ || mFrontend->mKeys[mFrontend->mKeyDownMap[mFrontend->KEY_MAP_ROTATE_AROUND_Z]];
267+
bool rotateModel = rotateModelTPC || mCfgO.rotateModel || mFrontend->mKeys[mFrontend->mKeyDownMap[mFrontend->KEY_MAP_ROTATE_MODEL]];
268268

269269
// Calculate rotation / translation scaling factors
270270
float scalefactor = mFrontend->mKeys[mFrontend->KEY_SHIFT] ? 0.2f : 1.0f;
@@ -324,15 +324,15 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(bool suspended, float animateTim
324324
}
325325

326326
if (mFrontend->mKeys[mFrontend->mKeyDownMap[mFrontend->KEY_MAP_CHANGE_ANIMATION_INTERVAL]]) {
327-
mCfgC.animationDelay += moveX;
328-
if (mCfgC.animationDelay < 0.05f) {
329-
mCfgC.animationDelay = 0.05f;
330-
} else if (mCfgC.animationDelay > 20.f) {
331-
mCfgC.animationDelay = 20.f;
327+
mCfgO.animationDelay += moveX;
328+
if (mCfgO.animationDelay < 0.05f) {
329+
mCfgO.animationDelay = 0.05f;
330+
} else if (mCfgO.animationDelay > 20.f) {
331+
mCfgO.animationDelay = 20.f;
332332
}
333333
moveX = 0.f;
334334
moveY = 0.f;
335-
SetInfo("Animation delay set to %1.2f", mCfgC.animationDelay);
335+
SetInfo("Animation delay set to %1.2f", mCfgO.animationDelay);
336336
}
337337

338338
if (yUp) {
@@ -641,15 +641,15 @@ void GPUDisplay::DrawGLScene_drawCommands()
641641

642642
void GPUDisplay::DrawGLScene_internal(bool suspended, float animateTime, bool renderToMixBuffer) // negative time = no mixing
643643
{
644-
if (mCfgC.requestScreenshot || mCfgC.animateScreenshot) {
644+
if (mCfgC.requestScreenshot || mCfgO.animateScreenshot) {
645645
const uint32_t factor = std::max(1, mCfgR.drawQualityDownsampleFSAA) * std::max(1, mCfgR.screenshotScaleFactor);
646646
if (std::max(mBackend->mScreenWidth, mBackend->mScreenHeight) * factor > mBackend->mMaxRenderSize) {
647647
GPUError("Screenshot not taken: requested render size %u x %u (window x FSAA x screenshot scale) exceeds the maximum size %u x %u", mBackend->mScreenWidth * factor, mBackend->mScreenHeight * factor, mBackend->mMaxRenderSize, mBackend->mMaxRenderSize);
648648
mCfgC.requestScreenshot = false;
649-
mCfgC.animateScreenshot = 0;
649+
mCfgO.animateScreenshot = 0;
650650
}
651651
}
652-
const bool animateScreenshot = mCfgC.animateScreenshot && mAnimate; // Copy, the animation resets animateScreenshot in its last frame
652+
const bool animateScreenshot = mCfgO.animateScreenshot && mAnimate; // Copy, the animation resets animateScreenshot in its last frame
653653
const bool screenshotFrame = mCfgC.requestScreenshot || animateScreenshot; // Also for the mix pass (animateTime >= 0), which must use the same render size
654654
const bool doScreenshot = screenshotFrame && animateTime < 0;
655655

@@ -724,7 +724,7 @@ void GPUDisplay::DrawGLScene_internal(bool suspended, float animateTime, bool re
724724
fps, mCfgL.drawSector, mCfgL.drawClusters, mCfgL.drawInitLinks, mCfgL.drawLinks, mCfgL.drawSeeds, mCfgL.drawTracklets, mCfgL.drawTracks, mCfgL.drawExtrapolatedTracks, mCfgL.drawFinal, mFramesDone, mNDrawCalls, mXYZ[0], mXYZ[1], mXYZ[2], mRPhiTheta[0], mRPhiTheta[1] * 180 / CAMath::Pi(),
725725
mRPhiTheta[2] * 180 / CAMath::Pi(), mAngle[1] * 180 / CAMath::Pi(), mAngle[0] * 180 / CAMath::Pi(), mAngle[2] * 180 / CAMath::Pi(), mBackend->mScreenWidth, mBackend->mScreenHeight);
726726
if (fpstime > 1.) {
727-
if (mCfgC.printInfoText & 2) {
727+
if (mCfgO.printInfoText & 2) {
728728
GPUInfo("%s", info);
729729
}
730730
if (mFPSScaleadjust++) {
@@ -735,12 +735,12 @@ void GPUDisplay::DrawGLScene_internal(bool suspended, float animateTime, bool re
735735
}
736736

737737
const float consoleFraction = consoleVerticalFraction();
738-
const bool drawText = (mCfgC.printInfoText & 1) || consoleFraction > 0.f;
738+
const bool drawText = (mCfgO.printInfoText & 1) || consoleFraction > 0.f;
739739
if (drawText) {
740740
mBackend->updateFontScale(mFrontend->getDisplayScale());
741741
mBackend->prepareText();
742742
}
743-
if (mCfgC.printInfoText & 1 || mCfgC.printInfoTextGUI) {
743+
if (mCfgO.printInfoText & 1 || mCfgO.printInfoTextGUI) {
744744
showInfo(info);
745745
}
746746
if (consoleFraction > 0.f) {
@@ -769,7 +769,7 @@ void GPUDisplay::DrawGLScene_internal(bool suspended, float animateTime, bool re
769769
if (animateScreenshot) {
770770
snprintf(tmpFileName, 48, "%d_%05d.bmp", mAnimationExport, mAnimationFrame);
771771
}
772-
DoScreenshot(animateScreenshot ? (mCfgC.mscreenShotName + tmpFileName).c_str() : mScreenshotFile.c_str(), pixels);
772+
DoScreenshot(animateScreenshot ? (mCfgO.mscreenShotName + tmpFileName).c_str() : mScreenshotFile.c_str(), pixels);
773773
}
774774
}
775775

‎GPU/GPUTracking/display/GPUDisplay.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class GPUDisplay : public GPUDisplayInterface
8989
GPUDisplayFrontend* frontend() { return mFrontend; }
9090
int32_t& drawTextFontSize() { return mDrawTextFontSize; }
9191

92+
GPUDisplayOptions mCfgO;
9293
GPUDisplayControl mCfgC;
9394

9495
private:
@@ -192,9 +193,9 @@ class GPUDisplay : public GPUDisplayInterface
192193
void calcXYZ(const float*);
193194
void mAnimationCloseAngle(float& newangle, float lastAngle);
194195
void mAnimateCloseQuaternion(float* v, float lastx, float lasty, float lastz, float lastw);
195-
void SaveGLPos(); // Camera position to mCfgC.glPosFile
196+
void SaveGLPos(); // Camera position to mCfgO.glPosFile
196197
void LoadGLPos();
197-
void SaveGLAnimation(); // Animation path to mCfgC.glAnimationFile
198+
void SaveGLAnimation(); // Animation path to mCfgO.glAnimationFile
198199
void LoadGLAnimation();
199200
void takeScreenshot();
200201
void runAnimation(); // Starts the animation if it has enough points
@@ -207,7 +208,6 @@ class GPUDisplay : public GPUDisplayInterface
207208
void resetAnimation();
208209
void removeAnimationPoint(int32_t i = -1); // -1: the selected one, the last one if none is selected
209210
void StopAnimation(); // Ends a running animation, camera and settings stay as they are; for changed settings (checkAndApplyConfigChanges), scene reset, changes of the animation points
210-
void setCameraFromAnimationPoint(const animationVector& p); // Camera stored in the point, as the animation shows it there
211211
void selectAnimationPoint(int32_t i); // -1: none, otherwise also loads its light settings and camera
212212
void setAnimationPointsFromGUI(const GPUDisplayMultiSliderValue& points); // New times from the Qt GUI: reorders the points, selection
213213
void updateAnimationPointsGUI(); // Range end of the GUI multi slider: last time + animationDelay, progress 0 without animation

‎GPU/GPUTracking/display/GPUDisplayControl.h‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@
2121

2222
// clang-format off
2323
BeginNamespace(o2::gpu)
24-
BeginHiddenConfig(GPUDisplayControl, control)
25-
AddVariable(displayControl, GPUDisplayCopyableAtomic<int32_t>, 0) // Control for next event (=1) or quit (=2)
26-
AddVariable(resetScene, GPUDisplayCopyableAtomic<bool>, false)
24+
BeginHiddenConfig(GPUDisplayOptions, options) // Display options without command line option, saved and reset with the other settings (console saveSettings / reset)
2725
AddVariable(printInfoText, int32_t, 1)
2826
AddVariable(printInfoTextAlways, bool, false)
29-
AddVariable(requestScreenshot, bool, false)
3027
AddVariable(animateScreenshot, int32_t, 0)
3128
AddVariable(animationChangeConfig, bool, true)
3229
AddVariable(animationDelay, float, 2.f)
@@ -35,14 +32,19 @@ BeginHiddenConfig(GPUDisplayControl, control)
3532
AddVariable(rotateModel, bool, false) // Rotate the model instead of the camera, like holding RCTRL (set in the Qt GUI)
3633
AddVariable(rotateAroundZ, bool, false) // Rotate the TPC around the beamline, like holding RALT (set in the Qt GUI)
3734
AddVariable(filterMacroCustom, std::string, "") // Code of the custom track filter ROOT macro (trackFilter = filterMacros.size() + 1), set in the Qt GUI
38-
AddVariable(mscreenShotName, std::string, "screenshot") // Name of screenshot and animation frame files, followed by numbers
35+
AddVariable(mscreenShotName, std::string, "screenshot") // Name of screenshot and animation frame files, followed by numbers
3936
AddVariable(glPosFile, std::string, "glpos.tmp") // File for saving / loading the camera position
4037
AddVariable(glAnimationFile, std::string, "glanimation.tmp") // File for saving / loading the animation path
4138
AddVariable(guiDarkMode, int8_t, -1) // Dark mode of the Qt GUI, -1 = not yet set: the GUI reports the system scheme when it starts
4239
AddVariable(guiScale, float, 1.f) // Scale factor of text and elements of the Qt GUI (on top of the system scaling), Ctrl + mouse wheel / Ctrl + 0 in the GUI
43-
AddVariable(showConsole, bool, false) // Console shown (^ key): all other keys go to the console
44-
AddVariable(applyToAllPoints, bool, false) // A change of the animation mode is applied to all animation points
40+
AddVariable(applyToAllPoints, bool, false) // A change of the animation mode is applied to all animation points
41+
EndConfig()
42+
43+
BeginHiddenConfig(GPUDisplayControl, control) // Transient control state and actions: not saved, not reset with the other settings
44+
AddVariable(displayControl, GPUDisplayCopyableAtomic<int32_t>, 0) // Control for next event (=1) or quit (=2)
45+
AddVariable(resetScene, GPUDisplayCopyableAtomic<bool>, false)
46+
AddVariable(requestScreenshot, bool, false)
47+
AddVariable(showConsole, bool, false) // Console shown (^ key): all other keys go to the console
4548
AddVariable(animationPoints, GPUDisplayMultiSliderValue, GPUDisplayMultiSliderValue()) // Times of the animation points (GPUDisplay::mAnimationVectors) and the selected one, shown in the Qt GUI
46-
AddVariable(dummy, bool, false) // dummy value to reference for keys that do not change variables
4749
EndConfig()
4850
EndNamespace() // o2::gpu

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,20 @@ void GPUDisplayFrontend::HandleExternalGUISignals()
135135
}
136136
applyGUIValues(*update);
137137
if (update->guiScale) {
138-
mDisplay->mCfgC.guiScale = *update->guiScale;
138+
mDisplay->mCfgO.guiScale = *update->guiScale;
139139
}
140140
if (update->guiDarkMode) {
141-
mDisplay->mCfgC.guiDarkMode = *update->guiDarkMode;
141+
mDisplay->mCfgO.guiDarkMode = *update->guiDarkMode;
142142
}
143143
}
144144

145145
if (gui) {
146-
GPUDisplayGUIChannel::Settings cfg{mDisplay->mCfgH, mDisplay->mCfgL, mDisplay->mCfgR, mDisplay->mCfgC};
146+
GPUDisplayGUIChannel::Settings cfg{mDisplay->mCfgH, mDisplay->mCfgL, mDisplay->mCfgR, mDisplay->mCfgO, mDisplay->mCfgC};
147147
{
148148
std::lock_guard lock(mGUIChannel->mutex);
149149
mGUIChannel->state.cfg = std::move(cfg);
150-
mGUIChannel->state.infoStatus = mDisplay->mCfgC.printInfoTextGUI ? mDisplay->mGUIInfoStatus : "";
151-
mGUIChannel->state.infoText = mDisplay->mCfgC.printInfoTextGUI ? mDisplay->mGUIInfoText : "";
150+
mGUIChannel->state.infoStatus = mDisplay->mCfgO.printInfoTextGUI ? mDisplay->mGUIInfoStatus : "";
151+
mGUIChannel->state.infoText = mDisplay->mCfgO.printInfoTextGUI ? mDisplay->mGUIInfoText : "";
152152
mGUIChannel->state.infoTextCounter = mDisplay->mGUIInfoTextCounter;
153153
if (mDisplay->mUpdateGUIOptions) {
154154
mGUIChannel->state.optionsRevision++;

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendConfig.cxx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct GPUDisplayFrontend::configRTTIExt : public qConfig::qConfigRTTIentry {
5656
using configKeyCallback = std::function<void()>;
5757

5858
struct GPUDisplayFrontend::GPUDisplayConfiguration {
59-
static constexpr std::tuple configStructs{&GPUDisplay::mCfgL, &GPUDisplay::mCfgH, &GPUDisplay::mCfgR, &GPUDisplay::mCfgC}; // Config structs with RTTI, as members of GPUDisplay
59+
static constexpr std::tuple configStructs{&GPUDisplay::mCfgL, &GPUDisplay::mCfgH, &GPUDisplay::mCfgR, &GPUDisplay::mCfgO, &GPUDisplay::mCfgC}; // Config structs with RTTI, as members of GPUDisplay
6060

6161
std::vector<configRTTIExt> rttiEntries; // qconfig RTTI of all options of configStructs (struct, name, type, offset, default, min / max, description, message), the index identifies an option
6262
std::vector<configKeyCallback> configInfos; // SetInfo callback for an option, indexed like rttiEntries, called after the callback of a key bound to it
@@ -240,7 +240,7 @@ void GPUDisplay::checkAndApplyConfigChanges()
240240
if (oldCfgH.trackFilter != mCfgH.trackFilter) {
241241
mUpdateTrackFilter = true;
242242
}
243-
mCfgC.rotateModel |= mCfgC.rotateAroundZ;
243+
mCfgO.rotateModel |= mCfgO.rotateAroundZ;
244244
if (mCfgC.showConsole != mConsoleShown) {
245245
mConsoleShown = mCfgC.showConsole;
246246
const double start = mConsoleTimer.IsRunning() ? std::max(0., mConfig.internal.consoleDelay - mConsoleTimer.GetCurrentElapsedTime()) : 0.; // Reverse a running animation from its current position
@@ -251,7 +251,7 @@ void GPUDisplay::checkAndApplyConfigChanges()
251251
std::fill(std::begin(mFrontend->mKeys), std::end(mFrontend->mKeys), false);
252252
}
253253
}
254-
if (mCfgC.applyToAllPoints && oldCfgL.animationMode != mCfgL.animationMode) { // Also for keys; the animation's own changes are in mOldCfg, so this is only user input
254+
if (mCfgO.applyToAllPoints && oldCfgL.animationMode != mCfgL.animationMode) { // Also for keys; the animation's own changes are in mOldCfg, so this is only user input
255255
for (auto& p : mAnimationVectors) {
256256
p.cfgL.animationMode = mCfgL.animationMode;
257257
}
@@ -454,7 +454,7 @@ void GPUDisplayFrontend::add_gui_binding(Args&&... args)
454454
using Type = GPUDisplayGUIChannel::ElementType;
455455
if (element.type.bitMask) { // The element sets / shows only these bits of the option
456456
element.set = [this, set = element.set, get = element.get, mask = element.type.bitMask](const GPUDisplayGUIValue& v) {
457-
const int64_t current = std::get<int64_t>(get({mDisplay->mCfgH, mDisplay->mCfgL, mDisplay->mCfgR, mDisplay->mCfgC}));
457+
const int64_t current = std::get<int64_t>(get({mDisplay->mCfgH, mDisplay->mCfgL, mDisplay->mCfgR, mDisplay->mCfgO, mDisplay->mCfgC}));
458458
set(std::get<int64_t>(v) ? (current | mask) : (current & ~mask));
459459
};
460460
element.get = [get = element.get, mask = element.type.bitMask](const GPUDisplayGUIChannel::Settings& cfg) -> GPUDisplayGUIValue { return (int64_t)((std::get<int64_t>(get(cfg)) & mask) != 0); };
@@ -521,7 +521,7 @@ void GPUDisplayFrontend::applyGUIValues(const GPUDisplayGUIUpdate& update)
521521
GPUError("Invalid value from the GUI for element %u: %s", id, ex.what());
522522
continue;
523523
}
524-
if (mDisplay->mCfgC.guiPrintInfo && e.rttiIndex < mConfiguration->configInfos.size()) {
524+
if (mDisplay->mCfgO.guiPrintInfo && e.rttiIndex < mConfiguration->configInfos.size()) {
525525
showConfigInfo(e.rttiIndex);
526526
}
527527
}

0 commit comments

Comments
 (0)