@nativescript/canvas 2.0.0-webgpu.17 → 2.0.0-webgpu.19
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/WebGPU/GPUBuffer.js +9 -1
- package/WebGPU/GPUBuffer.js.map +1 -1
- package/WebGPU/GPUCanvasContext.js +14 -2
- package/WebGPU/GPUCanvasContext.js.map +1 -1
- package/WebGPU/GPUCommandEncoder.d.ts +2 -9
- package/WebGPU/GPUCommandEncoder.js +91 -41
- package/WebGPU/GPUCommandEncoder.js.map +1 -1
- package/WebGPU/GPUDevice.d.ts +9 -71
- package/WebGPU/GPUDevice.js +23 -108
- package/WebGPU/GPUDevice.js.map +1 -1
- package/WebGPU/GPUQueue.js +35 -8
- package/WebGPU/GPUQueue.js.map +1 -1
- package/WebGPU/Interfaces.d.ts +81 -1
- package/WebGPU/Types.d.ts +8 -1
- package/WebGPU/Utils.d.ts +14 -0
- package/WebGPU/Utils.js +211 -0
- package/WebGPU/Utils.js.map +1 -1
- package/package.json +1 -1
- package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +3 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +150 -25
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +3 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +3 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +656 -647
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +6 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +150 -25
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +3 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +3 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +150 -25
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +3 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +3 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +22 -22
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +656 -647
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +696 -687
- package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +3 -2
package/WebGPU/GPUBuffer.js
CHANGED
|
@@ -33,9 +33,17 @@ export class GPUBuffer {
|
|
|
33
33
|
return this[native_].getMappedRange(offset, rangeSize);
|
|
34
34
|
}
|
|
35
35
|
mapAsync(mode, offset, size) {
|
|
36
|
-
|
|
36
|
+
const previousSrc = this[mapState_];
|
|
37
|
+
this[mapState_] = 'pending';
|
|
38
|
+
return this[native_]
|
|
39
|
+
.mapAsync(mode, offset, size)
|
|
40
|
+
.then((value) => {
|
|
37
41
|
this[mapState_] = 'mapped';
|
|
38
42
|
return value;
|
|
43
|
+
})
|
|
44
|
+
.catch((e) => {
|
|
45
|
+
this[mapState_] = previousSrc;
|
|
46
|
+
throw e;
|
|
39
47
|
});
|
|
40
48
|
}
|
|
41
49
|
unmap() {
|
package/WebGPU/GPUBuffer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GPUBuffer.js","sourceRoot":"","sources":["../../../../packages/canvas/WebGPU/GPUBuffer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,OAAO,SAAS;IAAtB;QAEC,QAAW,GAAsC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"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,CAAC,GAAG,SAAS,CAAC;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC;aAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC;aAC5B,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,IAAI,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;YAC3B,OAAO,KAAK,CAAC;QACd,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACZ,IAAI,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC;YAC9B,MAAM,CAAC,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,mBAA4B,KAAK;QAC1D,IAAI,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC;YAC5B,GAAG,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC;YACtB,IAAI,gBAAgB,EAAE,CAAC;gBACtB,GAAG,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;YAC3B,CAAC;YACD,OAAO,GAAG,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;KApEC,SAAS"}
|
|
@@ -45,8 +45,20 @@ export class GPUCanvasContext {
|
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
47
|
if (!capabilities.alphaModes.includes(options.alphaMode) && (options.alphaMode === 'opaque' || options.alphaMode === 'premultiplied')) {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
if (__IOS__ && options.alphaMode === 'premultiplied') {
|
|
49
|
+
let index = capabilities.alphaModes.indexOf('premultiplied');
|
|
50
|
+
if (index === -1) {
|
|
51
|
+
index = capabilities.alphaModes.indexOf('postmultiplied');
|
|
52
|
+
}
|
|
53
|
+
if (index === -1) {
|
|
54
|
+
index = 0;
|
|
55
|
+
}
|
|
56
|
+
opts.alphaMode = capabilities.alphaModes[index];
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
opts.alphaMode = capabilities.alphaModes[0];
|
|
60
|
+
}
|
|
61
|
+
console.warn(`GPUCanvasContext: configure alphaMode ${options.alphaMode} unsupported falling back to ${opts.alphaMode}`);
|
|
50
62
|
}
|
|
51
63
|
}
|
|
52
64
|
if (__ANDROID__ && !capabilities.format.includes(options.format) && (options.format === 'bgra8unorm' || options.format === 'bgra8unorm-srgb')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GPUCanvasContext.js","sourceRoot":"","sources":["../../../../packages/canvas/WebGPU/GPUCanvasContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,OAAO,gBAAgB;IAU5B,YAAY,OAAY,EAAE,cAAc;QACvC,IAAI,aAAa,GAAG,GAAG,CAAC;QACxB,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACtB,aAAa,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,CAAC;QACvD,CAAC;QAED,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YAClB,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;QAClD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;QAC3E,IAAI,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC;QAC5B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ffer } from './GPUCommandBuffer';
|
|
|
4
4
|
import { GPUComputePassEncoder } from './GPUComputePassEncoder';
|
|
5
5
|
import { GPUQuerySet } from './GPUQuerySet';
|
|
6
6
|
import { GPURenderPassEncoder } from './GPURenderPassEncoder';
|
|
7
|
-
import { GPUImageCopyBuffer, GPUImageCopyTexture,
|
|
7
|
+
import { GPUImageCopyBuffer, GPUImageCopyTexture, GPURenderPassDescriptor } from './Interfaces';
|
|
8
8
|
import { GPUExtent3D } from './Types';
|
|
9
9
|
export declare class GPUCommandEncoder {
|
|
10
10
|
[native_]: any;
|
|
@@ -18,14 +18,7 @@ export declare class GPUCommandEncoder {
|
|
|
18
18
|
querySet: GPUQuerySet;
|
|
19
19
|
};
|
|
20
20
|
}): GPUComputePassEncoder;
|
|
21
|
-
beginRenderPass(descriptor:
|
|
22
|
-
colorAttachments: (null | GPURenderPassColorAttachment)[];
|
|
23
|
-
depthStencilAttachment?: GPURenderPassDepthStencilAttachment;
|
|
24
|
-
label?: string;
|
|
25
|
-
maxDrawCount?: number;
|
|
26
|
-
occlusionQuerySet?: GPUQuerySet;
|
|
27
|
-
timestampWrites?: GPURenderPassTimestampWrites;
|
|
28
|
-
}): GPURenderPassEncoder;
|
|
21
|
+
beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
|
|
29
22
|
clearBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
|
|
30
23
|
copyBufferToBuffer(source: GPUBuffer, sourceOffset: number, destination: GPUBuffer, destinationOffset: number, size: number): void;
|
|
31
24
|
copyBufferToTexture(source: GPUImageCopyBuffer, destination: GPUImageCopyTexture, copySize: GPUExtent3D): void;
|
|
@@ -2,6 +2,7 @@ import { native_ } from './Constants';
|
|
|
2
2
|
import { GPUCommandBuffer } from './GPUCommandBuffer';
|
|
3
3
|
import { GPUComputePassEncoder } from './GPUComputePassEncoder';
|
|
4
4
|
import { GPURenderPassEncoder } from './GPURenderPassEncoder';
|
|
5
|
+
import { parseComputePassDescriptor, parseRenderPassDescriptor } from './Utils';
|
|
5
6
|
export class GPUCommandEncoder {
|
|
6
7
|
get label() {
|
|
7
8
|
return this[native_]?.label ?? '';
|
|
@@ -15,37 +16,12 @@ export class GPUCommandEncoder {
|
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
17
18
|
beginComputePass(descriptor) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
return GPUComputePassEncoder.fromNative(this[native_].beginComputePass(descriptor));
|
|
19
|
+
const desc = parseComputePassDescriptor(descriptor);
|
|
20
|
+
return GPUComputePassEncoder.fromNative(this[native_].beginComputePass(desc));
|
|
22
21
|
}
|
|
23
22
|
beginRenderPass(descriptor) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
attachment.clearValue = { r: attachment.clearValue[0], g: attachment.clearValue[1], b: attachment.clearValue[2], a: attachment.clearValue[3] };
|
|
27
|
-
}
|
|
28
|
-
if (attachment.view) {
|
|
29
|
-
attachment.view = attachment.view[native_];
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
/// ???
|
|
33
|
-
}
|
|
34
|
-
if (attachment.resolveTarget) {
|
|
35
|
-
attachment.resolveTarget = attachment.resolveTarget[native_];
|
|
36
|
-
}
|
|
37
|
-
return attachment;
|
|
38
|
-
});
|
|
39
|
-
if (descriptor?.depthStencilAttachment?.view?.[native_]) {
|
|
40
|
-
descriptor.depthStencilAttachment.view = descriptor.depthStencilAttachment.view[native_];
|
|
41
|
-
}
|
|
42
|
-
if (descriptor?.occlusionQuerySet) {
|
|
43
|
-
descriptor.occlusionQuerySet = descriptor.occlusionQuerySet[native_];
|
|
44
|
-
}
|
|
45
|
-
if (descriptor?.timestampWrites?.querySet) {
|
|
46
|
-
descriptor.timestampWrites.querySet = descriptor.timestampWrites.querySet[native_];
|
|
47
|
-
}
|
|
48
|
-
const passEncoder = this[native_].beginRenderPass(descriptor);
|
|
23
|
+
const desc = parseRenderPassDescriptor(descriptor);
|
|
24
|
+
const passEncoder = this[native_].beginRenderPass(desc);
|
|
49
25
|
return GPURenderPassEncoder.fromNative(passEncoder);
|
|
50
26
|
}
|
|
51
27
|
clearBuffer(buffer, offset, size) {
|
|
@@ -55,40 +31,114 @@ export class GPUCommandEncoder {
|
|
|
55
31
|
this[native_].copyBufferToBuffer(source[native_], sourceOffset, destination[native_], destinationOffset, size);
|
|
56
32
|
}
|
|
57
33
|
copyBufferToTexture(source, destination, copySize) {
|
|
58
|
-
|
|
59
|
-
|
|
34
|
+
const src = {
|
|
35
|
+
buffer: source.buffer[native_],
|
|
36
|
+
bytesPerRow: source.bytesPerRow,
|
|
37
|
+
};
|
|
38
|
+
if (typeof source.offset === 'number') {
|
|
39
|
+
src.offset = source.offset;
|
|
40
|
+
}
|
|
41
|
+
if (typeof source.rowsPerImage === 'number') {
|
|
42
|
+
src.rowsPerImage = source.rowsPerImage;
|
|
43
|
+
}
|
|
44
|
+
const dst = {
|
|
45
|
+
texture: destination.texture[native_],
|
|
46
|
+
};
|
|
47
|
+
if (destination.aspect) {
|
|
48
|
+
dst.aspect = destination.aspect;
|
|
49
|
+
}
|
|
50
|
+
if (typeof destination.mipLevel === 'number') {
|
|
51
|
+
dst.mipLevel = destination.mipLevel;
|
|
52
|
+
}
|
|
53
|
+
if (destination.origin) {
|
|
54
|
+
dst.origin = destination.origin;
|
|
55
|
+
}
|
|
56
|
+
let size;
|
|
60
57
|
if (Array.isArray(copySize)) {
|
|
61
|
-
|
|
58
|
+
size = {
|
|
62
59
|
width: copySize[0],
|
|
63
60
|
height: copySize[1] ?? 1,
|
|
64
61
|
depthOrArrayLayers: copySize[2] ?? 1,
|
|
65
62
|
};
|
|
66
63
|
}
|
|
67
|
-
|
|
64
|
+
else {
|
|
65
|
+
size = { ...copySize };
|
|
66
|
+
}
|
|
67
|
+
this[native_].copyBufferToTexture(src, dst, size);
|
|
68
68
|
}
|
|
69
69
|
copyTextureToBuffer(source, destination, copySize) {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
const src = {
|
|
71
|
+
texture: source.texture[native_],
|
|
72
|
+
};
|
|
73
|
+
if (source.aspect) {
|
|
74
|
+
src.aspect = source.aspect;
|
|
75
|
+
}
|
|
76
|
+
if (typeof source.mipLevel === 'number') {
|
|
77
|
+
src.mipLevel = source.mipLevel;
|
|
78
|
+
}
|
|
79
|
+
if (source.origin) {
|
|
80
|
+
src.origin = source.origin;
|
|
81
|
+
}
|
|
82
|
+
const dst = {
|
|
83
|
+
buffer: destination.buffer[native_],
|
|
84
|
+
bytesPerRow: destination.bytesPerRow,
|
|
85
|
+
};
|
|
86
|
+
if (typeof destination.offset === 'number') {
|
|
87
|
+
dst.offset = destination.offset;
|
|
88
|
+
}
|
|
89
|
+
if (typeof destination.rowsPerImage === 'number') {
|
|
90
|
+
dst.rowsPerImage = destination.rowsPerImage;
|
|
91
|
+
}
|
|
92
|
+
let size;
|
|
72
93
|
if (Array.isArray(copySize)) {
|
|
73
|
-
|
|
94
|
+
size = {
|
|
74
95
|
width: copySize[0],
|
|
75
96
|
height: copySize[1] ?? 1,
|
|
76
97
|
depthOrArrayLayers: copySize[2] ?? 1,
|
|
77
98
|
};
|
|
78
99
|
}
|
|
79
|
-
|
|
100
|
+
else {
|
|
101
|
+
size = { ...copySize };
|
|
102
|
+
}
|
|
103
|
+
this[native_].copyTextureToBuffer(src, dst, size);
|
|
80
104
|
}
|
|
81
105
|
copyTextureToTexture(source, destination, copySize) {
|
|
82
|
-
|
|
83
|
-
|
|
106
|
+
const src = {
|
|
107
|
+
texture: source.texture[native_],
|
|
108
|
+
};
|
|
109
|
+
if (source.aspect) {
|
|
110
|
+
src.aspect = source.aspect;
|
|
111
|
+
}
|
|
112
|
+
if (typeof source.mipLevel === 'number') {
|
|
113
|
+
src.mipLevel = source.mipLevel;
|
|
114
|
+
}
|
|
115
|
+
if (source.origin) {
|
|
116
|
+
src.origin = source.origin;
|
|
117
|
+
}
|
|
118
|
+
const dst = {
|
|
119
|
+
texture: destination.texture[native_],
|
|
120
|
+
};
|
|
121
|
+
if (destination.aspect) {
|
|
122
|
+
dst.aspect = destination.aspect;
|
|
123
|
+
}
|
|
124
|
+
if (typeof destination.mipLevel === 'number') {
|
|
125
|
+
dst.mipLevel = destination.mipLevel;
|
|
126
|
+
}
|
|
127
|
+
if (destination.origin) {
|
|
128
|
+
dst.origin = destination.origin;
|
|
129
|
+
}
|
|
130
|
+
let size;
|
|
84
131
|
if (Array.isArray(copySize)) {
|
|
85
|
-
|
|
132
|
+
size = {
|
|
86
133
|
width: copySize[0],
|
|
87
134
|
height: copySize[1] ?? 1,
|
|
88
135
|
depthOrArrayLayers: copySize[2] ?? 1,
|
|
89
136
|
};
|
|
90
137
|
}
|
|
91
|
-
|
|
138
|
+
else {
|
|
139
|
+
size = { ...copySize };
|
|
140
|
+
}
|
|
141
|
+
this[native_].copyTextureToTexture(src, dst, size);
|
|
92
142
|
}
|
|
93
143
|
finish(descriptor) {
|
|
94
144
|
const ret = this[native_].finish(descriptor);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GPUCommandEncoder.js","sourceRoot":"","sources":["../../../../packages/canvas/WebGPU/GPUCommandEncoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"GPUCommandEncoder.js","sourceRoot":"","sources":["../../../../packages/canvas/WebGPU/GPUCommandEncoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,oBAA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kB;QACvD,IAAI,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC;IAC7D,CAAC;CACD"}
|
package/WebGPU/GPUDevice.d.ts
CHANGED
|
@@ -10,11 +10,9 @@ import { GPUCommandEncoder } from './GPUCommandEncoder';
|
|
|
10
10
|
import { GPUDeviceLostInfo } from './Errors';
|
|
11
11
|
import { GPUBindGroup } from './GPUBindGroup';
|
|
12
12
|
import { GPUBindGroupLayout } from './GPUBindGroupLayout';
|
|
13
|
-
import { GPUTextureView } from './GPUTextureView';
|
|
14
13
|
import { GPUSampler } from './GPUSampler';
|
|
15
|
-
import {
|
|
16
|
-
import type {
|
|
17
|
-
import type { GPUDepthStencilState, GPUExternalTextureBindingLayout, GPUFragmentState, GPUMultisampleState, GPUPrimitiveState, GPUProgrammableStage, GPUVertexState } from './Interfaces';
|
|
14
|
+
import type { GPUAddressMode, GPUCompareFunction, GPUErrorFilter, GPUFilterMode, GPUMipmapFilterMode, GPUQueryType, GPUTextureFormat } from './Types';
|
|
15
|
+
import type { GPUBindGroupDescriptor, GPUBindGroupLayoutEntry, GPUComputePipelineDescriptor, GPURenderPipelineDescriptor } from './Interfaces';
|
|
18
16
|
import { GPUComputePipeline } from './GPUComputePipeline';
|
|
19
17
|
import { GPUQuerySet } from './GPUQuerySet';
|
|
20
18
|
import { GPURenderBundleEncoder } from './GPURenderBundleEncoder';
|
|
@@ -44,44 +42,8 @@ export declare class GPUDevice extends EventTarget {
|
|
|
44
42
|
get limits(): any;
|
|
45
43
|
get features(): GPUSupportedFeatures;
|
|
46
44
|
destroy(): void;
|
|
47
|
-
createBindGroup(descriptor:
|
|
48
|
-
|
|
49
|
-
layout: GPUBindGroupLayout;
|
|
50
|
-
entries: {
|
|
51
|
-
binding: number;
|
|
52
|
-
resource: GPUTextureView | GPUSampler | GPUExternalTexture | {
|
|
53
|
-
buffer: GPUBuffer;
|
|
54
|
-
offset?: number;
|
|
55
|
-
size?: number;
|
|
56
|
-
};
|
|
57
|
-
}[];
|
|
58
|
-
}): GPUBindGroup;
|
|
59
|
-
createBindGroupLayout(descriptor: {
|
|
60
|
-
label?: string;
|
|
61
|
-
entries: {
|
|
62
|
-
binding: number;
|
|
63
|
-
visibility: number;
|
|
64
|
-
buffer?: {
|
|
65
|
-
hasDynamicOffset?: boolean;
|
|
66
|
-
minBindingSize?: number;
|
|
67
|
-
type?: 'uniform' | 'storage' | 'read-only-storage';
|
|
68
|
-
};
|
|
69
|
-
externalTexture?: GPUExternalTextureBindingLayout;
|
|
70
|
-
sampler?: {
|
|
71
|
-
type?: 'filtering' | 'non-filtering' | 'comparison';
|
|
72
|
-
};
|
|
73
|
-
storageTexture?: {
|
|
74
|
-
access?: 'write-only' | 'read-only' | 'read-write';
|
|
75
|
-
format: GPUTextureFormat;
|
|
76
|
-
viewDimension?: GPUTextureViewDimension;
|
|
77
|
-
};
|
|
78
|
-
texture?: {
|
|
79
|
-
multisampled?: boolean;
|
|
80
|
-
sampleType?: GPUTextureSampleType;
|
|
81
|
-
viewDimension?: GPUTextureViewDimension;
|
|
82
|
-
};
|
|
83
|
-
}[];
|
|
84
|
-
}): GPUBindGroupLayout;
|
|
45
|
+
createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
|
|
46
|
+
createBindGroupLayout(descriptor: GPUBindGroupLayoutEntry): GPUBindGroupLayout;
|
|
85
47
|
createBuffer(descriptor: {
|
|
86
48
|
label?: string;
|
|
87
49
|
mappedAtCreation?: boolean;
|
|
@@ -91,16 +53,8 @@ export declare class GPUDevice extends EventTarget {
|
|
|
91
53
|
createCommandEncoder(descriptor?: {
|
|
92
54
|
label?: string;
|
|
93
55
|
}): GPUCommandEncoder;
|
|
94
|
-
createComputePipeline(descriptor:
|
|
95
|
-
|
|
96
|
-
label?: string;
|
|
97
|
-
layout: GPUPipelineLayout | 'auto';
|
|
98
|
-
}): GPUComputePipeline;
|
|
99
|
-
createComputePipelineAsync(descriptor: {
|
|
100
|
-
compute: GPUProgrammableStage;
|
|
101
|
-
label?: string;
|
|
102
|
-
layout: GPUPipelineLayout | 'auto';
|
|
103
|
-
}): Promise<unknown>;
|
|
56
|
+
createComputePipeline(descriptor: GPUComputePipelineDescriptor): GPUComputePipeline;
|
|
57
|
+
createComputePipelineAsync(descriptor: GPUComputePipelineDescriptor): Promise<unknown>;
|
|
104
58
|
createPipelineLayout(descriptor: {
|
|
105
59
|
bindGroupLayouts: GPUBindGroupLayout[];
|
|
106
60
|
label?: string;
|
|
@@ -118,24 +72,8 @@ export declare class GPUDevice extends EventTarget {
|
|
|
118
72
|
sampleCount?: number;
|
|
119
73
|
stencilReadOnly?: boolean;
|
|
120
74
|
}): GPURenderBundleEncoder;
|
|
121
|
-
createRenderPipeline(descriptor:
|
|
122
|
-
|
|
123
|
-
fragment?: GPUFragmentState;
|
|
124
|
-
label?: string;
|
|
125
|
-
layout: GPUPipelineLayout | 'auto';
|
|
126
|
-
multisample?: GPUMultisampleState;
|
|
127
|
-
primitive?: GPUPrimitiveState;
|
|
128
|
-
vertex: GPUVertexState;
|
|
129
|
-
}): GPURenderPipeline;
|
|
130
|
-
createRenderPipelineAsync(descriptor: {
|
|
131
|
-
depthStencil?: GPUDepthStencilState;
|
|
132
|
-
fragment?: GPUFragmentState;
|
|
133
|
-
label?: string;
|
|
134
|
-
layout: GPUPipelineLayout | 'auto';
|
|
135
|
-
multisample?: GPUMultisampleState;
|
|
136
|
-
primitive?: GPUPrimitiveState;
|
|
137
|
-
vertex: GPUVertexState;
|
|
138
|
-
}): Promise<unknown>;
|
|
75
|
+
createRenderPipeline(descriptor: GPURenderPipelineDescriptor): GPURenderPipeline;
|
|
76
|
+
createRenderPipelineAsync(descriptor: GPURenderPipelineDescriptor): Promise<unknown>;
|
|
139
77
|
createSampler(descriptor?: {
|
|
140
78
|
addressModeU?: GPUAddressMode;
|
|
141
79
|
addressModeV?: GPUAddressMode;
|
|
@@ -149,7 +87,7 @@ export declare class GPUDevice extends EventTarget {
|
|
|
149
87
|
minFilter?: GPUFilterMode;
|
|
150
88
|
mipmapFilter?: GPUMipmapFilterMode;
|
|
151
89
|
}): GPUSampler;
|
|
152
|
-
createShaderModule(
|
|
90
|
+
createShaderModule(descriptor: {
|
|
153
91
|
label?: string;
|
|
154
92
|
code: string;
|
|
155
93
|
sourceMap?: object;
|
package/WebGPU/GPUDevice.js
CHANGED
|
@@ -5,15 +5,13 @@ import { adapter_, native_ } from './Constants';
|
|
|
5
5
|
import { GPUShaderModule } from './GPUShaderModule';
|
|
6
6
|
import { GPUQueue } from './GPUQueue';
|
|
7
7
|
import { GPUPipelineLayout } from './GPUPipelineLayout';
|
|
8
|
-
import {
|
|
8
|
+
import { parseBindGroupDescriptor, parseComputePipelineDescriptor, parseRenderPipelineDescriptor } from './Utils';
|
|
9
9
|
import { GPURenderPipeline } from './GPURenderPipeline';
|
|
10
10
|
import { GPUCommandEncoder } from './GPUCommandEncoder';
|
|
11
11
|
import { GPUDeviceLostInfo, GPUInternalError, GPUOutOfMemoryError, GPUValidationError } from './Errors';
|
|
12
12
|
import { GPUBindGroup } from './GPUBindGroup';
|
|
13
13
|
import { GPUBindGroupLayout } from './GPUBindGroupLayout';
|
|
14
|
-
import { GPUTextureView } from './GPUTextureView';
|
|
15
14
|
import { GPUSampler } from './GPUSampler';
|
|
16
|
-
import { GPUExternalTexture } from './GPUExternalTexture';
|
|
17
15
|
import { GPUComputePipeline } from './GPUComputePipeline';
|
|
18
16
|
import { GPUQuerySet } from './GPUQuerySet';
|
|
19
17
|
import { GPURenderBundleEncoder } from './GPURenderBundleEncoder';
|
|
@@ -32,6 +30,8 @@ function fixup_shader_code(code) {
|
|
|
32
30
|
code = code.replace(/alias\s+float([2-4])x([2-4])\s*=\s*mat\1x\2<\s*f32\s*>\s*;/gm, '');
|
|
33
31
|
// patch switch issue
|
|
34
32
|
code = code.replace(/case\s+(\d+)\s*:\s*{/g, 'case $1u: {');
|
|
33
|
+
// diagnostic is unsupport atm, remove after https://github.com/gfx-rs/wgpu/pull/6148
|
|
34
|
+
code = code.replace(/diagnostic\s*\([^)]*\)/g, '');
|
|
35
35
|
return code;
|
|
36
36
|
}
|
|
37
37
|
// Doing so because :D
|
|
@@ -175,28 +175,8 @@ export class GPUDevice extends EventTarget {
|
|
|
175
175
|
this.native.destroy();
|
|
176
176
|
}
|
|
177
177
|
createBindGroup(descriptor) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
descriptor.entries = descriptor.entries.map((entry) => {
|
|
181
|
-
var _a, _b;
|
|
182
|
-
if (entry.resource instanceof GPUTextureView) {
|
|
183
|
-
entry.resource = entry.resource[native_];
|
|
184
|
-
}
|
|
185
|
-
else if (entry.resource instanceof GPUSampler) {
|
|
186
|
-
entry.resource = entry.resource[native_];
|
|
187
|
-
}
|
|
188
|
-
else if (entry.resource instanceof GPUExternalTexture) {
|
|
189
|
-
entry.resource = entry.resource[native_];
|
|
190
|
-
}
|
|
191
|
-
else if (entry?.resource?.buffer && entry?.resource?.buffer instanceof GPUBuffer) {
|
|
192
|
-
entry.resource.buffer = entry.resource.buffer[native_];
|
|
193
|
-
(_a = entry.resource).offset ?? (_a.offset = 0);
|
|
194
|
-
(_b = entry.resource).size ?? (_b.size = entry.resource.buffer.size - entry.resource.offset);
|
|
195
|
-
}
|
|
196
|
-
return entry;
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
const group = this.native.createBindGroup(descriptor);
|
|
178
|
+
const desc = parseBindGroupDescriptor(descriptor);
|
|
179
|
+
const group = this.native.createBindGroup(desc);
|
|
200
180
|
if (group) {
|
|
201
181
|
return GPUBindGroup.fromNative(group);
|
|
202
182
|
}
|
|
@@ -221,19 +201,13 @@ export class GPUDevice extends EventTarget {
|
|
|
221
201
|
return GPUCommandEncoder.fromNative(encoder);
|
|
222
202
|
}
|
|
223
203
|
createComputePipeline(descriptor) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
descriptor.compute.module = descriptor.compute.module[native_];
|
|
228
|
-
return GPUComputePipeline.fromNative(this.native.createComputePipeline(descriptor));
|
|
204
|
+
const desc = parseComputePipelineDescriptor(descriptor);
|
|
205
|
+
return GPUComputePipeline.fromNative(this.native.createComputePipeline(desc));
|
|
229
206
|
}
|
|
230
207
|
createComputePipelineAsync(descriptor) {
|
|
231
208
|
return new Promise((resolve, reject) => {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
descriptor.compute.module = descriptor.compute.module[native_];
|
|
236
|
-
this.native.createComputePipelineAsync(descriptor, (error, pipeline) => {
|
|
209
|
+
const desc = parseComputePipelineDescriptor(descriptor);
|
|
210
|
+
this.native.createComputePipelineAsync(desc, (error, pipeline) => {
|
|
237
211
|
if (error) {
|
|
238
212
|
reject(error.error);
|
|
239
213
|
}
|
|
@@ -245,11 +219,13 @@ export class GPUDevice extends EventTarget {
|
|
|
245
219
|
}
|
|
246
220
|
createPipelineLayout(descriptor) {
|
|
247
221
|
const desc = {
|
|
248
|
-
label: descriptor.label,
|
|
249
222
|
bindGroupLayouts: descriptor.bindGroupLayouts.map((layout) => {
|
|
250
223
|
return layout[native_];
|
|
251
224
|
}),
|
|
252
225
|
};
|
|
226
|
+
if (typeof descriptor?.label === 'string') {
|
|
227
|
+
desc.label = descriptor.label;
|
|
228
|
+
}
|
|
253
229
|
return GPUPipelineLayout.fromNative(this.native.createPipelineLayout(desc));
|
|
254
230
|
}
|
|
255
231
|
createQuerySet(descriptor) {
|
|
@@ -260,57 +236,13 @@ export class GPUDevice extends EventTarget {
|
|
|
260
236
|
return GPURenderBundleEncoder.fromNative(this.native.createRenderBundleEncoder(descriptor));
|
|
261
237
|
}
|
|
262
238
|
createRenderPipeline(descriptor) {
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
const buffers = vertex?.buffers;
|
|
266
|
-
if (Array.isArray(buffers)) {
|
|
267
|
-
vertex.buffers = buffers.map((buffer) => {
|
|
268
|
-
buffer.attributes = buffer.attributes.map((attr) => {
|
|
269
|
-
attr.format = parseVertexFormat(attr.format);
|
|
270
|
-
return attr;
|
|
271
|
-
});
|
|
272
|
-
return buffer;
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
const fragment = descriptor.fragment;
|
|
276
|
-
if (fragment) {
|
|
277
|
-
handleUnsupportedPlatformFormat(fragment, 'createRenderPipeline');
|
|
278
|
-
fragment.module = fragment.module[native_];
|
|
279
|
-
}
|
|
280
|
-
const layout = descriptor.layout;
|
|
281
|
-
if (layout instanceof GPUPipelineLayout) {
|
|
282
|
-
descriptor.layout = descriptor.layout[native_];
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
}
|
|
286
|
-
return GPURenderPipeline.fromNative(this[native_].createRenderPipeline(descriptor));
|
|
239
|
+
const desc = parseRenderPipelineDescriptor(descriptor, 'createRenderPipeline');
|
|
240
|
+
return GPURenderPipeline.fromNative(this[native_].createRenderPipeline(desc));
|
|
287
241
|
}
|
|
288
242
|
createRenderPipelineAsync(descriptor) {
|
|
289
243
|
return new Promise((resolve, reject) => {
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
const buffers = vertex?.buffers;
|
|
293
|
-
if (Array.isArray(buffers)) {
|
|
294
|
-
vertex.buffers = buffers.map((buffer) => {
|
|
295
|
-
buffer.attributes = buffer.attributes.map((attr) => {
|
|
296
|
-
attr.format = parseVertexFormat(attr.format);
|
|
297
|
-
return attr;
|
|
298
|
-
});
|
|
299
|
-
return buffer;
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
const fragment = descriptor.fragment;
|
|
303
|
-
if (fragment) {
|
|
304
|
-
handleUnsupportedPlatformFormat(fragment, 'createRenderPipelineAsync');
|
|
305
|
-
fragment.module = fragment.module[native_];
|
|
306
|
-
}
|
|
307
|
-
const layout = descriptor.layout;
|
|
308
|
-
if (layout instanceof GPUPipelineLayout) {
|
|
309
|
-
descriptor.layout = descriptor.layout[native_];
|
|
310
|
-
}
|
|
311
|
-
else {
|
|
312
|
-
}
|
|
313
|
-
this[native_].createRenderPipelineAsync(descriptor, (error, pipeline) => {
|
|
244
|
+
const desc = parseRenderPipelineDescriptor(descriptor, 'createRenderPipelineAsync');
|
|
245
|
+
this[native_].createRenderPipelineAsync(desc, (error, pipeline) => {
|
|
314
246
|
if (error) {
|
|
315
247
|
reject(error.error);
|
|
316
248
|
}
|
|
@@ -323,8 +255,13 @@ export class GPUDevice extends EventTarget {
|
|
|
323
255
|
createSampler(descriptor) {
|
|
324
256
|
return GPUSampler.fromNative(this.native.createSampler(descriptor));
|
|
325
257
|
}
|
|
326
|
-
createShaderModule(
|
|
327
|
-
desc
|
|
258
|
+
createShaderModule(descriptor) {
|
|
259
|
+
const desc = {
|
|
260
|
+
code: fixup_shader_code(descriptor.code),
|
|
261
|
+
};
|
|
262
|
+
if (typeof descriptor.label === 'string') {
|
|
263
|
+
desc.label = descriptor.label;
|
|
264
|
+
}
|
|
328
265
|
const module = this.native.createShaderModule(desc);
|
|
329
266
|
if (module) {
|
|
330
267
|
return GPUShaderModule.fromNative(module);
|
|
@@ -398,26 +335,4 @@ export class GPUDevice extends EventTarget {
|
|
|
398
335
|
return this._queue;
|
|
399
336
|
}
|
|
400
337
|
}
|
|
401
|
-
function handleUnsupportedPlatformFormat(fragment, method) {
|
|
402
|
-
// falls back to platform supported format ... maybe this can be removed once frameworks use the getPreferredCanvasFormat
|
|
403
|
-
if (__ANDROID__) {
|
|
404
|
-
let hasBrga = false;
|
|
405
|
-
fragment.targets = fragment.targets.map((target) => {
|
|
406
|
-
switch (target.format) {
|
|
407
|
-
case 'bgra8unorm':
|
|
408
|
-
target.format = 'rgba8unorm';
|
|
409
|
-
hasBrga = true;
|
|
410
|
-
break;
|
|
411
|
-
case 'bgra8unorm-srgb':
|
|
412
|
-
target.format = 'rgba8unorm-srgb';
|
|
413
|
-
hasBrga = true;
|
|
414
|
-
break;
|
|
415
|
-
}
|
|
416
|
-
return target;
|
|
417
|
-
});
|
|
418
|
-
if (hasBrga) {
|
|
419
|
-
console.warn(`GPUDevice:${method} using unsupported brga format falling back to rgba counterpart.`);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
338
|
//# sourceMappingURL=GPUDevice.js.map
|