зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1883810: refactor(webgpu): subvert/targetContext/presentationContext for `CommandEncoder`s r=webgpu-reviewers,jimb
Differential Revision: https://phabricator.services.mozilla.com/D203959
This commit is contained in:
Родитель
c35973d8c9
Коммит
1a670cacb4
|
@ -16,10 +16,13 @@ namespace mozilla::webgpu {
|
|||
GPU_IMPL_CYCLE_COLLECTION(CommandBuffer, mParent)
|
||||
GPU_IMPL_JS_WRAP(CommandBuffer)
|
||||
|
||||
CommandBuffer::CommandBuffer(Device* const aParent, RawId aId,
|
||||
nsTArray<WeakPtr<CanvasContext>>&& aTargetContexts,
|
||||
CommandBuffer::CommandBuffer(
|
||||
Device* const aParent, RawId aId,
|
||||
nsTArray<WeakPtr<CanvasContext>>&& aPresentationContexts,
|
||||
RefPtr<CommandEncoder>&& aEncoder)
|
||||
: ChildOf(aParent), mId(aId), mTargetContexts(std::move(aTargetContexts)) {
|
||||
: ChildOf(aParent),
|
||||
mId(aId),
|
||||
mPresentationContexts(std::move(aPresentationContexts)) {
|
||||
mEncoder = std::move(aEncoder);
|
||||
MOZ_RELEASE_ASSERT(aId);
|
||||
}
|
||||
|
@ -33,9 +36,9 @@ Maybe<RawId> CommandBuffer::Commit() {
|
|||
return Nothing();
|
||||
}
|
||||
mValid = false;
|
||||
for (const auto& targetContext : mTargetContexts) {
|
||||
if (targetContext) {
|
||||
targetContext->MaybeQueueSwapChainPresent();
|
||||
for (const auto& presentationContext : mPresentationContexts) {
|
||||
if (presentationContext) {
|
||||
presentationContext->MaybeQueueSwapChainPresent();
|
||||
}
|
||||
}
|
||||
return Some(mId);
|
||||
|
|
|
@ -22,7 +22,7 @@ class CommandBuffer final : public ObjectBase, public ChildOf<Device> {
|
|||
GPU_DECL_JS_WRAP(CommandBuffer)
|
||||
|
||||
CommandBuffer(Device* const aParent, RawId aId,
|
||||
nsTArray<WeakPtr<CanvasContext>>&& aTargetContexts,
|
||||
nsTArray<WeakPtr<CanvasContext>>&& aPresentationContexts,
|
||||
RefPtr<CommandEncoder>&& aEncoder);
|
||||
|
||||
Maybe<RawId> Commit();
|
||||
|
@ -33,7 +33,7 @@ class CommandBuffer final : public ObjectBase, public ChildOf<Device> {
|
|||
void Cleanup();
|
||||
|
||||
const RawId mId;
|
||||
const nsTArray<WeakPtr<CanvasContext>> mTargetContexts;
|
||||
const nsTArray<WeakPtr<CanvasContext>> mPresentationContexts;
|
||||
// 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
|
||||
|
|
|
@ -123,7 +123,7 @@ void CommandEncoder::CopyBufferToTexture(
|
|||
|
||||
const auto& targetContext = aDestination.mTexture->mTargetContext;
|
||||
if (targetContext) {
|
||||
mTargetContexts.AppendElement(targetContext);
|
||||
mPresentationContexts.AppendElement(targetContext);
|
||||
}
|
||||
}
|
||||
void CommandEncoder::CopyTextureToBuffer(
|
||||
|
@ -158,7 +158,7 @@ void CommandEncoder::CopyTextureToTexture(
|
|||
|
||||
const auto& targetContext = aDestination.mTexture->mTargetContext;
|
||||
if (targetContext) {
|
||||
mTargetContexts.AppendElement(targetContext);
|
||||
mPresentationContexts.AppendElement(targetContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,11 +218,11 @@ already_AddRefed<RenderPassEncoder> CommandEncoder::BeginRenderPass(
|
|||
for (const auto& at : aDesc.mColorAttachments) {
|
||||
auto* targetContext = at.mView->GetTargetContext();
|
||||
if (targetContext) {
|
||||
mTargetContexts.AppendElement(targetContext);
|
||||
mPresentationContexts.AppendElement(targetContext);
|
||||
}
|
||||
if (at.mResolveTarget.WasPassed()) {
|
||||
targetContext = at.mResolveTarget.Value().GetTargetContext();
|
||||
mTargetContexts.AppendElement(targetContext);
|
||||
mPresentationContexts.AppendElement(targetContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ already_AddRefed<CommandBuffer> CommandEncoder::Finish(
|
|||
|
||||
RefPtr<CommandEncoder> me(this);
|
||||
RefPtr<CommandBuffer> comb = new CommandBuffer(
|
||||
mParent, mId, std::move(mTargetContexts), std::move(me));
|
||||
mParent, mId, std::move(mPresentationContexts), std::move(me));
|
||||
return comb.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class CommandEncoder final : public ObjectBase, public ChildOf<Device> {
|
|||
void Cleanup();
|
||||
|
||||
RefPtr<WebGPUChild> mBridge;
|
||||
nsTArray<WeakPtr<CanvasContext>> mTargetContexts;
|
||||
nsTArray<WeakPtr<CanvasContext>> mPresentationContexts;
|
||||
|
||||
public:
|
||||
const auto& GetDevice() const { return mParent; };
|
||||
|
|
Загрузка…
Ссылка в новой задаче