rasterizer_interface.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 void DrawArrays() = 0;
  26. /// Clear the current framebuffer
  27. virtual void Clear() = 0;
  28. /// Dispatches a compute shader invocation
  29. virtual void DispatchCompute(GPUVAddr code_addr) = 0;
  30. /// Notify rasterizer that all caches should be flushed to Switch memory
  31. virtual void FlushAll() = 0;
  32. /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
  33. virtual void FlushRegion(CacheAddr addr, u64 size) = 0;
  34. /// Notify rasterizer that any caches of the specified region should be invalidated
  35. virtual void InvalidateRegion(CacheAddr addr, u64 size) = 0;
  36. /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
  37. /// and invalidated
  38. virtual void FlushAndInvalidateRegion(CacheAddr addr, u64 size) = 0;
  39. // Notify the rasterizer to send all written commands to the host GPU.
  40. virtual void FlushCommands() = 0;
  41. /// Notify rasterizer that a frame is about to finish
  42. virtual void TickFrame() = 0;
  43. /// Attempt to use a faster method to perform a surface copy
  44. virtual bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src,
  45. const Tegra::Engines::Fermi2D::Regs::Surface& dst,
  46. const Tegra::Engines::Fermi2D::Config& copy_config) {
  47. return false;
  48. }
  49. /// Attempt to use a faster method to display the framebuffer to screen
  50. virtual bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr,
  51. u32 pixel_stride) {
  52. return false;
  53. }
  54. virtual bool AccelerateDrawBatch(bool is_indexed) {
  55. return false;
  56. }
  57. /// Increase/decrease the number of object in pages touching the specified region
  58. virtual void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) {}
  59. /// Initialize disk cached resources for the game being emulated
  60. virtual void LoadDiskResources(const std::atomic_bool& stop_loading = false,
  61. const DiskResourceLoadCallback& callback = {}) {}
  62. };
  63. } // namespace VideoCore