diff --git a/DEPS b/DEPS index 37cd645bc8..fed43d7694 100644 --- a/DEPS +++ b/DEPS @@ -162,7 +162,7 @@ deps = { 'condition': 'dawn_node', }, 'third_party/gpuweb': { - 'url': '{github_git}/gpuweb/gpuweb.git@67edc187f5305a72456663c34d51153601b79f3b', + 'url': '{github_git}/gpuweb/gpuweb.git@0aadaca4c53ca131aa19708c1d2b1bed56da1118', 'condition': 'dawn_node', }, diff --git a/src/dawn_node/binding/Converter.cpp b/src/dawn_node/binding/Converter.cpp index e2a168f34b..a0fc7e44ff 100644 --- a/src/dawn_node/binding/Converter.cpp +++ b/src/dawn_node/binding/Converter.cpp @@ -283,7 +283,8 @@ namespace wgpu::binding { out = wgpu::TextureFormat::Stencil8; return true; case interop::GPUTextureFormat::kDepth16Unorm: - break; // TODO(crbug.com/dawn/1130): Unsupported. + out = wgpu::TextureFormat::Depth16Unorm; + return true; case interop::GPUTextureFormat::kDepth24Plus: out = wgpu::TextureFormat::Depth24Plus; return true; @@ -293,6 +294,12 @@ namespace wgpu::binding { case interop::GPUTextureFormat::kDepth32Float: out = wgpu::TextureFormat::Depth32Float; return true; + case interop::GPUTextureFormat::kDepth24UnormStencil8: + out = wgpu::TextureFormat::Depth24UnormStencil8; + return true; + case interop::GPUTextureFormat::kDepth32FloatStencil8: + out = wgpu::TextureFormat::Depth32FloatStencil8; + return true; case interop::GPUTextureFormat::kBc1RgbaUnorm: out = wgpu::TextureFormat::BC1RGBAUnorm; return true; @@ -335,12 +342,121 @@ namespace wgpu::binding { case interop::GPUTextureFormat::kBc7RgbaUnormSrgb: out = wgpu::TextureFormat::BC7RGBAUnormSrgb; return true; - case interop::GPUTextureFormat::kDepth24UnormStencil8: - break; // TODO(crbug.com/dawn/1130): Unsupported. - case interop::GPUTextureFormat::kDepth32FloatStencil8: - break; // TODO(crbug.com/dawn/1130): Unsupported. + case interop::GPUTextureFormat::kEtc2Rgb8Unorm: + out = wgpu::TextureFormat::ETC2RGB8Unorm; + return true; + case interop::GPUTextureFormat::kEtc2Rgb8UnormSrgb: + out = wgpu::TextureFormat::ETC2RGB8UnormSrgb; + return true; + case interop::GPUTextureFormat::kEtc2Rgb8A1Unorm: + out = wgpu::TextureFormat::ETC2RGB8A1Unorm; + return true; + case interop::GPUTextureFormat::kEtc2Rgb8A1UnormSrgb: + out = wgpu::TextureFormat::ETC2RGB8A1UnormSrgb; + return true; + case interop::GPUTextureFormat::kEtc2Rgba8Unorm: + out = wgpu::TextureFormat::ETC2RGBA8Unorm; + return true; + case interop::GPUTextureFormat::kEtc2Rgba8UnormSrgb: + out = wgpu::TextureFormat::ETC2RGBA8UnormSrgb; + return true; + case interop::GPUTextureFormat::kEacR11Unorm: + out = wgpu::TextureFormat::EACR11Unorm; + return true; + case interop::GPUTextureFormat::kEacR11Snorm: + out = wgpu::TextureFormat::EACR11Snorm; + return true; + case interop::GPUTextureFormat::kEacRg11Unorm: + out = wgpu::TextureFormat::EACRG11Unorm; + return true; + case interop::GPUTextureFormat::kEacRg11Snorm: + out = wgpu::TextureFormat::EACRG11Snorm; + return true; + case interop::GPUTextureFormat::kAstc4X4Unorm: + out = wgpu::TextureFormat::ASTC4x4Unorm; + return true; + case interop::GPUTextureFormat::kAstc4X4UnormSrgb: + out = wgpu::TextureFormat::ASTC4x4UnormSrgb; + return true; + case interop::GPUTextureFormat::kAstc5X4Unorm: + out = wgpu::TextureFormat::ASTC5x4Unorm; + return true; + case interop::GPUTextureFormat::kAstc5X4UnormSrgb: + out = wgpu::TextureFormat::ASTC5x4UnormSrgb; + return true; + case interop::GPUTextureFormat::kAstc5X5Unorm: + out = wgpu::TextureFormat::ASTC5x5Unorm; + return true; + case interop::GPUTextureFormat::kAstc5X5UnormSrgb: + out = wgpu::TextureFormat::ASTC5x5UnormSrgb; + return true; + case interop::GPUTextureFormat::kAstc6X5Unorm: + out = wgpu::TextureFormat::ASTC6x5Unorm; + return true; + case interop::GPUTextureFormat::kAstc6X5UnormSrgb: + out = wgpu::TextureFormat::ASTC6x5UnormSrgb; + return true; + case interop::GPUTextureFormat::kAstc6X6Unorm: + out = wgpu::TextureFormat::ASTC6x6Unorm; + return true; + case interop::GPUTextureFormat::kAstc6X6UnormSrgb: + out = wgpu::TextureFormat::ASTC6x6UnormSrgb; + return true; + case interop::GPUTextureFormat::kAstc8X5Unorm: + out = wgpu::TextureFormat::ASTC8x5Unorm; + return true; + case interop::GPUTextureFormat::kAstc8X5UnormSrgb: + out = wgpu::TextureFormat::ASTC8x5UnormSrgb; + return true; + case interop::GPUTextureFormat::kAstc8X6Unorm: + out = wgpu::TextureFormat::ASTC8x6Unorm; + return true; + case interop::GPUTextureFormat::kAstc8X6UnormSrgb: + out = wgpu::TextureFormat::ASTC8x6UnormSrgb; + return true; + case interop::GPUTextureFormat::kAstc8X8Unorm: + out = wgpu::TextureFormat::ASTC8x8Unorm; + return true; + case interop::GPUTextureFormat::kAstc8X8UnormSrgb: + out = wgpu::TextureFormat::ASTC8x8UnormSrgb; + return true; + case interop::GPUTextureFormat::kAstc10X5Unorm: + out = wgpu::TextureFormat::ASTC10x5Unorm; + return true; + case interop::GPUTextureFormat::kAstc10X5UnormSrgb: + out = wgpu::TextureFormat::ASTC10x5UnormSrgb; + return true; + case interop::GPUTextureFormat::kAstc10X6Unorm: + out = wgpu::TextureFormat::ASTC10x6Unorm; + return true; + case interop::GPUTextureFormat::kAstc10X6UnormSrgb: + out = wgpu::TextureFormat::ASTC10x6UnormSrgb; + return true; + case interop::GPUTextureFormat::kAstc10X8Unorm: + out = wgpu::TextureFormat::ASTC10x8Unorm; + return true; + case interop::GPUTextureFormat::kAstc10X8UnormSrgb: + out = wgpu::TextureFormat::ASTC10x8UnormSrgb; + return true; + case interop::GPUTextureFormat::kAstc10X10Unorm: + out = wgpu::TextureFormat::ASTC10x10Unorm; + return true; + case interop::GPUTextureFormat::kAstc10X10UnormSrgb: + out = wgpu::TextureFormat::ASTC10x10UnormSrgb; + return true; + case interop::GPUTextureFormat::kAstc12X10Unorm: + out = wgpu::TextureFormat::ASTC12x10Unorm; + return true; + case interop::GPUTextureFormat::kAstc12X10UnormSrgb: + out = wgpu::TextureFormat::ASTC12x12UnormSrgb; + return true; + case interop::GPUTextureFormat::kAstc12X12Unorm: + out = wgpu::TextureFormat::ASTC12x12Unorm; + return true; + case interop::GPUTextureFormat::kAstc12X12UnormSrgb: + out = wgpu::TextureFormat::ASTC12x12UnormSrgb; + return true; } - // TODO(crbug.com/dawn/1130): Add ASTC and ETC formats. Napi::Error::New(env, "invalid value for GPUTextureFormat").ThrowAsJavaScriptException(); return false; } @@ -1064,9 +1180,6 @@ namespace wgpu::binding { case interop::GPUQueryType::kOcclusion: out = wgpu::QueryType::Occlusion; return true; - case interop::GPUQueryType::kPipelineStatistics: - out = wgpu::QueryType::PipelineStatistics; - return true; case interop::GPUQueryType::kTimestamp: out = wgpu::QueryType::Timestamp; return true; @@ -1075,31 +1188,6 @@ namespace wgpu::binding { return false; } - bool Converter::Convert(wgpu::PipelineStatisticName& out, - const interop::GPUPipelineStatisticName& in) { - out = wgpu::PipelineStatisticName::VertexShaderInvocations; - switch (in) { - case interop::GPUPipelineStatisticName::kVertexShaderInvocations: - out = wgpu::PipelineStatisticName::VertexShaderInvocations; - return true; - case interop::GPUPipelineStatisticName::kClipperInvocations: - out = wgpu::PipelineStatisticName::ClipperInvocations; - return true; - case interop::GPUPipelineStatisticName::kClipperPrimitivesOut: - out = wgpu::PipelineStatisticName::ClipperPrimitivesOut; - return true; - case interop::GPUPipelineStatisticName::kFragmentShaderInvocations: - out = wgpu::PipelineStatisticName::FragmentShaderInvocations; - return true; - case interop::GPUPipelineStatisticName::kComputeShaderInvocations: - out = wgpu::PipelineStatisticName::ComputeShaderInvocations; - return true; - } - Napi::Error::New(env, "invalid value for GPUPipelineStatisticName") - .ThrowAsJavaScriptException(); - return false; - } - bool Converter::Convert(wgpu::AddressMode& out, const interop::GPUAddressMode& in) { out = wgpu::AddressMode::Repeat; switch (in) { diff --git a/src/dawn_node/binding/Converter.h b/src/dawn_node/binding/Converter.h index cacba0eb35..3af900ad7a 100644 --- a/src/dawn_node/binding/Converter.h +++ b/src/dawn_node/binding/Converter.h @@ -241,9 +241,6 @@ namespace wgpu::binding { [[nodiscard]] bool Convert(wgpu::QueryType& out, const interop::GPUQueryType& in); - [[nodiscard]] bool Convert(wgpu::PipelineStatisticName& out, - const interop::GPUPipelineStatisticName& in); - [[nodiscard]] bool Convert(wgpu::AddressMode& out, const interop::GPUAddressMode& in); [[nodiscard]] bool Convert(wgpu::FilterMode& out, const interop::GPUFilterMode& in); diff --git a/src/dawn_node/binding/GPUAdapter.cpp b/src/dawn_node/binding/GPUAdapter.cpp index 95667ab451..44c70d4fce 100644 --- a/src/dawn_node/binding/GPUAdapter.cpp +++ b/src/dawn_node/binding/GPUAdapter.cpp @@ -59,22 +59,31 @@ namespace wgpu::binding { class Features : public interop::GPUSupportedFeatures { public: Features(WGPUDeviceProperties properties) { - if (properties.depthClamping) { - enabled_.emplace(interop::GPUFeatureName::kDepthClamping); + if (properties.depth24UnormStencil8) { + enabled_.emplace(interop::GPUFeatureName::kDepth24UnormStencil8); } - if (properties.pipelineStatisticsQuery) { - enabled_.emplace(interop::GPUFeatureName::kPipelineStatisticsQuery); + if (properties.depth32FloatStencil8) { + enabled_.emplace(interop::GPUFeatureName::kDepth32FloatStencil8); + } + if (properties.timestampQuery) { + enabled_.emplace(interop::GPUFeatureName::kTimestampQuery); } if (properties.textureCompressionBC) { enabled_.emplace(interop::GPUFeatureName::kTextureCompressionBc); } + if (properties.textureCompressionETC2) { + enabled_.emplace(interop::GPUFeatureName::kTextureCompressionEtc2); + } + if (properties.textureCompressionASTC) { + enabled_.emplace(interop::GPUFeatureName::kTextureCompressionAstc); + } if (properties.timestampQuery) { enabled_.emplace(interop::GPUFeatureName::kTimestampQuery); } - // TODO(crbug.com/dawn/1130) - // interop::GPUFeatureName::kDepth24UnormStencil8: - // interop::GPUFeatureName::kDepth32FloatStencil8: + // TODO(dawn:1123) add support for these extensions when possible. + // wgpu::interop::GPUFeatureName::kIndirectFirstInstance + // wgpu::interop::GPUFeatureName::kDepthClipControl } bool has(interop::GPUFeatureName feature) { @@ -175,21 +184,28 @@ namespace wgpu::binding { // See src/dawn_native/Features.cpp for enum <-> string mappings. for (auto required : descriptor.requiredFeatures) { switch (required) { - case interop::GPUFeatureName::kDepthClamping: - requiredFeatures.emplace_back(wgpu::FeatureName::DepthClamping); - continue; - case interop::GPUFeatureName::kPipelineStatisticsQuery: - requiredFeatures.emplace_back(wgpu::FeatureName::PipelineStatisticsQuery); - continue; case interop::GPUFeatureName::kTextureCompressionBc: requiredFeatures.emplace_back(wgpu::FeatureName::TextureCompressionBC); continue; + case interop::GPUFeatureName::kTextureCompressionEtc2: + requiredFeatures.emplace_back(wgpu::FeatureName::TextureCompressionETC2); + continue; + case interop::GPUFeatureName::kTextureCompressionAstc: + requiredFeatures.emplace_back(wgpu::FeatureName::TextureCompressionASTC); + continue; case interop::GPUFeatureName::kTimestampQuery: requiredFeatures.emplace_back(wgpu::FeatureName::TimestampQuery); continue; case interop::GPUFeatureName::kDepth24UnormStencil8: + requiredFeatures.emplace_back(wgpu::FeatureName::Depth24UnormStencil8); + continue; case interop::GPUFeatureName::kDepth32FloatStencil8: - continue; // TODO(crbug.com/dawn/1130) + requiredFeatures.emplace_back(wgpu::FeatureName::Depth32FloatStencil8); + continue; + case interop::GPUFeatureName::kDepthClipControl: + case interop::GPUFeatureName::kIndirectFirstInstance: + // TODO(dawn:1123) Add support for these extensions when possible. + continue; } UNIMPLEMENTED("required: ", required); } diff --git a/src/dawn_node/binding/GPUCommandBuffer.cpp b/src/dawn_node/binding/GPUCommandBuffer.cpp index 461c6d92dd..9521871065 100644 --- a/src/dawn_node/binding/GPUCommandBuffer.cpp +++ b/src/dawn_node/binding/GPUCommandBuffer.cpp @@ -25,10 +25,6 @@ namespace wgpu::binding { GPUCommandBuffer::GPUCommandBuffer(wgpu::CommandBuffer cmd_buf) : cmd_buf_(std::move(cmd_buf)) { } - interop::Promise GPUCommandBuffer::getExecutionTime(Napi::Env) { - UNIMPLEMENTED(); - }; - std::optional GPUCommandBuffer::getLabel(Napi::Env) { UNIMPLEMENTED(); } diff --git a/src/dawn_node/binding/GPUCommandBuffer.h b/src/dawn_node/binding/GPUCommandBuffer.h index 8b35c21925..89a6056c4c 100644 --- a/src/dawn_node/binding/GPUCommandBuffer.h +++ b/src/dawn_node/binding/GPUCommandBuffer.h @@ -34,7 +34,6 @@ namespace wgpu::binding { } // interop::GPUCommandBuffer interface compliance - interop::Promise getExecutionTime(Napi::Env) override; std::optional getLabel(Napi::Env) override; void setLabel(Napi::Env, std::optional value) override; diff --git a/src/dawn_node/binding/GPUCommandEncoder.cpp b/src/dawn_node/binding/GPUCommandEncoder.cpp index d86cebf69c..b475de4e92 100644 --- a/src/dawn_node/binding/GPUCommandEncoder.cpp +++ b/src/dawn_node/binding/GPUCommandEncoder.cpp @@ -38,12 +38,14 @@ namespace wgpu::binding { Converter conv(env); wgpu::RenderPassDescriptor desc{}; + // TODO(dawn:1250) handle timestampWrites if (!conv(desc.colorAttachments, desc.colorAttachmentCount, descriptor.colorAttachments) || !conv(desc.depthStencilAttachment, descriptor.depthStencilAttachment) || !conv(desc.label, descriptor.label) || !conv(desc.occlusionQuerySet, descriptor.occlusionQuerySet)) { return {}; } + return interop::GPURenderPassEncoder::Create( env, enc_.BeginRenderPass(&desc)); } @@ -52,10 +54,27 @@ namespace wgpu::binding { Napi::Env env, interop::GPUComputePassDescriptor descriptor) { wgpu::ComputePassDescriptor desc{}; + // TODO(dawn:1250) handle timestampWrites return interop::GPUComputePassEncoder::Create( env, enc_.BeginComputePass(&desc)); } + void GPUCommandEncoder::clearBuffer(Napi::Env env, + interop::Interface buffer, + interop::GPUSize64 offset, + std::optional size) { + Converter conv(env); + + wgpu::Buffer b{}; + uint64_t s = wgpu::kWholeSize; + if (!conv(b, buffer) || // + !conv(s, size)) { + return; + } + + enc_.ClearBuffer(b, offset, s); + } + void GPUCommandEncoder::copyBufferToBuffer(Napi::Env env, interop::Interface source, interop::GPUSize64 sourceOffset, diff --git a/src/dawn_node/binding/GPUCommandEncoder.h b/src/dawn_node/binding/GPUCommandEncoder.h index 3402c7861e..ed6152639d 100644 --- a/src/dawn_node/binding/GPUCommandEncoder.h +++ b/src/dawn_node/binding/GPUCommandEncoder.h @@ -35,6 +35,10 @@ namespace wgpu::binding { interop::Interface beginComputePass( Napi::Env, interop::GPUComputePassDescriptor descriptor) override; + void clearBuffer(Napi::Env, + interop::Interface buffer, + interop::GPUSize64 offset, + std::optional size) override; void copyBufferToBuffer(Napi::Env, interop::Interface source, interop::GPUSize64 sourceOffset, diff --git a/src/dawn_node/binding/GPUComputePassEncoder.cpp b/src/dawn_node/binding/GPUComputePassEncoder.cpp index d827d84bc8..08b1fd2463 100644 --- a/src/dawn_node/binding/GPUComputePassEncoder.cpp +++ b/src/dawn_node/binding/GPUComputePassEncoder.cpp @@ -50,30 +50,6 @@ namespace wgpu::binding { enc_.DispatchIndirect(*indirectBuffer.As(), indirectOffset); } - void GPUComputePassEncoder::beginPipelineStatisticsQuery( - Napi::Env, - interop::Interface querySet, - interop::GPUSize32 queryIndex) { - UNIMPLEMENTED(); - } - - void GPUComputePassEncoder::endPipelineStatisticsQuery(Napi::Env) { - UNIMPLEMENTED(); - } - - void GPUComputePassEncoder::writeTimestamp(Napi::Env env, - interop::Interface querySet, - interop::GPUSize32 queryIndex) { - Converter conv(env); - - wgpu::QuerySet q{}; - if (!conv(q, querySet)) { - return; - } - - enc_.WriteTimestamp(q, queryIndex); - } - void GPUComputePassEncoder::endPass(Napi::Env) { enc_.EndPass(); } diff --git a/src/dawn_node/binding/GPUComputePassEncoder.h b/src/dawn_node/binding/GPUComputePassEncoder.h index faf0859851..b7199ac970 100644 --- a/src/dawn_node/binding/GPUComputePassEncoder.h +++ b/src/dawn_node/binding/GPUComputePassEncoder.h @@ -43,13 +43,6 @@ namespace wgpu::binding { void dispatchIndirect(Napi::Env, interop::Interface indirectBuffer, interop::GPUSize64 indirectOffset) override; - void beginPipelineStatisticsQuery(Napi::Env, - interop::Interface querySet, - interop::GPUSize32 queryIndex) override; - void endPipelineStatisticsQuery(Napi::Env) override; - void writeTimestamp(Napi::Env, - interop::Interface querySet, - interop::GPUSize32 queryIndex) override; void endPass(Napi::Env) override; void setBindGroup(Napi::Env, interop::GPUIndex32 index, diff --git a/src/dawn_node/binding/GPUDevice.cpp b/src/dawn_node/binding/GPUDevice.cpp index cddab093b1..2d09df7db9 100644 --- a/src/dawn_node/binding/GPUDevice.cpp +++ b/src/dawn_node/binding/GPUDevice.cpp @@ -413,9 +413,7 @@ namespace wgpu::binding { wgpu::QuerySetDescriptor desc{}; if (!conv(desc.label, descriptor.label) || !conv(desc.type, descriptor.type) || - !conv(desc.count, descriptor.count) || - !conv(desc.pipelineStatistics, desc.pipelineStatisticsCount, - descriptor.pipelineStatistics)) { + !conv(desc.count, descriptor.count)) { return {}; } diff --git a/src/dawn_node/binding/GPURenderPassEncoder.cpp b/src/dawn_node/binding/GPURenderPassEncoder.cpp index 128cbf9230..3306259971 100644 --- a/src/dawn_node/binding/GPURenderPassEncoder.cpp +++ b/src/dawn_node/binding/GPURenderPassEncoder.cpp @@ -71,30 +71,6 @@ namespace wgpu::binding { enc_.EndOcclusionQuery(); } - void GPURenderPassEncoder::beginPipelineStatisticsQuery( - Napi::Env, - interop::Interface querySet, - interop::GPUSize32 queryIndex) { - UNIMPLEMENTED(); - } - - void GPURenderPassEncoder::endPipelineStatisticsQuery(Napi::Env) { - UNIMPLEMENTED(); - } - - void GPURenderPassEncoder::writeTimestamp(Napi::Env env, - interop::Interface querySet, - interop::GPUSize32 queryIndex) { - Converter conv(env); - - wgpu::QuerySet q{}; - if (!conv(q, querySet)) { - return; - } - - enc_.WriteTimestamp(q, queryIndex); - } - void GPURenderPassEncoder::executeBundles( Napi::Env env, std::vector> bundles_in) { diff --git a/src/dawn_node/binding/GPURenderPassEncoder.h b/src/dawn_node/binding/GPURenderPassEncoder.h index 452dc1aeff..ecca2fbae8 100644 --- a/src/dawn_node/binding/GPURenderPassEncoder.h +++ b/src/dawn_node/binding/GPURenderPassEncoder.h @@ -50,13 +50,6 @@ namespace wgpu::binding { void setStencilReference(Napi::Env, interop::GPUStencilValue reference) override; void beginOcclusionQuery(Napi::Env, interop::GPUSize32 queryIndex) override; void endOcclusionQuery(Napi::Env) override; - void beginPipelineStatisticsQuery(Napi::Env, - interop::Interface querySet, - interop::GPUSize32 queryIndex) override; - void endPipelineStatisticsQuery(Napi::Env) override; - void writeTimestamp(Napi::Env, - interop::Interface querySet, - interop::GPUSize32 queryIndex) override; void executeBundles( Napi::Env, std::vector> bundles) override;