Skip to content

Commit 3fa70c2

Browse files
committed
[fix] instancing validation flag name & add it to render-validation-all.
1 parent c8f727f commit 3fa70c2

File tree

5 files changed

+39
-49
lines changed

5 files changed

+39
-49
lines changed

crates/lambda-rs/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ render-validation-strict = [
5858
render-validation-all = [
5959
"render-validation-strict",
6060
"render-validation-device",
61+
"render-validation-instancing",
6162
]
6263

6364
# Granular feature flags
@@ -73,7 +74,7 @@ render-validation-stencil = []
7374
render-validation-pass-compat = []
7475
render-validation-device = []
7576
render-validation-encoder = []
76-
render-instancing-validation = []
77+
render-validation-instancing = []
7778

7879

7980
# ---------------------------- PLATFORM DEPENDENCIES ---------------------------

crates/lambda-rs/src/render/mod.rs

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -621,17 +621,13 @@ impl RenderContext {
621621
{
622622
Self::apply_viewport(pass, &initial_viewport);
623623

624-
#[cfg(any(
625-
debug_assertions,
626-
feature = "render-validation-encoder",
627-
feature = "render-instancing-validation",
628-
))]
624+
#[cfg(any(debug_assertions, feature = "render-validation-encoder",))]
629625
let mut current_pipeline: Option<usize> = None;
630626

631627
#[cfg(any(debug_assertions, feature = "render-validation-encoder",))]
632628
let mut bound_index_buffer: Option<(usize, u32)> = None;
633629

634-
#[cfg(any(debug_assertions, feature = "render-instancing-validation",))]
630+
#[cfg(any(debug_assertions, feature = "render-validation-instancing",))]
635631
let mut bound_vertex_slots: HashSet<u32> = HashSet::new();
636632

