feat(lambda-rs): Add anisotropic clamping to texture samplers#187
feat(lambda-rs): Add anisotropic clamping to texture samplers#187
Conversation
✅ Coverage Report📊 View Full HTML Report (download artifact) Overall Coverage
Changed Files in This PR
PR Files Coverage: 86.90% (909/1046 lines) Generated by cargo-llvm-cov · Latest main coverage Last updated: 2026-02-18 03:28:46 UTC · Commit: |
There was a problem hiding this comment.
Pull request overview
This PR adds anisotropic filtering support to texture samplers, allowing users to improve texture quality at oblique viewing angles with configurable quality/performance tradeoffs. The feature is exposed through both the high-level lambda-rs API and the platform-level lambda-rs-platform API, with proper validation to ensure compatibility with wgpu requirements and hardware capabilities.
Changes:
- Added
anisotropy_clampfield toSamplerBuilderwith default value of 1 (disabled) - Added
with_anisotropy_clamp(u16)builder method with automatic clamping to [1, 16] range - Implemented validation logic to disable anisotropy when filters are not all linear or when hardware doesn't support it
- Added comprehensive documentation and unit tests for the new functionality
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/lambda-rs/src/render/texture.rs | Added high-level with_anisotropy_clamp method that forwards to platform builder |
| crates/lambda-rs-platform/src/wgpu/texture.rs | Added core anisotropy support with validation, downlevel capability checking, and comprehensive tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Expose anisotropic filtering on samplers so users can opt into higher-quality texture sampling at oblique viewing angles (with a configurable quality/perf tradeoff).
Related Issues
Changes
anisotropy_clamp: u16(default1) +with_anisotropy_clamp(u16)tolambda-rs-platformSamplerBuilder, plumbed towgpu::SamplerDescriptor::anisotropy_clamp.[1, 16]and disable anisotropy when unsupported by the adapter (or when filters are not all linear, per wgpu validation rules).lambda-rsSamplerBuilder::with_anisotropy_clamp(u16)that forwards to the platform builder.Type of Change
Affected Crates
lambda-rslambda-rs-platformlambda-rs-argslambda-rs-loggingChecklist
cargo +nightly fmt --all)cargo clippy --workspace --all-targets -- -D warnings)cargo test --workspace)Testing
Commands run:
Manual verification steps (if applicable):
with_anisotropy_clamp(8)with linear + mipmapped sampling.Screenshots/Recordings
N/A
Platform Testing
Additional Notes
ANISOTROPIC_FILTERINGdownlevel support, anisotropy is forced to1(disabled).Limits::max_sampler_anisotropy; this change clamps to[1, 16]and gates on downlevel capability.