20#ifdef GPUCA_BUILD_EVENT_DISPLAY_VULKAN
21#define GLFW_INCLUDE_VULKAN
23#include <GLFW/glfw3.h>
39int32_t GPUDisplayFrontendGlfw::GetKey(int32_t
key)
41 if (
key == GLFW_KEY_KP_SUBTRACT) {
44 if (
key == GLFW_KEY_KP_ADD) {
47 if (
key == GLFW_KEY_LEFT_SHIFT ||
key == GLFW_KEY_RIGHT_SHIFT) {
50 if (
key == GLFW_KEY_LEFT_ALT) {
53 if (
key == GLFW_KEY_RIGHT_ALT) {
56 if (
key == GLFW_KEY_LEFT_CONTROL) {
59 if (
key == GLFW_KEY_RIGHT_CONTROL) {
62 if (
key == GLFW_KEY_UP) {
65 if (
key == GLFW_KEY_DOWN) {
68 if (
key == GLFW_KEY_LEFT) {
71 if (
key == GLFW_KEY_RIGHT) {
74 if (
key == GLFW_KEY_PAGE_UP) {
77 if (
key == GLFW_KEY_PAGE_DOWN) {
78 return (KEY_PAGEDOWN);
80 if (
key == GLFW_KEY_ESCAPE) {
83 if (
key == GLFW_KEY_SPACE) {
86 if (
key == GLFW_KEY_HOME) {
89 if (
key == GLFW_KEY_END) {
92 if (
key == GLFW_KEY_INSERT) {
95 if (
key == GLFW_KEY_BACKSPACE) {
96 return (KEY_BACKSPACE);
98 if (
key == GLFW_KEY_DELETE) {
101 if (
key == GLFW_KEY_GRAVE_ACCENT) {
104 if (
key == GLFW_KEY_ENTER) {
107 if (
key == GLFW_KEY_F1) {
110 if (
key == GLFW_KEY_F2) {
113 if (
key == GLFW_KEY_F3) {
116 if (
key == GLFW_KEY_F4) {
119 if (
key == GLFW_KEY_F5) {
122 if (
key == GLFW_KEY_F6) {
125 if (
key == GLFW_KEY_F7) {
128 if (
key == GLFW_KEY_F8) {
131 if (
key == GLFW_KEY_F9) {
134 if (
key == GLFW_KEY_F10) {
137 if (
key == GLFW_KEY_F11) {
140 if (
key == GLFW_KEY_F12) {
146void GPUDisplayFrontendGlfw::GetKey(int32_t
key, int32_t scancode, int32_t mods, int32_t& keyOut, int32_t& keyPressOut)
149 const char*
str = glfwGetKeyName(
key, scancode);
150 char localeKey =
str ?
str[0] : 0;
151 if ((mods & GLFW_MOD_SHIFT) && localeKey >=
'a' && localeKey <=
'z') {
152 localeKey +=
'A' -
'a';
157 keyOut = keyPressOut = specialKey;
159 keyOut = keyPressOut = (
uint8_t)localeKey;
160 if (keyPressOut >=
'a' && keyPressOut <=
'z') {
161 keyPressOut +=
'A' -
'a';
166void GPUDisplayFrontendGlfw::error_callback(int32_t
error,
const char*
description) { fprintf(stderr,
"Error: %s\n",
description); }
168void GPUDisplayFrontendGlfw::key_callback(GLFWwindow* window, int32_t
key, int32_t scancode, int32_t action, int32_t mods)
170 int32_t handleKey = 0, keyPress = 0;
171 GetKey(
key, scancode, mods, handleKey, keyPress);
172 if (handleKey < 32) {
173 if (action == GLFW_PRESS || action == GLFW_REPEAT) {
174 me->mKeys[keyPress] = keyPress == KEY_SHIFT || !
me->consoleShown();
175 me->HandleKey(handleKey);
176 }
else if (action == GLFW_RELEASE) {
177 me->mKeys[keyPress] =
false;
179 }
else if (handleKey < 256) {
180 if (action == GLFW_PRESS) {
181 me->mLastKeyDown = handleKey;
182 if (
key == GLFW_KEY_GRAVE_ACCENT) {
183 me->mConsoleKeyPressed =
true;
186 }
else if (action == GLFW_RELEASE) {
187 keyPress = (
uint8_t)
me->mGLFWKeyDownMap[handleKey];
188 me->mKeys[keyPress] =
false;
193void GPUDisplayFrontendGlfw::char_callback(GLFWwindow* window,
uint32_t codepoint)
196 if (
me->mConsoleKeyPressed) {
197 me->mConsoleKeyPressed =
false;
200 if (codepoint < 256) {
202 if (keyPress >=
'a' && keyPress <=
'z') {
203 keyPress +=
'A' -
'a';
205 me->mGLFWKeyDownMap[
me->mLastKeyDown] = keyPress;
206 me->mKeys[keyPress] = keyPress == KEY_SHIFT || !
me->consoleShown();
207 me->HandleKey(codepoint);
211void GPUDisplayFrontendGlfw::mouseButton_callback(GLFWwindow* window, int32_t button, int32_t action, int32_t mods)
213 if (action == GLFW_PRESS) {
216 }
else if (button == 1) {
217 me->mMouseDnR =
true;
218 }
else if (button == GLFW_MOUSE_BUTTON_MIDDLE) {
219 me->mMouseDnM =
true;
221 me->mMouseDnX =
me->mMouseMvX;
222 me->mMouseDnY =
me->mMouseMvY;
223 }
else if (action == GLFW_RELEASE) {
225 me->mMouseDn =
false;
226 }
else if (button == 1) {
227 me->mMouseDnR =
false;
228 }
else if (button == GLFW_MOUSE_BUTTON_MIDDLE) {
229 me->mMouseDnM =
false;
234void GPUDisplayFrontendGlfw::scroll_callback(GLFWwindow* window,
double x,
double y) {
me->mMouseWheel +=
y * 100; }
236void GPUDisplayFrontendGlfw::cursorPos_callback(GLFWwindow* window,
double x,
double y)
238 me->mMouseMvX =
x *
me->mPixelRatio;
239 me->mMouseMvY =
y *
me->mPixelRatio;
242void GPUDisplayFrontendGlfw::resize_callback(GLFWwindow* window, int32_t
width, int32_t
height)
244 int32_t windowWidth, windowHeight;
245 glfwGetWindowSize(window, &windowWidth, &windowHeight);
246 me->mPixelRatio = windowWidth ? (double)
width / windowWidth : 1.;
250void GPUDisplayFrontendGlfw::focus_callback(GLFWwindow* window, int32_t focused)
257void GPUDisplayFrontendGlfw::contentScale_callback(GLFWwindow* window,
float xscale,
float yscale)
262void GPUDisplayFrontendGlfw::maximize_callback(GLFWwindow* window, int32_t maximized)
264 me->setWindowState(glfwGetWindowMonitor(window) !=
nullptr, maximized);
265 if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND) {
267 glfwGetWindowSize(window, &
me->mWindowedWidth, &
me->mWindowedHeight);
269 me->mRestoreWindowedSize =
true;
274int32_t GPUDisplayFrontendGlfw::FrontendMain()
279 fprintf(stderr,
"Error initializing glfw\n");
282 glfwSetErrorCallback(error_callback);
285 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
290 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, 0);
291 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
293 glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
296 fprintf(stderr,
"Error creating glfw window\n");
301 glfwMakeContextCurrent(mWindow);
304 glfwSetKeyCallback(mWindow, key_callback);
305 glfwSetCharCallback(mWindow, char_callback);
306 glfwSetMouseButtonCallback(mWindow, mouseButton_callback);
307 glfwSetScrollCallback(mWindow, scroll_callback);
308 glfwSetCursorPosCallback(mWindow, cursorPos_callback);
309 glfwSetFramebufferSizeCallback(mWindow, resize_callback);
310 glfwSetWindowMaximizeCallback(mWindow, maximize_callback);
311 glfwSetWindowFocusCallback(mWindow, focus_callback);
312 float xscale, yscale;
313 glfwGetWindowContentScale(mWindow, &xscale, &yscale);
314 contentScale_callback(mWindow, xscale, yscale);
315 glfwSetWindowContentScaleCallback(mWindow, contentScale_callback);
316 const float limitScale = (glfwGetPlatform() == GLFW_PLATFORM_X11 || glfwGetPlatform() == GLFW_PLATFORM_WIN32) ? mScale : 1.f;
317 glfwSetWindowSizeLimits(mWindow,
MIN_WIDTH * limitScale,
MIN_HEIGHT * limitScale, GLFW_DONT_CARE, GLFW_DONT_CARE);
318 int32_t fbWidth, fbHeight, windowWidth, windowHeight;
319 glfwGetFramebufferSize(mWindow, &fbWidth, &fbHeight);
320 glfwGetWindowSize(mWindow, &windowWidth, &windowHeight);
321 mPixelRatio = windowWidth ? (double)fbWidth / windowWidth : 1.;
326 fprintf(stderr,
"Error initializing GL extension wrapper\n");
331 fprintf(stderr,
"Error in GLFW display initialization\n");
336 while (!glfwWindowShouldClose(mWindow)) {
338 fprintf(stderr,
"Error drawing GL scene\n");
343 glfwSwapBuffers(mWindow);
347 mConsoleKeyPressed =
false;
348 if (mRestoreWindowedSize) {
349 mRestoreWindowedSize =
false;
350 if (mWindowedWidth > 0 && mWindowedHeight > 0 && !glfwGetWindowAttrib(mWindow, GLFW_MAXIMIZED)) {
351 glfwSetWindowSize(mWindow, mWindowedWidth, mWindowedHeight);
360 glfwDestroyWindow(mWindow);
371 glfwSetWindowShouldClose(mWindow,
true);
376 GPUInfo(
"Setting Full Screen %d", (
int32_t)set);
378 glfwGetWindowPos(mWindow, &mWindowX, &mWindowY);
379 glfwGetWindowSize(mWindow, &mWindowWidth, &mWindowHeight);
380 GLFWmonitor* primary = glfwGetPrimaryMonitor();
381 const GLFWvidmode*
mode = glfwGetVideoMode(primary);
382 glfwSetWindowMonitor(mWindow, primary, 0, 0,
mode->width,
mode->height,
mode->refreshRate);
384 glfwSetWindowMonitor(mWindow,
nullptr, mWindowX, mWindowY, mWindowWidth, mWindowHeight, GLFW_DONT_CARE);
391 glfwMaximizeWindow(mWindow);
393 glfwRestoreWindow(mWindow);
408 GLFWmonitor* monitor = glfwGetWindowMonitor(mWindow) ? glfwGetWindowMonitor(mWindow) : glfwGetPrimaryMonitor();
409 const GLFWvidmode*
mode = monitor ? glfwGetVideoMode(monitor) :
nullptr;
410 return mode ?
mode->refreshRate : 0.f;
420#ifdef GPUCA_BUILD_EVENT_DISPLAY_VULKAN
421 return glfwCreateWindowSurface(*(VkInstance*)instance, mWindow,
nullptr, (VkSurfaceKHR*)
surface) != VK_SUCCESS;
430#ifdef GPUCA_BUILD_EVENT_DISPLAY_VULKAN
431 p = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
433 return glfwExtensionCount;
header::DataDescription description
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
char error[CURL_ERROR_SIZE]
const Acts::Surface * surface
virtual int32_t ExtInit()
backendTypes backendType() const
void SetVSync(bool enable) override
void StopDisplayA() override
void getSize(int32_t &width, int32_t &height) override
void ToggleMaximized(bool set) override
uint32_t getReqVulkanExtensions(const char **&p) override
void SwitchFullscreen(bool set) override
int32_t getVulkanSurface(void *instance, void *surface) override
float getRefreshRate() override
bool canSetVSync() override
const char * mFrontendName
void setDisplayControl(int32_t v) override
std::mutex mExitStateMutex
int32_t HandleUpdatesAndDrawGLScene(bool suspended=false)
std::condition_variable mDisplayStoppedCV
static constexpr const char * DISPLAY_WINDOW_NAME
static constexpr int32_t INIT_WIDTH
static constexpr int32_t GL_MIN_VERSION_MAJOR
frontendTypes mFrontendType
GPUDisplayBackend * mBackend
static constexpr int32_t GL_MIN_VERSION_MINOR
int32_t InitDisplay(bool initFailure=false)
bool vsyncEnabled() const
GPUDisplayBackend * backend()
void applyInitialWindowState()
static constexpr int32_t MIN_WIDTH
static constexpr int32_t INIT_HEIGHT
static constexpr int32_t MIN_HEIGHT
std::atomic< bool > mDisplayRunning
GLint GLsizei GLsizei height