2019-12-29 18:41:50 +01:00
|
|
|
using Ryujinx.Graphics.GAL;
|
2021-09-02 05:17:43 +02:00
|
|
|
using Ryujinx.Graphics.Shader;
|
2019-10-13 08:02:07 +02:00
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Gpu.Image
|
|
|
|
{
|
2019-12-30 00:26:37 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Texture target.
|
|
|
|
/// </summary>
|
2020-11-17 22:20:17 +01:00
|
|
|
enum TextureTarget : byte
|
2019-10-13 08:02:07 +02:00
|
|
|
{
|
|
|
|
Texture1D,
|
|
|
|
Texture2D,
|
|
|
|
Texture3D,
|
|
|
|
Cubemap,
|
|
|
|
Texture1DArray,
|
|
|
|
Texture2DArray,
|
|
|
|
TextureBuffer,
|
2019-12-16 05:59:46 +01:00
|
|
|
Texture2DRect,
|
2023-07-02 02:47:54 +02:00
|
|
|
CubemapArray,
|
2019-10-13 08:02:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static class TextureTargetConverter
|
|
|
|
{
|
2019-12-30 00:26:37 +01:00
|
|
|
/// <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>
|
2019-10-13 08:02:07 +02:00
|
|
|
public static Target Convert(this TextureTarget target, bool isMultisample)
|
|
|
|
{
|
|
|
|
if (isMultisample)
|
|
|
|
{
|
|
|
|
switch (target)
|
|
|
|
{
|
2023-07-02 02:47:54 +02:00
|
|
|
case TextureTarget.Texture2D:
|
|
|
|
return Target.Texture2DMultisample;
|
|
|
|
case TextureTarget.Texture2DArray:
|
|
|
|
return Target.Texture2DMultisampleArray;
|
2019-10-13 08:02:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (target)
|
|
|
|
{
|
2023-07-02 02:47:54 +02:00
|
|
|
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;
|
2019-10-13 08:02:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Target.Texture1D;
|
|
|
|
}
|
2021-09-02 05:17:43 +02:00
|
|
|
|
|
|
|
/// <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
|
|
|
|
{
|
2023-07-02 02:47:54 +02:00
|
|
|
TextureTarget.Texture1D => SamplerType.Texture1D,
|
|
|
|
TextureTarget.Texture2D => SamplerType.Texture2D,
|
|
|
|
TextureTarget.Texture3D => SamplerType.Texture3D,
|
|
|
|
TextureTarget.Cubemap => SamplerType.TextureCube,
|
2021-09-02 05:17:43 +02:00
|
|
|
TextureTarget.Texture1DArray => SamplerType.Texture1D | SamplerType.Array,
|
|
|
|
TextureTarget.Texture2DArray => SamplerType.Texture2D | SamplerType.Array,
|
2023-07-02 02:47:54 +02:00
|
|
|
TextureTarget.TextureBuffer => SamplerType.TextureBuffer,
|
|
|
|
TextureTarget.Texture2DRect => SamplerType.Texture2D,
|
|
|
|
TextureTarget.CubemapArray => SamplerType.TextureCube | SamplerType.Array,
|
|
|
|
_ => SamplerType.Texture2D,
|
2021-09-02 05:17:43 +02:00
|
|
|
};
|
|
|
|
}
|
2019-10-13 08:02:07 +02:00
|
|
|
}
|
2023-07-02 02:47:54 +02:00
|
|
|
}
|