diff --git a/src/common/Matrix.h b/src/common/Matrix.h index 76e71dd1c..77586b9bd 100644 --- a/src/common/Matrix.h +++ b/src/common/Matrix.h @@ -83,16 +83,6 @@ public: **/ void operator *= (const Matrix4 &m); - static friend bool operator==(const Matrix4& first, const Matrix4& other) - { - for (int i = 0; i < 16; i++) { - if (first.e[i] != other.e[i]) { - return false; - } - } - return true; - } - /** * Gets a pointer to the 16 array elements. * @return The array elements. diff --git a/src/modules/graphics/Shader.h b/src/modules/graphics/Shader.h index 348943239..862e9f268 100644 --- a/src/modules/graphics/Shader.h +++ b/src/modules/graphics/Shader.h @@ -178,14 +178,6 @@ public: Vector4 normalMatrix[3]; // 3x3 matrix padded to an array of 3 vector4s. Vector4 screenSizeParams; Colorf constantColor; - - bool operator==(const BuiltinUniformData& other) { - auto first = *this; - return first.transformMatrix == other.transformMatrix && first.projectionMatrix == other.projectionMatrix - && first.normalMatrix[0] == other.normalMatrix[0] && first.normalMatrix[1] == other.normalMatrix[1] - && first.normalMatrix[2] == other.normalMatrix[2] && first.screenSizeParams == other.screenSizeParams - && first.constantColor == other.constantColor; - } }; // Pointer to currently active Shader. diff --git a/src/modules/graphics/vulkan/Graphics.cpp b/src/modules/graphics/vulkan/Graphics.cpp index e974d0421..9f5ec9632 100644 --- a/src/modules/graphics/vulkan/Graphics.cpp +++ b/src/modules/graphics/vulkan/Graphics.cpp @@ -972,14 +972,30 @@ VkSurfaceFormatKHR Graphics::chooseSwapSurfaceFormat(const std::vector& availablePresentModes) { - // needed ? - for (const auto& availablePresentMode : availablePresentModes) { - if (availablePresentMode == VK_PRESENT_MODE_MAILBOX_KHR) { - return availablePresentMode; + int vsync = Vulkan::getVsync(); + + switch (vsync) { + case -1: { + auto it = std::find(availablePresentModes.begin(), availablePresentModes.end(), VK_PRESENT_MODE_FIFO_RELAXED_KHR); + if (it != availablePresentModes.end()) { + return VK_PRESENT_MODE_FIFO_RELAXED_KHR; } } - - return VK_PRESENT_MODE_FIFO_KHR; + case 1: { + auto it = std::find(availablePresentModes.begin(), availablePresentModes.end(), VK_PRESENT_MODE_MAILBOX_KHR); + if (it != availablePresentModes.end()) { + return VK_PRESENT_MODE_MAILBOX_KHR; + } + } + case 0: { + auto it = std::find(availablePresentModes.begin(), availablePresentModes.end(), VK_PRESENT_MODE_IMMEDIATE_KHR); + if (it != availablePresentModes.end()) { + return VK_PRESENT_MODE_IMMEDIATE_KHR; + } + } + default: + return VK_PRESENT_MODE_FIFO_KHR; + } } VkExtent2D Graphics::chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities) { diff --git a/src/modules/graphics/vulkan/Vulkan.cpp b/src/modules/graphics/vulkan/Vulkan.cpp index a7aadc7c2..bced12665 100644 --- a/src/modules/graphics/vulkan/Vulkan.cpp +++ b/src/modules/graphics/vulkan/Vulkan.cpp @@ -7,6 +7,7 @@ namespace love { namespace graphics { namespace vulkan { static uint32_t numShaderSwitches; +static int vsync = 1; void Vulkan::shaderSwitch() { numShaderSwitches++; @@ -20,6 +21,14 @@ void Vulkan::resetShaderSwitches() { numShaderSwitches = 0; } +void Vulkan::setVsync(int value) { + vsync = value; +} + +int Vulkan::getVsync() { + return vsync; +} + VkFormat Vulkan::getVulkanVertexFormat(DataFormat format) { switch (format) { case DATAFORMAT_FLOAT: diff --git a/src/modules/graphics/vulkan/Vulkan.h b/src/modules/graphics/vulkan/Vulkan.h index ef9106f76..55b7578f7 100644 --- a/src/modules/graphics/vulkan/Vulkan.h +++ b/src/modules/graphics/vulkan/Vulkan.h @@ -30,6 +30,9 @@ public: static uint32_t getNumShaderSwitches(); static void resetShaderSwitches(); + static void setVsync(int vsync); + static int getVsync(); + static VkFormat getVulkanVertexFormat(DataFormat format); static TextureFormat getTextureFormat(PixelFormat); static std::string getVendorName(uint32_t vendorId); diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index bf59fad64..db3e575ae 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -21,7 +21,10 @@ // LOVE #include "common/config.h" #include "graphics/Graphics.h" -#include "graphics/vulkan/Graphics.h" +#ifdef LOVE_GRAPHICS_VULKAN +# include "graphics/vulkan/Graphics.h" +# include "graphics/vulkan/Vulkan.h" +#endif #include "Window.h" #ifdef LOVE_ANDROID @@ -1116,6 +1119,9 @@ void Window::setVSync(int vsync) } // fixme: doesn't work for vulkan yet. +#ifdef LOVE_GRAPHICS_VULKAN + love::graphics::vulkan::Vulkan::setVsync(vsync); +#endif #if defined(LOVE_GRAPHICS_METAL) && defined(LOVE_MACOS) if (metalView != nullptr)