Skip to content

Commit 5fa41eb

Browse files
committed
Revert "Bug 1972921 - Track canvas textures used in bind groups r=webgpu-reviewers,nical" for causing reftests failures.
This reverts commit f1ebe83.
1 parent c825204 commit 5fa41eb

24 files changed

+20
-627
lines changed

dom/webgpu/BindGroup.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ namespace mozilla::webgpu {
1414
GPU_IMPL_CYCLE_COLLECTION(BindGroup, mParent)
1515
GPU_IMPL_JS_WRAP(BindGroup)
1616

17-
BindGroup::BindGroup(Device* const aParent, RawId aId,
18-
CanvasContextArray&& aCanvasContexts)
19-
: ChildOf(aParent),
20-
mId(aId),
21-
mUsedCanvasContexts(std::move(aCanvasContexts)) {
17+
BindGroup::BindGroup(Device* const aParent, RawId aId)
18+
: ChildOf(aParent), mId(aId) {
2219
MOZ_RELEASE_ASSERT(aId);
2320
}
2421

dom/webgpu/BindGroup.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#define GPU_BindGroup_H_
88

99
#include "nsWrapperCache.h"
10-
#include "CanvasContext.h"
1110
#include "ObjectModel.h"
1211
#include "mozilla/webgpu/WebGPUTypes.h"
1312

@@ -20,21 +19,13 @@ class BindGroup final : public ObjectBase, public ChildOf<Device> {
2019
GPU_DECL_CYCLE_COLLECTION(BindGroup)
2120
GPU_DECL_JS_WRAP(BindGroup)
2221

23-
BindGroup(Device* const aParent, RawId aId,
24-
CanvasContextArray&& aCanvasContexts);
22+
BindGroup(Device* const aParent, RawId aId);
2523

2624
const RawId mId;
2725

28-
mozilla::Span<const WeakPtr<CanvasContext>> GetCanvasContexts() const {
29-
return mUsedCanvasContexts;
30-
}
31-
3226
private:
3327
~BindGroup();
3428
void Cleanup();
35-
36-
// The canvas contexts of any canvas textures used in this bind group.
37-
CanvasContextArray mUsedCanvasContexts;
3829
};
3930

4031
} // namespace mozilla::webgpu

dom/webgpu/CanvasContext.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ class CanvasContext final : public nsICanvasRenderingContextInternal,
118118
bool mNewTextureRequested = false;
119119
};
120120

121-
typedef AutoTArray<WeakPtr<CanvasContext>, 1> CanvasContextArray;
122-
123121
} // namespace webgpu
124122
} // namespace mozilla
125123

