kepler_memory.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "common/assert.h"
  4. #include "common/logging/log.h"
  5. #include "core/core.h"
  6. #include "video_core/engines/kepler_memory.h"
  7. #include "video_core/engines/maxwell_3d.h"
  8. #include "video_core/memory_manager.h"
  9. #include "video_core/rasterizer_interface.h"
  10. namespace Tegra::Engines {
  11. KeplerMemory::KeplerMemory(Core::System& system_, MemoryManager& memory_manager)
  12. : system{system_}, upload_state{memory_manager, regs.upload} {}
  13. KeplerMemory::~KeplerMemory() = default;
  14. void KeplerMemory::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) {
  15. upload_state.BindRasterizer(rasterizer_);
  16. execution_mask.reset();
  17. execution_mask[KEPLERMEMORY_REG_INDEX(exec)] = true;
  18. execution_mask[KEPLERMEMORY_REG_INDEX(data)] = true;
  19. }
  20. void KeplerMemory::ConsumeSinkImpl() {
  21. for (auto [method, value] : method_sink) {
  22. regs.reg_array[method] = value;
  23. }
  24. method_sink.clear();
  25. }
  26. void KeplerMemory::CallMethod(u32 method, u32 method_argument, bool is_last_call) {
  27. ASSERT_MSG(method < Regs::NUM_REGS,
  28. "Invalid KeplerMemory register, increase the size of the Regs structure");
  29. regs.reg_array[method] = method_argument;
  30. switch (method) {
  31. case KEPLERMEMORY_REG_INDEX(exec): {
  32. upload_state.ProcessExec(regs.exec.linear != 0);
  33. break;
  34. }
  35. case KEPLERMEMORY_REG_INDEX(data): {
  36. upload_state.ProcessData(method_argument, is_last_call);
  37. break;
  38. }
  39. }
  40. }
  41. void KeplerMemory::CallMultiMethod(u32 method, const u32* base_start, u32 amount,
  42. u32 methods_pending) {
  43. switch (method) {
  44. case KEPLERMEMORY_REG_INDEX(data):
  45. upload_state.ProcessData(base_start, amount);
  46. return;
  47. default:
  48. for (u32 i = 0; i < amount; i++) {
  49. CallMethod(method, base_start[i], methods_pending - i <= 1);
  50. }
  51. break;
  52. }
  53. }
  54. } // namespace Tegra::Engines