From 77199093978153d519d52264f9ef8b40b0592d0f Mon Sep 17 00:00:00 2001
From: A-w-x <80461138+A-w-x@users.noreply.github.com>
Date: Sun, 18 Apr 2021 02:27:19 +0200
Subject: [PATCH] HwCapabilities: Divide Intel into IntelWindows and IntelUnix
 (#2219)

as suggested by gdkchan
---
 Ryujinx.Graphics.OpenGL/Framebuffer.cs       | 4 ++--
 Ryujinx.Graphics.OpenGL/HwCapabilities.cs    | 9 ++++++---
 Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs | 2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/Ryujinx.Graphics.OpenGL/Framebuffer.cs b/Ryujinx.Graphics.OpenGL/Framebuffer.cs
index 66bf892b31..e6b70376ca 100644
--- a/Ryujinx.Graphics.OpenGL/Framebuffer.cs
+++ b/Ryujinx.Graphics.OpenGL/Framebuffer.cs
@@ -41,7 +41,7 @@ namespace Ryujinx.Graphics.OpenGL
             FramebufferAttachment attachment = FramebufferAttachment.ColorAttachment0 + index;
 
             if (HwCapabilities.Vendor == HwCapabilities.GpuVendor.Amd ||
-                HwCapabilities.Vendor == HwCapabilities.GpuVendor.Intel)
+                HwCapabilities.Vendor == HwCapabilities.GpuVendor.IntelWindows)
             {
                 GL.FramebufferTexture(FramebufferTarget.Framebuffer, attachment, color?.GetIncompatibleFormatViewHandle() ?? 0, 0);
             }
@@ -95,7 +95,7 @@ namespace Ryujinx.Graphics.OpenGL
         public void SignalModified()
         {
             if (HwCapabilities.Vendor == HwCapabilities.GpuVendor.Amd ||
-                HwCapabilities.Vendor == HwCapabilities.GpuVendor.Intel)
+                HwCapabilities.Vendor == HwCapabilities.GpuVendor.IntelWindows)
             {
                 for (int i = 0; i < 8; i++)
                 {
diff --git a/Ryujinx.Graphics.OpenGL/HwCapabilities.cs b/Ryujinx.Graphics.OpenGL/HwCapabilities.cs
index c297ef0ead..6795b4234f 100644
--- a/Ryujinx.Graphics.OpenGL/HwCapabilities.cs
+++ b/Ryujinx.Graphics.OpenGL/HwCapabilities.cs
@@ -18,7 +18,8 @@ namespace Ryujinx.Graphics.OpenGL
         {
             Unknown,
             Amd,
-            Intel,
+            IntelWindows,
+            IntelUnix,
             Nvidia
         }
 
@@ -34,7 +35,7 @@ namespace Ryujinx.Graphics.OpenGL
         public static bool SupportsViewportSwizzle           => _supportsViewportSwizzle.Value;
         public static bool SupportsSeamlessCubemapPerTexture => _supportsSeamlessCubemapPerTexture.Value;
         public static bool SupportsNonConstantTextureOffset  => _gpuVendor.Value == GpuVendor.Nvidia;
-        public static bool RequiresSyncFlush                 => _gpuVendor.Value == GpuVendor.Amd || _gpuVendor.Value == GpuVendor.Intel;
+        public static bool RequiresSyncFlush                 => _gpuVendor.Value == GpuVendor.Amd || _gpuVendor.Value == GpuVendor.IntelWindows || _gpuVendor.Value == GpuVendor.IntelUnix;
 
         public static int MaximumComputeSharedMemorySize => _maximumComputeSharedMemorySize.Value;
         public static int StorageBufferOffsetAlignment   => _storageBufferOffsetAlignment.Value;
@@ -71,7 +72,9 @@ namespace Ryujinx.Graphics.OpenGL
             }
             else if (vendor == "intel")
             {
-                return GpuVendor.Intel;
+                string renderer = GL.GetString(StringName.Renderer).ToLower();
+                
+                return renderer.Contains("mesa") ? GpuVendor.IntelUnix : GpuVendor.IntelWindows;
             }
             else if (vendor == "ati technologies inc." || vendor == "advanced micro devices, inc.")
             {
diff --git a/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs b/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs
index 621388ce05..e8dfcc4684 100644
--- a/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs
+++ b/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs
@@ -205,7 +205,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
                     int copyWidth = sizeInBlocks ? BitUtils.DivRoundUp(width, blockWidth) : width;
                     int copyHeight = sizeInBlocks ? BitUtils.DivRoundUp(height, blockHeight) : height;
 
-                    if (HwCapabilities.Vendor == HwCapabilities.GpuVendor.Intel)
+                    if (HwCapabilities.Vendor == HwCapabilities.GpuVendor.IntelWindows)
                     {
                         GL.CopyImageSubData(
                             src.Storage.Handle,