Skip to content

Commit faf106f

Browse files
committed
GPU Display: Make 'none' frontend and backend work
1 parent c6185d4 commit faf106f

21 files changed

+150
-70
lines changed

GPU/GPUTracking/Global/GPUChainTracking.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ int32_t GPUChainTracking::RunChainFinalize()
826826
if (!mDisplayRunning) {
827827
GPUInfo("Starting Event Display...");
828828
if (mEventDisplay->StartDisplay()) {
829+
GPUError("Error starting Event Display");
829830
return (1);
830831
}
831832
mDisplayRunning = true;

GPU/GPUTracking/Standalone/Benchmark/standalone.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,10 +703,10 @@ int32_t RunBenchmark(GPUReconstruction* recUse, GPUChainTracking* chainTrackingU
703703
configStandalone.noprompt = 1;
704704
}
705705
if (tmpRetVal == 3 && configStandalone.proc.ignoreNonFatalGPUErrors) {
706-
printf("Non-FATAL GPU error occured, ignoring\n");
706+
printf("GPU Standalone Benchmark: Non-FATAL GPU error occured, ignoring\n");
707707
} else if (tmpRetVal && !configStandalone.continueOnError) {
708708
if (tmpRetVal != 2) {
709-
printf("Error occured\n");
709+
printf("GPU Standalone Benchmark: Error occured\n");
710710
}
711711
return 1;
712712
}

GPU/GPUTracking/display/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ set(SRCS ../utils/qsem.cxx
5555
helpers/GPUDisplayMagneticField.cxx
5656
frontend/GPUDisplayFrontend.cxx
5757
frontend/GPUDisplayFrontendGlfw.cxx
58+
frontend/GPUDisplayFrontendNone.cxx
5859
backend/GPUDisplayBackend.cxx
60+
backend/GPUDisplayBackendNone.cxx
5961
backend/GPUDisplayBackendOpenGL.cxx)
6062

6163
set(SRCS_NO_H helpers/GPUDisplayLoader.cxx

GPU/GPUTracking/display/backend/GPUDisplayBackend.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "helpers/GPUDisplayMagneticField.h"
1717

1818
#include "GPUDisplayBackendOpenGL.h"
19-
19+
#include "GPUDisplayBackendNone.h"
2020
#ifdef GPUCA_BUILD_EVENT_DISPLAY_VULKAN
2121
#include "GPUDisplayBackendVulkan.h"
2222
#endif
@@ -51,6 +51,8 @@ GPUDisplayBackend* GPUDisplayBackend::getBackend(const char* type)
5151
#endif
5252
if (strcmp(type, "opengl") == 0 || strcmp(type, "auto") == 0) {
5353
return new GPUDisplayBackendOpenGL;
54+
} else if (strcmp(type, "none") == 0) {
55+
return new GPUDisplayBackendNone;
5456
} else {
5557
GPUError("Requested renderer not available");
5658
}

GPU/GPUTracking/display/backend/GPUDisplayBackend.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class GPUDisplayBackend
5757
enum backendTypes {
5858
TYPE_INVALID = -1,
5959
TYPE_OPENGL = 0,
60-
TYPE_VULKAN = 1
60+
TYPE_VULKAN = 1,
61+
TYPE_NONE = 2
6162
};
6263

6364
struct DrawArraysIndirectCommand {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file GPUDisplayBackendNone.cxx
13+
/// \author David Rohr
14+
15+
#include "GPUCommonDef.h"
16+
#include "GPUDisplayBackendNone.h"
17+
18+
using namespace o2::gpu;
19+
20+
GPUDisplayBackendNone::GPUDisplayBackendNone()
21+
{
22+
mBackendType = TYPE_NONE;
23+
mBackendName = "NONE";
24+
}
25+
26+
int32_t GPUDisplayBackendNone::InitBackendA()
27+
{
28+
29+
return 0;
30+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file GPUDisplayBackendNone.h
13+
/// \author David Rohr
14+
15+
#ifndef GPUDISPLAYBACKENDNONE_H
16+
#define GPUDISPLAYBACKENDNONE_H
17+
18+
#include "GPUDisplayBackend.h"
19+
20+
namespace o2::gpu
21+
{
22+
class GPUDisplayBackendNone : public GPUDisplayBackend
23+
{
24+
public:
25+
GPUDisplayBackendNone();
26+
~GPUDisplayBackendNone() override = default;
27+
28+
protected:
29+
uint32_t DepthBits() override { return 32; };
30+
uint32_t drawVertices(const vboList& v, const drawType t) override { return 0; }
31+
void ActivateColor(std::array<float, 4>& color) override {}
32+
void setDepthBuffer() override {}
33+
int32_t InitBackendA() override;
34+
void ExitBackendA() override {}
35+
void loadDataToGPU(size_t totalVertizes) override {}
36+
void prepareDraw(const hmm_mat4& proj, const hmm_mat4& view, bool requestScreenshot, bool toMixBuffer, float includeMixImage) override {}
37+
void finishDraw(bool doScreenshot, bool toMixBuffer, float includeMixImage) override {}
38+
void finishFrame(bool doScreenshot, bool toMixBuffer, float includeMixImage) override {}
39+
void prepareText() override {}
40+
void finishText() override {}
41+
void pointSizeFactor(float factor) override {}
42+
void lineWidthFactor(float factor) override {}
43+
void OpenGLPrint(const char* s, float x, float y, float* color, float scale) override {}
44+
void addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) override {}
45+
void initializeTextDrawing() override {}
46+
};
47+
} // namespace o2::gpu
48+
49+
#endif

GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717

1818
#ifdef _WIN32
1919
#include "GPUDisplayFrontendWindows.h"
20-
#elif defined(GPUCA_BUILD_EVENT_DISPLAY_X11)
20+
#else
21+
#include <pthread.h>
22+
#endif
23+
24+
#ifdef GPUCA_BUILD_EVENT_DISPLAY_X11
2125
#include "GPUDisplayFrontendX11.h"
2226
#endif
2327
#ifdef GPUCA_BUILD_EVENT_DISPLAY_GLFW
@@ -29,6 +33,7 @@
2933
#ifdef GPUCA_BUILD_EVENT_DISPLAY_WAYLAND
3034
#include "GPUDisplayFrontendWayland.h"
3135
#endif
36+
#include "GPUDisplayFrontendNone.h"
3237

3338
#include "GPULogging.h"
3439
#include <cstring>
@@ -118,7 +123,7 @@ bool GPUDisplayFrontend::isGUIRunning()
118123
}
119124

120125
GPUDisplayFrontend* GPUDisplayFrontend::getFrontend(const char* type)
121-
{
126+
{ // clang-format off
122127
#if !defined(GPUCA_STANDALONE) && defined(GPUCA_BUILD_EVENT_DISPLAY_GLFW)
123128
if (strcmp(type, "glfw") == 0 || strcmp(type, "auto") == 0) {
124129
return new GPUDisplayFrontendGlfw;
@@ -148,11 +153,13 @@ GPUDisplayFrontend* GPUDisplayFrontend::getFrontend(const char* type)
148153
return new GPUDisplayFrontendGlut;
149154
} else
150155
#endif
151-
{
156+
if (strcmp(type, "none") == 0) {
157+
return new GPUDisplayFrontendNone;
158+
} else {
152159
GPUError("Requested frontend not available");
153160
}
154161
return nullptr;
155-
}
162+
} // clang-format on
156163

157164
GPUDisplayBackend* GPUDisplayFrontend::backend()
158165
{
@@ -163,3 +170,21 @@ int32_t& GPUDisplayFrontend::drawTextFontSize()
163170
{
164171
return mDisplay->drawTextFontSize();
165172
}
173+
174+
int32_t GPUDisplayFrontend::StartDisplay()
175+
{
176+
#ifndef _WIN32
177+
static pthread_t hThread;
178+
if (pthread_create(&hThread, nullptr, FrontendThreadWrapper, this)) {
179+
GPUError("Coult not Create frontend Thread...");
180+
return (1);
181+
}
182+
#else
183+
HANDLE hThread;
184+
if ((hThread = CreateThread(nullptr, nullptr, &OpenGLWrapper, this, nullptr, nullptr)) == nullptr) {
185+
GPUError("Coult not Create GL Thread...");
186+
return (1);
187+
}
188+
#endif
189+
return (0);
190+
}

GPU/GPUTracking/display/frontend/GPUDisplayFrontend.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface
4040
TYPE_X11 = 1,
4141
TYPE_GLUT = 2,
4242
TYPE_GLFW = 3,
43-
TYPE_WAYLAND = 4
43+
TYPE_WAYLAND = 4,
44+
TYPE_NONE = 5
4445
};
4546

4647
// Compile time minimum version defined in GPUDisplay.h, keep in sync!
4748
static constexpr int32_t GL_MIN_VERSION_MAJOR = 4;
4849
static constexpr int32_t GL_MIN_VERSION_MINOR = 5;
4950

50-
virtual int32_t StartDisplay() = 0; // Start the display. This function returns, and should spawn a thread that runs the display, and calls InitDisplay
51+
int32_t StartDisplay(); // Start the display. This function returns, and should spawn a thread that runs the display, and calls InitDisplay
5152
void DisplayExit() override = 0; // Stop the display. Display thread should call ExitDisplay and the function returns after the thread has terminated
5253
virtual void SwitchFullscreen(bool set) = 0; // Toggle full-screen mode
5354
virtual void ToggleMaximized(bool set) = 0; // Maximize window

GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.cxx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ extern "C" int32_t gl3wInit();
3333
#include <cstdio>
3434
#include <cstring>
3535
#include <unistd.h>
36-
#include <pthread.h>
3736

3837
#ifdef GPUCA_O2_LIB
3938
#if __has_include("../src/imgui.h")
@@ -417,16 +416,6 @@ void GPUDisplayFrontendGlfw::ToggleMaximized(bool set)
417416

418417
void GPUDisplayFrontendGlfw::SetVSync(bool enable) { glfwSwapInterval(enable); }
419418

420-
int32_t GPUDisplayFrontendGlfw::StartDisplay()
421-
{
422-
static pthread_t hThread;
423-
if (pthread_create(&hThread, nullptr, FrontendThreadWrapper, this)) {
424-
GPUError("Coult not Create GL Thread...");
425-
return (1);
426-
}
427-
return (0);
428-
}
429-
430419
bool GPUDisplayFrontendGlfw::EnableSendKey()
431420
{
432421
#ifdef GPUCA_O2_LIB

0 commit comments

Comments
 (0)