ntk 7.3.1 → 7.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/gl.js +34 -6
- package/package.json +1 -1
package/lib/gl.js
CHANGED
|
@@ -32,8 +32,11 @@ import { nodeRequire } from './builtin.js';
|
|
|
32
32
|
* - `GL_NO_DRIVER` — the addon loaded but the GPU libraries it needs are
|
|
33
33
|
* missing (`libgbm`, `libEGL`, `libGLESv2`), or this is not Linux.
|
|
34
34
|
* - `GL_NO_DEVICE` — no readable DRM render node (`/dev/dri/renderD*`).
|
|
35
|
-
* - `GL_REMOTE_DISPLAY` —
|
|
36
|
-
*
|
|
35
|
+
* - `GL_REMOTE_DISPLAY` — a TCP or forwarded display, so there is no local
|
|
36
|
+
* socket to hand the server a buffer down.
|
|
37
|
+
* - `GL_NO_FD_PASSING` — the display is local, but this JavaScript runtime
|
|
38
|
+
* cannot send a descriptor over the socket. Bun is the case in the field;
|
|
39
|
+
* x11 does it through a Node internal Bun does not implement.
|
|
37
40
|
* - `GL_NO_DRI3` — the server has no DRI3/Present (Xvfb, Xephyr, XQuartz).
|
|
38
41
|
* - `GL_IMPORT_FAILED` — the server refused the buffer; usually client and
|
|
39
42
|
* server on different DRM devices.
|
|
@@ -45,6 +48,7 @@ export const GLError = {
|
|
|
45
48
|
NO_DRIVER: 'GL_NO_DRIVER',
|
|
46
49
|
NO_DEVICE: 'GL_NO_DEVICE',
|
|
47
50
|
REMOTE_DISPLAY: 'GL_REMOTE_DISPLAY',
|
|
51
|
+
NO_FD_PASSING: 'GL_NO_FD_PASSING',
|
|
48
52
|
NO_DRI3: 'GL_NO_DRI3',
|
|
49
53
|
IMPORT_FAILED: 'GL_IMPORT_FAILED',
|
|
50
54
|
CONTEXT_FAILED: 'GL_CONTEXT_FAILED'
|
|
@@ -235,6 +239,14 @@ export function canPassDescriptors(display) {
|
|
|
235
239
|
|
|
236
240
|
const displayName = () => globalThis.process?.env?.DISPLAY || 'the X server';
|
|
237
241
|
|
|
242
|
+
/** What is running this, for an error that is about the runtime. */
|
|
243
|
+
const runtimeName = () => {
|
|
244
|
+
const versions = globalThis.process?.versions;
|
|
245
|
+
if (versions?.bun) return `Bun (${versions.bun})`;
|
|
246
|
+
if (versions?.deno) return `Deno (${versions.deno})`;
|
|
247
|
+
return versions?.node ? `Node (${versions.node})` : 'JavaScript runtime';
|
|
248
|
+
};
|
|
249
|
+
|
|
238
250
|
const requireExt = (X, name) =>
|
|
239
251
|
new Promise((resolve) => X.require(name, (err, ext) => resolve(err ? null : ext)));
|
|
240
252
|
|
|
@@ -266,14 +278,29 @@ export function glCapabilities(app) {
|
|
|
266
278
|
if (policy.mode === 'off') {
|
|
267
279
|
return fail(GLError.DISABLED, "glPolicy is 'off', so no GL context will be created");
|
|
268
280
|
}
|
|
269
|
-
if (!
|
|
281
|
+
if (!app.display.isLocalSocket) {
|
|
270
282
|
return fail(
|
|
271
283
|
GLError.REMOTE_DISPLAY,
|
|
272
|
-
'this X connection is not a local socket
|
|
284
|
+
'this X connection is not a local socket, and DRI3 works by passing a descriptor down one',
|
|
273
285
|
'Direct rendering is local-only by construction. Over a network, indirect GLX is\n' +
|
|
274
286
|
'the backend that can work at all — leave glPolicy at its default.'
|
|
275
287
|
);
|
|
276
288
|
}
|
|
289
|
+
if (!canPassDescriptors(app.display)) {
|
|
290
|
+
// The socket is local; what is missing is the ability to send a
|
|
291
|
+
// descriptor along it. x11 does that through Node's internal
|
|
292
|
+
// `process.binding('pipe_wrap')`, so a runtime that does not implement
|
|
293
|
+
// it lands here — Bun, today. Saying "not a local socket" would send
|
|
294
|
+
// the reader off to check their DISPLAY, which is fine.
|
|
295
|
+
return fail(
|
|
296
|
+
GLError.NO_FD_PASSING,
|
|
297
|
+
`this ${runtimeName()} cannot pass file descriptors over the X socket, and DRI3 works by passing one`,
|
|
298
|
+
'The connection is local; the runtime is what cannot carry the descriptor.\n' +
|
|
299
|
+
"x11 sends one through Node's process.binding('pipe_wrap'), which Bun does\n" +
|
|
300
|
+
'not implement. Run under Node for direct rendering, or leave glPolicy at its\n' +
|
|
301
|
+
'default and use indirect GLX, which needs no descriptor passing at all.'
|
|
302
|
+
);
|
|
303
|
+
}
|
|
277
304
|
|
|
278
305
|
const client = probeDirect(policy);
|
|
279
306
|
if (!client.ok) return fail(client.code, client.message, client.hint);
|
|
@@ -291,9 +318,10 @@ export function glCapabilities(app) {
|
|
|
291
318
|
}
|
|
292
319
|
if (!DRI3.fdCapable) {
|
|
293
320
|
return fail(
|
|
294
|
-
GLError.
|
|
321
|
+
GLError.NO_FD_PASSING,
|
|
295
322
|
'the x11 client cannot send descriptors on this connection (DRI3.fdCapable is false)',
|
|
296
|
-
'x11 builds an fd-capable socket for local displays unless `shm: false` was passed\
|
|
323
|
+
'x11 builds an fd-capable socket for local displays unless `shm: false` was passed\n' +
|
|
324
|
+
'to createClient, and needs a runtime that can pass descriptors — see above.'
|
|
297
325
|
);
|
|
298
326
|
}
|
|
299
327
|
|