Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/net/vulkanmod/mixin/window/WindowMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/net/vulkanmod/vulkan/framebuffer/SwapChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down Expand Up @@ -243,19 +244,33 @@ public long getImageView(int i) {
private VkSurfaceFormatKHR getFormat(VkSurfaceFormatKHR.Buffer availableFormats) {
List<VkSurfaceFormatKHR> 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;
}
}

if (format.format() == VK_FORMAT_B8G8R8A8_UNORM)
isBGRAformat = true;

return format;
}

Expand Down