Split the WebRender device layer into a backend-neutral Device and a GL backend
Categories
(Core :: Graphics: WebRender, task)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox158 | --- | fixed |
People
(Reporter: gw, Assigned: gw)
Details
Attachments
(8 external files)
| Assignee | ||
Comment 1•2 months ago
|
||
Texture, ExternalTexture, Program, VAO, TransferBuffer and the framebuffer
and buffer id newtypes now hold plain integers rather than gleam types, and
Texture holds the ImageBufferKind it was created from rather than a GL enum,
converting at the call sites that issue GL. DepthFunction becomes a plain
enum with the GL mapping in to_gl. This lets the resource types be shared
with another backend without depending on gleam.
No behaviour change: from_gl_target, which could not tell
TextureExternalBT709 from TextureExternal, is no longer needed.
Updated•2 months ago
|
| Assignee | ||
Comment 2•2 months ago
|
||
Remove UniformLocation, get_uniform_location and draw_triangles_u16, none of
which had callers, and the phantom type parameter of reuse_render_target.
Privatise the helpers only called from inside the device: bind_read_target,
bind_external_draw_target, reset_draw_target, depth_bits, compile_shader,
invalidate_depth_target, create_transfer_buffer and
required_upload_size_and_stride.
What remains is what a backend trait will have to express, so it should be
as small as possible. No behaviour change.
| Assignee | ||
Comment 3•2 months ago
|
||
UploadBufferPool and TextureUploader reached into the GL context to
allocate, map, flush and orphan pixel buffers, to create and poll sync
objects, and to issue texture updates. Express those as Device operations
any backend can provide: allocate, map, flush and orphan_upload_buffer,
upload_texture_region, and create, poll and delete_fence over Fence and
FenceStatus. UploadChunk becomes the public description of one copy from an
upload buffer into a texture, and flush_upload_buffer performs a batch of
them, which is the shape of a staging buffer copy in explicit graphics APIs.
The pool and uploader then use only Device and Capabilities, so they can
move out of the GL backend.
GL calls are the same except that the pixel unpack buffer is unbound at the
end of each flush and orphan rather than once per returned buffer, adding a
rebind when an oversized buffer is orphaned, and that a recycled
persistently mapped buffer is no longer bound while being handed out, since
nothing used the binding.
| Assignee | ||
Comment 4•2 months ago
|
||
The GPU profiler held its own GL context handle for timer and occlusion
queries and for debug marker groups, and picked the GL debug extension
itself. Give it a GpuQueryBackend trait with the operations it needs,
implemented for GL by GlQueries in the device, which also owns the extension
choice. The file is renamed query_gl.rs to query.rs; its module path
device::query is unchanged. No behaviour change.
| Assignee | ||
Comment 5•2 months ago
|
||
Explicit graphics APIs bake blend, depth test, depth write and color write
mask into a pipeline object together with the shader, so a backend needs to
see them when the program is bound rather than as separate GL-style toggles.
Add RenderState holding those four settings and bind_pipeline(program,
state). The set_blend_mode, set_depth_test, set_depth_write and
set_color_write methods now only record the requested state and bind_program
applies it, so renderer call sites are unchanged. Debug builds still assert
that a draw follows the program bind, which is what makes the state known at
bind time.
The GL device caches the state the context holds and issues calls only for
the parts that differ, invalidating the cache in reset_state, which the
renderer already calls after external code may have used the context. The
color mask is the exception, assumed untouched by external code as it always
has been, because SWGL does not implement glColorMask and it must not be
issued unless the renderer asks for it. Clears set the depth write mask they
need themselves, being independent of pipeline state in explicit APIs, and
the stencil test is disabled once in begin_frame instead of through a
separate disable_stencil call. The GL calls issued are otherwise the same or
fewer.
| Assignee | ||
Comment 6•2 months ago
|
||
Device becomes a thin wrapper around Box<dyn GpuBackend>, the trait a
graphics API backend implements, and the GL implementation is renamed
GlDevice. The trait covers resource creation and destruction, render passes,
bind_pipeline, texture and vertex binding, uploads, readback, fences,
queries and draws, with vertex, instance and texel data passed as bytes so
that it is object safe.
The wrapper derefs to the backend, so renderer call sites are unchanged, and
owns what is backend independent: the requested RenderState and its set_*
methods, bind_program, the debug check that a draw follows a program bind,
the typed helpers over sampler types and typed slices, create_program_linked,
blit_render_target_invert_y and upload_texture. MappedTransferBuffer holds
the backend and unmaps through a new unmap_transfer_buffer, and the texture
counters become accessors.
Most of the diff is GlDevice's methods splitting into a trait impl block and
a private one; review with --color-moved. The GL calls issued are unchanged.
| Assignee | ||
Comment 7•2 months ago
|
||
Move the resource types, state and descriptor structs, targets and the
program binary cache from device/gl.rs to device/types.rs, and the upload
buffer pool and texture uploader to device/upload.rs, so that gl.rs holds
only the GL backend. The moved code is unchanged apart from imports and the
fields and helpers the GL backend fills in becoming pub(super). Methods that
need GL, such as DepthFunction::to_gl and ProgramSourceInfo::new, stay in
gl.rs as inherent impls on the moved types.
The gl_leaks test now scans everything except device/gl.rs. device/mod.rs
joins the allowlist because Device::new still takes the GL context, which
Pt 8 replaces with a backend selection. No behaviour change.
| Assignee | ||
Comment 8•2 months ago
|
||
create_webrender_instance and Device::new took the GL context directly,
which tied the embedder API to gleam. They now take GpuBackendConfig, an
enum with one variant per backend carrying what that backend needs from the
embedder; Gl carries the GL context. Gecko, wrench and the examples wrap
their context in GpuBackendConfig::Gl.
With that, renderer/init.rs and lib.rs no longer mention GL, so the gl_leaks
allowlist is empty. device/mod.rs is permanently allowed, since selecting a
backend means naming each one's native context type. No behaviour change.
Comment 10•1 month ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/28d6ee4697ad
https://hg.mozilla.org/mozilla-central/rev/2e82a5313a09
https://hg.mozilla.org/mozilla-central/rev/07a7a0922e20
https://hg.mozilla.org/mozilla-central/rev/3878799c78e1
https://hg.mozilla.org/mozilla-central/rev/0a48ebae16fa
https://hg.mozilla.org/mozilla-central/rev/0cb7d640b527
https://hg.mozilla.org/mozilla-central/rev/d146346fdc03
https://hg.mozilla.org/mozilla-central/rev/a6fcce2bb53d
Updated•1 month ago
|
Description
•