From 21d26135def9d9a2321a72c383540aed1e1694a0 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Mon, 19 Jan 2026 14:30:32 +0100 Subject: [PATCH 1/4] :wrench: --- packages/webgpu/scripts/install-dawn.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/webgpu/scripts/install-dawn.ts b/packages/webgpu/scripts/install-dawn.ts index 001876692..d9aa6a10c 100644 --- a/packages/webgpu/scripts/install-dawn.ts +++ b/packages/webgpu/scripts/install-dawn.ts @@ -1,7 +1,7 @@ #!/usr/bin/env tsx import { execSync } from "child_process"; -import { existsSync, mkdirSync, readFileSync, rmSync } from "fs"; +import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync } from "fs"; import { join } from "path"; import { checkBuildArtifacts } from "./build/dawn-configuration"; @@ -212,6 +212,27 @@ for (const [index, asset] of assets.entries()) { } } +// Copy dawn.json to libs +log.subheader("Copying Dawn Configuration"); +const dawnJsonSource = join( + __dirname, + "..", + "..", + "..", + "externals", + "dawn", + "src", + "dawn", + "dawn.json", +); +const dawnJsonDest = join(libsDir, "dawn.json"); +if (existsSync(dawnJsonSource)) { + copyFileSync(dawnJsonSource, dawnJsonDest); + log.success("dawn.json copied to libs/"); +} else { + log.warning(`dawn.json not found at ${dawnJsonSource}`); +} + // Verify build artifacts log.subheader("Verifying Installation"); console.log(""); From 975c174b3ac42691c1ecc3a8251c8c9e4f89073d Mon Sep 17 00:00:00 2001 From: William Candillon Date: Mon, 19 Jan 2026 15:02:38 +0100 Subject: [PATCH 2/4] :wrench: --- .../webgpu/scripts/codegen/Descriptors.ts | 25 +-- packages/webgpu/scripts/codegen/codegen.ts | 32 ++-- packages/webgpu/scripts/codegen/model/dawn.ts | 180 +++++++++++++++--- .../scripts/codegen/templates/HybridObject.ts | 46 +++-- .../scripts/codegen/templates/Unions.ts | 47 ++--- 5 files changed, 240 insertions(+), 90 deletions(-) diff --git a/packages/webgpu/scripts/codegen/Descriptors.ts b/packages/webgpu/scripts/codegen/Descriptors.ts index 181d37a21..7b65f170b 100644 --- a/packages/webgpu/scripts/codegen/Descriptors.ts +++ b/packages/webgpu/scripts/codegen/Descriptors.ts @@ -196,11 +196,8 @@ export const resolveType = (type: Type, state: ResolveTypeState): string => { dependencies.add("vector"); return `std::vector<${args.length === 1 ? args[0] : `std::variant<${args.join(", ")}>`}>`; } else if (symbol && symbol.getName() === "Promise") { - const arg = (type.getTypeArguments() ?? []).map((a) => - resolveType(a, state), - )[0]; - dependencies.add("future"); - return `std::future<${arg}>`; + // Promise types use async::AsyncTaskHandle + return `async::AsyncTaskHandle`; } else if ( type.getAliasSymbol() && stringSetNames.includes(type.getAliasSymbol()!.getName()) @@ -289,11 +286,15 @@ struct ${name} { .join("\n ")} }; +} // namespace rnwgpu + +namespace rnwgpu { + template <> -struct JSIConverter> { - static std::shared_ptr<${name}> +struct JSIConverter> { + static std::shared_ptr fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) { - auto result = std::make_unique<${name}>(); + auto result = std::make_unique(); if (!outOfBounds && arg.isObject()) { auto value = arg.getObject(runtime); ${props.map((prop) => (prop.name === "layout" && (prop.type === "std::variant>" || prop.type === "std::optional>>") ? layoutProp : jsiProp(prop))).join("\n")} @@ -301,12 +302,12 @@ struct JSIConverter> { return result; } - static jsi::Value - toJSI(jsi::Runtime &runtime, - std::shared_ptr<${name}> arg) { + static jsi::Value toJSI(jsi::Runtime &runtime, + std::shared_ptr arg) { throw std::runtime_error("Invalid ${name}::toJSI()"); } }; -} // namespace rnwgpu`; +} // namespace rnwgpu +`; }; diff --git a/packages/webgpu/scripts/codegen/codegen.ts b/packages/webgpu/scripts/codegen/codegen.ts index 40ed15fcb..dd7ffa9f1 100644 --- a/packages/webgpu/scripts/codegen/codegen.ts +++ b/packages/webgpu/scripts/codegen/codegen.ts @@ -152,22 +152,10 @@ sourceFile writeFile("union", "Unions", Unions(unions)); -// Enums +// Enums - skipped, manually maintained console.log("==="); -console.log("Enums"); +console.log("Enums (skipped - manually maintained)"); console.log("==="); -sourceFile - .getVariableDeclarations() - .filter( - (decl) => - decl.getName().startsWith("GPU") && - !decl.getName().endsWith("Error") && - !hasConstructor(decl) && - !hasProptotype(decl), - ) - .forEach((varDecl) => { - writeFile("enum", varDecl.getName(), getEnum(varDecl)); - }); // Errors console.log("==="); @@ -196,6 +184,7 @@ const objectsToSkip = [ "GPUCompilationInfo", "GPUCompilationMessage", "GPUDeviceLostInfo", + "GPUDevice", // has custom methods (forceLossForTesting, notifyDeviceLost) ]; const hybridObject = sourceFile .getInterfaces() @@ -231,6 +220,21 @@ const toSkip = [ "GPUCanvasConfiguration", "GPUPipelineErrorInit", "GPUUncapturedErrorEvent", + // Enum-like interfaces (manually maintained) + "GPUBufferUsage", + "GPUColorWrite", + "GPUMapMode", + "GPUShaderStage", + "GPUTextureUsage", + // New descriptors not yet implemented + "GPUDevice", // conflicts with object + "GPUCanvasConfigurationOut", + "GPUCanvasToneMapping", + "GPUCopyExternalImageDestInfo", + "GPUCopyExternalImageSourceInfo", + "GPUTexelCopyBufferInfo", + "GPUTexelCopyBufferLayout", + "GPUTexelCopyTextureInfo", ]; sourceFile diff --git a/packages/webgpu/scripts/codegen/model/dawn.ts b/packages/webgpu/scripts/codegen/model/dawn.ts index 60bb94ca9..4a2e92ace 100644 --- a/packages/webgpu/scripts/codegen/model/dawn.ts +++ b/packages/webgpu/scripts/codegen/model/dawn.ts @@ -46,36 +46,19 @@ export const resolved: Record< } > = { GPU: { - ctor: `GPU() - : NativeObject(CLASS_NAME) { - wgpu::InstanceDescriptor instanceDesc; - instanceDesc.features.timedWaitAnyEnable = true; - instanceDesc.features.timedWaitAnyMaxCount = 64; - _instance = wgpu::CreateInstance(&instanceDesc); - auto instance = &_instance; - _async = std::make_shared(instance); - }`, - }, - GPUDevice: { - ctor: `explicit GPUDevice(wgpu::Device instance, std::shared_ptr async, - std::string label) - : NativeObject(CLASS_NAME), _instance(instance), _async(async), - _label(label) { - m_lostPromise = std::make_shared>>(); - }`, - extra: - "std::shared_ptr>> m_lostPromise;", + ctor: `explicit GPU(jsi::Runtime &runtime);`, }, + // GPUDevice is skipped from codegen - maintained manually GPUBuffer: { methods: { mapAsync: { - returnType: "std::future", + returnType: "async::AsyncTaskHandle", args: [ { name: "modeIn", type: "uint64_t" }, { name: "offset", type: "std::optional" }, { name: "size", type: "std::optional" }, ], - deps: ["future"], + deps: [], }, getMappedRange: { returnType: "std::shared_ptr", @@ -86,14 +69,15 @@ export const resolved: Record< deps: ["memory", "optional", "ArrayBuffer"], }, }, - extra: `struct Mapping { - uint64_t start; - uint64_t end; - inline bool Intersects(uint64_t s, uint64_t e) const { return s < end && e > start; } - std::shared_ptr buffer; + extra: `size_t getMemoryPressure() override { return static_cast(getSize()); } + + struct Mapping { + uint64_t start; + uint64_t end; + inline bool Intersects(uint64_t s, uint64_t e) const { return s < end && e > start; } + std::shared_ptr buffer; }; - std::vector mappings; - `, + std::vector mappings;`, extraDeps: ["vector"], }, GPUCommandEncoder: { @@ -198,10 +182,146 @@ export const resolved: Record< }, }, GPUComputePipeline: { - extra: "friend class GPUDevice;", + extra: `size_t getMemoryPressure() override { + // Compute pipelines contain compiled compute shader state and + // driver-specific optimized code + // Estimate: 16KB for a typical compute pipeline (single compute shader) + return 16 * 1024; + } + + friend class GPUDevice;`, }, GPURenderPipeline: { - extra: "friend class GPUDevice;", + extra: `size_t getMemoryPressure() override { + // Render pipelines contain compiled shader state, vertex/fragment shaders, + // render state, and driver-specific optimized code + // Estimate: 24KB for a typical render pipeline with vertex + fragment shaders + return 24 * 1024; + } + + friend class GPUDevice;`, + }, + GPUBindGroup: { + extra: `size_t getMemoryPressure() override { + // Bind groups store resource bindings and descriptor state + // They reference buffers, textures, samplers, etc. + // Estimate: 1KB per bind group (descriptor tables and binding state) + return 1024; + }`, + }, + GPUBindGroupLayout: { + extra: `size_t getMemoryPressure() override { + // Bind group layouts define the structure/schema for bind groups + // They store binding descriptors, types, and validation info + // Estimate: 512 bytes per layout (smaller than actual bind groups) + return 512; + }`, + }, + GPUQuerySet: { + extra: `size_t getMemoryPressure() override { + uint32_t count = getCount(); + wgpu::QueryType type = getType(); + + // Estimate bytes per query based on type + size_t bytesPerQuery = 8; // Default estimate + switch (type) { + case wgpu::QueryType::Occlusion: + bytesPerQuery = 8; // 64-bit counter + break; + case wgpu::QueryType::Timestamp: + bytesPerQuery = 8; // 64-bit timestamp + break; + default: + bytesPerQuery = 8; // Safe default + break; + } + + return static_cast(count) * bytesPerQuery; + }`, + }, + GPUShaderModule: { + extra: `size_t getMemoryPressure() override { + // Estimate memory usage for compiled shader module + // Shaders can vary widely, but a reasonable estimate is 8-16KB for typical shaders + // Complex shaders (with many uniforms, textures, or computations) can be much larger + return 12 * 1024; // 12KB estimate for average shader + }`, + }, + GPUTexture: { + extraDeps: ["algorithm"], + extra: `size_t getMemoryPressure() override { + // Calculate approximate memory usage based on texture properties + uint32_t width = getWidth(); + uint32_t height = getHeight(); + uint32_t depthOrArrayLayers = getDepthOrArrayLayers(); + uint32_t mipLevelCount = getMipLevelCount(); + uint32_t sampleCount = getSampleCount(); + + // Estimate bytes per pixel based on format + // This is a simplified estimate - actual values depend on the specific format + size_t bytesPerPixel = 4; // Default to RGBA8 format + wgpu::TextureFormat format = getFormat(); + switch (format) { + case wgpu::TextureFormat::R8Unorm: + case wgpu::TextureFormat::R8Snorm: + case wgpu::TextureFormat::R8Uint: + case wgpu::TextureFormat::R8Sint: + bytesPerPixel = 1; + break; + case wgpu::TextureFormat::R16Uint: + case wgpu::TextureFormat::R16Sint: + case wgpu::TextureFormat::R16Float: + case wgpu::TextureFormat::RG8Unorm: + case wgpu::TextureFormat::RG8Snorm: + case wgpu::TextureFormat::RG8Uint: + case wgpu::TextureFormat::RG8Sint: + bytesPerPixel = 2; + break; + case wgpu::TextureFormat::RGBA8Unorm: + case wgpu::TextureFormat::RGBA8UnormSrgb: + case wgpu::TextureFormat::RGBA8Snorm: + case wgpu::TextureFormat::RGBA8Uint: + case wgpu::TextureFormat::RGBA8Sint: + case wgpu::TextureFormat::BGRA8Unorm: + case wgpu::TextureFormat::BGRA8UnormSrgb: + case wgpu::TextureFormat::RGB10A2Unorm: + case wgpu::TextureFormat::R32Float: + case wgpu::TextureFormat::R32Uint: + case wgpu::TextureFormat::R32Sint: + case wgpu::TextureFormat::RG16Uint: + case wgpu::TextureFormat::RG16Sint: + case wgpu::TextureFormat::RG16Float: + bytesPerPixel = 4; + break; + case wgpu::TextureFormat::RG32Float: + case wgpu::TextureFormat::RG32Uint: + case wgpu::TextureFormat::RG32Sint: + case wgpu::TextureFormat::RGBA16Uint: + case wgpu::TextureFormat::RGBA16Sint: + case wgpu::TextureFormat::RGBA16Float: + bytesPerPixel = 8; + break; + case wgpu::TextureFormat::RGBA32Float: + case wgpu::TextureFormat::RGBA32Uint: + case wgpu::TextureFormat::RGBA32Sint: + bytesPerPixel = 16; + break; + default: + bytesPerPixel = 4; // Safe default + break; + } + + // Calculate total memory for all mip levels + size_t totalMemory = 0; + for (uint32_t mip = 0; mip < mipLevelCount; ++mip) { + uint32_t mipWidth = std::max(1u, width >> mip); + uint32_t mipHeight = std::max(1u, height >> mip); + totalMemory += static_cast(mipWidth) * mipHeight * + depthOrArrayLayers * bytesPerPixel * sampleCount; + } + + return totalMemory; + }`, }, }; diff --git a/packages/webgpu/scripts/codegen/templates/HybridObject.ts b/packages/webgpu/scripts/codegen/templates/HybridObject.ts index 838c87c4b..1b1aa6962 100644 --- a/packages/webgpu/scripts/codegen/templates/HybridObject.ts +++ b/packages/webgpu/scripts/codegen/templates/HybridObject.ts @@ -15,10 +15,27 @@ import { mergeParentInterfaces } from "./common"; const instanceAliases: Record = { GPU: "Instance", GPUDeviceLostInfo: "DeviceLostReason", + GPUSupportedLimits: "Limits", }; -const deprecatedMethods = ["requestAdapterInfo"]; -const propblackList = ["onuncapturederror", "label", "prototype"]; +const deprecatedMethods = [ + "requestAdapterInfo", + // New methods not yet implemented + "setImmediates", +]; +const propblackList = [ + "onuncapturederror", + "label", + "prototype", + // New properties not yet implemented + "maxStorageBuffersInVertexStage", + "maxStorageBuffersInFragmentStage", + "maxStorageTexturesInVertexStage", + "maxStorageTexturesInFragmentStage", + "maxImmediateSize", + "textureBindingViewDimension", + "adapterInfo", +]; // const propWhiteList: string[] = [ // //"info" @@ -112,12 +129,20 @@ export const getHybridObject = (decl: InterfaceDeclaration) => { { name: "instance", type: instanceName }, ]; if (needsAsync) { - ctorParams.push({ name: "async", type: "std::shared_ptr" }); + ctorParams.push({ + name: "async", + type: "std::shared_ptr", + }); dependencies.add("memory"); } if (hasLabel) { ctorParams.push({ name: "label", type: "std::string" }); } + const asyncIncludes = needsAsync + ? ` +#include "rnwgpu/async/AsyncRunner.h" +#include "rnwgpu/async/AsyncTaskHandle.h"` + : ""; return `#pragma once ${Array.from(dependencies) @@ -128,8 +153,7 @@ ${Array.from(dependencies) #include "Unions.h" #include "NativeObject.h" - -#include "rnwgpu/async/AsyncRunner.h" +${asyncIncludes} #include "webgpu/webgpu_cpp.h" @@ -192,14 +216,14 @@ public: } } - inline const ${instanceName} get() { - return _instance; - } + inline const ${instanceName} get() { return _instance; } - private: - ${ctorParams.map((param) => `${param.type} _${param.name};`).join("\n ")} ${resolveExtra(className)} + +private: + ${ctorParams.map((param) => `${param.type} _${param.name};`).join("\n ")} }; -} // namespace rnwgpu`; +} // namespace rnwgpu +`; }; diff --git a/packages/webgpu/scripts/codegen/templates/Unions.ts b/packages/webgpu/scripts/codegen/templates/Unions.ts index 41eec1381..820a62b29 100644 --- a/packages/webgpu/scripts/codegen/templates/Unions.ts +++ b/packages/webgpu/scripts/codegen/templates/Unions.ts @@ -77,31 +77,32 @@ const Union = (union: Union) => { ? `rnwgpu::${name}` : `wgpu::${name.substring(3)}`; return ` -static void convertJSUnionToEnum(const std::string& inUnion, ${wgpuName}* outEnum) { - ${union.values - .map((val, index) => { - return `${index > 0 ? "else" : ""} if (inUnion == "${val}") { - *outEnum = ${wgpuName}::${enumName(val)}; - }`; - }) - .join("\n")} - else { - throw invalidUnion(inUnion); - } +inline void convertJSUnionToEnum(const std::string &inUnion, + ${wgpuName} *outEnum) { + ${union.values + .map((val, index) => { + return `${index > 0 ? "} else " : ""}if (inUnion == "${val}") { + *outEnum = ${wgpuName}::${enumName(val)};`; + }) + .join("\n ")} + } else { + throw invalidUnion(inUnion); } +} - static void convertEnumToJSUnion(${wgpuName} inEnum, std::string* outUnion) { - switch (inEnum) { - ${union.values - .map((val) => { - return `case ${wgpuName}::${enumName(val)}: - *outUnion = "${val}"; - break;`; - }) - .join("\n")} - default: - throw invalidEnum(inEnum); - } +inline void convertEnumToJSUnion(${wgpuName} inEnum, + std::string *outUnion) { + switch (inEnum) { + ${union.values + .map((val) => { + return `case ${wgpuName}::${enumName(val)}: + *outUnion = "${val}"; + break;`; + }) + .join("\n ")} + default: + throw invalidEnum(inEnum); } +} `; }; From c22eb1006d7562a0228a634e4b244f8e93d8ebb8 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Mon, 19 Jan 2026 15:10:35 +0100 Subject: [PATCH 3/4] :wrench: --- packages/webgpu/scripts/codegen/codegen.ts | 25 +++++++++---- .../webgpu/scripts/codegen/templates/Enum.ts | 37 +++++++------------ 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/packages/webgpu/scripts/codegen/codegen.ts b/packages/webgpu/scripts/codegen/codegen.ts index dd7ffa9f1..216da9a4f 100644 --- a/packages/webgpu/scripts/codegen/codegen.ts +++ b/packages/webgpu/scripts/codegen/codegen.ts @@ -152,10 +152,23 @@ sourceFile writeFile("union", "Unions", Unions(unions)); -// Enums - skipped, manually maintained +// Enums (enum-like interfaces with static constants) console.log("==="); -console.log("Enums (skipped - manually maintained)"); +console.log("Enums"); console.log("==="); +const enumInterfaces = [ + "GPUBufferUsage", + "GPUColorWrite", + "GPUMapMode", + "GPUShaderStage", + "GPUTextureUsage", +]; +sourceFile + .getInterfaces() + .filter((decl) => enumInterfaces.includes(decl.getName())) + .forEach((decl) => { + writeFile("enum", decl.getName(), getEnum(decl)); + }); // Errors console.log("==="); @@ -220,12 +233,8 @@ const toSkip = [ "GPUCanvasConfiguration", "GPUPipelineErrorInit", "GPUUncapturedErrorEvent", - // Enum-like interfaces (manually maintained) - "GPUBufferUsage", - "GPUColorWrite", - "GPUMapMode", - "GPUShaderStage", - "GPUTextureUsage", + // Enum-like interfaces (handled by enum generation) + ...enumInterfaces, // New descriptors not yet implemented "GPUDevice", // conflicts with object "GPUCanvasConfigurationOut", diff --git a/packages/webgpu/scripts/codegen/templates/Enum.ts b/packages/webgpu/scripts/codegen/templates/Enum.ts index acb73bb16..a9f51e9c7 100644 --- a/packages/webgpu/scripts/codegen/templates/Enum.ts +++ b/packages/webgpu/scripts/codegen/templates/Enum.ts @@ -1,6 +1,5 @@ import _ from "lodash"; -import type { PropertySignature, VariableDeclaration } from "ts-morph"; -import { Node } from "ts-morph"; +import type { InterfaceDeclaration, PropertySignature } from "ts-morph"; const enumAliases: Record = { ColorWrite: "ColorWriteMask", @@ -11,14 +10,13 @@ const getPropName = (prop: PropertySignature) => { return name; }; -export const getEnum = (decl: VariableDeclaration) => { +export const getEnum = (decl: InterfaceDeclaration) => { const name = decl.getName(); const wname = enumAliases[name.substring(3)] || name.substring(3); - const properties = decl.getDescendants().filter(Node.isPropertySignature); + const properties = decl.getProperties(); return `#pragma once -#include -#include +#include #include "webgpu/webgpu_cpp.h" @@ -26,30 +24,21 @@ namespace rnwgpu { namespace jsi = facebook::jsi; -class ${name} : public NativeObject<${name}> { +class ${name} { public: - static constexpr const char *CLASS_NAME = "${name}"; - - ${name}() : NativeObject(CLASS_NAME) {} - -public: - ${properties - .map((property) => { - const prop = getPropName(property); - return `double ${prop}() { - return static_cast(wgpu::${wname}::${prop}); - }`; - }) - .join("\n ")} - - static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) { + static jsi::Object create(jsi::Runtime &runtime) { + jsi::Object obj(runtime); ${properties .map((property) => { const prop = getPropName(property); - return `installGetter(runtime, prototype, "${property.getName()}", &${name}::${prop});`; + return `obj.setProperty(runtime, "${property.getName()}", + static_cast(wgpu::${wname}::${prop}));`; }) .join("\n ")} + return obj; } }; -} // namespace rnwgpu`; + +} // namespace rnwgpu +`; }; From 0d3afcbdff2e7f0468fd190abbe29dd6254aa00c Mon Sep 17 00:00:00 2001 From: William Candillon Date: Mon, 19 Jan 2026 16:34:08 +0100 Subject: [PATCH 4/4] :wrench: --- apps/example/ios/Podfile.lock | 62 +-- packages/webgpu/babel.config.js | 11 +- packages/webgpu/cpp/rnwgpu/api/GPU.h | 3 - packages/webgpu/cpp/rnwgpu/api/GPUBindGroup.h | 1 + .../cpp/rnwgpu/api/GPUBindGroupLayout.h | 1 + packages/webgpu/cpp/rnwgpu/api/GPUBuffer.h | 9 +- .../webgpu/cpp/rnwgpu/api/GPUCommandBuffer.h | 1 + .../webgpu/cpp/rnwgpu/api/GPUCommandEncoder.h | 1 + .../cpp/rnwgpu/api/GPUComputePassEncoder.h | 1 + .../cpp/rnwgpu/api/GPUComputePipeline.h | 4 +- .../cpp/rnwgpu/api/GPUExternalTexture.h | 1 + .../webgpu/cpp/rnwgpu/api/GPUPipelineLayout.h | 1 + packages/webgpu/cpp/rnwgpu/api/GPUQueue.h | 1 + .../webgpu/cpp/rnwgpu/api/GPURenderBundle.h | 1 + .../cpp/rnwgpu/api/GPURenderBundleEncoder.h | 1 + .../cpp/rnwgpu/api/GPURenderPassEncoder.h | 1 + .../webgpu/cpp/rnwgpu/api/GPURenderPipeline.h | 4 +- packages/webgpu/cpp/rnwgpu/api/GPUSampler.h | 1 + .../webgpu/cpp/rnwgpu/api/GPUShaderModule.h | 1 + .../cpp/rnwgpu/api/GPUSupportedLimits.h | 1 + .../webgpu/cpp/rnwgpu/api/GPUTextureView.h | 1 + .../api/descriptors/GPUBindGroupDescriptor.h | 2 +- .../GPUBindGroupLayoutDescriptor.h | 2 +- .../api/descriptors/GPUBindGroupLayoutEntry.h | 2 +- .../api/descriptors/GPUBlendComponent.h | 2 +- .../rnwgpu/api/descriptors/GPUBlendState.h | 2 +- .../rnwgpu/api/descriptors/GPUBufferBinding.h | 2 +- .../api/descriptors/GPUBufferBindingLayout.h | 2 +- .../api/descriptors/GPUBufferDescriptor.h | 2 +- .../api/descriptors/GPUColorTargetState.h | 2 +- .../descriptors/GPUCommandBufferDescriptor.h | 2 +- .../descriptors/GPUCommandEncoderDescriptor.h | 2 +- .../descriptors/GPUComputePassDescriptor.h | 2 +- .../GPUComputePassTimestampWrites.h | 2 +- .../GPUComputePipelineDescriptor.h | 2 +- .../api/descriptors/GPUDepthStencilState.h | 2 +- .../api/descriptors/GPUDeviceDescriptor.h | 29 +- .../GPUExternalTextureBindingLayout.h | 2 +- .../rnwgpu/api/descriptors/GPUFragmentState.h | 4 +- .../api/descriptors/GPUMultisampleState.h | 2 +- .../descriptors/GPUPipelineLayoutDescriptor.h | 22 +- .../api/descriptors/GPUPrimitiveState.h | 2 +- .../api/descriptors/GPUProgrammableStage.h | 2 +- .../api/descriptors/GPUQuerySetDescriptor.h | 2 +- .../api/descriptors/GPUQueueDescriptor.h | 2 +- .../descriptors/GPURenderBundleDescriptor.h | 2 +- .../GPURenderBundleEncoderDescriptor.h | 4 +- .../api/descriptors/GPURenderPassDescriptor.h | 5 +- .../GPURenderPassTimestampWrites.h | 2 +- .../descriptors/GPURenderPipelineDescriptor.h | 2 +- .../descriptors/GPURequestAdapterOptions.h | 16 +- .../api/descriptors/GPUSamplerBindingLayout.h | 2 +- .../api/descriptors/GPUSamplerDescriptor.h | 2 +- .../GPUShaderModuleCompilationHint.h | 2 +- .../descriptors/GPUShaderModuleDescriptor.h | 4 +- .../api/descriptors/GPUStencilFaceState.h | 2 +- .../GPUStorageTextureBindingLayout.h | 2 +- .../api/descriptors/GPUTextureBindingLayout.h | 2 +- .../api/descriptors/GPUTextureDescriptor.h | 12 +- .../descriptors/GPUTextureViewDescriptor.h | 14 +- .../descriptors/GPUUncapturedErrorEventInit.h | 2 +- .../api/descriptors/GPUVertexAttribute.h | 2 +- .../api/descriptors/GPUVertexBufferLayout.h | 2 +- .../rnwgpu/api/descriptors/GPUVertexState.h | 4 +- .../cpp/rnwgpu/api/descriptors/Unions.h | 379 ++++++------------ packages/webgpu/scripts/codegen/codegen.ts | 3 + packages/webgpu/scripts/codegen/model/dawn.ts | 16 + .../scripts/codegen/templates/HybridObject.ts | 25 +- .../scripts/codegen/templates/Unions.ts | 3 +- 69 files changed, 309 insertions(+), 405 deletions(-) diff --git a/apps/example/ios/Podfile.lock b/apps/example/ios/Podfile.lock index 7a048fa41..e21f3e877 100644 --- a/apps/example/ios/Podfile.lock +++ b/apps/example/ios/Podfile.lock @@ -1865,7 +1865,7 @@ PODS: - ReactCommon/turbomodule/core - SocketRocket - Yoga - - react-native-wgpu (0.5.0): + - react-native-wgpu (0.5.1): - boost - DoubleConversion - fast_float @@ -2460,7 +2460,7 @@ PODS: - ReactCommon/turbomodule/core - SocketRocket - Yoga - - RNReanimated (4.2.1): + - RNReanimated (3.19.1): - boost - DoubleConversion - fast_float @@ -2487,11 +2487,11 @@ PODS: - ReactCodegen - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNReanimated/reanimated (= 4.2.1) - - RNWorklets + - RNReanimated/reanimated (= 3.19.1) + - RNReanimated/worklets (= 3.19.1) - SocketRocket - Yoga - - RNReanimated/reanimated (4.2.1): + - RNReanimated/reanimated (3.19.1): - boost - DoubleConversion - fast_float @@ -2518,11 +2518,10 @@ PODS: - ReactCodegen - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNReanimated/reanimated/apple (= 4.2.1) - - RNWorklets + - RNReanimated/reanimated/apple (= 3.19.1) - SocketRocket - Yoga - - RNReanimated/reanimated/apple (4.2.1): + - RNReanimated/reanimated/apple (3.19.1): - boost - DoubleConversion - fast_float @@ -2549,10 +2548,9 @@ PODS: - ReactCodegen - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNWorklets - SocketRocket - Yoga - - RNWorklets (0.7.2): + - RNReanimated/worklets (3.19.1): - boost - DoubleConversion - fast_float @@ -2579,40 +2577,10 @@ PODS: - ReactCodegen - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNWorklets/worklets (= 0.7.2) + - RNReanimated/worklets/apple (= 3.19.1) - SocketRocket - Yoga - - RNWorklets/worklets (0.7.2): - - boost - - DoubleConversion - - fast_float - - fmt - - glog - - hermes-engine - - RCT-Folly - - RCT-Folly/Fabric - - RCTRequired - - RCTTypeSafety - - React-Core - - React-debug - - React-Fabric - - React-featureflags - - React-graphics - - React-hermes - - React-ImageManager - - React-jsi - - React-NativeModulesApple - - React-RCTFabric - - React-renderercss - - React-rendererdebug - - React-utils - - ReactCodegen - - ReactCommon/turbomodule/bridging - - ReactCommon/turbomodule/core - - RNWorklets/worklets/apple (= 0.7.2) - - SocketRocket - - Yoga - - RNWorklets/worklets/apple (0.7.2): + - RNReanimated/worklets/apple (3.19.1): - boost - DoubleConversion - fast_float @@ -2724,7 +2692,6 @@ DEPENDENCIES: - ReactTestApp-Resources (from `..`) - RNGestureHandler (from `../../../node_modules/react-native-gesture-handler`) - RNReanimated (from `../../../node_modules/react-native-reanimated`) - - RNWorklets (from `../../../node_modules/react-native-worklets`) - SocketRocket (~> 0.7.1) - Yoga (from `../../../node_modules/react-native/ReactCommon/yoga`) @@ -2890,8 +2857,6 @@ EXTERNAL SOURCES: :path: "../../../node_modules/react-native-gesture-handler" RNReanimated: :path: "../../../node_modules/react-native-reanimated" - RNWorklets: - :path: "../../../node_modules/react-native-worklets" Yoga: :path: "../../../node_modules/react-native/ReactCommon/yoga" @@ -2938,7 +2903,7 @@ SPEC CHECKSUMS: React-microtasksnativemodule: 75b6604b667d297292345302cc5bfb6b6aeccc1b react-native-safe-area-context: c00143b4823773bba23f2f19f85663ae89ceb460 react-native-skia: 5bf2b2107cd7f2d806fd364f5e16b1c7554ed3cd - react-native-wgpu: e54fcee5946cc2cee4814f63f425be358f097b14 + react-native-wgpu: 73132f915ab99a1ce2b0fdafcfa9a6523c11ceec React-NativeModulesApple: 879fbdc5dcff7136abceb7880fe8a2022a1bd7c3 React-oscompat: 93b5535ea7f7dff46aaee4f78309a70979bdde9d React-perflogger: 5536d2df3d18fe0920263466f7b46a56351c0510 @@ -2967,14 +2932,13 @@ SPEC CHECKSUMS: React-timing: 1e6a8acb66e2b7ac9d418956617fd1fdb19322fd React-utils: 52bbb03f130319ef82e4c3bc7a85eaacdb1fec87 ReactAppDependencyProvider: 433ddfb4536948630aadd5bd925aff8a632d2fe3 - ReactCodegen: 7042ec4a7316b59e8f247b8fa312891179d24f5a + ReactCodegen: 64dbbed4e9e0264d799578ea78492479a66fba4a ReactCommon: 394c6b92765cf6d211c2c3f7f6bc601dffb316a6 ReactNativeHost: f5e054387e917216a2a021a3f7fdc4f9f158e7e4 ReactTestApp-DevSupport: 9b7bbba5e8fed998e763809171d9906a1375f9d3 ReactTestApp-Resources: 1bd9ff10e4c24f2ad87101a32023721ae923bccf RNGestureHandler: e37bdb684df1ac17c7e1d8f71a3311b2793c186b - RNReanimated: 464375ff2caa801358547c44eca894ff0bf68e74 - RNWorklets: ee58e869ea579800ec5f2f1cb6ae195fd3537546 + RNReanimated: 4e53390354d1eed1398ab51ace22b869be6ce611 SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748 Yoga: a3ed390a19db0459bd6839823a6ac6d9c6db198d diff --git a/packages/webgpu/babel.config.js b/packages/webgpu/babel.config.js index 39cd3276e..0356d7b22 100644 --- a/packages/webgpu/babel.config.js +++ b/packages/webgpu/babel.config.js @@ -1,4 +1,13 @@ +const plugins = []; + +try { + require.resolve('react-native-worklets/plugin'); + plugins.push('react-native-worklets/plugin'); +} catch { + // react-native-worklets is optional +} + module.exports = { presets: ['module:@react-native/babel-preset'], - plugins: ['react-native-worklets/plugin'], + plugins, }; \ No newline at end of file diff --git a/packages/webgpu/cpp/rnwgpu/api/GPU.h b/packages/webgpu/cpp/rnwgpu/api/GPU.h index 27db1f903..80cbe01f2 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPU.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPU.h @@ -3,7 +3,6 @@ #include #include #include -#include #include "Unions.h" @@ -17,8 +16,6 @@ #include "GPUAdapter.h" #include "GPURequestAdapterOptions.h" -#include - namespace rnwgpu { namespace jsi = facebook::jsi; diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUBindGroup.h b/packages/webgpu/cpp/rnwgpu/api/GPUBindGroup.h index fd3c8c9d4..fd0083c5a 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUBindGroup.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUBindGroup.h @@ -30,6 +30,7 @@ class GPUBindGroup : public NativeObject { static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) { installGetter(runtime, prototype, "__brand", &GPUBindGroup::getBrand); + installGetterSetter(runtime, prototype, "label", &GPUBindGroup::getLabel, &GPUBindGroup::setLabel); } diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUBindGroupLayout.h b/packages/webgpu/cpp/rnwgpu/api/GPUBindGroupLayout.h index ae4abae79..88193ae24 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUBindGroupLayout.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUBindGroupLayout.h @@ -30,6 +30,7 @@ class GPUBindGroupLayout : public NativeObject { static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) { installGetter(runtime, prototype, "__brand", &GPUBindGroupLayout::getBrand); + installGetterSetter(runtime, prototype, "label", &GPUBindGroupLayout::getLabel, &GPUBindGroupLayout::setLabel); diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUBuffer.h b/packages/webgpu/cpp/rnwgpu/api/GPUBuffer.h index edfc8e41b..c91f24109 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUBuffer.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUBuffer.h @@ -69,10 +69,6 @@ class GPUBuffer : public NativeObject { size_t getMemoryPressure() override { return static_cast(getSize()); } -private: - wgpu::Buffer _instance; - std::shared_ptr _async; - std::string _label; struct Mapping { uint64_t start; uint64_t end; @@ -82,6 +78,11 @@ class GPUBuffer : public NativeObject { std::shared_ptr buffer; }; std::vector mappings; + +private: + wgpu::Buffer _instance; + std::shared_ptr _async; + std::string _label; }; } // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUCommandBuffer.h b/packages/webgpu/cpp/rnwgpu/api/GPUCommandBuffer.h index 4f537d084..3be424e3b 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUCommandBuffer.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUCommandBuffer.h @@ -30,6 +30,7 @@ class GPUCommandBuffer : public NativeObject { static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) { installGetter(runtime, prototype, "__brand", &GPUCommandBuffer::getBrand); + installGetterSetter(runtime, prototype, "label", &GPUCommandBuffer::getLabel, &GPUCommandBuffer::setLabel); diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUCommandEncoder.h b/packages/webgpu/cpp/rnwgpu/api/GPUCommandEncoder.h index 153426785..83fde50a5 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUCommandEncoder.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUCommandEncoder.h @@ -96,6 +96,7 @@ class GPUCommandEncoder : public NativeObject { &GPUCommandEncoder::popDebugGroup); installMethod(runtime, prototype, "insertDebugMarker", &GPUCommandEncoder::insertDebugMarker); + installGetterSetter(runtime, prototype, "label", &GPUCommandEncoder::getLabel, &GPUCommandEncoder::setLabel); diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUComputePassEncoder.h b/packages/webgpu/cpp/rnwgpu/api/GPUComputePassEncoder.h index 1dd8d725d..ad6d0539c 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUComputePassEncoder.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUComputePassEncoder.h @@ -70,6 +70,7 @@ class GPUComputePassEncoder : public NativeObject { &GPUComputePassEncoder::insertDebugMarker); installMethod(runtime, prototype, "setBindGroup", &GPUComputePassEncoder::setBindGroup); + installGetterSetter(runtime, prototype, "label", &GPUComputePassEncoder::getLabel, &GPUComputePassEncoder::setLabel); diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUComputePipeline.h b/packages/webgpu/cpp/rnwgpu/api/GPUComputePipeline.h index 66102d759..9cefa0820 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUComputePipeline.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUComputePipeline.h @@ -37,6 +37,7 @@ class GPUComputePipeline : public NativeObject { installGetter(runtime, prototype, "__brand", &GPUComputePipeline::getBrand); installMethod(runtime, prototype, "getBindGroupLayout", &GPUComputePipeline::getBindGroupLayout); + installGetterSetter(runtime, prototype, "label", &GPUComputePipeline::getLabel, &GPUComputePipeline::setLabel); @@ -51,10 +52,11 @@ class GPUComputePipeline : public NativeObject { return 16 * 1024; } + friend class GPUDevice; + private: wgpu::ComputePipeline _instance; std::string _label; - friend class GPUDevice; }; } // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUExternalTexture.h b/packages/webgpu/cpp/rnwgpu/api/GPUExternalTexture.h index 9be5efe6f..af00b9a4a 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUExternalTexture.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUExternalTexture.h @@ -30,6 +30,7 @@ class GPUExternalTexture : public NativeObject { static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) { installGetter(runtime, prototype, "__brand", &GPUExternalTexture::getBrand); + installGetterSetter(runtime, prototype, "label", &GPUExternalTexture::getLabel, &GPUExternalTexture::setLabel); diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUPipelineLayout.h b/packages/webgpu/cpp/rnwgpu/api/GPUPipelineLayout.h index 74ddd17e9..153e0e895 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUPipelineLayout.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUPipelineLayout.h @@ -30,6 +30,7 @@ class GPUPipelineLayout : public NativeObject { static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) { installGetter(runtime, prototype, "__brand", &GPUPipelineLayout::getBrand); + installGetterSetter(runtime, prototype, "label", &GPUPipelineLayout::getLabel, &GPUPipelineLayout::setLabel); diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUQueue.h b/packages/webgpu/cpp/rnwgpu/api/GPUQueue.h index be824e781..794788469 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUQueue.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUQueue.h @@ -66,6 +66,7 @@ class GPUQueue : public NativeObject { installMethod(runtime, prototype, "writeTexture", &GPUQueue::writeTexture); installMethod(runtime, prototype, "copyExternalImageToTexture", &GPUQueue::copyExternalImageToTexture); + installGetterSetter(runtime, prototype, "label", &GPUQueue::getLabel, &GPUQueue::setLabel); } diff --git a/packages/webgpu/cpp/rnwgpu/api/GPURenderBundle.h b/packages/webgpu/cpp/rnwgpu/api/GPURenderBundle.h index df7ca5821..9dd05d461 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPURenderBundle.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPURenderBundle.h @@ -30,6 +30,7 @@ class GPURenderBundle : public NativeObject { static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) { installGetter(runtime, prototype, "__brand", &GPURenderBundle::getBrand); + installGetterSetter(runtime, prototype, "label", &GPURenderBundle::getLabel, &GPURenderBundle::setLabel); } diff --git a/packages/webgpu/cpp/rnwgpu/api/GPURenderBundleEncoder.h b/packages/webgpu/cpp/rnwgpu/api/GPURenderBundleEncoder.h index 68e0cfcd1..a49697133 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPURenderBundleEncoder.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPURenderBundleEncoder.h @@ -95,6 +95,7 @@ class GPURenderBundleEncoder : public NativeObject { &GPURenderBundleEncoder::drawIndirect); installMethod(runtime, prototype, "drawIndexedIndirect", &GPURenderBundleEncoder::drawIndexedIndirect); + installGetterSetter(runtime, prototype, "label", &GPURenderBundleEncoder::getLabel, &GPURenderBundleEncoder::setLabel); diff --git a/packages/webgpu/cpp/rnwgpu/api/GPURenderPassEncoder.h b/packages/webgpu/cpp/rnwgpu/api/GPURenderPassEncoder.h index 5d1410af0..0d125b8b4 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPURenderPassEncoder.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPURenderPassEncoder.h @@ -115,6 +115,7 @@ class GPURenderPassEncoder : public NativeObject { &GPURenderPassEncoder::drawIndirect); installMethod(runtime, prototype, "drawIndexedIndirect", &GPURenderPassEncoder::drawIndexedIndirect); + installGetterSetter(runtime, prototype, "label", &GPURenderPassEncoder::getLabel, &GPURenderPassEncoder::setLabel); diff --git a/packages/webgpu/cpp/rnwgpu/api/GPURenderPipeline.h b/packages/webgpu/cpp/rnwgpu/api/GPURenderPipeline.h index 96245adcf..25795408c 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPURenderPipeline.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPURenderPipeline.h @@ -37,6 +37,7 @@ class GPURenderPipeline : public NativeObject { installGetter(runtime, prototype, "__brand", &GPURenderPipeline::getBrand); installMethod(runtime, prototype, "getBindGroupLayout", &GPURenderPipeline::getBindGroupLayout); + installGetterSetter(runtime, prototype, "label", &GPURenderPipeline::getLabel, &GPURenderPipeline::setLabel); @@ -52,10 +53,11 @@ class GPURenderPipeline : public NativeObject { return 24 * 1024; } + friend class GPUDevice; + private: wgpu::RenderPipeline _instance; std::string _label; - friend class GPUDevice; }; } // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUSampler.h b/packages/webgpu/cpp/rnwgpu/api/GPUSampler.h index 35cfc53f9..3bfd9c0d0 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUSampler.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUSampler.h @@ -30,6 +30,7 @@ class GPUSampler : public NativeObject { static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) { installGetter(runtime, prototype, "__brand", &GPUSampler::getBrand); + installGetterSetter(runtime, prototype, "label", &GPUSampler::getLabel, &GPUSampler::setLabel); } diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUShaderModule.h b/packages/webgpu/cpp/rnwgpu/api/GPUShaderModule.h index ab8561090..0717cfc58 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUShaderModule.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUShaderModule.h @@ -43,6 +43,7 @@ class GPUShaderModule : public NativeObject { installGetter(runtime, prototype, "__brand", &GPUShaderModule::getBrand); installMethod(runtime, prototype, "getCompilationInfo", &GPUShaderModule::getCompilationInfo); + installGetterSetter(runtime, prototype, "label", &GPUShaderModule::getLabel, &GPUShaderModule::setLabel); } diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUSupportedLimits.h b/packages/webgpu/cpp/rnwgpu/api/GPUSupportedLimits.h index e3e65f525..e36107aef 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUSupportedLimits.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUSupportedLimits.h @@ -56,6 +56,7 @@ class GPUSupportedLimits : public NativeObject { static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) { installGetter(runtime, prototype, "__brand", &GPUSupportedLimits::getBrand); + installGetter(runtime, prototype, "maxTextureDimension1D", &GPUSupportedLimits::getMaxTextureDimension1D); installGetter(runtime, prototype, "maxTextureDimension2D", diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUTextureView.h b/packages/webgpu/cpp/rnwgpu/api/GPUTextureView.h index c37058517..b11d27f85 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPUTextureView.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPUTextureView.h @@ -30,6 +30,7 @@ class GPUTextureView : public NativeObject { static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) { installGetter(runtime, prototype, "__brand", &GPUTextureView::getBrand); + installGetterSetter(runtime, prototype, "label", &GPUTextureView::getLabel, &GPUTextureView::setLabel); } diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h index 9893898b8..5b2925577 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h @@ -62,4 +62,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h index 01722bc8c..e8d9de5c4 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h @@ -54,4 +54,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h index 5d044a941..f1a70095b 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h @@ -95,4 +95,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h index a9db7526c..b08a56f0d 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h @@ -55,4 +55,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBlendState.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBlendState.h index b51f547c9..1d6222158 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBlendState.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBlendState.h @@ -50,4 +50,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h index b0dceca71..816fe81b0 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h @@ -54,4 +54,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h index 5150b9029..067d9a767 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h @@ -54,4 +54,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h index a80129444..8012b8c4f 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h @@ -57,4 +57,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h index b850428c0..c2e06fa85 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h @@ -56,4 +56,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h index 5d572660c..781783df8 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h @@ -43,4 +43,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h index f84fbacda..334473a3e 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h @@ -43,4 +43,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h index bbd7abd56..8e2fd2ae2 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h @@ -54,4 +54,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h index 3f25413c2..f77a8dbe3 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h @@ -56,4 +56,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h index 9ed70a047..a68f8bfb7 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h @@ -65,4 +65,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h index b307dec15..3858a805b 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h @@ -101,4 +101,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h index 5ec068b48..4fe912588 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h @@ -20,7 +20,7 @@ struct GPUDeviceDescriptor { std::optional> requiredFeatures; // Iterable std::optional> - requiredLimits; // Record< string, GPUSize64 > + requiredLimits; // Record< string, | GPUSize64 | undefined > std::optional> defaultQueue; // GPUQueueDescriptor std::optional label; // string @@ -30,33 +30,6 @@ struct GPUDeviceDescriptor { namespace rnwgpu { -// We add this extra convertor because we found so library that are sending -// invalid feature elements -template <> struct JSIConverter> { - - static std::vector - fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) { - jsi::Array array = arg.asObject(runtime).asArray(runtime); - size_t length = array.size(runtime); - - std::vector vector; - vector.reserve(length); - for (size_t i = 0; i < length; ++i) { - jsi::Value elementValue = array.getValueAtIndex(runtime, i); - if (elementValue.isString()) { - vector.emplace_back(JSIConverter::fromJSI( - runtime, elementValue, outOfBounds)); - } - } - return vector; - } - static jsi::Value toJSI(jsi::Runtime &runtime, - std::shared_ptr arg) { - throw std::runtime_error( - "Invalid JSIConverter>::toJSI()"); - } -}; - template <> struct JSIConverter> { static std::shared_ptr fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) { diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h index a296a15df..63e36c439 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h @@ -36,4 +36,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUFragmentState.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUFragmentState.h index 1a39b718e..63ff1d16b 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUFragmentState.h @@ -21,7 +21,7 @@ namespace rnwgpu { struct GPUFragmentState { std::vector< std::variant>> - targets; // Iterable + targets; // Iterable< | GPUColorTargetState | null | undefined > std::shared_ptr module; // GPUShaderModule std::optional entryPoint; // string std::optional> @@ -71,4 +71,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h index cbe7f3bf8..968e36e1c 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h @@ -52,4 +52,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h index fbcafd281..c3da0556c 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h @@ -2,6 +2,7 @@ #include #include +#include #include #include "webgpu/webgpu_cpp.h" @@ -16,9 +17,10 @@ namespace jsi = facebook::jsi; namespace rnwgpu { struct GPUPipelineLayoutDescriptor { - std::vector> - bindGroupLayouts; // Iterable - std::optional label; // string + std::vector>> + bindGroupLayouts; // Iterable< | GPUBindGroupLayout | null | undefined > + std::optional immediateSize; // GPUSize32 + std::optional label; // string }; } // namespace rnwgpu @@ -34,10 +36,14 @@ struct JSIConverter> { auto value = arg.getObject(runtime); if (value.hasProperty(runtime, "bindGroupLayouts")) { auto prop = value.getProperty(runtime, "bindGroupLayouts"); - result->bindGroupLayouts = JSIConverter< - std::vector>>::fromJSI(runtime, - prop, - false); + result->bindGroupLayouts = JSIConverter>>>:: + fromJSI(runtime, prop, false); + } + if (value.hasProperty(runtime, "immediateSize")) { + auto prop = value.getProperty(runtime, "immediateSize"); + result->immediateSize = + JSIConverter>::fromJSI(runtime, prop, false); } if (value.hasProperty(runtime, "label")) { auto prop = value.getProperty(runtime, "label"); @@ -55,4 +61,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h index fc917f2de..ec2d2467e 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h @@ -67,4 +67,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h index 90da61444..5beec56e5 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h @@ -59,4 +59,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h index 4a218bc14..8b902be84 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h @@ -53,4 +53,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h index dd7dfea00..86bf3a66d 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h @@ -41,4 +41,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h index 0fae5fefb..633791e36 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h @@ -43,4 +43,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h index fddda4464..336c56d54 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h @@ -17,7 +17,7 @@ struct GPURenderBundleEncoderDescriptor { std::optional depthReadOnly; // boolean std::optional stencilReadOnly; // boolean std::vector> - colorFormats; // Iterable + colorFormats; // Iterable< | GPUTextureFormat | null | undefined > std::optional depthStencilFormat; // GPUTextureFormat std::optional sampleCount; // GPUSize32 std::optional label; // string @@ -78,4 +78,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h index 768bc5b36..ef07cef43 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h @@ -22,7 +22,8 @@ namespace rnwgpu { struct GPURenderPassDescriptor { std::vector>> - colorAttachments; // Iterable + colorAttachments; // Iterable< | GPURenderPassColorAttachment | null | + // undefined > std::optional> depthStencilAttachment; // GPURenderPassDepthStencilAttachment std::optional> occlusionQuerySet; // GPUQuerySet @@ -90,4 +91,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h index bc94e9d23..5f8af6c7f 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h @@ -56,4 +56,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h index 7ceb9d632..383a383d9 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h @@ -101,4 +101,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h index 8f3113df8..b3e6f67b6 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "webgpu/webgpu_cpp.h" @@ -12,8 +13,10 @@ namespace jsi = facebook::jsi; namespace rnwgpu { struct GPURequestAdapterOptions { + std::optional featureLevel; // string std::optional powerPreference; // GPUPowerPreference std::optional forceFallbackAdapter; // boolean + std::optional xrCompatible; // boolean }; } // namespace rnwgpu @@ -27,6 +30,12 @@ struct JSIConverter> { auto result = std::make_unique(); if (!outOfBounds && arg.isObject()) { auto value = arg.getObject(runtime); + if (value.hasProperty(runtime, "featureLevel")) { + auto prop = value.getProperty(runtime, "featureLevel"); + result->featureLevel = + JSIConverter>::fromJSI(runtime, prop, + false); + } if (value.hasProperty(runtime, "powerPreference")) { auto prop = value.getProperty(runtime, "powerPreference"); result->powerPreference = @@ -38,6 +47,11 @@ struct JSIConverter> { result->forceFallbackAdapter = JSIConverter>::fromJSI(runtime, prop, false); } + if (value.hasProperty(runtime, "xrCompatible")) { + auto prop = value.getProperty(runtime, "xrCompatible"); + result->xrCompatible = + JSIConverter>::fromJSI(runtime, prop, false); + } } return result; @@ -49,4 +63,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h index c60c9aa10..acae99854 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h @@ -43,4 +43,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h index 8da56963a..c9b4e9c06 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h @@ -108,4 +108,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h index 12c182f3a..f7b0a2aa0 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h @@ -58,4 +58,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h index d3e6dc629..daa8237f6 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h @@ -18,7 +18,7 @@ namespace rnwgpu { struct GPUShaderModuleDescriptor { std::string code; // string std::optional>> - compilationHints; // Array + compilationHints; // Iterable std::optional label; // string }; @@ -60,4 +60,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h index 007dd6447..da8e3d5d1 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h @@ -62,4 +62,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h index 0d9a49420..3bf30323a 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h @@ -57,4 +57,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h index 76c0e7f7e..883b186aa 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h @@ -57,4 +57,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h index 758ebd28b..37dffa10c 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h @@ -23,7 +23,9 @@ struct GPUTextureDescriptor { wgpu::TextureFormat format; // GPUTextureFormat double usage; // GPUTextureUsageFlags std::optional> - viewFormats; // Iterable + viewFormats; // Iterable + std::optional + textureBindingViewDimension; // GPUTextureViewDimension std::optional label; // string }; @@ -74,6 +76,12 @@ template <> struct JSIConverter> { prop, false); } + if (value.hasProperty(runtime, "textureBindingViewDimension")) { + auto prop = value.getProperty(runtime, "textureBindingViewDimension"); + result->textureBindingViewDimension = + JSIConverter>::fromJSI( + runtime, prop, false); + } if (value.hasProperty(runtime, "label")) { auto prop = value.getProperty(runtime, "label"); result->label = JSIConverter>::fromJSI( @@ -89,4 +97,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h index c429eaf87..9240d3e14 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h @@ -16,11 +16,13 @@ struct GPUTextureViewDescriptor { std::optional format; // GPUTextureFormat std::optional dimension; // GPUTextureViewDimension + std::optional usage; // GPUTextureUsageFlags std::optional aspect; // GPUTextureAspect std::optional baseMipLevel; // GPUIntegerCoordinate std::optional mipLevelCount; // GPUIntegerCoordinate std::optional baseArrayLayer; // GPUIntegerCoordinate std::optional arrayLayerCount; // GPUIntegerCoordinate + std::optional swizzle; // string std::optional label; // string }; @@ -47,6 +49,11 @@ struct JSIConverter> { JSIConverter>::fromJSI( runtime, prop, false); } + if (value.hasProperty(runtime, "usage")) { + auto prop = value.getProperty(runtime, "usage"); + result->usage = + JSIConverter>::fromJSI(runtime, prop, false); + } if (value.hasProperty(runtime, "aspect")) { auto prop = value.getProperty(runtime, "aspect"); result->aspect = @@ -73,6 +80,11 @@ struct JSIConverter> { result->arrayLayerCount = JSIConverter>::fromJSI(runtime, prop, false); } + if (value.hasProperty(runtime, "swizzle")) { + auto prop = value.getProperty(runtime, "swizzle"); + result->swizzle = JSIConverter>::fromJSI( + runtime, prop, false); + } if (value.hasProperty(runtime, "label")) { auto prop = value.getProperty(runtime, "label"); result->label = JSIConverter>::fromJSI( @@ -89,4 +101,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h index cc4f82da5..15677d034 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h @@ -62,4 +62,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h index fe521d929..2f76b0100 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h @@ -51,4 +51,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h index 8360ca8c2..12e49c7a7 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h @@ -60,4 +60,4 @@ struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUVertexState.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUVertexState.h index 0a45ed5a7..ea89fe637 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUVertexState.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/GPUVertexState.h @@ -21,7 +21,7 @@ namespace rnwgpu { struct GPUVertexState { std::optional>>> - buffers; // Iterable + buffers; // Iterable< | GPUVertexBufferLayout | null | undefined > std::shared_ptr module; // GPUShaderModule std::optional entryPoint; // string std::optional> @@ -71,4 +71,4 @@ template <> struct JSIConverter> { } }; -} // namespace rnwgpu \ No newline at end of file +} // namespace rnwgpu diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/Unions.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/Unions.h index 3240eaf9d..aba5ddaf1 100644 --- a/packages/webgpu/cpp/rnwgpu/api/descriptors/Unions.h +++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/Unions.h @@ -410,16 +410,22 @@ inline void convertEnumToJSUnion(wgpu::ErrorFilter inEnum, inline void convertJSUnionToEnum(const std::string &inUnion, wgpu::FeatureName *outEnum) { - if (inUnion == "depth-clip-control") { + if (inUnion == "core-features-and-limits") { + *outEnum = wgpu::FeatureName::CoreFeaturesAndLimits; + } else if (inUnion == "depth-clip-control") { *outEnum = wgpu::FeatureName::DepthClipControl; } else if (inUnion == "depth32float-stencil8") { *outEnum = wgpu::FeatureName::Depth32FloatStencil8; } else if (inUnion == "texture-compression-bc") { *outEnum = wgpu::FeatureName::TextureCompressionBC; + } else if (inUnion == "texture-compression-bc-sliced-3d") { + *outEnum = wgpu::FeatureName::TextureCompressionBCSliced3D; } else if (inUnion == "texture-compression-etc2") { *outEnum = wgpu::FeatureName::TextureCompressionETC2; } else if (inUnion == "texture-compression-astc") { *outEnum = wgpu::FeatureName::TextureCompressionASTC; + } else if (inUnion == "texture-compression-astc-sliced-3d") { + *outEnum = wgpu::FeatureName::TextureCompressionASTCSliced3D; } else if (inUnion == "timestamp-query") { *outEnum = wgpu::FeatureName::TimestampQuery; } else if (inUnion == "indirect-first-instance") { @@ -432,111 +438,22 @@ inline void convertJSUnionToEnum(const std::string &inUnion, *outEnum = wgpu::FeatureName::BGRA8UnormStorage; } else if (inUnion == "float32-filterable") { *outEnum = wgpu::FeatureName::Float32Filterable; - } else if (inUnion == "subgroups") { - *outEnum = wgpu::FeatureName::Subgroups; - } else if (inUnion == "dawn-internal-usages") { - *outEnum = wgpu::FeatureName::DawnInternalUsages; - } else if (inUnion == "dawn-multi-planar-formats") { - *outEnum = wgpu::FeatureName::DawnMultiPlanarFormats; - } else if (inUnion == "dawn-native") { - *outEnum = wgpu::FeatureName::DawnNative; - } else if (inUnion == "chromium-experimental-timestamp-query-inside-passes") { - *outEnum = - wgpu::FeatureName::ChromiumExperimentalTimestampQueryInsidePasses; - } else if (inUnion == "implicit-device-synchronization") { - *outEnum = wgpu::FeatureName::ImplicitDeviceSynchronization; - } else if (inUnion == "transient-attachments") { - *outEnum = wgpu::FeatureName::TransientAttachments; - } else if (inUnion == "msaa-render-to-single-sampled") { - *outEnum = wgpu::FeatureName::MSAARenderToSingleSampled; - } else if (inUnion == "dual-source-blending") { - *outEnum = wgpu::FeatureName::DualSourceBlending; - } else if (inUnion == "d3d11-multithread-protected") { - *outEnum = wgpu::FeatureName::D3D11MultithreadProtected; - } else if (inUnion == "angle-texture-sharing") { - *outEnum = wgpu::FeatureName::ANGLETextureSharing; - } else if (inUnion == "chromium-experimental-subgroups-matrix") { - *outEnum = wgpu::FeatureName::ChromiumExperimentalSubgroupMatrix; - } else if (inUnion == "pixel-local-storage-coherent") { - *outEnum = wgpu::FeatureName::PixelLocalStorageCoherent; - } else if (inUnion == "pixel-local-storage-non-coherent") { - *outEnum = wgpu::FeatureName::PixelLocalStorageNonCoherent; - } else if (inUnion == "unorm16-texture-formats") { - *outEnum = wgpu::FeatureName::Unorm16TextureFormats; - } else if (inUnion == "snorm16-texture-formats") { - *outEnum = wgpu::FeatureName::Snorm16TextureFormats; - } else if (inUnion == "multi-planar-format-extended-usages") { - *outEnum = wgpu::FeatureName::MultiPlanarFormatExtendedUsages; - } else if (inUnion == "multi-planar-format-p010") { - *outEnum = wgpu::FeatureName::MultiPlanarFormatP010; - } else if (inUnion == "host-mapped-pointer") { - *outEnum = wgpu::FeatureName::HostMappedPointer; - } else if (inUnion == "multi-planar-render-targets") { - *outEnum = wgpu::FeatureName::MultiPlanarRenderTargets; - } else if (inUnion == "multi-planar-format-nv12a") { - *outEnum = wgpu::FeatureName::MultiPlanarFormatNv12a; - } else if (inUnion == "framebuffer-fetch") { - *outEnum = wgpu::FeatureName::FramebufferFetch; - } else if (inUnion == "buffer-map-extended-usages") { - *outEnum = wgpu::FeatureName::BufferMapExtendedUsages; - } else if (inUnion == "adapter-properties-memory-heaps") { - *outEnum = wgpu::FeatureName::AdapterPropertiesMemoryHeaps; - } else if (inUnion == "adapter-properties-d3d") { - *outEnum = wgpu::FeatureName::AdapterPropertiesD3D; - } else if (inUnion == "adapter-properties-vk") { - *outEnum = wgpu::FeatureName::AdapterPropertiesVk; - } else if (inUnion == "r8unorm-storage") { - *outEnum = wgpu::FeatureName::R8UnormStorage; - } else if (inUnion == "format-capabilities") { - *outEnum = wgpu::FeatureName::DawnFormatCapabilities; - } else if (inUnion == "norm16-texture-formats") { - *outEnum = wgpu::FeatureName::Norm16TextureFormats; - } else if (inUnion == "multi-planar-format-nv16") { - *outEnum = wgpu::FeatureName::MultiPlanarFormatNv16; - } else if (inUnion == "multi-planar-format-nv24") { - *outEnum = wgpu::FeatureName::MultiPlanarFormatNv24; - } else if (inUnion == "multi-planar-format-p210") { - *outEnum = wgpu::FeatureName::MultiPlanarFormatP210; - } else if (inUnion == "multi-planar-format-p410") { - *outEnum = wgpu::FeatureName::MultiPlanarFormatP410; - } else if (inUnion == "shared-texture-memory-vk-dedicated-allocation") { - *outEnum = wgpu::FeatureName::SharedTextureMemoryVkDedicatedAllocation; - } else if (inUnion == "shared-texture-memory-ahardware-buffer") { - *outEnum = wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer; - } else if (inUnion == "shared-texture-memory-dma-buf") { - *outEnum = wgpu::FeatureName::SharedTextureMemoryDmaBuf; - } else if (inUnion == "shared-texture-memory-opaque-fd") { - *outEnum = wgpu::FeatureName::SharedTextureMemoryOpaqueFD; - } else if (inUnion == "shared-texture-memory-zircon-handle") { - *outEnum = wgpu::FeatureName::SharedTextureMemoryZirconHandle; - } else if (inUnion == "shared-texture-memory-dxgi-shared-handle") { - *outEnum = wgpu::FeatureName::SharedTextureMemoryDXGISharedHandle; - } else if (inUnion == "shared-texture-memory-d3d11-texture2d") { - *outEnum = wgpu::FeatureName::SharedTextureMemoryD3D11Texture2D; - } else if (inUnion == "shared-texture-memory-iosurface") { - *outEnum = wgpu::FeatureName::SharedTextureMemoryIOSurface; - } else if (inUnion == "shared-texture-memory-egl-image") { - *outEnum = wgpu::FeatureName::SharedTextureMemoryEGLImage; - } else if (inUnion == "shared-fence-vk-semaphore-opaque-fd") { - *outEnum = wgpu::FeatureName::SharedFenceVkSemaphoreOpaqueFD; - } else if (inUnion == "shared-fence-vk-semaphore-zircon-handle") { - *outEnum = wgpu::FeatureName::SharedFenceVkSemaphoreZirconHandle; - } else if (inUnion == "shared-fence-dxgi-shared-handle") { - *outEnum = wgpu::FeatureName::SharedFenceDXGISharedHandle; - } else if (inUnion == "shared-fence-mtl-shared-event") { - *outEnum = wgpu::FeatureName::SharedFenceMTLSharedEvent; - } else if (inUnion == "shared-buffer-memory-d3d12-resource") { - *outEnum = wgpu::FeatureName::SharedBufferMemoryD3D12Resource; - } else if (inUnion == "static-samplers") { - *outEnum = wgpu::FeatureName::StaticSamplers; - } else if (inUnion == "ycbcr-vulkan-samplers") { - *outEnum = wgpu::FeatureName::YCbCrVulkanSamplers; - } else if (inUnion == "shader-module-compilation-options") { - *outEnum = wgpu::FeatureName::ShaderModuleCompilationOptions; - } else if (inUnion == "dawn-load-resolve-texture") { - *outEnum = wgpu::FeatureName::DawnLoadResolveTexture; + } else if (inUnion == "float32-blendable") { + *outEnum = wgpu::FeatureName::Float32Blendable; } else if (inUnion == "clip-distances") { *outEnum = wgpu::FeatureName::ClipDistances; + } else if (inUnion == "dual-source-blending") { + *outEnum = wgpu::FeatureName::DualSourceBlending; + } else if (inUnion == "subgroups") { + *outEnum = wgpu::FeatureName::Subgroups; + } else if (inUnion == "texture-formats-tier1") { + *outEnum = wgpu::FeatureName::TextureFormatsTier1; + } else if (inUnion == "texture-formats-tier2") { + *outEnum = wgpu::FeatureName::TextureFormatsTier2; + } else if (inUnion == "primitive-index") { + *outEnum = wgpu::FeatureName::PrimitiveIndex; + } else if (inUnion == "texture-component-swizzle") { + *outEnum = wgpu::FeatureName::TextureComponentSwizzle; } else { throw invalidUnion(inUnion); } @@ -545,6 +462,9 @@ inline void convertJSUnionToEnum(const std::string &inUnion, inline void convertEnumToJSUnion(wgpu::FeatureName inEnum, std::string *outUnion) { switch (inEnum) { + case wgpu::FeatureName::CoreFeaturesAndLimits: + *outUnion = "core-features-and-limits"; + break; case wgpu::FeatureName::DepthClipControl: *outUnion = "depth-clip-control"; break; @@ -554,12 +474,18 @@ inline void convertEnumToJSUnion(wgpu::FeatureName inEnum, case wgpu::FeatureName::TextureCompressionBC: *outUnion = "texture-compression-bc"; break; + case wgpu::FeatureName::TextureCompressionBCSliced3D: + *outUnion = "texture-compression-bc-sliced-3d"; + break; case wgpu::FeatureName::TextureCompressionETC2: *outUnion = "texture-compression-etc2"; break; case wgpu::FeatureName::TextureCompressionASTC: *outUnion = "texture-compression-astc"; break; + case wgpu::FeatureName::TextureCompressionASTCSliced3D: + *outUnion = "texture-compression-astc-sliced-3d"; + break; case wgpu::FeatureName::TimestampQuery: *outUnion = "timestamp-query"; break; @@ -578,164 +504,29 @@ inline void convertEnumToJSUnion(wgpu::FeatureName inEnum, case wgpu::FeatureName::Float32Filterable: *outUnion = "float32-filterable"; break; - case wgpu::FeatureName::Subgroups: - *outUnion = "subgroups"; - break; - case wgpu::FeatureName::DawnInternalUsages: - *outUnion = "dawn-internal-usages"; - break; - case wgpu::FeatureName::DawnMultiPlanarFormats: - *outUnion = "dawn-multi-planar-formats"; - break; - case wgpu::FeatureName::DawnNative: - *outUnion = "dawn-native"; + case wgpu::FeatureName::Float32Blendable: + *outUnion = "float32-blendable"; break; - case wgpu::FeatureName::DawnFormatCapabilities: - *outUnion = "format-capabilities"; - break; - case wgpu::FeatureName::ChromiumExperimentalTimestampQueryInsidePasses: - *outUnion = "chromium-experimental-timestamp-query-inside-passes"; - break; - case wgpu::FeatureName::ImplicitDeviceSynchronization: - *outUnion = "implicit-device-synchronization"; - break; - // case wgpu::FeatureName::SurfaceCapabilities: - // *outUnion = "surface-capabilities"; - // break; - case wgpu::FeatureName::TransientAttachments: - *outUnion = "transient-attachments"; - break; - case wgpu::FeatureName::MSAARenderToSingleSampled: - *outUnion = "msaa-render-to-single-sampled"; + case wgpu::FeatureName::ClipDistances: + *outUnion = "clip-distances"; break; case wgpu::FeatureName::DualSourceBlending: *outUnion = "dual-source-blending"; break; - case wgpu::FeatureName::D3D11MultithreadProtected: - *outUnion = "d3d11-multithread-protected"; - break; - case wgpu::FeatureName::ANGLETextureSharing: - *outUnion = "angle-texture-sharing"; - break; - case wgpu::FeatureName::ChromiumExperimentalSubgroupMatrix: - *outUnion = "chromium-experimental-subgroups-matrix"; - break; - case wgpu::FeatureName::PixelLocalStorageCoherent: - *outUnion = "pixel-local-storage-coherent"; - break; - case wgpu::FeatureName::PixelLocalStorageNonCoherent: - *outUnion = "pixel-local-storage-non-coherent"; - break; - case wgpu::FeatureName::Unorm16TextureFormats: - *outUnion = "unorm16-texture-formats"; - break; - case wgpu::FeatureName::Snorm16TextureFormats: - *outUnion = "snorm16-texture-formats"; - break; - case wgpu::FeatureName::MultiPlanarFormatExtendedUsages: - *outUnion = "multi-planar-format-extended-usages"; - break; - case wgpu::FeatureName::MultiPlanarFormatP010: - *outUnion = "multi-planar-format-p010"; - break; - case wgpu::FeatureName::HostMappedPointer: - *outUnion = "host-mapped-pointer"; - break; - case wgpu::FeatureName::MultiPlanarRenderTargets: - *outUnion = "multi-planar-render-targets"; - break; - case wgpu::FeatureName::MultiPlanarFormatNv12a: - *outUnion = "multi-planar-format-nv12a"; - break; - case wgpu::FeatureName::FramebufferFetch: - *outUnion = "framebuffer-fetch"; - break; - case wgpu::FeatureName::BufferMapExtendedUsages: - *outUnion = "buffer-map-extended-usages"; - break; - case wgpu::FeatureName::AdapterPropertiesMemoryHeaps: - *outUnion = "adapter-properties-memory-heaps"; - break; - case wgpu::FeatureName::AdapterPropertiesD3D: - *outUnion = "adapter-properties-d3d"; - break; - case wgpu::FeatureName::AdapterPropertiesVk: - *outUnion = "adapter-properties-vk"; - break; - case wgpu::FeatureName::R8UnormStorage: - *outUnion = "r8unorm-storage"; - break; - case wgpu::FeatureName::Norm16TextureFormats: - *outUnion = "norm16-texture-formats"; - break; - case wgpu::FeatureName::MultiPlanarFormatNv16: - *outUnion = "multi-planar-format-nv16"; - break; - case wgpu::FeatureName::MultiPlanarFormatNv24: - *outUnion = "multi-planar-format-nv24"; - break; - case wgpu::FeatureName::MultiPlanarFormatP210: - *outUnion = "multi-planar-format-p210"; - break; - case wgpu::FeatureName::MultiPlanarFormatP410: - *outUnion = "multi-planar-format-p410"; - break; - case wgpu::FeatureName::SharedTextureMemoryVkDedicatedAllocation: - *outUnion = "shared-texture-memory-vk-dedicated-allocation"; - break; - case wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer: - *outUnion = "shared-texture-memory-ahardware-buffer"; - break; - case wgpu::FeatureName::SharedTextureMemoryDmaBuf: - *outUnion = "shared-texture-memory-dma-buf"; - break; - case wgpu::FeatureName::SharedTextureMemoryOpaqueFD: - *outUnion = "shared-texture-memory-opaque-fd"; - break; - case wgpu::FeatureName::SharedTextureMemoryZirconHandle: - *outUnion = "shared-texture-memory-zircon-handle"; - break; - case wgpu::FeatureName::SharedTextureMemoryDXGISharedHandle: - *outUnion = "shared-texture-memory-dxgi-shared-handle"; - break; - case wgpu::FeatureName::SharedTextureMemoryD3D11Texture2D: - *outUnion = "shared-texture-memory-d3d11-texture2d"; - break; - case wgpu::FeatureName::SharedTextureMemoryIOSurface: - *outUnion = "shared-texture-memory-iosurface"; - break; - case wgpu::FeatureName::SharedTextureMemoryEGLImage: - *outUnion = "shared-texture-memory-egl-image"; - break; - case wgpu::FeatureName::SharedFenceVkSemaphoreOpaqueFD: - *outUnion = "shared-fence-vk-semaphore-opaque-fd"; - break; - case wgpu::FeatureName::SharedFenceVkSemaphoreZirconHandle: - *outUnion = "shared-fence-vk-semaphore-zircon-handle"; - break; - case wgpu::FeatureName::SharedFenceDXGISharedHandle: - *outUnion = "shared-fence-dxgi-shared-handle"; - break; - case wgpu::FeatureName::SharedFenceMTLSharedEvent: - *outUnion = "shared-fence-mtl-shared-event"; - break; - case wgpu::FeatureName::SharedBufferMemoryD3D12Resource: - *outUnion = "shared-buffer-memory-d3d12-resource"; + case wgpu::FeatureName::Subgroups: + *outUnion = "subgroups"; break; - case wgpu::FeatureName::StaticSamplers: - *outUnion = "static-samplers"; + case wgpu::FeatureName::TextureFormatsTier1: + *outUnion = "texture-formats-tier1"; break; - case wgpu::FeatureName::YCbCrVulkanSamplers: - *outUnion = "ycbcr-vulkan-samplers"; + case wgpu::FeatureName::TextureFormatsTier2: + *outUnion = "texture-formats-tier2"; break; - case wgpu::FeatureName::ShaderModuleCompilationOptions: - *outUnion = "shader-module-compilation-options"; + case wgpu::FeatureName::PrimitiveIndex: + *outUnion = "primitive-index"; break; - case wgpu::FeatureName::DawnLoadResolveTexture: - *outUnion = "dawn-load-resolve-texture"; - break; - case wgpu::FeatureName::ClipDistances: - *outUnion = "clip-distances"; + case wgpu::FeatureName::TextureComponentSwizzle: + *outUnion = "texture-component-swizzle"; break; default: throw invalidEnum(inEnum); @@ -1167,6 +958,10 @@ inline void convertJSUnionToEnum(const std::string &inUnion, *outEnum = wgpu::TextureFormat::R8Uint; } else if (inUnion == "r8sint") { *outEnum = wgpu::TextureFormat::R8Sint; + } else if (inUnion == "r16unorm") { + *outEnum = wgpu::TextureFormat::R16Unorm; + } else if (inUnion == "r16snorm") { + *outEnum = wgpu::TextureFormat::R16Snorm; } else if (inUnion == "r16uint") { *outEnum = wgpu::TextureFormat::R16Uint; } else if (inUnion == "r16sint") { @@ -1187,6 +982,10 @@ inline void convertJSUnionToEnum(const std::string &inUnion, *outEnum = wgpu::TextureFormat::R32Sint; } else if (inUnion == "r32float") { *outEnum = wgpu::TextureFormat::R32Float; + } else if (inUnion == "rg16unorm") { + *outEnum = wgpu::TextureFormat::RG16Unorm; + } else if (inUnion == "rg16snorm") { + *outEnum = wgpu::TextureFormat::RG16Snorm; } else if (inUnion == "rg16uint") { *outEnum = wgpu::TextureFormat::RG16Uint; } else if (inUnion == "rg16sint") { @@ -1221,6 +1020,10 @@ inline void convertJSUnionToEnum(const std::string &inUnion, *outEnum = wgpu::TextureFormat::RG32Sint; } else if (inUnion == "rg32float") { *outEnum = wgpu::TextureFormat::RG32Float; + } else if (inUnion == "rgba16unorm") { + *outEnum = wgpu::TextureFormat::RGBA16Unorm; + } else if (inUnion == "rgba16snorm") { + *outEnum = wgpu::TextureFormat::RGBA16Snorm; } else if (inUnion == "rgba16uint") { *outEnum = wgpu::TextureFormat::RGBA16Uint; } else if (inUnion == "rgba16sint") { @@ -1370,6 +1173,12 @@ inline void convertEnumToJSUnion(wgpu::TextureFormat inEnum, case wgpu::TextureFormat::R8Sint: *outUnion = "r8sint"; break; + case wgpu::TextureFormat::R16Unorm: + *outUnion = "r16unorm"; + break; + case wgpu::TextureFormat::R16Snorm: + *outUnion = "r16snorm"; + break; case wgpu::TextureFormat::R16Uint: *outUnion = "r16uint"; break; @@ -1400,6 +1209,12 @@ inline void convertEnumToJSUnion(wgpu::TextureFormat inEnum, case wgpu::TextureFormat::R32Float: *outUnion = "r32float"; break; + case wgpu::TextureFormat::RG16Unorm: + *outUnion = "rg16unorm"; + break; + case wgpu::TextureFormat::RG16Snorm: + *outUnion = "rg16snorm"; + break; case wgpu::TextureFormat::RG16Uint: *outUnion = "rg16uint"; break; @@ -1451,6 +1266,12 @@ inline void convertEnumToJSUnion(wgpu::TextureFormat inEnum, case wgpu::TextureFormat::RG32Float: *outUnion = "rg32float"; break; + case wgpu::TextureFormat::RGBA16Unorm: + *outUnion = "rgba16unorm"; + break; + case wgpu::TextureFormat::RGBA16Snorm: + *outUnion = "rgba16snorm"; + break; case wgpu::TextureFormat::RGBA16Uint: *outUnion = "rgba16uint"; break; @@ -1732,20 +1553,30 @@ inline void convertEnumToJSUnion(wgpu::TextureViewDimension inEnum, inline void convertJSUnionToEnum(const std::string &inUnion, wgpu::VertexFormat *outEnum) { - if (inUnion == "uint32") { + if (inUnion == "uint16") { + *outEnum = wgpu::VertexFormat::Uint16; + } else if (inUnion == "uint32") { *outEnum = wgpu::VertexFormat::Uint32; + } else if (inUnion == "uint8") { + *outEnum = wgpu::VertexFormat::Uint8; } else if (inUnion == "uint8x2") { *outEnum = wgpu::VertexFormat::Uint8x2; } else if (inUnion == "uint8x4") { *outEnum = wgpu::VertexFormat::Uint8x4; + } else if (inUnion == "sint8") { + *outEnum = wgpu::VertexFormat::Sint8; } else if (inUnion == "sint8x2") { *outEnum = wgpu::VertexFormat::Sint8x2; } else if (inUnion == "sint8x4") { *outEnum = wgpu::VertexFormat::Sint8x4; + } else if (inUnion == "unorm8") { + *outEnum = wgpu::VertexFormat::Unorm8; } else if (inUnion == "unorm8x2") { *outEnum = wgpu::VertexFormat::Unorm8x2; } else if (inUnion == "unorm8x4") { *outEnum = wgpu::VertexFormat::Unorm8x4; + } else if (inUnion == "snorm8") { + *outEnum = wgpu::VertexFormat::Snorm8; } else if (inUnion == "snorm8x2") { *outEnum = wgpu::VertexFormat::Snorm8x2; } else if (inUnion == "snorm8x4") { @@ -1754,18 +1585,26 @@ inline void convertJSUnionToEnum(const std::string &inUnion, *outEnum = wgpu::VertexFormat::Uint16x2; } else if (inUnion == "uint16x4") { *outEnum = wgpu::VertexFormat::Uint16x4; + } else if (inUnion == "sint16") { + *outEnum = wgpu::VertexFormat::Sint16; } else if (inUnion == "sint16x2") { *outEnum = wgpu::VertexFormat::Sint16x2; } else if (inUnion == "sint16x4") { *outEnum = wgpu::VertexFormat::Sint16x4; + } else if (inUnion == "unorm16") { + *outEnum = wgpu::VertexFormat::Unorm16; } else if (inUnion == "unorm16x2") { *outEnum = wgpu::VertexFormat::Unorm16x2; } else if (inUnion == "unorm16x4") { *outEnum = wgpu::VertexFormat::Unorm16x4; + } else if (inUnion == "snorm16") { + *outEnum = wgpu::VertexFormat::Snorm16; } else if (inUnion == "snorm16x2") { *outEnum = wgpu::VertexFormat::Snorm16x2; } else if (inUnion == "snorm16x4") { *outEnum = wgpu::VertexFormat::Snorm16x4; + } else if (inUnion == "float16") { + *outEnum = wgpu::VertexFormat::Float16; } else if (inUnion == "float16x2") { *outEnum = wgpu::VertexFormat::Float16x2; } else if (inUnion == "float16x4") { @@ -1794,6 +1633,8 @@ inline void convertJSUnionToEnum(const std::string &inUnion, *outEnum = wgpu::VertexFormat::Sint32x4; } else if (inUnion == "unorm10-10-10-2") { *outEnum = wgpu::VertexFormat::Unorm10_10_10_2; + } else if (inUnion == "unorm8x4-bgra") { + *outEnum = wgpu::VertexFormat::Unorm8x4BGRA; } else { throw invalidUnion(inUnion); } @@ -1802,27 +1643,42 @@ inline void convertJSUnionToEnum(const std::string &inUnion, inline void convertEnumToJSUnion(wgpu::VertexFormat inEnum, std::string *outUnion) { switch (inEnum) { + case wgpu::VertexFormat::Uint16: + *outUnion = "uint16"; + break; case wgpu::VertexFormat::Uint32: *outUnion = "uint32"; break; + case wgpu::VertexFormat::Uint8: + *outUnion = "uint8"; + break; case wgpu::VertexFormat::Uint8x2: *outUnion = "uint8x2"; break; case wgpu::VertexFormat::Uint8x4: *outUnion = "uint8x4"; break; + case wgpu::VertexFormat::Sint8: + *outUnion = "sint8"; + break; case wgpu::VertexFormat::Sint8x2: *outUnion = "sint8x2"; break; case wgpu::VertexFormat::Sint8x4: *outUnion = "sint8x4"; break; + case wgpu::VertexFormat::Unorm8: + *outUnion = "unorm8"; + break; case wgpu::VertexFormat::Unorm8x2: *outUnion = "unorm8x2"; break; case wgpu::VertexFormat::Unorm8x4: *outUnion = "unorm8x4"; break; + case wgpu::VertexFormat::Snorm8: + *outUnion = "snorm8"; + break; case wgpu::VertexFormat::Snorm8x2: *outUnion = "snorm8x2"; break; @@ -1835,24 +1691,36 @@ inline void convertEnumToJSUnion(wgpu::VertexFormat inEnum, case wgpu::VertexFormat::Uint16x4: *outUnion = "uint16x4"; break; + case wgpu::VertexFormat::Sint16: + *outUnion = "sint16"; + break; case wgpu::VertexFormat::Sint16x2: *outUnion = "sint16x2"; break; case wgpu::VertexFormat::Sint16x4: *outUnion = "sint16x4"; break; + case wgpu::VertexFormat::Unorm16: + *outUnion = "unorm16"; + break; case wgpu::VertexFormat::Unorm16x2: *outUnion = "unorm16x2"; break; case wgpu::VertexFormat::Unorm16x4: *outUnion = "unorm16x4"; break; + case wgpu::VertexFormat::Snorm16: + *outUnion = "snorm16"; + break; case wgpu::VertexFormat::Snorm16x2: *outUnion = "snorm16x2"; break; case wgpu::VertexFormat::Snorm16x4: *outUnion = "snorm16x4"; break; + case wgpu::VertexFormat::Float16: + *outUnion = "float16"; + break; case wgpu::VertexFormat::Float16x2: *outUnion = "float16x2"; break; @@ -1895,6 +1763,9 @@ inline void convertEnumToJSUnion(wgpu::VertexFormat inEnum, case wgpu::VertexFormat::Unorm10_10_10_2: *outUnion = "unorm10-10-10-2"; break; + case wgpu::VertexFormat::Unorm8x4BGRA: + *outUnion = "unorm8x4-bgra"; + break; default: throw invalidEnum(inEnum); } diff --git a/packages/webgpu/scripts/codegen/codegen.ts b/packages/webgpu/scripts/codegen/codegen.ts index 216da9a4f..f0e6d4d4e 100644 --- a/packages/webgpu/scripts/codegen/codegen.ts +++ b/packages/webgpu/scripts/codegen/codegen.ts @@ -244,6 +244,9 @@ const toSkip = [ "GPUTexelCopyBufferInfo", "GPUTexelCopyBufferLayout", "GPUTexelCopyTextureInfo", + // Descriptors with view type changes (GPUTexture | GPUTextureView) + "GPURenderPassColorAttachment", + "GPURenderPassDepthStencilAttachment", ]; sourceFile diff --git a/packages/webgpu/scripts/codegen/model/dawn.ts b/packages/webgpu/scripts/codegen/model/dawn.ts index 4a2e92ace..12b11b920 100644 --- a/packages/webgpu/scripts/codegen/model/dawn.ts +++ b/packages/webgpu/scripts/codegen/model/dawn.ts @@ -47,6 +47,10 @@ export const resolved: Record< > = { GPU: { ctor: `explicit GPU(jsi::Runtime &runtime);`, + extraDeps: ["GPUAdapter"], + }, + GPUAdapter: { + extraDeps: ["GPUDevice"], }, // GPUDevice is skipped from codegen - maintained manually GPUBuffer: { @@ -82,6 +86,17 @@ export const resolved: Record< }, GPUCommandEncoder: { methods: { + copyBufferToBuffer: { + deps: ["memory", "GPUBuffer"], + returnType: "void", + args: [ + { name: "source", type: "std::shared_ptr" }, + { name: "sourceOffset", type: "uint64_t" }, + { name: "destination", type: "std::shared_ptr" }, + { name: "destinationOffset", type: "uint64_t" }, + { name: "size", type: "uint64_t" }, + ], + }, copyTextureToBuffer: { deps: [ "memory", @@ -240,6 +255,7 @@ export const resolved: Record< }`, }, GPUShaderModule: { + extraDeps: ["GPUCompilationInfo"], extra: `size_t getMemoryPressure() override { // Estimate memory usage for compiled shader module // Shaders can vary widely, but a reasonable estimate is 8-16KB for typical shaders diff --git a/packages/webgpu/scripts/codegen/templates/HybridObject.ts b/packages/webgpu/scripts/codegen/templates/HybridObject.ts index 1b1aa6962..d848adfbe 100644 --- a/packages/webgpu/scripts/codegen/templates/HybridObject.ts +++ b/packages/webgpu/scripts/codegen/templates/HybridObject.ts @@ -71,21 +71,29 @@ export const getHybridObject = (decl: InterfaceDeclaration) => { }); return { type, name: signature.getName() }; }); + const seenMethods = new Set(); const methods = decl .getMethods() .filter((m) => !deprecatedMethods.includes(m.getName())) .map((signature) => { - const resolved = resolveMethod(className, signature.getName()); + const methodName = signature.getName(); + // Skip if we've already processed this method (handles overloads) + if (seenMethods.has(methodName)) { + return null; + } + seenMethods.add(methodName); + + const resolved = resolveMethod(className, methodName); if (resolved) { resolved.deps.forEach((dep) => { dependencies.add(dep); }); return { - name: signature.getName(), + name: methodName, ...resolved, }; } - const nativeMethod = resolveNative(className, signature.getName()); + const nativeMethod = resolveNative(className, methodName); const params = signature.getParameters(); const returnType = resolveType(signature.getReturnType(), { @@ -93,12 +101,12 @@ export const getHybridObject = (decl: InterfaceDeclaration) => { dependencies, typeNode: signature.getReturnTypeNode(), className, - name: signature.getName(), - debug: `Return value of ${className}.${signature.getName()}`, + name: methodName, + debug: `Return value of ${className}.${methodName}`, native: nativeMethod ? nativeMethod?.returns : undefined, }); return { - name: signature.getName(), + name: methodName, returnType, args: params.map((param, i) => ({ name: param.getName(), @@ -108,7 +116,7 @@ export const getHybridObject = (decl: InterfaceDeclaration) => { typeNode: param.getTypeNode(), className, name: param.getName(), - debug: `Parameter ${param.getName()} of ${className}.${signature.getName()}`, + debug: `Parameter ${param.getName()} of ${className}.${methodName}`, native: nativeMethod && nativeMethod?.args && nativeMethod?.args[i] ? nativeMethod?.args?.[i].type @@ -116,7 +124,8 @@ export const getHybridObject = (decl: InterfaceDeclaration) => { }), })), }; - }); + }) + .filter((m) => m !== null); const hasLabel = decl.getProperty("label") !== undefined; const instanceName = `wgpu::${instanceAliases[className] || className.substring(3)}`; const ctor = resolveCtor(className); diff --git a/packages/webgpu/scripts/codegen/templates/Unions.ts b/packages/webgpu/scripts/codegen/templates/Unions.ts index 820a62b29..7936cc91c 100644 --- a/packages/webgpu/scripts/codegen/templates/Unions.ts +++ b/packages/webgpu/scripts/codegen/templates/Unions.ts @@ -23,7 +23,8 @@ ${unions .filter( (union) => union.name !== "GPUCanvasAlphaMode" && - union.name !== "GPUPipelineErrorReason", + union.name !== "GPUPipelineErrorReason" && + union.name !== "GPUCanvasToneMappingMode", ) .map((union) => Union(union)) .join("\n")}