forked from quickshell/quickshell
		
	wayland/screencopy: log more information during buffer creation
This commit is contained in:
		
							parent
							
								
									c2ed5bf559
								
							
						
					
					
						commit
						ca79715cce
					
				
					 5 changed files with 67 additions and 42 deletions
				
			
		| 
						 | 
				
			
			@ -25,7 +25,6 @@
 | 
			
		|||
#include <qquickwindow.h>
 | 
			
		||||
#include <qscopedpointer.h>
 | 
			
		||||
#include <qsgtexture_platform.h>
 | 
			
		||||
#include <qtclasshelpermacros.h>
 | 
			
		||||
#include <qwayland-linux-dmabuf-v1.h>
 | 
			
		||||
#include <qwaylandclientextension.h>
 | 
			
		||||
#include <sys/mman.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -48,42 +47,7 @@ Q_LOGGING_CATEGORY(logDmabuf, "quickshell.wayland.buffer.dmabuf", QtWarningMsg);
 | 
			
		|||
 | 
			
		||||
LinuxDmabufManager* MANAGER = nullptr; // NOLINT
 | 
			
		||||
 | 
			
		||||
class FourCCStr {
 | 
			
		||||
public:
 | 
			
		||||
	explicit FourCCStr(uint32_t code)
 | 
			
