Renderer.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using OpenTK.Graphics.OpenGL;
  2. using Ryujinx.Graphics.GAL;
  3. using Ryujinx.Graphics.Shader;
  4. namespace Ryujinx.Graphics.OpenGL
  5. {
  6. public sealed class Renderer : IRenderer
  7. {
  8. private Pipeline _pipeline;
  9. public IPipeline Pipeline => _pipeline;
  10. private readonly Counters _counters;
  11. private readonly Window _window;
  12. public IWindow Window => _window;
  13. internal TextureCopy TextureCopy { get; }
  14. public Renderer()
  15. {
  16. _pipeline = new Pipeline();
  17. _counters = new Counters();
  18. _window = new Window();
  19. TextureCopy = new TextureCopy();
  20. }
  21. public IShader CompileShader(ShaderProgram shader)
  22. {
  23. return new Shader(shader);
  24. }
  25. public IBuffer CreateBuffer(int size)
  26. {
  27. return new Buffer(size);
  28. }
  29. public IProgram CreateProgram(IShader[] shaders)
  30. {
  31. return new Program(shaders);
  32. }
  33. public ISampler CreateSampler(SamplerCreateInfo info)
  34. {
  35. return new Sampler(info);
  36. }
  37. public ITexture CreateTexture(TextureCreateInfo info)
  38. {
  39. return new TextureStorage(this, info).CreateDefaultView();
  40. }
  41. public void FlushPipelines()
  42. {
  43. GL.Finish();
  44. }
  45. public Capabilities GetCapabilities()
  46. {
  47. return new Capabilities(
  48. HwCapabilities.SupportsAstcCompression,
  49. HwCapabilities.SupportsNonConstantTextureOffset,
  50. HwCapabilities.MaximumComputeSharedMemorySize,
  51. HwCapabilities.StorageBufferOffsetAlignment);
  52. }
  53. public ulong GetCounter(CounterType type)
  54. {
  55. return _counters.GetCounter(type);
  56. }
  57. public void InitializeCounters()
  58. {
  59. _counters.Initialize();
  60. }
  61. public void ResetCounter(CounterType type)
  62. {
  63. _counters.ResetCounter(type);
  64. }
  65. public void Dispose()
  66. {
  67. TextureCopy.Dispose();
  68. _pipeline.Dispose();
  69. _window.Dispose();
  70. }
  71. }
  72. }