| 406 | }; |
| 407 | |
| 408 | Task* GPUBuffer::DownloadDataAsync(BytesContainer& result) |
| 409 | { |
| 410 | // Skip for empty ones |
| 411 | if (GetSize() == 0) |
| 412 | return nullptr; |
| 413 | |
| 414 | // Create the staging resource |
| 415 | const auto staging = ToStagingReadback(); |
| 416 | if (staging == nullptr) |
| 417 | { |
| 418 | LOG(Warning, "Cannot create staging resource from {0}.", ToString()); |
| 419 | return nullptr; |
| 420 | } |
| 421 | |
| 422 | // Create async resource copy task |
| 423 | auto copyTask = ::New<GPUCopyResourceTask>(this, staging); |
| 424 | ASSERT(copyTask->HasReference(this) && copyTask->HasReference(staging)); |
| 425 | |
| 426 | // Create task to copy downloaded data to BytesContainer |
| 427 | const auto getDataTask = ::New<BufferDownloadDataTask>(this, staging, result); |
| 428 | ASSERT(getDataTask->HasReference(this) && getDataTask->HasReference(staging)); |
| 429 | |
| 430 | // Set continuation |
| 431 | copyTask->ContinueWith(getDataTask); |
| 432 | |
| 433 | return copyTask; |
| 434 | } |
| 435 | |
| 436 | bool GPUBuffer::GetData(BytesContainer& output) |
| 437 | { |
no test coverage detected