Serve a blit out of a plane whose GPU rows share bytes
The steps this packet landed as, in order: - Ask the read probe only for the plane form Metal makes - Re-derive the generated documents at the landing tip Content: the tree of `development` at 468e7db286, unchanged.
This commit is contained in:
1 parent
46d63b1354
commit
b31e26710b
7 files changed
+363
-23
No files matched your search
@@ -0,0 +1,215 @@
|
||||
// What Metal's `copyFromTexture:toBuffer:` reads out of an IOSurface plane whose GPU rows share
|
||||
// bytes, and whether it is the row copy's answer.
|
||||
//
|
||||
// `linear_plan.rs`'s **Rows that overlap** settles the write direction: Metal takes a plane at its
|
||||
// `bytesPerRow` rounded down to 16, so a plane whose pitch covers its own row but whose rounded
|
||||
// pitch falls below it has consecutive GPU rows 1 to 15 bytes apart in each other, and which row's
|
||||
// bytes survive a *write* has no single rule (423 processes: alternating by row parity at a pitch
|
||||
// of 16, three whole-plane answers over 23 processes for one shape). A *read* can have no such
|
||||
// race: two rows that overlap are read, not written, and the question is only which plane byte each
|
||||
// destination byte comes from.
|
||||
//
|
||||
// So this measures the read alone, over shapes that share bytes and controls that do not:
|
||||
//
|
||||
// 1. whether Metal makes the texture at all over a plane whose pitch is not a multiple of 16.
|
||||
// A surface with a plane dictionary is the only form it can be asked over: Metal's own
|
||||
// descriptor validation ends the process on one without ("IOSurface texture: bytesPerRow
|
||||
// (20) must be aligned to 16 bytes", `_mtlValidateStrideTextureParameters`, with no debug
|
||||
// layer set), which is the runtime's `Invalid(RowPitchAlignment)` for a flat surface, so the
|
||||
// flat form runs only where the pitch is aligned and shares nothing;
|
||||
// 2. whether IOSurface honours such a `bytesPerRow`, read back off the surface;
|
||||
// 3. for every destination texel, which plane word Metal read it from, against the row copy's
|
||||
// answer: destination row `y` from plane byte `max(bytesPerRow & ~15, 16) * y`.
|
||||
//
|
||||
// Every 4-byte word of the plane holds `0xB0000000 | k` for its own word index `k`, so a
|
||||
// destination word names the plane word Metal read, not merely that it differs; the destination
|
||||
// starts as `0xEEEEEEEE`, so an untouched word says so. One shape a process, the shape's index in
|
||||
// argv[1], since what Metal answers for a plane whose rows overlap was process-dependent for
|
||||
// writes.
|
||||
//
|
||||
// Nothing here writes a surface's bytes from the GPU, so no step can leave the plane racing.
|
||||
//
|
||||
// clang -fobjc-arc -framework Metal -framework Foundation -framework IOSurface \
|
||||
// -o overlapping_plane_row_reads overlapping_plane_row_reads.m
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <IOSurface/IOSurface.h>
|
||||
#import <Metal/Metal.h>
|
||||
|
||||
// The word every destination word starts as, which no plane word can be.
|
||||
static const uint32_t kUntouched = 0xEEEEEEEEu;
|
||||
// The high bits of a plane word, so a plane word is never mistaken for an untouched one.
|
||||
static const uint32_t kPlaneTag = 0xB0000000u;
|
||||
|
||||
// One shape: `w` x `h` BGRA8Unorm texels of a plane `bpr` bytes a row.
|
||||
struct Shape {
|
||||
size_t w;
|
||||
size_t h;
|
||||
size_t bpr;
|
||||
};
|
||||
|
||||
static const struct Shape kShapes[] = {
|
||||
// GPU rows that share bytes: the rounded pitch falls below the row.
|
||||
{5, 4, 20}, // pitch 16, row 20, 4 bytes shared
|
||||
{5, 2, 20}, // the same over two rows
|
||||
{5, 4, 28}, // pitch 16, row 20: the CPU's rows 28 apart, the GPU's 16
|
||||
{9, 4, 36}, // pitch 32, row 36, 4 bytes shared
|
||||
{7, 5, 28}, // pitch 16, row 28, 12 bytes shared
|
||||
// Controls whose GPU rows share nothing.
|
||||
{3, 3, 20}, // pitch 16, row 12
|
||||
{4, 4, 16}, // pitch 16, row 16
|
||||
};
|
||||
static const size_t kShapeCount = sizeof(kShapes) / sizeof(kShapes[0]);
|
||||
|
||||
// Where Metal's GPU is said to take a plane's rows: its `bytesPerRow` rounded down to 16, or 16
|
||||
// where that is 0.
|
||||
static size_t gpuPitch(size_t bpr) {
|
||||
size_t down = bpr - bpr % 16;
|
||||
return down == 0 ? 16 : down;
|
||||
}
|
||||
|
||||
// A surface of one `w` x `h` BGRA plane `bpr` bytes a row, with a plane dictionary (`planar`) or
|
||||
// without, every word naming its own index.
|
||||
static IOSurfaceRef makeSurface(size_t w, size_t h, size_t bpr, BOOL planar) {
|
||||
size_t length = bpr * h;
|
||||
NSMutableDictionary *properties = [@{
|
||||
(__bridge NSString *)kIOSurfaceWidth : @(w),
|
||||
(__bridge NSString *)kIOSurfaceHeight : @(h),
|
||||
(__bridge NSString *)kIOSurfaceBytesPerElement : @(4),
|
||||
(__bridge NSString *)kIOSurfacePixelFormat : @((uint32_t)'BGRA'),
|
||||
(__bridge NSString *)kIOSurfaceAllocSize : @(length),
|
||||
} mutableCopy];
|
||||
if (planar) {
|
||||
properties[(__bridge NSString *)kIOSurfacePlaneInfo] = @[ @{
|
||||
(__bridge NSString *)kIOSurfacePlaneWidth : @(w),
|
||||
(__bridge NSString *)kIOSurfacePlaneHeight : @(h),
|
||||
(__bridge NSString *)kIOSurfacePlaneBytesPerElement : @(4),
|
||||
(__bridge NSString *)kIOSurfacePlaneBytesPerRow : @(bpr),
|
||||
(__bridge NSString *)kIOSurfacePlaneOffset : @(0),
|
||||
(__bridge NSString *)kIOSurfacePlaneSize : @(length),
|
||||
} ];
|
||||
} else {
|
||||
properties[(__bridge NSString *)kIOSurfaceBytesPerRow] = @(bpr);
|
||||
}
|
||||
IOSurfaceRef surface = IOSurfaceCreate((__bridge CFDictionaryRef)properties);
|
||||
if (surface == NULL) { return NULL; }
|
||||
IOSurfaceLock(surface, 0, NULL);
|
||||
uint8_t *base = (uint8_t *)IOSurfaceGetBaseAddress(surface);
|
||||
size_t alloc = IOSurfaceGetAllocSize(surface);
|
||||
memset(base, 0, alloc);
|
||||
for (size_t k = 0; k * 4 + 4 <= alloc; k += 1) {
|
||||
uint32_t word = kPlaneTag | (uint32_t)k;
|
||||
memcpy(base + k * 4, &word, 4);
|
||||
}
|
||||
IOSurfaceUnlock(surface, 0, NULL);
|
||||
return surface;
|
||||
}
|
||||
|
||||
// Run one shape over one surface form; 0 where every destination texel held the row copy's answer,
|
||||
// else the mismatches.
|
||||
static int readShape(id<MTLDevice> device, id<MTLCommandQueue> queue, const struct Shape *shape,
|
||||
BOOL planar) {
|
||||
const char *form = planar ? "planar" : "flat";
|
||||
size_t w = shape->w, h = shape->h, bpr = shape->bpr;
|
||||
size_t row = w * 4, pitch = gpuPitch(bpr);
|
||||
IOSurfaceRef surface = makeSurface(w, h, bpr, planar);
|
||||
if (surface == NULL) {
|
||||
printf("%s %zux%zu at %zu: IOSurfaceCreate answered nil\n", form, w, h, bpr);
|
||||
return 1;
|
||||
}
|
||||
size_t surfaceRow = planar ? IOSurfaceGetBytesPerRowOfPlane(surface, 0)
|
||||
: IOSurfaceGetBytesPerRow(surface);
|
||||
MTLTextureDescriptor *d =
|
||||
[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm
|
||||
width:w
|
||||
height:h
|
||||
mipmapped:NO];
|
||||
d.usage = MTLTextureUsageShaderRead;
|
||||
d.storageMode = MTLStorageModeShared;
|
||||
id<MTLTexture> texture = [device newTextureWithDescriptor:d iosurface:surface plane:0];
|
||||
if (texture == nil) {
|
||||
printf("%s %zux%zu at %zu (surface row %zu): no texture\n", form, w, h, bpr, surfaceRow);
|
||||
CFRelease(surface);
|
||||
return 1;
|
||||
}
|
||||
size_t words = w * h;
|
||||
id<MTLBuffer> out = [device newBufferWithLength:words * 4 options:MTLResourceStorageModeShared];
|
||||
uint32_t *got = (uint32_t *)out.contents;
|
||||
for (size_t i = 0; i < words; i += 1) { got[i] = kUntouched; }
|
||||
id<MTLCommandBuffer> commands = [queue commandBuffer];
|
||||
id<MTLBlitCommandEncoder> blit = [commands blitCommandEncoder];
|
||||
[blit copyFromTexture:texture
|
||||
sourceSlice:0
|
||||
sourceLevel:0
|
||||
sourceOrigin:MTLOriginMake(0, 0, 0)
|
||||
sourceSize:MTLSizeMake(w, h, 1)
|
||||
toBuffer:out
|
||||
destinationOffset:0
|
||||
destinationBytesPerRow:row
|
||||
destinationBytesPerImage:row * h];
|
||||
[blit endEncoding];
|
||||
[commands commit];
|
||||
[commands waitUntilCompleted];
|
||||
if (commands.status != MTLCommandBufferStatusCompleted) {
|
||||
printf("%s %zux%zu at %zu: command buffer status %lu\n", form, w, h, bpr,
|
||||
(unsigned long)commands.status);
|
||||
CFRelease(surface);
|
||||
return 1;
|
||||
}
|
||||
int wrong = 0;
|
||||
for (size_t y = 0; y < h; y += 1) {
|
||||
for (size_t x = 0; x < w; x += 1) {
|
||||
uint32_t have = got[y * w + x];
|
||||
// The row copy reads destination row `y` from plane byte `pitch * y`.
|
||||
uint32_t want = kPlaneTag | (uint32_t)((pitch * y + x * 4) / 4);
|
||||
if (have == want) { continue; }
|
||||
wrong += 1;
|
||||
if (have == kUntouched) {
|
||||
printf("%s %zux%zu at %zu: texel (%zu, %zu) untouched, the row copy's plane word "
|
||||
"%u\n", form, w, h, bpr, x, y, want & 0x0fffffffu);
|
||||
} else if ((have & 0xf0000000u) == kPlaneTag) {
|
||||
printf("%s %zux%zu at %zu: texel (%zu, %zu) from plane word %u, the row copy's "
|
||||
"%u\n", form, w, h, bpr, x, y, have & 0x0fffffffu, want & 0x0fffffffu);
|
||||
} else {
|
||||
printf("%s %zux%zu at %zu: texel (%zu, %zu) is %#010x, no plane word; the row "
|
||||
"copy's %u\n", form, w, h, bpr, x, y, have, want & 0x0fffffffu);
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%s %zux%zu at %zu (surface row %zu, GPU pitch %zu, row %zu, shared %zu): %s\n", form,
|
||||
w, h, bpr, surfaceRow, pitch, row, row > pitch ? row - pitch : 0,
|
||||
wrong == 0 ? "every texel the row copy's" : "DIFFERS");
|
||||
CFRelease(surface);
|
||||
return wrong == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
@autoreleasepool {
|
||||
if (argc < 2) {
|
||||
printf("usage: %s <shape 0..%zu>\n", argv[0], kShapeCount - 1);
|
||||
return 2;
|
||||
}
|
||||
size_t index = (size_t)atoi(argv[1]);
|
||||
if (index >= kShapeCount) {
|
||||
printf("shape %zu is past %zu\n", index, kShapeCount - 1);
|
||||
return 2;
|
||||
}
|
||||
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
|
||||
if (device == nil) {
|
||||
printf("no Metal device\n");
|
||||
return 2;
|
||||
}
|
||||
printf("device %s, shape %zu, pid %d\n", device.name.UTF8String, index, getpid());
|
||||
id<MTLCommandQueue> queue = [device newCommandQueue];
|
||||
int wrong = 0;
|
||||
wrong += readShape(device, queue, &kShapes[index], YES);
|
||||
// A flat surface at a pitch off 16 is Metal's own assert, not an answer to read.
|
||||
if (kShapes[index].bpr % 16 == 0) {
|
||||
wrong += readShape(device, queue, &kShapes[index], NO);
|
||||
} else {
|
||||
printf("flat %zux%zu at %zu: not asked, Metal's descriptor validation asserts on a "
|
||||
"pitch off 16\n", kShapes[index].w, kShapes[index].h, kShapes[index].bpr);
|
||||
}
|
||||
return wrong == 0 ? 0 : 1;
|
||||
}
|
||||
}
|
||||
@@ -829,9 +829,13 @@ impl RowsCopy {
|
||||
/// row keeps the bytes they share, as plain Metal writes overlapping images in turn (an M4
|
||||
/// under macOS 27.0.1, the `ctb.race.*` cases; [`plan_placed_copy`] states the same rule for
|
||||
/// a layout off Metal's rules): an earlier row copies only the bytes no later row writes
|
||||
/// ([`later_rows_win`]). A texture's own rows never overlap here -- a plane's shared bytes
|
||||
/// have no one Metal order and are refused (`blit_texture.rs`), and a rotated texture's rows
|
||||
/// share no byte (`buffer_texture::turned_plane`).
|
||||
/// ([`later_rows_win`]). No texture's own rows overlap as the destination: a plane's shared
|
||||
/// bytes, which have no one Metal order, are refused wherever they would be written
|
||||
/// (`blit_texture.rs`), and a rotated texture's rows share no byte
|
||||
/// (`buffer_texture::turned_plane`). A plane's rows do overlap as the source, where they are
|
||||
/// read: each destination row takes the plane's bytes at its own GPU row, so a shared byte is
|
||||
/// read once for each row that holds it, and such a row joins neither neighbour into one
|
||||
/// range.
|
||||
pub(super) fn new(src: &[Range<u64>], dst: &[Range<u64>]) -> RowsCopy {
|
||||
debug_assert_eq!(src.len(), dst.len());
|
||||
// Each row as `later_rows_win` takes it: by the bytes it writes.
|
||||
@@ -939,9 +943,10 @@ pub(super) fn texel_rows(
|
||||
/// whichever of the two rows Metal's command wrote last, an order that follows the command, the
|
||||
/// GPU pitch and the row count and that one shape of `copyFromTexture:toTexture:` does not settle
|
||||
/// from run to run (`linear_plan.rs`'s **Rows that overlap**), so no order a row copy writes them
|
||||
/// in is Metal's. A source plane alone would be read, not written, but the destination is refused
|
||||
/// either way: the two sides may be one texture, and a copy out of a plane is refused where it
|
||||
/// goes in (`blit_texture.rs`).
|
||||
/// in is Metal's. A source plane alone would be read, not written, as a copy out of a plane into a
|
||||
/// buffer is (`blit_texture::copy_from_texture_to_buffer`), and so has no such order to miss; what
|
||||
/// Metal reads out of one between two textures over buffers is unmeasured, and the source stays
|
||||
/// refused with the destination until it is.
|
||||
pub(super) fn plan_texels_rows_copy(
|
||||
from: (&TexelsLayout, &TexelsLayout),
|
||||
to: (&TexelsLayout, &TexelsLayout),
|
||||
|
||||
@@ -567,7 +567,8 @@ impl BlitCommandEncoder {
|
||||
// leaves it from whichever row its own command wrote last -- an order that
|
||||
// follows the command, the GPU pitch and the row count, and that one shape
|
||||
// does not settle from run to run (`linear_plan.rs`'s **Rows that
|
||||
// overlap**).
|
||||
// overlap**). The other direction reads those rows instead of writing them
|
||||
// and is served (`copy_from_texture_to_buffer`).
|
||||
if texels.plane_rows_overlap() {
|
||||
return Err(Error::NotImplemented(RuntimeGap::OverlappingSurfaceRows));
|
||||
}
|
||||
@@ -719,15 +720,25 @@ impl BlitCommandEncoder {
|
||||
let unit = unit(CALL, source_texture, options)?;
|
||||
let region = region(CALL, source_origin, size, source_level, source_slice)?;
|
||||
if let Some(texels) = source_texture.buffer_texels() {
|
||||
// Rows that share bytes (an IOSurface plane's on Metal's GPU): the row
|
||||
// copies would write every shared byte from one fixed row, where Metal
|
||||
// leaves it from whichever row its own command wrote last -- an order that
|
||||
// follows the command, the GPU pitch and the row count, and that one shape
|
||||
// does not settle from run to run (`linear_plan.rs`'s **Rows that
|
||||
// overlap**).
|
||||
if texels.plane_rows_overlap() {
|
||||
return Err(Error::NotImplemented(RuntimeGap::OverlappingSurfaceRows));
|
||||
}
|
||||
// Rows that share bytes (an IOSurface plane's on Metal's GPU) are served
|
||||
// here, where they are read and not written. The plane is the source; the
|
||||
// destination is the caller's buffer, whose rows never share a byte, so no
|
||||
// row's bytes are taken from another: `plan_rows_copy` refuses a
|
||||
// `bytesPerRow` below the region's row (`CopyProblem::BytesPerRow`), and a
|
||||
// plane is a 2D texture of one image, so the only other way a layout's rows
|
||||
// could meet -- images closer than their rows -- cannot arise and
|
||||
// `RowsCopy::new` finds nothing to order. Each destination row takes the
|
||||
// plane's bytes at its own GPU row, so a byte two rows share is read once
|
||||
// for each of them, which is what Metal's own copy reads (an Apple M3 Max
|
||||
// under macOS 27.0.1, one shape a process,
|
||||
// `probes/overlapping_plane_row_reads.m`).
|
||||
//
|
||||
// Reading rows that overlap is not the mirror of writing them, so the
|
||||
// direction above stays refused and this one need not: a write has to settle
|
||||
// which of two rows leaves the shared bytes behind, and Metal settles it no
|
||||
// one way (`linear_plan.rs`'s **Rows that overlap**), while a read settles
|
||||
// nothing -- it only says which byte each destination byte comes from, and
|
||||
// every row that holds a shared byte holds the same byte.
|
||||
let (to, from) = plan_rows_copy(
|
||||
source_texture.record(),
|
||||
®ion,
|
||||
|
||||
@@ -122,10 +122,19 @@
|
||||
//! leaves of the shared bytes is not measured; the shapes whose rows of codes or units no row
|
||||
//! rule bounds (a two-plane YCbCr texture's, which overlap by any amount across any number of
|
||||
//! rows, `ycbcr.rs`; a two-plane extended-range one's, a 4:2:2 one's pairs, a depth or stencil
|
||||
//! plane's elements), which two regions do not express; and a blit that addresses such a
|
||||
//! plane's rows as bytes (`blit_texture.rs`), which writes every shared byte from one fixed row
|
||||
//! where Metal's order is no one order ([`super::blit_plan::RowsCopy`] holds only the one
|
||||
//! overlap that has an order, a buffer's rows whose images meet). A rotated plane never reaches
|
||||
//! plane's elements), which two regions do not express; and a blit that would write such a
|
||||
//! plane's rows as bytes (`blit_texture.rs`: a copy into it from a buffer, and one between two
|
||||
//! textures over buffers, whichever side it is on), which writes every shared byte from one
|
||||
//! fixed row where Metal's order is no one order ([`super::blit_plan::RowsCopy`] holds only the
|
||||
//! one overlap that has an order, a buffer's rows whose images meet). A blit out of such a plane
|
||||
//! into a buffer is served instead of refused, its rows being read and not written: each of the
|
||||
//! buffer's rows takes the plane's bytes at its own GPU row, so a byte two rows share is read
|
||||
//! once for each of them, which is what Metal's `copyFromTexture:toBuffer:` reads (an Apple M3
|
||||
//! Max under macOS 27.0.1, one shape a process, `probes/overlapping_plane_row_reads.m`). A read
|
||||
//! is not the mirror of a write here: a write must settle which row leaves the shared bytes
|
||||
//! behind and Metal settles it no one way, while a read settles nothing. A copy between the
|
||||
//! plane and an image texture is refused either way, its one `bufferRowLength` stating no
|
||||
//! sharing. A rotated plane never reaches
|
||||
//! any of this: its `bytesPerRow` must be a multiple of 16
|
||||
//! (`buffer_texture::turned_plane`), so its GPU rows lie at the pitch itself and share no byte
|
||||
//! (`tests::buffer_texture::no_rotated_plane_s_gpu_rows_share_bytes`).
|
||||
|
||||
@@ -1156,6 +1156,106 @@ fn surface_plane(
|
||||
.new_texture_with_iosurface_plane(&d, IoSurfacePlane::new(0, bpr, true))
|
||||
}
|
||||
|
||||
/// A plane whose GPU rows share bytes, copied out into a buffer: every row of the buffer takes
|
||||
/// the plane's bytes at its own GPU row, so a byte two rows share is read once for each row that
|
||||
/// holds it, which is what Metal's `copyFromTexture:toBuffer:` reads (an Apple M3 Max under macOS
|
||||
/// 27.0.1, one shape a process,
|
||||
/// `metal2vulkan-conformance/probes/overlapping_plane_row_reads.m`). Every byte of the buffer is
|
||||
/// `7i + 3` of its own address, which names each byte over the plane's span, so a read off Metal's
|
||||
/// names the byte it took instead of merely differing.
|
||||
///
|
||||
/// The copy leaves the plane's own bytes alone and `get_bytes` still reads the plane's rows, not
|
||||
/// the GPU's. The copy the other way stays refused: a write must settle which of two rows leaves
|
||||
/// the shared bytes behind and Metal settles it no one way, while a read settles nothing -- it
|
||||
/// only says where each byte comes from, and both rows that hold a shared byte hold the same byte.
|
||||
///
|
||||
/// The shapes share 4 bytes at a GPU pitch of 16 and of 32 and 12 bytes at a pitch of 16, over two
|
||||
/// to five rows, and include a `bytesPerRow` well past the row whose multiple of 16 still falls
|
||||
/// below it (the CPU's rows 28 bytes apart, the GPU's 16).
|
||||
#[test]
|
||||
fn a_blit_out_of_a_plane_whose_gpu_rows_share_bytes_reads_each_row_at_its_own_pitch() {
|
||||
on_device(|device| {
|
||||
for kind in [Kind::Ordinary, Kind::NoCopy] {
|
||||
let Some(held) = Held::new(device, kind) else {
|
||||
eprintln!("{}: no {kind:?} buffer", device.name());
|
||||
continue;
|
||||
};
|
||||
for [w, h, bpr] in [
|
||||
[5u64, 4, 20],
|
||||
[5, 2, 20],
|
||||
[5, 4, 28],
|
||||
[9, 4, 36],
|
||||
[7, 5, 28],
|
||||
] {
|
||||
let what = format!("{kind:?} {w}x{h} at {bpr}");
|
||||
let (row, pitch) = (4 * w, (bpr / 16 * 16).max(16));
|
||||
let n = (row * h) as usize;
|
||||
assert!(pitch < row, "{what}: the GPU rows share bytes");
|
||||
let mut d = TextureDescriptor::texture_2d(PixelFormat::RGBA8Unorm, w, h, false);
|
||||
d.usage = TextureUsage::SHADER_READ;
|
||||
d.resource_options = held.buffer.resource_options();
|
||||
let t = held
|
||||
.buffer
|
||||
.new_texture_with_iosurface_plane(&d, IoSurfacePlane::new(OFF, bpr, true))
|
||||
.unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
let out = buffer_with(device, &vec![0xee; n]).unwrap();
|
||||
blit(device, |e| {
|
||||
e.copy_from_texture_to_buffer(
|
||||
&t,
|
||||
0,
|
||||
0,
|
||||
origin([0, 0]),
|
||||
size([w, h]),
|
||||
&out,
|
||||
0,
|
||||
row,
|
||||
row * h,
|
||||
BlitOption::None,
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
assert_eq!(
|
||||
read_buffer(&out, 0, n as u64).unwrap(),
|
||||
gather(&held.model, &gpu_rows(OFF, bpr, row, h)),
|
||||
"{what}: a blit's read of rows that share bytes"
|
||||
);
|
||||
held.check(&format!("{what}: the plane after the read"));
|
||||
let mut back = vec![0u8; n];
|
||||
t.get_bytes(&mut back, row, 0, Region::new_2d(0, 0, w, h), 0, 0)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
back,
|
||||
gather(&held.model, &plane_rows(OFF, bpr, row, h)),
|
||||
"{what}: get_bytes after the read"
|
||||
);
|
||||
// The write stays refused, the read having settled nothing for it.
|
||||
let from = buffer_with(device, &vec![0u8; n]).unwrap();
|
||||
let queue = device.new_command_queue().unwrap();
|
||||
let command_buffer = queue.command_buffer().unwrap();
|
||||
let mut encoder = command_buffer.blit_command_encoder().unwrap();
|
||||
let into = encoder.copy_from_buffer_to_texture(
|
||||
&from,
|
||||
0,
|
||||
row,
|
||||
row * h,
|
||||
size([w, h]),
|
||||
&t,
|
||||
0,
|
||||
0,
|
||||
origin([0, 0]),
|
||||
BlitOption::None,
|
||||
);
|
||||
assert_eq!(
|
||||
into.err(),
|
||||
Some(Error::NotImplemented(RuntimeGap::OverlappingSurfaceRows)),
|
||||
"{what}: a blit into rows that share bytes"
|
||||
);
|
||||
encoder.end_encoding().unwrap();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// A depth or stencil texture over a plane of a surface with planes, which Metal makes and
|
||||
/// samples or reads and draws (an M4 under macOS 27.0.1, TTG2's format scout: `Depth16Unorm`,
|
||||
/// `Depth32Float`, `Depth32Float_Stencil8`, `Stencil8`, `X32_Stencil8`, each for reading and for
|
||||
|
||||
Vendored
+1
-1
@@ -93,7 +93,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 449;
|
||||
/// 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 = 1606;
|
||||
pub const RUNTIME_VERSION: u32 = 1607;
|
||||
|
||||
/// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex,
|
||||
/// of the manifest, the build script, and exactly the files the crate roots' module tree compiles
|
||||
|
||||
+2
-2
@@ -204,7 +204,7 @@ Columns:
|
||||
| `ExtensionEnable` | An extension a created device would enable that the device lists under none of the names the runtime knows for it | devices without the feature or extension it names | `ours` | 1: `crates/metal2vulkan-runtime/src/enables.rs (of)` | `none`: device creation with an extension under an unknown name |
|
||||
| `Render` | Render pipelines, passes and draws | every device (runtime piece not built) | `ours` | 26: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs (check_copies)`, `crates/metal2vulkan-runtime/src/attachment_stand_in.rs (stand_in_as, 2 sites)` (+19) | `system`: render pass, resolve and attachment forms not built (20 sites: see the appendix) |
|
||||
| `TexelsPastBufferLength` | A texture over a buffer whose texels run past the buffer's length, which Metal makes over bytes its buffer's allocation has past the length (a 2D... | every device (runtime piece not built) | `ours` | 2: `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error)`, `crates/metal2vulkan-runtime/src/texture/surface_depth.rs (surface_depth_twin)` | `rare`: a texture over a buffer past its length |
|
||||
| `OverlappingSurfaceRows` | A texture of an IOSurface plane (`Buffer::new_texture_with_iosurface_plane`, the stand-in for `newTextureWithDescriptor:iosurface:plane:`) whose... | every device (runtime piece not built) | `ours` | 5: `crates/metal2vulkan-runtime/src/blit_plan.rs (plan_texels_rows_copy)`, `crates/metal2vulkan-runtime/src/blit_texture.rs (copy_from_buffer_to_texture)` (+3) | `rare`: an IOSurface plane whose rows overlap |
|
||||
| `OverlappingSurfaceRows` | A texture of an IOSurface plane (`Buffer::new_texture_with_iosurface_plane`, the stand-in for `newTextureWithDescriptor:iosurface:plane:`) whose... | every device (runtime piece not built) | `ours` | 4: `crates/metal2vulkan-runtime/src/blit_plan.rs (plan_texels_rows_copy)`, `crates/metal2vulkan-runtime/src/blit_texture.rs (copy_from_buffer_to_texture)` (+2) | `rare`: an IOSurface plane whose rows overlap |
|
||||
| `MemorylessSurfacePlane` | A texture of an IOSurface plane (`Buffer::new_texture_with_iosurface_plane`, the stand-in for `newTextureWithDescriptor:iosurface:plane:`) whose... | every device (runtime piece not built) | `ours` | 1: `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error)` | `rare`: a memoryless texture over an IOSurface plane |
|
||||
| `IndirectCommandPastSize` | A command of an indirect command buffer at or past its size (`indirectComputeCommandAtIndex:`, `indirectRenderCommandAtIndex:`) | every device (runtime piece not built) | `ours` | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (command_at)` | `none`: an indirect command at or past the buffer's size |
|
||||
| `ExecutionRangePastBuffer` | An `MTLIndirectCommandBufferExecutionRange` whose 8 bytes run past the buffer it is read from (`execute_commands_in_buffer_indirect`, a compute... | every device (runtime piece not built) | `ours` | 1: `crates/metal2vulkan-runtime/src/indirect_execute.rs (check_range_buffer)` | `rare`: an execution range whose 8 bytes run past its buffer |
|
||||
@@ -704,7 +704,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `gap::ExtensionEnable`: `crates/metal2vulkan-runtime/src/enables.rs (of)`
|
||||
- `gap::Render`: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs (check_copies)`; `crates/metal2vulkan-runtime/src/attachment_stand_in.rs (stand_in_as, 2 sites)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (attachment_twin)`; `crates/metal2vulkan-runtime/src/color_resolve.rs (of_resolve)`; `crates/metal2vulkan-runtime/src/color_resolve.rs (plan, 2 sites)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs (check_sizes)`; `crates/metal2vulkan-runtime/src/kept_bytes.rs (settle)`; `crates/metal2vulkan-runtime/src/linear_attachment.rs (settle)`; `crates/metal2vulkan-runtime/src/nan_clear.rs (plan)`; `crates/metal2vulkan-runtime/src/pipeline/render.rs (imageblock_sample_length)`; `crates/metal2vulkan-runtime/src/render.rs (check_pipeline)`; `crates/metal2vulkan-runtime/src/render.rs (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs (next_instance)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs (scratch)`; `crates/metal2vulkan-runtime/src/render_pass.rs (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs (depth_stencil)`; `crates/metal2vulkan-runtime/src/render_pass.rs (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs (target, 2 sites)`; `crates/metal2vulkan-runtime/src/resolve.rs (attach)`; `crates/metal2vulkan-runtime/src/resolve.rs (color_copy)`; `crates/metal2vulkan-runtime/src/resolve.rs (destination, 3 sites)`
|
||||
- `gap::TexelsPastBufferLength`: `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error)`; `crates/metal2vulkan-runtime/src/texture/surface_depth.rs (surface_depth_twin)`
|
||||
- `gap::OverlappingSurfaceRows`: `crates/metal2vulkan-runtime/src/blit_plan.rs (plan_texels_rows_copy)`; `crates/metal2vulkan-runtime/src/blit_texture.rs (copy_from_buffer_to_texture)`; `crates/metal2vulkan-runtime/src/blit_texture.rs (copy_from_texture_to_buffer)`; `crates/metal2vulkan-runtime/src/blit_texture.rs (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error)`
|
||||
- `gap::OverlappingSurfaceRows`: `crates/metal2vulkan-runtime/src/blit_plan.rs (plan_texels_rows_copy)`; `crates/metal2vulkan-runtime/src/blit_texture.rs (copy_from_buffer_to_texture)`; `crates/metal2vulkan-runtime/src/blit_texture.rs (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error)`
|
||||
- `gap::MemorylessSurfacePlane`: `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error)`
|
||||
- `gap::IndirectCommandPastSize`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (command_at)`
|
||||
- `gap::ExecutionRangePastBuffer`: `crates/metal2vulkan-runtime/src/indirect_execute.rs (check_range_buffer)`
|
||||
|
||||
Reference in new issue
Block a user