		||||
	    : chars(
 | 
			
		||||
	          {static_cast<char>(code >> 0 & 0xff),
 | 
			
		||||
	           static_cast<char>(code >> 8 & 0xff),
 | 
			
		||||
	           static_cast<char>(code >> 16 & 0xff),
 | 
			
		||||
	           static_cast<char>(code >> 24 & 0xff),
 | 
			
		||||
	           '\0'}
 | 
			
		||||
	      ) {
 | 
			
		||||
		for (auto i = 3; i != 0; i--) {
 | 
			
		||||
			if (chars[i] == ' ') chars[i] = '\0';
 | 
			
		||||
			else break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[[nodiscard]] const char* cStr() const { return this->chars.data(); }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	std::array<char, 5> chars {};
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class FourCCModStr {
 | 
			
		||||
public:
 | 
			
		||||
	explicit FourCCModStr(uint64_t code): drmStr(drmGetFormatModifierName(code)) {}
 | 
			
		||||
	~FourCCModStr() {
 | 
			
		||||
		if (this->drmStr) drmFree(this->drmStr);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	Q_DISABLE_COPY_MOVE(FourCCModStr);
 | 
			
		||||
 | 
			
		||||
	[[nodiscard]] const char* cStr() const { return this->drmStr; }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	char* drmStr;
 | 
			
		||||
};
 | 
			
		||||
} // namespace
 | 
			
		||||
 | 
			
		||||
QDebug& operator<<(QDebug& debug, const FourCCStr& fourcc) {
 | 
			
		||||
	debug << fourcc.cStr();
 | 
			
		||||
| 
						 | 
				
			
			@ -95,8 +59,6 @@ QDebug& operator<<(QDebug& debug, const FourCCModStr& fourcc) {
 | 
			
		|||
	return debug;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace
 | 
			
		||||
 | 
			
		||||
QDebug& operator<<(QDebug& debug, const WlDmaBuffer* buffer) {
 | 
			
		||||
	auto saver = QDebugStateSaver(debug);
 | 
			
		||||
	debug.nospace();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,6 +17,7 @@
 | 
			
		|||
#include <sys/types.h>
 | 
			
		||||
#include <wayland-linux-dmabuf-v1-client-protocol.h>
 | 
			
		||||
#include <wayland-util.h>
 | 
			
		||||
#include <xf86drm.h>
 | 
			
		||||
 | 
			
		||||
#include "manager.hpp"
 | 
			
		||||
#include "qsg.hpp"
 | 
			
		||||
| 
						 | 
				
			
			@ -28,6 +29,45 @@ class WlBufferManagerPrivate;
 | 
			
		|||
namespace qs::wayland::buffer::dmabuf {
 | 
			
		||||
 | 
			
		||||
class LinuxDmabufManager;
 | 
			
		||||
class FourCCStr {
 | 
			
		||||
public:
 | 
			
		||||
	explicit FourCCStr(uint32_t code)
 | 
			
		||||
	    : chars(
 | 
			
		||||
	          {static_cast<char>(code >> 0 & 0xff),
 | 
			
		||||
	           static_cast<char>(code >> 8 & 0xff),
 | 
			
		||||
	           static_cast<char>(code >> 16 & 0xff),
 | 
			
		||||
	           static_cast<char>(code >> 24 & 0xff),
 | 
			
		||||
	           '\0'}
 | 
			
		||||
	      ) {
 | 
			
		||||
		for (auto i = 3; i != 0; i--) {
 | 
			
		||||
			if (chars[i] == ' ') chars[i] = '\0';
 | 
			
		||||
			else break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[[nodiscard]] const char* cStr() const { return this->chars.data(); }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	std::array<char, 5> chars {};
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class FourCCModStr {
 | 
			
		||||
public:
 | 
			
		||||
	explicit FourCCModStr(uint64_t code): drmStr(drmGetFormatModifierName(code)) {}
 | 
			
		||||
	~FourCCModStr() {
 | 
			
		||||
		if (this->drmStr) drmFree(this->drmStr);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	Q_DISABLE_COPY_MOVE(FourCCModStr);
 | 
			
		||||
 | 
			
		||||
	[[nodiscard]] const char* cStr() const { return this->drmStr; }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	char* drmStr;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
QDebug& operator<<(QDebug& debug, const FourCCStr& fourcc);
 | 
			
		||||
QDebug& operator<<(QDebug& debug, const FourCCModStr& fourcc);
 | 
			
		||||
 | 
			
		||||
class GbmDeviceHandle {
 | 
			
		||||
public:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,6 +17,10 @@
 | 
			
		|||
 | 
			
		||||
namespace qs::wayland::buffer {
 | 
			
		||||
 | 
			
		||||
namespace {
 | 
			
		||||
Q_LOGGING_CATEGORY(logBuffer, "quickshell.wayland.buffer", QtWarningMsg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
WlBuffer* WlBufferSwapchain::createBackbuffer(const WlBufferRequest& request, bool* newBuffer) {
 | 
			
		||||
	auto& buffer = this->presentSecondBuffer ? this->buffer1 : this->buffer2;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -42,9 +46,28 @@ bool WlBufferManager::isReady() const { return this->p->mReady; }
 | 
			
		|||
[[nodiscard]] WlBuffer* WlBufferManager::createBuffer(const WlBufferRequest& request) {
 | 
			
		||||
	static const bool dmabufDisabled = qEnvironmentVariableIsSet("QS_DISABLE_DMABUF");
 | 
			
		||||
 | 
			
		||||
	qCDebug(logBuffer).nospace() << "Creating buffer from request at " << request.width << 'x'
 | 
			
		||||
	                             << request.height;
 | 
			
		||||
	qCDebug(logBuffer).nospace() << "  Dmabuf requests on device " << request.dmabuf.device
 | 
			
		||||
	                             << " (disabled: " << dmabufDisabled << ')';
 | 
			
		||||
 | 
			
		||||
	for (const auto& [format, modifiers]: request.dmabuf.formats) {
 | 
			
		||||
		qCDebug(logBuffer) << "    Format" << dmabuf::FourCCStr(format);
 | 
			
		||||
 | 
			
		||||
		for (const auto& modifier: modifiers) {
 | 
			
		||||
			qCDebug(logBuffer) << "      Explicit Modifier" << dmabuf::FourCCModStr(modifier);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	qCDebug(logBuffer).nospace() << "  Shm requests";
 | 
			
		||||
 | 
			
		||||
	for (const auto& format: request.shm.formats) {
 | 
			
		||||
		qCDebug(logBuffer) << "    Format" << format;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (!dmabufDisabled) {
 | 
			
		||||
		if (auto* buf = this->p->dmabuf.createDmabuf(request)) return buf;
 | 
			
		||||
		qCWarning(shm::logShm) << "DMA buffer creation failed, falling back to SHM.";
 | 
			
		||||
		qCWarning(logBuffer) << "DMA buffer creation failed, falling back to SHM.";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return shm::ShmbufManager::createShmbuf(request);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,9 @@
 | 
			
		|||
 | 
			
		||||
namespace qs::wayland::buffer::shm {
 | 
			
		||||
 | 
			
		||||
namespace {
 | 
			
		||||
Q_LOGGING_CATEGORY(logShm, "quickshell.wayland.buffer.shm", QtWarningMsg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool WlShmBuffer::isCompatible(const WlBufferRequest& request) const {
 | 
			
		||||
	if (QSize(static_cast<int>(request.width), static_cast<int>(request.height)) != this->size()) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,8 +14,6 @@
 | 
			
		|||
 | 
			
		||||
namespace qs::wayland::buffer::shm {
 | 
			
		||||
 | 
			
		||||
Q_DECLARE_LOGGING_CATEGORY(logShm);
 | 
			
		||||
 | 
			
		||||
class WlShmBuffer: public WlBuffer {
 | 
			
		||||
public:
 | 
			
		||||
	~WlShmBuffer() override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue