diff options
Diffstat (limited to 'src/libs/dxvk-native-1.9.2a/src/vulkan/vulkan_presenter_headless.cpp')
-rw-r--r-- | src/libs/dxvk-native-1.9.2a/src/vulkan/vulkan_presenter_headless.cpp | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/src/libs/dxvk-native-1.9.2a/src/vulkan/vulkan_presenter_headless.cpp b/src/libs/dxvk-native-1.9.2a/src/vulkan/vulkan_presenter_headless.cpp new file mode 100644 index 00000000..998e13e7 --- /dev/null +++ b/src/libs/dxvk-native-1.9.2a/src/vulkan/vulkan_presenter_headless.cpp @@ -0,0 +1,177 @@ +#include "vulkan_presenter.h" + +#include "../dxvk/dxvk_format.h" +#include "../wsi/wsi_presenter.h" + +namespace dxvk::vk { + + Presenter::Presenter( + HWND window, + const Rc<InstanceFn>& vki, + const Rc<DeviceFn>& vkd, + PresenterDevice device, + const PresenterDesc& desc) + : m_vki(vki), m_vkd(vkd), m_device(device), m_window(window) { + } + + + Presenter::~Presenter() { + } + + + PresenterInfo Presenter::info() const { + return m_info; + } + + + PresenterImage Presenter::getImage(uint32_t index) const { + return m_images.at(index); + } + + + VkResult Presenter::acquireNextImage(PresenterSync& sync, uint32_t& index) { + return VK_SUCCESS; + } + + + VkResult Presenter::presentImage() { + return VK_SUCCESS; + } + + + VkResult Presenter::recreateSwapChain(const PresenterDesc& desc) { + return VK_SUCCESS; + } + + + void Presenter::setFrameRateLimit(double frameRate) { + m_fpsLimiter.setTargetFrameRate(frameRate); + } + + + void Presenter::setFrameRateLimiterRefreshRate(double refreshRate) { + m_fpsLimiter.setDisplayRefreshRate(refreshRate); + } + + + VkResult Presenter::getSupportedFormats(std::vector<VkSurfaceFormatKHR>& formats, const PresenterDesc& desc) { + return VK_SUCCESS; + } + + + VkResult Presenter::getSupportedPresentModes(std::vector<VkPresentModeKHR>& modes, const PresenterDesc& desc) { + return VK_SUCCESS; + } + + + VkResult Presenter::getSwapImages(std::vector<VkImage>& images) { + return VK_SUCCESS; + } + + + VkSurfaceFormatKHR Presenter::pickFormat( + uint32_t numSupported, + const VkSurfaceFormatKHR* pSupported, + uint32_t numDesired, + const VkSurfaceFormatKHR* pDesired) { + if (numDesired > 0) { + // If the implementation allows us to freely choose + // the format, we'll just use the preferred format. + if (numSupported == 1 && pSupported[0].format == VK_FORMAT_UNDEFINED) + return pDesired[0]; + + // If the preferred format is explicitly listed in + // the array of supported surface formats, use it + for (uint32_t i = 0; i < numDesired; i++) { + for (uint32_t j = 0; j < numSupported; j++) { + if (pSupported[j].format == pDesired[i].format + && pSupported[j].colorSpace == pDesired[i].colorSpace) + return pSupported[j]; + } + } + + // If that didn't work, we'll fall back to a format + // which has similar properties to the preferred one + DxvkFormatFlags prefFlags = imageFormatInfo(pDesired[0].format)->flags; + + for (uint32_t j = 0; j < numSupported; j++) { + auto currFlags = imageFormatInfo(pSupported[j].format)->flags; + + if ((currFlags & DxvkFormatFlag::ColorSpaceSrgb) + == (prefFlags & DxvkFormatFlag::ColorSpaceSrgb)) + return pSupported[j]; + } + } + + // Otherwise, fall back to the first supported format + return pSupported[0]; + } + + + VkPresentModeKHR Presenter::pickPresentMode( + uint32_t numSupported, + const VkPresentModeKHR* pSupported, + uint32_t numDesired, + const VkPresentModeKHR* pDesired) { + // Just pick the first desired and supported mode + for (uint32_t i = 0; i < numDesired; i++) { + for (uint32_t j = 0; j < numSupported; j++) { + if (pSupported[j] == pDesired[i]) + return pSupported[j]; + } + } + + // Guaranteed to be available + return VK_PRESENT_MODE_FIFO_KHR; + } + + + VkExtent2D Presenter::pickImageExtent( + const VkSurfaceCapabilitiesKHR& caps, + VkExtent2D desired) { + if (caps.currentExtent.width != std::numeric_limits<uint32_t>::max()) + return caps.currentExtent; + + VkExtent2D actual; + actual.width = clamp(desired.width, caps.minImageExtent.width, caps.maxImageExtent.width); + actual.height = clamp(desired.height, caps.minImageExtent.height, caps.maxImageExtent.height); + return actual; + } + + + uint32_t Presenter::pickImageCount( + const VkSurfaceCapabilitiesKHR& caps, + VkPresentModeKHR presentMode, + uint32_t desired) { + uint32_t count = caps.minImageCount; + + if (presentMode != VK_PRESENT_MODE_IMMEDIATE_KHR) + count = caps.minImageCount + 1; + + if (count < desired) + count = desired; + + if (count > caps.maxImageCount && caps.maxImageCount != 0) + count = caps.maxImageCount; + + return count; + } + + + VkResult Presenter::createSurface() { + return VK_SUCCESS; + } + + + void Presenter::destroySwapchain() { + m_images.clear(); + m_semaphores.clear(); + + m_swapchain = VK_NULL_HANDLE; + } + + + void Presenter::destroySurface() { + } + +} |