I wanted to test ` CopyTextureToBuffer` functionality but have totally failed so far. I have been using the code below, which I copied for the most part from `CopyCommandValidationTests`.When I look at the value of `WGPUBufferMapAsyncStatus` in SaveToFile the callback function called by ` MapAsync` I constantly get an error message.- I create a basic texture (empty)- Create a buffer to get copy the data to- use CopyTextureToBuffer for the cmd- push the command to the queue.- call MapAsync on the buffer so that it calls SaveToFile once the command has been fully executed.I would appreciate your input as to what I need to do better here (if that's obvious) or how I should be doing it. Thank you.```void CaptureScreen()
{
uint64_t offset = 0;
uint32_t bytesPerRow = sizeof(unsigned char) * newSize.width * 3;
uint32_t rowsPerImage = newSize.height;
// these 2 are globals
bufferSize = BufferSizeForTextureCopy(newSize.width, newSize.height, 1);
destination = CreateBuffer(bufferSize, wgpu::BufferUsage::CopyDst);
--
wgpu::ImageCopyBuffer imageCopyBuffer = CreateImageCopyBuffer(destination, offset, bytesPerRow, rowsPerImage);
wgpu::Texture source = Create2DTexture(device, wgpu::TextureDimension::e2D,
kColorFormat, newSize.width, newSize.width, 1, 1, 1);
wgpu::ImageCopyTexture imageCopyTexture = CreateImageCopyTexture( source , 1, {0, 0, 0});
wgpu::Extent3D extent3D = {width, height, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyTextureToBuffer(&imageCopyTexture, &imageCopyBuffer, &extent3D);
wgpu::CommandBuffer commands = encoder.Finish();
device.GetQueue().Submit(1, &commands);
destination.MapAsync(wgpu::MapMode::Read, 0, bufferSize, SaveToFile, nullptr);
}```
You received this message because you are subscribed to the Google Groups "Dawn Graphics" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dawn-graphic...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dawn-graphics/2e9b1b31-8172-4bf1-881f-14c33cb954ffn%40googlegroups.com.