diff --git a/crates/metal2vulkan-conformance/known-gaps.tsv b/crates/metal2vulkan-conformance/known-gaps.tsv index 8fbeff725..7bca9adc4 100644 --- a/crates/metal2vulkan-conformance/known-gaps.tsv +++ b/crates/metal2vulkan-conformance/known-gaps.tsv @@ -723,9 +723,6 @@ pass-bytes-srgb-encode-sweep llvmpipe divergent case/output/words 772 elements d pixel-downscales-1000x1080 llvmpipe divergent case/output/frac/norm/digest the digest is 264ceee98d6179ad0db33d7a10d196da1c8db63673b939b97ad07d9f0dcb7716 on Metal and 5d64a9642dc61d423f57de864ce9146b20705bda466075d8184e60f995326fbe here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1000x1080 llvmpipe divergent case/output/frac/norm/head 996 elements differ (F32), the largest difference 0.0036765336990356445 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1000x1080 llvmpipe divergent case/output/frac/norm/tail 980 elements differ (F32), the largest difference 0.003676474094390869 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. -pixel-downscales-1000x1080 llvmpipe divergent case/output/frac/slot/digest the digest is 264ceee98d6179ad0db33d7a10d196da1c8db63673b939b97ad07d9f0dcb7716 on Metal and 5d64a9642dc61d423f57de864ce9146b20705bda466075d8184e60f995326fbe here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. -pixel-downscales-1000x1080 llvmpipe divergent case/output/frac/slot/head 996 elements differ (F32), the largest difference 0.0036765336990356445 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. -pixel-downscales-1000x1080 llvmpipe divergent case/output/frac/slot/tail 980 elements differ (F32), the largest difference 0.003676474094390869 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1000x1080 llvmpipe divergent case/output/grid/norm/digest the digest is 753599b580fcc1231f00e0642effc44f37955f75a7f16bb7a9d6647809548337 on Metal and bc18c64b2a7bc7e15ad218a491ccd99017d79e0c2f83618952f8bdce6efe5e72 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1000x1080 llvmpipe divergent case/output/grid/norm/head 882 elements differ (F32), the largest difference 0.003921598196029663 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1000x1080 llvmpipe divergent case/output/grid/norm/tail 878 elements differ (F32), the largest difference 0.003921627998352051 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. @@ -741,9 +738,7 @@ pixel-downscales-1000x1080 llvmpipe divergent case/output/ulp/slot/tail 878 elem pixel-downscales-1366x1080 llvmpipe divergent case/output/frac/norm/digest the digest is caec2fd9f40845412cc4b24c5e57d6eeabcbefdb6699695dc4a600b506c2244b on Metal and 35d9bb3790a5895e965ddaebbe8c0df0f8e68acb11f2b9a022723983e0bd71c4 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1366x1080 llvmpipe divergent case/output/frac/norm/head 984 elements differ (F32), the largest difference 0.0036764442920684814 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1366x1080 llvmpipe divergent case/output/frac/norm/tail 992 elements differ (F32), the largest difference 0.003431349992752075 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. -pixel-downscales-1366x1080 llvmpipe divergent case/output/frac/slot/digest the digest is caec2fd9f40845412cc4b24c5e57d6eeabcbefdb6699695dc4a600b506c2244b on Metal and 35d9bb3790a5895e965ddaebbe8c0df0f8e68acb11f2b9a022723983e0bd71c4 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1366x1080 llvmpipe divergent case/output/frac/slot/head 984 elements differ (F32), the largest difference 0.0036764442920684814 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. -pixel-downscales-1366x1080 llvmpipe divergent case/output/frac/slot/tail 992 elements differ (F32), the largest difference 0.003431349992752075 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1366x1080 llvmpipe divergent case/output/grid/norm/digest the digest is 9857ff78b453810e4bcec887963d8251ef38d34500d278515a13ec047b4fc2cc on Metal and 7521a6636883ba4cf4fdc1d2f5a459f1ee3a0367c151ee05b6767662477e3263 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1366x1080 llvmpipe divergent case/output/grid/norm/head 880 elements differ (F32), the largest difference 0.003921598196029663 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1366x1080 llvmpipe divergent case/output/grid/norm/tail 892 elements differ (F32), the largest difference 0.003921627998352051 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. @@ -759,8 +754,6 @@ pixel-downscales-1366x1080 llvmpipe divergent case/output/ulp/slot/tail 892 elem pixel-downscales-1440x1080 llvmpipe divergent case/output/frac/norm/digest the digest is fd36975bce4f3ede7a2c59afbd86c0691166679fc63791ba1cb086c99f3e2573 on Metal and cf481aa735efc3f4fe234dc4c7f4dfba84ff876cbef640e4a4945d8baab0e86b here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1440x1080 llvmpipe divergent case/output/frac/norm/head 993 elements differ (F32), the largest difference 0.003676474094390869 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1440x1080 llvmpipe divergent case/output/frac/norm/tail 985 elements differ (F32), the largest difference 0.0036764591932296753 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. -pixel-downscales-1440x1080 llvmpipe divergent case/output/frac/slot/digest the digest is fd36975bce4f3ede7a2c59afbd86c0691166679fc63791ba1cb086c99f3e2573 on Metal and cf481aa735efc3f4fe234dc4c7f4dfba84ff876cbef640e4a4945d8baab0e86b here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. -pixel-downscales-1440x1080 llvmpipe divergent case/output/frac/slot/head 993 elements differ (F32), the largest difference 0.003676474094390869 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1440x1080 llvmpipe divergent case/output/frac/slot/tail 985 elements differ (F32), the largest difference 0.0036764591932296753 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1440x1080 llvmpipe divergent case/output/grid/norm/digest the digest is e15c34bb8f1ca197ae85f64c43ad4d18c866d8b9640cf478c8ce02e7e4cf7236 on Metal and 472e9efc6a6bdc5b5e04cf14acdeebcabd020925c5aa8ec69c548d183b745aa9 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1440x1080 llvmpipe divergent case/output/grid/norm/head 869 elements differ (F32), the largest difference 0.003921598196029663 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. @@ -777,8 +770,6 @@ pixel-downscales-1440x1080 llvmpipe divergent case/output/ulp/slot/tail 887 elem pixel-downscales-1440x1152 llvmpipe divergent case/output/frac/norm/digest the digest is aa690279b927f7b00810a4f688eba29d013e134b258b7730c08e07ef72343c0d on Metal and c594bdf1db227638515219dc8cb9c4a184acfa264164e88883b9c75ca1143003 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1440x1152 llvmpipe divergent case/output/frac/norm/head 993 elements differ (F32), the largest difference 0.003676474094390869 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1440x1152 llvmpipe divergent case/output/frac/norm/tail 984 elements differ (F32), the largest difference 0.0039215087890625 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. -pixel-downscales-1440x1152 llvmpipe divergent case/output/frac/slot/digest the digest is aa690279b927f7b00810a4f688eba29d013e134b258b7730c08e07ef72343c0d on Metal and c594bdf1db227638515219dc8cb9c4a184acfa264164e88883b9c75ca1143003 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. -pixel-downscales-1440x1152 llvmpipe divergent case/output/frac/slot/head 993 elements differ (F32), the largest difference 0.003676474094390869 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1440x1152 llvmpipe divergent case/output/frac/slot/tail 984 elements differ (F32), the largest difference 0.0039215087890625 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1440x1152 llvmpipe divergent case/output/grid/norm/digest the digest is b99e5cd231a628f1fcf76fe1668db429c2827eb7733a363ef9a3a406bd83a88b on Metal and 4dcf0e7b2c29eeb6d02967f051df7a9bedcc672423e53666a82d3c4c6997c636 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1440x1152 llvmpipe divergent case/output/grid/norm/head 869 elements differ (F32), the largest difference 0.003921598196029663 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. @@ -795,9 +786,7 @@ pixel-downscales-1440x1152 llvmpipe divergent case/output/ulp/slot/tail 900 elem pixel-downscales-1536x1080 llvmpipe divergent case/output/frac/norm/digest the digest is 6c9baf4f13010e70a06f1a1c5a82f9328fd681892d2cabdee00e2f5feb6b9d8f on Metal and 9f6725bd40980c3daa435a22fab2cd14c1e60a0fba4c54ea8431655afba8f3cf here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1536x1080 llvmpipe divergent case/output/frac/norm/head 988 elements differ (F32), the largest difference 0.003676474094390869 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1536x1080 llvmpipe divergent case/output/frac/norm/tail 976 elements differ (F32), the largest difference 0.003431379795074463 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. -pixel-downscales-1536x1080 llvmpipe divergent case/output/frac/slot/digest the digest is 6c9baf4f13010e70a06f1a1c5a82f9328fd681892d2cabdee00e2f5feb6b9d8f on Metal and 9f6725bd40980c3daa435a22fab2cd14c1e60a0fba4c54ea8431655afba8f3cf here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1536x1080 llvmpipe divergent case/output/frac/slot/head 988 elements differ (F32), the largest difference 0.003676474094390869 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. -pixel-downscales-1536x1080 llvmpipe divergent case/output/frac/slot/tail 976 elements differ (F32), the largest difference 0.003431379795074463 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1536x1080 llvmpipe divergent case/output/grid/norm/digest the digest is 67e124800a21073ed1ed42534aa41ad81d37a759b62cd5fc57134fbcaf7bc32b on Metal and 8cf978e1b84d2a7db554cbd0bab0a3692eaeccd95b2ca57170a5c4d5375c1451 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1536x1080 llvmpipe divergent case/output/grid/norm/head 870 elements differ (F32), the largest difference 0.003921627998352051 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1536x1080 llvmpipe divergent case/output/grid/norm/tail 901 elements differ (F32), the largest difference 0.003921627998352051 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. @@ -813,7 +802,6 @@ pixel-downscales-1536x1080 llvmpipe divergent case/output/ulp/slot/tail 901 elem pixel-downscales-1536x1152 llvmpipe divergent case/output/frac/norm/digest the digest is 810ec665b6fef8901c943b832632d1ae5e7dc6e05b54e7536429d9420a9d5a14 on Metal and 8b47ba29780ce026aae6766e81a0d3fac4a5605c850e7175c50ebf7e94a513a5 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1536x1152 llvmpipe divergent case/output/frac/norm/head 988 elements differ (F32), the largest difference 0.003676474094390869 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1536x1152 llvmpipe divergent case/output/frac/norm/tail 990 elements differ (F32), the largest difference 0.003676474094390869 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. -pixel-downscales-1536x1152 llvmpipe divergent case/output/frac/slot/digest the digest is 810ec665b6fef8901c943b832632d1ae5e7dc6e05b54e7536429d9420a9d5a14 on Metal and 8b47ba29780ce026aae6766e81a0d3fac4a5605c850e7175c50ebf7e94a513a5 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1536x1152 llvmpipe divergent case/output/frac/slot/head 988 elements differ (F32), the largest difference 0.003676474094390869 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1536x1152 llvmpipe divergent case/output/frac/slot/tail 990 elements differ (F32), the largest difference 0.003676474094390869 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1536x1152 llvmpipe divergent case/output/grid/norm/digest the digest is a5a6cb0f7fd6c18020b95b55ecdbb589fef8b15512e6c87c63a47f4fe64f0b92 on Metal and 90d82a8abc6752f7a47f7737a670dfc9084f4e48cee467338893ecc95f03d354 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. @@ -831,8 +819,6 @@ pixel-downscales-1536x1152 llvmpipe divergent case/output/ulp/slot/tail 896 elem pixel-downscales-1920x1080 llvmpipe divergent case/output/frac/norm/digest the digest is 71d2afefba11442056055f137daa6eb529172022ea43bf43431f258eeb7181ed on Metal and e34bb384264df4a8e58eeba63bc8e43d8c3c5c79ad5918f7b7c3548955035809 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1920x1080 llvmpipe divergent case/output/frac/norm/head 990 elements differ (F32), the largest difference 0.003676488995552063 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1920x1080 llvmpipe divergent case/output/frac/norm/tail 982 elements differ (F32), the largest difference 0.0036765336990356445 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. -pixel-downscales-1920x1080 llvmpipe divergent case/output/frac/slot/digest the digest is 71d2afefba11442056055f137daa6eb529172022ea43bf43431f258eeb7181ed on Metal and e34bb384264df4a8e58eeba63bc8e43d8c3c5c79ad5918f7b7c3548955035809 here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. -pixel-downscales-1920x1080 llvmpipe divergent case/output/frac/slot/head 990 elements differ (F32), the largest difference 0.003676488995552063 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1920x1080 llvmpipe divergent case/output/frac/slot/tail 982 elements differ (F32), the largest difference 0.0036765336990356445 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1920x1080 llvmpipe divergent case/output/grid/norm/digest the digest is 48d428cb1852e5e54ac020269ad34f361f3816bfa1975384e1c1e3bef1b03387 on Metal and 6c0afd2c73bda45de44f88b2fa4a6b05d11189e85b47cf10436a9c44ec54af7c here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1920x1080 llvmpipe divergent case/output/grid/norm/head 883 elements differ (F32), the largest difference 0.003921627998352051 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. @@ -846,37 +832,15 @@ pixel-downscales-1920x1080 llvmpipe divergent case/output/ulp/norm/tail 905 elem pixel-downscales-1920x1080 llvmpipe divergent case/output/ulp/slot/digest the digest is 48d428cb1852e5e54ac020269ad34f361f3816bfa1975384e1c1e3bef1b03387 on Metal and 6c0afd2c73bda45de44f88b2fa4a6b05d11189e85b47cf10436a9c44ec54af7c here The digest of a linear-filtered downscale's output, which differs wherever the site's `head` and `tail` elements do: the case samples through the device's own filter and texel conversion (`device-sampling`, `device-texel-conversion`), the native-arithmetic contract's answer, and validation derives no tolerance from either. The neighbouring `head` and `tail` rows carry the bound. Open: nothing. pixel-downscales-1920x1080 llvmpipe divergent case/output/ulp/slot/head 883 elements differ (F32), the largest difference 0.003921627998352051 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. pixel-downscales-1920x1080 llvmpipe divergent case/output/ulp/slot/tail 905 elements differ (F32), the largest difference 0.003921627998352051 A linear-filtered downscale through the device's own sampler: the site's elements differ by at most one code of 1/255 (0.00392, to an `f32` ulp). `device-sampling` records the device's filter, whose measured bound on lavapipe is a linear filter's largest difference of 1.0 code of 1/255 (2D textures of one level), which this site reaches and does not pass; validation derives no tolerance from it. Open: nothing. -pixel-samplers-rgba16f-linear-border llvmpipe divergent case/output/arg the digest is a33152229f2a9e0a2cedd5edd958a262c214bd5b4a682110837f3523a6fe5deb on Metal and 0f14b514e5d467aef3403cf69e785fbdb67e5ea6e0bcc8380aa11daf8f58cc86 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba16f-linear-border llvmpipe divergent case/output/const the digest is a33152229f2a9e0a2cedd5edd958a262c214bd5b4a682110837f3523a6fe5deb on Metal and 0f14b514e5d467aef3403cf69e785fbdb67e5ea6e0bcc8380aa11daf8f58cc86 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba16f-linear-border llvmpipe divergent case/output/norm the digest is a33152229f2a9e0a2cedd5edd958a262c214bd5b4a682110837f3523a6fe5deb on Metal and 5f2e422783414f0441fa8b910cd36f5436691c4ce9d4106548574de31dcb6b60 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba16f-linear-border llvmpipe divergent case/output/slot the digest is a33152229f2a9e0a2cedd5edd958a262c214bd5b4a682110837f3523a6fe5deb on Metal and 0f14b514e5d467aef3403cf69e785fbdb67e5ea6e0bcc8380aa11daf8f58cc86 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba16f-linear-edge llvmpipe divergent case/output/arg the digest is 7a6a5f64bc4531517ba0d4d4912c2d687ee0779777af9376c02b5e09f4af2421 on Metal and cec558f08858cb210896dfcfb0e548154e27e166c2a4ddd701b6597385d7d6c5 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba16f-linear-edge llvmpipe divergent case/output/const the digest is 7a6a5f64bc4531517ba0d4d4912c2d687ee0779777af9376c02b5e09f4af2421 on Metal and cec558f08858cb210896dfcfb0e548154e27e166c2a4ddd701b6597385d7d6c5 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba16f-linear-edge llvmpipe divergent case/output/norm the digest is 7a6a5f64bc4531517ba0d4d4912c2d687ee0779777af9376c02b5e09f4af2421 on Metal and 50d151360bbbb1dd97754bc64a53cdea8c10c5cd6151614bb0b870fdab62c15f here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba16f-linear-edge llvmpipe divergent case/output/slot the digest is 7a6a5f64bc4531517ba0d4d4912c2d687ee0779777af9376c02b5e09f4af2421 on Metal and cec558f08858cb210896dfcfb0e548154e27e166c2a4ddd701b6597385d7d6c5 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba16f-linear-mirror llvmpipe divergent case/output/arg the digest is 24724e535ae68eaccd7460b0c8948ce18d3118bb92395b690d7c8918dc521e06 on Metal and f7d1e3dc4c2990ec3fbf777f6bea7284cc26ff08c07e818355290efd1e0f5d7a here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba16f-linear-mirror llvmpipe divergent case/output/norm the digest is 24724e535ae68eaccd7460b0c8948ce18d3118bb92395b690d7c8918dc521e06 on Metal and f0a7f28a6c471e47b31f77cd59a7666ef50d419714cb58c4c62584e13396b4db here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba16f-linear-mirror llvmpipe divergent case/output/slot the digest is 24724e535ae68eaccd7460b0c8948ce18d3118bb92395b690d7c8918dc521e06 on Metal and f7d1e3dc4c2990ec3fbf777f6bea7284cc26ff08c07e818355290efd1e0f5d7a here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba16f-linear-zero llvmpipe divergent case/output/arg the digest is a33152229f2a9e0a2cedd5edd958a262c214bd5b4a682110837f3523a6fe5deb on Metal and 0f14b514e5d467aef3403cf69e785fbdb67e5ea6e0bcc8380aa11daf8f58cc86 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba16f-linear-zero llvmpipe divergent case/output/const the digest is dbb87cfd8c4ab3c54dede294e5ebc42ad0a2fd84166cc1b46a33e3a3b61e1777 on Metal and 5e1a35998c6bf3061dea679596ea6eb037ed938011ddef5168c2a7c28b976f7b here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba16f-linear-zero llvmpipe divergent case/output/norm the digest is a33152229f2a9e0a2cedd5edd958a262c214bd5b4a682110837f3523a6fe5deb on Metal and 5f2e422783414f0441fa8b910cd36f5436691c4ce9d4106548574de31dcb6b60 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba16f-linear-zero llvmpipe divergent case/output/slot the digest is a33152229f2a9e0a2cedd5edd958a262c214bd5b4a682110837f3523a6fe5deb on Metal and 0f14b514e5d467aef3403cf69e785fbdb67e5ea6e0bcc8380aa11daf8f58cc86 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba16f-nearest-mirror llvmpipe divergent case/output/norm the digest is fb1a84e8f744e0bd92aab91af807fe789fdf105b5ae8bd526fb427ef0d04409d on Metal and b7ae9327a782f44ca6cfe4b77178ee231700719a57282154cef820331210f709 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba8-linear-border llvmpipe divergent case/output/arg the digest is 8640b83f43b188201afa3e7ed424318caa473f82511150f87921d8ac871eb157 on Metal and f5b6552a414d921f5b61c19484586f177103bb5e647e8cf646aa1b59b5eb849c here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba8-linear-border llvmpipe divergent case/output/const the digest is 8640b83f43b188201afa3e7ed424318caa473f82511150f87921d8ac871eb157 on Metal and f5b6552a414d921f5b61c19484586f177103bb5e647e8cf646aa1b59b5eb849c here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba8-linear-border llvmpipe divergent case/output/norm the digest is 8640b83f43b188201afa3e7ed424318caa473f82511150f87921d8ac871eb157 on Metal and e3d46dca3d9e9e8a02104626468287d0002ba55c09b1ecce26dfb3b0337c5404 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba8-linear-border llvmpipe divergent case/output/slot the digest is 8640b83f43b188201afa3e7ed424318caa473f82511150f87921d8ac871eb157 on Metal and f5b6552a414d921f5b61c19484586f177103bb5e647e8cf646aa1b59b5eb849c here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba8-linear-edge llvmpipe divergent case/output/arg the digest is 4c832fb335efa8b6f389e8a2b8a6721efff8bef2d0d933df0670336ee3841051 on Metal and af3d3c3205f494397b347cb6f3850355692bdb7079714d08c811ec35dc608648 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba8-linear-edge llvmpipe divergent case/output/const the digest is 4c832fb335efa8b6f389e8a2b8a6721efff8bef2d0d933df0670336ee3841051 on Metal and af3d3c3205f494397b347cb6f3850355692bdb7079714d08c811ec35dc608648 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba8-linear-edge llvmpipe divergent case/output/norm the digest is 4c832fb335efa8b6f389e8a2b8a6721efff8bef2d0d933df0670336ee3841051 on Metal and b2f4efc2c14d766524cd814792c3b81ccf5703dfa20a721806e661b7ba08bdb2 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba8-linear-edge llvmpipe divergent case/output/slot the digest is 4c832fb335efa8b6f389e8a2b8a6721efff8bef2d0d933df0670336ee3841051 on Metal and af3d3c3205f494397b347cb6f3850355692bdb7079714d08c811ec35dc608648 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba8-linear-mirror llvmpipe divergent case/output/arg the digest is 26940521965a1456adaba62f9dc004a9f27967fd355737d6efdca7c46209b80b on Metal and 1a5f1fde7d3fbfadc27b9fee1d13423b3e56694594ef194c0b7d5866db92f73a here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba8-linear-mirror llvmpipe divergent case/output/norm the digest is 26940521965a1456adaba62f9dc004a9f27967fd355737d6efdca7c46209b80b on Metal and 753f7eda88c7b435befa74d74ec2465dd5ab51c38138b870b16593b6815d5f73 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba8-linear-mirror llvmpipe divergent case/output/slot the digest is 26940521965a1456adaba62f9dc004a9f27967fd355737d6efdca7c46209b80b on Metal and 1a5f1fde7d3fbfadc27b9fee1d13423b3e56694594ef194c0b7d5866db92f73a here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba8-linear-zero llvmpipe divergent case/output/arg the digest is 8640b83f43b188201afa3e7ed424318caa473f82511150f87921d8ac871eb157 on Metal and f5b6552a414d921f5b61c19484586f177103bb5e647e8cf646aa1b59b5eb849c here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba8-linear-zero llvmpipe divergent case/output/const the digest is 8c8ebb90b930331d3790933171428b8edff1c8296f8bb344a6c06362dc382c83 on Metal and 84db72fda456dffc5acc7637b31572a9410aa049d5f621b8c7f7b34014957bae here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba8-linear-zero llvmpipe divergent case/output/norm the digest is 8640b83f43b188201afa3e7ed424318caa473f82511150f87921d8ac871eb157 on Metal and e3d46dca3d9e9e8a02104626468287d0002ba55c09b1ecce26dfb3b0337c5404 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba8-linear-zero llvmpipe divergent case/output/slot the digest is 8640b83f43b188201afa3e7ed424318caa473f82511150f87921d8ac871eb157 on Metal and f5b6552a414d921f5b61c19484586f177103bb5e647e8cf646aa1b59b5eb849c here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba8-nearest-border llvmpipe divergent case/output/arg the digest is a0a4cd79e2609250f0131240bdb85e230771e5052b8ae7ed2f9af30c4a901a72 on Metal and 6333f6c5c4056f3df73d65c1d0fdca98f7896264b2204c509e454014f430ae64 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba8-nearest-border llvmpipe divergent case/output/const the digest is a0a4cd79e2609250f0131240bdb85e230771e5052b8ae7ed2f9af30c4a901a72 on Metal and 6333f6c5c4056f3df73d65c1d0fdca98f7896264b2204c509e454014f430ae64 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba8-nearest-border llvmpipe divergent case/output/norm the digest is a0a4cd79e2609250f0131240bdb85e230771e5052b8ae7ed2f9af30c4a901a72 on Metal and 6333f6c5c4056f3df73d65c1d0fdca98f7896264b2204c509e454014f430ae64 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. @@ -885,9 +849,7 @@ pixel-samplers-rgba8-nearest-edge llvmpipe divergent case/output/arg the digest pixel-samplers-rgba8-nearest-edge llvmpipe divergent case/output/const the digest is 250024876cde0c2f67dccea354f400d28c94b6cd9634aae0b38c6354f35070b7 on Metal and 0631f694a94fb6f7d83442a7e13675ce49a3a6fa14217138d72bcd7ef367ff86 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba8-nearest-edge llvmpipe divergent case/output/norm the digest is 250024876cde0c2f67dccea354f400d28c94b6cd9634aae0b38c6354f35070b7 on Metal and 0631f694a94fb6f7d83442a7e13675ce49a3a6fa14217138d72bcd7ef367ff86 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba8-nearest-edge llvmpipe divergent case/output/slot the digest is 250024876cde0c2f67dccea354f400d28c94b6cd9634aae0b38c6354f35070b7 on Metal and 0631f694a94fb6f7d83442a7e13675ce49a3a6fa14217138d72bcd7ef367ff86 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba8-nearest-mirror llvmpipe divergent case/output/arg the digest is 27c2ee7d7782b153e1e9daa8f2e37dba6ad073e4dc1f08b6350634a0b66fdf32 on Metal and b2704167a12244b6899021468bae1a322ca593e5463c8361ebcae85ccb11bf4b here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba8-nearest-mirror llvmpipe divergent case/output/norm the digest is 27c2ee7d7782b153e1e9daa8f2e37dba6ad073e4dc1f08b6350634a0b66fdf32 on Metal and 3b527eabc3bf63d32dc5a7eb74d7269814960084b4838b014b2b1f04d9b02055 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. -pixel-samplers-rgba8-nearest-mirror llvmpipe divergent case/output/slot the digest is 27c2ee7d7782b153e1e9daa8f2e37dba6ad073e4dc1f08b6350634a0b66fdf32 on Metal and b2704167a12244b6899021468bae1a322ca593e5463c8361ebcae85ccb11bf4b here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba8-nearest-zero llvmpipe divergent case/output/arg the digest is a0a4cd79e2609250f0131240bdb85e230771e5052b8ae7ed2f9af30c4a901a72 on Metal and 6333f6c5c4056f3df73d65c1d0fdca98f7896264b2204c509e454014f430ae64 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba8-nearest-zero llvmpipe divergent case/output/const the digest is 4ce73456509dc569e5a67d724ecd5f2bea5dda4d8b7279b5f8e4a7351998c5be on Metal and e07f0109d4d14e93f61713251150ebb10eca6b356036457aeae59d4d99af4612 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. pixel-samplers-rgba8-nearest-zero llvmpipe divergent case/output/norm the digest is a0a4cd79e2609250f0131240bdb85e230771e5052b8ae7ed2f9af30c4a901a72 on Metal and 6333f6c5c4056f3df73d65c1d0fdca98f7896264b2204c509e454014f430ae64 here A pixel-coordinate sample through the device's own sampler: the digest of the site's output differs, so the report gives no count or bound here. The case reads through the device's own sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from either. Which of them moves the output, and by how much, is not established by this run. Open: an element-by-element read of the site against the notes' recorded bounds. @@ -1124,3 +1086,65 @@ sampler-mip-filter-pairs-nearest llvmpipe divergent case/linear-linear-clamp-1-5 sampler-mip-filter-pairs-nearest llvmpipe divergent case/linear-min-nearest-mag-clamp-1-5/sampled 16 elements differ (F32), the largest difference 1000 Under a nearest mip filter and `lodMinClamp` 1.5 Metal reads level 1 (`ceil(clamp + 0.5) - 1`, the case's table); the device's own sampler takes the descriptor's clamp as given and lavapipe rounds the halfway level up, reading level 2, which Vulkan allows (its nearest mip level may round either way at a half). The device's native level selection, recorded as `DeviceSampling` (device-sampling), whose documentation states this shape (a nearest mip filter's level at a clamp halfway between two levels). Open: nothing; rule 1 makes the device's level the answer, and no clamp nudged off Metal's grid is kept to steer it. sampler-mip-filter-pairs-nearest llvmpipe divergent case/nearest-min-linear-mag-clamp-1-5/sampled 16 elements differ (F32), the largest difference 1000 Under a nearest mip filter and `lodMinClamp` 1.5 Metal reads level 1 (`ceil(clamp + 0.5) - 1`, the case's table); the device's own sampler takes the descriptor's clamp as given and lavapipe rounds the halfway level up, reading level 2, which Vulkan allows (its nearest mip level may round either way at a half). The device's native level selection, recorded as `DeviceSampling` (device-sampling), whose documentation states this shape (a nearest mip filter's level at a clamp halfway between two levels). Open: nothing; rule 1 makes the device's level the answer, and no clamp nudged off Metal's grid is kept to steer it. sampler-mip-filter-pairs-nearest llvmpipe divergent case/nearest-nearest-clamp-1-5/sampled 16 elements differ (F32), the largest difference 1000 Under a nearest mip filter and `lodMinClamp` 1.5 Metal reads level 1 (`ceil(clamp + 0.5) - 1`, the case's table); the device's own sampler takes the descriptor's clamp as given and lavapipe rounds the halfway level up, reading level 2, which Vulkan allows (its nearest mip level may round either way at a half). The device's native level selection, recorded as `DeviceSampling` (device-sampling), whose documentation states this shape (a nearest mip filter's level at a clamp halfway between two levels). Open: nothing; rule 1 makes the device's level the answer, and no clamp nudged off Metal's grid is kept to steer it. +pixel-samplers-rgba8-nearest-mirror llvmpipe divergent case/output/arg the digest is 27c2ee7d7782b153e1e9daa8f2e37dba6ad073e4dc1f08b6350634a0b66fdf32 on Metal and 3b527eabc3bf63d32dc5a7eb74d7269814960084b4838b014b2b1f04d9b02055 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`, `argument-pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba8-nearest-mirror llvmpipe divergent case/output/slot the digest is 27c2ee7d7782b153e1e9daa8f2e37dba6ad073e4dc1f08b6350634a0b66fdf32 on Metal and 3b527eabc3bf63d32dc5a7eb74d7269814960084b4838b014b2b1f04d9b02055 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba8-linear-edge llvmpipe divergent case/output/arg the digest is 4c832fb335efa8b6f389e8a2b8a6721efff8bef2d0d933df0670336ee3841051 on Metal and b2f4efc2c14d766524cd814792c3b81ccf5703dfa20a721806e661b7ba08bdb2 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`, `argument-pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba8-linear-edge llvmpipe divergent case/output/const the digest is 4c832fb335efa8b6f389e8a2b8a6721efff8bef2d0d933df0670336ee3841051 on Metal and b2f4efc2c14d766524cd814792c3b81ccf5703dfa20a721806e661b7ba08bdb2 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba8-linear-edge llvmpipe divergent case/output/slot the digest is 4c832fb335efa8b6f389e8a2b8a6721efff8bef2d0d933df0670336ee3841051 on Metal and b2f4efc2c14d766524cd814792c3b81ccf5703dfa20a721806e661b7ba08bdb2 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba8-linear-zero llvmpipe divergent case/output/arg the digest is 8640b83f43b188201afa3e7ed424318caa473f82511150f87921d8ac871eb157 on Metal and e3d46dca3d9e9e8a02104626468287d0002ba55c09b1ecce26dfb3b0337c5404 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`, `argument-pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba8-linear-zero llvmpipe divergent case/output/const the digest is 8c8ebb90b930331d3790933171428b8edff1c8296f8bb344a6c06362dc382c83 on Metal and a771e8262614bd35cb8c507f58cb9683ca197457021bd1f37ed7c52f84998c88 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba8-linear-zero llvmpipe divergent case/output/slot the digest is 8640b83f43b188201afa3e7ed424318caa473f82511150f87921d8ac871eb157 on Metal and e3d46dca3d9e9e8a02104626468287d0002ba55c09b1ecce26dfb3b0337c5404 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba8-linear-border llvmpipe divergent case/output/arg the digest is 8640b83f43b188201afa3e7ed424318caa473f82511150f87921d8ac871eb157 on Metal and e3d46dca3d9e9e8a02104626468287d0002ba55c09b1ecce26dfb3b0337c5404 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`, `argument-pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba8-linear-border llvmpipe divergent case/output/const the digest is 8640b83f43b188201afa3e7ed424318caa473f82511150f87921d8ac871eb157 on Metal and e3d46dca3d9e9e8a02104626468287d0002ba55c09b1ecce26dfb3b0337c5404 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba8-linear-border llvmpipe divergent case/output/slot the digest is 8640b83f43b188201afa3e7ed424318caa473f82511150f87921d8ac871eb157 on Metal and e3d46dca3d9e9e8a02104626468287d0002ba55c09b1ecce26dfb3b0337c5404 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba8-linear-mirror llvmpipe divergent case/output/arg the digest is 26940521965a1456adaba62f9dc004a9f27967fd355737d6efdca7c46209b80b on Metal and 753f7eda88c7b435befa74d74ec2465dd5ab51c38138b870b16593b6815d5f73 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`, `argument-pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba8-linear-mirror llvmpipe divergent case/output/slot the digest is 26940521965a1456adaba62f9dc004a9f27967fd355737d6efdca7c46209b80b on Metal and 753f7eda88c7b435befa74d74ec2465dd5ab51c38138b870b16593b6815d5f73 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba16f-nearest-mirror llvmpipe divergent case/output/arg the digest is fb1a84e8f744e0bd92aab91af807fe789fdf105b5ae8bd526fb427ef0d04409d on Metal and b7ae9327a782f44ca6cfe4b77178ee231700719a57282154cef820331210f709 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`, `argument-pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba16f-nearest-mirror llvmpipe divergent case/output/slot the digest is fb1a84e8f744e0bd92aab91af807fe789fdf105b5ae8bd526fb427ef0d04409d on Metal and b7ae9327a782f44ca6cfe4b77178ee231700719a57282154cef820331210f709 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba16f-linear-edge llvmpipe divergent case/output/arg the digest is 7a6a5f64bc4531517ba0d4d4912c2d687ee0779777af9376c02b5e09f4af2421 on Metal and 50d151360bbbb1dd97754bc64a53cdea8c10c5cd6151614bb0b870fdab62c15f here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`, `argument-pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba16f-linear-edge llvmpipe divergent case/output/const the digest is 7a6a5f64bc4531517ba0d4d4912c2d687ee0779777af9376c02b5e09f4af2421 on Metal and 50d151360bbbb1dd97754bc64a53cdea8c10c5cd6151614bb0b870fdab62c15f here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba16f-linear-edge llvmpipe divergent case/output/slot the digest is 7a6a5f64bc4531517ba0d4d4912c2d687ee0779777af9376c02b5e09f4af2421 on Metal and 50d151360bbbb1dd97754bc64a53cdea8c10c5cd6151614bb0b870fdab62c15f here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba16f-linear-zero llvmpipe divergent case/output/arg the digest is a33152229f2a9e0a2cedd5edd958a262c214bd5b4a682110837f3523a6fe5deb on Metal and 5f2e422783414f0441fa8b910cd36f5436691c4ce9d4106548574de31dcb6b60 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`, `argument-pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba16f-linear-zero llvmpipe divergent case/output/const the digest is dbb87cfd8c4ab3c54dede294e5ebc42ad0a2fd84166cc1b46a33e3a3b61e1777 on Metal and dcafa32e15959b6d6ff87ac1adbd569e607e2b70b46c5b94f4433b0e33a61c22 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba16f-linear-zero llvmpipe divergent case/output/slot the digest is a33152229f2a9e0a2cedd5edd958a262c214bd5b4a682110837f3523a6fe5deb on Metal and 5f2e422783414f0441fa8b910cd36f5436691c4ce9d4106548574de31dcb6b60 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba16f-linear-border llvmpipe divergent case/output/arg the digest is a33152229f2a9e0a2cedd5edd958a262c214bd5b4a682110837f3523a6fe5deb on Metal and 5f2e422783414f0441fa8b910cd36f5436691c4ce9d4106548574de31dcb6b60 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`, `argument-pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba16f-linear-border llvmpipe divergent case/output/const the digest is a33152229f2a9e0a2cedd5edd958a262c214bd5b4a682110837f3523a6fe5deb on Metal and 5f2e422783414f0441fa8b910cd36f5436691c4ce9d4106548574de31dcb6b60 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba16f-linear-border llvmpipe divergent case/output/slot the digest is a33152229f2a9e0a2cedd5edd958a262c214bd5b4a682110837f3523a6fe5deb on Metal and 5f2e422783414f0441fa8b910cd36f5436691c4ce9d4106548574de31dcb6b60 here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba16f-linear-mirror llvmpipe divergent case/output/arg the digest is 24724e535ae68eaccd7460b0c8948ce18d3118bb92395b690d7c8918dc521e06 on Metal and f0a7f28a6c471e47b31f77cd59a7666ef50d419714cb58c4c62584e13396b4db here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`, `argument-pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-samplers-rgba16f-linear-mirror llvmpipe divergent case/output/slot the digest is 24724e535ae68eaccd7460b0c8948ce18d3118bb92395b690d7c8918dc521e06 on Metal and f0a7f28a6c471e47b31f77cd59a7666ef50d419714cb58c4c62584e13396b4db here A pixel-coordinate sample through the device's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. On lavapipe the site answers exactly as the same sampler in normalized coordinates at the quotient (`runtime_lane::pixel_samplers`: 0 of 800 cells apart in every configuration), so what moves it from Metal's is the device's sampler and texel conversion (`device-sampling`, `device-texel-conversion`), which the native-arithmetic contract makes the answer; validation derives no tolerance from any of them. Open: an element-by-element read of the site against the notes' recorded bounds. +pixel-downscales-1536x1152 llvmpipe divergent case/output/frac/slot/digest the digest is 810ec665b6fef8901c943b832632d1ae5e7dc6e05b54e7536429d9420a9d5a14 on Metal and a4e686364a069f6a1af4c548092e494ce678a5cd4ad895f630a20aadeb3d4c73 here A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 2/255 of Metal's position on lavapipe. +pixel-downscales-1440x1080 llvmpipe divergent case/output/frac/slot/digest the digest is fd36975bce4f3ede7a2c59afbd86c0691166679fc63791ba1cb086c99f3e2573 on Metal and 49d380382e231bca7d0c8aead37c8dd3a4c905f3562d01d4536ea43cedad89da here A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 2/255 of Metal's position on lavapipe. +pixel-downscales-1440x1080 llvmpipe divergent case/output/frac/slot/head 994 elements differ (F32), the largest difference 0.003921568393707275 A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the site's elements differ by at most 1.00 codes of 1/255 (0.00392). `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Together they cover it. Open: nothing. +pixel-downscales-1920x1080 llvmpipe divergent case/output/frac/slot/digest the digest is 71d2afefba11442056055f137daa6eb529172022ea43bf43431f258eeb7181ed on Metal and af3717b7d311225894a0e0469bfe48630077cf2e7a4f485eeb3798ee7d20e3fb here A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 2/255 of Metal's position on lavapipe. +pixel-downscales-1920x1080 llvmpipe divergent case/output/frac/slot/head 990 elements differ (F32), the largest difference 0.004902005195617676 A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the site's elements differ by at most 1.25 codes of 1/255 (0.00490). `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Together they cover it. Open: nothing. +pixel-downscales-1366x1080 llvmpipe divergent case/output/frac/slot/digest the digest is caec2fd9f40845412cc4b24c5e57d6eeabcbefdb6699695dc4a600b506c2244b on Metal and 33ccc30106de63f9644e15b1ace9b48ca9005063a9e95062f5ed9e90e2497792 here A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 2/255 of Metal's position on lavapipe. +pixel-downscales-1366x1080 llvmpipe divergent case/output/frac/slot/tail 992 elements differ (F32), the largest difference 0.005147099494934082 A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the site's elements differ by at most 1.31 codes of 1/255 (0.00514). `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Together they cover it. Open: nothing. +pixel-downscales-1000x1080 llvmpipe divergent case/output/frac/slot/digest the digest is 264ceee98d6179ad0db33d7a10d196da1c8db63673b939b97ad07d9f0dcb7716 on Metal and 3a7b1c90be5fbe6c56a01962c18e4f523ab6a214580921a623f39cc479a2f5e9 here A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 2/255 of Metal's position on lavapipe. +pixel-downscales-1000x1080 llvmpipe divergent case/output/frac/slot/head 997 elements differ (F32), the largest difference 0.003921568393707275 A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the site's elements differ by at most 1.00 codes of 1/255 (0.00392). `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Together they cover it. Open: nothing. +pixel-downscales-1000x1080 llvmpipe divergent case/output/frac/slot/tail 980 elements differ (F32), the largest difference 0.005392134189605713 A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the site's elements differ by at most 1.37 codes of 1/255 (0.00539). `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Together they cover it. Open: nothing. +pixel-downscales-1440x1152 llvmpipe divergent case/output/frac/slot/digest the digest is aa690279b927f7b00810a4f688eba29d013e134b258b7730c08e07ef72343c0d on Metal and 99cb759719b2ced3a21aecfa9022cb5004295d5b447a27026a1911cb1c057d8c here A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 2/255 of Metal's position on lavapipe. +pixel-downscales-1440x1152 llvmpipe divergent case/output/frac/slot/head 994 elements differ (F32), the largest difference 0.003921568393707275 A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the site's elements differ by at most 1.00 codes of 1/255 (0.00392). `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Together they cover it. Open: nothing. +pixel-downscales-1536x1080 llvmpipe divergent case/output/frac/slot/digest the digest is 6c9baf4f13010e70a06f1a1c5a82f9328fd681892d2cabdee00e2f5feb6b9d8f on Metal and dd4fc4772ed5735f104d803bfc44e7b584ff413bcbe7ff304392e68a8091d2b8 here A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 2/255 of Metal's position on lavapipe. +pixel-downscales-1536x1080 llvmpipe divergent case/output/frac/slot/tail 977 elements differ (F32), the largest difference 0.004166662693023682 A linear-filtered downscale through a pixel sampler, on the device's own sampler at the coordinate divided by the size: the site's elements differ by at most 1.06 codes of 1/255 (0.00416). `device-sampling` records the device's filter (a linear filter's largest difference 1.0 code of 1/255 on lavapipe) and `pixel-sampler-scaling` its reading of the scaled coordinate (a linear weight one 1/256 step from Metal's on each axis, within 2/255 of Metal's position on lavapipe, `runtime_lane::pixel_downscales`); validation derives no tolerance from either. Together they cover it. Open: nothing. +pixel-samplers-rgba16f-linear-mirror Apple M3 Max divergent case/output/arg the digest is 24724e535ae68eaccd7460b0c8948ce18d3118bb92395b690d7c8918dc521e06 on Metal and e1a9d87970ee5feec628a7b19530b2d49d8f2926dcc7eff028450ea64d1c3fe6 here A pixel-coordinate sample through Metal's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`, `argument-pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. `runtime_lane::pixel_samplers` finds 10 of this configuration's 800 cells apart from the same sampler in normalized coordinates at the quotient, each that sampler's answer at a coordinate one `f32` ulp from the quotient, the note's measured bound on MoltenVK; validation derives no tolerance from it. Open: nothing. +pixel-samplers-rgba16f-linear-mirror Apple M3 Max divergent case/output/slot the digest is 24724e535ae68eaccd7460b0c8948ce18d3118bb92395b690d7c8918dc521e06 on Metal and e1a9d87970ee5feec628a7b19530b2d49d8f2926dcc7eff028450ea64d1c3fe6 here A pixel-coordinate sample through Metal's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. `runtime_lane::pixel_samplers` finds 10 of this configuration's 800 cells apart from the same sampler in normalized coordinates at the quotient, each that sampler's answer at a coordinate one `f32` ulp from the quotient, the note's measured bound on MoltenVK; validation derives no tolerance from it. Open: nothing. +pixel-samplers-rgba8-linear-mirror Apple M3 Max divergent case/output/arg the digest is 26940521965a1456adaba62f9dc004a9f27967fd355737d6efdca7c46209b80b on Metal and 038bb530529997aec870ddd0eed54d5f74248db560ca5630c9985e994995fd17 here A pixel-coordinate sample through Metal's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`, `argument-pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. `runtime_lane::pixel_samplers` finds 10 of this configuration's 800 cells apart from the same sampler in normalized coordinates at the quotient, each that sampler's answer at a coordinate one `f32` ulp from the quotient, the note's measured bound on MoltenVK; validation derives no tolerance from it. Open: nothing. +pixel-samplers-rgba8-linear-mirror Apple M3 Max divergent case/output/slot the digest is 26940521965a1456adaba62f9dc004a9f27967fd355737d6efdca7c46209b80b on Metal and 038bb530529997aec870ddd0eed54d5f74248db560ca5630c9985e994995fd17 here A pixel-coordinate sample through Metal's own sampler at the coordinate divided by the texture's size (`pixel-sampler-scaling`): the digest of the site's output differs, so the report gives no count or bound here. `runtime_lane::pixel_samplers` finds 10 of this configuration's 800 cells apart from the same sampler in normalized coordinates at the quotient, each that sampler's answer at a coordinate one `f32` ulp from the quotient, the note's measured bound on MoltenVK; validation derives no tolerance from it. Open: nothing. +pixel-downscales-1536x1152 Apple M3 Max divergent case/output/frac/slot/digest the digest is 810ec665b6fef8901c943b832632d1ae5e7dc6e05b54e7536429d9420a9d5a14 on Metal and e828212392e9120cef59433b615979fad891ab5fdc67fbb289ebe99a41d30493 here A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 1/255 of Metal's on MoltenVK. +pixel-downscales-1536x1152 Apple M3 Max divergent case/output/frac/slot/head 6 elements differ (F32), the largest difference 0.0022059082984924316 A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the site's elements differ by at most 0.56 codes of 1/255 (0.00220). `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Its bound covers it. Open: nothing. +pixel-downscales-1536x1152 Apple M3 Max divergent case/output/frac/slot/tail 11 elements differ (F32), the largest difference 0.0029411911964416504 A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the site's elements differ by at most 0.75 codes of 1/255 (0.00294). `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Its bound covers it. Open: nothing. +pixel-downscales-1440x1080 Apple M3 Max divergent case/output/frac/slot/digest the digest is fd36975bce4f3ede7a2c59afbd86c0691166679fc63791ba1cb086c99f3e2573 on Metal and 641eeebe0a729d4f4a574eb3128dae22591f87bb519152ac198b0eab7d2cc072 here A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 1/255 of Metal's on MoltenVK. +pixel-downscales-1440x1080 Apple M3 Max divergent case/output/frac/slot/head 8 elements differ (F32), the largest difference 0.0017156898975372314 A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the site's elements differ by at most 0.44 codes of 1/255 (0.00171). `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Its bound covers it. Open: nothing. +pixel-downscales-1440x1080 Apple M3 Max divergent case/output/frac/slot/tail 11 elements differ (F32), the largest difference 0.003431379795074463 A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the site's elements differ by at most 0.88 codes of 1/255 (0.00343). `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Its bound covers it. Open: nothing. +pixel-downscales-1920x1080 Apple M3 Max divergent case/output/frac/slot/digest the digest is 71d2afefba11442056055f137daa6eb529172022ea43bf43431f258eeb7181ed on Metal and 9f5339869f9dc890e726a31a6735b4a6a210cbda1fba8f0c21646485e6a37b92 here A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 1/255 of Metal's on MoltenVK. +pixel-downscales-1920x1080 Apple M3 Max divergent case/output/frac/slot/head 12 elements differ (F32), the largest difference 0.00196075439453125 A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the site's elements differ by at most 0.50 codes of 1/255 (0.00196). `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Its bound covers it. Open: nothing. +pixel-downscales-1920x1080 Apple M3 Max divergent case/output/frac/slot/tail 8 elements differ (F32), the largest difference 0.002450987696647644 A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the site's elements differ by at most 0.63 codes of 1/255 (0.00245). `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Its bound covers it. Open: nothing. +pixel-downscales-1366x1080 Apple M3 Max divergent case/output/frac/slot/digest the digest is caec2fd9f40845412cc4b24c5e57d6eeabcbefdb6699695dc4a600b506c2244b on Metal and ebde9a09a9d2d17bae13d8262f49bda5ee2919ff5b95a1379607021db5f4f3f6 here A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 1/255 of Metal's on MoltenVK. +pixel-downscales-1000x1080 Apple M3 Max divergent case/output/frac/slot/digest the digest is 264ceee98d6179ad0db33d7a10d196da1c8db63673b939b97ad07d9f0dcb7716 on Metal and 21a43a917a1b8cf5dce5612a40bceef41419da65fbce0409f0f633952a228f90 here A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 1/255 of Metal's on MoltenVK. +pixel-downscales-1000x1080 Apple M3 Max divergent case/output/frac/slot/head 11 elements differ (F32), the largest difference 0.0029411911964416504 A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the site's elements differ by at most 0.75 codes of 1/255 (0.00294). `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Its bound covers it. Open: nothing. +pixel-downscales-1440x1152 Apple M3 Max divergent case/output/frac/slot/digest the digest is aa690279b927f7b00810a4f688eba29d013e134b258b7730c08e07ef72343c0d on Metal and 8e2017d3c7818df953ce9d91128856209864cddc7f4a2c234386f4d735dd301c here A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 1/255 of Metal's on MoltenVK. +pixel-downscales-1440x1152 Apple M3 Max divergent case/output/frac/slot/head 8 elements differ (F32), the largest difference 0.0017156898975372314 A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the site's elements differ by at most 0.44 codes of 1/255 (0.00171). `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Its bound covers it. Open: nothing. +pixel-downscales-1440x1152 Apple M3 Max divergent case/output/frac/slot/tail 8 elements differ (F32), the largest difference 0.003431379795074463 A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the site's elements differ by at most 0.88 codes of 1/255 (0.00343). `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Its bound covers it. Open: nothing. +pixel-downscales-1536x1080 Apple M3 Max divergent case/output/frac/slot/digest the digest is 6c9baf4f13010e70a06f1a1c5a82f9328fd681892d2cabdee00e2f5feb6b9d8f on Metal and 2f34453941387bce237bc7cb625408c94480710d2d051e0d2aa280504994ba25 here A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the digest of the site's output differs, so the report gives no count or bound here. `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Open: nothing; `runtime_lane::pixel_downscales` holds the whole set within 1/255 of Metal's on MoltenVK. +pixel-downscales-1536x1080 Apple M3 Max divergent case/output/frac/slot/head 6 elements differ (F32), the largest difference 0.0022059082984924316 A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the site's elements differ by at most 0.56 codes of 1/255 (0.00220). `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Its bound covers it. Open: nothing. +pixel-downscales-1536x1080 Apple M3 Max divergent case/output/frac/slot/tail 12 elements differ (F32), the largest difference 0.002451002597808838 A linear-filtered downscale through a pixel sampler, on Metal's own sampler at the coordinate divided by the size: the site's elements differ by at most 0.63 codes of 1/255 (0.00245). `pixel-sampler-scaling` records the device's reading of the scaled coordinate in place of Metal's `1/256` cell of the pixel coordinate (a linear weight one 1/256 step from Metal's on each axis, within 1/255 of Metal's on MoltenVK, `runtime_lane::pixel_downscales`); validation derives no tolerance from it. Its bound covers it. Open: nothing. diff --git a/crates/metal2vulkan-conformance/src/cases/pixel_downscales.rs b/crates/metal2vulkan-conformance/src/cases/pixel_downscales.rs index 8bf560e22..771aeec96 100644 --- a/crates/metal2vulkan-conformance/src/cases/pixel_downscales.rs +++ b/crates/metal2vulkan-conformance/src/cases/pixel_downscales.rs @@ -415,14 +415,16 @@ impl Case for PixelDownscales { fn allowances(&self) -> Vec { // Metal announces nothing, so a notice of ours is a difference at the notices site. - // This is the kind a run of this round provoked (see `pixel_samplers`); a venue that - // announces another reads as divergent there until someone names it with a run. The - // device's own filter and sRGB decode (`float-sample-filter`, `srgb-texel-decode`) are - // native notes the suite declares for every case (`crate::replay::NATIVE_NOTES`). + // These are the kinds a run provoked (see `pixel_samplers`): the device reads the pixel + // coordinate divided by the size, not Metal's `1/256` cell of it. A venue that announces + // another reads as divergent there until someone names it with a run. The device's own + // filter and sRGB decode (`float-sample-filter`, `srgb-texel-decode`) are native notes the + // suite declares for every case (`crate::replay::NATIVE_NOTES`). // // **Each is a declaration and loosens nothing.** Each sits at the notices site alone, so // a texel that differs still fails the case wherever it differs. vec![ + notice_allowance(Degradation::PixelSamplerScaling.code()), notice_allowance(Degradation::ArgumentPixelSamplerScaling.code()), // The buffer each pass writes its sampled texels into is `Shared` // ([`crate::replay::shared_memory_notice`]). diff --git a/crates/metal2vulkan-conformance/src/cases/pixel_samplers.rs b/crates/metal2vulkan-conformance/src/cases/pixel_samplers.rs index d6a3025b6..4ef834c4f 100644 --- a/crates/metal2vulkan-conformance/src/cases/pixel_samplers.rs +++ b/crates/metal2vulkan-conformance/src/cases/pixel_samplers.rs @@ -28,15 +28,13 @@ //! `the_recorded_digests_are_the_lanes_m4_answers` hold the recorded M3 answers against the lane's //! M4 constants: same question, two chips. //! -//! **What may differ, and what justifies it.** On a device with Metal's own sampler -//! (`VkProperty::MetalSampler`, MoltenVK here) every source is Metal's and nothing is announced. -//! Elsewhere a slot's and a constexpr sampler's pixel coordinates reach Metal's texels through the -//! translator's snaps (a nearest sampler's texel centre, a gather's block, a linear sample's -//! footprint cell), filtered by the device's own sampler, while an argument buffer's sampler is -//! handed to the device's own, which announces -//! `argument-pixel-sampler-scaling`, and a device that converts an 8-bit texel to a float its own -//! way announces `float-sample-filter`. Those two sites — `arg` and `norm` — are the only ones -//! loosened, each naming the notice that must have fired. +//! **What may differ, and what justifies it.** Every pixel source hands the device the coordinate +//! divided by the size, which the device's sampler reads in its own arithmetic: at a texel edge or +//! a sub-texel step it may read the neighbouring texel or step, which the runtime announces on +//! every device (`pixel-sampler-scaling`, and `argument-pixel-sampler-scaling` for `arg`). A +//! device that converts an 8-bit texel to a float its own way announces `float-sample-filter`. +//! Each notice is declared at the notices site alone, so a texel that differs still fails the case +//! where it differs, and is a `known-gaps.tsv` row naming the note. //! //! Nothing here can fault a GPU: one small texture, three or four compute passes a case, no loop. //! The coordinates do reach outside the texture, which is what the address modes are for. @@ -465,16 +463,16 @@ impl Case for PixelSamplers { fn allowances(&self) -> Vec { // Metal announces nothing, so a notice of ours is a difference at the notices site. - // This is the kind a run of this round provoked: on lavapipe an argument buffer's pixel - // sampler is handed to the device's own. A venue that announces another kind — - // `pixel-sampler-scaling`, which neither venue here provoked — reads as divergent at that - // site until whoever adds the venue names it with a run behind it. The device's own - // conversion of a texel, its filter and its sRGB decode are native notes the suite - // declares for every case (`crate::replay::NATIVE_NOTES`). + // Every venue hands its sampler the pixel coordinate divided by the size (the two pixel + // notes). A venue that announces another kind reads as divergent at that site until + // whoever adds the venue names it with a run behind it. The device's own conversion of a + // texel, its filter and its sRGB decode are native notes the suite declares for every case + // (`crate::replay::NATIVE_NOTES`). // // **Each is a declaration and loosens nothing.** Each sits at the notices site alone, so // a texel that differs still fails the case wherever it differs. vec![ + notice_allowance(Degradation::PixelSamplerScaling.code()), notice_allowance(Degradation::ArgumentPixelSamplerScaling.code()), // The buffer each pass writes its sampled texels into is `Shared` // ([`crate::replay::shared_memory_notice`]). diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index 7c117434e..b3909a4e4 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -3553,11 +3553,11 @@ impl Device { /// Announce `PrecisionNote::ArgumentPixelSamplerScaling` at a draw or dispatch of a variant /// of `stages` whose commands list `samplers` (the device's live sampler states its sampler - /// table lists): where a stage records the note and a listed state has pixel coordinates and - /// a linear minification or magnification filter or a comparison, the states whose access - /// through an argument buffer may hand the device a scaled coordinate. A listed state is any an - /// argument buffer the commands read may name by its ID; which ones a program's argument - /// buffers hold, the CPU or the GPU writing them, the runtime does not see. Nothing else + /// table lists): where a stage records the note and a listed state has pixel coordinates, the + /// states whose access through an argument buffer may hand the device a scaled coordinate. A + /// listed state is any an argument buffer the commands read may name by its ID; which ones a + /// program's argument buffers hold, the CPU or the GPU writing them, the runtime does not + /// see. Nothing else /// announces the note: a pipeline that records it but never runs while such a state lives /// announces nothing. pub(crate) fn degrade_argument_pixel_samplers( @@ -3577,8 +3577,7 @@ impl Device { stage_object(stage.stage).to_owned(), format!( "{}: it samples through an argument buffer's sampler while sampler state {} \ - of pixel coordinates with a linear filter or a comparison lives, which a \ - program's argument buffer may name", + of pixel coordinates lives, which a program's argument buffer may name", self.note_reason(NOTE), state.gpu_resource_id().0 ), diff --git a/crates/metal2vulkan-runtime/src/sampler.rs b/crates/metal2vulkan-runtime/src/sampler.rs index 713b6db5e..6e219ec6e 100644 --- a/crates/metal2vulkan-runtime/src/sampler.rs +++ b/crates/metal2vulkan-runtime/src/sampler.rs @@ -815,15 +815,10 @@ impl SamplerState { /// Whether an access through an argument buffer that names this state may hand the device a /// pixel coordinate scaled by the texture's size (`Device::degrade_argument_pixel_samplers`): - /// its coordinates are pixels, and it filters (a minification or magnification filter other - /// than nearest) or compares. A nearest pixel state's sample reads Metal's texel, by its - /// flagged fetch or Metal's own sampler. + /// its coordinates are pixels. Every gather, comparison and sample through such a state but a + /// sample its flagged fetch answers (nearest, clamped to the edge) reads the scaled coordinate. pub(super) fn scales_in_an_argument_buffer(&self) -> bool { - let d = &self.0.descriptor; - !d.normalized_coordinates - && (d.min_filter != SamplerMinMagFilter::Nearest - || d.mag_filter != SamplerMinMagFilter::Nearest - || d.compare_function != CompareFunction::Never) + !self.0.descriptor.normalized_coordinates } /// The Vulkan sampler of `desc` (one of this state's binds, its view mapping included): the diff --git a/crates/metal2vulkan-validation/runtime-sources.sha256 b/crates/metal2vulkan-validation/runtime-sources.sha256 index 21894f301..6afd25d0e 100644 --- a/crates/metal2vulkan-validation/runtime-sources.sha256 +++ b/crates/metal2vulkan-validation/runtime-sources.sha256 @@ -1 +1 @@ -ccf4a35d02bfe1ca848ccd881679b525d0f023c4801dee656145756f5cd46468 +642d83b0c28987ebfa59627825022e075fc147e36d59e6385fedaf9b42a61632 diff --git a/crates/metal2vulkan-validation/src/runtime_lane/mirror_clamp.rs b/crates/metal2vulkan-validation/src/runtime_lane/mirror_clamp.rs index 2f0f15d0b..c52e4feb5 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/mirror_clamp.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/mirror_clamp.rs @@ -23,7 +23,7 @@ //! sixteenth plus a half. use super::degrade_notices::on_device; -use super::pixel_samplers::own_sampler; +use super::pixel_samplers::{own_sampler, shifted, REACH}; use super::{buffer_with, read_buffer}; use crate::air_library::AirLibrary; use metal2vulkan::bind::SamplerDescriptor; @@ -289,9 +289,12 @@ fn the_lanes_reach_past_the_level_both_ways() { } /// Every lane reads Metal's answer, on each op, pixel and normalized, 6 and 8 texels wide, where -/// the device samples through Metal's own sampler. Elsewhere it samples by its own (announced -/// `device-sampling`: its addressing, offsets and filter), whose differences are printed. Prints, -/// per case, the lanes checked and those that differ, and each lane that differs. +/// the device samples through Metal's own sampler; but a pixel coordinate reaches the device +/// divided by the size (`pixel-sampler-scaling`), so a pixel lane may read instead Metal's +/// normalized answer at a coordinate within [`REACH`] ulps of the quotient (counted apart). +/// Elsewhere the device samples by its own sampler (announced `device-sampling`: its addressing, +/// offsets and filter), whose differences are printed. Prints, per case, the lanes checked and +/// those that differ, and each lane that differs. #[test] fn mirror_clamped_samples_read_metal_s_texels() { on_device(|device, messages| { @@ -316,13 +319,23 @@ fn mirror_clamped_samples_read_metal_s_texels() { for op in Op::ALL { let texture = if op.compares() { &depth } else { &float }; let got = sampled(device, texture, op, pixel, &us); - let mut differ = 0usize; + let (mut differ, mut scaled) = (0usize, 0usize); for (lane, &u) in us.iter().enumerate() { let want = metal(op, u, n, pixel, lane); for (k, want) in want.iter().enumerate() { let have = got[lane * 5 + k]; - let same = (0..4).all(|c| have[c].to_bits() == want[c].to_bits()); - if !same { + let same = |want: &[f32; 4]| { + (0..4).all(|c| have[c].to_bits() == want[c].to_bits()) + }; + let near = || { + (-REACH..=REACH).any(|ulps| { + let v = shifted(u / n as f32, ulps); + same(&metal(op, v, n, false, lane)[k]) + }) + }; + if !same(want) && pixel && near() { + scaled += 1; + } else if !same(want) { differ += 1; wrong.push(format!( "{n} pixel {pixel} {op:?} u {u:e} offset {}: read {have:?}, \ @@ -334,7 +347,7 @@ fn mirror_clamped_samples_read_metal_s_texels() { } println!( "MIRROR-CLAMP {} {n} pixel {pixel} {op:?}: {} results, {differ} differ \ - from Metal", + from Metal, {scaled} Metal's at the scaled coordinate's neighbour", device.name(), us.len() * 5 ); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/pixel_downscales.rs b/crates/metal2vulkan-validation/src/runtime_lane/pixel_downscales.rs index cc495c631..cb1c2be4f 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/pixel_downscales.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/pixel_downscales.rs @@ -23,13 +23,15 @@ //! orchestrator, 2026-10-09). Plain Metal answered every size, and MoltenVK on an M4 and lavapipe //! answered Metal's at every one. //! -//! On a device with `VkProperty::MetalSampler` the module hands such a sample to Metal's own -//! normalized sampler at its cell (`position::celled_by_word`), which Metal answers as the pixel -//! sampler (0 of 97,200 texel channels differ at every perturbation tried, and in -//! the draw): every configuration must be Metal's and nothing is announced. Elsewhere every sample -//! is the device's sampler's, which the stages record (`PrecisionNote::DeviceSampling`) and the -//! device announces: each configuration's hash is printed beside Metal's, and one that is not -//! Metal's prints the cells that differ from the device's own `norm` control, without failing. +//! Each configuration runs through the runtime, which hands the device the pixel coordinate +//! divided by the texture's size; the device's sampler reads that normalized coordinate in its +//! own arithmetic, not at Metal's `1/256` cell of the pixel coordinate, which the stages record +//! (`PrecisionNote::PixelSamplerScaling`) and every device announces. Each kernel set is held to +//! the device's own `norm` control: every channel within [`CODES`] of `1/255` of the control's +//! (the widest is printed). Elsewhere than on a device with `VkProperty::MetalSampler` every +//! sample is also the device's sampler's (`PrecisionNote::DeviceSampling`, announced). Each +//! configuration's hash is printed beside Metal's, and one that is not Metal's prints the cells +//! that differ from the control, without failing. use super::argument_linear_samples::kernel; use super::degrade_notices::counts; @@ -85,6 +87,12 @@ const SIZES: [Size; 7] = [ /// The target's size. const TARGET: u64 = 256; +/// The widest difference of a kernel set's channel from the device's own `norm` control, in +/// `1/255` (the module docs): a linear weight one sub-texel step from Metal's on each axis, each +/// moving the value by at most `1/256` of the texels' range (measured: 1 on MoltenVK, 2 on +/// lavapipe). +const CODES: u32 = 2; + /// One size's answers: each configuration's name and hash. type Answers = [(&'static str, &'static str); 4]; @@ -313,8 +321,7 @@ fn the_inputs_are_the_probes() { assert_eq!(crate::hash::hex_encode(sha.finalize()), INPUTS_SHA); } -/// Metal's `1/256` cell of the pixel coordinate `x`, half up (`position::snapped_axis`'s -/// `AxisSnap::Cell`). +/// Metal's `1/256` cell of the pixel coordinate `x`, half up. fn cell(x: f32) -> f32 { let y = x * 256.0; let fl = y.floor(); @@ -485,6 +492,9 @@ struct Outcome { metal: Option, /// Its hash. hash: String, + /// A kernel set's widest channel difference from the device's own `norm` control, in `1/255` + /// rounded up (none for the draw). + codes: Option, /// Its hash where it is not Metal's, its cells that differ from the device's own `norm` /// control (a kernel's set), and its rows' hashes (the draw's), to name where it differs. differs: Vec, @@ -558,6 +568,9 @@ fn compare(device: &Device, size: Size) -> Vec { .any(|(a, b)| a.to_bits() != b.to_bits()) }) .collect(); + let codes = (0..4 * n) + .map(|c| ((out[c] - norm[c]).abs() * 255.0).ceil() as u32) + .max(); if !wrong.is_empty() { differs.push(format!( "{} of {n} cells differ from the device's own norm control", @@ -576,6 +589,7 @@ fn compare(device: &Device, size: Size) -> Vec { name, metal: is_metal, hash: got, + codes, differs, }); } @@ -598,6 +612,7 @@ fn compare(device: &Device, size: Size) -> Vec { name: "render", metal: is_metal, hash: got, + codes: None, differs, }); outcomes @@ -613,10 +628,10 @@ fn metal_sampler(device: &Device) -> bool { .contains(&VkProperty::MetalSampler) } -/// Each configuration at each size answers Metal's results where they are known (the module -/// docs) on a device with Metal's own sampler, announcing nothing; elsewhere the device's sampler -/// answers, announced `device-sampling`, and the configurations that are not Metal's are counted. -/// Every configuration's hash is printed, a size's that Metal's are not known for too. +/// Every device announces `pixel-sampler-scaling`, and each kernel set at each size is within +/// [`CODES`] of the device's own `norm` control (the module docs); `device-sampling` is announced +/// exactly where the device's sampler is not Metal's. Every configuration's hash is printed beside +/// Metal's where they are known, and the configurations that are not Metal's are counted. #[test] fn a_pixel_sampler_downscale_answers_metal_s_texels() { let cache = ScratchCache::new().unwrap(); @@ -634,6 +649,7 @@ fn a_pixel_sampler_downscale_answers_metal_s_texels() { let announced: BTreeSet = counts(&messages.take_notices()).into_keys().collect(); eprintln!("announced: {announced:?}"); let mut wrong = Vec::new(); + let mut beyond = Vec::new(); for (size, outcomes) in &outcomes { for o in outcomes { let verdict = match o.metal { @@ -642,11 +658,13 @@ fn a_pixel_sampler_downscale_answers_metal_s_texels() { None => "unmeasured", }; eprintln!( - "pixel downscale {}x{} {}: {verdict} hash {}{}", + "pixel downscale {}x{} {}: {verdict} hash {}, widest {:?} of 1/255 from the \ + control{}", size.w, size.h, o.name, o.hash, + o.codes, o.differs .iter() .map(|d| format!("\n {d}")) @@ -655,23 +673,23 @@ fn a_pixel_sampler_downscale_answers_metal_s_texels() { if o.metal == Some(false) { wrong.push(format!("{}x{} {}", size.w, size.h, o.name)); } + if o.codes.is_some_and(|c| c > CODES) { + beyond.push(format!("{}x{} {}: {:?}", size.w, size.h, o.name, o.codes)); + } } } + assert!( + announced.contains(&Degradation::PixelSamplerScaling), + "{announced:?}" + ); assert_eq!( announced.contains(&Degradation::DeviceSampling), !metal_sampler, "device-sampling exactly where the device's sampler is not Metal's: {announced:?}" ); - if metal_sampler { - assert!( - !announced.contains(&Degradation::PixelSamplerScaling), - "{announced:?}" - ); - assert!(wrong.is_empty(), "not Metal's: {wrong:?}"); - } else { - eprintln!( - "PIXEL-DOWNSCALE-DIFFERS: {} configurations are not Metal's: {wrong:?}", - wrong.len() - ); - } + eprintln!( + "PIXEL-DOWNSCALE-DIFFERS: {} configurations are not Metal's: {wrong:?}", + wrong.len() + ); + assert!(beyond.is_empty(), "beyond {CODES} of 1/255: {beyond:?}"); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/pixel_samplers.rs b/crates/metal2vulkan-validation/src/runtime_lane/pixel_samplers.rs index dfd5654d8..fccf97e99 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/pixel_samplers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/pixel_samplers.rs @@ -16,21 +16,24 @@ //! reads its border color, here opaque white, as clamp to the border does, and a constexpr one //! transparent black. //! -//! Each configuration here runs the same grid through the runtime. On a device with -//! `VkProperty::MetalSampler` (MoltenVK) the hash of its results must be Metal's, and none -//! announces `pixel-sampler-scaling`. Elsewhere every sample is the device's sampler's, which the -//! stages record (`PrecisionNote::DeviceSampling`) and the device announces: the lane prints each -//! configuration that is not Metal's (`PIXEL-SAMPLER-DIFFERS` lines) and the cells where a pixel -//! configuration differs from the device's own `norm` control, without failing. The kernel samples -//! without a comparison, so an argument buffer's pixel sampler reads the device sampler's texels -//! (a nearest word's flagged fetch, a linear word's footprint cell) and records no -//! `ArgumentPixelSamplerScaling` on any device; the note waits for a dispatch of a stage that -//! records it, a comparison's, while a pixel state that may scale lives -//! ([`the_argument_buffer_note_waits_for_a_filtering_pixel_state`]). +//! Each configuration here runs the same grid through the runtime. A pixel coordinate reaches +//! the device divided by the texture's size, and the device's sampler reads that normalized +//! coordinate in its own arithmetic: the stages record it (`PrecisionNote::PixelSamplerScaling`, +//! and `ArgumentPixelSamplerScaling` for an argument buffer's sampler) and every device announces +//! it. Each pixel configuration is held to its normalized control on the same device (the runtime +//! state's `norm`; for `const`, a constexpr sampler of the same words in normalized coordinates): +//! a cell that differs from the control at the same coordinate must be the control's answer at a +//! coordinate within [`REACH`] ulps of it on each axis, and the widest shift each configuration +//! needed is printed (`PIXEL-SAMPLER-REACH` lines). On a device with `VkProperty::MetalSampler` +//! (MoltenVK) each `norm` control's hash must be Metal's. Elsewhere every sample is the device's +//! sampler's, which the stages record (`PrecisionNote::DeviceSampling`) and the device announces. +//! Every configuration that is not Metal's is printed (`PIXEL-SAMPLER-DIFFERS` lines) without +//! failing. An argument buffer's note waits for a dispatch while a pixel state lives +//! ([`the_argument_buffer_note_waits_for_a_pixel_state`]). use super::argument_linear_samples::kernel; use super::degrade_notices::counts; -use super::depth_compares::{self, argument_kernel, pipeline_of, run_held, Held, Through}; +use super::depth_compares::{pipeline_of, run_held, Held, Through}; use super::driver_deviations::stage_notes; use super::extended_range_targets::half_bits; use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; @@ -38,7 +41,7 @@ use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; use metal2vulkan::device::VkProperty; use metal2vulkan::metal::{ - CompareFunction, PixelFormat, SamplerAddressMode, SamplerBorderColor, SamplerMinMagFilter, + PixelFormat, SamplerAddressMode, SamplerBorderColor, SamplerMinMagFilter, }; use metal2vulkan::pipeline::PrecisionNote; use metal2vulkan_devtools::llvm_assemble_text; @@ -429,25 +432,45 @@ fn pixel_words(code: u64, linear: bool, border: u64) -> u64 { (code | code << 3 | code << 6) | filters | 1 << 15 | 8 << 16 | 0x7bff << 40 | border << 56 } -/// The kernels sampling a slot's texture through runtime sampler slot 0, and an argument -/// buffer's texture through its sampler. -struct Kernels { - slot: ComputePipelineState, - argument: ComputePipelineState, +/// The widest shift [`compare`] searches for a pixel configuration's cell, in ulps of the +/// normalized coordinate on each axis. +pub(super) const REACH: i32 = 4; + +/// `v` moved by `k` ulps, up where `k` is positive. +pub(super) fn shifted(mut v: f32, k: i32) -> f32 { + for _ in 0..k.unsigned_abs() { + v = if k > 0 { v.next_up() } else { v.next_down() }; + } + v } -/// A configuration's results beside Metal's. +/// The normalized coordinate of each cell at `cells`, the probe's divided by the size. +fn normalized(cells: &[[f32; 2]]) -> Vec<[f32; 4]> { + cells + .iter() + .map(|&[x, y]| [x / W as f32, y / H as f32, 0.0, 0.0]) + .collect() +} + +/// A configuration's results beside Metal's and beside its normalized control. struct Outcome { /// The configuration's name (the module docs). name: String, /// Whether its results hash as Metal's. metal: bool, - /// Its hash, and its first cells that differ from the device's `norm` control (none for the - /// control itself). + /// Whether it is a `norm` control. + control: bool, + /// Its cells that differ from its control at the same coordinate (none for a control). + differ: usize, + /// The widest shift, in ulps on either axis, of the control's coordinate at which the control + /// answers each such cell as the configuration does; `None` where one is not the control's + /// within [`REACH`]. + reach: Option, + /// Its hash where it is not Metal's, then its first cells that differ from its control. differs: Vec, } -/// Every configuration's results on `device` beside Metal's. +/// Every configuration's results on `device` beside Metal's and beside its control. fn compare(device: &Device) -> Vec { let make = |heap: bool, through: Through| { pipeline_of( @@ -456,22 +479,10 @@ fn compare(device: &Device) -> Vec { "k", ) }; - let kernels = Kernels { - slot: make(false, Through::Runtime), - argument: make(true, Through::Argument), - }; + let (slot, argument) = (make(false, Through::Runtime), make(true, Through::Argument)); let metal: BTreeMap<&str, &str> = METAL.into_iter().collect(); let cells = grid(); - let jobs = |scale: bool| -> Vec<[f32; 4]> { - cells - .iter() - .map(|&[x, y]| match scale { - true => [x / W as f32, y / H as f32, 0.0, 0.0], - false => [x, y, 0.0, 0.0], - }) - .collect() - }; - let (pixel, normalized) = (jobs(false), jobs(true)); + let pixel: Vec<[f32; 4]> = cells.iter().map(|&[x, y]| [x, y, 0.0, 0.0]).collect(); let n = cells.len(); let run = |texture: &Texture, held: Held<'_>, @@ -479,9 +490,11 @@ fn compare(device: &Device) -> Vec { state: &ComputePipelineState, jobs: &[[f32; 4]]| { let mut out = run_held(device, (texture, held, sampler), state, jobs, 1); - out.truncate(4 * n); + out.truncate(4 * jobs.len()); out }; + let texel = + |out: &[f32], j: usize| -> [u32; 4] { std::array::from_fn(|c| out[4 * j + c].to_bits()) }; let mut outcomes = Vec::new(); for (format, fname) in [ (PixelFormat::RGBA8Unorm, "rgba8"), @@ -495,69 +508,120 @@ fn compare(device: &Device) -> Vec { for &(aname, address, constexpr) in &ADDRESSES { let pixel_state = sampler(device, filter, address, false); let norm_state = sampler(device, filter, address, true); - let norm = run( - &texture, - Held::Argument(Some(&norm_state)), - None, - &kernels.argument, - &normalized, - ); + // A configuration's control at `jobs`: the normalized state through the argument + // buffer, or a constexpr sampler of `words` in normalized coordinates. + let control = |words: Option, jobs: &[[f32; 4]]| match words { + None => run( + &texture, + Held::Argument(Some(&norm_state)), + None, + &argument, + jobs, + ), + Some(words) => run( + &texture, + Held::Slot, + None, + &make(false, Through::Constexpr(words & !(1 << 15))), + jobs, + ), + }; + let norm = control(None, &normalized(&cells)); let mut results = vec![ - ("norm", norm.clone()), + ("norm", None, None), ( "slot", - run( - &texture, - Held::Slot, - Some(&pixel_state), - &kernels.slot, - &pixel, - ), + Some(run(&texture, Held::Slot, Some(&pixel_state), &slot, &pixel)), + None, ), ( "arg", - run( + Some(run( &texture, Held::Argument(Some(&pixel_state)), None, - &kernels.argument, + &argument, &pixel, - ), + )), + None, ), ]; if let Some((code, border)) = constexpr { let words = pixel_words(code, filter == SamplerMinMagFilter::Linear, border); let state = make(false, Through::Constexpr(words)); - results.push(("const", run(&texture, Held::Slot, None, &state, &pixel))); + let out = run(&texture, Held::Slot, None, &state, &pixel); + results.push(("const", Some(out), Some(words))); } - for (source, out) in results { + for (source, out, words) in results { let name = format!("{fname}_{source}_{lname}_{aname}"); + let out = out.as_ref().unwrap_or(&norm); let bytes: Vec = out.iter().flat_map(|v| v.to_le_bytes()).collect(); let hash = crate::hash::hex_encode(Sha256::digest(&bytes)); - let metal = metal.get(name.as_str()) == Some(&hash.as_str()); - // The cells that differ from the `norm` control, which Metal answered alike - // but where a constexpr sampler clamps to zero. - let mut cells_wrong = Vec::new(); - for (j, &[x, y]) in cells.iter().enumerate() { - let (got, control) = (&out[4 * j..4 * j + 4], &norm[4 * j..4 * j + 4]); - if got + let is_metal = metal.get(name.as_str()) == Some(&hash.as_str()); + let mut differs = Vec::new(); + if !is_metal { + differs.push(format!("hash {hash}")); + } + if source == "norm" { + outcomes.push(Outcome { + name, + metal: is_metal, + control: true, + differ: 0, + reach: Some(0), + differs, + }); + continue; + } + let own = match words { + None => norm.clone(), + Some(words) => control(Some(words), &normalized(&cells)), + }; + let wrong: Vec = (0..n) + .filter(|&j| texel(out, j) != texel(&own, j)) + .collect(); + // Each such cell's control at every shift of its coordinate within `REACH`. + let shifts: Vec<(i32, i32)> = (-REACH..=REACH) + .flat_map(|kx| (-REACH..=REACH).map(move |ky| (kx, ky))) + .collect(); + let jobs: Vec<[f32; 4]> = wrong + .iter() + .flat_map(|&j| { + let [u, v, ..] = normalized(&cells[j..=j])[0]; + shifts + .iter() + .map(move |&(kx, ky)| [shifted(u, kx), shifted(v, ky), 0.0, 0.0]) + }) + .collect(); + let around = match jobs.is_empty() { + true => Vec::new(), + false => control(words, &jobs), + }; + let mut reach = Some(0); + for (w, &j) in wrong.iter().enumerate() { + let widest = shifts .iter() - .zip(control) - .any(|(a, b)| a.to_bits() != b.to_bits()) - && cells_wrong.len() < 6 - { - cells_wrong.push(format!( - "({x:e}, {y:e}): {got:?}, the normalized control {control:?}" + .enumerate() + .filter(|&(s, _)| texel(&around, w * shifts.len() + s) == texel(out, j)) + .map(|(_, &(kx, ky))| kx.unsigned_abs().max(ky.unsigned_abs())) + .min(); + reach = reach.zip(widest).map(|(a, b)| a.max(b)); + if differs.len() < 7 { + let [x, y] = cells[j]; + differs.push(format!( + "({x:e}, {y:e}): {:?}, the control {:?}, matched at a shift of {widest:?}", + &out[4 * j..4 * j + 4], + &own[4 * j..4 * j + 4] )); } } - if !metal { - cells_wrong.insert(0, format!("hash {hash}")); - } outcomes.push(Outcome { name, - metal, - differs: cells_wrong, + metal: is_metal, + control: false, + differ: wrong.len(), + reach, + differs, }); } } @@ -566,11 +630,11 @@ fn compare(device: &Device) -> Vec { outcomes } -/// On a device with Metal's own sampler every configuration answers Metal's results (the module -/// docs) and none announces a pixel sampler's note. Elsewhere the samples are the device's -/// sampler's: the device announces `device-sampling`, and each configuration that is not Metal's is -/// printed with the cells where it differs from the device's own `norm` control. No device -/// announces `argument-pixel-sampler-scaling`: the kernel samples without a comparison. +/// Every device announces both pixel samplers' notes, and every pixel configuration's cell is its +/// normalized control's within [`REACH`] ulps of the control's coordinate (the module docs). On a +/// device with Metal's own sampler each `norm` control answers Metal's results; elsewhere the +/// samples are the device's sampler's and the device announces `device-sampling`. Each +/// configuration that is not Metal's is printed with the cells where it differs from its control. #[test] fn pixel_samplers_answer_metal_s_texels() { let cache = ScratchCache::new().unwrap(); @@ -587,41 +651,60 @@ fn pixel_samplers_answer_metal_s_texels() { layer_reported_nothing_at_all(&messages); let announced: BTreeSet = counts(&messages.take_notices()).into_keys().collect(); eprintln!("announced: {announced:?}"); - assert!( - !announced.contains(&Degradation::ArgumentPixelSamplerScaling), - "{name}: an argument buffer's pixel note of a sample without a comparison" - ); + for kind in [ + Degradation::PixelSamplerScaling, + Degradation::ArgumentPixelSamplerScaling, + ] { + assert!(announced.contains(&kind), "{name}: {kind:?} not announced"); + } assert_eq!( announced.contains(&Degradation::DeviceSampling), !metal_sampler, "{name}: device-sampling exactly where the device's sampler is not Metal's" ); - if metal_sampler { - assert!(!announced.contains(&Degradation::PixelSamplerScaling)); - } assert_eq!(outcomes.len(), METAL.len()); - let wrong: BTreeMap> = outcomes - .into_iter() + for o in outcomes.iter().filter(|o| !o.control) { + eprintln!( + "PIXEL-SAMPLER-REACH {name}: {}: {} of {} cells differ from the control, widest \ + shift {:?} ulp", + o.name, + o.differ, + grid().len(), + o.reach + ); + } + let wrong: BTreeMap<&str, &Outcome> = outcomes + .iter() .filter(|o| !o.metal) - .map(|o| (o.name, o.differs)) + .map(|o| (o.name.as_str(), o)) .collect(); eprintln!( "{name}: {} of {} configurations are not Metal's", wrong.len(), METAL.len() ); - if !metal_sampler { - for (configuration, differs) in &wrong { - eprintln!("PIXEL-SAMPLER-DIFFERS {name}: {configuration}: {differs:?}"); - } - return; + for (configuration, o) in &wrong { + eprintln!( + "PIXEL-SAMPLER-DIFFERS {name}: {configuration}: {:?}", + o.differs + ); } + let beyond: Vec<(&str, &[String])> = outcomes + .iter() + .filter(|o| o.reach.is_none()) + .map(|o| (o.name.as_str(), o.differs.as_slice())) + .collect(); assert!( - wrong.is_empty(), - "{name}: {} of {} configurations are not Metal's: {wrong:#?}", - wrong.len(), - METAL.len() + beyond.is_empty(), + "{name}: cells beyond {REACH} ulps of the control: {beyond:#?}" ); + if metal_sampler { + let controls: Vec<&&str> = wrong.keys().filter(|n| n.contains("_norm_")).collect(); + assert!( + controls.is_empty(), + "{name}: normalized controls not Metal's: {controls:?}" + ); + } } /// Whether `device` samples through Metal's own sampler (`VkProperty::MetalSampler`). @@ -649,86 +732,51 @@ pub(super) fn own_sampler(device: &Device, messages: &Messages) -> bool { } /// `argument-pixel-sampler-scaling` fires at a dispatch, never at a state's making. An argument -/// buffer's comparison through the sampler it holds beside a `Depth32Float` texture -/// (`depth_compares::argument_kernel`), whose stage records the note on every device (a comparison -/// may filter, which the specialized module cannot read), dispatched while the device holds a -/// normalized comparing state and a nearest pixel state, announces nothing; making a pixel state -/// of linear filters announces nothing; the next dispatch, through the normalized state still, -/// announces it once. +/// buffer's sample through the sampler it holds, whose stage records the note on every device +/// (which state a program's argument buffer names, the module cannot see), dispatched while the +/// device holds only a normalized state, announces nothing; making a pixel state of nearest +/// filters announces nothing; the next dispatch, through the normalized state still, announces it +/// once. #[test] -fn the_argument_buffer_note_waits_for_a_filtering_pixel_state() { +fn the_argument_buffer_note_waits_for_a_pixel_state() { let cache = ScratchCache::new().unwrap(); let messages = Messages::default(); let kind = Degradation::ArgumentPixelSamplerScaling; { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); - let text = argument_kernel(Through::Argument, false, ("true", "0.0")); - let bitcode = llvm_assemble_text(&text).unwrap(); + let bitcode = llvm_assemble_text(&kernel(true, Through::Argument, false, false)).unwrap(); assert!( stage_notes(&device, &bitcode, "k") .contains(&PrecisionNote::ArgumentPixelSamplerScaling), - "an argument buffer's comparison records the note" + "an argument buffer's sample records the note" ); let argument = pipeline_of(&device, &bitcode, "k"); - let side = u64::from(depth_compares::SIDE); - let texture = device - .new_texture(&TextureDescriptor::texture_2d( - PixelFormat::Depth32Float, - side, - side, - false, - )) - .unwrap(); - let texels: Vec = depth_compares::VALUES - .iter() - .flat_map(|v| v.to_le_bytes()) - .collect(); - texture - .replace_region(Region::new_2d(0, 0, side, side), 0, 0, &texels, 4 * side, 0) - .unwrap(); - // Each texel's centre against a reference of 0.5. - let jobs: Vec<[f32; 4]> = (0..side * side) - .map(|i| { - let at = |k: u64| (k as f32 + 0.5) / side as f32; - [at(i % side), at(i / side), 0.5, 0.0] - }) - .collect(); - let state = |filter, normalized, compare| { - let mut d = SamplerDescriptor::new(); - d.min_filter = filter; - d.mag_filter = filter; - d.normalized_coordinates = normalized; - d.compare_function = compare; - let mut options = SamplerStateOptions::default(); - options.support_argument_buffers = true; - device.new_sampler_state_with_options(&d, options).unwrap() - }; - let normalized = state( + let texture = texture(&device, PixelFormat::RGBA8Unorm); + let jobs = normalized(&grid()); + let (nearest, edge) = ( SamplerMinMagFilter::Nearest, - true, - CompareFunction::LessEqual, + SamplerAddressMode::ClampToEdge, ); - let nearest = state(SamplerMinMagFilter::Nearest, false, CompareFunction::Never); - let dispatch = |state: &SamplerState| { + let normalized = sampler(&device, nearest, edge, true); + let dispatch = || { run_held( &device, - (&texture, Held::Argument(Some(state)), None), + (&texture, Held::Argument(Some(&normalized)), None), &argument, &jobs, 1, ); }; - dispatch(&normalized); - dispatch(&nearest); + dispatch(); let before = counts(&messages.take_notices()); assert!(!before.contains_key(&kind), "{before:?}"); - let linear = state(SamplerMinMagFilter::Linear, false, CompareFunction::Never); + let pixel = sampler(&device, nearest, edge, false); let made = counts(&messages.take_notices()); assert!(!made.contains_key(&kind), "{made:?}"); - dispatch(&normalized); + dispatch(); let after = counts(&messages.take_notices()); assert_eq!(after.get(&kind).copied(), Some(1), "{after:?}"); - drop((nearest, linear)); + drop(pixel); } layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/resource_ids.rs b/crates/metal2vulkan-validation/src/runtime_lane/resource_ids.rs index 907a03d4f..a198c3e43 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/resource_ids.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/resource_ids.rs @@ -55,6 +55,10 @@ use std::time::{Duration, Instant}; /// the device's or the pipeline's sampler arrays hold (and expects absent elsewhere). pub(super) const UNLISTED: [Degradation; 1] = [Degradation::UnlistedArgumentSampler]; +/// What a dispatch sampling through an argument buffer announces while a sampler state of pixel +/// coordinates lives. +const PIXEL_ARGUMENT: [Degradation; 1] = [Degradation::ArgumentPixelSamplerScaling]; + /// The kind [`a_texture_its_heap_array_cannot_view_is_announced_once`] takes. pub(super) const UNVIEWABLE: [Degradation; 1] = [Degradation::UnnamedTextureUnviewable]; @@ -2166,8 +2170,9 @@ fn late_sampler_states_past_twice_the_class_are_reached_by_their_ids() { /// 100003 and sampled through an argument buffer as their address modes say). With 100000 /// reserved before anything takes a sampler ID, the case's states take IDs past it, and a state /// in pixel coordinates standing in the argument buffer for the case's, at the next plain ID, -/// reads texel (0, 0), where the neutral sampler reads the case's own answer. Nothing is -/// announced. +/// reads texel (0, 0), where the neutral sampler reads the case's own answer. The dispatch +/// samples through an argument buffer while that pixel state lives, which announces +/// `argument-pixel-sampler-scaling` and nothing else. #[test] fn sampler_states_past_the_low_window_are_reached_by_their_ids() { on_device(|device, messages| { @@ -2207,7 +2212,7 @@ fn sampler_states_past_the_low_window_are_reached_by_their_ids() { corner(), "through ID {id}" ); - sampling.announced(device, messages, &[]); + sampling.announced(device, messages, &PIXEL_ARGUMENT); }); } @@ -2252,7 +2257,9 @@ const CROWD: u64 = 2048; /// ID Metal makes (16380), in pixel coordinates and standing in the argument buffer for the case's /// state, reads texel (0, 0) at all four of the case's coordinates (each below 1), as Metal's does /// (the M3 Max: bound and through an argument buffer alike), where the neutral -/// sampler the state would miss to reads the case's own answer; nothing is announced. A state is +/// sampler the state would miss to reads the case's own answer; the dispatch announces +/// `argument-pixel-sampler-scaling` alone, sampling through an argument buffer while the pixel +/// state lives. A state is /// left out only where more states live than the arrays hold: the line `SAMPLER-CAPACITY` reports /// the device's and the case's pipeline's, and where either holds at most [`CROWD`] elements the /// lane makes states past it, announced once (`UNLISTED`), and the command buffer completes with @@ -2298,7 +2305,7 @@ fn a_sampler_state_at_any_id_is_listed() { corner, "through ID {high}" ); - sampling.announced(device, messages, &[]); + sampling.announced(device, messages, &PIXEL_ARGUMENT); let [execution] = &command_buffer.executions()[..] else { panic!("one dispatch"); }; diff --git a/crates/metal2vulkan/src/bind/plan/resources.rs b/crates/metal2vulkan/src/bind/plan/resources.rs index ee74a3fa1..068955a38 100644 --- a/crates/metal2vulkan/src/bind/plan/resources.rs +++ b/crates/metal2vulkan/src/bind/plan/resources.rs @@ -1739,21 +1739,13 @@ impl ResourcePlanner<'_> { } /// The `SamplerState { slot, fields }` specialization: the bound sampler's word masked by - /// `fields`, the bits the function reads; 0 where no sampler is bound, and where `fields` - /// states `SamplerWord::PIXEL_GATED` and the word normalized coordinates, whose other fields - /// the function then reads only through tests that fail. + /// `fields`, the bits the function reads; 0 where no sampler is bound. pub fn sampler_state(&self, slot: SlotRef, fields: u32) -> u64 { - use crate::metal::sampler::SamplerWord; let word = self .stage_shape(slot.stage) .and_then(|s| s.samplers.get(&slot.index)) .map_or(0, |s| s.word.0); - let read = word & fields; - let gated = fields & SamplerWord::PIXEL_GATED != 0; - match gated && read & SamplerWord::PIXEL_COORDINATES == 0 { - true => 0, - false => u64::from(read), - } + u64::from(word & fields) } /// The `SamplerMinLevel(slot)` specialization: the level, in sixty-fourths, that Metal's diff --git a/crates/metal2vulkan/src/bind/plan/resources/tests.rs b/crates/metal2vulkan/src/bind/plan/resources/tests.rs index d1a5d8f77..c6138af34 100644 --- a/crates/metal2vulkan/src/bind/plan/resources/tests.rs +++ b/crates/metal2vulkan/src/bind/plan/resources/tests.rs @@ -862,9 +862,8 @@ fn bicubic_texels_follow_the_bound_format() { } /// A runtime sampler slot specializes `SamplerState` to the bound sampler's word masked by the -/// fields the function reads, and an unbound slot to 0. So the pixel predicates hold as they did of -/// `SamplerCoords` and `SamplerPixelNearest`: pixel coordinates wherever the sampler uses them, a -/// nearest pixel sampler exactly where it also filters nearest. +/// fields the function reads, and an unbound slot to 0. So the pixel predicate holds as it did of +/// `SamplerCoords`: pixel coordinates wherever the sampler uses them, whatever its filters. #[test] fn sampler_state_follows_the_bound_sampler() { use crate::bind::state::SamplerDescriptor; @@ -905,7 +904,7 @@ fn sampler_state_follows_the_bound_sampler() { template: Default::default(), alpha_red_texels: Default::default(), }; - [W::PIXEL_COORDINATES, W::PIXEL_NEAREST, W::FIELDS] + [W::PIXEL_COORDINATES, W::LINEAR, W::FIELDS] .map(|fields| planner.sampler_state(slot, fields) as u32) }; let with = |normalized: bool, filter: F| { @@ -922,21 +921,17 @@ fn sampler_state_follows_the_bound_sampler() { assert_eq!(plan(None), [0, 0, 0]); assert_eq!(plan(with(true, F::Nearest)), [0, 0, repeat_t]); assert_eq!(plan(with(true, F::Linear)), [0, linear, linear | repeat_t]); - assert_eq!( - plan(with(false, F::Nearest)), - [pixel, pixel, pixel | repeat_t] - ); + assert_eq!(plan(with(false, F::Nearest)), [pixel, 0, pixel | repeat_t]); assert_eq!( plan(with(false, F::Linear)), - [pixel, pixel | linear, pixel | linear | repeat_t] + [pixel, linear, pixel | linear | repeat_t] ); - // The pixel predicates: the word masked by them is exactly the pixel-coordinates bit. - let states = |desc, mask| plan(desc)[if mask == W::PIXEL_COORDINATES { 0 } else { 1 }] == pixel; - assert!(!states(with(true, F::Nearest), W::PIXEL_COORDINATES)); - assert!(states(with(false, F::Linear), W::PIXEL_COORDINATES)); - assert!(states(with(false, F::Nearest), W::PIXEL_NEAREST)); - assert!(!states(with(false, F::Linear), W::PIXEL_NEAREST)); - assert!(!states(None, W::PIXEL_NEAREST)); + // The pixel predicate: the word masked by it is exactly the pixel-coordinates bit. + let states = |desc| plan(desc)[0] == pixel; + assert!(!states(with(true, F::Nearest))); + assert!(states(with(false, F::Linear))); + assert!(states(with(false, F::Nearest))); + assert!(!states(None)); } /// A texture slot read or sampled with a `half` result specializes `TexelFormat` from the bound diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index 55c4a133a..20fd1b2da 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -60,7 +60,7 @@ mod tests; /// unchanged version, and its bless records the version. Independent of the crate's version and of /// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no /// history. -pub const SEMANTICS_VERSION: u32 = 1904; +pub const SEMANTICS_VERSION: u32 = 1905; /// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the /// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another @@ -93,7 +93,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 473; /// changes no behaviour, and then updates that hash alone with the commit saying why, or changes /// behaviour and also bumps this version. The commit that bumps it says what changed; this comment /// keeps no history. -pub const RUNTIME_VERSION: u32 = 1675; +pub const RUNTIME_VERSION: u32 = 1676; /// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex, /// of the manifest, the build script, and exactly the files the crate roots' module tree compiles diff --git a/crates/metal2vulkan/src/lower/sampler/anisotropic.rs b/crates/metal2vulkan/src/lower/sampler/anisotropic.rs index e7c676087..e18752c02 100644 --- a/crates/metal2vulkan/src/lower/sampler/anisotropic.rs +++ b/crates/metal2vulkan/src/lower/sampler/anisotropic.rs @@ -67,8 +67,8 @@ //! next face, as the device projects it). Through an isotropic constexpr sampler the module takes //! Metal's level alone, its major axis's (an isotropic cube's measured so: a footprint past //! `1 + 3/2048` minifies, `unk_cube_grad_table`'s turning points), and one tap, where no exact -//! path of the sample's own answers it (a snapped, fetched or centred coordinate): its levels are -//! Metal's, each the device's filter. +//! path of the sample's own answers it (a fetched coordinate): its levels are Metal's, each the +//! device's filter. //! //! **The loop**. Tap 0 is written out, and taps 1 to `n - 1` are one loop's body, which asks the //! driver not to unroll it (`LoopControl` `DontUnroll`): each tap's arithmetic and the sum's order diff --git a/crates/metal2vulkan/src/lower/sampler/emit.rs b/crates/metal2vulkan/src/lower/sampler/emit.rs index af8fa02c7..a93eb5424 100644 --- a/crates/metal2vulkan/src/lower/sampler/emit.rs +++ b/crates/metal2vulkan/src/lower/sampler/emit.rs @@ -976,71 +976,20 @@ pub(super) fn sampled_value( _ => None, }; let (mut coord, mut grad) = plane_and_gradients(cx, fb, s, grads)?; - // A pixel sampler's snap reads the coordinate as given. - let given = coord; // Pixel coordinates: the plane coordinate (and any gradient) over the level-0 size, always // or behind the runtime sampler's word. - let mut centred = None; - let size_lanes = image.plane + u8::from(image.arrayed); - // The image and level-0 size the pixel coordinates query, which a word snap reads too. - let mut level0 = None; if let Some(spec) = pixel_coordinates(cx, fb, s)? { let img = fb.image(si)?; let zero = fb.u32_const(0)?; let zero = fb.module().const_value(zero)?; let size = fb.query(ImageQuery::SizeLod(zero), img)?; - level0 = Some((img, size)); - centred = pixel_centre(cx, fb, s, coord, (size, size_lanes))?; + let size_lanes = image.plane + u8::from(image.arrayed); (coord, grad) = scaled(fb, s.lanes, (size, size_lanes), spec, (coord, grad))?; } // The plane coordinate as the sample reads it (pixel coordinates scaled), whose derivatives a // bias past the device's limit scales, and from which Metal's footprint of an observed access // follows. let plane = coord; - // The device reads a coordinate snapped onto the texels Metal reads. - if let Some(snap) = &s.snap { - coord = match snap.kind { - // A runtime or argument buffer's sampler's gather, and its linear pixel sample, on the - // base level's size the pixel coordinates queried, from the coordinate as given. - super::position::SnapKind::WordGather => { - let word = sampler_word(cx, fb, s.pixel)?; - let Some((_, size)) = level0 else { - return Err(cx.fail("a word gather without its base level's size")); - }; - super::position::gathered_by_word( - fb, - word, - (given, coord), - s.lanes, - (size, size_lanes), - )? - } - super::position::SnapKind::WordCell { .. } => { - let word = sampler_word(cx, fb, s.pixel)?; - let Some((_, size)) = level0 else { - return Err(cx.fail("a word cell without its base level's size")); - }; - super::position::celled_by_word( - fb, - word, - (given, coord), - s.lanes, - (size, size_lanes), - )? - } - _ => { - let offsets = snap_offsets(cx, fb, op_offset(&s.op), s.lanes)?; - let at = (given, offsets.as_slice(), offset_base(cx, s)?); - super::position::snapped(cx, fb, snap, at, s.lanes, (si, image))? - } - }; - } - // A nearest pixel sampler's texel at its centre. - coord = match centred { - Some((Some(nearest), centre)) => fb.select(nearest, centre, coord)?, - Some((None, centre)) => centre, - None => coord, - }; let (coord, layer) = layered(cx, fb, s, coord)?; // The access, from the sampled image `si`; under a sparse arm each arm loads its own. // The access, from the sampled image `si` (loaded in the open block); under a sparse arm each @@ -1287,8 +1236,7 @@ fn heap_sampler_field( /// Whether sampler word `word` masked by `mask` is exactly [`SamplerWord::PIXEL_COORDINATES`] (a /// `bool`): every predicate a sampling tests of a runtime sampler is a pixel sampler's, with the -/// other fields of `mask` at their zero values ([`SamplerWord::exact_fetch`], -/// [`SamplerWord::PIXEL_NEAREST`]). +/// other fields of `mask` at their zero values ([`SamplerWord::exact_fetch`]). fn word_states(fb: &mut FunctionBuilder<'_>, word: SValue, mask: u32) -> BResult { let m = fb.u32_const(mask)?; let m = fb.module().const_value(m)?; @@ -1298,60 +1246,6 @@ fn word_states(fb: &mut FunctionBuilder<'_>, word: SValue, mask: u32) -> BResult fb.binary(BinOp::IEqual, have, pixel) } -/// For a centred sample ([`Sampling::centred`]): where it reads the texel's centre (`None` always, -/// for a constexpr sampler; else where the runtime sampler's word masked by -/// [`Sampling::centre_word`] is [`SamplerWord::PIXEL_COORDINATES`]), and -/// the normalized centre of the texel Metal reads at pixel coordinate `coord` (`s.lanes` floats) on -/// a texture of level-0 size `size` (`size_lanes` components), `(floor(coord) + 1/2) / size` per -/// plane axis. Metal floors a nearest pixel sampler's coordinate (Apple M4, 1,378 -/// lanes a fraction of a texel either side of every integer, constexpr and runtime samplers, -/// clamped to the edge and to zero); a device's nearest filter takes `floor(u size)`, whose product -/// `u size` of the scaled coordinate can round onto the next integer, so the texel's centre, half a -/// texel from either edge, names it on every device. A coordinate outside the texture keeps its -/// centre outside it, where clamping to the edge, to zero, or to a border, or mirroring once and -/// clamping, reads what Metal reads. `None` for any other sampling: a gather or a comparison keeps the scaled coordinate, whose -/// texels are the device's. -fn pixel_centre( - cx: &mut EmitCx<'_>, - fb: &mut FunctionBuilder<'_>, - s: &Sampling, - coord: SValue, - (size, size_lanes): (SValue, u8), -) -> BResult, SValue)>> { - if !s.centred { - return Ok(None); - } - let nearest = match s.pixel { - Pixel::None => return Ok(None), - Pixel::Always => None, - // A runtime sampler: its word's nearest pixel sampler. - Pixel::Spec(_) | Pixel::Heap(_) => { - let word = sampler_word(cx, fb, s.pixel)?; - Some(word_states(fb, word, s.centre_word)?) - } - }; - let floor = fb.glsl(GlslOp::Floor, &[coord])?; - let f = f32_ty(fb)?; - let half = fb.module().constant(Constant::Scalar { - ty: f, - bits: ConstBits(u64::from(0.5f32.to_bits())), - })?; - let half = match s.lanes { - 1 => half, - len => { - let ty = fb.module().ty(SType::Vector { elem: f, len })?; - fb.module().constant(Constant::Composite { - ty, - parts: vec![half; usize::from(len)].into(), - })? - } - }; - let half = fb.module().const_value(half)?; - let centre = fb.binary(BinOp::FAdd, floor, half)?; - let centre = scale(fb, centre, size, s.lanes, size_lanes)?; - Ok(Some((nearest, centre))) -} - /// The plane coordinate `coord` (`lanes` floats) and gradients `grad` over the level-0 size /// `size` (`size_lanes` components): always, or where `spec` holds. pub(super) fn scaled( @@ -1398,7 +1292,7 @@ pub(super) fn layered( } /// The `SpecKey::OffsetBaseAxes` tests of `s`'s slot (`texture::OffsetBase`), by which its -/// emulation or snap places a texel offset (`position::offset_dropped`), where `s` reads them +/// emulation places a texel offset (`position::offset_dropped`), where `s` reads them /// ([`Sampling::offset_base`]); `None` for every other access, a heap element's among them. pub(super) fn offset_base( cx: &mut EmitCx<'_>, @@ -1418,50 +1312,6 @@ pub(super) fn offset_base( } } -/// The texel offset a sample or gather `op` carries, if any. -pub(super) fn op_offset(op: &SampleOp) -> Option<&Offset> { - match op { - SampleOp::Sample { offset, .. } | SampleOp::Gather { offset, .. } => offset.as_ref(), - _ => None, - } -} - -/// Each of the `lanes` plane axes' texel offset of `o` as an `f32` (`None` on an axis a constant -/// offset leaves at 0, and every axis without an offset), which a snapped axis moves its index -/// back by where Metal drops the offset the device adds (`position::snapped_axis`). A dynamic -/// offset is read as Metal reads it ([`metal_offset`]). -pub(super) fn snap_offsets( - cx: &mut EmitCx<'_>, - fb: &mut FunctionBuilder<'_>, - o: Option<&Offset>, - lanes: u8, -) -> BResult>> { - let mut out = Vec::with_capacity(usize::from(lanes)); - match o { - None => {} - Some(Offset::Const(k)) => { - for &v in k.iter().take(usize::from(lanes)) { - // Metal's offsets lie in [-8, 7], each exact as an `f32`. - let x = v as f32; - out.push((v != 0).then(|| f32_const(fb, x.to_bits())).transpose()?); - } - } - Some(Offset::Dynamic(v, _)) => { - let ov = metal_offset(cx, fb, *v, lanes)?; - let f = f32_ty(fb)?; - for a in 0..u32::from(lanes) { - let x = if lanes == 1 { - ov - } else { - fb.composite_extract(ov, &[a])? - }; - out.push(Some(fb.convert(ConvOp::ConvertSToF, x, f)?)); - } - } - } - Ok(out) -} - /// The texel offset operand of `o` on a `lanes`-component plane: a constant's `ConstOffset`, a /// dynamic one's `Offset` as Metal reads it, which an armed offset arms /// (`FunctionBuilder::arm_offset`, [`arm_selector`]): every access it is the operand of becomes diff --git a/crates/metal2vulkan/src/lower/sampler/level.rs b/crates/metal2vulkan/src/lower/sampler/level.rs index 57baa101d..e81ac955c 100644 --- a/crates/metal2vulkan/src/lower/sampler/level.rs +++ b/crates/metal2vulkan/src/lower/sampler/level.rs @@ -141,7 +141,7 @@ pub(super) fn nearest_on_grid( /// it, by its word `word`, where the sample's level before the sampler's clamp reads `nearest` /// (an `f32`, [`nearest_on_grid`]'s, or 0 at level 0) under a nearest mip filter: that level clamped into /// the levels the word's clamp leaves ([`SamplerWord::LEVEL_MIN`], [`SamplerWord::LEVEL_MAX`]) -/// under a nearest mip filter, else 0 (a snapped sample's sampler has no mip filter there). +/// under a nearest mip filter, else 0, the one level a sampler without a mip filter reads. pub(super) fn snap_level( fb: &mut FunctionBuilder<'_>, word: SValue, diff --git a/crates/metal2vulkan/src/lower/sampler/mod.rs b/crates/metal2vulkan/src/lower/sampler/mod.rs index 18edceed7..00b60d814 100644 --- a/crates/metal2vulkan/src/lower/sampler/mod.rs +++ b/crates/metal2vulkan/src/lower/sampler/mod.rs @@ -81,22 +81,20 @@ //! ([`Lod::Base`]), and `calculate_*_lod` is undefined in Metal (`NotRepresentable`). Gradients, //! explicit levels, and gathers (which read the base level) are not tangled. //! -//! **Pixel coordinates**. Vulkan unnormalized samplers are never used: the plane coordinate (and -//! any gradient) is divided by the level-0 size in the shader, always for a constexpr pixel -//! sampler, and selected by the word of the slot's `SamplerState` specialization for a runtime -//! sampler, so the one sampling instruction reads either coordinate. A constexpr pixel sampler with -//! nearest filtering and clamp-to-edge addressing instead fetches its texel exactly, -//! `OpImageFetch(clamp(floor(coord) + offset))` ([`SampleOp::PixelFetch`]), which also takes a -//! dynamic offset. An argument buffer's sampler is known only at run time: a sample through one -//! without comparison emits both the scaled sample and that fetch, and selects the fetch where its -//! table entry's word states the state (`metal::sampler::SamplerWord::exact_fetch`); gathers and -//! comparisons stay scaled. Every other sample without comparison through a pixel sampler that -//! filters nearest reads the centre of the texel Metal floors the coordinate to, `(floor(coord) + -//! 1/2) / size` (`emit::pixel_centre`): a constexpr sampler whose state reads one texel of one -//! level, always; a runtime sampler slot's where its `SamplerState` specialization's word says the -//! bound sampler filters nearest; an argument buffer's where its word says so -//! (`metal::sampler::SamplerWord::PIXEL_NEAREST`). Comparisons stay scaled; a gather snaps from -//! the coordinate as given (below). +//! **Pixel coordinates**. Vulkan unnormalized samplers, which take no gather, offset, comparison, +//! array, 3D image or level of detail, are never used: the plane coordinate (and any gradient) is +//! divided by the level-0 size in the shader, always for a constexpr pixel sampler, and selected by +//! the word of the slot's `SamplerState` specialization for a runtime sampler, so the one sampling +//! instruction reads either coordinate. The device's sampler reads its texels from that scaled +//! coordinate in its own arithmetic, which near a texel edge or a filter step's edge may read +//! another texel or weight than Metal's at the coordinate as given +//! (`PrecisionNote::PixelSamplerScaling`, `PrecisionNote::ArgumentPixelSamplerScaling`). A +//! constexpr pixel sampler with nearest filtering and clamp-to-edge addressing instead fetches its +//! texel, `OpImageFetch(clamp(floor(coord) + offset))` ([`SampleOp::PixelFetch`]), which also +//! takes a dynamic offset on any profile. An argument buffer's sampler is known only at run time: +//! a sample through one without comparison emits both the scaled sample and that fetch, and +//! selects the fetch where its table entry's word states the state +//! (`metal::sampler::SamplerWord::exact_fetch`); gathers and comparisons stay scaled. //! //! **Texel offsets**. Metal reads each component of an offset as the two's-complement value of its //! low four bits ([`metal_offset`]), which is the identity on its documented range @@ -124,20 +122,10 @@ //! (`VkProperty::DeviceSampling`, recorded as `PrecisionNote::DeviceSampling`); the module //! requires the property. A cube's direction takes Metal's face at a tie (`face::metal_ties`). //! Every footprint Metal's rule decides in the shader (the emulated filters the device has no form -//! for, a pixel sampler's snapped coordinate) reads Metal's position ([`position`]): the coordinate -//! wrapped into one period first on a repeating or mirrored axis, then scaled with ties away from -//! zero. -//! -//! **Pixel coordinates**. Through a pixel sampler Metal's position is the coordinate as given, -//! which the device's sampler, reading the coordinate over the level's size, does not reproduce. On -//! every device a constexpr pixel sampler's nearest sample reads its texel's centre, its gather of -//! a 2D texture or array snaps from the coordinate as given, and its linear sample snaps onto the -//! centre of its footprint cell, so the device's filter reads Metal's footprint. A runtime or -//! argument buffer's sampler's gather of a 2D texture or array snaps from the coordinate as given -//! where its word states pixel coordinates (`position::SnapKind::WordGather`), and its sample snaps -//! onto its footprint cell where its word states a linear pixel sampler -//! (`position::SnapKind::WordCell`). Metal reads a cube's coordinate as a direction through a pixel -//! sampler too, so a cube's pixel sampler is a normalized one here. +//! for) reads Metal's position ([`position`]): the coordinate wrapped into one period first on a +//! repeating or mirrored axis, then scaled with ties away from zero. Metal reads a cube's +//! coordinate as a direction through a pixel sampler too, so a cube's pixel sampler is a normalized +//! one here. //! //! Not lowered yet: a static texture sampled through an argument buffer's sampler, a heap image //! sampled through several sampler candidates, the binding-array rule, and the bicubic forms @@ -540,8 +528,7 @@ pub enum Pixel { /// A constexpr pixel-coordinate sampler: always scaled. Always, /// A runtime sampler in slot `n`: scaled when its `SamplerState` specialization's word states - /// pixel coordinates, and a sample at the centre of the texel Metal floors to when the word - /// states a nearest pixel sampler. + /// pixel coordinates. Spec(u32), /// An argument buffer's sampler of heap handle `handle`, the index of its sampler table /// entry: scaled when the entry's word states pixel coordinates; a sample without comparison is @@ -574,23 +561,9 @@ pub struct Sampling { /// Metal's footprint of an observed sample or gather where the rule decides it: its word is the /// residency of exactly those texels, through the slot's sparse arm or tile map. pub footprint: Option, - /// A gather or nearest sample whose plane coordinate is snapped onto the texels Metal reads - /// ([`position`]). - pub snap: Option, /// It reads a cube by a direction, whose ties between major axes the device is handed broken /// as Metal breaks them ([`face`]). pub cube: bool, - /// A sample through a pixel sampler that reads the centre of the texel Metal floors its - /// coordinate to where the sampler filters nearest: always for a constexpr sampler whose - /// state reads one texel of one level, behind the slot's `SamplerState` specialization - /// ([`Pixel::Spec`]) or the table entry's word ([`Pixel::Heap`]), each testing the word's - /// [`centre_word`](Self::centre_word) bits. - pub centred: bool, - /// The bits of a runtime sampler's word whose value [`SamplerWord::PIXEL_COORDINATES`] states - /// a sampler that reads one texel at a [`centred`](Self::centred) sample: - /// [`SamplerWord::PIXEL_NEAREST`], or for an integer texture, which no sampler filters, - /// [`SamplerWord::PIXEL_COORDINATES`] alone. - pub centre_word: u32, /// Whether the access reads one texel of one level: its `half` texel's lanes for the class's /// conversion. pub one_texel: crate::lower::texture::OneTexel, @@ -711,8 +684,8 @@ impl Sampling { /// The shape the arms of a switch-at-use share where it emulates once (SEMANTICS 1012, /// `sampler::shared_value`): this sampling with its texture slot and sampler taken out, where /// it is an emulation on a combined binding whose residency the function does not observe: a - /// bicubic sample, or a snapped gather or sample but a runtime sampler's word snap. Arms of one shape differ only in the binding they read: each emulation states its - /// sampler's addressing in its own fields, and the device's access stays in each arm. + /// bicubic sample. Arms of one shape differ only in the binding they read: each emulation + /// states its sampler's addressing in its own fields. pub(crate) fn shared_shape(&self) -> Option { let Source::Combined(key) = self.source else { return None; @@ -734,38 +707,17 @@ impl Sampling { sampler: SamplerRef::Slot(0), ..key }); - match (&mut k.op, &k.snap) { - (SampleOp::Bicubic(b), None) => b.texture = 0, - // A runtime sampler's word snap alone is no emulation to share. - (SampleOp::Sample { .. } | SampleOp::Gather { .. }, Some(p)) if !p.by_word() => {} - _ => return None, - } + let SampleOp::Bicubic(b) = &mut k.op else { + return None; + }; + b.texture = 0; Some(k) } - /// The sampled images each arm of a switch-at-use that emulates once makes (SEMANTICS 1012): - /// one for the device's access, a snapped access's, with a second where a dynamic bias may pass - /// the device's limit; none for a bicubic sample. The facts and the taps read the image alone. - pub(crate) fn shared_sampled_images(&self) -> u32 { - match &self.op { - SampleOp::Bicubic(_) => 0, - SampleOp::Sample { - lod: - Lod::Implicit { - reach: BiasReach::Either { .. }, - .. - }, - .. - } => 2, - _ => 1, - } - } - /// The estimated words each arm of a switch-at-use that emulates once adds (SEMANTICS 1012): /// per dispatch its case, label, branch, and merge operands, and its binding's load, and in it - /// the reads of the candidate's own image: the facts' size query, an emulation's tap fetches, - /// and a snapped access with its texel's conversion. - /// [`Sampling::words`] counts the emulation once. + /// the reads of the candidate's own image: the facts' size query and the bicubic filter's tap + /// fetches. [`Sampling::words`] counts the emulation once. pub(crate) fn shared_arm_words(&self) -> u32 { // A dispatch's arm: its case, label, branch, and merge operands, the binding's loads, // `OpSampledImage` of a separate binding, and `OpImage`. @@ -773,38 +725,17 @@ impl Sampling { // A read in an arm: the fetch or access with its operands, and its merge operands. const READ: u32 = 16; let facts = ARM + 3 * READ; - let half = match self.texel { - Some(f) if f.conv == crate::lower::texture::TexelConv::F16 => { - crate::lower::texture::half::CALL_WORDS.max(f.read_words()) - } - Some(f) => f.read_words(), - None => 0, + let SampleOp::Bicubic(b) = &self.op else { + return facts; }; - match (&self.op, &self.snap) { - (SampleOp::Bicubic(b), _) => { - // A 1D texture's one row of two taps, else each row of four and the half sum's - // row its loop reads. - let (rows, taps) = if b.address.len() == 1 { (2, 2) } else { (5, 4) }; - facts + rows * (ARM + taps * READ) - } - (SampleOp::Sample { lod, .. }, Some(_)) => { - let beyond = match lod { - Lod::Implicit { - reach: BiasReach::Either { .. }, - .. - } => ARM + 2 * READ, - _ => 0, - }; - facts + ARM + READ + half + beyond - } - _ => facts + ARM + READ + half, - } + // A 1D texture's one row of two taps, else each row of four and the half sum's row its + // loop reads. + let (rows, taps) = if b.address.len() == 1 { (2, 2) } else { (5, 4) }; + facts + rows * (ARM + taps * READ) } - /// The census name; a heap element's names its operation, one through an argument buffer's - /// sampler its operation too, and a texture slot's snapped gather is `sampler.gather.snapped` - /// or `sampler.gather_compare.snapped`, and a pixel sampler's linear sample snapped onto its - /// footprint cell `sampler.linear.snapped`. + /// The census name; a heap element's names its operation, and one through an argument buffer's + /// sampler its operation too. pub fn name(&self) -> &'static str { let compares = matches!(self.op, SampleOp::Gather { dref: Some(_), .. }); if let Source::HeapSampler { .. } = self.source { @@ -827,25 +758,6 @@ impl Sampling { SampleOp::QueryLevel { .. } => "sampler.heap.query_level", }; } - // A snapped coordinate; a runtime sampler's word snap keeps its operation's name, the snap - // one part of it. - if let Some(snap) = &self.snap { - let snapped = match (snap.kind, &self.op) { - (position::SnapKind::Axes(position::AxisSnap::Gather), _) if compares => { - Some("sampler.gather_compare.snapped") - } - (position::SnapKind::Axes(position::AxisSnap::Gather), _) => { - Some("sampler.gather.snapped") - } - (position::SnapKind::Axes(position::AxisSnap::Cell), _) => { - Some("sampler.linear.snapped") - } - (position::SnapKind::WordGather | position::SnapKind::WordCell { .. }, _) => None, - }; - if let Some(name) = snapped { - return name; - } - } match &self.op { SampleOp::Sample { lod: @@ -903,9 +815,8 @@ impl Sampling { /// `bias_gradients`, and (for a dynamic bias) the test, the selection, and the second sample, a /// `half` texel's call of its conversion routine or its exact rounding outside the bicubic /// filter, an sRGB texel's raw decode, a cube gradient's footprint, an argument buffer's pixel - /// sampler's flagged fetch, a snapped coordinate and the positions of an observed footprint, - /// the lanes Metal reads as constants, a cube direction's broken ties, a runtime pixel - /// sampler's texel centre, and a raw heap sample's decode. + /// sampler's flagged fetch, the positions of an observed footprint, the lanes Metal reads as + /// constants, a cube direction's broken ties, and a raw heap sample's decode. pub fn words(&self) -> u32 { // A swizzled slot's sampling: its swizzle, and a gather's of each component. match (self.swizzle, &self.op) { @@ -1000,21 +911,12 @@ impl Sampling { _ => 0, }; // An argument buffer's sampler reads its entry's word for each test of it: its pixel - // coordinates, its exact fetch, and its texel centre. + // coordinates and its exact fetch. let word = match self.pixel { - Pixel::Heap(_) => { - (1 + u32::from(fetch != 0) + u32::from(self.centred)) * ENTRY_FIELD_WORDS - } + Pixel::Heap(_) => (1 + u32::from(fetch != 0)) * ENTRY_FIELD_WORDS, _ => 0, }; - // The snapped coordinate, and the position of each axis of Metal's footprint of an observed - // sample or gather. - let snap = self.snap.as_ref().map_or(0, position::Snap::words) - + self - .snap - .as_ref() - .filter(|_| offset.is_some()) - .map_or(0, position::Snap::offset_words); + // The position of each axis of Metal's footprint of an observed sample or gather. let footprint = self .footprint .map_or(0, |fp| u32::from(fp.axes) * position::POSITION_WORDS); @@ -1037,13 +939,11 @@ impl Sampling { + half + fetch + word - + snap + footprint + parent + unmapped + if self.cube { face::TIE_WORDS } else { 0 } + if self.pixel == Pixel::None { 0 } else { 48 } - + if self.centred { PIXEL_CENTRE_WORDS } else { 0 } + self.heap_raw.as_ref().map_or(0, heap_raw::HeapRaw::words) } } @@ -1057,11 +957,6 @@ const SWIZZLE_WORDS: u32 = extended::SWIZZLE_WORDS; /// specialization constants), the construction, and their constants, at most 8 words each. pub const CONSTANT_LANES_WORDS: u32 = 4 * 3 * 8 + 16; -/// The estimated words of a pixel sampler's texel centre (`emit::pixel_centre`): its floor, -/// addition, scaling (a shuffle, a conversion, and a division), an argument buffer's handle test (a -/// mask and a comparison), and the select, and their constants, at most 8 words each. -pub const PIXEL_CENTRE_WORDS: u32 = 96; - /// A runtime sampler slot the function samples with. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct RuntimeSlot { @@ -1071,10 +966,6 @@ pub struct RuntimeSlot { /// A coordinate-sensitive operation uses it (`SamplerCoordinates`): the function reads its /// word's pixel coordinates. pub coordinates: bool, - /// A sample without comparison (not a gather) reads it with coordinates that may be pixels - /// ([`Sampling::centred`]): the function reads whether its word states a nearest pixel - /// sampler. - pub nearest: bool, /// An extended-range or heap raw texture's emulated filter reads it: the function reads its /// word's filter, coordinates, address modes, and border color. pub linear: bool, @@ -1084,12 +975,6 @@ pub struct RuntimeSlot { /// A cube's explicit gradients take their footprint by its word (`CubeFootprint::Word`): the /// function reads whether its word is anisotropic. pub anisotropy: bool, - /// A 2D gather snaps behind its word (`position::SnapKind::WordGather`): the function reads its - /// word's coordinates and its `s` and `t` address modes. - pub gathers: bool, - /// A sample snaps onto its footprint cell behind its word (`position::SnapKind::WordCell`): - /// the function reads whether its word states a linear pixel sampler. - pub cells: bool, /// A sample's `half` texel converts by the bound format's class where the sampler reads one /// texel of one level (`texture::OneTexel::Word`), on a device that samples through Metal's /// own sampler (`VkProperty::MetalSampler`): the function reads its word's filter fields. @@ -1105,48 +990,12 @@ pub struct RuntimeSlot { impl RuntimeSlot { /// The fields of the slot's sampler word the function reads: the mask of its - /// `SpecKey::SamplerState` specialization, with [`SamplerWord::PIXEL_GATED`] where it reads - /// fields beyond the coordinates only through the pixel tests ([`gated`](Self::gated)). + /// `SpecKey::SamplerState` specialization. pub fn fields(&self) -> u32 { - let fields = self.read_fields(); - match self.gated() && fields & !SamplerWord::PIXEL_COORDINATES != 0 { - true => fields | SamplerWord::PIXEL_GATED, - false => fields, - } - } - - /// Whether every read of the slot's word is the pixel coordinates bit itself, or a test that - /// fails where it is clear: the centre test (whether the word states a nearest pixel sampler, - /// `emit::word_states`), the footprint cell's (whether it states a linear pixel sampler, - /// `position::celled_by_word`), and the coordinates' (`SamplerCoordinates`). Every other use - /// reads fields that matter for normalized coordinates too. - pub fn gated(&self) -> bool { - let RuntimeSlot { - slot: _, - compare: _, - coordinates: _, - nearest: _, - cells: _, - min_level: _, - linear, - fetch_levels, - anisotropy, - gathers, - texels, - emulated, - } = *self; - ![linear, fetch_levels, anisotropy, emulated, gathers, texels].contains(&true) - } - - /// The fields the slot's uses read of its word, without [`SamplerWord::PIXEL_GATED`]. - fn read_fields(&self) -> u32 { let mut fields = 0; if self.coordinates { fields |= SamplerWord::PIXEL_COORDINATES; } - if self.nearest { - fields |= SamplerWord::PIXEL_NEAREST; - } if self.linear { fields |= SamplerWord::LINEAR_STATE; } @@ -1159,14 +1008,6 @@ impl RuntimeSlot { if self.emulated { fields |= SamplerWord::ANISOTROPIC | SamplerWord::MIP_FILTER; } - if self.gathers { - fields |= - SamplerWord::PIXEL_COORDINATES | SamplerWord::ADDRESS[0] | SamplerWord::ADDRESS[1]; - } - if self.cells { - fields |= - SamplerWord::PIXEL_COORDINATES | SamplerWord::MIN_LINEAR | SamplerWord::MAG_LINEAR; - } if self.texels { fields |= SamplerWord::LINEAR_FILTER; } @@ -1666,12 +1507,9 @@ pub fn select_param(cx: &mut SelectCx<'_>, b: &ParamBinding) -> Result<(), Error slot, compare: false, coordinates: false, - nearest: false, linear: false, fetch_levels: false, anisotropy: false, - gathers: false, - cells: false, texels: false, min_level: false, emulated: false, diff --git a/crates/metal2vulkan/src/lower/sampler/position.rs b/crates/metal2vulkan/src/lower/sampler/position.rs index 814f00965..ed6896df8 100644 --- a/crates/metal2vulkan/src/lower/sampler/position.rs +++ b/crates/metal2vulkan/src/lower/sampler/position.rs @@ -1,5 +1,6 @@ -//! Metal's texel-space position of a normalized coordinate, and the coordinate that makes a -//! device's gather or linear sample of a pixel sampler read the texels Metal reads. +//! Metal's texel-space position of a normalized coordinate, which the filters the device has no +//! form for read their footprints from (`bicubic`, `extended`, `heap_raw`, `in_place`, and the +//! residency `footprint`), and Metal's placement of a texel offset on a repeating or mirrored axis. //! //! **The position** (Apple M3 Max, macOS 26.7, and Apple M4, macOS 27.0.1, byte-identical; the //! tie, gather, and bicubic probes). Per axis of size `N` and normalized coordinate `u`, Apple's @@ -72,9 +73,8 @@ //! above the base through a view of that one level, which reads exactly as the level does: the //! view's parent's base-level size decides. //! -//! An emulated footprint applies the rule to its taps (`bicubic::axis`), and a snapped axis that -//! repeats or mirrors subtracts the offset the device will add where Metal drops it -//! ([`snapped_axis`]). The base-level size the rule reads is a view's parent's, which a shader +//! An emulated footprint applies the rule to its taps (`bicubic::axis`). The base-level size the +//! rule reads is a view's parent's, which a shader //! cannot query: a view whose first level lies above its parent's base reads the bound view's //! own, so on an axis of size 2 or 4 under a parent base that is not a power of two (where the //! view's base is) the rule would keep the offset Metal drops. The binder states those axes in the @@ -82,55 +82,22 @@ //! whose tests (`texture::OffsetBase`) the rule reads; a heap element's access reads none, and //! records `PrecisionNote::ViewBaseTexelOffset` (the residue there). //! -//! **The snapped coordinate** ([`snapped`]). A pixel sampler's coordinate, scaled for the -//! device, reads whichever texels the device's own arithmetic gives near a texel edge. Where -//! Metal's texels follow from the coordinate as given, a snapped axis instead hands the device a -//! coordinate half a step from every edge of them: a gather's `(i0 + 1) / N`, the centre of its -//! 2x2 block ([`AxisSnap::Gather`]), and a linear sample's footprint cell ([`AxisSnap::Cell`]), -//! with `i0` and the cell from Metal's position. Any device's rounding then reads Metal's block or -//! step, and the device keeps everything else: the texel conversion, the filter's weights, the -//! border, the comparison, the offset (added to the snapped index, then wrapped or clamped, as -//! Metal adds it), and the layer. A gather's `i0` is computed in `f32`, `floor(floor(256 X + 1/2) -//! / 256 - 1/2)`, exact for `|X| < 2^15` (every position of a Metal texture's repeating or mirrored -//! axis, at most `2N`, included). On a clamping axis `i0` is first clamped into `[-10, N + 8]`: -//! past either end, with any offset in Metal's gather range `[-8, 7]`, both texels lie outside the -//! level on the same side, so they read the same edge texels or border as the exact `i0` would, -//! and the coordinate stays small. On a repeating or mirrored axis whose size drops the offset -//! ([`offset_dropped`]), the snapped index is first moved back by the offset, which the device then -//! adds: the device reads the texel or block Metal reads there, the one without the offset. -//! -//! **A runtime or argument buffer's sampler** names its state in its word, read in the function: -//! where the word states pixel coordinates, its gather of a 2D texture or array snaps behind it -//! ([`gathered_by_word`]), each axis at the coordinate as given, with `i0` clamped into the wider -//! `[-2N - 10, 2N + 8]`, which holds every position of a repeating or mirrored axis and reads a -//! clamping axis's same edge texels or border; and where it also states linear min and mag -//! filters, its sample snaps onto its footprint cell ([`celled_by_word`]), as a constexpr pixel -//! sampler's does (that sample reads Metal's rule at the coordinate as given: our probe's 10,250 -//! lanes of a runtime pixel sampler on both chips). A normalized word's gather and every other -//! word's sample keep the device's coordinate. On a `MirrorClampToEdge` axis (which no constexpr -//! sampler states) Metal's position is a clamping axis's, `u N` unwrapped, its taps mirrored once -//! and clamped as Vulkan's `MIRROR_CLAMP_TO_EDGE` mirrors and clamps them ([`position_by_mode`]), -//! and a texel offset is dropped by the sizes that drop it on a repeating axis (every gather of -//! 13x11, 7x5 and 16x8 textures through a slot's and an argument buffer's runtime sampler, with -//! offsets of 2 and -3, on an Apple M3 Max and an Apple M4 alike), a pixel coordinate's as a -//! normalized one's, and a pixel word's texel centre moves back by a dropped offset -//! (`emit::pixel_centre`). +//! **A runtime sampler's position** ([`position_by_mode`]): an emulation of a runtime or argument +//! buffer's sampler reads the address mode from the sampler's word in the function. On a +//! `MirrorClampToEdge` axis (which no constexpr sampler states) Metal's position is a clamping +//! axis's, `u N` unwrapped, its taps mirrored once and clamped as Vulkan's `MIRROR_CLAMP_TO_EDGE` +//! mirrors and clamps them, and a texel offset is dropped by the sizes that drop it on a repeating +//! axis (every gather of 13x11, 7x5 and 16x8 textures through a slot's and an argument buffer's +//! runtime sampler, with offsets of 2 and -3, on an Apple M3 Max and an Apple M4 alike), a pixel +//! coordinate's as a normalized one's. -use crate::air::abi::{AddressMode, Coordinates, Filter}; -use crate::air::intrinsics::{ImageDim, ImageShape}; -use crate::error::Error; -use crate::lower::emit::EmitCx; -use crate::lower::select::SelectCx; -use crate::lower::texture::OffsetBase; use crate::metal::SamplerAddressMode; -use crate::pipeline::sym::SamplerRef; use crate::spirv::builder::FunctionBuilder; use crate::spirv::error::BResult; use crate::spirv::ids::Value as SValue; -use crate::spirv::ir::{BinOp, ConstBits, Constant, ConvOp, GlslOp, ImageQuery, Type as SType}; +use crate::spirv::ir::{BinOp, ConstBits, Constant, ConvOp, GlslOp, Type as SType}; use super::bicubic::TapAddress; -use super::{CombinedImage, SampleOp}; /// The census words of one axis's [`position`]: the conversion of the size, the wrap (a mirrored /// axis's four instructions, and the rounding's thirteen, which choose up or down by the size), the @@ -138,216 +105,6 @@ use super::{CombinedImage, SampleOp}; /// mirrored axis). Every estimate that emits a position adds it per axis. pub const POSITION_WORDS: u32 = 200; -/// How the texels a snapped plane axis hands the device follow from the position. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -pub enum AxisSnap { - /// A gather's 2x2 block: the coordinate `(i0 + 1) / N`. - Gather, - /// A linear sample's footprint cell: the coordinate `(floor(256 X - 127.5) + 128) / 256 / N`, - /// the centre of the `1/256` step `q` Metal's filter reads `X` as, half a step from either edge - /// of it. - Cell, -} - -/// What a snap hands the device. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -pub enum SnapKind { - /// The plane coordinate with [`Snap::axes`]' axes snapped. - Axes(AxisSnap), - /// A runtime or argument buffer's sampler's gather of a 2D texture or 2D array: behind the - /// sampler's word, where it states pixel coordinates, each plane axis takes - /// [`AxisSnap::Gather`]'s coordinate, the centre of the 2x2 block Metal reads at the coordinate - /// as given ([`gathered_by_word`]); a normalized coordinate is the device's gather's. - /// [`Snap::axes`] is empty: the word names the modes. - WordGather, - /// A runtime or argument buffer's sampler's sample of a texture of `axes` plane axes: where - /// the word states pixel coordinates - /// and linear min and mag filters, each plane axis takes [`AxisSnap::Cell`]'s coordinate, the - /// centre of the footprint step Metal reads the coordinate as given at, as a constexpr linear - /// pixel sampler's sample does there ([`celled_by_word`]); every other word keeps the scaled - /// coordinate. [`Snap::axes`] is empty. - WordCell { axes: u8 }, -} - -/// A gather or linear sample whose coordinate is snapped onto Metal's texels (module docs). -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -pub struct Snap { - pub kind: SnapKind, - /// Per plane axis (`s`, then `t`, then `r`), its addressing where the axis is snapped, or - /// `None` where the device reads the coordinate as given. - pub axes: Vec>, -} - -impl Snap { - /// A runtime or argument buffer's sampler's snap behind its word ([`SnapKind::WordGather`], - /// [`SnapKind::WordCell`]). - pub fn by_word(&self) -> bool { - matches!(self.kind, SnapKind::WordGather | SnapKind::WordCell { .. }) - } - - /// The census words: the image and its size query; per snapped plane axis the extractions, the - /// [`position`], the index and its clamp, and the coordinate, and the composite. - pub fn words(&self) -> u32 { - // The coordinate is in texels: Metal's position `X` is the coordinate as given. - let per_axis = 8 + match self.kind { - SnapKind::Axes(AxisSnap::Gather) => GATHER_AXIS_WORDS, - SnapKind::Axes(AxisSnap::Cell) => CELL_AXIS_WORDS, - SnapKind::WordGather => { - return 32 + WORD_REACH_WORDS + 2 * (8 + GATHER_AXIS_WORDS + WORD_AXIS_WORDS); - } - SnapKind::WordCell { axes } => { - return 32 - + WORD_REACH_WORDS - + u32::from(axes) * (8 + CELL_AXIS_WORDS + WORD_AXIS_WORDS); - } - }; - let snapped = self.axes.iter().filter(|a| a.is_some()).count() as u32; - 32 + snapped * per_axis + self.axes.len() as u32 * 8 - } - - /// The census words of the offset rule ([`offset_dropped`]) on each axis this snap may move - /// back, for an access with a texel offset: each snapped plane axis's, and each axis of a word - /// gather. - pub fn offset_words(&self) -> u32 { - let axes = match self.kind { - // The device's sampler places a pixel cell's. - SnapKind::WordCell { .. } => 0, - SnapKind::WordGather => 2, - SnapKind::Axes(_) => self.axes.iter().filter(|a| a.is_some()).count() as u32, - }; - axes * OFFSET_RULE_WORDS - } -} - -/// A gather axis's words past its position: the two extractions, `i0` (six instructions and their -/// constants), its clamp, and the coordinate. -const GATHER_AXIS_WORDS: u32 = 96; -/// A footprint cell's words past its position: the two extractions, the step (seven instructions -/// and their constants), and the coordinate. -const CELL_AXIS_WORDS: u32 = 96; -/// A word snap's test of its word (`SamplerWord::PIXEL_COORDINATES`, and a cell's linear filters): -/// the mask, the comparison, and their constants. -const WORD_REACH_WORDS: u32 = 24; -/// A word snap's axis words past its snapped coordinate: the extractions of the coordinate as -/// given and the device's, the size's conversion, a gather's widened clamp, and the select. -const WORD_AXIS_WORDS: u32 = 64; -/// The tap addressing of address mode `m`. -pub(super) fn address(m: AddressMode) -> TapAddress { - match m { - AddressMode::ClampToEdge => TapAddress::Edge, - AddressMode::Repeat => TapAddress::Repeat, - AddressMode::MirroredRepeat => TapAddress::Mirror, - AddressMode::ClampToZero | AddressMode::ClampToBorder => TapAddress::Border, - } -} - -/// The snap of `op` on a texture of `shape` through the static sampler `stat` (`None`: an -/// argument buffer's), where the module docs snap it. A pixel sampler's coordinate is Metal's -/// position as given, which the device's sampler, reading the coordinate over the size, does not -/// reproduce, its own or Metal's alike. So on every device: -/// -/// - a constexpr pixel sampler's gather of a 2D texture or 2D array snaps both plane axes from the -/// coordinate as given; -/// - a runtime or argument buffer's sampler's gather of a 2D texture or 2D array snaps behind the -/// sampler's word, where it states pixel coordinates ([`SnapKind::WordGather`]); -/// - a constexpr pixel sampler's linear sample of a 1D, 2D, or 3D texture or array with a -/// floating-point texel (an `integer` one's reads one texel) snaps every plane axis onto the -/// centre of its footprint cell, unless the sampler is anisotropic; -/// - a runtime or argument buffer's sampler's sample of such a texture, a comparison's included, -/// snaps onto its footprint cell where its word states a linear pixel sampler -/// ([`SnapKind::WordCell`]). -/// -/// Every other gather and sample is the device's, and the module requires the device's sampler -/// (`SamplerFamily::metal_sampler`). A cube's coordinate is a direction through a pixel sampler -/// too, so a cube takes no snap. -pub(super) fn plan( - cx: &mut SelectCx<'_>, - op: &SampleOp, - stat: Option<(SamplerRef, Coordinates)>, - (shape, integer): (ImageShape, bool), -) -> Result, Error> { - // A constexpr sampler's state, and whether its coordinate is in texels (not a cube's). - let state = match stat { - Some((SamplerRef::Constexpr(words), c)) => Some(( - super::state_of(words)?, - c == Coordinates::Pixel && shape.dim != ImageDim::Cube, - )), - _ => None, - }; - // The plane axes of a 1D, 2D, or 3D texture or array, single-sampled. - let plane = match (shape.dim, shape.ms) { - (ImageDim::D1, false) => 1, - (ImageDim::D2, false) => 2, - (ImageDim::D3, false) => 3, - _ => 0, - }; - match op { - SampleOp::Gather { .. } => match state { - Some((s, true)) if shape.dim == ImageDim::D2 && !shape.ms => Ok(Some(Snap { - kind: SnapKind::Axes(AxisSnap::Gather), - axes: vec![Some(address(s.address_s)), Some(address(s.address_t))], - })), - // A runtime or argument buffer's sampler's gather, behind its word. The device's own - // gather of a normalized coordinate is its block: the word snaps a pixel coordinate - // alone, and the module requires the device's sampler. - None if shape.dim == ImageDim::D2 && !shape.ms => { - cx.families.sampler.metal_sampler = true; - Ok(Some(Snap { - kind: SnapKind::WordGather, - axes: Vec::new(), - })) - } - _ => { - cx.families.sampler.metal_sampler = true; - Ok(None) - } - }, - // A linear pixel sample's footprint cell. - SampleOp::Sample { dref: None, .. } - if state.as_ref().is_some_and(|(s, pixel)| { - *pixel - && plane > 0 - && !integer - && s.min_filter == Filter::Linear - && s.mag_filter == Filter::Linear - }) => - { - let Some((s, _)) = state else { - return Ok(None); - }; - if s.max_anisotropy > 1 { - return Ok(None); - } - Ok(Some(Snap { - kind: SnapKind::Axes(AxisSnap::Cell), - axes: [s.address_s, s.address_t, s.address_r] - .into_iter() - .take(plane) - .map(|m| Some(address(m))) - .collect(), - })) - } - // A runtime or argument buffer's sampler's sample, a comparison's included, onto its - // footprint cell where its word states a linear pixel sampler, as a constexpr one's. An - // integer texture's sample reads one texel whatever the filters say, its pixel sampler's - // texel centre. - SampleOp::Sample { .. } - if plane > 0 && !integer && !matches!(stat, Some((SamplerRef::Constexpr(_), _))) => - { - cx.families.sampler.metal_sampler = true; - Ok(Some(Snap { - kind: SnapKind::WordCell { axes: plane as u8 }, - axes: Vec::new(), - })) - } - SampleOp::Sample { dref: None, .. } => { - cx.families.sampler.metal_sampler = true; - Ok(None) - } - _ => Ok(None), - } -} - fn f32_const(fb: &mut FunctionBuilder<'_>, x: f32) -> BResult { let ty = fb.module().ty(SType::Float { width: 32 })?; let c = fb.module().constant(Constant::Scalar { @@ -362,9 +119,9 @@ fn u32_const(fb: &mut FunctionBuilder<'_>, x: u32) -> BResult { fb.module().const_value(c) } -/// The census words of [`offset_dropped`] and of a snapped axis's compensation by it: the -/// subtractions, the comparisons, the mask and their conjunction, the select, the subtraction from -/// the index, and their constants, in the leveled form (the larger). +/// The census words of [`offset_dropped`] and of a footprint's placement of the offset by it: the +/// subtractions, the comparisons, the mask and their conjunction, the select, and their constants, +/// in the leveled form (the larger). pub const OFFSET_RULE_WORDS: u32 = 64; /// Whether Metal drops a constant texel offset on a repeating or mirrored axis whose level size is @@ -409,7 +166,7 @@ pub fn offset_dropped( } /// The census words a slot's `SpecKey::OffsetBaseAxes` test adds to [`offset_dropped`] on each -/// plane axis an offset moves, per footprint, snap or centre that places it: the general rule's +/// plane axis an offset moves, per footprint that places it: the general rule's /// words where they replace the base level's shorter ones, the disjunction, and their constants, /// and a share of the slot's tests' declaration (a specialization constant and three /// `OpSpecConstantOp` tests per axis, `texture::OffsetBase`). @@ -554,244 +311,5 @@ fn wrap( fb.convert(ConvOp::Bitcast, bs, f) } -/// A gather's base texel `i0` (an `f32`) at position `x`: `floor(floor(256 x + 1/2) / 256 - 1/2)`, -/// the `q >> 8`, exact for `|x| < 2^15` (module docs). -fn gather_base(fb: &mut FunctionBuilder<'_>, x: SValue) -> BResult { - let k256 = f32_const(fb, 256.0)?; - let y = fb.binary(BinOp::FMul, x, k256)?; - let half = f32_const(fb, 0.5)?; - let y = fb.binary(BinOp::FAdd, y, half)?; - let z = fb.glsl(GlslOp::Floor, &[y])?; - let step = f32_const(fb, 1.0 / 256.0)?; - let z = fb.binary(BinOp::FMul, z, step)?; - let z = fb.binary(BinOp::FSub, z, half)?; - fb.glsl(GlslOp::Floor, &[z]) -} - -/// Component `i` of `v`, or `v` itself for a one-lane value. -fn lane(fb: &mut FunctionBuilder<'_>, v: SValue, lanes: u8, i: u32) -> BResult { - if lanes == 1 { - Ok(v) - } else { - fb.composite_extract(v, &[i]) - } -} - -/// The snapped axis coordinate (an `f32`) of coordinate `u` (in texels, Metal's position as -/// given) on an axis of size `n` (a `u32`) addressed by `address`, -/// for `kind` (module docs), whose access the device moves by the constant texel offset `offset` -/// (an `f32` holding the axis's offset; `None`: none): on a repeating or mirrored axis whose size -/// drops it ([`offset_dropped`], whose `parent` is the axis's `texture::OffsetBase` test), the -/// index is moved back by it first. -pub fn snapped_axis( - fb: &mut FunctionBuilder<'_>, - kind: AxisSnap, - x: SValue, - n: SValue, - (address, offset, parent): (TapAddress, Option, Option), -) -> BResult { - let f = fb.module().ty(SType::Float { width: 32 })?; - let nf = fb.convert(ConvOp::ConvertUToF, n, f)?; - let at = match kind { - AxisSnap::Gather => { - let i0 = gather_base(fb, x)?; - let i0 = match address { - TapAddress::Edge | TapAddress::Border => { - let lo = f32_const(fb, -10.0)?; - let eight = f32_const(fb, 8.0)?; - let hi = fb.binary(BinOp::FAdd, nf, eight)?; - fb.glsl(GlslOp::FClamp, &[i0, lo, hi])? - } - TapAddress::Repeat | TapAddress::Mirror => i0, - }; - let one = f32_const(fb, 1.0)?; - fb.binary(BinOp::FAdd, i0, one)? - } - // `q + 128 = floor(256 X) + [frac(256 X) >= 1/2]`, as `bicubic::quantize` reads `q`: - // `256 X`, its floor, and its fraction are exact, where `256 X - 127.5` can round (a - // negative `X` whose sum carries into the next binade). The centre `(q + 128) / 256` is - // exact below `|X| = 2^15`. - AxisSnap::Cell => { - let k256 = f32_const(fb, 256.0)?; - let y = fb.binary(BinOp::FMul, x, k256)?; - let fl = fb.glsl(GlslOp::Floor, &[y])?; - let r = fb.binary(BinOp::FSub, y, fl)?; - let half = f32_const(fb, 0.5)?; - let up = fb.binary(BinOp::FOrdGreaterThanEqual, r, half)?; - let one = f32_const(fb, 1.0)?; - let zero = f32_const(fb, 0.0)?; - let up = fb.select(up, one, zero)?; - let c = fb.binary(BinOp::FAdd, fl, up)?; - let step = f32_const(fb, 1.0 / 256.0)?; - fb.binary(BinOp::FMul, c, step)? - } - }; - let at = match (address, offset) { - (TapAddress::Repeat | TapAddress::Mirror, Some(o)) => { - let dropped = offset_dropped(fb, n, None, parent)?; - let none = f32_const(fb, 0.0)?; - let back = fb.select(dropped, o, none)?; - fb.binary(BinOp::FSub, at, back)? - } - _ => at, - }; - fb.binary(BinOp::FDiv, at, nf) -} - -/// The coordinate `coord` (`lanes` floats, in texels) of a sample or gather of sampled image `si` (image facts `image`) snapped by `snap` (module docs) on -/// the base level's size: a normalized coordinate. `offsets` holds, per plane axis, the constant -/// texel offset the device adds to the access (an `f32`, or `None`; [`snapped_axis`]), and -/// `parent` the slot's `SpecKey::OffsetBaseAxes` tests (`texture::OffsetBase`). -pub fn snapped( - cx: &mut EmitCx<'_>, - fb: &mut FunctionBuilder<'_>, - snap: &Snap, - (coord, offsets, parent): (SValue, &[Option], Option), - lanes: u8, - (si, image): (SValue, CombinedImage), -) -> BResult { - let img = fb.image(si)?; - let zero = u32_const(fb, 0)?; - let size = fb.query(ImageQuery::SizeLod(zero), img)?; - snapped_on(cx, fb, snap, (coord, offsets, parent), lanes, (size, image)) -} - -/// The coordinate `coord` (`lanes` floats) snapped by `snap` (module docs) on the base level's -/// size `size` of an image with facts `image`: a plane coordinate's axes. `offsets` holds each -/// plane axis's constant texel offset the device adds ([`snapped_axis`]), and `parent` the slot's -/// `SpecKey::OffsetBaseAxes` tests (`texture::OffsetBase`). -pub fn snapped_on( - cx: &mut EmitCx<'_>, - fb: &mut FunctionBuilder<'_>, - snap: &Snap, - (coord, offsets, parent): (SValue, &[Option], Option), - lanes: u8, - (size, image): (SValue, CombinedImage), -) -> BResult { - let size_lanes = image.plane + u8::from(image.arrayed); - let kind = match snap.kind { - SnapKind::Axes(kind) => kind, - SnapKind::WordGather | SnapKind::WordCell { .. } => { - return Err(cx.fail("a word snap without its sampler's word")) - } - }; - let mut parts = Vec::with_capacity(usize::from(lanes)); - for (a, axis) in (0u32..).zip(&snap.axes).take(usize::from(lanes)) { - let u = lane(fb, coord, lanes, a)?; - parts.push(match axis { - Some(address) => { - let n = lane(fb, size, size_lanes, a)?; - let offset = offsets.get(a as usize).copied().flatten(); - let parent = OffsetBase::axis(parent, a); - snapped_axis(fb, kind, u, n, (*address, offset, parent))? - } - None => u, - }); - } - if let [x] = parts[..] { - return Ok(x); - } - let f = fb.module().ty(SType::Float { width: 32 })?; - let ty = fb.module().ty(SType::Vector { - elem: f, - len: lanes, - })?; - fb.composite_construct(ty, &parts) -} - -/// The plane coordinate of `parts` (one `f32` per plane axis). -fn composite(fb: &mut FunctionBuilder<'_>, parts: Vec) -> BResult { - if let [x] = parts[..] { - return Ok(x); - } - let f = fb.module().ty(SType::Float { width: 32 })?; - let ty = fb.module().ty(SType::Vector { - elem: f, - len: parts.len() as u8, - })?; - fb.composite_construct(ty, &parts) -} - -/// Whether sampler word `word` (a `u32`) masked by `mask` holds every bit of `mask`, a `bool`. -fn word_holds(fb: &mut FunctionBuilder<'_>, word: SValue, mask: u32) -> BResult { - let m = u32_const(fb, mask)?; - let have = fb.binary(BinOp::BitwiseAnd, word, m)?; - fb.binary(BinOp::IEqual, have, m) -} - -/// The coordinate of a runtime or argument buffer's sampler's 2D gather, its sampler's word -/// `word`, snapped by [`SnapKind::WordGather`] on the base level's size `size` (`size_lanes` -/// components): where the word states pixel coordinates, per plane axis the centre `(i0 + 1) / N` -/// of the 2x2 block Metal reads ([`AxisSnap::Gather`]), its base texel `i0` at Metal's position, -/// the coordinate as given (`given`, `lanes` floats); for a normalized word the coordinate the -/// device reads otherwise (`scaled`, `lanes` floats). `i0` is clamped into `[-2N - 10, 2N + 8]`, -/// past which, with any offset in Metal's gather range `[-8, 7]`, both texels of a clamping or -/// mirror-clamped axis read the same edge texel or border, as the exact `i0`'s do. The device's -/// sampler places an offset of the normalized centre (Metal's own drops it where it drops the -/// pixel coordinate's), so no offset moves it. -pub fn gathered_by_word( - fb: &mut FunctionBuilder<'_>, - word: SValue, - (given, scaled): (SValue, SValue), - lanes: u8, - (size, size_lanes): (SValue, u8), -) -> BResult { - use crate::metal::sampler::SamplerWord; - let pixel = word_holds(fb, word, SamplerWord::PIXEL_COORDINATES)?; - let f = fb.module().ty(SType::Float { width: 32 })?; - let lo = f32_const(fb, -10.0)?; - let eight = f32_const(fb, 8.0)?; - let one = f32_const(fb, 1.0)?; - let mut parts = Vec::with_capacity(usize::from(lanes)); - for a in 0..u32::from(lanes) { - let x = lane(fb, given, lanes, a)?; - let device = lane(fb, scaled, lanes, a)?; - let n = lane(fb, size, size_lanes, a)?; - let nf = fb.convert(ConvOp::ConvertUToF, n, f)?; - let i0 = gather_base(fb, x)?; - let twice = fb.binary(BinOp::FAdd, nf, nf)?; - let hi = fb.binary(BinOp::FAdd, twice, eight)?; - let low = fb.binary(BinOp::FSub, lo, twice)?; - let i0 = fb.glsl(GlslOp::FClamp, &[i0, low, hi])?; - let at = fb.binary(BinOp::FAdd, i0, one)?; - let centre = fb.binary(BinOp::FDiv, at, nf)?; - parts.push(fb.select(pixel, centre, device)?); - } - composite(fb, parts) -} - -/// The coordinate of a runtime or argument buffer's sampler's sample, its sampler's word `word`, -/// snapped by [`SnapKind::WordCell`] on the -/// base level's size `size` (`size_lanes` components): where the word states pixel coordinates and -/// linear min and mag filters, each plane axis of the coordinate as given (`given`, `lanes` floats) -/// onto the centre of its footprint step ([`AxisSnap::Cell`]); for every other word the coordinate -/// the device reads otherwise (`scaled`). A pixel sampler clamps every axis or mirrors it once and -/// clamps it (`runtime::sampler`'s rule), and the device's sampler places a texel offset of the -/// normalized cell (Metal's own as Metal places the pixel coordinate's: kept on a clamping axis, -/// dropped by a mirror-clamped one's sizes alike), so no offset moves the cell. -pub fn celled_by_word( - fb: &mut FunctionBuilder<'_>, - word: SValue, - (given, scaled): (SValue, SValue), - lanes: u8, - (size, size_lanes): (SValue, u8), -) -> BResult { - use crate::metal::sampler::SamplerWord; - let reach = word_holds( - fb, - word, - SamplerWord::PIXEL_COORDINATES | SamplerWord::MIN_LINEAR | SamplerWord::MAG_LINEAR, - )?; - let mut parts = Vec::with_capacity(usize::from(lanes)); - for a in 0..u32::from(lanes) { - let x = lane(fb, given, lanes, a)?; - let device = lane(fb, scaled, lanes, a)?; - let n = lane(fb, size, size_lanes, a)?; - let cell = snapped_axis(fb, AxisSnap::Cell, x, n, (TapAddress::Edge, None, None))?; - parts.push(fb.select(reach, cell, device)?); - } - composite(fb, parts) -} - #[cfg(test)] mod tests; diff --git a/crates/metal2vulkan/src/lower/sampler/position/tests.rs b/crates/metal2vulkan/src/lower/sampler/position/tests.rs index 00f7a02f6..ac33b700f 100644 --- a/crates/metal2vulkan/src/lower/sampler/position/tests.rs +++ b/crates/metal2vulkan/src/lower/sampler/position/tests.rs @@ -1,13 +1,12 @@ -//! Metal's position and the snapped coordinates, run on the interpreter against the rule computed -//! exactly. Each kernel reads `(bits(u), n)` per invocation and writes the bits of [`position`]'s -//! `X`, for one addressing, and of [`snapped_axis`]'s gather and footprint-cell coordinates reading -//! `u` as a pixel coordinate. +//! Metal's position and its offset rule, run on the interpreter against the rule computed exactly. +//! The position kernel reads `(bits(u), n)` per invocation and writes the bits of [`position`]'s +//! `X`, for one addressing. //! //! The reference wraps `u` with the same `f32` operations Metal's rule names (they are exact or //! rounded once, as on the device), forms the product `u' n` exactly in `f64` (at most 46 //! significant bits), and rounds it to `f32` with ties away from zero. -use super::{celled_by_word, gathered_by_word, offset_dropped, position, snapped_axis, AxisSnap}; +use super::{offset_dropped, position}; use crate::lower::sampler::bicubic::TapAddress; use crate::pipeline::sym::{ResourceKind, ResourceSlot, Stage}; use crate::spirv::builder::{FunctionBuilder, ModuleBuilder}; @@ -56,11 +55,9 @@ fn word(f: &mut FunctionBuilder<'_>, buf: GlobalId, i: Value, per: u32, k: u32) f.access_chain(base, &[zero, at]) } -/// A kernel whose invocation `i` reads `(bits(u), n)` from buffer 0 and writes `X` and, reading `u` -/// as a pixel coordinate, the gather's and the footprint cell's coordinates, as bits, to buffer 1, -/// for an axis addressed by `address` whose access the device moves by the constant texel offset -/// `offset` (0: none). -fn kernel(address: TapAddress, offset: i32) -> BResult { +/// A kernel whose invocation `i` reads `(bits(u), n)` from buffer 0 and writes `X`, as bits, to +/// buffer 1, for an axis addressed by `address`. +fn kernel(address: TapAddress) -> BResult { let mut b = ModuleBuilder::new(); let f32_ = b.ty(Type::Float { width: 32 })?; let u32_ = b.ty(Type::Int { @@ -82,20 +79,9 @@ fn kernel(address: TapAddress, offset: i32) -> BResult { let at = word(&mut f, input, i, 2, 1)?; let n = f.load(at, MemAccess::default())?; let (x, _) = position(&mut f, u, n, address)?; - let o = if offset == 0 { - None - } else { - // Metal's offsets lie in [-8, 7], each exact as an `f32`. - Some(super::f32_const(&mut f, offset as f32)?) - }; - let at = (address, o, None); - let pg = snapped_axis(&mut f, AxisSnap::Gather, u, n, at)?; - let cell = snapped_axis(&mut f, AxisSnap::Cell, u, n, at)?; - for (k, v) in [x, pg, cell].into_iter().enumerate() { - let bits = f.convert(ConvOp::Bitcast, v, u32_)?; - let at = word(&mut f, output, i, 3, k as u32)?; - f.store(at, bits, MemAccess::default())?; - } + let bits = f.convert(ConvOp::Bitcast, x, u32_)?; + let at = word(&mut f, output, i, 1, 0)?; + f.store(at, bits, MemAccess::default())?; f.ret(None)?; let main = f.finish()?; b.entry( @@ -106,14 +92,9 @@ fn kernel(address: TapAddress, offset: i32) -> BResult { b.finalize() } -/// The kernel's three words per lane `(u, n)`. -fn run(address: TapAddress, lanes: &[(f32, u32)]) -> Vec<[u32; 3]> { - run_offset(address, 0, lanes) -} - -/// The kernel's three words per lane `(u, n)`, under the constant texel offset `offset`. -fn run_offset(address: TapAddress, offset: i32, lanes: &[(f32, u32)]) -> Vec<[u32; 3]> { - let m = kernel(address, offset).expect("kernel"); +/// The kernel's `X` bits per lane `(u, n)`. +fn run(address: TapAddress, lanes: &[(f32, u32)]) -> Vec { + let m = kernel(address).expect("kernel"); let bytes: Vec = lanes .iter() .flat_map(|(u, n)| [u.to_bits().to_le_bytes(), n.to_le_bytes()]) @@ -129,7 +110,7 @@ fn run_offset(address: TapAddress, offset: i32, lanes: &[(f32, u32)]) -> Vec<[u3 Buffer { slot: Some(slot(1)), address: None, - bytes: vec![0xAB; lanes.len() * 12], + bytes: vec![0xAB; lanes.len() * 4], }, ], ..Resources::default() @@ -140,14 +121,10 @@ fn run_offset(address: TapAddress, offset: i32, lanes: &[(f32, u32)]) -> Vec<[u3 }; let (out, _) = interp::run_with_images(&m, &cfg, res, Vec::new()).expect("run"); out.buffers[1] - .as_chunks::<12>() + .as_chunks::<4>() .0 .iter() - .map(|c| { - std::array::from_fn(|k| { - u32::from_le_bytes([c[4 * k], c[4 * k + 1], c[4 * k + 2], c[4 * k + 3]]) - }) - }) + .map(|c| u32::from_le_bytes(*c)) .collect() } @@ -248,15 +225,6 @@ fn gather_i0(x: f32) -> i64 { q >> 8 } -/// The gather's snapped coordinate (module docs), computed from the exact `i0`. -fn gather_coordinate(x: f32, n: u32, address: TapAddress) -> f32 { - let mut i0 = gather_i0(x); - if matches!(address, TapAddress::Edge | TapAddress::Border) { - i0 = i0.clamp(-10, i64::from(n) + 8); - } - (i0 as f32 + 1.0) / n as f32 -} - const ADDRESSES: [TapAddress; 4] = [ TapAddress::Edge, TapAddress::Border, @@ -401,11 +369,11 @@ fn the_position_is_metals_wrap_first_and_ties_away() { for (&(u, n), got) in picked.iter().zip(&out) { let want = metal_x(u, n, address); assert_eq!( - got[0], + *got, want.to_bits(), "{address:?} n {n} u {u:e} ({:#010x}): X {:e} vs {want:e}", u.to_bits(), - f32::from_bits(got[0]) + f32::from_bits(*got) ); let even = even_x(u, n, address); if gather_i0(want) != gather_i0(even) || want.floor() != even.floor() { @@ -464,54 +432,13 @@ fn the_ties_hold_up_to_the_size_bound() { let mut decided = 0; for (&(u, n), got) in us.iter().zip(&out) { let want = metal_x(u, n, address); - assert_eq!(got[0], want.to_bits(), "{address:?} n {n} u {u:e}"); + assert_eq!(*got, want.to_bits(), "{address:?} n {n} u {u:e}"); decided += usize::from(want != even_x(u, n, address)); } assert!(decided > 0, "{address:?}: no tie rounded the other way"); } } -/// A pixel coordinate `x` is Metal's position as given. Its gather's snapped coordinate is the -/// gather's at `X = x`, and its footprint cell's, `(q + 128) / 256 / n` for `q = floor(256 x - -/// 127.5)`, reads as a normalized coordinate (Metal's own sampler's position of it, ties away from -/// zero) the same `q`: every lane a ulp either side of each step and texel edge and centre, on the -/// clamping axes (a pixel sampler only clamps) of Metal's sizes. -#[test] -fn pixel_coordinate_snaps_read_metals_footprint() { - let q = |x: f32| (256.0 * f64::from(x) - 127.5).floor() as i64; - for address in [TapAddress::Edge, TapAddress::Border] { - for n in [1u32, 2, 3, 13, 255, 1000, 16383, 16384] { - let mut xs = Vec::new(); - let top = i64::from(n).min(40) + 12; - for k in -12..=top { - for base in [ - k as f32, - k as f32 + 0.5 - 1.0 / 512.0, - k as f32 + 0.5 - 1.0 / 256.0, - ] { - xs.extend([base, base.next_down(), base.next_up(), base + 1.0 / 1024.0]); - } - } - for k in [n - 1, n, n + 1] { - let b = k as f32 - 0.5 - 1.0 / 512.0; - xs.extend([b, b.next_down(), b.next_up(), k as f32 - 0.25]); - } - let lanes: Vec<(f32, u32)> = xs.iter().map(|x| (*x, n)).collect(); - let out = run(address, &lanes); - for (&(x, n), got) in lanes.iter().zip(&out) { - let g = gather_coordinate(x, n, address); - assert_eq!(got[1], g.to_bits(), "{address:?} n {n} x {x:e}: gather"); - let c = f32::from_bits(got[2]); - assert_eq!( - q(metal_x(c, n, address)), - q(x), - "{address:?} n {n} x {x:e}: cell {c:e}" - ); - } - } - } -} - /// A kernel whose invocation `i` reads `(n, base, parent)` from buffer 0 and writes /// [`offset_dropped`]'s answer for a level of size `n` under a base level of size `base`, and its /// base-level form's for a base level of size `n`, each without a parent test and under the parent @@ -773,245 +700,3 @@ fn the_offset_rule_reads_the_parent_s_base_through_the_view_bit() { assert_eq!(got[0], u32::from(rule(n, own)), "{at}: no parent test"); } } - -/// On a repeating or mirrored axis whose size is 3, 5, 6 or 7, Metal drops a texel offset the -/// device adds, so each snapped coordinate (reading `u` as a pixel coordinate) moves back by the -/// offset there: the device's index at a gather's (`floor(c n - 1/2)`), plus the offset, is the -/// unmoved snap's, and the footprint cell moves back the same way. On every other size, and on -/// every clamping axis, the offset leaves the snap as it is (Metal adds it as the device does). -#[test] -fn a_snap_moves_back_by_the_offset_metal_drops() { - let mut moved = 0usize; - for address in ADDRESSES { - for n in (1u32..=10).chain([13, 16, 255]) { - let all = lanes(n); - let step = (all.len() / 200).max(1); - let picked: Vec<(f32, u32)> = all.into_iter().step_by(step).collect(); - let plain = run(address, &picked); - let dropped = matches!(address, TapAddress::Repeat | TapAddress::Mirror) - && matches!(n, 3 | 5 | 6 | 7); - for o in [-8i32, -1, 1, 7] { - let out = run_offset(address, o, &picked); - let back = if dropped { o as f32 } else { 0.0 }; - let nf = n as f32; - for ((&(u, _), got), was) in picked.iter().zip(&out).zip(&plain) { - let at = format!("{address:?} n {n} o {o} u {u:e}"); - if !dropped { - assert_eq!(got, was, "{at}: moved where Metal adds the offset"); - continue; - } - assert_eq!(got[0], was[0], "{at}: X"); - let pg = (gather_i0(u) as f32 + 1.0 - back) / nf; - assert_eq!(got[1], pg.to_bits(), "{at}: pixel gather"); - let y = 256.0 * u; - let fl = y.floor(); - let cell = (fl + if y - fl >= 0.5 { 1.0 } else { 0.0 }) * (1.0 / 256.0); - let cell = (cell - back) / nf; - assert_eq!(got[2], cell.to_bits(), "{at}: cell"); - // The device's index at the moved coordinate, plus the offset, is the - // unmoved one's. - let index = |bits: u32| { - let y = f64::from(f32::from_bits(bits)) * f64::from(n); - (y - 0.5).floor() as i64 - }; - assert_eq!(index(got[1]) + i64::from(o), index(was[1]), "{at}"); - moved += 1; - } - } - } - } - assert!(moved > 0, "no lane moved back"); -} - -/// The coordinate the word kernels hand the device where their snap does not reach a lane: a -/// marker no snap yields. -const DEVICE: f32 = -12345.0; - -/// A kernel whose invocation `i` reads `(bits(u), n, word)` from buffer 0 and writes the bits of -/// [`gathered_by_word`]'s coordinate of a one-axis gather of size `n` through a runtime sampler of -/// word `word`, and of [`celled_by_word`]'s, each handing [`DEVICE`] as the coordinate the device -/// reads otherwise, to buffer 1. -fn word_gather_kernel() -> BResult { - let mut b = ModuleBuilder::new(); - let f32_ = b.ty(Type::Float { width: 32 })?; - let u32_ = b.ty(Type::Int { - width: 32, - signed: false, - })?; - let uvec3 = b.ty(Type::Vector { elem: u32_, len: 3 })?; - let input = storage_buffer(&mut b, 0, u32_)?; - let output = storage_buffer(&mut b, 1, u32_)?; - let id = b.builtin(crate::spv::BuiltIn::GlobalInvocationId, IoDir::Input, uvec3)?; - let void = b.ty(Type::Void)?; - let mut f = b.function(void)?; - let gid = f.module().global_value(id)?; - let gid = f.load(gid, MemAccess::default())?; - let i = f.composite_extract(gid, &[0])?; - let at = word(&mut f, input, i, 3, 0)?; - let ub = f.load(at, MemAccess::default())?; - let u = f.convert(ConvOp::Bitcast, ub, f32_)?; - let at = word(&mut f, input, i, 3, 1)?; - let n = f.load(at, MemAccess::default())?; - let at = word(&mut f, input, i, 3, 2)?; - let w = f.load(at, MemAccess::default())?; - let device = super::f32_const(&mut f, DEVICE)?; - let g = gathered_by_word(&mut f, w, (u, device), 1, (n, 1))?; - let c = celled_by_word(&mut f, w, (u, device), 1, (n, 1))?; - for (k, v) in [g, c].into_iter().enumerate() { - let bits = f.convert(ConvOp::Bitcast, v, u32_)?; - let at = word(&mut f, output, i, 2, k as u32)?; - f.store(at, bits, MemAccess::default())?; - } - f.ret(None)?; - let main = f.finish()?; - b.entry( - ExecModel::GLCompute, - main, - vec![ExecMode::LocalSize { x: 1, y: 1, z: 1 }], - )?; - b.finalize() -} - -/// The word gather kernel's two coordinates' bits per lane `(u, n, word)`. -fn run_word_gather(lanes: &[(f32, u32, u32)]) -> Vec<[u32; 2]> { - let m = word_gather_kernel().expect("kernel"); - let bytes: Vec = lanes - .iter() - .flat_map(|(u, n, w)| [u.to_bits().to_le_bytes(), n.to_le_bytes(), w.to_le_bytes()]) - .flatten() - .collect(); - let res = Resources { - buffers: vec![ - Buffer { - slot: Some(slot(0)), - address: None, - bytes, - }, - Buffer { - slot: Some(slot(1)), - address: None, - bytes: vec![0xAB; lanes.len() * 8], - }, - ], - ..Resources::default() - }; - let cfg = Config { - workgroups: [u32::try_from(lanes.len()).expect("lanes"), 1, 1], - ..Config::default() - }; - let (out, _) = interp::run_with_images(&m, &cfg, res, Vec::new()).expect("run"); - out.buffers[1] - .as_chunks::<8>() - .0 - .iter() - .map(|c| { - std::array::from_fn(|k| { - u32::from_le_bytes([c[4 * k], c[4 * k + 1], c[4 * k + 2], c[4 * k + 3]]) - }) - }) - .collect() -} - -/// A runtime sampler's gather hands the device the centre of the 2x2 block Metal reads at the -/// coordinate as given where its word states pixel coordinates, and the device's coordinate for a -/// normalized word; a word's other fields leave it as it is. The footprint-cell snap takes the -/// centre of the step Metal reads the coordinate as given at where the word states a linear pixel -/// sampler, and the device's coordinate for every other word. -#[test] -fn a_runtime_samplers_gather_centres_metals_block_by_its_word() { - use crate::metal::sampler::SamplerWord; - use crate::metal::SamplerAddressMode as M; - let modes = [ - M::ClampToEdge, - M::MirrorClampToEdge, - M::Repeat, - M::MirrorRepeat, - M::ClampToZero, - M::ClampToBorderColor, - ]; - // Fields the gather ignores: the filters, the mip filter, the `t` and `r` modes, the border, - // the comparison, the reduction, anisotropy and the level clamps. - let ignored = SamplerWord::MIN_LINEAR - | SamplerWord::MAG_LINEAR - | SamplerWord::MIP_FILTER - | SamplerWord::ADDRESS[1] - | SamplerWord::ADDRESS[2] - | SamplerWord::BORDER - | SamplerWord::COMPARE - | SamplerWord::REDUCTION - | SamplerWord::ANISOTROPIC - | SamplerWord::LEVEL_MIN - | SamplerWord::LEVEL_MAX; - let linear_pixel = - SamplerWord::PIXEL_COORDINATES | SamplerWord::MIN_LINEAR | SamplerWord::MAG_LINEAR; - let mut checked = 0usize; - for n in [1u32, 3, 7, 13, 16, 255, 16383] { - let all = lanes(n); - let step = (all.len() / 60).max(1); - let us: Vec = all.into_iter().step_by(step).map(|(u, _)| u).collect(); - let mut picked = Vec::new(); - for mode in modes { - let m = mode.as_raw() << SamplerWord::ADDRESS_SHIFT[0]; - for w in [ - m, - m | ignored, - m | SamplerWord::PIXEL_COORDINATES, - m | linear_pixel, - m | SamplerWord::PIXEL_COORDINATES | SamplerWord::MIN_LINEAR, - ] { - picked.extend(us.iter().map(|&u| (u, n, w))); - } - } - // Pixel coordinates around the steps and edges of the texels near the level. - for k in -12i64..=i64::from(n.min(40)) + 12 { - for base in [k as f32, k as f32 + 0.5 - 1.0 / 512.0, k as f32 + 0.25] { - for x in [base, base.next_down(), base.next_up()] { - for w in [SamplerWord::PIXEL_COORDINATES, linear_pixel] { - picked.push((x, n, w)); - } - } - } - } - let out = run_word_gather(&picked); - let nf = n as f32; - for (&(u, n, w), got) in picked.iter().zip(&out) { - let at = format!("n {n} word {w:#x} u {u:e}"); - let pixel = w & SamplerWord::PIXEL_COORDINATES != 0; - let snapped = pixel.then_some(u); - let want = match snapped { - Some(x) => { - let i0 = gather_i0(x).clamp(-2 * i64::from(n) - 10, 2 * i64::from(n) + 8); - (i0 as f32 + 1.0) / nf - } - None => DEVICE, - }; - assert_eq!( - got[0], - want.to_bits(), - "{at}: gather {:e} vs {want:e}", - f32::from_bits(got[0]) - ); - if let Some(x) = snapped { - // The device reads the block at `i0`, as Metal does. - let c = f64::from(f32::from_bits(got[0])) * f64::from(n); - let i0 = gather_i0(x).clamp(-2 * i64::from(n) - 10, 2 * i64::from(n) + 8); - assert!((c - (i0 + 1) as f64).abs() <= 2f64.powi(-7) + 8.0, "{at}"); - } - let cell = if w & linear_pixel == linear_pixel { - let y = 256.0 * u; - let fl = y.floor(); - ((fl + if y - fl >= 0.5 { 1.0 } else { 0.0 }) * (1.0 / 256.0)) / nf - } else { - DEVICE - }; - assert_eq!( - got[1], - cell.to_bits(), - "{at}: cell {:e} vs {cell:e}", - f32::from_bits(got[1]) - ); - checked += 1; - } - } - assert!(checked > 15_000, "{checked}"); -} diff --git a/crates/metal2vulkan/src/lower/sampler/select.rs b/crates/metal2vulkan/src/lower/sampler/select.rs index 4c0f4e877..f3039bebd 100644 --- a/crates/metal2vulkan/src/lower/sampler/select.rs +++ b/crates/metal2vulkan/src/lower/sampler/select.rs @@ -1930,30 +1930,6 @@ fn select_one( SamplerArg::Static(SamplerRef::Constexpr(_), Coordinates::Pixel) if !cube => Pixel::Always, _ => Pixel::None, }; - // A nearest pixel sampler's sample, a comparison's included, reads the centre of the texel - // Metal floors its coordinate to: a constexpr sampler's where its state reads one texel of one - // level (an integer texture's whatever its filters say), exactly; a runtime or argument - // buffer's behind its word (its slot's `SamplerState` specialization or its table entry's), - // near only where the bound sampler filters linearly. (Metal's compiler takes no constexpr - // pixel sampler with a comparison; a runtime one's comparison floors as a sample does, item - // 24.) A gather snaps (`position::plan`). - let centred = matches!(op, SampleOp::Sample { .. }) - && match (pixel, sampler) { - (Pixel::Spec(_) | Pixel::Heap(_), _) => true, - (Pixel::Always, SamplerArg::Static(SamplerRef::Constexpr(words), _)) => { - let s = super::state_of(words)?; - (integer || (s.min_filter == Filter::Nearest && s.mag_filter == Filter::Nearest)) - && s.mip_filter == MipFilter::None - && s.max_anisotropy <= 1 - } - _ => false, - }; - // An integer texture reads one texel through any sampler, so its pixel sample reads the centre - // of the texel Metal floors to whatever the word's filters. - let centre_word = match integer { - true => SamplerWord::PIXEL_COORDINATES, - false => SamplerWord::PIXEL_NEAREST, - }; // A `half` texel's NaN is the device's decode, a bicubic sample's taps included: where the // bound format may hold one. let half = form.is_some_and(|f| f.conv == TexelConv::F16); @@ -1991,7 +1967,6 @@ fn select_one( }; s.compare |= compare; s.coordinates |= pixel != Pixel::None; - s.nearest |= centred; // A cube's gradients whose footprint the word chooses read its anisotropy. s.anisotropy |= matches!( op, @@ -2131,24 +2106,11 @@ fn select_one( if let Some((note, when)) = super::linear::filter_note(cx, &op, form, (by, image))? { cx.note_when(note, when, m)?; } - // A pixel sampler's gather (or a runtime sampler's, behind its word) and a linear pixel - // sample's footprint cell, snapped onto Metal's texels. - let snap = super::position::plan(cx, &op, stat, (shape, integer))?; - if let SamplerArg::Static(SamplerRef::Slot(n), _) = sampler { - if let Some(s) = cx.families.sampler.slots.get_mut(&n) { - match snap.as_ref().map(|p| p.kind) { - Some(super::position::SnapKind::WordGather) => s.gathers = true, - Some(super::position::SnapKind::WordCell { .. }) => s.cells = true, - _ => {} - } - } - } - // A pixel sampler's coordinate, scaled for the device, reads Metal's texels where Metal's - // position, the coordinate as given, decides them: a centred texel, a snapped gather or - // footprint cell. The note holds where none of them runs and the device's filter reads the - // scaled coordinate, as `pixel_note` says. An argument buffer's sampler records a note of its - // own, which the runtime announces only while a bound state can need it. - let when = pixel_note(&op, pixel, (centred, integer), snap.as_ref()); + // A pixel sampler's coordinate reaches the device's sampler over the level-0 size, whose + // texels at a texel edge or a filter step's edge are the device's arithmetic's on that + // coordinate (`pixel_note`). An argument buffer's sampler records a note of its own, which the + // runtime announces only while a bound state can need it. + let when = pixel_note(pixel); let note = match pixel { Pixel::Heap(_) => PrecisionNote::ArgumentPixelSamplerScaling, _ => PrecisionNote::PixelSamplerScaling, @@ -2351,10 +2313,7 @@ fn select_one( pixel, residency, footprint, - snap, cube, - centred, - centre_word, one_texel, half_texel: half_converts && !shape.depth, unmapped, @@ -2412,64 +2371,25 @@ fn clamps_reference( Ok(clamps) } -/// Where sampling `op` through a sampler of pixel coordinates `pixel` hands the device a -/// coordinate scaled by the texture's size whose texels the device's filter decides +/// Where a sampling through a sampler of pixel coordinates `pixel` hands the device a coordinate +/// scaled by the texture's level-0 size, whose texels the device's sampler decides /// (`PrecisionNote::PixelSamplerScaling`): the clauses of the arms that do (empty: none). /// -/// - A constexpr pixel sampler: never where the sample is `centred` or snapped onto Metal's -/// texels; always otherwise. -/// - A runtime sampler slot: where its word states pixel coordinates and the sample's arm is the -/// device's. A 2D gather snaps behind the word on every device. A sample (a comparison's -/// included) reads the texel's centre where the word states one texel ([`Sampling::centre_word`]: -/// every pixel word for an integer texture); otherwise it snaps onto its footprint cell where the -/// word's two filters are linear, on every device, leaving a word of mixed filters to the -/// device; without the cell the device filters. Metal admits a pixel sampler only -/// without a mip filter and isotropic (`runtime::sampler::check_descriptor`), so its word filters -/// exactly where a min or mag filter is linear. Any other sampling (an LOD query) is the -/// device's. -/// - An argument buffer's sampler ([`PrecisionNote::ArgumentPixelSamplerScaling`]): never for a 2D -/// gather (snapped behind its word), nor for a sample without a comparison, which reads the -/// device sampler's texels there (a nearest word's flagged fetch, a linear word's footprint -/// cell); always otherwise, since its word, which the specialized module cannot read, may filter. -fn pixel_note( - op: &SampleOp, - pixel: Pixel, - (centred, integer): (bool, bool), - snap: Option<&super::position::Snap>, -) -> Vec { - use super::position::SnapKind; - use crate::lower::select::{both, NoteClause}; - let always = || vec![NoteClause::new()]; - let gathered = snap.is_some_and(|s| matches!(s.kind, SnapKind::WordGather)); +/// - A constexpr pixel sampler: always (its exact fetch, `SampleOp::PixelFetch`, reaches here with +/// [`Pixel::None`]). +/// - A runtime sampler slot: where its word states pixel coordinates. +/// - An argument buffer's sampler ([`PrecisionNote::ArgumentPixelSamplerScaling`]): always, since +/// its word, which the specialized module cannot read, may state pixel coordinates; the runtime +/// announces it only while a state of pixel coordinates lives. +fn pixel_note(pixel: Pixel) -> Vec { + use crate::lower::select::NoteClause; match pixel { Pixel::None => Vec::new(), - Pixel::Always if centred || snap.is_some_and(|s| !s.by_word()) => Vec::new(), - Pixel::Always => always(), - Pixel::Heap(_) if gathered => Vec::new(), - Pixel::Heap(_) if matches!(op, SampleOp::Sample { dref: None, .. }) => Vec::new(), - Pixel::Heap(_) => always(), - Pixel::Spec(_) if gathered => Vec::new(), + Pixel::Always | Pixel::Heap(_) => vec![NoteClause::new()], Pixel::Spec(n) => { - let on = NoteOn::Sampler(n); - let coordinates = NoteTest::differ(on, SamplerWord::PIXEL_COORDINATES, 0); - let filter = |bit| NoteTest::differ(on, bit, 0); - let filters = [SamplerWord::MIN_LINEAR, SamplerWord::MAG_LINEAR].map(filter); - let device = match op { - SampleOp::Sample { .. } if centred && integer => Vec::new(), - SampleOp::Sample { .. } - if snap.is_some_and(|s| matches!(s.kind, SnapKind::WordCell { .. })) => - { - // Mixed filters: one linear, the other not. - let nearest = |bit| NoteTest::equal(on, bit, 0); - vec![ - [filters[0], nearest(SamplerWord::MAG_LINEAR)].into(), - [nearest(SamplerWord::MIN_LINEAR), filters[1]].into(), - ] - } - SampleOp::Sample { .. } if centred => filters.map(|t| NoteClause::from([t])).into(), - _ => always(), - }; - both(&[[coordinates].into()], &device) + let coordinates = + NoteTest::differ(NoteOn::Sampler(n), SamplerWord::PIXEL_COORDINATES, 0); + vec![[coordinates].into()] } } } diff --git a/crates/metal2vulkan/src/lower/sampler/shared.rs b/crates/metal2vulkan/src/lower/sampler/shared.rs index 17ca72101..e0d778e81 100644 --- a/crates/metal2vulkan/src/lower/sampler/shared.rs +++ b/crates/metal2vulkan/src/lower/sampler/shared.rs @@ -1,10 +1,10 @@ //! The shared emulation of a switch-at-use (SEMANTICS 1012). //! //! A switch-at-use whose every arm takes the same emulated sampling on its own texture slot -//! ([`Sampling::shared_shape`]): a bicubic sample, or a snapped gather or sample. Emitted per arm, each arm repeats the whole -//! emulation (its position, weights, sums, and routine calls), so the switch's words grow with arms × emulation, and so does -//! the driver's work once the bound formats make every arm's emulation live (an Intel ANV pipeline -//! of 32 such arms took 6 s to create). +//! ([`Sampling::shared_shape`]): a bicubic sample. Emitted per arm, each arm repeats the whole +//! emulation (its position, weights, sums, and routine calls), so the switch's words grow with +//! arms × emulation, and so does the driver's work once the bound formats make every arm's +//! emulation live (an Intel ANV pipeline of 32 such arms took 6 s to create). //! //! **The shared form** runs the emulation once, outside the dispatch, on the named candidate's //! facts, and dispatches only what reads a candidate's own image: @@ -13,9 +13,7 @@ //! format's bits (the slot's `BicubicTexels` specialization) and `true`, and //! whose null arm yields a size of ones, bits 0 and `false`; //! - the emulation on those facts (its footprint, weights and routine calls once), whose taps a -//! dispatch reads from each arm's image (the null arm's are zero); -//! - a snapped sample's coordinate snapped once on the named size, and the device's access and -//! texel conversion in each arm, the null arm yielding the switch's null value. +//! dispatch reads from each arm's image (the null arm's are zero). //! //! Where a handle names a candidate the facts are that candidate's, so every value is the one its //! own arm computed; elsewhere the switch's null value is selected. The emulation of a null handle @@ -23,16 +21,12 @@ use crate::lower::emit::EmitCx; use crate::lower::texture::{dispatch, with_word, NullLeaf}; -use crate::spirv::builder::constructs::{ArmEnd, ArmFn, Merged}; use crate::spirv::builder::FunctionBuilder; use crate::spirv::error::BResult; use crate::spirv::ids::{ConstId, Value as SValue}; -use crate::spirv::ir::{ConstBits, Constant, ImageOperands, ImageQuery, Type as SType}; +use crate::spirv::ir::{ConstBits, Constant, ImageQuery, Type as SType}; -use super::emit::{ - layered, offset_operands, op_offset, pixel_coordinates, plane_and_gradients, sample_access, - sample_operands, scaled, snap_offsets, texel_value, -}; +use super::bicubic::Bicubic; use super::{Binding, CombinedImage, SampleOp, Sampling, Source}; /// The candidates of a switch-at-use that emulates once: the handles' values dispatched on, @@ -57,16 +51,6 @@ impl Candidates<'_> { dispatch(cx, fb, &self.sels, &self.arms, &leaf, null) } - /// The sampled image of arm sampling `a`'s binding, made in the open block. - pub(super) fn sampled_image( - &self, - cx: &mut EmitCx<'_>, - fb: &mut FunctionBuilder<'_>, - a: &Sampling, - ) -> BResult { - binding(cx, a)?.0.sampled_image(fb) - } - /// The image of arm sampling `a`'s binding, loaded in the open block. pub(super) fn image( &self, @@ -89,54 +73,38 @@ fn binding(cx: &mut EmitCx<'_>, a: &Sampling) -> BResult<(Binding, CombinedImage } } -/// The emulation every arm of a shared switch takes. -#[derive(Clone, Copy)] -enum Emulation<'a> { - Bicubic(&'a super::bicubic::Bicubic), - Snap(&'a super::position::Snap), +/// The bicubic sample every arm of a shared switch takes ([`Sampling::shared_shape`]). +fn bicubic(s: &Sampling) -> Option<&Bicubic> { + match &s.op { + SampleOp::Bicubic(b) => Some(b), + _ => None, + } } -impl<'a> Emulation<'a> { - fn of(s: &'a Sampling) -> Option> { - match (&s.op, &s.snap) { - (SampleOp::Bicubic(b), None) => Some(Emulation::Bicubic(b)), - (SampleOp::Sample { .. } | SampleOp::Gather { .. }, Some(p)) if !p.by_word() => { - Some(Emulation::Snap(p)) - } - _ => None, - } - } - - /// The specialization holding the bound format's bits of arm sampling `a`'s slot, where the - /// emulation reads them: a bicubic sample's `BicubicTexels`. - fn bits(self, cx: &mut EmitCx<'_>, a: &Sampling) -> BResult> { - let spec = match (self, Emulation::of(a)) { - (Emulation::Bicubic(_), Some(Emulation::Bicubic(b))) => { - cx.decl.families.sampler.bicubic.get(&b.texture).copied() - } - (Emulation::Snap(_), Some(Emulation::Snap(_))) => return Ok(None), - _ => return Err(cx.fail("a shared switch's arms of different emulations")), - }; - match spec { - Some(c) => Ok(Some(c)), - None => Err(cx.fail("a shared switch's arm without its format specialization")), - } +/// The specialization holding the bound format's bits of arm sampling `a`'s slot, its bicubic +/// sample's `BicubicTexels`. +fn bits(cx: &mut EmitCx<'_>, a: &Sampling) -> BResult { + let Some(b) = bicubic(a) else { + return Err(cx.fail("a shared switch's arm without its bicubic sample")); + }; + match cx.decl.families.sampler.bicubic.get(&b.texture) { + Some(&c) => Ok(c), + None => Err(cx.fail("a shared switch's arm without its format specialization")), } } /// The value of the shared switch over `c` (module docs): its sampling's value where a handle -/// names a candidate, else `null`'s; `grads` are the gradients its rule-2 prelude hoisted. +/// names a candidate, else `null`'s. pub(crate) fn shared_value( cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, c: &Candidates<'_>, - grads: Option<(SValue, SValue)>, null: &NullLeaf<'_>, ) -> BResult { let Some(&(_, first)) = c.arms.first() else { return Err(cx.fail("a shared switch without arms")); }; - let Some(kind) = Emulation::of(first) else { + let Some(b) = bicubic(first) else { return Err(cx.fail("a shared switch without an emulation")); }; let (_, image) = binding(cx, first)?; @@ -145,42 +113,24 @@ pub(crate) fn shared_value( return Err(cx.fail("a shared switch's candidates of different images")); } } - let facts = facts(cx, fb, c, kind, image)?; - let (size, rest) = match &facts[..] { - [size, rest @ ..] => (*size, rest), - _ => return Err(cx.fail("a shared switch's facts without their sizes")), - }; - let (bits, named) = match (kind, rest) { - (Emulation::Snap(_), &[]) => (None, None), - (Emulation::Bicubic(_), &[bits, named]) => (Some(bits), Some(named)), - _ => return Err(cx.fail("a shared switch's facts without their values")), - }; - let x = match (kind, bits) { - (Emulation::Bicubic(b), Some(bits)) => { - super::bicubic::emit_shared(cx, fb, first, (size, image), b, bits, c)? - } - (Emulation::Snap(p), _) => { - return snapped(cx, fb, c, (first, p), grads, (size, image), null); - } - _ => return Err(cx.fail("a shared emulation without its format bits")), + let facts = facts(cx, fb, c, image)?; + let [size, bits, named] = facts[..] else { + return Err(cx.fail("a shared switch's facts without their values")); }; + let x = super::bicubic::emit_shared(cx, fb, first, (size, image), b, bits, c)?; let x = with_word(cx, fb, &first.result, x, None)?; - let Some(named) = named else { - return Err(cx.fail("a shared emulation without its named test")); - }; let [n] = null(cx, fb)?[..] else { return Err(cx.fail("a shared switch without its null value")); }; fb.select(named, x, n) } -/// The facts dispatch (module docs): each arm's level-0 size, and where `kind` reads them its -/// format's bits and `true`; the null arm's ones, 0, and `false`. +/// The facts dispatch (module docs): each arm's level-0 size, its format's bits and `true`; the +/// null arm's ones, 0, and `false`. fn facts( cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, c: &Candidates<'_>, - kind: Emulation<'_>, image: CombinedImage, ) -> BResult> { let u32_ = fb.module().ty(SType::Int { @@ -209,165 +159,23 @@ fn facts( let zero = scalar(fb, u32_, 0)?; let yes = scalar(fb, bool_, 1)?; let no = scalar(fb, bool_, 0)?; - let with_bits = !matches!(kind, Emulation::Snap(_)); let read = |cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, a: &Sampling| { let img = c.image(cx, fb, a)?; let level = fb.module().const_value(zero)?; - let mut v = vec![fb.query(ImageQuery::SizeLod(level), img)?]; - if let Some(bits) = kind.bits(cx, a)? { - v.push(fb.module().const_value(bits)?); - v.push(fb.module().const_value(yes)?); - } - Ok(v) + let size = fb.query(ImageQuery::SizeLod(level), img)?; + let bits = bits(cx, a)?; + Ok(vec![ + size, + fb.module().const_value(bits)?, + fb.module().const_value(yes)?, + ]) }; let null_facts = |_: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>| { - let mut v = vec![fb.module().const_value(ones)?]; - if with_bits { - v.push(fb.module().const_value(zero)?); - v.push(fb.module().const_value(no)?); - } - Ok(v) + Ok(vec![ + fb.module().const_value(ones)?, + fb.module().const_value(zero)?, + fb.module().const_value(no)?, + ]) }; c.each(cx, fb, &read, &null_facts) } - -/// The plane coordinate of sampling `s` as the device reads it, on the named candidate's level-0 -/// size `size` (image facts `image`): the plane coordinate scaled from pixel coordinates over the -/// level-0 size, then snapped by `snap` (a pixel sampler's snap from the coordinate as given), and -/// with the layer appended; and its gradients. The first of the pair is the plane coordinate before -/// the snap, which a bias past the device's limit differentiates. -fn device_coordinate( - cx: &mut EmitCx<'_>, - fb: &mut FunctionBuilder<'_>, - s: &Sampling, - grads: Option<(SValue, SValue)>, - (size, image): (SValue, CombinedImage), - snap: Option<&super::position::Snap>, -) -> BResult<((SValue, SValue), Option<(SValue, SValue)>)> { - let (mut coord, mut grad) = plane_and_gradients(cx, fb, s, grads)?; - // A pixel sampler's snap reads the coordinate as given. - let given = coord; - if let Some(spec) = pixel_coordinates(cx, fb, s)? { - // Pixel coordinates scale by the level-0 size. - let size_lanes = image.plane + u8::from(image.arrayed); - (coord, grad) = scaled(fb, s.lanes, (size, size_lanes), spec, (coord, grad))?; - } - let plane = coord; - if let Some(snap) = snap { - // The device adds the texel offset to the snapped coordinate; each snap moves its index - // back where Metal drops it. - let offsets = snap_offsets(cx, fb, op_offset(&s.op), s.lanes)?; - let at = (given, offsets.as_slice(), None); - coord = super::position::snapped_on(cx, fb, snap, at, s.lanes, (size, image))?; - } - let (coord, _) = layered(cx, fb, s, coord)?; - Ok(((plane, coord), grad)) -} - -/// A shared snapped gather or nearest sample (module docs): the coordinate snapped once on the -/// named size, and in each arm the device's access and the texel's conversion; the null arm -/// yields `null`'s value. -fn snapped( - cx: &mut EmitCx<'_>, - fb: &mut FunctionBuilder<'_>, - c: &Candidates<'_>, - (first, snap): (&Sampling, &super::position::Snap), - grads: Option<(SValue, SValue)>, - (size, image): (SValue, CombinedImage), - null: &NullLeaf<'_>, -) -> BResult { - let ((plane, coord), grad) = - device_coordinate(cx, fb, first, grads, (size, image), Some(snap))?; - let values = match &first.op { - SampleOp::Sample { - lod, - dref, - min_lod, - offset, - } => { - let (ops, dref, beyond) = sample_operands( - cx, - fb, - first, - (plane, grad, false), - (lod, *min_lod, offset, *dref), - )?; - let read = |cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, a: &Sampling| { - let si = c.sampled_image(cx, fb, a)?; - let x = sample_access(coord, dref, ops)(fb, si, false)?; - // Past the device's limit the sample with the scaled derivatives replaces the - // implicit one; the implicit sample stays where it was, unconditional. - let x = match beyond { - None => x, - Some((test, grads)) => { - let mut grad_ops = ops; - grad_ops.bias = None; - grad_ops.grad = Some(grads); - let past: ArmFn<'_, EmitCx<'_>> = Box::new(move |fb, cx| { - // A sampled image is consumed in the block that makes it. - let si = c.sampled_image(cx, fb, a)?; - let x = sample_access(coord, dref, grad_ops)(fb, si, false)?; - Ok(ArmEnd::FallThrough(vec![x])) - }); - let within: ArmFn<'_, EmitCx<'_>> = - Box::new(move |_, _| Ok(ArmEnd::FallThrough(vec![x]))); - let Merged(merged) = fb.if_(cx, test, past, Some(within))?; - match merged[..] { - [x] => x, - _ => return Err(cx.fail("a biased sample without its merged texel")), - } - } - }; - // A depth sample without comparison reads the first component. - let x = if a.depth && dref.is_none() { - fb.composite_extract(x, &[0])? - } else { - x - }; - Ok(vec![texel_value( - cx, - fb, - a, - image, - (x, crate::lower::texture::half::TexelOrigin::Computed), - None, - )?]) - }; - c.each(cx, fb, &read, null)? - } - SampleOp::Gather { - component, - dref, - offset, - } => { - let mut ops = ImageOperands::default(); - offset_operands(cx, fb, offset, first.lanes, &mut ops)?; - let component = *component; - let dref = match dref { - Some(r) => Some(super::emit::reference(cx, fb, first, *r)?), - None => None, - }; - let read = |cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, a: &Sampling| { - let si = c.sampled_image(cx, fb, a)?; - let x = match dref { - Some(r) => fb.dref_gather(si, coord, r, &ops)?, - None => fb.gather(si, coord, component, &ops)?, - }; - Ok(vec![texel_value( - cx, - fb, - a, - image, - (x, crate::lower::texture::half::TexelOrigin::Computed), - None, - )?]) - }; - c.each(cx, fb, &read, null)? - } - _ => return Err(cx.fail("a shared snapped access without its sample or gather")), - }; - match values[..] { - [x] => Ok(x), - _ => Err(cx.fail("a shared snapped access without its value")), - } -} diff --git a/crates/metal2vulkan/src/lower/select.rs b/crates/metal2vulkan/src/lower/select.rs index 9c7ff3daa..6725d9e98 100644 --- a/crates/metal2vulkan/src/lower/select.rs +++ b/crates/metal2vulkan/src/lower/select.rs @@ -1804,13 +1804,6 @@ fn clause_bytes(c: &NoteClause) -> usize { .saturating_add(tree_bytes(c.len(), test).max(NODE_TESTS * test)) } -/// The clauses of `a` and of `b` both holding: each pair's conjunction. -pub(crate) fn both(a: &[NoteClause], b: &[NoteClause]) -> Vec { - a.iter() - .flat_map(|x| b.iter().map(move |y| x.union(y).copied().collect())) - .collect() -} - /// Each test of `tests` alone, as clauses: the disjunction of the tests. pub(crate) fn any_of(tests: impl IntoIterator) -> Vec { tests.into_iter().map(|t| [t].into()).collect() @@ -1845,8 +1838,7 @@ fn declared(families: &FamilyPlans, t: NoteTest) -> Option { }) } -/// `clause` over the function's declared constants, or `None` where a test reads none, or reads -/// a gated sampler word in a way the binder's key does not keep (`pixel_gated`). +/// `clause` over the function's declared constants, or `None` where a test reads none. fn declared_clause(families: &FamilyPlans, clause: &NoteClause) -> Option { let mut all = clause .iter() @@ -1854,7 +1846,7 @@ fn declared_clause(families: &FamilyPlans, clause: &NoteClause) -> Option>>()?; all.sort_unstable(); all.dedup(); - pixel_gated(&all).then_some(SpecClause { all }) + Some(SpecClause { all }) } /// The module's notes and its specialized notes: every note `precision` holds, and each of @@ -1887,34 +1879,6 @@ fn resolve_notes( (precision.into_iter().collect(), kept) } -/// Whether the clause `all` holds of every `SamplerState` word as it holds of its key: a word -/// whose fields state `SamplerWord::PIXEL_GATED` keys as 0 where it states normalized coordinates -/// (its pixel-coordinates bit clear), so each such word's tests must agree on every such word and -/// on 0. A test agrees where it reads the bit alone, or tests it set (the masked word then never -/// equals the bits): its value is the one it takes of 0. The tests of a word agree together where -/// every one agrees, or where one that agrees fails of 0, failing the clause for every such word. -fn pixel_gated(all: &[SpecTest]) -> bool { - use crate::metal::sampler::SamplerWord; - const PIXEL: u32 = SamplerWord::PIXEL_COORDINATES; - let agrees = |t: &SpecTest| t.mask == PIXEL || (t.mask & PIXEL != 0 && t.bits & PIXEL != 0); - let of_zero = |t: &SpecTest| (t.bits == 0) == t.equal; - let words: BTreeSet = all - .iter() - .filter_map(|t| match t.key { - SpecKey::SamplerState { slot, fields } if fields & SamplerWord::PIXEL_GATED != 0 => { - Some(slot) - } - _ => None, - }) - .collect(); - words.into_iter().all(|slot| { - let tests = all - .iter() - .filter(|t| matches!(t.key, SpecKey::SamplerState { slot: s, .. } if s == slot)); - tests.clone().all(agrees) || tests.clone().any(|t| agrees(t) && !of_zero(t)) - }) -} - #[cfg(test)] mod tests { use super::*; @@ -2236,54 +2200,4 @@ mod tests { } } } - - /// A clause over a gated sampler word holds of its key, which is 0 for every word of - /// normalized coordinates, only where its tests of the word agree on every such word and on - /// 0, or one of them fails wherever the coordinates bit is clear; an ungated word's clause is - /// kept whatever it tests. - #[test] - fn a_gated_word_s_clause_must_hold_of_its_key() { - use crate::metal::sampler::SamplerWord as W; - use crate::pipeline::sym::SlotClass; - let slot = SlotRef { - stage: Stage::Fragment, - class: SlotClass::Sampler, - index: 2, - }; - let key = |fields| SpecKey::SamplerState { slot, fields }; - let gated = key(W::PIXEL_NEAREST | W::PIXEL_GATED); - let test = |key, mask, bits, equal| SpecTest { - key, - mask, - bits, - equal, - }; - let pixel = test(gated, W::PIXEL_COORDINATES, 0, false); - let normalized = test(gated, W::PIXEL_COORDINATES, 0, true); - let linear_min = test(gated, W::MIN_LINEAR, 0, false); - let nearest_pixel = test(gated, W::PIXEL_NEAREST, W::PIXEL_COORDINATES, true); - assert!(pixel_gated(&[pixel])); - assert!(pixel_gated(&[normalized])); - assert!(pixel_gated(&[pixel, linear_min])); - assert!(pixel_gated(&[nearest_pixel])); - assert!(pixel_gated(&[nearest_pixel, linear_min])); - // A filter test alone, or beside a test that holds for normalized coordinates, reads - // what the key clears. - assert!(!pixel_gated(&[linear_min])); - assert!(!pixel_gated(&[normalized, linear_min])); - // A word that is not a nearest pixel sampler: every word of normalized coordinates, as - // its key 0 is. - let not_nearest_pixel = test(gated, W::PIXEL_NEAREST, W::PIXEL_COORDINATES, false); - assert!(pixel_gated(&[not_nearest_pixel])); - assert!(!pixel_gated(&[not_nearest_pixel, linear_min])); - // An ungated word keeps every bit it reads. - let plain = key(W::PIXEL_NEAREST); - assert!(pixel_gated(&[test(plain, W::MIN_LINEAR, 0, false)])); - // Each gated word answers for itself. - let other = SpecKey::SamplerState { - slot: SlotRef { index: 3, ..slot }, - fields: W::PIXEL_NEAREST | W::PIXEL_GATED, - }; - assert!(!pixel_gated(&[pixel, test(other, W::MIN_LINEAR, 0, false)])); - } } diff --git a/crates/metal2vulkan/src/lower/texture/emit.rs b/crates/metal2vulkan/src/lower/texture/emit.rs index 3cc85cdd0..9fa63a6b2 100644 --- a/crates/metal2vulkan/src/lower/texture/emit.rs +++ b/crates/metal2vulkan/src/lower/texture/emit.rs @@ -111,7 +111,7 @@ fn switch( let c = crate::lower::sampler::Candidates { sels, arms: shared }; let null = |cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>| null_value(cx, fb, &sw.null); return Ok(Some(crate::lower::sampler::shared_value( - cx, fb, &c, grads, &null, + cx, fb, &c, &null, )?)); } let mut arms: Vec<(&[u32], Leaf<'_>)> = Vec::with_capacity(sw.arms.len()); diff --git a/crates/metal2vulkan/src/lower/texture/mod.rs b/crates/metal2vulkan/src/lower/texture/mod.rs index c5cb78f96..d476bb285 100644 --- a/crates/metal2vulkan/src/lower/texture/mod.rs +++ b/crates/metal2vulkan/src/lower/texture/mod.rs @@ -730,9 +730,8 @@ impl TextureStrategy { /// The sampled images of combined bindings this strategy makes: its own sampling's, or its /// switch's arms' (each the static sampling of one binding). Under the separate form each is /// made from the separate texture and sampler. A sampling makes one in its open block. A switch - /// that emulates once ([`Switch::shared`], - /// SEMANTICS 1012) makes them only for its arms' device accesses - /// ([`Sampling::shared_sampled_images`]). + /// that emulates once ([`Switch::shared`], SEMANTICS 1012) makes none: its bicubic taps read + /// each arm's image alone. pub fn combined_samplings(&self) -> u32 { match self { TextureStrategy::Sampling(s) => match s.source { @@ -740,9 +739,7 @@ impl TextureStrategy { _ => 0, }, TextureStrategy::Switch(w) => match w.shared() { - Some(arms) => arms - .iter() - .fold(0, |n, (_, s)| n.saturating_add(s.shared_sampled_images())), + Some(_) => 0, None => w .arms .iter() diff --git a/crates/metal2vulkan/src/metal/sampler.rs b/crates/metal2vulkan/src/metal/sampler.rs index ae753cb7f..07c200742 100644 --- a/crates/metal2vulkan/src/metal/sampler.rs +++ b/crates/metal2vulkan/src/metal/sampler.rs @@ -902,12 +902,6 @@ impl SamplerWord { pub const CUBIC: u32 = 1 << 30; /// Every bit a word may set. pub const FIELDS: u32 = (1 << 31) - 1; - /// Not a field of the word, which never sets it: in the fields of a slot's - /// `SpecKey::SamplerState` specialization, it states that the function reads every other - /// field only through a test that fails where [`PIXEL_COORDINATES`](Self::PIXEL_COORDINATES) - /// is clear (whether the word states a nearest or a linear pixel sampler), so the binder - /// keys a word of normalized coordinates as 0, the word of no sampler, whatever its filters. - pub const PIXEL_GATED: u32 = 1 << 31; /// The bits that state a cubic sampler's sample (a min or mag filter `Cubic`) beyond its /// filter, which Metal answers as a constexpr bicubic sampler of the same state: the /// coordinates, the mip filter, the address modes, the border color, the @@ -921,13 +915,6 @@ impl SamplerWord { | Self::BORDER | Self::REDUCTION | Self::ANISOTROPIC; - /// The bits of a pixel sampler that filters nearest: the word masked by them is - /// [`PIXEL_COORDINATES`](Self::PIXEL_COORDINATES) exactly for a sampler with pixel - /// coordinates whose min and mag filters are nearest. Metal admits a pixel sampler only - /// without a mip filter and isotropic (`runtime::sampler::check_descriptor`), so such a - /// sampler reads one texel of one level, the centre of the texel Metal floors a sample's - /// coordinate to. - pub const PIXEL_NEAREST: u32 = Self::PIXEL_COORDINATES | Self::MIN_LINEAR | Self::MAG_LINEAR; /// The bits of the filter Metal's linear rule answers: the word masked by them is /// [`LINEAR`](Self::LINEAR) exactly for a sampler whose minification and magnification filters /// are linear, without a mip filter, and isotropic. Its reduction does not decide it: a minimum @@ -2093,8 +2080,7 @@ mod tests { } /// The word answers the pixel samplers' predicates. A sampler with normalized coordinates - /// answers neither. A pixel sampler is nearest ([`SamplerWord::PIXEL_NEAREST`]) exactly when - /// its min and mag filters are; its exact fetch ([`SamplerWord::exact_fetch`]) needs one + /// answers neither. A pixel sampler's exact fetch ([`SamplerWord::exact_fetch`]) needs one /// isotropic level (no mip filter, not anisotropic), clamping to the edge on each of the /// image's plane axes (the others do not matter), and nearest filters unless the texture is /// integer. @@ -2238,7 +2224,6 @@ mod tests { holds(d, SamplerWord::exact_fetch(plane, integer)) }; let normalized = metal_default(); - assert!(!holds(&normalized, SamplerWord::PIXEL_NEAREST)); assert!(!holds(&normalized, SamplerWord::PIXEL_COORDINATES)); let mut pixel = metal_default(); pixel.normalized_coordinates = false; @@ -2258,23 +2243,16 @@ mod tests { d.min_filter = min; d.mag_filter = mag; let nearest = min == F::Nearest && mag == F::Nearest; - assert_eq!( - holds(&d, SamplerWord::PIXEL_NEAREST), - nearest, - "{min:?} {mag:?}" - ); assert_eq!(fetch(&d, 2, false), nearest, "{min:?} {mag:?}"); assert!(fetch(&d, 2, true), "{min:?} {mag:?}"); } for mip in [SamplerMipFilter::Nearest, SamplerMipFilter::Linear] { let mut d = pixel; d.mip_filter = mip; - assert!(holds(&d, SamplerWord::PIXEL_NEAREST), "{mip:?}"); assert!(!fetch(&d, 1, true), "{mip:?}"); } let mut d = pixel; d.max_anisotropy = 2; - assert!(holds(&d, SamplerWord::PIXEL_NEAREST)); assert!(!fetch(&d, 1, true)); for &mode in SamplerAddressMode::ALL { let edge = mode == SamplerAddressMode::ClampToEdge; diff --git a/crates/metal2vulkan/src/pipeline/api_tests.rs b/crates/metal2vulkan/src/pipeline/api_tests.rs index a635f9252..ee8992719 100644 --- a/crates/metal2vulkan/src/pipeline/api_tests.rs +++ b/crates/metal2vulkan/src/pipeline/api_tests.rs @@ -729,7 +729,7 @@ mod serde_round_trips { id: 0, key: SpecKey::SamplerState { slot: slot(Stage::Fragment, SlotClass::Sampler, 1), - fields: crate::metal::sampler::SamplerWord::PIXEL_NEAREST, + fields: crate::metal::sampler::SamplerWord::PIXEL_COORDINATES, }, size: 4, default: 0, diff --git a/crates/metal2vulkan/src/pipeline/artifact.rs b/crates/metal2vulkan/src/pipeline/artifact.rs index 50795fda5..929dc5e45 100644 --- a/crates/metal2vulkan/src/pipeline/artifact.rs +++ b/crates/metal2vulkan/src/pipeline/artifact.rs @@ -627,18 +627,28 @@ pub enum PrecisionNote { /// [`PrecisionNote::NativeMinMax`]'s. Validation derives no tolerance and no explanation from /// it: every `float` computation is exposed to it. DeviceDenormals, - /// Pixel-coordinate samplers scale coordinates in the shader, rounding differently. Recorded - /// for an access through a runtime sampler slot whose word may state pixel coordinates, and for - /// an access through a constexpr pixel sampler that reads Metal's texels from none of: an exact - /// fetch, the centre of the texel Metal floors its coordinate to, a gather snapped from the - /// coordinate as given, a linear sample's footprint step. A runtime slot's sample, a - /// comparison's included, is exact too where the bound sampler filters nearest (it reads that - /// centre) and, of a 1D, 2D or 3D texture or array with a floating-point texel, where it - /// filters linear both ways (it snaps onto its footprint cell behind the sampler's word, on - /// every device); its gather of a 2D texture or array snaps from the coordinate as given behind - /// the sampler's word; a word of mixed filters is the device's. A cube's pixel sampler is a - /// normalized one. An argument buffer's sampler records - /// [`PrecisionNote::ArgumentPixelSamplerScaling`] instead. + /// A pixel-coordinate sampler's coordinate reaches the device's sampler divided by the + /// texture's level-0 size in the shader (Vulkan's unnormalized samplers take no gather, + /// offset, comparison, array, 3D image or level of detail), and the device's sampler reads its + /// texels from that coordinate in its own arithmetic: the position it reads, `(x / N) N` in + /// the device's rounding and its sub-texel precision, lies within a few units in the last place + /// of the coordinate `x` as given, where Metal reads `x` itself. So a sample or gather reads + /// Metal's texels and weights but where `x` lies that close to a texel edge (a nearest + /// sample's texel, a gather's 2x2 block, a linear filter's pair of texels) or to the edge of + /// one of the device's sub-texel steps (a linear filter's weight), where it may read the + /// neighbouring texel, block or step. Measured: the device answers as its normalized sampler at + /// a coordinate within one `f32` ulp of the quotient `x / N` on MoltenVK, and at the quotient + /// itself on lavapipe (800 coordinates at and around each texel edge of a 5x3 texture, every + /// filter and address mode); a linear downscale by 8 of textures 1000 to 1920 texels wide is + /// within 1/255 of Metal's on MoltenVK and 2/255 on lavapipe (a weight one 1/256 step off on + /// each axis); other devices unmeasured. Recorded on every device for every access through a + /// constexpr pixel sampler but its exact fetch (nearest, clamped to the edge, + /// `sampler.pixel_fetch`), and for every access through a runtime sampler slot, held where the + /// bound sampler states pixel coordinates. A cube's pixel sampler is a normalized one. An + /// argument buffer's sampler records [`PrecisionNote::ArgumentPixelSamplerScaling`] instead. + /// + /// Validation derives no tolerance from it: at a texel edge the value is the neighbouring + /// texel's, whatever it holds. PixelSamplerScaling, /// Float division, remainder, square root, fused multiply-add, and dot products use Vulkan's /// precision bounds (e.g. 2.5 ULP division, a possibly unfused `Fma`) rather than correct @@ -1227,18 +1237,18 @@ pub enum PrecisionNote { ComputedSampleDepth, /// An access through an argument buffer's sampler whose word the specialized module cannot read /// may hand the device a pixel coordinate scaled by the texture's size, where the sampler - /// states pixel coordinates and a linear filter or a comparison. Recorded on every device for - /// such an access but a 2D gather, which snaps behind the sampler's word, and a sample without - /// a comparison, which reads the device sampler's texels (a nearest word's flagged fetch, a - /// linear word's footprint cell). Measured exact: a nearest or linear sample of `RGBA8Unorm` - /// and `RGBA16Float` through such a pixel sampler, clamped to the edge, to zero, to a border or - /// mirrored once, on MoltenVK and lavapipe. It is its own note, apart from + /// states pixel coordinates: the device's sampler reads its texels from that coordinate in its + /// own arithmetic, with [`PrecisionNote::PixelSamplerScaling`]'s measured bound (the + /// neighbouring texel, block or sub-texel step where the coordinate lies within a few units in + /// the last place of an edge of one). Recorded on every device for every such access; a sample + /// without a comparison through a sampler whose word states the exact fetch (nearest, clamped + /// to the edge, one level, isotropic) reads that fetch instead. It is its own note, apart from /// [`PrecisionNote::PixelSamplerScaling`], because only the bound states decide it: the runtime /// announces it at the first draw or dispatch of a pipeline that records it while the device - /// lists a sampler state of pixel coordinates with a linear filter or a comparison, never at - /// the pipeline's making. + /// lists a sampler state of pixel coordinates, never at the pipeline's making. /// - /// Validation derives no tolerance from it: the class is unbounded. + /// Validation derives no tolerance from it: at a texel edge the value is the neighbouring + /// texel's, whatever it holds. ArgumentPixelSamplerScaling, /// A fragment function returns a `half` color output (a scalar or vector of AIR's `half`) to /// an attachment the pipeline has, and either its module is compiled without fast math diff --git a/crates/metal2vulkan/src/tests/engine_graphics_binder.rs b/crates/metal2vulkan/src/tests/engine_graphics_binder.rs index eed627a0b..21e22c0ef 100644 --- a/crates/metal2vulkan/src/tests/engine_graphics_binder.rs +++ b/crates/metal2vulkan/src/tests/engine_graphics_binder.rs @@ -1379,8 +1379,7 @@ fn sampled_textures_and_runtime_samplers() { } assert!(plan.diagnostics.is_empty(), "{stem}"); // The pixel-coordinate path is selected by specialization when the kernel declares it: - // the bound sampler's word masked by the fields the kernel reads, 0 for a word of - // normalized coordinates where the fields are gated by the coordinates bit. + // the bound sampler's word masked by the fields the kernel reads. let state = p .stage .specialization @@ -1410,13 +1409,7 @@ fn sampled_textures_and_runtime_samplers() { u32::from_le_bytes(bytes.try_into().expect("a u32")) }; let normalized = sampler(true, SamplerReductionMode::WeightedAverage); - let keyed = |word: u32| { - let gated = fields & SamplerWord::PIXEL_GATED != 0; - match gated && word & SamplerWord::PIXEL_COORDINATES == 0 { - true => 0, - false => word & fields, - } - }; + let keyed = |word: u32| word & fields; assert_eq!( value(&plan), keyed(SamplerWord::of(&normalized.desc).0), diff --git a/crates/metal2vulkan/src/tests/engine_handles.rs b/crates/metal2vulkan/src/tests/engine_handles.rs index 44822286e..f723c5095 100644 --- a/crates/metal2vulkan/src/tests/engine_handles.rs +++ b/crates/metal2vulkan/src/tests/engine_handles.rs @@ -4238,15 +4238,13 @@ fn is_sampler_table(k: &ResourceKind) -> bool { /// own domain: a lookup in the stage's sampler table (set 0) whose element indexes the set-1 /// sampler array of the sample's use (comparison, integer texel), non-uniformly, and /// `OpSampledImage` of the heap image and that sampler. Each entry declares one sampler array of -/// its use; a comparison in the sampler's coordinates carries the argument buffer's -/// pixel-coordinate near-equivalent (`ArgumentPixelSamplerScaling`; a sample without comparison -/// reads the device sampler's texels; never `PixelSamplerScaling`), a comparison or an integer -/// texel samples through its own use, and a fragment samples at its implicit level. A sample -/// without comparison also fetches the texel the rule names, which the sampler's word selects; a -/// sample, a comparison's included, tests the word for a nearest pixel sampler -/// (`SamplerWord::PIXEL_NEAREST`; of an integer texture, for pixel coordinates), which selects the -/// centre of the texel Metal floors its coordinate to. A profile without the heap's features -/// refuses each naming them. +/// its use; every access in the sampler's coordinates carries the argument buffer's +/// pixel-coordinate near-equivalent (`ArgumentPixelSamplerScaling`; never `PixelSamplerScaling`), +/// a comparison or an integer texel samples through its own use, and a fragment samples at its +/// implicit level. A sample without comparison also fetches the texel the rule names, which the +/// sampler's word selects; no access reads a texel's centre (no test of the word's filters beside +/// its coordinates, `SamplerWord::PIXEL_COORDINATES | SamplerWord::MIN_LINEAR | +/// SamplerWord::MAG_LINEAR`). A profile without the heap's features refuses each naming them. #[test] fn argument_buffer_samplers_are_heap_lookups() { let Some(bc) = argument_samplers_fixture() else { @@ -4341,26 +4339,21 @@ fn argument_buffer_samplers_are_heap_lookups() { "{stem} {entry}" ); assert_eq!(non_uniform(&a), 6 + usize::from(!compare), "{stem} {entry}"); - assert_eq!( + assert!( a.precision .contains(&PrecisionNote::ArgumentPixelSamplerScaling), - compare, "{stem} {entry}" ); assert!( !a.precision.contains(&PrecisionNote::PixelSamplerScaling), "{stem} {entry}" ); - // A sample, a comparison's included, reads the texel's centre where the sampler's - // word states a nearest pixel sampler; an integer texture's, which no sampler filters, - // where it states pixel coordinates. - let centre = match use_.1 { - true => SamplerWord::PIXEL_COORDINATES, - false => SamplerWord::PIXEL_NEAREST, - }; + // No texel centre: no mask of the word's coordinates and filters. + let centre = + SamplerWord::PIXEL_COORDINATES | SamplerWord::MIN_LINEAR | SamplerWord::MAG_LINEAR; assert!( - u32_constants(&a).contains(¢re), - "{stem} {entry}: the word's nearest pixel sampler" + !u32_constants(&a).contains(¢re), + "{stem} {entry}: a test of the word's nearest pixel sampler" ); compiled += 1; } diff --git a/crates/metal2vulkan/src/tests/engine_snapped.rs b/crates/metal2vulkan/src/tests/engine_sample_coordinates.rs similarity index 68% rename from crates/metal2vulkan/src/tests/engine_snapped.rs rename to crates/metal2vulkan/src/tests/engine_sample_coordinates.rs index 990db6f1f..e52c6416b 100644 --- a/crates/metal2vulkan/src/tests/engine_snapped.rs +++ b/crates/metal2vulkan/src/tests/engine_sample_coordinates.rs @@ -1,16 +1,13 @@ //! The coordinates a device's gathers and samples read. A gather and a sample through a constexpr -//! normalized sampler are the device's sampler's on every device (Metal's own on MoltenVK). A -//! constexpr pixel sampler's position is the coordinate as given, on every device: its gather -//! snaps from it (`sampler.gather.snapped`), and its linear sample snaps onto its footprint cell -//! (`sampler.linear.snapped`), none of them noted `PixelSamplerScaling`; and a cube reads it as a -//! normalized sampler. A runtime sampler's gather snaps behind its word where the word states pixel -//! coordinates. Every module requires the device's sampler (`VkProperty::MetalSampler` or -//! `VkProperty::DeviceSampling`) and validates on every committed profile, and the plan's word +//! normalized sampler are the device's sampler's on every device (Metal's own on MoltenVK), at the +//! coordinate as given: a subnormal coordinate reaches the device unflushed, the border axes' +//! included. A pixel sampler's coordinate reaches the device's sampler divided by the level-0 +//! size, on every device, under the operation's own census name and noted `PixelSamplerScaling`; +//! a cube reads it as a normalized sampler. A runtime sampler's gather and sample read only its +//! word's coordinates bit. Every module requires the device's sampler (`VkProperty::MetalSampler` +//! or `VkProperty::DeviceSampling`) and validates on every committed profile, and the plan's word //! estimate bounds what it emits. //! -//! The snapped coordinate's arithmetic is checked bit for bit on the interpreter by -//! `lower::sampler::position`'s tests (the interpreter has no gather or sample). -//! //! `llvm-as` assembles the kernels; without it the tests skip visibly. use std::sync::atomic::{AtomicU64, Ordering}; @@ -29,7 +26,7 @@ const HEADER: &str = "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16 fn assemble(name: &str, body: &str) -> Option> { static NEXT: AtomicU64 = AtomicU64::new(0); let dir = std::env::temp_dir().join(format!( - "m2v-snapped-{}-{}-{}", + "m2v-coordinates-{}-{}-{}", std::process::id(), NEXT.fetch_add(1, Ordering::Relaxed), name.replace(' ', "-") @@ -93,6 +90,13 @@ enum Op { /// A kernel performing `op` through constexpr sampler `words` (`None`: the runtime /// `[[sampler(0)]]`). fn kernel(op: Op, words: Option) -> String { + kernel_of(op, words, false) +} + +/// [`kernel`], its coordinate, where `flushed`, replaced in the AIR by the zero of its sign on +/// each lane whose magnitude is subnormal (integer operations on its bits, a select between them): +/// the shape a flush of the coordinate takes in the module. +fn kernel_of(op: Op, words: Option, flushed: bool) -> String { let s = if words.is_some() { "@__air_sampler_state" } else { @@ -170,12 +174,25 @@ fn kernel(op: Op, words: Option) -> String { ), None => (String::new(), "", ""), }; + let load = match flushed { + false => " %uv = load <2 x float>, ptr addrspace(1) %p, align 8\n".to_owned(), + true => [ + " %given = load <2 x float>, ptr addrspace(1) %p, align 8", + " %bits = bitcast <2 x float> %given to <2 x i32>", + " %magnitude = and <2 x i32> %bits, ", + " %small = icmp ult <2 x i32> %magnitude, ", + " %sign = and <2 x i32> %bits, ", + " %kept = select <2 x i1> %small, <2 x i32> %sign, <2 x i32> %bits", + " %uv = bitcast <2 x i32> %kept to <2 x float>", + "", + ] + .join("\n"), + }; format!( r#"{state}define void @k(ptr addrspace(1) %t, ptr addrspace(1) %c, ptr addrspace(1) %out{params}, i32 %tid) {{ %i = zext i32 %tid to i64 %p = getelementptr inbounds <2 x float>, ptr addrspace(1) %c, i64 %i - %uv = load <2 x float>, ptr addrspace(1) %p, align 8 - %u = extractelement <2 x float> %uv, i64 0 +{load} %u = extractelement <2 x float> %uv, i64 0 %uvw = shufflevector <2 x float> %uv, <2 x float> , <3 x i32> {load_lod} %r = call {{ <4 x float>, i8 }} {call} %v = extractvalue {{ <4 x float>, i8 }} %r, 0 @@ -243,7 +260,6 @@ fn cases() -> Vec<(&'static str, Op, Option, &'static str)> { near([EDGE; 3]), "sampler.gather", ), - // Snapped behind its word, under the operation's own name. ("gather runtime sampler", gather, None, "sampler.gather"), ( "nearest repeat 2d", @@ -287,8 +303,6 @@ fn cases() -> Vec<(&'static str, Op, Option, &'static str)> { Some(sampler(0, 1, [REPEAT; 3], false)), "sampler.sample", ), - // A runtime sampler's sample snaps onto its footprint cell where its word states a - // linear pixel sampler, under the operation's own name. ( "nearest repeat runtime sampler", Op::Sample2D, @@ -366,41 +380,47 @@ fn the_fixture_cube_gathers_are_the_device_s() { /// coordinates). fn pixel_cases() -> Vec<(&'static str, Op, u64, Option<&'static str>)> { let pixel = |filter, address| sampler(filter, 0, address, true); - let snapped = Some("sampler.gather.snapped"); - let linear = Some("sampler.linear.snapped"); + let gather = Some("sampler.gather"); + let sample = Some("sampler.sample"); vec![ ( "pixel gather edge", Op::Gather { offset: (0, 0) }, pixel(0, [EDGE; 3]), - snapped, + gather, ), ( "pixel gather zero offset", Op::Gather { offset: (2, -3) }, pixel(0, [ZERO; 3]), - snapped, + gather, ), ( "pixel gather linear sampler", Op::Gather { offset: (0, 0) }, pixel(1, [EDGE; 3]), - snapped, + gather, ), ( "pixel gather array", Op::GatherArray, pixel(0, [ZERO, EDGE, EDGE]), - snapped, + gather, ), - ("pixel linear 1d", Op::Sample1D, pixel(1, [EDGE; 3]), linear), + ("pixel linear 1d", Op::Sample1D, pixel(1, [EDGE; 3]), sample), ( "pixel linear 2d", Op::Sample2D, pixel(1, [ZERO, EDGE, EDGE]), - linear, + sample, + ), + ("pixel linear 3d", Op::Sample3D, pixel(1, [EDGE; 3]), sample), + ( + "pixel nearest zero 2d", + Op::Sample2D, + pixel(0, [ZERO; 3]), + sample, ), - ("pixel linear 3d", Op::Sample3D, pixel(1, [EDGE; 3]), linear), ( "pixel nearest cube", Op::SampleCube, @@ -416,12 +436,33 @@ fn pixel_cases() -> Vec<(&'static str, Op, u64, Option<&'static str>)> { ] } -/// On every committed profile, a constexpr pixel sampler's gather and linear sample compile to -/// their census names, require the device's sampler, validate, and record no -/// `PixelSamplerScaling`; a cube through a pixel sampler compiles as through the same sampler with -/// normalized coordinates, to the same census, notes, and requirements. +/// The `GLSL.std.450` instructions numbered `glsl` the module of `a` calls. +fn glsl_count(a: &FunctionArtifact, glsl: u32) -> usize { + const OP_EXT_INST: u32 = 12; + let words = &a.module.words; + let mut n = 0; + let mut i = 5; + while i < words.len() { + let len = (words[i] >> 16) as usize; + if words[i] & 0xFFFF == OP_EXT_INST && words.get(i + 4) == Some(&glsl) { + n += 1; + } + i += len.max(1); + } + n +} + +/// `GLSL.std.450 Floor`, which a texel centre, a footprint cell and a gather's block all take. +const GLSL_FLOOR: u32 = 8; + +/// On every committed profile, a constexpr pixel sampler's gather and linear or clamp-to-zero +/// sample compile to their operation's census names, hand the device the coordinate divided by +/// the level-0 size as given (no `Floor` of it: no texel centre, footprint cell or block), +/// record `PixelSamplerScaling`, require the device's sampler and validate; a cube through a pixel +/// sampler compiles as through the same sampler with normalized coordinates, to the same census, +/// notes, and requirements. #[test] -fn pixel_samplers_read_metals_position_on_every_device() { +fn pixel_samplers_hand_the_device_the_scaled_coordinate() { let profiles = crate::spirv::testing::committed_profiles().expect("profiles"); for (name, op, words, expect) in pixel_cases() { let Some(bc) = assemble(name, &kernel(op, Some(words))) else { @@ -439,9 +480,10 @@ fn pixel_samplers_read_metals_position_on_every_device() { (Some(census), _) => { assert_eq!(uses(&a, census), 1, "{what}"); assert!( - !a.precision.contains(&PrecisionNote::PixelSamplerScaling), + a.precision.contains(&PrecisionNote::PixelSamplerScaling), "{what}" ); + assert_eq!(glsl_count(&a, GLSL_FLOOR), 0, "{what}"); assert!(requires_the_sampler(&a, p), "{what}"); } (None, Some(nbc)) => { @@ -469,18 +511,14 @@ fn sampler_fields(a: &FunctionArtifact) -> u32 { .expect("a `SamplerState` specialization") } -/// On every committed profile, a runtime sampler's gather of a 2D texture or array snaps behind its -/// word (`position::SnapKind::WordGather`): the function reads the word's coordinates and its `s` -/// and `t` modes, and records no `PixelSamplerScaling`, every word's gather reading Metal's block. -/// A runtime sampler's 2D sample reads whether the word states a linear pixel sampler -/// (`position::SnapKind::WordCell`), and keeps `PixelSamplerScaling`. Each requires the device's -/// sampler. +/// On every committed profile, a runtime sampler's gather of a 2D texture or array and its 2D +/// sample read only the coordinates bit of its word (none of its address modes or filters), hand +/// the device the coordinate scaled behind it (no `Floor`), and record `PixelSamplerScaling`. Each +/// requires the device's sampler. #[test] -fn a_runtime_samplers_gather_snaps_behind_its_word() { +fn a_runtime_samplers_gather_and_sample_read_only_its_coordinates() { use crate::metal::sampler::SamplerWord; let profiles = crate::spirv::testing::committed_profiles().expect("profiles"); - let gather = SamplerWord::PIXEL_COORDINATES | SamplerWord::ADDRESS[0] | SamplerWord::ADDRESS[1]; - let cell = SamplerWord::PIXEL_COORDINATES | SamplerWord::MIN_LINEAR | SamplerWord::MAG_LINEAR; for (name, op) in [ ("runtime gather", Op::Gather { offset: (0, 0) }), ("runtime gather offset", Op::Gather { offset: (2, -1) }), @@ -494,16 +532,135 @@ fn a_runtime_samplers_gather_snaps_behind_its_word() { let what = format!("{name} on {stem}"); let a = compile(&bc, "k", p).unwrap_or_else(|e| panic!("{what}: {e}")); link_and_validate(&a, p).unwrap_or_else(|e| panic!("{what}: {e}")); - let fields = sampler_fields(&a); - let scaled = a.precision.contains(&PrecisionNote::PixelSamplerScaling); assert!(requires_the_sampler(&a, p), "{what}"); - if matches!(op, Op::Sample2D) { - assert_eq!(fields & cell, cell, "{what}: {fields:#x}"); - assert!(scaled, "{what}"); - continue; + assert_eq!(sampler_fields(&a), SamplerWord::PIXEL_COORDINATES, "{what}"); + assert!( + a.precision.contains(&PrecisionNote::PixelSamplerScaling), + "{what}" + ); + assert_eq!(glsl_count(&a, GLSL_FLOOR), 0, "{what}"); + } + } +} + +/// Whether every coordinate operand of every sample and gather in the module `words` is the +/// coordinate the kernel loaded, its bits unchanged: built from the loaded words by bit moves alone +/// (loads, bitcasts, the extraction, construction and shuffle of lanes, constants), and an array's +/// layer by its conversion to `float`. Also whether the module samples or gathers at all. +fn coordinates_pass_through(words: &[u32]) -> (bool, bool) { + use crate::spirv_binary::{parse_bytes, Operand}; + use crate::spv::Op as O; + use std::collections::HashMap; + let bytes: Vec = words.iter().flat_map(|w| w.to_le_bytes()).collect(); + let parsed = parse_bytes(&bytes).expect("parse"); + let defs: HashMap = parsed + .instructions + .iter() + .filter_map(|i| i.result_id.map(|id| (id, i))) + .collect(); + let ids = |i: &crate::spirv_binary::Instruction| -> Vec { + i.operands + .iter() + .filter_map(|o| match o { + Operand::IdRef(w) => Some(*w), + _ => None, + }) + .collect() + }; + // The value `id` is a bit move of the loaded coordinate (or a constant, or a layer). + fn moves( + id: u32, + defs: &HashMap, + ids: &dyn Fn(&crate::spirv_binary::Instruction) -> Vec, + ) -> bool { + let Some(i) = defs.get(&id) else { + return false; + }; + match i.opcode { + // A load's operand is its pointer, not a value of the coordinate's. + O::Load + | O::Constant + | O::ConstantComposite + | O::ConstantNull + | O::ConvertUToF + | O::ConvertSToF => true, + O::Bitcast + | O::CompositeExtract + | O::CompositeConstruct + | O::CompositeInsert + | O::VectorShuffle + | O::CopyObject => ids(i).into_iter().all(|v| moves(v, defs, ids)), + _ => false, + } + } + let mut sampled = false; + let mut all = true; + for i in &parsed.instructions { + let coordinate = match i.opcode { + O::ImageSampleImplicitLod + | O::ImageSampleExplicitLod + | O::ImageSampleDrefImplicitLod + | O::ImageSampleDrefExplicitLod + | O::ImageGather + | O::ImageDrefGather + | O::ImageSparseSampleImplicitLod + | O::ImageSparseSampleExplicitLod + | O::ImageSparseGather => ids(i).get(1).copied(), + _ => continue, + }; + sampled = true; + all &= coordinate.is_some_and(|c| moves(c, &defs, &ids)); + } + (sampled, all) +} + +/// The kernels of the subnormal test: through constexpr normalized samplers whose every axis +/// addresses through the border (clamp to zero, and to an opaque white border), nearest and linear, +/// of 1D, 2D and 3D textures and a 2D gather. +fn border_cases() -> Vec<(String, Op, u64)> { + const OPAQUE_WHITE: u64 = 2 << 56; + let mut out = Vec::new(); + for (op, what) in [ + (Op::Sample1D, "1d"), + (Op::Sample2D, "2d"), + (Op::Sample3D, "3d"), + (Op::Gather { offset: (0, 0) }, "gather"), + ] { + for filter in [0, 1] { + for (border, colour) in [(0, "zero"), (OPAQUE_WHITE, "white")] { + let words = sampler(filter, 0, [ZERO; 3], false) | border; + out.push((format!("border {what} {filter} {colour}"), op, words)); + } + } + } + out +} + +/// A subnormal coordinate reaches the device's sampler as given, on every committed profile: the +/// coordinate operand of each sample and gather through a constexpr normalized sampler whose axes +/// address through the border (where Metal's texture unit reads a subnormal as the zero of its +/// sign before the address mode decides, `PrecisionNote::DeviceSampling`) is the loaded coordinate, +/// its bits unchanged. The negative control: the same kernels with the coordinate flushed in the +/// AIR, whose modules read the coordinate's bits before the sample, are told apart. +#[test] +fn a_subnormal_coordinate_reaches_the_device_unflushed() { + let profiles = crate::spirv::testing::committed_profiles().expect("profiles"); + for (name, op, words) in border_cases() { + for flushed in [false, true] { + let Some(bc) = assemble(&name, &kernel_of(op, Some(words), flushed)) else { + return; + }; + for (stem, p) in &profiles { + let what = format!("{name} (flushed: {flushed}) on {stem}"); + let a = compile(&bc, "k", p).unwrap_or_else(|e| panic!("{what}: {e}")); + link_and_validate(&a, p).unwrap_or_else(|e| panic!("{what}: {e}")); + let (sampled, through) = coordinates_pass_through(&a.module.words); + assert!(sampled, "{what}: no sample or gather"); + assert_eq!(through, !flushed, "{what}"); + if !flushed { + assert!(requires_the_sampler(&a, p), "{what}"); + } } - assert_eq!(fields & gather, gather, "{what}: {fields:#x}"); - assert!(!scaled, "{what}"); } } } @@ -511,7 +668,7 @@ fn a_runtime_samplers_gather_snaps_behind_its_word() { /// The plan's word estimate bounds the emitted module of every kernel above on every committed /// profile. #[test] -fn the_snapped_estimate_bounds_its_emission() { +fn the_coordinate_estimate_bounds_its_emission() { use crate::budget::SPIRV_WORDS; use crate::library::FunctionConstantValues; use crate::lower::select::LowerInputs; diff --git a/crates/metal2vulkan/src/tests/engine_sampler.rs b/crates/metal2vulkan/src/tests/engine_sampler.rs index 5ddf0ce52..8d09d2690 100644 --- a/crates/metal2vulkan/src/tests/engine_sampler.rs +++ b/crates/metal2vulkan/src/tests/engine_sampler.rs @@ -119,6 +119,25 @@ fn count(a: &FunctionArtifact, op: u16) -> usize { .count() } +/// The `GLSL.std.450` instructions numbered `glsl` the module's `OpExtInst`s call. +fn glsl_count(a: &FunctionArtifact, glsl: u32) -> usize { + const OP_EXT_INST: u32 = 12; + let words = &a.module.words; + let mut n = 0; + let mut i = 5; + while i < words.len() { + let len = (words[i] >> 16) as usize; + if words[i] & 0xFFFF == OP_EXT_INST && words.get(i + 4) == Some(&glsl) { + n += 1; + } + i += len.max(1); + } + n +} + +/// `GLSL.std.450 Floor`. +const GLSL_FLOOR: u32 = 8; + const OP_SELECT: u16 = 169; const OP_FDIV: u16 = 136; const OP_IMAGE_SAMPLE_IMPLICIT_LOD: u16 = 87; @@ -270,11 +289,8 @@ fn runtime_samplers_select_pixel_coordinates_by_specialization() { .facts .contains(&RuntimeFact::SamplerCoordinates { slot: s })); assert!(a.facts.contains(&RuntimeFact::SamplerReduction { slot: s })); - // Read only through the pixel tests: gated by the coordinates bit. - assert_eq!( - sampler_fields(&a, s), - Some(SamplerWord::PIXEL_NEAREST | SamplerWord::PIXEL_GATED) - ); + // The coordinates bit alone: the device's sampler reads the scaled coordinate. + assert_eq!(sampler_fields(&a, s), Some(SamplerWord::PIXEL_COORDINATES)); assert!(a.precision.contains(&PrecisionNote::PixelSamplerScaling)); assert_eq!(uses(&a, "sampler.sample"), 1); assert_eq!(combined(&a), vec![(0, SamplerRef::Slot(0), false, false)]); @@ -299,10 +315,9 @@ fn runtime_samplers_select_pixel_coordinates_by_specialization() { } /// A sample through a runtime sampler slot is the device's on every committed profile: the -/// function reads only the pixel fields of the slot's word (`SamplerWord::PIXEL_NEAREST`, gated by -/// the coordinates bit), never its filter, address modes or levels, and the module requires the -/// device's own sampler (`VkProperty::MetalSampler` on MoltenVK, `VkProperty::DeviceSampling` -/// elsewhere) and validates. +/// function reads only the coordinates bit of the slot's word (`SamplerWord::PIXEL_COORDINATES`), +/// never its filter, address modes or levels, and the module requires the device's own sampler +/// (`VkProperty::MetalSampler` on MoltenVK, `VkProperty::DeviceSampling` elsewhere) and validates. #[test] fn a_runtime_samplers_sample_is_the_device_s() { let Some(bc) = fixture() else { @@ -314,7 +329,7 @@ fn a_runtime_samplers_sample_is_the_device_s() { let a = ok(&bc, "sample_level", &p); assert_eq!( sampler_fields(&a, s), - Some(SamplerWord::PIXEL_NEAREST | SamplerWord::PIXEL_GATED), + Some(SamplerWord::PIXEL_COORDINATES), "{stem}" ); assert_eq!(uses(&a, "sampler.sample"), 1, "{stem}"); @@ -372,62 +387,62 @@ fn a_runtime_samples_level_is_the_device_s() { } } -/// A sample through a runtime sampler slot reads the slot's word for a nearest pixel sampler beside -/// its pixel coordinates (the `SamplerState` fields `SamplerWord::PIXEL_NEAREST`), and selects by -/// it the centre of the texel Metal floors a pixel coordinate to, keeping `PixelSamplerScaling`; a -/// gather through one reads the pixel coordinates and the `s` and `t` address modes, and snaps onto -/// Metal's block behind them, so it records no note. +/// A sample, a gather and a comparison through a runtime sampler slot read only the coordinates +/// bit of the slot's word (`SamplerWord::PIXEL_COORDINATES`), and hand the device's sampler the +/// coordinate scaled behind it, on every committed profile: each records `PixelSamplerScaling`, +/// held where the bound sampler states pixel coordinates (its one clause tests that bit), and +/// emits no texel centre, footprint cell or block (no `Floor`). #[test] -fn runtime_pixel_samples_read_the_texel_centre_by_specialization() { +fn runtime_pixel_accesses_hand_the_device_the_scaled_coordinate() { + use crate::pipeline::artifact::SpecializedNote; let s = slot(Stage::Kernel, SlotClass::Sampler, 0); - for gather in [false, true] { - let name = if gather { - "pixel_gather" - } else { - "pixel_sample" - }; - let Some(bc) = assemble(name, &dynamic_offset_kernel(gather)) else { + let kernels = [ + ("pixel_sample", dynamic_offset_kernel(false)), + ("pixel_gather", dynamic_offset_kernel(true)), + ("pixel_compare", COMPARE_KERNEL.to_owned()), + ]; + for (name, text) in kernels { + let Some(bc) = assemble(name, &text) else { return; }; - let a = ok(&bc, "k", &m3()); - let fields = match gather { - true => { - SamplerWord::PIXEL_COORDINATES | SamplerWord::ADDRESS[0] | SamplerWord::ADDRESS[1] - } - // Read only through the pixel tests: gated. - false => SamplerWord::PIXEL_NEAREST | SamplerWord::PIXEL_GATED, - }; - assert_eq!(sampler_fields(&a, s), Some(fields), "{name}"); - assert!(a - .facts - .contains(&RuntimeFact::SamplerCoordinates { slot: s })); - assert_eq!( - a.precision.contains(&PrecisionNote::PixelSamplerScaling), - !gather, - "{name}" - ); + for (stem, p) in committed_profiles().expect("profiles") { + let what = format!("{name} on {stem}"); + let a = ok(&bc, "k", &p); + assert_eq!( + sampler_fields(&a, s), + Some(SamplerWord::PIXEL_COORDINATES), + "{what}" + ); + assert!(a + .facts + .contains(&RuntimeFact::SamplerCoordinates { slot: s })); + assert!( + a.precision.contains(&PrecisionNote::PixelSamplerScaling), + "{what}" + ); + let key = SpecKey::SamplerState { + slot: s, + fields: SamplerWord::PIXEL_COORDINATES, + }; + let held: Vec<&SpecializedNote> = a + .specialized + .iter() + .filter(|n| n.note == PrecisionNote::PixelSamplerScaling) + .collect(); + assert_eq!(held.len(), 1, "{what}: {held:?}"); + assert!( + held[0].when.iter().all(|c| c + .all + .iter() + .all(|t| t.key == key && t.mask == SamplerWord::PIXEL_COORDINATES)), + "{what}: {held:?}" + ); + assert_eq!(glsl_count(&a, GLSL_FLOOR), 0, "{what}"); + assert!(count(&a, OP_FDIV) >= 1, "{what}"); + } } } -/// A comparison through a runtime sampler slot reads the centre of the texel Metal floors a pixel -/// coordinate to, as a sample does, behind the slot's word for a nearest pixel sampler -/// (`SamplerWord::PIXEL_NEAREST`), and records `PixelSamplerScaling` (the bound sampler may filter -/// linearly). -#[test] -fn a_runtime_pixel_comparison_reads_the_texel_centre_by_specialization() { - let s = slot(Stage::Kernel, SlotClass::Sampler, 0); - let Some(bc) = assemble("pixel_compare", COMPARE_KERNEL) else { - return; - }; - let a = ok(&bc, "k", &m3()); - assert_eq!(count(&a, OP_IMAGE_SAMPLE_DREF_EXPLICIT_LOD), 1); - assert_eq!( - sampler_fields(&a, s), - Some(SamplerWord::PIXEL_NEAREST | SamplerWord::PIXEL_GATED) - ); - assert!(a.precision.contains(&PrecisionNote::PixelSamplerScaling)); -} - /// A kernel whose one comparison samples `depth2d` slot 0 through runtime sampler /// slot 0 at a coordinate from its buffer. const COMPARE_KERNEL: &str = r#" @@ -762,11 +777,11 @@ fn gathers_gradients_and_pixel_constexpr_samplers() { // device's decode. assert_half_rounding(&h); assert!(h.precision.contains(&PrecisionNote::DeviceNanEncoding)); - // A linear pixel sample, which Metal's own sampler filters on this profile, snapped onto the - // centre of its footprint step: exact, so no `PixelSamplerScaling`. + // A linear pixel sample, the device's sampler's at the coordinate scaled in the shader: + // `PixelSamplerScaling`, on Metal's own sampler too. let x = ok(&bc, "sample_pixel", &p); - assert!(!x.precision.contains(&PrecisionNote::PixelSamplerScaling)); - assert_eq!(uses(&x, "sampler.linear.snapped"), 1); + assert!(x.precision.contains(&PrecisionNote::PixelSamplerScaling)); + assert_eq!(uses(&x, "sampler.sample"), 1); assert!(count(&x, OP_FDIV) >= 1); assert!(x .interface diff --git a/crates/metal2vulkan/src/tests/engine_sampler_completion.rs b/crates/metal2vulkan/src/tests/engine_sampler_completion.rs index 756ad4a1a..37328cf08 100644 --- a/crates/metal2vulkan/src/tests/engine_sampler_completion.rs +++ b/crates/metal2vulkan/src/tests/engine_sampler_completion.rs @@ -304,11 +304,11 @@ fn a_switch_of_pixel_fetches_hoists_nothing() { } /// A nearest pixel sampler that clamps to zero keeps the sample, because its out-of-range texel -/// depends on the bound pixel format, and reads the centre of the texel Metal floors its coordinate -/// to (its floor, divided by the size), which every device's nearest filter names: exact, so it -/// carries no `PixelSamplerScaling`. +/// depends on the bound pixel format, and hands the device's sampler the coordinate divided by the +/// size, as given (no floor, no texel centre): the device's nearest filter names the texel, so it +/// carries `PixelSamplerScaling`. #[test] -fn a_clamp_to_zero_pixel_sampler_samples_its_texel_centre() { +fn a_clamp_to_zero_pixel_sampler_samples_the_scaled_coordinate() { let Some(bc) = fixture() else { return; }; @@ -316,8 +316,8 @@ fn a_clamp_to_zero_pixel_sampler_samples_its_texel_centre() { assert_eq!(count(&a, OP_IMAGE_FETCH), 0); assert_eq!(uses(&a, "sampler.sample"), 1); assert!(count(&a, OP_FDIV) >= 1); - assert!(count(&a, OP_EXT_INST) >= 1); - assert!(!a.precision.contains(&PrecisionNote::PixelSamplerScaling)); + assert_eq!(glsl(&a, GLSL_FLOOR), 0); + assert!(a.precision.contains(&PrecisionNote::PixelSamplerScaling)); } /// The image-operand masks of every instruction `op` of the module, the mask being operand word diff --git a/crates/metal2vulkan/src/tests/fast_paths.rs b/crates/metal2vulkan/src/tests/fast_paths.rs index 638b4dc6b..94014f8e7 100644 --- a/crates/metal2vulkan/src/tests/fast_paths.rs +++ b/crates/metal2vulkan/src/tests/fast_paths.rs @@ -118,6 +118,8 @@ fn notes() -> Vec<(&'static str, Ledger)> { DevicePackConversion, DeviceDenormals, DeviceSampling, + PixelSamplerScaling, + ArgumentPixelSamplerScaling, DeviceTexelConversion, HalfTexelConversion, SrgbTexelDecode, @@ -140,7 +142,6 @@ fn notes() -> Vec<(&'static str, Ledger)> { F16IntConvDoubleRounding, GradFromBias, DeviceTranscendentals, - PixelSamplerScaling, DeviceArithmetic, DeviceRayIntersection, TessellationWinding, @@ -166,7 +167,6 @@ fn notes() -> Vec<(&'static str, Ledger)> { RotatedBlendRounding, LinkedSamplerNumbering, ComputedSampleDepth, - ArgumentPixelSamplerScaling, DiscardDropsSimdgroupStores, HelperBranchDropsSimdgroupStores, AnisotropicFilter, diff --git a/crates/metal2vulkan/src/tests/mod.rs b/crates/metal2vulkan/src/tests/mod.rs index 0adf72582..177b9c2db 100644 --- a/crates/metal2vulkan/src/tests/mod.rs +++ b/crates/metal2vulkan/src/tests/mod.rs @@ -112,6 +112,7 @@ mod engine_rgbx_storage; mod engine_roll; mod engine_rotated_colors; mod engine_rotated_weights; +mod engine_sample_coordinates; mod engine_sampler; mod engine_sampler_completion; mod engine_sampler_tail; @@ -128,7 +129,6 @@ mod engine_simd_partly_live; mod engine_simd_past_n; mod engine_simd_products; mod engine_skeleton; -mod engine_snapped; mod engine_snapshot_exact; mod engine_sparse_unmapped; mod engine_spec_bits; diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index c980acb0b..2f28fe70d 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -471,8 +471,6 @@ assoc-const metal2vulkan::metal::sampler::SamplerWord::MIN_LINEAR pub const MIN_ assoc-const metal2vulkan::metal::sampler::SamplerWord::MIP_FILTER pub const MIP_FILTER: u32 assoc-const metal2vulkan::metal::sampler::SamplerWord::MIP_FILTER_SHIFT pub const MIP_FILTER_SHIFT: u32 assoc-const metal2vulkan::metal::sampler::SamplerWord::PIXEL_COORDINATES pub const PIXEL_COORDINATES: u32 -assoc-const metal2vulkan::metal::sampler::SamplerWord::PIXEL_GATED pub const PIXEL_GATED: u32 -assoc-const metal2vulkan::metal::sampler::SamplerWord::PIXEL_NEAREST pub const PIXEL_NEAREST: u32 assoc-const metal2vulkan::metal::sampler::SamplerWord::REDUCTION pub const REDUCTION: u32 assoc-const metal2vulkan::metal::sampler::SamplerWord::REDUCTION_SHIFT pub const REDUCTION_SHIFT: u32 assoc-const metal2vulkan::pipeline::AccessSet::READ pub const READ: AccessSet @@ -967,8 +965,6 @@ assoc-const-value metal2vulkan::metal::sampler::SamplerWord::MIN_LINEAR 1 <<1 assoc-const-value metal2vulkan::metal::sampler::SamplerWord::MIP_FILTER 0b11 <