diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index a7cf20e73..90ce58b27 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -3994,8 +3994,8 @@ cache is answered compile-required on both. make pays the content's whole compile. A recorded session's heaviest content, a fragment function of about 30,800 SPIR-V instructions, takes 1,408 ms of driver time cold on an RTX 3090 (NVIDIA 620.70.06, job m3-max-58251), and 1,335 ms on a second RTX 3090 (m3-max-58134). Made - without either dynamic state rt adds (the feedback loop's enable, depth bias's enable), its time - changes by under 1% (m3-max-58251). It is paid once per cold cache: warm, with the driver's disk + without depth bias's enable and the feedback loop's enable as dynamic state, its time changes by + under 1% (m3-max-58251). It is paid once per cold cache: warm, with the driver's disk cache on, that session's 383 render pipelines take 34.5 ms of driver time through rt's cache on the second RTX 3090 (m3-max-58285). A warm make in a new process reads each render content's record (The cache directory), so it decodes and specializes no function: on lavapipe, a recorded @@ -4277,9 +4277,10 @@ cache is answered compile-required on both. from the layout the pass renders it in, the rest from home), and the rendering begins again with the attachment in that layout; the pass's second barrier moves the whole image home. Until then every draw of the pass reads the image's textures through their second elements (Set 1), a texture that reaches - no rendered level among them. Every render pipeline takes the feedback loop's enable as dynamic - state, which the encoder sets at its first draw and where it changes: colour for a draw that - reads an attachment, none otherwise, so a pass of no such draw sets it once. Each draw that + no rendered level among them. Every render pipeline is made with the feedback loop's colour + flag (`VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT`), which lets a draw read an + attachment in the feedback layout and asks nothing of a draw that reads none, so no draw records + a state for the loop. Each draw that reads an attachment through the loop, through a texture or by a fetch (below), counts in `Metrics::attachment_loop_reads`, its barriers in `Metrics::barriers`. - Through a copy, on a device without the feedback loop, and for a surface plane whose image took @@ -4617,8 +4618,8 @@ cache is answered compile-required on both. RX 550 and 5.2 µs on the XTX in a pass that loads an image the last pass moved home from the feedback layout with no draw between, 370.6 and 19.6 µs after the pass's clear (the table's), and 477.3 and 22.7 µs after a draw over the image in the pass. -- On a device that does not report `attachmentFeedbackLoopLayout` and - `attachmentFeedbackLoopDynamicState` (the UHD 630 among the lab's, Windows driver 101.2145), a +- On a device that does not report `attachmentFeedbackLoopLayout` (the UHD 630 among the lab's, + Windows driver 101.2145), a draw reads an attachment through a copy into the image's shadow, which Metal does not make: at the pass's first draw that reads the image, at the first after a memory barrier after draws, and where a draw reads what the shadow does not hold, the rendering ended and begun again @@ -5022,8 +5023,7 @@ Presenting runs on the runtime's own device; nothing is exported or imported. | `VK_EXT_shader_stencil_export` | device, where listed | a fragment function's `[[stencil]]` output as the fragment's stencil reference (`FragStencilRefEXT`); RADV, ANV, lavapipe, KosmicKrisp and the UHD 630's Windows driver list it, NVIDIA's 615 and 620 drivers do not | | `VK_KHR_portability_enumeration` | instance, where offered | listing portability devices, each checked against the floor as any other | | `VK_KHR_portability_subset` | device, where listed | Vulkan requires it enabled where a device lists it; the device is asked for the portability features below | -| `VK_EXT_attachment_feedback_loop_layout` | device, with the feedback loop | a draw's read of an attachment of its own pass through a texture, in the feedback layout (below) | -| `VK_EXT_attachment_feedback_loop_dynamic_state` | device, with the feedback loop | the feedback loop's enable as dynamic state of every render pipeline | +| `VK_EXT_attachment_feedback_loop_layout` | device, with the feedback loop | a draw's read of an attachment of its own pass through a texture, in the feedback layout, with the colour flag every render pipeline takes (below) | | `VK_KHR_vertex_attribute_divisor` | device, where listed | a vertex layout stepped per instance at a rate above 1, through the step-rate feature below | | `VK_EXT_vertex_attribute_divisor` | device, where listed | the same, on a device that lists only this extension, which the KHR was promoted from with the same feature and pipeline structures | | `VK_EXT_external_memory_host` | device, where listed | importing host memory by its address (`Device::import_host_memory`) | @@ -5358,15 +5358,14 @@ second elements beside the floor's arrays: 65,536 sampled images more than the l `maxUpdateAfterBindDescriptorsInAllPools`); a device without them refuses such a draw (`Gap::Draw` of `DrawKind::AttachmentRead`), and is otherwise the same (`floor::Capabilities::attachment_reads`). The draw reads through the attachment feedback loop -where the device also lists the two extensions marked "with the feedback loop" above and reports -each feature below, which device creation then enables, and none otherwise +where the device also lists the extension marked "with the feedback loop" above and reports the +feature below, which device creation then enables, and neither otherwise (`floor::Capabilities::feedback_loop`). A device that reads attachments without them reads through a copy of the image into its shadow (Render encoders), a known gap. | Attachment-read feature | Structure | Used for | |---|---|---| | `attachmentFeedbackLoopLayout` | `VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT` | the feedback layout and usage | -| `attachmentFeedbackLoopDynamicState` | `VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT` | the enable as dynamic state | ### Border swizzle diff --git a/crates/metal2vulkan-runtime/src/device.rs b/crates/metal2vulkan-runtime/src/device.rs index d35f3989d..11cdfaff3 100644 --- a/crates/metal2vulkan-runtime/src/device.rs +++ b/crates/metal2vulkan-runtime/src/device.rs @@ -260,10 +260,10 @@ pub(crate) struct Core { pub(crate) ticks: Ticks, /// `VK_EXT_calibrated_timestamps`, the floor's: the GPU's clock read with the host's. pub(crate) calibrated: ash::ext::calibrated_timestamps::Device, - /// `VK_EXT_attachment_feedback_loop_dynamic_state`'s command, where device creation enabled - /// the attachment feedback loop (`floor::Capabilities::feedback_loop`): every render pipeline - /// takes the feedback loop's enable as dynamic state, which each draw sets. - pub(crate) feedback: Option, + /// Device creation enabled the attachment feedback loop (`floor::Capabilities::feedback_loop`): + /// every render pipeline takes its colour flag, and a draw reads an attachment of its pass + /// with the image in the feedback layout. + pub(crate) feedback_loop: bool, /// `VK_EXT_device_fault`'s command, where device creation enabled it (where the device lists /// it): a lost device's fault report, read once, at its first loss (`crate::fault`). pub(crate) fault: Option, @@ -272,8 +272,8 @@ pub(crate) struct Core { /// indirect command buffer is refused without them. pub(crate) indirect: Option, /// A draw may read an attachment of its own pass through a texture - /// (`floor::Capabilities::attachment_reads`): through the feedback loop where `feedback` is - /// set, else through a copy of the image into its shadow (`crate::shadow`). + /// (`floor::Capabilities::attachment_reads`): through the feedback loop where `feedback_loop` + /// holds, else through a copy of the image into its shadow (`crate::shadow`). pub(crate) attachment_reads: bool, /// Device creation enabled `linearColorAttachment` (`VK_NV_linear_color_attachment`, where /// the device lists it): an opaque handle's surface plane whose format's `LINEAR` tiling @@ -559,7 +559,6 @@ impl Device { mut robustness2, mut portability, mut feedback_loop, - mut feedback_loop_dynamic, mut divisor, mut border_swizzle, mut linear_attachment, @@ -613,9 +612,7 @@ impl Device { features = features.push_next(&mut portability); } if capabilities.feedback_loop { - features = features - .push_next(&mut feedback_loop) - .push_next(&mut feedback_loop_dynamic); + features = features.push_next(&mut feedback_loop); } if enabled(ash::khr::vertex_attribute_divisor::NAME) || enabled(ash::ext::vertex_attribute_divisor::NAME) @@ -736,9 +733,6 @@ impl Device { ); // SAFETY: as above. let exports = unsafe { Exports::new(vk_instance, raw, &device, &capabilities.extensions) }; - let feedback = (capabilities.feedback_loop).then(|| { - ash::ext::attachment_feedback_loop_dynamic_state::Device::new(vk_instance, &device) - }); let fault = (capabilities .extensions .contains(&ash::ext::device_fault::NAME)) @@ -815,7 +809,7 @@ impl Device { counters, ticks, calibrated, - feedback, + feedback_loop: capabilities.feedback_loop, fault, indirect, attachment_reads: capabilities.attachment_reads, diff --git a/crates/metal2vulkan-runtime/src/extension.rs b/crates/metal2vulkan-runtime/src/extension.rs index 218dde968..91ac74ce2 100644 --- a/crates/metal2vulkan-runtime/src/extension.rs +++ b/crates/metal2vulkan-runtime/src/extension.rs @@ -38,8 +38,7 @@ impl DeviceExtension { /// `VkPhysicalDeviceShaderQuadControlFeaturesKHR`, /// `VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT`, /// `VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR`, - /// `VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT`, - /// `VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT` or + /// `VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT` or /// `VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR`. pub fn with_features(name: &CStr, wanted: T, needs: fn(&T) -> bool) -> DeviceExtension where diff --git a/crates/metal2vulkan-runtime/src/floor.rs b/crates/metal2vulkan-runtime/src/floor.rs index 71e6ccc5d..2e5de6e77 100644 --- a/crates/metal2vulkan-runtime/src/floor.rs +++ b/crates/metal2vulkan-runtime/src/floor.rs @@ -130,16 +130,14 @@ const _: () = { assert!(offset_of!(Maintenance8Features, maintenance8) == 16); }; -/// The device extensions of the attachment feedback loop (`VK_EXT_attachment_feedback_loop_layout` -/// and its dynamic state), through which a draw reads, through a texture, an attachment its own -/// pass renders (Metal's texture read of a render target): device creation enables both, with -/// their features, where the device reads attachments (`Capabilities::attachment_reads`), lists -/// both and reports both features, and neither otherwise. A device that reads attachments without -/// them reads through a copy of the image (`Capabilities::feedback_loop`). -pub const ATTACHMENT_READ_EXTENSIONS: &[&CStr] = &[ - ash::ext::attachment_feedback_loop_layout::NAME, - ash::ext::attachment_feedback_loop_dynamic_state::NAME, -]; +/// The device extension of the attachment feedback loop (`VK_EXT_attachment_feedback_loop_layout`), +/// through which a draw reads, through a texture, an attachment its own pass renders (Metal's +/// texture read of a render target): its layout, its image usage and its pipeline flag, which every +/// render pipeline takes. Device creation enables it, with its feature, where the device reads +/// attachments (`Capabilities::attachment_reads`), lists it and reports the feature, and not +/// otherwise. A device that reads attachments without it reads through a copy of the image +/// (`Capabilities::feedback_loop`). +pub const ATTACHMENT_READ_EXTENSIONS: &[&CStr] = &[ash::ext::attachment_feedback_loop_layout::NAME]; /// The device extension of a sampler's border colour through a view's component mapping /// (`VK_EXT_border_color_swizzle`), after `VK_EXT_custom_border_color`, which it requires and of @@ -371,13 +369,9 @@ pub struct Features { /// of such a device. pub portability: vk::PhysicalDevicePortabilitySubsetFeaturesKHR<'static>, /// `VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT`, of - /// `VK_EXT_attachment_feedback_loop_layout`: read where the device lists it, and enabled with - /// the other attachment-read features alone. + /// `VK_EXT_attachment_feedback_loop_layout`: read where the device lists it, and enabled where + /// the device reads attachments through the feedback loop alone. pub feedback_loop: vk::PhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT<'static>, - /// `VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT`, of - /// `VK_EXT_attachment_feedback_loop_dynamic_state`: likewise. - pub feedback_loop_dynamic: - vk::PhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT<'static>, /// `VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR`, of `VK_KHR_vertex_attribute_divisor` /// and `VK_EXT_vertex_attribute_divisor` (the same structure): read and enabled only where the /// device lists one of them, and then only the step-rate feature. @@ -453,9 +447,6 @@ macro_rules! feature { (@structure feedback_loop) => { "VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT" }; - (@structure feedback_loop_dynamic) => { - "VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT" - }; (@structure divisor) => { "VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR" }; @@ -688,13 +679,11 @@ pub(crate) const OPTIONAL: &[Feature] = &[ feature!(maintenance8.maintenance8 => Maintenance8), ]; -/// The features of the attachment feedback loop ([`ATTACHMENT_READ_EXTENSIONS`]): enabled together -/// where the device reads attachments and reports both, and neither otherwise; a device that reads -/// attachments without them reads through a copy of the image. -pub(crate) const ATTACHMENT_READS: &[Feature] = &[ - feature!(feedback_loop.attachment_feedback_loop_layout => AttachmentFeedbackLoopLayout), - feature!(feedback_loop_dynamic.attachment_feedback_loop_dynamic_state), -]; +/// The feature of the attachment feedback loop ([`ATTACHMENT_READ_EXTENSIONS`]): enabled where the +/// device reads attachments and reports it, and not otherwise; a device that reads attachments +/// without it reads through a copy of the image. +pub(crate) const ATTACHMENT_READS: &[Feature] = + &[feature!(feedback_loop.attachment_feedback_loop_layout => AttachmentFeedbackLoopLayout)]; /// The features device creation enables where the device reports them, for Metal's per-instance /// step at a rate above 1, which the translator builds in one form, a binding's divisor, and @@ -1029,9 +1018,9 @@ pub struct Capabilities { /// Metal reads a render target. It reads through the attachment feedback loop where /// [`feedback_loop`](Self::feedback_loop) holds, and through a copy of the image otherwise. pub attachment_reads: bool, - /// The attachment reads hold, and so does every attachment-read feature, with + /// The attachment reads hold, and so does the attachment-read feature, with /// [`ATTACHMENT_READ_EXTENSIONS`]: a draw reads an attachment through the attachment feedback - /// loop. + /// loop, the feedback layout its image moves to and the flag every render pipeline takes. pub feedback_loop: bool, /// The features device creation enables: every one the floor requires, each of the optional, /// step-rate, min-LOD, fill-mode, alpha-to-one, quad-control, pixel-interlock, linear-attachment @@ -1184,8 +1173,6 @@ unsafe fn query( let robustness2_listed = listed(ash::ext::robustness2::NAME); let portability_listed = listed(ash::khr::portability_subset::NAME); let feedback_loop_listed = listed(ash::ext::attachment_feedback_loop_layout::NAME); - let feedback_loop_dynamic_listed = - listed(ash::ext::attachment_feedback_loop_dynamic_state::NAME); let divisor_listed = listed(ash::khr::vertex_attribute_divisor::NAME) || listed(ash::ext::vertex_attribute_divisor::NAME); let border_swizzle_listed = listed(ash::ext::border_color_swizzle::NAME); @@ -1208,7 +1195,6 @@ unsafe fn query( robustness2, portability, feedback_loop, - feedback_loop_dynamic, divisor, border_swizzle, linear_attachment, @@ -1246,9 +1232,6 @@ unsafe fn query( if feedback_loop_listed { features = features.push_next(&mut *feedback_loop); } - if feedback_loop_dynamic_listed { - features = features.push_next(&mut *feedback_loop_dynamic); - } if divisor_listed { features = features.push_next(&mut *divisor); } @@ -1286,7 +1269,6 @@ unsafe fn query( robustness2.p_next = std::ptr::null_mut(); portability.p_next = std::ptr::null_mut(); feedback_loop.p_next = std::ptr::null_mut(); - feedback_loop_dynamic.p_next = std::ptr::null_mut(); divisor.p_next = std::ptr::null_mut(); border_swizzle.p_next = std::ptr::null_mut(); linear_attachment.p_next = std::ptr::null_mut(); diff --git a/crates/metal2vulkan-runtime/src/render.rs b/crates/metal2vulkan-runtime/src/render.rs index 08f3f27b4..651fb545c 100644 --- a/crates/metal2vulkan-runtime/src/render.rs +++ b/crates/metal2vulkan-runtime/src/render.rs @@ -1457,15 +1457,11 @@ impl RenderCompiled { if let Some(op) = fixed.logic_op { blend = blend.logic_op_enable(true).logic_op(op); } - // Where the device reads attachments through textures, every pipeline takes the feedback - // loop's enable as dynamic state too: a state is made before any draw binds its textures. - let feedback = core.feedback.is_some(); // A state without rasterization takes its discard as dynamic state, which the encoder sets // at each bind: a static discard would leave the fragment shader and output state out of // the pipeline, its attachment formats and the dynamic depth, stencil and blend state above // with them, which every draw records and its pass renders into. let states: Vec = (DYNAMIC.iter().copied()) - .chain(feedback.then_some(vk::DynamicState::ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT)) .chain( fixed .discard @@ -1477,7 +1473,16 @@ impl RenderCompiled { .color_attachment_formats(&fixed.colors) .depth_attachment_format(fixed.depth) .stencil_attachment_format(fixed.stencil); + // Where the device reads attachments through the feedback loop, every pipeline may draw + // with a colour attachment in the feedback layout and read it through a texture: a state is + // made before any draw binds its textures, and which texture a draw binds decides whether + // it reads its pass's attachment. A draw that reads none is valid with the flag. + let flags = match core.feedback_loop { + true => vk::PipelineCreateFlags::COLOR_ATTACHMENT_FEEDBACK_LOOP_EXT, + false => vk::PipelineCreateFlags::empty(), + }; let mut info = vk::GraphicsPipelineCreateInfo::default() + .flags(flags) .push_next(&mut rendering) .stages(&stages) .vertex_input_state(&vertex_input) diff --git a/crates/metal2vulkan-runtime/src/render_encoder.rs b/crates/metal2vulkan-runtime/src/render_encoder.rs index bacc5a71e..dc5487f85 100644 --- a/crates/metal2vulkan-runtime/src/render_encoder.rs +++ b/crates/metal2vulkan-runtime/src/render_encoder.rs @@ -34,9 +34,9 @@ //! attachment layout, the rest from home), and the rendering begins again with the attachment in //! that layout; the pass's second barrier moves the whole image home. While it is there, every //! draw of the pass reads the image's textures through their elements in that layout -//! (`crate::arrays`). Every pipeline takes the feedback loop's enable as dynamic state, which the -//! encoder sets at its first draw and where it changes: colour for a draw that reads an -//! attachment, none otherwise. +//! (`crate::arrays`). Every render pipeline is made with the feedback loop's colour flag +//! (`VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT`), so any draw may read an +//! attachment in the feedback layout and a draw that reads none needs nothing set. //! //! What such a draw reads that an earlier draw of the pass rendered, Metal orders by a memory //! barrier between the two. A memory barrier after draws that wrote no memory, where the pass @@ -190,11 +190,10 @@ pub struct IndexBuffer<'a> { const MAX_VIEWPORTS: usize = 16; /// The dynamic state a draw records before it: the viewport and scissor, the cull mode, the -/// front face, the depth test, the stencil references, the blend constants, the depth bias, the -/// feedback loop's enable where the device reads attachments, and the stencil test. A setter -/// marks its state only where the value it sets differs from the one it replaces, and a draw -/// records of the depth and stencil tests only the fields that differ from the ones the encoder -/// last recorded. +/// front face, the depth test, the stencil references, the blend constants, the depth bias and +/// the stencil test. A setter marks its state only where the value it sets differs from the one +/// it replaces, and a draw records of the depth and stencil tests only the fields that differ from +/// the ones the encoder last recorded. const VIEWPORT: u32 = 1; const CULL: u32 = 2; const FRONT: u32 = 4; @@ -202,9 +201,8 @@ const DEPTH: u32 = 8; const REFERENCE: u32 = 16; const BLEND: u32 = 32; const BIAS: u32 = 64; -const LOOP: u32 = 128; -const STENCIL: u32 = 256; -const ALL: u32 = 511; +const STENCIL: u32 = 128; +const ALL: u32 = 255; /// An image the pass moved whole to the feedback layout, which its second barrier moves home. struct Moved { @@ -696,8 +694,6 @@ pub struct RenderCommandEncoder { owed: bool, /// The images the pass moved to the feedback layout. moved: Vec, - /// The feedback loop's aspects the last draw set: colour for a draw that reads an attachment. - loop_aspects: vk::ImageAspectFlags, /// The images the pass's draws read through their shadows, without the feedback loop. shadowed: Vec, /// The texture slots of the draw being recorded that read a shadow: function and slot. @@ -782,7 +778,6 @@ impl CommandBuffer { pass_drew: false, owed: false, moved: Vec::new(), - loop_aspects: vk::ImageAspectFlags::NONE, shadowed: Vec::new(), shadow_slots: Vec::new(), facts: Facts::default(), @@ -2519,7 +2514,6 @@ impl RenderCommandEncoder { self.shadow_slots.clear(); self.push_filled = false; } - self.loop_reads(false); self.overs_after(commands); } } @@ -3092,7 +3086,7 @@ impl RenderCommandEncoder { if self.results.counting() && self.ends_rendering(reads.as_ref(), index, overs) { return Err(self.interrupt_refused()); } - let reads_attachment = match reads { + match reads { Some(found) => { if !found.moves.is_empty() { self.feedback_moves(found.moves)?; @@ -3109,17 +3103,14 @@ impl RenderCommandEncoder { .expect("an encoder holds its command buffer's recording until it ends") .count(Metric::AttachmentLoopReads); } - found.reads } None => { if !self.shadow_slots.is_empty() { self.shadow_slots.clear(); self.push_filled = false; } - false } - }; - self.loop_reads(reads_attachment); + } let Some(state) = &self.pipeline else { return Err(Error::Refused(Refusal::NoPipeline)); }; @@ -3292,21 +3283,6 @@ impl RenderCommandEncoder { ); } - /// Sets the feedback loop's aspects for a draw that reads an attachment (`reads`) or none, - /// where the device reads attachments through it: dirty where they change. - fn loop_reads(&mut self, reads: bool) { - if self.core.feedback.is_some() { - let aspects = match reads { - true => vk::ImageAspectFlags::COLOR, - false => vk::ImageAspectFlags::NONE, - }; - if aspects != self.loop_aspects { - self.loop_aspects = aspects; - self.dirty |= LOOP; - } - } - } - /// Records the dynamic state that changed since the last draw, and the draw's topology and /// primitive restart where they changed; the scissor empty where the draw is `hidden`, and /// the encoder's again at the next draw that is not. @@ -3321,7 +3297,6 @@ impl RenderCommandEncoder { hidden: bool, ) { let device = &self.core.device; - let feedback = self.core.feedback.as_ref(); let command = self.command; let dirty = self.dirty; self.dirty = 0; @@ -3429,13 +3404,6 @@ impl RenderCommandEncoder { device.cmd_set_depth_bias_enable(command, biased); self.biased = biased; } - // Every pipeline takes the enable as dynamic state where the device reads attachments. - if let (true, Some(feedback)) = (dirty & LOOP != 0, feedback) { - (feedback.fp().cmd_set_attachment_feedback_loop_enable_ext)( - command, - self.loop_aspects, - ); - } if self.topology != Some((topology, restart)) { device.cmd_set_primitive_topology(command, topology); device.cmd_set_primitive_restart_enable(command, restart); diff --git a/crates/metal2vulkan-runtime/src/tests/device.rs b/crates/metal2vulkan-runtime/src/tests/device.rs index fc72c678c..8922ed98d 100644 --- a/crates/metal2vulkan-runtime/src/tests/device.rs +++ b/crates/metal2vulkan-runtime/src/tests/device.rs @@ -394,7 +394,7 @@ fn every_device_of_the_cfgs_kind_enables_the_consumers_extensions_it_offers() { .filter(|&name| lists(name)), ); // The attachment reads' extensions, where device creation took them. - if device.core().feedback.is_some() { + if device.core().feedback_loop { expected.extend(floor::ATTACHMENT_READ_EXTENSIONS); } // The border swizzle's, where the device reports it from the image. diff --git a/crates/metal2vulkan-runtime/src/tests/draw.rs b/crates/metal2vulkan-runtime/src/tests/draw.rs index e7259549a..f99dc9c28 100644 --- a/crates/metal2vulkan-runtime/src/tests/draw.rs +++ b/crates/metal2vulkan-runtime/src/tests/draw.rs @@ -2876,7 +2876,7 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" { (device.grant_indices(IndexClass::Texture, 4096, 4)) .unwrap_or_else(|error| panic!("{name}: {error}")); let reads = device.core().attachment_reads; - let looped = device.core().feedback.is_some(); + let looped = device.core().feedback_loop; let plain = state(name, &device, &plain); let mut buffers = Buffers::new(&device); // Three triangles over the whole target, their colors none, blue and green. @@ -3028,7 +3028,7 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" { } (device.grant_indices(IndexClass::Texture, 4096, 4)) .unwrap_or_else(|error| panic!("{name}: {error}")); - let looped = device.core().feedback.is_some(); + let looped = device.core().feedback_loop; let plain = state(name, &device, &plain); let reading = state(name, &device, &own); let mut buffers = Buffers::new(&device); @@ -3116,7 +3116,7 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" { println!("{name}: no attachment reads"); return; } - let looped = device.core().feedback.is_some(); + let looped = device.core().feedback_loop; let counters = device.counters(); let before = counters.metrics(); for (class, first) in [(IndexClass::Texture, 4096), (IndexClass::Sampler, 1)] { diff --git a/crates/metal2vulkan-runtime/src/tests/fetch.rs b/crates/metal2vulkan-runtime/src/tests/fetch.rs index ad9239630..a77caf19d 100644 --- a/crates/metal2vulkan-runtime/src/tests/fetch.rs +++ b/crates/metal2vulkan-runtime/src/tests/fetch.rs @@ -213,7 +213,7 @@ mod on_device { (device.grant_indices(IndexClass::Texture, 4096, DRAWS.len() as u32)) .unwrap_or_else(|error| panic!("{name}: {error}")); let reads = device.core().attachment_reads; - let looped = device.core().feedback.is_some(); + let looped = device.core().feedback_loop; let state = state(name, &device, &d); let queue = device.new_command_queue(4).expect("a queue"); let clear = ClearColor { @@ -446,7 +446,7 @@ mod on_device { (device.grant_indices(IndexClass::Texture, 4096, DRAWS.len() as u32)) .unwrap_or_else(|error| panic!("{name}: {error}")); let reads = device.core().attachment_reads; - let feedback = device.core().feedback.is_some(); + let feedback = device.core().feedback_loop; // The feedback usage is the loop's extension's, so only a device with the loop is // asked it (`VUID-VkPhysicalDeviceImageFormatInfo2-usage-parameter`); the answer is // read only there. @@ -586,7 +586,7 @@ mod on_device { (device.grant_indices(IndexClass::Texture, 4096, count)) .unwrap_or_else(|error| panic!("{name}: {error}")); let reads = device.core().attachment_reads; - let feedback = device.core().feedback.is_some(); + let feedback = device.core().feedback_loop; // The feedback usage is the loop's extension's, so only a device with the loop is // asked it (`VUID-VkPhysicalDeviceImageFormatInfo2-usage-parameter`); the answer is // read only there. diff --git a/crates/metal2vulkan-runtime/src/tests/floor.rs b/crates/metal2vulkan-runtime/src/tests/floor.rs index c9ac2477d..251aa179c 100644 --- a/crates/metal2vulkan-runtime/src/tests/floor.rs +++ b/crates/metal2vulkan-runtime/src/tests/floor.rs @@ -1641,9 +1641,11 @@ fn a_run_time_texel_offset_is_the_sample_s_operand_where_maintenance8_is_reporte } /// A device reads attachments where its descriptor limits hold the sampled-texture array's second -/// elements: through the attachment feedback loop where it lists both extensions and reports both -/// features, which device creation then enables, and through a copy of the image where it does -/// not, enabling neither. A device without the room reads no attachment, whatever it reports. +/// elements: through the attachment feedback loop where it lists +/// `VK_EXT_attachment_feedback_loop_layout` and reports its feature, which device creation then +/// enables, with no other extension (its dynamic state is never enabled, listed or not), and +/// through a copy of the image where it does not, enabling neither. A device without the room +/// reads no attachment, whatever it reports. #[test] fn the_attachment_reads_take_the_feedback_loop_where_reported_and_a_copy_elsewhere() { let roomy = |device: &mut Queried| { @@ -1654,17 +1656,13 @@ fn the_attachment_reads_take_the_feedback_loop_where_reported_and_a_copy_elsewhe descriptors.max_update_after_bind_descriptors_in_all_pools = 6 * 65_536 + 3 * 8000; }; let looped = |device: &mut Queried| { - (device.extensions).extend( - ATTACHMENT_READ_EXTENSIONS - .iter() - .map(|&name| name.to_owned()), - ); + (device.extensions).push(ash::ext::attachment_feedback_loop_layout::NAME.to_owned()); device .features .feedback_loop .attachment_feedback_loop_layout = vk::TRUE; - (device.features.feedback_loop_dynamic).attachment_feedback_loop_dynamic_state = vk::TRUE; }; + let dynamic = ash::ext::attachment_feedback_loop_dynamic_state::NAME; let answer = |device: &Queried| { let capabilities = decide(device).unwrap_or_else(|below| panic!("{below}")); let enabled = (ATTACHMENT_READ_EXTENSIONS.iter()) @@ -1706,7 +1704,18 @@ fn the_attachment_reads_take_the_feedback_loop_where_reported_and_a_copy_elsewhe let mut device = at_the_floor(); roomy(&mut device); looped(&mut device); - assert_eq!(answer(&device), (true, true, 2, 2), "room and the loop"); + assert_eq!( + answer(&device), + (true, true, 1, 1), + "room and the layout extension alone: the loop" + ); + device.extensions.push(dynamic.to_owned()); + let capabilities = decide(&device).unwrap_or_else(|below| panic!("{below}")); + assert!(capabilities.feedback_loop); + assert!( + !capabilities.extensions.contains(&dynamic), + "the loop's dynamic state is never enabled" + ); } /// A set layout the created device does not support is named by its set. @@ -2099,7 +2108,6 @@ fn every_device_the_loader_lists_is_above_the_floor() { mut robustness2, mut portability, mut feedback_loop, - mut feedback_loop_dynamic, mut divisor, mut border_swizzle, mut linear_attachment, @@ -2136,9 +2144,7 @@ fn every_device_the_loader_lists_is_above_the_floor() { features = features.push_next(&mut portability); } if capabilities.feedback_loop { - features = features - .push_next(&mut feedback_loop) - .push_next(&mut feedback_loop_dynamic); + features = features.push_next(&mut feedback_loop); } if enabled(ash::khr::vertex_attribute_divisor::NAME) || enabled(ash::ext::vertex_attribute_divisor::NAME) diff --git a/crates/metal2vulkan-runtime/src/texture.rs b/crates/metal2vulkan-runtime/src/texture.rs index 669387011..9eb0bcf06 100644 --- a/crates/metal2vulkan-runtime/src/texture.rs +++ b/crates/metal2vulkan-runtime/src/texture.rs @@ -1716,7 +1716,7 @@ impl Device { }); let attachment_reads = plan.attachment_reads && !laid_over; // On a device without the feedback loop, a draw reads such an image through its shadow. - let shadowing = (attachment_reads && core.feedback.is_none()).then(|| { + let shadowing = (attachment_reads && !core.feedback_loop).then(|| { Box::new(Shadowing { made: (d, shape, plan.shadow()), shadow: Mutex::new(None), @@ -2625,7 +2625,7 @@ fn planned( // it has the attachment feedback loop, else through a copy into the image's shadow. The image // takes the sampled usage for it where shaders do not read the texture. let mut attachment_reads = plan.reads_attachments(core); - let looped = attachment_reads && core.feedback.is_some(); + let looped = attachment_reads && core.feedback_loop; let mut image_usage = plan.usage; if attachment_reads { image_usage |= vk::ImageUsageFlags::SAMPLED; @@ -6151,7 +6151,7 @@ impl Device { Ok(crate::surface::PlanePlan { format: plan.format, usage: plan.linear_usage(), - looped: plan.reads_attachments(self.core()) && self.core().feedback.is_some(), + looped: plan.reads_attachments(self.core()) && self.core().feedback_loop, view_formats: plan.view_formats.clone(), texel, }) diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index b22752cc7..5e99720c0 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -408,7 +408,7 @@ const-value metal2vulkan-runtime::HOST_DOMAIN vk::TimeDomainKHR::CLOCK_MONOTONIC const-value metal2vulkan-runtime::HOST_DOMAIN vk::TimeDomainKHR::QUERY_PERFORMANCE_COUNTER const-value metal2vulkan-runtime::MAX_BUFFER_LENGTH 1 <<31 const-value metal2vulkan-runtime::MAX_COLOR_ATTACHMENTS 8 -const-value metal2vulkan-runtime::floor::ATTACHMENT_READ_EXTENSIONS &[ash::ext::attachment_feedback_loop_layout::NAME, ash::ext::attachment_feedback_loop_dynamic_state::NAME] +const-value metal2vulkan-runtime::floor::ATTACHMENT_READ_EXTENSIONS &[ash::ext::attachment_feedback_loop_layout::NAME] const-value metal2vulkan-runtime::floor::BARYCENTRIC_EXTENSIONS &[ash::khr::fragment_shader_barycentric::NAME] const-value metal2vulkan-runtime::floor::BORDER_SWIZZLE_EXTENSIONS &[ash::ext::custom_border_color::NAME, ash::ext::border_color_swizzle::NAME] const-value metal2vulkan-runtime::floor::BUFFER_USAGE vk::BufferUsageFlags::from_raw(vk::BufferUsageFlags::TRANSFER_SRC.as_raw() | vk::BufferUsageFlags::TRANSFER_DST.as_raw() | vk::BufferUsageFlags::UNIFORM_TEXEL_BUFFER.as_raw() | vk::BufferUsageFlags::STORAGE_TEXEL_BUFFER.as_raw() | vk::BufferUsageFlags::UNIFORM_BUFFER.as_raw() | vk::BufferUsageFlags::STORAGE_BUFFER.as_raw() | vk::BufferUsageFlags::INDEX_BUFFER.as_raw() | vk::BufferUsageFlags::VERTEX_BUFFER.as_raw() | vk::BufferUsageFlags::INDIRECT_BUFFER.as_raw() | vk::BufferUsageFlags::SHADER_DEVICE_ADDRESS.as_raw()) @@ -1820,7 +1820,6 @@ field metal2vulkan-runtime::floor::Features.core pub core: vk::PhysicalDeviceFea field metal2vulkan-runtime::floor::Features.divisor pub divisor: vk::PhysicalDeviceVertexAttributeDivisorFeaturesKHR<'static> field metal2vulkan-runtime::floor::Features.fault pub fault: vk::PhysicalDeviceFaultFeaturesEXT<'static> field metal2vulkan-runtime::floor::Features.feedback_loop pub feedback_loop: vk::PhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT<'static> -field metal2vulkan-runtime::floor::Features.feedback_loop_dynamic pub feedback_loop_dynamic: vk::PhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT<'static> field metal2vulkan-runtime::floor::Features.generated_commands pub generated_commands: DgcFeatures field metal2vulkan-runtime::floor::Features.interlock pub interlock: vk::PhysicalDeviceFragmentShaderInterlockFeaturesEXT<'static> field metal2vulkan-runtime::floor::Features.line_rasterization pub line_rasterization: vk::PhysicalDeviceLineRasterizationFeaturesEXT<'static>