diff --git a/README.md b/README.md index a9b39ce7f..974e4bf74 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,9 @@ What the translator promises: - **Typed refusals.** Input the device cannot run exactly fails with an error that names the Metal feature and what would make it work. It never returns a module that computes something else. - **Recorded differences.** Where a pipeline gives a near-equivalent of Metal's answer, its - artifact records a precision note, and the runtime announces it once with a stable code. + artifact records a precision note. The runtime records each state's notes when the state is + made and exposes them, each with a stable code (`PrecisionNote::code`); the caller announces + them. - **The GPU's native arithmetic.** Where the device has a native form (its maths, rounding, conversions and sampler), that form gives the answer, its difference from Metal's recorded. - **Bounded work.** Every compile runs under a deadline, a cancellation token and deterministic diff --git a/crates/metal2vulkan-conformance/src/degradation.rs b/crates/metal2vulkan-conformance/src/degradation.rs index be7dafe9e..1a4d1d895 100644 --- a/crates/metal2vulkan-conformance/src/degradation.rs +++ b/crates/metal2vulkan-conformance/src/degradation.rs @@ -1,5 +1,6 @@ //! The degrade-notice codes the suite's cases name: `metal2vulkan-degrade-`, one per kind, -//! and the kind each of the runtime's precision notes announces as. +//! each its precision note's code as the translator states it (`PrecisionNote::code`), and the +//! kind each of the runtime's precision notes announces as. //! //! A case loosens a field by naming a code ([`crate::allowance`]), and the comparison holds it //! there only where the run announced that code. The runtime's side announces the codes of @@ -11,171 +12,171 @@ use metal2vulkan::pipeline::PrecisionNote; /// A kind of degrade notice, by its code ([`Degradation::code`]). #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Degradation { - /// `metal2vulkan-degrade-device-rounded-resolve`. + /// [`PrecisionNote::DeviceRoundedResolve`]. DeviceRoundedResolve, - /// `metal2vulkan-degrade-device-reconvergence`. + /// [`PrecisionNote::DeviceReconvergence`]. DeviceReconvergence, - /// `metal2vulkan-degrade-simdgroup-access-order`. + /// [`PrecisionNote::SimdgroupAccessOrder`]. SimdgroupAccessOrder, - /// `metal2vulkan-degrade-device-filtered-mipmaps`. + /// [`PrecisionNote::DeviceFilteredMipmaps`]. DeviceFilteredMipmaps, - /// `metal2vulkan-degrade-capped-lod-bias`. + /// [`PrecisionNote::CappedLodBias`]. CappedLodBias, - /// `metal2vulkan-degrade-snorm-minimum-kept`. + /// [`PrecisionNote::SnormMinimumKept`]. SnormMinimumKept, - /// `metal2vulkan-degrade-shared-exponent-kept`. + /// [`PrecisionNote::SharedExponentKept`]. SharedExponentKept, - /// `metal2vulkan-degrade-compressed-texel-decode`. + /// [`PrecisionNote::CompressedTexelDecode`]. CompressedTexelDecode, - /// `metal2vulkan-degrade-depth-denormals`. + /// [`PrecisionNote::DepthDenormals`]. DepthDenormals, - /// `metal2vulkan-degrade-f16-fma-double-rounding`. + /// [`PrecisionNote::F16FmaDoubleRounding`]. F16FmaDoubleRounding, - /// `metal2vulkan-degrade-f16-int-conv-double-rounding`. + /// [`PrecisionNote::F16IntConvDoubleRounding`]. F16IntConvDoubleRounding, - /// `metal2vulkan-degrade-grad-from-bias`. + /// [`PrecisionNote::GradFromBias`]. GradFromBias, - /// `metal2vulkan-degrade-device-transcendentals`. + /// [`PrecisionNote::DeviceTranscendentals`]. DeviceTranscendentals, - /// `metal2vulkan-degrade-reduction-order`. + /// [`PrecisionNote::ReductionOrder`]. ReductionOrder, - /// `metal2vulkan-degrade-device-denormals`. + /// [`PrecisionNote::DeviceDenormals`]. DeviceDenormals, - /// `metal2vulkan-degrade-pixel-sampler-scaling`. + /// [`PrecisionNote::PixelSamplerScaling`]. PixelSamplerScaling, - /// `metal2vulkan-degrade-device-arithmetic`. + /// [`PrecisionNote::DeviceArithmetic`]. DeviceArithmetic, - /// `metal2vulkan-degrade-device-signed-zero-inf-nan`. + /// [`PrecisionNote::DeviceSignedZeroInfNan`]. DeviceSignedZeroInfNan, - /// `metal2vulkan-degrade-device-ray-intersection`. + /// [`PrecisionNote::DeviceRayIntersection`]. DeviceRayIntersection, - /// `metal2vulkan-degrade-fast-math-rewrites`. + /// [`PrecisionNote::FastMathRewrites`]. FastMathRewrites, - /// `metal2vulkan-degrade-tessellation-winding`. + /// [`PrecisionNote::TessellationWinding`]. TessellationWinding, - /// `metal2vulkan-degrade-tessellation-fractional-spacing`. + /// [`PrecisionNote::TessellationFractionalSpacing`]. TessellationFractionalSpacing, - /// `metal2vulkan-degrade-tessellation-factor-edge-cases`. + /// [`PrecisionNote::TessellationFactorEdgeCases`]. TessellationFactorEdgeCases, - /// `metal2vulkan-degrade-tessellation-factor-scale`. + /// [`PrecisionNote::TessellationFactorScale`]. TessellationFactorScale, - /// `metal2vulkan-degrade-tessellation-factor-instance`. + /// [`PrecisionNote::TessellationFactorInstance`]. TessellationFactorInstance, - /// `metal2vulkan-degrade-fp8-value`. + /// [`PrecisionNote::Fp8Value`]. Fp8Value, - /// `metal2vulkan-degrade-multisample-position`. + /// [`PrecisionNote::MultisamplePosition`]. MultisamplePosition, - /// `metal2vulkan-degrade-bicubic-filter-arithmetic`. + /// [`PrecisionNote::BicubicFilterArithmetic`]. BicubicFilterArithmetic, - /// `metal2vulkan-degrade-sparse-residency`. + /// [`PrecisionNote::SparseResidency`]. SparseResidency, - /// `metal2vulkan-degrade-device-nan-encoding`. + /// [`PrecisionNote::DeviceNanEncoding`]. DeviceNanEncoding, - /// `metal2vulkan-degrade-restricted-depth-range`. + /// [`PrecisionNote::RestrictedDepthRange`]. RestrictedDepthRange, - /// `metal2vulkan-degrade-cube-gradient-footprint`. + /// [`PrecisionNote::CubeGradientFootprint`]. CubeGradientFootprint, - /// `metal2vulkan-degrade-half-texel-conversion`. + /// [`PrecisionNote::HalfTexelConversion`]. HalfTexelConversion, - /// `metal2vulkan-degrade-srgb-texel-decode`. + /// [`PrecisionNote::SrgbTexelDecode`]. SrgbTexelDecode, - /// `metal2vulkan-degrade-function-storage-assumed`. + /// [`PrecisionNote::FunctionStorageAssumed`]. FunctionStorageAssumed, - /// `metal2vulkan-degrade-quads-counted-before-discard`. + /// [`PrecisionNote::QuadsCountedBeforeDiscard`]. QuadsCountedBeforeDiscard, - /// `metal2vulkan-degrade-view-base-texel-offset`. + /// [`PrecisionNote::ViewBaseTexelOffset`]. ViewBaseTexelOffset, - /// `metal2vulkan-degrade-device-color-conversion`. + /// [`PrecisionNote::DeviceColorConversion`]. DeviceColorConversion, - /// `metal2vulkan-degrade-device-interpolation`. + /// [`PrecisionNote::DeviceInterpolation`]. DeviceInterpolation, - /// `metal2vulkan-degrade-device-interpolation-offset`. + /// [`PrecisionNote::DeviceInterpolationOffset`]. DeviceInterpolationOffset, - /// `metal2vulkan-degrade-extrapolated-interpolation`. + /// [`PrecisionNote::ExtrapolatedInterpolation`]. ExtrapolatedInterpolation, - /// `metal2vulkan-degrade-quads-split-by-clipping`. + /// [`PrecisionNote::QuadsSplitByClipping`]. QuadsSplitByClipping, - /// `metal2vulkan-degrade-fragment-simdgroup-grouping`. + /// [`PrecisionNote::FragmentSimdgroupGrouping`]. FragmentSimdgroupGrouping, - /// `metal2vulkan-degrade-blended-write-rounding`. + /// [`PrecisionNote::BlendedWriteRounding`]. BlendedWriteRounding, - /// `metal2vulkan-degrade-rotated-blend-rounding`. + /// [`PrecisionNote::RotatedBlendRounding`]. RotatedBlendRounding, - /// `metal2vulkan-degrade-linked-sampler-numbering`. + /// [`PrecisionNote::LinkedSamplerNumbering`]. LinkedSamplerNumbering, - /// `metal2vulkan-degrade-argument-pixel-sampler-scaling`. + /// [`PrecisionNote::ArgumentPixelSamplerScaling`]. ArgumentPixelSamplerScaling, - /// `metal2vulkan-degrade-half-output-precision`. + /// [`PrecisionNote::HalfOutputPrecision`]. HalfOutputPrecision, - /// `metal2vulkan-degrade-anisotropic-filter`. + /// [`PrecisionNote::AnisotropicFilter`]. AnisotropicFilter, - /// `metal2vulkan-degrade-device-anisotropic-filter`. + /// [`PrecisionNote::DeviceAnisotropicFilter`]. DeviceAnisotropicFilter, - /// `metal2vulkan-degrade-device-point-size`. + /// [`PrecisionNote::DevicePointSize`]. DevicePointSize, - /// `metal2vulkan-degrade-clipped-coverage-split`. + /// [`PrecisionNote::ClippedCoverageSplit`]. ClippedCoverageSplit, - /// `metal2vulkan-degrade-looped-sample-outputs`. + /// [`PrecisionNote::LoopedSampleOutputs`]. LoopedSampleOutputs, - /// `metal2vulkan-degrade-half-output-fast-math-blend`. + /// [`PrecisionNote::HalfOutputFastMathBlend`]. HalfOutputFastMathBlend, - /// `metal2vulkan-degrade-device-sampling`. + /// [`PrecisionNote::DeviceSampling`]. DeviceSampling, - /// `metal2vulkan-degrade-native-transcendentals`. + /// [`PrecisionNote::NativeTranscendentals`]. NativeTranscendentals, - /// `metal2vulkan-degrade-native-division`. + /// [`PrecisionNote::NativeDivision`]. NativeDivision, - /// `metal2vulkan-degrade-native-fma`. + /// [`PrecisionNote::NativeFma`]. NativeFma, - /// `metal2vulkan-degrade-device-texel-conversion`. + /// [`PrecisionNote::DeviceTexelConversion`]. DeviceTexelConversion, - /// `metal2vulkan-degrade-device-vertex-conversion`. + /// [`PrecisionNote::DeviceVertexConversion`]. DeviceVertexConversion, - /// `metal2vulkan-degrade-native-half-conversion`. + /// [`PrecisionNote::NativeHalfConversion`]. NativeHalfConversion, - /// `metal2vulkan-degrade-native-half-quantize`. + /// [`PrecisionNote::NativeHalfQuantize`]. NativeHalfQuantize, - /// `metal2vulkan-degrade-native-nan-encoding`. + /// [`PrecisionNote::NativeNanEncoding`]. NativeNanEncoding, - /// `metal2vulkan-degrade-native-min-max`. + /// [`PrecisionNote::NativeMinMax`]. NativeMinMax, - /// `metal2vulkan-degrade-native-dot`. + /// [`PrecisionNote::NativeDot`]. NativeDot, - /// `metal2vulkan-degrade-native-mix`. + /// [`PrecisionNote::NativeMix`]. NativeMix, - /// `metal2vulkan-degrade-device-pack-conversion`. + /// [`PrecisionNote::DevicePackConversion`]. DevicePackConversion, - /// `metal2vulkan-degrade-tessellation-triangle-order`. + /// [`PrecisionNote::TessellationTriangleOrder`]. TessellationTriangleOrder, - /// `metal2vulkan-degrade-unmeasured-group-speculation`. + /// [`PrecisionNote::UnmeasuredGroupSpeculation`]. UnmeasuredGroupSpeculation, - /// `metal2vulkan-degrade-device-sample-level`. + /// [`PrecisionNote::DeviceSampleLevel`]. DeviceSampleLevel, - /// `metal2vulkan-degrade-coverage-reads-rounded-alpha`. + /// [`PrecisionNote::CoverageReadsRoundedAlpha`]. CoverageReadsRoundedAlpha, - /// `metal2vulkan-degrade-device-alpha-coverage`. + /// [`PrecisionNote::DeviceAlphaCoverage`]. DeviceAlphaCoverage, - /// `metal2vulkan-degrade-unordered-fetch-within-draw`. + /// [`PrecisionNote::UnorderedFetchWithinDraw`]. UnorderedFetchWithinDraw, - /// `metal2vulkan-degrade-native-logic-operation`. + /// [`PrecisionNote::NativeLogicOperation`]. NativeLogicOperation, - /// `metal2vulkan-degrade-device-depth-bias`. + /// [`PrecisionNote::DeviceDepthBias`]. DeviceDepthBias, - /// `metal2vulkan-degrade-swizzled-opaque-black-border`. + /// [`PrecisionNote::SwizzledOpaqueBlackBorder`]. SwizzledOpaqueBlackBorder, - /// `metal2vulkan-degrade-device-line-rasterization`. + /// [`PrecisionNote::DeviceLineRasterization`]. DeviceLineRasterization, - /// `metal2vulkan-degrade-device-fragment-runs`. + /// [`PrecisionNote::DeviceFragmentRuns`]. DeviceFragmentRuns, - /// `metal2vulkan-degrade-device-occlusion-count`. + /// [`PrecisionNote::DeviceOcclusionCount`]. DeviceOcclusionCount, - /// `metal2vulkan-degrade-vertex-simdgroup-grouping`. + /// [`PrecisionNote::VertexSimdgroupGrouping`]. VertexSimdgroupGrouping, - /// `metal2vulkan-degrade-restricted-depth-upload`. + /// [`PrecisionNote::RestrictedDepthUpload`]. RestrictedDepthUpload, - /// `metal2vulkan-degrade-stencil-output-overlap`. + /// [`PrecisionNote::StencilOutputOverlap`]. StencilOutputOverlap, - /// `metal2vulkan-degrade-device-half-denormals`. + /// [`PrecisionNote::DeviceHalfDenormals`]. DeviceHalfDenormals, } @@ -267,134 +268,100 @@ impl Degradation { Degradation::DeviceHalfDenormals, ]; - /// The kind's code, `metal2vulkan-degrade-`. + /// The kind's code, `metal2vulkan-degrade-`: its precision note's, which the translator + /// states ([`PrecisionNote::code`]). pub const fn code(self) -> &'static str { + self.note().code() + } + + /// The precision note the kind is: [`Degradation::from_precision_note`] taken back. + pub const fn note(self) -> PrecisionNote { match self { - Degradation::DeviceRoundedResolve => "metal2vulkan-degrade-device-rounded-resolve", - Degradation::DeviceReconvergence => "metal2vulkan-degrade-device-reconvergence", - Degradation::SimdgroupAccessOrder => "metal2vulkan-degrade-simdgroup-access-order", - Degradation::DeviceFilteredMipmaps => "metal2vulkan-degrade-device-filtered-mipmaps", - Degradation::CappedLodBias => "metal2vulkan-degrade-capped-lod-bias", - Degradation::SnormMinimumKept => "metal2vulkan-degrade-snorm-minimum-kept", - Degradation::SharedExponentKept => "metal2vulkan-degrade-shared-exponent-kept", - Degradation::CompressedTexelDecode => "metal2vulkan-degrade-compressed-texel-decode", - Degradation::DepthDenormals => "metal2vulkan-degrade-depth-denormals", - Degradation::F16FmaDoubleRounding => "metal2vulkan-degrade-f16-fma-double-rounding", - Degradation::F16IntConvDoubleRounding => { - "metal2vulkan-degrade-f16-int-conv-double-rounding" - } - Degradation::GradFromBias => "metal2vulkan-degrade-grad-from-bias", - Degradation::DeviceTranscendentals => "metal2vulkan-degrade-device-transcendentals", - Degradation::ReductionOrder => "metal2vulkan-degrade-reduction-order", - Degradation::DeviceDenormals => "metal2vulkan-degrade-device-denormals", - Degradation::PixelSamplerScaling => "metal2vulkan-degrade-pixel-sampler-scaling", - Degradation::DeviceArithmetic => "metal2vulkan-degrade-device-arithmetic", - Degradation::DeviceSignedZeroInfNan => { - "metal2vulkan-degrade-device-signed-zero-inf-nan" - } - Degradation::DeviceRayIntersection => "metal2vulkan-degrade-device-ray-intersection", - Degradation::FastMathRewrites => "metal2vulkan-degrade-fast-math-rewrites", - Degradation::TessellationWinding => "metal2vulkan-degrade-tessellation-winding", + Degradation::DeviceRoundedResolve => PrecisionNote::DeviceRoundedResolve, + Degradation::DeviceReconvergence => PrecisionNote::DeviceReconvergence, + Degradation::SimdgroupAccessOrder => PrecisionNote::SimdgroupAccessOrder, + Degradation::DeviceFilteredMipmaps => PrecisionNote::DeviceFilteredMipmaps, + Degradation::CappedLodBias => PrecisionNote::CappedLodBias, + Degradation::SnormMinimumKept => PrecisionNote::SnormMinimumKept, + Degradation::SharedExponentKept => PrecisionNote::SharedExponentKept, + Degradation::CompressedTexelDecode => PrecisionNote::CompressedTexelDecode, + Degradation::DepthDenormals => PrecisionNote::DepthDenormals, + Degradation::F16FmaDoubleRounding => PrecisionNote::F16FmaDoubleRounding, + Degradation::F16IntConvDoubleRounding => PrecisionNote::F16IntConvDoubleRounding, + Degradation::GradFromBias => PrecisionNote::GradFromBias, + Degradation::DeviceTranscendentals => PrecisionNote::DeviceTranscendentals, + Degradation::ReductionOrder => PrecisionNote::ReductionOrder, + Degradation::DeviceDenormals => PrecisionNote::DeviceDenormals, + Degradation::PixelSamplerScaling => PrecisionNote::PixelSamplerScaling, + Degradation::DeviceArithmetic => PrecisionNote::DeviceArithmetic, + Degradation::DeviceSignedZeroInfNan => PrecisionNote::DeviceSignedZeroInfNan, + Degradation::DeviceRayIntersection => PrecisionNote::DeviceRayIntersection, + Degradation::FastMathRewrites => PrecisionNote::FastMathRewrites, + Degradation::TessellationWinding => PrecisionNote::TessellationWinding, Degradation::TessellationFractionalSpacing => { - "metal2vulkan-degrade-tessellation-fractional-spacing" + PrecisionNote::TessellationFractionalSpacing } - Degradation::TessellationFactorEdgeCases => { - "metal2vulkan-degrade-tessellation-factor-edge-cases" - } - Degradation::TessellationFactorScale => { - "metal2vulkan-degrade-tessellation-factor-scale" - } - Degradation::TessellationFactorInstance => { - "metal2vulkan-degrade-tessellation-factor-instance" - } - Degradation::Fp8Value => "metal2vulkan-degrade-fp8-value", - Degradation::MultisamplePosition => "metal2vulkan-degrade-multisample-position", - Degradation::BicubicFilterArithmetic => { - "metal2vulkan-degrade-bicubic-filter-arithmetic" - } - Degradation::SparseResidency => "metal2vulkan-degrade-sparse-residency", - Degradation::DeviceNanEncoding => "metal2vulkan-degrade-device-nan-encoding", - Degradation::RestrictedDepthRange => "metal2vulkan-degrade-restricted-depth-range", - Degradation::CubeGradientFootprint => "metal2vulkan-degrade-cube-gradient-footprint", - Degradation::HalfTexelConversion => "metal2vulkan-degrade-half-texel-conversion", - Degradation::SrgbTexelDecode => "metal2vulkan-degrade-srgb-texel-decode", - Degradation::FunctionStorageAssumed => "metal2vulkan-degrade-function-storage-assumed", - Degradation::QuadsCountedBeforeDiscard => { - "metal2vulkan-degrade-quads-counted-before-discard" - } - Degradation::ViewBaseTexelOffset => "metal2vulkan-degrade-view-base-texel-offset", - Degradation::DeviceColorConversion => "metal2vulkan-degrade-device-color-conversion", - Degradation::DeviceInterpolation => "metal2vulkan-degrade-device-interpolation", - Degradation::DeviceInterpolationOffset => { - "metal2vulkan-degrade-device-interpolation-offset" - } - Degradation::ExtrapolatedInterpolation => { - "metal2vulkan-degrade-extrapolated-interpolation" - } - Degradation::QuadsSplitByClipping => "metal2vulkan-degrade-quads-split-by-clipping", - Degradation::FragmentSimdgroupGrouping => { - "metal2vulkan-degrade-fragment-simdgroup-grouping" - } - Degradation::BlendedWriteRounding => "metal2vulkan-degrade-blended-write-rounding", - Degradation::RotatedBlendRounding => "metal2vulkan-degrade-rotated-blend-rounding", - Degradation::LinkedSamplerNumbering => "metal2vulkan-degrade-linked-sampler-numbering", - Degradation::ArgumentPixelSamplerScaling => { - "metal2vulkan-degrade-argument-pixel-sampler-scaling" - } - Degradation::HalfOutputPrecision => "metal2vulkan-degrade-half-output-precision", - Degradation::AnisotropicFilter => "metal2vulkan-degrade-anisotropic-filter", - Degradation::DeviceAnisotropicFilter => { - "metal2vulkan-degrade-device-anisotropic-filter" - } - Degradation::DevicePointSize => "metal2vulkan-degrade-device-point-size", - Degradation::ClippedCoverageSplit => "metal2vulkan-degrade-clipped-coverage-split", - Degradation::LoopedSampleOutputs => "metal2vulkan-degrade-looped-sample-outputs", - Degradation::HalfOutputFastMathBlend => { - "metal2vulkan-degrade-half-output-fast-math-blend" - } - Degradation::DeviceSampling => "metal2vulkan-degrade-device-sampling", - Degradation::NativeTranscendentals => "metal2vulkan-degrade-native-transcendentals", - Degradation::NativeDivision => "metal2vulkan-degrade-native-division", - Degradation::NativeFma => "metal2vulkan-degrade-native-fma", - Degradation::DeviceTexelConversion => "metal2vulkan-degrade-device-texel-conversion", - Degradation::DeviceVertexConversion => "metal2vulkan-degrade-device-vertex-conversion", - Degradation::NativeHalfConversion => "metal2vulkan-degrade-native-half-conversion", - Degradation::NativeHalfQuantize => "metal2vulkan-degrade-native-half-quantize", - Degradation::NativeNanEncoding => "metal2vulkan-degrade-native-nan-encoding", - Degradation::NativeMinMax => "metal2vulkan-degrade-native-min-max", - Degradation::NativeDot => "metal2vulkan-degrade-native-dot", - Degradation::NativeMix => "metal2vulkan-degrade-native-mix", - Degradation::DevicePackConversion => "metal2vulkan-degrade-device-pack-conversion", - Degradation::TessellationTriangleOrder => { - "metal2vulkan-degrade-tessellation-triangle-order" - } - Degradation::UnmeasuredGroupSpeculation => { - "metal2vulkan-degrade-unmeasured-group-speculation" - } - Degradation::DeviceSampleLevel => "metal2vulkan-degrade-device-sample-level", - Degradation::CoverageReadsRoundedAlpha => { - "metal2vulkan-degrade-coverage-reads-rounded-alpha" - } - Degradation::DeviceAlphaCoverage => "metal2vulkan-degrade-device-alpha-coverage", - Degradation::UnorderedFetchWithinDraw => { - "metal2vulkan-degrade-unordered-fetch-within-draw" - } - Degradation::NativeLogicOperation => "metal2vulkan-degrade-native-logic-operation", - Degradation::DeviceDepthBias => "metal2vulkan-degrade-device-depth-bias", - Degradation::SwizzledOpaqueBlackBorder => { - "metal2vulkan-degrade-swizzled-opaque-black-border" - } - Degradation::DeviceLineRasterization => { - "metal2vulkan-degrade-device-line-rasterization" - } - Degradation::DeviceFragmentRuns => "metal2vulkan-degrade-device-fragment-runs", - Degradation::DeviceOcclusionCount => "metal2vulkan-degrade-device-occlusion-count", - Degradation::VertexSimdgroupGrouping => { - "metal2vulkan-degrade-vertex-simdgroup-grouping" - } - Degradation::RestrictedDepthUpload => "metal2vulkan-degrade-restricted-depth-upload", - Degradation::StencilOutputOverlap => "metal2vulkan-degrade-stencil-output-overlap", - Degradation::DeviceHalfDenormals => "metal2vulkan-degrade-device-half-denormals", + Degradation::TessellationFactorEdgeCases => PrecisionNote::TessellationFactorEdgeCases, + Degradation::TessellationFactorScale => PrecisionNote::TessellationFactorScale, + Degradation::TessellationFactorInstance => PrecisionNote::TessellationFactorInstance, + Degradation::Fp8Value => PrecisionNote::Fp8Value, + Degradation::MultisamplePosition => PrecisionNote::MultisamplePosition, + Degradation::BicubicFilterArithmetic => PrecisionNote::BicubicFilterArithmetic, + Degradation::SparseResidency => PrecisionNote::SparseResidency, + Degradation::DeviceNanEncoding => PrecisionNote::DeviceNanEncoding, + Degradation::RestrictedDepthRange => PrecisionNote::RestrictedDepthRange, + Degradation::CubeGradientFootprint => PrecisionNote::CubeGradientFootprint, + Degradation::HalfTexelConversion => PrecisionNote::HalfTexelConversion, + Degradation::SrgbTexelDecode => PrecisionNote::SrgbTexelDecode, + Degradation::FunctionStorageAssumed => PrecisionNote::FunctionStorageAssumed, + Degradation::QuadsCountedBeforeDiscard => PrecisionNote::QuadsCountedBeforeDiscard, + Degradation::ViewBaseTexelOffset => PrecisionNote::ViewBaseTexelOffset, + Degradation::DeviceColorConversion => PrecisionNote::DeviceColorConversion, + Degradation::DeviceInterpolation => PrecisionNote::DeviceInterpolation, + Degradation::DeviceInterpolationOffset => PrecisionNote::DeviceInterpolationOffset, + Degradation::ExtrapolatedInterpolation => PrecisionNote::ExtrapolatedInterpolation, + Degradation::QuadsSplitByClipping => PrecisionNote::QuadsSplitByClipping, + Degradation::FragmentSimdgroupGrouping => PrecisionNote::FragmentSimdgroupGrouping, + Degradation::BlendedWriteRounding => PrecisionNote::BlendedWriteRounding, + Degradation::RotatedBlendRounding => PrecisionNote::RotatedBlendRounding, + Degradation::LinkedSamplerNumbering => PrecisionNote::LinkedSamplerNumbering, + Degradation::ArgumentPixelSamplerScaling => PrecisionNote::ArgumentPixelSamplerScaling, + Degradation::HalfOutputPrecision => PrecisionNote::HalfOutputPrecision, + Degradation::AnisotropicFilter => PrecisionNote::AnisotropicFilter, + Degradation::DeviceAnisotropicFilter => PrecisionNote::DeviceAnisotropicFilter, + Degradation::DevicePointSize => PrecisionNote::DevicePointSize, + Degradation::ClippedCoverageSplit => PrecisionNote::ClippedCoverageSplit, + Degradation::LoopedSampleOutputs => PrecisionNote::LoopedSampleOutputs, + Degradation::HalfOutputFastMathBlend => PrecisionNote::HalfOutputFastMathBlend, + Degradation::DeviceSampling => PrecisionNote::DeviceSampling, + Degradation::NativeTranscendentals => PrecisionNote::NativeTranscendentals, + Degradation::NativeDivision => PrecisionNote::NativeDivision, + Degradation::NativeFma => PrecisionNote::NativeFma, + Degradation::DeviceTexelConversion => PrecisionNote::DeviceTexelConversion, + Degradation::DeviceVertexConversion => PrecisionNote::DeviceVertexConversion, + Degradation::NativeHalfConversion => PrecisionNote::NativeHalfConversion, + Degradation::NativeHalfQuantize => PrecisionNote::NativeHalfQuantize, + Degradation::NativeNanEncoding => PrecisionNote::NativeNanEncoding, + Degradation::NativeMinMax => PrecisionNote::NativeMinMax, + Degradation::NativeDot => PrecisionNote::NativeDot, + Degradation::NativeMix => PrecisionNote::NativeMix, + Degradation::DevicePackConversion => PrecisionNote::DevicePackConversion, + Degradation::TessellationTriangleOrder => PrecisionNote::TessellationTriangleOrder, + Degradation::UnmeasuredGroupSpeculation => PrecisionNote::UnmeasuredGroupSpeculation, + Degradation::DeviceSampleLevel => PrecisionNote::DeviceSampleLevel, + Degradation::CoverageReadsRoundedAlpha => PrecisionNote::CoverageReadsRoundedAlpha, + Degradation::DeviceAlphaCoverage => PrecisionNote::DeviceAlphaCoverage, + Degradation::UnorderedFetchWithinDraw => PrecisionNote::UnorderedFetchWithinDraw, + Degradation::NativeLogicOperation => PrecisionNote::NativeLogicOperation, + Degradation::DeviceDepthBias => PrecisionNote::DeviceDepthBias, + Degradation::SwizzledOpaqueBlackBorder => PrecisionNote::SwizzledOpaqueBlackBorder, + Degradation::DeviceLineRasterization => PrecisionNote::DeviceLineRasterization, + Degradation::DeviceFragmentRuns => PrecisionNote::DeviceFragmentRuns, + Degradation::DeviceOcclusionCount => PrecisionNote::DeviceOcclusionCount, + Degradation::VertexSimdgroupGrouping => PrecisionNote::VertexSimdgroupGrouping, + Degradation::RestrictedDepthUpload => PrecisionNote::RestrictedDepthUpload, + Degradation::StencilOutputOverlap => PrecisionNote::StencilOutputOverlap, + Degradation::DeviceHalfDenormals => PrecisionNote::DeviceHalfDenormals, } } diff --git a/crates/metal2vulkan-conformance/src/tests.rs b/crates/metal2vulkan-conformance/src/tests.rs index 4674f7375..03c40813e 100644 --- a/crates/metal2vulkan-conformance/src/tests.rs +++ b/crates/metal2vulkan-conformance/src/tests.rs @@ -1051,6 +1051,16 @@ fn one_word_moving_names_its_row_and_index() { assert!(printed.contains("Metal 3"), "{printed}"); } +/// Each kind is one precision note's: [`Degradation::note`] takes +/// [`Degradation::from_precision_note`] back, so a kind's code is its note's +/// (`PrecisionNote::code`). +#[test] +fn every_kind_is_its_notes_kind() { + for &kind in Degradation::ALL { + assert_eq!(Degradation::from_precision_note(kind.note()), kind); + } +} + /// Every kind a case can name is a precision note's: `docs/API.md` section 9, the catalogue of /// the notes the runtime carries, lists its code. The runtime's side announces only the codes of /// those notes, so a kind outside the catalogue would never be announced, and a case that diff --git a/crates/metal2vulkan/src/pipeline/api_tests.rs b/crates/metal2vulkan/src/pipeline/api_tests.rs index c8880d6ed..ca2b684e6 100644 --- a/crates/metal2vulkan/src/pipeline/api_tests.rs +++ b/crates/metal2vulkan/src/pipeline/api_tests.rs @@ -744,3 +744,44 @@ fn descriptor_and_library_serde_round_trips() { #[cfg(feature = "serde")] mod bind_serde_round_trips {} + +/// Every precision note's code is `metal2vulkan-degrade-` and the note's name in kebab case, and +/// no two notes share one. The names are read from the enum's source, each note made from its +/// name through serde, so a note added to the enum is checked with no list to extend. +#[cfg(feature = "serde")] +#[test] +fn every_precision_note_code_is_its_name_in_kebab_case() { + let source = include_str!("artifact.rs"); + let start = source.find("pub enum PrecisionNote {").expect("the enum"); + let body = &source[start..]; + let body = &body[..body.find("\n}\n").expect("the enum's end")]; + let mut codes = std::collections::BTreeSet::new(); + for line in body.lines().skip(1) { + let Some(name) = line.strip_prefix(" ").and_then(|l| l.strip_suffix(',')) else { + continue; + }; + if !name.starts_with(|c: char| c.is_ascii_uppercase()) + || !name.chars().all(|c| c.is_ascii_alphanumeric()) + { + continue; + } + let note: PrecisionNote = + serde_json::from_str(&format!("\"{name}\"")).expect("a variant's name"); + let mut kebab = String::new(); + let mut after_lower = false; + for c in name.chars() { + if c.is_ascii_uppercase() && after_lower { + kebab.push('-'); + } + after_lower = c.is_ascii_lowercase() || c.is_ascii_digit(); + kebab.push(c.to_ascii_lowercase()); + } + assert_eq!( + note.code(), + format!("metal2vulkan-degrade-{kebab}"), + "{name}" + ); + assert!(codes.insert(note.code()), "{name}: a code another note has"); + } + assert!(!codes.is_empty(), "no variant read from the enum's source"); +} diff --git a/crates/metal2vulkan/src/pipeline/artifact.rs b/crates/metal2vulkan/src/pipeline/artifact.rs index 405138e04..24625593a 100644 --- a/crates/metal2vulkan/src/pipeline/artifact.rs +++ b/crates/metal2vulkan/src/pipeline/artifact.rs @@ -2190,6 +2190,148 @@ pub enum PrecisionNote { DeviceHalfDenormals, } +impl PrecisionNote { + /// The note's stable code, `metal2vulkan-degrade-` and the note's name in kebab case + /// (`NativeFma` is `metal2vulkan-degrade-native-fma`): the name `docs/API.md`'s catalogue of + /// degrade notices gives it, and the one a caller announces it by. `metal2vulkan-runtime` + /// records each state's notes at the state's creation and announces none itself. + pub const fn code(self) -> &'static str { + match self { + PrecisionNote::F16FmaDoubleRounding => "metal2vulkan-degrade-f16-fma-double-rounding", + PrecisionNote::F16IntConvDoubleRounding => { + "metal2vulkan-degrade-f16-int-conv-double-rounding" + } + PrecisionNote::GradFromBias => "metal2vulkan-degrade-grad-from-bias", + PrecisionNote::DeviceTranscendentals => "metal2vulkan-degrade-device-transcendentals", + PrecisionNote::ReductionOrder => "metal2vulkan-degrade-reduction-order", + PrecisionNote::DeviceDenormals => "metal2vulkan-degrade-device-denormals", + PrecisionNote::PixelSamplerScaling => "metal2vulkan-degrade-pixel-sampler-scaling", + PrecisionNote::DeviceArithmetic => "metal2vulkan-degrade-device-arithmetic", + PrecisionNote::DeviceSignedZeroInfNan => { + "metal2vulkan-degrade-device-signed-zero-inf-nan" + } + PrecisionNote::DeviceRayIntersection => "metal2vulkan-degrade-device-ray-intersection", + PrecisionNote::FastMathRewrites => "metal2vulkan-degrade-fast-math-rewrites", + PrecisionNote::TessellationWinding => "metal2vulkan-degrade-tessellation-winding", + PrecisionNote::TessellationFactorEdgeCases => { + "metal2vulkan-degrade-tessellation-factor-edge-cases" + } + PrecisionNote::TessellationFactorScale => { + "metal2vulkan-degrade-tessellation-factor-scale" + } + PrecisionNote::TessellationFactorInstance => { + "metal2vulkan-degrade-tessellation-factor-instance" + } + PrecisionNote::TessellationFractionalSpacing => { + "metal2vulkan-degrade-tessellation-fractional-spacing" + } + PrecisionNote::Fp8Value => "metal2vulkan-degrade-fp8-value", + PrecisionNote::MultisamplePosition => "metal2vulkan-degrade-multisample-position", + PrecisionNote::BicubicFilterArithmetic => { + "metal2vulkan-degrade-bicubic-filter-arithmetic" + } + PrecisionNote::SparseResidency => "metal2vulkan-degrade-sparse-residency", + PrecisionNote::DeviceNanEncoding => "metal2vulkan-degrade-device-nan-encoding", + PrecisionNote::RestrictedDepthRange => "metal2vulkan-degrade-restricted-depth-range", + PrecisionNote::CubeGradientFootprint => "metal2vulkan-degrade-cube-gradient-footprint", + PrecisionNote::HalfTexelConversion => "metal2vulkan-degrade-half-texel-conversion", + PrecisionNote::SrgbTexelDecode => "metal2vulkan-degrade-srgb-texel-decode", + PrecisionNote::FunctionStorageAssumed => { + "metal2vulkan-degrade-function-storage-assumed" + } + PrecisionNote::QuadsCountedBeforeDiscard => { + "metal2vulkan-degrade-quads-counted-before-discard" + } + PrecisionNote::ViewBaseTexelOffset => "metal2vulkan-degrade-view-base-texel-offset", + PrecisionNote::DeviceColorConversion => "metal2vulkan-degrade-device-color-conversion", + PrecisionNote::DeviceInterpolation => "metal2vulkan-degrade-device-interpolation", + PrecisionNote::QuadsSplitByClipping => "metal2vulkan-degrade-quads-split-by-clipping", + PrecisionNote::FragmentSimdgroupGrouping => { + "metal2vulkan-degrade-fragment-simdgroup-grouping" + } + PrecisionNote::BlendedWriteRounding => "metal2vulkan-degrade-blended-write-rounding", + PrecisionNote::RotatedBlendRounding => "metal2vulkan-degrade-rotated-blend-rounding", + PrecisionNote::LinkedSamplerNumbering => { + "metal2vulkan-degrade-linked-sampler-numbering" + } + PrecisionNote::ArgumentPixelSamplerScaling => { + "metal2vulkan-degrade-argument-pixel-sampler-scaling" + } + PrecisionNote::HalfOutputPrecision => "metal2vulkan-degrade-half-output-precision", + PrecisionNote::AnisotropicFilter => "metal2vulkan-degrade-anisotropic-filter", + PrecisionNote::DeviceAnisotropicFilter => { + "metal2vulkan-degrade-device-anisotropic-filter" + } + PrecisionNote::DevicePointSize => "metal2vulkan-degrade-device-point-size", + PrecisionNote::ClippedCoverageSplit => "metal2vulkan-degrade-clipped-coverage-split", + PrecisionNote::LoopedSampleOutputs => "metal2vulkan-degrade-looped-sample-outputs", + PrecisionNote::HalfOutputFastMathBlend => { + "metal2vulkan-degrade-half-output-fast-math-blend" + } + PrecisionNote::DeviceSampling => "metal2vulkan-degrade-device-sampling", + PrecisionNote::NativeTranscendentals => "metal2vulkan-degrade-native-transcendentals", + PrecisionNote::NativeDivision => "metal2vulkan-degrade-native-division", + PrecisionNote::NativeFma => "metal2vulkan-degrade-native-fma", + PrecisionNote::DeviceTexelConversion => "metal2vulkan-degrade-device-texel-conversion", + PrecisionNote::DeviceVertexConversion => { + "metal2vulkan-degrade-device-vertex-conversion" + } + PrecisionNote::NativeHalfConversion => "metal2vulkan-degrade-native-half-conversion", + PrecisionNote::NativeHalfQuantize => "metal2vulkan-degrade-native-half-quantize", + PrecisionNote::NativeNanEncoding => "metal2vulkan-degrade-native-nan-encoding", + PrecisionNote::NativeMinMax => "metal2vulkan-degrade-native-min-max", + PrecisionNote::NativeDot => "metal2vulkan-degrade-native-dot", + PrecisionNote::NativeMix => "metal2vulkan-degrade-native-mix", + PrecisionNote::DevicePackConversion => "metal2vulkan-degrade-device-pack-conversion", + PrecisionNote::TessellationTriangleOrder => { + "metal2vulkan-degrade-tessellation-triangle-order" + } + PrecisionNote::UnmeasuredGroupSpeculation => { + "metal2vulkan-degrade-unmeasured-group-speculation" + } + PrecisionNote::DeviceSampleLevel => "metal2vulkan-degrade-device-sample-level", + PrecisionNote::CoverageReadsRoundedAlpha => { + "metal2vulkan-degrade-coverage-reads-rounded-alpha" + } + PrecisionNote::DeviceAlphaCoverage => "metal2vulkan-degrade-device-alpha-coverage", + PrecisionNote::DeviceInterpolationOffset => { + "metal2vulkan-degrade-device-interpolation-offset" + } + PrecisionNote::ExtrapolatedInterpolation => { + "metal2vulkan-degrade-extrapolated-interpolation" + } + PrecisionNote::UnorderedFetchWithinDraw => { + "metal2vulkan-degrade-unordered-fetch-within-draw" + } + PrecisionNote::NativeLogicOperation => "metal2vulkan-degrade-native-logic-operation", + PrecisionNote::CappedLodBias => "metal2vulkan-degrade-capped-lod-bias", + PrecisionNote::DeviceReconvergence => "metal2vulkan-degrade-device-reconvergence", + PrecisionNote::SimdgroupAccessOrder => "metal2vulkan-degrade-simdgroup-access-order", + PrecisionNote::SnormMinimumKept => "metal2vulkan-degrade-snorm-minimum-kept", + PrecisionNote::DeviceDepthBias => "metal2vulkan-degrade-device-depth-bias", + PrecisionNote::DepthDenormals => "metal2vulkan-degrade-depth-denormals", + PrecisionNote::DeviceFilteredMipmaps => "metal2vulkan-degrade-device-filtered-mipmaps", + PrecisionNote::DeviceRoundedResolve => "metal2vulkan-degrade-device-rounded-resolve", + PrecisionNote::CompressedTexelDecode => "metal2vulkan-degrade-compressed-texel-decode", + PrecisionNote::SharedExponentKept => "metal2vulkan-degrade-shared-exponent-kept", + PrecisionNote::SwizzledOpaqueBlackBorder => { + "metal2vulkan-degrade-swizzled-opaque-black-border" + } + PrecisionNote::DeviceLineRasterization => { + "metal2vulkan-degrade-device-line-rasterization" + } + PrecisionNote::DeviceFragmentRuns => "metal2vulkan-degrade-device-fragment-runs", + PrecisionNote::DeviceOcclusionCount => "metal2vulkan-degrade-device-occlusion-count", + PrecisionNote::VertexSimdgroupGrouping => { + "metal2vulkan-degrade-vertex-simdgroup-grouping" + } + PrecisionNote::RestrictedDepthUpload => "metal2vulkan-degrade-restricted-depth-upload", + PrecisionNote::StencilOutputOverlap => "metal2vulkan-degrade-stencil-output-overlap", + PrecisionNote::DeviceHalfDenormals => "metal2vulkan-degrade-device-half-denormals", + } + } +} + /// Which lowering strategies a module used, with their word costs. /// /// Keys name `Strategy` variants (`Family::Variant`) for reporting only; translation never reads diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index 5ce88fd32..1bd087d9d 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -6168,6 +6168,7 @@ method metal2vulkan-runtime::MemoryClass::block_len pub const fn block_len(self) method metal2vulkan-runtime::PhysicalDevice::check pub fn check(&self) -> Result method metal2vulkan-runtime::PhysicalDevice::raw pub fn raw(&self) -> vk::PhysicalDevice method metal2vulkan-runtime::PixelFormatInfo::describes_a_format pub fn describes_a_format(&self) -> bool +method metal2vulkan-runtime::PrecisionNote::code pub const fn code(self) -> &'static str method metal2vulkan-runtime::PrecisionNote::of_float_operator pub fn of_float_operator(op: AirBin, width: FloatWidth, fmf: FastMath, p: &DeviceProfile) -> Option> method metal2vulkan-runtime::PrecisionNote::of_math_call pub fn of_math_call(call: Math, fmf: FastMath, p: &DeviceProfile) -> Option> method metal2vulkan-runtime::Refusal::basis pub fn basis(self) -> RefusalBasis @@ -6643,6 +6644,7 @@ method metal2vulkan::pipeline::MeshPipelineDescriptor::reflection pub fn reflect method metal2vulkan::pipeline::MeshPipelineDescriptor::slot_writes pub fn slot_writes(&self, budget: &crate::Budget) -> Result method metal2vulkan::pipeline::MeshPipelineDescriptor::stages_using_direct_arguments pub fn stages_using_direct_arguments(&self, budget: &crate::Budget, entries: &StageEntries) -> Result, Error> method metal2vulkan::pipeline::MeshPipelineDescriptor::unwritten_fragment_inputs pub fn unwritten_fragment_inputs(&self, budget: &crate::Budget, entries: &StageEntries) -> Result, Error> +method metal2vulkan::pipeline::PrecisionNote::code pub const fn code(self) -> &'static str method metal2vulkan::pipeline::PrecisionNote::of_float_operator pub fn of_float_operator(op: AirBin, width: FloatWidth, fmf: FastMath, p: &DeviceProfile) -> Option> method metal2vulkan::pipeline::PrecisionNote::of_math_call pub fn of_math_call(call: Math, fmf: FastMath, p: &DeviceProfile) -> Option> method metal2vulkan::pipeline::PrivateRenderState::new pub const fn new() -> PrivateRenderState diff --git a/docs/API.md b/docs/API.md index 4a335ee7e..4326e6102 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1615,10 +1615,10 @@ A note is never fatal: the work runs on every device. The runtime prints and sen consumer reads them through these items. The translator's own API gives a stage's notes (section 8). -Each entry below is named by a code, `metal2vulkan-degrade-` and the note's name in kebab case -(`PrecisionNote::NativeFma` is `metal2vulkan-degrade-native-fma`), with its category, and says what -makes an operation carry the note and what may differ. Each `PrecisionNote`'s rustdoc states its -bound. +Each entry below is named by a code (`PrecisionNote::code`), `metal2vulkan-degrade-` and the note's +name in kebab case (`PrecisionNote::NativeFma` is `metal2vulkan-degrade-native-fma`), with its +category, and says what makes an operation carry the note and what may differ. Each +`PrecisionNote`'s rustdoc states its bound. - `metal2vulkan-degrade-device-rounded-resolve` (precision). `DeviceRoundedResolve`: A multisample color resolve averages through Vulkan's `AVERAGE` mode, which leaves the rounding of the average