Skip to content

Commit 58e7dd9

Browse files
committed
[update] specification.
1 parent f1743e5 commit 58e7dd9

File tree

1 file changed

+53
-38
lines changed

1 file changed

+53
-38
lines changed

docs/specs/offscreen-render-targets-and-multipass.md

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: "Offscreen Render Targets and Multipass Rendering"
33
document_id: "offscreen-render-targets-2025-11-25"
44
status: "draft"
55
created: "2025-11-25T00:00:00Z"
6-
last_updated: "2025-12-17T00:00:00Z"
7-
version: "0.2.0"
6+
last_updated: "2025-12-17T23:00:02Z"
7+
version: "0.2.1"
88
engine_workspace_version: "2023.1.30"
99
wgpu_version: "26.0.1"
1010
shader_backend_default: "naga"
1111
winit_version: "0.29.10"
12-
repo_commit: "9d16168136e560133c937d5202e6e1c80c3b2d28"
12+
repo_commit: "f1743e5528bc4c8326a46e20123ffac62f717ec9"
1313
owners: ["lambda-sh"]
1414
reviewers: ["engine", "rendering"]
1515
tags: ["spec", "rendering", "offscreen", "multipass"]
@@ -18,6 +18,7 @@ tags: ["spec", "rendering", "offscreen", "multipass"]
1818
# Offscreen Render Targets and Multipass Rendering
1919

2020
Summary
21+
2122
- Defines an offscreen render-to-texture resource that produces a sampleable
2223
color texture.
2324
- Extends the command-driven renderer so a pass begin selects a render
@@ -41,41 +42,43 @@ Summary
4142

4243
## Scope
4344

44-
### Goals
45-
46-
- Add a first-class offscreen target resource with one color output and
47-
optional depth.
48-
- Allow a render pass begin command to select a destination: the surface or a
49-
specific offscreen target.
50-
- Enable multipass workflows where later passes sample from textures produced
51-
by earlier passes.
52-
- Provide validation and feature flags for render-target compatibility, sample
53-
count and format mismatches, and common configuration pitfalls.
54-
55-
### Non-Goals
56-
57-
- Multiple simultaneous color attachments (MRT) per pass; a single color
58-
attachment per pass remains the default in this specification.
59-
- A full framegraph scheduler; ordering remains the explicit command sequence.
60-
- Headless contexts without a presentation surface; this specification assumes
61-
a window-backed `RenderContext`.
62-
- Vendor-specific optimizations beyond what `wgpu` exposes via limits and
63-
capabilities.
45+
- Goals
46+
- Add a first-class offscreen target resource with one color output and
47+
optional depth.
48+
- Allow a pass begin command to select a destination: the surface or a
49+
specific offscreen target.
50+
- Enable multipass workflows where later passes sample from textures
51+
produced by earlier passes.
52+
- Provide validation and feature flags for render-target compatibility,
53+
sample count and format mismatches, and common configuration pitfalls.
54+
- Non-Goals
55+
- Multiple render targets (MRT) per pass; a single color attachment per pass
56+
remains the default in this document.
57+
- A full framegraph scheduler; ordering remains the explicit command
58+
sequence.
59+
- Headless contexts without a presentation surface; the current design
60+
requires a window-backed `RenderContext`.
61+
- Vendor-specific optimizations beyond what `wgpu` exposes via limits and
62+
capabilities.
6463

6564
## Terminology
6665

67-
- Presentation render target: A window-backed render target that acquires and
66+
- Multi-sample anti-aliasing (MSAA): rasterization technique that stores
67+
multiple coverage samples per pixel and resolves them to a single color.
68+
- Multiple render targets (MRT): rendering to more than one color attachment
69+
within a single pass.
70+
- Presentation render target: window-backed render target that acquires and
6871
presents swapchain frames (see `render_target::WindowSurface`).
69-
- Offscreen target: A persistent resource that owns textures for render-to-
72+
- Offscreen target: persistent resource that owns textures for render-to-
7073
texture workflows and exposes a sampleable color texture.
71-
- Render destination: The destination selected when beginning a render pass:
74+
- Render destination: destination selected when beginning a render pass:
7275
the presentation surface or a specific offscreen target.
73-
- Resolve texture: The single-sample color texture produced by resolving an
76+
- Resolve texture: single-sample color texture produced by resolving an
7477
MSAA color attachment; this is the texture sampled by later passes.
75-
- Multipass rendering: A sequence of two or more render passes in a single
78+
- Multipass rendering: sequence of two or more render passes in a single
7679
frame where later passes consume the results of earlier passes (for example,
7780
post-processing or shadow map sampling).
78-
- Ping-pong target: A pair of offscreen render targets alternated between read
81+
- Ping-pong target: pair of offscreen render targets alternated between read
7982
and write roles across passes.
8083

