🐛 Pass the host's IOSurface texture alignments to the guest
The guest's Metal device left iosurfaceTextureAlignmentBytes and iosurfaceReadOnlyTextureAlignmentBytes to the IOGPU base, which answers 16 from its own state, so the host's answer in the device info never reached the guest. CoreAnimation rounds the rows of its backing stores' IOSurfaces to iosurfaceTextureAlignmentBytes (to no less than 64 bytes) and names them to IOSurface, which keeps them. On RADV, which takes a linear image in place only at rows a multiple of 256 bytes, those 64- and 128-byte rows are the runtime's shadows. In a macOS 11.7.11 guest on a Radeon 780M, 1399 textures were shadows for their pitch over a cold boot and a 15 s Safari scroll, and 11 with the device answering 512. The device now answers both from the device info, which carries the Vulkan platform's answers. What the guest observes: since pin 37 the runtime answers the device's linear row alignment there, so on RADV (GFX9 to 11) the guest now sees 256 where it saw the base's 16, and CoreAnimation's backing stores take rows the host's GPU takes in place; on other GPUs it sees that GPU's linear row alignment. The device-info doc said an IOSurface's rows follow none of the device's answers; it now says which answers they follow.
This commit is contained in:
1 parent
6179228984
commit
18b642dab8
4 files changed
+45
-12
No files matched your search
@@ -359,16 +359,24 @@ fn lane_max_buffer_length(platform: Option<u64>, working_set: Option<u64>) -> Op
|
||||
/// dma-buf pages in place only with its rows a multiple of 256 bytes apart (metal2vulkan's
|
||||
/// `dma_buf.rs`, measured on Mesa 26.0.8 and 26.2.4), and shadows one at any other pitch; how many
|
||||
/// of a guest's textures this moves in place is unmeasured. Any 256-byte layout is one the
|
||||
/// platform's 16 takes too. An IOSurface's rows follow none of the device's answers: a surface made
|
||||
/// with no pitch named (`IOSurfaceCreate`, and CoreVideo's buffers and pools) takes rows at
|
||||
/// IOSurface's own alignment, `IOSurfaceGetPropertyAlignment(kIOSurfaceBytesPerRow)`, 64 bytes on
|
||||
/// the 5300M's Mac (macOS 26.7.1), whose device answers this 256 and
|
||||
/// `iosurfaceTextureAlignmentBytes` 16: 4032 bytes for 1001 `BGRA` pixels, 7360 for 1831 and 14656
|
||||
/// for 3662, the pitches metal2vulkan measured a macOS 26.7.2 guest's surfaces at on RADV. So on
|
||||
/// RADV a texture over such a surface at a pitch that is not a multiple of 256 is the runtime's
|
||||
/// shadow (its refused pitch), which no answer here moves in place: in two cold boots of that guest
|
||||
/// on a Radeon 780M, 583 and 639 textures over the guest's pages were shadows for their pitch,
|
||||
/// against 532 and 503 in place.
|
||||
/// platform's 16 takes too. An IOSurface's rows follow two other answers. A surface made with no
|
||||
/// pitch named (`IOSurfaceCreate`, and CoreVideo's buffers and pools) takes rows at IOSurface's own
|
||||
/// alignment, `IOSurfaceGetPropertyAlignment(kIOSurfaceBytesPerRow)`: 64 bytes on the 5300M's Mac
|
||||
/// (macOS 26.7.1), and here the device info's `linear_row_alignment` where the guest's kext raises
|
||||
/// it to that (256 bytes in macOS 11.7.11 and 14.8.9 guests on a Radeon 780M). CoreAnimation names
|
||||
/// the rows of its backing stores' surfaces itself, rounded to the device's
|
||||
/// `iosurfaceTextureAlignmentBytes` and to no less than 64 bytes, and IOSurface keeps them; the
|
||||
/// device answers the platform's `iosurfaceTextureAlignmentBytes` and
|
||||
/// `iosurfaceReadOnlyTextureAlignmentBytes` unchanged (the 5300M, the 630 and the M3 Max answer
|
||||
/// 16). So on RADV a texture over such a surface at a pitch that is not a multiple of 256 is the
|
||||
/// runtime's shadow (its refused pitch) where the platform answers less than 256 there: over a
|
||||
/// cold boot and a 15 s Safari scroll of a macOS 11.7.11 guest on a Radeon 780M, 1399 textures
|
||||
/// were shadows for their pitch with the platform's 16 (A8 rows of 64 and 128 bytes, a BGRA8
|
||||
/// surface 463 pixels wide at 1856), and 11 with the guest's device answering 512 there instead.
|
||||
/// metal2vulkan measured a macOS 26.7.2 guest's surfaces on RADV at 4032 bytes for 1001 `BGRA`
|
||||
/// pixels, 7360 for 1831 and 14656 for 3662, and in two cold boots of that guest on a Radeon 780M
|
||||
/// 583 and 639 textures over the guest's pages were shadows for their pitch, against 532 and 503
|
||||
/// in place.
|
||||
pub const LANE_LINEAR_TEXTURE_ALIGNMENT: u64 = 256;
|
||||
|
||||
/// The device's `NSUInteger` SPI answers where the lane's differ from the platform's: the linear
|
||||
|
||||
@@ -1269,6 +1269,25 @@ RGFX_LOG_UNRECOGNIZED
|
||||
return _caps.limit(kRgfxLimitDeviceLinearTextureAlignmentBytes);
|
||||
}
|
||||
|
||||
// The host's answers, the runtime's: the alignment its device takes a texture over an IOSurface's
|
||||
// rows at. The AMD 5300M, the Intel 630 and the M3 Max answer 16. CoreAnimation rounds the rows of
|
||||
// the IOSurfaces it makes for its backing stores to iosurfaceTextureAlignmentBytes, to no less
|
||||
// than 64 bytes, and names those rows to IOSurface, which keeps them: so this answer, not
|
||||
// IOSurface's own alignment, decides whether the host's GPU can take such a surface's texture in
|
||||
// place. Measured in a macOS 11.7.11 guest on a Radeon 780M: answering 16, A8 backing stores 125
|
||||
// pixels wide had rows of 128 bytes and 45 wide rows of 64; answering 512, a 1200-pixel BGRA8
|
||||
// surface's rows went from 4800 bytes to 5120, and of 1399 textures the runtime shadowed for their
|
||||
// rows over a 15 s scroll in Safari 11 were left. Left to the IOGPU base, these answered 16 there.
|
||||
- (NSUInteger)iosurfaceTextureAlignmentBytes
|
||||
{
|
||||
return _caps.limit(kRgfxLimitIOSurfaceTextureAlignmentBytes);
|
||||
}
|
||||
|
||||
- (NSUInteger)iosurfaceReadOnlyTextureAlignmentBytes
|
||||
{
|
||||
return _caps.limit(kRgfxLimitIOSurfaceReadOnlyTextureAlignmentBytes);
|
||||
}
|
||||
|
||||
- (MTLSize)sparseTileSizeWithTextureType:(MTLTextureType)textureType
|
||||
pixelFormat:(MTLPixelFormat)pixelFormat
|
||||
sampleCount:(NSUInteger)sampleCount
|
||||
|
||||
@@ -462,8 +462,8 @@ heapBufferSizeAndAlignWithLength:options: partial the host's heap buffer alignme
|
||||
heapTextureSizeAndAlignWithDescriptor: implemented
|
||||
indirectArgumentBufferCapabilities base %base-spi
|
||||
indirectArgumentBufferDecodingData base %base-spi
|
||||
iosurfaceReadOnlyTextureAlignmentBytes base %base-spi
|
||||
iosurfaceTextureAlignmentBytes base %base-spi
|
||||
iosurfaceReadOnlyTextureAlignmentBytes implemented
|
||||
iosurfaceTextureAlignmentBytes implemented
|
||||
isASTCPixelFormatsSupported base %base-spi
|
||||
isAnisoSampleFixSupported base %base-spi
|
||||
isBCTextureCompressionSupported base %base-spi
|
||||
|
||||
@@ -569,6 +569,8 @@ void test_caps()
|
||||
info.write_rounding_modes[1] = 1; // mode 2
|
||||
info.limits[kRgfxLimitDeviceLinearTextureAlignmentBytes] = 64;
|
||||
info.limits[kRgfxLimitLinearTextureAlignmentBytes] = 256;
|
||||
info.limits[kRgfxLimitIOSurfaceReadOnlyTextureAlignmentBytes] = 32;
|
||||
info.limits[kRgfxLimitIOSurfaceTextureAlignmentBytes] = 128;
|
||||
info.limits[kRgfxLimitMaxViewportCount] = 16; // last by position
|
||||
info.flags[kRgfxFlagAreRasterOrderGroupsSupported] = 1; // first by position
|
||||
info.flags[kRgfxFlagSupportsTileShaders] = 1; // last by position
|
||||
@@ -628,6 +630,10 @@ void test_caps()
|
||||
CHECK(caps.supportsWriteRoundingMode(2));
|
||||
CHECK(!caps.supportsWriteRoundingMode(1));
|
||||
CHECK(caps.limit(kRgfxLimitDeviceLinearTextureAlignmentBytes) == 64);
|
||||
// The IOSurface alignments the device answers, at their places between the linear ones.
|
||||
CHECK(caps.limit(kRgfxLimitIOSurfaceReadOnlyTextureAlignmentBytes) == 32);
|
||||
CHECK(caps.limit(kRgfxLimitIOSurfaceTextureAlignmentBytes) == 128);
|
||||
CHECK(caps.limit(kRgfxLimitLinearTextureAlignmentBytes) == 256);
|
||||
CHECK(caps.limit(kRgfxLimitMaxViewportCount) == 16);
|
||||
CHECK(caps.flag(kRgfxFlagAreRasterOrderGroupsSupported));
|
||||
CHECK(caps.flag(kRgfxFlagSupportsTileShaders));
|
||||
|
||||
Reference in new issue
Block a user