Render.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // Copyright 2008 Dolphin Emulator Project
  2. // Licensed under GPLv2+
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <string>
  6. #include "VideoCommon/RenderBase.h"
  7. namespace OGL
  8. {
  9. void ClearEFBCache();
  10. enum GLSL_VERSION
  11. {
  12. GLSL_130,
  13. GLSL_140,
  14. GLSL_150, // and above
  15. GLSLES_300, // GLES 3.0
  16. GLSLES_310, // GLES 3.1
  17. };
  18. // ogl-only config, so not in VideoConfig.h
  19. struct VideoConfig
  20. {
  21. bool bSupportsGLSLCache;
  22. bool bSupportsGLPinnedMemory;
  23. bool bSupportsGLSync;
  24. bool bSupportsGLBaseVertex;
  25. bool bSupportsGLBufferStorage;
  26. bool bSupportsMSAA;
  27. bool bSupportSampleShading;
  28. GLSL_VERSION eSupportedGLSLVersion;
  29. bool bSupportOGL31;
  30. bool bSupportViewportFloat;
  31. bool bSupportsAEP;
  32. bool bSupportsDebug;
  33. const char* gl_vendor;
  34. const char* gl_renderer;
  35. const char* gl_version;
  36. const char* glsl_version;
  37. s32 max_samples;
  38. };
  39. extern VideoConfig g_ogl_config;
  40. class Renderer : public ::Renderer
  41. {
  42. public:
  43. Renderer();
  44. ~Renderer();
  45. static void Init();
  46. static void Shutdown();
  47. void SetColorMask() override;
  48. void SetBlendMode(bool forceUpdate) override;
  49. void SetScissorRect(const EFBRectangle& rc) override;
  50. void SetGenerationMode() override;
  51. void SetDepthMode() override;
  52. void SetLogicOpMode() override;
  53. void SetDitherMode() override;
  54. void SetSamplerState(int stage, int texindex, bool custom_tex) override;
  55. void SetInterlacingMode() override;
  56. void SetViewport() override;
  57. // TODO: Implement and use these
  58. void ApplyState(bool bUseDstAlpha) override {}
  59. void RestoreState() override {}
  60. void RenderText(const std::string& text, int left, int top, u32 color) override;
  61. void ShowEfbCopyRegions();
  62. void FlipImageData(u8 *data, int w, int h, int pixel_width = 3);
  63. u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) override;
  64. void PokeEFB(EFBAccessType type, const std::vector<EfbPokeData>& data) override;
  65. u16 BBoxRead(int index) override;
  66. void BBoxWrite(int index, u16 value) override;
  67. void ResetAPIState() override;
  68. void RestoreAPIState() override;
  69. TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) override;
  70. void SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, float Gamma) override;
  71. void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override;
  72. void ReinterpretPixelData(unsigned int convtype) override;
  73. bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc) override;
  74. int GetMaxTextureSize() override;
  75. private:
  76. void UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRectangle& efbPixelRc, const TargetRectangle& targetPixelRc, const void* data);
  77. void BlitScreen(TargetRectangle src, TargetRectangle dst, GLuint src_texture, int src_width, int src_height);
  78. };
  79. }