CHeck for VK_KHR_mirror_clamp_to_edge extension
@@ -87,8 +87,6 @@ pub struct Sampler {
usable_with_swizzling: bool,
}
-// TODO: what's the story with VK_KHR_mirror_clamp_to_edge? Is it an extension or is it core?
-
impl Sampler {
/// Shortcut for creating a sampler with linear sampling, linear mipmaps, and with the repeat
/// mode for borders.
@@ -220,6 +218,15 @@ impl Sampler {
}
}
+ // Check MirrorClampToEdge extension support
+ if [address_u, address_v, address_w]
+ .iter()
+ .any(|&mode| mode == SamplerAddressMode::MirrorClampToEdge) {
+ if !device.loaded_extensions().khr_sampler_mirror_clamp_to_edge {
+ return Err(SamplerCreationError::SamplerMirrorClampToEdgeExtensionNotEnabled);
+ }
+ }
+
// Handling border color.
let border_color = address_u.border_color();
let border_color = match (border_color, address_v.border_color()) {
@@ -594,6 +601,10 @@ pub enum SamplerCreationError {
/// The maximum supported value.
maximum: f32
},
+
+ /// Using `MirrorClampToEdge` requires enabling the `VK_KHR_sampler_mirror_clamp_to_edge`
+ /// extension when creating the device.
+ SamplerMirrorClampToEdgeExtensionNotEnabled,
}
impl error::Error for SamplerCreationError {
@@ -606,6 +617,8 @@ impl error::Error for SamplerCreationError {
feature is not enabled",
SamplerCreationError::AnisotropyLimitExceeded { .. } => "anisotropy limit exceeded",
SamplerCreationError::MipLodBiasLimitExceeded { .. } => "mip lod bias limit exceeded",
+ SamplerCreationError::SamplerMirrorClampToEdgeExtensionNotEnabled =>
+ "the device extension `VK_KHR_sampler_mirror_clamp_to_edge` is not enabled",
}
}
@@ -790,4 +803,21 @@ mod tests {
_ => panic!()
}
}
+
+ #[test]
+ fn sampler_mirror_clamp_to_edge_extension() {
+ let (device, queue) = gfx_dev_and_queue!();
+
+ let r = sampler::Sampler::new(&device, sampler::Filter::Linear, sampler::Filter::Linear,
+ sampler::MipmapMode::Nearest,
+ sampler::SamplerAddressMode::MirrorClampToEdge,
+ sampler::SamplerAddressMode::MirrorClampToEdge,
+ sampler::SamplerAddressMode::MirrorClampToEdge, 1.0, 1.0,
+ 0.0, 2.0);
+
+ match r {
+ Err(sampler::SamplerCreationError::SamplerMirrorClampToEdgeExtensionNotEnabled) => (),
+ _ => panic!()
+ }
+ }
}
