<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>212013</bug_id>
          
          <creation_ts>2020-05-18 02:01:32 -0700</creation_ts>
          <short_desc>Nonmappable buffers with createBufferMapped() doesn&apos;t work</short_desc>
          <delta_ts>2020-05-18 17:02:47 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebGPU</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Myles C. Maxfield">mmaxfield</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1653525</commentid>
    <comment_count>0</comment_count>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2020-05-18 02:01:32 -0700</bug_when>
    <thetext>See the comments in https://bugs.webkit.org/show_bug.cgi?id=211882</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1653528</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-05-18 02:03:58 -0700</bug_when>
    <thetext>&lt;rdar://problem/63332658&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1653815</commentid>
    <comment_count>2</comment_count>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2020-05-18 17:02:47 -0700</bug_when>
    <thetext>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&lt;MTLDevice&gt; 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&lt;MTLTexture&gt; texture = [device newTextureWithDescriptor:textureDescriptor];

    id&lt;MTLBuffer&gt; buffer = [device newBufferWithLength:1048576 options:MTLStorageModeShared];
    uint8_t* p = (uint8_t*)buffer.contents;
    for (int i = 0; i &lt; 512; ++i) {
        for (int j = 0; j &lt; 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&lt;MTLCommandQueue&gt; queue = [device newCommandQueue];
    id&lt;MTLCommandBuffer&gt; commandBuffer = [queue commandBuffer];
    id&lt;MTLBlitCommandEncoder&gt; 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&lt;MTLCommandBuffer&gt; commandBuffer) {
        NSLog(@&quot;Test Done.&quot;);
    }];
    NSLog(@&quot;Test committing&quot;);
    [commandBuffer commit];
    [[NSRunLoop mainRunLoop] run];</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>