rasterizer_interface.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. namespace Tegra {
  11. class MemoryManager;
  12. }
  13. namespace VideoCore {
  14. enum class LoadCallbackStage {
  15. Prepare,
  16. Decompile,
  17. Build,
  18. Complete,
  19. };
  20. using DiskResourceLoadCallback = std::function<void(LoadCallbackStage, std::size_t, std::size_t)>;
  21. class RasterizerInterface {
  22. public:
  23. virtual ~RasterizerInterface() {}
  24. /// Draw the current batch of vertex arrays
  25. virtual bool DrawBatch(bool is_indexed) = 0;
  26. /// Draw the current batch of multiple instances of vertex arrays
  27. virtual bool DrawMultiBatch(bool is_indexed) = 0;
  28. /// Clear the current framebuffer
  29. virtual void Clear() = 0;
  30. /// Dispatches a compute shader invocation
  31. virtual void DispatchCompute(GPUVAddr code_addr) = 0;
  32. /// Notify rasterizer that all caches should be flushed to Switch memory
  33. virtual void FlushAll() = 0;
  34. /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
  35. virtual void FlushRegion(CacheAddr addr, u64 size) = 0;
  36. /// Notify rasterizer that any caches of the specified region should be invalidated
  37. virtual void InvalidateRegion(CacheAddr addr, u64 size) = 0;
  38. /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
  39. /// and invalidated
  40. virtual void FlushAndInvalidateRegion(CacheAddr addr, u64 size) = 0;
  41. /// Notify the rasterizer to send all written commands to the host GPU.
  42. virtual void FlushCommands() = 0;
  43. /// Notify rasterizer that a frame is about to finish
  44. virtual void TickFrame() = 0;
  45. /// Attempt to use a faster method to perform a surface copy
  46. virtual bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src,
  47. const Tegra::Engines::Fermi2D::Regs::Surface& dst,
  48. const Tegra::Engines::Fermi2D::Config& copy_config) {
  49. return false;
  50. }
  51. /// Attempt to use a faster method to display the framebuffer to screen
  52. virtual bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr,
  53. u32 pixel_stride) {
  54. return false;
  55. }
  56. /// Increase/decrease the number of object in pages touching the specified region
  57. virtual void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) {}
  58. /// Initialize disk cached resources for the game being emulated
  59. virtual void LoadDiskResources(const std::atomic_bool& stop_loading = false,
  60. const DiskResourceLoadCallback& callback = {}) {}
  61. };
  62. } // namespace VideoCore