Skip to content

feat(lambda-rs): Add anisotropic clamping to texture samplers#187

Merged
vmarcella merged 5 commits intomainfrom
vmarcella/add-anisotropy-clamp-control
Feb 18, 2026
Merged

feat(lambda-rs): Add anisotropic clamping to texture samplers#187
vmarcella merged 5 commits intomainfrom
vmarcella/add-anisotropy-clamp-control

Conversation

@vmarcella
Copy link
Member

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

  • Add anisotropy_clamp: u16 (default 1) + with_anisotropy_clamp(u16) to lambda-rs-platform SamplerBuilder, plumbed to wgpu::SamplerDescriptor::anisotropy_clamp.
  • Clamp requested anisotropy to [1, 16] and disable anisotropy when unsupported by the adapter (or when filters are not all linear, per wgpu validation rules).
  • Document the quality/performance tradeoff and include example usage.
  • Add unit tests verifying default + clamping behavior.
  • Add a high-level lambda-rs SamplerBuilder::with_anisotropy_clamp(u16) that forwards to the platform builder.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (updates to docs, specs, tutorials, or comments)
  • Refactor (code change that neither fixes a bug nor adds a feature)
  • Performance (change that improves performance)
  • Test (adding or updating tests)
  • Build/CI (changes to build process or CI configuration)

Affected Crates

  • lambda-rs
  • lambda-rs-platform
  • lambda-rs-args
  • lambda-rs-logging
  • Other:

Checklist

  • Code follows the repository style guidelines (cargo +nightly fmt --all)
  • Code passes clippy (cargo clippy --workspace --all-targets -- -D warnings)
  • Tests pass (cargo test --workspace)
  • New code includes appropriate documentation
  • Public API changes are documented
  • Breaking changes are noted in this PR description

Testing

Commands run:

cargo +nightly fmt --all
cargo test -p lambda-rs-platform
cargo test -p lambda-rs

Manual verification steps (if applicable):

  1. (Optional) Run a textured demo and confirm angled surfaces show reduced shimmering/blurring when using with_anisotropy_clamp(8) with linear + mipmapped sampling.

Screenshots/Recordings

N/A

Platform Testing

  • macOS
  • Windows
  • Linux

Additional Notes

  • wgpu requires all filter modes to be linear when anisotropy is enabled; the builder disables anisotropy if this constraint is not met to avoid runtime validation errors.
  • On adapters without ANISOTROPIC_FILTERING downlevel support, anisotropy is forced to 1 (disabled).
  • wgpu 28 does not expose a per-device Limits::max_sampler_anisotropy; this change clamps to [1, 16] and gates on downlevel capability.

@vmarcella vmarcella requested a review from Copilot February 18, 2026 03:00
@github-actions
Copy link

github-actions bot commented Feb 18, 2026

✅ Coverage Report

📊 View Full HTML Report (download artifact)

Overall Coverage

Metric Value
Total Line Coverage 76.61%
Lines Covered 12517 / 16338

Changed Files in This PR

File Coverage Lines
crates/lambda-rs-platform/src/wgpu/texture.rs 88.99% 582/654
crates/lambda-rs/src/render/texture.rs 83.42% 327/392

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: 1d65643

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_clamp field to SamplerBuilder with 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.

@vmarcella vmarcella merged commit ab6f5d9 into main Feb 18, 2026
10 checks passed
@vmarcella vmarcella deleted the vmarcella/add-anisotropy-clamp-control branch February 18, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add anisotropic filtering controls to SamplerBuilder

1 participant

Comments