kepler_memory.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 <vector>
  8. #include "common/bit_field.h"
  9. #include "common/common_funcs.h"
  10. #include "common/common_types.h"
  11. #include "video_core/engines/engine_upload.h"
  12. #include "video_core/gpu.h"
  13. namespace Core {
  14. class System;
  15. }
  16. namespace Tegra {
  17. class MemoryManager;
  18. }
  19. namespace Tegra::Engines {
  20. /**
  21. * This Engine is known as P2MF. Documentation can be found in:
  22. * https://github.com/envytools/envytools/blob/master/rnndb/graph/gk104_p2mf.xml
  23. * https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/nouveau/nvc0/nve4_p2mf.xml.h
  24. */
  25. #define KEPLERMEMORY_REG_INDEX(field_name) \
  26. (offsetof(Tegra::Engines::KeplerMemory::Regs, field_name) / sizeof(u32))
  27. class KeplerMemory final {
  28. public:
  29. KeplerMemory(Core::System& system, MemoryManager& memory_manager);
  30. ~KeplerMemory();
  31. /// Write the value to the register identified by method.
  32. void CallMethod(const GPU::MethodCall& method_call);
  33. struct Regs {
  34. static constexpr size_t NUM_REGS = 0x7F;
  35. union {
  36. struct {
  37. INSERT_PADDING_WORDS(0x60);
  38. Upload::Registers upload;
  39. struct {
  40. union {
  41. BitField<0, 1, u32> linear;
  42. };
  43. } exec;
  44. u32 data;
  45. INSERT_PADDING_WORDS(0x11);
  46. };
  47. std::array<u32, NUM_REGS> reg_array;
  48. };
  49. } regs{};
  50. private:
  51. Core::System& system;
  52. MemoryManager& memory_manager;
  53. Upload::State upload_state;
  54. };
  55. #define ASSERT_REG_POSITION(field_name, position) \
  56. static_assert(offsetof(KeplerMemory::Regs, field_name) == position * 4, \
  57. "Field " #field_name " has invalid position")
  58. ASSERT_REG_POSITION(upload, 0x60);
  59. ASSERT_REG_POSITION(exec, 0x6C);
  60. ASSERT_REG_POSITION(data, 0x6D);
  61. #undef ASSERT_REG_POSITION
  62. } // namespace Tegra::Engines