637633
// De-duplicate advisories within this pass
@@ -882,11 +878,7 @@ impl RenderContext {
882878
vertices,
883879
instances,
884880
} => {
885-
#[cfg(any(
886-
debug_assertions,
887-
feature = "render-validation-encoder",
888-
feature = "render-instancing-validation",
889-
))]
881+
#[cfg(any(debug_assertions, feature = "render-validation-encoder",))]
890882
{
891883
if current_pipeline.is_none() {
892884
return Err(RenderError::Configuration(
@@ -898,7 +890,7 @@ impl RenderContext {
898890

899891
#[cfg(any(
900892
debug_assertions,
901-
feature = "render-instancing-validation",
893+
feature = "render-validation-instancing",
902894
))]
903895
{
904896
let pipeline_index = current_pipeline
@@ -920,7 +912,7 @@ impl RenderContext {
920912
}
921913
#[cfg(any(
922914
debug_assertions,
923-
feature = "render-instancing-validation",
915+
feature = "render-validation-instancing",
924916
))]
925917
{
926918
if instances.start == instances.end {
@@ -976,21 +968,7 @@ impl RenderContext {
976968
}
977969
#[cfg(any(
978970
debug_assertions,
979-
feature = "render-validation-encoder",
980-
feature = "render-instancing-validation",
981-
))]
982-
{
983-
if current_pipeline.is_none() {
984-
return Err(RenderError::Configuration(
985-
"DrawIndexed command encountered before any pipeline was set in this render pass"
986-
.to_string(),
987-
));
988-
}
989-
}
990-
991-
#[cfg(any(
992-
debug_assertions,
993-
feature = "render-instancing-validation",
971+
feature = "render-validation-instancing",
994972
))]
995973
{
996974
let pipeline_index = current_pipeline
@@ -1012,7 +990,7 @@ impl RenderContext {
1012990
}
1013991
#[cfg(any(
1014992
debug_assertions,
1015-
feature = "render-instancing-validation",
993+
feature = "render-validation-instancing",
1016994
))]
1017995
{
1018996
if instances.start == instances.end {

docs/features.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: "Cargo Features Overview"
33
document_id: "features-2025-11-17"
44
status: "living"
55
created: "2025-11-17T23:59:00Z"
6-
last_updated: "2025-11-25T00:00:00Z"
7-
version: "0.1.1"
6+
last_updated: "2025-11-25T02:20:00Z"
7+
version: "0.1.3"
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: "b1f0509d245065823dff2721f97e16c0215acc4f"
12+
repo_commit: "c8f727f3774029135ed1f7a7224288faf7b9e442"
1313
owners: ["lambda-sh"]
1414
reviewers: ["engine", "rendering"]
1515
tags: ["guide", "features", "validation", "cargo"]
@@ -44,9 +44,9 @@ This document enumerates the primary Cargo features exposed by the workspace rel
4444
## Render Validation
4545

4646
Umbrella features (crate: `lambda-rs`)
47-
- `render-validation`: enables common builder/pipeline validation logs (MSAA counts, depth clear advisories, stencil format upgrades).
48-
- `render-validation-strict`: includes `render-validation` and enables per-draw SetPipeline-time compatibility checks.
49-
- `render-validation-all`: superset of `render-validation-strict` and enables device-probing advisories.
47+
- `render-validation`: enables common builder/pipeline validation logs (MSAA counts, depth clear advisories, stencil format upgrades) by composing granular validation features.
48+
- `render-validation-strict`: includes `render-validation` and enables per-draw SetPipeline-time compatibility checks by composing additional granular encoder features.
49+
- `render-validation-all`: superset of `render-validation-strict` and enables device-probing advisories and instancing validation. This umbrella includes all granular render-validation flags, including `render-validation-instancing`.
5050

5151
Granular features (crate: `lambda-rs`)
5252
- `render-validation-msaa`: validates/logs MSAA sample counts; logs pass/pipeline sample mismatches. Behavior:
@@ -57,7 +57,7 @@ Granular features (crate: `lambda-rs`)
5757
- `render-validation-pass-compat`: SetPipeline-time errors when color targets or depth/stencil expectations do not match the active pass.
5858
- `render-validation-device`: device/format probing advisories (if available via the platform layer).
5959
- `render-validation-encoder`: additional per-draw/encoder-time checks; highest runtime cost.
60-
- `render-instancing-validation`: instance-range and per-instance buffer binding validation for `RenderCommand::Draw` and `RenderCommand::DrawIndexed`. Behavior:
60+
- `render-validation-instancing`: instance-range and per-instance buffer binding validation for `RenderCommand::Draw` and `RenderCommand::DrawIndexed`. Behavior:
6161
- Validates that `instances.start <= instances.end` and treats `start == end` as a no-op (draw is skipped).
6262
- Ensures that all vertex buffer slots marked as per-instance on the active pipeline have been bound in the current render pass.
6363
- Adds per-draw checks proportional to the number of instanced draws and per-instance slots; SHOULD be enabled only when diagnosing instancing issues.
@@ -76,9 +76,13 @@ Usage examples
7676
- `cargo build -p lambda-rs --features render-validation`
7777
- Enable strict compatibility checks in release:
7878
- `cargo run -p lambda-rs --features render-validation-strict`
79+
- Enable all validations, including device advisories and instancing validation, in release:
80+
- `cargo test -p lambda-rs --features render-validation-all`
7981
- Enable only MSAA validation in release:
8082
- `cargo test -p lambda-rs --features render-validation-msaa`
8183

8284
## Changelog
85+
- 0.1.3 (2025-11-25): Rename the instancing validation feature to `render-validation-instancing`, clarify umbrella composition, and update metadata.
86+
- 0.1.2 (2025-11-25): Clarify umbrella versus granular validation features, record that `render-validation-all` includes `render-instancing-validation`, and update metadata.
8387
- 0.1.1 (2025-11-25): Document `render-instancing-validation` behavior and update metadata.
8488
- 0.1.0 (2025-11-17): Initial document introducing validation features and behavior by build type.

docs/specs/instanced-rendering.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: "Instanced Rendering"
33
document_id: "instanced-rendering-2025-11-23"
44
status: "draft"
55
created: "2025-11-23T00:00:00Z"
6-
last_updated: "2025-11-25T01:00:00Z"
7-
version: "0.1.3"
6+
last_updated: "2025-11-25T02:20:00Z"
7+
version: "0.1.5"
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: "7f8375d73a0dbca5eb143dda38e8e1600f62683c"
12+
repo_commit: "c8f727f3774029135ed1f7a7224288faf7b9e442"
1313
owners: ["lambda-sh"]
1414
reviewers: ["engine", "rendering"]
1515
tags: ["spec", "rendering", "instancing", "vertex-input"]
@@ -168,7 +168,7 @@ App Code
168168
- The `lambda-rs` crate MUST treat `instances = 0..1` as the default
169169
single-instance behavior used by existing rendering paths.
170170
- Feature flags (`lambda-rs`)
171-
- `render-instancing-validation`
171+
- `render-validation-instancing`
172172
- Owning crate: `lambda-rs`.
173173
- Default: disabled in release builds; MAY be enabled in debug builds or
174174
by opt-in.
@@ -211,15 +211,19 @@ App Code
211211
and instance) before issuing `Draw` or `DrawIndexed` commands that rely on
212212
those slots.
213213
- Validation behavior
214-
- When `render-instancing-validation` and `render-validation-encoder` are
215-
enabled, the `lambda-rs` crate SHOULD:
214+
- When `render-validation-instancing` is enabled (or when `debug_assertions`
215+
are active), the `lambda-rs` crate SHOULD:
216216
- Verify that all buffer slots used by per-instance attributes are bound
217217
before a draw that uses those attributes.
218218
- Emit a clear error when a draw is issued with an `instances` range whose
219219
upper bound exceeds expectations for the instance buffer size, when this
220220
information is available.
221221
- Check that `instances.start <= instances.end` and treat negative-length
222222
ranges as configuration errors.
223+
- Umbrella features such as `render-validation-all` MAY include
224+
`render-validation-instancing` for convenience, but code and tests MUST
225+
gate instancing behavior on the granular `render-validation-instancing`
226+
feature (plus `debug_assertions`), not on umbrella feature names.
223227

224228
### Validation and Errors
225229

@@ -233,7 +237,7 @@ App Code
233237
- `BindVertexBuffer` MUST reference a buffer created with `BufferType::Vertex`
234238
and a slot index that is less than the number of vertex buffer layouts
235239
declared on the pipeline.
236-
- When `render-instancing-validation` is enabled, the `lambda-rs` crate SHOULD:
240+
- When `render-validation-instancing` is enabled, the `lambda-rs` crate SHOULD:
237241
- Verify that the set of bound buffers covers all pipeline slots that
238242
declare per-instance attributes before a draw is issued.
239243
- Log an error if a draw is issued with a per-instance attribute whose slot
@@ -369,6 +373,8 @@ relevant code and tests, for example in the pull request description.
369373

370374
## Changelog
371375

376+
- 2025-11-25 (v0.1.5) — Rename the granular instancing validation feature to `render-validation-instancing`, clarify naming in feature documentation, and update metadata.
377+
- 2025-11-25 (v0.1.4) — Clarify that instancing validation is gated by the granular `render-instancing-validation` feature (and `debug_assertions`) and may be included in umbrella features such as `render-validation-all`; update metadata.
372378
- 2025-11-25 (v0.1.3) — Mark existing draw paths as compatible with `instances = 0..1`, record the addition of an instanced rendering example, and update metadata.
373379
- 2025-11-25 (v0.1.2) — Update terminology to reference crates by name, remove per-file implementation locations from the Requirements Checklist, and mark instancing validation features as implemented in `lambda-rs`.
374380
- 2025-11-24 (v0.1.1) — Mark initial instancing layout and step mode support as implemented in the Requirements Checklist; metadata updated.

docs/tutorials/instanced-quads.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: "Instanced Rendering: Grid of Colored Quads"
33
document_id: "instanced-quads-tutorial-2025-11-25"
44
status: "draft"
55
created: "2025-11-25T00:00:00Z"
6-
last_updated: "2025-11-25T00:00:00Z"
7-
version: "0.1.0"
6+
last_updated: "2025-11-25T02:20:00Z"
7+
version: "0.1.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: "2ff0a581af014a754e982881193c36f47e685602"
12+
repo_commit: "c8f727f3774029135ed1f7a7224288faf7b9e442"
1313
owners: ["lambda-sh"]
1414
reviewers: ["engine", "rendering"]
1515
tags: ["tutorial", "graphics", "instancing", "vertex-buffers", "rust", "wgpu"]
@@ -479,7 +479,7 @@ The commands bind both vertex buffers and the index buffer before issuing `DrawI
479479

480480
- Vertex attribute locations in the shaders MUST match the `VertexAttribute` configuration for both the per-vertex and per-instance buffers.
481481
- The instance buffer MUST be bound on the same slot that `with_instance_buffer` uses; binding a different slot will lead to incorrect or undefined attribute data during rendering.
482-
- Instance ranges for `DrawIndexed` MUST remain within the logical count of instances created for the instance buffer; validation features such as `render-instancing-validation` SHOULD be enabled when developing new instanced render paths.
482+
- Instance ranges for `DrawIndexed` MUST remain within the logical count of instances created for the instance buffer; validation features such as `render-validation-instancing` SHOULD be enabled when developing new instanced render paths.
483483
- Per-instance data MAY be updated each frame to animate offsets or colors; static data is sufficient for verifying buffer layouts and instance ranges.
484484

485485
## Conclusion <a name="conclusion"></a>
@@ -493,8 +493,9 @@ This tutorial demonstrates how the `lambda-rs` crate uses per-vertex and per-ins
493493
- Introduce a uniform buffer that applies a global transform to all instances and combine it with per-instance offsets.
494494
- Extend the shaders to include per-instance scale or rotation and add fields to `InstanceData` to drive those transforms.
495495
- Add a second instanced draw call that uses the same geometry but a different instance buffer to render a second grid with an alternate color pattern.
496-
- Experiment with validation features, such as `render-instancing-validation`, by intentionally omitting the instance buffer binding and observing how configuration errors are reported.
496+
- Experiment with validation features, such as `render-validation-instancing`, by intentionally omitting the instance buffer binding and observing how configuration errors are reported.
497497

498498
## Changelog <a name="changelog"></a>
499499

500+
- 2025-11-25 (v0.1.1) — Align feature naming with `render-validation-instancing` and update metadata.
500501
- 2025-11-25 (v0.1.0) — Initial instanced quads tutorial describing per-vertex and per-instance buffers and the `instanced_quads` example.

0 commit comments

Comments
 (0)