aboutsummaryrefslogtreecommitdiff
path: root/src/device_context.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/device_context.hh')
-rw-r--r--src/device_context.hh56
1 files changed, 14 insertions, 42 deletions
diff --git a/src/device_context.hh b/src/device_context.hh
index 6b5f000..172801c 100644
--- a/src/device_context.hh
+++ b/src/device_context.hh
@@ -11,59 +11,30 @@
#include <vulkan/vulkan_core.h>
#include "context.hh"
+#include "device_clock.hh"
#include "instance_context.hh"
#include "physical_device_context.hh"
+#include "queue_context.hh"
+#include "swapchain_monitor.hh"
namespace low_latency {
-class QueueContext;
-
-struct DeviceContext final : public Context {
+class DeviceContext final : public Context {
public:
InstanceContext& instance;
PhysicalDeviceContext& physical_device;
- const bool was_antilag_requested;
+ // Whether or not we were asked to do NV_VK_LowLatency2 or VK_AMD_anti_lag.
+ const bool was_capability_requested;
const VkDevice device;
const VkuDeviceDispatchTable vtable;
- // Tiny struct to represent any swapchain's low latency state.
- struct SwapchainInfo {
- std::chrono::milliseconds present_delay = std::chrono::milliseconds{0};
- bool was_low_latency_requested = false;
- };
- std::unordered_map<VkSwapchainKHR, SwapchainInfo> swapchain_infos{};
-
std::unordered_map<VkQueue, std::shared_ptr<QueueContext>> queues;
- struct Clock {
- public:
- using time_point_t = std::chrono::time_point<std::chrono::steady_clock,
- std::chrono::nanoseconds>;
- const DeviceContext& device;
-
- public:
- std::uint64_t host_ns;
- std::uint64_t error_bound;
- std::uint64_t device_ticks;
-
- public:
- Clock(const DeviceContext& device);
- ~Clock();
+ std::unique_ptr<DeviceClock> clock;
- public:
- // WARNING: This *MUST* be used over std::chrono::steady_clock::now if
- // you're planning on comparing it to a device's clock. If it isn't, the
- // timestamps might from different domains and will be completely
- // nonsensical.
- static time_point_t now();
-
- public:
- void calibrate();
- time_point_t ticks_to_time(const std::uint64_t& ticks) const;
- };
- std::unique_ptr<Clock> clock;
+ std::unordered_map<VkSwapchainKHR, SwapchainMonitor> swapchain_monitors;
public:
DeviceContext(InstanceContext& parent_instance,
@@ -73,13 +44,14 @@ struct DeviceContext final : public Context {
virtual ~DeviceContext();
public:
- void sleep_in_input();
-
// Updates the settings associated with that swapchain. If none is provided
// all swapchains are set to this value.
- void update_swapchain_infos(const std::optional<VkSwapchainKHR> target,
- const std::chrono::milliseconds& present_delay,
- const bool was_low_latency_requested);
+ void update_params(const std::optional<VkSwapchainKHR> target,
+ const std::chrono::milliseconds& present_delay,
+ const bool was_low_latency_requested);
+
+ void notify_present(const VkSwapchainKHR& swapchain,
+ const QueueContext::submissions_t& submissions);
};
}; // namespace low_latency