kepler_memory.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 "common/assert.h"
  7. #include "common/bit_field.h"
  8. #include "common/common_funcs.h"
  9. #include "common/common_types.h"
  10. #include "video_core/gpu.h"
  11. #include "video_core/memory_manager.h"
  12. namespace VideoCore {
  13. class RasterizerInterface;
  14. }
  15. namespace Tegra::Engines {
  16. #define KEPLERMEMORY_REG_INDEX(field_name) \
  17. (offsetof(Tegra::Engines::KeplerMemory::Regs, field_name) / sizeof(u32))
  18. class KeplerMemory final {
  19. public:
  20. KeplerMemory(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager);
  21. ~KeplerMemory();
  22. /// Write the value to the register identified by method.
  23. void CallMethod(const GPU::MethodCall& method_call);
  24. struct Regs {
  25. static constexpr size_t NUM_REGS = 0x7F;
  26. union {
  27. struct {
  28. INSERT_PADDING_WORDS(0x60);
  29. u32 line_length_in;
  30. u32 line_count;
  31. struct {
  32. u32 address_high;
  33. u32 address_low;
  34. u32 pitch;
  35. u32 block_dimensions;
  36. u32 width;
  37. u32 height;
  38. u32 depth;
  39. u32 z;
  40. u32 x;
  41. u32 y;
  42. GPUVAddr Address() const {
  43. return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) |
  44. address_low);
  45. }
  46. } dest;
  47. struct {
  48. union {
  49. BitField<0, 1, u32> linear;
  50. };
  51. } exec;
  52. u32 data;
  53. INSERT_PADDING_WORDS(0x11);
  54. };
  55. std::array<u32, NUM_REGS> reg_array;
  56. };
  57. } regs{};
  58. struct {
  59. u32 write_offset = 0;
  60. } state{};
  61. private:
  62. MemoryManager& memory_manager;
  63. VideoCore::RasterizerInterface& rasterizer;
  64. void ProcessData(u32 data);
  65. };
  66. #define ASSERT_REG_POSITION(field_name, position) \
  67. static_assert(offsetof(KeplerMemory::Regs, field_name) == position * 4, \
  68. "Field " #field_name " has invalid position")
  69. ASSERT_REG_POSITION(line_length_in, 0x60);
  70. ASSERT_REG_POSITION(line_count, 0x61);
  71. ASSERT_REG_POSITION(dest, 0x62);
  72. ASSERT_REG_POSITION(exec, 0x6C);
  73. ASSERT_REG_POSITION(data, 0x6D);
  74. #undef ASSERT_REG_POSITION
  75. } // namespace Tegra::Engines