[platforms/drm] Pass ownership of gbm_device to Platform
Just like 4e7392b907
:
the ownership of the gbm_device must be passed to the Platform as
the ownership of the EGLDisplay is also passed to the Platform and
we may not destroy the gbm_device for an EGLDisplay we are still using.
With this change I could restart the OpenGL compositor successfully
and switch from OpenGL 3.1 to OpenGL 2 without a crash or rendering
issues.
This commit is contained in:
parent
4e7392b907
commit
a67ccc3529
4 changed files with 20 additions and 9 deletions
|
@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "wayland_server.h"
|
||||
#if HAVE_GBM
|
||||
#include "egl_gbm_backend.h"
|
||||
#include <gbm.h>
|
||||
#endif
|
||||
// KWayland
|
||||
#include <KWayland/Server/seat_interface.h>
|
||||
|
@ -73,6 +74,11 @@ DrmBackend::DrmBackend(QObject *parent)
|
|||
|
||||
DrmBackend::~DrmBackend()
|
||||
{
|
||||
#if HAVE_GBM
|
||||
if (m_gbmDevice) {
|
||||
gbm_device_destroy(m_gbmDevice);
|
||||
}
|
||||
#endif
|
||||
if (m_fd >= 0) {
|
||||
// wait for pageflips
|
||||
while (m_pageFlipsPending != 0) {
|
||||
|
|
|
@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <xf86drmMode.h>
|
||||
|
||||
struct gbm_bo;
|
||||
struct gbm_device;
|
||||
struct gbm_surface;
|
||||
|
||||
namespace KWayland
|
||||
|
@ -89,6 +90,13 @@ public:
|
|||
void outputWentOff();
|
||||
void checkOutputsAreOn();
|
||||
|
||||
void setGbmDevice(gbm_device *device) {
|
||||
m_gbmDevice = device;
|
||||
}
|
||||
gbm_device *gbmDevice() const {
|
||||
return m_gbmDevice;
|
||||
}
|
||||
|
||||
public Q_SLOTS:
|
||||
void turnOutputsOn();
|
||||
|
||||
|
@ -129,6 +137,7 @@ private:
|
|||
QVector<DrmBuffer*> m_buffers;
|
||||
QScopedPointer<DpmsInputEventFilter> m_dpmsFilter;
|
||||
KWayland::Server::OutputManagementInterface *m_outputManagement = nullptr;
|
||||
gbm_device *m_gbmDevice = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -64,9 +64,6 @@ EglGbmBackend::~EglGbmBackend()
|
|||
{
|
||||
// TODO: cleanup front buffer?
|
||||
cleanup();
|
||||
if (m_device) {
|
||||
gbm_device_destroy(m_device);
|
||||
}
|
||||
}
|
||||
|
||||
void EglGbmBackend::cleanupSurfaces()
|
||||
|
@ -101,13 +98,14 @@ bool EglGbmBackend::initializeEgl()
|
|||
return false;
|
||||
}
|
||||
|
||||
m_device = gbm_create_device(m_backend->fd());
|
||||
if (!m_device) {
|
||||
auto device = gbm_create_device(m_backend->fd());
|
||||
if (!device) {
|
||||
setFailed("Could not create gbm device");
|
||||
return false;
|
||||
}
|
||||
m_backend->setGbmDevice(device);
|
||||
|
||||
display = eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, m_device, nullptr);
|
||||
display = eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, device, nullptr);
|
||||
}
|
||||
|
||||
if (display == EGL_NO_DISPLAY)
|
||||
|
@ -158,7 +156,7 @@ void EglGbmBackend::createOutput(DrmOutput *drmOutput)
|
|||
{
|
||||
Output o;
|
||||
o.output = drmOutput;
|
||||
o.gbmSurface = gbm_surface_create(m_device, drmOutput->size().width(), drmOutput->size().height(),
|
||||
o.gbmSurface = gbm_surface_create(m_backend->gbmDevice(), drmOutput->size().width(), drmOutput->size().height(),
|
||||
GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
|
||||
if (!o.gbmSurface) {
|
||||
qCCritical(KWIN_DRM) << "Create gbm surface failed";
|
||||
|
|
|
@ -22,7 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "abstract_egl_backend.h"
|
||||
#include "scene_opengl.h"
|
||||
|
||||
struct gbm_device;
|
||||
struct gbm_surface;
|
||||
|
||||
namespace KWin
|
||||
|
@ -74,7 +73,6 @@ private:
|
|||
void cleanupOutput(const Output &output);
|
||||
void createOutput(DrmOutput *output);
|
||||
DrmBackend *m_backend;
|
||||
gbm_device *m_device = nullptr;
|
||||
QVector<Output> m_outputs;
|
||||
friend class EglGbmTexture;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue