aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs
diff options
context:
space:
mode:
authorTSR Berry <20988865+TSRBerry@users.noreply.github.com>2023-04-08 01:22:00 +0200
committerMary <thog@protonmail.com>2023-04-27 23:51:14 +0200
commitcee712105850ac3385cd0091a923438167433f9f (patch)
tree4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs
parentcd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff)
Move solution and projects to src
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs')
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs
new file mode 100644
index 00000000..5e0a0721
--- /dev/null
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs
@@ -0,0 +1,81 @@
+using Ryujinx.Graphics.GAL;
+using Ryujinx.Graphics.Shader;
+
+namespace Ryujinx.Graphics.Gpu.Image
+{
+ /// <summary>
+ /// Texture target.
+ /// </summary>
+ enum TextureTarget : byte
+ {
+ Texture1D,
+ Texture2D,
+ Texture3D,
+ Cubemap,
+ Texture1DArray,
+ Texture2DArray,
+ TextureBuffer,
+ Texture2DRect,
+ CubemapArray
+ }
+
+ static class TextureTargetConverter
+ {
+ /// <summary>
+ /// Converts the texture target enum to a host compatible, Graphics Abstraction Layer enum.
+ /// </summary>
+ /// <param name="target">The target enum to convert</param>
+ /// <param name="isMultisample">True if the texture is a multisampled texture</param>
+ /// <returns>The host compatible texture target</returns>
+ public static Target Convert(this TextureTarget target, bool isMultisample)
+ {
+ if (isMultisample)
+ {
+ switch (target)
+ {
+ case TextureTarget.Texture2D: return Target.Texture2DMultisample;
+ case TextureTarget.Texture2DArray: return Target.Texture2DMultisampleArray;
+ }
+ }
+ else
+ {
+ switch (target)
+ {
+ case TextureTarget.Texture1D: return Target.Texture1D;
+ case TextureTarget.Texture2D: return Target.Texture2D;
+ case TextureTarget.Texture2DRect: return Target.Texture2D;
+ case TextureTarget.Texture3D: return Target.Texture3D;
+ case TextureTarget.Texture1DArray: return Target.Texture1DArray;
+ case TextureTarget.Texture2DArray: return Target.Texture2DArray;
+ case TextureTarget.Cubemap: return Target.Cubemap;
+ case TextureTarget.CubemapArray: return Target.CubemapArray;
+ case TextureTarget.TextureBuffer: return Target.TextureBuffer;
+ }
+ }
+
+ return Target.Texture1D;
+ }
+
+ /// <summary>
+ /// Converts the texture target enum to a shader sampler type.
+ /// </summary>
+ /// <param name="target">The target enum to convert</param>
+ /// <returns>The shader sampler type</returns>
+ public static SamplerType ConvertSamplerType(this TextureTarget target)
+ {
+ return target switch
+ {
+ TextureTarget.Texture1D => SamplerType.Texture1D,
+ TextureTarget.Texture2D => SamplerType.Texture2D,
+ TextureTarget.Texture3D => SamplerType.Texture3D,
+ TextureTarget.Cubemap => SamplerType.TextureCube,
+ TextureTarget.Texture1DArray => SamplerType.Texture1D | SamplerType.Array,
+ TextureTarget.Texture2DArray => SamplerType.Texture2D | SamplerType.Array,
+ TextureTarget.TextureBuffer => SamplerType.TextureBuffer,
+ TextureTarget.Texture2DRect => SamplerType.Texture2D,
+ TextureTarget.CubemapArray => SamplerType.TextureCube | SamplerType.Array,
+ _ => SamplerType.Texture2D
+ };
+ }
+ }
+} \ No newline at end of file