gpu.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_types.h"
  6. namespace GPU {
  7. struct Registers {
  8. u32 framebuffer_top_left_1;
  9. u32 framebuffer_top_left_2;
  10. u32 framebuffer_top_right_1;
  11. u32 framebuffer_top_right_2;
  12. u32 framebuffer_sub_left_1;
  13. u32 framebuffer_sub_left_2;
  14. u32 framebuffer_sub_right_1;
  15. u32 framebuffer_sub_right_2;
  16. u32 command_list_size;
  17. u32 command_list_address;
  18. u32 command_processing_enabled;
  19. };
  20. extern Registers g_regs;
  21. enum {
  22. TOP_ASPECT_X = 0x5,
  23. TOP_ASPECT_Y = 0x3,
  24. TOP_HEIGHT = 240,
  25. TOP_WIDTH = 400,
  26. BOTTOM_WIDTH = 320,
  27. // Physical addresses in FCRAM used by ARM9 applications - these are correct for real hardware
  28. PADDR_FRAMEBUFFER_SEL = 0x20184E59,
  29. PADDR_TOP_LEFT_FRAME1 = 0x20184E60,
  30. PADDR_TOP_LEFT_FRAME2 = 0x201CB370,
  31. PADDR_TOP_RIGHT_FRAME1 = 0x20282160,
  32. PADDR_TOP_RIGHT_FRAME2 = 0x202C8670,
  33. PADDR_SUB_FRAME1 = 0x202118E0,
  34. PADDR_SUB_FRAME2 = 0x20249CF0,
  35. // Physical addresses in VRAM - I'm not sure how these are actually allocated (so not real)
  36. PADDR_VRAM_FRAMEBUFFER_SEL = 0x18184E59,
  37. PADDR_VRAM_TOP_LEFT_FRAME1 = 0x18184E60,
  38. PADDR_VRAM_TOP_LEFT_FRAME2 = 0x181CB370,
  39. PADDR_VRAM_TOP_RIGHT_FRAME1 = 0x18282160,
  40. PADDR_VRAM_TOP_RIGHT_FRAME2 = 0x182C8670,
  41. PADDR_VRAM_SUB_FRAME1 = 0x182118E0,
  42. PADDR_VRAM_SUB_FRAME2 = 0x18249CF0,
  43. };
  44. enum {
  45. REG_FRAMEBUFFER_TOP_LEFT_1 = 0x1EF00468, // Main LCD, first framebuffer for 3D left
  46. REG_FRAMEBUFFER_TOP_LEFT_2 = 0x1EF0046C, // Main LCD, second framebuffer for 3D left
  47. REG_FRAMEBUFFER_TOP_RIGHT_1 = 0x1EF00494, // Main LCD, first framebuffer for 3D right
  48. REG_FRAMEBUFFER_TOP_RIGHT_2 = 0x1EF00498, // Main LCD, second framebuffer for 3D right
  49. REG_FRAMEBUFFER_SUB_LEFT_1 = 0x1EF00568, // Sub LCD, first framebuffer
  50. REG_FRAMEBUFFER_SUB_LEFT_2 = 0x1EF0056C, // Sub LCD, second framebuffer
  51. REG_FRAMEBUFFER_SUB_RIGHT_1 = 0x1EF00594, // Sub LCD, unused first framebuffer
  52. REG_FRAMEBUFFER_SUB_RIGHT_2 = 0x1EF00598, // Sub LCD, unused second framebuffer
  53. CommandListSize = 0x1EF018E0,
  54. CommandListAddress = 0x1EF018E8,
  55. ProcessCommandList = 0x1EF018F0,
  56. };
  57. /// Framebuffer location
  58. enum FramebufferLocation {
  59. FRAMEBUFFER_LOCATION_UNKNOWN, ///< Framebuffer location is unknown
  60. FRAMEBUFFER_LOCATION_FCRAM, ///< Framebuffer is in the GSP heap
  61. FRAMEBUFFER_LOCATION_VRAM, ///< Framebuffer is in VRAM
  62. };
  63. /**
  64. * Sets whether the framebuffers are in the GSP heap (FCRAM) or VRAM
  65. * @param
  66. */
  67. void SetFramebufferLocation(const FramebufferLocation mode);
  68. /**
  69. * Gets a read-only pointer to a framebuffer in memory
  70. * @param address Physical address of framebuffer
  71. * @return Returns const pointer to raw framebuffer
  72. */
  73. const u8* GetFramebufferPointer(const u32 address);
  74. /**
  75. * Gets the location of the framebuffers
  76. */
  77. const FramebufferLocation GetFramebufferLocation();
  78. template <typename T>
  79. inline void Read(T &var, const u32 addr);
  80. template <typename T>
  81. inline void Write(u32 addr, const T data);
  82. /// Update hardware
  83. void Update();
  84. /// Initialize hardware
  85. void Init();
  86. /// Shutdown hardware
  87. void Shutdown();
  88. } // namespace