kepler_memory.h 2.4 KB

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