| 49 | } |
| 50 | |
| 51 | Task* GPUSwapChain::DownloadDataAsync(TextureData& result) |
| 52 | { |
| 53 | if (_downloadTask) |
| 54 | { |
| 55 | LOG(Warning, "Can download window backuffer data only once at the time."); |
| 56 | return nullptr; |
| 57 | } |
| 58 | |
| 59 | auto texture = GPUDevice::Instance->CreateTexture(); |
| 60 | if (texture->Init(GPUTextureDescription::New2D(GetWidth(), GetHeight(), GetFormat(), GPUTextureFlags::None, 1).ToStagingReadback())) |
| 61 | { |
| 62 | LOG(Warning, "Failed to create staging texture for the window swapchain backuffer download."); |
| 63 | return nullptr; |
| 64 | } |
| 65 | |
| 66 | auto task = New<GPUSwapChainDownloadTask>(); |
| 67 | task->SwapChain = this; |
| 68 | task->Texture = texture; |
| 69 | |
| 70 | const auto downloadTask = texture->DownloadDataAsync(result); |
| 71 | task->ContinueWith(downloadTask); |
| 72 | |
| 73 | _downloadTask = task; |
| 74 | return task; |
| 75 | } |
| 76 | |
| 77 | void GPUSwapChain::End(RenderTask* task) |
| 78 | { |
nothing calls this directly
no test coverage detected