diff options
| author | Nicolas James <nj3ahxac@gmail.com> | 2026-03-29 20:44:23 +1100 |
|---|---|---|
| committer | Nicolas James <nj3ahxac@gmail.com> | 2026-03-29 20:44:23 +1100 |
| commit | 681bd5096ee416b50dd7338de30af7b3db385a36 (patch) | |
| tree | 358b6bc6f9a3af66729b8ac3b15dd38cc0f4bd2a /src/helper.hh | |
| parent | d5ef2dbbd77c69dd93e92d5b7046a65c2361b59b (diff) | |
Implement Reflex - break AntiLag in the process. Remove AntiLag1. WIP
Diffstat (limited to 'src/helper.hh')
| -rw-r--r-- | src/helper.hh | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/helper.hh b/src/helper.hh new file mode 100644 index 0000000..468f146 --- /dev/null +++ b/src/helper.hh @@ -0,0 +1,59 @@ +#ifndef HELPER_HH_ +#define HELPER_HH_ + +#include <vulkan/vk_layer.h> +#include <vulkan/vulkan.h> + +#include <cstdint> + +namespace low_latency { + +// Small templates which allow us to SFINAE find pNext structs. +template <typename T> +static T* find_next(void* const head, const VkStructureType& stype) { + for (auto i = reinterpret_cast<VkBaseOutStructure*>(head)->pNext; i; + i = i->pNext) { + + if (i->sType == stype) { + return reinterpret_cast<T*>(i); + } + } + return nullptr; +} + +template <typename T> +static const T* find_next(const void* const head, + const VkStructureType& stype) { + + for (auto i = reinterpret_cast<const VkBaseInStructure*>(head)->pNext; i; + i = i->pNext) { + + if (i->sType == stype) { + return reinterpret_cast<const T*>(i); + } + } + return nullptr; +} + +template <typename T> +static const T* find_link(const void* const head, + const VkStructureType& stype) { + for (auto info = find_next<T>(head, stype); info; + info = find_next<T>(info, stype)) { + + if (info->function == VK_LAYER_LINK_INFO) { + return reinterpret_cast<const T*>(info); + } + } + return nullptr; +} + +template <typename T> std::uint64_t extract_present_id(const T& submit) { + const auto lspi = find_next<VkLatencySubmissionPresentIdNV>( + &submit, VK_STRUCTURE_TYPE_LATENCY_SUBMISSION_PRESENT_ID_NV); + return lspi ? lspi->presentID : 0; +} + +} // namespace low_latency + +#endif
\ No newline at end of file |
