From 358535a7084eac9540af8ec1e41c8dd5ee25fed4 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Thu, 10 Oct 2024 14:42:34 +0200 Subject: [PATCH] merge conflict --- .../display/3rdparty/KHR/khrplatform.h | 24 +- GPU/GPUTracking/display/GPUDisplay.cxx | 44 ++-- GPU/GPUTracking/display/GPUDisplay.h | 148 +++++------ GPU/GPUTracking/display/GPUDisplayInterface.h | 16 +- .../display/backend/GPUDisplayBackend.cxx | 18 +- .../display/backend/GPUDisplayBackend.h | 48 ++-- .../backend/GPUDisplayBackendOpenGL.cxx | 90 +++---- .../display/backend/GPUDisplayBackendOpenGL.h | 100 ++++---- .../backend/GPUDisplayBackendVulkan.cxx | 134 +++++----- .../display/backend/GPUDisplayBackendVulkan.h | 38 +-- .../display/filterMacros/TRDCandidate.C | 2 +- .../display/filterMacros/filterGPUTrack.C | 2 +- .../display/filterMacros/filterTPCTrack.C | 2 +- GPU/GPUTracking/display/filterMacros/hasTRD.C | 2 +- .../display/frontend/GPUDisplayFrontend.cxx | 24 +- .../display/frontend/GPUDisplayFrontend.h | 114 ++++----- .../frontend/GPUDisplayFrontendGlfw.cxx | 58 +++-- .../display/frontend/GPUDisplayFrontendGlfw.h | 36 +-- .../frontend/GPUDisplayFrontendGlut.cxx | 40 +-- .../display/frontend/GPUDisplayFrontendGlut.h | 28 +- .../display/frontend/GPUDisplayFrontendNone.h | 2 +- .../frontend/GPUDisplayFrontendWayland.cxx | 38 +-- .../frontend/GPUDisplayFrontendWayland.h | 22 +- .../frontend/GPUDisplayFrontendWindows.cxx | 20 +- .../frontend/GPUDisplayFrontendWindows.h | 4 +- .../frontend/GPUDisplayFrontendX11.cxx | 58 ++--- .../display/frontend/GPUDisplayFrontendX11.h | 14 +- .../display/frontend/GPUDisplayGUIWrapper.cxx | 8 +- .../display/frontend/GPUDisplayGUIWrapper.h | 6 +- .../display/frontend/GPUDisplayKeys.cxx | 59 ++--- .../display/helpers/GPUDisplayAnimation.cxx | 26 +- .../GPUDisplayBackendOpenGLMagneticField.cxx | 26 +- .../display/helpers/GPUDisplayColors.inc | 8 +- .../display/helpers/GPUDisplayHelpers.cxx | 2 +- .../helpers/GPUDisplayInterpolation.cxx | 20 +- .../helpers/GPUDisplayMagneticField.cxx | 20 +- .../display/helpers/GPUDisplayMagneticField.h | 32 +-- .../display/helpers/GPUDisplayROOT.cxx | 4 +- GPU/GPUTracking/display/helpers/bitmapfile.h | 30 +-- .../helpers/field-uniform-exporter.cxx | 18 +- .../display/render/GPUDisplayDraw.cxx | 239 +++++++++--------- .../display/render/GPUDisplayImportEvent.cxx | 48 ++-- .../display/shaders/GPUDisplayShaders.h | 156 ++++++------ 43 files changed, 911 insertions(+), 917 deletions(-) diff --git a/GPU/GPUTracking/display/3rdparty/KHR/khrplatform.h b/GPU/GPUTracking/display/3rdparty/KHR/khrplatform.h index b6648a9a3d2b9..9fb630df9b8ad 100644 --- a/GPU/GPUTracking/display/3rdparty/KHR/khrplatform.h +++ b/GPU/GPUTracking/display/3rdparty/KHR/khrplatform.h @@ -186,11 +186,11 @@ typedef unsigned __int64 khronos_uint64_t; typedef int khronos_int32_t; typedef unsigned int khronos_uint32_t; #if defined(__arch64__) || defined(_LP64) -typedef long int khronos_int64_t; -typedef unsigned long int khronos_uint64_t; +typedef long khronos_int64_t; +typedef unsigned long khronos_uint64_t; #else -typedef long long int khronos_int64_t; -typedef unsigned long long int khronos_uint64_t; +typedef long khronos_int64_t; +typedef unsigned long khronos_uint64_t; #endif /* __arch64__ */ #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 @@ -234,15 +234,15 @@ typedef unsigned short int khronos_uint16_t; * to be the only LLP64 architecture in current use. */ #ifdef _WIN64 -typedef signed long long int khronos_intptr_t; -typedef unsigned long long int khronos_uintptr_t; -typedef signed long long int khronos_ssize_t; -typedef unsigned long long int khronos_usize_t; +typedef signed long khronos_intptr_t; +typedef unsigned long khronos_uintptr_t; +typedef signed long khronos_ssize_t; +typedef unsigned long khronos_usize_t; #else -typedef signed long int khronos_intptr_t; -typedef unsigned long int khronos_uintptr_t; -typedef signed long int khronos_ssize_t; -typedef unsigned long int khronos_usize_t; +typedef signed long khronos_intptr_t; +typedef unsigned long khronos_uintptr_t; +typedef signed long khronos_ssize_t; +typedef unsigned long khronos_usize_t; #endif #if KHRONOS_SUPPORT_FLOAT diff --git a/GPU/GPUTracking/display/GPUDisplay.cxx b/GPU/GPUTracking/display/GPUDisplay.cxx index 59d6d978c3eaf..74d89fbf6de81 100644 --- a/GPU/GPUTracking/display/GPUDisplay.cxx +++ b/GPU/GPUTracking/display/GPUDisplay.cxx @@ -109,9 +109,9 @@ void GPUDisplay::calcXYZ(const float* matrix) }*/ } -void GPUDisplay::SetCollisionFirstCluster(unsigned int collision, int slice, int cluster) +void GPUDisplay::SetCollisionFirstCluster(uint32_t collision, int32_t slice, int32_t cluster) { - mNCollissions = std::max(mNCollissions, collision + 1); + mNCollissions = std::max(mNCollissions, collision + 1); mOverlayTFClusters.resize(mNCollissions); mOverlayTFClusters[collision][slice] = cluster; } @@ -128,13 +128,13 @@ void GPUDisplay::mAnimateCloseQuaternion(float* v, float lastx, float lasty, flo float distPos2 = (lastx - v[0]) * (lastx - v[0]) + (lasty - v[1]) * (lasty - v[1]) + (lastz - v[2]) * (lastz - v[2]) + (lastw - v[3]) * (lastw - v[3]); float distNeg2 = (lastx + v[0]) * (lastx + v[0]) + (lasty + v[1]) * (lasty + v[1]) + (lastz + v[2]) * (lastz + v[2]) + (lastw + v[3]) * (lastw + v[3]); if (distPos2 > distNeg2) { - for (int i = 0; i < 4; i++) { + for (int32_t i = 0; i < 4; i++) { v[i] = -v[i]; } } } -void GPUDisplay::ResizeScene(int width, int height, bool init) +void GPUDisplay::ResizeScene(int32_t width, int32_t height, bool init) { if (height == 0) { // Prevent A Divide By Zero By height = 1; // Making Height Equal One @@ -160,9 +160,9 @@ inline void GPUDisplay::drawVertices(const vboList& v, const GPUDisplayBackend:: mNDrawCalls += mBackend->drawVertices(v, t); } -int GPUDisplay::InitDisplay(bool initFailure) +int32_t GPUDisplay::InitDisplay(bool initFailure) { - int retVal = initFailure; + int32_t retVal = initFailure; try { if (!initFailure) { retVal = InitDisplay_internal(); @@ -175,7 +175,7 @@ int GPUDisplay::InitDisplay(bool initFailure) return (retVal); } -int GPUDisplay::InitDisplay_internal() +int32_t GPUDisplay::InitDisplay_internal() { mThreadBuffers.resize(getNumThreads()); mThreadTracks.resize(getNumThreads()); @@ -184,7 +184,7 @@ int GPUDisplay::InitDisplay_internal() } mYFactor = mBackend->getYFactor(); mDrawTextInCompatMode = !mBackend->mFreetypeInitialized && mFrontend->mCanDrawText == 1; - int height = 0, width = 0; + int32_t height = 0, width = 0; mFrontend->getSize(width, height); if (height == 0 || width == 0) { width = GPUDisplayFrontend::INIT_WIDTH; @@ -199,12 +199,12 @@ void GPUDisplay::ExitDisplay() mBackend->ExitBackend(); } -int GPUDisplay::DrawGLScene() +int32_t GPUDisplay::DrawGLScene() { // Make sure event gets not overwritten during display mSemLockDisplay.Lock(); - int retVal = 0; + int32_t retVal = 0; if (mChain) { mIOPtrs = &mChain->mIOPtrs; mCalib = &mChain->calib(); @@ -227,7 +227,7 @@ int GPUDisplay::DrawGLScene() void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSlaveImage, hmm_mat4& nextViewMatrix) { - int mMouseWheelTmp = mFrontend->mMouseWheel; + int32_t mMouseWheelTmp = mFrontend->mMouseWheel; mFrontend->mMouseWheel = 0; bool lookOrigin = mCfgR.camLookOrigin ^ mFrontend->mKeys[mFrontend->KEY_ALT]; bool yUp = mCfgR.camYUp ^ mFrontend->mKeys[mFrontend->KEY_CTRL] ^ lookOrigin; @@ -270,10 +270,10 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla mResetScene = 0; } else { - float moveZ = scalefactor * ((float)mMouseWheelTmp / 150 + (float)(mFrontend->mKeys[(unsigned char)'W'] - mFrontend->mKeys[(unsigned char)'S']) * (!mFrontend->mKeys[mFrontend->KEY_SHIFT]) * 0.2f * mFPSScale); + float moveZ = scalefactor * ((float)mMouseWheelTmp / 150 + (float)(mFrontend->mKeys[(uint8_t)'W'] - mFrontend->mKeys[(uint8_t)'S']) * (!mFrontend->mKeys[mFrontend->KEY_SHIFT]) * 0.2f * mFPSScale); float moveY = scalefactor * ((float)(mFrontend->mKeys[mFrontend->KEY_PAGEDOWN] - mFrontend->mKeys[mFrontend->KEY_PAGEUP]) * 0.2f * mFPSScale); - float moveX = scalefactor * ((float)(mFrontend->mKeys[(unsigned char)'A'] - mFrontend->mKeys[(unsigned char)'D']) * (!mFrontend->mKeys[mFrontend->KEY_SHIFT]) * 0.2f * mFPSScale); - float rotRoll = rotatescalefactor * mFPSScale * 2 * (mFrontend->mKeys[(unsigned char)'E'] - mFrontend->mKeys[(unsigned char)'F']) * (!mFrontend->mKeys[mFrontend->KEY_SHIFT]); + float moveX = scalefactor * ((float)(mFrontend->mKeys[(uint8_t)'A'] - mFrontend->mKeys[(uint8_t)'D']) * (!mFrontend->mKeys[mFrontend->KEY_SHIFT]) * 0.2f * mFPSScale); + float rotRoll = rotatescalefactor * mFPSScale * 2 * (mFrontend->mKeys[(uint8_t)'E'] - mFrontend->mKeys[(uint8_t)'F']) * (!mFrontend->mKeys[mFrontend->KEY_SHIFT]); float rotYaw = rotatescalefactor * mFPSScale * 2 * (mFrontend->mKeys[mFrontend->KEY_RIGHT] - mFrontend->mKeys[mFrontend->KEY_LEFT]); float rotPitch = rotatescalefactor * mFPSScale * 2 * (mFrontend->mKeys[mFrontend->KEY_DOWN] - mFrontend->mKeys[mFrontend->KEY_UP]); @@ -289,7 +289,7 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla rotPitch += rotatescalefactor * mouseScale * ((float)mFrontend->mMouseMvY - (float)mFrontend->mMouseDnY); } - if (mFrontend->mKeys[(unsigned char)'<'] && !mFrontend->mKeysShift[(unsigned char)'<']) { + if (mFrontend->mKeys[(uint8_t)'<'] && !mFrontend->mKeysShift[(uint8_t)'<']) { mAnimationDelay += moveX; if (mAnimationDelay < 0.05f) { mAnimationDelay = 0.05f; @@ -379,7 +379,7 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla // Graphichs Options float minSize = 0.4f / (mCfgR.drawQualityDownsampleFSAA > 1 ? mCfgR.drawQualityDownsampleFSAA : 1); - int deltaLine = mFrontend->mKeys[(unsigned char)'+'] * mFrontend->mKeysShift[(unsigned char)'+'] - mFrontend->mKeys[(unsigned char)'-'] * mFrontend->mKeysShift[(unsigned char)'-']; + int32_t deltaLine = mFrontend->mKeys[(uint8_t)'+'] * mFrontend->mKeysShift[(uint8_t)'+'] - mFrontend->mKeys[(uint8_t)'-'] * mFrontend->mKeysShift[(uint8_t)'-']; mCfgL.lineWidth += (float)deltaLine * mFPSScale * 0.02f * mCfgL.lineWidth; if (mCfgL.lineWidth < minSize) { mCfgL.lineWidth = minSize; @@ -389,7 +389,7 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla mUpdateDrawCommands = 1; } minSize *= 2; - int deltaPoint = mFrontend->mKeys[(unsigned char)'+'] * (!mFrontend->mKeysShift[(unsigned char)'+']) - mFrontend->mKeys[(unsigned char)'-'] * (!mFrontend->mKeysShift[(unsigned char)'-']); + int32_t deltaPoint = mFrontend->mKeys[(uint8_t)'+'] * (!mFrontend->mKeysShift[(uint8_t)'+']) - mFrontend->mKeys[(uint8_t)'-'] * (!mFrontend->mKeysShift[(uint8_t)'-']); mCfgL.pointSize += (float)deltaPoint * mFPSScale * 0.02f * mCfgL.pointSize; if (mCfgL.pointSize < minSize) { mCfgL.pointSize = minSize; @@ -414,9 +414,9 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla void GPUDisplay::DrawGLScene_drawCommands() { -#define LOOP_SLICE for (int iSlice = (mCfgL.drawSlice == -1 ? 0 : mCfgL.drawRelatedSlices ? (mCfgL.drawSlice % (NSLICES / 4)) : mCfgL.drawSlice); iSlice < NSLICES; iSlice += (mCfgL.drawSlice == -1 ? 1 : mCfgL.drawRelatedSlices ? (NSLICES / 4) : NSLICES)) -#define LOOP_SLICE2 for (int iSlice = (mCfgL.drawSlice == -1 ? 0 : mCfgL.drawRelatedSlices ? (mCfgL.drawSlice % (NSLICES / 4)) : mCfgL.drawSlice) % (NSLICES / 2); iSlice < NSLICES / 2; iSlice += (mCfgL.drawSlice == -1 ? 1 : mCfgL.drawRelatedSlices ? (NSLICES / 4) : NSLICES)) -#define LOOP_COLLISION for (int iCol = (mCfgL.showCollision == -1 ? 0 : mCfgL.showCollision); iCol < mNCollissions; iCol += (mCfgL.showCollision == -1 ? 1 : mNCollissions)) +#define LOOP_SLICE for (int32_t iSlice = (mCfgL.drawSlice == -1 ? 0 : mCfgL.drawRelatedSlices ? (mCfgL.drawSlice % (NSLICES / 4)) : mCfgL.drawSlice); iSlice < NSLICES; iSlice += (mCfgL.drawSlice == -1 ? 1 : mCfgL.drawRelatedSlices ? (NSLICES / 4) : NSLICES)) +#define LOOP_SLICE2 for (int32_t iSlice = (mCfgL.drawSlice == -1 ? 0 : mCfgL.drawRelatedSlices ? (mCfgL.drawSlice % (NSLICES / 4)) : mCfgL.drawSlice) % (NSLICES / 2); iSlice < NSLICES / 2; iSlice += (mCfgL.drawSlice == -1 ? 1 : mCfgL.drawRelatedSlices ? (NSLICES / 4) : NSLICES)) +#define LOOP_COLLISION for (int32_t iCol = (mCfgL.showCollision == -1 ? 0 : mCfgL.showCollision); iCol < mNCollissions; iCol += (mCfgL.showCollision == -1 ? 1 : mNCollissions)) #define LOOP_COLLISION_COL(cmd) \ LOOP_COLLISION \ { \ @@ -636,7 +636,7 @@ void GPUDisplay::DrawGLScene_internal(float animateTime, bool renderToMixBuffer) if (mUpdateVertexLists && mIOPtrs) { size_t totalVertizes = DrawGLScene_updateVertexList(); if (showTimer) { - printf("Event visualization time: %'d us (vertices %'lld / %'lld bytes)\n", (int)(mTimerDraw.GetCurrentElapsedTime() * 1000000.), (long long int)totalVertizes, (long long int)(totalVertizes * sizeof(mVertexBuffer[0][0]))); + printf("Event visualization time: %'d us (vertices %'ld / %'ld bytes)\n", (int32_t)(mTimerDraw.GetCurrentElapsedTime() * 1000000.), (int64_t)totalVertizes, (int64_t)(totalVertizes * sizeof(mVertexBuffer[0][0]))); } } @@ -714,7 +714,7 @@ void GPUDisplay::ShowNextEvent(const GPUTrackingInOutPointers* ptrs) void GPUDisplay::WaitForNextEvent() { mSemLockDisplay.Lock(); } -int GPUDisplay::StartDisplay() +int32_t GPUDisplay::StartDisplay() { if (mFrontend->StartDisplay()) { return (1); diff --git a/GPU/GPUTracking/display/GPUDisplay.h b/GPU/GPUTracking/display/GPUDisplay.h index 78638bfaca4a6..38dacae60c51a 100644 --- a/GPU/GPUTracking/display/GPUDisplay.h +++ b/GPU/GPUTracking/display/GPUDisplay.h @@ -44,30 +44,30 @@ class GPUDisplay : public GPUDisplayInterface GPUDisplay(const GPUDisplay&) = delete; ~GPUDisplay() override = default; - int StartDisplay() override; + int32_t StartDisplay() override; void ShowNextEvent(const GPUTrackingInOutPointers* ptrs = nullptr) override; void WaitForNextEvent() override; - void SetCollisionFirstCluster(unsigned int collision, int slice, int cluster) override; + void SetCollisionFirstCluster(uint32_t collision, int32_t slice, int32_t cluster) override; void UpdateCalib(const GPUCalibObjectsConst* calib) override { mCalib = calib; } void UpdateParam(const GPUParam* param) override { mParam = param; } - void HandleKey(unsigned char key); - int DrawGLScene(); - void HandleSendKey(int key); - int InitDisplay(bool initFailure = false); + void HandleKey(uint8_t key); + int32_t DrawGLScene(); + void HandleSendKey(int32_t key); + int32_t InitDisplay(bool initFailure = false); void ExitDisplay(); - void ResizeScene(int width, int height, bool init = false); + void ResizeScene(int32_t width, int32_t height, bool init = false); const GPUSettingsDisplayRenderer& cfgR() const { return mCfgR; } const GPUSettingsDisplayLight& cfgL() const { return mCfgL; } const GPUSettingsDisplayHeavy& cfgH() const { return mCfgH; } const GPUSettingsDisplay& cfg() const { return mConfig; } bool useMultiVBO() const { return mUseMultiVBO; } - int updateDrawCommands() const { return mUpdateDrawCommands; } - int updateRenderPipeline() const { return mUpdateRenderPipeline; } + int32_t updateDrawCommands() const { return mUpdateDrawCommands; } + int32_t updateRenderPipeline() const { return mUpdateRenderPipeline; } GPUDisplayBackend* backend() const { return mBackend.get(); } - vecpod* vertexBufferStart() { return mVertexBufferStart; } - const vecpod* vertexBufferCount() const { return mVertexBufferCount; } + vecpod* vertexBufferStart() { return mVertexBufferStart; } + const vecpod* vertexBufferCount() const { return mVertexBufferCount; } struct vtx { float x, y, z; vtx(float a, float b, float c) : x(a), y(b), z(c) {} @@ -76,20 +76,20 @@ class GPUDisplay : public GPUDisplayInterface const GPUParam* param() { return mParam; } GPUDisplayFrontend* frontend() { return mFrontend; } bool drawTextInCompatMode() const { return mDrawTextInCompatMode; } - int& drawTextFontSize() { return mDrawTextFontSize; } + int32_t& drawTextFontSize() { return mDrawTextFontSize; } private: - static constexpr int NSLICES = GPUChainTracking::NSLICES; + static constexpr int32_t NSLICES = GPUChainTracking::NSLICES; static constexpr float GL_SCALE_FACTOR = (1.f / 100.f); - static constexpr const int N_POINTS_TYPE = 15; - static constexpr const int N_POINTS_TYPE_TPC = 9; - static constexpr const int N_POINTS_TYPE_TRD = 2; - static constexpr const int N_POINTS_TYPE_TOF = 2; - static constexpr const int N_POINTS_TYPE_ITS = 2; - static constexpr const int N_LINES_TYPE = 7; - static constexpr const int N_FINAL_TYPE = 4; - static constexpr int TRACK_TYPE_ID_LIMIT = 100; + static constexpr const int32_t N_POINTS_TYPE = 15; + static constexpr const int32_t N_POINTS_TYPE_TPC = 9; + static constexpr const int32_t N_POINTS_TYPE_TRD = 2; + static constexpr const int32_t N_POINTS_TYPE_TOF = 2; + static constexpr const int32_t N_POINTS_TYPE_ITS = 2; + static constexpr const int32_t N_LINES_TYPE = 7; + static constexpr const int32_t N_FINAL_TYPE = 4; + static constexpr int32_t TRACK_TYPE_ID_LIMIT = 100; enum PointTypes { tCLUSTER = 0, tINITLINK = 1, tLINK = 2, @@ -111,19 +111,19 @@ class GPUDisplay : public GPUDisplayInterface struct threadVertexBuffer { vecpod buffer; - vecpod start[N_FINAL_TYPE]; - vecpod count[N_FINAL_TYPE]; - std::pair*, vecpod*> vBuf[N_FINAL_TYPE]; + vecpod start[N_FINAL_TYPE]; + vecpod count[N_FINAL_TYPE]; + std::pair*, vecpod*> vBuf[N_FINAL_TYPE]; threadVertexBuffer() : buffer() { - for (int i = 0; i < N_FINAL_TYPE; i++) { + for (int32_t i = 0; i < N_FINAL_TYPE; i++) { vBuf[i].first = start + i; vBuf[i].second = count + i; } } void clear() { - for (int i = 0; i < N_FINAL_TYPE; i++) { + for (int32_t i = 0; i < N_FINAL_TYPE; i++) { start[i].clear(); count[i].clear(); } @@ -148,15 +148,15 @@ class GPUDisplay : public GPUDisplayInterface void DrawGLScene_cameraAndAnimation(float animateTime, float& mixSlaveImage, hmm_mat4& nextViewMatrix); size_t DrawGLScene_updateVertexList(); void DrawGLScene_drawCommands(); - int InitDisplay_internal(); - int getNumThreads(); + int32_t InitDisplay_internal(); + int32_t getNumThreads(); void disableUnsupportedOptions(); - int buildTrackFilter(); - const GPUTPCTracker& sliceTracker(int iSlice); + int32_t buildTrackFilter(); + const GPUTPCTracker& sliceTracker(int32_t iSlice); const GPUTRDGeometry* trdGeometry(); const GPUTrackingInOutPointers* mIOPtrs = nullptr; - void insertVertexList(std::pair*, vecpod*>& vBuf, size_t first, size_t last); - void insertVertexList(int iSlice, size_t first, size_t last); + void insertVertexList(std::pair*, vecpod*>& vBuf, size_t first, size_t last); + void insertVertexList(int32_t iSlice, size_t first, size_t last); template void SetInfo(Args... args) { @@ -175,7 +175,7 @@ class GPUDisplay : public GPUDisplayInterface void resetAnimation(); void removeAnimationPoint(); void startAnimation(); - int animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4& nextViewMatrix); + int32_t animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4& nextViewMatrix); void showInfo(const char* info); void ActivateColor(); void SetColorTRD(); @@ -192,23 +192,23 @@ class GPUDisplay : public GPUDisplayInterface void SetColorGrid(); void SetColorGridTRD(); void SetColorMarked(); - void SetCollisionColor(int col); + void SetCollisionColor(int32_t col); void updateConfig(); - void drawPointLinestrip(int iSlice, int cid, int id, int id_limit = TRACK_TYPE_ID_LIMIT); - vboList DrawClusters(int iSlice, int select, unsigned int iCol); - vboList DrawSpacePointsTRD(int iSlice, int select, int iCol); - vboList DrawSpacePointsTOF(int iSlice, int select, int iCol); - vboList DrawSpacePointsITS(int iSlice, int select, int iCol); - vboList DrawLinks(const GPUTPCTracker& tracker, int id, bool dodown = false); + void drawPointLinestrip(int32_t iSlice, int32_t cid, int32_t id, int32_t id_limit = TRACK_TYPE_ID_LIMIT); + vboList DrawClusters(int32_t iSlice, int32_t select, uint32_t iCol); + vboList DrawSpacePointsTRD(int32_t iSlice, int32_t select, int32_t iCol); + vboList DrawSpacePointsTOF(int32_t iSlice, int32_t select, int32_t iCol); + vboList DrawSpacePointsITS(int32_t iSlice, int32_t select, int32_t iCol); + vboList DrawLinks(const GPUTPCTracker& tracker, int32_t id, bool dodown = false); vboList DrawSeeds(const GPUTPCTracker& tracker); vboList DrawTracklets(const GPUTPCTracker& tracker); - vboList DrawTracks(const GPUTPCTracker& tracker, int global); - void DrawTrackITS(int trackId, int iSlice); + vboList DrawTracks(const GPUTPCTracker& tracker, int32_t global); + void DrawTrackITS(int32_t trackId, int32_t iSlice); GPUDisplay::vboList DrawFinalITS(); template - void DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, std::array, 2>& trackList, threadVertexBuffer& threadBuffer); + void DrawFinal(int32_t iSlice, int32_t /*iCol*/, GPUTPCGMPropagator* prop, std::array, 2>& trackList, threadVertexBuffer& threadBuffer); vboList DrawGrid(const GPUTPCTracker& tracker); - vboList DrawGridTRD(int sector); + vboList DrawGridTRD(int32_t sector); void DoScreenshot(const char* filename, std::vector& pixels, float animateTime = -1.f); void PrintHelp(); void createQuaternionFromMatrix(float* v, const float* mat); @@ -228,15 +228,15 @@ class GPUDisplay : public GPUDisplayInterface qSem mSemLockDisplay; bool mDrawTextInCompatMode = false; - int mDrawTextFontSize = 0; + int32_t mDrawTextFontSize = 0; - int mNDrawCalls = 0; + int32_t mNDrawCalls = 0; bool mUseMultiVBO = false; std::array mDrawColor = {1.f, 1.f, 1.f, 1.f}; - int mTestSetting = 0; + int32_t mTestSetting = 0; float mAngleRollOrigin = -1e9; float mMaxClusterZ = -1; @@ -248,12 +248,12 @@ class GPUDisplay : public GPUDisplayInterface float mRPhiTheta[3]; float mQuat[4]; - vecpod> mOverlayTFClusters; - int mNCollissions = 1; + vecpod> mOverlayTFClusters; + int32_t mNCollissions = 1; vecpod mVertexBuffer[NSLICES]; - vecpod mVertexBufferStart[NSLICES]; - vecpod mVertexBufferCount[NSLICES]; + vecpod mVertexBufferStart[NSLICES]; + vecpod mVertexBufferCount[NSLICES]; std::unique_ptr mGlobalPosPtr; std::unique_ptr mGlobalPosPtrTRD; @@ -265,48 +265,48 @@ class GPUDisplay : public GPUDisplayInterface float4* mGlobalPosTRD2; float4* mGlobalPosITS; float4* mGlobalPosTOF; - int mNMaxClusters = 0; - int mNMaxSpacePointsTRD = 0; - int mNMaxClustersITS = 0; - int mNMaxClustersTOF = 0; - int mCurrentClusters = 0; - int mCurrentSpacePointsTRD = 0; - int mCurrentClustersITS = 0; - int mCurrentClustersTOF = 0; - vecpod mTRDTrackIds; + int32_t mNMaxClusters = 0; + int32_t mNMaxSpacePointsTRD = 0; + int32_t mNMaxClustersITS = 0; + int32_t mNMaxClustersTOF = 0; + int32_t mCurrentClusters = 0; + int32_t mCurrentSpacePointsTRD = 0; + int32_t mCurrentClustersITS = 0; + int32_t mCurrentClustersTOF = 0; + vecpod mTRDTrackIds; vecpod mITSStandaloneTracks; std::vector mTrackFilter; bool mUpdateTrackFilter = false; - int mUpdateVertexLists = 1; - int mUpdateEventData = 0; - int mUpdateDrawCommands = 1; - int mUpdateRenderPipeline = 0; - volatile int mResetScene = 0; + int32_t mUpdateVertexLists = 1; + int32_t mUpdateEventData = 0; + int32_t mUpdateDrawCommands = 1; + int32_t mUpdateRenderPipeline = 0; + volatile int32_t mResetScene = 0; - int mAnimate = 0; + int32_t mAnimate = 0; HighResTimer mAnimationTimer; - int mAnimationFrame = 0; - int mAnimationLastBase = 0; - int mAnimateScreenshot = 0; - int mAnimationExport = 0; + int32_t mAnimationFrame = 0; + int32_t mAnimationLastBase = 0; + int32_t mAnimateScreenshot = 0; + int32_t mAnimationExport = 0; bool mAnimationChangeConfig = true; float mAnimationDelay = 2.f; vecpod mAnimateVectors[9]; vecpod mAnimateConfig; opengl_spline mAnimationSplines[8]; - int mPrintInfoText = 1; + int32_t mPrintInfoText = 1; bool mPrintInfoTextAlways = 0; char mInfoText2[1024]; HighResTimer mInfoText2Timer, mInfoHelpTimer; std::vector mThreadBuffers; - std::vector, 2>, NSLICES>>> mThreadTracks; - volatile int mInitResult = 0; + std::vector, 2>, NSLICES>>> mThreadTracks; + volatile int32_t mInitResult = 0; float mFPSScale = 1, mFPSScaleadjust = 0; - int mFramesDone = 0, mFramesDoneFPS = 0; + int32_t mFramesDone = 0, mFramesDoneFPS = 0; HighResTimer mTimerFPS, mTimerDisplay, mTimerDraw; vboList mGlDLLines[NSLICES][N_LINES_TYPE]; vecpod> mGlDLFinal[NSLICES]; diff --git a/GPU/GPUTracking/display/GPUDisplayInterface.h b/GPU/GPUTracking/display/GPUDisplayInterface.h index 431da46de33b9..49cdb7e9e2038 100644 --- a/GPU/GPUTracking/display/GPUDisplayInterface.h +++ b/GPU/GPUTracking/display/GPUDisplayInterface.h @@ -30,10 +30,10 @@ class GPUDisplayInterface public: GPUDisplayInterface(const GPUDisplayInterface&) = delete; virtual ~GPUDisplayInterface(); - virtual int StartDisplay() = 0; + virtual int32_t StartDisplay() = 0; virtual void ShowNextEvent(const GPUTrackingInOutPointers* ptrs = nullptr) = 0; virtual void WaitForNextEvent() = 0; - virtual void SetCollisionFirstCluster(unsigned int collision, int slice, int cluster) = 0; + virtual void SetCollisionFirstCluster(uint32_t collision, int32_t slice, int32_t cluster) = 0; virtual void UpdateCalib(const GPUCalibObjectsConst* calib) = 0; virtual void UpdateParam(const GPUParam* param) = 0; static GPUDisplayInterface* getDisplay(GPUDisplayFrontendInterface* frontend, GPUChainTracking* chain, GPUQA* qa, const GPUParam* param = nullptr, const GPUCalibObjectsConst* calib = nullptr, const GPUSettingsDisplay* config = nullptr); @@ -49,12 +49,12 @@ class GPUDisplayFrontendInterface static GPUDisplayFrontendInterface* getFrontend(const char* type); virtual void DisplayExit() = 0; virtual bool EnableSendKey() = 0; - virtual int getDisplayControl() const = 0; - virtual int getSendKey() const = 0; - virtual int getNeedUpdate() const = 0; - virtual void setDisplayControl(int v) = 0; - virtual void setSendKey(int v) = 0; - virtual void setNeedUpdate(int v) = 0; + virtual int32_t getDisplayControl() const = 0; + virtual int32_t getSendKey() const = 0; + virtual int32_t getNeedUpdate() const = 0; + virtual void setDisplayControl(int32_t v) = 0; + virtual void setSendKey(int32_t v) = 0; + virtual void setNeedUpdate(int32_t v) = 0; virtual const char* frontendName() const = 0; protected: diff --git a/GPU/GPUTracking/display/backend/GPUDisplayBackend.cxx b/GPU/GPUTracking/display/backend/GPUDisplayBackend.cxx index c6edd5cd40419..15b759e658354 100644 --- a/GPU/GPUTracking/display/backend/GPUDisplayBackend.cxx +++ b/GPU/GPUTracking/display/backend/GPUDisplayBackend.cxx @@ -48,7 +48,7 @@ GPUDisplayBackend* GPUDisplayBackend::getBackend(const char* type) return new GPUDisplayBackendVulkan; } else #endif - if (strcmp(type, "opengl") == 0 || strcmp(type, "auto") == 0) { + if (strcmp(type, "opengl") == 0 || strcmp(type, "auto") == 0) { return new GPUDisplayBackendOpenGL; } else { GPUError("Requested renderer not available"); @@ -56,9 +56,9 @@ GPUDisplayBackend* GPUDisplayBackend::getBackend(const char* type) return nullptr; } -int GPUDisplayBackend::InitBackend() +int32_t GPUDisplayBackend::InitBackend() { - int retVal = InitBackendA(); + int32_t retVal = InitBackendA(); if (retVal) { return retVal; } @@ -100,14 +100,14 @@ int GPUDisplayBackend::InitBackend() return 0; } - int fontSize = mDisplay->cfg().fontSize; + int32_t fontSize = mDisplay->cfg().fontSize; mDisplay->drawTextFontSize() = fontSize; if (smoothFont()) { fontSize *= 4; // Font size scaled by 4, can be downsampled } FT_Set_Pixel_Sizes(face, 0, fontSize); - for (unsigned int i = 0; i < 128; i++) { + for (uint32_t i = 0; i < 128; i++) { if (FT_Load_Char(face, i, FT_LOAD_RENDER)) { GPUError("Error loading freetype symbol"); return 0; @@ -140,9 +140,9 @@ void GPUDisplayBackend::fillIndirectCmdBuffer() mCmdBuffer.clear(); mIndirectSliceOffset.resize(GPUCA_NSLICES); // TODO: Check if this can be parallelized - for (int iSlice = 0; iSlice < GPUCA_NSLICES; iSlice++) { + for (int32_t iSlice = 0; iSlice < GPUCA_NSLICES; iSlice++) { mIndirectSliceOffset[iSlice] = mCmdBuffer.size(); - for (unsigned int k = 0; k < mDisplay->vertexBufferStart()[iSlice].size(); k++) { + for (uint32_t k = 0; k < mDisplay->vertexBufferStart()[iSlice].size(); k++) { mCmdBuffer.emplace_back(mDisplay->vertexBufferCount()[iSlice][k], 1, mDisplay->vertexBufferStart()[iSlice][k], 0); } } @@ -151,8 +151,8 @@ void GPUDisplayBackend::fillIndirectCmdBuffer() float GPUDisplayBackend::getDownsampleFactor(bool screenshot) { float factor = 1.0f; - int fsaa = mDisplay->cfgR().drawQualityDownsampleFSAA; - int screenshotScale = mDisplay->cfgR().screenshotScaleFactor; + int32_t fsaa = mDisplay->cfgR().drawQualityDownsampleFSAA; + int32_t screenshotScale = mDisplay->cfgR().screenshotScaleFactor; if (fsaa) { factor *= fsaa; } diff --git a/GPU/GPUTracking/display/backend/GPUDisplayBackend.h b/GPU/GPUTracking/display/backend/GPUDisplayBackend.h index 1ce279f6f9bb7..8f00f39b97ce3 100644 --- a/GPU/GPUTracking/display/backend/GPUDisplayBackend.h +++ b/GPU/GPUTracking/display/backend/GPUDisplayBackend.h @@ -42,11 +42,11 @@ class GPUDisplayBackend GPUDisplayBackend(); virtual ~GPUDisplayBackend(); - virtual int ExtInit() { return 0; }; + virtual int32_t ExtInit() { return 0; }; virtual bool CoreProfile() { return false; }; - virtual unsigned int DepthBits() = 0; + virtual uint32_t DepthBits() = 0; - typedef std::tuple vboList; + typedef std::tuple vboList; enum drawType { POINTS = 0, @@ -61,30 +61,30 @@ class GPUDisplayBackend }; struct DrawArraysIndirectCommand { - DrawArraysIndirectCommand(unsigned int a = 0, unsigned int b = 0, unsigned int c = 0, unsigned int d = 0) : count(a), instanceCount(b), first(c), baseInstance(d) {} - unsigned int count; - unsigned int instanceCount; + DrawArraysIndirectCommand(uint32_t a = 0, uint32_t b = 0, uint32_t c = 0, uint32_t d = 0) : count(a), instanceCount(b), first(c), baseInstance(d) {} + uint32_t count; + uint32_t instanceCount; - unsigned int first; - unsigned int baseInstance; + uint32_t first; + uint32_t baseInstance; }; struct FontSymbol { - int size[2]; - int offset[2]; - int advance; + int32_t size[2]; + int32_t offset[2]; + int32_t advance; }; - virtual unsigned int drawVertices(const vboList& v, const drawType t) = 0; - virtual unsigned int drawField() { return 0; } + virtual uint32_t drawVertices(const vboList& v, const drawType t) = 0; + virtual uint32_t drawField() { return 0; } virtual void ActivateColor(std::array& color) = 0; virtual void setQuality() {}; virtual void SetVSync(bool enable) {}; virtual bool backendNeedRedraw() { return true; } virtual void setDepthBuffer() = 0; - virtual int InitBackendA() = 0; + virtual int32_t InitBackendA() = 0; virtual void ExitBackendA() = 0; - int InitBackend(); + int32_t InitBackend(); void ExitBackend(); virtual void loadDataToGPU(size_t totalVertizes) = 0; virtual void prepareDraw(const hmm_mat4& proj, const hmm_mat4& view, bool requestScreenshot = false, bool toMixBuffer = false, float includeMixImage = 0.f) = 0; @@ -96,16 +96,16 @@ class GPUDisplayBackend virtual void lineWidthFactor(float factor) = 0; backendTypes backendType() const { return mBackendType; } const char* backendName() const { return mBackendName; } - virtual void resizeScene(unsigned int width, unsigned int height) {} + virtual void resizeScene(uint32_t width, uint32_t height) {} virtual size_t needMultiVBO() { return 0; } virtual void OpenGLPrint(const char* s, float x, float y, float* color, float scale) = 0; static GPUDisplayBackend* getBackend(const char* type); std::vector getPixels(); virtual float getYFactor() const { return 1.0f; } - virtual int getMaxMSAA() const { return 16; } + virtual int32_t getMaxMSAA() const { return 16; } protected: - virtual void addFontSymbol(int symbol, int sizex, int sizey, int offsetx, int offsety, int advance, void* data) = 0; + virtual void addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) = 0; virtual void initializeTextDrawing() = 0; float getDownsampleFactor(bool screenshot = false); @@ -113,18 +113,18 @@ class GPUDisplayBackend bool smoothFont(); GPUDisplay* mDisplay = nullptr; - std::vector mIndirectSliceOffset; + std::vector mIndirectSliceOffset; vecpod mCmdBuffer; bool mFreetypeInitialized = false; bool mFrontendCompatTextDraw = false; std::vector mScreenshotPixels; - int mDownsampleFactor = 1; + int32_t mDownsampleFactor = 1; - unsigned int mRenderWidth = 0; - unsigned int mRenderHeight = 0; - unsigned int mScreenWidth = 0; - unsigned int mScreenHeight = 0; + uint32_t mRenderWidth = 0; + uint32_t mRenderHeight = 0; + uint32_t mScreenWidth = 0; + uint32_t mScreenHeight = 0; backendTypes mBackendType = TYPE_INVALID; const char* mBackendName = nullptr; diff --git a/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.cxx b/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.cxx index c25fbede428ca..b92872a79c6de 100644 --- a/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.cxx +++ b/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.cxx @@ -60,12 +60,12 @@ GPUDisplayBackendOpenGL::GPUDisplayBackendOpenGL() } #ifdef GPUCA_DISPLAY_GL3W -int GPUDisplayBackendOpenGL::ExtInit() +int32_t GPUDisplayBackendOpenGL::ExtInit() { return gl3wInit(); } #else -int GPUDisplayBackendOpenGL::ExtInit() +int32_t GPUDisplayBackendOpenGL::ExtInit() { return glewInit(); } @@ -83,17 +83,17 @@ bool GPUDisplayBackendOpenGL::CoreProfile() #endif // #define CHKERR(cmd) {cmd;} -#define CHKERR(cmd) \ - do { \ - (cmd); \ - GLenum err = glGetError(); \ - while (err != GL_NO_ERROR) { \ - GPUError("OpenGL Error %d: %s (%s: %d)", (int)err, (const char*)gluErrorString(err), __FILE__, __LINE__); \ - throw std::runtime_error("OpenGL Failure"); \ - } \ +#define CHKERR(cmd) \ + do { \ + (cmd); \ + GLenum err = glGetError(); \ + while (err != GL_NO_ERROR) { \ + GPUError("OpenGL Error %d: %s (%s: %d)", (int32_t)err, (const char*)gluErrorString(err), __FILE__, __LINE__); \ + throw std::runtime_error("OpenGL Failure"); \ + } \ } while (false) -unsigned int GPUDisplayBackendOpenGL::DepthBits() +uint32_t GPUDisplayBackendOpenGL::DepthBits() { GLint depthBits = 0; #ifndef GPUCA_DISPLAY_OPENGL_CORE @@ -102,7 +102,7 @@ unsigned int GPUDisplayBackendOpenGL::DepthBits() return depthBits; } -void GPUDisplayBackendOpenGL::createFB(GLfb& fb, bool tex, bool withDepth, bool msaa, unsigned int width, unsigned int height) +void GPUDisplayBackendOpenGL::createFB(GLfb& fb, bool tex, bool withDepth, bool msaa, uint32_t width, uint32_t height) { fb.tex = tex; fb.depth = withDepth; @@ -154,7 +154,7 @@ void GPUDisplayBackendOpenGL::createFB(GLfb& fb, bool tex, bool withDepth, bool GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { - GPUError("Error creating framebuffer (tex %d) - incomplete (%d)", (int)tex, status); + GPUError("Error creating framebuffer (tex %d) - incomplete (%d)", (int32_t)tex, status); exit(1); } CHKERR(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFboId)); @@ -180,7 +180,7 @@ void GPUDisplayBackendOpenGL::deleteFB(GLfb& fb) fb.created = false; } -unsigned int GPUDisplayBackendOpenGL::drawVertices(const vboList& v, const drawType tt) +uint32_t GPUDisplayBackendOpenGL::drawVertices(const vboList& v, const drawType tt) { static constexpr GLenum types[3] = {GL_POINTS, GL_LINES, GL_LINE_STRIP}; GLenum t = types[tt]; @@ -210,7 +210,7 @@ unsigned int GPUDisplayBackendOpenGL::drawVertices(const vboList& v, const drawT if (mDisplay->cfgR().useGLIndirectDraw) { CHKERR(glMultiDrawArraysIndirect(t, (void*)(size_t)((mIndirectSliceOffset[iSlice] + first) * sizeof(DrawArraysIndirectCommand)), count, 0)); } else if (OPENGL_EMULATE_MULTI_DRAW) { - for (unsigned int k = 0; k < count; k++) { + for (uint32_t k = 0; k < count; k++) { CHKERR(glDrawArrays(t, mDisplay->vertexBufferStart()[iSlice][first + k], mDisplay->vertexBufferCount()[iSlice][first + k])); } } else { @@ -257,7 +257,7 @@ void GPUDisplayBackendOpenGL::setDepthBuffer() } } -void GPUDisplayBackendOpenGL::setFrameBuffer(unsigned int newID) +void GPUDisplayBackendOpenGL::setFrameBuffer(uint32_t newID) { if (newID == 0) { CHKERR(glBindFramebuffer(GL_FRAMEBUFFER, 0)); @@ -269,9 +269,9 @@ void GPUDisplayBackendOpenGL::setFrameBuffer(unsigned int newID) } } -int GPUDisplayBackendOpenGL::checkShaderStatus(unsigned int shader) +int32_t GPUDisplayBackendOpenGL::checkShaderStatus(uint32_t shader) { - int status, loglen; + int32_t status, loglen; glGetShaderiv(shader, GL_COMPILE_STATUS, &status); if (!status) { printf("failed to compile shader\n"); @@ -285,9 +285,9 @@ int GPUDisplayBackendOpenGL::checkShaderStatus(unsigned int shader) return 0; } -int GPUDisplayBackendOpenGL::checkProgramStatus(unsigned int program) +int32_t GPUDisplayBackendOpenGL::checkProgramStatus(uint32_t program) { - int status, loglen; + int32_t status, loglen; glGetProgramiv(program, GL_LINK_STATUS, &status); if (!status) { printf("failed to link program\n"); @@ -301,14 +301,14 @@ int GPUDisplayBackendOpenGL::checkProgramStatus(unsigned int program) return 0; } -int GPUDisplayBackendOpenGL::InitBackendA() +int32_t GPUDisplayBackendOpenGL::InitBackendA() { if (mDisplay->param()->par.debugLevel >= 2) { auto renderer = glGetString(GL_RENDERER); GPUInfo("Renderer: %s", (const char*)renderer); } - int glVersion[2] = {0, 0}; + int32_t glVersion[2] = {0, 0}; glGetIntegerv(GL_MAJOR_VERSION, &glVersion[0]); glGetIntegerv(GL_MINOR_VERSION, &glVersion[1]); if (glVersion[0] < GPUDisplayFrontend::GL_MIN_VERSION_MAJOR || (glVersion[0] == GPUDisplayFrontend::GL_MIN_VERSION_MAJOR && glVersion[1] < GPUDisplayFrontend::GL_MIN_VERSION_MINOR)) { @@ -457,7 +457,7 @@ void GPUDisplayBackendOpenGL::loadDataToGPU(size_t totalVertizes) { // TODO: Check if this can be parallelized if (mDisplay->useMultiVBO()) { - for (int i = 0; i < GPUCA_NSLICES; i++) { + for (int32_t i = 0; i < GPUCA_NSLICES; i++) { CHKERR(glNamedBufferData(mVBOId[i], mDisplay->vertexBuffer()[i].size() * sizeof(mDisplay->vertexBuffer()[i][0]), mDisplay->vertexBuffer()[i].data(), GL_STATIC_DRAW)); } } else { @@ -551,7 +551,7 @@ void GPUDisplayBackendOpenGL::finishDraw(bool doScreenshot, bool toMixBuffer, fl } if (mDisplay->cfgR().drawQualityMSAA) { - unsigned int dstId = toMixBuffer ? mMixBuffer.fb_id : (mDownsampleFactor != 1 ? mOffscreenBuffer.fb_id : 0); + uint32_t dstId = toMixBuffer ? mMixBuffer.fb_id : (mDownsampleFactor != 1 ? mOffscreenBuffer.fb_id : 0); CHKERR(glBlitNamedFramebuffer(mOffscreenBufferMSAA.fb_id, dstId, 0, 0, mRenderWidth, mRenderHeight, 0, 0, mRenderWidth, mRenderHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR)); } if (includeMixImage > 0) { @@ -569,9 +569,9 @@ void GPUDisplayBackendOpenGL::finishDraw(bool doScreenshot, bool toMixBuffer, fl void GPUDisplayBackendOpenGL::readImageToPixels() { - int scaleFactor = mDisplay->cfgR().screenshotScaleFactor; - unsigned int width = mScreenWidth * scaleFactor; - unsigned int height = mScreenHeight * scaleFactor; + int32_t scaleFactor = mDisplay->cfgR().screenshotScaleFactor; + uint32_t width = mScreenWidth * scaleFactor; + uint32_t height = mScreenHeight * scaleFactor; GLfb tmpBuffer; if (mDisplay->cfgR().drawQualityDownsampleFSAA && mDisplay->cfgR().screenshotScaleFactor != 1) { createFB(tmpBuffer, false, true, false, width, height); @@ -680,21 +680,21 @@ void GPUDisplayBackendOpenGL::lineWidthFactor(float factor) CHKERR(glLineWidth(mDisplay->cfgL().lineWidth * mDownsampleFactor * factor)); } -void GPUDisplayBackendOpenGL::addFontSymbol(int symbol, int sizex, int sizey, int offsetx, int offsety, int advance, void* data) +void GPUDisplayBackendOpenGL::addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) { - int oldAlign; + int32_t oldAlign; CHKERR(glGetIntegerv(GL_UNPACK_ALIGNMENT, &oldAlign)); CHKERR(glPixelStorei(GL_UNPACK_ALIGNMENT, 1)); - if (symbol != (int)mFontSymbols.size()) { + if (symbol != (int32_t)mFontSymbols.size()) { throw std::runtime_error("Incorrect symbol ID"); } - unsigned int texId; + uint32_t texId; glGenTextures(1, &texId); - std::vector tmp; + std::vector tmp; if (!smoothFont()) { tmp.resize(sizex * sizey); - unsigned char* src = (unsigned char*)data; - for (int i = 0; i < sizex * sizey; i++) { + uint8_t* src = (uint8_t*)data; + for (int32_t i = 0; i < sizex * sizey; i++) { tmp[i] = src[i] > 128 ? 255 : 0; } data = tmp.data(); @@ -736,8 +736,8 @@ void GPUDisplayBackendOpenGL::OpenGLPrint(const char* s, float x, float y, float scale *= 0.25f; // Font size is 48 to have nice bitmap, scale to size 12 } for (const char* c = s; *c; c++) { - if ((int)*c > (int)mFontSymbols.size()) { - GPUError("Trying to draw unsupported symbol: %d > %d\n", (int)*c, (int)mFontSymbols.size()); + if ((int32_t)*c > (int32_t)mFontSymbols.size()) { + GPUError("Trying to draw unsupported symbol: %d > %d\n", (int32_t)*c, (int32_t)mFontSymbols.size()); continue; } FontSymbolOpenGL sym = mFontSymbols[*c]; @@ -779,7 +779,7 @@ void GPUDisplayBackendOpenGL::ClearOffscreenBuffers() } } -void GPUDisplayBackendOpenGL::resizeScene(unsigned int width, unsigned int height) +void GPUDisplayBackendOpenGL::resizeScene(uint32_t width, uint32_t height) { mScreenWidth = width; mScreenHeight = height; @@ -821,27 +821,27 @@ void GPUDisplayBackendOpenGL::updateRenderer(bool withScreenshot) GPUDisplayBackendOpenGL::GPUDisplayBackendOpenGL() { } -int GPUDisplayBackendOpenGL::checkShaderStatus(unsigned int shader) { return 0; } -int GPUDisplayBackendOpenGL::checkProgramStatus(unsigned int program) { return 0; } -int GPUDisplayBackendOpenGL::ExtInit() { throw std::runtime_error("Insufficnet OpenGL version"); } +int32_t GPUDisplayBackendOpenGL::checkShaderStatus(uint32_t shader) { return 0; } +int32_t GPUDisplayBackendOpenGL::checkProgramStatus(uint32_t program) { return 0; } +int32_t GPUDisplayBackendOpenGL::ExtInit() { throw std::runtime_error("Insufficnet OpenGL version"); } bool GPUDisplayBackendOpenGL::CoreProfile() { return false; } -unsigned int GPUDisplayBackendOpenGL::DepthBits() { return 0; } -unsigned int GPUDisplayBackendOpenGL::drawVertices(const vboList& v, const drawType t) { return 0; } +uint32_t GPUDisplayBackendOpenGL::DepthBits() { return 0; } +uint32_t GPUDisplayBackendOpenGL::drawVertices(const vboList& v, const drawType t) { return 0; } void GPUDisplayBackendOpenGL::ActivateColor(std::array& color) {} void GPUDisplayBackendOpenGL::setQuality() {} void GPUDisplayBackendOpenGL::setDepthBuffer() {} -int GPUDisplayBackendOpenGL::InitBackendA() { throw std::runtime_error("Insufficnet OpenGL version"); } +int32_t GPUDisplayBackendOpenGL::InitBackendA() { throw std::runtime_error("Insufficnet OpenGL version"); } void GPUDisplayBackendOpenGL::ExitBackendA() {} void GPUDisplayBackendOpenGL::loadDataToGPU(size_t totalVertizes) {} void GPUDisplayBackendOpenGL::prepareDraw(const hmm_mat4& proj, const hmm_mat4& view, bool requestScreenshot, bool toMixBuffer, float includeMixImage) {} -void GPUDisplayBackendOpenGL::resizeScene(unsigned int width, unsigned int height) {} +void GPUDisplayBackendOpenGL::resizeScene(uint32_t width, uint32_t height) {} void GPUDisplayBackendOpenGL::finishDraw(bool doScreenshot, bool toMixBuffer, float includeMixImage) {} void GPUDisplayBackendOpenGL::finishFrame(bool doScreenshot, bool toMixBuffer, float includeMixImage) {} void GPUDisplayBackendOpenGL::prepareText() {} void GPUDisplayBackendOpenGL::finishText() {} void GPUDisplayBackendOpenGL::pointSizeFactor(float factor) {} void GPUDisplayBackendOpenGL::lineWidthFactor(float factor) {} -void GPUDisplayBackendOpenGL::addFontSymbol(int symbol, int sizex, int sizey, int offsetx, int offsety, int advance, void* data) {} +void GPUDisplayBackendOpenGL::addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) {} void GPUDisplayBackendOpenGL::initializeTextDrawing() {} void GPUDisplayBackendOpenGL::OpenGLPrint(const char* s, float x, float y, float* color, float scale) {} #endif // GPUCA_BUILD_EVENT_DISPLAY_OPENGL diff --git a/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.h b/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.h index f7e2d4ee44460..b1bcb25740ed4 100644 --- a/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.h +++ b/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.h @@ -22,7 +22,7 @@ namespace GPUCA_NAMESPACE::gpu { struct GLfb { - unsigned int fb_id = 0, fbCol_id = 0, fbDepth_id = 0; + uint32_t fb_id = 0, fbCol_id = 0, fbDepth_id = 0; bool tex = false; bool msaa = false; bool depth = false; @@ -33,30 +33,30 @@ class GPUDisplayBackendOpenGL : public GPUDisplayBackend public: GPUDisplayBackendOpenGL(); ~GPUDisplayBackendOpenGL() override = default; - int ExtInit() override; + int32_t ExtInit() override; bool CoreProfile() override; - unsigned int DepthBits() override; + uint32_t DepthBits() override; protected: - void createFB(GLfb& fb, bool tex, bool withDepth, bool msaa, unsigned int width, unsigned int height); + void createFB(GLfb& fb, bool tex, bool withDepth, bool msaa, uint32_t width, uint32_t height); void deleteFB(GLfb& fb); - unsigned int drawVertices(const vboList& v, const drawType t) override; - unsigned int drawField() override; + uint32_t drawVertices(const vboList& v, const drawType t) override; + uint32_t drawField() override; void ActivateColor(std::array& color) override; void setQuality() override; void setDepthBuffer() override; - void setFrameBuffer(unsigned int newID = 0); - int InitBackendA() override; - int InitMagFieldVisualization(); + void setFrameBuffer(uint32_t newID = 0); + int32_t InitBackendA() override; + int32_t InitMagFieldVisualization(); void ExitBackendA() override; void ExitMagFieldVisualization(); - static int checkShaderStatus(unsigned int shader); - static int checkProgramStatus(unsigned int program); + static int32_t checkShaderStatus(uint32_t shader); + static int32_t checkProgramStatus(uint32_t program); void clearScreen(bool alphaOnly = false); void loadDataToGPU(size_t totalVertizes) override; void prepareDraw(const hmm_mat4& proj, const hmm_mat4& view, bool requestScreenshot, bool toMixBuffer, float includeMixImage) override; - void resizeScene(unsigned int width, unsigned int height) override; + void resizeScene(uint32_t width, uint32_t height) override; void updateRenderer(bool withScreenshot); void ClearOffscreenBuffers(); void finishDraw(bool doScreenshot, bool toMixBuffer, float includeMixImage) override; @@ -69,51 +69,51 @@ class GPUDisplayBackendOpenGL : public GPUDisplayBackend size_t needMultiVBO() override { return 0x100000000ll; } void readImageToPixels(); - void addFontSymbol(int symbol, int sizex, int sizey, int offsetx, int offsety, int advance, void* data) override; + void addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) override; void initializeTextDrawing() override; void OpenGLPrint(const char* s, float x, float y, float* color, float scale) override; struct FontSymbolOpenGL : public FontSymbol { - unsigned int texId; + uint32_t texId; }; - unsigned int mVertexShader; - unsigned int mFragmentShader; - unsigned int mVertexShaderTexture; - unsigned int mVertexShaderPassthrough; - unsigned int mFragmentShaderTexture; - unsigned int mFragmentShaderText; - unsigned int mGeometryShader; - unsigned int mShaderProgram; - unsigned int mShaderProgramText; - unsigned int mShaderProgramTexture; - unsigned int mShaderProgramField; - unsigned int mVertexArray; - - unsigned int mIndirectId; - std::vector mVBOId; + uint32_t mVertexShader; + uint32_t mFragmentShader; + uint32_t mVertexShaderTexture; + uint32_t mVertexShaderPassthrough; + uint32_t mFragmentShaderTexture; + uint32_t mFragmentShaderText; + uint32_t mGeometryShader; + uint32_t mShaderProgram; + uint32_t mShaderProgramText; + uint32_t mShaderProgramTexture; + uint32_t mShaderProgramField; + uint32_t mVertexArray; + + uint32_t mIndirectId; + std::vector mVBOId; std::vector mFontSymbols; - int mModelViewProjId; - int mColorId; - int mModelViewProjIdTexture; - int mAlphaIdTexture; - int mModelViewProjIdText; - int mColorIdText; - unsigned int mSPIRVModelViewBuffer; - unsigned int mSPIRVColorBuffer; - - unsigned int mFieldModelViewBuffer; - unsigned int mFieldModelConstantsBuffer; - unsigned int mSolenoidSegmentsBuffer; - unsigned int mSolenoidParameterizationBuffer; - unsigned int mDipoleSegmentsBuffer; - unsigned int mDipoleParameterizationBuffer; - - unsigned int VAO_text, VBO_text; - - unsigned int VAO_texture, VBO_texture; - - unsigned int VAO_field, VBO_field; + int32_t mModelViewProjId; + int32_t mColorId; + int32_t mModelViewProjIdTexture; + int32_t mAlphaIdTexture; + int32_t mModelViewProjIdText; + int32_t mColorIdText; + uint32_t mSPIRVModelViewBuffer; + uint32_t mSPIRVColorBuffer; + + uint32_t mFieldModelViewBuffer; + uint32_t mFieldModelConstantsBuffer; + uint32_t mSolenoidSegmentsBuffer; + uint32_t mSolenoidParameterizationBuffer; + uint32_t mDipoleSegmentsBuffer; + uint32_t mDipoleParameterizationBuffer; + + uint32_t VAO_text, VBO_text; + + uint32_t VAO_texture, VBO_texture; + + uint32_t VAO_field, VBO_field; bool mSPIRVShaders = false; diff --git a/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.cxx b/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.cxx index a6920942b9990..5491555ace8d2 100644 --- a/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.cxx +++ b/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.cxx @@ -32,13 +32,13 @@ QGET_LD_BINARY_SYMBOLS(shaders_shaders_fragmentTexture_frag_spv); QGET_LD_BINARY_SYMBOLS(shaders_shaders_fragmentText_frag_spv); // #define CHKERR(cmd) {cmd;} -#define CHKERR(cmd) \ - do { \ - auto tmp_internal_retVal = cmd; \ - if ((int)tmp_internal_retVal < 0) { \ - GPUError("VULKAN ERROR: %d: %s (%s: %d)", (int)tmp_internal_retVal, "ERROR", __FILE__, __LINE__); \ - throw std::runtime_error("Vulkan Failure"); \ - } \ +#define CHKERR(cmd) \ + do { \ + auto tmp_internal_retVal = cmd; \ + if ((int32_t)tmp_internal_retVal < 0) { \ + GPUError("VULKAN ERROR: %d: %s (%s: %d)", (int32_t)tmp_internal_retVal, "ERROR", __FILE__, __LINE__); \ + throw std::runtime_error("Vulkan Failure"); \ + } \ } while (false) GPUDisplayBackendVulkan::GPUDisplayBackendVulkan() @@ -50,7 +50,7 @@ GPUDisplayBackendVulkan::~GPUDisplayBackendVulkan() = default; // ---------------------------- VULKAN HELPERS ---------------------------- -static int checkVulkanLayersSupported(const std::vector& validationLayers) +static int32_t checkVulkanLayersSupported(const std::vector& validationLayers) { std::vector availableLayers = vk::enumerateInstanceLayerProperties(); for (const char* layerName : validationLayers) { @@ -113,7 +113,7 @@ vk::Extent2D GPUDisplayBackendVulkan::chooseSwapExtent(const vk::SurfaceCapabili if (capabilities.currentExtent.width != std::numeric_limits::max()) { return capabilities.currentExtent; } else { - int width, height; + int32_t width, height; mDisplay->frontend()->getSize(width, height); vk::Extent2D actualExtent = {(uint32_t)width, (uint32_t)height}; actualExtent.width = std::clamp(actualExtent.width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width); @@ -221,7 +221,7 @@ static void createImageI(vk::Device device, vk::PhysicalDevice physicalDevice, v device.bindImageMemory(image, imageMemory, 0); } -static unsigned int getMaxUsableSampleCount(vk::PhysicalDeviceProperties& physicalDeviceProperties) +static uint32_t getMaxUsableSampleCount(vk::PhysicalDeviceProperties& physicalDeviceProperties) { vk::SampleCountFlags counts = physicalDeviceProperties.limits.framebufferColorSampleCounts & physicalDeviceProperties.limits.framebufferDepthSampleCounts; if (counts & vk::SampleCountFlagBits::e64) { @@ -240,7 +240,7 @@ static unsigned int getMaxUsableSampleCount(vk::PhysicalDeviceProperties& physic return 1; } -static vk::SampleCountFlagBits getMSAASamplesFlag(unsigned int msaa) +static vk::SampleCountFlagBits getMSAASamplesFlag(uint32_t msaa) { if (msaa == 2) { return vk::SampleCountFlagBits::e2; @@ -281,7 +281,7 @@ double GPUDisplayBackendVulkan::checkDevice(vk::PhysicalDevice device, const std std::vector queueFamilies = device.getQueueFamilyProperties(); bool found = false; - for (unsigned int i = 0; i < queueFamilies.size(); i++) { + for (uint32_t i = 0; i < queueFamilies.size(); i++) { if (!(queueFamilies[i].queueFlags & vk::QueueFlagBits::eGraphics)) { return (-1); } @@ -299,9 +299,9 @@ double GPUDisplayBackendVulkan::checkDevice(vk::PhysicalDevice device, const std } std::vector availableExtensions = device.enumerateDeviceExtensionProperties(nullptr); - unsigned int extensionsFound = 0; - for (unsigned int i = 0; i < reqDeviceExtensions.size(); i++) { - for (unsigned int j = 0; j < availableExtensions.size(); j++) { + uint32_t extensionsFound = 0; + for (uint32_t i = 0; i < reqDeviceExtensions.size(); i++) { + for (uint32_t j = 0; j < availableExtensions.size(); j++) { if (strcmp(reqDeviceExtensions[i], availableExtensions[j].extensionName) == 0) { extensionsFound++; break; @@ -326,7 +326,7 @@ double GPUDisplayBackendVulkan::checkDevice(vk::PhysicalDevice device, const std score += 1e11; } - for (unsigned int i = 0; i < memoryProperties.memoryHeapCount; i++) { + for (uint32_t i = 0; i < memoryProperties.memoryHeapCount; i++) { if (memoryProperties.memoryHeaps[i].flags & vk::MemoryHeapFlagBits::eDeviceLocal) { score += memoryProperties.memoryHeaps[i].size; } @@ -354,7 +354,7 @@ void GPUDisplayBackendVulkan::createDevice() const std::vector reqValidationLayers = { "VK_LAYER_KHRONOS_validation"}; auto debugCallback = [](VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData) -> VkBool32 { - static int throwOnError = getenv("GPUCA_VULKAN_VALIDATION_THROW") ? atoi(getenv("GPUCA_VULKAN_VALIDATION_THROW")) : 0; + static int32_t throwOnError = getenv("GPUCA_VULKAN_VALIDATION_THROW") ? atoi(getenv("GPUCA_VULKAN_VALIDATION_THROW")) : 0; static bool showVulkanValidationInfo = getenv("GPUCA_VULKAN_VALIDATION_INFO") && atoi(getenv("GPUCA_VULKAN_VALIDATION_INFO")); switch (messageSeverity) { case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: @@ -429,7 +429,7 @@ void GPUDisplayBackendVulkan::createDevice() throw std::runtime_error("No Vulkan device present!"); } double bestScore = -1.; - for (unsigned int i = 0; i < devices.size(); i++) { + for (uint32_t i = 0; i < devices.size(); i++) { double score = checkDevice(devices[i], reqDeviceExtensions); if (mDisplay->param()->par.debugLevel >= 2) { vk::PhysicalDeviceProperties deviceProperties = devices[i].getProperties(); @@ -441,7 +441,7 @@ void GPUDisplayBackendVulkan::createDevice() } } if (mDisplay->cfg().vulkan.forceDevice != -1) { - if (mDisplay->cfg().vulkan.forceDevice < 0 || mDisplay->cfg().vulkan.forceDevice >= (int)devices.size()) { + if (mDisplay->cfg().vulkan.forceDevice < 0 || mDisplay->cfg().vulkan.forceDevice >= (int32_t)devices.size()) { throw std::runtime_error("Invalid Vulkan device selected"); } mPhysicalDevice = devices[mDisplay->cfg().vulkan.forceDevice]; @@ -463,7 +463,7 @@ void GPUDisplayBackendVulkan::createDevice() mCubicFilterSupported = (bool)(formatProperties.optimalTilingFeatures & vk::FormatFeatureFlagBits::eSampledImageFilterCubicEXT); bool mailboxSupported = std::find(mSwapChainDetails.presentModes.begin(), mSwapChainDetails.presentModes.end(), vk::PresentModeKHR::eMailbox) != mSwapChainDetails.presentModes.end(); if (mDisplay->param()->par.debugLevel >= 2) { - GPUInfo("Max MSAA: %d, 32 bit Z buffer %d, 32 bit Z buffer + stencil buffer %d, Cubic Filtering %d, Mailbox present mode %d\n", (int)mMaxMSAAsupported, (int)mZSupported, (int)mStencilSupported, (int)mCubicFilterSupported, (int)mailboxSupported); + GPUInfo("Max MSAA: %d, 32 bit Z buffer %d, 32 bit Z buffer + stencil buffer %d, Cubic Filtering %d, Mailbox present mode %d\n", (int32_t)mMaxMSAAsupported, (int32_t)mZSupported, (int32_t)mStencilSupported, (int32_t)mCubicFilterSupported, (int32_t)mailboxSupported); } vk::DeviceQueueCreateInfo queueCreateInfo{}; @@ -536,7 +536,7 @@ void GPUDisplayBackendVulkan::createSemaphoresAndFences() mMixFinishedSemaphore.resize(mFramesInFlight); mDownsampleFinishedSemaphore.resize(mFramesInFlight); mInFlightFence.resize(mFramesInFlight); - for (unsigned int i = 0; i < mFramesInFlight; i++) { + for (uint32_t i = 0; i < mFramesInFlight; i++) { mImageAvailableSemaphore[i] = mDevice.createSemaphore(semaphoreInfo, nullptr); mRenderFinishedSemaphore[i] = mDevice.createSemaphore(semaphoreInfo, nullptr); mTextFinishedSemaphore[i] = mDevice.createSemaphore(semaphoreInfo, nullptr); @@ -563,10 +563,10 @@ void GPUDisplayBackendVulkan::clearSemaphoresAndFences() void GPUDisplayBackendVulkan::createUniformLayoutsAndBuffers() { - for (int j = 0; j < 3; j++) { + for (int32_t j = 0; j < 3; j++) { mUniformBuffersMat[j].resize(mFramesInFlight); mUniformBuffersCol[j].resize(mFramesInFlight); - for (unsigned int i = 0; i < mFramesInFlight; i++) { + for (uint32_t i = 0; i < mFramesInFlight; i++) { mUniformBuffersMat[j][i] = createBuffer(sizeof(hmm_mat4), nullptr, vk::BufferUsageFlagBits::eUniformBuffer, mDisplay->cfg().vulkan.uniformBuffersInDeviceMemory ? 2 : 0); mUniformBuffersCol[j][i] = createBuffer(sizeof(float) * 4, nullptr, vk::BufferUsageFlagBits::eUniformBuffer, mDisplay->cfg().vulkan.uniformBuffersInDeviceMemory ? 2 : 0); } @@ -608,14 +608,14 @@ void GPUDisplayBackendVulkan::createUniformLayoutsAndBuffers() vk::DescriptorSetAllocateInfo allocInfo{}; allocInfo.descriptorPool = mDescriptorPool; allocInfo.descriptorSetCount = (uint32_t)mFramesInFlight; - for (int j = 0; j < 3; j++) { // 0 = Render, 1 = Text, 2 = Texture + for (int32_t j = 0; j < 3; j++) { // 0 = Render, 1 = Text, 2 = Texture std::vector layouts(mFramesInFlight, j ? mUniformDescriptorTexture : mUniformDescriptor); allocInfo.pSetLayouts = layouts.data(); mDescriptorSets[j] = mDevice.allocateDescriptorSets(allocInfo); - for (int k = 0; k < 2; k++) { + for (int32_t k = 0; k < 2; k++) { auto& mUniformBuffers = k ? mUniformBuffersCol[j] : mUniformBuffersMat[j]; - for (unsigned int i = 0; i < mFramesInFlight; i++) { + for (uint32_t i = 0; i < mFramesInFlight; i++) { vk::DescriptorBufferInfo bufferInfo{}; bufferInfo.buffer = mUniformBuffers[i].buffer; bufferInfo.offset = 0; @@ -645,13 +645,13 @@ void GPUDisplayBackendVulkan::clearUniformLayoutsAndBuffers() mDevice.destroyDescriptorSetLayout(mUniformDescriptor, nullptr); mDevice.destroyDescriptorSetLayout(mUniformDescriptorTexture, nullptr); mDevice.destroyDescriptorPool(mDescriptorPool, nullptr); - for (int j = 0; j < 3; j++) { + for (int32_t j = 0; j < 3; j++) { clearVector(mUniformBuffersMat[j], [&](auto& x) { clearBuffer(x); }); clearVector(mUniformBuffersCol[j], [&](auto& x) { clearBuffer(x); }); } } -void GPUDisplayBackendVulkan::setMixDescriptor(int descriptorIndex, int imageIndex) +void GPUDisplayBackendVulkan::setMixDescriptor(int32_t descriptorIndex, int32_t imageIndex) { vk::DescriptorImageInfo imageInfo{}; imageInfo.imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal; @@ -741,7 +741,7 @@ void GPUDisplayBackendVulkan::createSwapChain(bool forScreenshot, bool forMixing mSwapChain = mDevice.createSwapchainKHR(swapCreateInfo, nullptr); mSwapChainImages = mDevice.getSwapchainImagesKHR(mSwapChain); - unsigned int oldFramesInFlight = mFramesInFlight; + uint32_t oldFramesInFlight = mFramesInFlight; mImageCount = mSwapChainImages.size(); mFramesInFlight = mDisplay->cfg().vulkan.nFramesInFlight == 0 ? mImageCount : mDisplay->cfg().vulkan.nFramesInFlight; mCommandBufferPerImage = mFramesInFlight == mImageCount; @@ -759,7 +759,7 @@ void GPUDisplayBackendVulkan::createSwapChain(bool forScreenshot, bool forMixing } mSwapChainImageViews.resize(mImageCount); - for (unsigned int i = 0; i < mImageCount; i++) { + for (uint32_t i = 0; i < mImageCount; i++) { mSwapChainImageViews[i] = createImageViewI(mDevice, mSwapChainImages[i], mSurfaceFormat.format); } } @@ -774,7 +774,7 @@ void GPUDisplayBackendVulkan::recreateRendering(bool forScreenshot, bool forMixi { mDevice.waitIdle(); bool needUpdateSwapChain = mMustUpdateSwapChain || mDownsampleFactor != getDownsampleFactor(forScreenshot) || mSwapchainImageReadable != forScreenshot; - bool needUpdateOffscreenBuffers = needUpdateSwapChain || mMSAASampleCount != getMSAASamplesFlag(std::min(mMaxMSAAsupported, mDisplay->cfgR().drawQualityMSAA)) || mZActive != (mZSupported && mDisplay->cfgL().depthBuffer) || mMixingSupported != forMixing; + bool needUpdateOffscreenBuffers = needUpdateSwapChain || mMSAASampleCount != getMSAASamplesFlag(std::min(mMaxMSAAsupported, mDisplay->cfgR().drawQualityMSAA)) || mZActive != (mZSupported && mDisplay->cfgL().depthBuffer) || mMixingSupported != forMixing; clearPipeline(); if (needUpdateOffscreenBuffers) { clearOffscreenBuffers(); @@ -792,7 +792,7 @@ void GPUDisplayBackendVulkan::recreateRendering(bool forScreenshot, bool forMixi void GPUDisplayBackendVulkan::createOffscreenBuffers(bool forScreenshot, bool forMixing) { - mMSAASampleCount = getMSAASamplesFlag(std::min(mMaxMSAAsupported, mDisplay->cfgR().drawQualityMSAA)); + mMSAASampleCount = getMSAASamplesFlag(std::min(mMaxMSAAsupported, mDisplay->cfgR().drawQualityMSAA)); mZActive = mZSupported && mDisplay->cfgL().depthBuffer; mMixingSupported = forMixing; @@ -823,7 +823,7 @@ void GPUDisplayBackendVulkan::createOffscreenBuffers(bool forScreenshot, bool fo colorAttachmentResolve.stencilStoreOp = vk::AttachmentStoreOp::eDontCare; colorAttachmentResolve.initialLayout = vk::ImageLayout::eUndefined; colorAttachmentResolve.finalLayout = mDownsampleFSAA ? vk::ImageLayout::eColorAttachmentOptimal : vk::ImageLayout::ePresentSrcKHR; - int nAttachments = 0; + int32_t nAttachments = 0; vk::AttachmentReference colorAttachmentRef{}; colorAttachmentRef.attachment = nAttachments++; colorAttachmentRef.layout = vk::ImageLayout::eColorAttachmentOptimal; @@ -866,7 +866,7 @@ void GPUDisplayBackendVulkan::createOffscreenBuffers(bool forScreenshot, bool fo renderPassInfo.pDependencies = &dependency; mRenderPass = mDevice.createRenderPass(renderPassInfo, nullptr); - const unsigned int imageCountWithMixImages = mImageCount * (mMixingSupported ? 2 : 1); + const uint32_t imageCountWithMixImages = mImageCount * (mMixingSupported ? 2 : 1); mRenderTargetView.resize(imageCountWithMixImages); mFramebuffers.resize(imageCountWithMixImages); if (mDownsampleFSAA) { @@ -919,7 +919,7 @@ void GPUDisplayBackendVulkan::createOffscreenBuffers(bool forScreenshot, bool fo mRenderPassTexture = mDevice.createRenderPass(renderPassInfo, nullptr); } - for (unsigned int i = 0; i < imageCountWithMixImages; i++) { + for (uint32_t i = 0; i < imageCountWithMixImages; i++) { if (i < mImageCount) { // Main render chain // primary buffer mSwapChainImageViews[i] created as part of createSwapChain, not here } else if (!mDownsampleFSAA) { // for rendering to mixBuffer @@ -990,7 +990,7 @@ void GPUDisplayBackendVulkan::createOffscreenBuffers(bool forScreenshot, bool fo mMixingTextureVertexArray = createBuffer(sizeof(vertices), &vertices[0][0], vk::BufferUsageFlagBits::eVertexBuffer, 1); if (mCommandBufferPerImage) { - for (unsigned int i = 0; i < mFramesInFlight; i++) { + for (uint32_t i = 0; i < mFramesInFlight; i++) { setMixDescriptor(i, i); } } @@ -1157,7 +1157,7 @@ void GPUDisplayBackendVulkan::createPipeline() mPipelines.resize(mMixingSupported ? 5 : 4); static constexpr vk::PrimitiveTopology types[3] = {vk::PrimitiveTopology::ePointList, vk::PrimitiveTopology::eLineList, vk::PrimitiveTopology::eLineStrip}; - for (unsigned int i = 0; i < mPipelines.size(); i++) { + for (uint32_t i = 0; i < mPipelines.size(); i++) { if (i == 4) { // Texture rendering bindingDescription.stride = 4 * sizeof(float); attributeDescriptions.format = vk::Format::eR32G32B32A32Sfloat; @@ -1203,7 +1203,7 @@ void GPUDisplayBackendVulkan::createPipeline() } } -void GPUDisplayBackendVulkan::startFillCommandBuffer(vk::CommandBuffer& commandBuffer, unsigned int imageIndex, bool toMixBuffer) +void GPUDisplayBackendVulkan::startFillCommandBuffer(vk::CommandBuffer& commandBuffer, uint32_t imageIndex, bool toMixBuffer) { commandBuffer.reset({}); @@ -1284,7 +1284,7 @@ void GPUDisplayBackendVulkan::writeToBuffer(VulkanBuffer& buffer, size_t size, c } } -GPUDisplayBackendVulkan::VulkanBuffer GPUDisplayBackendVulkan::createBuffer(size_t size, const void* srcData, vk::BufferUsageFlags type, int deviceMemory) +GPUDisplayBackendVulkan::VulkanBuffer GPUDisplayBackendVulkan::createBuffer(size_t size, const void* srcData, vk::BufferUsageFlags type, int32_t deviceMemory) { vk::MemoryPropertyFlags properties; if (deviceMemory) { @@ -1372,7 +1372,7 @@ void GPUDisplayBackendVulkan::writeToImage(VulkanImage& image, const void* srcDa clearBuffer(tmp); } -GPUDisplayBackendVulkan::VulkanImage GPUDisplayBackendVulkan::createImage(unsigned int sizex, unsigned int sizey, const void* srcData, size_t srcSize, vk::Format format) +GPUDisplayBackendVulkan::VulkanImage GPUDisplayBackendVulkan::createImage(uint32_t sizex, uint32_t sizey, const void* srcData, size_t srcSize, vk::Format format) { VulkanImage image; createImageI(mDevice, mPhysicalDevice, image.image, image.memory, sizex, sizey, format, vk::ImageUsageFlagBits::eTransferDst | vk::ImageUsageFlagBits::eSampled, vk::MemoryPropertyFlagBits::eDeviceLocal, vk::ImageTiling::eOptimal, vk::SampleCountFlagBits::e1); @@ -1398,7 +1398,7 @@ void GPUDisplayBackendVulkan::clearImage(VulkanImage& image) // ---------------------------- VULKAN INIT EXIT ---------------------------- -int GPUDisplayBackendVulkan::InitBackendA() +int32_t GPUDisplayBackendVulkan::InitBackendA() { mEnableValidationLayers = mDisplay->param() && mDisplay->param()->par.debugLevel >= 2; mFramesInFlight = 2; @@ -1436,7 +1436,7 @@ void GPUDisplayBackendVulkan::ExitBackendA() // ---------------------------- USER CODE ---------------------------- -void GPUDisplayBackendVulkan::resizeScene(unsigned int width, unsigned int height) +void GPUDisplayBackendVulkan::resizeScene(uint32_t width, uint32_t height) { if (mScreenWidth == width && mScreenHeight == height) { return; @@ -1461,7 +1461,7 @@ void GPUDisplayBackendVulkan::loadDataToGPU(size_t totalVertizes) needRecordCommandBuffers(); } -unsigned int GPUDisplayBackendVulkan::drawVertices(const vboList& v, const drawType tt) +uint32_t GPUDisplayBackendVulkan::drawVertices(const vboList& v, const drawType tt) { auto first = std::get<0>(v); auto count = std::get<1>(v); @@ -1480,7 +1480,7 @@ unsigned int GPUDisplayBackendVulkan::drawVertices(const vboList& v, const drawT if (mDisplay->cfgR().useGLIndirectDraw) { mCurrentCommandBuffer.drawIndirect(mIndirectCommandBuffer.buffer, (mIndirectSliceOffset[iSlice] + first) * sizeof(DrawArraysIndirectCommand), count, sizeof(DrawArraysIndirectCommand)); } else { - for (unsigned int k = 0; k < count; k++) { + for (uint32_t k = 0; k < count; k++) { mCurrentCommandBuffer.draw(mDisplay->vertexBufferCount()[iSlice][first + k], 1, mDisplay->vertexBufferStart()[iSlice][first + k], 0); } } @@ -1777,9 +1777,9 @@ void GPUDisplayBackendVulkan::needRecordCommandBuffers() std::fill(mCommandBufferUpToDate.begin(), mCommandBufferUpToDate.end(), false); } -void GPUDisplayBackendVulkan::addFontSymbol(int symbol, int sizex, int sizey, int offsetx, int offsety, int advance, void* data) +void GPUDisplayBackendVulkan::addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) { - if (symbol != (int)mFontSymbols.size()) { + if (symbol != (int32_t)mFontSymbols.size()) { throw std::runtime_error("Incorrect symbol ID"); } mFontSymbols.emplace_back(FontSymbolVulkan{{{sizex, sizey}, {offsetx, offsety}, advance}, nullptr, 0.f, 0.f, 0.f, 0.f}); @@ -1792,29 +1792,29 @@ void GPUDisplayBackendVulkan::addFontSymbol(int symbol, int sizex, int sizey, in void GPUDisplayBackendVulkan::initializeTextDrawing() { - int maxSizeX = 0, maxSizeY = 0, maxBigX = 0, maxBigY = 0, maxRowY = 0; + int32_t maxSizeX = 0, maxSizeY = 0, maxBigX = 0, maxBigY = 0, maxRowY = 0; bool smooth = smoothFont(); // Build a mega texture containing all fonts for (auto& symbol : mFontSymbols) { maxSizeX = std::max(maxSizeX, symbol.size[0]); maxSizeY = std::max(maxSizeY, symbol.size[1]); } - unsigned int nn = ceil(std::sqrt(mFontSymbols.size())); - int sizex = nn * maxSizeX; - int sizey = nn * maxSizeY; + uint32_t nn = ceil(std::sqrt(mFontSymbols.size())); + int32_t sizex = nn * maxSizeX; + int32_t sizey = nn * maxSizeY; std::unique_ptr bigImage{new char[sizex * sizey]}; memset(bigImage.get(), 0, sizex * sizey); - int rowy = 0, colx = 0; - for (unsigned int i = 0; i < mFontSymbols.size(); i++) { + int32_t rowy = 0, colx = 0; + for (uint32_t i = 0; i < mFontSymbols.size(); i++) { auto& s = mFontSymbols[i]; if (colx + s.size[0] > sizex) { colx = 0; rowy += maxRowY; maxRowY = 0; } - for (int k = 0; k < s.size[1]; k++) { - for (int j = 0; j < s.size[0]; j++) { - char val = s.data.get()[j + k * s.size[0]]; + for (int32_t k = 0; k < s.size[1]; k++) { + for (int32_t j = 0; j < s.size[0]; j++) { + int8_t val = s.data.get()[j + k * s.size[0]]; if (!smooth) { val = val < 0 ? 0xFF : 0; } @@ -1832,13 +1832,13 @@ void GPUDisplayBackendVulkan::initializeTextDrawing() colx += s.size[0]; } if (maxBigX != sizex) { - for (int y = 1; y < maxBigY; y++) { + for (int32_t y = 1; y < maxBigY; y++) { memmove(bigImage.get() + y * maxBigX, bigImage.get() + y * sizex, maxBigX); } } sizex = maxBigX; sizey = maxBigY; - for (unsigned int i = 0; i < mFontSymbols.size(); i++) { + for (uint32_t i = 0; i < mFontSymbols.size(); i++) { auto& s = mFontSymbols[i]; s.x0 /= sizex; s.x1 /= sizex; @@ -1856,7 +1856,7 @@ void GPUDisplayBackendVulkan::updateFontTextureDescriptor() imageInfo.imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal; imageInfo.imageView = mFontImage.view; imageInfo.sampler = mTextureSampler; - for (unsigned int i = 0; i < mFramesInFlight; i++) { + for (uint32_t i = 0; i < mFramesInFlight; i++) { vk::WriteDescriptorSet descriptorWrite{}; descriptorWrite.dstSet = mDescriptorSets[1][i]; descriptorWrite.dstBinding = 2; @@ -1880,8 +1880,8 @@ void GPUDisplayBackendVulkan::OpenGLPrint(const char* s, float x, float y, float } for (const char* c = s; *c; c++) { - if ((int)*c > (int)mFontSymbols.size()) { - GPUError("Trying to draw unsupported symbol: %d > %d\n", (int)*c, (int)mFontSymbols.size()); + if ((int32_t)*c > (int32_t)mFontSymbols.size()) { + GPUError("Trying to draw unsupported symbol: %d > %d\n", (int32_t)*c, (int32_t)mFontSymbols.size()); continue; } const FontSymbolVulkan& sym = mFontSymbols[*c]; @@ -1919,9 +1919,9 @@ void GPUDisplayBackendVulkan::OpenGLPrint(const char* s, float x, float y, float void GPUDisplayBackendVulkan::readImageToPixels(vk::Image image, vk::ImageLayout layout, std::vector& pixels) { - unsigned int width = mScreenWidth * mDisplay->cfgR().screenshotScaleFactor; - unsigned int height = mScreenHeight * mDisplay->cfgR().screenshotScaleFactor; - static constexpr int bytesPerPixel = 4; + uint32_t width = mScreenWidth * mDisplay->cfgR().screenshotScaleFactor; + uint32_t height = mScreenHeight * mDisplay->cfgR().screenshotScaleFactor; + static constexpr int32_t bytesPerPixel = 4; pixels.resize(width * height * bytesPerPixel); vk::Image dstImage, dstImage2, src2; @@ -1932,8 +1932,8 @@ void GPUDisplayBackendVulkan::readImageToPixels(vk::Image image, vk::ImageLayout if (mDisplay->cfgR().screenshotScaleFactor != 1) { createImageI(mDevice, mPhysicalDevice, dstImage2, dstImageMemory2, width, height, mSurfaceFormat.format, vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eTransferSrc | vk::ImageUsageFlagBits::eTransferDst, vk::MemoryPropertyFlagBits::eDeviceLocal, vk::ImageTiling::eOptimal); cmdImageMemoryBarrier(cmdBuffer, dstImage2, {}, vk::AccessFlagBits::eTransferWrite, vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer); - vk::Offset3D blitSizeSrc = {(int)mRenderWidth, (int)mRenderHeight, 1}; - vk::Offset3D blitSizeDst = {(int)width, (int)height, 1}; + vk::Offset3D blitSizeSrc = {(int32_t)mRenderWidth, (int32_t)mRenderHeight, 1}; + vk::Offset3D blitSizeDst = {(int32_t)width, (int32_t)height, 1}; vk::ImageBlit imageBlitRegion{}; imageBlitRegion.srcSubresource.aspectMask = vk::ImageAspectFlagBits::eColor; imageBlitRegion.srcSubresource.layerCount = 1; @@ -1968,7 +1968,7 @@ void GPUDisplayBackendVulkan::readImageToPixels(vk::Image image, vk::ImageLayout const char* data; CHKERR(mDevice.mapMemory(dstImageMemory, 0, VK_WHOLE_SIZE, {}, (void**)&data)); data += subResourceLayout.offset; - for (unsigned int i = 0; i < height; i++) { + for (uint32_t i = 0; i < height; i++) { memcpy(pixels.data() + i * width * bytesPerPixel, data + (height - i - 1) * width * bytesPerPixel, width * bytesPerPixel); } mDevice.unmapMemory(dstImageMemory); @@ -1980,7 +1980,7 @@ void GPUDisplayBackendVulkan::readImageToPixels(vk::Image image, vk::ImageLayout } } -unsigned int GPUDisplayBackendVulkan::DepthBits() +uint32_t GPUDisplayBackendVulkan::DepthBits() { return 32; } diff --git a/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.h b/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.h index 480dd321dbfdb..00310e58dd5a8 100644 --- a/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.h +++ b/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.h @@ -31,7 +31,7 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend GPUDisplayBackendVulkan(); ~GPUDisplayBackendVulkan() override; - unsigned int DepthBits() override; + uint32_t DepthBits() override; protected: struct SwapChainSupportDetails { @@ -43,13 +43,13 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend vk::Buffer buffer; vk::DeviceMemory memory; size_t size = 0; - int deviceMemory; + int32_t deviceMemory; }; struct VulkanImage { vk::Image image; vk::ImageView view; vk::DeviceMemory memory; - unsigned int sizex = 0, sizey = 0; + uint32_t sizex = 0, sizey = 0; vk::Format format; }; struct FontSymbolVulkan : public GPUDisplayBackend::FontSymbol { @@ -62,12 +62,12 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend float color[4]; }; - unsigned int drawVertices(const vboList& v, const drawType t) override; + uint32_t drawVertices(const vboList& v, const drawType t) override; void ActivateColor(std::array& color) override; void SetVSync(bool enable) override { mMustUpdateSwapChain = true; }; void setDepthBuffer() override {}; bool backendNeedRedraw() override; - int InitBackendA() override; + int32_t InitBackendA() override; void ExitBackendA() override; void loadDataToGPU(size_t totalVertizes) override; void prepareDraw(const hmm_mat4& proj, const hmm_mat4& view, bool requestScreenshot, bool toMixBuffer, float includeMixImage) override; @@ -76,25 +76,25 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend void prepareText() override; void finishText() override; void mixImages(vk::CommandBuffer cmdBuffer, float mixSlaveImage); - void setMixDescriptor(int descriptorIndex, int imageIndex); + void setMixDescriptor(int32_t descriptorIndex, int32_t imageIndex); void pointSizeFactor(float factor) override; void lineWidthFactor(float factor) override; - void resizeScene(unsigned int width, unsigned int height) override; + void resizeScene(uint32_t width, uint32_t height) override; float getYFactor() const override { return -1.0f; } - int getMaxMSAA() const override { return mMaxMSAAsupported; } + int32_t getMaxMSAA() const override { return mMaxMSAAsupported; } double checkDevice(vk::PhysicalDevice device, const std::vector& reqDeviceExtensions); vk::Extent2D chooseSwapExtent(const vk::SurfaceCapabilitiesKHR& capabilities); void transitionImageLayout(vk::CommandBuffer commandBuffer, vk::Image image, vk::Format format, vk::ImageLayout oldLayout, vk::ImageLayout newLayout); - VulkanBuffer createBuffer(size_t size, const void* srcData = nullptr, vk::BufferUsageFlags type = vk::BufferUsageFlagBits::eVertexBuffer, int deviceMemory = 1); + VulkanBuffer createBuffer(size_t size, const void* srcData = nullptr, vk::BufferUsageFlags type = vk::BufferUsageFlagBits::eVertexBuffer, int32_t deviceMemory = 1); void writeToBuffer(VulkanBuffer& buffer, size_t size, const void* srcData); void clearBuffer(VulkanBuffer& buffer); - VulkanImage createImage(unsigned int sizex, unsigned int sizey, const void* srcData = nullptr, size_t srcSize = 0, vk::Format format = vk::Format::eR8G8B8A8Srgb); + VulkanImage createImage(uint32_t sizex, uint32_t sizey, const void* srcData = nullptr, size_t srcSize = 0, vk::Format format = vk::Format::eR8G8B8A8Srgb); void writeToImage(VulkanImage& image, const void* srcData, size_t srcSize); void clearImage(VulkanImage& image); void clearVertexBuffers(); - void startFillCommandBuffer(vk::CommandBuffer& commandBuffer, unsigned int imageIndex, bool toMixBuffer = false); + void startFillCommandBuffer(vk::CommandBuffer& commandBuffer, uint32_t imageIndex, bool toMixBuffer = false); void endFillCommandBuffer(vk::CommandBuffer& commandBuffer); vk::CommandBuffer getSingleTimeCommandBuffer(); void submitSingleTimeCommandBuffer(vk::CommandBuffer commandBuffer); @@ -124,11 +124,11 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend void recreateRendering(bool forScreenshot = false, bool forMixing = false); void needRecordCommandBuffers(); - void addFontSymbol(int symbol, int sizex, int sizey, int offsetx, int offsety, int advance, void* data) override; + void addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) override; void initializeTextDrawing() override; void OpenGLPrint(const char* s, float x, float y, float* color, float scale) override; - unsigned int mGraphicsFamily; + uint32_t mGraphicsFamily; SwapChainSupportDetails mSwapChainDetails; bool mEnableValidationLayers = false; @@ -165,13 +165,13 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend bool mCommandBufferPerImage = false; bool mCommandInfrastructureCreated = false; - unsigned int mImageCount = 0; - unsigned int mFramesInFlight = 0; - int mCurrentFrame = 0; + uint32_t mImageCount = 0; + uint32_t mFramesInFlight = 0; + int32_t mCurrentFrame = 0; uint32_t mCurrentImageIndex = 0; - int mCurrentBufferSet = 0; + int32_t mCurrentBufferSet = 0; vk::CommandBuffer mCurrentCommandBuffer; - int mCurrentCommandBufferLastPipeline = -1; + int32_t mCurrentCommandBufferLastPipeline = -1; std::vector mCommandBuffers; std::vector mCommandBuffersDownsample; @@ -205,7 +205,7 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend bool mSwapchainImageReadable = false; vk::SampleCountFlagBits mMSAASampleCount = vk::SampleCountFlagBits::e16; - unsigned int mMaxMSAAsupported = 0; + uint32_t mMaxMSAAsupported = 0; bool mZActive = false; bool mZSupported = false; bool mStencilSupported = false; diff --git a/GPU/GPUTracking/display/filterMacros/TRDCandidate.C b/GPU/GPUTracking/display/filterMacros/TRDCandidate.C index a58558b0b52a0..f00681d0ca335 100644 --- a/GPU/GPUTracking/display/filterMacros/TRDCandidate.C +++ b/GPU/GPUTracking/display/filterMacros/TRDCandidate.C @@ -4,7 +4,7 @@ using namespace o2::gpu; void gpuDisplayTrackFilter(std::vector* filter, const GPUTrackingInOutPointers* ioPtrs, const GPUConstantMem* processors) { - for (unsigned int i = 0; i < filter->size(); i++) { + for (uint32_t i = 0; i < filter->size(); i++) { (*filter)[i] = processors->trdTrackerGPU.PreCheckTrackTRDCandidate(ioPtrs->mergedTracks[i]) && processors->trdTrackerGPU.CheckTrackTRDCandidate((GPUTRDTrackGPU)ioPtrs->mergedTracks[i]); } } diff --git a/GPU/GPUTracking/display/filterMacros/filterGPUTrack.C b/GPU/GPUTracking/display/filterMacros/filterGPUTrack.C index 1c70fbd7768fa..886ed29611553 100644 --- a/GPU/GPUTracking/display/filterMacros/filterGPUTrack.C +++ b/GPU/GPUTracking/display/filterMacros/filterGPUTrack.C @@ -10,7 +10,7 @@ using namespace o2::gpu; void gpuDisplayTrackFilter(std::vector* filter, const GPUTrackingInOutPointers* ioPtrs, const GPUConstantMem* processors) { - for (unsigned int i = 0; i < filter->size(); i++) { + for (uint32_t i = 0; i < filter->size(); i++) { auto& trk = ioPtrs->mergedTracks[i]; (*filter)[i] = fabsf(trk.GetParam().GetQPt()) < 1.0f; } diff --git a/GPU/GPUTracking/display/filterMacros/filterTPCTrack.C b/GPU/GPUTracking/display/filterMacros/filterTPCTrack.C index b2d161d967f2f..636cdd0319011 100644 --- a/GPU/GPUTracking/display/filterMacros/filterTPCTrack.C +++ b/GPU/GPUTracking/display/filterMacros/filterTPCTrack.C @@ -12,7 +12,7 @@ using namespace o2::gpu; void gpuDisplayTrackFilter(std::vector* filter, const GPUTrackingInOutPointers* ioPtrs, const GPUConstantMem* processors) { - for (unsigned int i = 0; i < filter->size(); i++) { + for (uint32_t i = 0; i < filter->size(); i++) { auto& trk = ioPtrs->outputTracksTPCO2[i]; (*filter)[i] = fabsf(trk.getQ2Pt()) < 1.0f; } diff --git a/GPU/GPUTracking/display/filterMacros/hasTRD.C b/GPU/GPUTracking/display/filterMacros/hasTRD.C index 355fd213c57fd..cd98fb2fe349b 100644 --- a/GPU/GPUTracking/display/filterMacros/hasTRD.C +++ b/GPU/GPUTracking/display/filterMacros/hasTRD.C @@ -6,7 +6,7 @@ void gpuDisplayTrackFilter(std::vector* filter, const GPUTrackingInOutPoin if (!ioPtrs->tpcLinkTRD) { return; } - for (unsigned int i = 0; i < filter->size(); i++) { + for (uint32_t i = 0; i < filter->size(); i++) { (*filter)[i] = ioPtrs->tpcLinkTRD[i] != -1; } } diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx index 437ff654fe9d8..b48d5b994fcf8 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx @@ -48,7 +48,7 @@ GPUDisplayFrontend::~GPUDisplayFrontend() = default; void* GPUDisplayFrontend::FrontendThreadWrapper(void* ptr) { GPUDisplayFrontend* me = reinterpret_cast(ptr); - int retVal = me->FrontendMain(); + int32_t retVal = me->FrontendMain(); if (retVal == -1) { me->InitDisplay(true); } @@ -63,15 +63,15 @@ void GPUDisplayFrontend::HandleSendKey() } } -void GPUDisplayFrontend::HandleKey(unsigned char key) { mDisplay->HandleKey(key); } -int GPUDisplayFrontend::DrawGLScene() { return mDisplay->DrawGLScene(); } -void GPUDisplayFrontend::ResizeScene(int width, int height) +void GPUDisplayFrontend::HandleKey(uint8_t key) { mDisplay->HandleKey(key); } +int32_t GPUDisplayFrontend::DrawGLScene() { return mDisplay->DrawGLScene(); } +void GPUDisplayFrontend::ResizeScene(int32_t width, int32_t height) { mDisplayHeight = height; mDisplayWidth = width; mDisplay->ResizeScene(width, height); } -int GPUDisplayFrontend::InitDisplay(bool initFailure) { return mDisplay->InitDisplay(initFailure); } +int32_t GPUDisplayFrontend::InitDisplay(bool initFailure) { return mDisplay->InitDisplay(initFailure); } void GPUDisplayFrontend::ExitDisplay() { mDisplay->ExitDisplay(); @@ -89,9 +89,9 @@ void GPUDisplayFrontend::stopGUI() #endif } -int GPUDisplayFrontend::startGUI() +int32_t GPUDisplayFrontend::startGUI() { - int retVal = 1; + int32_t retVal = 1; #ifdef GPUCA_BUILD_EVENT_DISPLAY_QT if (!mGUI) { mGUI.reset(new GPUDisplayGUIWrapper); @@ -122,7 +122,7 @@ GPUDisplayFrontend* GPUDisplayFrontend::getFrontend(const char* type) } else #endif #ifdef _WIN32 - if (strcmp(type, "windows") == 0 || strcmp(type, "auto") == 0) { + if (strcmp(type, "windows") == 0 || strcmp(type, "auto") == 0) { return new GPUDisplayFrontendWindows; } else #elif defined(GPUCA_BUILD_EVENT_DISPLAY_X11) @@ -131,17 +131,17 @@ GPUDisplayFrontend* GPUDisplayFrontend::getFrontend(const char* type) } else #endif #if defined(GPUCA_STANDALONE) && defined(GPUCA_BUILD_EVENT_DISPLAY_GLFW) - if (strcmp(type, "glfw") == 0 || strcmp(type, "auto") == 0) { + if (strcmp(type, "glfw") == 0 || strcmp(type, "auto") == 0) { return new GPUDisplayFrontendGlfw; } else #endif #ifdef GPUCA_BUILD_EVENT_DISPLAY_WAYLAND - if (strcmp(type, "wayland") == 0 || (strcmp(type, "auto") == 0 && getenv("XDG_SESSION_TYPE") && strcmp(getenv("XDG_SESSION_TYPE"), "wayland") == 0)) { + if (strcmp(type, "wayland") == 0 || (strcmp(type, "auto") == 0 && getenv("XDG_SESSION_TYPE") && strcmp(getenv("XDG_SESSION_TYPE"), "wayland") == 0)) { return new GPUDisplayFrontendWayland; } else #endif #ifdef GPUCA_BUILD_EVENT_DISPLAY_GLUT - if (strcmp(type, "glut") == 0 || strcmp(type, "auto") == 0) { + if (strcmp(type, "glut") == 0 || strcmp(type, "auto") == 0) { return new GPUDisplayFrontendGlut; } else #endif @@ -156,7 +156,7 @@ GPUDisplayBackend* GPUDisplayFrontend::backend() return mDisplay->backend(); } -int& GPUDisplayFrontend::drawTextFontSize() +int32_t& GPUDisplayFrontend::drawTextFontSize() { return mDisplay->drawTextFontSize(); } diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.h index c1e41eac81bb7..1c459d77beee9 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.h @@ -44,10 +44,10 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface }; // Compile time minimum version defined in GPUDisplay.h, keep in sync! - static constexpr int GL_MIN_VERSION_MAJOR = 4; - static constexpr int GL_MIN_VERSION_MINOR = 5; + static constexpr int32_t GL_MIN_VERSION_MAJOR = 4; + static constexpr int32_t GL_MIN_VERSION_MINOR = 5; - virtual int StartDisplay() = 0; // Start the display. This function returns, and should spawn a thread that runs the display, and calls InitDisplay + virtual int32_t StartDisplay() = 0; // Start the display. This function returns, and should spawn a thread that runs the display, and calls InitDisplay void DisplayExit() override = 0; // Stop the display. Display thread should call ExitDisplay and the function returns after the thread has terminated virtual void SwitchFullscreen(bool set) = 0; // Toggle full-screen mode virtual void ToggleMaximized(bool set) = 0; // Maximize window @@ -56,79 +56,79 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface virtual void OpenGLPrint(const char* s, float x, float y, float r, float g, float b, float a, bool fromBotton = true) = 0; // Print text on the display (needs the backend to build the font) GPUDisplayBackend* backend(); static GPUDisplayFrontend* getFrontend(const char* type); - virtual void getSize(int& width, int& height) { width = height = 0; } - virtual int getVulkanSurface(void* instance, void* surface) { return 1; } - virtual unsigned int getReqVulkanExtensions(const char**& p) { return 0; }; + virtual void getSize(int32_t& width, int32_t& height) { width = height = 0; } + virtual int32_t getVulkanSurface(void* instance, void* surface) { return 1; } + virtual uint32_t getReqVulkanExtensions(const char**& p) { return 0; }; - int getDisplayControl() const override { return mDisplayControl; } - int getSendKey() const override { return mSendKey; } - int getNeedUpdate() const override { return mNeedUpdate; } - void setDisplayControl(int v) override { mDisplayControl = v; } - void setSendKey(int v) override { mSendKey = v; } - void setNeedUpdate(int v) override { mNeedUpdate = v; } + int32_t getDisplayControl() const override { return mDisplayControl; } + int32_t getSendKey() const override { return mSendKey; } + int32_t getNeedUpdate() const override { return mNeedUpdate; } + void setDisplayControl(int32_t v) override { mDisplayControl = v; } + void setSendKey(int32_t v) override { mSendKey = v; } + void setNeedUpdate(int32_t v) override { mNeedUpdate = v; } frontendTypes frontendType() const { return mFrontendType; } const char* frontendName() const override { return mFrontendName; } - int startGUI(); + int32_t startGUI(); void stopGUI(); bool isGUIRunning(); // volatile variables to exchange control informations between display and backend - volatile int mDisplayControl = 0; // Control for next event (=1) or quit (=2) - volatile int mSendKey = 0; // Key sent by external entity (usually console), may be ignored by backend. - volatile int mNeedUpdate = 0; // flag that backend shall update the GL window, and call DrawGLScene + volatile int32_t mDisplayControl = 0; // Control for next event (=1) or quit (=2) + volatile int32_t mSendKey = 0; // Key sent by external entity (usually console), may be ignored by backend. + volatile int32_t mNeedUpdate = 0; // flag that backend shall update the GL window, and call DrawGLScene protected: - virtual int FrontendMain() = 0; + virtual int32_t FrontendMain() = 0; static void* FrontendThreadWrapper(void*); - static constexpr int INIT_WIDTH = 1024, INIT_HEIGHT = 768; // Initial window size, before maximizing + static constexpr int32_t INIT_WIDTH = 1024, INIT_HEIGHT = 768; // Initial window size, before maximizing static constexpr const char* DISPLAY_WINDOW_NAME = "GPU CA Standalone Event Display"; // Title of event display set by backend // Constant key codes for special mKeys (to unify different treatment in X11 / Windows / GLUT / etc.) - static constexpr int KEY_UP = 1; - static constexpr int KEY_DOWN = 2; - static constexpr int KEY_LEFT = 3; - static constexpr int KEY_RIGHT = 4; - static constexpr int KEY_PAGEUP = 5; - static constexpr int KEY_PAGEDOWN = 6; - static constexpr int KEY_SHIFT = 8; - static constexpr int KEY_ALT = 9; - static constexpr int KEY_RALT = 10; - static constexpr int KEY_CTRL = 11; - static constexpr int KEY_RCTRL = 12; - static constexpr int KEY_ENTER = 13; // fixed at 13 - static constexpr int KEY_F1 = 14; - static constexpr int KEY_F2 = 15; - static constexpr int KEY_F3 = 26; - static constexpr int KEY_F4 = 17; - static constexpr int KEY_F5 = 18; - static constexpr int KEY_F6 = 19; - static constexpr int KEY_F7 = 20; - static constexpr int KEY_F8 = 21; - static constexpr int KEY_F9 = 22; - static constexpr int KEY_F10 = 23; - static constexpr int KEY_F11 = 24; - static constexpr int KEY_F12 = 25; - static constexpr int KEY_INSERT = 26; - static constexpr int KEY_ESCAPE = 27; // fixed at 27 - static constexpr int KEY_HOME = 28; - static constexpr int KEY_END = 29; - static constexpr int KEY_SPACE = 32; // fixed at 32 + static constexpr int32_t KEY_UP = 1; + static constexpr int32_t KEY_DOWN = 2; + static constexpr int32_t KEY_LEFT = 3; + static constexpr int32_t KEY_RIGHT = 4; + static constexpr int32_t KEY_PAGEUP = 5; + static constexpr int32_t KEY_PAGEDOWN = 6; + static constexpr int32_t KEY_SHIFT = 8; + static constexpr int32_t KEY_ALT = 9; + static constexpr int32_t KEY_RALT = 10; + static constexpr int32_t KEY_CTRL = 11; + static constexpr int32_t KEY_RCTRL = 12; + static constexpr int32_t KEY_ENTER = 13; // fixed at 13 + static constexpr int32_t KEY_F1 = 14; + static constexpr int32_t KEY_F2 = 15; + static constexpr int32_t KEY_F3 = 26; + static constexpr int32_t KEY_F4 = 17; + static constexpr int32_t KEY_F5 = 18; + static constexpr int32_t KEY_F6 = 19; + static constexpr int32_t KEY_F7 = 20; + static constexpr int32_t KEY_F8 = 21; + static constexpr int32_t KEY_F9 = 22; + static constexpr int32_t KEY_F10 = 23; + static constexpr int32_t KEY_F11 = 24; + static constexpr int32_t KEY_F12 = 25; + static constexpr int32_t KEY_INSERT = 26; + static constexpr int32_t KEY_ESCAPE = 27; // fixed at 27 + static constexpr int32_t KEY_HOME = 28; + static constexpr int32_t KEY_END = 29; + static constexpr int32_t KEY_SPACE = 32; // fixed at 32 // Keyboard / Mouse actions bool mMouseDn = false; // Mouse button down bool mMouseDnR = false; // Right mouse button down float mMouseDnX, mMouseDnY; // X/Y position where mouse button was pressed float mMouseMvX, mMouseMvY; // Current mouse pointer position - int mMouseWheel = 0; // Incremental value of mouse wheel, ca +/- 100 per wheel tick + int32_t mMouseWheel = 0; // Incremental value of mouse wheel, ca +/- 100 per wheel tick bool mKeys[256] = {false}; // Array of mKeys currently pressed bool mKeysShift[256] = {false}; // Array whether shift was held during key-press - int mDisplayHeight = INIT_HEIGHT; - int mDisplayWidth = INIT_WIDTH; - int mCanDrawText = 0; // 1 = in compat mode, 2 = with shader + int32_t mDisplayHeight = INIT_HEIGHT; + int32_t mDisplayWidth = INIT_WIDTH; + int32_t mCanDrawText = 0; // 1 = in compat mode, 2 = with shader - int mMaxFPSRate = 0; // run at highest possible frame rate, do not sleep in between frames + int32_t mMaxFPSRate = 0; // run at highest possible frame rate, do not sleep in between frames GPUDisplay* mDisplay = nullptr; // Ptr to display, not owning, set by display when it connects to backend GPUDisplayBackend* mBackend = nullptr; // Ptr to backend, not owning @@ -138,13 +138,13 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface std::unique_ptr mGUI; - void HandleKey(unsigned char key); // Callback for handling key presses - int DrawGLScene(); // Callback to draw the GL scene + void HandleKey(uint8_t key); // Callback for handling key presses + int32_t DrawGLScene(); // Callback to draw the GL scene void HandleSendKey(); // Optional callback to handle key press from external source (e.g. stdin by default) - void ResizeScene(int width, int height); // Callback when GL window is resized - int InitDisplay(bool initFailure = false); // Callback to initialize the GL Display (to be called in StartDisplay) + void ResizeScene(int32_t width, int32_t height); // Callback when GL window is resized + int32_t InitDisplay(bool initFailure = false); // Callback to initialize the GL Display (to be called in StartDisplay) void ExitDisplay(); // Callback to clean up the GL Display - int& drawTextFontSize(); + int32_t& drawTextFontSize(); }; } // namespace GPUCA_NAMESPACE::gpu diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.cxx index 1644bb23d5b94..d9cfbedf3ba53 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.cxx @@ -22,7 +22,7 @@ #endif #if defined(GPUCA_O2_LIB) && !defined(GPUCA_DISPLAY_GL3W) // Hack: we have to define this in order to initialize gl3w, cannot include the header as it clashes with glew -extern "C" int gl3wInit(); +extern "C" int32_t gl3wInit(); #endif #ifdef GPUCA_BUILD_EVENT_DISPLAY_VULKAN @@ -56,7 +56,7 @@ GPUDisplayFrontendGlfw::GPUDisplayFrontendGlfw() static GPUDisplayFrontendGlfw* me = nullptr; -int GPUDisplayFrontendGlfw::GetKey(int key) +int32_t GPUDisplayFrontendGlfw::GetKey(int32_t key) { if (key == GLFW_KEY_KP_SUBTRACT) { return ('-'); @@ -154,31 +154,31 @@ int GPUDisplayFrontendGlfw::GetKey(int key) return (0); } -void GPUDisplayFrontendGlfw::GetKey(int key, int scancode, int mods, int& keyOut, int& keyPressOut) +void GPUDisplayFrontendGlfw::GetKey(int32_t key, int32_t scancode, int32_t mods, int32_t& keyOut, int32_t& keyPressOut) { - int specialKey = GetKey(key); + int32_t specialKey = GetKey(key); const char* str = glfwGetKeyName(key, scancode); char localeKey = str ? str[0] : 0; if ((mods & GLFW_MOD_SHIFT) && localeKey >= 'a' && localeKey <= 'z') { localeKey += 'A' - 'a'; } - // GPUInfo("Key: key %d (%c) scancode %d -> %d (%c) special %d (%c)", key, (char)key, scancode, (int)localeKey, localeKey, specialKey, (char)specialKey); + // GPUInfo("Key: key %d (%c) scancode %d -> %d (%c) special %d (%c)", key, (char)key, scancode, (int32_t)localeKey, localeKey, specialKey, (char)specialKey); if (specialKey) { keyOut = keyPressOut = specialKey; } else { - keyOut = keyPressOut = (unsigned char)localeKey; + keyOut = keyPressOut = (uint8_t)localeKey; if (keyPressOut >= 'a' && keyPressOut <= 'z') { keyPressOut += 'A' - 'a'; } } } -void GPUDisplayFrontendGlfw::error_callback(int error, const char* description) { fprintf(stderr, "Error: %s\n", description); } +void GPUDisplayFrontendGlfw::error_callback(int32_t error, const char* description) { fprintf(stderr, "Error: %s\n", description); } -void GPUDisplayFrontendGlfw::key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) +void GPUDisplayFrontendGlfw::key_callback(GLFWwindow* window, int32_t key, int32_t scancode, int32_t action, int32_t mods) { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(key, scancode, mods, handleKey, keyPress); if (handleKey < 32) { if (action == GLFW_PRESS) { @@ -193,27 +193,29 @@ void GPUDisplayFrontendGlfw::key_callback(GLFWwindow* window, int key, int scanc if (action == GLFW_PRESS) { me->mLastKeyDown = handleKey; } else if (action == GLFW_RELEASE) { - keyPress = (unsigned char)me->mKeyDownMap[handleKey]; + keyPress = (uint8_t)me->mKeyDownMap[handleKey]; me->mKeys[keyPress] = false; me->mKeysShift[keyPress] = false; } } } -void GPUDisplayFrontendGlfw::char_callback(GLFWwindow* window, unsigned int codepoint) +void GPUDisplayFrontendGlfw::char_callback(GLFWwindow* window, uint32_t codepoint) { - // GPUInfo("Key (char callback): %d %c - key: %d", codepoint, (char)codepoint, (int)me->mLastKeyDown); - int keyPress = codepoint; - if (keyPress >= 'a' && keyPress <= 'z') { - keyPress += 'A' - 'a'; - } - me->mKeyDownMap[me->mLastKeyDown] = keyPress; - me->mKeys[keyPress] = true; - me->mKeysShift[keyPress] = me->mKeys[KEY_SHIFT]; - me->HandleKey(codepoint); + // GPUInfo("Key (char callback): %d %c - key: %d", codepoint, (char)codepoint, (int32_t)me->mLastKeyDown); + if (codepoint < 256) { + uint8_t keyPress = codepoint; + if (keyPress >= 'a' && keyPress <= 'z') { + keyPress += 'A' - 'a'; + } + me->mKeyDownMap[me->mLastKeyDown] = keyPress; + me->mKeys[keyPress] = true; + me->mKeysShift[keyPress] = me->mKeys[KEY_SHIFT]; + me->HandleKey(codepoint); + } } -void GPUDisplayFrontendGlfw::mouseButton_callback(GLFWwindow* window, int button, int action, int mods) +void GPUDisplayFrontendGlfw::mouseButton_callback(GLFWwindow* window, int32_t button, int32_t action, int32_t mods) { if (action == GLFW_PRESS) { if (button == 0) { @@ -240,7 +242,7 @@ void GPUDisplayFrontendGlfw::cursorPos_callback(GLFWwindow* window, double x, do me->mMouseMvY = y; } -void GPUDisplayFrontendGlfw::resize_callback(GLFWwindow* window, int width, int height) { me->ResizeScene(width, height); } +void GPUDisplayFrontendGlfw::resize_callback(GLFWwindow* window, int32_t width, int32_t height) { me->ResizeScene(width, height); } #ifdef GPUCA_O2_LIB void GPUDisplayFrontendGlfw::DisplayLoop() @@ -254,7 +256,7 @@ void GPUDisplayFrontendGlfw::DisplayLoop() } #endif -int GPUDisplayFrontendGlfw::FrontendMain() +int32_t GPUDisplayFrontendGlfw::FrontendMain() { me = this; @@ -392,7 +394,7 @@ void GPUDisplayFrontendGlfw::OpenGLPrint(const char* s, float x, float y, float void GPUDisplayFrontendGlfw::SwitchFullscreen(bool set) { - GPUInfo("Setting Full Screen %d", (int)set); + GPUInfo("Setting Full Screen %d", (int32_t)set); if (set) { glfwGetWindowPos(mWindow, &mWindowX, &mWindowY); glfwGetWindowSize(mWindow, &mWindowWidth, &mWindowHeight); @@ -415,7 +417,7 @@ void GPUDisplayFrontendGlfw::ToggleMaximized(bool set) void GPUDisplayFrontendGlfw::SetVSync(bool enable) { glfwSwapInterval(enable); } -int GPUDisplayFrontendGlfw::StartDisplay() +int32_t GPUDisplayFrontendGlfw::StartDisplay() { static pthread_t hThread; if (pthread_create(&hThread, nullptr, FrontendThreadWrapper, this)) { @@ -434,12 +436,12 @@ bool GPUDisplayFrontendGlfw::EnableSendKey() #endif } -void GPUDisplayFrontendGlfw::getSize(int& width, int& height) +void GPUDisplayFrontendGlfw::getSize(int32_t& width, int32_t& height) { glfwGetFramebufferSize(mWindow, &width, &height); } -int GPUDisplayFrontendGlfw::getVulkanSurface(void* instance, void* surface) +int32_t GPUDisplayFrontendGlfw::getVulkanSurface(void* instance, void* surface) { #ifdef GPUCA_BUILD_EVENT_DISPLAY_VULKAN return glfwCreateWindowSurface(*(VkInstance*)instance, mWindow, nullptr, (VkSurfaceKHR*)surface) != VK_SUCCESS; @@ -448,7 +450,7 @@ int GPUDisplayFrontendGlfw::getVulkanSurface(void* instance, void* surface) #endif } -unsigned int GPUDisplayFrontendGlfw::getReqVulkanExtensions(const char**& p) +uint32_t GPUDisplayFrontendGlfw::getReqVulkanExtensions(const char**& p) { uint32_t glfwExtensionCount = 0; #ifdef GPUCA_BUILD_EVENT_DISPLAY_VULKAN diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.h index 5f2bd26ed9375..792abcf64b839 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.h @@ -28,41 +28,41 @@ class GPUDisplayFrontendGlfw : public GPUDisplayFrontend GPUDisplayFrontendGlfw(); ~GPUDisplayFrontendGlfw() override = default; - int StartDisplay() override; + int32_t StartDisplay() override; void DisplayExit() override; void SwitchFullscreen(bool set) override; void ToggleMaximized(bool set) override; void SetVSync(bool enable) override; void OpenGLPrint(const char* s, float x, float y, float r, float g, float b, float a, bool fromBotton = true) override; bool EnableSendKey() override; - void getSize(int& width, int& height) override; - int getVulkanSurface(void* instance, void* surface) override; - unsigned int getReqVulkanExtensions(const char**& p) override; + void getSize(int32_t& width, int32_t& height) override; + int32_t getVulkanSurface(void* instance, void* surface) override; + uint32_t getReqVulkanExtensions(const char**& p) override; private: - int FrontendMain() override; + int32_t FrontendMain() override; static void DisplayLoop(); - static void error_callback(int error, const char* description); - static void key_callback(GLFWwindow* mWindow, int key, int scancode, int action, int mods); - static void char_callback(GLFWwindow* window, unsigned int codepoint); - static void mouseButton_callback(GLFWwindow* mWindow, int button, int action, int mods); + static void error_callback(int32_t error, const char* description); + static void key_callback(GLFWwindow* mWindow, int32_t key, int32_t scancode, int32_t action, int32_t mods); + static void char_callback(GLFWwindow* window, uint32_t codepoint); + static void mouseButton_callback(GLFWwindow* mWindow, int32_t button, int32_t action, int32_t mods); static void scroll_callback(GLFWwindow* mWindow, double x, double y); static void cursorPos_callback(GLFWwindow* mWindow, double x, double y); - static void resize_callback(GLFWwindow* mWindow, int width, int height); - static int GetKey(int key); - static void GetKey(int keyin, int scancode, int mods, int& keyOut, int& keyPressOut); + static void resize_callback(GLFWwindow* mWindow, int32_t width, int32_t height); + static int32_t GetKey(int32_t key); + static void GetKey(int32_t keyin, int32_t scancode, int32_t mods, int32_t& keyOut, int32_t& keyPressOut); GLFWwindow* mWindow; volatile bool mGlfwRunning = false; pthread_mutex_t mSemLockExit = PTHREAD_MUTEX_INITIALIZER; - int mWindowX = 0; - int mWindowY = 0; - int mWindowWidth = INIT_WIDTH; - int mWindowHeight = INIT_HEIGHT; - char mKeyDownMap[256] = {0}; - unsigned char mLastKeyDown = 0; + int32_t mWindowX = 0; + int32_t mWindowY = 0; + int32_t mWindowWidth = INIT_WIDTH; + int32_t mWindowHeight = INIT_HEIGHT; + uint8_t mKeyDownMap[256] = {0}; + uint8_t mLastKeyDown = 0; bool mUseIMGui = false; }; } // namespace GPUCA_NAMESPACE::gpu diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.cxx index a165e51840e0c..ab435586820e8 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.cxx @@ -44,7 +44,7 @@ void GPUDisplayFrontendGlut::glutLoopFunc() displayFunc(); } -int GPUDisplayFrontendGlut::GetKey(int key) +int32_t GPUDisplayFrontendGlut::GetKey(int32_t key) { if (key == GLUT_KEY_UP) { return KEY_UP; @@ -125,10 +125,10 @@ int GPUDisplayFrontendGlut::GetKey(int key) return (0); } -void GPUDisplayFrontendGlut::GetKey(int key, int& keyOut, int& keyPressOut, bool special) +void GPUDisplayFrontendGlut::GetKey(int32_t key, int32_t& keyOut, int32_t& keyPressOut, bool special) { - int specialKey = special ? GetKey(key) : 0; - // GPUInfo("Key: key %d (%c) (special %d) -> %d (%c) special %d (%c)", key, (char) key, (int) special, (int) key, key, specialKey, (char) specialKey); + int32_t specialKey = special ? GetKey(key) : 0; + // GPUInfo("Key: key %d (%c) (special %d) -> %d (%c) special %d (%c)", key, (char) key, (int32_t) special, (int32_t) key, key, specialKey, (char) specialKey); if (specialKey) { keyOut = keyPressOut = specialKey; @@ -140,41 +140,41 @@ void GPUDisplayFrontendGlut::GetKey(int key, int& keyOut, int& keyPressOut, bool } } -void GPUDisplayFrontendGlut::keyboardDownFunc(unsigned char key, int x, int y) +void GPUDisplayFrontendGlut::keyboardDownFunc(uint8_t key, int32_t x, int32_t y) { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(key, handleKey, keyPress, false); me->mKeysShift[keyPress] = glutGetModifiers() & GLUT_ACTIVE_SHIFT; me->mKeys[keyPress] = true; me->HandleKey(handleKey); } -void GPUDisplayFrontendGlut::keyboardUpFunc(unsigned char key, int x, int y) +void GPUDisplayFrontendGlut::keyboardUpFunc(uint8_t key, int32_t x, int32_t y) { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(key, handleKey, keyPress, false); me->mKeys[keyPress] = false; me->mKeysShift[keyPress] = false; } -void GPUDisplayFrontendGlut::specialDownFunc(int key, int x, int y) +void GPUDisplayFrontendGlut::specialDownFunc(int32_t key, int32_t x, int32_t y) { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(key, handleKey, keyPress, true); me->mKeysShift[keyPress] = glutGetModifiers() & GLUT_ACTIVE_SHIFT; me->mKeys[keyPress] = true; me->HandleKey(handleKey); } -void GPUDisplayFrontendGlut::specialUpFunc(int key, int x, int y) +void GPUDisplayFrontendGlut::specialUpFunc(int32_t key, int32_t x, int32_t y) { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(key, handleKey, keyPress, true); me->mKeys[keyPress] = false; me->mKeysShift[keyPress] = false; } -void GPUDisplayFrontendGlut::ResizeSceneWrapper(int width, int height) +void GPUDisplayFrontendGlut::ResizeSceneWrapper(int32_t width, int32_t height) { if (!me->mFullScreen) { me->mWidth = width; @@ -183,7 +183,7 @@ void GPUDisplayFrontendGlut::ResizeSceneWrapper(int width, int height) me->ResizeScene(width, height); } -void GPUDisplayFrontendGlut::mouseFunc(int button, int state, int x, int y) +void GPUDisplayFrontendGlut::mouseFunc(int32_t button, int32_t state, int32_t x, int32_t y) { if (button == 3) { me->mMouseWheel += 100; @@ -206,15 +206,15 @@ void GPUDisplayFrontendGlut::mouseFunc(int button, int state, int x, int y) } } -void GPUDisplayFrontendGlut::mouseMoveFunc(int x, int y) +void GPUDisplayFrontendGlut::mouseMoveFunc(int32_t x, int32_t y) { me->mMouseMvX = x; me->mMouseMvY = y; } -void GPUDisplayFrontendGlut::mMouseWheelFunc(int button, int dir, int x, int y) { me->mMouseWheel += dir; } +void GPUDisplayFrontendGlut::mMouseWheelFunc(int32_t button, int32_t dir, int32_t x, int32_t y) { me->mMouseWheel += dir; } -int GPUDisplayFrontendGlut::FrontendMain() +int32_t GPUDisplayFrontendGlut::FrontendMain() { if (backend()->backendType() != GPUDisplayBackend::TYPE_OPENGL) { fprintf(stderr, "Only OpenGL backend supported\n"); @@ -226,7 +226,7 @@ int GPUDisplayFrontendGlut::FrontendMain() drawTextFontSize() = 12; } - int nopts = 2; + int32_t nopts = 2; char opt1[] = "progname"; char opt2[] = "-direct"; char* opts[] = {opt1, opt2}; @@ -293,7 +293,7 @@ void GPUDisplayFrontendGlut::OpenGLPrint(const char* s, float x, float y, float } glColor4f(r, g, b, a); glRasterPos2f(x, y); - glutBitmapString(GLUT_BITMAP_HELVETICA_12, (const unsigned char*)s); + glutBitmapString(GLUT_BITMAP_HELVETICA_12, (const uint8_t*)s); #endif } @@ -310,7 +310,7 @@ void GPUDisplayFrontendGlut::SwitchFullscreen(bool set) void GPUDisplayFrontendGlut::ToggleMaximized(bool set) {} void GPUDisplayFrontendGlut::SetVSync(bool enable) {} -int GPUDisplayFrontendGlut::StartDisplay() +int32_t GPUDisplayFrontendGlut::StartDisplay() { static pthread_t hThread; if (pthread_create(&hThread, nullptr, FrontendThreadWrapper, this)) { diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.h index 90d69a48ef79f..71d7d17c935c8 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.h @@ -26,7 +26,7 @@ class GPUDisplayFrontendGlut : public GPUDisplayFrontend GPUDisplayFrontendGlut(); ~GPUDisplayFrontendGlut() override = default; - int StartDisplay() override; + int32_t StartDisplay() override; void DisplayExit() override; void SwitchFullscreen(bool set) override; void ToggleMaximized(bool set) override; @@ -34,26 +34,26 @@ class GPUDisplayFrontendGlut : public GPUDisplayFrontend void OpenGLPrint(const char* s, float x, float y, float r, float g, float b, float a, bool fromBotton = true) override; private: - int FrontendMain() override; + int32_t FrontendMain() override; static void displayFunc(); static void glutLoopFunc(); - static void keyboardUpFunc(unsigned char key, int x, int y); - static void keyboardDownFunc(unsigned char key, int x, int y); - static void specialUpFunc(int key, int x, int y); - static void specialDownFunc(int key, int x, int y); - static void mouseMoveFunc(int x, int y); - static void mMouseWheelFunc(int button, int dir, int x, int y); - static void mouseFunc(int button, int state, int x, int y); - static void ResizeSceneWrapper(int width, int height); - static int GetKey(int key); - static void GetKey(int keyin, int& keyOut, int& keyPressOut, bool special); + static void keyboardUpFunc(uint8_t key, int32_t x, int32_t y); + static void keyboardDownFunc(uint8_t key, int32_t x, int32_t y); + static void specialUpFunc(int32_t key, int32_t x, int32_t y); + static void specialDownFunc(int32_t key, int32_t x, int32_t y); + static void mouseMoveFunc(int32_t x, int32_t y); + static void mMouseWheelFunc(int32_t button, int32_t dir, int32_t x, int32_t y); + static void mouseFunc(int32_t button, int32_t state, int32_t x, int32_t y); + static void ResizeSceneWrapper(int32_t width, int32_t height); + static int32_t GetKey(int32_t key); + static void GetKey(int32_t keyin, int32_t& keyOut, int32_t& keyPressOut, bool special); volatile bool mGlutRunning = false; pthread_mutex_t mSemLockExit = PTHREAD_MUTEX_INITIALIZER; - int mWidth = INIT_WIDTH; - int mHeight = INIT_HEIGHT; + int32_t mWidth = INIT_WIDTH; + int32_t mHeight = INIT_HEIGHT; bool mFullScreen = false; }; } // namespace GPUCA_NAMESPACE::gpu diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendNone.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendNone.h index 6eebbf2c9c168..c95927c6655b9 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendNone.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendNone.h @@ -24,7 +24,7 @@ class GPUDisplayFrontendNone : public GPUDisplayFrontend GPUDisplayFrontendNone() = default; ~GPUDisplayFrontendNone() override = default; - int StartDisplay() override { return 1; } + int32_t StartDisplay() override { return 1; } void DisplayExit() override {} void SwitchFullscreen(bool set) override {} void ToggleMaximized(bool set) override {} diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.cxx index 6c85336f9791a..b920259a1e70d 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.cxx @@ -59,9 +59,9 @@ struct CCallWrapper { } }; -int GPUDisplayFrontendWayland::GetKey(unsigned int key, unsigned int state) +int32_t GPUDisplayFrontendWayland::GetKey(uint32_t key, uint32_t state) { - int retVal = 0; + int32_t retVal = 0; if (mXKBkeymap) { xkb_keysym_t sym = xkb_state_key_get_one_sym(mXKBstate, key + 8); if (sym == 65453) { @@ -138,10 +138,10 @@ int GPUDisplayFrontendWayland::GetKey(unsigned int key, unsigned int state) return retVal; } -void GPUDisplayFrontendWayland::createBuffer(unsigned int width, unsigned int height) +void GPUDisplayFrontendWayland::createBuffer(uint32_t width, uint32_t height) { - const unsigned int stride = width * 4; - const unsigned int size = stride * height; + const uint32_t stride = width * 4; + const uint32_t size = stride * height; if (ftruncate(mFd, size) < 0) { throw std::runtime_error("Error setting waysland shm file size"); } @@ -160,7 +160,7 @@ void GPUDisplayFrontendWayland::createBuffer(unsigned int width, unsigned int he wl_surface_commit(mSurface); } -void GPUDisplayFrontendWayland::recreateBuffer(unsigned int width, unsigned int height) +void GPUDisplayFrontendWayland::recreateBuffer(uint32_t width, uint32_t height) { wl_surface_attach(mSurface, nullptr, 0, 0); wl_surface_commit(mSurface); @@ -169,7 +169,7 @@ void GPUDisplayFrontendWayland::recreateBuffer(unsigned int width, unsigned int createBuffer(width, height); } -int GPUDisplayFrontendWayland::FrontendMain() +int32_t GPUDisplayFrontendWayland::FrontendMain() { if (backend()->backendType() != GPUDisplayBackend::TYPE_VULKAN) { fprintf(stderr, "Only Vulkan backend supported\n"); @@ -232,7 +232,7 @@ int GPUDisplayFrontendWayland::FrontendMain() const wl_pointer_listener pointer_listener = {.enter = pointer_enter, .leave = pointer_leave, .motion = pointer_motion, .button = pointer_button, .axis = pointer_axis, .frame = nullptr, .axis_source = nullptr, .axis_stop = nullptr, .axis_discrete = nullptr}; #pragma GCC diagnostic pop - auto keyboard_keymap = [](void* data, wl_keyboard* wl_keyboard, uint format, int fd, uint size) { + auto keyboard_keymap = [](void* data, wl_keyboard* wl_keyboard, uint32_t format, int32_t fd, uint32_t size) { GPUDisplayFrontendWayland* me = (GPUDisplayFrontendWayland*)data; if (me->mXKBkeymap) { xkb_state_unref(me->mXKBstate); @@ -244,12 +244,12 @@ int GPUDisplayFrontendWayland::FrontendMain() munmap(keymap_string, size); close(fd); }; - auto keyboard_enter = [](void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface, wl_array* keys) {}; - auto keyboard_leave = [](void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface) {}; - auto keyboard_key = [](void* data, wl_keyboard* wl_keyboard, uint serial, uint time, uint key, uint state) { + auto keyboard_enter = [](void* data, wl_keyboard* wl_keyboard, uint32_t serial, wl_surface* surface, wl_array* keys) {}; + auto keyboard_leave = [](void* data, wl_keyboard* wl_keyboard, uint32_t serial, wl_surface* surface) {}; + auto keyboard_key = [](void* data, wl_keyboard* wl_keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) { GPUDisplayFrontendWayland* me = (GPUDisplayFrontendWayland*)data; - int symbol = me->GetKey(key, state); - int keyPress = (symbol >= 'a' && symbol <= 'z') ? symbol + 'A' - 'a' : symbol; + int32_t symbol = me->GetKey(key, state); + int32_t keyPress = (symbol >= 'a' && symbol <= 'z') ? symbol + 'A' - 'a' : symbol; if (state == XKB_KEY_DOWN) { me->mKeys[keyPress] = true; me->mKeysShift[keyPress] = me->mKeys[KEY_SHIFT]; @@ -259,11 +259,11 @@ int GPUDisplayFrontendWayland::FrontendMain() me->mKeysShift[keyPress] = false; } }; - auto keyboard_modifiers = [](void* data, wl_keyboard* wl_keyboard, uint serial, uint mods_depressed, uint mods_latched, uint mods_locked, uint group) { + auto keyboard_modifiers = [](void* data, wl_keyboard* wl_keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) { GPUDisplayFrontendWayland* me = (GPUDisplayFrontendWayland*)data; xkb_state_update_mask(me->mXKBstate, mods_depressed, mods_latched, mods_locked, 0, 0, group); }; - auto keyboard_repat = [](void* data, wl_keyboard* wl_keyboard, int rate, int delay) {}; + auto keyboard_repat = [](void* data, wl_keyboard* wl_keyboard, int32_t rate, int32_t delay) {}; const wl_keyboard_listener keyboard_listener = {.keymap = keyboard_keymap, .enter = keyboard_enter, .leave = keyboard_leave, .key = keyboard_key, .modifiers = keyboard_modifiers, .repeat_info = keyboard_repat}; auto xdg_wm_base_ping = [](void* data, struct xdg_wm_base* xdg_wm_base, uint32_t serial) { @@ -471,7 +471,7 @@ void GPUDisplayFrontendWayland::SetVSync(bool enable) { } -int GPUDisplayFrontendWayland::StartDisplay() +int32_t GPUDisplayFrontendWayland::StartDisplay() { static pthread_t hThread; if (pthread_create(&hThread, nullptr, FrontendThreadWrapper, this)) { @@ -481,13 +481,13 @@ int GPUDisplayFrontendWayland::StartDisplay() return (0); } -void GPUDisplayFrontendWayland::getSize(int& width, int& height) +void GPUDisplayFrontendWayland::getSize(int32_t& width, int32_t& height) { width = mDisplayWidth; height = mDisplayHeight; } -int GPUDisplayFrontendWayland::getVulkanSurface(void* instance, void* surface) +int32_t GPUDisplayFrontendWayland::getVulkanSurface(void* instance, void* surface) { VkWaylandSurfaceCreateInfoKHR info{}; info.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR; @@ -497,7 +497,7 @@ int GPUDisplayFrontendWayland::getVulkanSurface(void* instance, void* surface) return vkCreateWaylandSurfaceKHR(*(VkInstance*)instance, &info, nullptr, (VkSurfaceKHR*)surface) != VK_SUCCESS; } -unsigned int GPUDisplayFrontendWayland::getReqVulkanExtensions(const char**& p) +uint32_t GPUDisplayFrontendWayland::getReqVulkanExtensions(const char**& p) { static const char* exts[] = {"VK_KHR_surface", "VK_KHR_wayland_surface"}; p = exts; diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.h index 1ae8b8acbe243..f13c6fe831e0d 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.h @@ -36,21 +36,21 @@ class GPUDisplayFrontendWayland : public GPUDisplayFrontend GPUDisplayFrontendWayland(); ~GPUDisplayFrontendWayland() override = default; - int StartDisplay() override; + int32_t StartDisplay() override; void DisplayExit() override; void SwitchFullscreen(bool set) override; void ToggleMaximized(bool set) override; void SetVSync(bool enable) override; void OpenGLPrint(const char* s, float x, float y, float r, float g, float b, float a, bool fromBotton = true) override; - void getSize(int& width, int& height) override; - int getVulkanSurface(void* instance, void* surface) override; - unsigned int getReqVulkanExtensions(const char**& p) override; + void getSize(int32_t& width, int32_t& height) override; + int32_t getVulkanSurface(void* instance, void* surface) override; + uint32_t getReqVulkanExtensions(const char**& p) override; private: - int FrontendMain() override; - int GetKey(unsigned int key, unsigned int state); - void createBuffer(unsigned int width, unsigned int height); - void recreateBuffer(unsigned int width, unsigned int height); + int32_t FrontendMain() override; + int32_t GetKey(uint32_t key, uint32_t state); + void createBuffer(uint32_t width, uint32_t height); + void recreateBuffer(uint32_t width, uint32_t height); pthread_mutex_t mSemLockExit = PTHREAD_MUTEX_INITIALIZER; volatile bool mDisplayRunning = false; @@ -71,7 +71,7 @@ class GPUDisplayFrontendWayland : public GPUDisplayFrontend wl_output* mOutput = nullptr; - int mFd = 0; + int32_t mFd = 0; wl_shm_pool* mPool; wl_buffer* mBuffer; @@ -82,8 +82,8 @@ class GPUDisplayFrontendWayland : public GPUDisplayFrontend zxdg_decoration_manager_v1* mDecManager = nullptr; // zxdg_toplevel_decoration_v1* mXdgDecoration = nullptr; - int mWidthRequested = 0; - int mHeightRequested = 0; + int32_t mWidthRequested = 0; + int32_t mHeightRequested = 0; }; } // namespace GPUCA_NAMESPACE::gpu diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.cxx index 75a1d04e2fc51..d8e05a3f03b9b 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.cxx @@ -37,7 +37,7 @@ bool fullscreen = TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default POINT mouseCursorPos; -volatile int mouseReset = false; +volatile int32_t mouseReset = false; void KillGLWindow() // Properly Kill The Window { @@ -78,17 +78,17 @@ void KillGLWindow() // Properly Kill The Window } } -BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag) +BOOL CreateGLWindow(char* title, int32_t width, int32_t height, int32_t bits, bool fullscreenflag) { GLuint PixelFormat; // Holds The Results After Searching For A Match WNDCLASS wc; // Windows Class Structure DWORD dwExStyle; // Window Extended Style DWORD dwStyle; // Window Style RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values - WindowRect.left = (long)0; // Set Left Value To 0 - WindowRect.right = (long)width; // Set Right Value To Requested Width - WindowRect.top = (long)0; // Set Top Value To 0 - WindowRect.bottom = (long)height; // Set Bottom Value To Requested Height + WindowRect.left = (int64_t)0; // Set Left Value To 0 + WindowRect.right = (int64_t)width; // Set Right Value To Requested Width + WindowRect.top = (int64_t)0; // Set Top Value To 0 + WindowRect.bottom = (int64_t)height; // Set Bottom Value To Requested Height fullscreen = fullscreenflag; // Set The Global Fullscreen Flag @@ -150,7 +150,7 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscree PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format - (unsigned char)bits, // Select Our Color Depth + (uint8_t)bits, // Select Our Color Depth 0, 0, 0, @@ -217,7 +217,7 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscree return TRUE; } -int GetKey(int key) +int32_t GetKey(int32_t key) { if (key == 107 || key == 187) { return ('+'); @@ -322,7 +322,7 @@ GPUDisplayFrontendWindows::GPUDisplayFrontendWindows() mFrontendName = "Win32"; } -int GPUDisplayFrontendWindows::FrontendMain() +int32_t GPUDisplayFrontendWindows::FrontendMain() { MSG msg; BOOL done = FALSE; @@ -376,7 +376,7 @@ void SwitchFullscreen(bool set) {} void ToggleMaximized(bool set) {} void SetVSync(bool enable) {} -int GPUDisplayFrontendWindows::StartDisplay() +int32_t GPUDisplayFrontendWindows::StartDisplay() { HANDLE hThread; if ((hThread = CreateThread(nullptr, nullptr, &OpenGLWrapper, this, nullptr, nullptr)) == nullptr) { diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.h index cd5e333931628..62b1a7437a58f 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.h @@ -25,7 +25,7 @@ class GPUDisplayFrontendWindows : public GPUDisplayFrontend GPUDisplayFrontendWindows(); ~GPUDisplayFrontendWindows() override = default; - int StartDisplay() override; + int32_t StartDisplay() override; void DisplayExit() override; void SwitchFullscreen(bool set) override; void ToggleMaximized(bool set) override; @@ -33,7 +33,7 @@ class GPUDisplayFrontendWindows : public GPUDisplayFrontend void OpenGLPrint(const char* s, float x, float y, float r, float g, float b, float a, bool fromBotton = true) override; private: - int FrontendMain() override; + int32_t FrontendMain() override; }; } // namespace GPUCA_NAMESPACE::gpu diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.cxx index c1fae89b7227f..2ef2ccca92baf 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.cxx @@ -28,7 +28,7 @@ #include #endif -typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*); +typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int32_t*); using namespace GPUCA_NAMESPACE::gpu; @@ -38,7 +38,7 @@ GPUDisplayFrontendX11::GPUDisplayFrontendX11() mFrontendName = "X11"; } -int GPUDisplayFrontendX11::GetKey(int key) +int32_t GPUDisplayFrontendX11::GetKey(int32_t key) { if (key == 65453) { return ('-'); @@ -139,16 +139,16 @@ int GPUDisplayFrontendX11::GetKey(int key) return 0; } -void GPUDisplayFrontendX11::GetKey(XEvent& event, int& keyOut, int& keyPressOut) +void GPUDisplayFrontendX11::GetKey(XEvent& event, int32_t& keyOut, int32_t& keyPressOut) { char tmpString[9]; KeySym sym; if (XLookupString(&event.xkey, tmpString, 8, &sym, nullptr) == 0) { tmpString[0] = 0; } - int specialKey = GetKey(sym); - int localeKey = (unsigned char)tmpString[0]; - // GPUInfo("Key: keycode %d -> sym %d (%c) key %d (%c) special %d (%c)", (int)event.xkey.keycode, (int)sym, (char)sym, (int)localeKey, (char)localeKey, (int)specialKey, (char)specialKey); + int32_t specialKey = GetKey(sym); + int32_t localeKey = (uint8_t)tmpString[0]; + // GPUInfo("Key: keycode %d -> sym %d (%c) key %d (%c) special %d (%c)", (int32_t)event.xkey.keycode, (int32_t)sym, (char)sym, (int32_t)localeKey, (char)localeKey, (int32_t)specialKey, (char)specialKey); if (specialKey) { keyOut = keyPressOut = specialKey; @@ -182,15 +182,15 @@ void GPUDisplayFrontendX11::OpenGLPrint(const char* s, float x, float y, float r #endif } -int GPUDisplayFrontendX11::FrontendMain() +int32_t GPUDisplayFrontendX11::FrontendMain() { XSetWindowAttributes windowAttributes; XVisualInfo* visualInfo = nullptr; XEvent event; Colormap colorMap; GLXContext glxContext = nullptr; - int errorBase; - int eventBase; + int32_t errorBase; + int32_t eventBase; // Open a connection to the X server mDisplay = XOpenDisplay(nullptr); @@ -215,13 +215,13 @@ int GPUDisplayFrontendX11::FrontendMain() } // Require MSAA, double buffering, and Depth buffer - int attribs[] = {GLX_X_RENDERABLE, True, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, GLX_DOUBLEBUFFER, True, - // GLX_SAMPLE_BUFFERS , 1, //Disable MSAA here, we do it by rendering to offscreenbuffer - // GLX_SAMPLES , MSAA_SAMPLES, - None}; + int32_t attribs[] = {GLX_X_RENDERABLE, True, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, GLX_DOUBLEBUFFER, True, + // GLX_SAMPLE_BUFFERS , 1, //Disable MSAA here, we do it by rendering to offscreenbuffer + // GLX_SAMPLES , MSAA_SAMPLES, + None}; GLXFBConfig fbconfig = nullptr; - int fbcount; + int32_t fbcount; GLXFBConfig* fbc = glXChooseFBConfig(mDisplay, DefaultScreen(mDisplay), attribs, &fbcount); if (fbc == nullptr || fbcount == 0) { GPUError("Failed to get MSAA GLXFBConfig"); @@ -240,7 +240,7 @@ int GPUDisplayFrontendX11::FrontendMain() // Create an OpenGL rendering context glXCreateContextAttribsARBProc glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)glXGetProcAddressARB((const GLubyte*)"glXCreateContextAttribsARB"); if (glXCreateContextAttribsARB) { - int context_attribs[] = { + int32_t context_attribs[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, GL_MIN_VERSION_MAJOR, GLX_CONTEXT_MINOR_VERSION_ARB, GL_MIN_VERSION_MINOR, GLX_CONTEXT_PROFILE_MASK_ARB, mBackend->CoreProfile() ? GLX_CONTEXT_CORE_PROFILE_BIT_ARB : GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, @@ -291,8 +291,8 @@ int GPUDisplayFrontendX11::FrontendMain() GPUError("XLoadQueryFont failed."); return (-1); } else { - int first = font_info->min_char_or_byte2; - int last = font_info->max_char_or_byte2; + int32_t first = font_info->min_char_or_byte2; + int32_t last = font_info->max_char_or_byte2; glXUseXFont(font_info->fid, first, last - first + 1, mFontBase + first); } } @@ -309,7 +309,7 @@ int GPUDisplayFrontendX11::FrontendMain() XMapWindow(mDisplay, mWindow); XFlush(mDisplay); - int x11_fd = ConnectionNumber(mDisplay); + int32_t x11_fd = ConnectionNumber(mDisplay); // Enable vsync if (backend()->backendType() == GPUDisplayBackend::TYPE_OPENGL && vsync_supported) { @@ -331,10 +331,10 @@ int GPUDisplayFrontendX11::FrontendMain() std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now(); while (1) { - int num_ready_fds; + int32_t num_ready_fds; struct timeval tv; fd_set in_fds; - int waitCount = 0; + int32_t waitCount = 0; do { FD_ZERO(&in_fds); FD_SET(x11_fd, &in_fds); @@ -399,7 +399,7 @@ int GPUDisplayFrontendX11::FrontendMain() } case KeyPress: { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(event, handleKey, keyPress); mKeysShift[keyPress] = mKeys[KEY_SHIFT]; mKeys[keyPress] = true; @@ -408,7 +408,7 @@ int GPUDisplayFrontendX11::FrontendMain() } case KeyRelease: { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(event, handleKey, keyPress); mKeys[keyPress] = false; mKeysShift[keyPress] = false; @@ -514,11 +514,11 @@ void GPUDisplayFrontendX11::ToggleMaximized(bool set) void GPUDisplayFrontendX11::SetVSync(bool enable) { if (backend()->backendType() == GPUDisplayBackend::TYPE_OPENGL && vsync_supported) { - mGlXSwapIntervalEXT(mDisplay, glXGetCurrentDrawable(), (int)enable); + mGlXSwapIntervalEXT(mDisplay, glXGetCurrentDrawable(), (int32_t)enable); } } -int GPUDisplayFrontendX11::StartDisplay() +int32_t GPUDisplayFrontendX11::StartDisplay() { static pthread_t hThread; if (pthread_create(&hThread, nullptr, FrontendThreadWrapper, this)) { @@ -528,11 +528,11 @@ int GPUDisplayFrontendX11::StartDisplay() return (0); } -void GPUDisplayFrontendX11::getSize(int& width, int& height) +void GPUDisplayFrontendX11::getSize(int32_t& width, int32_t& height) { Window root_return; - int x_return, y_return; - unsigned int width_return, height_return, border_width_return, depth_return; + int32_t x_return, y_return; + uint32_t width_return, height_return, border_width_return, depth_return; if (XGetGeometry(mDisplay, mWindow, &root_return, &x_return, &y_return, &width_return, &height_return, &border_width_return, &depth_return) == 0) { throw std::runtime_error("Cannot query X11 window geometry"); } @@ -540,7 +540,7 @@ void GPUDisplayFrontendX11::getSize(int& width, int& height) height = height_return; } -int GPUDisplayFrontendX11::getVulkanSurface(void* instance, void* surface) +int32_t GPUDisplayFrontendX11::getVulkanSurface(void* instance, void* surface) { #ifdef GPUCA_BUILD_EVENT_DISPLAY_VULKAN VkXlibSurfaceCreateInfoKHR info{}; @@ -554,7 +554,7 @@ int GPUDisplayFrontendX11::getVulkanSurface(void* instance, void* surface) #endif } -unsigned int GPUDisplayFrontendX11::getReqVulkanExtensions(const char**& p) +uint32_t GPUDisplayFrontendX11::getReqVulkanExtensions(const char**& p) { static const char* exts[] = {"VK_KHR_surface", "VK_KHR_xlib_surface"}; p = exts; diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.h index e53961db97399..16920ce77460e 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.h @@ -29,20 +29,20 @@ class GPUDisplayFrontendX11 : public GPUDisplayFrontend GPUDisplayFrontendX11(); ~GPUDisplayFrontendX11() override = default; - int StartDisplay() override; + int32_t StartDisplay() override; void DisplayExit() override; void SwitchFullscreen(bool set) override; void ToggleMaximized(bool set) override; void SetVSync(bool enable) override; void OpenGLPrint(const char* s, float x, float y, float r, float g, float b, float a, bool fromBotton = true) override; - void getSize(int& width, int& height) override; - int getVulkanSurface(void* instance, void* surface) override; - unsigned int getReqVulkanExtensions(const char**& p) override; + void getSize(int32_t& width, int32_t& height) override; + int32_t getVulkanSurface(void* instance, void* surface) override; + uint32_t getReqVulkanExtensions(const char**& p) override; private: - int FrontendMain() override; - int GetKey(int key); - void GetKey(XEvent& event, int& keyOut, int& keyPressOut); + int32_t FrontendMain() override; + int32_t GetKey(int32_t key); + void GetKey(XEvent& event, int32_t& keyOut, int32_t& keyPressOut); pthread_mutex_t mSemLockExit = PTHREAD_MUTEX_INITIALIZER; volatile bool mDisplayRunning = false; diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.cxx index 000019dbd9446..a5ba968f9e50d 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.cxx @@ -76,7 +76,7 @@ void GPUDisplayGUIWrapper::UpdateTimer() void GPUDisplayGUIWrapper::guiThread() { - static int tmp_argc = 1; + static int32_t tmp_argc = 1; static const char* tmp_argv[2] = {"GPU CA Standalone Event Display GUI", NULL}; mO->app.reset(new QApplication(tmp_argc, (char**)tmp_argv)); while (!mO->terminate) { @@ -116,7 +116,7 @@ void GPUDisplayGUIWrapper::guiThread() mO->app.reset(nullptr); } -int GPUDisplayGUIWrapper::start() +int32_t GPUDisplayGUIWrapper::start() { if (!mO->started) { { @@ -134,7 +134,7 @@ int GPUDisplayGUIWrapper::start() return 0; } -int GPUDisplayGUIWrapper::stop() +int32_t GPUDisplayGUIWrapper::stop() { if (mO->started) { mO->stop = true; @@ -148,7 +148,7 @@ int GPUDisplayGUIWrapper::stop() return 0; } -int GPUDisplayGUIWrapper::focus() +int32_t GPUDisplayGUIWrapper::focus() { if (mO->started) { } diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.h b/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.h index 855e949ac409c..ef632c6f2d54b 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.h @@ -30,9 +30,9 @@ class GPUDisplayGUIWrapper bool isRunning() const; void UpdateTimer(); - int start(); - int stop(); - int focus(); + int32_t start(); + int32_t stop(); + int32_t focus(); private: std::unique_ptr mO; diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayKeys.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayKeys.cxx index 9a2481d1964cb..1842c276a580c 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayKeys.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayKeys.cxx @@ -71,12 +71,12 @@ const char* HelpText[] = { void GPUDisplay::PrintHelp() { mInfoHelpTimer.ResetStart(); - for (unsigned int i = 0; i < sizeof(HelpText) / sizeof(HelpText[0]); i++) { + for (uint32_t i = 0; i < sizeof(HelpText) / sizeof(HelpText[0]); i++) { GPUInfo("%s", HelpText[i]); } } -void GPUDisplay::HandleKey(unsigned char key) +void GPUDisplay::HandleKey(uint8_t key) { GPUSettingsDisplayHeavy oldCfgH = mCfgH; GPUSettingsDisplayLight oldCfgL = mCfgL; @@ -152,10 +152,10 @@ void GPUDisplay::HandleKey(unsigned char key) } } else if (key == 'F') { mCfgR.fullScreen ^= 1; - SetInfo("Toggling full screen (%d)", (int)mCfgR.fullScreen); + SetInfo("Toggling full screen (%d)", (int32_t)mCfgR.fullScreen); } else if (key == '_') { mCfgR.maximized ^= 1; - SetInfo("Toggling Maximized window (%d)", (int)mCfgR.maximized); + SetInfo("Toggling Maximized window (%d)", (int32_t)mCfgR.maximized); } else if (key == 'R') { mCfgR.maxFPSRate ^= 1; SetInfo("FPS rate %s", mCfgR.maxFPSRate ? "not limited" : "limited"); @@ -175,12 +175,7 @@ void GPUDisplay::HandleKey(unsigned char key) mCfgH.markClusters <<= 1; } SetInfo("Cluster flag highlight mask set to %d (%s)", mCfgH.markClusters, - mCfgH.markClusters == 0 ? "off" : mCfgH.markClusters == 1 ? "split pad" - : mCfgH.markClusters == 2 ? "split time" - : mCfgH.markClusters == 4 ? "edge" - : mCfgH.markClusters == 8 ? "singlePad" - : mCfgH.markClusters == 0x10 ? "reject distance" - : "reject error"); + mCfgH.markClusters == 0 ? "off" : mCfgH.markClusters == 1 ? "split pad" : mCfgH.markClusters == 2 ? "split time" : mCfgH.markClusters == 4 ? "edge" : mCfgH.markClusters == 8 ? "singlePad" : mCfgH.markClusters == 0x10 ? "reject distance" : "reject error"); } else if (key == 'z') { mCfgH.markFakeClusters ^= 1; SetInfo("Marking fake clusters: %s", mCfgH.markFakeClusters ? "on" : "off"); @@ -318,40 +313,40 @@ void GPUDisplay::HandleKey(unsigned char key) } else if (key == mFrontend->KEY_F1) { if (mFrontend->mKeysShift[mFrontend->KEY_F1]) { mCfgH.drawTPCTracks ^= 1; - SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int)mCfgH.drawTPCTracks, (int)mCfgH.drawTRDTracks, (int)mCfgH.drawTOFTracks, (int)mCfgH.drawITSTracks); + SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int32_t)mCfgH.drawTPCTracks, (int32_t)mCfgH.drawTRDTracks, (int32_t)mCfgH.drawTOFTracks, (int32_t)mCfgH.drawITSTracks); } else { mCfgL.drawTPC ^= 1; - SetInfo("Showing TPC Clusters: %d", (int)mCfgL.drawTPC); + SetInfo("Showing TPC Clusters: %d", (int32_t)mCfgL.drawTPC); } } else if (key == mFrontend->KEY_F2) { if (mFrontend->mKeysShift[mFrontend->KEY_F2]) { mCfgH.drawTRDTracks ^= 1; - SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int)mCfgH.drawTPCTracks, (int)mCfgH.drawTRDTracks, (int)mCfgH.drawTOFTracks, (int)mCfgH.drawITSTracks); + SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int32_t)mCfgH.drawTPCTracks, (int32_t)mCfgH.drawTRDTracks, (int32_t)mCfgH.drawTOFTracks, (int32_t)mCfgH.drawITSTracks); } else { mCfgL.drawTRD ^= 1; - SetInfo("Showing TRD Tracklets: %d", (int)mCfgL.drawTRD); + SetInfo("Showing TRD Tracklets: %d", (int32_t)mCfgL.drawTRD); } } else if (key == mFrontend->KEY_F3) { if (mFrontend->mKeysShift[mFrontend->KEY_F3]) { mCfgH.drawTOFTracks ^= 1; - SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int)mCfgH.drawTPCTracks, (int)mCfgH.drawTRDTracks, (int)mCfgH.drawTOFTracks, (int)mCfgH.drawITSTracks); + SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int32_t)mCfgH.drawTPCTracks, (int32_t)mCfgH.drawTRDTracks, (int32_t)mCfgH.drawTOFTracks, (int32_t)mCfgH.drawITSTracks); } else { mCfgL.drawTOF ^= 1; - SetInfo("Showing TOF Hits: %d", (int)mCfgL.drawTOF); + SetInfo("Showing TOF Hits: %d", (int32_t)mCfgL.drawTOF); } } else if (key == mFrontend->KEY_F4) { if (mFrontend->mKeysShift[mFrontend->KEY_F4]) { mCfgH.drawITSTracks ^= 1; - SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int)mCfgH.drawTPCTracks, (int)mCfgH.drawTRDTracks, (int)mCfgH.drawTOFTracks, (int)mCfgH.drawITSTracks); + SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int32_t)mCfgH.drawTPCTracks, (int32_t)mCfgH.drawTRDTracks, (int32_t)mCfgH.drawTOFTracks, (int32_t)mCfgH.drawITSTracks); } else { mCfgL.drawITS ^= 1; - SetInfo("Showing ITS Clusters: %d", (int)mCfgL.drawITS); + SetInfo("Showing ITS Clusters: %d", (int32_t)mCfgL.drawITS); } } else if (key == mFrontend->KEY_F12 && mFrontend->mKeysShift[mFrontend->KEY_F12]) { mCfgH.drawTracksAndFilter ^= 1; SetInfo("Track filter: %s", mCfgH.drawTracksAndFilter ? "AND" : "OR"); } else if (key == 't') { - static int nScreenshot = 1; + static int32_t nScreenshot = 1; char fname[32]; snprintf(fname, 32, "screenshot%d.bmp", nScreenshot++); mRequestScreenshot = true; @@ -378,7 +373,7 @@ void GPUDisplay::HandleKey(unsigned char key) SetInfo("Interpolating visualization settings during Animation %s", mAnimationChangeConfig ? "enabled" : "disabled"); } else if (key == 'Y') { setAnimationPoint(); - SetInfo("Added Animation point (%d points, %6.2f seconds)", (int)mAnimateVectors[0].size(), mAnimateVectors[0].back()); + SetInfo("Added Animation point (%d points, %6.2f seconds)", (int32_t)mAnimateVectors[0].size(), mAnimateVectors[0].back()); } else if (key == 'X') { resetAnimation(); SetInfo("Reset Animation points", 1); @@ -394,9 +389,7 @@ void GPUDisplay::HandleKey(unsigned char key) if (mCfgL.animationMode == 6) { SetInfo("Animation mode %d - Centered on origin", mCfgL.animationMode); } else { - SetInfo("Animation mode %d - Position: %s, Direction: %s", mCfgL.animationMode, (mCfgL.animationMode & 2) ? "Spherical (spherical rotation)" : (mCfgL.animationMode & 4) ? "Spherical (Euler angles)" - : "Cartesian", - (mCfgL.animationMode & 1) ? "Euler angles" : "Quaternion"); + SetInfo("Animation mode %d - Position: %s, Direction: %s", mCfgL.animationMode, (mCfgL.animationMode & 2) ? "Spherical (spherical rotation)" : (mCfgL.animationMode & 4) ? "Spherical (Euler angles)" : "Cartesian", (mCfgL.animationMode & 1) ? "Euler angles" : "Quaternion"); } } else if (key == 'u') { mCfgH.trackFilter = (mCfgH.trackFilter + 1) % (mConfig.filterMacros.size() + 1); @@ -405,7 +398,7 @@ void GPUDisplay::HandleKey(unsigned char key) } else if (key == 'o') { FILE* ftmp = fopen("glpos.tmp", "w+b"); if (ftmp) { - int retval = fwrite(&mViewMatrix, sizeof(mViewMatrix), 1, ftmp); + int32_t retval = fwrite(&mViewMatrix, sizeof(mViewMatrix), 1, ftmp); if (retval != 1) { GPUError("Error writing position to file"); } else { @@ -419,7 +412,7 @@ void GPUDisplay::HandleKey(unsigned char key) } else if (key == 'p') { FILE* ftmp = fopen("glpos.tmp", "rb"); if (ftmp) { - int retval = fread(&mViewMatrix, 1, sizeof(mViewMatrix), ftmp); + int32_t retval = fread(&mViewMatrix, 1, sizeof(mViewMatrix), ftmp); if (retval == sizeof(mViewMatrix)) { GPUInfo("Position read from file"); } else { @@ -434,9 +427,9 @@ void GPUDisplay::HandleKey(unsigned char key) FILE* ftmp = fopen("glanimation.tmp", "w+b"); if (ftmp) { fwrite(&mCfgL, sizeof(mCfgL), 1, ftmp); - int size = mAnimateVectors[0].size(); + int32_t size = mAnimateVectors[0].size(); fwrite(&size, sizeof(size), 1, ftmp); - for (int i = 0; i < 9; i++) { + for (int32_t i = 0; i < 9; i++) { fwrite(mAnimateVectors[i].data(), sizeof(mAnimateVectors[i][0]), size, ftmp); } fwrite(mAnimateConfig.data(), sizeof(mAnimateConfig[0]), size, ftmp); @@ -448,10 +441,10 @@ void GPUDisplay::HandleKey(unsigned char key) } else if (key == 'P') { FILE* ftmp = fopen("glanimation.tmp", "rb"); if (ftmp) { - int retval = fread(&mCfgL, sizeof(mCfgL), 1, ftmp); - int size; + int32_t retval = fread(&mCfgL, sizeof(mCfgL), 1, ftmp); + int32_t size; retval += fread(&size, sizeof(size), 1, ftmp); - for (int i = 0; i < 9; i++) { + for (int32_t i = 0; i < 9; i++) { mAnimateVectors[i].resize(size); retval += fread(mAnimateVectors[i].data(), sizeof(mAnimateVectors[i][0]), size, ftmp); } @@ -521,12 +514,12 @@ void GPUDisplay::HandleKey(unsigned char key) } } -void GPUDisplay::HandleSendKey(int key) +void GPUDisplay::HandleSendKey(int32_t key) { // GPUError("key %d '%c'", key, (char) key); bool shifted = key >= 'A' && key <= 'Z'; - int press = key; + int32_t press = key; if (press >= 'a' && press <= 'z') { press += 'A' - 'a'; } @@ -538,7 +531,7 @@ void GPUDisplay::HandleSendKey(int key) void GPUDisplay::PrintGLHelpText(float colorValue) { - for (unsigned int i = 0; i < sizeof(HelpText) / sizeof(HelpText[0]); i++) { + for (uint32_t i = 0; i < sizeof(HelpText) / sizeof(HelpText[0]); i++) { OpenGLPrint(HelpText[i], 40.f, 35 + std::max(20, mDrawTextFontSize + 4) * (1 + i), colorValue, colorValue, colorValue, mInfoHelpTimer.GetCurrentElapsedTime() >= 5 ? (6 - mInfoHelpTimer.GetCurrentElapsedTime()) : 1, false); } } diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayAnimation.cxx b/GPU/GPUTracking/display/helpers/GPUDisplayAnimation.cxx index 8d023fb70cb16..77b7181a3a377 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayAnimation.cxx +++ b/GPU/GPUTracking/display/helpers/GPUDisplayAnimation.cxx @@ -35,7 +35,7 @@ void GPUDisplay::setAnimationPoint() mAnimateVectors[2].emplace_back(anglePhi); mAnimateVectors[3].emplace_back(angleTheta); } else { - for (int i = 0; i < 3; i++) { + for (int32_t i = 0; i < 3; i++) { mAnimateVectors[i + 1].emplace_back(mXYZ[i]); } // Cartesian @@ -44,7 +44,7 @@ void GPUDisplay::setAnimationPoint() mAnimateVectors[4].emplace_back(r); if (mCfgL.animationMode & 1) // Euler-angles { - for (int i = 0; i < 3; i++) { + for (int32_t i = 0; i < 3; i++) { float newangle = mAngle[i]; if (mAnimateVectors[0].size()) { mAnimationCloseAngle(newangle, mAnimateVectors[i + 5].back()); @@ -58,13 +58,13 @@ void GPUDisplay::setAnimationPoint() if (mAnimateVectors[0].size()) { mAnimateCloseQuaternion(v, mAnimateVectors[5].back(), mAnimateVectors[6].back(), mAnimateVectors[7].back(), mAnimateVectors[8].back()); } - for (int i = 0; i < 4; i++) { + for (int32_t i = 0; i < 4; i++) { mAnimateVectors[i + 5].emplace_back(v[i]); } } float delay = 0.f; if (mAnimateVectors[0].size()) { - delay = mAnimateVectors[0].back() + ((int)(mAnimationDelay * 20)) / 20.f; + delay = mAnimateVectors[0].back() + ((int32_t)(mAnimationDelay * 20)) / 20.f; } mAnimateVectors[0].emplace_back(delay); mAnimateConfig.emplace_back(mCfgL); @@ -72,7 +72,7 @@ void GPUDisplay::setAnimationPoint() void GPUDisplay::resetAnimation() { - for (int i = 0; i < 9; i++) { + for (int32_t i = 0; i < 9; i++) { mAnimateVectors[i].clear(); } mAnimateConfig.clear(); @@ -84,7 +84,7 @@ void GPUDisplay::removeAnimationPoint() if (mAnimateVectors[0].size() == 0) { return; } - for (int i = 0; i < 9; i++) { + for (int32_t i = 0; i < 9; i++) { mAnimateVectors[i].pop_back(); } mAnimateConfig.pop_back(); @@ -92,7 +92,7 @@ void GPUDisplay::removeAnimationPoint() void GPUDisplay::startAnimation() { - for (int i = 0; i < 8; i++) { + for (int32_t i = 0; i < 8; i++) { mAnimationSplines[i].create(mAnimateVectors[0], mAnimateVectors[i + 1]); } mAnimationTimer.ResetStart(); @@ -101,7 +101,7 @@ void GPUDisplay::startAnimation() mAnimationLastBase = 0; } -int GPUDisplay::animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4& nextViewMatrix) +int32_t GPUDisplay::animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4& nextViewMatrix) { float time = animateTime; if (mAnimate && time < 0) { @@ -125,12 +125,12 @@ int GPUDisplay::animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4 return 0; } float vals[8]; - for (int i = 0; i < 8; i++) { + for (int32_t i = 0; i < 8; i++) { vals[i] = mAnimationSplines[i].evaluate(time); } if (mAnimationChangeConfig && animateTime < 0) { - int base = 0; - int k = mAnimateVectors[0].size() - 1; + int32_t base = 0; + int32_t k = mAnimateVectors[0].size() - 1; while (base < k && time > mAnimateVectors[0][base]) { base++; } @@ -162,7 +162,7 @@ int GPUDisplay::animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4 if (mag < 0.0001f) { vals[7] = 1; } else { - for (int i = 0; i < 4; i++) { + for (int32_t i = 0; i < 4; i++) { vals[4 + i] /= mag; } } @@ -184,7 +184,7 @@ int GPUDisplay::animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4 r = 1; } r = vals[3] / r; - for (int i = 0; i < 3; i++) { + for (int32_t i = 0; i < 3; i++) { vals[i] *= r; } } diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayBackendOpenGLMagneticField.cxx b/GPU/GPUTracking/display/helpers/GPUDisplayBackendOpenGLMagneticField.cxx index ad1fd33cab686..16166baa9a91c 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayBackendOpenGLMagneticField.cxx +++ b/GPU/GPUTracking/display/helpers/GPUDisplayBackendOpenGLMagneticField.cxx @@ -49,17 +49,17 @@ using namespace GPUCA_NAMESPACE::gpu; #ifdef GPUCA_BUILD_EVENT_DISPLAY_OPENGL -#define CHKERR(cmd) \ - do { \ - (cmd); \ - GLenum err = glGetError(); \ - while (err != GL_NO_ERROR) { \ - GPUError("OpenGL Error %d: %s (%s: %d)", (int)err, (const char*)gluErrorString(err), __FILE__, __LINE__); \ - throw std::runtime_error("OpenGL Failure"); \ - } \ +#define CHKERR(cmd) \ + do { \ + (cmd); \ + GLenum err = glGetError(); \ + while (err != GL_NO_ERROR) { \ + GPUError("OpenGL Error %d: %s (%s: %d)", (int32_t)err, (const char*)gluErrorString(err), __FILE__, __LINE__); \ + throw std::runtime_error("OpenGL Failure"); \ + } \ } while (false) -int GPUDisplayBackendOpenGL::InitMagFieldVisualization() +int32_t GPUDisplayBackendOpenGL::InitMagFieldVisualization() { #ifndef GPUCA_NO_FMT mMagneticFieldVisualization = std::make_unique(); @@ -144,13 +144,13 @@ int GPUDisplayBackendOpenGL::InitMagFieldVisualization() return 0; } -unsigned int GPUDisplayBackendOpenGL::drawField() +uint32_t GPUDisplayBackendOpenGL::drawField() { if (!mMagneticFieldVisualization) { return InitMagFieldVisualization(); // next frame will fill MVP matrix } - if (mMagneticFieldVisualization->mFieldLineSeedPoints.size() != (unsigned int)mDisplay->cfgL().bFieldLinesCount) { + if (mMagneticFieldVisualization->mFieldLineSeedPoints.size() != (uint32_t)mDisplay->cfgL().bFieldLinesCount) { mMagneticFieldVisualization->generateSeedPoints(mDisplay->cfgL().bFieldLinesCount); CHKERR(glNamedBufferData(VBO_field, mMagneticFieldVisualization->mFieldLineSeedPoints.size() * sizeof(GPUDisplayMagneticField::vtx), mMagneticFieldVisualization->mFieldLineSeedPoints.data(), GL_STATIC_DRAW)); } @@ -196,10 +196,10 @@ void GPUDisplayBackendOpenGL::ExitMagFieldVisualization() } #else // GPUCA_BUILD_EVENT_DISPLAY_OPENGL -int GPUDisplayBackendOpenGL::InitMagFieldVisualization() +int32_t GPUDisplayBackendOpenGL::InitMagFieldVisualization() { return 0; } -unsigned int GPUDisplayBackendOpenGL::drawField() { return 0; } +uint32_t GPUDisplayBackendOpenGL::drawField() { return 0; } void GPUDisplayBackendOpenGL::ExitMagFieldVisualization() {} #endif // GPUCA_BUILD_EVENT_DISPLAY_OPENGL diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayColors.inc b/GPU/GPUTracking/display/helpers/GPUDisplayColors.inc index 75093ab191804..2994af86980d8 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayColors.inc +++ b/GPU/GPUTracking/display/helpers/GPUDisplayColors.inc @@ -162,11 +162,11 @@ inline void GPUDisplay::SetColorMarked() } ActivateColor(); } -inline void GPUDisplay::SetCollisionColor(int col) +inline void GPUDisplay::SetCollisionColor(int32_t col) { - int red = (col * 2) % 5; - int blue = (2 + col * 3) % 7; - int green = (4 + col * 5) % 6; + int32_t red = (col * 2) % 5; + int32_t blue = (2 + col * 3) % 7; + int32_t green = (4 + col * 5) % 6; if (mCfgL.invertColors && red == 4 && blue == 5 && green == 6) { red = 0; } diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayHelpers.cxx b/GPU/GPUTracking/display/helpers/GPUDisplayHelpers.cxx index a41be9d9e278a..cd73cc0b9b34f 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayHelpers.cxx +++ b/GPU/GPUTracking/display/helpers/GPUDisplayHelpers.cxx @@ -23,7 +23,7 @@ using namespace GPUCA_NAMESPACE::gpu; -int GPUDisplay::getNumThreads() +int32_t GPUDisplay::getNumThreads() { if (mChain) { return mChain->GetProcessingSettings().ompThreads; diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayInterpolation.cxx b/GPU/GPUTracking/display/helpers/GPUDisplayInterpolation.cxx index d3a2a4d584460..3df61bfc81110 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayInterpolation.cxx +++ b/GPU/GPUTracking/display/helpers/GPUDisplayInterpolation.cxx @@ -27,9 +27,9 @@ void GPUDisplay::opengl_spline::create(const vecpod& x, const vecpod %f", i, x[i], y[i]); } } @@ -39,36 +39,36 @@ void GPUDisplay::opengl_spline::create(const vecpod& x, const vecpod h(k + 1), alpha(k + 1), l(k + 1), mu(k + 1), z(k + 1); - for (int i = 0; i <= k; i++) { + for (int32_t i = 0; i <= k; i++) { ma[i] = y[i]; } - for (int i = 0; i < k; i++) { + for (int32_t i = 0; i < k; i++) { h[i] = x[i + 1] - x[i]; } - for (int i = 1; i < k; i++) { + for (int32_t i = 1; i < k; i++) { alpha[i] = 3.f / h[i] * (ma[i + 1] - ma[i]) - 3.f / h[i - 1] * (ma[i] - ma[i - 1]); } l[0] = l[k] = 1; mu[0] = z[0] = z[k] = mc[k] = 0; - for (int i = 1; i < k; i++) { + for (int32_t i = 1; i < k; i++) { l[i] = 2.f * (x[i + 1] - x[i - 1]) - h[i - 1] * mu[i - 1]; mu[i] = h[i] / l[i]; z[i] = (alpha[i] - h[i - 1] * z[i - 1]) / l[i]; } - for (int i = k - 1; i >= 0; i--) { + for (int32_t i = k - 1; i >= 0; i--) { mc[i] = z[i] - mu[i] * mc[i + 1]; mb[i] = (ma[i + 1] - ma[i]) / h[i] - h[i] / 3.f * (mc[i + 1] + 2.f * mc[i]); md[i] = (mc[i + 1] - mc[i]) / (3.f * h[i]); } - for (int i = 0; i <= k; i++) { + for (int32_t i = 0; i <= k; i++) { mx[i] = x[i]; } } float GPUDisplay::opengl_spline::evaluate(float x) { - int base = 0; - const int k = mx.size() - 1; + int32_t base = 0; + const int32_t k = mx.size() - 1; if (k < 0) { return (0); } diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.cxx b/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.cxx index 357274e2decfc..352f029ab3648 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.cxx +++ b/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.cxx @@ -47,9 +47,9 @@ void GPUDisplayMagneticField::generateSeedPoints(std::size_t count) std::mt19937 rng(0xDEADBEEF); // TODO: fetch these values from somewhere? - std::uniform_int_distribution generator_x(-512, 512); - std::uniform_int_distribution generator_y(-512, 512); - std::uniform_int_distribution generator_z(-455 - 1312, -455 + 1312); + std::uniform_int_distribution generator_x(-512, 512); + std::uniform_int_distribution generator_y(-512, 512); + std::uniform_int_distribution generator_z(-455 - 1312, -455 + 1312); mFieldLineSeedPoints.clear(); @@ -131,7 +131,7 @@ std::tuple loadParams(std::i } #ifndef GPUCA_O2_LIB -int GPUDisplayMagneticField::initializeUniforms() +int32_t GPUDisplayMagneticField::initializeUniforms() { mSolenoidSegments = std::make_unique(); mDipoleSegments = std::make_unique(); @@ -177,7 +177,7 @@ int GPUDisplayMagneticField::initializeUniforms() #endif #if !defined(GPUCA_NO_ROOT) && defined(GPUCA_O2_LIB) -int GPUDisplayMagneticField::initializeUniforms() +int32_t GPUDisplayMagneticField::initializeUniforms() { mRenderConstantsUniform = std::make_unique(); @@ -198,7 +198,7 @@ int GPUDisplayMagneticField::initializeUniforms() return initializeUniformsFromField(field); } -int GPUDisplayMagneticField::initializeUniformsFromField(o2::field::MagneticField* field) +int32_t GPUDisplayMagneticField::initializeUniformsFromField(o2::field::MagneticField* field) { const auto chebMap = field->getMeasuredMap(); @@ -279,8 +279,8 @@ int GPUDisplayMagneticField::initializeUniformsFromField(o2::field::MagneticFiel const auto getParameterSolenoid = [chebMap](Int_t i) { return chebMap->getParameterSolenoid(i); }; const auto getParameterDipole = [chebMap](Int_t i) { return chebMap->getParameterDipole(i); }; - auto countArraySizes = [](int numberOfParametrization, auto& getParameter) { - int TotalRows = 0, TotalColumns = 0, TotalCoefficients = 0; + auto countArraySizes = [](int32_t numberOfParametrization, auto& getParameter) { + int32_t TotalRows = 0, TotalColumns = 0, TotalCoefficients = 0; UShort_t MaxChebyshevOrder = 0; for (auto i = 0; i < numberOfParametrization; ++i) { @@ -389,8 +389,8 @@ int GPUDisplayMagneticField::initializeUniformsFromField(o2::field::MagneticFiel mDipoleSegments = std::make_unique(); loadSegments(dipoleTableInfo, *mDipoleSegments); - auto initParametrization = [](int numberOfParametrization, auto& getParameter, auto& parametrizationUniform) { - int ColsAtRowOffset = 0, CofsAtRowOffset = 0, CofsAtColOffset = 0, Coeffs = 0; + auto initParametrization = [](int32_t numberOfParametrization, auto& getParameter, auto& parametrizationUniform) { + int32_t ColsAtRowOffset = 0, CofsAtRowOffset = 0, CofsAtColOffset = 0, Coeffs = 0; for (auto i = 0; i < numberOfParametrization; ++i) { const auto param = getParameter(i); diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.h b/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.h index 3ec9682b6b6b3..f8461e4c036f4 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.h +++ b/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.h @@ -51,7 +51,7 @@ class GPUDisplayMagneticField static constexpr std::size_t MAX_CHEBYSHEV_ORDER = 32; struct RenderConstantsUniform { - unsigned int StepCount; + uint32_t StepCount; float StepSize; }; @@ -61,21 +61,21 @@ class GPUDisplayMagneticField float MaxZ; float MultiplicativeFactor; - int ZSegments; + int32_t ZSegments; float SegDim1[MAX_DIM1_SEGMENTS]; - int BegSegDim2[MAX_DIM1_SEGMENTS]; - int NSegDim2[MAX_DIM1_SEGMENTS]; + int32_t BegSegDim2[MAX_DIM1_SEGMENTS]; + int32_t NSegDim2[MAX_DIM1_SEGMENTS]; float SegDim2[MAX_DIM2_SEGMENTS]; - int BegSegDim3[MAX_DIM2_SEGMENTS]; - int NSegDim3[MAX_DIM2_SEGMENTS]; + int32_t BegSegDim3[MAX_DIM2_SEGMENTS]; + int32_t NSegDim3[MAX_DIM2_SEGMENTS]; float SegDim3[MAX_DIM3_SEGMENTS]; - int SegID[MAX_DIM3_SEGMENTS]; + int32_t SegID[MAX_DIM3_SEGMENTS]; }; template @@ -85,15 +85,15 @@ class GPUDisplayMagneticField float BMin[MAX_PARAMETERIZATIONS]; float BMax[MAX_PARAMETERIZATIONS]; - int NRows[MAX_PARAMETERIZATIONS]; - int ColsAtRowOffset[MAX_PARAMETERIZATIONS]; - int CofsAtRowOffset[MAX_PARAMETERIZATIONS]; + int32_t NRows[MAX_PARAMETERIZATIONS]; + int32_t ColsAtRowOffset[MAX_PARAMETERIZATIONS]; + int32_t CofsAtRowOffset[MAX_PARAMETERIZATIONS]; - int NColsAtRow[MAX_ROWS]; - int CofsAtColOffset[MAX_ROWS]; + int32_t NColsAtRow[MAX_ROWS]; + int32_t CofsAtColOffset[MAX_ROWS]; - int NCofsAtCol[MAX_COLUMNS]; - int AtColCoefOffset[MAX_COLUMNS]; + int32_t NCofsAtCol[MAX_COLUMNS]; + int32_t AtColCoefOffset[MAX_COLUMNS]; float Coeffs[MAX_COEFFICIENTS]; }; @@ -110,9 +110,9 @@ class GPUDisplayMagneticField vtx(float a, float b, float c) : x(a), y(b), z(c) {} }; - int initializeUniforms(); + int32_t initializeUniforms(); #ifdef GPUCA_O2_LIB - int initializeUniformsFromField(o2::field::MagneticField* field); + int32_t initializeUniformsFromField(o2::field::MagneticField* field); #endif void generateSeedPoints(std::size_t count); diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayROOT.cxx b/GPU/GPUTracking/display/helpers/GPUDisplayROOT.cxx index cb81b485bc6dd..4d99c3aa38cfc 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayROOT.cxx +++ b/GPU/GPUTracking/display/helpers/GPUDisplayROOT.cxx @@ -25,7 +25,7 @@ using namespace GPUCA_NAMESPACE::gpu; #include "TSystem.h" #include "TMethodCall.h" -int GPUDisplay::buildTrackFilter() +int32_t GPUDisplay::buildTrackFilter() { if (!mCfgH.trackFilter) { return 0; @@ -54,7 +54,7 @@ int GPUDisplay::buildTrackFilter() #else -int GPUDisplay::buildTrackFilter() +int32_t GPUDisplay::buildTrackFilter() { } diff --git a/GPU/GPUTracking/display/helpers/bitmapfile.h b/GPU/GPUTracking/display/helpers/bitmapfile.h index 274993633e36e..ead2b80045cc6 100644 --- a/GPU/GPUTracking/display/helpers/bitmapfile.h +++ b/GPU/GPUTracking/display/helpers/bitmapfile.h @@ -13,24 +13,24 @@ /// \author David Rohr struct BITMAPFILEHEADER { - unsigned short bfType; - unsigned int bfSize; - unsigned int bfReserved; - unsigned int bfOffBits; + uint16_t bfType; + uint32_t bfSize; + uint32_t bfReserved; + uint32_t bfOffBits; } __attribute__((packed)); struct BITMAPINFOHEADER { - unsigned int biSize; - unsigned int biWidth; - unsigned int biHeight; - unsigned short biPlanes; - unsigned short biBitCount; - unsigned int biCompression; - unsigned int biSizeImage; - unsigned int biXPelsPerMeter; - unsigned int biYPelsPerMeter; - unsigned int biClrUsed; - unsigned int biClrImportant; + uint32_t biSize; + uint32_t biWidth; + uint32_t biHeight; + uint16_t biPlanes; + uint16_t biBitCount; + uint32_t biCompression; + uint32_t biSizeImage; + uint32_t biXPelsPerMeter; + uint32_t biYPelsPerMeter; + uint32_t biClrUsed; + uint32_t biClrImportant; } __attribute__((packed)); enum BI_Compression { BI_RGB = 0x0000, diff --git a/GPU/GPUTracking/display/helpers/field-uniform-exporter.cxx b/GPU/GPUTracking/display/helpers/field-uniform-exporter.cxx index 3f564f5bc8e5b..d8210979efa64 100644 --- a/GPU/GPUTracking/display/helpers/field-uniform-exporter.cxx +++ b/GPU/GPUTracking/display/helpers/field-uniform-exporter.cxx @@ -24,7 +24,7 @@ namespace bpo = boost::program_options; using namespace GPUCA_NAMESPACE::gpu; template -void saveSegments(std::ofstream& file, int NSegDim1, int NSegDim2, int NSegDim3, GPUDisplayMagneticField::SegmentsUniform& segments) +void saveSegments(std::ofstream& file, int32_t NSegDim1, int32_t NSegDim2, int32_t NSegDim3, GPUDisplayMagneticField::SegmentsUniform& segments) { file.write(reinterpret_cast(&segments.MinZ), sizeof(segments.MinZ)); file.write(reinterpret_cast(&segments.MaxZ), sizeof(segments.MaxZ)); @@ -51,7 +51,7 @@ void saveSegments(std::ofstream& file, int NSegDim1, int NSegDim2, int NSegDim3, } template -void saveParams(std::ofstream& file, int numberOfParametrization, int Nrows, int Ncolums, int Ncoeffs, GPUDisplayMagneticField::ParametrizationUniform& param) +void saveParams(std::ofstream& file, int32_t numberOfParametrization, int32_t Nrows, int32_t Ncolums, int32_t Ncoeffs, GPUDisplayMagneticField::ParametrizationUniform& param) { file.write(reinterpret_cast(&numberOfParametrization), sizeof(std::int32_t)); @@ -66,20 +66,20 @@ void saveParams(std::ofstream& file, int numberOfParametrization, int Nrows, int file.write(reinterpret_cast(&Nrows), sizeof(std::int32_t)); - file.write(reinterpret_cast(param.NColsAtRow), Nrows * sizeof(int)); - file.write(reinterpret_cast(param.CofsAtColOffset), Nrows * sizeof(int)); + file.write(reinterpret_cast(param.NColsAtRow), Nrows * sizeof(int32_t)); + file.write(reinterpret_cast(param.CofsAtColOffset), Nrows * sizeof(int32_t)); - file.write(reinterpret_cast(&Ncolums), sizeof(int)); + file.write(reinterpret_cast(&Ncolums), sizeof(int32_t)); - file.write(reinterpret_cast(param.NCofsAtCol), Ncolums * sizeof(int)); - file.write(reinterpret_cast(param.AtColCoefOffset), Ncolums * sizeof(int)); + file.write(reinterpret_cast(param.NCofsAtCol), Ncolums * sizeof(int32_t)); + file.write(reinterpret_cast(param.AtColCoefOffset), Ncolums * sizeof(int32_t)); - file.write(reinterpret_cast(&Ncoeffs), sizeof(int)); + file.write(reinterpret_cast(&Ncoeffs), sizeof(int32_t)); file.write(reinterpret_cast(param.Coeffs), Ncoeffs * sizeof(float)); } -int main(int argc, char** argv) +int32_t main(int argc, char** argv) { bpo::options_description options("Field Uniform exporter options"); diff --git a/GPU/GPUTracking/display/render/GPUDisplayDraw.cxx b/GPU/GPUTracking/display/render/GPUDisplayDraw.cxx index 801ec0abddbe8..ab7ebf6811766 100644 --- a/GPU/GPUTracking/display/render/GPUDisplayDraw.cxx +++ b/GPU/GPUTracking/display/render/GPUDisplayDraw.cxx @@ -47,9 +47,9 @@ using namespace GPUCA_NAMESPACE::gpu; #define SEPERATE_GLOBAL_TRACKS_LIMIT (mCfgH.separateGlobalTracks ? tGLOBALTRACK : TRACK_TYPE_ID_LIMIT) const GPUTRDGeometry* GPUDisplay::trdGeometry() { return (GPUTRDGeometry*)mCalib->trdGeometry; } -const GPUTPCTracker& GPUDisplay::sliceTracker(int iSlice) { return mChain->GetTPCSliceTrackers()[iSlice]; } +const GPUTPCTracker& GPUDisplay::sliceTracker(int32_t iSlice) { return mChain->GetTPCSliceTrackers()[iSlice]; } -inline void GPUDisplay::insertVertexList(std::pair*, vecpod*>& vBuf, size_t first, size_t last) +inline void GPUDisplay::insertVertexList(std::pair*, vecpod*>& vBuf, size_t first, size_t last) { if (first == last) { return; @@ -57,13 +57,13 @@ inline void GPUDisplay::insertVertexList(std::pair*, vecpodemplace_back(first); vBuf.second->emplace_back(last - first); } -inline void GPUDisplay::insertVertexList(int iSlice, size_t first, size_t last) +inline void GPUDisplay::insertVertexList(int32_t iSlice, size_t first, size_t last) { - std::pair*, vecpod*> vBuf(mVertexBufferStart + iSlice, mVertexBufferCount + iSlice); + std::pair*, vecpod*> vBuf(mVertexBufferStart + iSlice, mVertexBufferCount + iSlice); insertVertexList(vBuf, first, last); } -inline void GPUDisplay::drawPointLinestrip(int iSlice, int cid, int id, int id_limit) +inline void GPUDisplay::drawPointLinestrip(int32_t iSlice, int32_t cid, int32_t id, int32_t id_limit) { mVertexBuffer[iSlice].emplace_back(mGlobalPos[cid].x, mGlobalPos[cid].y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPos[cid].z); if (mGlobalPos[cid].w < id_limit) { @@ -71,14 +71,14 @@ inline void GPUDisplay::drawPointLinestrip(int iSlice, int cid, int id, int id_l } } -GPUDisplay::vboList GPUDisplay::DrawSpacePointsTRD(int iSlice, int select, int iCol) +GPUDisplay::vboList GPUDisplay::DrawSpacePointsTRD(int32_t iSlice, int32_t select, int32_t iCol) { size_t startCount = mVertexBufferStart[iSlice].size(); size_t startCountInner = mVertexBuffer[iSlice].size(); if (iCol == 0) { - for (unsigned int i = 0; i < mIOPtrs->nTRDTracklets; i++) { - int iSec = trdGeometry()->GetSector(mIOPtrs->trdTracklets[i].GetDetector()); + for (uint32_t i = 0; i < mIOPtrs->nTRDTracklets; i++) { + int32_t iSec = trdGeometry()->GetSector(mIOPtrs->trdTracklets[i].GetDetector()); bool draw = iSlice == iSec && mGlobalPosTRD[i].w == select; if (draw) { mVertexBuffer[iSlice].emplace_back(mGlobalPosTRD[i].x, mGlobalPosTRD[i].y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTRD[i].z); @@ -91,13 +91,13 @@ GPUDisplay::vboList GPUDisplay::DrawSpacePointsTRD(int iSlice, int select, int i return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -GPUDisplay::vboList GPUDisplay::DrawSpacePointsTOF(int iSlice, int select, int iCol) +GPUDisplay::vboList GPUDisplay::DrawSpacePointsTOF(int32_t iSlice, int32_t select, int32_t iCol) { size_t startCount = mVertexBufferStart[iSlice].size(); size_t startCountInner = mVertexBuffer[iSlice].size(); if (iCol == 0 && iSlice == 0) { - for (unsigned int i = 0; i < mIOPtrs->nTOFClusters; i++) { + for (uint32_t i = 0; i < mIOPtrs->nTOFClusters; i++) { mVertexBuffer[iSlice].emplace_back(mGlobalPosTOF[i].x, mGlobalPosTOF[i].y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTOF[i].z); } } @@ -106,13 +106,13 @@ GPUDisplay::vboList GPUDisplay::DrawSpacePointsTOF(int iSlice, int select, int i return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -GPUDisplay::vboList GPUDisplay::DrawSpacePointsITS(int iSlice, int select, int iCol) +GPUDisplay::vboList GPUDisplay::DrawSpacePointsITS(int32_t iSlice, int32_t select, int32_t iCol) { size_t startCount = mVertexBufferStart[iSlice].size(); size_t startCountInner = mVertexBuffer[iSlice].size(); if (iCol == 0 && iSlice == 0 && mIOPtrs->itsClusters) { - for (unsigned int i = 0; i < mIOPtrs->nItsClusters; i++) { + for (uint32_t i = 0; i < mIOPtrs->nItsClusters; i++) { mVertexBuffer[iSlice].emplace_back(mGlobalPosITS[i].x, mGlobalPosITS[i].y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosITS[i].z); } } @@ -121,17 +121,16 @@ GPUDisplay::vboList GPUDisplay::DrawSpacePointsITS(int iSlice, int select, int i return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -GPUDisplay::vboList GPUDisplay::DrawClusters(int iSlice, int select, unsigned int iCol) +GPUDisplay::vboList GPUDisplay::DrawClusters(int32_t iSlice, int32_t select, uint32_t iCol) { size_t startCount = mVertexBufferStart[iSlice].size(); size_t startCountInner = mVertexBuffer[iSlice].size(); if (mOverlayTFClusters.size() > 0 || iCol == 0 || mNCollissions) { - const int firstCluster = (mOverlayTFClusters.size() > 1 && iCol > 0) ? mOverlayTFClusters[iCol - 1][iSlice] : 0; - const int lastCluster = (mOverlayTFClusters.size() > 1 && iCol + 1 < mOverlayTFClusters.size()) ? mOverlayTFClusters[iCol][iSlice] : (mParam->par.earlyTpcTransform ? mIOPtrs->nClusterData[iSlice] : mIOPtrs->clustersNative ? mIOPtrs->clustersNative->nClustersSector[iSlice] - : 0); + const int32_t firstCluster = (mOverlayTFClusters.size() > 1 && iCol > 0) ? mOverlayTFClusters[iCol - 1][iSlice] : 0; + const int32_t lastCluster = (mOverlayTFClusters.size() > 1 && iCol + 1 < mOverlayTFClusters.size()) ? mOverlayTFClusters[iCol][iSlice] : (mParam->par.earlyTpcTransform ? mIOPtrs->nClusterData[iSlice] : mIOPtrs->clustersNative ? mIOPtrs->clustersNative->nClustersSector[iSlice] : 0); const bool checkClusterCollision = mQA && mNCollissions && mOverlayTFClusters.size() == 0 && mIOPtrs->clustersNative && mIOPtrs->clustersNative->clustersMCTruth; - for (int cidInSlice = firstCluster; cidInSlice < lastCluster; cidInSlice++) { - const int cid = GET_CID(iSlice, cidInSlice); + for (int32_t cidInSlice = firstCluster; cidInSlice < lastCluster; cidInSlice++) { + const int32_t cid = GET_CID(iSlice, cidInSlice); #ifdef GPUCA_TPC_GEOMETRY_O2 if (checkClusterCollision) { const auto& labels = mIOPtrs->clustersNative->clustersMCTruth->getLabels(cid); @@ -148,7 +147,7 @@ GPUDisplay::vboList GPUDisplay::DrawClusters(int iSlice, int select, unsigned in bool draw = mGlobalPos[cid].w == select; if (mCfgH.markAdjacentClusters) { - const int attach = mIOPtrs->mergedTrackHitAttachment[cid]; + const int32_t attach = mIOPtrs->mergedTrackHitAttachment[cid]; if (attach) { if (mCfgH.markAdjacentClusters >= 32) { if (mQA && mQA->clusterRemovable(attach, mCfgH.markAdjacentClusters == 33)) { @@ -169,7 +168,7 @@ GPUDisplay::vboList GPUDisplay::DrawClusters(int iSlice, int select, unsigned in } } } else if (mCfgH.markClusters) { - short flags; + int16_t flags; if (mParam->par.earlyTpcTransform) { flags = mIOPtrs->clusterData[iSlice][cidInSlice].flags; } else { @@ -190,23 +189,23 @@ GPUDisplay::vboList GPUDisplay::DrawClusters(int iSlice, int select, unsigned in return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -GPUDisplay::vboList GPUDisplay::DrawLinks(const GPUTPCTracker& tracker, int id, bool dodown) +GPUDisplay::vboList GPUDisplay::DrawLinks(const GPUTPCTracker& tracker, int32_t id, bool dodown) { - int iSlice = tracker.ISlice(); + int32_t iSlice = tracker.ISlice(); if (mCfgH.clustersOnly) { return (vboList(0, 0, iSlice)); } size_t startCount = mVertexBufferStart[iSlice].size(); size_t startCountInner = mVertexBuffer[iSlice].size(); - for (int i = 0; i < GPUCA_ROW_COUNT; i++) { + for (int32_t i = 0; i < GPUCA_ROW_COUNT; i++) { const GPUTPCRow& row = tracker.Data().Row(i); if (i < GPUCA_ROW_COUNT - 2) { const GPUTPCRow& rowUp = tracker.Data().Row(i + 2); - for (int j = 0; j < row.NHits(); j++) { + for (int32_t j = 0; j < row.NHits(); j++) { if (tracker.Data().HitLinkUpData(row, j) != CALINK_INVAL) { - const int cid1 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, j)); - const int cid2 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(rowUp, tracker.Data().HitLinkUpData(row, j))); + const int32_t cid1 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, j)); + const int32_t cid2 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(rowUp, tracker.Data().HitLinkUpData(row, j))); drawPointLinestrip(iSlice, cid1, id); drawPointLinestrip(iSlice, cid2, id); } @@ -215,10 +214,10 @@ GPUDisplay::vboList GPUDisplay::DrawLinks(const GPUTPCTracker& tracker, int id, if (dodown && i >= 2) { const GPUTPCRow& rowDown = tracker.Data().Row(i - 2); - for (int j = 0; j < row.NHits(); j++) { + for (int32_t j = 0; j < row.NHits(); j++) { if (tracker.Data().HitLinkDownData(row, j) != CALINK_INVAL) { - const int cid1 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, j)); - const int cid2 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(rowDown, tracker.Data().HitLinkDownData(row, j))); + const int32_t cid1 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, j)); + const int32_t cid2 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(rowDown, tracker.Data().HitLinkDownData(row, j))); drawPointLinestrip(iSlice, cid1, id); drawPointLinestrip(iSlice, cid2, id); } @@ -231,19 +230,19 @@ GPUDisplay::vboList GPUDisplay::DrawLinks(const GPUTPCTracker& tracker, int id, GPUDisplay::vboList GPUDisplay::DrawSeeds(const GPUTPCTracker& tracker) { - int iSlice = tracker.ISlice(); + int32_t iSlice = tracker.ISlice(); if (mCfgH.clustersOnly) { return (vboList(0, 0, iSlice)); } size_t startCount = mVertexBufferStart[iSlice].size(); - for (unsigned int i = 0; i < *tracker.NStartHits(); i++) { + for (uint32_t i = 0; i < *tracker.NStartHits(); i++) { const GPUTPCHitId& hit = tracker.TrackletStartHit(i); size_t startCountInner = mVertexBuffer[iSlice].size(); - int ir = hit.RowIndex(); + int32_t ir = hit.RowIndex(); calink ih = hit.HitIndex(); do { const GPUTPCRow& row = tracker.Data().Row(ir); - const int cid = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, ih)); + const int32_t cid = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, ih)); drawPointLinestrip(iSlice, cid, tSEED); ir += 2; ih = tracker.Data().HitLinkUpData(row, ih); @@ -255,20 +254,20 @@ GPUDisplay::vboList GPUDisplay::DrawSeeds(const GPUTPCTracker& tracker) GPUDisplay::vboList GPUDisplay::DrawTracklets(const GPUTPCTracker& tracker) { - int iSlice = tracker.ISlice(); + int32_t iSlice = tracker.ISlice(); if (mCfgH.clustersOnly) { return (vboList(0, 0, iSlice)); } size_t startCount = mVertexBufferStart[iSlice].size(); - for (unsigned int i = 0; i < *tracker.NTracklets(); i++) { + for (uint32_t i = 0; i < *tracker.NTracklets(); i++) { const GPUTPCTracklet& tracklet = tracker.Tracklet(i); size_t startCountInner = mVertexBuffer[iSlice].size(); float4 oldpos; - for (int j = tracklet.FirstRow(); j <= tracklet.LastRow(); j++) { + for (int32_t j = tracklet.FirstRow(); j <= tracklet.LastRow(); j++) { const calink rowHit = tracker.TrackletRowHits()[tracklet.FirstHit() + (j - tracklet.FirstRow())]; if (rowHit != CALINK_INVAL && rowHit != CALINK_DEAD_CHANNEL) { const GPUTPCRow& row = tracker.Data().Row(j); - const int cid = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, rowHit)); + const int32_t cid = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, rowHit)); oldpos = mGlobalPos[cid]; drawPointLinestrip(iSlice, cid, tTRACKLET); } @@ -278,20 +277,20 @@ GPUDisplay::vboList GPUDisplay::DrawTracklets(const GPUTPCTracker& tracker) return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -GPUDisplay::vboList GPUDisplay::DrawTracks(const GPUTPCTracker& tracker, int global) +GPUDisplay::vboList GPUDisplay::DrawTracks(const GPUTPCTracker& tracker, int32_t global) { - int iSlice = tracker.ISlice(); + int32_t iSlice = tracker.ISlice(); if (mCfgH.clustersOnly) { return (vboList(0, 0, iSlice)); } size_t startCount = mVertexBufferStart[iSlice].size(); - for (unsigned int i = (global ? tracker.CommonMemory()->nLocalTracks : 0); i < (global ? *tracker.NTracks() : tracker.CommonMemory()->nLocalTracks); i++) { + for (uint32_t i = (global ? tracker.CommonMemory()->nLocalTracks : 0); i < (global ? *tracker.NTracks() : tracker.CommonMemory()->nLocalTracks); i++) { GPUTPCTrack& track = tracker.Tracks()[i]; size_t startCountInner = mVertexBuffer[iSlice].size(); - for (int j = 0; j < track.NHits(); j++) { + for (int32_t j = 0; j < track.NHits(); j++) { const GPUTPCHitId& hit = tracker.TrackHits()[track.FirstHitID() + j]; const GPUTPCRow& row = tracker.Data().Row(hit.RowIndex()); - const int cid = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, hit.HitIndex())); + const int32_t cid = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, hit.HitIndex())); drawPointLinestrip(iSlice, cid, tSLICETRACK + global); } insertVertexList(iSlice, startCountInner, mVertexBuffer[iSlice].size()); @@ -299,12 +298,12 @@ GPUDisplay::vboList GPUDisplay::DrawTracks(const GPUTPCTracker& tracker, int glo return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -void GPUDisplay::DrawTrackITS(int trackId, int iSlice) +void GPUDisplay::DrawTrackITS(int32_t trackId, int32_t iSlice) { #ifdef GPUCA_HAVE_O2HEADERS const auto& trk = mIOPtrs->itsTracks[trackId]; - for (int k = 0; k < trk.getNClusters(); k++) { - int cid = mIOPtrs->itsTrackClusIdx[trk.getFirstClusterEntry() + k]; + for (int32_t k = 0; k < trk.getNClusters(); k++) { + int32_t cid = mIOPtrs->itsTrackClusIdx[trk.getFirstClusterEntry() + k]; mVertexBuffer[iSlice].emplace_back(mGlobalPosITS[cid].x, mGlobalPosITS[cid].y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosITS[cid].z); mGlobalPosITS[cid].w = tITSATTACHED; } @@ -313,9 +312,9 @@ void GPUDisplay::DrawTrackITS(int trackId, int iSlice) GPUDisplay::vboList GPUDisplay::DrawFinalITS() { - const int iSlice = 0; + const int32_t iSlice = 0; size_t startCount = mVertexBufferStart[iSlice].size(); - for (unsigned int i = 0; i < mIOPtrs->nItsTracks; i++) { + for (uint32_t i = 0; i < mIOPtrs->nItsTracks; i++) { if (mITSStandaloneTracks[i]) { size_t startCountInner = mVertexBuffer[iSlice].size(); DrawTrackITS(i, iSlice); @@ -326,24 +325,24 @@ GPUDisplay::vboList GPUDisplay::DrawFinalITS() } template -void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, std::array, 2>& trackList, threadVertexBuffer& threadBuffer) +void GPUDisplay::DrawFinal(int32_t iSlice, int32_t /*iCol*/, GPUTPCGMPropagator* prop, std::array, 2>& trackList, threadVertexBuffer& threadBuffer) { auto& vBuf = threadBuffer.vBuf; auto& buffer = threadBuffer.buffer; - unsigned int nTracks = std::max(trackList[0].size(), trackList[1].size()); + uint32_t nTracks = std::max(trackList[0].size(), trackList[1].size()); if (mCfgH.clustersOnly) { nTracks = 0; } - for (unsigned int ii = 0; ii < nTracks; ii++) { - int i = 0; + for (uint32_t ii = 0; ii < nTracks; ii++) { + int32_t i = 0; const T* track = nullptr; - int lastCluster = -1; + int32_t lastCluster = -1; while (true) { if (ii >= trackList[0].size()) { break; } i = trackList[0][ii]; - int nClusters; + int32_t nClusters; if constexpr (std::is_same_v) { track = &mIOPtrs->mergedTracks[i]; nClusters = track->NClusters(); @@ -376,7 +375,7 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s // Print TOF part of track if constexpr (std::is_same_v) { if (mIOPtrs->tpcLinkTOF && mIOPtrs->tpcLinkTOF[i] != -1 && mIOPtrs->nTOFClusters) { - int cid = mIOPtrs->tpcLinkTOF[i]; + int32_t cid = mIOPtrs->tpcLinkTOF[i]; drawing = true; mVertexBuffer[iSlice].emplace_back(mGlobalPosTOF[cid].x, mGlobalPosTOF[cid].y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTOF[cid].z); mGlobalPosTOF[cid].w = tTOFATTACHED; @@ -385,8 +384,8 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s // Print TRD part of track auto tmpDoTRDTracklets = [&](const auto& trk) { - for (int k = 5; k >= 0; k--) { - int cid = trk.getTrackletIndex(k); + for (int32_t k = 5; k >= 0; k--) { + int32_t cid = trk.getTrackletIndex(k); if (cid < 0) { continue; } @@ -397,7 +396,7 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s } }; if (std::is_same_v || (!mIOPtrs->tpcLinkTRD && mIOPtrs->trdTracksO2)) { - if (mChain && ((int)mConfig.showTPCTracksFromO2Format == (int)mChain->GetProcessingSettings().trdTrackModelO2) && mTRDTrackIds[i] != -1 && mIOPtrs->nTRDTracklets) { + if (mChain && ((int32_t)mConfig.showTPCTracksFromO2Format == (int32_t)mChain->GetProcessingSettings().trdTrackModelO2) && mTRDTrackIds[i] != -1 && mIOPtrs->nTRDTracklets) { if (mIOPtrs->trdTracksO2) { #ifdef GPUCA_HAVE_O2HEADERS tmpDoTRDTracklets(mIOPtrs->trdTracksO2[mTRDTrackIds[i]]); @@ -417,19 +416,19 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s } // Print TPC part of track - for (int k = 0; k < nClusters; k++) { + for (int32_t k = 0; k < nClusters; k++) { if constexpr (std::is_same_v) { if (mCfgH.hideRejectedClusters && (mIOPtrs->mergedTrackHits[track->FirstClusterRef() + k].state & GPUTPCGMMergedTrackHit::flagReject)) { continue; } } - int cid; + int32_t cid; if constexpr (std::is_same_v) { cid = mIOPtrs->mergedTrackHits[track->FirstClusterRef() + k].num; } else { cid = &track->getCluster(mIOPtrs->outputClusRefsTPCO2, k, *mIOPtrs->clustersNative) - mIOPtrs->clustersNative->clustersLinear; } - int w = mGlobalPos[cid].w; + int32_t w = mGlobalPos[cid].w; if (drawing) { drawPointLinestrip(iSlice, cid, tFINALTRACK, SEPERATE_GLOBAL_TRACKS_LIMIT); } @@ -473,7 +472,7 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s } // Propagate track paramters / plot MC tracks - for (int iMC = 0; iMC < 2; iMC++) { + for (int32_t iMC = 0; iMC < 2; iMC++) { if (iMC) { if (ii >= trackList[1].size()) { continue; @@ -489,7 +488,7 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s } size_t startCountInner = mVertexBuffer[iSlice].size(); - for (int inFlyDirection = 0; inFlyDirection < 2; inFlyDirection++) { + for (int32_t inFlyDirection = 0; inFlyDirection < 2; inFlyDirection++) { GPUTPCGMPhysicalTrackModel trkParam; float ZOffset = 0; float x = 0; @@ -575,7 +574,7 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s } float alpha = alphaOrg; vecpod& useBuffer = iMC && inFlyDirection == 0 ? buffer : mVertexBuffer[iSlice]; - int nPoints = 0; + int32_t nPoints = 0; while (nPoints++ < 5000) { if ((inFlyDirection == 0 && x < 0) || (inFlyDirection && x * x + trkParam.Y() * trkParam.Y() > (iMC ? (450 * 450) : (300 * 300)))) { @@ -619,7 +618,7 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s if (inFlyDirection == 0) { if (iMC) { - for (int k = (int)buffer.size() - 1; k >= 0; k--) { + for (int32_t k = (int32_t)buffer.size() - 1; k >= 0; k--) { mVertexBuffer[iSlice].emplace_back(buffer[k]); } } else { @@ -635,12 +634,12 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s GPUDisplay::vboList GPUDisplay::DrawGrid(const GPUTPCTracker& tracker) { - int iSlice = tracker.ISlice(); + int32_t iSlice = tracker.ISlice(); size_t startCount = mVertexBufferStart[iSlice].size(); size_t startCountInner = mVertexBuffer[iSlice].size(); - for (int i = 0; i < GPUCA_ROW_COUNT; i++) { + for (int32_t i = 0; i < GPUCA_ROW_COUNT; i++) { const GPUTPCRow& row = tracker.Data().Row(i); - for (int j = 0; j <= (signed)row.Grid().Ny(); j++) { + for (int32_t j = 0; j <= (signed)row.Grid().Ny(); j++) { float z1 = row.Grid().ZMin(); float z2 = row.Grid().ZMax(); float x = row.X() + mCfgH.xAdd; @@ -658,7 +657,7 @@ GPUDisplay::vboList GPUDisplay::DrawGrid(const GPUTPCTracker& tracker) mVertexBuffer[iSlice].emplace_back(xx1 * GL_SCALE_FACTOR, yy1 * GL_SCALE_FACTOR * mYFactor, zz1 * GL_SCALE_FACTOR); mVertexBuffer[iSlice].emplace_back(xx2 * GL_SCALE_FACTOR, yy2 * GL_SCALE_FACTOR * mYFactor, zz2 * GL_SCALE_FACTOR); } - for (int j = 0; j <= (signed)row.Grid().Nz(); j++) { + for (int32_t j = 0; j <= (signed)row.Grid().Nz(); j++) { float y1 = row.Grid().YMin(); float y2 = row.Grid().YMax(); float x = row.X() + mCfgH.xAdd; @@ -681,7 +680,7 @@ GPUDisplay::vboList GPUDisplay::DrawGrid(const GPUTPCTracker& tracker) return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -GPUDisplay::vboList GPUDisplay::DrawGridTRD(int sector) +GPUDisplay::vboList GPUDisplay::DrawGridTRD(int32_t sector) { // TODO: tilted pads ignored at the moment size_t startCount = mVertexBufferStart[sector].size(); @@ -689,20 +688,20 @@ GPUDisplay::vboList GPUDisplay::DrawGridTRD(int sector) #ifdef GPUCA_HAVE_O2HEADERS auto* geo = trdGeometry(); if (geo) { - int trdsector = NSLICES / 2 - 1 - sector; + int32_t trdsector = NSLICES / 2 - 1 - sector; float alpha = geo->GetAlpha() / 2.f + geo->GetAlpha() * trdsector; if (trdsector >= 9) { alpha -= 2 * CAMath::Pi(); } - for (int iLy = 0; iLy < GPUTRDTracker::EGPUTRDTracker::kNLayers; ++iLy) { - for (int iStack = 0; iStack < GPUTRDTracker::EGPUTRDTracker::kNStacks; ++iStack) { - int iDet = geo->GetDetector(iLy, iStack, trdsector); + for (int32_t iLy = 0; iLy < GPUTRDTracker::EGPUTRDTracker::kNLayers; ++iLy) { + for (int32_t iStack = 0; iStack < GPUTRDTracker::EGPUTRDTracker::kNStacks; ++iStack) { + int32_t iDet = geo->GetDetector(iLy, iStack, trdsector); auto matrix = geo->GetClusterMatrix(iDet); if (!matrix) { continue; } auto pp = geo->GetPadPlane(iDet); - for (int i = 0; i < pp->GetNrows(); ++i) { + for (int32_t i = 0; i < pp->GetNrows(); ++i) { float xyzLoc1[3]; float xyzLoc2[3]; float xyzGlb1[3]; @@ -722,7 +721,7 @@ GPUDisplay::vboList GPUDisplay::DrawGridTRD(int sector) mVertexBuffer[sector].emplace_back(xyzGlb1[0] * GL_SCALE_FACTOR, xyzGlb1[1] * GL_SCALE_FACTOR * mYFactor, xyzGlb1[2] * GL_SCALE_FACTOR); mVertexBuffer[sector].emplace_back(xyzGlb2[0] * GL_SCALE_FACTOR, xyzGlb2[1] * GL_SCALE_FACTOR * mYFactor, xyzGlb2[2] * GL_SCALE_FACTOR); } - for (int j = 0; j < pp->GetNcols(); ++j) { + for (int32_t j = 0; j < pp->GetNcols(); ++j) { float xyzLoc1[3]; float xyzLoc2[3]; float xyzGlb1[3]; @@ -752,38 +751,38 @@ GPUDisplay::vboList GPUDisplay::DrawGridTRD(int sector) size_t GPUDisplay::DrawGLScene_updateVertexList() { - for (int i = 0; i < NSLICES; i++) { + for (int32_t i = 0; i < NSLICES; i++) { mVertexBuffer[i].clear(); mVertexBufferStart[i].clear(); mVertexBufferCount[i].clear(); } - for (int i = 0; i < mCurrentClusters; i++) { + for (int32_t i = 0; i < mCurrentClusters; i++) { mGlobalPos[i].w = tCLUSTER; } - for (int i = 0; i < mCurrentSpacePointsTRD; i++) { + for (int32_t i = 0; i < mCurrentSpacePointsTRD; i++) { mGlobalPosTRD[i].w = tTRDCLUSTER; } - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - for (int i = 0; i < N_POINTS_TYPE; i++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t i = 0; i < N_POINTS_TYPE; i++) { mGlDLPoints[iSlice][i].resize(mNCollissions); } - for (int i = 0; i < N_FINAL_TYPE; i++) { + for (int32_t i = 0; i < N_FINAL_TYPE; i++) { mGlDLFinal[iSlice].resize(mNCollissions); } } GPUCA_OPENMP(parallel num_threads(getNumThreads())) { #ifdef WITH_OPENMP - int numThread = omp_get_thread_num(); - int numThreads = omp_get_num_threads(); + int32_t numThread = omp_get_thread_num(); + int32_t numThreads = omp_get_num_threads(); #else - int numThread = 0, numThreads = 1; + int32_t numThread = 0, numThreads = 1; #endif if (mChain && (mChain->GetRecoSteps() & GPUDataTypes::RecoStep::TPCSliceTracking)) { GPUCA_OPENMP(for) - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { GPUTPCTracker& tracker = (GPUTPCTracker&)sliceTracker(iSlice); tracker.SetPointersDataLinks(tracker.LinkTmpMemory()); mGlDLLines[iSlice][tINITLINK] = DrawLinks(tracker, tINITLINK, true); @@ -792,7 +791,7 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() GPUCA_OPENMP(barrier) GPUCA_OPENMP(for) - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { const GPUTPCTracker& tracker = sliceTracker(iSlice); mGlDLLines[iSlice][tLINK] = DrawLinks(tracker, tLINK); @@ -807,25 +806,25 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() GPUCA_OPENMP(barrier) GPUCA_OPENMP(for) - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { const GPUTPCTracker& tracker = sliceTracker(iSlice); mGlDLLines[iSlice][tGLOBALTRACK] = DrawTracks(tracker, 1); } GPUCA_OPENMP(barrier) } mThreadTracks[numThread].resize(mNCollissions); - for (int i = 0; i < mNCollissions; i++) { - for (int j = 0; j < NSLICES; j++) { - for (int k = 0; k < 2; k++) { + for (int32_t i = 0; i < mNCollissions; i++) { + for (int32_t j = 0; j < NSLICES; j++) { + for (int32_t k = 0; k < 2; k++) { mThreadTracks[numThread][i][j][k].clear(); } } } if (mConfig.showTPCTracksFromO2Format) { #ifdef GPUCA_TPC_GEOMETRY_O2 - unsigned int col = 0; + uint32_t col = 0; GPUCA_OPENMP(for) - for (unsigned int i = 0; i < mIOPtrs->nOutputTracksTPCO2; i++) { + for (uint32_t i = 0; i < mIOPtrs->nOutputTracksTPCO2; i++) { uint8_t sector, row; if (mIOPtrs->clustersNative) { mIOPtrs->outputTracksTPCO2[i].getCluster(mIOPtrs->outputClusRefsTPCO2, 0, *mIOPtrs->clustersNative, sector, row); @@ -840,7 +839,7 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() #endif } else { GPUCA_OPENMP(for) - for (unsigned int i = 0; i < mIOPtrs->nMergedTracks; i++) { + for (uint32_t i = 0; i < mIOPtrs->nMergedTracks; i++) { const GPUTPCGMMergedTrack* track = &mIOPtrs->mergedTracks[i]; if (track->NClusters() == 0) { continue; @@ -848,8 +847,8 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() if (mCfgH.hideRejectedTracks && !track->OK()) { continue; } - int slice = mIOPtrs->mergedTrackHits[track->FirstClusterRef() + track->NClusters() - 1].slice; - unsigned int col = 0; + int32_t slice = mIOPtrs->mergedTrackHits[track->FirstClusterRef() + track->NClusters() - 1].slice; + uint32_t col = 0; if (mQA) { const auto& label = mQA->GetMCTrackLabel(i); #ifdef GPUCA_TPC_GEOMETRY_O2 @@ -863,9 +862,9 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() mThreadTracks[numThread][col][slice][0].emplace_back(i); } } - for (unsigned int col = 0; col < mIOPtrs->nMCInfosTPCCol; col++) { + for (uint32_t col = 0; col < mIOPtrs->nMCInfosTPCCol; col++) { GPUCA_OPENMP(for) - for (unsigned int i = mIOPtrs->mcInfosTPCCol[col].first; i < mIOPtrs->mcInfosTPCCol[col].first + mIOPtrs->mcInfosTPCCol[col].num; i++) { + for (uint32_t i = mIOPtrs->mcInfosTPCCol[col].first; i < mIOPtrs->mcInfosTPCCol[col].first + mIOPtrs->mcInfosTPCCol[col].num; i++) { const GPUTPCMCInfo& mc = mIOPtrs->mcInfosTPC[i]; if (mc.charge == 0.f) { continue; @@ -878,7 +877,7 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() if (alpha < 0) { alpha += 2 * CAMath::Pi(); } - int slice = alpha / (2 * CAMath::Pi()) * 18; + int32_t slice = alpha / (2 * CAMath::Pi()) * 18; if (mc.z < 0) { slice += 18; } @@ -893,10 +892,10 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() prop.SetPolynomialField(&mParam->polynomialField); GPUCA_OPENMP(for) - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - for (int iCol = 0; iCol < mNCollissions; iCol++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t iCol = 0; iCol < mNCollissions; iCol++) { mThreadBuffers[numThread].clear(); - for (int iSet = 0; iSet < numThreads; iSet++) { + for (int32_t iSet = 0; iSet < numThreads; iSet++) { #ifdef GPUCA_HAVE_O2HEADERS if (mConfig.showTPCTracksFromO2Format) { DrawFinal(iSlice, iCol, &prop, mThreadTracks[iSet][iCol][iSlice], mThreadBuffers[numThread]); @@ -907,9 +906,9 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() } } vboList* list = &mGlDLFinal[iSlice][iCol][0]; - for (int i = 0; i < N_FINAL_TYPE; i++) { + for (int32_t i = 0; i < N_FINAL_TYPE; i++) { size_t startCount = mVertexBufferStart[iSlice].size(); - for (unsigned int j = 0; j < mThreadBuffers[numThread].start[i].size(); j++) { + for (uint32_t j = 0; j < mThreadBuffers[numThread].start[i].size(); j++) { mVertexBufferStart[iSlice].emplace_back(mThreadBuffers[numThread].start[i][j]); mVertexBufferCount[iSlice].emplace_back(mThreadBuffers[numThread].count[i][j]); } @@ -920,9 +919,9 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() GPUCA_OPENMP(barrier) GPUCA_OPENMP(for) - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - for (int i = 0; i < N_POINTS_TYPE_TPC; i++) { - for (int iCol = 0; iCol < mNCollissions; iCol++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t i = 0; i < N_POINTS_TYPE_TPC; i++) { + for (int32_t iCol = 0; iCol < mNCollissions; iCol++) { mGlDLPoints[iSlice][i][iCol] = DrawClusters(iSlice, i, iCol); } } @@ -932,26 +931,26 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() mGlDLFinalITS = DrawFinalITS(); - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - for (int i = N_POINTS_TYPE_TPC; i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD; i++) { - for (int iCol = 0; iCol < mNCollissions; iCol++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t i = N_POINTS_TYPE_TPC; i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD; i++) { + for (int32_t iCol = 0; iCol < mNCollissions; iCol++) { mGlDLPoints[iSlice][i][iCol] = DrawSpacePointsTRD(iSlice, i, iCol); } } } - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - for (int i = N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD; i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF; i++) { - for (int iCol = 0; iCol < mNCollissions; iCol++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t i = N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD; i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF; i++) { + for (int32_t iCol = 0; iCol < mNCollissions; iCol++) { mGlDLPoints[iSlice][i][iCol] = DrawSpacePointsTOF(iSlice, i, iCol); } } break; // TODO: Only slice 0 filled for now } - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - for (int i = N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF; i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF + N_POINTS_TYPE_ITS; i++) { - for (int iCol = 0; iCol < mNCollissions; iCol++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t i = N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF; i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF + N_POINTS_TYPE_ITS; i++) { + for (int32_t iCol = 0; iCol < mNCollissions; iCol++) { mGlDLPoints[iSlice][i][iCol] = DrawSpacePointsITS(iSlice, i, iCol); } } @@ -960,19 +959,19 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() mUpdateVertexLists = 0; size_t totalVertizes = 0; - for (int i = 0; i < NSLICES; i++) { + for (int32_t i = 0; i < NSLICES; i++) { totalVertizes += mVertexBuffer[i].size(); } if (totalVertizes > 0xFFFFFFFF) { - throw std::runtime_error("Display vertex count exceeds 32bit uint counter"); + throw std::runtime_error("Display vertex count exceeds 32bit uint32_t counter"); } size_t needMultiVBOSize = mBackend->needMultiVBO(); mUseMultiVBO = needMultiVBOSize && (totalVertizes * sizeof(mVertexBuffer[0][0]) >= needMultiVBOSize); if (!mUseMultiVBO) { size_t totalYet = mVertexBuffer[0].size(); mVertexBuffer[0].resize(totalVertizes); - for (int i = 1; i < GPUCA_NSLICES; i++) { - for (unsigned int j = 0; j < mVertexBufferStart[i].size(); j++) { + for (int32_t i = 1; i < GPUCA_NSLICES; i++) { + for (uint32_t j = 0; j < mVertexBufferStart[i].size(); j++) { mVertexBufferStart[i][j] += totalYet; } memcpy(&mVertexBuffer[0][totalYet], &mVertexBuffer[i][0], mVertexBuffer[i].size() * sizeof(mVertexBuffer[i][0])); @@ -981,7 +980,7 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() } } mBackend->loadDataToGPU(totalVertizes); - for (int i = 0; i < (mUseMultiVBO ? GPUCA_NSLICES : 1); i++) { + for (int32_t i = 0; i < (mUseMultiVBO ? GPUCA_NSLICES : 1); i++) { mVertexBuffer[i].clear(); } return totalVertizes; diff --git a/GPU/GPUTracking/display/render/GPUDisplayImportEvent.cxx b/GPU/GPUTracking/display/render/GPUDisplayImportEvent.cxx index b1e6dfe21fb97..072119f7d528f 100644 --- a/GPU/GPUTracking/display/render/GPUDisplayImportEvent.cxx +++ b/GPU/GPUTracking/display/render/GPUDisplayImportEvent.cxx @@ -44,7 +44,7 @@ void GPUDisplay::DrawGLScene_updateEventData() mCurrentClusters = mIOPtrs->clustersNative->nClustersTotal; } else { mCurrentClusters = 0; - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { mCurrentClusters += mIOPtrs->nClusterData[iSlice]; } } @@ -77,18 +77,18 @@ void GPUDisplay::DrawGLScene_updateEventData() mGlobalPosTOF = mGlobalPosPtrTOF.get(); } - unsigned int nTpcMergedTracks = mConfig.showTPCTracksFromO2Format ? mIOPtrs->nOutputTracksTPCO2 : mIOPtrs->nMergedTracks; + uint32_t nTpcMergedTracks = mConfig.showTPCTracksFromO2Format ? mIOPtrs->nOutputTracksTPCO2 : mIOPtrs->nMergedTracks; if ((size_t)nTpcMergedTracks > mTRDTrackIds.size()) { mTRDTrackIds.resize(nTpcMergedTracks); } if (mIOPtrs->nItsTracks > mITSStandaloneTracks.size()) { mITSStandaloneTracks.resize(mIOPtrs->nItsTracks); } - for (unsigned int i = 0; i < nTpcMergedTracks; i++) { + for (uint32_t i = 0; i < nTpcMergedTracks; i++) { mTRDTrackIds[i] = -1; } auto tmpDoTRDTracklets = [&](auto* trdTracks) { - for (unsigned int i = 0; i < mIOPtrs->nTRDTracks; i++) { + for (uint32_t i = 0; i < mIOPtrs->nTRDTracks; i++) { if (trdTracks[i].getNtracklets()) { mTRDTrackIds[trdTracks[i].getRefGlobalTrackIdRaw()] = i; } @@ -104,7 +104,7 @@ void GPUDisplay::DrawGLScene_updateEventData() if (mIOPtrs->nItsTracks) { std::fill(mITSStandaloneTracks.begin(), mITSStandaloneTracks.end(), true); if (mIOPtrs->tpcLinkITS) { - for (unsigned int i = 0; i < nTpcMergedTracks; i++) { + for (uint32_t i = 0; i < nTpcMergedTracks; i++) { if (mIOPtrs->tpcLinkITS[i] != -1) { mITSStandaloneTracks[mIOPtrs->tpcLinkITS[i]] = false; } @@ -113,18 +113,18 @@ void GPUDisplay::DrawGLScene_updateEventData() } if (mCfgH.trackFilter) { - unsigned int nTracks = mConfig.showTPCTracksFromO2Format ? mIOPtrs->nOutputTracksTPCO2 : mIOPtrs->nMergedTracks; + uint32_t nTracks = mConfig.showTPCTracksFromO2Format ? mIOPtrs->nOutputTracksTPCO2 : mIOPtrs->nMergedTracks; mTrackFilter.resize(nTracks); std::fill(mTrackFilter.begin(), mTrackFilter.end(), true); if (buildTrackFilter()) { SetInfo("Error running track filter from %s", mConfig.filterMacros[mCfgH.trackFilter - 1].c_str()); } else { - unsigned int nFiltered = 0; - for (unsigned int i = 0; i < mTrackFilter.size(); i++) { + uint32_t nFiltered = 0; + for (uint32_t i = 0; i < mTrackFilter.size(); i++) { nFiltered += !mTrackFilter[i]; } if (mUpdateTrackFilter) { - SetInfo("Applied track filter %s - filtered %u / %u", mConfig.filterMacros[mCfgH.trackFilter - 1].c_str(), nFiltered, (unsigned int)mTrackFilter.size()); + SetInfo("Applied track filter %s - filtered %u / %u", mConfig.filterMacros[mCfgH.trackFilter - 1].c_str(), nFiltered, (uint32_t)mTrackFilter.size()); } } } @@ -132,19 +132,19 @@ void GPUDisplay::DrawGLScene_updateEventData() mMaxClusterZ = 0; GPUCA_OPENMP(parallel for num_threads(getNumThreads()) reduction(max : mMaxClusterZ)) - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - int row = 0; - unsigned int nCls = mParam->par.earlyTpcTransform ? mIOPtrs->nClusterData[iSlice] : mIOPtrs->clustersNative ? mIOPtrs->clustersNative->nClustersSector[iSlice] - : 0; - for (unsigned int i = 0; i < nCls; i++) { - int cid; + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + int32_t row = 0; + uint32_t nCls = mParam->par.earlyTpcTransform ? mIOPtrs->nClusterData[iSlice] : mIOPtrs->clustersNative ? mIOPtrs->clustersNative->nClustersSector[iSlice] + : 0; + for (uint32_t i = 0; i < nCls; i++) { + int32_t cid; if (mParam->par.earlyTpcTransform) { const auto& cl = mIOPtrs->clusterData[iSlice][i]; cid = cl.id; row = cl.row; } else { cid = mIOPtrs->clustersNative->clusterOffset[iSlice][0] + i; - while (row < GPUCA_ROW_COUNT - 1 && mIOPtrs->clustersNative->clusterOffset[iSlice][row + 1] <= (unsigned int)cid) { + while (row < GPUCA_ROW_COUNT - 1 && mIOPtrs->clustersNative->clusterOffset[iSlice][row + 1] <= (uint32_t)cid) { row++; } } @@ -176,11 +176,11 @@ void GPUDisplay::DrawGLScene_updateEventData() } } - int trdTriggerRecord = -1; + int32_t trdTriggerRecord = -1; float trdZoffset = 0; GPUCA_OPENMP(parallel for num_threads(getNumThreads()) reduction(max : mMaxClusterZ) firstprivate(trdTriggerRecord, trdZoffset)) - for (int i = 0; i < mCurrentSpacePointsTRD; i++) { - while (mParam->par.continuousTracking && trdTriggerRecord < (int)mIOPtrs->nTRDTriggerRecords - 1 && mIOPtrs->trdTrackletIdxFirst[trdTriggerRecord + 1] <= i) { + for (int32_t i = 0; i < mCurrentSpacePointsTRD; i++) { + while (mParam->par.continuousTracking && trdTriggerRecord < (int32_t)mIOPtrs->nTRDTriggerRecords - 1 && mIOPtrs->trdTrackletIdxFirst[trdTriggerRecord + 1] <= i) { trdTriggerRecord++; #ifdef GPUCA_HAVE_O2HEADERS float trdTime = mIOPtrs->trdTriggerTimes[trdTriggerRecord] * 1e3 / o2::constants::lhc::LHCBunchSpacingNS / o2::tpc::constants::LHCBCPERTIMEBIN; @@ -188,7 +188,7 @@ void GPUDisplay::DrawGLScene_updateEventData() #endif } const auto& sp = mIOPtrs->trdSpacePoints[i]; - int iSec = trdGeometry()->GetSector(mIOPtrs->trdTracklets[i].GetDetector()); + int32_t iSec = trdGeometry()->GetSector(mIOPtrs->trdTracklets[i].GetDetector()); float4* ptr = &mGlobalPosTRD[i]; mParam->Slice2Global(iSec, sp.getX() + mCfgH.xAdd, sp.getY(), sp.getZ(), &ptr->x, &ptr->y, &ptr->z); ptr->z += ptr->z > 0 ? trdZoffset : -trdZoffset; @@ -212,7 +212,7 @@ void GPUDisplay::DrawGLScene_updateEventData() } GPUCA_OPENMP(parallel for num_threads(getNumThreads()) reduction(max : mMaxClusterZ)) - for (int i = 0; i < mCurrentClustersTOF; i++) { + for (int32_t i = 0; i < mCurrentClustersTOF; i++) { #ifdef GPUCA_HAVE_O2HEADERS float4* ptr = &mGlobalPosTOF[i]; mParam->Slice2Global(mIOPtrs->tofClusters[i].getSector(), mIOPtrs->tofClusters[i].getX() + mCfgH.xAdd, mIOPtrs->tofClusters[i].getY(), mIOPtrs->tofClusters[i].getZ(), &ptr->x, &ptr->y, &ptr->z); @@ -241,8 +241,8 @@ void GPUDisplay::DrawGLScene_updateEventData() itsROFhalfLen = alpParams.roFrameLengthInBC / (float)o2::tpc::constants::LHCBCPERTIMEBIN / 2; } #endif - int i = 0; - for (unsigned int j = 0; j < mIOPtrs->nItsClusterROF; j++) { + int32_t i = 0; + for (uint32_t j = 0; j < mIOPtrs->nItsClusterROF; j++) { float ZOffset = 0; if (mParam->par.continuousTracking) { o2::InteractionRecord startIR = o2::InteractionRecord(0, mIOPtrs->settingsTF && mIOPtrs->settingsTF->hasTfStartOrbit ? mIOPtrs->settingsTF->tfStartOrbit : 0); @@ -252,7 +252,7 @@ void GPUDisplay::DrawGLScene_updateEventData() if (i != mIOPtrs->itsClusterROF[j].getFirstEntry()) { throw std::runtime_error("Inconsistent ITS data, number of clusters does not match ROF content"); } - for (int k = 0; k < mIOPtrs->itsClusterROF[j].getNEntries(); k++) { + for (int32_t k = 0; k < mIOPtrs->itsClusterROF[j].getNEntries(); k++) { float4* ptr = &mGlobalPosITS[i]; const auto& cl = mIOPtrs->itsClusters[i]; auto* itsGeo = o2::its::GeometryTGeo::Instance(); diff --git a/GPU/GPUTracking/display/shaders/GPUDisplayShaders.h b/GPU/GPUTracking/display/shaders/GPUDisplayShaders.h index 9f365d59ecc5b..ff22006ceb37e 100644 --- a/GPU/GPUTracking/display/shaders/GPUDisplayShaders.h +++ b/GPU/GPUTracking/display/shaders/GPUDisplayShaders.h @@ -126,7 +126,7 @@ void main() static constexpr const char* fieldModelShaderCode = R"( layout(std430, binding = 0) restrict readonly buffer field_config_ssbo { - uint StepCount; + uint32_t StepCount; float StepSize; } field_config; @@ -135,19 +135,19 @@ layout(std430, binding = 1) restrict readonly buffer sol_segment_ssbo { float MaxZ; float MultiplicativeFactor; - int ZSegments; + int32_t ZSegments; float SegZSol[SOL_Z_SEGS]; - int BegSegPSol[SOL_Z_SEGS]; - int NSegPSol[SOL_Z_SEGS]; + int32_t BegSegPSol[SOL_Z_SEGS]; + int32_t NSegPSol[SOL_Z_SEGS]; float SegPSol[SOL_P_SEGS]; - int BegSegRSol[SOL_P_SEGS]; - int NSegRSol[SOL_P_SEGS]; + int32_t BegSegRSol[SOL_P_SEGS]; + int32_t NSegRSol[SOL_P_SEGS]; float SegRSol[SOL_R_SEGS]; - int SegIDSol[SOL_R_SEGS]; + int32_t SegIDSol[SOL_R_SEGS]; } sol_segment; layout(std430, binding = 2) restrict readonly buffer dip_segment_ssbo { @@ -155,19 +155,19 @@ layout(std430, binding = 2) restrict readonly buffer dip_segment_ssbo { float MaxZ; float MultiplicativeFactor; - int ZSegments; + int32_t ZSegments; float SegZDip[DIP_Z_SEGS]; - int BegSegYDip[DIP_Z_SEGS]; - int NSegYDip[DIP_Z_SEGS]; + int32_t BegSegYDip[DIP_Z_SEGS]; + int32_t NSegYDip[DIP_Z_SEGS]; float SegYDip[DIP_Y_SEGS]; - int BegSegXDip[DIP_Y_SEGS]; - int NSegXDip[DIP_Y_SEGS]; + int32_t BegSegXDip[DIP_Y_SEGS]; + int32_t NSegXDip[DIP_Y_SEGS]; float SegXDip[DIP_X_SEGS]; - int SegIDDip[DIP_X_SEGS]; + int32_t SegIDDip[DIP_X_SEGS]; } dip_segment; layout(std430, binding = 3) restrict readonly buffer sol_params_ssbo { @@ -175,15 +175,15 @@ layout(std430, binding = 3) restrict readonly buffer sol_params_ssbo { float BScales[DIMENSIONS*SOL_PARAMS]; float BMin[DIMENSIONS*SOL_PARAMS]; float BMax[DIMENSIONS*SOL_PARAMS]; - int NRows[DIMENSIONS*SOL_PARAMS]; - int ColsAtRowOffset[DIMENSIONS*SOL_PARAMS]; - int CofsAtRowOffset[DIMENSIONS*SOL_PARAMS]; + int32_t NRows[DIMENSIONS*SOL_PARAMS]; + int32_t ColsAtRowOffset[DIMENSIONS*SOL_PARAMS]; + int32_t CofsAtRowOffset[DIMENSIONS*SOL_PARAMS]; - int NColsAtRow[SOL_ROWS]; - int CofsAtColOffset[SOL_ROWS]; + int32_t NColsAtRow[SOL_ROWS]; + int32_t CofsAtColOffset[SOL_ROWS]; - int NCofsAtCol[SOL_COLUMNS]; - int AtColCoefOffset[SOL_COLUMNS]; + int32_t NCofsAtCol[SOL_COLUMNS]; + int32_t AtColCoefOffset[SOL_COLUMNS]; float Coeffs[SOL_COEFFS]; } sol_params; @@ -193,15 +193,15 @@ layout(std430, binding = 4) restrict readonly buffer dip_params_ssbo { float BScales[DIMENSIONS*DIP_PARAMS]; float BMin[DIMENSIONS*DIP_PARAMS]; float BMax[DIMENSIONS*DIP_PARAMS]; - int NRows[DIMENSIONS*DIP_PARAMS]; - int ColsAtRowOffset[DIMENSIONS*DIP_PARAMS]; - int CofsAtRowOffset[DIMENSIONS*DIP_PARAMS]; + int32_t NRows[DIMENSIONS*DIP_PARAMS]; + int32_t ColsAtRowOffset[DIMENSIONS*DIP_PARAMS]; + int32_t CofsAtRowOffset[DIMENSIONS*DIP_PARAMS]; - int NColsAtRow[DIP_ROWS]; - int CofsAtColOffset[DIP_ROWS]; + int32_t NColsAtRow[DIP_ROWS]; + int32_t CofsAtColOffset[DIP_ROWS]; - int NCofsAtCol[DIP_COLUMNS]; - int AtColCoefOffset[DIP_COLUMNS]; + int32_t NCofsAtCol[DIP_COLUMNS]; + int32_t AtColCoefOffset[DIP_COLUMNS]; float Coeffs[DIP_COEFFS]; } dip_params; @@ -213,18 +213,18 @@ vec3 CarttoCyl(vec3 pos) { return vec3(length(pos.xy), atan(pos.y, pos.x), pos.z); } -int findSolSegment(vec3 pos) { - int rid,pid,zid; +int32_t findSolSegment(vec3 pos) { + int32_t rid,pid,zid; for(zid=0; zid < sol_segment.ZSegments; zid++) if(pos.z=0;i--) { + for (int32_t i=ncf;i>=0;i--) { b.zy = b.yx; b.x = arr[i]; b.x = dot(t1, b); @@ -287,7 +287,7 @@ float cheb1DArray(float x, float arr[MAX_CHEB_ORDER], int ncf) { return dot(t, b); } -float cheb1DParamsSol(float x, int coeff_offset, int ncf) { +float cheb1DParamsSol(float x, int32_t coeff_offset, int32_t ncf) { if(ncf <= 0) return 0.0f; const float x2 = 2*x; @@ -297,7 +297,7 @@ float cheb1DParamsSol(float x, int coeff_offset, int ncf) { const vec3 t1 = vec3(1, x2, -1); - for (int i=ncf;i>=0;i--) { + for (int32_t i=ncf;i>=0;i--) { b.zy = b.yx; b.x = sol_params.Coeffs[coeff_offset + i]; b.x = dot(t1, b); @@ -307,7 +307,7 @@ float cheb1DParamsSol(float x, int coeff_offset, int ncf) { return dot(t, b); } -float cheb1DParamsDip(float x, int coeff_offset, int ncf) { +float cheb1DParamsDip(float x, int32_t coeff_offset, int32_t ncf) { if(ncf <= 0) return 0.0f; const float x2 = 2*x; @@ -317,7 +317,7 @@ float cheb1DParamsDip(float x, int coeff_offset, int ncf) { const vec3 t1 = vec3(1, x2, -1); - for (int i=ncf;i>=0;i--) { + for (int32_t i=ncf;i>=0;i--) { b.zy = b.yx; b.x = dip_params.Coeffs[coeff_offset + i]; b.x = dot(t1, b); @@ -331,8 +331,8 @@ bool IsBetween(vec3 sMin, vec3 val, vec3 sMax) { return all(lessThanEqual(sMin, val)) && all(lessThanEqual(val, sMax)); } -bool IsInsideSol(int segID, vec3 rphiz) { - const int index = DIMENSIONS*segID; +bool IsInsideSol(int32_t segID, vec3 rphiz) { + const int32_t index = DIMENSIONS*segID; const vec3 seg_min = vec3(sol_params.BMin[index+0], sol_params.BMin[index+1], sol_params.BMin[index+2]); const vec3 seg_max = vec3(sol_params.BMax[index+0], sol_params.BMax[index+1], sol_params.BMax[index+2]); @@ -340,8 +340,8 @@ bool IsInsideSol(int segID, vec3 rphiz) { return IsBetween(seg_min, rphiz, seg_max); } -bool IsInsideDip(int segID, vec3 pos) { - const int index = DIMENSIONS*segID; +bool IsInsideDip(int32_t segID, vec3 pos) { + const int32_t index = DIMENSIONS*segID; const vec3 seg_min = vec3(dip_params.BMin[index+0], dip_params.BMin[index+1], dip_params.BMin[index+2]); const vec3 seg_max = vec3(dip_params.BMax[index+0], dip_params.BMax[index+1], dip_params.BMax[index+2]); @@ -349,21 +349,21 @@ bool IsInsideDip(int segID, vec3 pos) { return IsBetween(seg_min, pos, seg_max); } -float Eval3DSol(int segID, int dim, vec3 internal) { - const int index = DIMENSIONS*segID; - const int n_rows = sol_params.NRows[index+dim]; - const int cols_at_row_offset = sol_params.ColsAtRowOffset[index+dim]; - const int coeffs_at_row_offset = sol_params.CofsAtRowOffset[index+dim]; +float Eval3DSol(int32_t segID, int32_t dim, vec3 internal) { + const int32_t index = DIMENSIONS*segID; + const int32_t n_rows = sol_params.NRows[index+dim]; + const int32_t cols_at_row_offset = sol_params.ColsAtRowOffset[index+dim]; + const int32_t coeffs_at_row_offset = sol_params.CofsAtRowOffset[index+dim]; - for(int row = 0; row < n_rows; row++) { - const int n_cols = sol_params.NColsAtRow[cols_at_row_offset+row]; - const int coeff_at_col_offset = sol_params.CofsAtColOffset[cols_at_row_offset+row]; + for(int32_t row = 0; row < n_rows; row++) { + const int32_t n_cols = sol_params.NColsAtRow[cols_at_row_offset+row]; + const int32_t coeff_at_col_offset = sol_params.CofsAtColOffset[cols_at_row_offset+row]; - for(int col = 0; col < n_cols; col++) { - const int n_coeffs = sol_params.NCofsAtCol[coeff_at_col_offset+col]; - const int per_col_coeff_offset = sol_params.AtColCoefOffset[coeff_at_col_offset+col]; + for(int32_t col = 0; col < n_cols; col++) { + const int32_t n_coeffs = sol_params.NCofsAtCol[coeff_at_col_offset+col]; + const int32_t per_col_coeff_offset = sol_params.AtColCoefOffset[coeff_at_col_offset+col]; - const int coeffs_offset = coeffs_at_row_offset + per_col_coeff_offset; + const int32_t coeffs_offset = coeffs_at_row_offset + per_col_coeff_offset; tmpCfs1[col] = cheb1DParamsSol(internal.z, coeffs_offset,n_coeffs); } @@ -373,26 +373,26 @@ float Eval3DSol(int segID, int dim, vec3 internal) { return cheb1DArray(internal.x, tmpCfs0, n_rows); } -vec3 EvalSol(int segID, vec3 rphiz) { +vec3 EvalSol(int32_t segID, vec3 rphiz) { const vec3 internal = mapToInternalSol(segID, rphiz); return vec3(Eval3DSol(segID, 0, internal), Eval3DSol(segID, 1, internal), Eval3DSol(segID, 2, internal)); } -float Eval3DDip(int segID, int dim, vec3 internal) { - const int index = DIMENSIONS*segID; - const int n_rows = dip_params.NRows[index+dim]; - const int cols_at_row_offset = dip_params.ColsAtRowOffset[index+dim]; - const int coeffs_at_row_offset = dip_params.CofsAtRowOffset[index+dim]; +float Eval3DDip(int32_t segID, int32_t dim, vec3 internal) { + const int32_t index = DIMENSIONS*segID; + const int32_t n_rows = dip_params.NRows[index+dim]; + const int32_t cols_at_row_offset = dip_params.ColsAtRowOffset[index+dim]; + const int32_t coeffs_at_row_offset = dip_params.CofsAtRowOffset[index+dim]; - for(int row = 0; row < n_rows; row++) { - const int n_cols = dip_params.NColsAtRow[cols_at_row_offset+row]; - const int coeff_at_col_offset = dip_params.CofsAtColOffset[cols_at_row_offset+row]; + for(int32_t row = 0; row < n_rows; row++) { + const int32_t n_cols = dip_params.NColsAtRow[cols_at_row_offset+row]; + const int32_t coeff_at_col_offset = dip_params.CofsAtColOffset[cols_at_row_offset+row]; - for(int col = 0; col < n_cols; col++) { - const int n_coeffs = dip_params.NCofsAtCol[coeff_at_col_offset+col]; - const int per_col_coeff_offset = dip_params.AtColCoefOffset[coeff_at_col_offset+col]; + for(int32_t col = 0; col < n_cols; col++) { + const int32_t n_coeffs = dip_params.NCofsAtCol[coeff_at_col_offset+col]; + const int32_t per_col_coeff_offset = dip_params.AtColCoefOffset[coeff_at_col_offset+col]; - const int coeffs_offset = coeffs_at_row_offset + per_col_coeff_offset; + const int32_t coeffs_offset = coeffs_at_row_offset + per_col_coeff_offset; tmpCfs1[col] = cheb1DParamsDip(internal.z, coeffs_offset, n_coeffs); } @@ -402,7 +402,7 @@ float Eval3DDip(int segID, int dim, vec3 internal) { return cheb1DArray(internal.x, tmpCfs0, n_rows); } -vec3 EvalDip(int segID, vec3 pos) { +vec3 EvalDip(int32_t segID, vec3 pos) { const vec3 internal = mapToInternalDip(segID, pos); return vec3(Eval3DDip(segID, 0, internal), Eval3DDip(segID, 1, internal), Eval3DDip(segID, 2, internal)); } @@ -421,14 +421,14 @@ vec3 MachineField(vec3 pos) { vec3 SolDipField(vec3 pos) { if(pos.z > sol_segment.MinZ) { const vec3 rphiz = CarttoCyl(pos); - const int segID = findSolSegment(rphiz); + const int32_t segID = findSolSegment(rphiz); if(segID >=0 && IsInsideSol(segID, rphiz)) { const vec3 brphiz = EvalSol(segID, rphiz); return CyltoCartCylB(rphiz, brphiz) * sol_segment.MultiplicativeFactor; } } - const int segID = findDipSegment(pos); + const int32_t segID = findDipSegment(pos); if(segID >= 0 && IsInsideDip(segID, pos)) { return EvalDip(segID, pos) * dip_segment.MultiplicativeFactor; } @@ -458,7 +458,7 @@ const float positionScale = 100.0f; void main() { vec3 position = gl_in[0].gl_Position.xyz; - for(uint i = 0; i < field_config.StepCount; ++i) { + for(uint32_t i = 0; i < field_config.StepCount; ++i) { gl_Position = um.ModelViewProj * vec4(position/positionScale, 1.0f); EmitVertex(); const vec3 b_vec = Field(position);