Files
mirai/src/render/vulkan_time_semaphore.cpp
2026-01-08 10:03:19 +08:00

29 lines
822 B
C++

#include "vulkan_time_semaphore.h"
#include "vulkan_device.h"
#include "core/logger.h"
namespace mirai {
vulkan_time_semaphore::vulkan_time_semaphore(const std::shared_ptr<vulkan_device>& device, u32 initial_value) {
device_ = device;
vk::SemaphoreTypeCreateInfo type_info{ vk::SemaphoreType::eTimeline, initial_value };
vk::SemaphoreCreateInfo sem_info{};
sem_info.setPNext(&type_info);
auto [result, timeline_semaphore] = device_->get_device().createSemaphore(sem_info);
if (result != vk::Result::eSuccess) {
MIRAI_LOG_ERROR("创建 Vulkan 时间信号量失败: {}", to_string(result));
return;
}
semaphore_ = timeline_semaphore;
}
void vulkan_time_semaphore::on_destroying() {
object::on_destroying();
if (semaphore_) {
device_->get_device().destroySemaphore(semaphore_);
}
}
}