dom/webgpu/CommandEncoder.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ void CommandEncoder::Cleanup() {
9999

100100
RefPtr<WebGPUChild> CommandEncoder::GetBridge() { return mBridge; }
101101

102-
void CommandEncoder::TrackPresentationContext(
103-
WeakPtr<CanvasContext> aTargetContext) {
102+
void CommandEncoder::TrackPresentationContext(CanvasContext* aTargetContext) {
104103
if (aTargetContext) {
105104
mPresentationContexts.AppendElement(aTargetContext);
106105
}
@@ -257,8 +256,7 @@ void CommandEncoder::ResolveQuerySet(QuerySet& aQuerySet, uint32_t aFirstQuery,
257256
aQueryCount, aDestination.mId, aDestinationOffset);
258257
}
259258

260-
void CommandEncoder::EndComputePass(ffi::WGPURecordedComputePass& aPass,
261-
CanvasContextArray& aCanvasContexts) {
259+
void CommandEncoder::EndComputePass(ffi::WGPURecordedComputePass& aPass) {
262260
// Because this can be called during child Cleanup, we need to check
263261
// that the bridge is still alive.
264262
if (!mBridge) {
@@ -273,16 +271,11 @@ void CommandEncoder::EndComputePass(ffi::WGPURecordedComputePass& aPass,
273271
}
274272
mState = CommandEncoderState::Open;
275273

276-
for (const auto& context : aCanvasContexts) {
277-
TrackPresentationContext(context);
278-
}
279-
280274
ffi::wgpu_compute_pass_finish(mBridge->GetClient(), mParent->mId, mId,
281275
&aPass);
282276
}
283277

284-
void CommandEncoder::EndRenderPass(ffi::WGPURecordedRenderPass& aPass,
285-
CanvasContextArray& aCanvasContexts) {
278+
void CommandEncoder::EndRenderPass(ffi::WGPURecordedRenderPass& aPass) {
286279
// Because this can be called during child Cleanup, we need to check
287280
// that the bridge is still alive.
288281
if (!mBridge) {
@@ -297,10 +290,6 @@ void CommandEncoder::EndRenderPass(ffi::WGPURecordedRenderPass& aPass,
297290
}
298291
mState = CommandEncoderState::Open;
299292

300-
for (const auto& context : aCanvasContexts) {
301-
TrackPresentationContext(context);
302-
}
303-
304293
ffi::wgpu_render_pass_finish(mBridge->GetClient(), mParent->mId, mId, &aPass);
305294
}
306295

dom/webgpu/CommandEncoder.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "mozilla/webgpu/ffi/wgpu.h"
1313
#include "mozilla/webgpu/WebGPUTypes.h"
1414
#include "nsWrapperCache.h"
15-
#include "CanvasContext.h"
1615
#include "ObjectModel.h"
1716
#include "QuerySet.h"
1817

@@ -69,20 +68,18 @@ class CommandEncoder final : public ObjectBase, public ChildOf<Device> {
6968
CommandEncoderState mState;
7069

7170
RefPtr<WebGPUChild> mBridge;
72-
CanvasContextArray mPresentationContexts;
71+
nsTArray<WeakPtr<CanvasContext>> mPresentationContexts;
7372

74-
void TrackPresentationContext(WeakPtr<CanvasContext> aTargetContext);
73+
void TrackPresentationContext(CanvasContext* aTargetContext);
7574

7675
public:
7776
const auto& GetDevice() const { return mParent; };
7877
RefPtr<WebGPUChild> GetBridge();
7978

8079
CommandEncoderState GetState() const { return mState; };
8180

82-
void EndComputePass(ffi::WGPURecordedComputePass& aPass,
83-
CanvasContextArray& aCanvasContexts);
84-
void EndRenderPass(ffi::WGPURecordedRenderPass& aPass,
85-
CanvasContextArray& aCanvasContexts);
81+
void EndComputePass(ffi::WGPURecordedComputePass& aPass);
82+
void EndRenderPass(ffi::WGPURecordedRenderPass& aPass);
8683

8784
void CopyBufferToBuffer(const Buffer& aSource, const Buffer& aDestination,
8885
const dom::Optional<BufferAddress>& aSize) {

dom/webgpu/ComputePassEncoder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ void ComputePassEncoder::SetBindGroup(uint32_t aSlot,
6464
RawId bindGroup = 0;
6565
if (aBindGroup) {
6666
mUsedBindGroups.AppendElement(aBindGroup);
67-
mUsedCanvasContexts.AppendElements(aBindGroup->GetCanvasContexts());
6867
bindGroup = aBindGroup->mId;
6968
}
7069
ffi::wgpu_recorded_compute_pass_set_bind_group(
@@ -160,7 +159,7 @@ void ComputePassEncoder::End() {
160159
return;
161160
}
162161
MOZ_ASSERT(!!mPass);
163-
mParent->EndComputePass(*mPass, mUsedCanvasContexts);
162+
mParent->EndComputePass(*mPass);
164163
Cleanup();
165164
}
166165

dom/webgpu/ComputePassEncoder.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ class ComputePassEncoder final : public ObjectBase,
5050
nsTArray<RefPtr<const Buffer>> mUsedBuffers;
5151
nsTArray<RefPtr<const ComputePipeline>> mUsedPipelines;
5252

53-
// The canvas contexts of any canvas textures used in bind groups of this
54-
// compute pass.
55-
CanvasContextArray mUsedCanvasContexts;
56-
5753
// programmable pass encoder
5854
private:
5955
void SetBindGroup(uint32_t aSlot, BindGroup* const aBindGroup,
@@ -83,11 +79,6 @@ class ComputePassEncoder final : public ObjectBase,
8379
void InsertDebugMarker(const nsAString& aString);
8480

8581
void End();
86-
87-
// helpers not defined by WebGPU
88-
mozilla::Span<const WeakPtr<CanvasContext>> GetCanvasContexts() const {
89-
return mUsedCanvasContexts;
90-
}
9182
};
9283

9384
} // namespace webgpu

dom/webgpu/Device.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ already_AddRefed<PipelineLayout> Device::CreatePipelineLayout(
441441
already_AddRefed<BindGroup> Device::CreateBindGroup(
442442
const dom::GPUBindGroupDescriptor& aDesc) {
443443
nsTArray<ffi::WGPUBindGroupEntry> entries(aDesc.mEntries.Length());
444-
CanvasContextArray canvasContexts;
445444
for (const auto& entry : aDesc.mEntries) {
446445
ffi::WGPUBindGroupEntry e = {};
447446
e.binding = entry.mBinding;
@@ -455,12 +454,7 @@ already_AddRefed<BindGroup> Device::CreateBindGroup(
455454
e.offset = bufBinding.mOffset;
456455
e.size = bufBinding.mSize.WasPassed() ? bufBinding.mSize.Value() : 0;
457456
} else if (entry.mResource.IsGPUTextureView()) {
458-
auto texture_view = entry.mResource.GetAsGPUTextureView();
459-
e.texture_view = texture_view->mId;
460-
auto context = texture_view->GetTargetContext();
461-
if (context) {
462-
canvasContexts.AppendElement(context);
463-
}
457+
e.texture_view = entry.mResource.GetAsGPUTextureView()->mId;
464458
} else if (entry.mResource.IsGPUSampler()) {
465459
e.sampler = entry.mResource.GetAsGPUSampler()->mId;
466460
} else {
@@ -484,7 +478,7 @@ already_AddRefed<BindGroup> Device::CreateBindGroup(
484478
RawId id =
485479
ffi::wgpu_client_create_bind_group(mBridge->GetClient(), mId, &desc);
486480

487-
RefPtr<BindGroup> object = new BindGroup(this, id, std::move(canvasContexts));
481+
RefPtr<BindGroup> object = new BindGroup(this, id);
488482
object->SetLabel(aDesc.mLabel);
489483

490484
return object.forget();

dom/webgpu/RenderBundle.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ namespace mozilla::webgpu {
1414
GPU_IMPL_CYCLE_COLLECTION(RenderBundle, mParent)
1515
GPU_IMPL_JS_WRAP(RenderBundle)
1616

17-
RenderBundle::RenderBundle(Device* const aParent, RawId aId,
18-
CanvasContextArray&& aCanvasContexts)
19-
: ChildOf(aParent),
20-
mId(aId),
21-
mUsedCanvasContexts(std::move(aCanvasContexts)) {
17+
RenderBundle::RenderBundle(Device* const aParent, RawId aId)
18+
: ChildOf(aParent), mId(aId) {
2219
// TODO: we may be running into this if we finish an encoder twice.
2320
MOZ_RELEASE_ASSERT(aId);
2421
}

dom/webgpu/RenderBundle.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#define GPU_RenderBundle_H_
88

99
#include "nsWrapperCache.h"
10-
#include "CanvasContext.h"
1110
#include "ObjectModel.h"
1211

1312
namespace mozilla::webgpu {
@@ -19,21 +18,13 @@ class RenderBundle final : public ObjectBase, public ChildOf<Device> {
1918
GPU_DECL_CYCLE_COLLECTION(RenderBundle)
2019
GPU_DECL_JS_WRAP(RenderBundle)
2120

22-
RenderBundle(Device* const aParent, RawId aId,
23-
CanvasContextArray&& aCanvasContexts);
21+
RenderBundle(Device* const aParent, RawId aId);
2422

2523
const RawId mId;
2624

27-
mozilla::Span<const WeakPtr<CanvasContext>> GetCanvasContexts() const {
28-
return mUsedCanvasContexts;
29-
}
30-
3125
private:
3226
virtual ~RenderBundle();
3327
void Cleanup();
34-
35-
// The canvas contexts of any canvas textures used in this render bundle.
36-
CanvasContextArray mUsedCanvasContexts;
3728
};
3829

3930
} // namespace mozilla::webgpu

0 commit comments

Comments
 (0)