Closed Bug 1712963 Opened 3 years ago Closed 5 months ago

Refactor mValid checks in WebGPU for early-out

Categories

(Core :: Graphics: WebGPU, task, P3)

task

Tracking

()

RESOLVED FIXED
127 Branch
Tracking Status
firefox127 --- fixed

People

(Reporter: kvark, Assigned: bradwerth)

References

(Blocks 2 open bugs, Regressed 2 open bugs)

Details

Attachments

(1 file)

Requested in https://phabricator.services.mozilla.com/D114878#inline-643161
In code like this:

if (mValid) {
    ffi::wgpu_render_bundle_draw(mEncoder, aVertexCount, aInstanceCount,
                                 aFirstVertex, aFirstInstance);
  }

The suggestion is to d oif (!mValid) { ... return; } instead.

Blocks: webgpu-v1
Priority: -- → P3
Blocks: webgpu-phase-2
No longer blocks: webgpu-v1
Assignee: nobody → bwerth

Primarily this standardizes ComputePassEncoder, RenderBundleEncoder and
RenderPassEncoder on the "if (!mValid)" pattern for early exits for ffi
functions. It also attempts to make each class have at most two ways to
become invalid:

  1. RenderBundleEncoder and RenderPassEncoder can become invalid at
    construction time.
  2. Those classes and ComputePassEncoder all now have an implementation
    of their ::Cleanup method, which is called from the destructor, and the
    Cleanup method is responsible for making the object invalid and
    releasing internal resources (possibly by calling another method).

Together these changes make it easier to reason about what mValid means
for these classes, and what is the state of their internal resources.

Pushed by bwerth@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e98d0558c0bf Simplify mValid handling in some WebGPU classes. r=webgpu-reviewers,nical
Status: NEW → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 127 Branch
Type: enhancement → task
Regressions: 1905383
Regressions: 1907457
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: