23#include <GL/freeglut.h>
24#include <GL/freeglut_ucall.h>
26#ifdef GPUCA_BUILD_EVENT_DISPLAY_X11
40void GPUDisplayFrontendGlut::displayFunc()
42 mRedisplayPending =
false;
48void GPUDisplayFrontendGlut::glutLoopFunc()
50 if (mRedisplayPending) {
55 mRedisplayPending =
true;
59int32_t GPUDisplayFrontendGlut::GetKey(int32_t
key)
70 case GLUT_KEY_PAGE_UP:
72 case GLUT_KEY_PAGE_DOWN:
104 case GLUT_KEY_SHIFT_L:
105 case GLUT_KEY_SHIFT_R:
107 case GLUT_KEY_CTRL_L:
109 case GLUT_KEY_CTRL_R:
120void GPUDisplayFrontendGlut::GetKey(int32_t
key, int32_t& keyOut, int32_t& keyPressOut,
bool special)
122 int32_t specialKey = special ? GetKey(
key) : 0;
126 keyOut = keyPressOut = specialKey;
128 keyOut = keyPressOut =
key == 8 ? KEY_BACKSPACE : (
key == 127 ? KEY_DELETE :
key);
129 if (keyPressOut >=
'a' && keyPressOut <=
'z') {
130 keyPressOut +=
'A' -
'a';
135void GPUDisplayFrontendGlut::keyboardFunc(int32_t
key,
bool special,
bool down)
137 int32_t handleKey = 0, keyPress = 0;
138 GetKey(
key, handleKey, keyPress, special);
145void GPUDisplayFrontendGlut::ResizeSceneWrapper(int32_t
width, int32_t
height)
152#ifdef GPUCA_BUILD_EVENT_DISPLAY_X11
153 Display*
display = glXGetCurrentDisplay();
156 unsigned long nItems, bytesAfter;
157 unsigned char*
data =
nullptr;
158 if (!
display || XGetWindowProperty(
display, glXGetCurrentDrawable(), XInternAtom(
display,
"_NET_WM_STATE", False), 0, 1024, False, XA_ATOM, &
type, &
format, &nItems, &bytesAfter, &
data) != Success ||
data ==
nullptr) {
161 const Atom maxHorz = XInternAtom(
display,
"_NET_WM_STATE_MAXIMIZED_HORZ", False), maxVert = XInternAtom(
display,
"_NET_WM_STATE_MAXIMIZED_VERT", False);
162 bool isMaxHorz =
false, isMaxVert =
false;
163 for (
unsigned long i = 0;
i < nItems;
i++) {
164 isMaxHorz |= ((Atom*)
data)[
i] == maxHorz;
165 isMaxVert |= ((Atom*)
data)[
i] == maxVert;
172void GPUDisplayFrontendGlut::mouseFunc(int32_t button, int32_t state, int32_t
x, int32_t
y)
176 }
else if (button == 4) {
178 }
else if (state == GLUT_DOWN) {
179 if (button == GLUT_LEFT_BUTTON) {
181 }
else if (button == GLUT_RIGHT_BUTTON) {
183 }
else if (button == GLUT_MIDDLE_BUTTON) {
188 }
else if (state == GLUT_UP) {
189 if (button == GLUT_LEFT_BUTTON) {
191 }
else if (button == GLUT_RIGHT_BUTTON) {
193 }
else if (button == GLUT_MIDDLE_BUTTON) {
199void GPUDisplayFrontendGlut::mouseMoveFunc(int32_t
x, int32_t
y)
205void GPUDisplayFrontendGlut::mMouseWheelFunc(int32_t button, int32_t dir, int32_t
x, int32_t
y) {
mMouseWheel += dir; }
207int32_t GPUDisplayFrontendGlut::FrontendMain()
210 fprintf(stderr,
"Only OpenGL backend supported\n");
218 char opt1[] =
"progname";
219 char opt2[] =
"-direct";
220 char* opts[] = {opt1, opt2};
221 glutInit(&nopts, opts);
223 glutInitContextProfile(GLUT_CORE_PROFILE);
224 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
227 glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
230 fprintf(stderr,
"Error initializing GL extension wrapper\n");
234 glutDisplayFuncUcall([](
void* p) { self(p)->displayFunc(); },
this);
235 glutIdleFuncUcall([](
void* p) { self(p)->glutLoopFunc(); },
this);
236 glutReshapeFuncUcall([](int32_t
width, int32_t
height,
void* p) { self(p)->ResizeSceneWrapper(
width,
height); },
this);
237 glutKeyboardFuncUcall([](
uint8_t key, int32_t
x, int32_t
y,
void* p) { self(p)->keyboardFunc(
key,
false,
true); },
this);
238 glutKeyboardUpFuncUcall([](
uint8_t key, int32_t
x, int32_t
y,
void* p) { self(p)->keyboardFunc(
key,
false,
false); },
this);
239 glutSpecialFuncUcall([](int32_t
key, int32_t
x, int32_t
y,
void* p) { self(p)->keyboardFunc(
key,
true,
true); },
this);
240 glutSpecialUpFuncUcall([](int32_t
key, int32_t
x, int32_t
y,
void* p) { self(p)->keyboardFunc(
key,
true,
false); },
this);
241 glutMouseFuncUcall([](int32_t button, int32_t state, int32_t
x, int32_t
y,
void* p) { self(p)->mouseFunc(button, state,
x,
y); },
this);
242 glutMotionFuncUcall(mouseMoveFunc,
this);
243 glutPassiveMotionFuncUcall(mouseMoveFunc,
this);
244 glutMouseWheelFuncUcall([](int32_t button, int32_t dir, int32_t
x, int32_t
y,
void* p) { self(p)->mMouseWheelFunc(button, dir,
x,
y); },
this);
249 fprintf(stderr,
"Error in OpenGL initialization\n");
275 glutReshapeWindow(mWidth, mHeight);
281#ifdef GPUCA_BUILD_EVENT_DISPLAY_X11
282 Display*
display = glXGetCurrentDisplay();
287 memset(&xev, 0,
sizeof(xev));
288 xev.type = ClientMessage;
289 xev.xclient.window = glXGetCurrentDrawable();
290 xev.xclient.message_type = XInternAtom(
display,
"_NET_WM_STATE", False);
291 xev.xclient.format = 32;
292 xev.xclient.data.l[0] = set ? 1 : 0;
293 xev.xclient.data.l[1] = XInternAtom(
display,
"_NET_WM_STATE_MAXIMIZED_HORZ", False);
294 xev.xclient.data.l[2] = XInternAtom(
display,
"_NET_WM_STATE_MAXIMIZED_VERT", False);
295 XSendEvent(
display, DefaultRootWindow(
display), False, SubstructureNotifyMask | SubstructureRedirectMask, &xev);
302#ifdef GPUCA_BUILD_EVENT_DISPLAY_X11
304 ((PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddressARB((
const GLubyte*)
"glXSwapIntervalEXT"))(glXGetCurrentDisplay(), glXGetCurrentDrawable(),
enable);
311#ifdef GPUCA_BUILD_EVENT_DISPLAY_X11
312 return glXGetProcAddressARB((
const GLubyte*)
"glXSwapIntervalEXT") && glXGetCurrentDisplay();
int32_t GetKey(int32_t key)
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
virtual int32_t ExtInit()
void ToggleMaximized(bool set) override
void StopDisplayA() override
bool canSetVSync() override
void SetVSync(bool enable) override
void SwitchFullscreen(bool set) override
int32_t & drawTextFontSize()
const char * mFrontendName
void HandleKey(uint8_t key)
void setDisplayControl(int32_t v) override
std::mutex mExitStateMutex
int32_t HandleUpdatesAndDrawGLScene(bool suspended=false)
void ResizeScene(int32_t width, int32_t height)
std::condition_variable mDisplayStoppedCV
std::mutex mConfigUpdateMutex
static constexpr const char * DISPLAY_WINDOW_NAME
static constexpr int32_t INIT_WIDTH
static constexpr int32_t GL_MIN_VERSION_MAJOR
frontendTypes mFrontendType
void setWindowState(bool fullScreen, bool maximized)
GPUDisplayBackend * mBackend
static constexpr int32_t GL_MIN_VERSION_MINOR
int32_t InitDisplay(bool initFailure=false)
bool vsyncEnabled() const
GPUDisplayBackend * backend()
void applyInitialWindowState()
std::condition_variable mConfigUpdateCV
static constexpr int32_t INIT_HEIGHT
bool consoleShown() const
bool mConfigUpdatePending
std::atomic< bool > mDisplayRunning
GLint GLsizei GLsizei height
GLint GLint GLsizei GLint GLenum GLenum type
GLint GLint GLsizei GLint GLenum format