33#include " GPU.h"
44#include " RNWebGPU.h"
55
6+ // GPU API classes (for instanceof support)
7+ #include " GPUAdapter.h"
8+ #include " GPUAdapterInfo.h"
9+ #include " GPUBindGroup.h"
10+ #include " GPUBindGroupLayout.h"
11+ #include " GPUBuffer.h"
12+ #include " GPUCanvasContext.h"
13+ #include " GPUCommandBuffer.h"
14+ #include " GPUCommandEncoder.h"
15+ #include " GPUCompilationInfo.h"
16+ #include " GPUCompilationMessage.h"
17+ #include " GPUComputePassEncoder.h"
18+ #include " GPUComputePipeline.h"
19+ #include " GPUDevice.h"
20+ #include " GPUDeviceLostInfo.h"
21+ #include " GPUExternalTexture.h"
22+ #include " GPUPipelineLayout.h"
23+ #include " GPUQuerySet.h"
24+ #include " GPUQueue.h"
25+ #include " GPURenderBundle.h"
26+ #include " GPURenderBundleEncoder.h"
27+ #include " GPURenderPassEncoder.h"
28+ #include " GPURenderPipeline.h"
29+ #include " GPUSampler.h"
30+ #include " GPUShaderModule.h"
31+ #include " GPUSupportedLimits.h"
32+ #include " GPUTexture.h"
33+ #include " GPUTextureView.h"
34+
635// Enums
736#include " GPUBufferUsage.h"
837#include " GPUColorWrite.h"
@@ -28,29 +57,47 @@ RNWebGPUManager::RNWebGPUManager(
2857 _jsRuntime->global ().setProperty (*_jsRuntime, " RNWebGPU" ,
2958 RNWebGPU::create (*_jsRuntime, rnWebGPU));
3059
31- auto bufferUsage = std::make_shared<GPUBufferUsage>();
32- _jsRuntime->global ().setProperty (
33- *_jsRuntime, " GPUBufferUsage" ,
34- GPUBufferUsage::create (*_jsRuntime, std::move (bufferUsage)));
35-
36- auto colorWrite = std::make_shared<GPUColorWrite>();
37- _jsRuntime->global ().setProperty (
38- *_jsRuntime, " GPUColorWrite" ,
39- GPUColorWrite::create (*_jsRuntime, std::move (colorWrite)));
60+ // Install constructors for instanceof support
61+ GPU::installConstructor (*_jsRuntime);
62+ GPUAdapter::installConstructor (*_jsRuntime);
63+ GPUAdapterInfo::installConstructor (*_jsRuntime);
64+ GPUBindGroup::installConstructor (*_jsRuntime);
65+ GPUBindGroupLayout::installConstructor (*_jsRuntime);
66+ GPUBuffer::installConstructor (*_jsRuntime);
67+ GPUCanvasContext::installConstructor (*_jsRuntime);
68+ GPUCommandBuffer::installConstructor (*_jsRuntime);
69+ GPUCommandEncoder::installConstructor (*_jsRuntime);
70+ GPUCompilationInfo::installConstructor (*_jsRuntime);
71+ GPUCompilationMessage::installConstructor (*_jsRuntime);
72+ GPUComputePassEncoder::installConstructor (*_jsRuntime);
73+ GPUComputePipeline::installConstructor (*_jsRuntime);
74+ GPUDevice::installConstructor (*_jsRuntime);
75+ GPUDeviceLostInfo::installConstructor (*_jsRuntime);
76+ GPUExternalTexture::installConstructor (*_jsRuntime);
77+ GPUPipelineLayout::installConstructor (*_jsRuntime);
78+ GPUQuerySet::installConstructor (*_jsRuntime);
79+ GPUQueue::installConstructor (*_jsRuntime);
80+ GPURenderBundle::installConstructor (*_jsRuntime);
81+ GPURenderBundleEncoder::installConstructor (*_jsRuntime);
82+ GPURenderPassEncoder::installConstructor (*_jsRuntime);
83+ GPURenderPipeline::installConstructor (*_jsRuntime);
84+ GPUSampler::installConstructor (*_jsRuntime);
85+ GPUShaderModule::installConstructor (*_jsRuntime);
86+ GPUSupportedLimits::installConstructor (*_jsRuntime);
87+ GPUTexture::installConstructor (*_jsRuntime);
88+ GPUTextureView::installConstructor (*_jsRuntime);
4089
41- auto mapMode = std::make_shared<GPUMapMode>();
90+ // Install constant objects as plain JS objects with own properties
91+ _jsRuntime->global ().setProperty (*_jsRuntime, " GPUBufferUsage" ,
92+ GPUBufferUsage::create (*_jsRuntime));
93+ _jsRuntime->global ().setProperty (*_jsRuntime, " GPUColorWrite" ,
94+ GPUColorWrite::create (*_jsRuntime));
4295 _jsRuntime->global ().setProperty (*_jsRuntime, " GPUMapMode" ,
43- GPUMapMode::create (*_jsRuntime, mapMode));
44-
45- auto shaderStage = std::make_shared<GPUShaderStage>();
46- _jsRuntime->global ().setProperty (
47- *_jsRuntime, " GPUShaderStage" ,
48- GPUShaderStage::create (*_jsRuntime, std::move (shaderStage)));
49-
50- auto textureUsage = std::make_shared<GPUTextureUsage>();
51- _jsRuntime->global ().setProperty (
52- *_jsRuntime, " GPUTextureUsage" ,
53- GPUTextureUsage::create (*_jsRuntime, std::move (textureUsage)));
96+ GPUMapMode::create (*_jsRuntime));
97+ _jsRuntime->global ().setProperty (*_jsRuntime, " GPUShaderStage" ,
98+ GPUShaderStage::create (*_jsRuntime));
99+ _jsRuntime->global ().setProperty (*_jsRuntime, " GPUTextureUsage" ,
100+ GPUTextureUsage::create (*_jsRuntime));
54101}
55102
56103RNWebGPUManager::~RNWebGPUManager () {
0 commit comments