aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--src/device_context.cc16
-rw-r--r--src/device_context.hh3
-rw-r--r--src/queue_context.cc21
-rw-r--r--src/queue_context.hh3
-rw-r--r--src/strategies/anti_lag/device_strategy.cc10
-rw-r--r--src/strategies/anti_lag/device_strategy.hh18
-rw-r--r--src/strategies/anti_lag/queue_strategy.cc10
-rw-r--r--src/strategies/anti_lag/queue_strategy.hh18
-rw-r--r--src/strategies/device_strategy.cc9
-rw-r--r--src/strategies/device_strategy.hh18
-rw-r--r--src/strategies/low_latency2/device_strategy.cc10
-rw-r--r--src/strategies/low_latency2/device_strategy.hh18
-rw-r--r--src/strategies/low_latency2/queue_strategy.cc10
-rw-r--r--src/strategies/low_latency2/queue_strategy.hh18
-rw-r--r--src/strategies/queue_strategy.cc11
-rw-r--r--src/strategies/queue_strategy.hh18
17 files changed, 207 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f44ba5d..f4db493 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,6 +22,10 @@ target_link_libraries(${LIBRARY_NAME}
${Vulkan_LIBRARIES}
)
+target_include_directories(${LIBRARY_NAME} PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+)
+
include(GNUInstallDirs)
# Prefix an absolute directory to our layer's json so the loader knows where the shared library is.
configure_file(
diff --git a/src/device_context.cc b/src/device_context.cc
index d61c1bf..a4f3a13 100644
--- a/src/device_context.cc
+++ b/src/device_context.cc
@@ -1,5 +1,9 @@
#include "device_context.hh"
+#include "layer_context.hh"
+#include "strategies/anti_lag/device_strategy.hh"
+#include "strategies/low_latency2/device_strategy.hh"
+
#include <utility>
#include <vulkan/vulkan_core.h>
@@ -15,9 +19,17 @@ DeviceContext::DeviceContext(InstanceContext& parent_instance,
vtable(std::move(vtable)) {
// Only create our clock if we were asked to do anything.
- if (this->was_capability_requested) {
- this->clock = std::make_unique<DeviceClock>(*this);
+ if (!this->was_capability_requested) {
+ return;
}
+
+ this->clock = std::make_unique<DeviceClock>(*this);
+ this->strategy = [&]() -> std::unique_ptr<DeviceStrategy> {
+ if (parent_instance.layer.should_expose_reflex) {
+ return std::make_unique<LowLatency2DeviceStrategy>(*this);
+ }
+ return std::make_unique<AntiLagDeviceStrategy>(*this);
+ }();
}
DeviceContext::~DeviceContext() {
diff --git a/src/device_context.hh b/src/device_context.hh
index c4d6a43..975d67c 100644
--- a/src/device_context.hh
+++ b/src/device_context.hh
@@ -14,6 +14,7 @@
#include "instance_context.hh"
#include "physical_device_context.hh"
#include "queue_context.hh"
+#include "strategies/device_strategy.hh"
namespace low_latency {
@@ -32,6 +33,8 @@ class DeviceContext final : public Context {
std::unique_ptr<DeviceClock> clock;
std::unordered_map<VkQueue, std::shared_ptr<QueueContext>> queues;
+ std::unique_ptr<DeviceStrategy> strategy;
+
public:
DeviceContext(InstanceContext& parent_instance,
PhysicalDeviceContext& parent_physical,
diff --git a/src/queue_context.cc b/src/queue_context.cc
index 635b593..fce501b 100644
--- a/src/queue_context.cc
+++ b/src/queue_context.cc
@@ -1,6 +1,9 @@
#include "queue_context.hh"
#include "device_context.hh"
#include "helper.hh"
+#include "layer_context.hh"
+#include "strategies/anti_lag/queue_strategy.hh"
+#include "strategies/low_latency2/queue_strategy.hh"
#include "timestamp_pool.hh"
#include <span>
@@ -36,16 +39,22 @@ QueueContext::QueueContext(DeviceContext& device, const VkQueue& queue,
: device(device), queue(queue), queue_family_index(queue_family_index),
command_pool(std::make_unique<CommandPoolOwner>(*this)) {
- // Only construct a timestamp pool if we support it!
- if (device.physical_device.supports_required_extensions) {
- this->timestamp_pool = std::make_unique<TimestampPool>(*this);
+ // Only construct things if we actually support our operations.
+ if (!device.physical_device.supports_required_extensions) {
+ return;
}
-}
-QueueContext::~QueueContext() {
- this->timestamp_pool.reset();
+ this->timestamp_pool = std::make_unique<TimestampPool>(*this);
+ this->strategy = [&]() -> std::unique_ptr<QueueStrategy> {
+ if (device.instance.layer.should_expose_reflex) {
+ return std::make_unique<LowLatency2QueueStrategy>(*this);
+ }
+ return std::make_unique<AntiLagQueueStrategy>(*this);
+ }();
}
+QueueContext::~QueueContext() { this->timestamp_pool.reset(); }
+
bool QueueContext::should_inject_timestamps() const {
const auto& physical_device = this->device.physical_device;
diff --git a/src/queue_context.hh b/src/queue_context.hh
index f10c796..02d6367 100644
--- a/src/queue_context.hh
+++ b/src/queue_context.hh
@@ -3,6 +3,7 @@
#include "context.hh"
#include "device_clock.hh"
+#include "strategies/queue_strategy.hh"
#include "timestamp_pool.hh"
#include <vulkan/utility/vk_dispatch_table.h>
@@ -42,6 +43,8 @@ class QueueContext final : public Context {
std::unique_ptr<TimestampPool> timestamp_pool;
+ std::unique_ptr<QueueStrategy> strategy;
+
public:
QueueContext(DeviceContext& device_context, const VkQueue& queue,
const std::uint32_t& queue_family_index);
diff --git a/src/strategies/anti_lag/device_strategy.cc b/src/strategies/anti_lag/device_strategy.cc
new file mode 100644
index 0000000..5032c97
--- /dev/null
+++ b/src/strategies/anti_lag/device_strategy.cc
@@ -0,0 +1,10 @@
+#include "device_strategy.hh"
+
+namespace low_latency {
+
+AntiLagDeviceStrategy::AntiLagDeviceStrategy(DeviceContext& device)
+ : DeviceStrategy(device) {}
+
+AntiLagDeviceStrategy::~AntiLagDeviceStrategy() {}
+
+} // namespace low_latency \ No newline at end of file
diff --git a/src/strategies/anti_lag/device_strategy.hh b/src/strategies/anti_lag/device_strategy.hh
new file mode 100644
index 0000000..8a9afee
--- /dev/null
+++ b/src/strategies/anti_lag/device_strategy.hh
@@ -0,0 +1,18 @@
+#ifndef STRATEGIES_ANTI_LAG_DEVICE_STRATEGY_HH_
+#define STRATEGIES_ANTI_LAG_DEVICE_STRATEGY_HH_
+
+#include "strategies/device_strategy.hh"
+
+namespace low_latency {
+
+class DeviceContext;
+
+class AntiLagDeviceStrategy final : public DeviceStrategy {
+ public:
+ AntiLagDeviceStrategy(DeviceContext& device);
+ virtual ~AntiLagDeviceStrategy();
+};
+
+} // namespace low_latency
+
+#endif
diff --git a/src/strategies/anti_lag/queue_strategy.cc b/src/strategies/anti_lag/queue_strategy.cc
new file mode 100644
index 0000000..ba60535
--- /dev/null
+++ b/src/strategies/anti_lag/queue_strategy.cc
@@ -0,0 +1,10 @@
+#include "queue_strategy.hh"
+
+namespace low_latency {
+
+AntiLagQueueStrategy::AntiLagQueueStrategy(QueueContext& queue)
+ : QueueStrategy(queue) {}
+
+AntiLagQueueStrategy::~AntiLagQueueStrategy() {}
+
+} // namespace low_latency
diff --git a/src/strategies/anti_lag/queue_strategy.hh b/src/strategies/anti_lag/queue_strategy.hh
new file mode 100644
index 0000000..81ae653
--- /dev/null
+++ b/src/strategies/anti_lag/queue_strategy.hh
@@ -0,0 +1,18 @@
+#ifndef STRATEGIES_ANTI_LAG_QUEUE_STRATEGY_HH_
+#define STRATEGIES_ANTI_LAG_QUEUE_STRATEGY_HH_
+
+#include "strategies/queue_strategy.hh"
+
+namespace low_latency {
+
+class QueueContext;
+
+class AntiLagQueueStrategy final : public QueueStrategy {
+ public:
+ AntiLagQueueStrategy(QueueContext& queue);
+ virtual ~AntiLagQueueStrategy();
+};
+
+} // namespace low_latency
+
+#endif
diff --git a/src/strategies/device_strategy.cc b/src/strategies/device_strategy.cc
new file mode 100644
index 0000000..1afdc60
--- /dev/null
+++ b/src/strategies/device_strategy.cc
@@ -0,0 +1,9 @@
+#include "device_strategy.hh"
+
+namespace low_latency {
+
+DeviceStrategy::DeviceStrategy(DeviceContext& device) : device(device) {}
+
+DeviceStrategy::~DeviceStrategy() {}
+
+} // namespace low_latency \ No newline at end of file
diff --git a/src/strategies/device_strategy.hh b/src/strategies/device_strategy.hh
new file mode 100644
index 0000000..1b95e11
--- /dev/null
+++ b/src/strategies/device_strategy.hh
@@ -0,0 +1,18 @@
+#ifndef STRATEGIES_DEVICE_STRATEGY_HH_
+#define STRATEGIES_DEVICE_STRATEGY_HH_
+
+namespace low_latency {
+
+class DeviceContext;
+
+class DeviceStrategy {
+ DeviceContext& device;
+
+ public:
+ DeviceStrategy(DeviceContext& device);
+ virtual ~DeviceStrategy();
+};
+
+} // namespace low_latency
+
+#endif \ No newline at end of file
diff --git a/src/strategies/low_latency2/device_strategy.cc b/src/strategies/low_latency2/device_strategy.cc
new file mode 100644
index 0000000..7c10088
--- /dev/null
+++ b/src/strategies/low_latency2/device_strategy.cc
@@ -0,0 +1,10 @@
+#include "device_strategy.hh"
+
+namespace low_latency {
+
+LowLatency2DeviceStrategy::LowLatency2DeviceStrategy(DeviceContext& device)
+ : DeviceStrategy(device) {}
+
+LowLatency2DeviceStrategy::~LowLatency2DeviceStrategy() {}
+
+} // namespace low_latency
diff --git a/src/strategies/low_latency2/device_strategy.hh b/src/strategies/low_latency2/device_strategy.hh
new file mode 100644
index 0000000..18f8bd9
--- /dev/null
+++ b/src/strategies/low_latency2/device_strategy.hh
@@ -0,0 +1,18 @@
+#ifndef STRATEGIES_LOW_LATENCY2_DEVICE_STRATEGY_HH_
+#define STRATEGIES_LOW_LATENCY2_DEVICE_STRATEGY_HH_
+
+#include "strategies/device_strategy.hh"
+
+namespace low_latency {
+
+class DeviceContext;
+
+class LowLatency2DeviceStrategy final : public DeviceStrategy {
+ public:
+ LowLatency2DeviceStrategy(DeviceContext& device);
+ virtual ~LowLatency2DeviceStrategy();
+};
+
+} // namespace low_latency
+
+#endif
diff --git a/src/strategies/low_latency2/queue_strategy.cc b/src/strategies/low_latency2/queue_strategy.cc
new file mode 100644
index 0000000..85e1aae
--- /dev/null
+++ b/src/strategies/low_latency2/queue_strategy.cc
@@ -0,0 +1,10 @@
+#include "queue_strategy.hh"
+
+namespace low_latency {
+
+LowLatency2QueueStrategy::LowLatency2QueueStrategy(QueueContext& queue)
+ : QueueStrategy(queue) {}
+
+LowLatency2QueueStrategy::~LowLatency2QueueStrategy() {}
+
+} // namespace low_latency
diff --git a/src/strategies/low_latency2/queue_strategy.hh b/src/strategies/low_latency2/queue_strategy.hh
new file mode 100644
index 0000000..9688cf4
--- /dev/null
+++ b/src/strategies/low_latency2/queue_strategy.hh
@@ -0,0 +1,18 @@
+#ifndef STRATEGIES_LOW_LATENCY2_QUEUE_STRATEGY_HH_
+#define STRATEGIES_LOW_LATENCY2_QUEUE_STRATEGY_HH_
+
+#include "strategies/queue_strategy.hh"
+
+namespace low_latency {
+
+class QueueContext;
+
+class LowLatency2QueueStrategy final : public QueueStrategy {
+ public:
+ LowLatency2QueueStrategy(QueueContext& queue);
+ virtual ~LowLatency2QueueStrategy();
+};
+
+} // namespace low_latency
+
+#endif
diff --git a/src/strategies/queue_strategy.cc b/src/strategies/queue_strategy.cc
new file mode 100644
index 0000000..7b88e17
--- /dev/null
+++ b/src/strategies/queue_strategy.cc
@@ -0,0 +1,11 @@
+#include "queue_strategy.hh"
+
+#include "queue_context.hh"
+
+namespace low_latency {
+
+QueueStrategy::QueueStrategy(QueueContext& queue) : queue(queue) {}
+
+QueueStrategy::~QueueStrategy() {}
+
+} // namespace low_latency \ No newline at end of file
diff --git a/src/strategies/queue_strategy.hh b/src/strategies/queue_strategy.hh
new file mode 100644
index 0000000..0b9edc8
--- /dev/null
+++ b/src/strategies/queue_strategy.hh
@@ -0,0 +1,18 @@
+#ifndef STRATEGIES_QUEUE_STRATEGY_HH_
+#define STRATEGIES_QUEUE_STRATEGY_HH_
+
+namespace low_latency {
+
+class QueueContext;
+
+class QueueStrategy {
+ QueueContext& queue;
+
+ public:
+ QueueStrategy(QueueContext& queue);
+ virtual ~QueueStrategy();
+};
+
+} // namespace low_latency
+
+#endif \ No newline at end of file