Title: [289885] trunk/Source/WebCore
- Revision
- 289885
- Author
- [email protected]
- Date
- 2022-02-16 02:55:58 -0800 (Wed, 16 Feb 2022)
Log Message
[GTK][WPE] Use drm render nodes in GbmDevice and make the fd global to the process
https://bugs.webkit.org/show_bug.cgi?id=236607
Patch by Alejandro G. Castro <[email protected]> on 2022-02-16
Reviewed by Žan Doberšek.
We are creating a global static variable to handle the fd of the
device in the process, to make sure we search and open once for
the graphics device. Also we are using the DRM_NODE_RENDER because
we do not need the primary device for the operations we expect to
use.
No new tests, already covered in the tests.
* platform/graphics/gbm/GBMDevice.cpp:
(WebCore::GBMDevice::GBMDevice): Use a new global fd.
* platform/graphics/gbm/GBMDevice.h: Ditto.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (289884 => 289885)
--- trunk/Source/WebCore/ChangeLog 2022-02-16 09:39:44 UTC (rev 289884)
+++ trunk/Source/WebCore/ChangeLog 2022-02-16 10:55:58 UTC (rev 289885)
@@ -1,3 +1,22 @@
+2022-02-16 Alejandro G. Castro <[email protected]>
+
+ [GTK][WPE] Use drm render nodes in GbmDevice and make the fd global to the process
+ https://bugs.webkit.org/show_bug.cgi?id=236607
+
+ Reviewed by Žan Doberšek.
+
+ We are creating a global static variable to handle the fd of the
+ device in the process, to make sure we search and open once for
+ the graphics device. Also we are using the DRM_NODE_RENDER because
+ we do not need the primary device for the operations we expect to
+ use.
+
+ No new tests, already covered in the tests.
+
+ * platform/graphics/gbm/GBMDevice.cpp:
+ (WebCore::GBMDevice::GBMDevice): Use a new global fd.
+ * platform/graphics/gbm/GBMDevice.h: Ditto.
+
2022-02-16 Chris Lord <[email protected]>
[GTK][WPE] Crashing/weird behaviour when trying to use videos as textures with ANGLE WebGL enabled
Modified: trunk/Source/WebCore/platform/graphics/gbm/GBMDevice.cpp (289884 => 289885)
--- trunk/Source/WebCore/platform/graphics/gbm/GBMDevice.cpp 2022-02-16 09:39:44 UTC (rev 289884)
+++ trunk/Source/WebCore/platform/graphics/gbm/GBMDevice.cpp 2022-02-16 10:55:58 UTC (rev 289885)
@@ -55,9 +55,31 @@
GBMDevice::GBMDevice()
{
- int fd = getDeviceFd();
- if (fd >= 0)
- m_device = gbm_create_device(fd);
+ static int s_globalFd { -1 };
+ static std::once_flag s_onceFlag;
+ std::call_once(s_onceFlag, [] {
+ drmDevicePtr devices[64];
+ memset(devices, 0, sizeof(devices));
+
+ int numDevices = drmGetDevices2(0, devices, WTF_ARRAY_LENGTH(devices));
+ if (numDevices <= 0)
+ return;
+
+ for (int i = 0; i < numDevices; ++i) {
+ drmDevice* device = devices[i];
+ if (!(device->available_nodes & (1 << DRM_NODE_RENDER)))
+ continue;
+
+ s_globalFd = open(device->nodes[DRM_NODE_RENDER], O_RDWR | O_CLOEXEC);
+ if (s_globalFd >= 0)
+ break;
+ }
+
+ drmFreeDevices(devices, numDevices);
+ });
+
+ if (s_globalFd >= 0)
+ m_device = gbm_create_device(s_globalFd);
}
GBMDevice::~GBMDevice()
@@ -68,29 +90,6 @@
}
}
-int GBMDevice::getDeviceFd()
-{
- drmDevicePtr devices[64];
- memset(devices, 0, sizeof(devices));
-
- int numDevices = drmGetDevices2(0, devices, WTF_ARRAY_LENGTH(devices));
- if (numDevices <=0)
- return -1;
-
- int fd = -1;
- for (int i = 0; i < numDevices; ++i) {
- drmDevice* device = devices[i];
- if (!(device->available_nodes & (1 << DRM_NODE_PRIMARY)))
- continue;
-
- fd = open(device->nodes[DRM_NODE_PRIMARY], O_RDWR);
- if (fd < 0)
- continue;
- }
-
- return fd;
-}
-
} // namespace WebCore
#endif // USE(ANGLE) && USE(NICOSIA)
Modified: trunk/Source/WebCore/platform/graphics/gbm/GBMDevice.h (289884 => 289885)
--- trunk/Source/WebCore/platform/graphics/gbm/GBMDevice.h 2022-02-16 09:39:44 UTC (rev 289884)
+++ trunk/Source/WebCore/platform/graphics/gbm/GBMDevice.h 2022-02-16 10:55:58 UTC (rev 289885)
@@ -44,8 +44,6 @@
struct gbm_device* device() const { return m_device; }
private:
- int getDeviceFd();
-
struct gbm_device* m_device { nullptr };
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes