mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-22 10:29:47 +00:00
drop the environment switches
The backend, decoration and resize-logging switches were only used while working on this, and undocumented ones should not stay: - VOXEL_WINDOW_BACKEND: the backend is still chosen by WAYLAND_DISPLAY, and GLFW is used when it is not set; - VOXEL_DECORATIONS: own decorations are always enabled when the compositor provides none; - VOXEL_LOG_RESIZE: the resize statistics are removed together with the counters they needed. WaylandDecorations.cpp replaces WaylandBar.cpp: drawing moved to the engine, the file only holds the decoration behaviour now.
This commit is contained in:
parent
1dbd445027
commit
6a5e485bca
4 changed files with 1 additions and 80 deletions
|
|
@ -5,16 +5,11 @@
|
||||||
#include "window/input.hpp"
|
#include "window/input.hpp"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
static debug::Logger logger("window");
|
static debug::Logger logger("window");
|
||||||
|
|
||||||
#ifdef VOXELENGINE_WAYLAND
|
#ifdef VOXELENGINE_WAYLAND
|
||||||
static bool prefer_wayland() {
|
static bool prefer_wayland() {
|
||||||
const char* backend = getenv("VOXEL_WINDOW_BACKEND");
|
|
||||||
if (backend != nullptr) {
|
|
||||||
return strcmp(backend, "wayland") == 0;
|
|
||||||
}
|
|
||||||
const char* display = getenv("WAYLAND_DISPLAY");
|
const char* display = getenv("WAYLAND_DISPLAY");
|
||||||
if (display != nullptr && *display) {
|
if (display != nullptr && *display) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -111,22 +111,9 @@ void WaylandWindow::swapBuffers() {
|
||||||
1.0 / 30.0
|
1.0 / 30.0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (resizeLogging) {
|
}
|
||||||
summarySum += interval;
|
|
||||||
summaryMax = std::max(summaryMax, interval);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lastPresent = current;
|
lastPresent = current;
|
||||||
nextFrameTime = current + frameInterval;
|
nextFrameTime = current + frameInterval;
|
||||||
if (resizeLogging) {
|
|
||||||
summaryFrames++;
|
|
||||||
}
|
|
||||||
if (resizing) {
|
|
||||||
const double elapsed = now() - configureTime;
|
|
||||||
resizeTimeSum += elapsed;
|
|
||||||
resizeTimeMax = std::max(resizeTimeMax, elapsed);
|
|
||||||
resizePresents++;
|
|
||||||
}
|
|
||||||
lastSwapEnd = now();
|
lastSwapEnd = now();
|
||||||
if (framerate > 0 && !resizing) {
|
if (framerate > 0 && !resizing) {
|
||||||
auto elapsed = time() - prevSwap;
|
auto elapsed = time() - prevSwap;
|
||||||
|
|
@ -245,7 +232,6 @@ void WaylandWindow::resize(int width, int height) {
|
||||||
if (size.x != width || size.y != height) {
|
if (size.x != width || size.y != height) {
|
||||||
markResizing();
|
markResizing();
|
||||||
}
|
}
|
||||||
configureTime = now();
|
|
||||||
presentPending = true;
|
presentPending = true;
|
||||||
if (eglWindow) {
|
if (eglWindow) {
|
||||||
wl_egl_window_resize(eglWindow, width, height, 0, 0);
|
wl_egl_window_resize(eglWindow, width, height, 0, 0);
|
||||||
|
|
@ -496,7 +482,6 @@ void WaylandWindow::paceFrame() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateResizing();
|
updateResizing();
|
||||||
logSummary();
|
|
||||||
if (resizing) {
|
if (resizing) {
|
||||||
if (!renderPending && now() - lastResize > RESIZE_PAUSE &&
|
if (!renderPending && now() - lastResize > RESIZE_PAUSE &&
|
||||||
now() - lastCacheTime > cacheTimeout) {
|
now() - lastCacheTime > cacheTimeout) {
|
||||||
|
|
@ -520,47 +505,10 @@ void WaylandWindow::paceFrame() {
|
||||||
frameOnCallback = frameDone;
|
frameOnCallback = frameDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaylandWindow::logSummary() {
|
|
||||||
const double current = now();
|
|
||||||
if (resizeLogging) {
|
|
||||||
if (lastLoop > 0.0) {
|
|
||||||
loopGapMax = std::max(loopGapMax, current - lastLoop);
|
|
||||||
}
|
|
||||||
lastLoop = current;
|
|
||||||
loopCount++;
|
|
||||||
}
|
|
||||||
if (!resizeLogging || lastSummary <= 0.0) {
|
|
||||||
if (resizeLogging) {
|
|
||||||
lastSummary = current;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (current - lastSummary < 1.0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
waylandLogger.info() << "loop " << loopCount << "/s (max gap "
|
|
||||||
<< loopGapMax * 1000.0 << " ms), presents "
|
|
||||||
<< summaryFrames << "/s (max gap "
|
|
||||||
<< summaryMax * 1000.0 << " ms), resizing "
|
|
||||||
<< (resizing ? "yes" : "no");
|
|
||||||
lastSummary = current;
|
|
||||||
loopCount = 0;
|
|
||||||
loopGapMax = 0.0;
|
|
||||||
summaryFrames = 0;
|
|
||||||
summarySum = 0.0;
|
|
||||||
summaryMax = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaylandWindow::markResizing() {
|
void WaylandWindow::markResizing() {
|
||||||
lastResize = now();
|
lastResize = now();
|
||||||
if (!resizing) {
|
if (!resizing) {
|
||||||
resizing = true;
|
resizing = true;
|
||||||
resizePresents = 0;
|
|
||||||
resizeTimeSum = 0.0;
|
|
||||||
resizeTimeMax = 0.0;
|
|
||||||
if (resizeLogging) {
|
|
||||||
waylandLogger.info() << "resize started";
|
|
||||||
}
|
|
||||||
setShouldRefresh();
|
setShouldRefresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -569,15 +517,6 @@ void WaylandWindow::updateResizing() {
|
||||||
if (resizing && now() - lastResize > RESIZE_TIMEOUT) {
|
if (resizing && now() - lastResize > RESIZE_TIMEOUT) {
|
||||||
resizing = false;
|
resizing = false;
|
||||||
renderPending = true;
|
renderPending = true;
|
||||||
if (resizeLogging) {
|
|
||||||
double average = resizePresents > 0
|
|
||||||
? resizeTimeSum / resizePresents
|
|
||||||
: 0.0;
|
|
||||||
waylandLogger.info()
|
|
||||||
<< "resize finished, presented " << resizePresents
|
|
||||||
<< ", avg " << average * 1000.0 << " ms, max "
|
|
||||||
<< resizeTimeMax * 1000.0 << " ms";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ static constexpr double MAX_CACHE_TIMEOUT = 3.0;
|
||||||
int framerate = -1;
|
int framerate = -1;
|
||||||
double prevSwap = 0.0;
|
double prevSwap = 0.0;
|
||||||
double lastResize = 0.0;
|
double lastResize = 0.0;
|
||||||
static inline bool resizeLogging = getenv("VOXEL_LOG_RESIZE") != nullptr;
|
|
||||||
bool barEnabled = false;
|
bool barEnabled = false;
|
||||||
bool fullscreen = false;
|
bool fullscreen = false;
|
||||||
std::string title = "VoxelCore";
|
std::string title = "VoxelCore";
|
||||||
|
|
@ -49,18 +48,7 @@ double cacheTimeout = 0.5;
|
||||||
bool resizing = false;
|
bool resizing = false;
|
||||||
bool renderPending = true;
|
bool renderPending = true;
|
||||||
bool presentPending = true;
|
bool presentPending = true;
|
||||||
int resizePresents = 0;
|
|
||||||
double configureTime = 0.0;
|
|
||||||
double resizeTimeSum = 0.0;
|
|
||||||
double resizeTimeMax = 0.0;
|
|
||||||
double lastPresent = 0.0;
|
double lastPresent = 0.0;
|
||||||
double lastSummary = 0.0;
|
|
||||||
double summarySum = 0.0;
|
|
||||||
double summaryMax = 0.0;
|
|
||||||
int summaryFrames = 0;
|
|
||||||
double lastLoop = 0.0;
|
|
||||||
double loopGapMax = 0.0;
|
|
||||||
int loopCount = 0;
|
|
||||||
wl_callback* frameCallback = nullptr;
|
wl_callback* frameCallback = nullptr;
|
||||||
bool frameDone = false;
|
bool frameDone = false;
|
||||||
GLuint stretchProgram = 0;
|
GLuint stretchProgram = 0;
|
||||||
|
|
@ -132,7 +120,6 @@ glm::vec4 scissorArea {};
|
||||||
void onFrameDone();
|
void onFrameDone();
|
||||||
void requestFrame();
|
void requestFrame();
|
||||||
void paceFrame();
|
void paceFrame();
|
||||||
void logSummary();
|
|
||||||
void markResizing();
|
void markResizing();
|
||||||
void updateResizing();
|
void updateResizing();
|
||||||
void setIdleInhibit(bool enabled);
|
void setIdleInhibit(bool enabled);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue