Skip to content

Commit cd89ebc

Browse files
committed
GPU Display: Stop using DebugGUI, just pull in the stuff directly, and hide HandMadeMath in GPUDisplay.h
1 parent bd42198 commit cd89ebc

7 files changed

Lines changed: 23 additions & 37 deletions

File tree

‎GPU/GPUTracking/display/GPUDisplay.cxx‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "frontend/GPUDisplayInfo.inc"
1717

1818
#include "GPUTPCDef.h"
19+
#include "HandMadeMath.h"
1920

2021
#include <vector>
2122
#include <memory>
@@ -60,6 +61,8 @@ const GPUSettingsProcessing& GPUDisplay::GetProcessingConfig(GPUChainTracking* c
6061

6162
GPUDisplay::GPUDisplay(GPUDisplayFrontend* frontend, GPUChainTracking* chain, GPUQA* qa, const GPUParam* param, const GPUCalibObjectsConst* calib, const GPUSettingsDisplay* config, const GPUSettingsProcessing* proc) : GPUDisplayInterface(), mFrontend(frontend), mChain(chain), mConfig(config ? *config : GetConfig(chain)), mProcessingSettings(proc ? *proc : GetProcessingConfig(chain)), mQA(qa)
6263
{
64+
mViewMatrix = std::make_unique<hmm_mat4>();
65+
mModelMatrix = std::make_unique<hmm_mat4>();
6366
mParam = param ? param : &mChain->GetParam();
6467
mCalib = calib;
6568
mCfgL = mConfig.light;
@@ -146,8 +149,8 @@ void GPUDisplay::ResizeScene(int32_t width, int32_t height, bool init)
146149

147150
if (init) {
148151
mResetScene = true;
149-
mViewMatrix = MY_HMM_IDENTITY;
150-
mModelMatrix = MY_HMM_IDENTITY;
152+
*mViewMatrix = MY_HMM_IDENTITY;
153+
*mModelMatrix = MY_HMM_IDENTITY;
151154
}
152155
}
153156

@@ -251,6 +254,7 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla
251254
if (mCfgL.drawSector != -1) {
252255
scalefactor *= 0.2f;
253256
}
257+
float* const mViewMatrixP = &mViewMatrix->Elements[0][0];
254258
float sqrdist = sqrtf(sqrtf(mViewMatrixP[12] * mViewMatrixP[12] + mViewMatrixP[13] * mViewMatrixP[13] + mViewMatrixP[14] * mViewMatrixP[14]) * GL_SCALE_FACTOR) * 0.8f;
255259
if (sqrdist < 0.2f) {
256260
sqrdist = 0.2f;
@@ -267,8 +271,8 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla
267271
} else if (mResetScene) {
268272
const float initialZpos = mCfgH.projectXY ? 16 : (mParam->par.continuousTracking ? (mMaxClusterZ * GL_SCALE_FACTOR + 8) : 8);
269273
nextViewMatrix = nextViewMatrix * HMM_Translate({{0, 0, -initialZpos}});
270-
mViewMatrix = MY_HMM_IDENTITY;
271-
mModelMatrix = MY_HMM_IDENTITY;
274+
*mViewMatrix = MY_HMM_IDENTITY;
275+
*mModelMatrix = MY_HMM_IDENTITY;
272276

273277
mCfgL.pointSize = 2.0f;
274278
mCfgL.lineWidth = 1.4f;
@@ -367,23 +371,23 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla
367371
nextViewMatrix = nextViewMatrix * HMM_Rotate(rotRoll * mYFactor, {{0, 0, 1}});
368372
}
369373
}
370-
nextViewMatrix = nextViewMatrix * mViewMatrix; // Apply previous translation / rotation
374+
nextViewMatrix = nextViewMatrix * *mViewMatrix; // Apply previous translation / rotation
371375
if (yUp) {
372376
calcXYZ(&nextViewMatrix.Elements[0][0]);
373377
nextViewMatrix = HMM_Rotate(mAngle[2] * 180.f / CAMath::Pi(), {{0, 0, 1}}) * nextViewMatrix;
374378
}
375379
if (rotateModel) {
376380
if (rotYaw != 0.f) {
377-
mModelMatrix = HMM_Rotate(rotYaw, {{nextViewMatrix.Elements[0][1], nextViewMatrix.Elements[1][1], nextViewMatrix.Elements[2][1]}}) * mModelMatrix;
381+
*mModelMatrix = HMM_Rotate(rotYaw, {{nextViewMatrix.Elements[0][1], nextViewMatrix.Elements[1][1], nextViewMatrix.Elements[2][1]}}) * *mModelMatrix;
378382
}
379383
if (rotPitch != 0.f) {
380-
mModelMatrix = HMM_Rotate(rotPitch, {{nextViewMatrix.Elements[0][0], nextViewMatrix.Elements[1][0], nextViewMatrix.Elements[2][0]}}) * mModelMatrix;
384+
*mModelMatrix = HMM_Rotate(rotPitch, {{nextViewMatrix.Elements[0][0], nextViewMatrix.Elements[1][0], nextViewMatrix.Elements[2][0]}}) * *mModelMatrix;
381385
}
382386
if (rotRoll != 0.f) {
383387
if (rotateModelTPC) {
384-
mModelMatrix = HMM_Rotate(-rotRoll, {{0, 0, 1}}) * mModelMatrix;
388+
*mModelMatrix = HMM_Rotate(-rotRoll, {{0, 0, 1}}) * *mModelMatrix;
385389
} else {
386-
mModelMatrix = HMM_Rotate(-rotRoll, {{nextViewMatrix.Elements[0][2], nextViewMatrix.Elements[1][2], nextViewMatrix.Elements[2][2]}}) * mModelMatrix;
390+
*mModelMatrix = HMM_Rotate(-rotRoll, {{nextViewMatrix.Elements[0][2], nextViewMatrix.Elements[1][2], nextViewMatrix.Elements[2][2]}}) * *mModelMatrix;
387391
}
388392
}
389393
}
@@ -414,8 +418,8 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla
414418

