Translator and runtime: BGR10_XR and BGRA10_XR render targets take Metal's writes, clears, masks and covered blends
The red commit's test, and the conformance cases that render into either format, which the runtime refused (Gap::TextureFormat on a RenderTarget texture). Attachments. A BGR10_XR or BGRA10_XR color attachment is its texture's UNORM image (FormatEmulation::ExtendedRangeUnorm, now admitted as a color attachment and, blended, as a blended one): A2R10G10B10_UNORM_PACK32, and R16G16B16A16_UNORM with red and blue exchanged. The formats' second, raw candidate and ExtendedRange::of_attachment are gone; the runtime makes a RenderTarget texture of either, and a device whose format query lacks the usages is refused the pipeline, naming them (the runtime's floor does not require R16G16B16A16_UNORM as a color attachment). Writes (lower::stage_io::extended_unorm_color). A fragment function writes Metal's code of its output (rounded to half, nearest even, then encoded as a kernel write encodes it) as the field's value over its maximum, a little above the code (metal::format::extended_unorm_field: 10-bit (c + 0.0005) / 1023, 16-bit (64 c + 0.25) / 65535), which a device's conversion stores as that code whether it rounds to nearest, toward zero, by floor(x 1024) or, as lavapipe does for a 10-bit target, through 16 bits (round(x 65535) >> 6; an offset of 0.25 stored code + 1 for the 251 codes from 772). BGR10_XR's two alpha bits are written as ones, as Metal writes them. Clears store Metal's clear codes (metal::format::extended_unorm_clear, the runtime's clear values). Masks are Metal's on the image's channels (BGRA10_XR's red and blue exchanged; BGR10_XR's alpha bits written with any color channel). A resolve is the device's AVERAGE of the codes, which average as the values do; PrecisionNote::DeviceRoundedResolve now names a BGRA10_XR field's low bits. A fetch of either attachment is refused NotImplemented(Format) at compile, and at link where the function does not write it. Blends (pipeline::extended_blend). Metal's blend into these formats, measured on an Apple M3 Max (macOS 27.0.1) over the xr-blend recordings: the source clamped to the values of codes 0 and 1022 (a NaN to code 0) and alpha to [0, 1], a destination color code to 1022, half arithmetic, the result rounded to a code. That model is every recorded channel's but 9 of 172,032 (premultiplied source-over, one code each, listed in the ledger rows). The function clamps its output as Metal's blend does; a blend that stores its source (one and zero, added) stores the clamped codes exactly. Any other blends the codes in Vulkan with a source factor of one, the function writing the term X that makes Vulkan's blend of the codes Metal's blend of the values; destination factors that read the source read it from a second output (dualSrcBlend, in the floor), BGR10_XR's alpha too, so its alpha bits stay ones. A factor pair the module does not cover (a BGRA10_XR destination alpha among them) is refused NotImplemented(Format). Notes, static per pipeline: PrecisionNote::ExtendedRangeBlend on every blend that does not store its source (the device rounds each draw's result to the field, a BGRA10_XR field keeping the fraction of a code in its six low bits); PrecisionNote::ExtendedRangeBlendWindow where the corrected term or a second-output factor can leave [0, 1], which Vulkan clamps (pipeline::extended_blend::window_holds, from the factors and operations at the corners of the source's range; a unit test classifies every factor pair and operation at both formats). Both are in docs/API.md's catalogue with counts, and the runtime's README records the window as a known gap with its trigger. Ledger: 18 llvmpipe rows of the B cases that differ (the xr-blend addition and premultiplied source-over, xr-gamut, the blended xr-gradient and xr-masked over draws, and xr-gradient's unblended resolve), each citing its note, with counts from a model of our blend whose count of differing elements is lavapipe's replay's to within 11; and the same cases' rows on the RTX 3090 (NVIDIA 620.70.06, m3-max-85796; there xr-gradient-bgra10xr-unblended-x1 too, 39 fields a code off by the device's arithmetic of the gradient), the RX 7900 XTX (m3-max-85797) and the Iris Xe (m3-max-85798), each pointing at the case's llvmpipe row, with that device's counts. Cache key: LoweringInputs::extended_unorm_colors is hashed into the function key where it is set (pipeline::compile::key), so a fragment function compiled for a BGR10_XR or BGRA10_XR attachment never takes another's translation; the key test asserts that the attachment and the format each change the key. SEMANTICS_VERSION 2378 and ARTIFACT_FORMAT_VERSION 612. RUNTIME_VERSION 2577 (XR render targets are made); runtime-sources.sha256 re-pinned. api_signatures blessed and api_surface extended (ExtendedUnormBlend, ExtendedUnormColor, extended_unorm_clear); docs/REFUSALS.md regenerated (the fetch's refusal site).
This commit is contained in:
1 parent
e9290d8138
commit
3e3deb25b9
44 files changed
+1986
-215
No files matched your search
@@ -3278,6 +3278,75 @@ texture-pairs-usage-crossings RX 550 refused case/MTLPixelFormatASTC_4x4_LDR/Typ
|
||||
texture-pairs-usage-crossings RX 550 refused case/MTLPixelFormatBC1_RGBA/Type2D/64x64x1/levels-1/samples-1/slices-1/usage-0x4/private/size-and-align Err(Error::Unsupported("no texture of BC1RGBA is made on this device for the usage")) The device's own answer (rule 2): this device's format queries offer no image of MTLPixelFormatBC1_RGBA with the usage the case asks, so rt makes no such texture (Gap::TextureFormat, or the creator's NotMade).
|
||||
texture-pairs-usage-crossings RX 550 refused case/MTLPixelFormatBC1_RGBA/Type2D/64x64x1/levels-1/samples-1/slices-1/usage-0x4/private/texture Err(Error::Unsupported("no texture of BC1RGBA is made on this device for the usage")) The device's own answer (rule 2): this device's format queries offer no image of MTLPixelFormatBC1_RGBA with the usage the case asks, so rt makes no such texture (Gap::TextureFormat, or the creator's NotMade).
|
||||
vertex-fetch-past-4gib-small-buffer * refused case/pipeline:vertex-6 Err(Error::Translation("the translator made no pipeline: unsupported: VertexInputLayout; needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (VertexInputLayout: the vertex layout); rt README, Known gaps of pipeline states.
|
||||
xr-blend-bgr10xr-add llvmpipe divergent case/texels 6913 elements differ (U32), the largest difference 403046697 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): an addition of one and one, whose source term Vulkan clamps to `[0, 1]` where the source is negative. By a model of the blend whose count of differing texels is lavapipe's to one (6,912), of the 24,576 channels 8,421 lie more than 32 codes from Metal's (up to 384), 894 two to 32 and 2,021 one; lavapipe stores the blend through 16 bits, `round(x 65535) >> 6`, where rounding to ten bits would leave 819 one code off. Metal's blend (its source clamped to codes 0 and 1022, a destination code to 1022, in `half`, the result rounded to a code) is that model's on every channel of this recording.
|
||||
xr-blend-bgr10xr-add NVIDIA divergent case/texels 6546 elements differ (U32), the largest difference 403046697 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-blend-bgr10xr-add RX 7900 XTX divergent case/texels 6806 elements differ (U32), the largest difference 403046697 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-blend-bgr10xr-add Iris(R) Xe divergent case/texels 6520 elements differ (U32), the largest difference 403046697 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-blend-bgr10xr-premul llvmpipe divergent case/texels 5972 elements differ (U32), the largest difference 403046547 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over, whose source term Vulkan clamps to `[0, 1]` where the source is below `-0.7529` times its alpha. By a model of the blend whose count of differing texels is lavapipe's to one (5,971), of the 24,576 channels 4,233 lie more than 32 codes from Metal's (up to 384), 915 two to 32 and 3,735 one; lavapipe stores the blend through 16 bits, `round(x 65535) >> 6`. Metal's blend (its source clamped to codes 0 and 1022, a destination code to 1022, in `half`, the result rounded to a code) is that model's but on 5 channels, each one code from it: draw 1032's red (source -2.982421875, destination code 749, alpha 0.7001953125: Metal 110, the model 109), draw 2508's green (-2.970703125, 996, 0.066162109375: 572, 571), draw 2747's blue (-0.77490234375, 708, 0.51708984375: 157, 156), draw 3579's blue (1.5703125, 132, 0.292236328125: 843, 844) and draw 7048's red (-1.6650390625, 448, 0.994140625: 1, 0).
|
||||
xr-blend-bgr10xr-premul NVIDIA divergent case/texels 5954 elements differ (U32), the largest difference 403046547 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-blend-bgr10xr-premul RX 7900 XTX divergent case/texels 5443 elements differ (U32), the largest difference 403046547 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-blend-bgr10xr-premul Iris(R) Xe divergent case/texels 5891 elements differ (U32), the largest difference 403046547 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-blend-bgra10xr-add llvmpipe divergent case/texels 32668 elements differ (U16), the largest difference 24701 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): an addition of one and one, whose source term Vulkan clamps to `[0, 1]` where the source is negative. By a model of the blend whose count of differing fields is lavapipe's to one (32,667), of the 32,768 fields 12,450 lie more than 32 codes from Metal's (up to 386), 1,290 two to 32, 3,089 one, and 15,838 hold Metal's code with the blend's fraction of a code in the six low bits Metal writes as zero. Metal's blend (its source clamped to codes 0 and 1022, a destination color code to 1022, in `half`, the result rounded to a code) is that model's on every channel of this recording.
|
||||
xr-blend-bgra10xr-add NVIDIA divergent case/texels 32668 elements differ (U16), the largest difference 24701 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-blend-bgra10xr-add RX 7900 XTX divergent case/texels 32668 elements differ (U16), the largest difference 24701 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-blend-bgra10xr-add Iris(R) Xe divergent case/texels 32666 elements differ (U16), the largest difference 24701 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-blend-bgra10xr-premul llvmpipe divergent case/texels 31526 elements differ (U16), the largest difference 24637 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over, whose source term Vulkan clamps to `[0, 1]` where the source is below `-0.7529` times its alpha. By a model of the blend whose count of differing fields is lavapipe's to 11 (31,515), of the 32,768 fields 4,724 lie more than 32 codes from Metal's (up to 385), 1,164 two to 32, 7,369 one, and 18,258 hold Metal's code with the blend's fraction of a code in the six low bits. Metal's blend (its source clamped to codes 0 and 1022, a destination color code to 1022, in `half`, the result rounded to a code) is that model's but on 4 channels, each one code from it: draw 4's red (source -0.77587890625, destination code 946, alpha 0.256591796875: Metal 418, the model 417), draw 1932's green (-2.32421875, 909, 0.2276611328125: 406, 405), draw 2802's green (-1.1484375, 691, 0.55859375: 136, 135) and draw 7665's green (-0.7734375, 898, 0.243896484375: 389, 388).
|
||||
xr-blend-bgra10xr-premul NVIDIA divergent case/texels 31526 elements differ (U16), the largest difference 24637 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-blend-bgra10xr-premul RX 7900 XTX divergent case/texels 31518 elements differ (U16), the largest difference 24637 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-blend-bgra10xr-premul Iris(R) Xe divergent case/texels 31524 elements differ (U16), the largest difference 24637 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-float-x1 llvmpipe divergent case/texels 3971 elements differ (U16), the largest difference 129 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of the case's premultiplied extended-range sources, inside the window, the result rounded to the 16-bit field at each draw where Metal blends `half` values and stores a code: Metal's code with the blend's fraction in the six low bits Metal writes as zero, or a code or two from it.
|
||||
xr-gamut-bgra10xr-over-float-x1 NVIDIA divergent case/texels 3974 elements differ (U16), the largest difference 129 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-float-x1 RX 7900 XTX divergent case/texels 3974 elements differ (U16), the largest difference 129 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-float-x1 Iris(R) Xe divergent case/texels 3972 elements differ (U16), the largest difference 129 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-float-x4 llvmpipe divergent case/texels 4019 elements differ (U16), the largest difference 84 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of the case's premultiplied extended-range sources, inside the window, the result rounded to the 16-bit field at each draw where Metal blends `half` values and stores a code: Metal's code with the blend's fraction in the six low bits Metal writes as zero, or a code or two from it; at four samples the resolve averages the fields (`PrecisionNote::DeviceRoundedResolve`).
|
||||
xr-gamut-bgra10xr-over-float-x4 NVIDIA divergent case/texels 4039 elements differ (U16), the largest difference 84 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-float-x4 RX 7900 XTX divergent case/texels 4032 elements differ (U16), the largest difference 84 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-float-x4 Iris(R) Xe divergent case/texels 4034 elements differ (U16), the largest difference 84 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-half-x1 llvmpipe divergent case/texels 3971 elements differ (U16), the largest difference 129 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of the case's premultiplied extended-range sources, inside the window, the result rounded to the 16-bit field at each draw where Metal blends `half` values and stores a code: Metal's code with the blend's fraction in the six low bits Metal writes as zero, or a code or two from it.
|
||||
xr-gamut-bgra10xr-over-half-x1 NVIDIA divergent case/texels 3974 elements differ (U16), the largest difference 129 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-half-x1 RX 7900 XTX divergent case/texels 3974 elements differ (U16), the largest difference 129 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-half-x1 Iris(R) Xe divergent case/texels 3972 elements differ (U16), the largest difference 129 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-half-x4 llvmpipe divergent case/texels 4019 elements differ (U16), the largest difference 84 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of the case's premultiplied extended-range sources, inside the window, the result rounded to the 16-bit field at each draw where Metal blends `half` values and stores a code: Metal's code with the blend's fraction in the six low bits Metal writes as zero, or a code or two from it; at four samples the resolve averages the fields (`PrecisionNote::DeviceRoundedResolve`).
|
||||
xr-gamut-bgra10xr-over-half-x4 NVIDIA divergent case/texels 4039 elements differ (U16), the largest difference 84 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-half-x4 RX 7900 XTX divergent case/texels 4032 elements differ (U16), the largest difference 84 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-half-x4 Iris(R) Xe divergent case/texels 4034 elements differ (U16), the largest difference 84 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-half-x4-stencil llvmpipe divergent case/texels 4019 elements differ (U16), the largest difference 84 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of the case's premultiplied extended-range sources, inside the window, the result rounded to the 16-bit field at each draw where Metal blends `half` values and stores a code: Metal's code with the blend's fraction in the six low bits Metal writes as zero, or a code or two from it; at four samples the resolve averages the fields (`PrecisionNote::DeviceRoundedResolve`).
|
||||
xr-gamut-bgra10xr-over-half-x4-stencil NVIDIA divergent case/texels 4039 elements differ (U16), the largest difference 84 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-half-x4-stencil RX 7900 XTX divergent case/texels 4032 elements differ (U16), the largest difference 84 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-over-half-x4-stencil Iris(R) Xe divergent case/texels 4034 elements differ (U16), the largest difference 84 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-straight-float-x1 llvmpipe divergent case/texels 3971 elements differ (U16), the largest difference 61 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md): straight alpha-over of the case's premultiplied extended-range sources, inside the window, the result rounded to the 16-bit field at each draw where Metal blends `half` values and stores a code: Metal's code with the blend's fraction in the six low bits Metal writes as zero, or a code or two from it.
|
||||
xr-gamut-bgra10xr-straight-float-x1 NVIDIA divergent case/texels 3973 elements differ (U16), the largest difference 61 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-straight-float-x1 RX 7900 XTX divergent case/texels 3974 elements differ (U16), the largest difference 61 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-straight-float-x1 Iris(R) Xe divergent case/texels 3972 elements differ (U16), the largest difference 61 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-straight-float-x4 llvmpipe divergent case/texels 4012 elements differ (U16), the largest difference 63 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md): straight alpha-over of the case's premultiplied extended-range sources, inside the window, the result rounded to the 16-bit field at each draw where Metal blends `half` values and stores a code: Metal's code with the blend's fraction in the six low bits Metal writes as zero, or a code or two from it; at four samples the resolve averages the fields (`PrecisionNote::DeviceRoundedResolve`).
|
||||
xr-gamut-bgra10xr-straight-float-x4 NVIDIA divergent case/texels 4023 elements differ (U16), the largest difference 63 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-straight-float-x4 RX 7900 XTX divergent case/texels 4019 elements differ (U16), the largest difference 63 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-straight-float-x4 Iris(R) Xe divergent case/texels 4024 elements differ (U16), the largest difference 63 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-straight-half-x1 llvmpipe divergent case/texels 3971 elements differ (U16), the largest difference 61 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md): straight alpha-over of the case's premultiplied extended-range sources, inside the window, the result rounded to the 16-bit field at each draw where Metal blends `half` values and stores a code: Metal's code with the blend's fraction in the six low bits Metal writes as zero, or a code or two from it.
|
||||
xr-gamut-bgra10xr-straight-half-x1 NVIDIA divergent case/texels 3973 elements differ (U16), the largest difference 61 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-straight-half-x1 RX 7900 XTX divergent case/texels 3974 elements differ (U16), the largest difference 61 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-straight-half-x1 Iris(R) Xe divergent case/texels 3972 elements differ (U16), the largest difference 61 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-straight-half-x4 llvmpipe divergent case/texels 4012 elements differ (U16), the largest difference 63 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md): straight alpha-over of the case's premultiplied extended-range sources, inside the window, the result rounded to the 16-bit field at each draw where Metal blends `half` values and stores a code: Metal's code with the blend's fraction in the six low bits Metal writes as zero, or a code or two from it; at four samples the resolve averages the fields (`PrecisionNote::DeviceRoundedResolve`).
|
||||
xr-gamut-bgra10xr-straight-half-x4 NVIDIA divergent case/texels 4023 elements differ (U16), the largest difference 63 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-straight-half-x4 RX 7900 XTX divergent case/texels 4019 elements differ (U16), the largest difference 63 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gamut-bgra10xr-straight-half-x4 Iris(R) Xe divergent case/texels 4024 elements differ (U16), the largest difference 63 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gradient-bgra10xr-blended-x1 llvmpipe divergent case/texels 3911 elements differ (U16), the largest difference 46 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md): premultiplied source-over of the gradient over the first draw, inside the window for the case's premultiplied sources, the result rounded to the 16-bit field at each draw where Metal blends `half` values and stores a code: Metal's code with the blend's fraction in the six low bits Metal writes as zero, or a code from it.
|
||||
xr-gradient-bgra10xr-blended-x1 NVIDIA divergent case/texels 3873 elements differ (U16), the largest difference 48 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gradient-bgra10xr-blended-x1 RX 7900 XTX divergent case/texels 3869 elements differ (U16), the largest difference 45 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gradient-bgra10xr-blended-x1 Iris(R) Xe divergent case/texels 3909 elements differ (U16), the largest difference 46 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gradient-bgra10xr-blended-x4 llvmpipe divergent case/texels 3907 elements differ (U16), the largest difference 60 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md): premultiplied source-over of the gradient over the first draw, inside the window for the case's premultiplied sources, the result rounded to the 16-bit field at each draw where Metal blends `half` values and stores a code: Metal's code with the blend's fraction in the six low bits Metal writes as zero, or a code from it; at four samples the resolve averages the fields (`PrecisionNote::DeviceRoundedResolve`).
|
||||
xr-gradient-bgra10xr-blended-x4 NVIDIA divergent case/texels 3871 elements differ (U16), the largest difference 59 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gradient-bgra10xr-blended-x4 RX 7900 XTX divergent case/texels 3870 elements differ (U16), the largest difference 59 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gradient-bgra10xr-blended-x4 Iris(R) Xe divergent case/texels 3909 elements differ (U16), the largest difference 60 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gradient-bgra10xr-unblended-x1 NVIDIA divergent case/texels 39 elements differ (U16), the largest difference 64 The device's own arithmetic of the gradient (the device notes the case announces, `PrecisionNote::DeviceArithmetic` among them): an output a step of `half` from Metal's at a rounding boundary stores a code one from Metal's.
|
||||
xr-gradient-bgra10xr-unblended-x4 llvmpipe divergent case/texels 146 elements differ (U16), the largest difference 48 The device's average of the samples (`PrecisionNote::DeviceRoundedResolve`, docs/API.md): the resolve averages the four samples' 16-bit fields, keeping the average's fraction of a code in the six low bits Metal writes as zero, within one code.
|
||||
xr-gradient-bgra10xr-unblended-x4 NVIDIA divergent case/texels 180 elements differ (U16), the largest difference 64 The device's average of the samples (`PrecisionNote::DeviceRoundedResolve`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gradient-bgra10xr-unblended-x4 RX 7900 XTX divergent case/texels 146 elements differ (U16), the largest difference 48 The device's average of the samples (`PrecisionNote::DeviceRoundedResolve`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-gradient-bgra10xr-unblended-x4 Iris(R) Xe divergent case/texels 146 elements differ (U16), the largest difference 48 The device's average of the samples (`PrecisionNote::DeviceRoundedResolve`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-masked-bgr10xr-red-over llvmpipe divergent case/texels 224 elements differ (U32), the largest difference 1048576 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of a premultiplied extended-range source, inside the window, whose result the device rounds to a code at each draw where Metal blends `half` values: a code one from Metal's (red's, bit 20).
|
||||
xr-masked-bgr10xr-red-over NVIDIA divergent case/texels 279 elements differ (U32), the largest difference 1048576 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-masked-bgr10xr-red-over RX 7900 XTX divergent case/texels 158 elements differ (U32), the largest difference 1048576 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-masked-bgr10xr-red-over Iris(R) Xe divergent case/texels 277 elements differ (U32), the largest difference 1048576 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-masked-bgr10xr-srgb-blue-green * refused case/pipeline/second Err(Error::Translation("the translator made no pipeline: unsupported: FramebufferFetch; needs NotImplemented at render pipeline, color attachment 0")) refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The state is an extended-range attachment under a partial write mask, or a mask under a blend, which the translator merges into the attachment's packed word in the fragment function, reading the attachment's texel (the translator's typed `Unsupported` `FramebufferFetch`, not implemented). That computed write is not built on any device (rt README, Known gaps of pipeline states); it is built on the runtime's own fetch form when a guest meets it.
|
||||
xr-masked-bgr10xr-srgb-red * refused case/pipeline/second Err(Error::Translation("the translator made no pipeline: unsupported: FramebufferFetch; needs NotImplemented at render pipeline, color attachment 0")) refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The state is an extended-range attachment under a partial write mask, or a mask under a blend, which the translator merges into the attachment's packed word in the fragment function, reading the attachment's texel (the translator's typed `Unsupported` `FramebufferFetch`, not implemented). That computed write is not built on any device (rt README, Known gaps of pipeline states); it is built on the runtime's own fetch form when a guest meets it.
|
||||
xr-masked-bgr10xr-srgb-red-over llvmpipe refused case/pipeline/second Err(Error::Translation("the translator made no pipeline: unsupported: Format; needs NotImplemented at metadata of entry rt6_fill_rgba16float, color attachment 0")) refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The translator refuses the pipeline: a blend into one of Apple's extended-range formats (Format) is not implemented on any device, as Metal's tile holds such an attachment as half through the render pass, which the codes the attachment stores do not keep.
|
||||
@@ -3287,6 +3356,10 @@ xr-masked-bgr10xr-srgb-red-over NVIDIA refused case/pipeline/second Err(Error::T
|
||||
xr-masked-bgr10xr-srgb-red-over Iris(R) Xe refused case/pipeline/second Err(Error::Translation("the translator made no pipeline: unsupported: Format; needs NotImplemented at metadata of entry rt6_fill_rgba16float, color attachment 0")) refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The translator refuses the pipeline: a blend into one of Apple's extended-range formats (Format) is not implemented on any device, as Metal's tile holds such an attachment as half through the render pass, which the codes the attachment stores do not keep.
|
||||
xr-masked-bgr10xr-srgb-red-over RX 550 refused case/pipeline/second Err(Error::Translation("the translator made no pipeline: unsupported: Format; needs NotImplemented at metadata of entry rt6_fill_rgba16float, color attachment 0")) refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The translator refuses the pipeline: a blend into one of Apple's extended-range formats (Format) is not implemented on any device, as Metal's tile holds such an attachment as half through the render pass, which the codes the attachment stores do not keep.
|
||||
xr-masked-bgr10xr-srgb-red-over Apple M3 Max refused case/pipeline/second Err(Error::Translation("the translator made no pipeline: unsupported: Format; needs NotImplemented at metadata of entry rt6_fill_rgba16float, color attachment 0")) refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The translator refuses the pipeline: a blend into one of Apple's extended-range formats (Format) is not implemented on any device, as Metal's tile holds such an attachment as half through the render pass, which the codes the attachment stores do not keep.
|
||||
xr-masked-bgra10xr-rgb-over llvmpipe divergent case/texels 2919 elements differ (U16), the largest difference 64 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of a premultiplied extended-range source, inside the window, whose result the device rounds to the 16-bit field where Metal blends `half` values and stores a code: a field one code from Metal's, or Metal's code with the blend's fraction in the six low bits Metal writes as zero.
|
||||
xr-masked-bgra10xr-rgb-over NVIDIA divergent case/texels 2924 elements differ (U16), the largest difference 64 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-masked-bgra10xr-rgb-over RX 7900 XTX divergent case/texels 2925 elements differ (U16), the largest difference 64 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-masked-bgra10xr-rgb-over Iris(R) Xe divergent case/texels 2927 elements differ (U16), the largest difference 64 The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row records; the counts are this device's.
|
||||
xr-masked-bgra10xr-srgb-rgb-over llvmpipe refused case/pipeline/second Err(Error::Translation("the translator made no pipeline: unsupported: Format; needs NotImplemented at metadata of entry rt6_fill_rgba16float, color attachment 0")) refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The translator refuses the pipeline: a blend into one of Apple's extended-range formats (Format) is not implemented on any device, as Metal's tile holds such an attachment as half through the render pass, which the codes the attachment stores do not keep.
|
||||
xr-masked-bgra10xr-srgb-rgb-over RX 7900 XTX refused case/pipeline/second Err(Error::Translation("the translator made no pipeline: unsupported: Format; needs NotImplemented at metadata of entry rt6_fill_rgba16float, color attachment 0")) refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The translator refuses the pipeline: a blend into one of Apple's extended-range formats (Format) is not implemented on any device, as Metal's tile holds such an attachment as half through the render pass, which the codes the attachment stores do not keep.
|
||||
xr-masked-bgra10xr-srgb-rgb-over 780M refused case/pipeline/second Err(Error::Translation("the translator made no pipeline: unsupported: Format; needs NotImplemented at metadata of entry rt6_fill_rgba16float, color attachment 0")) refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The translator refuses the pipeline: a blend into one of Apple's extended-range formats (Format) is not implemented on any device, as Metal's tile holds such an attachment as half through the render pass, which the codes the attachment stores do not keep.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -41,8 +41,9 @@ use crate::transcript::{Node, Observed, Sites, Value};
|
||||
use metal2vulkan::metal::BlendFactor;
|
||||
|
||||
use super::extended_range_targets::{
|
||||
fixture, fixture_inputs, half_bytes, not_read, program, read_layout, shader_refs, shape,
|
||||
texel_layout, Format, FILLS, FILL_HALF, FORMATS, HEIGHT, PLANES, READ_FLOAT, VERTEX, WIDTH,
|
||||
blend_notices, fixture, fixture_inputs, half_bytes, not_read, program, read_layout,
|
||||
shader_refs, shape, texel_layout, Format, FILLS, FILL_HALF, FORMATS, HEIGHT, PLANES,
|
||||
READ_FLOAT, VERTEX, WIDTH,
|
||||
};
|
||||
|
||||
/// The kernel that writes a `float4` into a two-plane extended-range texture, which is how the
|
||||
@@ -240,9 +241,12 @@ impl Case for ExtendedRangeBlend {
|
||||
// device that blends as Metal does shows as announced with nothing differing -- which is
|
||||
// what this M3 Max and lavapipe both show -- and one that does not shows the code. The
|
||||
// allowance fails the case if the notice stops firing, so it cannot outlive its reason.
|
||||
vec![crate::replay::notice_allowance(
|
||||
let mut allowances = vec![crate::replay::notice_allowance(
|
||||
Degradation::HalfOutputFastMathBlend.code(),
|
||||
)]
|
||||
)];
|
||||
// A `BGR10_XR` or `BGRA10_XR` target's blend of its codes (`blend_notices`).
|
||||
allowances.extend(blend_notices(self.format.format, Some(&self.blend)));
|
||||
allowances
|
||||
}
|
||||
|
||||
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! A wide-gamut client's render pipelines into `BGRA10_XR` and its `_sRGB` twin: what a draw
|
||||
//! stores, compared code for code.
|
||||
//!
|
||||
//! A `CAMetalLayer` that asks for wide gamut hands its client `BGRA10_XR` drawables, and a client
|
||||
//! such as Impeller then makes every pipeline over that format: four samples resolved into the
|
||||
//! A `CAMetalLayer` that asks for wide gamut hands its client `BGRA10_XR` drawables, and a 2D
|
||||
//! renderer then makes every pipeline over that format: four samples resolved into the
|
||||
//! drawable, a stencil (or depth and stencil) attachment, and blending on by default. Three
|
||||
//! families hold those shapes against Metal:
|
||||
//!
|
||||
@@ -50,8 +50,8 @@ use crate::values::StoreAction;
|
||||
use metal2vulkan::metal::{BlendFactor as F, BlendOperation as O, ColorWriteMask, PixelFormat};
|
||||
|
||||
use super::extended_range_targets::{
|
||||
fixture, fixture_inputs, half_bits, not_read, program, shader_refs, shape, texel_layout,
|
||||
Format, FILLS, FILL_FLOAT, FILL_HALF, FORMATS, VERTEX,
|
||||
blend_notices, fixture, fixture_inputs, half_bits, not_read, program, shader_refs, shape,
|
||||
texel_layout, Format, FILLS, FILL_FLOAT, FILL_HALF, FORMATS, VERTEX,
|
||||
};
|
||||
|
||||
/// The fixture's fill that writes depth alone (`[[depth(any)]]`), reading a `float` a sample.
|
||||
@@ -312,9 +312,12 @@ impl Case for GamutDraw {
|
||||
MetalSource::Run
|
||||
}
|
||||
|
||||
/// The family's notices, and nothing else: every texel compares exactly.
|
||||
/// The family's notices, and a `BGRA10_XR` target's blend of its codes (`blend_notices`):
|
||||
/// every texel compares exactly.
|
||||
fn allowances(&self) -> Vec<Allowance> {
|
||||
notices()
|
||||
let mut allowances = notices();
|
||||
allowances.extend(blend_notices(self.format.format, Some(&self.blend)));
|
||||
allowances
|
||||
}
|
||||
|
||||
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
|
||||
@@ -733,9 +736,12 @@ impl Case for MaskedDraw {
|
||||
MetalSource::Run
|
||||
}
|
||||
|
||||
/// The family's notices, and nothing else: every texel compares exactly.
|
||||
/// The family's notices, and the second draw's blend of a `BGR10_XR` or `BGRA10_XR` target's
|
||||
/// codes (`blend_notices`): every texel compares exactly.
|
||||
fn allowances(&self) -> Vec<Allowance> {
|
||||
notices()
|
||||
let mut allowances = notices();
|
||||
allowances.extend(blend_notices(self.format.format, self.blend.as_ref()));
|
||||
allowances
|
||||
}
|
||||
|
||||
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//! its gradients into: what the pass stores, compared code for code.
|
||||
//!
|
||||
//! A `CAMetalLayer` that asks for wide gamut hands its client `BGRA10_XR` drawables, and a 2D
|
||||
//! renderer such as Impeller fills its gradients there by draws that evaluate the gradient in the
|
||||
//! renderer fills its gradients there by draws that evaluate the gradient in the
|
||||
//! fragment function from a buffer of color stops, often at four samples resolved into the
|
||||
//! drawable. Each case here is one pass over a 32 x 32 target cleared to an opaque color, with two
|
||||
//! draws of the owned fixture `xr_gradients`:
|
||||
@@ -34,7 +34,8 @@ use crate::values::StoreAction;
|
||||
use metal2vulkan::metal::BlendFactor as F;
|
||||
|
||||
use super::extended_range_targets::{
|
||||
fixture, fixture_inputs, not_read, program, shader_refs, texel_layout, Format, FORMATS,
|
||||
blend_notices, fixture, fixture_inputs, not_read, program, shader_refs, texel_layout, Format,
|
||||
FORMATS,
|
||||
};
|
||||
|
||||
/// The fixture and its entry points.
|
||||
@@ -245,9 +246,13 @@ impl Case for GradientDraw {
|
||||
/// still compares exactly): `half-output-fast-math-blend` (the fixture is a fast-math module
|
||||
/// whose `half4` gradient a pipeline blends).
|
||||
fn allowances(&self) -> Vec<Allowance> {
|
||||
vec![crate::replay::notice_allowance(
|
||||
let mut allowances = vec![crate::replay::notice_allowance(
|
||||
Degradation::HalfOutputFastMathBlend.code(),
|
||||
)]
|
||||
)];
|
||||
// A `BGRA10_XR` target's blend of its codes (`blend_notices`).
|
||||
let blend = self.blended.then_some(&OVER);
|
||||
allowances.extend(blend_notices(self.format.format, blend));
|
||||
allowances
|
||||
}
|
||||
|
||||
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
|
||||
|
||||
@@ -39,8 +39,8 @@ use crate::degradation::Degradation;
|
||||
use crate::fixture::{Fixture, METAL_TEXT, RUNTIME_TEXT};
|
||||
use crate::recording::ShaderRef;
|
||||
use crate::render::{
|
||||
ColorState, Dispatch, PassColor, Plane, ReadAt, RenderPass, RenderPipelineSpec, RenderStep,
|
||||
RenderWork, TargetSpec,
|
||||
Blend, ColorState, Dispatch, PassColor, Plane, ReadAt, RenderPass, RenderPipelineSpec,
|
||||
RenderStep, RenderWork, TargetSpec,
|
||||
};
|
||||
use crate::transcript::{
|
||||
Aspect, ByteLayout, Digest, Element, Gaps, Node, Observed, Region, Sites, Value,
|
||||
@@ -269,6 +269,37 @@ pub(super) fn half_bytes() -> Vec<u8> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The notices a pipeline announces that blends `blend` into an attachment of `format`, where the
|
||||
/// attachment is `BGR10_XR` or `BGRA10_XR`, whose images blend their codes: `extended-range-blend`
|
||||
/// where the blend stores more than its source as it is, and `extended-range-blend-window` beside
|
||||
/// it where its corrected source term can leave the code range. This restates the translator's
|
||||
/// classification from the blend's factors (`PrecisionNote::ExtendedRangeBlendWindow`) for the
|
||||
/// blends this family draws: one and zero, added, stores its source; straight alpha-over holds the
|
||||
/// window; an addition of one and one and premultiplied source-over do not. A blend the family does
|
||||
/// not draw is a panic here, so a new one is classified before it is recorded. Every texel still
|
||||
/// compares exactly: a difference is the gap the notes describe.
|
||||
pub(super) fn blend_notices(format: PixelFormat, blend: Option<&Blend>) -> Vec<Allowance> {
|
||||
use metal2vulkan::metal::BlendFactor as F;
|
||||
let codes = matches!(format, PixelFormat::BGR10XR | PixelFormat::BGRA10XR);
|
||||
let Some(blend) = blend.filter(|_| codes) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let window = match (blend.source_rgb, blend.destination_rgb) {
|
||||
(F::One, F::Zero) => return Vec::new(),
|
||||
(F::SourceAlpha, F::OneMinusSourceAlpha) => false,
|
||||
(F::One, F::One) | (F::One, F::OneMinusSourceAlpha) => true,
|
||||
other => panic!("a blend this family does not draw: {other:?}"),
|
||||
};
|
||||
let mut notes = vec![Degradation::ExtendedRangeBlend];
|
||||
if window {
|
||||
notes.push(Degradation::ExtendedRangeBlendWindow);
|
||||
}
|
||||
notes
|
||||
.into_iter()
|
||||
.map(|kind| crate::replay::notice_allowance(kind.code()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The buffer the fills read their extent from: the row's width and the samples of a pixel, as the
|
||||
/// fixture's `Rt6Shape`.
|
||||
pub(super) fn shape(width: u32, samples: u32) -> Vec<u8> {
|
||||
|
||||
@@ -174,6 +174,10 @@ pub enum Degradation {
|
||||
DeviceHalfDenormals,
|
||||
/// [`PrecisionNote::RoundedSampleDepthCopy`].
|
||||
RoundedSampleDepthCopy,
|
||||
/// [`PrecisionNote::ExtendedRangeBlend`].
|
||||
ExtendedRangeBlend,
|
||||
/// [`PrecisionNote::ExtendedRangeBlendWindow`].
|
||||
ExtendedRangeBlendWindow,
|
||||
}
|
||||
|
||||
impl Degradation {
|
||||
@@ -260,6 +264,8 @@ impl Degradation {
|
||||
Degradation::StencilOutputOverlap,
|
||||
Degradation::DeviceHalfDenormals,
|
||||
Degradation::RoundedSampleDepthCopy,
|
||||
Degradation::ExtendedRangeBlend,
|
||||
Degradation::ExtendedRangeBlendWindow,
|
||||
];
|
||||
|
||||
/// The kind's code, `metal2vulkan-degrade-<kind>`: its precision note's, which the translator
|
||||
@@ -354,6 +360,8 @@ impl Degradation {
|
||||
Degradation::StencilOutputOverlap => PrecisionNote::StencilOutputOverlap,
|
||||
Degradation::DeviceHalfDenormals => PrecisionNote::DeviceHalfDenormals,
|
||||
Degradation::RoundedSampleDepthCopy => PrecisionNote::RoundedSampleDepthCopy,
|
||||
Degradation::ExtendedRangeBlend => PrecisionNote::ExtendedRangeBlend,
|
||||
Degradation::ExtendedRangeBlendWindow => PrecisionNote::ExtendedRangeBlendWindow,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,6 +451,8 @@ impl Degradation {
|
||||
PrecisionNote::StencilOutputOverlap => Degradation::StencilOutputOverlap,
|
||||
PrecisionNote::DeviceHalfDenormals => Degradation::DeviceHalfDenormals,
|
||||
PrecisionNote::RoundedSampleDepthCopy => Degradation::RoundedSampleDepthCopy,
|
||||
PrecisionNote::ExtendedRangeBlend => Degradation::ExtendedRangeBlend,
|
||||
PrecisionNote::ExtendedRangeBlendWindow => Degradation::ExtendedRangeBlendWindow,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1946,11 +1946,11 @@ once, as it is made, with no lock, and never rewritten for layouts.
|
||||
format), and the device's image format query takes the image. `BGR10_XR` and `BGRA10_XR` are
|
||||
made in the UNORM format of their bits (`A2R10G10B10_UNORM_PACK32`, `R16G16B16A16_UNORM`) for
|
||||
shader reads, whose codes every identity function's `float` sample, gather and read maps to
|
||||
Metal's values where the texture's word names them (docs/API.md). Their render targets are not
|
||||
built yet: a texture of either with `RenderTarget` usage, or on a device whose format query
|
||||
lacks that format for the usage, is `Gap::TextureFormat` (a render pipeline with an attachment
|
||||
of either is made, writing their raw texels, so no draw reaches it), and one made for shader
|
||||
writes has no storage element (below). Elsewhere it is `Gap::TextureFormat`: the shaders of the
|
||||
Metal's values where the texture's word names them, and for rendering: a fragment function
|
||||
writes the codes Metal stores, a pass clears to them and resolves them, and a blend whose source
|
||||
the function can correct is Vulkan's blend of the codes (docs/API.md). On a device whose format
|
||||
query lacks that format for the usage the texture is `Gap::TextureFormat`, and one made for
|
||||
shader writes has no storage element (below). Elsewhere it is `Gap::TextureFormat`: the shaders of the
|
||||
identity domains read a texture through its view alone, so another format whose texels the
|
||||
shader converts (the
|
||||
extended-range `_sRGB` and two-plane formats, the padded 10-bit ones, bfloat, YCbCr, decoded,
|
||||
@@ -2396,6 +2396,20 @@ once, as it is made, with no lock, and never rewritten for layouts.
|
||||
sample across the edge blends toward it. A sample of a `BGRA10_XR` texel whose fields'
|
||||
low 6 bits, which Metal neither reads nor writes, hold ones (bytes a CPU copy or a blit wrote)
|
||||
filters them in, within `63/64` of a code step (`1 / 510`) of Metal's.
|
||||
- A blended `BGR10_XR` or `BGRA10_XR` attachment blends its codes in the device's precision,
|
||||
rounding to the field at every draw, where Metal's tile blends `half` values through the pass:
|
||||
a channel stores Metal's code or one beside it a draw, and a `BGRA10_XR` field's six low bits
|
||||
hold the fraction (`PrecisionNote::ExtendedRangeBlend`, docs/API.md). Where the blend's corrected
|
||||
source term can leave the code range (an addition with a negative source; premultiplied
|
||||
source-over with a source below `-0.7529` times its alpha), Vulkan clamps it, and a channel
|
||||
stores a code up to 386 from Metal's (`PrecisionNote::ExtendedRangeBlendWindow`). Trigger: a
|
||||
kept stream or a walk in which a pipeline carrying `ExtendedRangeBlendWindow` blends an
|
||||
extended-range target and a picture differs from Metal's; the exact form, an ordered read of
|
||||
the attachment where the device has the pixel interlock, then goes back to the planner. A blend
|
||||
whose factors read the destination's colour, `BGRA10_XR`'s destination alpha, the blend colour
|
||||
or a second output of the function's own, or a reverse subtraction, is refused
|
||||
(`NotImplemented(Format)`); a blend whose destination factor reads the source's colour or alpha
|
||||
reads it from a second output, which needs dual-source blending at attachment 0.
|
||||
- A texture buffer with a swizzle other than each channel's own is `Gap::TextureBufferSwizzle`:
|
||||
Metal applies it to the reads, and neither a buffer view nor a `gpuResourceID` carries one.
|
||||
- A view of a texture buffer (`newTextureViewWithPixelFormat:` and its kin) is `Gap::TextureView`
|
||||
@@ -5767,9 +5781,9 @@ cache is answered compile-required on both.
|
||||
(`PushField::FetchedColor`), if a guest meets it:
|
||||
- a padded extended-range attachment's blend (`R10Unorm_X6`, `RG10Unorm_X12`, their `_sRGB`
|
||||
twins and `RGB10A2Unorm_sRGB`), refused naming `FramebufferFetch`, not implemented;
|
||||
- a write of some of the codes one word of an extended-range attachment holds (`BGR10_XR`, the
|
||||
two-plane forms' colour word and their `_sRGB` twins, under a mask of some of those codes),
|
||||
refused naming `FramebufferFetch`, not implemented;
|
||||
- a write of some of the codes one word of an extended-range attachment holds (the two-plane
|
||||
forms' colour word and the `_sRGB` twins', under a mask of some of those codes), refused
|
||||
naming `FramebufferFetch`, not implemented;
|
||||
- a blend no Vulkan state gives on an attachment whose image holds its channels rotated
|
||||
(`ARGB8Unorm` reading destination alpha), refused naming `FramebufferFetch`, not implemented;
|
||||
- a word attachment written under a mask of some of its channels, which takes its format's own
|
||||
@@ -5938,8 +5952,8 @@ cache is answered compile-required on both.
|
||||
`VUID-VkRenderingInfo-multisampledRenderToSingleSampled-06857`), a resolve the runtime does not
|
||||
build (`Resolve`: into a resolve texture of another pixel format, of more than one sample, or
|
||||
whose level is not the attachment level's size; out of an attachment of one sample; of an
|
||||
extended-range, bfloat or YCbCr format, whose image Vulkan's average would read in its own
|
||||
encoding; or of a depth and a stencil attachment into two views), a resolve into a texture made
|
||||
extended-range format but `BGR10_XR` and `BGRA10_XR`, or of a bfloat or YCbCr format, whose
|
||||
image Vulkan's average would read in its own encoding; or of a depth and a stencil attachment into two views), a resolve into a texture made
|
||||
without `RenderTarget` usage whose image has no attachment usage (`ResolveUsage`: Metal
|
||||
resolves into a texture of any usage; Vulkan only into a view with the attachment usage,
|
||||
`VUID-VkRenderingInfo-colorAttachmentCount-09476`, which a one-sample colour texture of an
|
||||
@@ -5961,7 +5975,7 @@ cache is answered compile-required on both.
|
||||
`resolveDepthPlane` (`TextureType`; a resolve texture of another type is resolved into as at
|
||||
plane 0, as Metal with its validation layer off does, probe `resolve_depth_planes.m`), the
|
||||
`CustomSampleDepthStore` store action, a clear of a format only a shader clears (extended
|
||||
range, bfloat, YCbCr), a `renderTargetArrayLength` past the device's `maxFramebufferLayers`
|
||||
range but `BGR10_XR` and `BGRA10_XR`, bfloat, YCbCr), a `renderTargetArrayLength` past the device's `maxFramebufferLayers`
|
||||
(`ArrayLength`: Vulkan renders at most that many layers,
|
||||
`VUID-VkRenderingInfo-layerCount-07817`, and requires 256 of it, where Metal's arrays hold 2048
|
||||
slices), and a pass with no attachment past the device's `maxFramebufferWidth` or
|
||||
|
||||
@@ -2186,8 +2186,9 @@ pub enum RenderPassKind {
|
||||
/// A resolve the runtime does not build: into a resolve texture of another pixel format than
|
||||
/// its attachment's (the format's sRGB twin among them), of more than one sample, or whose
|
||||
/// level is not the attachment level's width and height; of an attachment of one sample; of
|
||||
/// an extended-range, bfloat or YCbCr color attachment, whose image Vulkan's average would
|
||||
/// read in its own encoding; or of a depth and a stencil attachment into two views
|
||||
/// an extended-range color attachment but `BGR10_XR` and `BGRA10_XR` (whose codes average as
|
||||
/// their values do), or a bfloat or YCbCr one, whose image Vulkan's average would read in its
|
||||
/// own encoding; or of a depth and a stencil attachment into two views
|
||||
/// (VUID-VkRenderingInfo-pDepthAttachment-06086).
|
||||
Resolve,
|
||||
/// A resolve into a texture made without `RenderTarget` usage (and not of Metal's unknown
|
||||
@@ -2271,7 +2272,8 @@ pub enum RenderPassKind {
|
||||
/// `setColorStoreAction:atIndex:` family.
|
||||
StoreAction,
|
||||
/// A `Clear` load action on an attachment whose format the runtime clears only through a
|
||||
/// shader: an extended-range, bfloat or YCbCr format.
|
||||
/// shader: an extended-range format but `BGR10_XR` and `BGRA10_XR`, or a bfloat or YCbCr
|
||||
/// format.
|
||||
ClearFormat,
|
||||
/// A pass with no attachment wider or taller than the device's `maxFramebufferWidth` or
|
||||
/// `maxFramebufferHeight`: Vulkan's rendering covers at most that
|
||||
|
||||
@@ -205,8 +205,9 @@ impl ClearColor {
|
||||
///
|
||||
/// A store action that resolves resolves into `resolve_texture` by the device's average (the
|
||||
/// module's documentation). Refused, as [`Gap::RenderPass`] of [`RenderPassKind::Resolve`]: a
|
||||
/// resolve of an extended-range, bfloat or YCbCr format, which Vulkan's average would take in the
|
||||
/// image's own encoding. An integer format has no resolve, [`Refusal::ResolveFormat`].
|
||||
/// resolve of an extended-range format but `BGR10_XR` and `BGRA10_XR` (whose codes average as their
|
||||
/// values do), or of a bfloat or YCbCr format, which Vulkan's average would take in the image's
|
||||
/// own encoding. An integer format has no resolve, [`Refusal::ResolveFormat`].
|
||||
///
|
||||
/// Not built: `storeActionOptions`, whose one option needs more than one sample.
|
||||
///
|
||||
@@ -928,11 +929,14 @@ impl Pass {
|
||||
if !matches!(formats::sampled_type(pf), Some(SampledType::Float)) {
|
||||
return Err(Error::Refused(Refusal::ResolveFormat { pixel_format: pf }));
|
||||
}
|
||||
// `BGR10_XR`'s and `BGRA10_XR`'s codes average as their values do (the map
|
||||
// is affine), the device rounding the average.
|
||||
if !matches!(
|
||||
texture.emulation(),
|
||||
FormatEmulation::Direct
|
||||
| FormatEmulation::RotatedView
|
||||
| FormatEmulation::AlphaInRed
|
||||
| FormatEmulation::ExtendedRangeUnorm
|
||||
) {
|
||||
return Err(gap(RenderPassKind::Resolve));
|
||||
}
|
||||
@@ -1358,14 +1362,19 @@ fn target(
|
||||
/// The Vulkan clear value of `color` for a color attachment of `pf` held as `emulation`: an
|
||||
/// integer channel's value truncated toward zero and saturated to its range, NaN 0; any other
|
||||
/// channel's as a `float`, in the image's channels: a rotated format's, and `A8Unorm`'s held in
|
||||
/// `R8_UNORM`, rotated (`to_rotated_image`), so its alpha lands in red. `None` where only a shader
|
||||
/// clears the format: an extended-range, bfloat or YCbCr format.
|
||||
/// `R8_UNORM`, rotated (`to_rotated_image`), so its alpha lands in red; `BGR10_XR`'s and
|
||||
/// `BGRA10_XR`'s as the UNORM codes Metal's clear stores (`metal::format::extended_unorm_clear`).
|
||||
/// `None` where only a shader clears the format: another extended-range, bfloat or YCbCr format.
|
||||
pub(crate) fn clear_color(
|
||||
pf: PixelFormat,
|
||||
emulation: FormatEmulation,
|
||||
color: ClearColor,
|
||||
) -> Option<vk::ClearColorValue> {
|
||||
let rgba = [color.red, color.green, color.blue, color.alpha];
|
||||
if emulation == FormatEmulation::ExtendedRangeUnorm {
|
||||
return formats::extended_unorm_clear(pf, rgba)
|
||||
.map(|float32| vk::ClearColorValue { float32 });
|
||||
}
|
||||
if !matches!(
|
||||
emulation,
|
||||
FormatEmulation::Direct | FormatEmulation::RotatedView | FormatEmulation::AlphaInRed
|
||||
|
||||
@@ -729,7 +729,7 @@ mod on_device {
|
||||
c.load_action = LoadAction::Clear;
|
||||
c.clear_color = ClearColor::new(clear[0], clear[1], clear[2], clear[3]);
|
||||
let command_buffer = queue.command_buffer().expect("a command buffer");
|
||||
let mut encoder = (command_buffer.render_command_encoder(&p))
|
||||
let encoder = (command_buffer.render_command_encoder(&p))
|
||||
.unwrap_or_else(|e| panic!("{name}: {what}: {e}"));
|
||||
encoder.end_encoding();
|
||||
run(name, &command_buffer);
|
||||
|
||||
@@ -1 +1 @@
|
||||
f563674eec4934f5b264ab81db342410a1756b43627256e8dd75700654d66522
|
||||
986bcbfd0cb49e9112466f201ba5a88a91d62af519a913609afbd561954e94ef
|
||||
@@ -260,6 +260,10 @@ impl UlpTable {
|
||||
/// not exact by construction may store a channel one code apart from Metal's, which moves every
|
||||
/// later word that reads it: a difference is a mismatch for review, deferred until an exact path
|
||||
/// exists.
|
||||
/// - `ExtendedRangeBlend` and `ExtendedRangeBlendWindow`: [`Allowance::Recorded`]. A blended
|
||||
/// `BGR10_XR` or `BGRA10_XR` channel rounds to the field at each draw, a code from Metal's value
|
||||
/// where its source term lies in the code range and up to 384 codes outside it: a difference is
|
||||
/// a mismatch for review.
|
||||
/// - `HalfOutputPrecision`, `DevicePointSize`, `LoopedSampleOutputs`, `NativeLogicOperation` and
|
||||
/// `UnorderedFetchWithinDraw`: [`Allowance::Recorded`]. Each note's documentation keeps a
|
||||
/// difference a mismatch for review.
|
||||
@@ -336,6 +340,8 @@ pub fn allowance(note: PrecisionNote) -> Allowance {
|
||||
| N::CoverageReadsRoundedAlpha
|
||||
| N::DeviceAlphaCoverage
|
||||
| N::RotatedBlendRounding
|
||||
| N::ExtendedRangeBlend
|
||||
| N::ExtendedRangeBlendWindow
|
||||
| N::HalfOutputPrecision
|
||||
| N::DevicePointSize
|
||||
| N::LoopedSampleOutputs
|
||||
|
||||
@@ -68,6 +68,8 @@ fn every_precision_note_has_its_table_row() {
|
||||
(N::CoverageReadsRoundedAlpha, Allowance::Recorded),
|
||||
(N::DeviceAlphaCoverage, Allowance::Recorded),
|
||||
(N::RotatedBlendRounding, Allowance::Recorded),
|
||||
(N::ExtendedRangeBlend, Allowance::Recorded),
|
||||
(N::ExtendedRangeBlendWindow, Allowance::Recorded),
|
||||
(N::UnorderedFetchWithinDraw, Allowance::Recorded),
|
||||
(N::NativeLogicOperation, Allowance::Recorded),
|
||||
(N::CappedLodBias, Allowance::Unbounded),
|
||||
|
||||
@@ -311,6 +311,8 @@ pub fn reach(note: PrecisionNote) -> Reach {
|
||||
| N::DeviceColorConversion
|
||||
| N::BlendedWriteRounding
|
||||
| N::RotatedBlendRounding
|
||||
| N::ExtendedRangeBlend
|
||||
| N::ExtendedRangeBlendWindow
|
||||
| N::HalfOutputPrecision
|
||||
| N::HalfOutputFastMathBlend
|
||||
| N::DevicePointSize
|
||||
|
||||
+13
-2
@@ -51,7 +51,10 @@ use crate::pipeline::interface::{
|
||||
use crate::pipeline::layout::{
|
||||
BindingSource, DescriptorBinding, DescriptorSetLayout, PipelineLayout, PushConstantRange,
|
||||
};
|
||||
use crate::pipeline::lower_inputs::{ChannelWrite, ExtendedRangeColor, FactorLane, VertexFetch};
|
||||
use crate::pipeline::lower_inputs::{
|
||||
ChannelWrite, ExtendedRangeColor, ExtendedUnormBlend, ExtendedUnormColor, FactorLane,
|
||||
VertexFetch,
|
||||
};
|
||||
use crate::pipeline::stage_io::{
|
||||
CoverageLoop, CoverageLoopRefusal, DepthCompares, DepthMode, Interpolation as IoInterpolation,
|
||||
IoNumeric, IoRole, IoType, IoVariable, PulledInput, Sampling as IoSampling, StageBuiltin,
|
||||
@@ -1122,7 +1125,8 @@ codec_struct! {
|
||||
StageIo {
|
||||
inputs, outputs, builtins, pulled, stage_in, multisampled, varyings_at_pixel,
|
||||
position_depth, coverage_loop, color_writes, rounded_colors, primitive_inputs,
|
||||
early_fragment_tests, extended_range_colors, unattached_colors, sample_mask,
|
||||
early_fragment_tests, extended_range_colors, extended_unorm_colors, unattached_colors,
|
||||
sample_mask,
|
||||
rotated_colors, rotated_factors, rotated_blends, decoded_fetches,
|
||||
texture_write_rounding, uniform_outputs, uniform_inputs, instanced_attributes,
|
||||
half_blend_colors, half_fast_colors, float_blend_colors, zero_indices,
|
||||
@@ -1131,6 +1135,11 @@ codec_struct! {
|
||||
DepthCompares { samplers, clamped }
|
||||
WordField { shift, bits }
|
||||
ExtendedRangeColor { form, blended, nearest_even }
|
||||
ExtendedUnormColor { pixel_format, blend }
|
||||
ExtendedUnormBlend {
|
||||
source_rgb, destination_rgb, rgb_operation, source_alpha, destination_alpha,
|
||||
alpha_operation,
|
||||
}
|
||||
PulledInput { index, ty, fetch }
|
||||
StageInInput { index, ty, fetch }
|
||||
StageInFetch { format, buffer_index, offset, stride, step_function, step_rate, index }
|
||||
@@ -1412,6 +1421,8 @@ codec_enum! {
|
||||
StencilOutputOverlap,
|
||||
DeviceHalfDenormals,
|
||||
RoundedSampleDepthCopy,
|
||||
ExtendedRangeBlend,
|
||||
ExtendedRangeBlendWindow,
|
||||
}
|
||||
BindingSource {
|
||||
Buffer(f0), Synthetic { stage, binding }, IdentityArray,
|
||||
|
||||
Vendored
+3
-3
@@ -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 = 2377;
|
||||
pub const SEMANTICS_VERSION: u32 = 2378;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
@@ -70,7 +70,7 @@ pub const SEMANTICS_VERSION: u32 = 2377;
|
||||
/// re-typed in an encoded type, its `codec` body or its `envelope`. A variant removed while its tag
|
||||
/// stays unused needs no bump: an entry holding it fails to decode, which is a miss. The commit that
|
||||
/// bumps it says what changed; this comment keeps no history.
|
||||
pub const ARTIFACT_FORMAT_VERSION: u32 = 611;
|
||||
pub const ARTIFACT_FORMAT_VERSION: u32 = 612;
|
||||
|
||||
/// The version of what this crate gives a runtime for the runs of a compiled pipeline, beside the
|
||||
/// compile: the device a run opens and what it enables, the Vulkan and Metal vocabularies a runtime
|
||||
@@ -93,7 +93,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 611;
|
||||
/// 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 = 2576;
|
||||
pub const RUNTIME_VERSION: u32 = 2577;
|
||||
|
||||
/// Writes a digest as lowercase hex.
|
||||
pub(crate) fn write_hex(f: &mut fmt::Formatter<'_>, name: &str, hash: &Hash256) -> fmt::Result {
|
||||
|
||||
@@ -558,7 +558,7 @@ pub(crate) fn pack(
|
||||
}
|
||||
|
||||
/// A `vec4` constant of the four `f32` lanes `v`.
|
||||
fn per_lane_f(fb: &mut FunctionBuilder<'_>, v: [f32; 4]) -> BResult<Value> {
|
||||
pub(crate) fn per_lane_f(fb: &mut FunctionBuilder<'_>, v: [f32; 4]) -> BResult<Value> {
|
||||
let ft = crate::lower::arith::ops::ty(fb, floats())?;
|
||||
let e = fb.module().ty(Type::Float { width: 32 })?;
|
||||
let mut parts = Vec::with_capacity(4);
|
||||
|
||||
@@ -129,6 +129,14 @@ pub(super) fn select_param(cx: &mut SelectCx<'_>, b: &ParamBinding) -> Result<Co
|
||||
let refused = Unsupported::not_implemented(Feature::Format);
|
||||
return Err(refused.at_attachment(Attachment::Color(color)).into());
|
||||
}
|
||||
// A fetch of a `BGR10_XR` or `BGRA10_XR` attachment, its image the UNORM codes of its bits
|
||||
// (`LoweringInputs::extended_unorm_colors`), would read the codes' fractions where Metal's
|
||||
// tile holds the draws' `half`s: not implemented (link refuses a fetch of one the function
|
||||
// does not write, `link::graphics`).
|
||||
if cx.inputs.extended_unorm_colors.contains_key(&color) {
|
||||
let refused = Unsupported::not_implemented(Feature::Format);
|
||||
return Err(refused.at_attachment(Attachment::Color(color)).into());
|
||||
}
|
||||
// A fetch of a bfloat attachment is unmeasured (its draws are built; what a fetch reads of the
|
||||
// `half`s Metal's tile holds is not).
|
||||
if extended.is_some_and(|e| e.form.bfloat()) {
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
//! A fragment function's color outputs to `BGR10_XR` and `BGRA10_XR` attachments
|
||||
//! (`LoweringInputs::extended_unorm_colors`), whose images hold the UNORM codes of the formats'
|
||||
//! bits (`metal::format::FormatEmulation::ExtendedRangeUnorm`): `A2R10G10B10_UNORM_PACK32`, whose
|
||||
//! red, green and blue are Metal's, and `R16G16B16A16_UNORM`, whose red and blue are Metal's blue
|
||||
//! and red and whose fields hold each code in their top ten bits.
|
||||
//!
|
||||
//! The function writes each such output through a `float` variable of four components ([`plan`],
|
||||
//! [`encode`]). Unblended, each channel is the code Metal stores for the output (a `float` output
|
||||
//! rounded to `half` first, nearest even, then encoded as a kernel write encodes it,
|
||||
//! `arith::extended_range::write_codes`) as its field's value, over the field's maximum
|
||||
//! (`metal::format::extended_unorm_field`: a little above the code, which a device's conversion
|
||||
//! to the UNORM field stores as that code), `BGRA10_XR`'s low six bits zero; `BGR10_XR`'s alpha is
|
||||
//! 1, its two alpha bits ones, as Metal writes them.
|
||||
//!
|
||||
//! Where the pipeline blends there, the output is first clamped as Metal's blend clamps its source
|
||||
//! (measured, an Apple M3 Max under macOS 27.0.1): each color channel to the values of codes 0 and
|
||||
//! 1022, a NaN to code 0's, and alpha to `[0, 1]`, a NaN to 0. Under a blend that stores the
|
||||
//! source as it is (one and zero, added) the function writes the clamped output's codes as an
|
||||
//! unblended one does, which Metal's store is. Under another, it writes the value `X` that makes
|
||||
//! Vulkan's blend of the codes, with a source factor of one, Metal's blend of the values
|
||||
//! (`pipeline::extended_blend`): with `r = 510 / m` and `c = 384 / m`, `X = Fs v r + (1 - Fd) c`
|
||||
//! under an addition, `Fs v r + (1 + Fd) c` under a subtraction, and `v r + c` under a minimum or a
|
||||
//! maximum, `Fs` and `Fd` Metal's factors' values from the clamped output; `BGR10_XR`'s alpha is 1.
|
||||
|
||||
use crate::error::{Error, Feature, Unsupported};
|
||||
use crate::lower::arith::extended_range::{per_lane_f, write_codes};
|
||||
use crate::lower::arith::{FloatFmt, Form};
|
||||
use crate::lower::select::SelectCx;
|
||||
use crate::metal::format::{extended_unorm_field, ExtendedRange};
|
||||
use crate::metal::{BlendFactor, BlendOperation, PixelFormat};
|
||||
use crate::pipeline::extended_blend::{covered, notes};
|
||||
use crate::pipeline::lower_inputs::ExtendedUnormColor;
|
||||
use crate::pipeline::stage_io::{IoNumeric, IoType};
|
||||
use crate::pipeline::sym::Stage;
|
||||
use crate::spirv::builder::FunctionBuilder;
|
||||
use crate::spirv::error::BResult;
|
||||
use crate::spirv::ids::Value;
|
||||
use crate::spirv::ir::{BinOp, ConvOp, GlslOp, Type};
|
||||
|
||||
/// The form whose codes a `BGR10_XR` or `BGRA10_XR` output takes: the four linear codes, red
|
||||
/// first (`BGR10_XR`'s alpha code unused).
|
||||
const CODES: ExtendedRange = ExtendedRange::Bgra10 { srgb: false };
|
||||
|
||||
/// Plan output `f` (dual-source `index`) of a fragment function to color attachment `color`: where
|
||||
/// `LoweringInputs::extended_unorm_colors` lists the attachment and the output is a first output
|
||||
/// of `float` or `half`, record the attachment on the interface
|
||||
/// (`StageIo::extended_unorm_colors`) and the encode each return stores, and give the type the
|
||||
/// output variable is declared with, four `float`s. `None` where the output is stored as it is:
|
||||
/// another attachment's, a second output, or an integer output (link refuses its pipeline).
|
||||
pub(super) fn plan(
|
||||
cx: &mut SelectCx<'_>,
|
||||
color: u32,
|
||||
index: u32,
|
||||
f: Form,
|
||||
) -> Result<Option<IoType>, Error> {
|
||||
if cx.stage != Stage::Fragment || index != 0 {
|
||||
return Ok(None);
|
||||
}
|
||||
let Some(e) = cx.inputs.extended_unorm_colors.get(&color).copied() else {
|
||||
return Ok(None);
|
||||
};
|
||||
let Some(fmt) = f.float_fmt() else {
|
||||
return Ok(None);
|
||||
};
|
||||
if !matches!(fmt, FloatFmt::F32 | FloatFmt::Half) {
|
||||
return Err(Unsupported::not_implemented(Feature::Format).into());
|
||||
}
|
||||
if let Some(b) = e.blend {
|
||||
if !covered(e.pixel_format, &b) {
|
||||
return Err(Unsupported::not_implemented(Feature::Format).into());
|
||||
}
|
||||
cx.precision.extend(notes(e.pixel_format, &b));
|
||||
}
|
||||
let sp = &mut cx.families.stage_io;
|
||||
sp.interface.extended_unorm_colors.insert(color, e);
|
||||
sp.extended_unorm.insert(color, e);
|
||||
Ok(Some(IoType {
|
||||
numeric: IoNumeric::Float,
|
||||
components: 4,
|
||||
source_bits: 32,
|
||||
}))
|
||||
}
|
||||
|
||||
/// The four `float`s the function stores for output `x` (form `f`, `float` or `half` lanes) to
|
||||
/// the attachment `e`, in its image's channels (the module docs).
|
||||
pub(super) fn encode(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
e: ExtendedUnormColor,
|
||||
f: Form,
|
||||
x: Value,
|
||||
) -> BResult<Value> {
|
||||
let four = e.pixel_format == PixelFormat::BGRA10XR;
|
||||
let (scale, max, offset) = extended_unorm_field(four);
|
||||
// The code's maximum: 1023, or a 16-bit field's 65535 over the 64 its six low bits count.
|
||||
let m = f64::from(max) / f64::from(scale);
|
||||
let v = super::extended_color::held(fb, CODES, f, x)?;
|
||||
let v = match e.blend {
|
||||
Some(_) => clamped(fb, v)?,
|
||||
None => v,
|
||||
};
|
||||
let fractions = match e.blend {
|
||||
Some(b) if !b.stores_source(e.pixel_format) => {
|
||||
let color = corrected(
|
||||
fb,
|
||||
b.source_rgb,
|
||||
b.destination_rgb,
|
||||
b.rgb_operation,
|
||||
false,
|
||||
v,
|
||||
m,
|
||||
)?;
|
||||
let alpha = corrected(
|
||||
fb,
|
||||
b.source_alpha,
|
||||
b.destination_alpha,
|
||||
b.alpha_operation,
|
||||
true,
|
||||
v,
|
||||
m,
|
||||
)?;
|
||||
fb.vector_shuffle(color, alpha, &[0, 1, 2, 7])?
|
||||
}
|
||||
_ => {
|
||||
let codes = write_codes(fb, CODES, v)?;
|
||||
let ft = vec4(fb)?;
|
||||
let codes = fb.convert(ConvOp::ConvertUToF, codes, ft)?;
|
||||
let scale = per_lane_f(fb, [scale; 4])?;
|
||||
let offset = per_lane_f(fb, [offset; 4])?;
|
||||
let fields = fb.binary(BinOp::FMul, codes, scale)?;
|
||||
let fields = fb.binary(BinOp::FAdd, fields, offset)?;
|
||||
let k = per_lane_f(fb, [1.0 / max; 4])?;
|
||||
fb.binary(BinOp::FMul, fields, k)?
|
||||
}
|
||||
};
|
||||
if four {
|
||||
return fb.vector_shuffle(fractions, fractions, &[2, 1, 0, 3]);
|
||||
}
|
||||
let one = per_lane_f(fb, [1.0; 4])?;
|
||||
fb.vector_shuffle(fractions, one, &[0, 1, 2, 7])
|
||||
}
|
||||
|
||||
/// `v` (a `vec4` of `f32`, red first) clamped as Metal's blend clamps its source (the module
|
||||
/// docs): red, green and blue to the values of codes 0 and 1022, alpha to `[0, 1]`, a NaN to the
|
||||
/// lower bound.
|
||||
fn clamped(fb: &mut FunctionBuilder<'_>, v: Value) -> BResult<Value> {
|
||||
let low = (-384.0f64 / 510.0) as f32;
|
||||
let high = (638.0f64 / 510.0) as f32;
|
||||
let lo = per_lane_f(fb, [low, low, low, 0.0])?;
|
||||
let hi = per_lane_f(fb, [high, high, high, 1.0])?;
|
||||
fb.glsl(GlslOp::NClamp, &[v, lo, hi])
|
||||
}
|
||||
|
||||
/// The `vec4` of `f32` type.
|
||||
fn vec4(fb: &mut FunctionBuilder<'_>) -> BResult<crate::spirv::ids::TypeId> {
|
||||
let f32_ = fb.module().ty(Type::Float { width: 32 })?;
|
||||
fb.module().ty(Type::Vector { elem: f32_, len: 4 })
|
||||
}
|
||||
|
||||
/// `X` of the term of Metal's source factor `src`, destination factor `dst` and operation `op`
|
||||
/// for the `half` output `v` (a `vec4` of `f32`), each lane's, a term of the alpha where `alpha`
|
||||
/// (whose source color factors read the source's alpha), at codes of maximum `m` (the module
|
||||
/// docs).
|
||||
fn corrected(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
src: BlendFactor,
|
||||
dst: BlendFactor,
|
||||
op: BlendOperation,
|
||||
alpha: bool,
|
||||
v: Value,
|
||||
m: f64,
|
||||
) -> BResult<Value> {
|
||||
let r = per_lane_f(fb, [(510.0 / m) as f32; 4])?;
|
||||
let c = per_lane_f(fb, [(384.0 / m) as f32; 4])?;
|
||||
let one = per_lane_f(fb, [1.0; 4])?;
|
||||
let s = match op {
|
||||
BlendOperation::Min | BlendOperation::Max => v,
|
||||
_ => {
|
||||
let fs = factor(fb, src, alpha, v)?;
|
||||
fb.binary(BinOp::FMul, fs, v)?
|
||||
}
|
||||
};
|
||||
let scaled = fb.binary(BinOp::FMul, s, r)?;
|
||||
let weight = match op {
|
||||
BlendOperation::Min | BlendOperation::Max => one,
|
||||
BlendOperation::Subtract => {
|
||||
let fd = factor(fb, dst, alpha, v)?;
|
||||
fb.binary(BinOp::FAdd, one, fd)?
|
||||
}
|
||||
_ => {
|
||||
let fd = factor(fb, dst, alpha, v)?;
|
||||
fb.binary(BinOp::FSub, one, fd)?
|
||||
}
|
||||
};
|
||||
let offset = fb.binary(BinOp::FMul, weight, c)?;
|
||||
fb.binary(BinOp::FAdd, scaled, offset)
|
||||
}
|
||||
|
||||
/// The value of Metal's factor `f` in each lane for the `half` output `v`, of a term of the
|
||||
/// alpha where `alpha`: the factors `pipeline::extended_blend` covers, at a `BGR10_XR` attachment
|
||||
/// whose destination alpha Metal reads as 1. A factor it does not cover is refused before
|
||||
/// (`plan`), and reads 0 here.
|
||||
fn factor(fb: &mut FunctionBuilder<'_>, f: BlendFactor, alpha: bool, v: Value) -> BResult<Value> {
|
||||
use BlendFactor as F;
|
||||
let a = fb.vector_shuffle(v, v, &[3, 3, 3, 3])?;
|
||||
let source = match alpha {
|
||||
true => a,
|
||||
false => v,
|
||||
};
|
||||
let one = per_lane_f(fb, [1.0; 4])?;
|
||||
let zero = per_lane_f(fb, [0.0; 4])?;
|
||||
Ok(match f {
|
||||
F::One | F::DestinationAlpha => one,
|
||||
F::SourceColor => source,
|
||||
F::OneMinusSourceColor => fb.binary(BinOp::FSub, one, source)?,
|
||||
F::SourceAlpha => a,
|
||||
F::OneMinusSourceAlpha => fb.binary(BinOp::FSub, one, a)?,
|
||||
// Metal's saturated source alpha is `min(a, 1 - 1)` in a color term, 1 in an alpha one.
|
||||
F::SourceAlphaSaturated if alpha => one,
|
||||
F::SourceAlphaSaturated => fb.glsl(GlslOp::FMin, &[a, zero])?,
|
||||
_ => zero,
|
||||
})
|
||||
}
|
||||
@@ -153,6 +153,7 @@
|
||||
|
||||
pub(crate) mod color_write;
|
||||
pub(crate) mod extended_color;
|
||||
mod extended_unorm_color;
|
||||
pub mod fetch;
|
||||
mod plan;
|
||||
pub(crate) mod stage_in;
|
||||
@@ -422,6 +423,10 @@ pub struct StageIoPlan {
|
||||
/// as the raw texel Metal stores (`extended_color::encode`), with the form each is held in
|
||||
/// (and, a bfloat one's rounding).
|
||||
pub extended: BTreeMap<u32, crate::pipeline::lower_inputs::ExtendedRangeColor>,
|
||||
/// The `BGR10_XR` and `BGRA10_XR` attachments whose `float` or `half` output each return
|
||||
/// stores as the codes' fractions, or the corrected source of their blend
|
||||
/// (`extended_unorm_color::encode`).
|
||||
pub extended_unorm: BTreeMap<u32, crate::pipeline::lower_inputs::ExtendedUnormColor>,
|
||||
/// The word attachments whose `float` or `half` output each return stores as the word Metal
|
||||
/// stores (`word_color::encode`), with each word's layout.
|
||||
pub words_written: BTreeMap<u32, crate::metal::format::WordAttachment>,
|
||||
@@ -2264,10 +2269,17 @@ fn output_part(
|
||||
Some(color) => match (
|
||||
cx.plan.families.stage_io.words_written.get(&color).copied(),
|
||||
cx.plan.families.stage_io.extended.get(&color).copied(),
|
||||
cx.plan
|
||||
.families
|
||||
.stage_io
|
||||
.extended_unorm
|
||||
.get(&color)
|
||||
.copied(),
|
||||
) {
|
||||
(Some(w), _) => word_color::encode(fb, w, (o.link.form, part))?,
|
||||
(None, Some(e)) => extended_color::encode(fb, e, o.link.form, part)?,
|
||||
(None, None) => color_write::round(cx, fb, color, o.link.form, part)?,
|
||||
(Some(w), _, _) => word_color::encode(fb, w, (o.link.form, part))?,
|
||||
(None, Some(e), _) => extended_color::encode(fb, e, o.link.form, part)?,
|
||||
(None, None, Some(e)) => extended_unorm_color::encode(fb, e, o.link.form, part)?,
|
||||
(None, None, None) => color_write::round(cx, fb, color, o.link.form, part)?,
|
||||
},
|
||||
None => part,
|
||||
};
|
||||
|
||||
@@ -1081,7 +1081,9 @@ fn zeroed_output(
|
||||
}
|
||||
// What Metal stores into an extended-range attachment the pipeline lacks is unmeasured (its
|
||||
// tile holds decoded values, not the raw texel's bytes).
|
||||
if crate::metal::format::ExtendedRange::of_attachment(format).is_some() {
|
||||
if crate::metal::format::ExtendedRange::of(format).is_some()
|
||||
|| crate::metal::format::extended_unorm(format)
|
||||
{
|
||||
return Err(Unsupported::not_implemented(Feature::Format).into());
|
||||
}
|
||||
cx.facts.insert(RuntimeFact::ZeroedColor { color, format });
|
||||
@@ -2336,6 +2338,23 @@ pub fn entry(cx: &mut SelectCx<'_>) -> Result<(), Error> {
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
// A `BGR10_XR` or `BGRA10_XR` attachment whose blend reads a second output the codes need
|
||||
// (`LoweringInputs::rotated_factors`) takes it beside the first output.
|
||||
if let OutputRole::RenderTarget {
|
||||
attachment: AbiInt::Const(attachment),
|
||||
index: 0,
|
||||
..
|
||||
} = o.role
|
||||
{
|
||||
if cx.stage == Stage::Fragment
|
||||
&& cx.inputs.extended_unorm_colors.contains_key(&attachment)
|
||||
&& link.form.float_fmt().is_some()
|
||||
{
|
||||
if let Some(&lanes) = cx.inputs.rotated_factors.get(&attachment) {
|
||||
seconds.push((attachment, o.field, link.form, lanes));
|
||||
}
|
||||
}
|
||||
}
|
||||
let added = raw.and_then(|(_, _, field)| offset(field));
|
||||
cx.families.stage_io.outputs.push(PlannedOutput {
|
||||
field: o.field,
|
||||
@@ -2828,7 +2847,12 @@ fn output(cx: &mut SelectCx<'_>, o: &OutputBinding, ty: AirTypeId) -> Result<Lin
|
||||
// and a word attachment's word; the interface keeps the Metal output's type.
|
||||
let declared = match super::word_color::plan(cx, attachment, index, f)? {
|
||||
Some(word) => word,
|
||||
None => super::extended_color::plan(cx, attachment, index, f)?.unwrap_or(io),
|
||||
None => match super::extended_color::plan(cx, attachment, index, f)? {
|
||||
Some(raw) => raw,
|
||||
None => {
|
||||
super::extended_unorm_color::plan(cx, attachment, index, f)?.unwrap_or(io)
|
||||
}
|
||||
},
|
||||
};
|
||||
let key = VaryingKey::color(attachment, index);
|
||||
let deco = IoDecor {
|
||||
|
||||
@@ -143,9 +143,13 @@ pub enum FormatEmulation {
|
||||
/// over its maximum; under the identity domains a function's `float` sample, gather and read
|
||||
/// of a sampled image maps that to Metal's value where the texture's word names one of these
|
||||
/// formats (`lower::texture::extended_unorm`): exact for a texel read and gathered, the
|
||||
/// device's filter of the codes for a sample. Copies and blits move the bytes unchanged.
|
||||
/// device's filter of the codes for a sample. Copies and blits move the bytes unchanged. A
|
||||
/// color attachment of either is the image itself, which a fragment function writes as the
|
||||
/// codes Metal stores over their maximum, red and blue exchanged in `BGRA10_XR`'s
|
||||
/// (`LoweringInputs::extended_unorm_colors`), and a pass clears and resolves as codes.
|
||||
/// Admitted for sampling, whose filters and reductions the map keeps (it is increasing and
|
||||
/// affine); a device whose format query lacks the usage is refused the texture.
|
||||
/// affine), and for rendering and blending; a device whose format query lacks the usage is
|
||||
/// refused the texture.
|
||||
ExtendedRangeUnorm,
|
||||
/// Apple's two-plane YCbCr formats this crate holds ([`ycbcr`]), which Metal makes only over
|
||||
/// an IOSurface's two planes and reads as RGB: held as texels of exactly Metal's values,
|
||||
@@ -268,7 +272,11 @@ impl FormatEmulation {
|
||||
}
|
||||
FormatEmulation::ExtendedRangeUnorm => matches!(
|
||||
usage,
|
||||
U::SampledImage | U::SampledImageFilterLinear | U::SampledImageFilterMinmax
|
||||
U::SampledImage
|
||||
| U::SampledImageFilterLinear
|
||||
| U::SampledImageFilterMinmax
|
||||
| U::ColorAttachment
|
||||
| U::ColorAttachmentBlend
|
||||
),
|
||||
FormatEmulation::YCbCr => {
|
||||
matches!(usage, U::SampledImage | U::SampledImageFilterLinear)
|
||||
@@ -311,8 +319,7 @@ impl FormatEmulation {
|
||||
/// One of Apple's extended-range pixel formats, as a texture slot bound in it reads and writes
|
||||
/// its raw texels. A texture of `BGR10_XR` or `BGRA10_XR` is not held so but as the UNORM codes
|
||||
/// of its bits ([`FormatEmulation::ExtendedRangeUnorm`]); their forms here are a texture buffer's
|
||||
/// words (`texel_words`) and a color attachment's raw texels
|
||||
/// (`ExtendedRange::of_attachment`). Metal's answers, measured on an Apple M3 Max (macOS
|
||||
/// words (`texel_words`). Metal's answers, measured on an Apple M3 Max (macOS
|
||||
/// 26.7) and an Apple M4 (macOS 27.0.1) alike, every code and channel:
|
||||
///
|
||||
/// - **Codes.** A channel's 10-bit code `c` is the value `(c - 384) / 510` correctly rounded to
|
||||
@@ -426,20 +433,6 @@ impl ExtendedRange {
|
||||
}
|
||||
}
|
||||
|
||||
/// The form a render pipeline's color attachment of `pf` is held in: [`of`](Self::of)'s, and
|
||||
/// `BGR10_XR`'s and `BGRA10_XR`'s raw texels (`Bgr10` and `Bgra10`, not `srgb`, through their
|
||||
/// formats' second candidate). Such a pipeline is made, its function writing the raw texels;
|
||||
/// a texture of either format is held as the UNORM codes of its bits
|
||||
/// ([`FormatEmulation::ExtendedRangeUnorm`]), whose render targets are not built: one made
|
||||
/// with `RenderTarget` usage is refused, so no pass draws into one.
|
||||
pub(crate) fn of_attachment(pf: PixelFormat) -> Option<ExtendedRange> {
|
||||
match pf {
|
||||
PixelFormat::BGR10XR => Some(ExtendedRange::Bgr10 { srgb: false }),
|
||||
PixelFormat::BGRA10XR => Some(ExtendedRange::Bgra10 { srgb: false }),
|
||||
_ => ExtendedRange::of(pf),
|
||||
}
|
||||
}
|
||||
|
||||
/// The unsigned integer format of the texels' bytes, which holds them.
|
||||
pub fn raw_format(self) -> vk::Format {
|
||||
match self {
|
||||
@@ -1378,35 +1371,27 @@ fn make_repr(pf: PixelFormat) -> Repr {
|
||||
// (sRGB-encoded in the `_sRGB` twins), which no Vulkan format has. The `_sRGB` twins are
|
||||
// held raw in the integer format of their bytes.
|
||||
// `BGR10_XR` and `BGRA10_XR` in the UNORM format of their bits, whose fields a function
|
||||
// maps to Metal's values ([`FormatEmulation::ExtendedRangeUnorm`]); a color attachment of
|
||||
// either in its bytes' integer format, raw ([`ExtendedRange::of_attachment`]): their
|
||||
// render targets are not built.
|
||||
P::BGR10XR => color(vec![
|
||||
Candidate {
|
||||
format: F::A2R10G10B10_UNORM_PACK32,
|
||||
components: vk::ComponentMapping {
|
||||
r: S::IDENTITY,
|
||||
g: S::IDENTITY,
|
||||
b: S::IDENTITY,
|
||||
a: S::ONE,
|
||||
},
|
||||
emulation: E::ExtendedRangeUnorm,
|
||||
// maps to Metal's values ([`FormatEmulation::ExtendedRangeUnorm`]).
|
||||
P::BGR10XR => color(vec![Candidate {
|
||||
format: F::A2R10G10B10_UNORM_PACK32,
|
||||
components: vk::ComponentMapping {
|
||||
r: S::IDENTITY,
|
||||
g: S::IDENTITY,
|
||||
b: S::IDENTITY,
|
||||
a: S::ONE,
|
||||
},
|
||||
combined(F::R32_UINT, E::ExtendedRange),
|
||||
]),
|
||||
P::BGRA10XR => color(vec![
|
||||
Candidate {
|
||||
format: F::R16G16B16A16_UNORM,
|
||||
components: vk::ComponentMapping {
|
||||
r: S::B,
|
||||
g: S::G,
|
||||
b: S::R,
|
||||
a: S::A,
|
||||
},
|
||||
emulation: E::ExtendedRangeUnorm,
|
||||
emulation: E::ExtendedRangeUnorm,
|
||||
}]),
|
||||
P::BGRA10XR => color(vec![Candidate {
|
||||
format: F::R16G16B16A16_UNORM,
|
||||
components: vk::ComponentMapping {
|
||||
r: S::B,
|
||||
g: S::G,
|
||||
b: S::R,
|
||||
a: S::A,
|
||||
},
|
||||
combined(F::R16G16B16A16_UINT, E::ExtendedRange),
|
||||
]),
|
||||
emulation: E::ExtendedRangeUnorm,
|
||||
}]),
|
||||
P::BGR10XRSRGB => color(vec![combined(F::R32_UINT, E::ExtendedRange)]),
|
||||
P::BGRA10XRSRGB => color(vec![combined(F::R16G16B16A16_UINT, E::ExtendedRange)]),
|
||||
// Two planes, the extended-range color word and an alpha byte, held side by side in one
|
||||
@@ -1932,6 +1917,51 @@ pub(crate) fn extended_unorm(pf: PixelFormat) -> bool {
|
||||
)
|
||||
}
|
||||
|
||||
/// How a channel of the image of `BGRA10_XR` (`sixteen`, its 16-bit fields) or `BGR10_XR`
|
||||
/// ([`extended_unorm`]) takes a code `c` as a value the device converts: `(c * scale + offset) /
|
||||
/// max`, its field's value (the code, or the code times 64 in a 16-bit field) a little up, over
|
||||
/// the field's maximum (65535 or 1023). Vulkan's conversion of a value whose field is not an
|
||||
/// integer may store either neighbour (`convertFloatToUint`), so the offset is chosen to store the
|
||||
/// code under each conversion a device makes of it: a quarter in a 16-bit field, which rounding to
|
||||
/// nearest and toward zero store as the code; 1/2000 of a code in a 10-bit field, which those two,
|
||||
/// a conversion through 16 bits that drops the low six (lavapipe's, measured: a quarter stores the
|
||||
/// next code above code 771 there) and `floor(x * 1024)` all store as the code, from `f32`
|
||||
/// arithmetic.
|
||||
pub(crate) fn extended_unorm_field(sixteen: bool) -> (f32, f32, f32) {
|
||||
match sixteen {
|
||||
true => (64.0, 65535.0, 0.25),
|
||||
false => (1.0, 1023.0, 0.0005),
|
||||
}
|
||||
}
|
||||
|
||||
/// The clear value, in the image's channels, of a color attachment of `pf`, `BGR10_XR` or
|
||||
/// `BGRA10_XR` (held as the UNORM codes of its bits), that Metal clears to the color `rgba` (red
|
||||
/// first): each channel's value rounded to `float`, then to `half` (nearest even), stored as the
|
||||
/// code a write of it stores ([`ExtendedRange::write_code`]; a NaN is code 384), as its field's
|
||||
/// value (a little above the code, over the field's maximum); `BGRA10_XR`'s red and blue
|
||||
/// exchanged, `BGR10_XR`'s alpha 1. Metal clears a plain private target of 16 by 16 in a pass with
|
||||
/// no draw from the `float` instead, which stores another code at a tie between codes and at a NaN
|
||||
/// (an Apple M3 Max, macOS 27.0.1): this is the route its smaller, `ShaderWrite` and drawn targets
|
||||
/// take. `None` for another format.
|
||||
pub fn extended_unorm_clear(pf: PixelFormat, rgba: [f64; 4]) -> Option<[f32; 4]> {
|
||||
let sixteen = match pf {
|
||||
PixelFormat::BGRA10XR => true,
|
||||
PixelFormat::BGR10XR => false,
|
||||
_ => return None,
|
||||
};
|
||||
let (scale, max, offset) = extended_unorm_field(sixteen);
|
||||
let codes = ExtendedRange::Bgra10 { srgb: false };
|
||||
let fraction = |c: usize| {
|
||||
let half = crate::float16::f16_bits_to_f32(crate::float16::f32_to_f16_bits(rgba[c] as f32));
|
||||
let code = codes.write_code(half, c == 3).unwrap_or(384);
|
||||
(code as f32 * scale + offset) * (1.0 / max)
|
||||
};
|
||||
Some(match sixteen {
|
||||
true => [fraction(2), fraction(1), fraction(0), fraction(3)],
|
||||
false => [fraction(0), fraction(1), fraction(2), 1.0],
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether Metal completes a function's writes to a texture of `pf` and stores nothing: the
|
||||
/// 4:2:2 formats, the YCbCr formats ([`ycbcr`]) whose chroma is subsampled, 4:2:0 and 4:2:2 (a
|
||||
/// kernel's write leaves both planes' bytes as they were, and Metal's validation stops the
|
||||
@@ -2227,7 +2257,7 @@ pub(crate) fn write_conversion(pf: PixelFormat) -> Option<WriteConversion> {
|
||||
let h = f(10, true);
|
||||
let hu = |bits| Some(C::HalfUnorm { bits });
|
||||
let srgb = Some(C::Srgb);
|
||||
if ExtendedRange::of_attachment(pf).is_some() {
|
||||
if ExtendedRange::of(pf).is_some() || extended_unorm(pf) {
|
||||
return Some(WriteConversion::Encoded);
|
||||
}
|
||||
// A two-plane YCbCr attachment a pass renders holds the function's floats
|
||||
|
||||
@@ -146,8 +146,8 @@ fn direct_formats_round_trip() {
|
||||
FormatEmulation::Direct => back.entry(candidates[0].format).or_default().push(pf),
|
||||
FormatEmulation::ExtendedRange => {}
|
||||
// `BGR10_XR`'s and `BGRA10_XR`'s bits in the UNORM format of the same bits, which
|
||||
// `BGR10A2Unorm` and `RGBA16Unorm` hold directly; no raw-held form names them but an
|
||||
// attachment's (their second candidate, raw).
|
||||
// `BGR10A2Unorm` and `RGBA16Unorm` hold directly; no raw-held form names them, and
|
||||
// the image is the only candidate, for its attachments too.
|
||||
FormatEmulation::ExtendedRangeUnorm => {
|
||||
assert!(
|
||||
matches!(pf, PixelFormat::BGR10XR | PixelFormat::BGRA10XR),
|
||||
@@ -158,10 +158,10 @@ fn direct_formats_round_trip() {
|
||||
"{pf:?}"
|
||||
);
|
||||
assert!(!crate::metal::texel_format::crosses_classes(pf), "{pf:?}");
|
||||
assert!(ExtendedRange::of_attachment(pf).is_some(), "{pf:?}");
|
||||
assert_eq!(candidates.len(), 1, "{pf:?}");
|
||||
assert_eq!(
|
||||
candidates.get(1).map(|c| c.emulation),
|
||||
Some(FormatEmulation::ExtendedRange),
|
||||
write_conversion(pf),
|
||||
Some(WriteConversion::Encoded),
|
||||
"{pf:?}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -234,6 +234,14 @@ mod serde_round_trips {
|
||||
true,
|
||||
),
|
||||
)]),
|
||||
extended_unorm_colors: BTreeMap::from([(
|
||||
6,
|
||||
ExtendedUnormColor::new(metal::PixelFormat::BGRA10XR).with_blend(
|
||||
ExtendedUnormBlend::of(&crate::pipeline::ColorAttachmentDescriptor::new(
|
||||
metal::PixelFormat::BGRA10XR,
|
||||
)),
|
||||
),
|
||||
)]),
|
||||
word_colors: BTreeMap::from([(
|
||||
5,
|
||||
crate::metal::format::WordAttachment::layout(metal::PixelFormat::ABGR4Unorm)
|
||||
|
||||
@@ -1816,9 +1816,14 @@ pub enum PrecisionNote {
|
||||
/// device's own stands; a float channel's average may differ in its last bits, and a NaN or
|
||||
/// infinite sample's average is the device's. Measured against Metal's rules at 2 and 4
|
||||
/// samples: on RADV, ANV, NVIDIA and lavapipe every unorm, snorm and packed 16-bit unorm
|
||||
/// channel within one code of Metal's, an sRGB channel within two. Static per operation: no
|
||||
/// pipeline stage records it; `metal2vulkan-runtime`'s render pass carries it for every color
|
||||
/// attachment it resolves (`RenderPassDescriptor::precision_note`), on every device.
|
||||
/// channel within one code of Metal's, an sRGB channel within two. A `BGR10_XR` or `BGRA10_XR`
|
||||
/// attachment, held as the UNORM codes of its bits, averages its codes, as the values average
|
||||
/// (the map is affine): a `BGRA10_XR` field keeps the average's fraction of a code in its six
|
||||
/// low bits, which Metal writes as zero (lavapipe: 146 of the 4,096 fields of
|
||||
/// `xr-gradient-bgra10xr-unblended-x4`, within 48 of a code's 64 steps). Static per
|
||||
/// operation: no pipeline stage records it; `metal2vulkan-runtime`'s render pass carries it
|
||||
/// for every color attachment it resolves (`RenderPassDescriptor::precision_note`), on every
|
||||
/// device.
|
||||
///
|
||||
/// Validation derives no tolerance from it: a difference stays a mismatch, which the note
|
||||
/// explains.
|
||||
@@ -2013,6 +2018,39 @@ pub enum PrecisionNote {
|
||||
/// Validation derives no tolerance from it: a difference stays a mismatch, which the note
|
||||
/// explains.
|
||||
RoundedSampleDepthCopy,
|
||||
/// A fragment function writes a `BGR10_XR` or `BGRA10_XR` color attachment the pipeline blends
|
||||
/// by more than storing its source as it is (`LoweringInputs::extended_unorm_colors`): the
|
||||
/// device blends the image's UNORM codes, with a source term the function corrects so the
|
||||
/// blend is Metal's blend of the values (`pipeline::extended_blend`), in its own precision,
|
||||
/// and rounds the result to the field at every draw, where Metal blends `half` values and its
|
||||
/// tile keeps them through the pass. Where the source term lies in the code range, a channel
|
||||
/// stores Metal's code or one beside it a draw: of 40,000 random single draws a blend, on
|
||||
/// `BGR10_XR`, straight alpha-over stored a code one from Metal's on 2,169 channels,
|
||||
/// destination-in on 1,296 and destination-out on 1,595; a `BGRA10_XR` field's six low bits,
|
||||
/// which Metal writes as zero and reads past, hold the blend's fraction of a code on about 98%
|
||||
/// of its channels. A destination code Metal's blend reads clamped (a color code 1023, an
|
||||
/// alpha code outside 384 to 894) is read as it is. Where the source term can leave the code
|
||||
/// range, the pipeline also carries `ExtendedRangeBlendWindow`.
|
||||
///
|
||||
/// Validation derives no tolerance from it: a difference stays a mismatch, which the note
|
||||
/// explains.
|
||||
ExtendedRangeBlend,
|
||||
/// A `BGR10_XR` or `BGRA10_XR` color attachment's blend (`ExtendedRangeBlend`) whose corrected
|
||||
/// source term can leave `[0, 1]` for a source in Metal's range, or whose destination factor
|
||||
/// Vulkan reads from a second output Metal's value of which can leave `[0, 1]`
|
||||
/// (`pipeline::extended_blend::window_holds`, from the blend's factors and operations): Vulkan
|
||||
/// clamps both to `[0, 1]`, so a source outside the window stores a code up to 386 from
|
||||
/// Metal's. An addition of one and one with a negative source, and premultiplied source-over
|
||||
/// with a source below `-0.7529` times its alpha, are outside it: on the conformance suite's
|
||||
/// random sources, 12,450 of 32,768 `BGRA10_XR` channels and 8,421 of 24,576 `BGR10_XR` ones
|
||||
/// under the addition, and 4,724 of 32,768 and 4,233 of 24,576 under premultiplied
|
||||
/// source-over, lie more than 32 codes from Metal's (a model of the blend whose count of
|
||||
/// differing elements is lavapipe's replay's to within 11 of 32,768).
|
||||
/// Premultiplied source-over of a premultiplied extended-range source stays inside it.
|
||||
///
|
||||
/// Validation derives no tolerance from it: a difference stays a mismatch, which the note
|
||||
/// explains.
|
||||
ExtendedRangeBlendWindow,
|
||||
}
|
||||
|
||||
impl PrecisionNote {
|
||||
@@ -2151,6 +2189,10 @@ impl PrecisionNote {
|
||||
PrecisionNote::RoundedSampleDepthCopy => {
|
||||
"metal2vulkan-degrade-rounded-sample-depth-copy"
|
||||
}
|
||||
PrecisionNote::ExtendedRangeBlend => "metal2vulkan-degrade-extended-range-blend",
|
||||
PrecisionNote::ExtendedRangeBlendWindow => {
|
||||
"metal2vulkan-degrade-extended-range-blend-window"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,9 @@ use crate::metal::TextureWriteRoundingMode;
|
||||
use crate::pipeline::artifact::PrecisionNote;
|
||||
use crate::pipeline::descriptor::ColorAttachmentDescriptor;
|
||||
use crate::pipeline::graphics::ColorAttachmentState;
|
||||
use crate::pipeline::lower_inputs::{ChannelWrite, ExtendedRangeColor, FactorLane};
|
||||
use crate::pipeline::lower_inputs::{
|
||||
ChannelWrite, ExtendedRangeColor, ExtendedUnormBlend, ExtendedUnormColor, FactorLane,
|
||||
};
|
||||
use crate::pipeline::rotated_blend::{inexact, rotated_blend, RotatedBlend};
|
||||
use crate::pipeline::stage_io::IoRole;
|
||||
|
||||
@@ -267,7 +269,7 @@ fn nearest_even(
|
||||
/// `colors` (alpha-to-coverage on where `alpha_to_coverage`, rounding by `rounding`) on `p`: the
|
||||
/// color writes it compiled under are the pipeline's for the attachments it writes
|
||||
/// ([`writes_hold`]), and so are its extended-range attachments' writes
|
||||
/// ([`wanted_extended_range`]), and every color it stores nowhere (`StageIo::unattached_colors`)
|
||||
/// ([`wanted_extended_range`], [`wanted_extended_unorm`]), and every color it stores nowhere (`StageIo::unattached_colors`)
|
||||
/// has no attachment and is not color 0 under alpha to coverage, and the second outputs it writes
|
||||
/// for rotated attachments are the pipeline's ([`wanted_rotated_factors`]), and so are those of
|
||||
/// their blends not exact by construction ([`wanted_rotated_blends`]), and the attachments holding
|
||||
@@ -290,6 +292,7 @@ pub(crate) fn check(
|
||||
});
|
||||
if writes_hold(fragment, colors, (alpha_to_coverage, rounding), p)
|
||||
&& wanted_extended_range(fragment, colors, rounding) == io.extended_range_colors
|
||||
&& wanted_extended_unorm(fragment, colors) == io.extended_unorm_colors
|
||||
&& wanted_word_colors(fragment, colors, alpha_to_coverage, p) == io.word_colors
|
||||
&& wanted_rotated(fragment, colors, p) == io.rotated_colors
|
||||
&& wanted_alpha_in_red(fragment, colors, p) == io.alpha_in_red_colors
|
||||
@@ -318,13 +321,57 @@ pub(crate) fn extended_range_colors(
|
||||
.enumerate()
|
||||
.filter_map(|(i, c)| {
|
||||
let c = c.as_ref()?;
|
||||
let form = metal::format::ExtendedRange::of_attachment(c.pixel_format)?;
|
||||
let form = metal::format::ExtendedRange::of(c.pixel_format)?;
|
||||
let write = ExtendedRangeColor::new(form, c.blending_enabled).with_rounding(rounding);
|
||||
Some((i as u32, write))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Whether Vulkan blends attachment `c`, of `BGR10_XR` or `BGRA10_XR`: the pipeline blends there
|
||||
/// by more than storing its source as it is (`ExtendedUnormBlend::stores_source`), placeholders
|
||||
/// resolved.
|
||||
pub(crate) fn extended_unorm_blended(c: &ColorAttachmentDescriptor) -> bool {
|
||||
c.blending_enabled && !ExtendedUnormBlend::of(c).stores_source(c.pixel_format)
|
||||
}
|
||||
|
||||
/// The color attachments of `BGR10_XR` and `BGRA10_XR` of a render pipeline whose color
|
||||
/// attachments are `colors`, by color index (`LoweringInputs::extended_unorm_colors`): each with
|
||||
/// Metal's blend where the pipeline blends there.
|
||||
pub(crate) fn extended_unorm_colors(
|
||||
colors: &[Option<ColorAttachmentDescriptor>],
|
||||
) -> BTreeMap<u32, ExtendedUnormColor> {
|
||||
colors
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, c)| {
|
||||
let c = c.as_ref()?;
|
||||
if !metal::format::extended_unorm(c.pixel_format) {
|
||||
return None;
|
||||
}
|
||||
let write = ExtendedUnormColor::new(c.pixel_format);
|
||||
let write = match c.blending_enabled {
|
||||
true => write.with_blend(ExtendedUnormBlend::of(c)),
|
||||
false => write,
|
||||
};
|
||||
Some((i as u32, write))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The `BGR10_XR` and `BGRA10_XR` writes the fragment stage `fragment` compiles under in a render
|
||||
/// pipeline whose color attachments are `colors`: [`extended_unorm_colors`]'s, for the
|
||||
/// attachments it writes through output variables of dual-source index 0.
|
||||
pub(crate) fn wanted_extended_unorm(
|
||||
fragment: &FunctionArtifact,
|
||||
colors: &[Option<ColorAttachmentDescriptor>],
|
||||
) -> BTreeMap<u32, ExtendedUnormColor> {
|
||||
let written: BTreeSet<u32> = written(fragment).collect();
|
||||
let mut out = extended_unorm_colors(colors);
|
||||
out.retain(|a, _| written.contains(a));
|
||||
out
|
||||
}
|
||||
|
||||
/// Whether color attachment `c`, of an extended-range form that holds its three color codes in
|
||||
/// one raw component (`BGR10_XR`, the two-plane forms' color word, and their `_sRGB` twins), is
|
||||
/// written unblended under a mask of some of those codes ([`merges_extended`]): no mask of the
|
||||
@@ -343,10 +390,7 @@ pub(crate) fn merges_extended(
|
||||
) -> bool {
|
||||
use metal::format::ExtendedRange as X;
|
||||
use metal::ColorWriteMask as M;
|
||||
let word = matches!(
|
||||
X::of_attachment(pf),
|
||||
Some(X::Bgr10 { .. } | X::Planes { .. })
|
||||
);
|
||||
let word = matches!(X::of(pf), Some(X::Bgr10 { .. } | X::Planes { .. }));
|
||||
let rgb = M::RED.union(M::GREEN).union(M::BLUE);
|
||||
let color = mask & rgb;
|
||||
word && !blended && !color.is_empty() && color != rgb
|
||||
@@ -550,9 +594,10 @@ pub(crate) fn rotated_blend_in_shader(c: &ColorAttachmentDescriptor, p: &DeviceP
|
||||
!second
|
||||
}
|
||||
|
||||
/// The second outputs of the attachments of `colors` held with their channels rotated, on `p`
|
||||
/// (`LoweringInputs::rotated_factors`): every such attachment whose blend Vulkan's factors read
|
||||
/// from a second output the rotation needs (`rotated_blend::RotatedBlend::Synthesized`). An
|
||||
/// The second outputs of the attachments of `colors` held with their channels rotated, or of
|
||||
/// `BGR10_XR` or `BGRA10_XR`, on `p` (`LoweringInputs::rotated_factors`): every such attachment
|
||||
/// whose blend Vulkan's factors read from a second output the rotation or the codes need
|
||||
/// (`rotated_blend::RotatedBlend::Synthesized`, `extended_blend::ExtendedBlend::lanes`). An
|
||||
/// attachment whose blend no Vulkan state gives has none; link refuses its pipeline.
|
||||
pub(crate) fn rotated_factors(
|
||||
colors: &[Option<ColorAttachmentDescriptor>],
|
||||
@@ -563,6 +608,13 @@ pub(crate) fn rotated_factors(
|
||||
.enumerate()
|
||||
.filter_map(|(i, c)| {
|
||||
let c = c.as_ref()?;
|
||||
if metal::format::extended_unorm(c.pixel_format) {
|
||||
if !extended_unorm_blended(c) {
|
||||
return None;
|
||||
}
|
||||
let blend = crate::pipeline::extended_blend::extended_blend(c, p).ok()??;
|
||||
return blend.lanes.map(|lanes| (i as u32, lanes));
|
||||
}
|
||||
if !metal::format::rotated_channels(c.pixel_format) {
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -2421,6 +2421,8 @@ pub(crate) fn fragment_inputs(
|
||||
d.color_attachments,
|
||||
d.texture_write_rounding_mode,
|
||||
);
|
||||
out.extended_unorm_colors =
|
||||
crate::pipeline::color_writes::extended_unorm_colors(d.color_attachments);
|
||||
out.word_colors =
|
||||
crate::pipeline::color_writes::word_colors(d.color_attachments, d.alpha_to_coverage, p);
|
||||
out.rotated_colors = crate::pipeline::color_writes::rotated_colors(d.color_attachments, p);
|
||||
|
||||
@@ -451,6 +451,12 @@ pub fn function_key(
|
||||
h.bytes(b"arrayed-fetches")
|
||||
.bytes(format!("{:?}", inputs.arrayed_fetches).as_bytes());
|
||||
}
|
||||
// Appended only when set, as `signed_color_attachments`: a fragment function that writes no
|
||||
// `BGR10_XR` or `BGRA10_XR` attachment keeps its key.
|
||||
if !inputs.extended_unorm_colors.is_empty() {
|
||||
h.bytes(b"extended-unorm-colors")
|
||||
.bytes(format!("{:?}", inputs.extended_unorm_colors).as_bytes());
|
||||
}
|
||||
// Appended only when present, so a stage that links nothing keeps its key: the tag's length
|
||||
// prefix keeps the encoding unambiguous.
|
||||
if !linked.is_empty() {
|
||||
|
||||
@@ -586,6 +586,21 @@ fn function_keys_cover_their_inputs() {
|
||||
assert_ne!(writes(&[(0, unorm)]), writes(&[(0, srgb)]));
|
||||
assert_ne!(writes(&[(0, unorm)]), writes(&[(0, device)]));
|
||||
assert_ne!(layer, writes(&[(0, device)]));
|
||||
// So is how it writes a `BGR10_XR` or `BGRA10_XR` attachment, by attachment and format.
|
||||
use crate::pipeline::lower_inputs::ExtendedUnormColor;
|
||||
let unorm_colors = |entries: &[(u32, metal::PixelFormat)]| {
|
||||
let mut i = LoweringInputs::new();
|
||||
i.extended_unorm_colors = entries
|
||||
.iter()
|
||||
.map(|&(color, pf)| (color, ExtendedUnormColor::new(pf)))
|
||||
.collect();
|
||||
a.function_compile_key(&fd, &i)
|
||||
};
|
||||
let bgr10 = unorm_colors(&[(0, metal::PixelFormat::BGR10XR)]);
|
||||
assert_ne!(with_true, bgr10);
|
||||
assert_ne!(writes(&[(0, unorm)]), bgr10);
|
||||
assert_ne!(bgr10, unorm_colors(&[(1, metal::PixelFormat::BGR10XR)]));
|
||||
assert_ne!(bgr10, unorm_colors(&[(0, metal::PixelFormat::BGRA10XR)]));
|
||||
}
|
||||
|
||||
/// A key without the emulated-simdgroups input and the later ones hashes the inputs as it did
|
||||
@@ -672,7 +687,8 @@ fn the_inputs_encoding_is_the_earlier_derived_debug() {
|
||||
.replace(", depth_range_fold: false", "")
|
||||
.replace(", push_base: 0", "")
|
||||
.replace(", word_bound_buffers: {}", "")
|
||||
.replace(", arrayed_fetches: {}", ""),
|
||||
.replace(", arrayed_fetches: {}", "")
|
||||
.replace(", extended_unorm_colors: {}", ""),
|
||||
"{derived}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,354 @@
|
||||
//! Blending into a color attachment of `BGR10_XR` or `BGRA10_XR`, whose image holds the UNORM
|
||||
//! codes of the format's bits (`metal::format::FormatEmulation::ExtendedRangeUnorm`).
|
||||
//!
|
||||
//! A code `c` is the value `v = (c - 384) / 510`; the image holds `u = c / m` (`m` 1023 in
|
||||
//! `BGR10_XR`'s `A2R10G10B10_UNORM_PACK32`, 65535 over 64 in `BGRA10_XR`'s
|
||||
//! `R16G16B16A16_UNORM`), so `v = A u + B` with `A = m / 510` and `B = -384 / 510`. Metal blends
|
||||
//! the values; Vulkan blends the codes. With Vulkan's source factor one and the destination
|
||||
//! factor `Fd` Metal's, an added blend stores `X + Fd u_d`, which is Metal's `Fs v_s + Fd v_d`
|
||||
//! where the fragment function writes `X = (Fs v_s + (Fd - 1) B) / A`; a subtraction needs
|
||||
//! `X = (Fs v_s - (Fd + 1) B) / A`, and a minimum or a maximum, which takes no factor, the plain
|
||||
//! `X = (v_s - B) / A` (`lower::stage_io::extended_color`). So [`extended_blend`] gives Vulkan's
|
||||
//! state for a blend whose source factors the function computes and whose destination factors
|
||||
//! Vulkan reads as Metal's:
|
||||
//!
|
||||
//! - **Source factors**, which the function folds into `X`: zero, one, the source's color or
|
||||
//! alpha and one minus either; on `BGR10_XR`, whose destination alpha Metal reads as 1, the
|
||||
//! destination alpha, one minus it, and the saturated source alpha.
|
||||
//! - **Destination factors** Vulkan reads as Metal's: zero and one; the source's alpha, its color
|
||||
//! and one minus either, from a second output the function writes, Metal's color and alpha in the
|
||||
//! image's channels (`LoweringInputs::rotated_factors`'s lanes, Vulkan's `SRC1` factors, which
|
||||
//! need `dualSrcBlend` and an attachment below `maxFragmentDualSrcAttachments`); on `BGR10_XR`,
|
||||
//! the destination alpha (1) and one minus it (0). `BGR10_XR`'s output alpha is 1, so its two
|
||||
//! alpha bits are written as ones, as Metal writes them.
|
||||
//! - **Refused** (`NotImplemented(Format)`): every other factor (a destination color, a
|
||||
//! `BGRA10_XR` destination alpha, the blend color, a saturated source alpha Vulkan would read
|
||||
//! against the image's alpha bits, and any factor of Metal's own second output, whose value
|
||||
//! the correction would read beside the first output's), and a reverse subtraction.
|
||||
//!
|
||||
//! Metal's blend (measured on an Apple M3 Max under macOS 27.0.1) clamps its source and
|
||||
//! destination, each color channel to the values of codes 0 and 1022 and alpha to `[0, 1]`, blends
|
||||
//! in `half` with a fused multiply-add, clamps the result to codes 0 to 1023, and rounds it to
|
||||
//! nearest even; the function clamps the source alike (`lower::stage_io::extended_unorm_color`).
|
||||
//! A blend that stores the source as it is (one and zero, added) is then Metal's exactly, and takes
|
||||
//! no Vulkan blend. Every other blend carries two static notes of the pipeline, from its factors and
|
||||
//! operations alone ([`notes`]):
|
||||
//!
|
||||
//! - `PrecisionNote::ExtendedRangeBlend`, on each: Vulkan blends the codes in its own precision and
|
||||
//! rounds the result to the field at every draw, where Metal blends `half` values and its tile
|
||||
//! keeps them through the pass: within one code a draw while the source term lies in the code
|
||||
//! range, `BGRA10_XR`'s six low bits holding the fraction.
|
||||
//! - `PrecisionNote::ExtendedRangeBlendWindow`, where the corrected source term `X` can leave
|
||||
//! `[0, 1]`, which Vulkan clamps it to, for a source in Metal's range, or Vulkan's `SRC1` factor,
|
||||
//! which it clamps to `[0, 1]`, can differ from Metal's ([`window_holds`], at the corners of the
|
||||
//! source's range): an addition with a negative source, or premultiplied source-over with a source
|
||||
//! below `-0.7529` times its alpha, stores a code up to 386 from Metal's. Straight alpha-over, a
|
||||
//! source factor of zero, a minimum and a maximum hold by construction.
|
||||
|
||||
use crate::device::requirements::VkFeature;
|
||||
use crate::device::DeviceProfile;
|
||||
use crate::error::{Capability, Error, Feature, Unsupported};
|
||||
use crate::metal::state::blend_factors;
|
||||
use crate::metal::{BlendFactor, BlendOperation, PixelFormat};
|
||||
use crate::pipeline::artifact::PrecisionNote;
|
||||
use crate::pipeline::descriptor::ColorAttachmentDescriptor;
|
||||
use crate::pipeline::graphics::BlendState;
|
||||
use crate::pipeline::lower_inputs::{ExtendedUnormBlend, FactorLane};
|
||||
use crate::vk;
|
||||
|
||||
/// Vulkan's blend of an attachment of `BGR10_XR` or `BGRA10_XR` (the module docs), which link
|
||||
/// takes.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct ExtendedBlend {
|
||||
/// The blend state: a source factor of one, the destination factors Metal's.
|
||||
pub(crate) state: BlendState,
|
||||
/// The second output the function writes for the blend, per channel of the image, where its
|
||||
/// factors read one that is not Metal's own (`LoweringInputs::rotated_factors`).
|
||||
pub(crate) lanes: Option<[FactorLane; 4]>,
|
||||
}
|
||||
|
||||
/// Where Vulkan reads a destination factor of Metal's from.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum Read {
|
||||
/// A constant: Vulkan's factor.
|
||||
Constant(vk::BlendFactor),
|
||||
/// The second output the blend needs: a color (false) or alpha (true) factor of it, one minus
|
||||
/// it where the second is true.
|
||||
Synthesized(bool, bool),
|
||||
}
|
||||
|
||||
/// Whether `pf` is `BGRA10_XR`, whose image exchanges red and blue and holds an alpha code.
|
||||
fn four(pf: PixelFormat) -> bool {
|
||||
pf == PixelFormat::BGRA10XR
|
||||
}
|
||||
|
||||
/// The value of Metal's factor `f` in a term of the color (`alpha` false) or the alpha at an
|
||||
/// attachment of `pf`, for the clamped source whose own channel in the term is `s` (a color
|
||||
/// channel, or the alpha) and whose alpha is `a`: `None` for a factor the function does not fold
|
||||
/// (the module docs). The emitted factors are this function's (`lower::stage_io::extended_unorm_color`).
|
||||
pub(crate) fn factor_value(
|
||||
pf: PixelFormat,
|
||||
f: BlendFactor,
|
||||
alpha: bool,
|
||||
s: f64,
|
||||
a: f64,
|
||||
) -> Option<f64> {
|
||||
use BlendFactor as F;
|
||||
Some(match f {
|
||||
F::Zero => 0.0,
|
||||
F::One => 1.0,
|
||||
F::SourceColor => s,
|
||||
F::OneMinusSourceColor => 1.0 - s,
|
||||
F::SourceAlpha => a,
|
||||
F::OneMinusSourceAlpha => 1.0 - a,
|
||||
// `BGR10_XR`'s destination alpha is 1, and its saturated source alpha
|
||||
// `min(a, 1 - 1)` in a color term, 1 in an alpha one.
|
||||
F::DestinationAlpha if !four(pf) => 1.0,
|
||||
F::OneMinusDestinationAlpha if !four(pf) => 0.0,
|
||||
F::SourceAlphaSaturated if !four(pf) => match alpha {
|
||||
true => 1.0,
|
||||
false => a.min(0.0),
|
||||
},
|
||||
F::DestinationAlpha
|
||||
| F::OneMinusDestinationAlpha
|
||||
| F::SourceAlphaSaturated
|
||||
| F::DestinationColor
|
||||
| F::OneMinusDestinationColor
|
||||
| F::BlendColor
|
||||
| F::OneMinusBlendColor
|
||||
| F::BlendAlpha
|
||||
| F::OneMinusBlendAlpha
|
||||
| F::Source1Color
|
||||
| F::OneMinusSource1Color
|
||||
| F::Source1Alpha
|
||||
| F::OneMinusSource1Alpha
|
||||
| F::Unspecialized => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether the function folds Metal's source factor `f` into its output, at an attachment of
|
||||
/// `pf` (the module docs).
|
||||
pub(crate) fn folds(pf: PixelFormat, f: BlendFactor) -> bool {
|
||||
factor_value(pf, f, false, 0.0, 0.0).is_some()
|
||||
}
|
||||
|
||||
/// Where Vulkan reads Metal's destination factor `f` of the color (`alpha` false) or alpha
|
||||
/// terms at an attachment of `pf`; `None` where it does not.
|
||||
fn read(pf: PixelFormat, f: BlendFactor, alpha: bool) -> Option<Read> {
|
||||
use vk::BlendFactor as V;
|
||||
use BlendFactor as F;
|
||||
Some(match f {
|
||||
F::Zero => Read::Constant(V::ZERO),
|
||||
F::One => Read::Constant(V::ONE),
|
||||
F::SourceAlpha => Read::Synthesized(true, false),
|
||||
F::OneMinusSourceAlpha => Read::Synthesized(true, true),
|
||||
// An alpha term's source color factor is the source's alpha.
|
||||
F::SourceColor => Read::Synthesized(alpha, false),
|
||||
F::OneMinusSourceColor => Read::Synthesized(alpha, true),
|
||||
F::DestinationAlpha if !four(pf) => Read::Constant(V::ONE),
|
||||
F::OneMinusDestinationAlpha if !four(pf) => Read::Constant(V::ZERO),
|
||||
F::DestinationAlpha
|
||||
| F::OneMinusDestinationAlpha
|
||||
| F::SourceAlphaSaturated
|
||||
| F::DestinationColor
|
||||
| F::OneMinusDestinationColor
|
||||
| F::BlendColor
|
||||
| F::OneMinusBlendColor
|
||||
| F::BlendAlpha
|
||||
| F::OneMinusBlendAlpha
|
||||
| F::Source1Color
|
||||
| F::OneMinusSource1Color
|
||||
| F::Source1Alpha
|
||||
| F::OneMinusSource1Alpha
|
||||
| F::Unspecialized => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Vulkan's operation of Metal's `op` (the module docs): `None` for a reverse subtraction.
|
||||
fn operation(op: BlendOperation) -> Option<vk::BlendOp> {
|
||||
Some(match op {
|
||||
BlendOperation::Add => vk::BlendOp::ADD,
|
||||
BlendOperation::Subtract => vk::BlendOp::SUBTRACT,
|
||||
BlendOperation::Min => vk::BlendOp::MIN,
|
||||
BlendOperation::Max => vk::BlendOp::MAX,
|
||||
BlendOperation::ReverseSubtract | BlendOperation::Unspecialized => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether Metal's operation `op` takes factors: not a minimum or a maximum.
|
||||
fn weighs(op: BlendOperation) -> bool {
|
||||
!matches!(op, BlendOperation::Min | BlendOperation::Max)
|
||||
}
|
||||
|
||||
/// Where Vulkan reads the destination factors of Metal's blend `b` at an attachment of `pf`,
|
||||
/// the color term's and `BGRA10_XR`'s alpha term's (a term whose operation takes no factor reads
|
||||
/// none: one), and Vulkan's operations; `None` where the blend is not covered (the module docs).
|
||||
fn reads(pf: PixelFormat, b: &ExtendedUnormBlend) -> Option<([Read; 2], [vk::BlendOp; 2])> {
|
||||
let rgb_op = operation(b.rgb_operation)?;
|
||||
// `BGR10_XR` stores no alpha: its alpha terms are not Metal's to blend.
|
||||
let alpha_op = match four(pf) {
|
||||
true => operation(b.alpha_operation)?,
|
||||
false => vk::BlendOp::ADD,
|
||||
};
|
||||
let mut terms = vec![(b.source_rgb, b.destination_rgb, b.rgb_operation, false)];
|
||||
if four(pf) {
|
||||
terms.push((b.source_alpha, b.destination_alpha, b.alpha_operation, true));
|
||||
}
|
||||
let mut out = [Read::Constant(vk::BlendFactor::ONE); 2];
|
||||
for (i, &(src, dst, op, alpha)) in terms.iter().enumerate() {
|
||||
if !weighs(op) {
|
||||
continue;
|
||||
}
|
||||
if !folds(pf, src) {
|
||||
return None;
|
||||
}
|
||||
out[i] = read(pf, dst, alpha)?;
|
||||
}
|
||||
Some((out, [rgb_op, alpha_op]))
|
||||
}
|
||||
|
||||
/// Whether link blends an attachment of `pf` under Metal's blend `b` (the module docs): its
|
||||
/// factors and operations are covered. A blend a device lacks the features for is not told apart.
|
||||
pub(crate) fn covered(pf: PixelFormat, b: &ExtendedUnormBlend) -> bool {
|
||||
reads(pf, b).is_some()
|
||||
}
|
||||
|
||||
/// The value of `X`, the source term the function writes ([`window_holds`]), of Metal's source
|
||||
/// factor `src`, destination factor `dst` and operation `op` in a term of the color (`alpha`
|
||||
/// false) or the alpha at an attachment of `pf`, for the clamped source `(s, a)` ([`factor_value`])
|
||||
/// at codes of maximum `m`; and whether Vulkan's reading of `dst` is Metal's factor there (a factor
|
||||
/// Vulkan reads from the second output, which it clamps to `[0, 1]`). `None` for a factor not
|
||||
/// covered.
|
||||
fn term(
|
||||
pf: PixelFormat,
|
||||
(src, dst, op): (BlendFactor, BlendFactor, BlendOperation),
|
||||
alpha: bool,
|
||||
(s, a): (f64, f64),
|
||||
m: f64,
|
||||
) -> Option<(f64, bool)> {
|
||||
let (r, c) = (510.0 / m, 384.0 / m);
|
||||
if !weighs(op) {
|
||||
return Some((s * r + c, true));
|
||||
}
|
||||
let fs = factor_value(pf, src, alpha, s, a)?;
|
||||
let fd = factor_value(pf, dst, alpha, s, a)?;
|
||||
let read = (0.0..=1.0).contains(&fd);
|
||||
let weight = match op {
|
||||
BlendOperation::Subtract => 1.0 + fd,
|
||||
_ => 1.0 - fd,
|
||||
};
|
||||
Some((fs * s * r + weight * c, read))
|
||||
}
|
||||
|
||||
/// Whether Vulkan's blend of Metal's blend `b` at an attachment of `pf` (covered: [`covered`])
|
||||
/// stays within one code of Metal's for every source in Metal's clamped range: at every corner of
|
||||
/// that range, and at the vertices of the products of the source with itself (0 and 0.5), the
|
||||
/// corrected source term of the color, and of `BGRA10_XR`'s alpha, lies in `[0, 1]`, and Vulkan's
|
||||
/// reading of each destination factor is Metal's. The term is at most quadratic in the source's
|
||||
/// channel and affine in its alpha, so these points bound it.
|
||||
pub(crate) fn window_holds(pf: PixelFormat, b: &ExtendedUnormBlend) -> bool {
|
||||
let m = match four(pf) {
|
||||
true => 65535.0 / 64.0,
|
||||
false => 1023.0,
|
||||
};
|
||||
let (low, high) = (-384.0 / 510.0, 638.0 / 510.0);
|
||||
let mut terms = vec![(
|
||||
(b.source_rgb, b.destination_rgb, b.rgb_operation),
|
||||
false,
|
||||
vec![low, 0.0, 0.5, high],
|
||||
)];
|
||||
if four(pf) {
|
||||
terms.push((
|
||||
(b.source_alpha, b.destination_alpha, b.alpha_operation),
|
||||
true,
|
||||
vec![0.0, 0.5, 1.0],
|
||||
));
|
||||
}
|
||||
terms.into_iter().all(|(factors, alpha, sources)| {
|
||||
sources.iter().all(|&s| {
|
||||
let alphas = match alpha {
|
||||
true => vec![s],
|
||||
false => vec![0.0, 1.0],
|
||||
};
|
||||
alphas.into_iter().all(|a| {
|
||||
term(pf, factors, alpha, (s, a), m)
|
||||
.is_some_and(|(x, read)| read && (-1e-9..=1.0 + 1e-9).contains(&x))
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// The precision notes of Metal's blend `b` at an attachment of `pf` (covered: [`covered`]), from
|
||||
/// its factors and operations alone (the module docs): none where it stores the source as it is,
|
||||
/// `ExtendedRangeBlend` elsewhere, and `ExtendedRangeBlendWindow` beside it where
|
||||
/// [`window_holds`] does not.
|
||||
pub(crate) fn notes(pf: PixelFormat, b: &ExtendedUnormBlend) -> Vec<PrecisionNote> {
|
||||
if b.stores_source(pf) {
|
||||
return Vec::new();
|
||||
}
|
||||
let mut notes = vec![PrecisionNote::ExtendedRangeBlend];
|
||||
if !window_holds(pf, b) {
|
||||
notes.push(PrecisionNote::ExtendedRangeBlendWindow);
|
||||
}
|
||||
notes
|
||||
}
|
||||
|
||||
/// Vulkan's blend of attachment `a`, of `BGR10_XR` or `BGRA10_XR`, on `p` (the module docs):
|
||||
/// `None` without blending, `NotImplemented(Format)` where none is Metal's,
|
||||
/// `Unsupported{DualSourceBlending, Feature(DualSrcBlend)}` where a second output gives it and
|
||||
/// the device has no dual-source blending, and the descriptor's own errors.
|
||||
pub(crate) fn extended_blend(
|
||||
a: &ColorAttachmentDescriptor,
|
||||
p: &DeviceProfile,
|
||||
) -> Result<Option<ExtendedBlend>, Error> {
|
||||
use vk::BlendFactor as V;
|
||||
// Metal 4's placeholders resolve to their slot's own default first.
|
||||
let a = &a.specialized();
|
||||
// The descriptor's own errors first: a `Source1` factor without dual-source blending.
|
||||
let Some(plain) = blend_factors(a, p)? else {
|
||||
return Ok(None);
|
||||
};
|
||||
let refused = || Error::from(Unsupported::not_implemented(Feature::Format));
|
||||
// A factor of Metal's own second output, folded or read, is not covered.
|
||||
if plain.reads_second_output() {
|
||||
return Err(refused());
|
||||
}
|
||||
let pf = a.pixel_format;
|
||||
let b = ExtendedUnormBlend::of(a);
|
||||
let (reads, [rgb_op, alpha_op]) = reads(pf, &b).ok_or_else(refused)?;
|
||||
let synthesized = reads.iter().any(|r| matches!(r, Read::Synthesized(..)));
|
||||
let factor = |r: Read| match r {
|
||||
Read::Constant(v) => v,
|
||||
Read::Synthesized(false, false) => V::SRC1_COLOR,
|
||||
Read::Synthesized(false, true) => V::ONE_MINUS_SRC1_COLOR,
|
||||
Read::Synthesized(true, false) => V::SRC1_ALPHA,
|
||||
Read::Synthesized(true, true) => V::ONE_MINUS_SRC1_ALPHA,
|
||||
};
|
||||
let state = BlendState {
|
||||
src_color: V::ONE,
|
||||
dst_color: factor(reads[0]),
|
||||
color_op: rgb_op,
|
||||
src_alpha: V::ONE,
|
||||
dst_alpha: match four(pf) {
|
||||
true => factor(reads[1]),
|
||||
false => V::ZERO,
|
||||
},
|
||||
alpha_op,
|
||||
};
|
||||
if state.reads_second_output() && !p.fields().fragment.dual_src_blend {
|
||||
return Err(Unsupported::needs(
|
||||
Feature::DualSourceBlending,
|
||||
Capability::Feature(VkFeature::DualSrcBlend),
|
||||
)
|
||||
.into());
|
||||
}
|
||||
// The second output holds Metal's color and alpha in the image's channels.
|
||||
let lanes = synthesized.then(|| match four(pf) {
|
||||
true => [2, 1, 0, 3].map(FactorLane::Output),
|
||||
false => [0, 1, 2, 3].map(FactorLane::Output),
|
||||
});
|
||||
Ok(Some(ExtendedBlend { state, lanes }))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -0,0 +1,201 @@
|
||||
//! [`window_holds`] and [`notes`] against a dense numeric model of the source term: every factor
|
||||
//! pair and operation Metal names, at both formats, so a factor or an operation that is added later
|
||||
//! is classified here before it reaches a pipeline.
|
||||
|
||||
use super::*;
|
||||
|
||||
/// Metal's factor `f` in a term of the color (`alpha` false) or the alpha at an attachment of
|
||||
/// `pf`, for the clamped source whose channel in the term is `s` and alpha `a`, as Metal's
|
||||
/// documentation states each factor, with `BGR10_XR`'s destination alpha 1; `None` for a factor
|
||||
/// that reads the destination's color, `BGRA10_XR`'s destination alpha, the blend color or a
|
||||
/// second output.
|
||||
fn metal_factor(pf: PixelFormat, f: BlendFactor, alpha: bool, s: f64, a: f64) -> Option<f64> {
|
||||
use BlendFactor as F;
|
||||
let wide = pf == PixelFormat::BGRA10XR;
|
||||
match f {
|
||||
F::Zero => Some(0.0),
|
||||
F::One => Some(1.0),
|
||||
F::SourceColor => Some(s),
|
||||
F::OneMinusSourceColor => Some(1.0 - s),
|
||||
F::SourceAlpha => Some(a),
|
||||
F::OneMinusSourceAlpha => Some(1.0 - a),
|
||||
F::DestinationAlpha if !wide => Some(1.0),
|
||||
F::OneMinusDestinationAlpha if !wide => Some(0.0),
|
||||
F::SourceAlphaSaturated if !wide && alpha => Some(1.0),
|
||||
// `min(a, 1 - Ad)` with the destination alpha 1.
|
||||
F::SourceAlphaSaturated if !wide => Some(a.min(0.0)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the source term of `(src, dst, op)` lies in `[0, 1]`, and Metal's destination factor in
|
||||
/// `[0, 1]` where Vulkan reads it from the second output, at every point of a dense grid over the
|
||||
/// clamped source's range; `None` where a factor is not modelled.
|
||||
fn dense_holds(pf: PixelFormat, b: &ExtendedUnormBlend) -> Option<bool> {
|
||||
let wide = pf == PixelFormat::BGRA10XR;
|
||||
let m = match wide {
|
||||
true => 65535.0 / 64.0,
|
||||
false => 1023.0,
|
||||
};
|
||||
let (low, high) = (-384.0 / 510.0, 638.0 / 510.0);
|
||||
let mut terms = vec![(b.source_rgb, b.destination_rgb, b.rgb_operation, false)];
|
||||
if wide {
|
||||
terms.push((b.source_alpha, b.destination_alpha, b.alpha_operation, true));
|
||||
}
|
||||
let mut holds = true;
|
||||
for (src, dst, op, alpha) in terms {
|
||||
// An alpha term's own channel is the alpha.
|
||||
let channels = if alpha { 0 } else { 200 };
|
||||
for i in 0..=channels {
|
||||
for j in 0..=20 {
|
||||
let a = f64::from(j) / 20.0;
|
||||
let s = match alpha {
|
||||
true => a,
|
||||
false => low + (high - low) * f64::from(i) / 200.0,
|
||||
};
|
||||
let x = match op {
|
||||
BlendOperation::Min | BlendOperation::Max => (s * 510.0 + 384.0) / m,
|
||||
_ => {
|
||||
let fs = metal_factor(pf, src, alpha, s, a)?;
|
||||
let fd = metal_factor(pf, dst, alpha, s, a)?;
|
||||
if !(0.0..=1.0).contains(&fd) {
|
||||
holds = false;
|
||||
}
|
||||
let weight = match op {
|
||||
BlendOperation::Subtract => 1.0 + fd,
|
||||
_ => 1.0 - fd,
|
||||
};
|
||||
(fs * s * 510.0 + weight * 384.0) / m
|
||||
}
|
||||
};
|
||||
if !(-1e-9..=1.0 + 1e-9).contains(&x) {
|
||||
holds = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(holds)
|
||||
}
|
||||
|
||||
/// A blend of `(src, dst, op)` for the color and the alpha alike.
|
||||
fn blend(src: BlendFactor, dst: BlendFactor, op: BlendOperation) -> ExtendedUnormBlend {
|
||||
let mut c = ColorAttachmentDescriptor::new(PixelFormat::BGRA10XR);
|
||||
c.blending_enabled = true;
|
||||
c.source_rgb_blend_factor = src;
|
||||
c.destination_rgb_blend_factor = dst;
|
||||
c.rgb_blend_operation = op;
|
||||
c.source_alpha_blend_factor = src;
|
||||
c.destination_alpha_blend_factor = dst;
|
||||
c.alpha_blend_operation = op;
|
||||
ExtendedUnormBlend::of(&c)
|
||||
}
|
||||
|
||||
/// For every factor pair and operation Metal names, at both formats: a covered blend's corner
|
||||
/// evaluation is the dense model's, and its notes are none where it stores its source as it is,
|
||||
/// `ExtendedRangeBlend` elsewhere, with `ExtendedRangeBlendWindow` where the window does not hold;
|
||||
/// an uncovered one is a factor or an operation the module refuses.
|
||||
#[test]
|
||||
fn every_factor_pair_and_operation_is_classified_at_the_corners() {
|
||||
let factors: Vec<BlendFactor> = BlendFactor::ALL
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|f| *f != BlendFactor::Unspecialized)
|
||||
.collect();
|
||||
let operations: Vec<BlendOperation> = BlendOperation::ALL
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|o| *o != BlendOperation::Unspecialized)
|
||||
.collect();
|
||||
let mut counted = [0usize; 4];
|
||||
for pf in [PixelFormat::BGR10XR, PixelFormat::BGRA10XR] {
|
||||
for &src in &factors {
|
||||
for &dst in &factors {
|
||||
for &op in &operations {
|
||||
let b = blend(src, dst, op);
|
||||
let what = format!("{pf:?} {src:?} {dst:?} {op:?}");
|
||||
if !covered(pf, &b) {
|
||||
let refused = op == BlendOperation::ReverseSubtract
|
||||
|| (op != BlendOperation::Min
|
||||
&& op != BlendOperation::Max
|
||||
&& (!folds(pf, src) || read(pf, dst, false).is_none()));
|
||||
assert!(refused, "{what}: uncovered");
|
||||
counted[0] += 1;
|
||||
continue;
|
||||
}
|
||||
let dense = dense_holds(pf, &b).unwrap_or_else(|| panic!("{what}: modelled"));
|
||||
assert_eq!(window_holds(pf, &b), dense, "{what}");
|
||||
let n = notes(pf, &b);
|
||||
match (b.stores_source(pf), dense) {
|
||||
(true, _) => {
|
||||
assert!(n.is_empty(), "{what}: {n:?}");
|
||||
counted[1] += 1;
|
||||
}
|
||||
(false, true) => {
|
||||
assert_eq!(n, vec![PrecisionNote::ExtendedRangeBlend], "{what}");
|
||||
counted[2] += 1;
|
||||
}
|
||||
(false, false) => {
|
||||
assert_eq!(
|
||||
n,
|
||||
vec![
|
||||
PrecisionNote::ExtendedRangeBlend,
|
||||
PrecisionNote::ExtendedRangeBlendWindow
|
||||
],
|
||||
"{what}"
|
||||
);
|
||||
counted[3] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(counted.iter().all(|&c| c > 0), "{counted:?}");
|
||||
}
|
||||
|
||||
/// The blends the notes name: straight alpha-over, a source factor of zero, a minimum and a maximum
|
||||
/// hold the window; an addition of one and one, premultiplied source-over and a destination factor
|
||||
/// of the source's color do not; one and zero, added, carries no note.
|
||||
#[test]
|
||||
fn the_named_blends_hold_the_window_or_not() {
|
||||
use BlendFactor as F;
|
||||
use BlendOperation as O;
|
||||
for pf in [PixelFormat::BGR10XR, PixelFormat::BGRA10XR] {
|
||||
let mut straight = blend(F::SourceAlpha, F::OneMinusSourceAlpha, O::Add);
|
||||
straight.source_alpha = F::One;
|
||||
for (name, b, holds) in [
|
||||
("straight-over", straight, true),
|
||||
(
|
||||
"destination-in",
|
||||
blend(F::Zero, F::SourceAlpha, O::Add),
|
||||
true,
|
||||
),
|
||||
(
|
||||
"destination-out",
|
||||
blend(F::Zero, F::OneMinusSourceAlpha, O::Add),
|
||||
true,
|
||||
),
|
||||
("clear", blend(F::Zero, F::Zero, O::Add), true),
|
||||
("minimum", blend(F::One, F::One, O::Min), true),
|
||||
("maximum", blend(F::One, F::One, O::Max), true),
|
||||
("plus", blend(F::One, F::One, O::Add), false),
|
||||
(
|
||||
"source-over",
|
||||
blend(F::One, F::OneMinusSourceAlpha, O::Add),
|
||||
false,
|
||||
),
|
||||
("modulate", blend(F::Zero, F::SourceColor, O::Add), false),
|
||||
] {
|
||||
assert!(covered(pf, &b), "{pf:?} {name}");
|
||||
assert_eq!(window_holds(pf, &b), holds, "{pf:?} {name}");
|
||||
assert_eq!(
|
||||
notes(pf, &b).contains(&PrecisionNote::ExtendedRangeBlendWindow),
|
||||
!holds,
|
||||
"{pf:?} {name}"
|
||||
);
|
||||
}
|
||||
let identity = blend(F::One, F::Zero, O::Add);
|
||||
assert!(identity.stores_source(pf), "{pf:?}");
|
||||
assert!(notes(pf, &identity).is_empty(), "{pf:?}");
|
||||
}
|
||||
}
|
||||
@@ -222,7 +222,8 @@ fn textured_fetches(r: &RenderLinkInputs, fs: Option<&StageInterface>) -> Result
|
||||
if metal::format::rotated_channels(pf)
|
||||
|| metal::format::ycbcr_renders(pf)
|
||||
|| metal::format::ycbcr_pass_refused(pf)
|
||||
|| ExtendedRange::of_attachment(pf).is_some()
|
||||
|| ExtendedRange::of(pf).is_some()
|
||||
|| metal::format::extended_unorm(pf)
|
||||
{
|
||||
let refused = Unsupported::not_implemented(Feature::Format);
|
||||
return Err(refused.at_attachment(Attachment::Color(color)).into());
|
||||
@@ -351,7 +352,7 @@ pub fn graphics_state(
|
||||
let unblendable = r.color_attachments.iter().position(|a| {
|
||||
a.is_some_and(|a| {
|
||||
a.blending_enabled
|
||||
&& ExtendedRange::of_attachment(a.pixel_format).is_some_and(ExtendedRange::bfloat)
|
||||
&& ExtendedRange::of(a.pixel_format).is_some_and(ExtendedRange::bfloat)
|
||||
})
|
||||
});
|
||||
if let Some(index) = unblendable {
|
||||
@@ -395,6 +396,51 @@ pub fn graphics_state(
|
||||
blend: None,
|
||||
});
|
||||
}
|
||||
// A `BGR10_XR` or `BGRA10_XR` attachment is its UNORM image, which the
|
||||
// function writes as the codes over their maximum
|
||||
// (`LoweringInputs::extended_unorm_colors`): Metal's mask on the image's
|
||||
// channels (`BGRA10_XR`'s red and blue exchanged; `BGR10_XR`'s two alpha bits
|
||||
// written as ones with its codes, as Metal's store writes them), and Vulkan's
|
||||
// blend of the codes with a source factor of one (`pipeline::extended_blend`).
|
||||
if metal::format::extended_unorm(a.pixel_format) {
|
||||
use vk::ColorComponentFlags as C;
|
||||
let written_here = written.contains(&(index as u32));
|
||||
let blend = match written_here && color_writes::extended_unorm_blended(a) {
|
||||
true => crate::pipeline::extended_blend::extended_blend(a, p)?,
|
||||
false => None,
|
||||
};
|
||||
let mut usages = BTreeSet::from([FormatUsage::ColorAttachment]);
|
||||
if blend.is_some() {
|
||||
usages.insert(FormatUsage::ColorAttachmentBlend);
|
||||
}
|
||||
let format = vk_format(a.pixel_format, &usages, p)?.format;
|
||||
let mask = color_write_mask(a.write_mask)?;
|
||||
let write_mask = match a.pixel_format {
|
||||
_ if !written_here => C::empty(),
|
||||
metal::PixelFormat::BGRA10XR => {
|
||||
let mut swapped = mask & (C::G | C::A);
|
||||
if mask.contains(C::R) {
|
||||
swapped |= C::B;
|
||||
}
|
||||
if mask.contains(C::B) {
|
||||
swapped |= C::R;
|
||||
}
|
||||
swapped
|
||||
}
|
||||
_ => {
|
||||
let color = mask & (C::R | C::G | C::B);
|
||||
match color.is_empty() {
|
||||
true => color,
|
||||
false => color | C::A,
|
||||
}
|
||||
}
|
||||
};
|
||||
return Ok(ColorAttachmentState {
|
||||
format,
|
||||
write_mask,
|
||||
blend: blend.map(|b| b.state),
|
||||
});
|
||||
}
|
||||
// Metal's blend of one and zero stores the output as written, as no blend
|
||||
// does, so an attachment the function writes whose format converts the
|
||||
// output (its channels take a rule of Metal's in this pipeline,
|
||||
@@ -423,7 +469,7 @@ pub fn graphics_state(
|
||||
// unwritten attachment (the module docs), so its blend changes nothing: it
|
||||
// takes none, nor the blend usage its raw unsigned format lacks (a padded
|
||||
// one's too; a bfloat one's blend is refused above).
|
||||
let extended = ExtendedRange::of_attachment(a.pixel_format);
|
||||
let extended = ExtendedRange::of(a.pixel_format);
|
||||
let written_here = written.contains(&(index as u32));
|
||||
let unwritten_extended = !written_here && extended.is_some();
|
||||
// An attachment held with its channels rotated takes the function's rotated
|
||||
@@ -862,11 +908,11 @@ fn reads_alpha_to_coverage(
|
||||
metal: MetalAnswer::EndsProcess,
|
||||
}));
|
||||
}
|
||||
// An extended-range attachment 0 is written as raw texels, whose alpha the coverage cannot
|
||||
// read: what Metal's coverage is there is unmeasured.
|
||||
if r.color_attachments[0]
|
||||
.is_some_and(|a| ExtendedRange::of_attachment(a.pixel_format).is_some())
|
||||
{
|
||||
// An extended-range attachment 0 is written as raw texels or codes, whose alpha the coverage
|
||||
// cannot read: what Metal's coverage is there is unmeasured.
|
||||
if r.color_attachments[0].is_some_and(|a| {
|
||||
ExtendedRange::of(a.pixel_format).is_some() || metal::format::extended_unorm(a.pixel_format)
|
||||
}) {
|
||||
let refused = Unsupported::not_implemented(Feature::Format);
|
||||
return Err(refused.at_attachment(Attachment::Color(0)).into());
|
||||
}
|
||||
|
||||
@@ -422,6 +422,19 @@ pub struct LoweringInputs {
|
||||
/// one compiled under another as `NeedsInput(ColorWrites)`. Empty for any other function.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub extended_range_colors: BTreeMap<u32, ExtendedRangeColor>,
|
||||
/// The color attachments the fragment function's render pipeline gives `BGR10_XR` or
|
||||
/// `BGRA10_XR`, by color index ([`ExtendedUnormColor`]): each such attachment's image holds
|
||||
/// the UNORM codes of the format's bits (`metal::format::FormatEmulation::ExtendedRangeUnorm`),
|
||||
/// so the function writes it through a `float` output variable of four components, each
|
||||
/// channel the code Metal stores for its `float` or `half` output over the code's maximum
|
||||
/// (`BGRA10_XR`'s red and blue exchanged, `BGR10_XR`'s alpha 1), and under a blend the value
|
||||
/// Vulkan's blend of the codes takes to Metal's blend of the values
|
||||
/// (`lower::stage_io::extended_color`). `Device::compile_render_pipeline` sets it for a
|
||||
/// `Function` fragment stage from the pipeline's color attachments, and link refuses a
|
||||
/// fragment compiled under another map as `NeedsInput(ColorWrites)`. Empty for any other
|
||||
/// function.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub extended_unorm_colors: BTreeMap<u32, ExtendedUnormColor>,
|
||||
/// The color attachments the device renders through a word view
|
||||
/// (`metal::format::WordAttachment`), by color index: an attachment the pipeline writes
|
||||
/// unblended (or blended with factors one and zero, added), under a write mask of all of the
|
||||
@@ -754,6 +767,96 @@ pub struct LoweringInputs {
|
||||
pub arrayed_fetches: BTreeSet<u32>,
|
||||
}
|
||||
|
||||
/// How a fragment function writes a color attachment of `BGR10_XR` or `BGRA10_XR`
|
||||
/// (`LoweringInputs::extended_unorm_colors`), whose image holds the UNORM codes of the format's
|
||||
/// bits: unblended, each channel is the code Metal stores for the output (a `float` output
|
||||
/// rounded to `half` first, nearest even, then encoded as a kernel write encodes it) over the
|
||||
/// code's maximum, which the device's conversion stores as that code. Where the pipeline blends
|
||||
/// there, the output is clamped first as Metal's blend clamps its source; under a blend that stores
|
||||
/// the source as it is its codes are written so, and under another Vulkan blends the codes, with a
|
||||
/// source factor of one, and the function writes the value that makes that blend Metal's blend of
|
||||
/// the values: the source term Metal's source factor gives, less the offset the destination factor
|
||||
/// weighs (`lower::stage_io::extended_unorm_color`).
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct ExtendedUnormColor {
|
||||
/// The attachment's format: `BGR10_XR` or `BGRA10_XR`.
|
||||
pub pixel_format: metal::PixelFormat,
|
||||
/// Metal's blend at the attachment, its placeholders resolved; `None` where the pipeline
|
||||
/// does not blend there.
|
||||
pub blend: Option<ExtendedUnormBlend>,
|
||||
}
|
||||
|
||||
impl ExtendedUnormColor {
|
||||
/// The unblended write of an attachment of `pixel_format`.
|
||||
pub fn new(pixel_format: metal::PixelFormat) -> ExtendedUnormColor {
|
||||
ExtendedUnormColor {
|
||||
pixel_format,
|
||||
blend: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// This write under the blend `blend`.
|
||||
pub fn with_blend(self, blend: ExtendedUnormBlend) -> ExtendedUnormColor {
|
||||
ExtendedUnormColor {
|
||||
blend: Some(blend),
|
||||
..self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Metal's blend at a color attachment of `BGR10_XR` or `BGRA10_XR`
|
||||
/// ([`ExtendedUnormColor::blend`]): its factors and operations, as the pipeline descriptor gives
|
||||
/// them with Metal's placeholders resolved.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct ExtendedUnormBlend {
|
||||
/// `sourceRGBBlendFactor`.
|
||||
pub source_rgb: metal::BlendFactor,
|
||||
/// `destinationRGBBlendFactor`.
|
||||
pub destination_rgb: metal::BlendFactor,
|
||||
/// `rgbBlendOperation`.
|
||||
pub rgb_operation: metal::BlendOperation,
|
||||
/// `sourceAlphaBlendFactor`.
|
||||
pub source_alpha: metal::BlendFactor,
|
||||
/// `destinationAlphaBlendFactor`.
|
||||
pub destination_alpha: metal::BlendFactor,
|
||||
/// `alphaBlendOperation`.
|
||||
pub alpha_operation: metal::BlendOperation,
|
||||
}
|
||||
|
||||
impl ExtendedUnormBlend {
|
||||
/// The blend of color attachment `c`, its placeholders resolved
|
||||
/// (`ColorAttachmentDescriptor::specialized`).
|
||||
pub fn of(c: &crate::pipeline::ColorAttachmentDescriptor) -> ExtendedUnormBlend {
|
||||
let c = c.specialized();
|
||||
ExtendedUnormBlend {
|
||||
source_rgb: c.source_rgb_blend_factor,
|
||||
destination_rgb: c.destination_rgb_blend_factor,
|
||||
rgb_operation: c.rgb_blend_operation,
|
||||
source_alpha: c.source_alpha_blend_factor,
|
||||
destination_alpha: c.destination_alpha_blend_factor,
|
||||
alpha_operation: c.alpha_blend_operation,
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether this blend stores its source as it is at an attachment of `pf`: one and zero,
|
||||
/// added, for the color, and for the alpha of `BGRA10_XR` (`BGR10_XR` stores no alpha).
|
||||
pub(crate) fn stores_source(&self, pf: metal::PixelFormat) -> bool {
|
||||
use metal::{BlendFactor as F, BlendOperation as O};
|
||||
let identity = |src, dst, op| (src, dst, op) == (F::One, F::Zero, O::Add);
|
||||
identity(self.source_rgb, self.destination_rgb, self.rgb_operation)
|
||||
&& (pf != metal::PixelFormat::BGRA10XR
|
||||
|| identity(
|
||||
self.source_alpha,
|
||||
self.destination_alpha,
|
||||
self.alpha_operation,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/// One channel of the second output a fragment function writes for an attachment held with its
|
||||
/// channels rotated (`LoweringInputs::rotated_factors`): a constant, or a channel of its first
|
||||
/// output to the attachment as the function returns it, so the blend reads the very value
|
||||
|
||||
@@ -82,6 +82,7 @@ pub(crate) mod artifact;
|
||||
pub(crate) mod color_writes;
|
||||
pub(crate) mod compile;
|
||||
pub(crate) mod descriptor;
|
||||
pub(crate) mod extended_blend;
|
||||
pub(crate) mod facts;
|
||||
pub(crate) mod graphics;
|
||||
mod indirect_draws;
|
||||
@@ -132,8 +133,9 @@ pub use link::{
|
||||
heap_sampler_capacity, heap_unused_while_pending, LEVEL_ZERO_ELEMENT, UNNORMALIZED_TWIN_ELEMENT,
|
||||
};
|
||||
pub use lower_inputs::{
|
||||
AliasView, AmplificationDraws, ChannelWrite, ExtendedRangeColor, FactorLane, KernelVariant,
|
||||
LoweringInputs, StorageImageChoice, StorageImageClass, VertexFetch, VertexFetchProjection,
|
||||
AliasView, AmplificationDraws, ChannelWrite, ExtendedRangeColor, ExtendedUnormBlend,
|
||||
ExtendedUnormColor, FactorLane, KernelVariant, LoweringInputs, StorageImageChoice,
|
||||
StorageImageClass, VertexFetch, VertexFetchProjection,
|
||||
};
|
||||
pub use own::{
|
||||
own_draw, own_kernel, ExecutionCounts, OwnDrawModules, OwnKernel, SampleAspect, SampleBytes,
|
||||
|
||||
@@ -177,6 +177,16 @@ pub struct StageIo {
|
||||
/// stage compiled for another map than the pipeline's (`NeedsInput(ColorWrites)`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub extended_range_colors: BTreeMap<u32, crate::pipeline::lower_inputs::ExtendedRangeColor>,
|
||||
/// The `BGR10_XR` and `BGRA10_XR` attachments the fragment function writes a `float` or
|
||||
/// `half` output to through output variables of dual-source index 0
|
||||
/// (`LoweringInputs::extended_unorm_colors`), by color index: each output variable there is
|
||||
/// declared as four 32-bit `float` components and holds the codes' fractions the device
|
||||
/// stores ([`StageIo::declared_type`]; the variable's `ty` stays the Metal output's), and link
|
||||
/// gives the attachment the UNORM image's format, Metal's mask on its channels and the blend
|
||||
/// whose source the function corrected, and refuses a stage compiled for another map than the
|
||||
/// pipeline's (`NeedsInput(ColorWrites)`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub extended_unorm_colors: BTreeMap<u32, crate::pipeline::lower_inputs::ExtendedUnormColor>,
|
||||
/// The word attachments the fragment function writes a `float` or `half` output to through
|
||||
/// output variables of dual-source index 0 (`LoweringInputs::word_colors`), by color index:
|
||||
/// each output variable there is declared as the word's unsigned integer and holds the word
|
||||
@@ -490,8 +500,8 @@ impl StageIo {
|
||||
|
||||
/// The type variable `v` is declared with: its `ty`, but for a color output of dual-source
|
||||
/// index 0 to an attachment among `extended_range_colors` the raw texel's, the raw format's
|
||||
/// unsigned 32-bit components, and to one among `word_colors` the word's, one unsigned 32-bit
|
||||
/// component.
|
||||
/// unsigned 32-bit components, to one among `extended_unorm_colors` four 32-bit `float`
|
||||
/// components, and to one among `word_colors` the word's, one unsigned 32-bit component.
|
||||
pub(crate) fn declared_type(&self, v: &IoVariable) -> IoType {
|
||||
let IoRole::Color {
|
||||
attachment,
|
||||
@@ -507,6 +517,13 @@ impl StageIo {
|
||||
source_bits: 32,
|
||||
};
|
||||
}
|
||||
if self.extended_unorm_colors.contains_key(&attachment) {
|
||||
return IoType {
|
||||
numeric: IoNumeric::Float,
|
||||
components: 4,
|
||||
source_bits: 32,
|
||||
};
|
||||
}
|
||||
match self.extended_range_colors.get(&attachment) {
|
||||
Some(e) => IoType {
|
||||
numeric: IoNumeric::Uint,
|
||||
|
||||
@@ -220,6 +220,8 @@ pub fn fragment_inputs(
|
||||
&r.color_attachments,
|
||||
r.texture_write_rounding_mode,
|
||||
);
|
||||
inputs.extended_unorm_colors =
|
||||
crate::pipeline::color_writes::extended_unorm_colors(&r.color_attachments);
|
||||
inputs.word_colors =
|
||||
crate::pipeline::color_writes::word_colors(&r.color_attachments, r.alpha_to_coverage, p);
|
||||
inputs.rotated_colors = crate::pipeline::color_writes::rotated_colors(&r.color_attachments, p);
|
||||
|
||||
@@ -1,23 +1,36 @@
|
||||
//! Whole render pipelines into an extended-range attachment in the shapes a wide-gamut
|
||||
//! `CAMetalLayer` client (Impeller's) makes them: color 0 `BGRA10_XR` or its `_sRGB` twin, under
|
||||
//! Impeller's pipeline blends (premultiplied source-over among them) and straight alpha-over, write
|
||||
//! `CAMetalLayer` client's 2D renderer makes them: color 0 `BGRA10_XR` or its `_sRGB` twin, under
|
||||
//! the compositing blends (premultiplied source-over among them) and straight alpha-over, write
|
||||
//! masks of every channel and of none, no depth or stencil attachment, `Stencil8` or
|
||||
//! `Depth32Float_Stencil8`, one sample and four, a `half4` and a `float4` output; and the shapes
|
||||
//! beside them: a pipeline without a fragment function, a fragment function that writes no color,
|
||||
//! and write masks of some channels.
|
||||
//!
|
||||
//! On the profiles of the reported device's family (`nvidia-rtx50-linux`, `nvidia-rtx5080-laptop`),
|
||||
//! on MoltenVK's, on lavapipe's and on the runtime's floor, a written blended attachment is refused
|
||||
//! `NotImplemented(Format)`: Metal's tile holds the attachment as `half` through the pass, which
|
||||
//! the codes it holds do not keep (`lower::fragment::fetch::codes_round_the_tile`). Every other
|
||||
//! pipeline is made (but lavapipe's of four samples, below): an unwritten one with no blend and an
|
||||
//! empty mask, a partly masked one under the mask of its fields. The committed lavapipe profile
|
||||
//! states no multisampled color attachment of the raw format (`R16G16B16A16_UINT`: its
|
||||
//! `framebufferIntegerColorSampleCounts` is one sample, and it records no count of that format's
|
||||
//! own), so a pipeline of four samples is refused there naming the properties it needs. An
|
||||
//! unblended mask of some of the codes one word holds (`BGR10_XR`'s, the two-plane forms') is
|
||||
//! refused `NotImplemented(FramebufferFetch)` on every device: their merge over an ordered read of
|
||||
//! the attachment is not built. No GPU is used.
|
||||
//! on MoltenVK's, on lavapipe's and on the runtime's floor:
|
||||
//!
|
||||
//! - A written blended `BGRA10_XR` attachment, held as the UNORM codes of its bits
|
||||
//! (`R16G16B16A16_UNORM`), is made where `pipeline::extended_blend` covers the blend: Vulkan's
|
||||
//! source factor one, its destination factors Metal's, read from a second output the function
|
||||
//! writes where they read the source (`SRC1`). A blend whose factors read the destination's
|
||||
//! alpha (destination-over, source-in, source-out, source-atop, xor) is refused
|
||||
//! `NotImplemented(Format)`, and so is one whose `SRC1` factors a device without `dualSrcBlend`
|
||||
//! lacks, naming the feature. The floor does not require `R16G16B16A16_UNORM` as a blended color
|
||||
//! attachment, so on its description a covered blend is refused naming those two usages
|
||||
//! ([`floor_lacks_the_image`]), and is made on the floor's description with them.
|
||||
//! - A written blended `BGRA10_XR_sRGB` attachment is refused `NotImplemented(Format)`: Metal's
|
||||
//! tile holds the attachment as `half` through the pass, which the raw codes it holds do not keep
|
||||
//! (`lower::fragment::fetch::codes_round_the_tile`).
|
||||
//! - Every other pipeline is made (but lavapipe's of four samples of the twin, below): an unwritten
|
||||
//! one with no blend and an empty mask, a partly masked one under the mask of its fields. The
|
||||
//! committed lavapipe profile states no multisampled color attachment of the twin's raw format
|
||||
//! (`R16G16B16A16_UINT`: its `framebufferIntegerColorSampleCounts` is one sample, and it records
|
||||
//! no count of that format's own), so a pipeline of four samples is refused there naming the
|
||||
//! properties it needs.
|
||||
//!
|
||||
//! An unblended mask of some of the codes one word holds (`BGR10_XR_sRGB`'s, the two-plane forms')
|
||||
//! is refused `NotImplemented(FramebufferFetch)` on every device: their merge over an ordered read
|
||||
//! of the attachment is not built. No GPU is used.
|
||||
//!
|
||||
//! `llvm-as` assembles the fixture `rt6_samples`; without it the tests skip visibly.
|
||||
|
||||
@@ -120,10 +133,53 @@ fn attachment(
|
||||
a
|
||||
}
|
||||
|
||||
/// Every shape a wide-gamut client makes writes the blended attachment, so each is refused on every
|
||||
/// venue, under a mask of every channel and of none alike.
|
||||
/// The refusal of a covered blend into a `BGRA10_XR` attachment on a device whose
|
||||
/// `R16G16B16A16_UNORM` is not a blended color attachment (the floor's description): `Format`,
|
||||
/// needing both usages, at color 0.
|
||||
fn floor_lacks_the_image(u: &Unsupported, what: &str) {
|
||||
use crate::device::requirements::FormatUsage;
|
||||
use crate::error::Capability;
|
||||
let usage = |usage| Capability::Format {
|
||||
format: vk::Format::R16G16B16A16_UNORM,
|
||||
usage,
|
||||
};
|
||||
let needs = Needs::AnyOf(vec![vec![
|
||||
usage(FormatUsage::ColorAttachment),
|
||||
usage(FormatUsage::ColorAttachmentBlend),
|
||||
]]);
|
||||
assert_eq!(u.feature, Feature::Format, "{what}: {u:?}");
|
||||
assert_eq!(u.needs, needs, "{what}: {u:?}");
|
||||
let at = u.location.as_ref().and_then(|l| l.attachment());
|
||||
assert_eq!(
|
||||
at,
|
||||
Some(crate::error::Attachment::Color(0)),
|
||||
"{what}: {u:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The floor's description with `R16G16B16A16_UNORM` a blended color attachment of
|
||||
/// `framebufferColorSampleCounts`' counts, as most devices offer it.
|
||||
fn with_the_unorm_image(mut desc: DeviceDescription) -> DeviceDescription {
|
||||
use vk::FormatFeatureFlags2 as F;
|
||||
let p = desc
|
||||
.formats
|
||||
.formats
|
||||
.entry(vk::Format::R16G16B16A16_UNORM)
|
||||
.or_default();
|
||||
p.optimal_tiling |= F::COLOR_ATTACHMENT | F::COLOR_ATTACHMENT_BLEND | F::SAMPLED_IMAGE;
|
||||
p.color_attachment_sample_counts =
|
||||
vk::SampleCountFlags::COUNT_1 | vk::SampleCountFlags::COUNT_4;
|
||||
desc
|
||||
}
|
||||
|
||||
/// Every shape a wide-gamut client makes writes the blended attachment: on every venue, under a
|
||||
/// mask of every channel and of none alike, a `BGRA10_XR` one is made where the blend is covered,
|
||||
/// with Vulkan's source factors one and the destination factors read as Metal's (`SRC1` where they
|
||||
/// read the source), and refused where its factors read the destination's alpha; a
|
||||
/// `BGRA10_XR_sRGB` one is refused. On the floor's description a covered blend is refused naming
|
||||
/// the image it lacks ([`floor_lacks_the_image`]).
|
||||
#[test]
|
||||
fn wide_gamut_client_pipelines_are_refused() {
|
||||
fn wide_gamut_client_pipelines_blend_the_codes_or_are_refused() {
|
||||
let Some(library) = library() else {
|
||||
return;
|
||||
};
|
||||
@@ -132,35 +188,55 @@ fn wide_gamut_client_pipelines_are_refused() {
|
||||
library.function(name).expect("function"),
|
||||
))
|
||||
};
|
||||
use vk::BlendFactor as V;
|
||||
use BlendFactor as F;
|
||||
let (sa, da) = (F::SourceAlpha, F::DestinationAlpha);
|
||||
let (msa, mda) = (F::OneMinusSourceAlpha, F::OneMinusDestinationAlpha);
|
||||
// Impeller's pipeline blends (source and destination, color then alpha) and straight
|
||||
// alpha-over.
|
||||
let blends: [(&str, [F; 4]); 12] = [
|
||||
("source-over", [F::One, msa, F::One, msa]),
|
||||
("straight-over", [sa, msa, F::One, msa]),
|
||||
("clear", [F::Zero, F::Zero, F::Zero, F::Zero]),
|
||||
("destination-over", [mda, F::One, mda, F::One]),
|
||||
("source-in", [da, F::Zero, da, F::Zero]),
|
||||
("destination-in", [F::Zero, sa, F::Zero, sa]),
|
||||
("source-out", [mda, F::Zero, mda, F::Zero]),
|
||||
("destination-out", [F::Zero, msa, F::Zero, msa]),
|
||||
("source-atop", [da, msa, da, msa]),
|
||||
("xor", [mda, msa, mda, msa]),
|
||||
("plus", [F::One, F::One, F::One, F::One]),
|
||||
("modulate", [F::Zero, F::SourceColor, F::Zero, sa]),
|
||||
let (s1, ms1) = (V::SRC1_ALPHA, V::ONE_MINUS_SRC1_ALPHA);
|
||||
// The compositing blends (source and destination, color then alpha) and straight
|
||||
// alpha-over, with Vulkan's destination factors (color, alpha) of `BGRA10_XR`'s, `None` where
|
||||
// it is refused.
|
||||
type Blend = (&'static str, [F; 4], Option<(V, V)>);
|
||||
let blends: [Blend; 12] = [
|
||||
("source-over", [F::One, msa, F::One, msa], Some((ms1, ms1))),
|
||||
("straight-over", [sa, msa, F::One, msa], Some((ms1, ms1))),
|
||||
(
|
||||
"clear",
|
||||
[F::Zero, F::Zero, F::Zero, F::Zero],
|
||||
Some((V::ZERO, V::ZERO)),
|
||||
),
|
||||
("destination-over", [mda, F::One, mda, F::One], None),
|
||||
("source-in", [da, F::Zero, da, F::Zero], None),
|
||||
("destination-in", [F::Zero, sa, F::Zero, sa], Some((s1, s1))),
|
||||
("source-out", [mda, F::Zero, mda, F::Zero], None),
|
||||
(
|
||||
"destination-out",
|
||||
[F::Zero, msa, F::Zero, msa],
|
||||
Some((ms1, ms1)),
|
||||
),
|
||||
("source-atop", [da, msa, da, msa], None),
|
||||
("xor", [mda, msa, mda, msa], None),
|
||||
(
|
||||
"plus",
|
||||
[F::One, F::One, F::One, F::One],
|
||||
Some((V::ONE, V::ONE)),
|
||||
),
|
||||
(
|
||||
"modulate",
|
||||
[F::Zero, F::SourceColor, F::Zero, sa],
|
||||
Some((V::SRC1_COLOR, s1)),
|
||||
),
|
||||
];
|
||||
let depth_stencil = [
|
||||
None,
|
||||
Some(PixelFormat::Stencil8),
|
||||
Some(PixelFormat::Depth32FloatStencil8),
|
||||
];
|
||||
let mut refused_count = 0;
|
||||
let (mut made_count, mut refused_count, mut floor_count) = (0, 0, 0);
|
||||
for stem in VENUES.into_iter().chain(["runtime-floor"]) {
|
||||
let dev = device(stem);
|
||||
for pf in FORMATS {
|
||||
for (name, factors) in blends {
|
||||
for (name, factors, codes) in blends {
|
||||
for mask in [ColorWriteMask::ALL, ColorWriteMask::NONE] {
|
||||
for ds in depth_stencil {
|
||||
for samples in [1, 4] {
|
||||
@@ -178,8 +254,39 @@ fn wide_gamut_client_pipelines_are_refused() {
|
||||
"{stem} {pf:?} {name} mask {} {ds:?} x{samples} {fill}",
|
||||
mask.as_raw()
|
||||
);
|
||||
refused(&dev, &d, &what);
|
||||
refused_count += 1;
|
||||
let codes = codes.filter(|_| pf == PixelFormat::BGRA10XR);
|
||||
let Some((color, alpha)) = codes else {
|
||||
refused(&dev, &d, &what);
|
||||
refused_count += 1;
|
||||
continue;
|
||||
};
|
||||
if stem == "runtime-floor" {
|
||||
match dev.compile_render_pipeline(&d, &Budget::standard()) {
|
||||
Err(Error::Unsupported(u)) => {
|
||||
floor_lacks_the_image(&u, &what)
|
||||
}
|
||||
other => panic!("{what}: {:?}", other.map(|_| ())),
|
||||
}
|
||||
floor_count += 1;
|
||||
continue;
|
||||
}
|
||||
let pipe =
|
||||
match dev.compile_render_pipeline(&d, &Budget::standard()) {
|
||||
Ok(pipe) => pipe,
|
||||
Err(e) => panic!("{what}: {e:?}"),
|
||||
};
|
||||
made_count += 1;
|
||||
let a = pipe.graphics.color_attachments[0].expect("attachment");
|
||||
assert_eq!(a.format, vk::Format::R16G16B16A16_UNORM, "{what}");
|
||||
let b = a.blend.expect("a blend");
|
||||
assert_eq!((b.src_color, b.src_alpha), (V::ONE, V::ONE), "{what}");
|
||||
assert_eq!((b.dst_color, b.dst_alpha), (color, alpha), "{what}");
|
||||
use vk::ColorComponentFlags as C;
|
||||
let fields = match mask == ColorWriteMask::ALL {
|
||||
true => C::R | C::G | C::B | C::A,
|
||||
false => C::empty(),
|
||||
};
|
||||
assert_eq!(a.write_mask, fields, "{what}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,15 +294,25 @@ fn wide_gamut_client_pipelines_are_refused() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Every shape at both sample counts on each venue.
|
||||
let shapes = FORMATS.len() * blends.len() * 2 * depth_stencil.len() * 2 * 2;
|
||||
assert_eq!(refused_count, (VENUES.len() + 1) * shapes);
|
||||
// Every shape at both sample counts on each venue: `BGRA10_XR`'s covered blends made but on
|
||||
// the floor, the rest refused.
|
||||
let per_blend = 2 * depth_stencil.len() * 2 * 2;
|
||||
let covered = blends.iter().filter(|b| b.2.is_some()).count();
|
||||
assert_eq!(made_count, VENUES.len() * covered * per_blend);
|
||||
assert_eq!(floor_count, covered * per_blend);
|
||||
let refused_blends = FORMATS.len() * blends.len() - covered;
|
||||
assert_eq!(
|
||||
refused_count,
|
||||
(VENUES.len() + 1) * refused_blends * per_blend
|
||||
);
|
||||
}
|
||||
|
||||
/// A pipeline without a fragment function and one whose function writes no color (depth alone)
|
||||
/// leave a blended attachment as it is, under every mask: no blend, an empty mask. An unblended
|
||||
/// mask of some of the format's channels is made, the mask of the fields, red and blue traded. A
|
||||
/// written blended attachment is refused under every mask (`refused`).
|
||||
/// mask of some of the format's channels is made, the mask of the fields, red and blue traded, in
|
||||
/// `BGRA10_XR`'s `R16G16B16A16_UNORM` image or its twin's raw `R16G16B16A16_UINT` one. A written
|
||||
/// blended attachment of the twin is refused under every mask (`refused`); `BGRA10_XR`'s blends
|
||||
/// are [`wide_gamut_client_pipelines_blend_the_codes_or_are_refused`]'s.
|
||||
#[test]
|
||||
fn unwritten_and_masked_extended_range_attachments_are_made() {
|
||||
let Some(library) = library() else {
|
||||
@@ -254,8 +371,11 @@ fn unwritten_and_masked_extended_range_attachments_are_made() {
|
||||
mask.as_raw()
|
||||
);
|
||||
let written = fragment == Some("rt6_fill_rgba16float");
|
||||
let codes = pf == PixelFormat::BGRA10XR;
|
||||
if blended && written {
|
||||
refused(&dev, &d, &what);
|
||||
if !codes {
|
||||
refused(&dev, &d, &what);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let Some(pipe) = made(stem, &dev, &d, &what) else {
|
||||
@@ -264,7 +384,11 @@ fn unwritten_and_masked_extended_range_attachments_are_made() {
|
||||
made_count += 1;
|
||||
let a = pipe.graphics.color_attachments[0].expect("attachment");
|
||||
assert!(a.blend.is_none(), "{what}");
|
||||
assert_eq!(a.format, vk::Format::R16G16B16A16_UINT, "{what}");
|
||||
let format = match codes {
|
||||
true => vk::Format::R16G16B16A16_UNORM,
|
||||
false => vk::Format::R16G16B16A16_UINT,
|
||||
};
|
||||
assert_eq!(a.format, format, "{what}");
|
||||
let expected = match written {
|
||||
false => C::empty(),
|
||||
true => fields,
|
||||
@@ -276,17 +400,23 @@ fn unwritten_and_masked_extended_range_attachments_are_made() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Every shape but the written blended ones, on the three venues of four samples, and
|
||||
// lavapipe's single-sampled half.
|
||||
let shapes = FORMATS.len() * (2 * masks.len() * fragments.len() - masks.len());
|
||||
assert_eq!(made_count, 3 * shapes * 2 + shapes);
|
||||
// Every shape but the written blended ones: `BGRA10_XR`'s on the four venues at both sample
|
||||
// counts, the twin's on the three venues of four samples and lavapipe's single-sampled half.
|
||||
let shapes = 2 * masks.len() * fragments.len() - masks.len();
|
||||
assert_eq!(made_count, 4 * shapes * 2 + (3 * shapes * 2 + shapes));
|
||||
}
|
||||
|
||||
/// On the runtime's floor (no `fragmentShaderPixelInterlock`), a written blended attachment of
|
||||
/// either format is refused `NotImplemented(Format)`, as on every device: no device would make it.
|
||||
/// The unwritten attachment, which takes no blend, is still made there.
|
||||
/// On the runtime's floor (no `fragmentShaderPixelInterlock`), a written blended `BGRA10_XR_sRGB`
|
||||
/// attachment is refused `NotImplemented(Format)`, as on every device: no device would make it.
|
||||
/// The floor does not require `R16G16B16A16_UNORM` as a blended color attachment, so a
|
||||
/// `BGRA10_XR` one under premultiplied source-over is refused naming it
|
||||
/// ([`floor_lacks_the_image`]). On the floor's description with it ([`with_the_unorm_image`]), it
|
||||
/// is made, its destination factors read from the second output (`dualSrcBlend`, which the floor
|
||||
/// requires); without `dualSrcBlend` too, it is refused naming the feature, and a blend of
|
||||
/// constant factors (plus) is still made. The unwritten attachment, which takes no blend, is made
|
||||
/// on both.
|
||||
#[test]
|
||||
fn the_floor_refuses_an_extended_range_blend_as_every_device_does() {
|
||||
fn the_floor_blends_bgra10_xr_codes_and_refuses_its_twin() {
|
||||
let Some(library) = library() else {
|
||||
return;
|
||||
};
|
||||
@@ -295,6 +425,8 @@ fn the_floor_refuses_an_extended_range_blend_as_every_device_does() {
|
||||
library.function(name).expect("function"),
|
||||
))
|
||||
};
|
||||
use crate::device::requirements::VkFeature;
|
||||
use crate::error::Capability;
|
||||
use BlendFactor as F;
|
||||
let over = [
|
||||
F::One,
|
||||
@@ -302,39 +434,79 @@ fn the_floor_refuses_an_extended_range_blend_as_every_device_does() {
|
||||
F::One,
|
||||
F::OneMinusSourceAlpha,
|
||||
];
|
||||
let wanted = Unsupported::not_implemented(Feature::Format);
|
||||
for stem in ["runtime-floor"] {
|
||||
let dev = device(stem);
|
||||
let plus = [F::One; 4];
|
||||
let stem = "runtime-floor";
|
||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../metal2vulkan-validation/profiles")
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let floor = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let mut desc = with_the_unorm_image(floor);
|
||||
let paired = Device::from_queries(desc.clone()).expect("device");
|
||||
assert!(
|
||||
desc.features.remove(&VkFeature::DualSrcBlend),
|
||||
"the floor's"
|
||||
);
|
||||
let single = Device::from_queries(desc).expect("device");
|
||||
let compile = |dev: &Device, pf: PixelFormat, factors: [F; 4], fill: Option<&str>| {
|
||||
let mut d = RenderPipelineDescriptor::new(function("rt6_fill_vertex"));
|
||||
d.fragment = fill.map(function);
|
||||
d.color_attachments[0] = Some(attachment(pf, Some(factors), ColorWriteMask::ALL));
|
||||
dev.compile_render_pipeline(&d, &Budget::standard())
|
||||
};
|
||||
for fill in ["rt6_fill_rgba16float", "rt6_fill_rgba32float"] {
|
||||
let what = format!("{stem} {fill}");
|
||||
match compile(&device(stem), PixelFormat::BGRA10XR, over, Some(fill)) {
|
||||
Err(Error::Unsupported(u)) => floor_lacks_the_image(&u, &what),
|
||||
other => panic!("{what}: {:?}", other.map(|_| ())),
|
||||
}
|
||||
}
|
||||
for (dev, dual) in [(paired, true), (single, false)] {
|
||||
for pf in FORMATS {
|
||||
for fill in ["rt6_fill_rgba16float", "rt6_fill_rgba32float"] {
|
||||
let mut d = RenderPipelineDescriptor::new(function("rt6_fill_vertex"));
|
||||
d.fragment = Some(function(fill));
|
||||
d.color_attachments[0] = Some(attachment(pf, Some(over), ColorWriteMask::ALL));
|
||||
let what = format!("{stem} {pf:?} {fill}");
|
||||
match dev.compile_render_pipeline(&d, &Budget::standard()) {
|
||||
Err(Error::Unsupported(u)) => {
|
||||
let what = format!("{stem} dual {dual} {pf:?} {fill}");
|
||||
let made = compile(&dev, pf, over, Some(fill));
|
||||
match (pf, dual, made) {
|
||||
(PixelFormat::BGRA10XR, true, Ok(pipe)) => {
|
||||
let a = pipe.graphics.color_attachments[0].expect("attachment");
|
||||
let b = a.blend.expect("a blend");
|
||||
assert_eq!(b.dst_color, vk::BlendFactor::ONE_MINUS_SRC1_ALPHA, "{what}");
|
||||
}
|
||||
(PixelFormat::BGRA10XR, false, Err(Error::Unsupported(u))) => {
|
||||
let wanted = Unsupported::needs(
|
||||
Feature::DualSourceBlending,
|
||||
Capability::Feature(VkFeature::DualSrcBlend),
|
||||
);
|
||||
assert_eq!(u.feature, wanted.feature, "{what}: {u:?}");
|
||||
assert_eq!(u.needs, wanted.needs, "{what}: {u:?}");
|
||||
}
|
||||
other => panic!("{what}: {other:?}"),
|
||||
(_, _, Err(Error::Unsupported(u))) if pf != PixelFormat::BGRA10XR => {
|
||||
assert_eq!(u.feature, Feature::Format, "{what}: {u:?}");
|
||||
assert_eq!(u.needs, Needs::NotImplemented, "{what}: {u:?}");
|
||||
}
|
||||
(_, _, other) => panic!("{what}: {:?}", other.map(|_| ())),
|
||||
}
|
||||
if pf == PixelFormat::BGRA10XR {
|
||||
let pipe = compile(&dev, pf, plus, Some(fill))
|
||||
.unwrap_or_else(|e| panic!("{what} plus: {e:?}"));
|
||||
let a = pipe.graphics.color_attachments[0].expect("attachment");
|
||||
let b = a.blend.expect("a blend");
|
||||
assert_eq!(b.dst_color, vk::BlendFactor::ONE, "{what} plus");
|
||||
}
|
||||
}
|
||||
let mut d = RenderPipelineDescriptor::new(function("rt6_fill_vertex"));
|
||||
d.color_attachments[0] = Some(attachment(pf, Some(over), ColorWriteMask::ALL));
|
||||
let pipe = dev
|
||||
.compile_render_pipeline(&d, &Budget::standard())
|
||||
.unwrap_or_else(|e| panic!("{stem} {pf:?} unwritten: {e:?}"));
|
||||
let pipe = compile(&dev, pf, over, None)
|
||||
.unwrap_or_else(|e| panic!("{stem} dual {dual} {pf:?} unwritten: {e:?}"));
|
||||
let a = pipe.graphics.color_attachments[0].expect("attachment");
|
||||
assert!(
|
||||
a.blend.is_none() && a.write_mask.is_empty(),
|
||||
"{stem} {pf:?}"
|
||||
"{stem} dual {dual} {pf:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An unblended write of some of the codes one word holds (`BGR10_XR`'s and its twin's word, the
|
||||
/// two-plane forms' color word: `color_writes::merged_extended`), which no mask of the raw
|
||||
/// An unblended write of some of the codes one word holds (`BGR10_XR_sRGB`'s word, the two-plane
|
||||
/// forms' color word: `color_writes::merged_extended`), which no mask of the raw
|
||||
/// components gives, from a `half4` output and a `float4` one, is refused
|
||||
/// `NotImplemented(FramebufferFetch)` on every device here, lavapipe and the floor included: the
|
||||
/// merge over an ordered read of the attachment is not built. At four samples a device that lacks
|
||||
@@ -350,7 +522,6 @@ fn a_mask_of_some_codes_of_a_word_is_refused_on_every_device() {
|
||||
))
|
||||
};
|
||||
let formats = [
|
||||
PixelFormat::BGR10XR,
|
||||
PixelFormat::BGR10XRSRGB,
|
||||
PixelFormat::RGB10A82PXR10,
|
||||
PixelFormat::RGB10A82PXR10SRGB,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
//! Extended-range render targets: a fragment function's `float` or `half` output to an attachment
|
||||
//! of one of Apple's extended-range formats is written as the raw texel Metal stores, and the
|
||||
//! attachment holds the format's raw texels.
|
||||
//! of one of Apple's extended-range formats held raw is written as the raw texel Metal stores, and
|
||||
//! the attachment holds the format's raw texels; to a `BGR10_XR` or `BGRA10_XR` attachment, held
|
||||
//! as the UNORM codes of its bits, as the codes' fractions
|
||||
//! ([`fragment_outputs_to_unorm_targets_write_codes`]).
|
||||
//!
|
||||
//! - On every committed profile, a fragment function compiled for a pipeline with such an
|
||||
//! attachment (`rt6_fill_rgba32float`, `rt6_fill_rgba16float`) records the attachment
|
||||
@@ -45,14 +47,12 @@ const VENUES: [&str; 5] = [
|
||||
"nvidia-rtx5080-laptop",
|
||||
];
|
||||
|
||||
/// The six formats and their forms.
|
||||
const FORMATS: [(PixelFormat, ExtendedRange); 6] = [
|
||||
(PixelFormat::BGR10XR, ExtendedRange::Bgr10 { srgb: false }),
|
||||
/// The four formats held raw and their forms.
|
||||
const FORMATS: [(PixelFormat, ExtendedRange); 4] = [
|
||||
(
|
||||
PixelFormat::BGR10XRSRGB,
|
||||
ExtendedRange::Bgr10 { srgb: true },
|
||||
),
|
||||
(PixelFormat::BGRA10XR, ExtendedRange::Bgra10 { srgb: false }),
|
||||
(
|
||||
PixelFormat::BGRA10XRSRGB,
|
||||
ExtendedRange::Bgra10 { srgb: true },
|
||||
@@ -99,7 +99,7 @@ fn pipeline_of(pf: PixelFormat, mask: ColorWriteMask, blended: bool) -> RenderLi
|
||||
|
||||
/// The form an attachment of `pf` is held in.
|
||||
fn form_of(pf: PixelFormat) -> ExtendedRange {
|
||||
ExtendedRange::of_attachment(pf).expect("an extended-range format")
|
||||
ExtendedRange::of(pf).expect("an extended-range format")
|
||||
}
|
||||
|
||||
fn render(r: &RenderLinkInputs) -> LinkInputs {
|
||||
@@ -213,6 +213,139 @@ fn fragment_outputs_to_extended_range_targets_write_raw_texels() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The fixture's `float4` and `half4` fills compile for a `BGR10_XR` and a `BGRA10_XR` attachment
|
||||
/// on every venue: the function records the attachment (`StageIo::extended_unorm_colors`), keeps
|
||||
/// its interface variable's Metal type, declares four `float`s, and links with the UNORM image's
|
||||
/// format, Metal's mask on its channels (`BGRA10_XR`'s red and blue traded; `BGR10_XR`'s alpha
|
||||
/// bits written with its codes) and no blend, both modules passing L3. Under premultiplied
|
||||
/// source-over, either format blends with Vulkan's source factor one over one minus the source
|
||||
/// alpha, which it reads from a second output the function writes, Metal's channels in the image's
|
||||
/// (every venue blends dual-source), `BGR10_XR`'s alpha bits written as ones; a blend reading
|
||||
/// `BGRA10_XR`'s destination alpha is refused `NotImplemented(Format)`.
|
||||
#[test]
|
||||
fn fragment_outputs_to_unorm_targets_write_codes() {
|
||||
use crate::metal::BlendFactor as F;
|
||||
use crate::pipeline::lower_inputs::{ExtendedUnormBlend, ExtendedUnormColor, FactorLane};
|
||||
use vk::BlendFactor as V;
|
||||
use vk::ColorComponentFlags as C;
|
||||
let Some(bc) = fixture() else {
|
||||
return;
|
||||
};
|
||||
let masks = [
|
||||
ColorWriteMask::ALL,
|
||||
ColorWriteMask::NONE,
|
||||
ColorWriteMask::RED,
|
||||
ColorWriteMask::BLUE.union(ColorWriteMask::GREEN),
|
||||
ColorWriteMask::ALPHA,
|
||||
];
|
||||
for stem in VENUES {
|
||||
let p = venue(stem);
|
||||
assert!(p.fields().fragment.dual_src_blend, "{stem}");
|
||||
let v = compile(&bc, "rt6_fill_vertex", &p).expect("vertex");
|
||||
for pf in [PixelFormat::BGR10XR, PixelFormat::BGRA10XR] {
|
||||
let four = pf == PixelFormat::BGRA10XR;
|
||||
for entry in ["rt6_fill_rgba32float", "rt6_fill_rgba16float"] {
|
||||
for mask in masks {
|
||||
let what = format!("{stem} {entry} {pf:?} {mask:?}");
|
||||
let r = pipeline_of(pf, mask, false);
|
||||
let inputs = fragment_inputs(&r, &p);
|
||||
let f = compile_with(&bc, entry, &p, &inputs)
|
||||
.unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
assert_eq!(
|
||||
f.interface.io.extended_unorm_colors,
|
||||
BTreeMap::from([(0, ExtendedUnormColor::new(pf))]),
|
||||
"{what}"
|
||||
);
|
||||
let l = link(&[&v, &f], &render(&r), &p)
|
||||
.unwrap_or_else(|e| panic!("{what}: link: {e}"));
|
||||
let a = l.graphics.as_ref().expect("graphics").color_attachments[0]
|
||||
.expect("attachment");
|
||||
let format = match four {
|
||||
true => vk::Format::R16G16B16A16_UNORM,
|
||||
false => vk::Format::A2R10G10B10_UNORM_PACK32,
|
||||
};
|
||||
assert_eq!(a.format, format, "{what}");
|
||||
let want = match (four, mask) {
|
||||
(_, m) if m == ColorWriteMask::NONE => C::empty(),
|
||||
(_, m) if m == ColorWriteMask::ALL => C::R | C::G | C::B | C::A,
|
||||
(true, m) if m == ColorWriteMask::RED => C::B,
|
||||
(true, m) if m == ColorWriteMask::ALPHA => C::A,
|
||||
(true, _) => C::R | C::G,
|
||||
(false, m) if m == ColorWriteMask::RED => C::R | C::A,
|
||||
(false, m) if m == ColorWriteMask::ALPHA => C::empty(),
|
||||
(false, _) => C::G | C::B | C::A,
|
||||
};
|
||||
assert_eq!(a.write_mask, want, "{what}");
|
||||
assert!(a.blend.is_none(), "{what}");
|
||||
for s in [&*v, &*f] {
|
||||
let w = relocate(s, &l.table).expect("relocate");
|
||||
check_words_valid(&w, &s.requirements, &p)
|
||||
.unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
}
|
||||
}
|
||||
// Premultiplied source-over, and destination-over, which reads the destination's
|
||||
// alpha.
|
||||
for (name, factors) in [
|
||||
("over", [F::One, F::OneMinusSourceAlpha]),
|
||||
("destination-over", [F::OneMinusDestinationAlpha, F::One]),
|
||||
] {
|
||||
let what = format!("{stem} {entry} {pf:?} {name}");
|
||||
let mut r = pipeline_of(pf, ColorWriteMask::ALL, true);
|
||||
let c = r.color_attachments[0].as_mut().expect("attachment");
|
||||
c.source_rgb_blend_factor = factors[0];
|
||||
c.destination_rgb_blend_factor = factors[1];
|
||||
c.source_alpha_blend_factor = factors[0];
|
||||
c.destination_alpha_blend_factor = factors[1];
|
||||
let inputs = fragment_inputs(&r, &p);
|
||||
let compiled = compile_with(&bc, entry, &p, &inputs);
|
||||
if four && name == "destination-over" {
|
||||
let e = compiled.expect_err("refused");
|
||||
assert!(is_format_refusal(&e), "{what}: {e:?}");
|
||||
continue;
|
||||
}
|
||||
let f = compiled.unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
let blend = ExtendedUnormBlend::of(r.color_attachments[0].as_ref().unwrap());
|
||||
assert_eq!(
|
||||
f.interface.io.extended_unorm_colors,
|
||||
BTreeMap::from([(0, ExtendedUnormColor::new(pf).with_blend(blend))]),
|
||||
"{what}"
|
||||
);
|
||||
let l = link(&[&v, &f], &render(&r), &p)
|
||||
.unwrap_or_else(|e| panic!("{what}: link: {e}"));
|
||||
let a = l.graphics.as_ref().expect("graphics").color_attachments[0]
|
||||
.expect("attachment");
|
||||
let b = a.blend.expect("a blend");
|
||||
assert_eq!(b.src_color, V::ONE, "{what}");
|
||||
let (dst, lanes) = match (four, name) {
|
||||
(true, _) => (
|
||||
V::ONE_MINUS_SRC1_ALPHA,
|
||||
Some([2, 1, 0, 3].map(FactorLane::Output)),
|
||||
),
|
||||
(false, "over") => (
|
||||
V::ONE_MINUS_SRC1_ALPHA,
|
||||
Some([0, 1, 2, 3].map(FactorLane::Output)),
|
||||
),
|
||||
(false, _) => (V::ONE, None),
|
||||
};
|
||||
let mask = C::R | C::G | C::B | C::A;
|
||||
assert_eq!(b.dst_color, dst, "{what}");
|
||||
assert_eq!(a.write_mask, mask, "{what}");
|
||||
assert_eq!(
|
||||
f.interface.io.rotated_factors.get(&0).copied(),
|
||||
lanes,
|
||||
"{what}"
|
||||
);
|
||||
for s in [&*v, &*f] {
|
||||
let w = relocate(s, &l.table).expect("relocate");
|
||||
check_words_valid(&w, &s.requirements, &p)
|
||||
.unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A bfloat attachment (`R16Bfloat`, `RG16Bfloat`, `RGBA16Bfloat`) takes the fixture's `float4`
|
||||
/// and `half4` fills on every venue at either `textureWriteRoundingMode`: the function records
|
||||
/// the attachment with the mode's rounding (`ExtendedRangeColor::nearest_even`), declares the raw
|
||||
|
||||
@@ -463,6 +463,7 @@ fn a_fetched_extended_range_attachment_is_refused() {
|
||||
);
|
||||
inputs.extended_range_colors =
|
||||
crate::pipeline::color_writes::extended_range_colors(colors, Default::default());
|
||||
inputs.extended_unorm_colors = crate::pipeline::color_writes::extended_unorm_colors(colors);
|
||||
inputs
|
||||
};
|
||||
let refused = |r: Result<std::sync::Arc<crate::library::FunctionArtifact>, Error>,
|
||||
|
||||
@@ -2494,6 +2494,14 @@ field metal2vulkan::pipeline::EntryPlan.strategies pub strategies: BTreeMap<Stri
|
||||
field metal2vulkan::pipeline::ExtendedRangeColor.blended pub blended: bool
|
||||
field metal2vulkan::pipeline::ExtendedRangeColor.form pub form: metal::format::ExtendedRange
|
||||
field metal2vulkan::pipeline::ExtendedRangeColor.nearest_even pub nearest_even: bool
|
||||
field metal2vulkan::pipeline::ExtendedUnormBlend.alpha_operation pub alpha_operation: metal::BlendOperation
|
||||
field metal2vulkan::pipeline::ExtendedUnormBlend.destination_alpha pub destination_alpha: metal::BlendFactor
|
||||
field metal2vulkan::pipeline::ExtendedUnormBlend.destination_rgb pub destination_rgb: metal::BlendFactor
|
||||
field metal2vulkan::pipeline::ExtendedUnormBlend.rgb_operation pub rgb_operation: metal::BlendOperation
|
||||
field metal2vulkan::pipeline::ExtendedUnormBlend.source_alpha pub source_alpha: metal::BlendFactor
|
||||
field metal2vulkan::pipeline::ExtendedUnormBlend.source_rgb pub source_rgb: metal::BlendFactor
|
||||
field metal2vulkan::pipeline::ExtendedUnormColor.blend pub blend: Option<ExtendedUnormBlend>
|
||||
field metal2vulkan::pipeline::ExtendedUnormColor.pixel_format pub pixel_format: metal::PixelFormat
|
||||
field metal2vulkan::pipeline::FunctionDescriptor.constants pub constants: FunctionConstantValues
|
||||
field metal2vulkan::pipeline::FunctionDescriptor.function pub function: Function
|
||||
field metal2vulkan::pipeline::FunctionDescriptor.libraries pub libraries: DynamicLibraries
|
||||
@@ -2556,6 +2564,7 @@ field metal2vulkan::pipeline::LoweringInputs.dropped_colors pub dropped_colors:
|
||||
field metal2vulkan::pipeline::LoweringInputs.emulated_simdgroups pub emulated_simdgroups: bool
|
||||
field metal2vulkan::pipeline::LoweringInputs.extended_range pub extended_range: BTreeMap<SlotRef, metal::format::ExtendedRange>
|
||||
field metal2vulkan::pipeline::LoweringInputs.extended_range_colors pub extended_range_colors: BTreeMap<u32, ExtendedRangeColor>
|
||||
field metal2vulkan::pipeline::LoweringInputs.extended_unorm_colors pub extended_unorm_colors: BTreeMap<u32, ExtendedUnormColor>
|
||||
field metal2vulkan::pipeline::LoweringInputs.flat_grid pub flat_grid: bool
|
||||
field metal2vulkan::pipeline::LoweringInputs.folded_groups pub folded_groups: bool
|
||||
field metal2vulkan::pipeline::LoweringInputs.indirect_range pub indirect_range: bool
|
||||
@@ -2913,6 +2922,7 @@ fn metal2vulkan::metal::format::byte_format pub fn byte_format(pf: PixelFormat)
|
||||
fn metal2vulkan::metal::format::color_record pub fn color_record(formats: &[Option<PixelFormat>]) -> Option<Vec<Option<(u32, u32)>>>
|
||||
fn metal2vulkan::metal::format::copies_only pub fn copies_only(pf: PixelFormat) -> bool
|
||||
fn metal2vulkan::metal::format::direct_format pub fn direct_format(pf: PixelFormat) -> Option<vk::Format>
|
||||
fn metal2vulkan::metal::format::extended_unorm_clear pub fn extended_unorm_clear(pf: PixelFormat, rgba: [f64; 4]) -> Option<[f32; 4]>
|
||||
fn metal2vulkan::metal::format::footprint pub fn footprint(pf: PixelFormat) -> Option<Footprint>
|
||||
fn metal2vulkan::metal::format::image_type pub fn image_type(ty: TextureType) -> Option<(vk::ImageType, vk::ImageCreateFlags)>
|
||||
fn metal2vulkan::metal::format::image_view_type pub fn image_view_type(ty: TextureType) -> Option<vk::ImageViewType>
|
||||
@@ -6605,6 +6615,9 @@ method metal2vulkan::pipeline::DynamicLibraries::with_preloaded pub fn with_prel
|
||||
method metal2vulkan::pipeline::EntryDescriptor::new pub fn new(bitcode: &'a [u8], entry: EntryRef<'a>) -> EntryDescriptor<'a>
|
||||
method metal2vulkan::pipeline::ExtendedRangeColor::new pub fn new(form: metal::format::ExtendedRange, blended: bool) -> ExtendedRangeColor
|
||||
method metal2vulkan::pipeline::ExtendedRangeColor::with_rounding pub fn with_rounding(self, rounding: metal::TextureWriteRoundingMode) -> ExtendedRangeColor
|
||||
method metal2vulkan::pipeline::ExtendedUnormBlend::of pub fn of(c: &crate::pipeline::ColorAttachmentDescriptor) -> ExtendedUnormBlend
|
||||
method metal2vulkan::pipeline::ExtendedUnormColor::new pub fn new(pixel_format: metal::PixelFormat) -> ExtendedUnormColor
|
||||
method metal2vulkan::pipeline::ExtendedUnormColor::with_blend pub fn with_blend(self, blend: ExtendedUnormBlend) -> ExtendedUnormColor
|
||||
method metal2vulkan::pipeline::FunctionDescriptor::needs_specialization pub fn needs_specialization(&self, budget: &Budget, entries: &StageEntries) -> Result<bool, Error>
|
||||
method metal2vulkan::pipeline::FunctionDescriptor::new pub fn new(function: Function) -> FunctionDescriptor
|
||||
method metal2vulkan::pipeline::FunctionDescriptor::with_libraries pub fn with_libraries(mut self, libraries: DynamicLibraries) -> FunctionDescriptor
|
||||
@@ -7115,6 +7128,8 @@ struct metal2vulkan::pipeline::EntryDescriptor #[derive(Clone, Debug)] #[non_exh
|
||||
struct metal2vulkan::pipeline::EntryPlan #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct EntryPlan
|
||||
struct metal2vulkan::pipeline::ExecutionCounts #[derive(Clone, Copy, Debug)] pub struct ExecutionCounts
|
||||
struct metal2vulkan::pipeline::ExtendedRangeColor #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct ExtendedRangeColor
|
||||
struct metal2vulkan::pipeline::ExtendedUnormBlend #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct ExtendedUnormBlend
|
||||
struct metal2vulkan::pipeline::ExtendedUnormColor #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct ExtendedUnormColor
|
||||
struct metal2vulkan::pipeline::FunctionDescriptor #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct FunctionDescriptor
|
||||
struct metal2vulkan::pipeline::FunctionHandle #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct FunctionHandle(u32)
|
||||
struct metal2vulkan::pipeline::GraphicsState #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct GraphicsState
|
||||
@@ -8645,6 +8660,8 @@ variant metal2vulkan-runtime::PrecisionNote::DeviceSignedZeroInfNan DeviceSigned
|
||||
variant metal2vulkan-runtime::PrecisionNote::DeviceTexelConversion DeviceTexelConversion
|
||||
variant metal2vulkan-runtime::PrecisionNote::DeviceTranscendentals DeviceTranscendentals
|
||||
variant metal2vulkan-runtime::PrecisionNote::DeviceVertexConversion DeviceVertexConversion
|
||||
variant metal2vulkan-runtime::PrecisionNote::ExtendedRangeBlend ExtendedRangeBlend
|
||||
variant metal2vulkan-runtime::PrecisionNote::ExtendedRangeBlendWindow ExtendedRangeBlendWindow
|
||||
variant metal2vulkan-runtime::PrecisionNote::ExtrapolatedInterpolation ExtrapolatedInterpolation
|
||||
variant metal2vulkan-runtime::PrecisionNote::F16FmaDoubleRounding F16FmaDoubleRounding
|
||||
variant metal2vulkan-runtime::PrecisionNote::F16IntConvDoubleRounding F16IntConvDoubleRounding
|
||||
@@ -10039,6 +10056,8 @@ variant metal2vulkan::pipeline::PrecisionNote::DeviceSignedZeroInfNan DeviceSign
|
||||
variant metal2vulkan::pipeline::PrecisionNote::DeviceTexelConversion DeviceTexelConversion
|
||||
variant metal2vulkan::pipeline::PrecisionNote::DeviceTranscendentals DeviceTranscendentals
|
||||
variant metal2vulkan::pipeline::PrecisionNote::DeviceVertexConversion DeviceVertexConversion
|
||||
variant metal2vulkan::pipeline::PrecisionNote::ExtendedRangeBlend ExtendedRangeBlend
|
||||
variant metal2vulkan::pipeline::PrecisionNote::ExtendedRangeBlendWindow ExtendedRangeBlendWindow
|
||||
variant metal2vulkan::pipeline::PrecisionNote::ExtrapolatedInterpolation ExtrapolatedInterpolation
|
||||
variant metal2vulkan::pipeline::PrecisionNote::F16FmaDoubleRounding F16FmaDoubleRounding
|
||||
variant metal2vulkan::pipeline::PrecisionNote::F16IntConvDoubleRounding F16IntConvDoubleRounding
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -396,6 +396,8 @@ surface! {
|
||||
struct AmplificationDraws N;
|
||||
enum ChannelWrite N;
|
||||
struct ExtendedRangeColor N;
|
||||
struct ExtendedUnormBlend N;
|
||||
struct ExtendedUnormColor N;
|
||||
enum FactorLane N;
|
||||
enum KernelVariant N;
|
||||
struct LoweringInputs N;
|
||||
@@ -579,6 +581,7 @@ surface! {
|
||||
fn writes_dropped;
|
||||
fn ycbcr_renders;
|
||||
fn ycbcr_pass_refused;
|
||||
fn extended_unorm_clear;
|
||||
fn x_channel;
|
||||
fn bound_texel_format;
|
||||
fn integer_channels_word;
|
||||
|
||||
+56
-7
@@ -1028,11 +1028,31 @@ Where Metal's rules differ from Vulkan's, the pipeline gives Metal's answer:
|
||||
cannot take: none attached, or one of another numeric class than the read's
|
||||
(`InvalidDescriptor` at the color attachment), or one of a rotated, Y'CbCr or extended-range
|
||||
format (`Unsupported{Format}`). A read of one of Apple's extended-range formats (`BGR10_XR`,
|
||||
`BGRA10_XR`, `RGB10A8_2P_XR10` and their `_sRGB` twins), and a blend into one, are refused on
|
||||
every device (`Unsupported{Format}` at the color attachment): Metal's tile holds
|
||||
such an attachment as `half` through the render pass and rounds it to the codes only at the
|
||||
store, so a read or a blend after an earlier draw's write sees that draw's `half`, which the
|
||||
stored codes do not keep. An unblended write, under any write mask, is built. A write the
|
||||
`BGRA10_XR`, `RGB10A8_2P_XR10` and their `_sRGB` twins), and a blend into one but `BGR10_XR` and
|
||||
`BGRA10_XR`, are refused on every device (`Unsupported{Format}` at the color attachment):
|
||||
Metal's tile holds such an attachment as `half` through the render pass and rounds it to the
|
||||
codes only at the store, so a read or a blend after an earlier draw's write sees that draw's
|
||||
`half`, which the stored codes do not keep. An unblended write, under any write mask, is built.
|
||||
A `BGR10_XR` or `BGRA10_XR` attachment is the UNORM image of its bits: the function writes each
|
||||
channel as the code Metal stores (its `float` output rounded to `half`, nearest even, then a
|
||||
kernel write's code) as its field's value a little up over the field's maximum (a quarter of a
|
||||
16-bit field's unit, 1/2000 of a 10-bit code), which a device's conversion to nearest, toward
|
||||
zero, or through 16 bits stores as the code (`BGRA10_XR`'s six low bits zero, `BGR10_XR`'s two
|
||||
top bits ones), Metal's mask applies to the image's channels, a clear stores the code of the
|
||||
clear color through `half` (Metal clears a plain private target of 16 by 16 in a pass with no
|
||||
draw from the `float`, another code at a tie and at a NaN), and a resolve averages the codes.
|
||||
Where the pipeline blends there, the function first clamps the output as Metal's blend clamps its
|
||||
source (measured: each color channel to the values of codes 0 and 1022, a NaN to code 0's, alpha
|
||||
to `[0, 1]`); a blend of one and zero, added, then stores the clamped output's codes, as Metal's
|
||||
does. Another blend is Vulkan's blend of the codes with a source factor of one, the function
|
||||
writing `X = (Fs v + (1 - Fd) 384/510) 510/m` under an addition (`(1 + Fd)` under a
|
||||
subtraction, `v` alone under a minimum or a maximum), Metal's source factor folded and its
|
||||
destination factor Vulkan's, from a second output (the source's alpha or colour, which needs
|
||||
dual-source blending at attachment 0) or a constant (`BGR10_XR`'s destination alpha, 1), with
|
||||
`PrecisionNote::ExtendedRangeBlend`, and with `PrecisionNote::ExtendedRangeBlendWindow` where
|
||||
`X` can leave `[0, 1]` for a source in Metal's range. A blend whose factors read the destination's colour,
|
||||
`BGRA10_XR`'s destination alpha, the blend colour or a second output of the function's own, or a
|
||||
reverse subtraction, is refused (`Unsupported{Format}` at the color attachment). A write the
|
||||
function would compute over its own read of the attachment, where no Vulkan blend or write mask
|
||||
gives Metal's, is not built (`Unsupported{FramebufferFetch}`, not implemented, on every device):
|
||||
a padded extended-range attachment's blend, a write of some of the codes one word of an
|
||||
@@ -1615,8 +1635,11 @@ category, and says what makes an operation carry the note and what may differ. E
|
||||
- `metal2vulkan-degrade-device-rounded-resolve` (precision). `DeviceRoundedResolve`: A multisample
|
||||
color resolve averages through Vulkan's `AVERAGE` mode, which leaves the rounding of the average
|
||||
(and the sRGB encoding) to the device: any
|
||||
color attachment but an extended-range one and one resolving into its format's sRGB twin (each
|
||||
resolved after the pass). Also, on every device, a resolve into an 8-bit UNORM attachment's
|
||||
color attachment but an extended-range one held raw and one resolving into its format's sRGB
|
||||
twin (each resolved after the pass); a `BGR10_XR` or `BGRA10_XR` attachment, held as the UNORM
|
||||
codes of its bits, averages its codes as the values average, a `BGRA10_XR` field keeping the
|
||||
average's fraction of a code in its six low bits, which Metal writes as zero (lavapipe: 146 of
|
||||
the 4,096 fields of `xr-gradient-bgra10xr-unblended-x4`, within 48 of a code's 64 steps). Also, on every device, a resolve into an 8-bit UNORM attachment's
|
||||
sRGB twin where the device has
|
||||
the sRGB format: the crate-owned resolve decodes the samples and encodes their average by the
|
||||
device's own sRGB conversions, where Metal's resolve takes its own 12-bit tables (with correctly
|
||||
@@ -2267,6 +2290,32 @@ category, and says what makes an operation carry the note and what may differ. E
|
||||
apart in its color and alpha arithmetic, as Apple's does, and the rotation moves Metal's blue into
|
||||
the image's alpha and Metal's alpha into its red, so a channel may store one code apart from
|
||||
Metal's.
|
||||
- `metal2vulkan-degrade-extended-range-blend` (precision). `PrecisionNote::ExtendedRangeBlend`: A
|
||||
fragment function writes a `BGR10_XR` or `BGRA10_XR` color attachment the pipeline blends by more
|
||||
than storing its source as it is (`LoweringInputs::extended_unorm_colors`). The device blends the
|
||||
image's UNORM codes, with a source term the function corrects so the blend is Metal's blend of
|
||||
the values, in its own precision, and rounds the result to the field at every draw, where Metal
|
||||
blends `half` values and its tile keeps them through the pass. Where the source term lies in the
|
||||
code range, a channel stores Metal's code or one beside it a draw: of 40,000 random single draws
|
||||
a blend, on `BGR10_XR`, straight alpha-over stored a code one from Metal's on 2,169 channels,
|
||||
destination-in on 1,296 and destination-out on 1,595; a `BGRA10_XR` field's six low bits, which
|
||||
Metal writes as zero and reads past, hold the blend's fraction of a code on about 98% of its
|
||||
channels. A destination code Metal's blend reads clamped (a color code 1023, an alpha code
|
||||
outside 384 to 894) is read as it is.
|
||||
- `metal2vulkan-degrade-extended-range-blend-window` (precision).
|
||||
`PrecisionNote::ExtendedRangeBlendWindow`: A `BGR10_XR` or `BGRA10_XR` color attachment's blend
|
||||
whose corrected source term can leave `[0, 1]` for a source in Metal's range, or whose
|
||||
destination factor Vulkan reads from a second output where Metal's value of it can leave
|
||||
`[0, 1]`, decided from the blend's factors and operations at the corners of the source's range.
|
||||
Vulkan clamps both to `[0, 1]`, so a source outside the window stores a code up to 386 from
|
||||
Metal's. An addition of one and one with a negative source, and premultiplied source-over with a
|
||||
source below `-0.7529` times its alpha, are outside it: on the conformance suite's random
|
||||
sources, 12,450 of 32,768 `BGRA10_XR` channels and 8,421 of 24,576 `BGR10_XR` ones under the
|
||||
addition, and 4,724 of 32,768 and 4,233 of 24,576 under premultiplied source-over, lie more than
|
||||
32 codes from Metal's, up to 386 (a model of the blend whose count of differing elements is
|
||||
lavapipe's replay's to within 11 of 32,768; the conformance ledger's rows). Straight alpha-over, a
|
||||
source factor of zero, a minimum and a maximum hold by construction, and premultiplied
|
||||
source-over of a premultiplied extended-range source stays inside the window.
|
||||
- `metal2vulkan-degrade-linked-sampler-numbering` (precision).
|
||||
`PrecisionNote::LinkedSamplerNumbering`: The sampler resource IDs a pipeline state takes for the
|
||||
constexpr samplers of the visible functions its stage links may be other than Metal's: two or more
|
||||
|
||||
@@ -43,7 +43,7 @@ Its limits, measured rather than asserted:
|
||||
| committed recordings | 1356 |
|
||||
| distinct SDK items the Metal leg reaches, of any status | 812 |
|
||||
| of those, reached only where this cannot name the family | 5 |
|
||||
| ledger rows (a case whose gap is recorded) | 8134 |
|
||||
| ledger rows (a case whose gap is recorded) | 8207 |
|
||||
| declared crossings of the option space (pairs put to Metal at once) | 26 |
|
||||
| declared crossings that are no pair of it (a boolean or numeric field, or one type in two slots) | 30 |
|
||||
|
||||
@@ -5369,6 +5369,75 @@ A case whose difference from Metal is recorded rather than compared away. The le
|
||||
| `texture-pairs-usage-crossings` | The device's own answer (rule 2): this device's format queries offer no image of MTLPixelFormatBC1_RGBA with the usage the case asks, so rt makes no such textur… |
|
||||
| `texture-pairs-usage-crossings` | The device's own answer (rule 2): this device's format queries offer no image of MTLPixelFormatBC1_RGBA with the usage the case asks, so rt makes no such textur… |
|
||||
| `vertex-fetch-past-4gib-small-buffer` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… |
|
||||
| `xr-blend-bgr10xr-add` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): an addition of one and one, wh… |
|
||||
| `xr-blend-bgr10xr-add` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-blend-bgr10xr-add` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-blend-bgr10xr-add` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-blend-bgr10xr-premul` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over, who… |
|
||||
| `xr-blend-bgr10xr-premul` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-blend-bgr10xr-premul` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-blend-bgr10xr-premul` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-blend-bgra10xr-add` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): an addition of one and one, wh… |
|
||||
| `xr-blend-bgra10xr-add` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-blend-bgra10xr-add` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-blend-bgra10xr-add` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-blend-bgra10xr-premul` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over, who… |
|
||||
| `xr-blend-bgra10xr-premul` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-blend-bgra10xr-premul` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-blend-bgra10xr-premul` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-float-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of t… |
|
||||
| `xr-gamut-bgra10xr-over-float-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-float-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-float-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-float-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of t… |
|
||||
| `xr-gamut-bgra10xr-over-float-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-float-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-float-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-half-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of t… |
|
||||
| `xr-gamut-bgra10xr-over-half-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-half-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-half-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-half-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of t… |
|
||||
| `xr-gamut-bgra10xr-over-half-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-half-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-half-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-half-x4-stencil` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of t… |
|
||||
| `xr-gamut-bgra10xr-over-half-x4-stencil` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-half-x4-stencil` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-over-half-x4-stencil` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-gamut-bgra10xr-straight-float-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md): straight alpha-over of the case's premultiplied extended-range sources, insi… |
|
||||
| `xr-gamut-bgra10xr-straight-float-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gamut-bgra10xr-straight-float-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gamut-bgra10xr-straight-float-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gamut-bgra10xr-straight-float-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md): straight alpha-over of the case's premultiplied extended-range sources, insi… |
|
||||
| `xr-gamut-bgra10xr-straight-float-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gamut-bgra10xr-straight-float-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gamut-bgra10xr-straight-float-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gamut-bgra10xr-straight-half-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md): straight alpha-over of the case's premultiplied extended-range sources, insi… |
|
||||
| `xr-gamut-bgra10xr-straight-half-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gamut-bgra10xr-straight-half-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gamut-bgra10xr-straight-half-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gamut-bgra10xr-straight-half-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md): straight alpha-over of the case's premultiplied extended-range sources, insi… |
|
||||
| `xr-gamut-bgra10xr-straight-half-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gamut-bgra10xr-straight-half-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gamut-bgra10xr-straight-half-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gradient-bgra10xr-blended-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md): premultiplied source-over of the gradient over the first draw, inside the wi… |
|
||||
| `xr-gradient-bgra10xr-blended-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gradient-bgra10xr-blended-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gradient-bgra10xr-blended-x1` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gradient-bgra10xr-blended-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md): premultiplied source-over of the gradient over the first draw, inside the wi… |
|
||||
| `xr-gradient-bgra10xr-blended-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gradient-bgra10xr-blended-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gradient-bgra10xr-blended-x4` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gradient-bgra10xr-unblended-x1` | The device's own arithmetic of the gradient (the device notes the case announces, `PrecisionNote::DeviceArithmetic` among them): an output a step of `half` from… |
|
||||
| `xr-gradient-bgra10xr-unblended-x4` | The device's average of the samples (`PrecisionNote::DeviceRoundedResolve`, docs/API.md): the resolve averages the four samples' 16-bit fields, keeping the aver… |
|
||||
| `xr-gradient-bgra10xr-unblended-x4` | The device's average of the samples (`PrecisionNote::DeviceRoundedResolve`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gradient-bgra10xr-unblended-x4` | The device's average of the samples (`PrecisionNote::DeviceRoundedResolve`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-gradient-bgra10xr-unblended-x4` | The device's average of the samples (`PrecisionNote::DeviceRoundedResolve`, docs/API.md), as the case's llvmpipe row records; the counts are this device's. |
|
||||
| `xr-masked-bgr10xr-red-over` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of a… |
|
||||
| `xr-masked-bgr10xr-red-over` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-masked-bgr10xr-red-over` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-masked-bgr10xr-red-over` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-masked-bgr10xr-srgb-blue-green` | refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The st… |
|
||||
| `xr-masked-bgr10xr-srgb-red` | refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The st… |
|
||||
| `xr-masked-bgr10xr-srgb-red-over` | refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The tr… |
|
||||
@@ -5378,6 +5447,10 @@ A case whose difference from Metal is recorded rather than compared away. The le
|
||||
| `xr-masked-bgr10xr-srgb-red-over` | refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The tr… |
|
||||
| `xr-masked-bgr10xr-srgb-red-over` | refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The tr… |
|
||||
| `xr-masked-bgr10xr-srgb-red-over` | refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The tr… |
|
||||
| `xr-masked-bgra10xr-rgb-over` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md): premultiplied source-over of a… |
|
||||
| `xr-masked-bgra10xr-rgb-over` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-masked-bgra10xr-rgb-over` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-masked-bgra10xr-rgb-over` | The device's blend of the codes (`PrecisionNote::ExtendedRangeBlend` and `PrecisionNote::ExtendedRangeBlendWindow`, docs/API.md), as the case's llvmpipe row rec… |
|
||||
| `xr-masked-bgra10xr-srgb-rgb-over` | refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The tr… |
|
||||
| `xr-masked-bgra10xr-srgb-rgb-over` | refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The tr… |
|
||||
| `xr-masked-bgra10xr-srgb-rgb-over` | refused: no stream uses it yet (rt play-report census 11-19: 158 rt reports across the matrix streams, no render pipeline refused for framebuffer fetch). The tr… |
|
||||
|
||||
+4
-4
@@ -87,7 +87,7 @@ Columns:
|
||||
| `ImageAtomics` | Image atomics beyond 32-bit integers | every device (not implemented) | `ours` | 1: `crates/metal2vulkan/src/lower/texture/atomic.rs (select)` | `rare`: texture atomics beyond 32-bit integers |
|
||||
| `DescriptorCount` | Too many descriptors of one kind in a stage or pipeline | devices short of a device limit the site names | `device` | 2: `crates/metal2vulkan/src/lower/select.rs (finish)`, `crates/metal2vulkan/src/pipeline/link.rs (limit_error)` | `app`: many textures or buffers in one stage on a smaller device |
|
||||
| `Float64Arithmetic` | 64-bit float arithmetic | devices without VkFeature::ShaderFloat64 | `device` | 2: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`, `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)` | `rare`: doubles (MSL has none outside Apple's own code) |
|
||||
| `Format` | A pixel or vertex format not supported for the required use | devices without VkFeature::ShaderStorageImageExtendedFormats; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`missing`); devices without a capability the site computes (`routes`); devices without a format's usage; every device (no Vulkan mechanism); every device (not implemented) | `ours` | 46: `crates/metal2vulkan/src/lower/access/tile.rs (storage_format)`, `crates/metal2vulkan/src/lower/fragment/color.rs (select_param, 5 sites)` (+24) | `system`: pixel formats a device lacks for a use (CoreVideo's 4:2:x and 10-bit formats among them) |
|
||||
| `Format` | A pixel or vertex format not supported for the required use | devices without VkFeature::ShaderStorageImageExtendedFormats; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`missing`); devices without a capability the site computes (`routes`); devices without a format's usage; every device (no Vulkan mechanism); every device (not implemented) | `ours` | 50: `crates/metal2vulkan/src/lower/access/tile.rs (storage_format)`, `crates/metal2vulkan/src/lower/fragment/color.rs (select_param, 6 sites)` (+26) | `system`: pixel formats a device lacks for a use (CoreVideo's 4:2:x and 10-bit formats among them) |
|
||||
| `DivergentImplicitLod` | Divergent implicit-LOD sampling or LOD query through a multi-candidate handle | every device (not implemented) | `ours` | 1: `crates/metal2vulkan/src/lower/sampler/select.rs (tangled)` | `app`: implicit-LOD sampling through a dynamically chosen texture |
|
||||
| `ImplicitLodOutsideFragment` | Implicit-LOD sampling outside fragment | every device (not implemented) | `ours` | 3: `crates/metal2vulkan/src/lower/sampler/constexpr.rs (query_min_level)`, `crates/metal2vulkan/src/lower/sampler/select.rs (query_level_measured)` (+1) | `rare`: implicit-LOD sampling outside fragment functions |
|
||||
| `MinLodClamp` | `min_lod_clamp` without `shaderResourceMinLod` | devices without VkFeature::ShaderResourceMinLod; every device (not implemented) | `ours` | 2: `crates/metal2vulkan/src/lower/sampler/select.rs (min_lod)`, `crates/metal2vulkan/src/lower/sampler/select.rs (select_one)` | `rare`: min_lod_clamp on a device without shaderResourceMinLod |
|
||||
@@ -109,7 +109,7 @@ Columns:
|
||||
| `VertexAmplification` | Vertex amplification | devices short of a Vulkan feature the site names; devices without VkFeature::Multiview; devices without VkFeature::MultiviewTessellationShader; every device (not implemented) | `ours` | 4: `crates/metal2vulkan/src/lower/stage_io/plan.rs (index_store)`, `crates/metal2vulkan/src/lower/tessellation/mod.rs (select_param)` (+2) | `rare`: vertex amplification |
|
||||
| `LayeredRendering` | Layered rendering (`render_target_array_index`, `viewport_array_index`) | devices short of a Vulkan feature the site names; devices without VkFeature::ShaderOutputLayer; devices without VkFeature::ShaderOutputViewportIndex | `device` | 3: `crates/metal2vulkan/src/lower/mesh/mod.rs (target_index, 2 sites)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (index_store)` | `rare`: layered rendering on a device without its features |
|
||||
| `ClipDistance` | Clip or cull distances | devices without VkFeature::ShaderClipDistance; devices without VkLimit::MaxClipDistances | `device` | 2: `crates/metal2vulkan/src/lower/mesh/mod.rs (select, 2 sites)` | `rare`: clip distances on a device without them |
|
||||
| `DualSourceBlending` | Dual-source blending | devices without VkFeature::DualSrcBlend; devices without VkLimit::MaxFragmentDualSrcAttachments | `device` | 3: `crates/metal2vulkan/src/metal/state.rs (blend_factor)`, `crates/metal2vulkan/src/pipeline/link/graphics.rs (check_outputs)` (+1) | `rare`: dual-source blending on a device without it |
|
||||
| `DualSourceBlending` | Dual-source blending | devices without VkFeature::DualSrcBlend; devices without VkLimit::MaxFragmentDualSrcAttachments | `device` | 4: `crates/metal2vulkan/src/metal/state.rs (blend_factor)`, `crates/metal2vulkan/src/pipeline/extended_blend.rs (extended_blend)` (+2) | `rare`: dual-source blending on a device without it |
|
||||
| `Barycentrics` | Barycentric coordinates | devices without VkFeature::FragmentShaderBarycentric | `device` | 2: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)` | `rare`: barycentric coordinates |
|
||||
| `StencilExport` | Stencil export | devices without VkExtension::ExtShaderStencilExport | `device` | 1: `crates/metal2vulkan/src/lower/stage_io/plan.rs (stencil_export_refused)` | `rare`: stencil from the shader |
|
||||
| `SampleRateShading` | Per-sample shading | devices without VkFeature::SampleRateShading; devices without a capability the site computes (`needs`); every device (not implemented) | `ours` | 3: `crates/metal2vulkan/src/pipeline/link/graphics.rs (sample_invocations, 3 sites)` | `rare`: per-sample shading |
|
||||
@@ -415,7 +415,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `feature::ImageAtomics`: `crates/metal2vulkan/src/lower/texture/atomic.rs (select)`
|
||||
- `feature::DescriptorCount`: `crates/metal2vulkan/src/lower/select.rs (finish)`; `crates/metal2vulkan/src/pipeline/link.rs (limit_error)`
|
||||
- `feature::Float64Arithmetic`: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)`
|
||||
- `feature::Format`: `crates/metal2vulkan/src/lower/access/tile.rs (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs (select_param, 5 sites)`; `crates/metal2vulkan/src/lower/sampler/select.rs (select_extended)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs (plan, 2 sites)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_image)`; `crates/metal2vulkan/src/lower/texture/slot.rs (atomic_format, 2 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs (storage_format, 6 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (ulong_format, 3 sites)`; `crates/metal2vulkan/src/lower/texture/words.rs (not_built)`; `crates/metal2vulkan/src/metal/format/mod.rs (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs (held_storage_choice, 3 sites)`; `crates/metal2vulkan/src/metal/format/mod.rs (storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs (vk_format, 2 sites)`; `crates/metal2vulkan/src/metal/vertex.rs (fetch_as, 2 sites)`; `crates/metal2vulkan/src/pipeline/color_writes.rs (rotated_blend_in_shader)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (extended_write_mask, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (graphics_state, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (reads_alpha_to_coverage, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (textured_fetches)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (alpha_in_red_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (rotated_blend)`
|
||||
- `feature::Format`: `crates/metal2vulkan/src/lower/access/tile.rs (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs (select_param, 6 sites)`; `crates/metal2vulkan/src/lower/sampler/select.rs (select_extended)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs (plan, 2 sites)`; `crates/metal2vulkan/src/lower/stage_io/extended_unorm_color.rs (plan, 2 sites)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_image)`; `crates/metal2vulkan/src/lower/texture/slot.rs (atomic_format, 2 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs (storage_format, 6 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (ulong_format, 3 sites)`; `crates/metal2vulkan/src/lower/texture/words.rs (not_built)`; `crates/metal2vulkan/src/metal/format/mod.rs (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs (held_storage_choice, 3 sites)`; `crates/metal2vulkan/src/metal/format/mod.rs (storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs (vk_format, 2 sites)`; `crates/metal2vulkan/src/metal/vertex.rs (fetch_as, 2 sites)`; `crates/metal2vulkan/src/pipeline/color_writes.rs (rotated_blend_in_shader)`; `crates/metal2vulkan/src/pipeline/extended_blend.rs (extended_blend)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (extended_write_mask, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (graphics_state, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (reads_alpha_to_coverage, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (textured_fetches)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (alpha_in_red_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (rotated_blend)`
|
||||
- `feature::DivergentImplicitLod`: `crates/metal2vulkan/src/lower/sampler/select.rs (tangled)`
|
||||
- `feature::ImplicitLodOutsideFragment`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs (query_min_level)`; `crates/metal2vulkan/src/lower/sampler/select.rs (query_level_measured)`; `crates/metal2vulkan/src/lower/sampler/select.rs (query_min_level)`
|
||||
- `feature::MinLodClamp`: `crates/metal2vulkan/src/lower/sampler/select.rs (min_lod)`; `crates/metal2vulkan/src/lower/sampler/select.rs (select_one)`
|
||||
@@ -436,7 +436,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `feature::VertexAmplification`: `crates/metal2vulkan/src/lower/stage_io/plan.rs (index_store)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs (select_param)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (vertex_amplification)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs (control_plan)`
|
||||
- `feature::LayeredRendering`: `crates/metal2vulkan/src/lower/mesh/mod.rs (target_index, 2 sites)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (index_store)`
|
||||
- `feature::ClipDistance`: `crates/metal2vulkan/src/lower/mesh/mod.rs (select, 2 sites)`
|
||||
- `feature::DualSourceBlending`: `crates/metal2vulkan/src/metal/state.rs (blend_factor)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (check_outputs)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (rotated_blend)`
|
||||
- `feature::DualSourceBlending`: `crates/metal2vulkan/src/metal/state.rs (blend_factor)`; `crates/metal2vulkan/src/pipeline/extended_blend.rs (extended_blend)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (check_outputs)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (rotated_blend)`
|
||||
- `feature::Barycentrics`: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)`
|
||||
- `feature::StencilExport`: `crates/metal2vulkan/src/lower/stage_io/plan.rs (stencil_export_refused)`
|
||||
- `feature::SampleRateShading`: `crates/metal2vulkan/src/pipeline/link/graphics.rs (sample_invocations, 3 sites)`
|
||||
|
||||
Reference in new issue
Block a user