core: Add GraphicsBufferOptions::software

The software flag indicates whether the graphics buffer allocator needs
to allocate a buffer suitable for software rendering. Its intended usage
is to allow the gbm allocator to allocate both dmabuf and dumb buffers.
remotes/origin/work/zamundaaa/fix-nvidia-primary-gpu
Vlad Zahorodnii 3 years ago
parent 1833d790f5
commit 7782cb6853
  1. 1
      src/backends/virtual/virtual_qpainter_backend.cpp
  2. 1
      src/backends/wayland/wayland_qpainter_backend.cpp
  3. 1
      src/backends/x11/windowed/x11_windowed_qpainter_backend.cpp
  4. 4
      src/core/gbmgraphicsbufferallocator.cpp
  5. 3
      src/core/graphicsbufferallocator.h
  6. 3
      src/core/shmgraphicsbufferallocator.cpp

@ -80,6 +80,7 @@ std::shared_ptr<VirtualQPainterBufferSlot> VirtualQPainterSwapchain::acquire()
ShmGraphicsBuffer *buffer = m_allocator->allocate(GraphicsBufferOptions{
.size = m_size,
.format = m_format,
.software = true,
});
if (!buffer) {
qCDebug(KWIN_VIRTUAL) << "Did not get a new Buffer from Shm Pool";

@ -84,6 +84,7 @@ std::shared_ptr<WaylandQPainterBufferSlot> WaylandQPainterSwapchain::acquire()
ShmGraphicsBuffer *buffer = m_allocator->allocate(GraphicsBufferOptions{
.size = m_size,
.format = m_format,
.software = true,
});
if (!buffer) {
qCDebug(KWIN_WAYLAND_BACKEND) << "Did not get a new Buffer from Shm Pool";

@ -91,6 +91,7 @@ std::shared_ptr<X11WindowedQPainterLayerBuffer> X11WindowedQPainterLayerSwapchai
ShmGraphicsBuffer *graphicsBuffer = m_allocator->allocate(GraphicsBufferOptions{
.size = m_size,
.format = m_format,
.software = true,
});
if (!graphicsBuffer) {
qCWarning(KWIN_X11WINDOWED) << "Failed to allocate a shared memory graphics buffer";

@ -24,6 +24,10 @@ GbmGraphicsBufferAllocator::~GbmGraphicsBufferAllocator()
GbmGraphicsBuffer *GbmGraphicsBufferAllocator::allocate(const GraphicsBufferOptions &options)
{
if (options.software) {
return nullptr;
}
if (!options.modifiers.isEmpty() && !(options.modifiers.size() == 1 && options.modifiers.first() == DRM_FORMAT_MOD_INVALID)) {
gbm_bo *bo = gbm_bo_create_with_modifiers(m_gbmDevice,
options.size.width(),

@ -29,6 +29,9 @@ struct GraphicsBufferOptions
/// An optional list of modifiers, see DRM_FORMAT_MOD_*.
QVector<uint64_t> modifiers;
/// Whether the graphics buffer should be suitable for software rendering.
bool software = false;
};
class KWIN_EXPORT GraphicsBufferAllocator

@ -38,6 +38,9 @@ const ShmAttributes *ShmGraphicsBuffer::shmAttributes() const
ShmGraphicsBuffer *ShmGraphicsBufferAllocator::allocate(const GraphicsBufferOptions &options)
{
if (!options.software) {
return nullptr;
}
if (!options.modifiers.isEmpty()) {
return nullptr;
}

Loading…
Cancel
Save