@luma.gl/webgl 9.0.0-beta.6 → 9.0.0-beta.8
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 +81 -84
- package/dist/adapter/converters/sampler-parameters.js +17 -17
- package/dist/adapter/converters/shader-formats.js +12 -12
- package/dist/adapter/converters/texture-formats.d.ts +10 -8
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +175 -168
- package/dist/adapter/converters/vertex-formats.js +20 -20
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +2 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +14 -2
- package/dist/adapter/device-helpers/webgl-device-info.js +5 -5
- package/dist/adapter/device-helpers/webgl-device-limits.js +10 -10
- package/dist/adapter/helpers/decode-webgl-types.js +45 -45
- package/dist/adapter/helpers/get-shader-layout.js +29 -29
- package/dist/adapter/helpers/set-uniform.js +40 -40
- package/dist/adapter/helpers/webgl-topology-utils.js +38 -38
- package/dist/adapter/objects/webgl-renderbuffer.js +6 -6
- package/dist/adapter/objects/webgl-resource.js +1 -2
- package/dist/adapter/resources/webgl-buffer.js +14 -14
- package/dist/adapter/resources/webgl-command-buffer.js +25 -25
- package/dist/adapter/resources/webgl-external-texture.js +3 -3
- package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -4
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +41 -36
- package/dist/adapter/resources/webgl-query-set.js +6 -6
- package/dist/adapter/resources/webgl-render-pass.js +5 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +19 -13
- package/dist/adapter/resources/webgl-sampler.js +2 -2
- package/dist/adapter/resources/webgl-shader.js +4 -4
- package/dist/adapter/resources/webgl-texture.d.ts +2 -1
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +29 -27
- package/dist/adapter/resources/webgl-transform-feedback.js +8 -8
- package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +5 -5
- package/dist/adapter/webgl-device.d.ts +6 -3
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +22 -17
- package/dist/classic/accessor.js +4 -4
- package/dist/classic/clear.js +2 -2
- package/dist/classic/copy-and-blit.js +15 -16
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.js +14 -14
- package/dist/classic/typed-array-utils.js +18 -18
- package/dist/context/parameters/unified-parameter-api.d.ts +3 -4
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +4 -9
- package/dist/context/parameters/webgl-parameter-tables.d.ts +2 -13
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +292 -298
- package/dist/context/state-tracker/with-parameters.d.ts +1 -2
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +2 -5
- package/dist/dist.dev.js +3796 -5522
- package/dist/dist.min.js +10 -0
- package/dist/index.cjs +1253 -1188
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +6 -7
- package/src/.DS_Store +0 -0
- package/src/adapter/.DS_Store +0 -0
- package/src/adapter/converters/device-parameters.ts +9 -11
- package/src/adapter/converters/texture-formats.ts +64 -61
- package/src/adapter/device-helpers/webgl-device-features.ts +22 -2
- package/src/adapter/objects/webgl-renderbuffer.ts +1 -1
- package/src/adapter/objects/webgl-resource.ts +1 -1
- package/src/adapter/resources/webgl-external-texture.ts +3 -3
- package/src/adapter/resources/webgl-framebuffer.ts +29 -26
- package/src/adapter/resources/webgl-render-pass.ts +3 -3
- package/src/adapter/resources/webgl-render-pipeline.ts +13 -6
- package/src/adapter/resources/webgl-texture.ts +7 -3
- package/src/adapter/webgl-device.ts +24 -19
- package/src/classic/clear.ts +2 -2
- package/src/context/.DS_Store +0 -0
- package/src/context/parameters/unified-parameter-api.ts +4 -16
- package/src/context/state-tracker/with-parameters.ts +2 -7
- package/src/index.ts +4 -4
- package/dist/adapter/device-helpers/device-features.d.ts +0 -6
- package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-features.js +0 -65
- package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
- package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js +0 -92
- package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js +0 -87
- package/dist/context/context/context-data.d.ts +0 -14
- package/dist/context/context/context-data.d.ts.map +0 -1
- package/dist/context/context/context-data.js +0 -33
- package/dist/context/context/create-browser-context.d.ts +0 -35
- package/dist/context/context/create-browser-context.d.ts.map +0 -1
- package/dist/context/context/create-browser-context.js +0 -66
- package/dist.min.js +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/device-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,UAAU,EACV,eAAe,EAMhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AACtC,OAAO,KAAK,EAAmC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAOvF;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,GAAG,OAAO,EACnD,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,
|
|
1
|
+
{"version":3,"file":"device-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/device-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,UAAU,EACV,eAAe,EAMhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AACtC,OAAO,KAAK,EAAmC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAOvF;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,GAAG,OAAO,EACnD,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAgBH;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAC1C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,YAAY,EACxB,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAeH;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,OAAO,EAC9C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAgBH;AAED,kCAAkC;AAClC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,QAkMzE;AAyBD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,EAAE,CAWpF;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,eAAe,CAWtF"}
|
|
@@ -5,7 +5,6 @@ import { log, isObjectEmpty } from '@luma.gl/core';
|
|
|
5
5
|
import { GL } from '@luma.gl/constants';
|
|
6
6
|
import { pushContextState, popContextState } from "../../context/state-tracker/track-context-state.js";
|
|
7
7
|
import { setGLParameters } from "../../context/parameters/unified-parameter-api.js";
|
|
8
|
-
import { WebGLDevice } from "../webgl-device.js";
|
|
9
8
|
/* eslint-disable no-unused-expressions */ // For expression ? gl.enable() : gl.disable()
|
|
10
9
|
/**
|
|
11
10
|
* Execute a function with a set of temporary WebGL parameter overrides
|
|
@@ -21,16 +20,15 @@ export function withDeviceAndGLParameters(device, parameters, glParameters, func
|
|
|
21
20
|
return func(device);
|
|
22
21
|
}
|
|
23
22
|
// Wrap in a try-catch to ensure that parameters are restored on exceptions
|
|
24
|
-
|
|
25
|
-
pushContextState(
|
|
23
|
+
const webglDevice = device;
|
|
24
|
+
pushContextState(webglDevice.gl);
|
|
26
25
|
try {
|
|
27
26
|
setDeviceParameters(device, parameters);
|
|
28
|
-
setGLParameters(
|
|
27
|
+
setGLParameters(webglDevice.gl, glParameters);
|
|
29
28
|
return func(device);
|
|
30
29
|
}
|
|
31
30
|
finally {
|
|
32
|
-
|
|
33
|
-
popContextState(device.gl);
|
|
31
|
+
popContextState(webglDevice.gl);
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
34
|
/**
|
|
@@ -48,15 +46,14 @@ export function withGLParameters(device, parameters, func) {
|
|
|
48
46
|
return func(device);
|
|
49
47
|
}
|
|
50
48
|
// Wrap in a try-catch to ensure that parameters are restored on exceptions
|
|
51
|
-
|
|
52
|
-
pushContextState(
|
|
49
|
+
const webglDevice = device;
|
|
50
|
+
pushContextState(webglDevice.gl);
|
|
53
51
|
try {
|
|
54
|
-
setGLParameters(
|
|
52
|
+
setGLParameters(webglDevice.gl, parameters);
|
|
55
53
|
return func(device);
|
|
56
54
|
}
|
|
57
55
|
finally {
|
|
58
|
-
|
|
59
|
-
popContextState(device.gl);
|
|
56
|
+
popContextState(webglDevice.gl);
|
|
60
57
|
}
|
|
61
58
|
}
|
|
62
59
|
/**
|
|
@@ -86,34 +83,34 @@ export function withDeviceParameters(device, parameters, func) {
|
|
|
86
83
|
}
|
|
87
84
|
/** Set WebGPU Style Parameters */
|
|
88
85
|
export function setDeviceParameters(device, parameters) {
|
|
89
|
-
const webglDevice =
|
|
86
|
+
const webglDevice = device;
|
|
90
87
|
const { gl } = webglDevice;
|
|
91
88
|
// RASTERIZATION SETTINGS
|
|
92
89
|
if (parameters.cullMode) {
|
|
93
90
|
switch (parameters.cullMode) {
|
|
94
91
|
case 'none':
|
|
95
|
-
gl.disable(
|
|
92
|
+
gl.disable(2884);
|
|
96
93
|
break;
|
|
97
94
|
case 'front':
|
|
98
|
-
gl.enable(
|
|
99
|
-
gl.cullFace(
|
|
95
|
+
gl.enable(2884);
|
|
96
|
+
gl.cullFace(1028);
|
|
100
97
|
break;
|
|
101
98
|
case 'back':
|
|
102
|
-
gl.enable(
|
|
103
|
-
gl.cullFace(
|
|
99
|
+
gl.enable(2884);
|
|
100
|
+
gl.cullFace(1029);
|
|
104
101
|
break;
|
|
105
102
|
}
|
|
106
103
|
}
|
|
107
104
|
if (parameters.frontFace) {
|
|
108
105
|
gl.frontFace(map('frontFace', parameters.frontFace, {
|
|
109
|
-
ccw:
|
|
110
|
-
cw:
|
|
106
|
+
ccw: 2305,
|
|
107
|
+
cw: 2304
|
|
111
108
|
}));
|
|
112
109
|
}
|
|
113
110
|
if (parameters.unclippedDepth) {
|
|
114
111
|
if (device.features.has('depth-clip-control')) {
|
|
115
112
|
// EXT_depth_clamp
|
|
116
|
-
gl.enable(
|
|
113
|
+
gl.enable(34383);
|
|
117
114
|
}
|
|
118
115
|
}
|
|
119
116
|
if (parameters.depthBias !== undefined) {
|
|
@@ -128,8 +125,8 @@ export function setDeviceParameters(device, parameters) {
|
|
|
128
125
|
const ext = extensions.WEBGL_provoking_vertex;
|
|
129
126
|
if (parameters.provokingVertex) {
|
|
130
127
|
const vertex = map('provokingVertex', parameters.provokingVertex, {
|
|
131
|
-
first:
|
|
132
|
-
last:
|
|
128
|
+
first: 36429,
|
|
129
|
+
last: 36430
|
|
133
130
|
});
|
|
134
131
|
ext?.provokingVertexWEBGL(vertex);
|
|
135
132
|
}
|
|
@@ -139,40 +136,40 @@ export function setDeviceParameters(device, parameters) {
|
|
|
139
136
|
const ext = extensions.WEBGL_polygon_mode;
|
|
140
137
|
if (parameters.polygonMode) {
|
|
141
138
|
const mode = map('polygonMode', parameters.provokingVertex, {
|
|
142
|
-
fill:
|
|
143
|
-
lint:
|
|
139
|
+
fill: 6914,
|
|
140
|
+
lint: 6913
|
|
144
141
|
});
|
|
145
|
-
ext?.polygonModeWEBGL(
|
|
146
|
-
ext?.polygonModeWEBGL(
|
|
142
|
+
ext?.polygonModeWEBGL(1028, mode);
|
|
143
|
+
ext?.polygonModeWEBGL(1029, mode);
|
|
147
144
|
}
|
|
148
145
|
if (parameters.polygonOffsetLine) {
|
|
149
|
-
gl.enable(
|
|
146
|
+
gl.enable(10754);
|
|
150
147
|
}
|
|
151
148
|
}
|
|
152
149
|
if (device.features.has('shader-clip-cull-distance-webgl')) {
|
|
153
150
|
if (parameters.clipDistance0) {
|
|
154
|
-
gl.enable(
|
|
151
|
+
gl.enable(12288);
|
|
155
152
|
}
|
|
156
153
|
if (parameters.clipDistance1) {
|
|
157
|
-
gl.enable(
|
|
154
|
+
gl.enable(12289);
|
|
158
155
|
}
|
|
159
156
|
if (parameters.clipDistance2) {
|
|
160
|
-
gl.enable(
|
|
157
|
+
gl.enable(12290);
|
|
161
158
|
}
|
|
162
159
|
if (parameters.clipDistance3) {
|
|
163
|
-
gl.enable(
|
|
160
|
+
gl.enable(12291);
|
|
164
161
|
}
|
|
165
162
|
if (parameters.clipDistance4) {
|
|
166
|
-
gl.enable(
|
|
163
|
+
gl.enable(12292);
|
|
167
164
|
}
|
|
168
165
|
if (parameters.clipDistance5) {
|
|
169
|
-
gl.enable(
|
|
166
|
+
gl.enable(12293);
|
|
170
167
|
}
|
|
171
168
|
if (parameters.clipDistance6) {
|
|
172
|
-
gl.enable(
|
|
169
|
+
gl.enable(12294);
|
|
173
170
|
}
|
|
174
171
|
if (parameters.clipDistance7) {
|
|
175
|
-
gl.enable(
|
|
172
|
+
gl.enable(12295);
|
|
176
173
|
}
|
|
177
174
|
}
|
|
178
175
|
// DEPTH STENCIL
|
|
@@ -180,13 +177,13 @@ export function setDeviceParameters(device, parameters) {
|
|
|
180
177
|
gl.depthMask(mapBoolean('depthWriteEnabled', parameters.depthWriteEnabled));
|
|
181
178
|
}
|
|
182
179
|
if (parameters.depthCompare) {
|
|
183
|
-
parameters.depthCompare !== 'always' ? gl.enable(
|
|
180
|
+
parameters.depthCompare !== 'always' ? gl.enable(2929) : gl.disable(2929);
|
|
184
181
|
gl.depthFunc(convertCompareFunction('depthCompare', parameters.depthCompare));
|
|
185
182
|
}
|
|
186
183
|
if (parameters.stencilWriteMask) {
|
|
187
184
|
const mask = parameters.stencilWriteMask;
|
|
188
|
-
gl.stencilMaskSeparate(
|
|
189
|
-
gl.stencilMaskSeparate(
|
|
185
|
+
gl.stencilMaskSeparate(1028, mask);
|
|
186
|
+
gl.stencilMaskSeparate(1029, mask);
|
|
190
187
|
}
|
|
191
188
|
if (parameters.stencilReadMask) {
|
|
192
189
|
// stencilReadMask is handle inside stencil***Compare.
|
|
@@ -197,10 +194,10 @@ export function setDeviceParameters(device, parameters) {
|
|
|
197
194
|
const glValue = convertCompareFunction('depthCompare', parameters.stencilCompare);
|
|
198
195
|
// TODO - ensure back doesn't overwrite
|
|
199
196
|
parameters.stencilCompare !== 'always'
|
|
200
|
-
? gl.enable(
|
|
201
|
-
: gl.disable(
|
|
202
|
-
gl.stencilFuncSeparate(
|
|
203
|
-
gl.stencilFuncSeparate(
|
|
197
|
+
? gl.enable(2960)
|
|
198
|
+
: gl.disable(2960);
|
|
199
|
+
gl.stencilFuncSeparate(1028, glValue, 0, mask);
|
|
200
|
+
gl.stencilFuncSeparate(1029, glValue, 0, mask);
|
|
204
201
|
}
|
|
205
202
|
if (parameters.stencilPassOperation &&
|
|
206
203
|
parameters.stencilFailOperation &&
|
|
@@ -208,8 +205,8 @@ export function setDeviceParameters(device, parameters) {
|
|
|
208
205
|
const dppass = convertStencilOperation('stencilPassOperation', parameters.stencilPassOperation);
|
|
209
206
|
const sfail = convertStencilOperation('stencilFailOperation', parameters.stencilFailOperation);
|
|
210
207
|
const dpfail = convertStencilOperation('stencilDepthFailOperation', parameters.stencilDepthFailOperation);
|
|
211
|
-
gl.stencilOpSeparate(
|
|
212
|
-
gl.stencilOpSeparate(
|
|
208
|
+
gl.stencilOpSeparate(1028, sfail, dpfail, dppass);
|
|
209
|
+
gl.stencilOpSeparate(1029, sfail, dpfail, dppass);
|
|
213
210
|
}
|
|
214
211
|
// stencilDepthFailOperation() {
|
|
215
212
|
// // handled by stencilPassOperation
|
|
@@ -219,7 +216,7 @@ export function setDeviceParameters(device, parameters) {
|
|
|
219
216
|
// },
|
|
220
217
|
// COLOR STATE
|
|
221
218
|
if (parameters.blendColorOperation || parameters.blendAlphaOperation) {
|
|
222
|
-
gl.enable(
|
|
219
|
+
gl.enable(3042);
|
|
223
220
|
const colorEquation = convertBlendOperationToEquation('blendColorOperation', parameters.blendColorOperation || 'add');
|
|
224
221
|
const alphaEquation = convertBlendOperationToEquation('blendAlphaOperation', parameters.blendAlphaOperation || 'add');
|
|
225
222
|
gl.blendEquationSeparate(colorEquation, alphaEquation);
|
|
@@ -254,61 +251,61 @@ export function setDeviceParameters(device, parameters) {
|
|
|
254
251
|
*/
|
|
255
252
|
export function convertCompareFunction(parameter, value) {
|
|
256
253
|
return map(parameter, value, {
|
|
257
|
-
never:
|
|
258
|
-
less:
|
|
259
|
-
equal:
|
|
260
|
-
'less-equal':
|
|
261
|
-
greater:
|
|
262
|
-
'not-equal':
|
|
263
|
-
'greater-equal':
|
|
264
|
-
always:
|
|
254
|
+
never: 512,
|
|
255
|
+
less: 513,
|
|
256
|
+
equal: 514,
|
|
257
|
+
'less-equal': 515,
|
|
258
|
+
greater: 516,
|
|
259
|
+
'not-equal': 517,
|
|
260
|
+
'greater-equal': 518,
|
|
261
|
+
always: 519
|
|
265
262
|
});
|
|
266
263
|
}
|
|
267
264
|
export function convertToCompareFunction(parameter, value) {
|
|
268
265
|
return map(parameter, value, {
|
|
269
|
-
[
|
|
270
|
-
[
|
|
271
|
-
[
|
|
272
|
-
[
|
|
273
|
-
[
|
|
274
|
-
[
|
|
275
|
-
[
|
|
276
|
-
[
|
|
266
|
+
[512]: 'never',
|
|
267
|
+
[513]: 'less',
|
|
268
|
+
[514]: 'equal',
|
|
269
|
+
[515]: 'less-equal',
|
|
270
|
+
[516]: 'greater',
|
|
271
|
+
[517]: 'not-equal',
|
|
272
|
+
[518]: 'greater-equal',
|
|
273
|
+
[519]: 'always'
|
|
277
274
|
});
|
|
278
275
|
}
|
|
279
276
|
function convertStencilOperation(parameter, value) {
|
|
280
277
|
return map(parameter, value, {
|
|
281
|
-
keep:
|
|
282
|
-
zero:
|
|
283
|
-
replace:
|
|
284
|
-
invert:
|
|
285
|
-
'increment-clamp':
|
|
286
|
-
'decrement-clamp':
|
|
287
|
-
'increment-wrap':
|
|
288
|
-
'decrement-wrap':
|
|
278
|
+
keep: 7680,
|
|
279
|
+
zero: 0,
|
|
280
|
+
replace: 7681,
|
|
281
|
+
invert: 5386,
|
|
282
|
+
'increment-clamp': 7682,
|
|
283
|
+
'decrement-clamp': 7683,
|
|
284
|
+
'increment-wrap': 34055,
|
|
285
|
+
'decrement-wrap': 34056
|
|
289
286
|
});
|
|
290
287
|
}
|
|
291
288
|
function convertBlendOperationToEquation(parameter, value) {
|
|
292
289
|
return map(parameter, value, {
|
|
293
|
-
add:
|
|
294
|
-
subtract:
|
|
295
|
-
'reverse-subtract':
|
|
296
|
-
min:
|
|
297
|
-
max:
|
|
290
|
+
add: 32774,
|
|
291
|
+
subtract: 32778,
|
|
292
|
+
'reverse-subtract': 32779,
|
|
293
|
+
min: 32775,
|
|
294
|
+
max: 32776
|
|
298
295
|
});
|
|
299
296
|
}
|
|
300
297
|
function convertBlendFactorToFunction(parameter, value) {
|
|
301
298
|
return map(parameter, value, {
|
|
302
|
-
one:
|
|
303
|
-
zero:
|
|
304
|
-
'src-color':
|
|
305
|
-
'one-minus-src-color':
|
|
306
|
-
'dst-color':
|
|
307
|
-
'one-minus-dst-color':
|
|
308
|
-
'src-alpha':
|
|
309
|
-
'one-minus-src-alpha':
|
|
310
|
-
'dst-alpha':
|
|
311
|
-
'one-minus-dst-alpha':
|
|
299
|
+
one: 1,
|
|
300
|
+
zero: 0,
|
|
301
|
+
'src-color': 768,
|
|
302
|
+
'one-minus-src-color': 769,
|
|
303
|
+
'dst-color': 774,
|
|
304
|
+
'one-minus-dst-color': 775,
|
|
305
|
+
'src-alpha': 770,
|
|
306
|
+
'one-minus-src-alpha': 771,
|
|
307
|
+
'dst-alpha': 772,
|
|
308
|
+
'one-minus-dst-alpha': 773
|
|
312
309
|
});
|
|
313
310
|
}
|
|
314
311
|
function message(parameter, value) {
|
|
@@ -11,37 +11,37 @@ import { convertCompareFunction } from "./device-parameters.js";
|
|
|
11
11
|
export function convertSamplerParametersToWebGL(props) {
|
|
12
12
|
const params = {};
|
|
13
13
|
if (props.addressModeU) {
|
|
14
|
-
params[
|
|
14
|
+
params[10242] = convertAddressMode(props.addressModeU);
|
|
15
15
|
}
|
|
16
16
|
if (props.addressModeV) {
|
|
17
|
-
params[
|
|
17
|
+
params[10243] = convertAddressMode(props.addressModeV);
|
|
18
18
|
}
|
|
19
19
|
if (props.addressModeW) {
|
|
20
|
-
params[
|
|
20
|
+
params[32882] = convertAddressMode(props.addressModeW);
|
|
21
21
|
}
|
|
22
22
|
if (props.magFilter) {
|
|
23
|
-
params[
|
|
23
|
+
params[10240] = convertMaxFilterMode(props.magFilter);
|
|
24
24
|
}
|
|
25
25
|
if (props.minFilter || props.mipmapFilter) {
|
|
26
26
|
// TODO - arbitrary choice of linear?
|
|
27
|
-
params[
|
|
27
|
+
params[10241] = convertMinFilterMode(props.minFilter || 'linear', props.mipmapFilter);
|
|
28
28
|
}
|
|
29
29
|
if (props.lodMinClamp !== undefined) {
|
|
30
|
-
params[
|
|
30
|
+
params[33082] = props.lodMinClamp;
|
|
31
31
|
}
|
|
32
32
|
if (props.lodMaxClamp !== undefined) {
|
|
33
|
-
params[
|
|
33
|
+
params[33083] = props.lodMaxClamp;
|
|
34
34
|
}
|
|
35
35
|
if (props.type === 'comparison-sampler') {
|
|
36
36
|
// Setting prop.compare turns this into a comparison sampler
|
|
37
|
-
params[
|
|
37
|
+
params[34892] = 34894;
|
|
38
38
|
}
|
|
39
39
|
if (props.compare) {
|
|
40
|
-
params[
|
|
40
|
+
params[34893] = convertCompareFunction('compare', props.compare);
|
|
41
41
|
}
|
|
42
42
|
// Note depends on WebGL extension
|
|
43
43
|
if (props.maxAnisotropy) {
|
|
44
|
-
params[
|
|
44
|
+
params[34046] = props.maxAnisotropy;
|
|
45
45
|
}
|
|
46
46
|
return params;
|
|
47
47
|
}
|
|
@@ -50,19 +50,19 @@ export function convertSamplerParametersToWebGL(props) {
|
|
|
50
50
|
function convertAddressMode(addressMode) {
|
|
51
51
|
switch (addressMode) {
|
|
52
52
|
case 'clamp-to-edge':
|
|
53
|
-
return
|
|
53
|
+
return 33071;
|
|
54
54
|
case 'repeat':
|
|
55
|
-
return
|
|
55
|
+
return 10497;
|
|
56
56
|
case 'mirror-repeat':
|
|
57
|
-
return
|
|
57
|
+
return 33648;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
function convertMaxFilterMode(maxFilter) {
|
|
61
61
|
switch (maxFilter) {
|
|
62
62
|
case 'nearest':
|
|
63
|
-
return
|
|
63
|
+
return 9728;
|
|
64
64
|
case 'linear':
|
|
65
|
-
return
|
|
65
|
+
return 9729;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
@@ -75,8 +75,8 @@ function convertMinFilterMode(minFilter, mipmapFilter) {
|
|
|
75
75
|
}
|
|
76
76
|
switch (minFilter) {
|
|
77
77
|
case 'nearest':
|
|
78
|
-
return mipmapFilter === 'nearest' ?
|
|
78
|
+
return mipmapFilter === 'nearest' ? 9984 : 9986;
|
|
79
79
|
case 'linear':
|
|
80
|
-
return mipmapFilter === 'nearest' ?
|
|
80
|
+
return mipmapFilter === 'nearest' ? 9985 : 9987;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -21,21 +21,21 @@ export function getShaderAttributeTypeFromGL(type, components) {
|
|
|
21
21
|
/** Get shader data type from GL constants */
|
|
22
22
|
export function getShaderDataTypeFromGL(type) {
|
|
23
23
|
switch (type) {
|
|
24
|
-
case
|
|
24
|
+
case 5124:
|
|
25
25
|
return 'i32';
|
|
26
|
-
case
|
|
26
|
+
case 5125:
|
|
27
27
|
return 'u32';
|
|
28
|
-
case
|
|
28
|
+
case 5122:
|
|
29
29
|
return 'i32';
|
|
30
|
-
case
|
|
30
|
+
case 5123:
|
|
31
31
|
return 'u32';
|
|
32
|
-
case
|
|
32
|
+
case 5120:
|
|
33
33
|
return 'i32';
|
|
34
|
-
case
|
|
34
|
+
case 5121:
|
|
35
35
|
return 'u32';
|
|
36
|
-
case
|
|
36
|
+
case 5126:
|
|
37
37
|
return 'f32';
|
|
38
|
-
case
|
|
38
|
+
case 5131:
|
|
39
39
|
return 'f16';
|
|
40
40
|
default:
|
|
41
41
|
throw new Error(String(type));
|
|
@@ -46,13 +46,13 @@ export function getGLFromShaderDataType(type) {
|
|
|
46
46
|
switch (type) {
|
|
47
47
|
// TODO
|
|
48
48
|
case 'i32':
|
|
49
|
-
return
|
|
49
|
+
return 5124;
|
|
50
50
|
case 'u32':
|
|
51
|
-
return
|
|
51
|
+
return 5125;
|
|
52
52
|
case 'f32':
|
|
53
|
-
return
|
|
53
|
+
return 5126;
|
|
54
54
|
case 'f16':
|
|
55
|
-
return
|
|
55
|
+
return 5131;
|
|
56
56
|
default:
|
|
57
57
|
throw new Error(String(type));
|
|
58
58
|
}
|
|
@@ -33,7 +33,8 @@ type Format = {
|
|
|
33
33
|
attachment?: GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT;
|
|
34
34
|
/** if depthTexture is set this is a depth/stencil format that can be set to a texture */
|
|
35
35
|
depthTexture?: boolean;
|
|
36
|
-
|
|
36
|
+
/** @deprecated can this format be used with renderbuffers */
|
|
37
|
+
rb?: boolean;
|
|
37
38
|
};
|
|
38
39
|
/**
|
|
39
40
|
* Texture format data -
|
|
@@ -41,7 +42,7 @@ type Format = {
|
|
|
41
42
|
*/
|
|
42
43
|
export declare const TEXTURE_FORMATS: Record<TextureFormat, Format>;
|
|
43
44
|
/** Checks if a texture format is supported */
|
|
44
|
-
export declare function isTextureFormatSupported(gl: WebGL2RenderingContext,
|
|
45
|
+
export declare function isTextureFormatSupported(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
|
|
45
46
|
export declare function isRenderbufferFormatSupported(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
|
|
46
47
|
/**
|
|
47
48
|
* Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
|
|
@@ -52,7 +53,7 @@ export declare function convertGLToTextureFormat(format: GL | TextureFormat): Te
|
|
|
52
53
|
*/
|
|
53
54
|
export declare function convertTextureFormatToGL(format: TextureFormat): GL | undefined;
|
|
54
55
|
/** Checks if a texture format is supported */
|
|
55
|
-
export declare function getTextureFormatSupport(gl: WebGL2RenderingContext,
|
|
56
|
+
export declare function getTextureFormatSupport(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): {
|
|
56
57
|
supported: boolean;
|
|
57
58
|
filterable?: boolean;
|
|
58
59
|
renderable?: boolean;
|
|
@@ -60,16 +61,17 @@ export declare function getTextureFormatSupport(gl: WebGL2RenderingContext, form
|
|
|
60
61
|
storable?: boolean;
|
|
61
62
|
};
|
|
62
63
|
/** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
|
|
63
|
-
export declare function isTextureFormatFilterable(gl: WebGL2RenderingContext,
|
|
64
|
-
export declare function isTextureFormatRenderable(gl: WebGL2RenderingContext,
|
|
65
|
-
|
|
64
|
+
export declare function isTextureFormatFilterable(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
|
|
65
|
+
export declare function isTextureFormatRenderable(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
|
|
66
|
+
/** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
|
|
67
|
+
export declare function getWebGLTextureParameters(format: TextureFormat): {
|
|
66
68
|
format: GL;
|
|
67
69
|
dataFormat: GL;
|
|
68
|
-
type:
|
|
70
|
+
type: number;
|
|
69
71
|
compressed: any;
|
|
70
72
|
};
|
|
71
73
|
export declare function getDepthStencilAttachmentWebGL(format: TextureFormat): GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT;
|
|
72
74
|
/** TODO - VERY roundabout legacy way of calculating bytes per pixel */
|
|
73
|
-
export declare function getTextureFormatBytesPerPixel(
|
|
75
|
+
export declare function getTextureFormatBytesPerPixel(format: TextureFormat): number;
|
|
74
76
|
export {};
|
|
75
77
|
//# sourceMappingURL=texture-formats.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texture-formats.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/texture-formats.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAC,EAAE,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAC;AA2CpD,eAAO,MAAM,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAwBrE,CAAC;AAEF,wGAAwG;AASxG,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAEhE;AAED,wFAAwF;AACxF,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,sBAAsB,EAC1B,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,YAAY,GACvB,OAAO,CAGT;AAID,0CAA0C;AAC1C,KAAK,MAAM,GAAG;IACZ,EAAE,CAAC,EAAE,EAAE,CAAC;IACR,mGAAmG;IACnG,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,wDAAwD;IACxD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,eAAe;IACf,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa;IACb,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,iBAAiB;IACjB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,CAAC,CAAC,EAAE,aAAa,CAAC;IAClB,uCAAuC;IACvC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,uCAAuC;IACvC,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB,iCAAiC;IACjC,IAAI,CAAC,EAAE,KAAK,CAAC;IAEb,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAEjB,UAAU,CAAC,EAAE,EAAE,CAAC;IAChB,iHAAiH;IACjH,UAAU,CAAC,EAAE,EAAE,CAAC,gBAAgB,GAAG,EAAE,CAAC,kBAAkB,GAAG,EAAE,CAAC,wBAAwB,CAAC;IACvF,0FAA0F;IAC1F,YAAY,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"texture-formats.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/texture-formats.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAC,EAAE,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAC;AA2CpD,eAAO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