@gtkx/gl 1.0.0-rc.1 → 1.0.0-rc.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/dist/overrides.d.ts +26 -14
- package/dist/overrides.d.ts.map +1 -1
- package/dist/overrides.js +34 -20
- package/dist/overrides.js.map +1 -1
- package/package.json +40 -8
- package/src/overrides.ts +98 -52
package/dist/overrides.d.ts
CHANGED
|
@@ -1,37 +1,48 @@
|
|
|
1
1
|
import type { DebugSeverity, DebugSource, DebugType, GLsync, GLuint, SyncObjectMask, SyncStatus } from "./generated/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A debug message reported by the GL driver.
|
|
4
|
+
*/
|
|
5
|
+
type DebugMessage = {
|
|
6
|
+
/** The origin of the message (API, window system, shader compiler, and so on). */
|
|
7
|
+
source: DebugSource;
|
|
8
|
+
/** The category of the message (error, deprecated behavior, performance, and so on). */
|
|
9
|
+
type: DebugType;
|
|
10
|
+
/** The driver-assigned identifier of the message. */
|
|
11
|
+
id: GLuint;
|
|
12
|
+
/** The severity level of the message. */
|
|
13
|
+
severity: DebugSeverity;
|
|
14
|
+
/** The human-readable message text. */
|
|
15
|
+
message: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Callback invoked for each GL debug message reported by the driver.
|
|
19
|
+
* @param message The message reported by the driver.
|
|
20
|
+
*/
|
|
21
|
+
type DebugMessageCallback = (message: DebugMessage) => void;
|
|
2
22
|
/**
|
|
3
23
|
* Reads the info log for a shader object, containing compilation diagnostics.
|
|
4
24
|
* @param shader The name of the shader object to query.
|
|
5
25
|
* @returns The shader info log, or an empty string when none is available.
|
|
6
26
|
*/
|
|
7
|
-
|
|
27
|
+
declare function getShaderInfoLog(shader: GLuint): string;
|
|
8
28
|
/**
|
|
9
29
|
* Reads the info log for a program object, containing linking diagnostics.
|
|
10
30
|
* @param program The name of the program object to query.
|
|
11
31
|
* @returns The program info log, or an empty string when none is available.
|
|
12
32
|
*/
|
|
13
|
-
|
|
33
|
+
declare function getProgramInfoLog(program: GLuint): string;
|
|
14
34
|
/**
|
|
15
35
|
* Reads the info log for a program pipeline object, containing validation diagnostics.
|
|
16
36
|
* @param pipeline The name of the program pipeline object to query.
|
|
17
37
|
* @returns The pipeline info log, or an empty string when none is available.
|
|
18
38
|
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Callback invoked for each GL debug message reported by the driver.
|
|
22
|
-
* @param source The origin of the message (API, window system, shader compiler, and so on).
|
|
23
|
-
* @param type The category of the message (error, deprecated behavior, performance, and so on).
|
|
24
|
-
* @param id The driver-assigned identifier of the message.
|
|
25
|
-
* @param severity The severity level of the message.
|
|
26
|
-
* @param message The human-readable message text.
|
|
27
|
-
*/
|
|
28
|
-
export type DebugMessageCallback = (source: DebugSource, type: DebugType, id: GLuint, severity: DebugSeverity, message: string) => void;
|
|
39
|
+
declare function getProgramPipelineInfoLog(pipeline: GLuint): string;
|
|
29
40
|
/**
|
|
30
41
|
* Installs a callback that receives GL debug messages, enabling synchronous debug output.
|
|
31
42
|
* Passing null removes any previously installed callback.
|
|
32
43
|
* @param callback The handler to invoke for each debug message, or null to clear it.
|
|
33
44
|
*/
|
|
34
|
-
|
|
45
|
+
declare function debugMessageCallback(callback: DebugMessageCallback | null): void;
|
|
35
46
|
/**
|
|
36
47
|
* Blocks until a sync object is signaled or the timeout elapses, looping over glClientWaitSync
|
|
37
48
|
* in bounded chunks so long waits are not truncated by the driver's per-call limit.
|
|
@@ -40,5 +51,6 @@ export declare function debugMessageCallback(callback: DebugMessageCallback | nu
|
|
|
40
51
|
* @param timeoutNs The total time to wait, in nanoseconds.
|
|
41
52
|
* @returns The status of the sync object: signaled, condition satisfied, or timeout expired.
|
|
42
53
|
*/
|
|
43
|
-
|
|
54
|
+
declare function clientWaitSyncLoop(sync: GLsync, flags: SyncObjectMask, timeoutNs: number): SyncStatus;
|
|
55
|
+
export { getShaderInfoLog, getProgramInfoLog, getProgramPipelineInfoLog, debugMessageCallback, clientWaitSyncLoop, type DebugMessage, type DebugMessageCallback, };
|
|
44
56
|
//# sourceMappingURL=overrides.d.ts.map
|
package/dist/overrides.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../src/overrides.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../src/overrides.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,aAAa,EACb,WAAW,EACX,SAAS,EAGT,MAAM,EACN,MAAM,EACN,cAAc,EACd,UAAU,EACb,MAAM,sBAAsB,CAAC;AAc9B;;GAEG;AACH,KAAK,YAAY,GAAG;IAChB,kFAAkF;IAClF,MAAM,EAAE,WAAW,CAAC;IACpB,wFAAwF;IACxF,IAAI,EAAE,SAAS,CAAC;IAChB,qDAAqD;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,yCAAyC;IACzC,QAAQ,EAAE,aAAa,CAAC;IACxB,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,KAAK,oBAAoB,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;AAoC5D;;;;GAIG;AACH,iBAAS,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;GAIG;AACH,iBAAS,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;GAIG;AACH,iBAAS,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;GAIG;AACH,iBAAS,oBAAoB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI,GAAG,IAAI,CAczE;AAcD;;;;;;;GAOG;AACH,iBAAS,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,CAoB9F;AAED,OAAO,EACH,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,oBAAoB,GAC5B,CAAC"}
|
package/dist/overrides.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { t } from "@gtkx/runtime";
|
|
2
2
|
import { clientWaitSync, enable, getProgramiv, getProgramPipelineiv, getShaderiv, LIB } from "./generated/commands.js";
|
|
3
3
|
import { ALREADY_SIGNALED, CONDITION_SATISFIED, DEBUG_OUTPUT, DEBUG_OUTPUT_SYNCHRONOUS, INFO_LOG_LENGTH, TIMEOUT_EXPIRED, } from "./generated/enums.js";
|
|
4
|
+
const glDebugMessageCallbackBinding = t.bind(LIB, "glDebugMessageCallback", [
|
|
5
|
+
t.callback([t.uint32, t.uint32, t.uint32, t.uint32, t.int32, t.string("borrowed"), t.uint64], t.void, {
|
|
6
|
+
userDataIndex: 6,
|
|
7
|
+
scope: "forever",
|
|
8
|
+
}),
|
|
9
|
+
], t.void);
|
|
10
|
+
const MAX_WAIT_CHUNK_NS = 1_000_000_000;
|
|
4
11
|
const readInfoLog = (symbol, id, query) => {
|
|
5
12
|
const length = query(id, INFO_LOG_LENGTH);
|
|
6
|
-
if (length <= 0)
|
|
13
|
+
if (length <= 0) {
|
|
7
14
|
return "";
|
|
15
|
+
}
|
|
8
16
|
const written = { value: 0 };
|
|
9
17
|
const log = { value: "" };
|
|
10
18
|
t.bind(LIB, symbol, [t.uint32, t.int32, t.ref(t.int32), t.ref(t.string("borrowed", length))], t.void)(id, length, written, log);
|
|
@@ -15,7 +23,7 @@ const readInfoLog = (symbol, id, query) => {
|
|
|
15
23
|
* @param shader The name of the shader object to query.
|
|
16
24
|
* @returns The shader info log, or an empty string when none is available.
|
|
17
25
|
*/
|
|
18
|
-
|
|
26
|
+
function getShaderInfoLog(shader) {
|
|
19
27
|
return readInfoLog("glGetShaderInfoLog", shader, getShaderiv);
|
|
20
28
|
}
|
|
21
29
|
/**
|
|
@@ -23,7 +31,7 @@ export function getShaderInfoLog(shader) {
|
|
|
23
31
|
* @param program The name of the program object to query.
|
|
24
32
|
* @returns The program info log, or an empty string when none is available.
|
|
25
33
|
*/
|
|
26
|
-
|
|
34
|
+
function getProgramInfoLog(program) {
|
|
27
35
|
return readInfoLog("glGetProgramInfoLog", program, getProgramiv);
|
|
28
36
|
}
|
|
29
37
|
/**
|
|
@@ -31,30 +39,35 @@ export function getProgramInfoLog(program) {
|
|
|
31
39
|
* @param pipeline The name of the program pipeline object to query.
|
|
32
40
|
* @returns The pipeline info log, or an empty string when none is available.
|
|
33
41
|
*/
|
|
34
|
-
|
|
42
|
+
function getProgramPipelineInfoLog(pipeline) {
|
|
35
43
|
return readInfoLog("glGetProgramPipelineInfoLog", pipeline, getProgramPipelineiv);
|
|
36
44
|
}
|
|
37
|
-
const glDebugMessageCallbackBinding = t.bind(LIB, "glDebugMessageCallback", [
|
|
38
|
-
t.callback([t.uint32, t.uint32, t.uint32, t.uint32, t.int32, t.string("borrowed"), t.uint64], t.void, {
|
|
39
|
-
userDataIndex: 6,
|
|
40
|
-
scope: "forever",
|
|
41
|
-
}),
|
|
42
|
-
], t.void);
|
|
43
45
|
/**
|
|
44
46
|
* Installs a callback that receives GL debug messages, enabling synchronous debug output.
|
|
45
47
|
* Passing null removes any previously installed callback.
|
|
46
48
|
* @param callback The handler to invoke for each debug message, or null to clear it.
|
|
47
49
|
*/
|
|
48
|
-
|
|
50
|
+
function debugMessageCallback(callback) {
|
|
49
51
|
if (callback === null) {
|
|
50
52
|
glDebugMessageCallbackBinding(null);
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
53
55
|
enable(DEBUG_OUTPUT);
|
|
54
56
|
enable(DEBUG_OUTPUT_SYNCHRONOUS);
|
|
55
|
-
glDebugMessageCallbackBinding((
|
|
57
|
+
glDebugMessageCallbackBinding((...args) => {
|
|
58
|
+
const [source, type, id, severity, , message] = args;
|
|
59
|
+
callback({ source, type, id, severity, message });
|
|
60
|
+
});
|
|
56
61
|
}
|
|
57
|
-
const
|
|
62
|
+
const settledSyncStatus = (status) => {
|
|
63
|
+
if (status === ALREADY_SIGNALED || status === CONDITION_SATISFIED) {
|
|
64
|
+
return status;
|
|
65
|
+
}
|
|
66
|
+
if (status !== TIMEOUT_EXPIRED) {
|
|
67
|
+
return status;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
};
|
|
58
71
|
/**
|
|
59
72
|
* Blocks until a sync object is signaled or the timeout elapses, looping over glClientWaitSync
|
|
60
73
|
* in bounded chunks so long waits are not truncated by the driver's per-call limit.
|
|
@@ -63,20 +76,21 @@ const MAX_WAIT_CHUNK_NS = 1_000_000_000;
|
|
|
63
76
|
* @param timeoutNs The total time to wait, in nanoseconds.
|
|
64
77
|
* @returns The status of the sync object: signaled, condition satisfied, or timeout expired.
|
|
65
78
|
*/
|
|
66
|
-
|
|
79
|
+
function clientWaitSyncLoop(sync, flags, timeoutNs) {
|
|
67
80
|
let remaining = timeoutNs;
|
|
68
81
|
let currentFlags = flags;
|
|
69
82
|
for (;;) {
|
|
70
83
|
const chunk = Math.min(remaining, MAX_WAIT_CHUNK_NS);
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
return status;
|
|
84
|
+
const settled = settledSyncStatus(clientWaitSync(sync, currentFlags, chunk));
|
|
85
|
+
if (settled !== null) {
|
|
86
|
+
return settled;
|
|
87
|
+
}
|
|
76
88
|
remaining -= chunk;
|
|
77
|
-
if (remaining <= 0)
|
|
89
|
+
if (remaining <= 0) {
|
|
78
90
|
return TIMEOUT_EXPIRED;
|
|
91
|
+
}
|
|
79
92
|
currentFlags = 0;
|
|
80
93
|
}
|
|
81
94
|
}
|
|
95
|
+
export { getShaderInfoLog, getProgramInfoLog, getProgramPipelineInfoLog, debugMessageCallback, clientWaitSyncLoop, };
|
|
82
96
|
//# sourceMappingURL=overrides.js.map
|
package/dist/overrides.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.js","sourceRoot":"","sources":["../src/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"overrides.js","sourceRoot":"","sources":["../src/overrides.ts"],"names":[],"mappings":"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","sourcesContent":["import { t } from \"@gtkx/runtime\";\nimport type {\n DebugSeverity,\n DebugSource,\n DebugType,\n GLenum,\n GLint,\n GLsync,\n GLuint,\n SyncObjectMask,\n SyncStatus,\n} from \"./generated/types.js\";\nimport { clientWaitSync, enable, getProgramiv, getProgramPipelineiv, getShaderiv, LIB } from \"./generated/commands.js\";\nimport {\n ALREADY_SIGNALED,\n CONDITION_SATISFIED,\n DEBUG_OUTPUT,\n DEBUG_OUTPUT_SYNCHRONOUS,\n INFO_LOG_LENGTH,\n TIMEOUT_EXPIRED,\n} from \"./generated/enums.js\";\n\ntype LengthQuery = (id: GLuint, pname: GLenum) => GLint;\ntype DebugCallbackArgs = [GLenum, GLenum, GLuint, GLenum, number, string];\n\n/**\n * A debug message reported by the GL driver.\n */\ntype DebugMessage = {\n /** The origin of the message (API, window system, shader compiler, and so on). */\n source: DebugSource;\n /** The category of the message (error, deprecated behavior, performance, and so on). */\n type: DebugType;\n /** The driver-assigned identifier of the message. */\n id: GLuint;\n /** The severity level of the message. */\n severity: DebugSeverity;\n /** The human-readable message text. */\n message: string;\n};\n\n/**\n * Callback invoked for each GL debug message reported by the driver.\n * @param message The message reported by the driver.\n */\ntype DebugMessageCallback = (message: DebugMessage) => void;\n\nconst glDebugMessageCallbackBinding = t.bind(\n LIB,\n \"glDebugMessageCallback\",\n [\n t.callback([t.uint32, t.uint32, t.uint32, t.uint32, t.int32, t.string(\"borrowed\"), t.uint64], t.void, {\n userDataIndex: 6,\n scope: \"forever\",\n }),\n ],\n t.void,\n);\n\nconst MAX_WAIT_CHUNK_NS = 1_000_000_000;\n\nconst readInfoLog = (symbol: string, id: GLuint, query: LengthQuery): string => {\n const length = query(id, INFO_LOG_LENGTH);\n\n if (length <= 0) {\n return \"\";\n }\n\n const written = { value: 0 };\n const log = { value: \"\" };\n\n t.bind(LIB, symbol, [t.uint32, t.int32, t.ref(t.int32), t.ref(t.string(\"borrowed\", length))], t.void)(\n id,\n length,\n written,\n log,\n );\n\n return log.value;\n};\n\n/**\n * Reads the info log for a shader object, containing compilation diagnostics.\n * @param shader The name of the shader object to query.\n * @returns The shader info log, or an empty string when none is available.\n */\nfunction getShaderInfoLog(shader: GLuint): string {\n return readInfoLog(\"glGetShaderInfoLog\", shader, getShaderiv);\n}\n\n/**\n * Reads the info log for a program object, containing linking diagnostics.\n * @param program The name of the program object to query.\n * @returns The program info log, or an empty string when none is available.\n */\nfunction getProgramInfoLog(program: GLuint): string {\n return readInfoLog(\"glGetProgramInfoLog\", program, getProgramiv);\n}\n\n/**\n * Reads the info log for a program pipeline object, containing validation diagnostics.\n * @param pipeline The name of the program pipeline object to query.\n * @returns The pipeline info log, or an empty string when none is available.\n */\nfunction getProgramPipelineInfoLog(pipeline: GLuint): string {\n return readInfoLog(\"glGetProgramPipelineInfoLog\", pipeline, getProgramPipelineiv);\n}\n\n/**\n * Installs a callback that receives GL debug messages, enabling synchronous debug output.\n * Passing null removes any previously installed callback.\n * @param callback The handler to invoke for each debug message, or null to clear it.\n */\nfunction debugMessageCallback(callback: DebugMessageCallback | null): void {\n if (callback === null) {\n glDebugMessageCallbackBinding(null);\n\n return;\n }\n\n enable(DEBUG_OUTPUT);\n enable(DEBUG_OUTPUT_SYNCHRONOUS);\n\n glDebugMessageCallbackBinding((...args: DebugCallbackArgs) => {\n const [source, type, id, severity, , message] = args;\n callback({ source, type, id, severity, message });\n });\n}\n\nconst settledSyncStatus = (status: SyncStatus): SyncStatus | null => {\n if (status === ALREADY_SIGNALED || status === CONDITION_SATISFIED) {\n return status;\n }\n\n if (status !== TIMEOUT_EXPIRED) {\n return status;\n }\n\n return null;\n};\n\n/**\n * Blocks until a sync object is signaled or the timeout elapses, looping over glClientWaitSync\n * in bounded chunks so long waits are not truncated by the driver's per-call limit.\n * @param sync The sync object (fence) to wait on.\n * @param flags Flags controlling the wait, such as flushing pending commands on the first call.\n * @param timeoutNs The total time to wait, in nanoseconds.\n * @returns The status of the sync object: signaled, condition satisfied, or timeout expired.\n */\nfunction clientWaitSyncLoop(sync: GLsync, flags: SyncObjectMask, timeoutNs: number): SyncStatus {\n let remaining = timeoutNs;\n let currentFlags = flags;\n\n for (;;) {\n const chunk = Math.min(remaining, MAX_WAIT_CHUNK_NS);\n const settled = settledSyncStatus(clientWaitSync(sync, currentFlags, chunk));\n\n if (settled !== null) {\n return settled;\n }\n\n remaining -= chunk;\n\n if (remaining <= 0) {\n return TIMEOUT_EXPIRED;\n }\n\n currentFlags = 0;\n }\n}\n\nexport {\n getShaderInfoLog,\n getProgramInfoLog,\n getProgramPipelineInfoLog,\n debugMessageCallback,\n clientWaitSyncLoop,\n type DebugMessage,\n type DebugMessageCallback,\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/gl",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
4
|
"description": "Generated OpenGL 4.6 core bindings plus override helpers for GTKX GLArea rendering",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -40,17 +40,49 @@
|
|
|
40
40
|
"node": ">=24"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@gtkx/runtime": "1.0.0-rc.
|
|
44
|
-
"@gtkx/native": "1.0.0-rc.
|
|
43
|
+
"@gtkx/runtime": "1.0.0-rc.2",
|
|
44
|
+
"@gtkx/native": "1.0.0-rc.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@types/node": "^26.1.
|
|
48
|
-
"
|
|
49
|
-
"@gtkx/
|
|
47
|
+
"@types/node": "^26.1.2",
|
|
48
|
+
"vitest": "^4.1.10",
|
|
49
|
+
"@gtkx/codegen": "1.0.0-rc.2",
|
|
50
|
+
"@gtkx/utils": "1.0.0-rc.2",
|
|
51
|
+
"@gtkx/vitest": "1.0.0-rc.2"
|
|
52
|
+
},
|
|
53
|
+
"nx": {
|
|
54
|
+
"targets": {
|
|
55
|
+
"codegen": {
|
|
56
|
+
"cache": true,
|
|
57
|
+
"dependsOn": [
|
|
58
|
+
"gtkx:codegen"
|
|
59
|
+
],
|
|
60
|
+
"inputs": [
|
|
61
|
+
"{projectRoot}/scripts/**/*",
|
|
62
|
+
"{projectRoot}/src/overrides.ts",
|
|
63
|
+
"^production",
|
|
64
|
+
"{workspaceRoot}/packages/codegen/src/khronos/**/*"
|
|
65
|
+
],
|
|
66
|
+
"outputs": [
|
|
67
|
+
"{projectRoot}/src/generated/**"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"build": {
|
|
71
|
+
"dependsOn": [
|
|
72
|
+
"^build",
|
|
73
|
+
"gtkx:codegen",
|
|
74
|
+
"codegen"
|
|
75
|
+
],
|
|
76
|
+
"inputs": [
|
|
77
|
+
"...",
|
|
78
|
+
{
|
|
79
|
+
"dependentTasksOutputFiles": "**/*.ts"
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
50
84
|
},
|
|
51
85
|
"scripts": {
|
|
52
|
-
"build": "tsc -b tsconfig.lib.json",
|
|
53
|
-
"typecheck": "tsc -b --emitDeclarationOnly",
|
|
54
86
|
"codegen": "NODE_OPTIONS=--conditions=source tsx ./scripts/codegen.ts",
|
|
55
87
|
"release": "tsx ../../scripts/release-package.ts"
|
|
56
88
|
}
|
package/src/overrides.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import { t } from "@gtkx/runtime";
|
|
2
|
-
import { clientWaitSync, enable, getProgramiv, getProgramPipelineiv, getShaderiv, LIB } from "./generated/commands.js";
|
|
3
|
-
import {
|
|
4
|
-
ALREADY_SIGNALED,
|
|
5
|
-
CONDITION_SATISFIED,
|
|
6
|
-
DEBUG_OUTPUT,
|
|
7
|
-
DEBUG_OUTPUT_SYNCHRONOUS,
|
|
8
|
-
INFO_LOG_LENGTH,
|
|
9
|
-
TIMEOUT_EXPIRED,
|
|
10
|
-
} from "./generated/enums.js";
|
|
11
2
|
import type {
|
|
12
3
|
DebugSeverity,
|
|
13
4
|
DebugSource,
|
|
@@ -19,20 +10,72 @@ import type {
|
|
|
19
10
|
SyncObjectMask,
|
|
20
11
|
SyncStatus,
|
|
21
12
|
} from "./generated/types.js";
|
|
13
|
+
import { clientWaitSync, enable, getProgramiv, getProgramPipelineiv, getShaderiv, LIB } from "./generated/commands.js";
|
|
14
|
+
import {
|
|
15
|
+
ALREADY_SIGNALED,
|
|
16
|
+
CONDITION_SATISFIED,
|
|
17
|
+
DEBUG_OUTPUT,
|
|
18
|
+
DEBUG_OUTPUT_SYNCHRONOUS,
|
|
19
|
+
INFO_LOG_LENGTH,
|
|
20
|
+
TIMEOUT_EXPIRED,
|
|
21
|
+
} from "./generated/enums.js";
|
|
22
22
|
|
|
23
23
|
type LengthQuery = (id: GLuint, pname: GLenum) => GLint;
|
|
24
|
+
type DebugCallbackArgs = [GLenum, GLenum, GLuint, GLenum, number, string];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A debug message reported by the GL driver.
|
|
28
|
+
*/
|
|
29
|
+
type DebugMessage = {
|
|
30
|
+
/** The origin of the message (API, window system, shader compiler, and so on). */
|
|
31
|
+
source: DebugSource;
|
|
32
|
+
/** The category of the message (error, deprecated behavior, performance, and so on). */
|
|
33
|
+
type: DebugType;
|
|
34
|
+
/** The driver-assigned identifier of the message. */
|
|
35
|
+
id: GLuint;
|
|
36
|
+
/** The severity level of the message. */
|
|
37
|
+
severity: DebugSeverity;
|
|
38
|
+
/** The human-readable message text. */
|
|
39
|
+
message: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Callback invoked for each GL debug message reported by the driver.
|
|
44
|
+
* @param message The message reported by the driver.
|
|
45
|
+
*/
|
|
46
|
+
type DebugMessageCallback = (message: DebugMessage) => void;
|
|
47
|
+
|
|
48
|
+
const glDebugMessageCallbackBinding = t.bind(
|
|
49
|
+
LIB,
|
|
50
|
+
"glDebugMessageCallback",
|
|
51
|
+
[
|
|
52
|
+
t.callback([t.uint32, t.uint32, t.uint32, t.uint32, t.int32, t.string("borrowed"), t.uint64], t.void, {
|
|
53
|
+
userDataIndex: 6,
|
|
54
|
+
scope: "forever",
|
|
55
|
+
}),
|
|
56
|
+
],
|
|
57
|
+
t.void,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const MAX_WAIT_CHUNK_NS = 1_000_000_000;
|
|
24
61
|
|
|
25
62
|
const readInfoLog = (symbol: string, id: GLuint, query: LengthQuery): string => {
|
|
26
63
|
const length = query(id, INFO_LOG_LENGTH);
|
|
27
|
-
|
|
64
|
+
|
|
65
|
+
if (length <= 0) {
|
|
66
|
+
return "";
|
|
67
|
+
}
|
|
68
|
+
|
|
28
69
|
const written = { value: 0 };
|
|
29
70
|
const log = { value: "" };
|
|
71
|
+
|
|
30
72
|
t.bind(LIB, symbol, [t.uint32, t.int32, t.ref(t.int32), t.ref(t.string("borrowed", length))], t.void)(
|
|
31
73
|
id,
|
|
32
74
|
length,
|
|
33
75
|
written,
|
|
34
76
|
log,
|
|
35
77
|
);
|
|
78
|
+
|
|
36
79
|
return log.value;
|
|
37
80
|
};
|
|
38
81
|
|
|
@@ -41,7 +84,7 @@ const readInfoLog = (symbol: string, id: GLuint, query: LengthQuery): string =>
|
|
|
41
84
|
* @param shader The name of the shader object to query.
|
|
42
85
|
* @returns The shader info log, or an empty string when none is available.
|
|
43
86
|
*/
|
|
44
|
-
|
|
87
|
+
function getShaderInfoLog(shader: GLuint): string {
|
|
45
88
|
return readInfoLog("glGetShaderInfoLog", shader, getShaderiv);
|
|
46
89
|
}
|
|
47
90
|
|
|
@@ -50,7 +93,7 @@ export function getShaderInfoLog(shader: GLuint): string {
|
|
|
50
93
|
* @param program The name of the program object to query.
|
|
51
94
|
* @returns The program info log, or an empty string when none is available.
|
|
52
95
|
*/
|
|
53
|
-
|
|
96
|
+
function getProgramInfoLog(program: GLuint): string {
|
|
54
97
|
return readInfoLog("glGetProgramInfoLog", program, getProgramiv);
|
|
55
98
|
}
|
|
56
99
|
|
|
@@ -59,57 +102,42 @@ export function getProgramInfoLog(program: GLuint): string {
|
|
|
59
102
|
* @param pipeline The name of the program pipeline object to query.
|
|
60
103
|
* @returns The pipeline info log, or an empty string when none is available.
|
|
61
104
|
*/
|
|
62
|
-
|
|
105
|
+
function getProgramPipelineInfoLog(pipeline: GLuint): string {
|
|
63
106
|
return readInfoLog("glGetProgramPipelineInfoLog", pipeline, getProgramPipelineiv);
|
|
64
107
|
}
|
|
65
108
|
|
|
66
|
-
/**
|
|
67
|
-
* Callback invoked for each GL debug message reported by the driver.
|
|
68
|
-
* @param source The origin of the message (API, window system, shader compiler, and so on).
|
|
69
|
-
* @param type The category of the message (error, deprecated behavior, performance, and so on).
|
|
70
|
-
* @param id The driver-assigned identifier of the message.
|
|
71
|
-
* @param severity The severity level of the message.
|
|
72
|
-
* @param message The human-readable message text.
|
|
73
|
-
*/
|
|
74
|
-
export type DebugMessageCallback = (
|
|
75
|
-
source: DebugSource,
|
|
76
|
-
type: DebugType,
|
|
77
|
-
id: GLuint,
|
|
78
|
-
severity: DebugSeverity,
|
|
79
|
-
message: string,
|
|
80
|
-
) => void;
|
|
81
|
-
|
|
82
|
-
const glDebugMessageCallbackBinding = t.bind(
|
|
83
|
-
LIB,
|
|
84
|
-
"glDebugMessageCallback",
|
|
85
|
-
[
|
|
86
|
-
t.callback([t.uint32, t.uint32, t.uint32, t.uint32, t.int32, t.string("borrowed"), t.uint64], t.void, {
|
|
87
|
-
userDataIndex: 6,
|
|
88
|
-
scope: "forever",
|
|
89
|
-
}),
|
|
90
|
-
],
|
|
91
|
-
t.void,
|
|
92
|
-
);
|
|
93
|
-
|
|
94
109
|
/**
|
|
95
110
|
* Installs a callback that receives GL debug messages, enabling synchronous debug output.
|
|
96
111
|
* Passing null removes any previously installed callback.
|
|
97
112
|
* @param callback The handler to invoke for each debug message, or null to clear it.
|
|
98
113
|
*/
|
|
99
|
-
|
|
114
|
+
function debugMessageCallback(callback: DebugMessageCallback | null): void {
|
|
100
115
|
if (callback === null) {
|
|
101
116
|
glDebugMessageCallbackBinding(null);
|
|
117
|
+
|
|
102
118
|
return;
|
|
103
119
|
}
|
|
120
|
+
|
|
104
121
|
enable(DEBUG_OUTPUT);
|
|
105
122
|
enable(DEBUG_OUTPUT_SYNCHRONOUS);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
123
|
+
|
|
124
|
+
glDebugMessageCallbackBinding((...args: DebugCallbackArgs) => {
|
|
125
|
+
const [source, type, id, severity, , message] = args;
|
|
126
|
+
callback({ source, type, id, severity, message });
|
|
127
|
+
});
|
|
110
128
|
}
|
|
111
129
|
|
|
112
|
-
const
|
|
130
|
+
const settledSyncStatus = (status: SyncStatus): SyncStatus | null => {
|
|
131
|
+
if (status === ALREADY_SIGNALED || status === CONDITION_SATISFIED) {
|
|
132
|
+
return status;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (status !== TIMEOUT_EXPIRED) {
|
|
136
|
+
return status;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return null;
|
|
140
|
+
};
|
|
113
141
|
|
|
114
142
|
/**
|
|
115
143
|
* Blocks until a sync object is signaled or the timeout elapses, looping over glClientWaitSync
|
|
@@ -119,16 +147,34 @@ const MAX_WAIT_CHUNK_NS = 1_000_000_000;
|
|
|
119
147
|
* @param timeoutNs The total time to wait, in nanoseconds.
|
|
120
148
|
* @returns The status of the sync object: signaled, condition satisfied, or timeout expired.
|
|
121
149
|
*/
|
|
122
|
-
|
|
150
|
+
function clientWaitSyncLoop(sync: GLsync, flags: SyncObjectMask, timeoutNs: number): SyncStatus {
|
|
123
151
|
let remaining = timeoutNs;
|
|
124
152
|
let currentFlags = flags;
|
|
153
|
+
|
|
125
154
|
for (;;) {
|
|
126
155
|
const chunk = Math.min(remaining, MAX_WAIT_CHUNK_NS);
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
if (
|
|
156
|
+
const settled = settledSyncStatus(clientWaitSync(sync, currentFlags, chunk));
|
|
157
|
+
|
|
158
|
+
if (settled !== null) {
|
|
159
|
+
return settled;
|
|
160
|
+
}
|
|
161
|
+
|
|
130
162
|
remaining -= chunk;
|
|
131
|
-
|
|
163
|
+
|
|
164
|
+
if (remaining <= 0) {
|
|
165
|
+
return TIMEOUT_EXPIRED;
|
|
166
|
+
}
|
|
167
|
+
|
|
132
168
|
currentFlags = 0;
|
|
133
169
|
}
|
|
134
170
|
}
|
|
171
|
+
|
|
172
|
+
export {
|
|
173
|
+
getShaderInfoLog,
|
|
174
|
+
getProgramInfoLog,
|
|
175
|
+
getProgramPipelineInfoLog,
|
|
176
|
+
debugMessageCallback,
|
|
177
|
+
clientWaitSyncLoop,
|
|
178
|
+
type DebugMessage,
|
|
179
|
+
type DebugMessageCallback,
|
|
180
|
+
};
|