@luma.gl/webgl 9.0.0-alpha.52 → 9.0.0-alpha.54
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/sampler-parameters.d.ts +2 -8
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +12 -107
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +21 -3
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +4 -7
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +13 -19
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +2 -3
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +9 -7
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.js +5 -2
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/dist.dev.js +87 -65
- package/dist/index.cjs +161 -148
- package/dist.min.js +38 -38
- package/package.json +5 -5
- package/src/adapter/converters/sampler-parameters.ts +26 -151
- package/src/adapter/device-helpers/get-device-info.ts +24 -5
- package/src/adapter/resources/webgl-buffer.ts +46 -56
- package/src/adapter/resources/webgl-texture.ts +3 -4
- package/src/adapter/webgl-device.ts +13 -10
- package/src/context/polyfill/polyfill-context.ts +6 -2
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SamplerProps } from '@luma.gl/core';
|
|
2
2
|
import { GLSamplerParameters } from '@luma.gl/constants';
|
|
3
3
|
/**
|
|
4
4
|
* Convert WebGPU-style sampler props to WebGL
|
|
5
5
|
* @param props
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare function convertSamplerParametersToWebGL(props:
|
|
9
|
-
/**
|
|
10
|
-
* Convert WebGL-style sampler props to WebGPU
|
|
11
|
-
* @param props
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
export declare function convertToSamplerParameters(params: GLSamplerParameters): SamplerParameters;
|
|
8
|
+
export declare function convertSamplerParametersToWebGL(props: SamplerProps): GLSamplerParameters;
|
|
15
9
|
/**
|
|
16
10
|
* Override sampler settings that are not supported by Non-Power-of-Two textures in WebGL1.
|
|
17
11
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampler-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/sampler-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"sampler-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/sampler-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAK,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAG3D;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,YAAY,GAAG,mBAAmB,CAuCxF;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,mBAAmB,GAC9B,mBAAmB,CAUrB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { convertCompareFunction
|
|
1
|
+
import { convertCompareFunction } from "./device-parameters.js";
|
|
2
2
|
export function convertSamplerParametersToWebGL(props) {
|
|
3
3
|
const params = {};
|
|
4
4
|
if (props.addressModeU) {
|
|
@@ -33,6 +33,17 @@ export function convertSamplerParametersToWebGL(props) {
|
|
|
33
33
|
}
|
|
34
34
|
return params;
|
|
35
35
|
}
|
|
36
|
+
export function updateSamplerParametersForNPOT(parameters) {
|
|
37
|
+
const newParameters = {
|
|
38
|
+
...parameters
|
|
39
|
+
};
|
|
40
|
+
if (parameters[10241] !== 9728) {
|
|
41
|
+
newParameters[10241] = 9729;
|
|
42
|
+
}
|
|
43
|
+
newParameters[10242] = 33071;
|
|
44
|
+
newParameters[10243] = 33071;
|
|
45
|
+
return newParameters;
|
|
46
|
+
}
|
|
36
47
|
function convertAddressMode(addressMode) {
|
|
37
48
|
switch (addressMode) {
|
|
38
49
|
case 'clamp-to-edge':
|
|
@@ -62,110 +73,4 @@ function convertMinFilterMode(minFilter, mipmapFilter) {
|
|
|
62
73
|
return mipmapFilter === 'nearest' ? 9985 : 9987;
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
|
-
export function convertToSamplerParameters(params) {
|
|
66
|
-
const props = {};
|
|
67
|
-
if (params[10242]) {
|
|
68
|
-
props.addressModeU = convertToAddressMode(params[10242]);
|
|
69
|
-
}
|
|
70
|
-
if (params[10243]) {
|
|
71
|
-
props.addressModeV = convertToAddressMode(params[10243]);
|
|
72
|
-
}
|
|
73
|
-
if (params[32882]) {
|
|
74
|
-
props.addressModeW = convertToAddressMode(params[32882]);
|
|
75
|
-
}
|
|
76
|
-
if (params[10240]) {
|
|
77
|
-
props.magFilter = convertToMaxFilterMode(params[10240]);
|
|
78
|
-
}
|
|
79
|
-
if (params[10241]) {
|
|
80
|
-
props.minFilter = convertToMinFilterMode(params[10241]);
|
|
81
|
-
}
|
|
82
|
-
if (params[10241]) {
|
|
83
|
-
props.mipmapFilter = convertToMipmapFilterMode(params[10241]);
|
|
84
|
-
}
|
|
85
|
-
if (params[33082]) {
|
|
86
|
-
props.lodMinClamp = params[33082];
|
|
87
|
-
}
|
|
88
|
-
if (params[33083]) {
|
|
89
|
-
props.lodMaxClamp = params[33083];
|
|
90
|
-
}
|
|
91
|
-
if (params[34892]) {
|
|
92
|
-
props.type = params[34892] === 34894 ? 'comparison-sampler' : 'color-sampler';
|
|
93
|
-
}
|
|
94
|
-
if (params[34893]) {
|
|
95
|
-
props.compare = convertToCompareFunction('compare', params[34893]);
|
|
96
|
-
}
|
|
97
|
-
if (params[34046]) {
|
|
98
|
-
props.maxAnisotropy = params[34046];
|
|
99
|
-
}
|
|
100
|
-
return props;
|
|
101
|
-
}
|
|
102
|
-
function convertToAddressMode(addressMode) {
|
|
103
|
-
switch (addressMode) {
|
|
104
|
-
case 33071:
|
|
105
|
-
return 'clamp-to-edge';
|
|
106
|
-
case 10497:
|
|
107
|
-
return 'repeat';
|
|
108
|
-
case 33648:
|
|
109
|
-
return 'mirror-repeat';
|
|
110
|
-
default:
|
|
111
|
-
throw new Error('address');
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function convertToMaxFilterMode(filterMode) {
|
|
115
|
-
switch (filterMode) {
|
|
116
|
-
case 9728:
|
|
117
|
-
return 'nearest';
|
|
118
|
-
case 9729:
|
|
119
|
-
return 'linear';
|
|
120
|
-
default:
|
|
121
|
-
throw new Error('maxfilter');
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
function convertToMinFilterMode(filterMode) {
|
|
125
|
-
switch (filterMode) {
|
|
126
|
-
case 9728:
|
|
127
|
-
return 'nearest';
|
|
128
|
-
case 9729:
|
|
129
|
-
return 'linear';
|
|
130
|
-
case 9984:
|
|
131
|
-
return 'nearest';
|
|
132
|
-
case 9985:
|
|
133
|
-
return 'linear';
|
|
134
|
-
case 9986:
|
|
135
|
-
return 'nearest';
|
|
136
|
-
case 9987:
|
|
137
|
-
return 'linear';
|
|
138
|
-
default:
|
|
139
|
-
throw new Error('minfilter');
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function convertToMipmapFilterMode(filterMode) {
|
|
143
|
-
switch (filterMode) {
|
|
144
|
-
case 9728:
|
|
145
|
-
return 'nearest';
|
|
146
|
-
case 9729:
|
|
147
|
-
return 'linear';
|
|
148
|
-
case 9984:
|
|
149
|
-
return 'nearest';
|
|
150
|
-
case 9985:
|
|
151
|
-
return 'nearest';
|
|
152
|
-
case 9986:
|
|
153
|
-
return 'linear';
|
|
154
|
-
case 9987:
|
|
155
|
-
return 'linear';
|
|
156
|
-
default:
|
|
157
|
-
throw new Error('mipmap');
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
export function updateSamplerParametersForNPOT(parameters) {
|
|
161
|
-
const newParameters = {
|
|
162
|
-
...parameters
|
|
163
|
-
};
|
|
164
|
-
if (parameters[10241] !== 9728) {
|
|
165
|
-
newParameters[10241] = 9729;
|
|
166
|
-
}
|
|
167
|
-
newParameters[10242] = 33071;
|
|
168
|
-
newParameters[10243] = 33071;
|
|
169
|
-
return newParameters;
|
|
170
|
-
}
|
|
171
76
|
//# sourceMappingURL=sampler-parameters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampler-parameters.js","names":["convertCompareFunction","convertToCompareFunction","convertSamplerParametersToWebGL","props","params","addressModeU","convertAddressMode","addressModeV","addressModeW","magFilter","convertMaxFilterMode","minFilter","mipmapFilter","convertMinFilterMode","lodMinClamp","undefined","lodMaxClamp","type","compare","maxAnisotropy","addressMode","maxFilter","convertToSamplerParameters","convertToAddressMode","convertToMaxFilterMode","convertToMinFilterMode","convertToMipmapFilterMode","Error","filterMode","updateSamplerParametersForNPOT","parameters","newParameters"],"sources":["../../../src/adapter/converters/sampler-parameters.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// SAMPLER FILTERS\nimport {SamplerParameters} from '@luma.gl/core';\nimport {GL, GLSamplerParameters} from '@luma.gl/constants';\nimport {convertCompareFunction, convertToCompareFunction} from './device-parameters';\n\n/* eslint-disable consistent-return */\n\n/**\n * Convert WebGPU-style sampler props to WebGL\n * @param props\n * @returns\n */\nexport function convertSamplerParametersToWebGL(props: SamplerParameters): GLSamplerParameters {\n const params: Record<number, number> = {};\n if (props.addressModeU) {\n params[GL.TEXTURE_WRAP_S] = convertAddressMode(props.addressModeU);\n }\n if (props.addressModeV) {\n params[GL.TEXTURE_WRAP_T] = convertAddressMode(props.addressModeV);\n }\n if (props.addressModeW) {\n params[GL.TEXTURE_WRAP_R] = convertAddressMode(props.addressModeW);\n }\n if (props.magFilter) {\n params[GL.TEXTURE_MAG_FILTER] = convertMaxFilterMode(props.magFilter);\n }\n if (props.minFilter || props.mipmapFilter) {\n // TODO - arbitrary choice of linear?\n params[GL.TEXTURE_MIN_FILTER] = convertMinFilterMode(\n props.minFilter || 'linear',\n props.mipmapFilter\n );\n }\n if (props.lodMinClamp !== undefined) {\n params[GL.TEXTURE_MIN_LOD] = props.lodMinClamp;\n }\n if (props.lodMaxClamp !== undefined) {\n params[GL.TEXTURE_MAX_LOD] = props.lodMaxClamp;\n }\n if (props.type === 'comparison-sampler') {\n // Setting prop.compare turns this into a comparison sampler\n params[GL.TEXTURE_COMPARE_MODE] = GL.COMPARE_REF_TO_TEXTURE;\n }\n if (props.compare) {\n params[GL.TEXTURE_COMPARE_FUNC] = convertCompareFunction('compare', props.compare);\n }\n // Note depends on WebGL extension\n if (props.maxAnisotropy) {\n params[GL.TEXTURE_MAX_ANISOTROPY_EXT] = props.maxAnisotropy;\n }\n return params;\n}\n\n/** Convert address more */\nfunction convertAddressMode(addressMode: 'clamp-to-edge' | 'repeat' | 'mirror-repeat'): GL {\n switch (addressMode) {\n case 'clamp-to-edge':\n return GL.CLAMP_TO_EDGE;\n case 'repeat':\n return GL.REPEAT;\n case 'mirror-repeat':\n return GL.MIRRORED_REPEAT;\n }\n}\n\nfunction convertMaxFilterMode(maxFilter: 'nearest' | 'linear'): GL {\n switch (maxFilter) {\n case 'nearest':\n return GL.NEAREST;\n case 'linear':\n return GL.LINEAR;\n }\n}\n\n/**\n * WebGPU has separate min filter and mipmap filter,\n * WebGL is combined and effectively offers 6 options\n */\nfunction convertMinFilterMode(\n minFilter: 'nearest' | 'linear',\n mipmapFilter?: 'nearest' | 'linear'\n): GL {\n if (!mipmapFilter) {\n return convertMaxFilterMode(minFilter);\n }\n switch (minFilter) {\n case 'nearest':\n return mipmapFilter === 'nearest' ? GL.NEAREST_MIPMAP_NEAREST : GL.NEAREST_MIPMAP_LINEAR;\n case 'linear':\n return mipmapFilter === 'nearest' ? GL.LINEAR_MIPMAP_NEAREST : GL.LINEAR_MIPMAP_LINEAR;\n }\n}\n\n// Convert from WebGL to WebGPU\n\n/**\n * Convert WebGL-style sampler props to WebGPU\n * @param props\n * @returns\n */\nexport function convertToSamplerParameters(params: GLSamplerParameters): SamplerParameters {\n const props: SamplerParameters = {};\n if (params[GL.TEXTURE_WRAP_S]) {\n props.addressModeU = convertToAddressMode(params[GL.TEXTURE_WRAP_S]);\n }\n if (params[GL.TEXTURE_WRAP_T]) {\n props.addressModeV = convertToAddressMode(params[GL.TEXTURE_WRAP_T]);\n }\n if (params[GL.TEXTURE_WRAP_R]) {\n props.addressModeW = convertToAddressMode(params[GL.TEXTURE_WRAP_R]);\n }\n if (params[GL.TEXTURE_MAG_FILTER]) {\n props.magFilter = convertToMaxFilterMode(params[GL.TEXTURE_MAG_FILTER]);\n }\n if (params[GL.TEXTURE_MIN_FILTER]) {\n props.minFilter = convertToMinFilterMode(params[GL.TEXTURE_MIN_FILTER]);\n }\n if (params[GL.TEXTURE_MIN_FILTER]) {\n props.mipmapFilter = convertToMipmapFilterMode(params[GL.TEXTURE_MIN_FILTER]);\n }\n if (params[GL.TEXTURE_MIN_LOD]) {\n props.lodMinClamp = params[GL.TEXTURE_MIN_LOD];\n }\n if (params[GL.TEXTURE_MAX_LOD]) {\n props.lodMaxClamp = params[GL.TEXTURE_MAX_LOD];\n }\n if (params[GL.TEXTURE_COMPARE_MODE]) {\n props.type =\n params[GL.TEXTURE_COMPARE_MODE] === GL.COMPARE_REF_TO_TEXTURE\n ? 'comparison-sampler'\n : 'color-sampler';\n }\n if (params[GL.TEXTURE_COMPARE_FUNC]) {\n props.compare = convertToCompareFunction('compare', params[GL.TEXTURE_COMPARE_FUNC]);\n }\n // NOTE depends on extension (very common)\n if (params[GL.TEXTURE_MAX_ANISOTROPY_EXT]) {\n props.maxAnisotropy = params[GL.TEXTURE_MAX_ANISOTROPY_EXT];\n }\n return props;\n}\n\n/** Convert address more */\nfunction convertToAddressMode(\n addressMode: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT\n): 'clamp-to-edge' | 'repeat' | 'mirror-repeat' {\n switch (addressMode) {\n case GL.CLAMP_TO_EDGE:\n return 'clamp-to-edge';\n case GL.REPEAT:\n return 'repeat';\n case GL.MIRRORED_REPEAT:\n return 'mirror-repeat';\n default:\n throw new Error('address');\n }\n}\n\nfunction convertToMaxFilterMode(filterMode: GL.NEAREST | GL.LINEAR): 'nearest' | 'linear' {\n switch (filterMode) {\n case GL.NEAREST:\n return 'nearest';\n case GL.LINEAR:\n return 'linear';\n default:\n throw new Error('maxfilter');\n }\n}\n\ntype GLMinFilter =\n | GL.NEAREST\n | GL.LINEAR\n | GL.NEAREST_MIPMAP_NEAREST\n | GL.LINEAR_MIPMAP_NEAREST\n | GL.NEAREST_MIPMAP_LINEAR\n | GL.LINEAR_MIPMAP_LINEAR;\n\n/** WebGPU has separate min filter and mipmap filter, WebGL is combined */\nfunction convertToMinFilterMode(filterMode: GLMinFilter): 'nearest' | 'linear' {\n switch (filterMode) {\n // TODO is this correct?\n case GL.NEAREST:\n return 'nearest';\n case GL.LINEAR:\n return 'linear';\n case GL.NEAREST_MIPMAP_NEAREST:\n return 'nearest';\n case GL.LINEAR_MIPMAP_NEAREST:\n return 'linear';\n case GL.NEAREST_MIPMAP_LINEAR:\n return 'nearest';\n case GL.LINEAR_MIPMAP_LINEAR:\n return 'linear';\n default:\n throw new Error('minfilter');\n }\n}\n\nfunction convertToMipmapFilterMode(filterMode: GLMinFilter): 'nearest' | 'linear' {\n switch (filterMode) {\n // TODO is this correct?\n case GL.NEAREST:\n return 'nearest';\n case GL.LINEAR:\n return 'linear';\n case GL.NEAREST_MIPMAP_NEAREST:\n return 'nearest';\n case GL.LINEAR_MIPMAP_NEAREST:\n return 'nearest';\n case GL.NEAREST_MIPMAP_LINEAR:\n return 'linear';\n case GL.LINEAR_MIPMAP_LINEAR:\n return 'linear';\n default:\n throw new Error('mipmap');\n }\n}\n\n/**\n * Override sampler settings that are not supported by Non-Power-of-Two textures in WebGL1.\n */\nexport function updateSamplerParametersForNPOT(\n parameters: GLSamplerParameters\n): GLSamplerParameters {\n const newParameters = {...parameters};\n if (parameters[GL.TEXTURE_MIN_FILTER] !== GL.NEAREST) {\n // log.warn(`texture: ${this} is Non-Power-Of-Two, forcing TEXTURE_MIN_FILTER to LINEAR`)();\n newParameters[GL.TEXTURE_MIN_FILTER] = GL.LINEAR;\n }\n // log.warn(`texture: ${this} is Non-Power-Of-Two, forcing TEXTURE_WRAP_S to CLAMP_TO_EDGE`)();\n newParameters[GL.TEXTURE_WRAP_S] = GL.CLAMP_TO_EDGE;\n newParameters[GL.TEXTURE_WRAP_T] = GL.CLAMP_TO_EDGE;\n return newParameters;\n}\n"],"mappings":"SAMQA,sBAAsB,EAAEC,wBAAwB;AASxD,OAAO,SAASC,+BAA+BA,CAACC,KAAwB,EAAuB;EAC7F,MAAMC,MAA8B,GAAG,CAAC,CAAC;EACzC,IAAID,KAAK,CAACE,YAAY,EAAE;IACtBD,MAAM,OAAmB,GAAGE,kBAAkB,CAACH,KAAK,CAACE,YAAY,CAAC;EACpE;EACA,IAAIF,KAAK,CAACI,YAAY,EAAE;IACtBH,MAAM,OAAmB,GAAGE,kBAAkB,CAACH,KAAK,CAACI,YAAY,CAAC;EACpE;EACA,IAAIJ,KAAK,CAACK,YAAY,EAAE;IACtBJ,MAAM,OAAmB,GAAGE,kBAAkB,CAACH,KAAK,CAACK,YAAY,CAAC;EACpE;EACA,IAAIL,KAAK,CAACM,SAAS,EAAE;IACnBL,MAAM,OAAuB,GAAGM,oBAAoB,CAACP,KAAK,CAACM,SAAS,CAAC;EACvE;EACA,IAAIN,KAAK,CAACQ,SAAS,IAAIR,KAAK,CAACS,YAAY,EAAE;IAEzCR,MAAM,OAAuB,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E,OAAO,eAAe;IACxB;MACE,OAAO,QAAQ;IACjB;MACE,OAAO,eAAe;IACxB;MACE,MAAM,IAAIO,KAAK,CAAC,SAAS,CAAC;EAC9B;AACF;AAEA,SAASH,sBAAsBA,CAACI,UAAkC,EAAwB;EACxF,QAAQA,UAAU;IAChB;MACE,OAAO,SAAS;IAClB;MACE,OAAO,QAAQ;IACjB;MACE,MAAM,IAAID,KAAK,CAAC,WAAW,CAAC;EAChC;AACF;AAWA,SAASF,sBAAsBA,CAACG,UAAuB,EAAwB;EAC7E,QAAQA,UAAU;IAEhB;MACE,OAAO,SAAS;IAClB;MACE,OAAO,QAAQ;IACjB;MACE,OAAO,SAAS;IAClB;MACE,OAAO,QAAQ;IACjB;MACE,OAAO,SAAS;IAClB;MACE,OAAO,QAAQ;IACjB;MACE,MAAM,IAAID,KAAK,CAAC,WAAW,CAAC;EAChC;AACF;AAEA,SAASD,yBAAyBA,CAACE,UAAuB,EAAwB;EAChF,QAAQA,UAAU;IAEhB;MACE,OAAO,SAAS;IAClB;MACE,OAAO,QAAQ;IACjB;MACE,OAAO,SAAS;IAClB;MACE,OAAO,SAAS;IAClB;MACE,OAAO,QAAQ;IACjB;MACE,OAAO,QAAQ;IACjB;MACE,MAAM,IAAID,KAAK,CAAC,QAAQ,CAAC;EAC7B;AACF;AAKA,OAAO,SAASE,8BAA8BA,CAC5CC,UAA+B,EACV;EACrB,MAAMC,aAAa,GAAG;IAAC,GAAGD;EAAU,CAAC;EACrC,IAAIA,UAAU,OAAuB,SAAe,EAAE;IAEpDC,aAAa,OAAuB,OAAY;EAClD;EAEAA,aAAa,OAAmB,QAAmB;EACnDA,aAAa,OAAmB,QAAmB;EACnD,OAAOA,aAAa;AACtB"}
|
|
1
|
+
{"version":3,"file":"sampler-parameters.js","names":["convertCompareFunction","convertSamplerParametersToWebGL","props","params","addressModeU","convertAddressMode","addressModeV","addressModeW","magFilter","convertMaxFilterMode","minFilter","mipmapFilter","convertMinFilterMode","lodMinClamp","undefined","lodMaxClamp","type","compare","maxAnisotropy","updateSamplerParametersForNPOT","parameters","newParameters","addressMode","maxFilter"],"sources":["../../../src/adapter/converters/sampler-parameters.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// SAMPLER FILTERS\nimport {SamplerProps} from '@luma.gl/core';\nimport {GL, GLSamplerParameters} from '@luma.gl/constants';\nimport {convertCompareFunction} from './device-parameters';\n\n/**\n * Convert WebGPU-style sampler props to WebGL\n * @param props\n * @returns\n */\nexport function convertSamplerParametersToWebGL(props: SamplerProps): GLSamplerParameters {\n const params: GLSamplerParameters = {};\n if (props.addressModeU) {\n params[GL.TEXTURE_WRAP_S] = convertAddressMode(props.addressModeU);\n }\n if (props.addressModeV) {\n params[GL.TEXTURE_WRAP_T] = convertAddressMode(props.addressModeV);\n }\n if (props.addressModeW) {\n params[GL.TEXTURE_WRAP_R] = convertAddressMode(props.addressModeW);\n }\n if (props.magFilter) {\n params[GL.TEXTURE_MAG_FILTER] = convertMaxFilterMode(props.magFilter);\n }\n if (props.minFilter || props.mipmapFilter) {\n // TODO - arbitrary choice of linear?\n params[GL.TEXTURE_MIN_FILTER] = convertMinFilterMode(\n props.minFilter || 'linear',\n props.mipmapFilter\n );\n }\n if (props.lodMinClamp !== undefined) {\n params[GL.TEXTURE_MIN_LOD] = props.lodMinClamp;\n }\n if (props.lodMaxClamp !== undefined) {\n params[GL.TEXTURE_MAX_LOD] = props.lodMaxClamp;\n }\n if (props.type === 'comparison-sampler') {\n // Setting prop.compare turns this into a comparison sampler\n params[GL.TEXTURE_COMPARE_MODE] = GL.COMPARE_REF_TO_TEXTURE;\n }\n if (props.compare) {\n params[GL.TEXTURE_COMPARE_FUNC] = convertCompareFunction('compare', props.compare);\n }\n // Note depends on WebGL extension\n if (props.maxAnisotropy) {\n params[GL.TEXTURE_MAX_ANISOTROPY_EXT] = props.maxAnisotropy;\n }\n return params;\n}\n\n/**\n * Override sampler settings that are not supported by Non-Power-of-Two textures in WebGL1.\n */\nexport function updateSamplerParametersForNPOT(\n parameters: GLSamplerParameters\n): GLSamplerParameters {\n const newParameters = {...parameters};\n if (parameters[GL.TEXTURE_MIN_FILTER] !== GL.NEAREST) {\n // log.warn(`texture: ${this} is Non-Power-Of-Two, forcing TEXTURE_MIN_FILTER to LINEAR`)();\n newParameters[GL.TEXTURE_MIN_FILTER] = GL.LINEAR;\n }\n // log.warn(`texture: ${this} is Non-Power-Of-Two, forcing TEXTURE_WRAP_S to CLAMP_TO_EDGE`)();\n newParameters[GL.TEXTURE_WRAP_S] = GL.CLAMP_TO_EDGE;\n newParameters[GL.TEXTURE_WRAP_T] = GL.CLAMP_TO_EDGE;\n return newParameters;\n}\n\n// HELPERS\n\n/** Convert address more */\nfunction convertAddressMode(addressMode: 'clamp-to-edge' | 'repeat' | 'mirror-repeat'): GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT {\n switch (addressMode) {\n case 'clamp-to-edge':\n return GL.CLAMP_TO_EDGE;\n case 'repeat':\n return GL.REPEAT;\n case 'mirror-repeat':\n return GL.MIRRORED_REPEAT;\n }\n}\n\nfunction convertMaxFilterMode(maxFilter: 'nearest' | 'linear'): GL.NEAREST | GL.LINEAR {\n switch (maxFilter) {\n case 'nearest':\n return GL.NEAREST;\n case 'linear':\n return GL.LINEAR;\n }\n}\n\n/**\n * WebGPU has separate min filter and mipmap filter,\n * WebGL is combined and effectively offers 6 options\n */\nfunction convertMinFilterMode(\n minFilter: 'nearest' | 'linear',\n mipmapFilter?: 'nearest' | 'linear'\n): GL.NEAREST | GL.LINEAR | GL.NEAREST_MIPMAP_NEAREST | GL.LINEAR_MIPMAP_NEAREST | GL.NEAREST_MIPMAP_LINEAR | GL.LINEAR_MIPMAP_LINEAR {\n if (!mipmapFilter) {\n return convertMaxFilterMode(minFilter);\n }\n switch (minFilter) {\n case 'nearest':\n return mipmapFilter === 'nearest' ? GL.NEAREST_MIPMAP_NEAREST : GL.NEAREST_MIPMAP_LINEAR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EA,IAAIf,KAAK,CAACgB,aAAa,EAAE;IACvBf,MAAM,OAA+B,GAAGD,KAAK,CAACgB,aAAa;EAC7D;EACA,OAAOf,MAAM;AACf;AAKA,OAAO,SAASgB,8BAA8BA,CAC5CC,UAA+B,EACV;EACrB,MAAMC,aAAa,GAAG;IAAC,GAAGD;EAAU,CAAC;EACrC,IAAIA,UAAU,OAAuB,SAAe,EAAE;IAEpDC,aAAa,OAAuB,OAAY;EAClD;EAEAA,aAAa,OAAmB,QAAmB;EACnDA,aAAa,OAAmB,QAAmB;EACnD,OAAOA,aAAa;AACtB;AAKA,SAAShB,kBAAkBA,CAACiB,WAAyD,EAAqD;EACxI,QAAQA,WAAW;IACjB,KAAK,eAAe;MAClB;IACF,KAAK,QAAQ;MACX;IACF,KAAK,eAAe;MAClB;EACJ;AACF;AAEA,SAASb,oBAAoBA,CAACc,SAA+B,EAA0B;EACrF,QAAQA,SAAS;IACf,KAAK,SAAS;MACZ;IACF,KAAK,QAAQ;MACX;EACJ;AACF;AAMA,SAASX,oBAAoBA,CAC3BF,SAA+B,EAC/BC,YAAmC,EACiG;EACpI,IAAI,CAACA,YAAY,EAAE;IACjB,OAAOF,oBAAoB,CAACC,SAAS,CAAC;EACxC;EACA,QAAQA,SAAS;IACf,KAAK,SAAS;MACZ,OAAOC,YAAY,KAAK,SAAS,cAAuD;IAC1F,KAAK,QAAQ;MACX,OAAOA,YAAY,KAAK,SAAS,cAAqD;EAC1F;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-device-info.d.ts","sourceRoot":"","sources":["../../../src/adapter/device-helpers/get-device-info.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAIzC,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,EAAE,EAAE,qBAAqB,GAAG,UAAU,
|
|
1
|
+
{"version":3,"file":"get-device-info.d.ts","sourceRoot":"","sources":["../../../src/adapter/device-helpers/get-device-info.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAIzC,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,EAAE,EAAE,qBAAqB,GAAG,UAAU,CAuCnE"}
|
|
@@ -10,11 +10,13 @@ export function getDeviceInfo(gl) {
|
|
|
10
10
|
const version = gl.getParameter(7938);
|
|
11
11
|
const gpu = identifyGPUVendor(vendor, renderer);
|
|
12
12
|
const gpuBackend = identifyGPUBackend(vendor, renderer);
|
|
13
|
+
const gpuType = identifyGPUType(vendor, renderer);
|
|
13
14
|
const shadingLanguage = 'glsl';
|
|
14
15
|
const shadingLanguageVersion = isWebGL2(gl) ? 300 : 100;
|
|
15
16
|
return {
|
|
16
17
|
type: isWebGL2(gl) ? 'webgl2' : 'webgl',
|
|
17
18
|
gpu,
|
|
19
|
+
gpuType,
|
|
18
20
|
gpuBackend,
|
|
19
21
|
vendor,
|
|
20
22
|
renderer,
|
|
@@ -42,12 +44,28 @@ function identifyGPUVendor(vendor, renderer) {
|
|
|
42
44
|
return 'unknown';
|
|
43
45
|
}
|
|
44
46
|
function identifyGPUBackend(vendor, renderer) {
|
|
45
|
-
if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {
|
|
46
|
-
return 'angle';
|
|
47
|
-
}
|
|
48
47
|
if (/Metal/i.exec(vendor) || /Metal/i.exec(renderer)) {
|
|
49
48
|
return 'metal';
|
|
50
49
|
}
|
|
50
|
+
if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {
|
|
51
|
+
return 'opengl';
|
|
52
|
+
}
|
|
51
53
|
return 'unknown';
|
|
52
54
|
}
|
|
55
|
+
function identifyGPUType(vendor, renderer) {
|
|
56
|
+
if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {
|
|
57
|
+
return 'cpu';
|
|
58
|
+
}
|
|
59
|
+
const gpuVendor = identifyGPUVendor(vendor, renderer);
|
|
60
|
+
switch (gpuVendor) {
|
|
61
|
+
case 'intel':
|
|
62
|
+
return 'integrated';
|
|
63
|
+
case 'software':
|
|
64
|
+
return 'cpu';
|
|
65
|
+
case 'unknown':
|
|
66
|
+
return 'unknown';
|
|
67
|
+
default:
|
|
68
|
+
return 'discrete';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
53
71
|
//# sourceMappingURL=get-device-info.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-device-info.js","names":["isWebGL2","getDeviceInfo","gl","vendorMasked","getParameter","rendererMasked","ext","getExtension","vendorUnmasked","UNMASKED_VENDOR_WEBGL","rendererUnmasked","UNMASKED_RENDERER_WEBGL","vendor","renderer","version","gpu","identifyGPUVendor","gpuBackend","identifyGPUBackend","shadingLanguage","shadingLanguageVersion","type","exec"],"sources":["../../../src/adapter/device-helpers/get-device-info.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {DeviceInfo} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {isWebGL2} from '../../context/context/webgl-checks';\n\n/** @returns strings identifying the GPU vendor and driver. */\nexport function getDeviceInfo(gl: WebGLRenderingContext): DeviceInfo {\n // \"Masked\" info is always available, but don't contain much useful information\n const vendorMasked = gl.getParameter(GL.VENDOR);\n const rendererMasked = gl.getParameter(GL.RENDERER);\n\n // If we are lucky, unmasked info is available\n // https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/\n const ext = gl.getExtension('WEBGL_debug_renderer_info');\n const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : GL.VENDOR);\n const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : GL.RENDERER);\n const vendor = vendorUnmasked || vendorMasked;\n const renderer = rendererUnmasked || rendererMasked;\n\n // Driver version\n const version = gl.getParameter(GL.VERSION) as string;\n\n // \"Sniff\" the GPU type and backend from the info. This works best if unmasked info is available.\n const gpu = identifyGPUVendor(vendor, renderer);\n const gpuBackend = identifyGPUBackend(vendor, renderer);\n\n // Determine GLSL version\n // For now, skip parsing of the long version string, just use context type below to deduce version\n // const version = gl.getParameter(GL.SHADING_LANGUAGE_VERSION) as string;\n // const shadingLanguageVersion = parseGLSLVersion(version);\n const shadingLanguage = 'glsl';\n const shadingLanguageVersion = isWebGL2(gl) ? 300 : 100\n\n return {\n type: isWebGL2(gl) ? 'webgl2' : 'webgl',\n gpu,\n gpuBackend,\n vendor,\n renderer,\n version,\n shadingLanguage,\n shadingLanguageVersion\n };\n}\n\n/** \"Sniff\" the GPU type from the info. This works best if unmasked info is available. */\nfunction identifyGPUVendor(vendor: string, renderer: string): 'nvidia' | 'intel' | 'apple' | 'amd' | 'software' | 'unknown' {\n if ((/NVIDIA/i.exec(vendor)) || (/NVIDIA/i.exec(renderer))) {\n return 'nvidia';\n }\n if ((/INTEL/i.exec(vendor)) || (/INTEL/i.exec(renderer))) {\n return 'intel';\n }\n if ((/Apple/i.exec(vendor)) || (/Apple/i.exec(renderer))) {\n return 'apple';\n }\n if (\n (/AMD/i.exec(vendor)) ||\n (/AMD/i.exec(renderer)) ||\n (/ATI/i.exec(vendor)) ||\n (/ATI/i.exec(renderer))\n ) {\n return 'amd';\n }\n if ((/SwiftShader/i.exec(vendor)) || (/SwiftShader/i.exec(renderer))) {\n return 'software';\n }\n \n return 'unknown';\n}\n\n/** \"Sniff\" the GPU backend from the info. This works best if unmasked info is available. */\nfunction identifyGPUBackend(vendor: string, renderer: string): '
|
|
1
|
+
{"version":3,"file":"get-device-info.js","names":["isWebGL2","getDeviceInfo","gl","vendorMasked","getParameter","rendererMasked","ext","getExtension","vendorUnmasked","UNMASKED_VENDOR_WEBGL","rendererUnmasked","UNMASKED_RENDERER_WEBGL","vendor","renderer","version","gpu","identifyGPUVendor","gpuBackend","identifyGPUBackend","gpuType","identifyGPUType","shadingLanguage","shadingLanguageVersion","type","exec","gpuVendor"],"sources":["../../../src/adapter/device-helpers/get-device-info.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {DeviceInfo} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {isWebGL2} from '../../context/context/webgl-checks';\n\n/** @returns strings identifying the GPU vendor and driver. */\nexport function getDeviceInfo(gl: WebGLRenderingContext): DeviceInfo {\n // \"Masked\" info is always available, but don't contain much useful information\n const vendorMasked = gl.getParameter(GL.VENDOR);\n const rendererMasked = gl.getParameter(GL.RENDERER);\n\n // If we are lucky, unmasked info is available\n // https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/\n const ext = gl.getExtension('WEBGL_debug_renderer_info');\n const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : GL.VENDOR);\n const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : GL.RENDERER);\n const vendor = vendorUnmasked || vendorMasked;\n const renderer = rendererUnmasked || rendererMasked;\n\n // Driver version\n const version = gl.getParameter(GL.VERSION) as string;\n\n // \"Sniff\" the GPU type and backend from the info. This works best if unmasked info is available.\n const gpu = identifyGPUVendor(vendor, renderer);\n const gpuBackend = identifyGPUBackend(vendor, renderer);\n const gpuType = identifyGPUType(vendor, renderer);\n\n // Determine GLSL version\n // For now, skip parsing of the long version string, just use context type below to deduce version\n // const version = gl.getParameter(GL.SHADING_LANGUAGE_VERSION) as string;\n // const shadingLanguageVersion = parseGLSLVersion(version);\n const shadingLanguage = 'glsl';\n const shadingLanguageVersion = isWebGL2(gl) ? 300 : 100\n\n return {\n type: isWebGL2(gl) ? 'webgl2' : 'webgl',\n gpu,\n gpuType,\n gpuBackend,\n vendor,\n renderer,\n version,\n shadingLanguage,\n shadingLanguageVersion\n };\n}\n\n/** \"Sniff\" the GPU type from the info. This works best if unmasked info is available. */\nfunction identifyGPUVendor(vendor: string, renderer: string): 'nvidia' | 'intel' | 'apple' | 'amd' | 'software' | 'unknown' {\n if ((/NVIDIA/i.exec(vendor)) || (/NVIDIA/i.exec(renderer))) {\n return 'nvidia';\n }\n if ((/INTEL/i.exec(vendor)) || (/INTEL/i.exec(renderer))) {\n return 'intel';\n }\n if ((/Apple/i.exec(vendor)) || (/Apple/i.exec(renderer))) {\n return 'apple';\n }\n if (\n (/AMD/i.exec(vendor)) ||\n (/AMD/i.exec(renderer)) ||\n (/ATI/i.exec(vendor)) ||\n (/ATI/i.exec(renderer))\n ) {\n return 'amd';\n }\n if ((/SwiftShader/i.exec(vendor)) || (/SwiftShader/i.exec(renderer))) {\n return 'software';\n }\n \n return 'unknown';\n}\n\n/** \"Sniff\" the GPU backend from the info. This works best if unmasked info is available. */\nfunction identifyGPUBackend(vendor: string, renderer: string): 'opengl' | 'metal' | 'unknown' {\n if ((/Metal/i.exec(vendor)) || (/Metal/i.exec(renderer))) {\n return 'metal';\n }\n if ((/ANGLE/i.exec(vendor)) || (/ANGLE/i.exec(renderer))) {\n return 'opengl';\n } \n return 'unknown';\n}\n\nfunction identifyGPUType(vendor: string, renderer: string): 'discrete' | 'integrated' | 'cpu' | 'unknown' {\n if ((/SwiftShader/i.exec(vendor)) || (/SwiftShader/i.exec(renderer))) {\n return 'cpu';\n }\n\n const gpuVendor = identifyGPUVendor(vendor, renderer);\n switch (gpuVendor) {\n case 'intel':\n return 'integrated';\n case 'software':\n return 'cpu';\n case 'unknown':\n return 'unknown';\n default:\n return 'discrete';\n }\n}\n"],"mappings":"SAKQA,QAAQ;AAGhB,OAAO,SAASC,aAAaA,CAACC,EAAyB,EAAc;EAEnE,MAAMC,YAAY,GAAGD,EAAE,CAACE,YAAY,KAAU,CAAC;EAC/C,MAAMC,cAAc,GAAGH,EAAE,CAACE,YAAY,KAAY,CAAC;EAInD,MAAME,GAAG,GAAGJ,EAAE,CAACK,YAAY,CAAC,2BAA2B,CAAC;EACxD,MAAMC,cAAc,GAAGN,EAAE,CAACE,YAAY,CAACE,GAAG,GAAGA,GAAG,CAACG,qBAAqB,OAAY,CAAC;EACnF,MAAMC,gBAAgB,GAAGR,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,IAAI,CAACX,QAAQ,CAAE,IACtB,MAAM,CAACW,IAAI,CAACZ,MAAM,CAAE,IACpB,MAAM,CAACY,IAAI,CAACX,QAAQ,CAAE,EACvB;IACA,OAAO,KAAK;EACd;EACA,IAAK,cAAc,CAACW,IAAI,CAACZ,MAAM,CAAC,IAAM,cAAc,CAACY,IAAI,CAACX,QAAQ,CAAE,EAAE;IACpE,OAAO,UAAU;EACnB;EAEA,OAAO,SAAS;AAClB;AAGA,SAASK,kBAAkBA,CAACN,MAAc,EAAEC,QAAgB,EAAkC;EAC5F,IAAK,QAAQ,CAACW,IAAI,CAACZ,MAAM,CAAC,IAAM,QAAQ,CAACY,IAAI,CAACX,QAAQ,CAAE,EAAE;IACxD,OAAO,OAAO;EAChB;EACA,IAAK,QAAQ,CAACW,IAAI,CAACZ,MAAM,CAAC,IAAM,QAAQ,CAACY,IAAI,CAACX,QAAQ,CAAE,EAAE;IACxD,OAAO,QAAQ;EACjB;EACA,OAAO,SAAS;AAClB;AAEA,SAASO,eAAeA,CAACR,MAAc,EAAEC,QAAgB,EAAiD;EACxG,IAAK,cAAc,CAACW,IAAI,CAACZ,MAAM,CAAC,IAAM,cAAc,CAACY,IAAI,CAACX,QAAQ,CAAE,EAAE;IACpE,OAAO,KAAK;EACd;EAEA,MAAMY,SAAS,GAAGT,iBAAiB,CAACJ,MAAM,EAAEC,QAAQ,CAAC;EACrD,QAAQY,SAAS;IACf,KAAK,OAAO;MACV,OAAO,YAAY;IACrB,KAAK,UAAU;MACb,OAAO,KAAK;IACd,KAAK,SAAS;MACZ,OAAO,SAAS;IAClB;MACE,OAAO,UAAU;EACrB;AACF"}
|
|
@@ -18,18 +18,15 @@ export declare class WEBGLBuffer extends Buffer {
|
|
|
18
18
|
byteLength: number;
|
|
19
19
|
/** Number of bytes used */
|
|
20
20
|
bytesUsed: number;
|
|
21
|
-
/** A partial CPU-side copy of the data in this buffer, for debugging purposes */
|
|
22
|
-
debugData: ArrayBuffer | null;
|
|
23
21
|
constructor(device: WebGLDevice, props?: BufferProps);
|
|
24
22
|
/** Allocate a new buffer and initialize to contents of typed array */
|
|
25
|
-
_initWithData(data:
|
|
23
|
+
_initWithData(data: ArrayBuffer | ArrayBufferView, byteOffset?: number, byteLength?: number): void;
|
|
26
24
|
_initWithByteLength(byteLength: number): this;
|
|
27
25
|
destroy(): void;
|
|
28
26
|
write(data: ArrayBufferView, byteOffset?: number): void;
|
|
29
|
-
/**
|
|
27
|
+
/** Asynchronously read data from the buffer */
|
|
30
28
|
readAsync(byteOffset?: number, byteLength?: number): Promise<Uint8Array>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
_getReadTarget(): GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER;
|
|
29
|
+
/** Synchronously read data from the buffer. WebGL only. */
|
|
30
|
+
readSyncWebGL2(byteOffset?: number, byteLength?: number): Uint8Array;
|
|
34
31
|
}
|
|
35
32
|
//# sourceMappingURL=webgl-buffer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-buffer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAC,MAAM,EAAS,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AACtC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-buffer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAC,MAAM,EAAS,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AACtC,OAAO,EAAC,WAAW,EAAC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
1
|
import { Buffer, assert } from '@luma.gl/core';
|
|
2
|
-
const DEBUG_DATA_LENGTH = 10;
|
|
3
2
|
export class WEBGLBuffer extends Buffer {
|
|
4
3
|
constructor(device) {
|
|
5
4
|
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -13,7 +12,6 @@ export class WEBGLBuffer extends Buffer {
|
|
|
13
12
|
this.glIndexType = 5123;
|
|
14
13
|
this.byteLength = void 0;
|
|
15
14
|
this.bytesUsed = void 0;
|
|
16
|
-
this.debugData = null;
|
|
17
15
|
this.device = device;
|
|
18
16
|
this.gl = this.device.gl;
|
|
19
17
|
this.gl2 = this.device.gl2;
|
|
@@ -26,7 +24,6 @@ export class WEBGLBuffer extends Buffer {
|
|
|
26
24
|
this.glTarget = getWebGLTarget(this.props.usage);
|
|
27
25
|
this.glUsage = getWebGLUsage(this.props.usage);
|
|
28
26
|
this.glIndexType = this.props.indexType === 'uint32' ? 5125 : 5123;
|
|
29
|
-
this.debugData = null;
|
|
30
27
|
if (props.data) {
|
|
31
28
|
this._initWithData(props.data, props.byteOffset, props.byteLength);
|
|
32
29
|
} else {
|
|
@@ -36,17 +33,15 @@ export class WEBGLBuffer extends Buffer {
|
|
|
36
33
|
_initWithData(data) {
|
|
37
34
|
let byteOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
38
35
|
let byteLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : data.byteLength + byteOffset;
|
|
39
|
-
|
|
40
|
-
const glTarget = this._getWriteTarget();
|
|
36
|
+
const glTarget = this.glTarget;
|
|
41
37
|
this.gl.bindBuffer(glTarget, this.handle);
|
|
42
38
|
this.gl.bufferData(glTarget, byteLength, this.glUsage);
|
|
43
39
|
this.gl.bufferSubData(glTarget, byteOffset, data);
|
|
44
40
|
this.gl.bindBuffer(glTarget, null);
|
|
45
|
-
this.debugData = data.slice(0, DEBUG_DATA_LENGTH);
|
|
46
41
|
this.bytesUsed = byteLength;
|
|
47
42
|
this.byteLength = byteLength;
|
|
43
|
+
this._setDebugData(data, byteOffset, byteLength);
|
|
48
44
|
this.trackAllocatedMemory(byteLength);
|
|
49
|
-
return this;
|
|
50
45
|
}
|
|
51
46
|
_initWithByteLength(byteLength) {
|
|
52
47
|
assert(byteLength >= 0);
|
|
@@ -54,13 +49,14 @@ export class WEBGLBuffer extends Buffer {
|
|
|
54
49
|
if (byteLength === 0) {
|
|
55
50
|
data = new Float32Array(0);
|
|
56
51
|
}
|
|
57
|
-
const glTarget = this.
|
|
52
|
+
const glTarget = this.glTarget;
|
|
58
53
|
this.gl.bindBuffer(glTarget, this.handle);
|
|
59
54
|
this.gl.bufferData(glTarget, data, this.glUsage);
|
|
60
55
|
this.gl.bindBuffer(glTarget, null);
|
|
61
|
-
this.debugData = null;
|
|
62
56
|
this.bytesUsed = byteLength;
|
|
63
57
|
this.byteLength = byteLength;
|
|
58
|
+
this._setDebugData(null, 0, byteLength);
|
|
59
|
+
this.trackAllocatedMemory(byteLength);
|
|
64
60
|
return this;
|
|
65
61
|
}
|
|
66
62
|
destroy() {
|
|
@@ -85,29 +81,27 @@ export class WEBGLBuffer extends Buffer {
|
|
|
85
81
|
this.gl.bufferSubData(glTarget, byteOffset, data);
|
|
86
82
|
}
|
|
87
83
|
this.gl.bindBuffer(glTarget, null);
|
|
84
|
+
this._setDebugData(data, byteOffset, data.byteLength);
|
|
88
85
|
}
|
|
89
86
|
async readAsync() {
|
|
87
|
+
let byteOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
88
|
+
let byteLength = arguments.length > 1 ? arguments[1] : undefined;
|
|
89
|
+
return this.readSyncWebGL2(byteOffset, byteLength);
|
|
90
|
+
}
|
|
91
|
+
readSyncWebGL2() {
|
|
90
92
|
var _byteLength;
|
|
91
93
|
let byteOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
92
94
|
let byteLength = arguments.length > 1 ? arguments[1] : undefined;
|
|
93
95
|
this.device.assertWebGL2();
|
|
94
|
-
byteLength = (_byteLength = byteLength) !== null && _byteLength !== void 0 ? _byteLength : this.byteLength;
|
|
96
|
+
byteLength = (_byteLength = byteLength) !== null && _byteLength !== void 0 ? _byteLength : this.byteLength - byteOffset;
|
|
95
97
|
const data = new Uint8Array(byteLength);
|
|
96
98
|
const dstOffset = 0;
|
|
97
99
|
this.gl.bindBuffer(36662, this.handle);
|
|
98
100
|
this.gl2.getBufferSubData(36662, byteOffset, data, dstOffset, byteLength);
|
|
99
101
|
this.gl.bindBuffer(36662, null);
|
|
102
|
+
this._setDebugData(data, byteOffset, byteLength);
|
|
100
103
|
return data;
|
|
101
104
|
}
|
|
102
|
-
_invalidateDebugData() {
|
|
103
|
-
this.debugData = null;
|
|
104
|
-
}
|
|
105
|
-
_getWriteTarget() {
|
|
106
|
-
return this.glTarget;
|
|
107
|
-
}
|
|
108
|
-
_getReadTarget() {
|
|
109
|
-
return this.glTarget;
|
|
110
|
-
}
|
|
111
105
|
}
|
|
112
106
|
function getWebGLTarget(usage) {
|
|
113
107
|
if (usage & Buffer.INDEX) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-buffer.js","names":["Buffer","assert","DEBUG_DATA_LENGTH","WEBGLBuffer","constructor","device","props","arguments","length","undefined","gl","gl2","handle","glTarget","glUsage","glIndexType","byteLength","bytesUsed","debugData","createBuffer","setSpectorMetadata","data","getWebGLTarget","usage","getWebGLUsage","indexType","_initWithData","byteOffset","_initWithByteLength","ArrayBuffer","isView","_getWriteTarget","bindBuffer","bufferData","bufferSubData","slice","trackAllocatedMemory","Float32Array","destroy","destroyed","removeStats","trackDeallocatedMemory","deleteBuffer","write","srcOffset","isWebGL2","assertWebGL2","readAsync","_byteLength","Uint8Array","dstOffset","getBufferSubData","_invalidateDebugData","_getReadTarget","INDEX","VERTEX","UNIFORM"],"sources":["../../../src/adapter/resources/webgl-buffer.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {BufferProps} from '@luma.gl/core';\nimport {Buffer, assert} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n/** WebGL Buffer interface */\nexport class WEBGLBuffer extends Buffer {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly handle: WebGLBuffer;\n\n /** Target in OpenGL defines the type of buffer */\n readonly glTarget: GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER;\n /** Usage is a hint on how frequently the buffer will be updates */\n readonly glUsage: GL.STATIC_DRAW | GL.DYNAMIC_DRAW;\n /** Index type is needed when issuing draw calls, so we pre-compute it */\n readonly glIndexType: GL.UNSIGNED_SHORT | GL.UNSIGNED_INT = GL.UNSIGNED_SHORT;\n\n /** Number of bytes allocated on the GPU for this buffer */\n byteLength: number;\n /** Number of bytes used */\n bytesUsed: number;\n /** A partial CPU-side copy of the data in this buffer, for debugging purposes */\n debugData: ArrayBuffer | null = null;\n\n constructor(device: WebGLDevice, props: BufferProps = {}) {\n super(device, props);\n\n this.device = device;\n this.gl = this.device.gl;\n this.gl2 = this.device.gl2;\n\n const handle = typeof props === 'object' ? props.handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n device.setSpectorMetadata(this.handle, {...this.props, data: typeof this.props.data});\n\n // - In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // - In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n this.glTarget = getWebGLTarget(this.props.usage);\n this.glUsage = getWebGLUsage(this.props.usage);\n this.glIndexType = this.props.indexType === 'uint32' ? GL.UNSIGNED_INT : GL.UNSIGNED_SHORT;\n\n this.debugData = null;\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._initWithByteLength(props.byteLength || 0);\n }\n }\n\n // PRIVATE METHODS\n\n /** Allocate a new buffer and initialize to contents of typed array */\n _initWithData(\n data,\n byteOffset: number = 0,\n byteLength: number = data.byteLength + byteOffset\n ): this {\n assert(ArrayBuffer.isView(data));\n\n const glTarget = this._getWriteTarget();\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, byteLength, this.glUsage);\n this.gl.bufferSubData(glTarget, byteOffset, data);\n this.gl.bindBuffer(glTarget, null);\n\n this.debugData = data.slice(0, DEBUG_DATA_LENGTH);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const glTarget = this._getWriteTarget();\n\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, data, this.glUsage);\n this.gl.bindBuffer(glTarget, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n return this;\n }\n\n override destroy(): void {\n if (!this.destroyed && this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n this.destroyed = true;\n // @ts-expect-error\n this.handle = null;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = undefined; // data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const glTarget = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n this.gl.bindBuffer(glTarget, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.device.assertWebGL2();\n this.gl2.bufferSubData(glTarget, byteOffset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(glTarget, byteOffset, data);\n }\n this.gl.bindBuffer(glTarget, null);\n\n // TODO - update local `data` if offsets are right\n // this.debugData = data.slice(byteOffset, 40);\n }\n\n /** Read data from the buffer */\n override async readAsync(byteOffset = 0, byteLength?: number): Promise<Uint8Array> {\n this.device.assertWebGL2();\n\n byteLength = byteLength ?? this.byteLength;\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n // this.debugData = null;\n\n return data;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n _invalidateDebugData() {\n this.debugData = null;\n }\n\n _getWriteTarget() {\n return this.glTarget;\n // return this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n }\n\n _getReadTarget() {\n return this.glTarget;\n // return this.device.isWebGL2 ? GL.COPY_READ_BUFFER : this.glTarget;\n }\n}\n\n// static MAP_READ = 0x01;\n// static MAP_WRITE = 0x02;\n// static COPY_SRC = 0x0004;\n// static COPY_DST = 0x0008;\n// static INDEX = 0x0010;\n// static VERTEX = 0x0020;\n// static UNIFORM = 0x0040;\n// static STORAGE = 0x0080;\n// static INDIRECT = 0x0100;\n// static QUERY_RESOLVE = 0x0200;\n\nfunction getWebGLTarget(\n usage: number\n): GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER {\n if (usage & Buffer.INDEX) {\n return GL.ELEMENT_ARRAY_BUFFER;\n }\n if (usage & Buffer.VERTEX) {\n return GL.ARRAY_BUFFER;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.UNIFORM_BUFFER;\n }\n\n // gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n // gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n // gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n // gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n // gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n return GL.ARRAY_BUFFER;\n}\n\n/** @todo usage is not passed correctly */\nfunction getWebGLUsage(usage: number): GL.STATIC_DRAW | GL.DYNAMIC_DRAW {\n if (usage & Buffer.INDEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.VERTEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.DYNAMIC_DRAW;\n }\n return GL.STATIC_DRAW;\n}\n"],"mappings":"AAIA,SAAQA,MAAM,EAAEC,MAAM,QAAO,eAAe;AAI5C,MAAMC,iBAAiB,GAAG,EAAE;AAG5B,OAAO,MAAMC,WAAW,SAASH,MAAM,CAAC;EAoBtCI,WAAWA,CAACC,MAAmB,EAA2B;IAAA,IAAzBC,KAAkB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IACtD,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAAC,KApBdD,MAAM;IAAA,KACNK,EAAE;IAAA,KACFC,GAAG;IAAA,KACHC,MAAM;IAAA,KAGNC,QAAQ;IAAA,KAERC,OAAO;IAAA,KAEPC,WAAW;IAAA,KAGpBC,UAAU;IAAA,KAEVC,SAAS;IAAA,KAETC,SAAS,GAAuB,IAAI;IAKlC,IAAI,CAACb,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACK,EAAE,GAAG,IAAI,CAACL,MAAM,CAACK,EAAE;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B;EACF;EACA,IAAI/B,KAAK,GAAGvB,MAAM,CAACuD,MAAM,EAAE;IACzB;EACF;EACA,IAAIhC,KAAK,GAAGvB,MAAM,CAACwD,OAAO,EAAE;IAC1B;EACF;EACA;AACF"}
|
|
1
|
+
{"version":3,"file":"webgl-buffer.js","names":["Buffer","assert","WEBGLBuffer","constructor","device","props","arguments","length","undefined","gl","gl2","handle","glTarget","glUsage","glIndexType","byteLength","bytesUsed","createBuffer","setSpectorMetadata","data","getWebGLTarget","usage","getWebGLUsage","indexType","_initWithData","byteOffset","_initWithByteLength","bindBuffer","bufferData","bufferSubData","_setDebugData","trackAllocatedMemory","Float32Array","destroy","destroyed","removeStats","trackDeallocatedMemory","deleteBuffer","write","srcOffset","isWebGL2","assertWebGL2","readAsync","readSyncWebGL2","_byteLength","Uint8Array","dstOffset","getBufferSubData","INDEX","VERTEX","UNIFORM"],"sources":["../../../src/adapter/resources/webgl-buffer.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {BufferProps} from '@luma.gl/core';\nimport {Buffer, assert} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\n\n/** WebGL Buffer interface */\nexport class WEBGLBuffer extends Buffer {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly handle: WebGLBuffer;\n\n /** Target in OpenGL defines the type of buffer */\n readonly glTarget: GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER;\n /** Usage is a hint on how frequently the buffer will be updates */\n readonly glUsage: GL.STATIC_DRAW | GL.DYNAMIC_DRAW;\n /** Index type is needed when issuing draw calls, so we pre-compute it */\n readonly glIndexType: GL.UNSIGNED_SHORT | GL.UNSIGNED_INT = GL.UNSIGNED_SHORT;\n\n /** Number of bytes allocated on the GPU for this buffer */\n byteLength: number;\n /** Number of bytes used */\n bytesUsed: number;\n\n constructor(device: WebGLDevice, props: BufferProps = {}) {\n super(device, props);\n\n this.device = device;\n this.gl = this.device.gl;\n this.gl2 = this.device.gl2;\n\n const handle = typeof props === 'object' ? props.handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n device.setSpectorMetadata(this.handle, {...this.props, data: typeof this.props.data});\n\n // - In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // - In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n this.glTarget = getWebGLTarget(this.props.usage);\n this.glUsage = getWebGLUsage(this.props.usage);\n this.glIndexType = this.props.indexType === 'uint32' ? GL.UNSIGNED_INT : GL.UNSIGNED_SHORT;\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._initWithByteLength(props.byteLength || 0);\n }\n }\n\n // PRIVATE METHODS\n\n /** Allocate a new buffer and initialize to contents of typed array */\n _initWithData(\n data: ArrayBuffer | ArrayBufferView,\n byteOffset: number = 0,\n byteLength: number = data.byteLength + byteOffset\n ): void {\n // const glTarget = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n const glTarget = this.glTarget;\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, byteLength, this.glUsage);\n this.gl.bufferSubData(glTarget, byteOffset, data);\n this.gl.bindBuffer(glTarget, null);\n\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n this._setDebugData(data, byteOffset, byteLength);\n this.trackAllocatedMemory(byteLength);\n }\n\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n // const glTarget = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n const glTarget = this.glTarget;\n\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, data, this.glUsage);\n this.gl.bindBuffer(glTarget, null);\n\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n this._setDebugData(null, 0, byteLength);\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n override destroy(): void {\n if (!this.destroyed && this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n this.destroyed = true;\n // @ts-expect-error\n this.handle = null;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = undefined; // data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const glTarget = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n this.gl.bindBuffer(glTarget, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.device.assertWebGL2();\n this.gl2.bufferSubData(glTarget, byteOffset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(glTarget, byteOffset, data);\n }\n this.gl.bindBuffer(glTarget, null);\n\n this._setDebugData(data, byteOffset, data.byteLength);\n }\n\n /** Asynchronously read data from the buffer */\n override async readAsync(byteOffset = 0, byteLength?: number): Promise<Uint8Array> {\n return this.readSyncWebGL2(byteOffset, byteLength);\n }\n\n /** Synchronously read data from the buffer. WebGL only. */\n override readSyncWebGL2(byteOffset = 0, byteLength?: number): Uint8Array {\n this.device.assertWebGL2();\n\n byteLength = byteLength ?? this.byteLength - byteOffset;\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // Update local `data` if offsets are 0\n this._setDebugData(data, byteOffset, byteLength);\n\n return data;\n }\n}\n\n/**\n * Returns a WebGL buffer target\n *\n * @param usage\n * static MAP_READ = 0x01;\n * static MAP_WRITE = 0x02;\n * static COPY_SRC = 0x0004;\n * static COPY_DST = 0x0008;\n * static INDEX = 0x0010;\n * static VERTEX = 0x0020;\n * static UNIFORM = 0x0040;\n * static STORAGE = 0x0080;\n * static INDIRECT = 0x0100;\n * static QUERY_RESOLVE = 0x0200;\n * \n * @returns WebGL buffer targe\n * \n * Buffer bind points in WebGL2\n * gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n * gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n * gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n * gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n * gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n */\nfunction getWebGLTarget(\n usage: number\n): GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER {\n if (usage & Buffer.INDEX) {\n return GL.ELEMENT_ARRAY_BUFFER;\n }\n if (usage & Buffer.VERTEX) {\n return GL.ARRAY_BUFFER;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.UNIFORM_BUFFER;\n }\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, we can use GL.COPY_WRITE_BUFFER to avoid locking the type\n return GL.ARRAY_BUFFER;\n}\n\n/** @todo usage is not passed correctly */\nfunction getWebGLUsage(usage: number): GL.STATIC_DRAW | GL.DYNAMIC_DRAW {\n if (usage & Buffer.INDEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.VERTEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.DYNAMIC_DRAW;\n }\n return GL.STATIC_DRAW;\n}\n"],"mappings":"AAIA,SAAQA,MAAM,EAAE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AGnB,IAAI,CAACrC,EAAE,CAACkB,UAAU,QAAsB,IAAI,CAAChB,MAAM,CAAC;IACpD,IAAI,CAACD,GAAG,CAACqC,gBAAgB,QAAsBtB,UAAU,EAAEN,IAAI,EAAE2B,SAAS,EAAE/B,UAAU,CAAC;IACvF,IAAI,CAACN,EAAE,CAACkB,UAAU,QAAsB,IAAI,CAAC;IAG7C,IAAI,CAACG,aAAa,CAACX,IAAI,EAAEM,UAAU,EAAEV,UAAU,CAAC;IAEhD,OAAOI,IAAI;EACb;AACF;AA0BA,SAASC,cAAcA,CACrBC,KAAa,EACkD;EAC/D,IAAIA,KAAK,GAAGrB,MAAM,CAACgD,KAAK,EAAE;IACxB;EACF;EACA,IAAI3B,KAAK,GAAGrB,MAAM,CAACiD,MAAM,EAAE;IACzB;EACF;EACA,IAAI5B,KAAK,GAAGrB,MAAM,CAACkD,OAAO,EAAE;IAC1B;EACF;EAIA;AACF;AAGA,SAAS5B,aAAaA,CAACD,KAAa,EAAoC;EACtE,IAAIA,KAAK,GAAGrB,MAAM,CAACgD,KAAK,EAAE;IACxB;EACF;EACA,IAAI3B,KAAK,GAAGrB,MAAM,CAACiD,MAAM,EAAE;IACzB;EACF;EACA,IAAI5B,KAAK,GAAGrB,MAAM,CAACkD,OAAO,EAAE;IAC1B;EACF;EACA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,OAAO,EACP,YAAY,EAEZ,UAAU,
|
|
1
|
+
{"version":3,"file":"webgl-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,OAAO,EACP,YAAY,EAEZ,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,OAAO,EAAsD,MAAM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,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,OAAO,GAC5B,MAAM;CAqBV"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { isObjectEmpty } from '@luma.gl/core';
|
|
2
|
-
import { Texture, cast, log, assert, isPowerOfTwo, loadImage } from '@luma.gl/core';
|
|
1
|
+
import { Texture, log, assert, isPowerOfTwo, loadImage, isObjectEmpty } from '@luma.gl/core';
|
|
3
2
|
import { withGLParameters } from "../../context/state-tracker/with-parameters.js";
|
|
4
3
|
import { convertTextureFormatToGL, getWebGLTextureParameters, getTextureFormatBytesPerPixel } from "../converters/texture-formats.js";
|
|
5
4
|
import { convertSamplerParametersToWebGL, updateSamplerParametersForNPOT } from "../converters/sampler-parameters.js";
|
|
@@ -36,7 +35,7 @@ export class WEBGLTexture extends Texture {
|
|
|
36
35
|
this.textureUnit = undefined;
|
|
37
36
|
this.loaded = false;
|
|
38
37
|
this._video = void 0;
|
|
39
|
-
this.device =
|
|
38
|
+
this.device = device;
|
|
40
39
|
this.gl = this.device.gl;
|
|
41
40
|
this.gl2 = this.device.gl2;
|
|
42
41
|
this.handle = this.props.handle || this.gl.createTexture();
|