[Webkit-unassigned] [Bug 212013] Nonmappable buffers with createBufferMapped() doesn't work

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon May 18 17:02:47 PDT 2020


https://bugs.webkit.org/show_bug.cgi?id=212013

--- Comment #2 from Myles C. Maxfield <mmaxfield at apple.com> ---
If you copy/paste this into WebKit, it takes 11 seconds to complete. However, if you put it in a sample project, it takes less than 1 second to complete. Maybe the sandbox is interfering?

    id<MTLDevice> device = MTLCreateSystemDefaultDevice();
    MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor new];
    textureDescriptor.textureType = MTLTextureType2DArray;
    textureDescriptor.pixelFormat = MTLPixelFormatRGBA8Unorm;
    textureDescriptor.width = 512;
    textureDescriptor.height = 512;
    textureDescriptor.depth = 1;
    textureDescriptor.mipmapLevelCount = 9;
    textureDescriptor.sampleCount = 1;
    textureDescriptor.arrayLength = 2;
    textureDescriptor.storageMode = MTLStorageModePrivate;
    textureDescriptor.usage = MTLTextureUsageShaderRead;
    id<MTLTexture> texture = [device newTextureWithDescriptor:textureDescriptor];

    id<MTLBuffer> buffer = [device newBufferWithLength:1048576 options:MTLStorageModeShared];
    uint8_t* p = (uint8_t*)buffer.contents;
    for (int i = 0; i < 512; ++i) {
        for (int j = 0; j < 512; ++j) {
            p[i * 512 * 4 + j * 4 + 0] = 0;
            p[i * 512 * 4 + j * 4 + 1] = 255;
            p[i * 512 * 4 + j * 4 + 2] = 0;
            p[i * 512 * 4 + j * 4 + 3] = 255;
        }
    }
    id<MTLCommandQueue> queue = [device newCommandQueue];
    id<MTLCommandBuffer> commandBuffer = [queue commandBuffer];
    id<MTLBlitCommandEncoder> commandEncoder = [commandBuffer blitCommandEncoder];
    [commandEncoder copyFromBuffer:buffer sourceOffset:0 sourceBytesPerRow:2048 sourceBytesPerImage:1048576 sourceSize:MTLSizeMake(512, 512, 1) toTexture:texture destinationSlice:0 destinationLevel:0 destinationOrigin: MTLOriginMake(0, 0, 0)];
    [commandEncoder endEncoding];
    [commandBuffer addCompletedHandler:^(id<MTLCommandBuffer> commandBuffer) {
        NSLog(@"Test Done.");
    }];
    NSLog(@"Test committing");
    [commandBuffer commit];
    [[NSRunLoop mainRunLoop] run];

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200519/75d24540/attachment-0001.htm>


More information about the webkit-unassigned mailing list