@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.6
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/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +71 -11
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +3 -2
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +40 -20
- package/dist/adapter/converters/texture-formats.d.ts +10 -7
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +76 -64
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +2 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +18 -5
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +77 -43
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +2 -1
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.js +17 -14
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +33 -48
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js +42 -87
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +2 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +6 -5
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +2 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +2 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +2 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +24 -11
- package/dist/adapter/objects/webgl-resource.d.ts +2 -24
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +6 -100
- package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +2 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +7 -6
- package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +4 -2
- package/dist/adapter/resources/webgl-external-texture.js +3 -2
- package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -8
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +25 -23
- package/dist/adapter/resources/webgl-query-set.d.ts +44 -0
- package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-query-set.js +136 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts +3 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +15 -7
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +4 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +34 -49
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +12 -6
- package/dist/adapter/resources/webgl-texture-view.d.ts +14 -0
- package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-texture-view.js +18 -0
- package/dist/adapter/resources/webgl-texture.d.ts +4 -3
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +12 -7
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +2 -2
- package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -3
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +5 -4
- package/dist/adapter/webgl-canvas-context.d.ts +2 -2
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +3 -2
- package/dist/adapter/webgl-device.d.ts +29 -27
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +90 -94
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +4 -3
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +3 -2
- package/dist/classic/copy-and-blit.d.ts +1 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +5 -4
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +2 -1
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +2 -1
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +2 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +7 -6
- package/dist/context/helpers/create-browser-context.d.ts +35 -0
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -0
- package/dist/context/helpers/create-browser-context.js +67 -0
- package/dist/context/helpers/webgl-context-data.d.ts +13 -0
- package/dist/context/helpers/webgl-context-data.d.ts.map +1 -0
- package/dist/context/helpers/webgl-context-data.js +21 -0
- package/dist/context/helpers/webgl-extensions.d.ts +4 -0
- package/dist/context/helpers/webgl-extensions.d.ts.map +1 -0
- package/dist/context/helpers/webgl-extensions.js +10 -0
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +4 -3
- package/dist/context/parameters/webgl-parameter-tables.d.ts +10 -0
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +29 -16
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +2 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +5 -4
- package/dist/context/state-tracker/with-parameters.d.ts +1 -1
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +5 -4
- package/dist/dist.dev.js +941 -730
- package/dist/index.cjs +732 -565
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +25 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist.min.js +5 -5
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +105 -16
- package/src/adapter/converters/sampler-parameters.ts +12 -3
- package/src/adapter/converters/shader-formats.ts +47 -22
- package/src/adapter/converters/texture-formats.ts +87 -66
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +83 -51
- package/src/adapter/device-helpers/webgl-device-info.ts +28 -19
- package/src/adapter/device-helpers/webgl-device-limits.ts +46 -150
- package/src/adapter/helpers/decode-webgl-types.ts +13 -7
- package/src/adapter/helpers/get-shader-layout.ts +4 -3
- package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
- package/src/adapter/helpers/set-uniform.ts +2 -1
- package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
- package/src/adapter/objects/constants-to-keys.ts +2 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +35 -13
- package/src/adapter/objects/webgl-resource.ts +6 -124
- package/src/adapter/resources/webgl-buffer.ts +4 -3
- package/src/adapter/resources/webgl-command-buffer.ts +5 -5
- package/src/adapter/resources/webgl-command-encoder.ts +14 -11
- package/src/adapter/resources/webgl-external-texture.ts +3 -2
- package/src/adapter/resources/webgl-framebuffer.ts +34 -29
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +17 -8
- package/src/adapter/resources/webgl-render-pipeline.ts +41 -48
- package/src/adapter/resources/webgl-sampler.ts +2 -1
- package/src/adapter/resources/webgl-shader.ts +12 -5
- package/src/adapter/resources/webgl-texture-view.ts +28 -0
- package/src/adapter/resources/webgl-texture.ts +9 -2
- package/src/adapter/resources/webgl-transform-feedback.ts +2 -7
- package/src/adapter/resources/webgl-vertex-array.ts +4 -3
- package/src/adapter/webgl-canvas-context.ts +6 -4
- package/src/adapter/webgl-device.ts +94 -90
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +12 -6
- package/src/classic/copy-and-blit.ts +11 -4
- package/src/classic/format-utils.ts +2 -1
- package/src/classic/typed-array-utils.ts +3 -7
- package/src/context/debug/spector.ts +9 -6
- package/src/context/debug/webgl-developer-tools.ts +27 -14
- package/src/context/{context → helpers}/create-browser-context.ts +3 -2
- package/src/context/helpers/webgl-context-data.ts +31 -0
- package/src/context/helpers/webgl-extensions.ts +17 -0
- package/src/context/parameters/unified-parameter-api.ts +2 -1
- package/src/context/parameters/webgl-parameter-tables.ts +69 -32
- package/src/context/state-tracker/deep-array-equal.ts +2 -1
- package/src/context/state-tracker/track-context-state.ts +11 -6
- package/src/context/state-tracker/with-parameters.ts +7 -2
- package/src/index.ts +3 -2
- package/src/types.ts +2 -1
- package/src/context/context/context-data.ts +0 -44
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// WebGL2 Query (also handles disjoint timer extensions)
|
|
2
|
+
import { QuerySet } from '@luma.gl/core';
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
|
+
/**
|
|
5
|
+
* Asynchronous queries for different kinds of information
|
|
6
|
+
*/
|
|
7
|
+
export class WEBGLQuerySet extends QuerySet {
|
|
8
|
+
device;
|
|
9
|
+
handle;
|
|
10
|
+
target = null;
|
|
11
|
+
_queryPending = false;
|
|
12
|
+
_pollingPromise = null;
|
|
13
|
+
get [Symbol.toStringTag]() {
|
|
14
|
+
return 'Query';
|
|
15
|
+
}
|
|
16
|
+
// Create a query class
|
|
17
|
+
constructor(device, props) {
|
|
18
|
+
super(device, props);
|
|
19
|
+
this.device = device;
|
|
20
|
+
if (props.count > 1) {
|
|
21
|
+
throw new Error('WebGL QuerySet can only have one value');
|
|
22
|
+
}
|
|
23
|
+
this.handle = this.device.gl.createQuery();
|
|
24
|
+
Object.seal(this);
|
|
25
|
+
}
|
|
26
|
+
destroy() {
|
|
27
|
+
this.device.gl.deleteQuery(this.handle);
|
|
28
|
+
}
|
|
29
|
+
// FOR RENDER PASS AND COMMAND ENCODER
|
|
30
|
+
/**
|
|
31
|
+
* Shortcut for timer query (dependent on extension in both WebGL1 and 2)
|
|
32
|
+
* Measures GPU time delta between this call and a matching `end` call in the
|
|
33
|
+
* GPU instruction stream.
|
|
34
|
+
*/
|
|
35
|
+
beginTimestampQuery() {
|
|
36
|
+
return this._begin(GL.TIME_ELAPSED_EXT);
|
|
37
|
+
}
|
|
38
|
+
endTimestampQuery() {
|
|
39
|
+
this._end();
|
|
40
|
+
}
|
|
41
|
+
// Shortcut for occlusion queries
|
|
42
|
+
beginOcclusionQuery(options) {
|
|
43
|
+
return this._begin(options?.conservative ? GL.ANY_SAMPLES_PASSED_CONSERVATIVE : GL.ANY_SAMPLES_PASSED);
|
|
44
|
+
}
|
|
45
|
+
endOcclusionQuery() {
|
|
46
|
+
this._end();
|
|
47
|
+
}
|
|
48
|
+
// Shortcut for transformFeedbackQuery
|
|
49
|
+
beginTransformFeedbackQuery() {
|
|
50
|
+
return this._begin(GL.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
|
|
51
|
+
}
|
|
52
|
+
endTransformFeedbackQuery() {
|
|
53
|
+
this._end();
|
|
54
|
+
}
|
|
55
|
+
async resolveQuery() {
|
|
56
|
+
const value = await this.pollQuery();
|
|
57
|
+
return [value];
|
|
58
|
+
}
|
|
59
|
+
// PRIVATE METHODS
|
|
60
|
+
/**
|
|
61
|
+
* Due to OpenGL API limitations, after calling `begin()` on one Query
|
|
62
|
+
* instance, `end()` must be called on that same instance before
|
|
63
|
+
* calling `begin()` on another query. While there can be multiple
|
|
64
|
+
* outstanding queries representing disjoint `begin()`/`end()` intervals.
|
|
65
|
+
* It is not possible to interleave or overlap `begin` and `end` calls.
|
|
66
|
+
*/
|
|
67
|
+
_begin(target) {
|
|
68
|
+
// Don't start a new query if one is already active.
|
|
69
|
+
if (this._queryPending) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.target = target;
|
|
73
|
+
this.device.gl.beginQuery(this.target, this.handle);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// ends the current query
|
|
77
|
+
_end() {
|
|
78
|
+
// Can't end a new query if the last one hasn't been resolved.
|
|
79
|
+
if (this._queryPending) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (this.target) {
|
|
83
|
+
this.device.gl.endQuery(this.target);
|
|
84
|
+
this.target = null;
|
|
85
|
+
this._queryPending = true;
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// Returns true if the query result is available
|
|
90
|
+
isResultAvailable() {
|
|
91
|
+
if (!this._queryPending) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const resultAvailable = this.device.gl.getQueryParameter(this.handle, GL.QUERY_RESULT_AVAILABLE);
|
|
95
|
+
if (resultAvailable) {
|
|
96
|
+
this._queryPending = false;
|
|
97
|
+
}
|
|
98
|
+
return resultAvailable;
|
|
99
|
+
}
|
|
100
|
+
// Timing query is disjoint, i.e. results are invalid
|
|
101
|
+
isTimerDisjoint() {
|
|
102
|
+
return this.device.gl.getParameter(GL.GPU_DISJOINT_EXT);
|
|
103
|
+
}
|
|
104
|
+
// Returns query result.
|
|
105
|
+
getResult() {
|
|
106
|
+
return this.device.gl.getQueryParameter(this.handle, GL.QUERY_RESULT);
|
|
107
|
+
}
|
|
108
|
+
// Returns the query result, converted to milliseconds to match JavaScript conventions.
|
|
109
|
+
getTimerMilliseconds() {
|
|
110
|
+
return this.getResult() / 1e6;
|
|
111
|
+
}
|
|
112
|
+
// Polls the query
|
|
113
|
+
pollQuery(limit = Number.POSITIVE_INFINITY) {
|
|
114
|
+
if (this._pollingPromise) {
|
|
115
|
+
return this._pollingPromise;
|
|
116
|
+
}
|
|
117
|
+
let counter = 0;
|
|
118
|
+
this._pollingPromise = new Promise((resolve, reject) => {
|
|
119
|
+
const poll = () => {
|
|
120
|
+
if (this.isResultAvailable()) {
|
|
121
|
+
resolve(this.getResult());
|
|
122
|
+
this._pollingPromise = null;
|
|
123
|
+
}
|
|
124
|
+
else if (counter++ > limit) {
|
|
125
|
+
reject('Timed out');
|
|
126
|
+
this._pollingPromise = null;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
requestAnimationFrame(poll);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
requestAnimationFrame(poll);
|
|
133
|
+
});
|
|
134
|
+
return this._pollingPromise;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RenderPass, RenderPassProps, NumberArray, RenderPassParameters } from '@luma.gl/core';
|
|
2
|
-
import { WebGLDevice } from
|
|
2
|
+
import { WebGLDevice } from "../webgl-device.js";
|
|
3
3
|
import { GLParameters } from '@luma.gl/constants';
|
|
4
4
|
export declare class WEBGLRenderPass extends RenderPass {
|
|
5
5
|
readonly device: WebGLDevice;
|
|
@@ -14,6 +14,8 @@ export declare class WEBGLRenderPass extends RenderPass {
|
|
|
14
14
|
* Maps RenderPass parameters to GL parameters
|
|
15
15
|
*/
|
|
16
16
|
setParameters(parameters?: RenderPassParameters): void;
|
|
17
|
+
beginOcclusionQuery(queryIndex: number): void;
|
|
18
|
+
endOcclusionQuery(): void;
|
|
17
19
|
/**
|
|
18
20
|
* Optionally clears depth, color and stencil buffers based on parameters
|
|
19
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pass.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pass.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAC5C,OAAO,EAAK,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAapD,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B,8DAA8D;IAC9D,YAAY,EAAE,YAAY,CAAC;gBAEf,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe;IAYvD,GAAG,IAAI,IAAI;IAQX,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IACxC,aAAa,IAAI,IAAI;IACrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAO5C;;OAEG;IACH,aAAa,CAAC,UAAU,GAAE,oBAAyB,GAAG,IAAI;IA+C1D,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAKpC,iBAAiB,IAAI,IAAI;IAOlC;;OAEG;IACH,SAAS,CAAC,KAAK,IAAI,IAAI;IA+BvB;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,UAAU,GAAE,MAAU,EAAE,KAAK,GAAE,WAA0B;CAwCrF"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
import { RenderPass } from '@luma.gl/core';
|
|
4
5
|
import { GL } from '@luma.gl/constants';
|
|
5
|
-
import { withGLParameters } from
|
|
6
|
-
import { setGLParameters } from
|
|
7
|
-
import { pushContextState, popContextState } from
|
|
6
|
+
import { withGLParameters } from "../../context/state-tracker/with-parameters.js";
|
|
7
|
+
import { setGLParameters } from "../../context/parameters/unified-parameter-api.js";
|
|
8
|
+
import { pushContextState, popContextState } from "../../context/state-tracker/track-context-state.js";
|
|
8
9
|
// Should collapse during minification
|
|
9
10
|
const GL_DEPTH_BUFFER_BIT = 0x00000100;
|
|
10
11
|
const GL_STENCIL_BUFFER_BIT = 0x00000400;
|
|
@@ -33,7 +34,6 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
33
34
|
pushDebugGroup(groupLabel) { }
|
|
34
35
|
popDebugGroup() { }
|
|
35
36
|
insertDebugMarker(markerLabel) { }
|
|
36
|
-
// writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
|
|
37
37
|
// beginOcclusionQuery(queryIndex: number): void;
|
|
38
38
|
// endOcclusionQuery(): void;
|
|
39
39
|
// executeBundles(bundles: Iterable<GPURenderBundle>): void;
|
|
@@ -80,7 +80,15 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
80
80
|
this.glParameters = glParameters;
|
|
81
81
|
setGLParameters(this.device, glParameters);
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
beginOcclusionQuery(queryIndex) {
|
|
84
|
+
const webglQuerySet = this.props.occlusionQuerySet;
|
|
85
|
+
webglQuerySet?.beginOcclusionQuery();
|
|
86
|
+
}
|
|
87
|
+
endOcclusionQuery() {
|
|
88
|
+
const webglQuerySet = this.props.occlusionQuerySet;
|
|
89
|
+
webglQuerySet?.endOcclusionQuery();
|
|
90
|
+
}
|
|
91
|
+
// PRIVATE
|
|
84
92
|
/**
|
|
85
93
|
* Optionally clears depth, color and stencil buffers based on parameters
|
|
86
94
|
*/
|
|
@@ -106,7 +114,7 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
106
114
|
});
|
|
107
115
|
// TODO - clear multiple color attachments
|
|
108
116
|
// for (attachment of this.framebuffer.colorAttachments) {
|
|
109
|
-
// this.clearColorBuffer
|
|
117
|
+
// this.clearColorBuffer
|
|
110
118
|
// }
|
|
111
119
|
}
|
|
112
120
|
}
|
|
@@ -2,9 +2,9 @@ import type { UniformValue, RenderPipelineProps, Binding } from '@luma.gl/core';
|
|
|
2
2
|
import type { ShaderLayout } from '@luma.gl/core';
|
|
3
3
|
import type { RenderPass, VertexArray } from '@luma.gl/core';
|
|
4
4
|
import { RenderPipeline } from '@luma.gl/core';
|
|
5
|
-
import { WebGLDevice } from
|
|
6
|
-
import { WEBGLShader } from
|
|
7
|
-
import { WEBGLTransformFeedback } from
|
|
5
|
+
import { WebGLDevice } from "../webgl-device.js";
|
|
6
|
+
import { WEBGLShader } from "./webgl-shader.js";
|
|
7
|
+
import { WEBGLTransformFeedback } from "./webgl-transform-feedback.js";
|
|
8
8
|
/** Creates a new render pipeline */
|
|
9
9
|
export declare class WEBGLRenderPipeline extends RenderPipeline {
|
|
10
10
|
/** The WebGL device that created this render pipeline */
|
|
@@ -32,8 +32,6 @@ export declare class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
32
32
|
* @todo needed for portable model
|
|
33
33
|
*/
|
|
34
34
|
setBindings(bindings: Record<string, Binding>): void;
|
|
35
|
-
/** This function is @deprecated, use uniform buffers */
|
|
36
|
-
setUniforms(uniforms: Record<string, UniformValue>): void;
|
|
37
35
|
/** @todo needed for portable model
|
|
38
36
|
* @note The WebGL API is offers many ways to draw things
|
|
39
37
|
* This function unifies those ways into a single call using common parameters with sane defaults
|
|
@@ -51,6 +49,7 @@ export declare class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
51
49
|
baseVertex?: number;
|
|
52
50
|
transformFeedback?: WEBGLTransformFeedback;
|
|
53
51
|
}): boolean;
|
|
52
|
+
setUniformsWebGL(uniforms: Record<string, UniformValue>): void;
|
|
54
53
|
protected _linkShaders(): Promise<void>;
|
|
55
54
|
/** Report link status. First, check for shader compilation failures if linking fails */
|
|
56
55
|
_reportLinkStatus(status: 'success' | 'linking' | 'validation'): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pipeline.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pipeline.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,mBAAmB,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAC9E,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAsC,MAAM,eAAe,CAAC;AAUlF,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C,OAAO,EAAC,WAAW,EAAC,0BAAuB;AAK3C,OAAO,EAAC,sBAAsB,EAAC,sCAAmC;AAKlE,oCAAoC;AACpC,qBAAa,mBA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cAkBhD,YAAY;IA2B5B,wFAAwF;IACxF,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY;IAmB9D;;;;OAIG;IACH,cAAc,IAAI,SAAS,GAAG,SAAS,GAAG,YAAY;IAmBtD,6DAA6D;IACvD,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB3C;;;;OAIG;IACH,sBAAsB;IAatB,iDAAiD;IACjD,cAAc;IAyFd;;;OAGG;IACH,cAAc;CASf"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
import { RenderPipeline, cast, splitUniformsAndBindings, log } from '@luma.gl/core';
|
|
4
5
|
import { mergeShaderLayout } from '@luma.gl/core';
|
|
5
6
|
// import {mergeShaderLayout, getAttributeInfosFromLayouts} from '@luma.gl/core';
|
|
6
7
|
import { GL } from '@luma.gl/constants';
|
|
7
|
-
import { getShaderLayout } from
|
|
8
|
-
import { withDeviceAndGLParameters } from
|
|
9
|
-
import { setUniform } from
|
|
10
|
-
import { WEBGLBuffer } from
|
|
11
|
-
import { WEBGLFramebuffer } from
|
|
12
|
-
import { WEBGLTexture } from
|
|
13
|
-
import {
|
|
8
|
+
import { getShaderLayout } from "../helpers/get-shader-layout.js";
|
|
9
|
+
import { withDeviceAndGLParameters } from "../converters/device-parameters.js";
|
|
10
|
+
import { setUniform } from "../helpers/set-uniform.js";
|
|
11
|
+
import { WEBGLBuffer } from "./webgl-buffer.js";
|
|
12
|
+
import { WEBGLFramebuffer } from "./webgl-framebuffer.js";
|
|
13
|
+
import { WEBGLTexture } from "./webgl-texture.js";
|
|
14
|
+
import { WEBGLTextureView } from "./webgl-texture-view.js";
|
|
15
|
+
import { getGLDrawMode } from "../helpers/webgl-topology-utils.js";
|
|
14
16
|
const LOG_PROGRAM_PERF_PRIORITY = 4;
|
|
15
17
|
/** Creates a new render pipeline */
|
|
16
18
|
export class WEBGLRenderPipeline extends RenderPipeline {
|
|
@@ -50,7 +52,9 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
50
52
|
this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
|
|
51
53
|
}
|
|
52
54
|
this._linkShaders();
|
|
55
|
+
log.time(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
53
56
|
this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
|
|
57
|
+
log.timeEnd(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
54
58
|
// Merge provided layout with introspected layout
|
|
55
59
|
this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);
|
|
56
60
|
// WebGPU has more restrictive topology support than WebGL
|
|
@@ -102,7 +106,9 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
102
106
|
}
|
|
103
107
|
break;
|
|
104
108
|
case 'texture':
|
|
105
|
-
if (!(value instanceof
|
|
109
|
+
if (!(value instanceof WEBGLTextureView ||
|
|
110
|
+
value instanceof WEBGLTexture ||
|
|
111
|
+
value instanceof WEBGLFramebuffer)) {
|
|
106
112
|
throw new Error('texture value');
|
|
107
113
|
}
|
|
108
114
|
break;
|
|
@@ -115,15 +121,6 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
115
121
|
this.bindings[name] = value;
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
|
-
/** This function is @deprecated, use uniform buffers */
|
|
119
|
-
setUniforms(uniforms) {
|
|
120
|
-
const { bindings } = splitUniformsAndBindings(uniforms);
|
|
121
|
-
Object.keys(bindings).forEach(name => {
|
|
122
|
-
log.warn(`Unsupported value "${JSON.stringify(bindings[name])}" used in setUniforms() for key ${name}. Use setBindings() instead?`)();
|
|
123
|
-
});
|
|
124
|
-
// TODO - check against layout
|
|
125
|
-
Object.assign(this.uniforms, uniforms);
|
|
126
|
-
}
|
|
127
124
|
/** @todo needed for portable model
|
|
128
125
|
* @note The WebGL API is offers many ways to draw things
|
|
129
126
|
* This function unifies those ways into a single call using common parameters with sane defaults
|
|
@@ -162,34 +159,8 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
162
159
|
this._applyBindings();
|
|
163
160
|
this._applyUniforms();
|
|
164
161
|
const webglRenderPass = renderPass;
|
|
165
|
-
// // TODO - Use polyfilled WebGL2RenderingContext instead of ANGLE extension
|
|
166
|
-
// if (isIndexed && isInstanced) {
|
|
167
|
-
// // ANGLE_instanced_arrays extension
|
|
168
|
-
// this.device.gl.drawElementsInstanced(
|
|
169
|
-
// drawMode,
|
|
170
|
-
// vertexCount || 0, // indexCount?
|
|
171
|
-
// indexType,
|
|
172
|
-
// firstVertex,
|
|
173
|
-
// instanceCount || 0
|
|
174
|
-
// );
|
|
175
|
-
// // } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) {
|
|
176
|
-
// // this.device.gldrawRangeElements(drawMode, start, end, vertexCount, indexType, offset);
|
|
177
|
-
// } else if (isIndexed) {
|
|
178
|
-
// this.device.gl.drawElements(drawMode, vertexCount || 0, indexType, firstVertex); // indexCount?
|
|
179
|
-
// } else if (isInstanced) {
|
|
180
|
-
// this.device.gl.drawArraysInstanced(
|
|
181
|
-
// drawMode,
|
|
182
|
-
// firstVertex,
|
|
183
|
-
// vertexCount || 0,
|
|
184
|
-
// instanceCount || 0
|
|
185
|
-
// );
|
|
186
|
-
// } else {
|
|
187
|
-
// this.device.gl.drawArrays(drawMode, firstVertex, vertexCount || 0);
|
|
188
|
-
// }
|
|
189
|
-
// });
|
|
190
162
|
withDeviceAndGLParameters(this.device, this.props.parameters, webglRenderPass.glParameters, () => {
|
|
191
163
|
if (isIndexed && isInstanced) {
|
|
192
|
-
// ANGLE_instanced_arrays extension
|
|
193
164
|
this.device.gl.drawElementsInstanced(glDrawMode, vertexCount || 0, // indexCount?
|
|
194
165
|
glIndexType, firstVertex, instanceCount || 0);
|
|
195
166
|
// } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) {
|
|
@@ -211,6 +182,15 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
211
182
|
vertexArray.unbindAfterRender(renderPass);
|
|
212
183
|
return true;
|
|
213
184
|
}
|
|
185
|
+
// DEPRECATED METHODS
|
|
186
|
+
setUniformsWebGL(uniforms) {
|
|
187
|
+
const { bindings } = splitUniformsAndBindings(uniforms);
|
|
188
|
+
Object.keys(bindings).forEach(name => {
|
|
189
|
+
log.warn(`Unsupported value "${JSON.stringify(bindings[name])}" used in setUniforms() for key ${name}. Use setBindings() instead?`)();
|
|
190
|
+
});
|
|
191
|
+
// TODO - check against layout
|
|
192
|
+
Object.assign(this.uniforms, uniforms);
|
|
193
|
+
}
|
|
214
194
|
// PRIVATE METHODS
|
|
215
195
|
// setAttributes(attributes: Record<string, Buffer>): void {}
|
|
216
196
|
// setBindings(bindings: Record<string, Binding>): void {}
|
|
@@ -225,7 +205,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
225
205
|
if (log.level === 0) {
|
|
226
206
|
// return;
|
|
227
207
|
}
|
|
228
|
-
if (!this.device.features.has('
|
|
208
|
+
if (!this.device.features.has('compilation-status-async-webgl')) {
|
|
229
209
|
const status = this._getLinkStatus();
|
|
230
210
|
this._reportLinkStatus(status);
|
|
231
211
|
return;
|
|
@@ -281,13 +261,13 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
281
261
|
const waitMs = async (ms) => await new Promise(resolve => setTimeout(resolve, ms));
|
|
282
262
|
const DELAY_MS = 10; // Shader compilation is typically quite fast (with some exceptions)
|
|
283
263
|
// If status polling is not available, we can't wait for completion. Just wait a little to minimize blocking
|
|
284
|
-
if (!this.device.features.has('
|
|
264
|
+
if (!this.device.features.has('compilation-status-async-webgl')) {
|
|
285
265
|
await waitMs(DELAY_MS);
|
|
286
266
|
return;
|
|
287
267
|
}
|
|
288
268
|
const { gl } = this.device;
|
|
289
269
|
for (;;) {
|
|
290
|
-
const complete = gl.getProgramParameter(this.handle, GL.
|
|
270
|
+
const complete = gl.getProgramParameter(this.handle, GL.COMPLETION_STATUS_KHR);
|
|
291
271
|
if (complete) {
|
|
292
272
|
return;
|
|
293
273
|
}
|
|
@@ -350,11 +330,16 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
350
330
|
uniformBufferIndex += 1;
|
|
351
331
|
break;
|
|
352
332
|
case 'texture':
|
|
353
|
-
if (!(value instanceof
|
|
333
|
+
if (!(value instanceof WEBGLTextureView ||
|
|
334
|
+
value instanceof WEBGLTexture ||
|
|
335
|
+
value instanceof WEBGLFramebuffer)) {
|
|
354
336
|
throw new Error('texture');
|
|
355
337
|
}
|
|
356
338
|
let texture;
|
|
357
|
-
if (value instanceof
|
|
339
|
+
if (value instanceof WEBGLTextureView) {
|
|
340
|
+
texture = value.texture;
|
|
341
|
+
}
|
|
342
|
+
else if (value instanceof WEBGLTexture) {
|
|
358
343
|
texture = value;
|
|
359
344
|
}
|
|
360
345
|
else if (value instanceof WEBGLFramebuffer &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Sampler, SamplerProps } from '@luma.gl/core';
|
|
2
2
|
import { GLSamplerParameters } from '@luma.gl/constants';
|
|
3
|
-
import type { WebGLDevice } from
|
|
3
|
+
import type { WebGLDevice } from "../webgl-device.js";
|
|
4
4
|
/**
|
|
5
5
|
* Sampler object -
|
|
6
6
|
* so that they can be set directly on the texture
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-sampler.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-sampler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl-sampler.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-sampler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,EAAK,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAC,WAAW,EAAC,2BAAwB;AAEjD;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,OAAO;IACvC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAC;gBAE7B,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY;IAQ3C,OAAO,IAAI,IAAI;IAQf,QAAQ,IAAI,MAAM;IAI3B,4CAA4C;IAC5C,OAAO,CAAC,qBAAqB;CAgB9B"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
import { Sampler } from '@luma.gl/core';
|
|
4
5
|
import { GL } from '@luma.gl/constants';
|
|
5
|
-
import { convertSamplerParametersToWebGL } from
|
|
6
|
+
import { convertSamplerParametersToWebGL } from "../converters/sampler-parameters.js";
|
|
6
7
|
/**
|
|
7
8
|
* Sampler object -
|
|
8
9
|
* so that they can be set directly on the texture
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Shader, ShaderProps, CompilerMessage } from '@luma.gl/core';
|
|
2
|
-
import { WebGLDevice } from
|
|
2
|
+
import { WebGLDevice } from "../webgl-device.js";
|
|
3
3
|
/**
|
|
4
4
|
* An immutable compiled shader program that execute portions of the GPU Pipeline
|
|
5
5
|
*/
|
|
@@ -10,6 +10,7 @@ export declare class WEBGLShader extends Shader {
|
|
|
10
10
|
destroy(): void;
|
|
11
11
|
getCompilationInfo(): Promise<readonly CompilerMessage[]>;
|
|
12
12
|
getCompilationInfoSync(): readonly CompilerMessage[];
|
|
13
|
+
getTranslatedSource(): string | null;
|
|
13
14
|
/** Compile a shader and get compilation status */
|
|
14
15
|
protected _compile(source: string): Promise<void>;
|
|
15
16
|
/** Use KHR_parallel_shader_compile extension if available */
|
|
@@ -18,7 +19,7 @@ export declare class WEBGLShader extends Shader {
|
|
|
18
19
|
* Get the shader compilation status
|
|
19
20
|
* TODO - Load log even when no error reported, to catch warnings?
|
|
20
21
|
* https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings
|
|
21
|
-
|
|
22
|
+
*/
|
|
22
23
|
protected _getCompilationStatus(): void;
|
|
23
24
|
}
|
|
24
25
|
//# sourceMappingURL=webgl-shader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-shader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-shader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,eAAe,EAAM,MAAM,eAAe,CAAC;AAGxE,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C;;GAEG;AACH,qBAAa,WAAY,SAAQ,MAAM;IACrC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;gBAEjB,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW;IAgB1C,OAAO,IAAI,IAAI;IAST,kBAAkB,IAAI,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;IAK/D,sBAAsB;IAKtB,mBAAmB,IAAI,MAAM,GAAG,IAAI;IAQ7C,kDAAkD;cAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCvD,6DAA6D;cAC7C,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB5D;;;;OAIG;IACH,SAAS,CAAC,qBAAqB;CAKhC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
import { Shader, log } from '@luma.gl/core';
|
|
4
5
|
import { GL } from '@luma.gl/constants';
|
|
5
|
-
import { parseShaderCompilerLog } from
|
|
6
|
+
import { parseShaderCompilerLog } from "../helpers/parse-shader-compiler-log.js";
|
|
6
7
|
/**
|
|
7
8
|
* An immutable compiled shader program that execute portions of the GPU Pipeline
|
|
8
9
|
*/
|
|
@@ -40,6 +41,11 @@ export class WEBGLShader extends Shader {
|
|
|
40
41
|
const log = this.device.gl.getShaderInfoLog(this.handle);
|
|
41
42
|
return parseShaderCompilerLog(log);
|
|
42
43
|
}
|
|
44
|
+
getTranslatedSource() {
|
|
45
|
+
const extensions = this.device.getExtension('WEBGL_debug_shaders');
|
|
46
|
+
const ext = extensions.WEBGL_debug_shaders;
|
|
47
|
+
return ext?.getTranslatedShaderSource(this.handle);
|
|
48
|
+
}
|
|
43
49
|
// PRIVATE METHODS
|
|
44
50
|
/** Compile a shader and get compilation status */
|
|
45
51
|
async _compile(source) {
|
|
@@ -54,7 +60,7 @@ export class WEBGLShader extends Shader {
|
|
|
54
60
|
return;
|
|
55
61
|
}
|
|
56
62
|
// Sync case - slower, but advantage is that it throws in the constructor, making break on error more useful
|
|
57
|
-
if (!this.device.features.has('
|
|
63
|
+
if (!this.device.features.has('compilation-status-async-webgl')) {
|
|
58
64
|
this._getCompilationStatus();
|
|
59
65
|
if (this.compilationStatus === 'error') {
|
|
60
66
|
throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);
|
|
@@ -76,13 +82,13 @@ export class WEBGLShader extends Shader {
|
|
|
76
82
|
const waitMs = async (ms) => await new Promise(resolve => setTimeout(resolve, ms));
|
|
77
83
|
const DELAY_MS = 10; // Shader compilation is typically quite fast (with some exceptions)
|
|
78
84
|
// If status polling is not available, we can't wait for completion. Just wait a little to minimize blocking
|
|
79
|
-
if (!this.device.features.has('
|
|
85
|
+
if (!this.device.features.has('compilation-status-async-webgl')) {
|
|
80
86
|
await waitMs(DELAY_MS);
|
|
81
87
|
return;
|
|
82
88
|
}
|
|
83
89
|
const { gl } = this.device;
|
|
84
90
|
for (;;) {
|
|
85
|
-
const complete = gl.getShaderParameter(this.handle, GL.
|
|
91
|
+
const complete = gl.getShaderParameter(this.handle, GL.COMPLETION_STATUS_KHR);
|
|
86
92
|
if (complete) {
|
|
87
93
|
return;
|
|
88
94
|
}
|
|
@@ -93,7 +99,7 @@ export class WEBGLShader extends Shader {
|
|
|
93
99
|
* Get the shader compilation status
|
|
94
100
|
* TODO - Load log even when no error reported, to catch warnings?
|
|
95
101
|
* https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings
|
|
96
|
-
|
|
102
|
+
*/
|
|
97
103
|
_getCompilationStatus() {
|
|
98
104
|
this.compilationStatus = this.device.gl.getShaderParameter(this.handle, GL.COMPILE_STATUS)
|
|
99
105
|
? 'success'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Device, TextureViewProps } from '@luma.gl/core';
|
|
2
|
+
import { TextureView } from '@luma.gl/core';
|
|
3
|
+
import { WebGLDevice } from "../webgl-device.js";
|
|
4
|
+
import { WEBGLTexture } from "./webgl-texture.js";
|
|
5
|
+
export declare class WEBGLTextureView extends TextureView {
|
|
6
|
+
readonly device: WebGLDevice;
|
|
7
|
+
readonly gl: WebGL2RenderingContext;
|
|
8
|
+
readonly handle: WebGLTexture;
|
|
9
|
+
readonly texture: WEBGLTexture;
|
|
10
|
+
constructor(device: Device, props: TextureViewProps & {
|
|
11
|
+
texture: WEBGLTexture;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=webgl-texture-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgl-texture-view.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture-view.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAC,WAAW,EAAU,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAC5C,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAE7C,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,EAAE,EAAE,sBAAsB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAE9B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;gBAEnB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG;QAAC,OAAO,EAAE,YAAY,CAAA;KAAC;CAS9E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// import {decodeTextureFormat} from '@luma.gl/core';
|
|
5
|
+
import { TextureView, Texture } from '@luma.gl/core';
|
|
6
|
+
export class WEBGLTextureView extends TextureView {
|
|
7
|
+
device;
|
|
8
|
+
gl;
|
|
9
|
+
handle;
|
|
10
|
+
texture;
|
|
11
|
+
constructor(device, props) {
|
|
12
|
+
super(device, { ...Texture.defaultProps, ...props });
|
|
13
|
+
this.device = device;
|
|
14
|
+
this.gl = this.device.gl;
|
|
15
|
+
this.handle = null;
|
|
16
|
+
this.texture = props.texture;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Device, TextureProps, Sampler, SamplerProps, TypedArray } from '@luma.gl/core';
|
|
2
2
|
import { Texture } from '@luma.gl/core';
|
|
3
3
|
import { GL, GLSamplerParameters } from '@luma.gl/constants';
|
|
4
|
-
import { WebGLDevice } from
|
|
5
|
-
import { WEBGLSampler } from
|
|
4
|
+
import { WebGLDevice } from "../webgl-device.js";
|
|
5
|
+
import { WEBGLSampler } from "./webgl-sampler.js";
|
|
6
|
+
import { WEBGLTextureView } from "./webgl-texture-view.js";
|
|
6
7
|
export type WEBGLTextureProps = TextureProps & {
|
|
7
8
|
/** @deprecated use props.sampler */
|
|
8
9
|
parameters?: Record<number, number>;
|
|
@@ -103,8 +104,8 @@ export declare class WEBGLTexture extends Texture<WEBGLTextureProps> {
|
|
|
103
104
|
readonly device: WebGLDevice;
|
|
104
105
|
readonly gl: WebGL2RenderingContext;
|
|
105
106
|
readonly handle: WebGLTexture;
|
|
106
|
-
/** Sampler object (currently unused) */
|
|
107
107
|
sampler: WEBGLSampler;
|
|
108
|
+
view: WEBGLTextureView;
|
|
108
109
|
glFormat: GL;
|
|
109
110
|
type: GL;
|
|
110
111
|
dataFormat: GL;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture.ts"],"names":[],"mappings":"AASA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,OAAO,EACP,YAAY,EAEZ,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,OAAO,EAAwC,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAC,EAAE,EAAE,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAQ3D,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAC7C,OAAO,EAAC,gBAAgB,EAAC,gCAA6B;AAEtD,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG;IAC7C,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,iCAAiC;IACjC,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,mCAAmC;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