Skip to content

Commit

Permalink
Isolating the Vulkan Command specific changes
Browse files Browse the repository at this point in the history
Per requested, creating a bundle of changes specifically for the VK
command changes.
  • Loading branch information
phoenixxxx authored and poweifeng committed Nov 6, 2024
1 parent 3b0e44c commit 4a7d330
Show file tree
Hide file tree
Showing 6 changed files with 419 additions and 357 deletions.
41 changes: 9 additions & 32 deletions filament/backend/src/vulkan/VulkanAsyncHandles.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,20 @@ namespace filament::backend {

// Wrapper to enable use of shared_ptr for implementing shared ownership of low-level Vulkan fences.
struct VulkanCmdFence {
struct SetValueScope {
public:
~SetValueScope() {
mHolder->mutex.unlock();
mHolder->condition.notify_all();
}

private:
SetValueScope(VulkanCmdFence* fenceHolder, VkResult result) :
mHolder(fenceHolder) {
mHolder->mutex.lock();
mHolder->status.store(result);
}
VulkanCmdFence* mHolder;
friend struct VulkanCmdFence;
};

VulkanCmdFence(VkFence ifence);
~VulkanCmdFence() = default;

SetValueScope setValue(VkResult value) {
return {this, value};
VulkanCmdFence(VkResult initialStatus) {
// Internally we use the VK_INCOMPLETE status to mean "not yet submitted". When this fence
// gets submitted, its status changes to VK_NOT_READY. Finally, when the GPU actually
// finishes executing the command buffer, the status changes to VK_SUCCESS.
status.store(initialStatus);
}

VkFence& getFence() {
return fence;
}
~VulkanCmdFence() = default;

VkResult getStatus() {
std::unique_lock<utils::Mutex> lock(mutex);
return status.load(std::memory_order_acquire);
}
void setStatus(VkResult value) { status.store(value); }

VkResult getStatus() { return status.load(std::memory_order_acquire); }

private:
VkFence fence;
utils::Condition condition;
utils::Mutex mutex;
std::atomic<VkResult> status;
};

Expand Down
Loading

0 comments on commit 4a7d330

Please sign in to comment.