1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
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,
};
}
}
}
|