kepler_compute.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 <array>
  6. #include <cstddef>
  7. #include "common/common_funcs.h"
  8. #include "common/common_types.h"
  9. #include "video_core/gpu.h"
  10. #include "video_core/memory_manager.h"
  11. namespace Tegra::Engines {
  12. #define KEPLER_COMPUTE_REG_INDEX(field_name) \
  13. (offsetof(Tegra::Engines::KeplerCompute::Regs, field_name) / sizeof(u32))
  14. class KeplerCompute final {
  15. public:
  16. explicit KeplerCompute(MemoryManager& memory_manager);
  17. ~KeplerCompute();
  18. static constexpr std::size_t NumConstBuffers = 8;
  19. struct Regs {
  20. static constexpr std::size_t NUM_REGS = 0xCF8;
  21. union {
  22. struct {
  23. INSERT_PADDING_WORDS(0xAF);
  24. u32 launch;
  25. INSERT_PADDING_WORDS(0xC48);
  26. };
  27. std::array<u32, NUM_REGS> reg_array;
  28. };
  29. } regs{};
  30. static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32),
  31. "KeplerCompute Regs has wrong size");
  32. MemoryManager& memory_manager;
  33. /// Write the value to the register identified by method.
  34. void CallMethod(const GPU::MethodCall& method_call);
  35. };
  36. #define ASSERT_REG_POSITION(field_name, position) \
  37. static_assert(offsetof(KeplerCompute::Regs, field_name) == position * 4, \
  38. "Field " #field_name " has invalid position")
  39. ASSERT_REG_POSITION(launch, 0xAF);
  40. #undef ASSERT_REG_POSITION
  41. } // namespace Tegra::Engines