|
| 1 | +--- |
| 2 | +title: "Cargo Features Overview" |
| 3 | +document_id: "features-2025-11-17" |
| 4 | +status: "living" |
| 5 | +created: "2025-11-17T23:59:00Z" |
| 6 | +last_updated: "2025-11-17T23:59:00Z" |
| 7 | +version: "0.1.0" |
| 8 | +engine_workspace_version: "2023.1.30" |
| 9 | +wgpu_version: "26.0.1" |
| 10 | +shader_backend_default: "naga" |
| 11 | +winit_version: "0.29.10" |
| 12 | +repo_commit: "70670f8ad6bb7ac14a62e7d5847bf21cfe13f665" |
| 13 | +owners: ["lambda-sh"] |
| 14 | +reviewers: ["engine", "rendering"] |
| 15 | +tags: ["guide", "features", "validation", "cargo"] |
| 16 | +--- |
| 17 | + |
| 18 | +## Overview |
| 19 | +This document enumerates the primary Cargo features exposed by the workspace relevant to rendering and validation behavior. It defines defaults, relationships, and expected behavior in debug and release builds. |
| 20 | + |
| 21 | +## Table of Contents |
| 22 | +- [Overview](#overview) |
| 23 | +- [Defaults](#defaults) |
| 24 | +- [Rendering Backends](#rendering-backends) |
| 25 | +- [Shader Backends](#shader-backends) |
| 26 | +- [Render Validation](#render-validation) |
| 27 | +- [Changelog](#changelog) |
| 28 | + |
| 29 | +## Defaults |
| 30 | +- Workspace defaults prefer `wgpu` on supported platforms and `naga` for shader compilation. |
| 31 | +- Debug builds enable all validations unconditionally via `debug_assertions`. |
| 32 | +- Release builds enable only cheap safety checks by default; validation logs and per-draw checks MUST be enabled explicitly via features. |
| 33 | + |
| 34 | +## Rendering Backends |
| 35 | +- `lambda-rs` |
| 36 | + - `with-wgpu` (default): enables the `wgpu` platform backend via `lambda-rs-platform`. |
| 37 | + - Platform specializations: `with-wgpu-vulkan`, `with-wgpu-metal`, `with-wgpu-dx12`, `with-wgpu-gl`. |
| 38 | + |
| 39 | +## Shader Backends |
| 40 | +- `lambda-rs-platform` |
| 41 | + - `shader-backend-naga` (default): uses `naga` for shader handling. |
| 42 | + - `shader-backend-shaderc`: uses `shaderc`; optional `shader-backend-shaderc-build-from-source`. |
| 43 | + |
| 44 | +## Render Validation |
| 45 | + |
| 46 | +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. |
| 50 | + |
| 51 | +Granular features (crate: `lambda-rs`) |
| 52 | +- `render-validation-msaa`: validates/logs MSAA sample counts; logs pass/pipeline sample mismatches. Behavior: |
| 53 | + - Builder APIs clamp invalid MSAA counts to `1`. |
| 54 | + - Pipelines align `sample_count` to the pass `sample_count`. |
| 55 | +- `render-validation-depth`: logs when clamping depth clear to `[0.0, 1.0]`; adds depth usage advisories when a pass has depth but the pipeline does not. |
| 56 | +- `render-validation-stencil`: logs when enabling stencil requires upgrading the depth format to `Depth24PlusStencil8`; warns about stencil usage mismatches. |
| 57 | +- `render-validation-pass-compat`: SetPipeline-time errors when color targets or depth/stencil expectations do not match the active pass. |
| 58 | +- `render-validation-device`: device/format probing advisories (if available via the platform layer). |
| 59 | +- `render-validation-encoder`: additional per-draw/encoder-time checks; highest runtime cost. |
| 60 | + |
| 61 | +Always-on safeguards (debug and release) |
| 62 | +- Clamp depth clear values to `[0.0, 1.0]`. |
| 63 | +- Align pipeline `sample_count` to the active pass `sample_count`. |
| 64 | +- Clamp invalid MSAA sample counts to `1`. |
| 65 | + |
| 66 | +Behavior by build type |
| 67 | +- Debug (`debug_assertions`): all validations active regardless of features. |
| 68 | +- Release: validations are active only when the corresponding feature is enabled; safeguards above remain active. |
| 69 | + |
| 70 | +Usage examples |
| 71 | +- Enable common validations in release: |
| 72 | + - `cargo build -p lambda-rs --features render-validation` |
| 73 | +- Enable strict compatibility checks in release: |
| 74 | + - `cargo run -p lambda-rs --features render-validation-strict` |
| 75 | +- Enable only MSAA validation in release: |
| 76 | + - `cargo test -p lambda-rs --features render-validation-msaa` |
| 77 | + |
| 78 | +## Changelog |
| 79 | +- 0.1.0 (2025-11-17): Initial document introducing validation features and behavior by build type. |
0 commit comments