Skip to content

Commit ca79715

Browse files
committed
wayland/screencopy: log more information during buffer creation
1 parent c2ed5bf commit ca79715

File tree

5 files changed

+67
-42
lines changed

5 files changed

+67
-42
lines changed

src/wayland/buffer/dmabuf.cpp

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <qquickwindow.h>
2626
#include <qscopedpointer.h>
2727
#include <qsgtexture_platform.h>
28-
#include <qtclasshelpermacros.h>
2928
#include <qwayland-linux-dmabuf-v1.h>
3029
#include <qwaylandclientextension.h>
3130
#include <sys/mman.h>
@@ -48,42 +47,7 @@ Q_LOGGING_CATEGORY(logDmabuf, "quickshell.wayland.buffer.dmabuf", QtWarningMsg);
4847

4948
LinuxDmabufManager* MANAGER = nullptr; // NOLINT
5049

51-
class FourCCStr {
52-
public:
53-
explicit FourCCStr(uint32_t code)
54-
: chars(
55-
{static_cast<char>(code >> 0 & 0xff),
56-
static_cast<char>(code >> 8 & 0xff),
57-
static_cast<char>(code >> 16 & 0xff),
58-
static_cast<char>(code >> 24 & 0xff),
59-
'\0'}
60-
) {
61-
for (auto i = 3; i != 0; i--) {
62-
if (chars[i] == ' ') chars[i] = '\0';
63-
else break;
64-
}
65-
}
66-
67-
[[nodiscard]] const char* cStr() const { return this->chars.data(); }
68-
69-
private:
70-
std::array<char, 5> chars {};
71-
};
72-
73-
class FourCCModStr {
74-
public:
75-
explicit FourCCModStr(uint64_t code): drmStr(drmGetFormatModifierName(code)) {}
76-
~FourCCModStr() {
77-
if (this->drmStr) drmFree(this->drmStr);
78-
}
79-
80-
Q_DISABLE_COPY_MOVE(FourCCModStr);
81-
82-
[[nodiscard]] const char* cStr() const { return this->drmStr; }
83-
84-
private:
85-
char* drmStr;
86-
};
50+
} // namespace
8751

8852
QDebug& operator<<(QDebug& debug, const FourCCStr& fourcc) {
8953
debug << fourcc.cStr();
@@ -95,8 +59,6 @@ QDebug& operator<<(QDebug& debug, const FourCCModStr& fourcc) {
9559
return debug;
9660
}
9761

98-
} // namespace
99-
10062
QDebug& operator<<(QDebug& debug, const WlDmaBuffer* buffer) {
10163
auto saver = QDebugStateSaver(debug);
10264
debug.nospace();

src/wayland/buffer/dmabuf.hpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <sys/types.h>
1818
#include <wayland-linux-dmabuf-v1-client-protocol.h>
1919
#include <wayland-util.h>
20+
#include <xf86drm.h>
2021

2122
#include "manager.hpp"
2223
#include "qsg.hpp"
@@ -28,6 +29,45 @@ class WlBufferManagerPrivate;
2829
namespace qs::wayland::buffer::dmabuf {
2930

3031
class LinuxDmabufManager;
32+
class FourCCStr {
33+
public:
34+
explicit FourCCStr(uint32_t code)
35+
: chars(
36+
{static_cast<char>(code >> 0 & 0xff),
37+
static_cast<char>(code >> 8 & 0xff),
38+
static_cast<char>(code >> 16 & 0xff),
39+
static_cast<char>(code >> 24 & 0xff),
40+
'\0'}
41+
) {
42+
for (auto i = 3; i != 0; i--) {
43+
if (chars[i] == ' ') chars[i] = '\0';
44+
else break;
45+
}
46+
}
47+
48+
[[nodiscard]] const char* cStr() const { return this->chars.data(); }
49+
50+
private:
51+
std::array<char, 5> chars {};
52+
};
53+
54+
class FourCCModStr {
55+
public:
56+
explicit FourCCModStr(uint64_t code): drmStr(drmGetFormatModifierName(code)) {}
57+
~FourCCModStr() {
58+
if (this->drmStr) drmFree(this->drmStr);
59+
}
60+
61+
Q_DISABLE_COPY_MOVE(FourCCModStr);
62+
63+
[[nodiscard]] const char* cStr() const { return this->drmStr; }
64+
65+
private:
66+
char* drmStr;
67+
};
68+
69+
QDebug& operator<<(QDebug& debug, const FourCCStr& fourcc);
70+
QDebug& operator<<(QDebug& debug, const FourCCModStr& fourcc);
3171

3272
class GbmDeviceHandle {
3373
public:

src/wayland/buffer/manager.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
namespace qs::wayland::buffer {
1919

20+
namespace {
21+
Q_LOGGING_CATEGORY(logBuffer, "quickshell.wayland.buffer", QtWarningMsg);
22+
}
23+
2024
WlBuffer* WlBufferSwapchain::createBackbuffer(const WlBufferRequest& request, bool* newBuffer) {
2125
auto& buffer = this->presentSecondBuffer ? this->buffer1 : this->buffer2;
2226

@@ -42,9 +46,28 @@ bool WlBufferManager::isReady() const { return this->p->mReady; }
4246
[[nodiscard]] WlBuffer* WlBufferManager::createBuffer(const WlBufferRequest& request) {
4347
static const bool dmabufDisabled = qEnvironmentVariableIsSet("QS_DISABLE_DMABUF");
4448

49+
qCDebug(logBuffer).nospace() << "Creating buffer from request at " << request.width << 'x'
50+
<< request.height;
51+
qCDebug(logBuffer).nospace() << " Dmabuf requests on device " << request.dmabuf.device
52+
<< " (disabled: " << dmabufDisabled << ')';
53+
54+
for (const auto& [format, modifiers]: request.dmabuf.formats) {
55+
qCDebug(logBuffer) << " Format" << dmabuf::FourCCStr(format);
56+
57+
for (const auto& modifier: modifiers) {
58+
qCDebug(logBuffer) << " Explicit Modifier" << dmabuf::FourCCModStr(modifier);
59+
}
60+
}
61+
62+
qCDebug(logBuffer).nospace() << " Shm requests";
63+
64+
for (const auto& format: request.shm.formats) {
65+
qCDebug(logBuffer) << " Format" << format;
66+
}
67+
4568
if (!dmabufDisabled) {
4669
if (auto* buf = this->p->dmabuf.createDmabuf(request)) return buf;
47-
qCWarning(shm::logShm) << "DMA buffer creation failed, falling back to SHM.";
70+
qCWarning(logBuffer) << "DMA buffer creation failed, falling back to SHM.";
4871
}
4972

5073
return shm::ShmbufManager::createShmbuf(request);

src/wayland/buffer/shm.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
namespace qs::wayland::buffer::shm {
1919

20+
namespace {
2021
Q_LOGGING_CATEGORY(logShm, "quickshell.wayland.buffer.shm", QtWarningMsg);
22+
}
2123

2224
bool WlShmBuffer::isCompatible(const WlBufferRequest& request) const {
2325
if (QSize(static_cast<int>(request.width), static_cast<int>(request.height)) != this->size()) {

src/wayland/buffer/shm.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
namespace qs::wayland::buffer::shm {
1616

17-
Q_DECLARE_LOGGING_CATEGORY(logShm);
18-
1917
class WlShmBuffer: public WlBuffer {
2018
public:
2119
~WlShmBuffer() override;

0 commit comments

Comments
 (0)