gpu_asynch.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright 2019 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "core/core.h"
  5. #include "core/hardware_interrupt_manager.h"
  6. #include "video_core/gpu_asynch.h"
  7. #include "video_core/gpu_thread.h"
  8. #include "video_core/renderer_base.h"
  9. namespace VideoCommon {
  10. GPUAsynch::GPUAsynch(Core::System& system, std::unique_ptr<VideoCore::RendererBase>&& renderer_,
  11. std::unique_ptr<Core::Frontend::GraphicsContext>&& context)
  12. : GPU(system, std::move(renderer_), true), gpu_thread{system},
  13. cpu_context(renderer->GetRenderWindow().CreateSharedContext()),
  14. gpu_context(std::move(context)) {}
  15. GPUAsynch::~GPUAsynch() = default;
  16. void GPUAsynch::Start() {
  17. gpu_thread.StartThread(*renderer, *gpu_context, *dma_pusher);
  18. }
  19. void GPUAsynch::ObtainContext() {
  20. cpu_context->MakeCurrent();
  21. }
  22. void GPUAsynch::ReleaseContext() {
  23. cpu_context->DoneCurrent();
  24. }
  25. void GPUAsynch::PushGPUEntries(Tegra::CommandList&& entries) {
  26. gpu_thread.SubmitList(std::move(entries));
  27. }
  28. void GPUAsynch::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) {
  29. gpu_thread.SwapBuffers(framebuffer);
  30. }
  31. void GPUAsynch::FlushRegion(VAddr addr, u64 size) {
  32. gpu_thread.FlushRegion(addr, size);
  33. }
  34. void GPUAsynch::InvalidateRegion(VAddr addr, u64 size) {
  35. gpu_thread.InvalidateRegion(addr, size);
  36. }
  37. void GPUAsynch::FlushAndInvalidateRegion(VAddr addr, u64 size) {
  38. gpu_thread.FlushAndInvalidateRegion(addr, size);
  39. }
  40. void GPUAsynch::TriggerCpuInterrupt(const u32 syncpoint_id, const u32 value) const {
  41. auto& interrupt_manager = system.InterruptManager();
  42. interrupt_manager.GPUInterruptSyncpt(syncpoint_id, value);
  43. }
  44. void GPUAsynch::WaitIdle() const {
  45. gpu_thread.WaitIdle();
  46. }
  47. void GPUAsynch::OnCommandListEnd() {
  48. gpu_thread.OnCommandListEnd();
  49. }
  50. } // namespace VideoCommon