aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs
blob: d5abb9e55730b64a12bab69ebd85ea0f2ddd6574 (plain) (blame)
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
namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
    /// <summary>
    /// Result of a shader cache load operation.
    /// </summary>
    enum DiskCacheLoadResult
    {
        /// <summary>
        /// No error.
        /// </summary>
        Success,

        /// <summary>
        /// File can't be accessed.
        /// </summary>
        NoAccess,

        /// <summary>
        /// The constant buffer 1 data length is too low for the translation of the guest shader.
        /// </summary>
        InvalidCb1DataLength,

        /// <summary>
        /// The cache is missing the length of a texture array used by the shader.
        /// </summary>
        MissingTextureArrayLength,

        /// <summary>
        /// The cache is missing the descriptor of a texture used by the shader.
        /// </summary>
        MissingTextureDescriptor,

        /// <summary>
        /// File is corrupted.
        /// </summary>
        FileCorruptedGeneric,

        /// <summary>
        /// File is corrupted, detected by magic value check.
        /// </summary>
        FileCorruptedInvalidMagic,

        /// <summary>
        /// File is corrupted, detected by length check.
        /// </summary>
        FileCorruptedInvalidLength,

        /// <summary>
        /// File might be valid, but is incompatible with the current emulator version.
        /// </summary>
        IncompatibleVersion,
    }

    static class DiskCacheLoadResultExtensions
    {
        /// <summary>
        /// Gets an error message from a result code.
        /// </summary>
        /// <param name="result">Result code</param>
        /// <returns>Error message</returns>
        public static string GetMessage(this DiskCacheLoadResult result)
        {
            return result switch
            {
                DiskCacheLoadResult.Success => "No error.",
                DiskCacheLoadResult.NoAccess => "Could not access the cache file.",
                DiskCacheLoadResult.InvalidCb1DataLength => "Constant buffer 1 data length is too low.",
                DiskCacheLoadResult.MissingTextureArrayLength => "Texture array length missing from the cache file.",
                DiskCacheLoadResult.MissingTextureDescriptor => "Texture descriptor missing from the cache file.",
                DiskCacheLoadResult.FileCorruptedGeneric => "The cache file is corrupted.",
                DiskCacheLoadResult.FileCorruptedInvalidMagic => "Magic check failed, the cache file is corrupted.",
                DiskCacheLoadResult.FileCorruptedInvalidLength => "Length check failed, the cache file is corrupted.",
                DiskCacheLoadResult.IncompatibleVersion => "The version of the disk cache is not compatible with this version of the emulator.",
                _ => "Unknown error.",
            };
        }
    }
}