rasterizer_interface.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Copyright 2018 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <atomic>
  6. #include <functional>
  7. #include "common/common_types.h"
  8. #include "video_core/engines/fermi_2d.h"
  9. #include "video_core/gpu.h"
  10. #include "video_core/memory_manager.h"
  11. namespace VideoCore {
  12. enum class LoadCallbackStage {
  13. Prepare,
  14. Decompile,
  15. Build,
  16. Complete,
  17. };
  18. using DiskResourceLoadCallback = std::function<void(LoadCallbackStage, std::size_t, std::size_t)>;
  19. class RasterizerInterface {
  20. public:
  21. virtual ~RasterizerInterface() {}
  22. /// Draw the current batch of vertex arrays
  23. virtual void DrawArrays() = 0;
  24. /// Clear the current framebuffer
  25. virtual void Clear() = 0;
  26. /// Notify rasterizer that all caches should be flushed to Switch memory
  27. virtual void FlushAll() = 0;
  28. /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
  29. virtual void FlushRegion(VAddr addr, u64 size) = 0;
  30. /// Notify rasterizer that any caches of the specified region should be invalidated
  31. virtual void InvalidateRegion(VAddr addr, u64 size) = 0;
  32. /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
  33. /// and invalidated
  34. virtual void FlushAndInvalidateRegion(VAddr addr, u64 size) = 0;
  35. /// Attempt to use a faster method to perform a surface copy
  36. virtual bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src,
  37. const Tegra::Engines::Fermi2D::Regs::Surface& dst,
  38. const MathUtil::Rectangle<u32>& src_rect,
  39. const MathUtil::Rectangle<u32>& dst_rect) {
  40. return false;
  41. }
  42. /// Attempt to use a faster method to display the framebuffer to screen
  43. virtual bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr,
  44. u32 pixel_stride) {
  45. return false;
  46. }
  47. virtual bool AccelerateDrawBatch(bool is_indexed) {
  48. return false;
  49. }
  50. /// Increase/decrease the number of object in pages touching the specified region
  51. virtual void UpdatePagesCachedCount(Tegra::GPUVAddr addr, u64 size, int delta) {}
  52. /// Initialize disk cached resources for the game being emulated
  53. virtual void LoadDiskResources(const std::atomic_bool& stop_loading = false,
  54. const DiskResourceLoadCallback& callback = {}) {}
  55. };
  56. } // namespace VideoCore