Renderer.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.MaximumViewportDimensions,
  51. HwCapabilities.MaximumComputeSharedMemorySize,
  52. HwCapabilities.StorageBufferOffsetAlignment);
  53. }
  54. public ulong GetCounter(CounterType type)
  55. {
  56. return _counters.GetCounter(type);
  57. }
  58. public void InitializeCounters()
  59. {
  60. _counters.Initialize();
  61. }
  62. public void ResetCounter(CounterType type)
  63. {
  64. _counters.ResetCounter(type);
  65. }
  66. }
  67. }