#ifndef DEVICE_CONTEXT_HH_ #define DEVICE_CONTEXT_HH_ #include #include #include #include #include #include #include #include "context.hh" #include "instance_context.hh" #include "physical_device_context.hh" namespace low_latency { class QueueContext; struct DeviceContext final : public Context { public: InstanceContext& instance; PhysicalDeviceContext& physical_device; const bool was_antilag_requested; const VkDevice device; const VkuDeviceDispatchTable vtable; std::unordered_map> queues; struct Clock { public: using time_point_t = std::chrono::time_point; 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(); 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; std::uint32_t antilag_fps = 0; // TODO VkAntiLagModeAMD antilag_mode = VK_ANTI_LAG_MODE_DRIVER_CONTROL_AMD; // The queue used in the last present. std::shared_ptr present_queue; private: void sleep_in_input(); public: DeviceContext(InstanceContext& parent_instance, PhysicalDeviceContext& parent_physical, const VkDevice& device, const bool was_antilag_requested, VkuDeviceDispatchTable&& vtable); virtual ~DeviceContext(); public: void notify_antilag_update(const VkAntiLagDataAMD& data); void notify_queue_present(const QueueContext& queue); }; }; // namespace low_latency #endif