forked from mirrors/gecko-dev
Backed out 3 changesets (bug 1861985, bug 1860958) for causing build bustages in RefPtr.h CLOSED TREE
Backed out changeset 13f07117425f (bug 1861985) Backed out changeset 0bdc4c60018e (bug 1861985) Backed out changeset 5e6f2b2e19c6 (bug 1860958)
This commit is contained in:
parent
709e423bb2
commit
b428472b9e
22 changed files with 140 additions and 223 deletions
|
|
@ -203,7 +203,7 @@ void CanvasContext::SwapChainPresent() {
|
||||||
mBridge->SwapChainPresent(mTexture->mId, *mLastRemoteTextureId,
|
mBridge->SwapChainPresent(mTexture->mId, *mLastRemoteTextureId,
|
||||||
*mRemoteTextureOwnerId);
|
*mRemoteTextureOwnerId);
|
||||||
if (mUseExternalTextureInSwapChain) {
|
if (mUseExternalTextureInSwapChain) {
|
||||||
mTexture->Destroy();
|
mTexture->ForceDestroy();
|
||||||
mNewTextureRequested = true;
|
mNewTextureRequested = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,22 @@ GPU_IMPL_CYCLE_COLLECTION(CommandBuffer, mParent)
|
||||||
GPU_IMPL_JS_WRAP(CommandBuffer)
|
GPU_IMPL_JS_WRAP(CommandBuffer)
|
||||||
|
|
||||||
CommandBuffer::CommandBuffer(Device* const aParent, RawId aId,
|
CommandBuffer::CommandBuffer(Device* const aParent, RawId aId,
|
||||||
nsTArray<WeakPtr<CanvasContext>>&& aTargetContexts,
|
nsTArray<WeakPtr<CanvasContext>>&& aTargetContexts)
|
||||||
RefPtr<CommandEncoder>&& aEncoder)
|
|
||||||
: ChildOf(aParent), mId(aId), mTargetContexts(std::move(aTargetContexts)) {
|
: ChildOf(aParent), mId(aId), mTargetContexts(std::move(aTargetContexts)) {
|
||||||
mEncoder = std::move(aEncoder);
|
|
||||||
MOZ_RELEASE_ASSERT(aId);
|
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<RawId> CommandBuffer::Commit() {
|
Maybe<RawId> CommandBuffer::Commit() {
|
||||||
if (!mValid) {
|
if (!mValid) {
|
||||||
|
|
|
||||||
|
|
@ -22,23 +22,17 @@ class CommandBuffer final : public ObjectBase, public ChildOf<Device> {
|
||||||
GPU_DECL_JS_WRAP(CommandBuffer)
|
GPU_DECL_JS_WRAP(CommandBuffer)
|
||||||
|
|
||||||
CommandBuffer(Device* const aParent, RawId aId,
|
CommandBuffer(Device* const aParent, RawId aId,
|
||||||
nsTArray<WeakPtr<CanvasContext>>&& aTargetContexts,
|
nsTArray<WeakPtr<CanvasContext>>&& aTargetContexts);
|
||||||
RefPtr<CommandEncoder>&& aEncoder);
|
|
||||||
|
|
||||||
Maybe<RawId> Commit();
|
Maybe<RawId> Commit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CommandBuffer() = delete;
|
CommandBuffer() = delete;
|
||||||
~CommandBuffer() = default;
|
~CommandBuffer();
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
|
|
||||||
const RawId mId;
|
const RawId mId;
|
||||||
const nsTArray<WeakPtr<CanvasContext>> mTargetContexts;
|
const nsTArray<WeakPtr<CanvasContext>> 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<CommandEncoder> mEncoder;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mozilla::webgpu
|
} // namespace mozilla::webgpu
|
||||||
|
|
|
||||||
|
|
@ -80,12 +80,11 @@ CommandEncoder::CommandEncoder(Device* const aParent,
|
||||||
CommandEncoder::~CommandEncoder() { Cleanup(); }
|
CommandEncoder::~CommandEncoder() { Cleanup(); }
|
||||||
|
|
||||||
void CommandEncoder::Cleanup() {
|
void CommandEncoder::Cleanup() {
|
||||||
if (!mValid) {
|
if (mValid) {
|
||||||
return;
|
mValid = false;
|
||||||
}
|
if (mBridge->IsOpen()) {
|
||||||
mValid = false;
|
mBridge->SendCommandEncoderDrop(mId);
|
||||||
if (mBridge->IsOpen()) {
|
}
|
||||||
mBridge->SendCommandEncoderDrop(mId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,102 +93,88 @@ void CommandEncoder::CopyBufferToBuffer(const Buffer& aSource,
|
||||||
const Buffer& aDestination,
|
const Buffer& aDestination,
|
||||||
BufferAddress aDestinationOffset,
|
BufferAddress aDestinationOffset,
|
||||||
BufferAddress aSize) {
|
BufferAddress aSize) {
|
||||||
if (!mBridge->IsOpen()) {
|
if (mValid && mBridge->IsOpen()) {
|
||||||
return;
|
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(
|
void CommandEncoder::CopyBufferToTexture(
|
||||||
const dom::GPUImageCopyBuffer& aSource,
|
const dom::GPUImageCopyBuffer& aSource,
|
||||||
const dom::GPUImageCopyTexture& aDestination,
|
const dom::GPUImageCopyTexture& aDestination,
|
||||||
const dom::GPUExtent3D& aCopySize) {
|
const dom::GPUExtent3D& aCopySize) {
|
||||||
if (!mBridge->IsOpen()) {
|
if (mValid && mBridge->IsOpen()) {
|
||||||
return;
|
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;
|
const auto& targetContext = aDestination.mTexture->mTargetContext;
|
||||||
ffi::WGPUImageDataLayout src_layout = {};
|
if (targetContext) {
|
||||||
CommandEncoder::ConvertTextureDataLayoutToFFI(aSource, &src_layout);
|
mTargetContexts.AppendElement(targetContext);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CommandEncoder::CopyTextureToBuffer(
|
void CommandEncoder::CopyTextureToBuffer(
|
||||||
const dom::GPUImageCopyTexture& aSource,
|
const dom::GPUImageCopyTexture& aSource,
|
||||||
const dom::GPUImageCopyBuffer& aDestination,
|
const dom::GPUImageCopyBuffer& aDestination,
|
||||||
const dom::GPUExtent3D& aCopySize) {
|
const dom::GPUExtent3D& aCopySize) {
|
||||||
if (!mBridge->IsOpen()) {
|
if (mValid && mBridge->IsOpen()) {
|
||||||
return;
|
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(
|
void CommandEncoder::CopyTextureToTexture(
|
||||||
const dom::GPUImageCopyTexture& aSource,
|
const dom::GPUImageCopyTexture& aSource,
|
||||||
const dom::GPUImageCopyTexture& aDestination,
|
const dom::GPUImageCopyTexture& aDestination,
|
||||||
const dom::GPUExtent3D& aCopySize) {
|
const dom::GPUExtent3D& aCopySize) {
|
||||||
if (!mBridge->IsOpen()) {
|
if (mValid && mBridge->IsOpen()) {
|
||||||
return;
|
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;
|
const auto& targetContext = aDestination.mTexture->mTargetContext;
|
||||||
ffi::wgpu_command_encoder_copy_texture_to_texture(
|
if (targetContext) {
|
||||||
ConvertTextureCopyView(aSource), ConvertTextureCopyView(aDestination),
|
mTargetContexts.AppendElement(targetContext);
|
||||||
ConvertExtent(aCopySize), ToFFI(&bb));
|
}
|
||||||
mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb));
|
|
||||||
|
|
||||||
const auto& targetContext = aDestination.mTexture->mTargetContext;
|
|
||||||
if (targetContext) {
|
|
||||||
mTargetContexts.AppendElement(targetContext);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandEncoder::PushDebugGroup(const nsAString& aString) {
|
void CommandEncoder::PushDebugGroup(const nsAString& aString) {
|
||||||
if (!mBridge->IsOpen()) {
|
if (mValid && mBridge->IsOpen()) {
|
||||||
return;
|
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() {
|
void CommandEncoder::PopDebugGroup() {
|
||||||
if (!mBridge->IsOpen()) {
|
if (mValid && mBridge->IsOpen()) {
|
||||||
return;
|
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) {
|
void CommandEncoder::InsertDebugMarker(const nsAString& aString) {
|
||||||
if (!mBridge->IsOpen()) {
|
if (mValid && mBridge->IsOpen()) {
|
||||||
return;
|
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<ComputePassEncoder> CommandEncoder::BeginComputePass(
|
already_AddRefed<ComputePassEncoder> CommandEncoder::BeginComputePass(
|
||||||
|
|
@ -215,9 +200,10 @@ already_AddRefed<RenderPassEncoder> CommandEncoder::BeginRenderPass(
|
||||||
return pass.forget();
|
return pass.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandEncoder::EndComputePass(ffi::WGPUComputePass& aPass) {
|
void CommandEncoder::EndComputePass(ffi::WGPUComputePass& aPass,
|
||||||
if (!mBridge->IsOpen()) {
|
ErrorResult& aRv) {
|
||||||
return;
|
if (!mValid || !mBridge->IsOpen()) {
|
||||||
|
return aRv.ThrowInvalidStateError("Command encoder is not valid");
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc::ByteBuf byteBuf;
|
ipc::ByteBuf byteBuf;
|
||||||
|
|
@ -225,9 +211,10 @@ void CommandEncoder::EndComputePass(ffi::WGPUComputePass& aPass) {
|
||||||
mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(byteBuf));
|
mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(byteBuf));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandEncoder::EndRenderPass(ffi::WGPURenderPass& aPass) {
|
void CommandEncoder::EndRenderPass(ffi::WGPURenderPass& aPass,
|
||||||
if (!mBridge->IsOpen()) {
|
ErrorResult& aRv) {
|
||||||
return;
|
if (!mValid || !mBridge->IsOpen()) {
|
||||||
|
return aRv.ThrowInvalidStateError("Command encoder is not valid");
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc::ByteBuf byteBuf;
|
ipc::ByteBuf byteBuf;
|
||||||
|
|
@ -237,12 +224,13 @@ void CommandEncoder::EndRenderPass(ffi::WGPURenderPass& aPass) {
|
||||||
|
|
||||||
already_AddRefed<CommandBuffer> CommandEncoder::Finish(
|
already_AddRefed<CommandBuffer> CommandEncoder::Finish(
|
||||||
const dom::GPUCommandBufferDescriptor& aDesc) {
|
const dom::GPUCommandBufferDescriptor& aDesc) {
|
||||||
// WebGPUChild::CommandEncoderFinish handles the case where the IPC channel
|
RawId id = 0;
|
||||||
// closed.
|
if (mValid && mBridge->IsOpen()) {
|
||||||
RawId id = mBridge->CommandEncoderFinish(mId, mParent->mId, aDesc);
|
mValid = false;
|
||||||
RefPtr<CommandEncoder> me(this);
|
id = mBridge->CommandEncoderFinish(mId, mParent->mId, aDesc);
|
||||||
|
}
|
||||||
RefPtr<CommandBuffer> comb =
|
RefPtr<CommandBuffer> comb =
|
||||||
new CommandBuffer(mParent, id, std::move(mTargetContexts), std::move(me));
|
new CommandBuffer(mParent, id, std::move(mTargetContexts));
|
||||||
return comb.forget();
|
return comb.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,8 @@ class CommandEncoder final : public ObjectBase, public ChildOf<Device> {
|
||||||
public:
|
public:
|
||||||
const auto& GetDevice() const { return mParent; };
|
const auto& GetDevice() const { return mParent; };
|
||||||
|
|
||||||
void EndComputePass(ffi::WGPUComputePass& aPass);
|
void EndComputePass(ffi::WGPUComputePass& aPass, ErrorResult& aRv);
|
||||||
void EndRenderPass(ffi::WGPURenderPass& aPass);
|
void EndRenderPass(ffi::WGPURenderPass& aPass, ErrorResult& aRv);
|
||||||
|
|
||||||
void CopyBufferToBuffer(const Buffer& aSource, BufferAddress aSourceOffset,
|
void CopyBufferToBuffer(const Buffer& aSource, BufferAddress aSourceOffset,
|
||||||
const Buffer& aDestination,
|
const Buffer& aDestination,
|
||||||
|
|
|
||||||
|
|
@ -99,12 +99,12 @@ void ComputePassEncoder::InsertDebugMarker(const nsAString& aString) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputePassEncoder::End() {
|
void ComputePassEncoder::End(ErrorResult& aRv) {
|
||||||
if (mValid) {
|
if (mValid) {
|
||||||
mValid = false;
|
mValid = false;
|
||||||
auto* pass = mPass.forget();
|
auto* pass = mPass.forget();
|
||||||
MOZ_ASSERT(pass);
|
MOZ_ASSERT(pass);
|
||||||
mParent->EndComputePass(*pass);
|
mParent->EndComputePass(*pass, aRv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ class ComputePassEncoder final : public ObjectBase,
|
||||||
void PopDebugGroup();
|
void PopDebugGroup();
|
||||||
void InsertDebugMarker(const nsAString& aString);
|
void InsertDebugMarker(const nsAString& aString);
|
||||||
|
|
||||||
void End();
|
void End(ErrorResult& aRv);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webgpu
|
} // namespace webgpu
|
||||||
|
|
|
||||||
|
|
@ -318,12 +318,12 @@ void RenderPassEncoder::InsertDebugMarker(const nsAString& aString) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPassEncoder::End() {
|
void RenderPassEncoder::End(ErrorResult& aRv) {
|
||||||
if (mValid) {
|
if (mValid) {
|
||||||
mValid = false;
|
mValid = false;
|
||||||
auto* pass = mPass.forget();
|
auto* pass = mPass.forget();
|
||||||
MOZ_ASSERT(pass);
|
MOZ_ASSERT(pass);
|
||||||
mParent->EndRenderPass(*pass);
|
mParent->EndRenderPass(*pass, aRv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ class RenderPassEncoder final : public ObjectBase,
|
||||||
void ExecuteBundles(
|
void ExecuteBundles(
|
||||||
const dom::Sequence<OwningNonNull<RenderBundle>>& aBundles);
|
const dom::Sequence<OwningNonNull<RenderBundle>>& aBundles);
|
||||||
|
|
||||||
void End();
|
void End(ErrorResult& aRv);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webgpu
|
} // namespace webgpu
|
||||||
|
|
|
||||||
|
|
@ -45,26 +45,18 @@ Texture::Texture(Device* const aParent, RawId aId,
|
||||||
MOZ_RELEASE_ASSERT(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(); }
|
Texture::~Texture() { Cleanup(); }
|
||||||
|
|
||||||
|
void Texture::Cleanup() {
|
||||||
|
if (mValid && mParent) {
|
||||||
|
mValid = false;
|
||||||
|
auto bridge = mParent->GetBridge();
|
||||||
|
if (bridge && bridge->IsOpen()) {
|
||||||
|
bridge->SendTextureDrop(mId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
already_AddRefed<TextureView> Texture::CreateView(
|
already_AddRefed<TextureView> Texture::CreateView(
|
||||||
const dom::GPUTextureViewDescriptor& aDesc) {
|
const dom::GPUTextureViewDescriptor& aDesc) {
|
||||||
auto bridge = mParent->GetBridge();
|
auto bridge = mParent->GetBridge();
|
||||||
|
|
@ -78,10 +70,12 @@ already_AddRefed<TextureView> Texture::CreateView(
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::Destroy() {
|
void Texture::Destroy() {
|
||||||
auto bridge = mParent->GetBridge();
|
// TODO: we don't have to implement it right now, but it's used by the
|
||||||
if (bridge && bridge->IsOpen()) {
|
// examples
|
||||||
bridge->SendTextureDestroy(mId, mParent->GetId());
|
|
||||||
}
|
// XXX Bug 1860958.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Texture::ForceDestroy() { Cleanup(); }
|
||||||
|
|
||||||
} // namespace mozilla::webgpu
|
} // namespace mozilla::webgpu
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ class Texture final : public ObjectBase, public ChildOf<Device> {
|
||||||
already_AddRefed<TextureView> CreateView(
|
already_AddRefed<TextureView> CreateView(
|
||||||
const dom::GPUTextureViewDescriptor& aDesc);
|
const dom::GPUTextureViewDescriptor& aDesc);
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
void ForceDestroy();
|
||||||
|
|
||||||
uint32_t Width() const { return mSize.width; }
|
uint32_t Width() const { return mSize.width; }
|
||||||
uint32_t Height() const { return mSize.height; }
|
uint32_t Height() const { return mSize.height; }
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ parent:
|
||||||
async BufferUnmap(RawId deviceId, RawId bufferId, bool flush);
|
async BufferUnmap(RawId deviceId, RawId bufferId, bool flush);
|
||||||
async BufferDestroy(RawId selfId);
|
async BufferDestroy(RawId selfId);
|
||||||
async BufferDrop(RawId selfId);
|
async BufferDrop(RawId selfId);
|
||||||
async TextureDestroy(RawId selfId, RawId deviceId);
|
|
||||||
async TextureDrop(RawId selfId);
|
async TextureDrop(RawId selfId);
|
||||||
async TextureViewDrop(RawId selfId);
|
async TextureViewDrop(RawId selfId);
|
||||||
async SamplerDrop(RawId selfId);
|
async SamplerDrop(RawId selfId);
|
||||||
|
|
@ -64,6 +63,7 @@ parent:
|
||||||
|
|
||||||
async CommandEncoderFinish(RawId selfId, RawId deviceId, GPUCommandBufferDescriptor desc);
|
async CommandEncoderFinish(RawId selfId, RawId deviceId, GPUCommandBufferDescriptor desc);
|
||||||
async CommandEncoderDrop(RawId selfId);
|
async CommandEncoderDrop(RawId selfId);
|
||||||
|
async CommandBufferDrop(RawId selfId);
|
||||||
async RenderBundleDrop(RawId selfId);
|
async RenderBundleDrop(RawId selfId);
|
||||||
async QueueSubmit(RawId selfId, RawId aDeviceId, RawId[] commandBuffers);
|
async QueueSubmit(RawId selfId, RawId aDeviceId, RawId[] commandBuffers);
|
||||||
async QueueOnSubmittedWorkDone(RawId selfId) returns (void_t ok);
|
async QueueOnSubmittedWorkDone(RawId selfId) returns (void_t ok);
|
||||||
|
|
|
||||||
|
|
@ -441,22 +441,13 @@ RawId WebGPUChild::DeviceCreateCommandEncoder(
|
||||||
RawId WebGPUChild::CommandEncoderFinish(
|
RawId WebGPUChild::CommandEncoderFinish(
|
||||||
RawId aSelfId, RawId aDeviceId,
|
RawId aSelfId, RawId aDeviceId,
|
||||||
const dom::GPUCommandBufferDescriptor& aDesc) {
|
const dom::GPUCommandBufferDescriptor& aDesc) {
|
||||||
|
if (!SendCommandEncoderFinish(aSelfId, aDeviceId, aDesc)) {
|
||||||
|
MOZ_CRASH("IPC failure");
|
||||||
|
}
|
||||||
// We rely on knowledge that `CommandEncoderId` == `CommandBufferId`
|
// We rely on knowledge that `CommandEncoderId` == `CommandBufferId`
|
||||||
// TODO: refactor this to truly behave as if the encoder is being finished,
|
// 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
|
// and a new command buffer ID is being created from it. Resolve the ID
|
||||||
// type aliasing at the place that introduces it: `wgpu-core`.
|
// 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;
|
return aSelfId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -708,23 +708,13 @@ ipc::IPCResult WebGPUParent::RecvBufferDestroy(RawId aBufferId) {
|
||||||
return IPC_OK();
|
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);
|
auto it = mExternalTextures.find(aTextureId);
|
||||||
if (it != mExternalTextures.end()) {
|
if (it != mExternalTextures.end()) {
|
||||||
mExternalTextures.erase(it);
|
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();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -760,6 +750,11 @@ ipc::IPCResult WebGPUParent::RecvCommandEncoderDrop(RawId aEncoderId) {
|
||||||
return IPC_OK();
|
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) {
|
ipc::IPCResult WebGPUParent::RecvRenderBundleDrop(RawId aBundleId) {
|
||||||
ffi::wgpu_server_render_bundle_drop(mContext.get(), aBundleId);
|
ffi::wgpu_server_render_bundle_drop(mContext.get(), aBundleId);
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
|
|
@ -1176,16 +1171,9 @@ ipc::IPCResult WebGPUParent::RecvSwapChainPresent(
|
||||||
static_cast<uint32_t>(size.height),
|
static_cast<uint32_t>(size.height),
|
||||||
1,
|
1,
|
||||||
};
|
};
|
||||||
|
ffi::wgpu_server_encoder_copy_texture_to_buffer(
|
||||||
{
|
mContext.get(), aCommandEncoderId, &texView, bufferId, &bufLayout,
|
||||||
ErrorBuffer error;
|
&extent);
|
||||||
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::WGPUCommandBufferDescriptor commandDesc = {};
|
ffi::WGPUCommandBufferDescriptor commandDesc = {};
|
||||||
{
|
{
|
||||||
ErrorBuffer error;
|
ErrorBuffer error;
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ class WebGPUParent final : public PWebGPUParent {
|
||||||
ipc::IPCResult RecvBufferUnmap(RawId aDeviceId, RawId aBufferId, bool aFlush);
|
ipc::IPCResult RecvBufferUnmap(RawId aDeviceId, RawId aBufferId, bool aFlush);
|
||||||
ipc::IPCResult RecvBufferDestroy(RawId aBufferId);
|
ipc::IPCResult RecvBufferDestroy(RawId aBufferId);
|
||||||
ipc::IPCResult RecvBufferDrop(RawId aBufferId);
|
ipc::IPCResult RecvBufferDrop(RawId aBufferId);
|
||||||
ipc::IPCResult RecvTextureDestroy(RawId aTextureId, RawId aDeviceId);
|
|
||||||
ipc::IPCResult RecvTextureDrop(RawId aTextureId);
|
ipc::IPCResult RecvTextureDrop(RawId aTextureId);
|
||||||
ipc::IPCResult RecvTextureViewDrop(RawId aTextureViewId);
|
ipc::IPCResult RecvTextureViewDrop(RawId aTextureViewId);
|
||||||
ipc::IPCResult RecvSamplerDrop(RawId aSamplerId);
|
ipc::IPCResult RecvSamplerDrop(RawId aSamplerId);
|
||||||
|
|
@ -170,8 +169,6 @@ class WebGPUParent final : public PWebGPUParent {
|
||||||
uint8_t* aUserData);
|
uint8_t* aUserData);
|
||||||
void DeallocBufferShmem(RawId aBufferId);
|
void DeallocBufferShmem(RawId aBufferId);
|
||||||
|
|
||||||
void RemoveExternalTexture(RawId aTextureId);
|
|
||||||
|
|
||||||
virtual ~WebGPUParent();
|
virtual ~WebGPUParent();
|
||||||
void MaintainDevices();
|
void MaintainDevices();
|
||||||
void LoseDevice(const RawId aDeviceId, Maybe<uint8_t> aReason,
|
void LoseDevice(const RawId aDeviceId, Maybe<uint8_t> aReason,
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,6 @@ fail-if = [
|
||||||
"os == 'mac'",
|
"os == 'mac'",
|
||||||
]
|
]
|
||||||
|
|
||||||
["test_double_encoder_finish.html"]
|
|
||||||
fail-if = [
|
|
||||||
"os == 'linux' && os_version == '18.04'",
|
|
||||||
]
|
|
||||||
|
|
||||||
["test_enabled.html"]
|
["test_enabled.html"]
|
||||||
|
|
||||||
["test_error_scope.html"]
|
["test_error_scope.html"]
|
||||||
|
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
||||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script>
|
|
||||||
ok(
|
|
||||||
SpecialPowers.getBoolPref("dom.webgpu.enabled"),
|
|
||||||
"Pref should be enabled."
|
|
||||||
);
|
|
||||||
|
|
||||||
const func = async function () {
|
|
||||||
const adapter = await navigator.gpu.requestAdapter();
|
|
||||||
const device = await adapter.requestDevice();
|
|
||||||
const encoder = device.createCommandEncoder();
|
|
||||||
|
|
||||||
const command_buffer = encoder.finish();
|
|
||||||
ok(command_buffer !== undefined, "command_buffer !== undefined");
|
|
||||||
|
|
||||||
const invalid_command_buffer = encoder.finish();
|
|
||||||
ok(
|
|
||||||
invalid_command_buffer !== undefined,
|
|
||||||
"invalid_command_buffer !== undefined"
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
|
||||||
func()
|
|
||||||
.catch(e => ok(false, "Unhandled exception " + e))
|
|
||||||
.finally(() => SimpleTest.finish());
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -922,6 +922,7 @@ interface GPUComputePassEncoder {
|
||||||
[Pref="dom.webgpu.indirect-dispatch.enabled"]
|
[Pref="dom.webgpu.indirect-dispatch.enabled"]
|
||||||
undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
|
undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
|
||||||
|
|
||||||
|
[Throws]
|
||||||
undefined end();
|
undefined end();
|
||||||
};
|
};
|
||||||
GPUComputePassEncoder includes GPUObjectBase;
|
GPUComputePassEncoder includes GPUObjectBase;
|
||||||
|
|
@ -950,6 +951,7 @@ interface GPURenderPassEncoder {
|
||||||
//undefined endOcclusionQuery();
|
//undefined endOcclusionQuery();
|
||||||
|
|
||||||
undefined executeBundles(sequence<GPURenderBundle> bundles);
|
undefined executeBundles(sequence<GPURenderBundle> bundles);
|
||||||
|
[Throws]
|
||||||
undefined end();
|
undefined end();
|
||||||
};
|
};
|
||||||
GPURenderPassEncoder includes GPUObjectBase;
|
GPURenderPassEncoder includes GPUObjectBase;
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ mod foreign {
|
||||||
},
|
},
|
||||||
resource::{
|
resource::{
|
||||||
BufferAccessError, CreateBufferError, CreateSamplerError, CreateTextureError,
|
BufferAccessError, CreateBufferError, CreateSamplerError, CreateTextureError,
|
||||||
CreateTextureViewError, DestroyError,
|
CreateTextureViewError,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -653,10 +653,4 @@ mod foreign {
|
||||||
ErrorBufferType::Validation
|
ErrorBufferType::Validation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasErrorBufferType for DestroyError {
|
|
||||||
fn error_type(&self) -> ErrorBufferType {
|
|
||||||
ErrorBufferType::Validation
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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));
|
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]
|
#[no_mangle]
|
||||||
pub extern "C" fn wgpu_server_render_bundle_drop(global: &Global, self_id: id::RenderBundleId) {
|
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));
|
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_buffer: wgc::id::BufferId,
|
||||||
dst_layout: &crate::ImageDataLayout,
|
dst_layout: &crate::ImageDataLayout,
|
||||||
size: &wgt::Extent3d,
|
size: &wgt::Extent3d,
|
||||||
mut error_buf: ErrorBuffer,
|
|
||||||
) {
|
) {
|
||||||
let destination = wgc::command::ImageCopyBuffer {
|
let destination = wgc::command::ImageCopyBuffer {
|
||||||
buffer: dst_buffer,
|
buffer: dst_buffer,
|
||||||
layout: dst_layout.into_wgt(),
|
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)) {
|
gfx_select!(self_id => global.command_encoder_copy_texture_to_buffer(self_id, source, &destination, size)).unwrap();
|
||||||
error_buf.init(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Safety
|
/// # 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));
|
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]
|
#[no_mangle]
|
||||||
pub extern "C" fn wgpu_server_texture_drop(global: &Global, self_id: id::TextureId) {
|
pub extern "C" fn wgpu_server_texture_drop(global: &Global, self_id: id::TextureId) {
|
||||||
gfx_select!(self_id => global.texture_drop(self_id, false));
|
gfx_select!(self_id => global.texture_drop(self_id, false));
|
||||||
|
|
|
||||||
|
|
@ -535,3 +535,7 @@
|
||||||
[:]
|
[:]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
||||||
|
[cts.https.html?q=webgpu:api,validation,queue,destroyed,texture:writeTexture:*]
|
||||||
|
[:]
|
||||||
|
expected: FAIL
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,9 @@
|
||||||
|
|
||||||
|
|
||||||
[cts.https.html?q=webgpu:api,validation,queue,writeTexture:texture_state:*]
|
[cts.https.html?q=webgpu:api,validation,queue,writeTexture:texture_state:*]
|
||||||
|
[:textureState="destroyed"]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
[:textureState="invalid"]
|
[:textureState="invalid"]
|
||||||
expected:
|
expected:
|
||||||
if os == "win": [PASS, FAIL]
|
if os == "win": [PASS, FAIL]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue