mirror of
https://github.com/hyprwm/aquamarine.git
synced 2024-11-17 08:26:00 +01:00
drm/renderer: also use blitting for cursor planes
This commit is contained in:
parent
0faf47cf2f
commit
ee0dea62e2
2 changed files with 53 additions and 14 deletions
|
@ -217,6 +217,11 @@ namespace Aquamarine {
|
||||||
Hyprutils::Memory::CSharedPointer<SDRMConnector> connector;
|
Hyprutils::Memory::CSharedPointer<SDRMConnector> connector;
|
||||||
Hyprutils::Memory::CSharedPointer<std::function<void(void)>> frameIdle;
|
Hyprutils::Memory::CSharedPointer<std::function<void(void)>> frameIdle;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
Hyprutils::Memory::CSharedPointer<CSwapchain> swapchain;
|
||||||
|
Hyprutils::Memory::CSharedPointer<CSwapchain> cursorSwapchain;
|
||||||
|
} mgpu;
|
||||||
|
|
||||||
bool lastCommitNoBuffer = true;
|
bool lastCommitNoBuffer = true;
|
||||||
|
|
||||||
friend struct SDRMConnector;
|
friend struct SDRMConnector;
|
||||||
|
@ -365,7 +370,6 @@ namespace Aquamarine {
|
||||||
// multigpu state, only present if this backend is not primary, aka if this->primary != nullptr
|
// multigpu state, only present if this backend is not primary, aka if this->primary != nullptr
|
||||||
struct {
|
struct {
|
||||||
Hyprutils::Memory::CSharedPointer<IAllocator> allocator;
|
Hyprutils::Memory::CSharedPointer<IAllocator> allocator;
|
||||||
Hyprutils::Memory::CSharedPointer<CSwapchain> swapchain;
|
|
||||||
Hyprutils::Memory::CSharedPointer<CDRMRenderer> renderer;
|
Hyprutils::Memory::CSharedPointer<CDRMRenderer> renderer;
|
||||||
} mgpu;
|
} mgpu;
|
||||||
|
|
||||||
|
|
|
@ -482,13 +482,6 @@ bool Aquamarine::CDRMBackend::initMgpu() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mgpu.swapchain = CSwapchain::create(mgpu.allocator, self.lock());
|
|
||||||
|
|
||||||
if (!mgpu.swapchain) {
|
|
||||||
backend->log(AQ_LOG_ERROR, "drm: initMgpu: no swapchain");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mgpu.renderer = CDRMRenderer::attempt(gpu->fd, backend.lock());
|
mgpu.renderer = CDRMRenderer::attempt(gpu->fd, backend.lock());
|
||||||
|
|
||||||
if (!mgpu.renderer) {
|
if (!mgpu.renderer) {
|
||||||
|
@ -1358,14 +1351,19 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) {
|
||||||
if (backend->shouldBlit()) {
|
if (backend->shouldBlit()) {
|
||||||
TRACE(backend->backend->log(AQ_LOG_TRACE, "drm: Backend requires blit, blitting"));
|
TRACE(backend->backend->log(AQ_LOG_TRACE, "drm: Backend requires blit, blitting"));
|
||||||
|
|
||||||
|
if (!mgpu.swapchain) {
|
||||||
|
TRACE(backend->backend->log(AQ_LOG_TRACE, "drm: No swapchain for blit, creating"));
|
||||||
|
mgpu.swapchain = CSwapchain::create(backend->mgpu.allocator, backend.lock());
|
||||||
|
}
|
||||||
|
|
||||||
auto OPTIONS = swapchain->currentOptions();
|
auto OPTIONS = swapchain->currentOptions();
|
||||||
OPTIONS.multigpu = false; // this is not a shared swapchain, and additionally, don't make it linear, nvidia would be mad
|
OPTIONS.multigpu = false; // this is not a shared swapchain, and additionally, don't make it linear, nvidia would be mad
|
||||||
if (!backend->mgpu.swapchain->reconfigure(OPTIONS)) {
|
if (!mgpu.swapchain->reconfigure(OPTIONS)) {
|
||||||
backend->backend->log(AQ_LOG_ERROR, "drm: Backend requires blit, but the mgpu swapchain failed reconfiguring");
|
backend->backend->log(AQ_LOG_ERROR, "drm: Backend requires blit, but the mgpu swapchain failed reconfiguring");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto NEWAQBUF = backend->mgpu.swapchain->next(nullptr);
|
auto NEWAQBUF = mgpu.swapchain->next(nullptr);
|
||||||
if (!backend->mgpu.renderer->blit(STATE.buffer, NEWAQBUF)) {
|
if (!backend->mgpu.renderer->blit(STATE.buffer, NEWAQBUF)) {
|
||||||
backend->backend->log(AQ_LOG_ERROR, "drm: Backend requires blit, but blit failed");
|
backend->backend->log(AQ_LOG_ERROR, "drm: Backend requires blit, but blit failed");
|
||||||
return false;
|
return false;
|
||||||
|
@ -1446,17 +1444,54 @@ SP<IBackendImplementation> Aquamarine::CDRMOutput::getBackend() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Aquamarine::CDRMOutput::setCursor(SP<IBuffer> buffer, const Vector2D& hotspot) {
|
bool Aquamarine::CDRMOutput::setCursor(SP<IBuffer> buffer, const Vector2D& hotspot) {
|
||||||
|
if (!buffer->dmabuf().success) {
|
||||||
|
backend->backend->log(AQ_LOG_ERROR, "drm: Cursor buffer has to be a dmabuf");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
setCursorVisible(false);
|
setCursorVisible(false);
|
||||||
else {
|
else {
|
||||||
cursorHotspot = hotspot;
|
SP<CDRMFB> fb;
|
||||||
bool isNew = false;
|
|
||||||
auto fb = CDRMFB::create(buffer, backend, &isNew);
|
if (backend->primary) {
|
||||||
|
TRACE(backend->backend->log(AQ_LOG_TRACE, "drm: Backend requires cursor blit, blitting"));
|
||||||
|
|
||||||
|
if (!mgpu.cursorSwapchain) {
|
||||||
|
TRACE(backend->backend->log(AQ_LOG_TRACE, "drm: No cursorSwapchain for blit, creating"));
|
||||||
|
mgpu.cursorSwapchain = CSwapchain::create(backend->mgpu.allocator, backend.lock());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto OPTIONS = mgpu.cursorSwapchain->currentOptions();
|
||||||
|
OPTIONS.multigpu = false;
|
||||||
|
OPTIONS.scanout = true;
|
||||||
|
OPTIONS.cursor = true;
|
||||||
|
OPTIONS.format = buffer->dmabuf().format;
|
||||||
|
OPTIONS.size = buffer->dmabuf().size;
|
||||||
|
OPTIONS.length = 2;
|
||||||
|
|
||||||
|
if (!mgpu.cursorSwapchain->reconfigure(OPTIONS)) {
|
||||||
|
backend->backend->log(AQ_LOG_ERROR, "drm: Backend requires blit, but the mgpu cursorSwapchain failed reconfiguring");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto NEWAQBUF = mgpu.cursorSwapchain->next(nullptr);
|
||||||
|
if (!backend->mgpu.renderer->blit(buffer, NEWAQBUF)) {
|
||||||
|
backend->backend->log(AQ_LOG_ERROR, "drm: Backend requires blit, but cursor blit failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fb = CDRMFB::create(NEWAQBUF, backend, nullptr); // will return attachment if present
|
||||||
|
} else
|
||||||
|
fb = CDRMFB::create(buffer, backend, nullptr);
|
||||||
|
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
backend->backend->log(AQ_LOG_ERROR, "drm: Cursor buffer failed to import to KMS");
|
backend->backend->log(AQ_LOG_ERROR, "drm: Cursor buffer failed to import to KMS");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cursorHotspot = hotspot;
|
||||||
|
|
||||||
backend->backend->log(AQ_LOG_DEBUG, std::format("drm: Cursor buffer imported into KMS with id {}", fb->id));
|
backend->backend->log(AQ_LOG_DEBUG, std::format("drm: Cursor buffer imported into KMS with id {}", fb->id));
|
||||||
|
|
||||||
connector->crtc->pendingCursor = fb;
|
connector->crtc->pendingCursor = fb;
|
||||||
|
|
Loading…
Reference in a new issue