415419
// Store position
416420
if (animateTime < 0) {
417-
mViewMatrix = nextViewMatrix;
418-
calcXYZ(mViewMatrixP);
421+
*mViewMatrix = nextViewMatrix;
422+
calcXYZ(&mViewMatrix->Elements[0][0]);
419423
}
420424

421425
if (mFrontend->mMouseDn || mFrontend->mMouseDnR) {
@@ -659,7 +663,7 @@ void GPUDisplay::DrawGLScene_internal(float animateTime, bool renderToMixBuffer)
659663
}
660664

661665
// Draw Event
662-
nextViewMatrix = nextViewMatrix * mModelMatrix;
666+
nextViewMatrix = nextViewMatrix * *mModelMatrix;
663667
const float zFar = ((mParam->par.continuousTracking ? (mMaxClusterZ * GL_SCALE_FACTOR) : 8.f) + 50.f) * 2.f;
664668
const hmm_mat4 proj = HMM_Perspective(mCfgR.fov, (float)mBackend->mRenderWidth / (float)mBackend->mRenderHeight, 0.1f, zFar);
665669
mBackend->prepareDraw(proj, nextViewMatrix, doScreenshot || mRequestScreenshot, renderToMixBuffer, mixSlaveImage);

‎GPU/GPUTracking/display/GPUDisplay.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <mutex>
2626
#include <condition_variable>
2727

28-
#include "HandMadeMath.h"
28+
union hmm_mat4; // From HandMadeMath
2929

3030
#include "utils/timer.h"
3131
#include "utils/vecpod.h"
@@ -248,8 +248,7 @@ class GPUDisplay : public GPUDisplayInterface
248248
float mAngleRollOrigin = -1e9;
249249
float mMaxClusterZ = -1;
250250

