10 SDL_GPUCopyPass* pass,
11 SDL_GPUTexture* sourceTexture,
16 auto info = SDL_GPUTransferBufferCreateInfo {
17 .usage = SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD, .size = width * height * 4
19 buffer = SDL_CreateGPUTransferBuffer(device, &info);
21 throw std::runtime_error(
"Could not create transfer buffer");
23 auto src = SDL_GPUTextureRegion {
24 .texture = sourceTexture, .w = width, .h = height, .d = 1
26 auto dst = SDL_GPUTextureTransferInfo {
29 SDL_DownloadFromGPUTexture(pass, &src, &dst);
33 SDL_UnmapGPUTransferBuffer(device_,
buffer);
34 SDL_ReleaseGPUTransferBuffer(device_,
buffer);
38 return reinterpret_cast<unsigned char*
>(
39 SDL_MapGPUTransferBuffer(device_, buffer,
false)