From e71da4fb747aaff45eafd40bbbd62638b4d659c7 Mon Sep 17 00:00:00 2001
From: greggameplayer <33609333+greggameplayer@users.noreply.github.com>
Date: Mon, 16 Jul 2018 20:09:34 +0200
Subject: [PATCH] Implement BC6H_SF16 & BC6H_UF16 Texture Formats (#255)

* Implement BC6H_SF16 & BC6H_UF16

* correct coding style (1/5)

* correct coding style (2/5)

* correct coding style (3/5)

* correct coding style (4/5)

* correct coding style (5/5)
---
 Ryujinx.Graphics/Gal/GalTextureFormat.cs        |  2 ++
 Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs | 16 +++++++++-------
 Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs       |  4 +++-
 Ryujinx.HLE/Gpu/Texture/TextureHelper.cs        |  2 ++
 Ryujinx.HLE/Gpu/Texture/TextureReader.cs        |  2 ++
 5 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/Ryujinx.Graphics/Gal/GalTextureFormat.cs b/Ryujinx.Graphics/Gal/GalTextureFormat.cs
index 231d33ec0e..30f5c22974 100644
--- a/Ryujinx.Graphics/Gal/GalTextureFormat.cs
+++ b/Ryujinx.Graphics/Gal/GalTextureFormat.cs
@@ -6,6 +6,8 @@ namespace Ryujinx.Graphics.Gal
         R16G16B16A16 = 0x3,
         A8B8G8R8     = 0x8,
         R32          = 0xf,
+        BC6H_SF16    = 0x10,
+        BC6H_UF16    = 0x11,
         A1B5G5R5     = 0x14,
         B5G6R5       = 0x15,
         BC7U         = 0x17,
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs
index 8f189d2b08..5d20c931ef 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs
@@ -148,12 +148,14 @@ namespace Ryujinx.Graphics.Gal.OpenGL
         {
             switch (Format)
             {
-                case GalTextureFormat.BC7U: return InternalFormat.CompressedRgbaBptcUnorm;
-                case GalTextureFormat.BC1:  return InternalFormat.CompressedRgbaS3tcDxt1Ext;
-                case GalTextureFormat.BC2:  return InternalFormat.CompressedRgbaS3tcDxt3Ext;
-                case GalTextureFormat.BC3:  return InternalFormat.CompressedRgbaS3tcDxt5Ext;
-                case GalTextureFormat.BC4:  return InternalFormat.CompressedRedRgtc1;
-                case GalTextureFormat.BC5:  return InternalFormat.CompressedRgRgtc2;
+                case GalTextureFormat.BC6H_UF16: return InternalFormat.CompressedRgbBptcUnsignedFloat;
+                case GalTextureFormat.BC6H_SF16: return InternalFormat.CompressedRgbBptcSignedFloat;
+                case GalTextureFormat.BC7U:      return InternalFormat.CompressedRgbaBptcUnorm;
+                case GalTextureFormat.BC1:       return InternalFormat.CompressedRgbaS3tcDxt1Ext;
+                case GalTextureFormat.BC2:       return InternalFormat.CompressedRgbaS3tcDxt3Ext;
+                case GalTextureFormat.BC3:       return InternalFormat.CompressedRgbaS3tcDxt5Ext;
+                case GalTextureFormat.BC4:       return InternalFormat.CompressedRedRgtc1;
+                case GalTextureFormat.BC5:       return InternalFormat.CompressedRgRgtc2;
             }
 
             throw new NotImplementedException(Format.ToString());
@@ -264,4 +266,4 @@ namespace Ryujinx.Graphics.Gal.OpenGL
             throw new ArgumentException(nameof(BlendFactor));
         }
     }
-}
\ No newline at end of file
+}
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
index 5caca6ecde..ac30e6fd81 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
@@ -212,6 +212,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
         {
             switch (Format)
             {
+                case GalTextureFormat.BC6H_UF16:
+                case GalTextureFormat.BC6H_SF16:
                 case GalTextureFormat.BC7U:
                 case GalTextureFormat.BC1:
                 case GalTextureFormat.BC2:
@@ -224,4 +226,4 @@ namespace Ryujinx.Graphics.Gal.OpenGL
             return false;
         }
     }
-}
\ No newline at end of file
+}
diff --git a/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs b/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs
index c0749d6a25..dbbc87d409 100644
--- a/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs
+++ b/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs
@@ -54,6 +54,8 @@ namespace Ryujinx.HLE.Gpu.Texture
                     return CompressedTextureSize(Texture.Width, Texture.Height, 4, 4, 8);
                 }
 
+                case GalTextureFormat.BC6H_SF16:
+                case GalTextureFormat.BC6H_UF16:
                 case GalTextureFormat.BC7U:
                 case GalTextureFormat.BC2:
                 case GalTextureFormat.BC3:
diff --git a/Ryujinx.HLE/Gpu/Texture/TextureReader.cs b/Ryujinx.HLE/Gpu/Texture/TextureReader.cs
index 6c08cd6c4d..1d8c8056a6 100644
--- a/Ryujinx.HLE/Gpu/Texture/TextureReader.cs
+++ b/Ryujinx.HLE/Gpu/Texture/TextureReader.cs
@@ -19,6 +19,8 @@ namespace Ryujinx.HLE.Gpu.Texture
                 case GalTextureFormat.G8R8:         return Read2Bpp                  (Memory, Texture);
                 case GalTextureFormat.R16:          return Read2Bpp                  (Memory, Texture);
                 case GalTextureFormat.R8:           return Read1Bpp                  (Memory, Texture);
+                case GalTextureFormat.BC6H_SF16:    return Read16BptCompressedTexture(Memory, Texture, 4, 4);
+                case GalTextureFormat.BC6H_UF16:    return Read16BptCompressedTexture(Memory, Texture, 4, 4);
                 case GalTextureFormat.BC7U:         return Read16BptCompressedTexture(Memory, Texture, 4, 4);
                 case GalTextureFormat.BC1:          return Read8Bpt4x4               (Memory, Texture);
                 case GalTextureFormat.BC2:          return Read16BptCompressedTexture(Memory, Texture, 4, 4);