diff --git a/dom/webgpu/CanvasContext.cpp b/dom/webgpu/CanvasContext.cpp index 85b6fdecee1b..1c2d84edefad 100644 --- a/dom/webgpu/CanvasContext.cpp +++ b/dom/webgpu/CanvasContext.cpp @@ -203,7 +203,7 @@ void CanvasContext::SwapChainPresent() { mBridge->SwapChainPresent(mTexture->mId, *mLastRemoteTextureId, *mRemoteTextureOwnerId); if (mUseExternalTextureInSwapChain) { - mTexture->Destroy(); + mTexture->ForceDestroy(); mNewTextureRequested = true; } } diff --git a/dom/webgpu/CommandBuffer.cpp b/dom/webgpu/CommandBuffer.cpp index 5381902c1f90..a666878e3bb4 100644 --- a/dom/webgpu/CommandBuffer.cpp +++ b/dom/webgpu/CommandBuffer.cpp @@ -16,14 +16,22 @@ GPU_IMPL_CYCLE_COLLECTION(CommandBuffer, mParent) GPU_IMPL_JS_WRAP(CommandBuffer) CommandBuffer::CommandBuffer(Device* const aParent, RawId aId, - nsTArray>&& aTargetContexts, - RefPtr&& aEncoder) + nsTArray>&& aTargetContexts) : ChildOf(aParent), mId(aId), mTargetContexts(std::move(aTargetContexts)) { - mEncoder = std::move(aEncoder); MOZ_RELEASE_ASSERT(aId); } -void CommandBuffer::Cleanup() { mEncoder = nullptr; } +CommandBuffer::~CommandBuffer() { Cleanup(); } + +void CommandBuffer::Cleanup() { + if (mValid && mParent) { + mValid = false; + auto bridge = mParent->GetBridge(); + if (bridge && bridge->IsOpen()) { + bridge->SendCommandBufferDrop(mId); + } + } +} Maybe CommandBuffer::Commit() { if (!mValid) { diff --git a/dom/webgpu/CommandBuffer.h b/dom/webgpu/CommandBuffer.h index c0d1c36f8fd1..be525d98f388 100644 --- a/dom/webgpu/CommandBuffer.h +++ b/dom/webgpu/CommandBuffer.h @@ -22,23 +22,17 @@ class CommandBuffer final : public ObjectBase, public ChildOf { GPU_DECL_JS_WRAP(CommandBuffer) CommandBuffer(Device* const aParent, RawId aId, - nsTArray>&& aTargetContexts, - RefPtr&& aEncoder); + nsTArray>&& aTargetContexts); Maybe Commit(); private: CommandBuffer() = delete; - ~CommandBuffer() = default; + ~CommandBuffer(); void Cleanup(); const RawId mId; const nsTArray> mTargetContexts; - // Command buffers and encoders share the same identity (this is a - // simplifcation currently made by wgpu). To avoid dropping the same ID twice, - // the wgpu resource lifetime is tied to the encoder which is held alive by - // the command buffer. - RefPtr mEncoder; }; } // namespace mozilla::webgpu diff --git a/dom/webgpu/CommandEncoder.cpp b/dom/webgpu/CommandEncoder.cpp index a23421cb3035..5969fe9b35c3 100644 --- a/dom/webgpu/CommandEncoder.cpp +++ b/dom/webgpu/CommandEncoder.cpp @@ -80,12 +80,11 @@ CommandEncoder::CommandEncoder(Device* const aParent, CommandEncoder::~CommandEncoder() { Cleanup(); } void CommandEncoder::Cleanup() { - if (!mValid) { - return; - } - mValid = false; - if (mBridge->IsOpen()) { - mBridge->SendCommandEncoderDrop(mId); + if (mValid) { + mValid = false; + if (mBridge->IsOpen()) { + mBridge->SendCommandEncoderDrop(mId); + } } } @@ -94,102 +93,88 @@ void CommandEncoder::CopyBufferToBuffer(const Buffer& aSource, const Buffer& aDestination, BufferAddress aDestinationOffset, BufferAddress aSize) { - if (!mBridge->IsOpen()) { - return; + if (mValid && mBridge->IsOpen()) { + ipc::ByteBuf bb; + ffi::wgpu_command_encoder_copy_buffer_to_buffer( + aSource.mId, aSourceOffset, aDestination.mId, aDestinationOffset, aSize, + ToFFI(&bb)); + mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); } - - ipc::ByteBuf bb; - ffi::wgpu_command_encoder_copy_buffer_to_buffer( - aSource.mId, aSourceOffset, aDestination.mId, aDestinationOffset, aSize, - ToFFI(&bb)); - mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); } void CommandEncoder::CopyBufferToTexture( const dom::GPUImageCopyBuffer& aSource, const dom::GPUImageCopyTexture& aDestination, const dom::GPUExtent3D& aCopySize) { - if (!mBridge->IsOpen()) { - return; - } + if (mValid && mBridge->IsOpen()) { + ipc::ByteBuf bb; + ffi::WGPUImageDataLayout src_layout = {}; + CommandEncoder::ConvertTextureDataLayoutToFFI(aSource, &src_layout); + ffi::wgpu_command_encoder_copy_buffer_to_texture( + aSource.mBuffer->mId, &src_layout, ConvertTextureCopyView(aDestination), + ConvertExtent(aCopySize), ToFFI(&bb)); + mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); - ipc::ByteBuf bb; - ffi::WGPUImageDataLayout src_layout = {}; - CommandEncoder::ConvertTextureDataLayoutToFFI(aSource, &src_layout); - ffi::wgpu_command_encoder_copy_buffer_to_texture( - aSource.mBuffer->mId, &src_layout, ConvertTextureCopyView(aDestination), - ConvertExtent(aCopySize), ToFFI(&bb)); - mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); - - const auto& targetContext = aDestination.mTexture->mTargetContext; - if (targetContext) { - mTargetContexts.AppendElement(targetContext); + const auto& targetContext = aDestination.mTexture->mTargetContext; + if (targetContext) { + mTargetContexts.AppendElement(targetContext); + } } } void CommandEncoder::CopyTextureToBuffer( const dom::GPUImageCopyTexture& aSource, const dom::GPUImageCopyBuffer& aDestination, const dom::GPUExtent3D& aCopySize) { - if (!mBridge->IsOpen()) { - return; + if (mValid && mBridge->IsOpen()) { + ipc::ByteBuf bb; + ffi::WGPUImageDataLayout dstLayout = {}; + CommandEncoder::ConvertTextureDataLayoutToFFI(aDestination, &dstLayout); + ffi::wgpu_command_encoder_copy_texture_to_buffer( + ConvertTextureCopyView(aSource), aDestination.mBuffer->mId, &dstLayout, + ConvertExtent(aCopySize), ToFFI(&bb)); + mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); } - - ipc::ByteBuf bb; - ffi::WGPUImageDataLayout dstLayout = {}; - CommandEncoder::ConvertTextureDataLayoutToFFI(aDestination, &dstLayout); - ffi::wgpu_command_encoder_copy_texture_to_buffer( - ConvertTextureCopyView(aSource), aDestination.mBuffer->mId, &dstLayout, - ConvertExtent(aCopySize), ToFFI(&bb)); - mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); } void CommandEncoder::CopyTextureToTexture( const dom::GPUImageCopyTexture& aSource, const dom::GPUImageCopyTexture& aDestination, const dom::GPUExtent3D& aCopySize) { - if (!mBridge->IsOpen()) { - return; - } + if (mValid && mBridge->IsOpen()) { + ipc::ByteBuf bb; + ffi::wgpu_command_encoder_copy_texture_to_texture( + ConvertTextureCopyView(aSource), ConvertTextureCopyView(aDestination), + ConvertExtent(aCopySize), ToFFI(&bb)); + mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); - ipc::ByteBuf bb; - ffi::wgpu_command_encoder_copy_texture_to_texture( - ConvertTextureCopyView(aSource), ConvertTextureCopyView(aDestination), - ConvertExtent(aCopySize), ToFFI(&bb)); - mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); - - const auto& targetContext = aDestination.mTexture->mTargetContext; - if (targetContext) { - mTargetContexts.AppendElement(targetContext); + const auto& targetContext = aDestination.mTexture->mTargetContext; + if (targetContext) { + mTargetContexts.AppendElement(targetContext); + } } } void CommandEncoder::PushDebugGroup(const nsAString& aString) { - if (!mBridge->IsOpen()) { - return; + if (mValid && mBridge->IsOpen()) { + ipc::ByteBuf bb; + NS_ConvertUTF16toUTF8 marker(aString); + ffi::wgpu_command_encoder_push_debug_group(&marker, ToFFI(&bb)); + mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); } - - ipc::ByteBuf bb; - NS_ConvertUTF16toUTF8 marker(aString); - ffi::wgpu_command_encoder_push_debug_group(&marker, ToFFI(&bb)); - mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); } void CommandEncoder::PopDebugGroup() { - if (!mBridge->IsOpen()) { - return; + if (mValid && mBridge->IsOpen()) { + ipc::ByteBuf bb; + ffi::wgpu_command_encoder_pop_debug_group(ToFFI(&bb)); + mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); } - - ipc::ByteBuf bb; - ffi::wgpu_command_encoder_pop_debug_group(ToFFI(&bb)); - mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); } void CommandEncoder::InsertDebugMarker(const nsAString& aString) { - if (!mBridge->IsOpen()) { - return; + if (mValid && mBridge->IsOpen()) { + ipc::ByteBuf bb; + NS_ConvertUTF16toUTF8 marker(aString); + ffi::wgpu_command_encoder_insert_debug_marker(&marker, ToFFI(&bb)); + mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); } - - ipc::ByteBuf bb; - NS_ConvertUTF16toUTF8 marker(aString); - ffi::wgpu_command_encoder_insert_debug_marker(&marker, ToFFI(&bb)); - mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb)); } already_AddRefed CommandEncoder::BeginComputePass( @@ -215,9 +200,10 @@ already_AddRefed CommandEncoder::BeginRenderPass( return pass.forget(); } -void CommandEncoder::EndComputePass(ffi::WGPUComputePass& aPass) { - if (!mBridge->IsOpen()) { - return; +void CommandEncoder::EndComputePass(ffi::WGPUComputePass& aPass, + ErrorResult& aRv) { + if (!mValid || !mBridge->IsOpen()) { + return aRv.ThrowInvalidStateError("Command encoder is not valid"); } ipc::ByteBuf byteBuf; @@ -225,9 +211,10 @@ void CommandEncoder::EndComputePass(ffi::WGPUComputePass& aPass) { mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(byteBuf)); } -void CommandEncoder::EndRenderPass(ffi::WGPURenderPass& aPass) { - if (!mBridge->IsOpen()) { - return; +void CommandEncoder::EndRenderPass(ffi::WGPURenderPass& aPass, + ErrorResult& aRv) { + if (!mValid || !mBridge->IsOpen()) { + return aRv.ThrowInvalidStateError("Command encoder is not valid"); } ipc::ByteBuf byteBuf; @@ -237,12 +224,13 @@ void CommandEncoder::EndRenderPass(ffi::WGPURenderPass& aPass) { already_AddRefed CommandEncoder::Finish( const dom::GPUCommandBufferDescriptor& aDesc) { - // WebGPUChild::CommandEncoderFinish handles the case where the IPC channel - // closed. - RawId id = mBridge->CommandEncoderFinish(mId, mParent->mId, aDesc); - RefPtr me(this); + RawId id = 0; + if (mValid && mBridge->IsOpen()) { + mValid = false; + id = mBridge->CommandEncoderFinish(mId, mParent->mId, aDesc); + } RefPtr comb = - new CommandBuffer(mParent, id, std::move(mTargetContexts), std::move(me)); + new CommandBuffer(mParent, id, std::move(mTargetContexts)); return comb.forget(); } diff --git a/dom/webgpu/CommandEncoder.h b/dom/webgpu/CommandEncoder.h index 7a1abc513bdf..fc58b7ee35a3 100644 --- a/dom/webgpu/CommandEncoder.h +++ b/dom/webgpu/CommandEncoder.h @@ -72,8 +72,8 @@ class CommandEncoder final : public ObjectBase, public ChildOf { public: const auto& GetDevice() const { return mParent; }; - void EndComputePass(ffi::WGPUComputePass& aPass); - void EndRenderPass(ffi::WGPURenderPass& aPass); + void EndComputePass(ffi::WGPUComputePass& aPass, ErrorResult& aRv); + void EndRenderPass(ffi::WGPURenderPass& aPass, ErrorResult& aRv); void CopyBufferToBuffer(const Buffer& aSource, BufferAddress aSourceOffset, const Buffer& aDestination, diff --git a/dom/webgpu/ComputePassEncoder.cpp b/dom/webgpu/ComputePassEncoder.cpp index 27a31b033ea6..a81587cf6c1f 100644 --- a/dom/webgpu/ComputePassEncoder.cpp +++ b/dom/webgpu/ComputePassEncoder.cpp @@ -99,12 +99,12 @@ void ComputePassEncoder::InsertDebugMarker(const nsAString& aString) { } } -void ComputePassEncoder::End() { +void ComputePassEncoder::End(ErrorResult& aRv) { if (mValid) { mValid = false; auto* pass = mPass.forget(); MOZ_ASSERT(pass); - mParent->EndComputePass(*pass); + mParent->EndComputePass(*pass, aRv); } } diff --git a/dom/webgpu/ComputePassEncoder.h b/dom/webgpu/ComputePassEncoder.h index 7602238e914a..273cfe92088c 100644 --- a/dom/webgpu/ComputePassEncoder.h +++ b/dom/webgpu/ComputePassEncoder.h @@ -67,7 +67,7 @@ class ComputePassEncoder final : public ObjectBase, void PopDebugGroup(); void InsertDebugMarker(const nsAString& aString); - void End(); + void End(ErrorResult& aRv); }; } // namespace webgpu diff --git a/dom/webgpu/RenderPassEncoder.cpp b/dom/webgpu/RenderPassEncoder.cpp index c01c08205237..437d999322f3 100644 --- a/dom/webgpu/RenderPassEncoder.cpp +++ b/dom/webgpu/RenderPassEncoder.cpp @@ -318,12 +318,12 @@ void RenderPassEncoder::InsertDebugMarker(const nsAString& aString) { } } -void RenderPassEncoder::End() { +void RenderPassEncoder::End(ErrorResult& aRv) { if (mValid) { mValid = false; auto* pass = mPass.forget(); MOZ_ASSERT(pass); - mParent->EndRenderPass(*pass); + mParent->EndRenderPass(*pass, aRv); } } diff --git a/dom/webgpu/RenderPassEncoder.h b/dom/webgpu/RenderPassEncoder.h index 4832c66eb837..0255003b2257 100644 --- a/dom/webgpu/RenderPassEncoder.h +++ b/dom/webgpu/RenderPassEncoder.h @@ -95,7 +95,7 @@ class RenderPassEncoder final : public ObjectBase, void ExecuteBundles( const dom::Sequence>& aBundles); - void End(); + void End(ErrorResult& aRv); }; } // namespace webgpu diff --git a/dom/webgpu/Texture.cpp b/dom/webgpu/Texture.cpp index 36fa9c3a830d..80287d2bc9df 100644 --- a/dom/webgpu/Texture.cpp +++ b/dom/webgpu/Texture.cpp @@ -45,26 +45,18 @@ Texture::Texture(Device* const aParent, RawId aId, MOZ_RELEASE_ASSERT(aId); } -void Texture::Cleanup() { - if (!mParent) { - return; - } - - auto bridge = mParent->GetBridge(); - if (bridge && bridge->IsOpen()) { - bridge->SendTextureDrop(mId); - } - - // After cleanup is called, no other method should ever be called on the - // object so we don't have to null-check mParent in other places. - // This serves the purpose of preventing SendTextureDrop from happening - // twice. TODO: Does it matter for breaking cycles too? Cleanup is called - // by the macros that deal with cycle colleciton. - mParent = nullptr; -} - Texture::~Texture() { Cleanup(); } +void Texture::Cleanup() { + if (mValid && mParent) { + mValid = false; + auto bridge = mParent->GetBridge(); + if (bridge && bridge->IsOpen()) { + bridge->SendTextureDrop(mId); + } + } +} + already_AddRefed Texture::CreateView( const dom::GPUTextureViewDescriptor& aDesc) { auto bridge = mParent->GetBridge(); @@ -78,10 +70,12 @@ already_AddRefed Texture::CreateView( } void Texture::Destroy() { - auto bridge = mParent->GetBridge(); - if (bridge && bridge->IsOpen()) { - bridge->SendTextureDestroy(mId, mParent->GetId()); - } + // TODO: we don't have to implement it right now, but it's used by the + // examples + + // XXX Bug 1860958. } +void Texture::ForceDestroy() { Cleanup(); } + } // namespace mozilla::webgpu diff --git a/dom/webgpu/Texture.h b/dom/webgpu/Texture.h index e31878f825ef..28c390816485 100644 --- a/dom/webgpu/Texture.h +++ b/dom/webgpu/Texture.h @@ -56,6 +56,7 @@ class Texture final : public ObjectBase, public ChildOf { already_AddRefed CreateView( const dom::GPUTextureViewDescriptor& aDesc); void Destroy(); + void ForceDestroy(); uint32_t Width() const { return mSize.width; } uint32_t Height() const { return mSize.height; } diff --git a/dom/webgpu/ipc/PWebGPU.ipdl b/dom/webgpu/ipc/PWebGPU.ipdl index 01b469f82946..1b84b341756f 100644 --- a/dom/webgpu/ipc/PWebGPU.ipdl +++ b/dom/webgpu/ipc/PWebGPU.ipdl @@ -55,7 +55,6 @@ parent: async BufferUnmap(RawId deviceId, RawId bufferId, bool flush); async BufferDestroy(RawId selfId); async BufferDrop(RawId selfId); - async TextureDestroy(RawId selfId, RawId deviceId); async TextureDrop(RawId selfId); async TextureViewDrop(RawId selfId); async SamplerDrop(RawId selfId); @@ -64,6 +63,7 @@ parent: async CommandEncoderFinish(RawId selfId, RawId deviceId, GPUCommandBufferDescriptor desc); async CommandEncoderDrop(RawId selfId); + async CommandBufferDrop(RawId selfId); async RenderBundleDrop(RawId selfId); async QueueSubmit(RawId selfId, RawId aDeviceId, RawId[] commandBuffers); async QueueOnSubmittedWorkDone(RawId selfId) returns (void_t ok); diff --git a/dom/webgpu/ipc/WebGPUChild.cpp b/dom/webgpu/ipc/WebGPUChild.cpp index b3f3e0d2417e..2ba70a61d0c5 100644 --- a/dom/webgpu/ipc/WebGPUChild.cpp +++ b/dom/webgpu/ipc/WebGPUChild.cpp @@ -441,22 +441,13 @@ RawId WebGPUChild::DeviceCreateCommandEncoder( RawId WebGPUChild::CommandEncoderFinish( RawId aSelfId, RawId aDeviceId, const dom::GPUCommandBufferDescriptor& aDesc) { + if (!SendCommandEncoderFinish(aSelfId, aDeviceId, aDesc)) { + MOZ_CRASH("IPC failure"); + } // We rely on knowledge that `CommandEncoderId` == `CommandBufferId` // TODO: refactor this to truly behave as if the encoder is being finished, // and a new command buffer ID is being created from it. Resolve the ID // type aliasing at the place that introduces it: `wgpu-core`. - - if (!IsOpen()) { - // The GPU process went down. This will be handled elsewhere so pretend - // the message was sent successfully. There is nothing we can do with - // the produced handle so all we need is to make sure it isn't invalid - // (it must not be zero). - return aSelfId; - } - - if (!SendCommandEncoderFinish(aSelfId, aDeviceId, aDesc)) { - MOZ_CRASH("IPC failure"); - } return aSelfId; } diff --git a/dom/webgpu/ipc/WebGPUParent.cpp b/dom/webgpu/ipc/WebGPUParent.cpp index 54149e247353..9531b5341689 100644 --- a/dom/webgpu/ipc/WebGPUParent.cpp +++ b/dom/webgpu/ipc/WebGPUParent.cpp @@ -708,23 +708,13 @@ ipc::IPCResult WebGPUParent::RecvBufferDestroy(RawId aBufferId) { return IPC_OK(); } -void WebGPUParent::RemoveExternalTexture(RawId aTextureId) { +ipc::IPCResult WebGPUParent::RecvTextureDrop(RawId aTextureId) { + ffi::wgpu_server_texture_drop(mContext.get(), aTextureId); + auto it = mExternalTextures.find(aTextureId); if (it != mExternalTextures.end()) { mExternalTextures.erase(it); } -} - -ipc::IPCResult WebGPUParent::RecvTextureDestroy(RawId aTextureId, - RawId aDeviceId) { - ffi::wgpu_server_texture_destroy(mContext.get(), aTextureId); - RemoveExternalTexture(aTextureId); - return IPC_OK(); -} - -ipc::IPCResult WebGPUParent::RecvTextureDrop(RawId aTextureId) { - ffi::wgpu_server_texture_drop(mContext.get(), aTextureId); - RemoveExternalTexture(aTextureId); return IPC_OK(); } @@ -760,6 +750,11 @@ ipc::IPCResult WebGPUParent::RecvCommandEncoderDrop(RawId aEncoderId) { return IPC_OK(); } +ipc::IPCResult WebGPUParent::RecvCommandBufferDrop(RawId aCommandBufferId) { + ffi::wgpu_server_command_buffer_drop(mContext.get(), aCommandBufferId); + return IPC_OK(); +} + ipc::IPCResult WebGPUParent::RecvRenderBundleDrop(RawId aBundleId) { ffi::wgpu_server_render_bundle_drop(mContext.get(), aBundleId); return IPC_OK(); @@ -1176,16 +1171,9 @@ ipc::IPCResult WebGPUParent::RecvSwapChainPresent( static_cast(size.height), 1, }; - - { - ErrorBuffer error; - ffi::wgpu_server_encoder_copy_texture_to_buffer( - mContext.get(), aCommandEncoderId, &texView, bufferId, &bufLayout, - &extent, error.ToFFI()); - if (ForwardError(data->mDeviceId, error)) { - return IPC_OK(); - } - } + ffi::wgpu_server_encoder_copy_texture_to_buffer( + mContext.get(), aCommandEncoderId, &texView, bufferId, &bufLayout, + &extent); ffi::WGPUCommandBufferDescriptor commandDesc = {}; { ErrorBuffer error; diff --git a/dom/webgpu/ipc/WebGPUParent.h b/dom/webgpu/ipc/WebGPUParent.h index 20787b9b1d5b..db211b0b3933 100644 --- a/dom/webgpu/ipc/WebGPUParent.h +++ b/dom/webgpu/ipc/WebGPUParent.h @@ -65,7 +65,6 @@ class WebGPUParent final : public PWebGPUParent { ipc::IPCResult RecvBufferUnmap(RawId aDeviceId, RawId aBufferId, bool aFlush); ipc::IPCResult RecvBufferDestroy(RawId aBufferId); ipc::IPCResult RecvBufferDrop(RawId aBufferId); - ipc::IPCResult RecvTextureDestroy(RawId aTextureId, RawId aDeviceId); ipc::IPCResult RecvTextureDrop(RawId aTextureId); ipc::IPCResult RecvTextureViewDrop(RawId aTextureViewId); ipc::IPCResult RecvSamplerDrop(RawId aSamplerId); @@ -170,8 +169,6 @@ class WebGPUParent final : public PWebGPUParent { uint8_t* aUserData); void DeallocBufferShmem(RawId aBufferId); - void RemoveExternalTexture(RawId aTextureId); - virtual ~WebGPUParent(); void MaintainDevices(); void LoseDevice(const RawId aDeviceId, Maybe aReason, diff --git a/dom/webgpu/mochitest/mochitest.toml b/dom/webgpu/mochitest/mochitest.toml index 00d71d8112de..5d50e1fe20b6 100644 --- a/dom/webgpu/mochitest/mochitest.toml +++ b/dom/webgpu/mochitest/mochitest.toml @@ -52,11 +52,6 @@ fail-if = [ "os == 'mac'", ] -["test_double_encoder_finish.html"] -fail-if = [ - "os == 'linux' && os_version == '18.04'", -] - ["test_enabled.html"] ["test_error_scope.html"] diff --git a/dom/webgpu/mochitest/test_double_encoder_finish.html b/dom/webgpu/mochitest/test_double_encoder_finish.html deleted file mode 100644 index 24c91c316567..000000000000 --- a/dom/webgpu/mochitest/test_double_encoder_finish.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - diff --git a/dom/webidl/WebGPU.webidl b/dom/webidl/WebGPU.webidl index 77aeba9f419e..62a2794cec00 100644 --- a/dom/webidl/WebGPU.webidl +++ b/dom/webidl/WebGPU.webidl @@ -922,6 +922,7 @@ interface GPUComputePassEncoder { [Pref="dom.webgpu.indirect-dispatch.enabled"] undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); + [Throws] undefined end(); }; GPUComputePassEncoder includes GPUObjectBase; @@ -950,6 +951,7 @@ interface GPURenderPassEncoder { //undefined endOcclusionQuery(); undefined executeBundles(sequence bundles); + [Throws] undefined end(); }; GPURenderPassEncoder includes GPUObjectBase; diff --git a/gfx/wgpu_bindings/src/error.rs b/gfx/wgpu_bindings/src/error.rs index 4497f35102de..f2c3f32985bd 100644 --- a/gfx/wgpu_bindings/src/error.rs +++ b/gfx/wgpu_bindings/src/error.rs @@ -151,7 +151,7 @@ mod foreign { }, resource::{ BufferAccessError, CreateBufferError, CreateSamplerError, CreateTextureError, - CreateTextureViewError, DestroyError, + CreateTextureViewError, }, }; @@ -653,10 +653,4 @@ mod foreign { ErrorBufferType::Validation } } - - impl HasErrorBufferType for DestroyError { - fn error_type(&self) -> ErrorBufferType { - ErrorBufferType::Validation - } - } } diff --git a/gfx/wgpu_bindings/src/server.rs b/gfx/wgpu_bindings/src/server.rs index 75615efe1fab..ed75770c5983 100644 --- a/gfx/wgpu_bindings/src/server.rs +++ b/gfx/wgpu_bindings/src/server.rs @@ -982,6 +982,11 @@ pub extern "C" fn wgpu_server_encoder_drop(global: &Global, self_id: id::Command gfx_select!(self_id => global.command_encoder_drop(self_id)); } +#[no_mangle] +pub extern "C" fn wgpu_server_command_buffer_drop(global: &Global, self_id: id::CommandBufferId) { + gfx_select!(self_id => global.command_buffer_drop(self_id)); +} + #[no_mangle] pub extern "C" fn wgpu_server_render_bundle_drop(global: &Global, self_id: id::RenderBundleId) { gfx_select!(self_id => global.render_bundle_drop(self_id)); @@ -995,15 +1000,12 @@ pub unsafe extern "C" fn wgpu_server_encoder_copy_texture_to_buffer( dst_buffer: wgc::id::BufferId, dst_layout: &crate::ImageDataLayout, size: &wgt::Extent3d, - mut error_buf: ErrorBuffer, ) { let destination = wgc::command::ImageCopyBuffer { buffer: dst_buffer, layout: dst_layout.into_wgt(), }; - if let Err(err) = gfx_select!(self_id => global.command_encoder_copy_texture_to_buffer(self_id, source, &destination, size)) { - error_buf.init(err); - } + gfx_select!(self_id => global.command_encoder_copy_texture_to_buffer(self_id, source, &destination, size)).unwrap(); } /// # Safety @@ -1098,14 +1100,6 @@ pub extern "C" fn wgpu_server_render_pipeline_drop(global: &Global, self_id: id: gfx_select!(self_id => global.render_pipeline_drop(self_id)); } -#[no_mangle] -pub extern "C" fn wgpu_server_texture_destroy( - global: &Global, - self_id: id::TextureId, -) { - let _ = gfx_select!(self_id => global.texture_destroy(self_id)); -} - #[no_mangle] pub extern "C" fn wgpu_server_texture_drop(global: &Global, self_id: id::TextureId) { gfx_select!(self_id => global.texture_drop(self_id, false)); diff --git a/testing/web-platform/mozilla/meta/webgpu/chunked/25/cts.https.html.ini b/testing/web-platform/mozilla/meta/webgpu/chunked/25/cts.https.html.ini index 68e7ba871017..275927f2f2db 100644 --- a/testing/web-platform/mozilla/meta/webgpu/chunked/25/cts.https.html.ini +++ b/testing/web-platform/mozilla/meta/webgpu/chunked/25/cts.https.html.ini @@ -535,3 +535,7 @@ [:] expected: FAIL + +[cts.https.html?q=webgpu:api,validation,queue,destroyed,texture:writeTexture:*] + [:] + expected: FAIL diff --git a/testing/web-platform/mozilla/meta/webgpu/chunked/26/cts.https.html.ini b/testing/web-platform/mozilla/meta/webgpu/chunked/26/cts.https.html.ini index 673301484486..eaee86091aa4 100644 --- a/testing/web-platform/mozilla/meta/webgpu/chunked/26/cts.https.html.ini +++ b/testing/web-platform/mozilla/meta/webgpu/chunked/26/cts.https.html.ini @@ -69,6 +69,9 @@ [cts.https.html?q=webgpu:api,validation,queue,writeTexture:texture_state:*] + [:textureState="destroyed"] + expected: FAIL + [:textureState="invalid"] expected: if os == "win": [PASS, FAIL]