HwCapabilities.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using OpenTK.Graphics.OpenGL;
  2. using System;
  3. namespace Ryujinx.Graphics.OpenGL
  4. {
  5. static class HwCapabilities
  6. {
  7. private static Lazy<bool> _supportsAstcCompression = new Lazy<bool>(() => HasExtension("GL_KHR_texture_compression_astc_ldr"));
  8. private static Lazy<int> _storageBufferOffsetAlignment = new Lazy<int>(() => GetLimit(All.ShaderStorageBufferOffsetAlignment));
  9. public static bool SupportsAstcCompression => _supportsAstcCompression.Value;
  10. public static int StorageBufferOffsetAlignment => _storageBufferOffsetAlignment.Value;
  11. private static bool HasExtension(string name)
  12. {
  13. int numExtensions = GL.GetInteger(GetPName.NumExtensions);
  14. for (int extension = 0; extension < numExtensions; extension++)
  15. {
  16. if (GL.GetString(StringNameIndexed.Extensions, extension) == name)
  17. {
  18. return true;
  19. }
  20. }
  21. return false;
  22. }
  23. private static int GetLimit(All name)
  24. {
  25. return GL.GetInteger((GetPName)name);
  26. }
  27. }
  28. }