TextureMsaaMode.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. namespace Ryujinx.Graphics.Gpu.Image
  2. {
  3. /// <summary>
  4. /// Multisampled texture samples count.
  5. /// </summary>
  6. enum TextureMsaaMode
  7. {
  8. Ms1x1 = 0,
  9. Ms2x2 = 2,
  10. Ms4x2 = 4,
  11. Ms2x1 = 5,
  12. Ms4x4 = 6
  13. }
  14. static class TextureMsaaModeConverter
  15. {
  16. /// <summary>
  17. /// Returns the total number of samples from the MSAA mode.
  18. /// </summary>
  19. /// <param name="msaaMode">The MSAA mode</param>
  20. /// <returns>The total number of samples</returns>
  21. public static int SamplesCount(this TextureMsaaMode msaaMode)
  22. {
  23. return msaaMode switch
  24. {
  25. TextureMsaaMode.Ms2x1 => 2,
  26. TextureMsaaMode.Ms2x2 => 4,
  27. TextureMsaaMode.Ms4x2 => 8,
  28. TextureMsaaMode.Ms4x4 => 16,
  29. _ => 1
  30. };
  31. }
  32. /// <summary>
  33. /// Returns the number of samples in the X direction from the MSAA mode.
  34. /// </summary>
  35. /// <param name="msaaMode">The MSAA mode</param>
  36. /// <returns>The number of samples in the X direction</returns>
  37. public static int SamplesInX(this TextureMsaaMode msaaMode)
  38. {
  39. return msaaMode switch
  40. {
  41. TextureMsaaMode.Ms2x1 => 2,
  42. TextureMsaaMode.Ms2x2 => 2,
  43. TextureMsaaMode.Ms4x2 => 4,
  44. TextureMsaaMode.Ms4x4 => 4,
  45. _ => 1
  46. };
  47. }
  48. /// <summary>
  49. /// Returns the number of samples in the Y direction from the MSAA mode.
  50. /// </summary>
  51. /// <param name="msaaMode">The MSAA mode</param>
  52. /// <returns>The number of samples in the Y direction</returns>
  53. public static int SamplesInY(this TextureMsaaMode msaaMode)
  54. {
  55. return msaaMode switch
  56. {
  57. TextureMsaaMode.Ms2x1 => 1,
  58. TextureMsaaMode.Ms2x2 => 2,
  59. TextureMsaaMode.Ms4x2 => 2,
  60. TextureMsaaMode.Ms4x4 => 4,
  61. _ => 1
  62. };
  63. }
  64. }
  65. }