Skip to content

Commit 33689dd

Browse files
committed
[add] warning when setting anisotropy to a level higher than what the GPU supports.
1 parent 4c0b453 commit 33689dd

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

crates/lambda-rs-platform/src/wgpu/texture.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,15 +697,20 @@ linear; anisotropy disabled.",
697697

698698
/// Create the sampler on the provided device.
699699
pub fn build(self, gpu: &Gpu) -> Sampler {
700+
let requested_anisotropy = self.anisotropy_clamp.clamp(1, 16);
700701
let downlevel = gpu.adapter().get_downlevel_capabilities();
701-
let max_supported_anisotropy = if downlevel
702+
let supports_anisotropy = downlevel
702703
.flags
703-
.contains(wgpu::DownlevelFlags::ANISOTROPIC_FILTERING)
704-
{
705-
16
706-
} else {
707-
1
708-
};
704+
.contains(wgpu::DownlevelFlags::ANISOTROPIC_FILTERING);
705+
if requested_anisotropy > 1 && !supports_anisotropy {
706+
logging::warn!(
707+
"Sampler anisotropy requested ({}), but adapter does not report \
708+
anisotropic filtering support; anisotropy disabled.",
709+
requested_anisotropy
710+
);
711+
}
712+
713+
let max_supported_anisotropy = if supports_anisotropy { 16 } else { 1 };
709714
let desc = self.to_descriptor(max_supported_anisotropy);
710715
let raw = gpu.device().create_sampler(&desc);
711716
return Sampler {

0 commit comments

Comments
 (0)