Renderer.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using OpenTK.Graphics.OpenGL;
  2. using Ryujinx.Graphics.GAL;
  3. using Ryujinx.Graphics.Shader;
  4. namespace Ryujinx.Graphics.OpenGL
  5. {
  6. public class Renderer : IRenderer
  7. {
  8. public IPipeline Pipeline { get; }
  9. private readonly Counters _counters;
  10. private readonly Window _window;
  11. public IWindow Window => _window;
  12. internal TextureCopy TextureCopy { get; }
  13. public Renderer()
  14. {
  15. Pipeline = new Pipeline();
  16. _counters = new Counters();
  17. _window = new Window();
  18. TextureCopy = new TextureCopy();
  19. }
  20. public IShader CompileShader(ShaderProgram shader)
  21. {
  22. return new Shader(shader);
  23. }
  24. public IBuffer CreateBuffer(int size)
  25. {
  26. return new Buffer(size);
  27. }
  28. public IProgram CreateProgram(IShader[] shaders)
  29. {
  30. return new Program(shaders);
  31. }
  32. public ISampler CreateSampler(SamplerCreateInfo info)
  33. {
  34. return new Sampler(info);
  35. }
  36. public ITexture CreateTexture(TextureCreateInfo info)
  37. {
  38. return new TextureStorage(this, info).CreateDefaultView();
  39. }
  40. public void FlushPipelines()
  41. {
  42. GL.Finish();
  43. }
  44. public Capabilities GetCapabilities()
  45. {
  46. return new Capabilities(
  47. HwCapabilities.SupportsAstcCompression,
  48. HwCapabilities.SupportsNonConstantTextureOffset,
  49. HwCapabilities.MaximumViewportDimensions,
  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. }
  66. }