From acbd88acea596c6866e215d291e279e9a728a931 Mon Sep 17 00:00:00 2001 From: TNTpower0v0 Date: Sat, 24 Jan 2026 17:49:46 +0300 Subject: [PATCH] Add P3 colors for MacOS if available --- .../net/vulkanmod/mixin/window/WindowMixin.java | 9 +++++++++ .../vulkanmod/vulkan/framebuffer/SwapChain.java | 17 ++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/vulkanmod/mixin/window/WindowMixin.java b/src/main/java/net/vulkanmod/mixin/window/WindowMixin.java index 4827f9043..a10b949da 100644 --- a/src/main/java/net/vulkanmod/mixin/window/WindowMixin.java +++ b/src/main/java/net/vulkanmod/mixin/window/WindowMixin.java @@ -61,6 +61,15 @@ private void redirect(int hint, int value) { } private void vulkanHint(WindowEventHandler windowEventHandler, ScreenManager screenManager, DisplayData displayData, String string, String string2, CallbackInfo ci) { GLFW.glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); + // Enable 32bit P3 wide color gamut on macOS + if (Platform.isMacOS()) { + GLFW.glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE); + GLFW.glfwWindowHint(GLFW_RED_BITS, 10); + GLFW.glfwWindowHint(GLFW_GREEN_BITS, 10); + GLFW.glfwWindowHint(GLFW_BLUE_BITS, 10); + GLFW.glfwWindowHint(GLFW_ALPHA_BITS, 2); + } + //Fix Gnome Client-Side Decorators boolean b = (Platform.isGnome() | Platform.isWeston() | Platform.isGeneric()) && Platform.isWayLand(); GLFW.glfwWindowHint(GLFW_DECORATED, (b ? GLFW_FALSE : GLFW_TRUE)); diff --git a/src/main/java/net/vulkanmod/vulkan/framebuffer/SwapChain.java b/src/main/java/net/vulkanmod/vulkan/framebuffer/SwapChain.java index 9fe29eec7..33160712f 100644 --- a/src/main/java/net/vulkanmod/vulkan/framebuffer/SwapChain.java +++ b/src/main/java/net/vulkanmod/vulkan/framebuffer/SwapChain.java @@ -9,6 +9,7 @@ import net.vulkanmod.vulkan.queue.Queue; import net.vulkanmod.vulkan.texture.SamplerManager; import net.vulkanmod.vulkan.texture.VulkanImage; +import net.vulkanmod.config.Platform; import org.lwjgl.system.MemoryStack; import org.lwjgl.vulkan.*; @@ -243,12 +244,25 @@ public long getImageView(int i) { private VkSurfaceFormatKHR getFormat(VkSurfaceFormatKHR.Buffer availableFormats) { List list = availableFormats.stream().toList(); - VkSurfaceFormatKHR format = list.get(0); + // Extended sRGB (P3 gamut with sRGB gamma) on macOS + if (Platform.isMacOS()) { + for (VkSurfaceFormatKHR f : list) { + if (f.format() == VK_FORMAT_B8G8R8A8_UNORM && f.colorSpace() == 1000104001) { + isBGRAformat = true; + return f; + } + } + } + // If fail try RGBA format with standard sRGB for (VkSurfaceFormatKHR availableFormat : list) { if (availableFormat.format() == VK_FORMAT_R8G8B8A8_UNORM && availableFormat.colorSpace() == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR) return availableFormat; + } + // Standard BGRA sRGB + VkSurfaceFormatKHR format = list.get(0); + for (VkSurfaceFormatKHR availableFormat : list) { if (availableFormat.format() == VK_FORMAT_B8G8R8A8_UNORM && availableFormat.colorSpace() == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR) { format = availableFormat; } @@ -256,6 +270,7 @@ private VkSurfaceFormatKHR getFormat(VkSurfaceFormatKHR.Buffer availableFormats) if (format.format() == VK_FORMAT_B8G8R8A8_UNORM) isBGRAformat = true; + return format; }