react-native-wgpu 0.1.21 → 0.1.23
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/apple/ApplePlatformContext.mm +6 -2
- package/apple/MetalView.h +1 -1
- package/apple/MetalView.mm +8 -9
- package/cpp/rnwgpu/SurfaceRegistry.h +1 -3
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +12 -27
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +28 -1
- package/cpp/rnwgpu/api/descriptors/Unions.h +277 -4
- package/lib/commonjs/Offscreen.js +6 -27
- package/lib/commonjs/Offscreen.js.map +1 -1
- package/lib/module/Offscreen.js +6 -27
- package/lib/module/Offscreen.js.map +1 -1
- package/lib/typescript/lib/commonjs/Offscreen.d.ts +2 -8
- package/lib/typescript/lib/commonjs/Offscreen.d.ts.map +1 -1
- package/lib/typescript/lib/module/Offscreen.d.ts +2 -8
- package/lib/typescript/lib/module/Offscreen.d.ts.map +1 -1
- package/lib/typescript/src/Offscreen.d.ts +4 -15
- package/lib/typescript/src/Offscreen.d.ts.map +1 -1
- package/lib/typescript/src/__tests__/components/Wireframe/models.d.ts +10 -10
- package/lib/typescript/src/__tests__/components/cube.d.ts +1 -1
- package/lib/typescript/src/__tests__/components/cube.d.ts.map +1 -1
- package/lib/typescript/src/__tests__/components/meshes/mesh.d.ts +3 -3
- package/lib/typescript/src/__tests__/components/meshes/mesh.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/Offscreen.ts +7 -58
- package/src/__tests__/GPU.spec.ts +70 -39
|
@@ -25,7 +25,9 @@ void checkIfUsingSimulatorWithAPIValidation() {
|
|
|
25
25
|
#endif
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
ApplePlatformContext::ApplePlatformContext() {
|
|
28
|
+
ApplePlatformContext::ApplePlatformContext() {
|
|
29
|
+
checkIfUsingSimulatorWithAPIValidation();
|
|
30
|
+
}
|
|
29
31
|
|
|
30
32
|
wgpu::Surface ApplePlatformContext::makeSurface(wgpu::Instance instance,
|
|
31
33
|
void *surface, int width,
|
|
@@ -62,7 +64,9 @@ ImageData ApplePlatformContext::createImageBitmap(std::string blobId,
|
|
|
62
64
|
#if !TARGET_OS_OSX
|
|
63
65
|
CGImageRef cgImage = image.CGImage;
|
|
64
66
|
#else
|
|
65
|
-
CGImageRef cgImage = [image CGImageForProposedRect:NULL
|
|
67
|
+
CGImageRef cgImage = [image CGImageForProposedRect:NULL
|
|
68
|
+
context:NULL
|
|
69
|
+
hints:NULL];
|
|
66
70
|
#endif
|
|
67
71
|
size_t width = CGImageGetWidth(cgImage);
|
|
68
72
|
size_t height = CGImageGetHeight(cgImage);
|
package/apple/MetalView.h
CHANGED
package/apple/MetalView.mm
CHANGED
|
@@ -13,15 +13,14 @@
|
|
|
13
13
|
+ (Class)layerClass {
|
|
14
14
|
return [CAMetalLayer class];
|
|
15
15
|
}
|
|
16
|
-
#else
|
|
17
|
-
- (instancetype)init
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return self;
|
|
16
|
+
#else // !TARGET_OS_OSX
|
|
17
|
+
- (instancetype)init {
|
|
18
|
+
self = [super init];
|
|
19
|
+
if (self) {
|
|
20
|
+
self.wantsLayer = true;
|
|
21
|
+
self.layer = [CAMetalLayer layer];
|
|
22
|
+
}
|
|
23
|
+
return self;
|
|
25
24
|
}
|
|
26
25
|
#endif // !TARGET_OS_OSX
|
|
27
26
|
|
|
@@ -24,9 +24,7 @@ public:
|
|
|
24
24
|
SurfaceInfo(wgpu::Instance gpu, int width, int height)
|
|
25
25
|
: gpu(std::move(gpu)), width(width), height(height) {}
|
|
26
26
|
|
|
27
|
-
~SurfaceInfo() {
|
|
28
|
-
surface = nullptr;
|
|
29
|
-
}
|
|
27
|
+
~SurfaceInfo() { surface = nullptr; }
|
|
30
28
|
|
|
31
29
|
void reconfigure(int newWidth, int newHeight) {
|
|
32
30
|
std::unique_lock<std::shared_mutex> lock(_mutex);
|
|
@@ -18,36 +18,18 @@ namespace m = margelo;
|
|
|
18
18
|
|
|
19
19
|
class GPUAdapterInfo : public m::HybridObject {
|
|
20
20
|
public:
|
|
21
|
-
explicit GPUAdapterInfo(wgpu::AdapterInfo &
|
|
22
|
-
: HybridObject("GPUAdapterInfo"),
|
|
21
|
+
explicit GPUAdapterInfo(wgpu::AdapterInfo &info)
|
|
22
|
+
: HybridObject("GPUAdapterInfo"), _vendor(info.vendor),
|
|
23
|
+
_architecture(info.architecture), _device(info.device),
|
|
24
|
+
_description(info.description) {}
|
|
23
25
|
|
|
24
26
|
public:
|
|
25
27
|
std::string getBrand() { return _name; }
|
|
26
28
|
|
|
27
|
-
std::string getVendor() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return "";
|
|
32
|
-
}
|
|
33
|
-
std::string getArchitecture() {
|
|
34
|
-
if (_instance.architecture.length) {
|
|
35
|
-
return _instance.architecture.data;
|
|
36
|
-
}
|
|
37
|
-
return "";
|
|
38
|
-
}
|
|
39
|
-
std::string getDevice() {
|
|
40
|
-
if (_instance.device.length) {
|
|
41
|
-
return _instance.device.data;
|
|
42
|
-
}
|
|
43
|
-
return "";
|
|
44
|
-
}
|
|
45
|
-
std::string getDescription() {
|
|
46
|
-
if (_instance.device.length) {
|
|
47
|
-
return _instance.device.data;
|
|
48
|
-
}
|
|
49
|
-
return "";
|
|
50
|
-
}
|
|
29
|
+
std::string getVendor() { return _vendor; }
|
|
30
|
+
std::string getArchitecture() { return _architecture; }
|
|
31
|
+
std::string getDevice() { return _device; }
|
|
32
|
+
std::string getDescription() { return _description; }
|
|
51
33
|
|
|
52
34
|
void loadHybridMethods() override {
|
|
53
35
|
registerHybridGetter("__brand", &GPUAdapterInfo::getBrand, this);
|
|
@@ -60,7 +42,10 @@ public:
|
|
|
60
42
|
}
|
|
61
43
|
|
|
62
44
|
private:
|
|
63
|
-
|
|
45
|
+
std::string _vendor;
|
|
46
|
+
std::string _architecture;
|
|
47
|
+
std::string _device;
|
|
48
|
+
std::string _description;
|
|
64
49
|
};
|
|
65
50
|
|
|
66
51
|
} // namespace rnwgpu
|
|
@@ -34,6 +34,33 @@ namespace margelo {
|
|
|
34
34
|
|
|
35
35
|
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
36
36
|
|
|
37
|
+
// We add this extra convertor because we found so library that are sending
|
|
38
|
+
// invalid feature elements
|
|
39
|
+
template <> struct JSIConverter<std::vector<wgpu::FeatureName>> {
|
|
40
|
+
|
|
41
|
+
static std::vector<wgpu::FeatureName>
|
|
42
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
43
|
+
jsi::Array array = arg.asObject(runtime).asArray(runtime);
|
|
44
|
+
size_t length = array.size(runtime);
|
|
45
|
+
|
|
46
|
+
std::vector<wgpu::FeatureName> vector;
|
|
47
|
+
vector.reserve(length);
|
|
48
|
+
for (size_t i = 0; i < length; ++i) {
|
|
49
|
+
jsi::Value elementValue = array.getValueAtIndex(runtime, i);
|
|
50
|
+
if (elementValue.isString()) {
|
|
51
|
+
vector.emplace_back(JSIConverter<wgpu::FeatureName>::fromJSI(
|
|
52
|
+
runtime, elementValue, outOfBounds));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return vector;
|
|
56
|
+
}
|
|
57
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
58
|
+
std::shared_ptr<rnwgpu::GPUDeviceDescriptor> arg) {
|
|
59
|
+
throw std::runtime_error(
|
|
60
|
+
"Invalid JSIConverter<std::vector<wgpu::FeatureName>>::toJSI()");
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
37
64
|
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUDeviceDescriptor>> {
|
|
38
65
|
static std::shared_ptr<rnwgpu::GPUDeviceDescriptor>
|
|
39
66
|
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
@@ -74,4 +101,4 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUDeviceDescriptor>> {
|
|
|
74
101
|
}
|
|
75
102
|
};
|
|
76
103
|
|
|
77
|
-
} // namespace margelo
|
|
104
|
+
} // namespace margelo
|
|
@@ -432,10 +432,118 @@ static void convertJSUnionToEnum(const std::string &inUnion,
|
|
|
432
432
|
*outEnum = wgpu::FeatureName::BGRA8UnormStorage;
|
|
433
433
|
} else if (inUnion == "float32-filterable") {
|
|
434
434
|
*outEnum = wgpu::FeatureName::Float32Filterable;
|
|
435
|
-
} else if (inUnion == "
|
|
436
|
-
*outEnum = wgpu::FeatureName::
|
|
435
|
+
} else if (inUnion == "subgroups") {
|
|
436
|
+
*outEnum = wgpu::FeatureName::Subgroups;
|
|
437
|
+
} else if (inUnion == "subgroups-f16") {
|
|
438
|
+
*outEnum = wgpu::FeatureName::SubgroupsF16;
|
|
439
|
+
} else if (inUnion == "dawn-internal-usages") {
|
|
440
|
+
*outEnum = wgpu::FeatureName::DawnInternalUsages;
|
|
441
|
+
} else if (inUnion == "dawn-multi-planar-formats") {
|
|
442
|
+
*outEnum = wgpu::FeatureName::DawnMultiPlanarFormats;
|
|
443
|
+
} else if (inUnion == "dawn-native") {
|
|
444
|
+
*outEnum = wgpu::FeatureName::DawnNative;
|
|
445
|
+
} else if (inUnion == "chromium-experimental-timestamp-query-inside-passes") {
|
|
446
|
+
*outEnum = wgpu::FeatureName::ChromiumExperimentalTimestampQueryInsidePasses;
|
|
447
|
+
} else if (inUnion == "implicit-device-synchronization") {
|
|
448
|
+
*outEnum = wgpu::FeatureName::ImplicitDeviceSynchronization;
|
|
449
|
+
} else if (inUnion == "transient-attachments") {
|
|
450
|
+
*outEnum = wgpu::FeatureName::TransientAttachments;
|
|
451
|
+
} else if (inUnion == "msaa-render-to-single-sampled") {
|
|
452
|
+
*outEnum = wgpu::FeatureName::MSAARenderToSingleSampled;
|
|
437
453
|
} else if (inUnion == "dual-source-blending") {
|
|
438
454
|
*outEnum = wgpu::FeatureName::DualSourceBlending;
|
|
455
|
+
} else if (inUnion == "d3d11-multithread-protected") {
|
|
456
|
+
*outEnum = wgpu::FeatureName::D3D11MultithreadProtected;
|
|
457
|
+
} else if (inUnion == "angle-texture-sharing") {
|
|
458
|
+
*outEnum = wgpu::FeatureName::ANGLETextureSharing;
|
|
459
|
+
} else if (inUnion == "chromium-experimental-subgroups") {
|
|
460
|
+
*outEnum = wgpu::FeatureName::ChromiumExperimentalSubgroups;
|
|
461
|
+
} else if (inUnion == "chromium-experimental-subgroup-uniform-control-flow") {
|
|
462
|
+
*outEnum = wgpu::FeatureName::ChromiumExperimentalSubgroupUniformControlFlow;
|
|
463
|
+
} else if (inUnion == "pixel-local-storage-coherent") {
|
|
464
|
+
*outEnum = wgpu::FeatureName::PixelLocalStorageCoherent;
|
|
465
|
+
} else if (inUnion == "pixel-local-storage-non-coherent") {
|
|
466
|
+
*outEnum = wgpu::FeatureName::PixelLocalStorageNonCoherent;
|
|
467
|
+
} else if (inUnion == "unorm16-texture-formats") {
|
|
468
|
+
*outEnum = wgpu::FeatureName::Unorm16TextureFormats;
|
|
469
|
+
} else if (inUnion == "snorm16-texture-formats") {
|
|
470
|
+
*outEnum = wgpu::FeatureName::Snorm16TextureFormats;
|
|
471
|
+
} else if (inUnion == "multi-planar-format-extended-usages") {
|
|
472
|
+
*outEnum = wgpu::FeatureName::MultiPlanarFormatExtendedUsages;
|
|
473
|
+
} else if (inUnion == "multi-planar-format-p010") {
|
|
474
|
+
*outEnum = wgpu::FeatureName::MultiPlanarFormatP010;
|
|
475
|
+
} else if (inUnion == "host-mapped-pointer") {
|
|
476
|
+
*outEnum = wgpu::FeatureName::HostMappedPointer;
|
|
477
|
+
} else if (inUnion == "multi-planar-render-targets") {
|
|
478
|
+
*outEnum = wgpu::FeatureName::MultiPlanarRenderTargets;
|
|
479
|
+
} else if (inUnion == "multi-planar-format-nv12a") {
|
|
480
|
+
*outEnum = wgpu::FeatureName::MultiPlanarFormatNv12a;
|
|
481
|
+
} else if (inUnion == "framebuffer-fetch") {
|
|
482
|
+
*outEnum = wgpu::FeatureName::FramebufferFetch;
|
|
483
|
+
} else if (inUnion == "buffer-map-extended-usages") {
|
|
484
|
+
*outEnum = wgpu::FeatureName::BufferMapExtendedUsages;
|
|
485
|
+
} else if (inUnion == "adapter-properties-memory-heaps") {
|
|
486
|
+
*outEnum = wgpu::FeatureName::AdapterPropertiesMemoryHeaps;
|
|
487
|
+
} else if (inUnion == "adapter-properties-d3d") {
|
|
488
|
+
*outEnum = wgpu::FeatureName::AdapterPropertiesD3D;
|
|
489
|
+
} else if (inUnion == "adapter-properties-vk") {
|
|
490
|
+
*outEnum = wgpu::FeatureName::AdapterPropertiesVk;
|
|
491
|
+
} else if (inUnion == "r8unorm-storage") {
|
|
492
|
+
*outEnum = wgpu::FeatureName::R8UnormStorage;
|
|
493
|
+
} else if (inUnion == "format-capabilities") {
|
|
494
|
+
*outEnum = wgpu::FeatureName::FormatCapabilities;
|
|
495
|
+
} else if (inUnion == "drm-format-capabilities") {
|
|
496
|
+
*outEnum = wgpu::FeatureName::DrmFormatCapabilities;
|
|
497
|
+
} else if (inUnion == "norm16-texture-formats") {
|
|
498
|
+
*outEnum = wgpu::FeatureName::Norm16TextureFormats;
|
|
499
|
+
} else if (inUnion == "multi-planar-format-nv16") {
|
|
500
|
+
*outEnum = wgpu::FeatureName::MultiPlanarFormatNv16;
|
|
501
|
+
} else if (inUnion == "multi-planar-format-nv24") {
|
|
502
|
+
*outEnum = wgpu::FeatureName::MultiPlanarFormatNv24;
|
|
503
|
+
} else if (inUnion == "multi-planar-format-p210") {
|
|
504
|
+
*outEnum = wgpu::FeatureName::MultiPlanarFormatP210;
|
|
505
|
+
} else if (inUnion == "multi-planar-format-p410") {
|
|
506
|
+
*outEnum = wgpu::FeatureName::MultiPlanarFormatP410;
|
|
507
|
+
} else if (inUnion == "shared-texture-memory-vk-dedicated-allocation") {
|
|
508
|
+
*outEnum = wgpu::FeatureName::SharedTextureMemoryVkDedicatedAllocation;
|
|
509
|
+
} else if (inUnion == "shared-texture-memory-ahardware-buffer") {
|
|
510
|
+
*outEnum = wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer;
|
|
511
|
+
} else if (inUnion == "shared-texture-memory-dma-buf") {
|
|
512
|
+
*outEnum = wgpu::FeatureName::SharedTextureMemoryDmaBuf;
|
|
513
|
+
} else if (inUnion == "shared-texture-memory-opaque-fd") {
|
|
514
|
+
*outEnum = wgpu::FeatureName::SharedTextureMemoryOpaqueFD;
|
|
515
|
+
} else if (inUnion == "shared-texture-memory-zircon-handle") {
|
|
516
|
+
*outEnum = wgpu::FeatureName::SharedTextureMemoryZirconHandle;
|
|
517
|
+
} else if (inUnion == "shared-texture-memory-dxgi-shared-handle") {
|
|
518
|
+
*outEnum = wgpu::FeatureName::SharedTextureMemoryDXGISharedHandle;
|
|
519
|
+
} else if (inUnion == "shared-texture-memory-d3d11-texture2d") {
|
|
520
|
+
*outEnum = wgpu::FeatureName::SharedTextureMemoryD3D11Texture2D;
|
|
521
|
+
} else if (inUnion == "shared-texture-memory-iosurface") {
|
|
522
|
+
*outEnum = wgpu::FeatureName::SharedTextureMemoryIOSurface;
|
|
523
|
+
} else if (inUnion == "shared-texture-memory-egl-image") {
|
|
524
|
+
*outEnum = wgpu::FeatureName::SharedTextureMemoryEGLImage;
|
|
525
|
+
} else if (inUnion == "shared-fence-vk-semaphore-opaque-fd") {
|
|
526
|
+
*outEnum = wgpu::FeatureName::SharedFenceVkSemaphoreOpaqueFD;
|
|
527
|
+
} else if (inUnion == "shared-fence-vk-semaphore-sync-fd") {
|
|
528
|
+
*outEnum = wgpu::FeatureName::SharedFenceVkSemaphoreSyncFD;
|
|
529
|
+
} else if (inUnion == "shared-fence-vk-semaphore-zircon-handle") {
|
|
530
|
+
*outEnum = wgpu::FeatureName::SharedFenceVkSemaphoreZirconHandle;
|
|
531
|
+
} else if (inUnion == "shared-fence-dxgi-shared-handle") {
|
|
532
|
+
*outEnum = wgpu::FeatureName::SharedFenceDXGISharedHandle;
|
|
533
|
+
} else if (inUnion == "shared-fence-mtl-shared-event") {
|
|
534
|
+
*outEnum = wgpu::FeatureName::SharedFenceMTLSharedEvent;
|
|
535
|
+
} else if (inUnion == "shared-buffer-memory-d3d12-resource") {
|
|
536
|
+
*outEnum = wgpu::FeatureName::SharedBufferMemoryD3D12Resource;
|
|
537
|
+
} else if (inUnion == "static-samplers") {
|
|
538
|
+
*outEnum = wgpu::FeatureName::StaticSamplers;
|
|
539
|
+
} else if (inUnion == "ycbcr-vulkan-samplers") {
|
|
540
|
+
*outEnum = wgpu::FeatureName::YCbCrVulkanSamplers;
|
|
541
|
+
} else if (inUnion == "shader-module-compilation-options") {
|
|
542
|
+
*outEnum = wgpu::FeatureName::ShaderModuleCompilationOptions;
|
|
543
|
+
} else if (inUnion == "dawn-load-resolve-texture") {
|
|
544
|
+
*outEnum = wgpu::FeatureName::DawnLoadResolveTexture;
|
|
545
|
+
} else if (inUnion == "clip-distances") {
|
|
546
|
+
*outEnum = wgpu::FeatureName::ClipDistances;
|
|
439
547
|
} else {
|
|
440
548
|
throw invalidUnion(inUnion);
|
|
441
549
|
}
|
|
@@ -477,12 +585,177 @@ static void convertEnumToJSUnion(wgpu::FeatureName inEnum,
|
|
|
477
585
|
case wgpu::FeatureName::Float32Filterable:
|
|
478
586
|
*outUnion = "float32-filterable";
|
|
479
587
|
break;
|
|
480
|
-
case wgpu::FeatureName::
|
|
481
|
-
*outUnion = "
|
|
588
|
+
case wgpu::FeatureName::Subgroups:
|
|
589
|
+
*outUnion = "subgroups";
|
|
590
|
+
break;
|
|
591
|
+
case wgpu::FeatureName::SubgroupsF16:
|
|
592
|
+
*outUnion = "subgroups-f16";
|
|
593
|
+
break;
|
|
594
|
+
case wgpu::FeatureName::DawnInternalUsages:
|
|
595
|
+
*outUnion = "dawn-internal-usages";
|
|
596
|
+
break;
|
|
597
|
+
case wgpu::FeatureName::DawnMultiPlanarFormats:
|
|
598
|
+
*outUnion = "dawn-multi-planar-formats";
|
|
599
|
+
break;
|
|
600
|
+
case wgpu::FeatureName::DawnNative:
|
|
601
|
+
*outUnion = "dawn-native";
|
|
602
|
+
break;
|
|
603
|
+
case wgpu::FeatureName::ChromiumExperimentalTimestampQueryInsidePasses:
|
|
604
|
+
*outUnion = "chromium-experimental-timestamp-query-inside-passes";
|
|
605
|
+
break;
|
|
606
|
+
case wgpu::FeatureName::ImplicitDeviceSynchronization:
|
|
607
|
+
*outUnion = "implicit-device-synchronization";
|
|
608
|
+
break;
|
|
609
|
+
// case wgpu::FeatureName::SurfaceCapabilities:
|
|
610
|
+
// *outUnion = "surface-capabilities";
|
|
611
|
+
// break;
|
|
612
|
+
case wgpu::FeatureName::TransientAttachments:
|
|
613
|
+
*outUnion = "transient-attachments";
|
|
614
|
+
break;
|
|
615
|
+
case wgpu::FeatureName::MSAARenderToSingleSampled:
|
|
616
|
+
*outUnion = "msaa-render-to-single-sampled";
|
|
482
617
|
break;
|
|
483
618
|
case wgpu::FeatureName::DualSourceBlending:
|
|
484
619
|
*outUnion = "dual-source-blending";
|
|
485
620
|
break;
|
|
621
|
+
case wgpu::FeatureName::D3D11MultithreadProtected:
|
|
622
|
+
*outUnion = "d3d11-multithread-protected";
|
|
623
|
+
break;
|
|
624
|
+
case wgpu::FeatureName::ANGLETextureSharing:
|
|
625
|
+
*outUnion = "angle-texture-sharing";
|
|
626
|
+
break;
|
|
627
|
+
case wgpu::FeatureName::ChromiumExperimentalSubgroups:
|
|
628
|
+
*outUnion = "chromium-experimental-subgroups";
|
|
629
|
+
break;
|
|
630
|
+
case wgpu::FeatureName::ChromiumExperimentalSubgroupUniformControlFlow:
|
|
631
|
+
*outUnion = "chromium-experimental-subgroup-uniform-control-flow";
|
|
632
|
+
break;
|
|
633
|
+
case wgpu::FeatureName::PixelLocalStorageCoherent:
|
|
634
|
+
*outUnion = "pixel-local-storage-coherent";
|
|
635
|
+
break;
|
|
636
|
+
case wgpu::FeatureName::PixelLocalStorageNonCoherent:
|
|
637
|
+
*outUnion = "pixel-local-storage-non-coherent";
|
|
638
|
+
break;
|
|
639
|
+
case wgpu::FeatureName::Unorm16TextureFormats:
|
|
640
|
+
*outUnion = "unorm16-texture-formats";
|
|
641
|
+
break;
|
|
642
|
+
case wgpu::FeatureName::Snorm16TextureFormats:
|
|
643
|
+
*outUnion = "snorm16-texture-formats";
|
|
644
|
+
break;
|
|
645
|
+
case wgpu::FeatureName::MultiPlanarFormatExtendedUsages:
|
|
646
|
+
*outUnion = "multi-planar-format-extended-usages";
|
|
647
|
+
break;
|
|
648
|
+
case wgpu::FeatureName::MultiPlanarFormatP010:
|
|
649
|
+
*outUnion = "multi-planar-format-p010";
|
|
650
|
+
break;
|
|
651
|
+
case wgpu::FeatureName::HostMappedPointer:
|
|
652
|
+
*outUnion = "host-mapped-pointer";
|
|
653
|
+
break;
|
|
654
|
+
case wgpu::FeatureName::MultiPlanarRenderTargets:
|
|
655
|
+
*outUnion = "multi-planar-render-targets";
|
|
656
|
+
break;
|
|
657
|
+
case wgpu::FeatureName::MultiPlanarFormatNv12a:
|
|
658
|
+
*outUnion = "multi-planar-format-nv12a";
|
|
659
|
+
break;
|
|
660
|
+
case wgpu::FeatureName::FramebufferFetch:
|
|
661
|
+
*outUnion = "framebuffer-fetch";
|
|
662
|
+
break;
|
|
663
|
+
case wgpu::FeatureName::BufferMapExtendedUsages:
|
|
664
|
+
*outUnion = "buffer-map-extended-usages";
|
|
665
|
+
break;
|
|
666
|
+
case wgpu::FeatureName::AdapterPropertiesMemoryHeaps:
|
|
667
|
+
*outUnion = "adapter-properties-memory-heaps";
|
|
668
|
+
break;
|
|
669
|
+
case wgpu::FeatureName::AdapterPropertiesD3D:
|
|
670
|
+
*outUnion = "adapter-properties-d3d";
|
|
671
|
+
break;
|
|
672
|
+
case wgpu::FeatureName::AdapterPropertiesVk:
|
|
673
|
+
*outUnion = "adapter-properties-vk";
|
|
674
|
+
break;
|
|
675
|
+
case wgpu::FeatureName::R8UnormStorage:
|
|
676
|
+
*outUnion = "r8unorm-storage";
|
|
677
|
+
break;
|
|
678
|
+
case wgpu::FeatureName::FormatCapabilities:
|
|
679
|
+
*outUnion = "format-capabilities";
|
|
680
|
+
break;
|
|
681
|
+
case wgpu::FeatureName::DrmFormatCapabilities:
|
|
682
|
+
*outUnion = "drm-format-capabilities";
|
|
683
|
+
break;
|
|
684
|
+
case wgpu::FeatureName::Norm16TextureFormats:
|
|
685
|
+
*outUnion = "norm16-texture-formats";
|
|
686
|
+
break;
|
|
687
|
+
case wgpu::FeatureName::MultiPlanarFormatNv16:
|
|
688
|
+
*outUnion = "multi-planar-format-nv16";
|
|
689
|
+
break;
|
|
690
|
+
case wgpu::FeatureName::MultiPlanarFormatNv24:
|
|
691
|
+
*outUnion = "multi-planar-format-nv24";
|
|
692
|
+
break;
|
|
693
|
+
case wgpu::FeatureName::MultiPlanarFormatP210:
|
|
694
|
+
*outUnion = "multi-planar-format-p210";
|
|
695
|
+
break;
|
|
696
|
+
case wgpu::FeatureName::MultiPlanarFormatP410:
|
|
697
|
+
*outUnion = "multi-planar-format-p410";
|
|
698
|
+
break;
|
|
699
|
+
case wgpu::FeatureName::SharedTextureMemoryVkDedicatedAllocation:
|
|
700
|
+
*outUnion = "shared-texture-memory-vk-dedicated-allocation";
|
|
701
|
+
break;
|
|
702
|
+
case wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer:
|
|
703
|
+
*outUnion = "shared-texture-memory-ahardware-buffer";
|
|
704
|
+
break;
|
|
705
|
+
case wgpu::FeatureName::SharedTextureMemoryDmaBuf:
|
|
706
|
+
*outUnion = "shared-texture-memory-dma-buf";
|
|
707
|
+
break;
|
|
708
|
+
case wgpu::FeatureName::SharedTextureMemoryOpaqueFD:
|
|
709
|
+
*outUnion = "shared-texture-memory-opaque-fd";
|
|
710
|
+
break;
|
|
711
|
+
case wgpu::FeatureName::SharedTextureMemoryZirconHandle:
|
|
712
|
+
*outUnion = "shared-texture-memory-zircon-handle";
|
|
713
|
+
break;
|
|
714
|
+
case wgpu::FeatureName::SharedTextureMemoryDXGISharedHandle:
|
|
715
|
+
*outUnion = "shared-texture-memory-dxgi-shared-handle";
|
|
716
|
+
break;
|
|
717
|
+
case wgpu::FeatureName::SharedTextureMemoryD3D11Texture2D:
|
|
718
|
+
*outUnion = "shared-texture-memory-d3d11-texture2d";
|
|
719
|
+
break;
|
|
720
|
+
case wgpu::FeatureName::SharedTextureMemoryIOSurface:
|
|
721
|
+
*outUnion = "shared-texture-memory-iosurface";
|
|
722
|
+
break;
|
|
723
|
+
case wgpu::FeatureName::SharedTextureMemoryEGLImage:
|
|
724
|
+
*outUnion = "shared-texture-memory-egl-image";
|
|
725
|
+
break;
|
|
726
|
+
case wgpu::FeatureName::SharedFenceVkSemaphoreOpaqueFD:
|
|
727
|
+
*outUnion = "shared-fence-vk-semaphore-opaque-fd";
|
|
728
|
+
break;
|
|
729
|
+
case wgpu::FeatureName::SharedFenceVkSemaphoreSyncFD:
|
|
730
|
+
*outUnion = "shared-fence-vk-semaphore-sync-fd";
|
|
731
|
+
break;
|
|
732
|
+
case wgpu::FeatureName::SharedFenceVkSemaphoreZirconHandle:
|
|
733
|
+
*outUnion = "shared-fence-vk-semaphore-zircon-handle";
|
|
734
|
+
break;
|
|
735
|
+
case wgpu::FeatureName::SharedFenceDXGISharedHandle:
|
|
736
|
+
*outUnion = "shared-fence-dxgi-shared-handle";
|
|
737
|
+
break;
|
|
738
|
+
case wgpu::FeatureName::SharedFenceMTLSharedEvent:
|
|
739
|
+
*outUnion = "shared-fence-mtl-shared-event";
|
|
740
|
+
break;
|
|
741
|
+
case wgpu::FeatureName::SharedBufferMemoryD3D12Resource:
|
|
742
|
+
*outUnion = "shared-buffer-memory-d3d12-resource";
|
|
743
|
+
break;
|
|
744
|
+
case wgpu::FeatureName::StaticSamplers:
|
|
745
|
+
*outUnion = "static-samplers";
|
|
746
|
+
break;
|
|
747
|
+
case wgpu::FeatureName::YCbCrVulkanSamplers:
|
|
748
|
+
*outUnion = "ycbcr-vulkan-samplers";
|
|
749
|
+
break;
|
|
750
|
+
case wgpu::FeatureName::ShaderModuleCompilationOptions:
|
|
751
|
+
*outUnion = "shader-module-compilation-options";
|
|
752
|
+
break;
|
|
753
|
+
case wgpu::FeatureName::DawnLoadResolveTexture:
|
|
754
|
+
*outUnion = "dawn-load-resolve-texture";
|
|
755
|
+
break;
|
|
756
|
+
case wgpu::FeatureName::ClipDistances:
|
|
757
|
+
*outUnion = "clip-distances";
|
|
758
|
+
break;
|
|
486
759
|
default:
|
|
487
760
|
throw invalidEnum(inEnum);
|
|
488
761
|
}
|
|
@@ -4,45 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.GPUOffscreenCanvas = void 0;
|
|
7
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
7
|
class GPUOffscreenCanvas {
|
|
9
|
-
oncontextlost = null;
|
|
10
|
-
oncontextrestored = null;
|
|
11
8
|
constructor(width, height) {
|
|
12
9
|
this.width = width;
|
|
13
10
|
this.height = height;
|
|
14
11
|
this.context = new GPUOffscreenCanvasContext(this);
|
|
15
12
|
}
|
|
16
|
-
|
|
17
|
-
// Implementation for converting the canvas content to a Blob
|
|
18
|
-
throw new Error("Method not implemented.");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Overloaded method signatures
|
|
22
|
-
|
|
23
|
-
getContext(contextId, _options) {
|
|
13
|
+
getContext(contextId) {
|
|
24
14
|
if (contextId === "webgpu") {
|
|
25
15
|
return this.context;
|
|
26
16
|
}
|
|
27
17
|
// Implement other context types if necessary
|
|
28
18
|
return null;
|
|
29
19
|
}
|
|
30
|
-
transferToImageBitmap() {
|
|
31
|
-
// Implementation for transferring the canvas content to an ImageBitmap
|
|
32
|
-
throw new Error("Method not implemented.");
|
|
33
|
-
}
|
|
34
|
-
addEventListener(_type, _listener, _options) {
|
|
35
|
-
// Event listener implementation
|
|
36
|
-
throw new Error("Method not implemented.");
|
|
37
|
-
}
|
|
38
|
-
removeEventListener(_type, _listener, _options) {
|
|
39
|
-
// Remove event listener implementation
|
|
40
|
-
throw new Error("Method not implemented.");
|
|
41
|
-
}
|
|
42
|
-
dispatchEvent(_event) {
|
|
43
|
-
// Event dispatch implementation
|
|
44
|
-
throw new Error("Method not implemented.");
|
|
45
|
-
}
|
|
46
20
|
getImageData() {
|
|
47
21
|
const device = this.context.getDevice();
|
|
48
22
|
const texture = this.context.getTexture();
|
|
@@ -78,10 +52,15 @@ class GPUOffscreenCanvasContext {
|
|
|
78
52
|
__brand = "GPUCanvasContext";
|
|
79
53
|
texture = null;
|
|
80
54
|
device = null;
|
|
55
|
+
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
57
|
constructor(canvas) {
|
|
82
58
|
this.canvas = canvas;
|
|
83
59
|
this.textureFormat = navigator.gpu.getPreferredCanvasFormat();
|
|
84
60
|
}
|
|
61
|
+
getConfiguration() {
|
|
62
|
+
throw new Error("Method not implemented.");
|
|
63
|
+
}
|
|
85
64
|
present() {
|
|
86
65
|
// Do nothing
|
|
87
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GPUOffscreenCanvas","
|
|
1
|
+
{"version":3,"names":["GPUOffscreenCanvas","constructor","width","height","context","GPUOffscreenCanvasContext","getContext","contextId","getImageData","device","getDevice","texture","getTexture","commandEncoder","createCommandEncoder","bytesPerRow","buffer","createBuffer","size","usage","GPUBufferUsage","COPY_DST","MAP_READ","copyTextureToBuffer","queue","submit","finish","mapAsync","GPUMapMode","READ","then","arrayBuffer","getMappedRange","uint8Array","Uint8Array","data","Array","from","unmap","format","navigator","gpu","getPreferredCanvasFormat","exports","__brand","canvas","textureFormat","getConfiguration","Error","present","configure","config","createTexture","GPUTextureUsage","RENDER_ATTACHMENT","COPY_SRC","TEXTURE_BINDING","undefined","unconfigure","destroy","getCurrentTexture"],"sourceRoot":"../../src","sources":["Offscreen.ts"],"mappings":"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","ignoreList":[]}
|
package/lib/module/Offscreen.js
CHANGED
|
@@ -1,42 +1,16 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
export class GPUOffscreenCanvas {
|
|
3
|
-
oncontextlost = null;
|
|
4
|
-
oncontextrestored = null;
|
|
5
2
|
constructor(width, height) {
|
|
6
3
|
this.width = width;
|
|
7
4
|
this.height = height;
|
|
8
5
|
this.context = new GPUOffscreenCanvasContext(this);
|
|
9
6
|
}
|
|
10
|
-
|
|
11
|
-
// Implementation for converting the canvas content to a Blob
|
|
12
|
-
throw new Error("Method not implemented.");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Overloaded method signatures
|
|
16
|
-
|
|
17
|
-
getContext(contextId, _options) {
|
|
7
|
+
getContext(contextId) {
|
|
18
8
|
if (contextId === "webgpu") {
|
|
19
9
|
return this.context;
|
|
20
10
|
}
|
|
21
11
|
// Implement other context types if necessary
|
|
22
12
|
return null;
|
|
23
13
|
}
|
|
24
|
-
transferToImageBitmap() {
|
|
25
|
-
// Implementation for transferring the canvas content to an ImageBitmap
|
|
26
|
-
throw new Error("Method not implemented.");
|
|
27
|
-
}
|
|
28
|
-
addEventListener(_type, _listener, _options) {
|
|
29
|
-
// Event listener implementation
|
|
30
|
-
throw new Error("Method not implemented.");
|
|
31
|
-
}
|
|
32
|
-
removeEventListener(_type, _listener, _options) {
|
|
33
|
-
// Remove event listener implementation
|
|
34
|
-
throw new Error("Method not implemented.");
|
|
35
|
-
}
|
|
36
|
-
dispatchEvent(_event) {
|
|
37
|
-
// Event dispatch implementation
|
|
38
|
-
throw new Error("Method not implemented.");
|
|
39
|
-
}
|
|
40
14
|
getImageData() {
|
|
41
15
|
const device = this.context.getDevice();
|
|
42
16
|
const texture = this.context.getTexture();
|
|
@@ -71,10 +45,15 @@ class GPUOffscreenCanvasContext {
|
|
|
71
45
|
__brand = "GPUCanvasContext";
|
|
72
46
|
texture = null;
|
|
73
47
|
device = null;
|
|
48
|
+
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
50
|
constructor(canvas) {
|
|
75
51
|
this.canvas = canvas;
|
|
76
52
|
this.textureFormat = navigator.gpu.getPreferredCanvasFormat();
|
|
77
53
|
}
|
|
54
|
+
getConfiguration() {
|
|
55
|
+
throw new Error("Method not implemented.");
|
|
56
|
+
}
|
|
78
57
|
present() {
|
|
79
58
|
// Do nothing
|
|
80
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GPUOffscreenCanvas","
|
|
1
|
+
{"version":3,"names":["GPUOffscreenCanvas","constructor","width","height","context","GPUOffscreenCanvasContext","getContext","contextId","getImageData","device","getDevice","texture","getTexture","commandEncoder","createCommandEncoder","bytesPerRow","buffer","createBuffer","size","usage","GPUBufferUsage","COPY_DST","MAP_READ","copyTextureToBuffer","queue","submit","finish","mapAsync","GPUMapMode","READ","then","arrayBuffer","getMappedRange","uint8Array","Uint8Array","data","Array","from","unmap","format","navigator","gpu","getPreferredCanvasFormat","__brand","canvas","textureFormat","getConfiguration","Error","present","configure","config","createTexture","GPUTextureUsage","RENDER_ATTACHMENT","COPY_SRC","TEXTURE_BINDING","undefined","unconfigure","destroy","getCurrentTexture"],"sourceRoot":"../../src","sources":["Offscreen.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
export const __esModule: boolean;
|
|
2
2
|
export class GPUOffscreenCanvas {
|
|
3
3
|
constructor(width: any, height: any);
|
|
4
|
-
oncontextlost: null;
|
|
5
|
-
oncontextrestored: null;
|
|
6
4
|
width: any;
|
|
7
5
|
height: any;
|
|
8
6
|
context: GPUOffscreenCanvasContext;
|
|
9
|
-
|
|
10
|
-
getContext(contextId: any, _options: any): GPUOffscreenCanvasContext | null;
|
|
11
|
-
transferToImageBitmap(): void;
|
|
12
|
-
addEventListener(_type: any, _listener: any, _options: any): void;
|
|
13
|
-
removeEventListener(_type: any, _listener: any, _options: any): void;
|
|
14
|
-
dispatchEvent(_event: any): void;
|
|
7
|
+
getContext(contextId: any): GPUOffscreenCanvasContext | null;
|
|
15
8
|
getImageData(): any;
|
|
16
9
|
}
|
|
17
10
|
declare class GPUOffscreenCanvasContext {
|
|
@@ -21,6 +14,7 @@ declare class GPUOffscreenCanvasContext {
|
|
|
21
14
|
device: null;
|
|
22
15
|
canvas: any;
|
|
23
16
|
textureFormat: GPUTextureFormat;
|
|
17
|
+
getConfiguration(): void;
|
|
24
18
|
present(): void;
|
|
25
19
|
getDevice(): never;
|
|
26
20
|
getTexture(): never;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Offscreen.d.ts","sourceRoot":"","sources":["../../../commonjs/Offscreen.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Offscreen.d.ts","sourceRoot":"","sources":["../../../commonjs/Offscreen.js"],"names":[],"mappings":";AAMA;IACE,qCAIC;IAHC,WAAkB;IAClB,YAAoB;IACpB,mCAAkD;IAEpD,6DAMC;IACD,oBA4BC;CACF;AAED;IAME,yBAGC;IARD,gBAA6B;IAC7B,cAAe;IACf,aAAc;IAIZ,YAAoB;IACpB,gCAA6D;IAE/D,yBAEC;IACD,gBAEC;IACD,mBAKC;IACD,oBAKC;IACD,kCASC;IACD,yBAMC;IACD,2BAKC;CACF"}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
export class GPUOffscreenCanvas {
|
|
2
2
|
constructor(width: any, height: any);
|
|
3
|
-
oncontextlost: null;
|
|
4
|
-
oncontextrestored: null;
|
|
5
3
|
width: any;
|
|
6
4
|
height: any;
|
|
7
5
|
context: GPUOffscreenCanvasContext;
|
|
8
|
-
|
|
9
|
-
getContext(contextId: any, _options: any): GPUOffscreenCanvasContext | null;
|
|
10
|
-
transferToImageBitmap(): void;
|
|
11
|
-
addEventListener(_type: any, _listener: any, _options: any): void;
|
|
12
|
-
removeEventListener(_type: any, _listener: any, _options: any): void;
|
|
13
|
-
dispatchEvent(_event: any): void;
|
|
6
|
+
getContext(contextId: any): GPUOffscreenCanvasContext | null;
|
|
14
7
|
getImageData(): any;
|
|
15
8
|
}
|
|
16
9
|
declare class GPUOffscreenCanvasContext {
|
|
@@ -20,6 +13,7 @@ declare class GPUOffscreenCanvasContext {
|
|
|
20
13
|
device: null;
|
|
21
14
|
canvas: any;
|
|
22
15
|
textureFormat: GPUTextureFormat;
|
|
16
|
+
getConfiguration(): void;
|
|
23
17
|
present(): void;
|
|
24
18
|
getDevice(): never;
|
|
25
19
|
getTexture(): never;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Offscreen.d.ts","sourceRoot":"","sources":["../../../module/Offscreen.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Offscreen.d.ts","sourceRoot":"","sources":["../../../module/Offscreen.js"],"names":[],"mappings":"AAAA;IACE,qCAIC;IAHC,WAAkB;IAClB,YAAoB;IACpB,mCAAkD;IAEpD,6DAMC;IACD,oBA4BC;CACF;AACD;IAME,yBAGC;IARD,gBAA6B;IAC7B,cAAe;IACf,aAAc;IAIZ,YAAoB;IACpB,gCAA6D;IAE/D,yBAEC;IACD,gBAEC;IACD,mBAKC;IACD,oBAKC;IACD,kCASC;IACD,yBAMC;IACD,2BAKC;CACF"}
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
export declare class GPUOffscreenCanvas
|
|
1
|
+
export declare class GPUOffscreenCanvas {
|
|
2
2
|
width: number;
|
|
3
3
|
height: number;
|
|
4
|
-
oncontextlost: ((this: OffscreenCanvas, ev: Event) => any) | null;
|
|
5
|
-
oncontextrestored: ((this: OffscreenCanvas, ev: Event) => any) | null;
|
|
6
4
|
private context;
|
|
7
5
|
constructor(width: number, height: number);
|
|
8
|
-
convertToBlob(_options?: ImageEncodeOptions): Promise<Blob>;
|
|
9
|
-
getContext(contextId: "2d", options?: any): OffscreenCanvasRenderingContext2D | null;
|
|
10
|
-
getContext(contextId: "bitmaprenderer", options?: any): ImageBitmapRenderingContext | null;
|
|
11
|
-
getContext(contextId: "webgl", options?: any): WebGLRenderingContext | null;
|
|
12
|
-
getContext(contextId: "webgl2", options?: any): WebGL2RenderingContext | null;
|
|
13
|
-
getContext(contextId: OffscreenRenderingContextId, options?: any): OffscreenRenderingContext | null;
|
|
14
6
|
getContext(contextId: "webgpu"): GPUOffscreenCanvasContext | null;
|
|
15
|
-
transferToImageBitmap(): ImageBitmap;
|
|
16
|
-
addEventListener<K extends keyof OffscreenCanvasEventMap>(_type: K, _listener: (this: OffscreenCanvas, ev: OffscreenCanvasEventMap[K]) => any, _options?: boolean | AddEventListenerOptions): void;
|
|
17
|
-
removeEventListener<K extends keyof OffscreenCanvasEventMap>(_type: K, _listener: (this: OffscreenCanvas, ev: OffscreenCanvasEventMap[K]) => any, _options?: boolean | EventListenerOptions): void;
|
|
18
|
-
dispatchEvent(_event: Event): boolean;
|
|
19
7
|
getImageData(): Promise<{
|
|
20
8
|
data: number[];
|
|
21
9
|
width: number;
|
|
@@ -24,12 +12,13 @@ export declare class GPUOffscreenCanvas implements OffscreenCanvas {
|
|
|
24
12
|
}>;
|
|
25
13
|
}
|
|
26
14
|
declare class GPUOffscreenCanvasContext implements GPUCanvasContext {
|
|
27
|
-
readonly canvas:
|
|
15
|
+
readonly canvas: any;
|
|
28
16
|
__brand: "GPUCanvasContext";
|
|
29
17
|
private textureFormat;
|
|
30
18
|
private texture;
|
|
31
19
|
private device;
|
|
32
|
-
constructor(canvas:
|
|
20
|
+
constructor(canvas: any);
|
|
21
|
+
getConfiguration(): GPUCanvasConfigurationOut | null;
|
|
33
22
|
present(): void;
|
|
34
23
|
getDevice(): GPUDevice;
|
|
35
24
|
getTexture(): GPUTexture;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Offscreen.d.ts","sourceRoot":"","sources":["../../../src/Offscreen.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Offscreen.d.ts","sourceRoot":"","sources":["../../../src/Offscreen.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAkB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,CAAC,OAAO,CAA4B;gBAE/B,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAMzC,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,yBAAyB,GAAG,IAAI;IAQjE,YAAY;;;;;;CA6Bb;AAED,cAAM,yBAA0B,YAAW,gBAAgB;aAQ7B,MAAM,EAAE,GAAG;IAPvC,OAAO,EAAG,kBAAkB,CAAU;IAEtC,OAAO,CAAC,aAAa,CAAmB;IACxC,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,MAAM,CAA0B;gBAGZ,MAAM,EAAE,GAAG;IAGvC,gBAAgB,IAAI,yBAAyB,GAAG,IAAI;IAIpD,OAAO;IAIP,SAAS;IAOT,UAAU;IAOV,SAAS,CAAC,MAAM,EAAE,sBAAsB;IAcxC,WAAW;IAQX,iBAAiB,IAAI,UAAU;CAMhC"}
|
|
@@ -4,25 +4,25 @@ type Mesh = {
|
|
|
4
4
|
normals: [number, number, number][];
|
|
5
5
|
};
|
|
6
6
|
export declare function convertMeshToTypedArrays(mesh: Mesh, scale: number, offset?: number[]): {
|
|
7
|
-
vertices: Float32Array
|
|
8
|
-
indices: Uint32Array
|
|
7
|
+
vertices: Float32Array<ArrayBuffer>;
|
|
8
|
+
indices: Uint32Array<ArrayBuffer>;
|
|
9
9
|
};
|
|
10
10
|
export declare const modelData: {
|
|
11
11
|
teapot: {
|
|
12
|
-
vertices: Float32Array
|
|
13
|
-
indices: Uint32Array
|
|
12
|
+
vertices: Float32Array<ArrayBuffer>;
|
|
13
|
+
indices: Uint32Array<ArrayBuffer>;
|
|
14
14
|
};
|
|
15
15
|
sphere: {
|
|
16
|
-
vertices: Float32Array
|
|
17
|
-
indices: Uint32Array
|
|
16
|
+
vertices: Float32Array<ArrayBuffer>;
|
|
17
|
+
indices: Uint32Array<ArrayBuffer>;
|
|
18
18
|
};
|
|
19
19
|
jewel: {
|
|
20
|
-
vertices: Float32Array
|
|
21
|
-
indices: Uint32Array
|
|
20
|
+
vertices: Float32Array<ArrayBuffer>;
|
|
21
|
+
indices: Uint32Array<ArrayBuffer>;
|
|
22
22
|
};
|
|
23
23
|
rock: {
|
|
24
|
-
vertices: Float32Array
|
|
25
|
-
indices: Uint32Array
|
|
24
|
+
vertices: Float32Array<ArrayBuffer>;
|
|
25
|
+
indices: Uint32Array<ArrayBuffer>;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
export {};
|
|
@@ -3,5 +3,5 @@ export declare const cubePositionOffset = 0;
|
|
|
3
3
|
export declare const cubeColorOffset: number;
|
|
4
4
|
export declare const cubeUVOffset: number;
|
|
5
5
|
export declare const cubeVertexCount = 36;
|
|
6
|
-
export declare const cubeVertexArray: Float32Array
|
|
6
|
+
export declare const cubeVertexArray: Float32Array<ArrayBuffer>;
|
|
7
7
|
//# sourceMappingURL=cube.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cube.d.ts","sourceRoot":"","sources":["../../../../../src/__tests__/components/cube.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,QAAS,CAAC;AACrC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,eAAe,QAAQ,CAAC;AACrC,eAAO,MAAM,YAAY,QAAQ,CAAC;AAClC,eAAO,MAAM,eAAe,KAAK,CAAC;AAGlC,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"cube.d.ts","sourceRoot":"","sources":["../../../../../src/__tests__/components/cube.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,QAAS,CAAC;AACrC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,eAAe,QAAQ,CAAC;AACrC,eAAO,MAAM,YAAY,QAAQ,CAAC;AAClC,eAAO,MAAM,eAAe,KAAK,CAAC;AAGlC,eAAO,MAAM,eAAe,2BA2C1B,CAAC"}
|
|
@@ -16,7 +16,7 @@ export interface Mesh {
|
|
|
16
16
|
* @returns {boolean} An object containing an array of bindGroups and the bindGroupLayout they implement.
|
|
17
17
|
*/
|
|
18
18
|
export declare const createMeshRenderable: (device: GPUDevice, mesh: Mesh, storeVertices?: boolean, storeIndices?: boolean) => Renderable;
|
|
19
|
-
export declare const getMeshPosAtIndex: (mesh: Mesh, index: number) => Float32Array
|
|
20
|
-
export declare const getMeshNormalAtIndex: (mesh: Mesh, index: number) => Float32Array
|
|
21
|
-
export declare const getMeshUVAtIndex: (mesh: Mesh, index: number) => Float32Array
|
|
19
|
+
export declare const getMeshPosAtIndex: (mesh: Mesh, index: number) => Float32Array<ArrayBufferLike>;
|
|
20
|
+
export declare const getMeshNormalAtIndex: (mesh: Mesh, index: number) => Float32Array<ArrayBufferLike>;
|
|
21
|
+
export declare const getMeshUVAtIndex: (mesh: Mesh, index: number) => Float32Array<ArrayBufferLike>;
|
|
22
22
|
//# sourceMappingURL=mesh.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh.d.ts","sourceRoot":"","sources":["../../../../../../src/__tests__/components/meshes/mesh.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,SAAS,CAAC;IACxB,WAAW,EAAE,SAAS,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,YAAY,CAAC;CAC1B;AAED,MAAM,WAAW,IAAI;IACnB,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,WAAW,GAAG,WAAW,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,WACvB,SAAS,QACX,IAAI,sDAGT,UAyCF,CAAC;AAEF,eAAO,MAAM,iBAAiB,SAAU,IAAI,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"mesh.d.ts","sourceRoot":"","sources":["../../../../../../src/__tests__/components/meshes/mesh.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,SAAS,CAAC;IACxB,WAAW,EAAE,SAAS,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,YAAY,CAAC;CAC1B;AAED,MAAM,WAAW,IAAI;IACnB,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,WAAW,GAAG,WAAW,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,WACvB,SAAS,QACX,IAAI,sDAGT,UAyCF,CAAC;AAEF,eAAO,MAAM,iBAAiB,SAAU,IAAI,SAAS,MAAM,kCAO1D,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAAU,IAAI,SAAS,MAAM,kCAO7D,CAAC;AAEF,eAAO,MAAM,gBAAgB,SAAU,IAAI,SAAS,MAAM,kCAOzD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-wgpu",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"description": "React Native WebGPU",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@types/ws": "^8.5.10",
|
|
66
66
|
"@typescript-eslint/eslint-plugin": "^8.4.0",
|
|
67
67
|
"@typescript-eslint/parser": "^8.4.0",
|
|
68
|
-
"@webgpu/types": "0.1.
|
|
68
|
+
"@webgpu/types": "0.1.51",
|
|
69
69
|
"clang-format": "^1.8.0",
|
|
70
70
|
"del-cli": "^5.1.0",
|
|
71
71
|
"eslint": "8",
|
package/src/Offscreen.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export class GPUOffscreenCanvas implements OffscreenCanvas {
|
|
1
|
+
export class GPUOffscreenCanvas {
|
|
3
2
|
width: number;
|
|
4
3
|
height: number;
|
|
5
|
-
oncontextlost: ((this: OffscreenCanvas, ev: Event) => any) | null = null;
|
|
6
|
-
oncontextrestored: ((this: OffscreenCanvas, ev: Event) => any) | null = null;
|
|
7
4
|
|
|
8
5
|
private context: GPUOffscreenCanvasContext;
|
|
9
6
|
|
|
@@ -13,31 +10,7 @@ export class GPUOffscreenCanvas implements OffscreenCanvas {
|
|
|
13
10
|
this.context = new GPUOffscreenCanvasContext(this);
|
|
14
11
|
}
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
// Implementation for converting the canvas content to a Blob
|
|
18
|
-
throw new Error("Method not implemented.");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Overloaded method signatures
|
|
22
|
-
getContext(
|
|
23
|
-
contextId: "2d",
|
|
24
|
-
options?: any,
|
|
25
|
-
): OffscreenCanvasRenderingContext2D | null;
|
|
26
|
-
getContext(
|
|
27
|
-
contextId: "bitmaprenderer",
|
|
28
|
-
options?: any,
|
|
29
|
-
): ImageBitmapRenderingContext | null;
|
|
30
|
-
getContext(contextId: "webgl", options?: any): WebGLRenderingContext | null;
|
|
31
|
-
getContext(contextId: "webgl2", options?: any): WebGL2RenderingContext | null;
|
|
32
|
-
getContext(
|
|
33
|
-
contextId: OffscreenRenderingContextId,
|
|
34
|
-
options?: any,
|
|
35
|
-
): OffscreenRenderingContext | null;
|
|
36
|
-
getContext(contextId: "webgpu"): GPUOffscreenCanvasContext | null;
|
|
37
|
-
getContext(
|
|
38
|
-
contextId: unknown,
|
|
39
|
-
_options?: any,
|
|
40
|
-
): OffscreenRenderingContext | GPUOffscreenCanvasContext | null {
|
|
13
|
+
getContext(contextId: "webgpu"): GPUOffscreenCanvasContext | null {
|
|
41
14
|
if (contextId === "webgpu") {
|
|
42
15
|
return this.context;
|
|
43
16
|
}
|
|
@@ -45,34 +18,6 @@ export class GPUOffscreenCanvas implements OffscreenCanvas {
|
|
|
45
18
|
return null;
|
|
46
19
|
}
|
|
47
20
|
|
|
48
|
-
transferToImageBitmap(): ImageBitmap {
|
|
49
|
-
// Implementation for transferring the canvas content to an ImageBitmap
|
|
50
|
-
throw new Error("Method not implemented.");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
addEventListener<K extends keyof OffscreenCanvasEventMap>(
|
|
54
|
-
_type: K,
|
|
55
|
-
_listener: (this: OffscreenCanvas, ev: OffscreenCanvasEventMap[K]) => any,
|
|
56
|
-
_options?: boolean | AddEventListenerOptions,
|
|
57
|
-
): void {
|
|
58
|
-
// Event listener implementation
|
|
59
|
-
throw new Error("Method not implemented.");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
removeEventListener<K extends keyof OffscreenCanvasEventMap>(
|
|
63
|
-
_type: K,
|
|
64
|
-
_listener: (this: OffscreenCanvas, ev: OffscreenCanvasEventMap[K]) => any,
|
|
65
|
-
_options?: boolean | EventListenerOptions,
|
|
66
|
-
): void {
|
|
67
|
-
// Remove event listener implementation
|
|
68
|
-
throw new Error("Method not implemented.");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
dispatchEvent(_event: Event): boolean {
|
|
72
|
-
// Event dispatch implementation
|
|
73
|
-
throw new Error("Method not implemented.");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
21
|
getImageData() {
|
|
77
22
|
const device = this.context.getDevice();
|
|
78
23
|
const texture = this.context.getTexture();
|
|
@@ -111,9 +56,13 @@ class GPUOffscreenCanvasContext implements GPUCanvasContext {
|
|
|
111
56
|
private texture: GPUTexture | null = null;
|
|
112
57
|
private device: GPUDevice | null = null;
|
|
113
58
|
|
|
114
|
-
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
constructor(public readonly canvas: any) {
|
|
115
61
|
this.textureFormat = navigator.gpu.getPreferredCanvasFormat();
|
|
116
62
|
}
|
|
63
|
+
getConfiguration(): GPUCanvasConfigurationOut | null {
|
|
64
|
+
throw new Error("Method not implemented.");
|
|
65
|
+
}
|
|
117
66
|
|
|
118
67
|
present() {
|
|
119
68
|
// Do nothing
|
|
@@ -52,6 +52,26 @@ describe("Adapter", () => {
|
|
|
52
52
|
});
|
|
53
53
|
expect(result).toBe(true);
|
|
54
54
|
});
|
|
55
|
+
it("requestAdapter (6)", async () => {
|
|
56
|
+
const result = await client.eval(({ gpu }) => {
|
|
57
|
+
return gpu.requestAdapter().then((adapter) => {
|
|
58
|
+
if (!adapter) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
vendor: adapter.info.vendor,
|
|
63
|
+
architecture: adapter.info.architecture,
|
|
64
|
+
device: adapter.info.device,
|
|
65
|
+
description: adapter.info.description,
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
expect(result).toBeDefined();
|
|
70
|
+
expect(result!.vendor).toBeDefined();
|
|
71
|
+
expect(result!.architecture).toBeDefined();
|
|
72
|
+
expect(result!.device).toBeDefined();
|
|
73
|
+
expect(result!.description).toBeDefined();
|
|
74
|
+
});
|
|
55
75
|
it("isFallback", async () => {
|
|
56
76
|
const result = await client.eval(({ adapter }) => {
|
|
57
77
|
return adapter.isFallbackAdapter;
|
|
@@ -66,32 +86,60 @@ describe("Adapter", () => {
|
|
|
66
86
|
expect(result.includes("rg11b10ufloat-renderable")).toBe(true);
|
|
67
87
|
expect(result.includes("texture-compression-etc2")).toBe(true);
|
|
68
88
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
it("requiredLimits", async () => {
|
|
90
|
+
const result = await client.eval(({ adapter }) => {
|
|
91
|
+
return adapter
|
|
92
|
+
.requestDevice({
|
|
93
|
+
requiredLimits: {
|
|
94
|
+
maxBufferSize: 1024 * 1024 * 4,
|
|
95
|
+
},
|
|
96
|
+
})
|
|
97
|
+
.then((device) => !!device);
|
|
98
|
+
});
|
|
99
|
+
expect(result).toBe(true);
|
|
100
|
+
});
|
|
101
|
+
it("request device with timestamp queries", async () => {
|
|
102
|
+
const result = await client.eval(({ adapter }) => {
|
|
103
|
+
if (adapter.features.has("timestamp-query")) {
|
|
104
|
+
return adapter
|
|
105
|
+
.requestDevice({
|
|
106
|
+
requiredFeatures: ["timestamp-query"],
|
|
107
|
+
})
|
|
108
|
+
.then((device) => device.features.has("timestamp-query"));
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
});
|
|
112
|
+
expect(result).toBe(true);
|
|
113
|
+
});
|
|
114
|
+
it("request device faulty input", async () => {
|
|
115
|
+
const result = await client.eval(({ adapter }) => {
|
|
116
|
+
return adapter
|
|
117
|
+
.requestDevice({
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
119
|
+
// @ts-expect-error
|
|
120
|
+
requiredFeatures: [["bgra8unorm-storage"]],
|
|
121
|
+
requiredLimits: {
|
|
122
|
+
maxComputeWorkgroupStorageSize: 16352,
|
|
123
|
+
maxComputeWorkgroupsPerDimension: 65535,
|
|
124
|
+
maxStorageBufferBindingSize: 268435456,
|
|
125
|
+
maxBufferSize: 268435456,
|
|
126
|
+
maxComputeWorkgroupSizeX: 512,
|
|
127
|
+
maxComputeInvocationsPerWorkgroup: 512,
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
.then((device) => !!device);
|
|
131
|
+
});
|
|
132
|
+
expect(result).toBe(true);
|
|
133
|
+
});
|
|
134
|
+
// it("request device with unknown feature", async () => {
|
|
89
135
|
// const result = await client.eval(({ adapter }) => {
|
|
90
136
|
// return adapter
|
|
91
137
|
// .requestDevice({
|
|
92
|
-
//
|
|
138
|
+
// // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
139
|
+
// // @ts-expect-error
|
|
140
|
+
// requiredFeatures: ["foobar"],
|
|
93
141
|
// })
|
|
94
|
-
// .
|
|
142
|
+
// .catch(() => true);
|
|
95
143
|
// });
|
|
96
144
|
// expect(result).toBe(true);
|
|
97
145
|
// });
|
|
@@ -120,7 +168,6 @@ describe("Adapter", () => {
|
|
|
120
168
|
maxBufferSize,
|
|
121
169
|
maxVertexAttributes,
|
|
122
170
|
maxVertexBufferArrayStride,
|
|
123
|
-
maxInterStageShaderComponents,
|
|
124
171
|
maxInterStageShaderVariables,
|
|
125
172
|
maxColorAttachments,
|
|
126
173
|
maxColorAttachmentBytesPerSample,
|
|
@@ -155,7 +202,6 @@ describe("Adapter", () => {
|
|
|
155
202
|
maxBufferSize,
|
|
156
203
|
maxVertexAttributes,
|
|
157
204
|
maxVertexBufferArrayStride,
|
|
158
|
-
maxInterStageShaderComponents,
|
|
159
205
|
maxInterStageShaderVariables,
|
|
160
206
|
maxColorAttachments,
|
|
161
207
|
maxColorAttachmentBytesPerSample,
|
|
@@ -194,21 +240,6 @@ describe("Adapter", () => {
|
|
|
194
240
|
expect(result.maxTextureDimension2D).toBeGreaterThanOrEqual(2048);
|
|
195
241
|
expect(result.maxTextureDimension3D).toBeGreaterThanOrEqual(256);
|
|
196
242
|
});
|
|
197
|
-
// it("adapter info", async () => {
|
|
198
|
-
// const result = await client.eval(({ adapter }) => {
|
|
199
|
-
// return {
|
|
200
|
-
// __brand: adapter.info.__brand,
|
|
201
|
-
// description: adapter.info.description,
|
|
202
|
-
// architecture: adapter.info.architecture,
|
|
203
|
-
// device: adapter.info.device,
|
|
204
|
-
// vendor: adapter.info.vendor,
|
|
205
|
-
// };
|
|
206
|
-
// });
|
|
207
|
-
// expect(result.description).toBeTruthy();
|
|
208
|
-
// expect(result.architecture).toBeTruthy();
|
|
209
|
-
// expect(result.device).toBeTruthy();
|
|
210
|
-
// expect(result.vendor).toBeTruthy();
|
|
211
|
-
// });
|
|
212
243
|
it("getPreferredCanvasFormat", async () => {
|
|
213
244
|
const result = await client.eval(({ gpu }) => {
|
|
214
245
|
return gpu.getPreferredCanvasFormat();
|