Renderer.cs 1.9 KB

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