diff options
author | Jaebaek Seo <duke.acacia@gmail.com> | 2018-12-11 09:13:22 -0500 |
---|---|---|
committer | dan sinclair <dj2@everburning.com> | 2018-12-11 09:13:22 -0500 |
commit | 09a1bc62851b29d516ea711b504e79e4028027f5 (patch) | |
tree | 7cfb3b210b9a37eaf62d9854f3a881087f741171 /src | |
parent | 8c92408511b88dbf1d732152af6ec826c1f9d321 (diff) | |
download | amber-09a1bc62851b29d516ea711b504e79e4028027f5.tar.gz |
Vulkan: submit commands after resizing buffers (#165)
Resizing buffers requires copy commands from old buffers to new
buffers. It must be done before updating those buffers with new
data. This CL submit commands right after resizing buffers to
guarantee this.
Fixes #163
Diffstat (limited to 'src')
-rw-r--r-- | src/vulkan/pipeline.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/vulkan/pipeline.cc b/src/vulkan/pipeline.cc index cdfc5f7..bce91f5 100644 --- a/src/vulkan/pipeline.cc +++ b/src/vulkan/pipeline.cc @@ -304,7 +304,27 @@ Result Pipeline::SendDescriptorDataToDeviceIfNeeded() { memory_properties_); if (!r.IsSuccess()) return r; + } + + r = command_->End(); + if (!r.IsSuccess()) + return r; + // Note that if a buffer for a descriptor is host accessible and + // does not need to record a command to copy data to device, it + // directly writes data to the buffer. The direct write must be + // done after resizing backed buffer i.e., copying data to the new + // buffer from the old one. Thus, we must submit commands here to + // guarantee this. + r = command_->SubmitAndReset(GetFenceTimeout()); + if (!r.IsSuccess()) + return r; + + r = command_->BeginIfNotInRecording(); + if (!r.IsSuccess()) + return r; + + for (const auto& desc : descriptors_) { desc->UpdateResourceIfNeeded(command_->GetCommandBuffer()); } |