251-
hmm_mat4 mViewMatrix, mModelMatrix;
252-
float* const mViewMatrixP = &mViewMatrix.Elements[0][0];
251+
std::unique_ptr<hmm_mat4> mViewMatrix, mModelMatrix;
253252
float mXYZ[3];
254253
float mAngle[3];
255254
float mRPhiTheta[3];

‎GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.cxx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#else
2323
#define gluErrorString(err) ""
2424
#endif
25+
#include "HandMadeMath.h"
2526

2627
#include "GPUCommonDef.h"
2728
#include "GPUDisplayBackendOpenGL.h"

‎GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.cxx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
1616
#include <vulkan/vulkan.hpp>
1717
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
18+
#include "HandMadeMath.h"
1819

1920
#include "GPUCommonDef.h"
2021
#include "GPUDisplayBackendVulkan.h"

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
#include <cstring>
2727
#include <unistd.h>
2828

29-
#ifndef GPUCA_STANDALONE
30-
#include <DebugGUI/imgui.h>
31-
#include <DebugGUI/DebugGUI.h>
32-
#endif
33-
3429
using namespace o2::gpu;
3530

3631
GPUDisplayFrontendGlfw::GPUDisplayFrontendGlfw()
@@ -263,18 +258,6 @@ void GPUDisplayFrontendGlfw::maximize_callback(GLFWwindow* window, int32_t maxim
263258
}
264259
}
265260

266-
#ifndef GPUCA_STANDALONE
267-
void GPUDisplayFrontendGlfw::DisplayLoop()
268-
{
269-
ImGui::SetNextWindowPos(ImVec2(0, 0));
270-
ImGui::SetNextWindowSize(ImVec2(me->mDisplayWidth, me->mDisplayHeight));
271-
ImGui::SetNextWindowBgAlpha(0.f);
272-
ImGui::Begin("Console", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
273-
me->DrawGLScene();
274-
ImGui::End();
275-
}
276-
#endif
277-
278261
int32_t GPUDisplayFrontendGlfw::FrontendMain()
279262
{
280263
me = this;
@@ -410,11 +393,7 @@ void GPUDisplayFrontendGlfw::SetVSync(bool enable) { glfwSwapInterval(enable); }
410393

411394
bool GPUDisplayFrontendGlfw::EnableSendKey()
412395
{
413-
#ifdef GPUCA_STANDALONE
414396
return true;
415-
#else
416-
return false;
417-
#endif
418397
}
419398

420399
void GPUDisplayFrontendGlfw::getSize(int32_t& width, int32_t& height)

‎GPU/GPUTracking/display/helpers/GPUDisplayAnimation.cxx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "GPUDisplay.h"
1616
#include "frontend/GPUDisplayInfo.inc"
1717
#include "GPUCommonMath.h"
18+
#include "HandMadeMath.h"
1819

1920
using namespace o2::gpu;
2021

@@ -56,7 +57,7 @@ void GPUDisplay::setAnimationPoint()
5657
mAnimateVectors[8].emplace_back(0);
5758
} else { // Quaternions
5859
float v[4];
59-
createQuaternionFromMatrix(v, mViewMatrixP);
60+
createQuaternionFromMatrix(v, &mViewMatrix->Elements[0][0]);
6061
if (mAnimateVectors[0].size()) {
6162
mAnimateCloseQuaternion(v, mAnimateVectors[5].back(), mAnimateVectors[6].back(), mAnimateVectors[7].back(), mAnimateVectors[8].back());
6263
}

‎GPU/GPUTracking/display/helpers/GPUDisplayBackendOpenGLMagneticField.cxx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#else
2323
#define gluErrorString(err) ""
2424
#endif
25+
#include "HandMadeMath.h"
2526

2627
#include "GPUCommonDef.h"
2728
#include "GPUDisplayMagneticField.h"

0 commit comments

Comments
 (0)