mirror of
https://github.com/hyprwm/aquamarine.git
synced 2024-11-17 04:56:00 +01:00
drm: avoid using unsupported modifiers for mgpu
This commit is contained in:
parent
815df06da2
commit
27008ef767
4 changed files with 37 additions and 3 deletions
|
@ -62,8 +62,11 @@ Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hypruti
|
||||||
attrs.format = params.format;
|
attrs.format = params.format;
|
||||||
size = attrs.size;
|
size = attrs.size;
|
||||||
|
|
||||||
const bool CURSOR = params.cursor && params.scanout;
|
const bool CURSOR = params.cursor && params.scanout;
|
||||||
const bool MULTIGPU = params.multigpu && params.scanout;
|
const bool MULTIGPU = params.multigpu && params.scanout;
|
||||||
|
|
||||||
|
TRACE(allocator->backend->log(AQ_LOG_TRACE,
|
||||||
|
std::format("GBM: Allocating a buffer: size {}, format {}, cursor: {}, multigpu: {}", attrs.size, fourccToName(attrs.format), CURSOR, MULTIGPU)));
|
||||||
|
|
||||||
const auto FORMATS = CURSOR ? swapchain->backendImpl->getCursorFormats() : swapchain->backendImpl->getRenderFormats();
|
const auto FORMATS = CURSOR ? swapchain->backendImpl->getCursorFormats() : swapchain->backendImpl->getRenderFormats();
|
||||||
|
|
||||||
|
@ -95,8 +98,10 @@ Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hypruti
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Nvidia cannot render to linear buffers. What do?
|
// FIXME: Nvidia cannot render to linear buffers. What do?
|
||||||
if (MULTIGPU)
|
if (MULTIGPU) {
|
||||||
|
allocator->backend->log(AQ_LOG_DEBUG, "GBM: Buffer is marked as multigpu, forcing linear");
|
||||||
explicitModifiers = {DRM_FORMAT_MOD_LINEAR};
|
explicitModifiers = {DRM_FORMAT_MOD_LINEAR};
|
||||||
|
}
|
||||||
|
|
||||||
if (explicitModifiers.empty()) {
|
if (explicitModifiers.empty()) {
|
||||||
// fall back to using a linear buffer.
|
// fall back to using a linear buffer.
|
||||||
|
|
|
@ -1358,6 +1358,8 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) {
|
||||||
|
|
||||||
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
|
||||||
|
OPTIONS.cursor = false;
|
||||||
|
OPTIONS.scanout = true;
|
||||||
if (!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;
|
||||||
|
|
|
@ -541,6 +541,12 @@ bool CDRMRenderer::blit(SP<IBuffer> from, SP<IBuffer> to) {
|
||||||
EGLImageKHR rboImage = nullptr;
|
EGLImageKHR rboImage = nullptr;
|
||||||
GLuint rboID = 0, fboID = 0;
|
GLuint rboID = 0, fboID = 0;
|
||||||
auto toDma = to->dmabuf();
|
auto toDma = to->dmabuf();
|
||||||
|
|
||||||
|
if (!verifyDestinationDMABUF(toDma)) {
|
||||||
|
backend->log(AQ_LOG_ERROR, "EGL (blit): failed to blit: destination dmabuf unsupported");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto attachment = to->attachments.get(AQ_ATTACHMENT_DRM_RENDERER_DATA);
|
auto attachment = to->attachments.get(AQ_ATTACHMENT_DRM_RENDERER_DATA);
|
||||||
if (attachment) {
|
if (attachment) {
|
||||||
|
@ -674,6 +680,26 @@ void CDRMRenderer::onBufferAttachmentDrop(CDRMRendererBufferAttachment* attachme
|
||||||
restoreEGL();
|
restoreEGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CDRMRenderer::verifyDestinationDMABUF(const SDMABUFAttrs& attrs) {
|
||||||
|
for (auto& fmt : formats) {
|
||||||
|
if (fmt.drmFormat != attrs.format)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (fmt.modifier != attrs.modifier)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (fmt.external) {
|
||||||
|
backend->log(AQ_LOG_ERROR, "EGL (verifyDestinationDMABUF): FAIL, format is external-only");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
backend->log(AQ_LOG_ERROR, "EGL (verifyDestinationDMABUF): FAIL, format is unsupported by EGL");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
CDRMRendererBufferAttachment::CDRMRendererBufferAttachment(Hyprutils::Memory::CWeakPointer<CDRMRenderer> renderer_, Hyprutils::Memory::CSharedPointer<IBuffer> buffer,
|
CDRMRendererBufferAttachment::CDRMRendererBufferAttachment(Hyprutils::Memory::CWeakPointer<CDRMRenderer> renderer_, Hyprutils::Memory::CSharedPointer<IBuffer> buffer,
|
||||||
EGLImageKHR image, GLuint fbo_, GLuint rbo_, GLuint texid_) :
|
EGLImageKHR image, GLuint fbo_, GLuint rbo_, GLuint texid_) :
|
||||||
eglImage(image), fbo(fbo_), rbo(rbo_), renderer(renderer_), texid(texid_) {
|
eglImage(image), fbo(fbo_), rbo(rbo_), renderer(renderer_), texid(texid_) {
|
||||||
|
|
|
@ -96,6 +96,7 @@ namespace Aquamarine {
|
||||||
EGLImageKHR createEGLImage(const SDMABUFAttrs& attrs);
|
EGLImageKHR createEGLImage(const SDMABUFAttrs& attrs);
|
||||||
std::optional<std::vector<std::pair<uint64_t, bool>>> getModsForFormat(EGLint format);
|
std::optional<std::vector<std::pair<uint64_t, bool>>> getModsForFormat(EGLint format);
|
||||||
bool initDRMFormats();
|
bool initDRMFormats();
|
||||||
|
bool verifyDestinationDMABUF(const SDMABUFAttrs& attrs);
|
||||||
bool hasModifiers = false;
|
bool hasModifiers = false;
|
||||||
|
|
||||||
Hyprutils::Memory::CWeakPointer<CBackend> backend;
|
Hyprutils::Memory::CWeakPointer<CBackend> backend;
|
||||||
|
|
Loading…
Reference in a new issue