kepler_compute.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright 2018 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <bitset>
  5. #include "common/assert.h"
  6. #include "common/logging/log.h"
  7. #include "core/core.h"
  8. #include "video_core/engines/kepler_compute.h"
  9. #include "video_core/engines/maxwell_3d.h"
  10. #include "video_core/memory_manager.h"
  11. #include "video_core/rasterizer_interface.h"
  12. #include "video_core/renderer_base.h"
  13. #include "video_core/textures/decoders.h"
  14. namespace Tegra::Engines {
  15. KeplerCompute::KeplerCompute(Core::System& system_, MemoryManager& memory_manager_)
  16. : system{system_}, memory_manager{memory_manager_}, upload_state{memory_manager, regs.upload} {}
  17. KeplerCompute::~KeplerCompute() = default;
  18. void KeplerCompute::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) {
  19. rasterizer = rasterizer_;
  20. upload_state.BindRasterizer(rasterizer);
  21. }
  22. void KeplerCompute::CallMethod(u32 method, u32 method_argument, bool is_last_call) {
  23. ASSERT_MSG(method < Regs::NUM_REGS,
  24. "Invalid KeplerCompute register, increase the size of the Regs structure");
  25. regs.reg_array[method] = method_argument;
  26. switch (method) {
  27. case KEPLER_COMPUTE_REG_INDEX(exec_upload): {
  28. upload_state.ProcessExec(regs.exec_upload.linear != 0);
  29. break;
  30. }
  31. case KEPLER_COMPUTE_REG_INDEX(data_upload): {
  32. upload_state.ProcessData(method_argument, is_last_call);
  33. if (is_last_call) {
  34. }
  35. break;
  36. }
  37. case KEPLER_COMPUTE_REG_INDEX(launch):
  38. ProcessLaunch();
  39. break;
  40. default:
  41. break;
  42. }
  43. }
  44. void KeplerCompute::CallMultiMethod(u32 method, const u32* base_start, u32 amount,
  45. u32 methods_pending) {
  46. for (std::size_t i = 0; i < amount; i++) {
  47. CallMethod(method, base_start[i], methods_pending - static_cast<u32>(i) <= 1);
  48. }
  49. }
  50. void KeplerCompute::ProcessLaunch() {
  51. const GPUVAddr launch_desc_loc = regs.launch_desc_loc.Address();
  52. memory_manager.ReadBlockUnsafe(launch_desc_loc, &launch_description,
  53. LaunchParams::NUM_LAUNCH_PARAMETERS * sizeof(u32));
  54. rasterizer->DispatchCompute();
  55. }
  56. Texture::TICEntry KeplerCompute::GetTICEntry(u32 tic_index) const {
  57. const GPUVAddr tic_address_gpu{regs.tic.Address() + tic_index * sizeof(Texture::TICEntry)};
  58. Texture::TICEntry tic_entry;
  59. memory_manager.ReadBlockUnsafe(tic_address_gpu, &tic_entry, sizeof(Texture::TICEntry));
  60. return tic_entry;
  61. }
  62. Texture::TSCEntry KeplerCompute::GetTSCEntry(u32 tsc_index) const {
  63. const GPUVAddr tsc_address_gpu{regs.tsc.Address() + tsc_index * sizeof(Texture::TSCEntry)};
  64. Texture::TSCEntry tsc_entry;
  65. memory_manager.ReadBlockUnsafe(tsc_address_gpu, &tsc_entry, sizeof(Texture::TSCEntry));
  66. return tsc_entry;
  67. }
  68. } // namespace Tegra::Engines