refactor(material): split shader programs from material instances #941
No reviewers
Labels
No labels
Context: Bug
Context: Enhancements
Platform: Android
Platform: Linux
Platform: Web
Platform: Windows
Platform: iOS
Platform: macOS
Release
Target: CI
Target: CLI
Target: Dependency
Target: Engine
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
SakulFlee/Orbital!941
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/renderer-material-v2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Phase 3: split compiled shader programs from material instances, add a shared pass-aware pipeline cache, and introduce material render state.
Programs, materials and pipelines
ShaderProgram: assembled shader module, pipeline layout, material bind-group layout and static pipeline state. It does not own textures, buffers or a render pipeline.PipelineCache: keyed by program id + pass + color format + depth format. Programs are tracked weakly, so pipelines for dropped materials are pruned instead of leaking.MaterialShaderowns aShaderProgram, its material bind group/variables and a cached forward pipeline.ShaderDescriptornow separates layout construction from variable realization:bind_group_layout_entries/bind_group_layout_onlyrealize_variablesbind_group_with_layoutbind_group_layout/bind_groupkeep their behavior.TextureDescriptor::view_dimension()so layouts can be created before texture data exists.PipelineCacheResourceand share one cache per device.or_insert(value), which eagerly constructed a new material and pipeline even on a hit. Cache hits now only clone the existing entry.Material render state
MaterialShaderDescriptornow carries:AlphaMode::{Opaque, Mask(cutoff), Blend}BlendStatedepth_write/depth_compareRenderQueue::{Opaque, Transparent}cast_shadows/receive_shadowsShaderProgrambuilds the forward pipeline from this state, andMaterialShaderexposes it for renderer queue selection. Defaults keep every existing material opaque, replace-blended, depth-writing and shadow-casting.PassKindcurrently exposesForward; shadow/G-buffer variants and theSurfacecontract are the next phase-3 changes. No visual change in this PR.Lockfile
The v1.6.0 version bump left workspace package versions at 1.5.0 in
Cargo.lock; refreshed in a separate commit.Verification
cargo fmt --all -- --checkcargo clippy -p orbital_texture -p orbital_shader_core -p orbital_material_shader -p orbital_model -p orbital_renderer -p orbital_app -- -D warningscargo test -p orbital_texture -p orbital_shader_core -p orbital_material_shader -p orbital_model -p orbital_renderer -p orbital_app --no-fail-fastRefs #781.
Smart test results
Result: PASS
Scope: full workspace
Reason: workspace-level change: Cargo.lock
Elapsed: 14m 6s
Workflow run
Overall: 439 tests, 429 passed, 0 failed, 10 skipped
Nextest: 428 tests, 428 passed, 0 failed, 0 skipped
Doctests: 11 tests, 1 passed, 0 failed, 10 skipped
Outcome charts are split between nextest and doctests. The timing chart covers nextest only.