|
|
@ -2,8 +2,7 @@
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
#include <thread>
|
|
|
|
#include <chrono>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "common/settings.h"
|
|
|
|
#include "common/settings.h"
|
|
|
|
#include "video_core/renderer_vulkan/vk_master_semaphore.h"
|
|
|
|
#include "video_core/renderer_vulkan/vk_master_semaphore.h"
|
|
|
@ -12,8 +11,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace Vulkan {
|
|
|
|
namespace Vulkan {
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std::chrono_literals;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MasterSemaphore::MasterSemaphore(const Device& device) {
|
|
|
|
MasterSemaphore::MasterSemaphore(const Device& device) {
|
|
|
|
static constexpr VkSemaphoreTypeCreateInfoKHR semaphore_type_ci{
|
|
|
|
static constexpr VkSemaphoreTypeCreateInfoKHR semaphore_type_ci{
|
|
|
|
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO_KHR,
|
|
|
|
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO_KHR,
|
|
|
@ -34,9 +31,9 @@ MasterSemaphore::MasterSemaphore(const Device& device) {
|
|
|
|
// Validation layers have a bug where they fail to track resource usage when using timeline
|
|
|
|
// Validation layers have a bug where they fail to track resource usage when using timeline
|
|
|
|
// semaphores and synchronizing with GetSemaphoreCounterValueKHR. To workaround this issue, have
|
|
|
|
// semaphores and synchronizing with GetSemaphoreCounterValueKHR. To workaround this issue, have
|
|
|
|
// a separate thread waiting for each timeline semaphore value.
|
|
|
|
// a separate thread waiting for each timeline semaphore value.
|
|
|
|
debug_thread = std::thread([this] {
|
|
|
|
debug_thread = std::jthread([this](std::stop_token stop_token) {
|
|
|
|
u64 counter = 0;
|
|
|
|
u64 counter = 0;
|
|
|
|
while (!shutdown) {
|
|
|
|
while (!stop_token.stop_requested()) {
|
|
|
|
if (semaphore.Wait(counter, 10'000'000)) {
|
|
|
|
if (semaphore.Wait(counter, 10'000'000)) {
|
|
|
|
++counter;
|
|
|
|
++counter;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -44,13 +41,6 @@ MasterSemaphore::MasterSemaphore(const Device& device) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MasterSemaphore::~MasterSemaphore() {
|
|
|
|
MasterSemaphore::~MasterSemaphore() = default;
|
|
|
|
shutdown = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This thread might not be started
|
|
|
|
|
|
|
|
if (debug_thread.joinable()) {
|
|
|
|
|
|
|
|
debug_thread.join();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Vulkan
|
|
|
|
} // namespace Vulkan
|
|
|
|