diff --git a/crates/metal2vulkan-rt/README.md b/crates/metal2vulkan-rt/README.md index 9676d9322..755d704d6 100644 --- a/crates/metal2vulkan-rt/README.md +++ b/crates/metal2vulkan-rt/README.md @@ -653,6 +653,14 @@ made, with no lock, and never rewritten for layouts. - Anisotropy is the device's own filter (`samplerAnisotropy` is in the floor). A cubic filter is `Gap::CubicSampler`. A descriptor the translator makes no device sampler of is `Error::Translation`. +- A state bound with LOD clamps (`set_sampler_state_with_lod_clamps`, and the render encoder's + `set_vertex_sampler_state_with_lod_clamps` and `set_fragment_sampler_state_with_lod_clamps`: + Metal's `lodMinClamp:lodMaxClamp:` forms, whose range forms are loops of them) is bound as it + is where its samples read alike with its clamps replaced by these: each bound, held to `[0, + 15]`, is the state's own so held (`metal::sampler::lod_clamps_read_alike`). A sample's level + lies in `[0, 14]` (Metal's largest textures have 15 levels), so a clamp of 1000 over a state's + `FLT_MAX`, which a replay stream binds, reads as the state's own. Clamps that read otherwise + are `Gap::LodClamps`, and nothing is bound. ## Queues, command buffers and events diff --git a/crates/metal2vulkan-rt/src/encoder.rs b/crates/metal2vulkan-rt/src/encoder.rs index 75930e0ea..be1b83481 100644 --- a/crates/metal2vulkan-rt/src/encoder.rs +++ b/crates/metal2vulkan-rt/src/encoder.rs @@ -590,6 +590,26 @@ impl ComputeCommandEncoder { Ok(()) } + /// `setSamplerState:lodMinClamp:lodMaxClamp:atIndex:` + /// (`setSamplerStates:lodMinClamps:lodMaxClamps:withRange:` is a loop of it): the state bound + /// as [`set_sampler_state`](Self::set_sampler_state) binds it, where its samples read alike + /// with its LOD clamps replaced by these: each bound, held to the levels a sample can read + /// (`[0, 15]`; Metal's largest textures have 15 levels), is the state's own so held, as a + /// clamp of 1000 over a state's `FLT_MAX` is. + /// + /// Err: [`Gap::LodClamps`] where they read otherwise (nothing is bound); as + /// [`set_sampler_state`](Self::set_sampler_state). + pub fn set_sampler_state_with_lod_clamps( + &mut self, + sampler: Option<&SamplerState>, + lod_min_clamp: f32, + lod_max_clamp: f32, + index: u32, + ) -> Result<(), Error> { + crate::sampler::clamps_at_bind(sampler, lod_min_clamp, lod_max_clamp)?; + self.set_sampler_state(sampler, index) + } + /// `setBufferOffset:atIndex:`. /// /// Err: [`Refusal::BufferIndex`] for an index of 31 or more; [`Refusal::NoBufferAtIndex`] diff --git a/crates/metal2vulkan-rt/src/error.rs b/crates/metal2vulkan-rt/src/error.rs index 1b1439595..69303bb97 100644 --- a/crates/metal2vulkan-rt/src/error.rs +++ b/crates/metal2vulkan-rt/src/error.rs @@ -790,6 +790,15 @@ pub enum Gap { /// Basis: ours (the translator's identity domains do not filter bicubically, and Vulkan's /// cubic filter is not Metal's). CubicSampler, + /// A sampler state bound with LOD clamps its samples read otherwise through + /// ([`ComputeCommandEncoder::set_sampler_state_with_lod_clamps`](crate::ComputeCommandEncoder::set_sampler_state_with_lod_clamps) + /// and the render encoder's vertex and fragment forms): a bound that differs from the state's + /// own once both are held to the levels a sample can read + /// ([`lod_clamps_read_alike`](metal2vulkan::metal::sampler::lod_clamps_read_alike)). + /// + /// Basis: ours (no replay stream binds such clamps: every bind-time clamp the streams make + /// reads as its state's own). + LodClamps, /// [`Texture::replace_region`](crate::Texture::replace_region), /// [`Texture::get_bytes`](crate::Texture::get_bytes) or a blit copy between a buffer and a /// texture @@ -1503,6 +1512,9 @@ impl fmt::Display for Gap { Gap::MemorylessTexture => f.write_str("Memoryless textures are not built"), Gap::CubeArrayTexture => f.write_str("cube array textures are not built"), Gap::CubicSampler => f.write_str("cubic sampler filters are not built"), + Gap::LodClamps => f.write_str( + "a sampler state's bind-time LOD clamps that read otherwise than its own are not built", + ), Gap::TextureBuffer => f.write_str("texture buffers are not built"), Gap::TextureFormat { pixel_format } => write!( f, diff --git a/crates/metal2vulkan-rt/src/render_encoder.rs b/crates/metal2vulkan-rt/src/render_encoder.rs index b19d3700b..2b1e87256 100644 --- a/crates/metal2vulkan-rt/src/render_encoder.rs +++ b/crates/metal2vulkan-rt/src/render_encoder.rs @@ -819,6 +819,44 @@ impl RenderCommandEncoder { self.set_sampler_state(FRAGMENT, sampler, index) } + /// `setVertexSamplerState:lodMinClamp:lodMaxClamp:atIndex:` + /// (`setVertexSamplerStates:lodMinClamps:lodMaxClamps:withRange:` is a loop of it): the state + /// bound as [`set_vertex_sampler_state`](Self::set_vertex_sampler_state) binds it, where its + /// samples read alike with its LOD clamps replaced by these: each bound, held to the levels a + /// sample can read (`[0, 15]`; Metal's largest textures have 15 levels), is the state's own so + /// held, as a clamp of 1000 over a state's `FLT_MAX` is. + /// + /// Err: [`Gap::LodClamps`] where they read otherwise (nothing is bound); as + /// [`set_vertex_sampler_state`](Self::set_vertex_sampler_state). + pub fn set_vertex_sampler_state_with_lod_clamps( + &mut self, + sampler: Option<&SamplerState>, + lod_min_clamp: f32, + lod_max_clamp: f32, + index: u32, + ) -> Result<(), Error> { + crate::sampler::clamps_at_bind(sampler, lod_min_clamp, lod_max_clamp)?; + self.set_sampler_state(VERTEX, sampler, index) + } + + /// `setFragmentSamplerState:lodMinClamp:lodMaxClamp:atIndex:` + /// (`setFragmentSamplerStates:lodMinClamps:lodMaxClamps:withRange:` is a loop of it), as + /// [`set_vertex_sampler_state_with_lod_clamps`](Self::set_vertex_sampler_state_with_lod_clamps) + /// for the fragment function. + /// + /// Err: as + /// [`set_vertex_sampler_state_with_lod_clamps`](Self::set_vertex_sampler_state_with_lod_clamps). + pub fn set_fragment_sampler_state_with_lod_clamps( + &mut self, + sampler: Option<&SamplerState>, + lod_min_clamp: f32, + lod_max_clamp: f32, + index: u32, + ) -> Result<(), Error> { + crate::sampler::clamps_at_bind(sampler, lod_min_clamp, lod_max_clamp)?; + self.set_sampler_state(FRAGMENT, sampler, index) + } + fn set_sampler_state( &mut self, table: usize, diff --git a/crates/metal2vulkan-rt/src/sampler.rs b/crates/metal2vulkan-rt/src/sampler.rs index 4b2667595..ef7e5ee42 100644 --- a/crates/metal2vulkan-rt/src/sampler.rs +++ b/crates/metal2vulkan-rt/src/sampler.rs @@ -16,7 +16,7 @@ use crate::error::{Error, Gap, Limit}; use crate::reaper::{Free, Job}; use ash::vk; use metal2vulkan::bind::SamplerDescriptor; -use metal2vulkan::metal::sampler::{vk_sampler, SamplerUse, SamplerWord}; +use metal2vulkan::metal::sampler::{lod_clamps_read_alike, vk_sampler, SamplerUse, SamplerWord}; use metal2vulkan::metal::{CompareFunction, SamplerMinMagFilter}; use metal2vulkan::vk::{BorderColor, SamplerAddressMode, SamplerDesc}; use std::collections::HashMap; @@ -82,6 +82,27 @@ impl SamplerTable { } } +/// The LOD clamps a sampler state is bound with (Metal's `lodMinClamp:lodMaxClamp:` bind forms): +/// the state is bound as it is where its samples read alike with its clamps replaced by these +/// ([`lod_clamps_read_alike`]: each bound held to the levels a sample can read is the state's +/// own). `None` binds no state and reads no clamps. +/// +/// Err: [`Gap::LodClamps`] where they read otherwise. +pub(crate) fn clamps_at_bind( + sampler: Option<&SamplerState>, + lod_min_clamp: f32, + lod_max_clamp: f32, +) -> Result<(), Error> { + match sampler { + Some(sampler) + if !lod_clamps_read_alike(sampler.descriptor(), lod_min_clamp, lod_max_clamp) => + { + Err(Error::Unsupported(Gap::LodClamps)) + } + _ => Ok(()), + } +} + /// `desc` as the device reads it: a border colour no address mode reads is the default one, so /// create infos that differ only there are one. pub(crate) fn canonical(mut desc: SamplerDesc) -> SamplerDesc { diff --git a/crates/metal2vulkan-rt/src/tests/sampler.rs b/crates/metal2vulkan-rt/src/tests/sampler.rs index 1471df4d1..fa09b4d15 100644 --- a/crates/metal2vulkan-rt/src/tests/sampler.rs +++ b/crates/metal2vulkan-rt/src/tests/sampler.rs @@ -11,7 +11,9 @@ //! another holds takes it, and the earlier state's going leaves it; the grant waits for the //! index's owner, and the index is free once that state is gone. The device's samplers come //! back to zero with the device. A state's constexpr samplers numbered up to one the -//! translator refuses give back what the earlier ones took. +//! translator refuses give back what the earlier ones took. A state binds with LOD clamps that +//! read as its own on the compute encoder and the render encoder's vertex and fragment +//! functions, and clamps that read otherwise are `Gap::LodClamps`. use crate::error::{Error, Limit}; use crate::sampler::SamplerTable; @@ -47,8 +49,9 @@ fn a_device_sampler_is_shared_by_create_info_up_to_the_cap() { mod on_device { use crate::tests::devices_of_the_cfgs_kind; use crate::{ - CompareFunction, Device, DeviceOptions, Error, Gap, IndexClass, Refusal, - SamplerBorderColor, SamplerDescriptor, SamplerMinMagFilter, SamplerState, + CompareFunction, Device, DeviceOptions, DispatchType, Error, Gap, IndexClass, PixelFormat, + Refusal, RenderPassDescriptor, SamplerBorderColor, SamplerDescriptor, SamplerMinMagFilter, + SamplerState, TextureDescriptor, TextureType, TextureUsage, }; use metal2vulkan::metal::sampler::SamplerWord; @@ -153,6 +156,65 @@ mod on_device { } } + /// A state bound with LOD clamps that read as its own, `(0, 1000)` over its `(0, FLT_MAX)` as + /// a replay stream binds it, and `(-1, infinity)`, binds on the compute encoder and on the + /// render encoder's vertex and fragment functions; clamps that read otherwise, a raised lower + /// bound, an upper bound below the last level a sample can read, or a NaN, are + /// `Gap::LodClamps` on each. No state binds with any clamps. + #[test] + fn every_device_binds_a_state_with_clamps_that_read_as_its_own() { + let instance = crate::tests::validation::instance(&[]); + let devices = devices_of_the_cfgs_kind(&instance); + assert!( + !devices.is_empty(), + "the loader lists no device of this cfg's kind" + ); + for (name, physical) in devices { + let device = Device::new(&physical, DeviceOptions::default()) + .unwrap_or_else(|error| panic!("{name}: {error}")); + let _grant = device + .grant_indices(IndexClass::Sampler, 1, 1) + .unwrap_or_else(|error| panic!("{name}: {error}")); + let state = device + .new_sampler_state(&SamplerDescriptor::new(), 1) + .unwrap_or_else(|error| panic!("{name}: {error}")); + let bound = |result: Result<(), Error>| { + result.unwrap_or_else(|error| panic!("{name}: {error}")) + }; + let gap = |result: Result<(), Error>| { + assert!( + matches!(result, Err(Error::Unsupported(Gap::LodClamps))), + "{name}: {result:?}" + ) + }; + let queue = device.new_command_queue(4).expect("a queue"); + let command_buffer = queue.command_buffer().expect("a command buffer"); + let mut compute = (command_buffer.compute_command_encoder(DispatchType::Serial)) + .unwrap_or_else(|error| panic!("{name}: {error}")); + bound(compute.set_sampler_state_with_lod_clamps(Some(&state), 0.0, 1000.0, 0)); + bound(compute.set_sampler_state_with_lod_clamps(Some(&state), -1.0, f32::INFINITY, 1)); + gap(compute.set_sampler_state_with_lod_clamps(Some(&state), 0.5, f32::MAX, 2)); + bound(compute.set_sampler_state_with_lod_clamps(None, 3.0, 2.0, 2)); + compute.end_encoding(); + let mut d = TextureDescriptor::new(TextureType::Type2D, PixelFormat::RGBA8Unorm, 4, 4); + d.usage = TextureUsage::RENDER_TARGET; + let color = + (device.new_texture(&d, None)).unwrap_or_else(|error| panic!("{name}: {error}")); + let mut pass = RenderPassDescriptor::default(); + pass.color_attachments[0].texture = Some(color); + let mut render = (command_buffer.render_command_encoder(&pass)) + .unwrap_or_else(|error| panic!("{name}: {error}")); + bound(render.set_vertex_sampler_state_with_lod_clamps(Some(&state), 0.0, 1000.0, 0)); + bound(render.set_fragment_sampler_state_with_lod_clamps(Some(&state), 0.0, 1000.0, 0)); + gap(render.set_vertex_sampler_state_with_lod_clamps(Some(&state), 0.0, 14.0, 1)); + gap(render.set_fragment_sampler_state_with_lod_clamps(Some(&state), 0.0, f32::NAN, 1)); + render.end_encoding(); + command_buffer.commit().expect("a commit"); + crate::tests::command::on_device::finished(name, &command_buffer); + assert_eq!(command_buffer.error(), None, "{name}"); + } + } + /// A state's constexpr samplers, numbered up to one whose device sampler the translator does /// not state: the refusal gives back what the earlier one took, its arrays' elements at once /// and its device sampler through the reaper, and leaves its index free. diff --git a/crates/metal2vulkan-rt/src/tests/sampling.rs b/crates/metal2vulkan-rt/src/tests/sampling.rs index 2b7c013e8..b92bdf335 100644 --- a/crates/metal2vulkan-rt/src/tests/sampling.rs +++ b/crates/metal2vulkan-rt/src/tests/sampling.rs @@ -1,8 +1,9 @@ //! Kernels that sample textures, under a device cfg on every device of the cfg's kind: the -//! harness's `sample_down`, through a runtime sampler state, and `sample_up`, through a constexpr -//! sampler at the index the consumer gives it, chained in one serial encoder so the second samples -//! what the first wrote. Each answer is checked against the linear filter's, and the constexpr -//! sampler's index is shared between the states that number it there and freed with the last. +//! harness's `sample_down`, through a runtime sampler state bound with LOD clamps that read as its +//! own, and `sample_up`, through a constexpr sampler at the index the consumer gives it, chained in +//! one serial encoder so the second samples what the first wrote. Each answer is checked against +//! the linear filter's, and the constexpr sampler's index is shared between the states that number +//! it there and freed with the last. //! A texture of any usage is made at any index of a texture grant: `sample_down` samples a texture //! of shader-read usage alone at an index below 4,096 and writes one of shader-write usage above //! it, in one dispatch. An index belongs to the texture placed there last: sampling and writing @@ -205,8 +206,9 @@ mod on_device { encoder.set_compute_pipeline_state(down).expect("down"); encoder.set_texture(Some(source), 0).expect("source"); encoder.set_texture(Some(target), 1).expect("target"); + // Bound with the clamps a replay stream binds it with, which read as its own. encoder - .set_sampler_state(Some(sampler), 0) + .set_sampler_state_with_lod_clamps(Some(sampler), 0.0, 1000.0, 0) .expect("sampler"); encoder .dispatch_threads([SIDE / 2, SIDE / 2, 1], [4, 4, 1]) diff --git a/crates/metal2vulkan/src/metal/sampler.rs b/crates/metal2vulkan/src/metal/sampler.rs index 15fb7ec63..f464888f6 100644 --- a/crates/metal2vulkan/src/metal/sampler.rs +++ b/crates/metal2vulkan/src/metal/sampler.rs @@ -284,6 +284,26 @@ pub(crate) fn mipmapped_min_lod(lo: f32) -> f32 { lo.clamp(0.0, LAST_WORD_LEVEL as f32) } +/// Whether `desc` samples alike with its LOD clamps replaced by `lod_min_clamp` and +/// `lod_max_clamp`, as Metal's bind-time clamps replace them +/// (`setFragmentSamplerState:lodMinClamp:lodMaxClamp:atIndex:`, its vertex and compute forms, and +/// their range forms): where each bound, held to `[0, LAST_WORD_LEVEL]`, is the descriptor's own +/// so held. A sample's level is clamped into the bounds and then to the texture's levels, which +/// are at least 0 and at most 14 (Metal's largest textures have 15 levels), so a bound below 0 +/// clamps as 0 does and every bound at or past [`LAST_WORD_LEVEL`] clamps nothing, in Metal's +/// sampler, in the device sampler [`vk_sampler`] makes (Vulkan clamps the level into `[minLod, +/// maxLod]` and then to the view's levels) and in the word [`SamplerWord::of`] makes. A NaN bound +/// reads alike with none. +pub fn lod_clamps_read_alike( + desc: &SamplerDescriptor, + lod_min_clamp: f32, + lod_max_clamp: f32, +) -> bool { + let held = |c: f32| c.clamp(0.0, LAST_WORD_LEVEL as f32); + held(lod_min_clamp) == held(desc.lod_min_clamp) + && held(lod_max_clamp) == held(desc.lod_max_clamp) +} + /// Metal's level clamp bound `c` on the sixty-fourths grid of its level and weight: its value at or /// above 0, truncated onto sixty-fourths. Metal clamps a sample's level into the sampler's clamp /// before truncating it, so a level clamped by bounds on the grid truncates to the level clamped by @@ -1226,6 +1246,55 @@ mod tests { } } + /// Bind-time clamps read as the descriptor's own where each bound held to the levels a sample + /// can read is the descriptor's: a replay's `(0, 1000)` over a state's `(0, FLT_MAX)` among + /// them. Each pair that reads alike gives the descriptor's word and its device sampler's + /// `minLod`, and a `maxLod` at or past every level. + #[test] + fn bind_time_lod_clamps_read_alike_where_each_held_bound_is_the_descriptors() { + let desc = metal_default(); + assert!(lod_clamps_read_alike(&desc, 0.0, 1000.0)); + assert!(lod_clamps_read_alike(&desc, -1.0, f32::INFINITY)); + assert!(lod_clamps_read_alike(&desc, -0.0, LAST_WORD_LEVEL as f32)); + assert!(!lod_clamps_read_alike(&desc, 0.0, 14.0)); + assert!(!lod_clamps_read_alike(&desc, 0.5, f32::MAX)); + assert!(!lod_clamps_read_alike(&desc, f32::NAN, f32::MAX)); + assert!(!lod_clamps_read_alike(&desc, 0.0, f32::NAN)); + let raised = SamplerDescriptor { + lod_min_clamp: 2.25, + lod_max_clamp: 6.5, + ..metal_default() + }; + assert!(lod_clamps_read_alike(&raised, 2.25, 6.5)); + assert!(!lod_clamps_read_alike(&raised, 2.25, 6.75)); + for mip_filter in [ + SamplerMipFilter::NotMipmapped, + SamplerMipFilter::Nearest, + SamplerMipFilter::Linear, + ] { + let own = SamplerDescriptor { + mip_filter, + ..metal_default() + }; + for (lo, hi) in [(0.0, 1000.0), (-1.0, f32::INFINITY), (0.0, 15.0)] { + assert!(lod_clamps_read_alike(&own, lo, hi)); + let bound = SamplerDescriptor { + lod_min_clamp: lo, + lod_max_clamp: hi, + ..own + }; + assert_eq!(SamplerWord::of(&bound).0, SamplerWord::of(&own).0); + assert_eq!(query_min_level(&bound), query_min_level(&own)); + assert_eq!(mipmapped_min_lod(lo), mipmapped_min_lod(own.lod_min_clamp)); + assert_eq!( + not_mipmapped_lods(lo, hi), + not_mipmapped_lods(0.0, f32::MAX) + ); + assert!(hi >= LAST_WORD_LEVEL as f32); + } + } + } + /// The level Metal's `calculate_clamped_lod` answers outside a fragment function before the /// texture's last level, for every runtime sampler our probes measured (the M3 Max's and the /// M4's answers are the same), in sixty-fourths. diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index d0f042a73..4af6d9a15 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -6185,6 +6185,7 @@ fn metal2vulkan::metal::sampler::check_border_view pub fn check_border_view(opaq fn metal2vulkan::metal::sampler::check_sampler pub fn check_sampler(shape: &SamplerShape, use_: SamplerUse, profile: &DeviceProfile) -> Result<(), Error> fn metal2vulkan::metal::sampler::compare_op pub fn compare_op(f: CompareFunction) -> vk::CompareOp fn metal2vulkan::metal::sampler::device_lod_bias pub fn device_lod_bias(lod_bias: f32, profile: &DeviceProfile) -> DeviceLodBias +fn metal2vulkan::metal::sampler::lod_clamps_read_alike pub fn lod_clamps_read_alike(desc: &SamplerDescriptor, lod_min_clamp: f32, lod_max_clamp: f32) -> bool fn metal2vulkan::metal::sampler::opaque_black_border pub fn opaque_black_border(pf: PixelFormat, mapping: &FormatMapping, swizzle: TextureSwizzleChannels, profile: &DeviceProfile) -> Result fn metal2vulkan::metal::sampler::opaque_black_reads_transparent pub fn opaque_black_reads_transparent(pf: PixelFormat, swizzle: TextureSwizzleChannels) -> bool fn metal2vulkan::metal::sampler::vk_sampler pub fn vk_sampler(desc: &SamplerDescriptor, use_: SamplerUse, profile: &DeviceProfile) -> Result @@ -9511,6 +9512,7 @@ method metal2vulkan-rt::ComputeCommandEncoder::set_buffer_offset pub fn set_buff method metal2vulkan-rt::ComputeCommandEncoder::set_bytes pub fn set_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> method metal2vulkan-rt::ComputeCommandEncoder::set_compute_pipeline_state pub fn set_compute_pipeline_state(&mut self, state: &ComputePipelineState) -> Result<(), Error> method metal2vulkan-rt::ComputeCommandEncoder::set_sampler_state pub fn set_sampler_state(&mut self, sampler: Option<&SamplerState>, index: u32) -> Result<(), Error> +method metal2vulkan-rt::ComputeCommandEncoder::set_sampler_state_with_lod_clamps pub fn set_sampler_state_with_lod_clamps(&mut self, sampler: Option<&SamplerState>, lod_min_clamp: f32, lod_max_clamp: f32, index: u32) -> Result<(), Error> method metal2vulkan-rt::ComputeCommandEncoder::set_texture pub fn set_texture(&mut self, texture: Option<&Texture>, index: u32) -> Result<(), Error> method metal2vulkan-rt::ComputeCommandEncoder::set_threadgroup_memory_length pub fn set_threadgroup_memory_length(&mut self, length: u32, index: u32) -> Result<(), Error> method metal2vulkan-rt::ComputeCommandEncoder::update_fence pub fn update_fence(&mut self, fence: &Fence) -> Result<(), Error> @@ -9604,6 +9606,7 @@ method metal2vulkan-rt::RenderCommandEncoder::set_fragment_buffer pub fn set_fra method metal2vulkan-rt::RenderCommandEncoder::set_fragment_buffer_offset pub fn set_fragment_buffer_offset(&mut self, offset: u64, index: u32) -> Result<(), Error> method metal2vulkan-rt::RenderCommandEncoder::set_fragment_bytes pub fn set_fragment_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> method metal2vulkan-rt::RenderCommandEncoder::set_fragment_sampler_state pub fn set_fragment_sampler_state(&mut self, sampler: Option<&SamplerState>, index: u32) -> Result<(), Error> +method metal2vulkan-rt::RenderCommandEncoder::set_fragment_sampler_state_with_lod_clamps pub fn set_fragment_sampler_state_with_lod_clamps(&mut self, sampler: Option<&SamplerState>, lod_min_clamp: f32, lod_max_clamp: f32, index: u32) -> Result<(), Error> method metal2vulkan-rt::RenderCommandEncoder::set_fragment_texture pub fn set_fragment_texture(&mut self, texture: Option<&Texture>, index: u32) -> Result<(), Error> method metal2vulkan-rt::RenderCommandEncoder::set_front_facing_winding pub fn set_front_facing_winding(&mut self, winding: Winding) method metal2vulkan-rt::RenderCommandEncoder::set_render_pipeline_state pub fn set_render_pipeline_state(&mut self, state: &RenderPipelineState) -> Result<(), Error> @@ -9617,6 +9620,7 @@ method metal2vulkan-rt::RenderCommandEncoder::set_vertex_buffer pub fn set_verte method metal2vulkan-rt::RenderCommandEncoder::set_vertex_buffer_offset pub fn set_vertex_buffer_offset(&mut self, offset: u64, index: u32) -> Result<(), Error> method metal2vulkan-rt::RenderCommandEncoder::set_vertex_bytes pub fn set_vertex_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> method metal2vulkan-rt::RenderCommandEncoder::set_vertex_sampler_state pub fn set_vertex_sampler_state(&mut self, sampler: Option<&SamplerState>, index: u32) -> Result<(), Error> +method metal2vulkan-rt::RenderCommandEncoder::set_vertex_sampler_state_with_lod_clamps pub fn set_vertex_sampler_state_with_lod_clamps(&mut self, sampler: Option<&SamplerState>, lod_min_clamp: f32, lod_max_clamp: f32, index: u32) -> Result<(), Error> method metal2vulkan-rt::RenderCommandEncoder::set_vertex_texture pub fn set_vertex_texture(&mut self, texture: Option<&Texture>, index: u32) -> Result<(), Error> method metal2vulkan-rt::RenderCommandEncoder::set_viewport pub fn set_viewport(&mut self, viewport: Viewport) -> Result<(), Error> method metal2vulkan-rt::RenderCommandEncoder::set_viewports pub fn set_viewports(&mut self, viewports: &[Viewport]) -> Result<(), Error> @@ -13650,6 +13654,7 @@ variant metal2vulkan-rt::Gap::FloatDepthUpload FloatDepthUpload { pixel_format: variant metal2vulkan-rt::Gap::HeapTexture HeapTexture { pixel_format: PixelFormat } variant metal2vulkan-rt::Gap::IndirectCommandBuffers IndirectCommandBuffers variant metal2vulkan-rt::Gap::KernelInput KernelInput +variant metal2vulkan-rt::Gap::LodClamps LodClamps variant metal2vulkan-rt::Gap::MemorylessTexture MemorylessTexture variant metal2vulkan-rt::Gap::PartialSimdgroups PartialSimdgroups { threads_per_threadgroup: [u32; 3], width: u32 } variant metal2vulkan-rt::Gap::PartialThreadgroups PartialThreadgroups { threads_per_grid: [u32; 3], threads_per_threadgroup: [u32; 3] } diff --git a/crates/metal2vulkan/tests/api_surface.rs b/crates/metal2vulkan/tests/api_surface.rs index 678010b80..134d49604 100644 --- a/crates/metal2vulkan/tests/api_surface.rs +++ b/crates/metal2vulkan/tests/api_surface.rs @@ -1029,6 +1029,7 @@ surface! { fn check_sampler; fn vk_sampler; fn device_lod_bias; + fn lod_clamps_read_alike; fn check_border_swizzle; fn check_border_view; fn opaque_black_reads_transparent; diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index 4c7e7ca0e..4bf329422 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -702,6 +702,7 @@ Columns: | `CubeArrayTexture` | A cube array texture (`MTLTextureTypeCubeArray`), and so a view of one | every device (a public call's own check of its arguments) | `ours`: no replay stream makes a cube array texture or view; built when one does | 1: `crates/metal2vulkan-rt/src/texture.rs (checked)` | `-` | | `TextureFormat` | A texture of a pixel format the runtime makes no image of on this device for the descriptor's usage | every device (a public call's own check of its arguments) | `ours`: the device's format query, or the identity domains' shaders read every texture through its view alone | 1: `crates/metal2vulkan-rt/src/texture.rs (plan)` | `-` | | `CubicSampler` | A sampler state whose minification or magnification filter is cubic (`Device::new_sampler_state`) | every device (a public call's own check of its arguments) | `ours`: the translator's identity domains do not filter bicubically, and Vulkan's cubic filter is not Metal's | 1: `crates/metal2vulkan-rt/src/sampler.rs (new_sampler_state)` | `-` | +| `LodClamps` | A sampler state bound with LOD clamps its samples read otherwise through (`ComputeCommandEncoder::set_sampler_state_with_lod_clamps` and the... | every device (a public call's own check of its arguments) | `ours`: no replay stream binds such clamps: every bind-time clamp the streams make reads as its state's own | 1: `crates/metal2vulkan-rt/src/sampler.rs (clamps_at_bind)` | `-` | | `TextureBytes` | `Texture::replace_region`, `Texture::get_bytes` or a blit copy between a buffer and a texture (`BlitCommandEncoder::copy_from_buffer`) of a... | every device (a public call's own check of its arguments) | `ours`: no copy between such an image and bytes is built | 3: `crates/metal2vulkan-rt/src/blit.rs (buffer_copy)`, `crates/metal2vulkan-rt/src/texture.rs (check_places)` (+1) | `-` | | `FloatDepthUpload` | `Texture::replace_region` or `BlitCommandEncoder::copy_from_buffer` into a 32-bit float depth (`Depth32Float`) | every device (a public call's own check of its arguments) | `ours`: no upload of a 32-bit float depth is built | 3: `crates/metal2vulkan-rt/src/blit.rs (buffer_copy)`, `crates/metal2vulkan-rt/src/texture.rs (replace_region)` (+1) | `-` | | `TextureCopy` | `BlitCommandEncoder::copy_from_texture` that no single `vkCmdCopyImage` in the floor makes | every device (a public call's own check of its arguments) | `ours`: Vulkan 1.3 copies none of these with one command; each is built when a replay stream makes one | 1: `crates/metal2vulkan-rt/src/blit.rs (texture_copy)` | `-` | @@ -1282,6 +1283,7 @@ Each refusal's sites, with the function that builds it. - `rt:Gap::CubeArrayTexture`: `crates/metal2vulkan-rt/src/texture.rs (checked)` - `rt:Gap::TextureFormat`: `crates/metal2vulkan-rt/src/texture.rs (plan)` - `rt:Gap::CubicSampler`: `crates/metal2vulkan-rt/src/sampler.rs (new_sampler_state)` +- `rt:Gap::LodClamps`: `crates/metal2vulkan-rt/src/sampler.rs (clamps_at_bind)` - `rt:Gap::TextureBytes`: `crates/metal2vulkan-rt/src/blit.rs (buffer_copy)`; `crates/metal2vulkan-rt/src/texture.rs (check_places)`; `crates/metal2vulkan-rt/src/texture.rs (copy)` - `rt:Gap::FloatDepthUpload`: `crates/metal2vulkan-rt/src/blit.rs (buffer_copy)`; `crates/metal2vulkan-rt/src/texture.rs (replace_region)`; `crates/metal2vulkan-rt/src/texture.rs (upload_region)` - `rt:Gap::TextureCopy`: `crates/metal2vulkan-rt/src/blit.rs (texture_copy)`