diff --git a/crates/metal2vulkan-rt/README.md b/crates/metal2vulkan-rt/README.md index 755d704d6..cba027dfc 100644 --- a/crates/metal2vulkan-rt/README.md +++ b/crates/metal2vulkan-rt/README.md @@ -956,6 +956,9 @@ that touch blocks first. texture's format (`metal::format::integer_channels_word`); and for each constexpr sampler it samples through, the index the consumer gave it at the state's creation. Nothing is written into set 1 at bind or dispatch time, and every texture stays in its home layout. +- `set_stage_in_region` (`setStageInRegion:`) changes nothing a dispatch does: a kernel with a + `[[stage_in]]` argument, which fetches by the region, is `Gap::KernelInput` at its state's + creation, and a kernel without one ignores the region, as Metal's does. - `use_heap` is `useHeap:`, for the block a heap's memory is: the command buffer keeps the block until it retires, as it keeps a used buffer's block, so a heap given back while the work runs stays valid under it. It declares no access (Metal states no retention for it; keeping is the diff --git a/crates/metal2vulkan-rt/src/encoder.rs b/crates/metal2vulkan-rt/src/encoder.rs index be1b83481..939f7efd4 100644 --- a/crates/metal2vulkan-rt/src/encoder.rs +++ b/crates/metal2vulkan-rt/src/encoder.rs @@ -18,7 +18,7 @@ use crate::pipeline::{ use crate::record::Reach; use crate::ring::CHUNK; use crate::sampler::SamplerState; -use crate::texture::Texture; +use crate::texture::{Region, Texture}; use ash::vk; use metal2vulkan::metal::format::integer_channels_word; use metal2vulkan::pipeline::{ @@ -610,6 +610,14 @@ impl ComputeCommandEncoder { self.set_sampler_state(sampler, index) } + /// `setStageInRegion:`: it changes nothing a dispatch does. The region is what a kernel's + /// `[[stage_in]]` argument fetches by, and a kernel with one is [`Gap::KernelInput`] at its + /// state's creation, so no state this encoder dispatches has one; a dispatch of a kernel + /// without one ignores the region, as Metal's does. + pub fn set_stage_in_region(&mut self, region: Region) { + let _ = region; + } + /// `setBufferOffset:atIndex:`. /// /// Err: [`Refusal::BufferIndex`] for an index of 31 or more; [`Refusal::NoBufferAtIndex`] diff --git a/crates/metal2vulkan-rt/src/tests/sampling.rs b/crates/metal2vulkan-rt/src/tests/sampling.rs index b92bdf335..8ac6203a1 100644 --- a/crates/metal2vulkan-rt/src/tests/sampling.rs +++ b/crates/metal2vulkan-rt/src/tests/sampling.rs @@ -1,9 +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 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. +//! own, under a stage-in region it ignores, 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 @@ -210,6 +210,11 @@ mod on_device { encoder .set_sampler_state_with_lod_clamps(Some(sampler), 0.0, 1000.0, 0) .expect("sampler"); + // A stage-in region, which a kernel without a `[[stage_in]]` argument ignores. + encoder.set_stage_in_region(Region { + origin: [1, 2, 0], + size: [3, 4, 1], + }); encoder .dispatch_threads([SIDE / 2, SIDE / 2, 1], [4, 4, 1]) .unwrap_or_else(|error| panic!("{name}: sample_down: {error}")); diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index 4af6d9a15..3b994b0ca 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -9513,6 +9513,7 @@ method metal2vulkan-rt::ComputeCommandEncoder::set_bytes pub fn set_bytes(&mut s 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_stage_in_region pub fn set_stage_in_region(&mut self, region: Region) 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>