8184
## Architecture Overview
@@ -85,10 +88,13 @@ Summary
8588
presenting frames.
8689
- `lambda::render::target::RenderTarget`: offscreen render-to-texture resource.
8790

88-
This specification treats the trait in `render_target` as the canonical meaning
89-
of \"render target\". The offscreen resource is specified as `OffscreenTarget`.
90-
The implementation SHOULD rename `lambda::render::target::RenderTarget` to
91-
avoid API ambiguity.
91+
Terminology in this document:
92+
- "Render target" refers to `lambda::render::render_target::RenderTarget`.
93+
- The offscreen resource is specified as `OffscreenTarget`.
94+
95+
Implementation note:
96+
- `lambda::render::target::RenderTarget` SHOULD be renamed to avoid API
97+
ambiguity.
9298

9399
Data flow (setup → per-frame multipass):
94100
```
@@ -106,7 +112,7 @@ RenderPipelineBuilder::new()
106112
--> RenderPipeline (built for a specific color format)
107113
108114
Per-frame commands:
109-
BeginRenderPassTo { pass_id, viewport, destination } // surface or offscreen
115+
BeginRenderPassTo { render_pass, viewport, destination } // surface or offscreen
110116
SetPipeline / SetBindGroup / Draw...
111117
EndRenderPass
112118
(repeat for additional passes)
@@ -269,7 +275,7 @@ Per-frame commands:
269275
### Always-on safeguards
270276

271277
- Reject zero-sized offscreen targets at build time.
272-
- Clamp invalid MSAA sample count inputs to `1` in builder APIs.
278+
- Treat `sample_count == 0` as `1` in builder APIs.
273279

274280
### Feature-gated validation
275281

@@ -284,7 +290,9 @@ Crate: `lambda-rs`
284290
count).
285291
- Checks MUST occur at pass begin and at `SetPipeline` time, not per draw.
286292
- Logs SHOULD include:
287-
- Destination size mismatches versus `RenderContext::surface_size()`.
293+
- Destination size mismatches versus `RenderContext::surface_size()` when
294+
the offscreen target is surface-sized by default and the surface
295+
resizes.
288296
- Missing depth attachment when depth or stencil ops are requested.
289297
- Color format mismatches between destination and pipeline.
290298
- Expected runtime cost is low to moderate.
@@ -294,11 +302,15 @@ Umbrella composition (crate: `lambda-rs`)
294302
- Umbrella features MUST only compose granular features.
295303

296304
Build-type behavior
297-
- Debug builds (`debug_assertions`) MAY enable offscreen validation regardless
298-
of features.
305+
- Debug builds (`debug_assertions`) MAY enable offscreen validation.
299306
- Release builds MUST keep offscreen validation disabled by default and enable
300307
it only via `render-validation-render-targets` (or umbrellas that include it).
301308

309+
Gating requirements
310+
- Offscreen validation MUST be gated behind
311+
`cfg(any(debug_assertions, feature = "render-validation-render-targets"))`.
312+
- Offscreen validation MUST NOT be gated behind umbrella feature names.
313+
302314
## Constraints and Rules
303315

304316
- Offscreen target constraints
@@ -405,6 +417,9 @@ Build-type behavior
405417

406418
## Changelog
407419

420+
- 2025-12-17 (v0.2.1) — Polish language for style consistency, clarify MSAA
421+
terminology and builder safeguards, and specify validation gating
422+
requirements.
408423
- 2025-12-17 (v0.2.0) — Align terminology with `render_target::RenderTarget`,
409424
specify destination-based pass targeting, define the offscreen MSAA resolve
410425
model, and define feature-gated validation requirements.

0 commit comments

Comments
 (0)