rasterizer_interface.h 3.2 KB

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