diff --git a/crates/metal2vulkan-rt/README.md b/crates/metal2vulkan-rt/README.md index 57541f37d..b89a1d4cc 100644 --- a/crates/metal2vulkan-rt/README.md +++ b/crates/metal2vulkan-rt/README.md @@ -1858,7 +1858,7 @@ or does not check is rebuilt from the generations' names, with young counted ful step function or enabled factor scale (`Tessellation`; a descriptor's tessellation state with any other vertex function is ignored, as Metal ignores it), stages the translator synthesizes beside the functions' and a tessellation's, framebuffer fetch, an imageblock, a - fragment function's stencil output, alpha to one, constant data the binder supplies, a + fragment function's stencil output, constant data the binder supplies, a specialization other than the sample and amplification counts, dynamic state beyond Vulkan 1.3's (a vertex buffer layout whose stride is set per bind among it), a feature or extension device creation does not enable, and a function that reads what a draw @@ -2303,6 +2303,9 @@ Presenting runs on the runtime's own device; nothing is exported or imported. | `shaderStorageImageWriteWithoutFormat` | `VkPhysicalDeviceFeatures` | writes to array elements of any pixel format | | `nullDescriptor` | `VkPhysicalDeviceRobustness2FeaturesEXT` | every texture element no texture owns: a nil, freed or unowned index reads zeros, sizes 0 and drops writes, as Metal's nil texture does. The robust buffer access beside it stays off | | `samplerAnisotropy` | `VkPhysicalDeviceFeatures` | a sampler state's `maxAnisotropy`, which the device's own filter takes | +| `shaderStorageImageExtendedFormats` | `VkPhysicalDeviceFeatures` | a read-write texture of a format Vulkan lists among the storage image extended formats (`RG16Float`, `RG11B10Float`, `R8Unorm` and the rest), declared with its format where a shader reads it; Vulkan 1.4 and Roadmap 2022 require it | +| `samplerMirrorClampToEdge` | `VkPhysicalDeviceVulkan12Features` | a sampler state's `MTLSamplerAddressModeMirrorClampToEdge`; Vulkan 1.4 and Roadmap 2022 require it | +| `shaderImageGatherExtended` | `VkPhysicalDeviceFeatures` | a gather at an offset the shader computes; Vulkan 1.4 requires it | | `shaderInt16` | `VkPhysicalDeviceFeatures` | `short` and `ushort` in shaders | | `shaderInt8` | `VkPhysicalDeviceVulkan12Features` | `char` and `uchar` in shaders | | `storageBuffer16BitAccess` | `VkPhysicalDeviceVulkan11Features` | 16-bit values in buffers | @@ -2317,7 +2320,12 @@ Presenting runs on the runtime's own device; nothing is exported or imported. | `robustImageAccess2` | `VkPhysicalDeviceRobustness2FeaturesEXT` | an image read or fetch out of range, past the view's levels included, answering Metal's texel (zero, alpha 1 for a format without alpha), with no check in the shader; a texel buffer's read is still checked in the shader | | `independentBlend` | `VkPhysicalDeviceFeatures` | each color attachment of a render pipeline blended by its own state, as Metal's are | | `fragmentStoresAndAtomics` | `VkPhysicalDeviceFeatures` | a fragment function's writes and atomics on device memory | +| `alphaToOne` | `VkPhysicalDeviceFeatures` | a render pipeline's `alphaToOneEnabled` | +| `logicOp` | `VkPhysicalDeviceFeatures` | a render pipeline's logic operation (private render state), the device's own; without it the fragment function would compute it, which needs fragment interlock or raster-order attachment access | +| `fullDrawIndexUint32` | `VkPhysicalDeviceFeatures` | an indexed draw's 32-bit indices past `2^24 - 1`; Vulkan 1.4 and Roadmap 2022 require it | +| `shaderClipDistance` | `VkPhysicalDeviceFeatures` | a vertex or post-tessellation vertex function's `[[clip_distance]]` | | `tessellationShader` | `VkPhysicalDeviceFeatures` | a post-tessellation vertex function's patches, drawn through the device's tessellator | +| `shaderTessellationAndGeometryPointSize` | `VkPhysicalDeviceFeatures` | a post-tessellation vertex function's `[[point_size]]`; without it the device draws every such point at size 1 | | `dualSrcBlend` | `VkPhysicalDeviceFeatures` | a fragment function's second output for colour attachment 0 (`[[color(0), index(1)]]`) as the blend's second source (`Source1Color`, `Source1Alpha` and their complements) | | `sampleRateShading` | `VkPhysicalDeviceFeatures` | a fragment function that reads its `[[sample_id]]`, or an interpolant at a sample, run once per covered sample as Metal runs it; Vulkan 1.4 requires it | | `vertexPipelineStoresAndAtomics` | `VkPhysicalDeviceFeatures` | a vertex or post-tessellation vertex function's writes and atomics on device memory | diff --git a/crates/metal2vulkan-rt/src/error.rs b/crates/metal2vulkan-rt/src/error.rs index 1388ddd45..5ce54c5c5 100644 --- a/crates/metal2vulkan-rt/src/error.rs +++ b/crates/metal2vulkan-rt/src/error.rs @@ -1164,8 +1164,6 @@ pub enum RenderPipelineKind { Imageblock, /// A fragment function's stencil output applied by the shader. ShaderStencil, - /// `alphaToOneEnabled`, which needs a feature the floor does not require. - AlphaToOne, /// A function that reads constant data the binder supplies. ConstantData, /// A specialization the draw would set, beside the sample and amplification counts. diff --git a/crates/metal2vulkan-rt/src/floor.rs b/crates/metal2vulkan-rt/src/floor.rs index 4b00ace67..57290a373 100644 --- a/crates/metal2vulkan-rt/src/floor.rs +++ b/crates/metal2vulkan-rt/src/floor.rs @@ -292,8 +292,18 @@ pub(crate) const REQUIRED: &[Feature] = &[ feature!(vulkan12.shader_sampled_image_array_non_uniform_indexing => ShaderSampledImageArrayNonUniformIndexing), feature!(vulkan12.shader_storage_image_array_non_uniform_indexing => ShaderStorageImageArrayNonUniformIndexing), feature!(core.shader_storage_image_write_without_format => ShaderStorageImageWriteWithoutFormat), + // A read-write texture of a format Vulkan lists among the storage image extended formats + // (`RG16Float`, `RG11B10Float`, `R8Unorm` and the rest), declared with its format where a + // shader reads it. Vulkan 1.4 and Roadmap 2022 require it of every device. + feature!(core.shader_storage_image_extended_formats => ShaderStorageImageExtendedFormats), // A sampler state's anisotropy is the device's own filter. feature!(core.sampler_anisotropy => SamplerAnisotropy), + // A sampler state's `MTLSamplerAddressModeMirrorClampToEdge`, the device's own address mode. + // Vulkan 1.4 and Roadmap 2022 require it of every device. + feature!(vulkan12.sampler_mirror_clamp_to_edge => SamplerMirrorClampToEdge), + // A gather at an offset the shader computes, as Metal's `gather` takes one. Vulkan 1.4 + // requires it of every device. + feature!(core.shader_image_gather_extended => ShaderImageGatherExtended), // Every array element no texture owns is a null descriptor: a nil, freed or unowned texture // index reads zeros, answers 0 to its size queries and drops its writes, as Metal's nil // texture does, with no code in the shader. @@ -326,10 +336,28 @@ pub(crate) const REQUIRED: &[Feature] = &[ // requires both of every graphics device. feature!(core.independent_blend => IndependentBlend), feature!(core.fragment_stores_and_atomics => FragmentStoresAndAtomics), + // A render pipeline's `alphaToOneEnabled`, the device's own: each sample's alpha 1 after the + // coverage is taken. Every floor driver reports it. + feature!(core.alpha_to_one => AlphaToOne), + // A render pipeline's logic operation (private render state), the device's own `logicOp`. A + // device without it would compute the operation in the fragment function, which needs + // fragment interlock or raster-order attachment access, neither in the floor. Every floor + // driver reports it. + feature!(core.logic_op => LogicOp), + // An indexed draw's 32-bit indices past `2^24 - 1`, which Metal draws. Vulkan 1.4 and + // Roadmap 2022 require it of every device. + feature!(core.full_draw_index_uint32 => FullDrawIndexUint32), + // A vertex or post-tessellation vertex function's `[[clip_distance]]`, the device's own + // clipping. Every floor driver reports it. + feature!(core.shader_clip_distance => ShaderClipDistance), // A render pipeline of a post-tessellation vertex function draws its patches through the // device's tessellator: a synthesized control stage reads each patch's factors through their // address, and the function is the evaluation stage. A device without it is below the floor. feature!(core.tessellation_shader => TessellationShader), + // A post-tessellation vertex function's `[[point_size]]`, which a point draw of its patches + // takes. Without it the device draws every such point at size 1. Every floor driver reports + // it. + feature!(core.shader_tessellation_and_geometry_point_size => ShaderTessellationAndGeometryPointSize), // A fragment function's second output for a colour attachment (`[[color(0), index(1)]]`) // blends with its first, as Metal's dual-source blending does. A device without it is below // the floor. diff --git a/crates/metal2vulkan-rt/src/render.rs b/crates/metal2vulkan-rt/src/render.rs index 96b0e7d27..41393edaf 100644 --- a/crates/metal2vulkan-rt/src/render.rs +++ b/crates/metal2vulkan-rt/src/render.rs @@ -200,7 +200,13 @@ struct Fixed { discard: bool, samples: vk::SampleCountFlags, alpha_to_coverage: bool, + /// `alphaToOneEnabled`, the device's own (`alphaToOne`, which the floor requires). + alpha_to_one: bool, blends: Vec, + /// The logic operation the translator states (private render state), the device's own + /// (`logicOp`, which the floor requires); `None` with the operation off, or copy or no-op, + /// which the attachments' states already draw. + logic_op: Option, /// Each colour attachment's format by Metal index, `UNDEFINED` for an absent one. colors: Vec, /// A patch list's control points per patch (`patchControlPoints`), 0 but for a @@ -556,8 +562,6 @@ fn unbuilt(pipeline: &RenderPipeline, enabled: &EnabledCaps) -> Option Queried { .shader_storage_image_array_non_uniform_indexing = vk::TRUE; features.core.shader_storage_image_write_without_format = vk::TRUE; features.core.sampler_anisotropy = vk::TRUE; + features.core.shader_storage_image_extended_formats = vk::TRUE; + features.vulkan12.sampler_mirror_clamp_to_edge = vk::TRUE; + features.core.shader_image_gather_extended = vk::TRUE; + features.core.alpha_to_one = vk::TRUE; + features.core.logic_op = vk::TRUE; + features.core.full_draw_index_uint32 = vk::TRUE; + features.core.shader_clip_distance = vk::TRUE; + features.core.shader_tessellation_and_geometry_point_size = vk::TRUE; features.core.shader_int16 = vk::TRUE; features.vulkan12.shader_int8 = vk::TRUE; features.vulkan11.storage_buffer16_bit_access = vk::TRUE; @@ -336,7 +344,7 @@ fn each_missing_feature_is_named() { const CORE: &str = "VkPhysicalDeviceFeatures"; const ROBUSTNESS2: &str = "VkPhysicalDeviceRobustness2FeaturesEXT"; type Clear = fn(&mut Features); - let cases: [(Clear, Missing); 42] = [ + let cases: [(Clear, Missing); 50] = [ ( |f| f.vulkan12.buffer_device_address = vk::FALSE, feature(V12, "bufferDeviceAddress"), @@ -511,6 +519,35 @@ fn each_missing_feature_is_named() { |f| f.core.sampler_anisotropy = vk::FALSE, feature(CORE, "samplerAnisotropy"), ), + ( + |f| f.core.shader_storage_image_extended_formats = vk::FALSE, + feature(CORE, "shaderStorageImageExtendedFormats"), + ), + ( + |f| f.vulkan12.sampler_mirror_clamp_to_edge = vk::FALSE, + feature(V12, "samplerMirrorClampToEdge"), + ), + ( + |f| f.core.shader_image_gather_extended = vk::FALSE, + feature(CORE, "shaderImageGatherExtended"), + ), + ( + |f| f.core.alpha_to_one = vk::FALSE, + feature(CORE, "alphaToOne"), + ), + (|f| f.core.logic_op = vk::FALSE, feature(CORE, "logicOp")), + ( + |f| f.core.full_draw_index_uint32 = vk::FALSE, + feature(CORE, "fullDrawIndexUint32"), + ), + ( + |f| f.core.shader_clip_distance = vk::FALSE, + feature(CORE, "shaderClipDistance"), + ), + ( + |f| f.core.shader_tessellation_and_geometry_point_size = vk::FALSE, + feature(CORE, "shaderTessellationAndGeometryPointSize"), + ), ]; assert_eq!( cases.len(), diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index 233acdd5a..8dee3435b 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -13973,7 +13973,6 @@ variant metal2vulkan-rt::RenderPassKind::Resolve Resolve variant metal2vulkan-rt::RenderPassKind::SampleCounts SampleCounts variant metal2vulkan-rt::RenderPassKind::StoreAction StoreAction variant metal2vulkan-rt::RenderPassKind::TextureType TextureType -variant metal2vulkan-rt::RenderPipelineKind::AlphaToOne AlphaToOne variant metal2vulkan-rt::RenderPipelineKind::ConstantData ConstantData variant metal2vulkan-rt::RenderPipelineKind::DepthStencilFormats DepthStencilFormats variant metal2vulkan-rt::RenderPipelineKind::DeviceFeature DeviceFeature