regs_rasterizer.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // Copyright 2017 Citra 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/bit_field.h"
  7. #include "common/common_funcs.h"
  8. #include "common/common_types.h"
  9. #include "video_core/pica_types.h"
  10. namespace Pica {
  11. struct RasterizerRegs {
  12. enum class CullMode : u32 {
  13. // Select which polygons are considered to be "frontfacing".
  14. KeepAll = 0,
  15. KeepClockWise = 1,
  16. KeepCounterClockWise = 2,
  17. // TODO: What does the third value imply?
  18. };
  19. union {
  20. BitField<0, 2, CullMode> cull_mode;
  21. };
  22. BitField<0, 24, u32> viewport_size_x;
  23. INSERT_PADDING_WORDS(0x1);
  24. BitField<0, 24, u32> viewport_size_y;
  25. INSERT_PADDING_WORDS(0x3);
  26. BitField<0, 1, u32> clip_enable;
  27. BitField<0, 24, u32> clip_coef[4]; // float24
  28. Math::Vec4<float24> GetClipCoef() const {
  29. return {float24::FromRaw(clip_coef[0]), float24::FromRaw(clip_coef[1]),
  30. float24::FromRaw(clip_coef[2]), float24::FromRaw(clip_coef[3])};
  31. }
  32. INSERT_PADDING_WORDS(0x1);
  33. BitField<0, 24, u32> viewport_depth_range; // float24
  34. BitField<0, 24, u32> viewport_depth_near_plane; // float24
  35. BitField<0, 3, u32> vs_output_total;
  36. union VSOutputAttributes {
  37. // Maps components of output vertex attributes to semantics
  38. enum Semantic : u32 {
  39. POSITION_X = 0,
  40. POSITION_Y = 1,
  41. POSITION_Z = 2,
  42. POSITION_W = 3,
  43. QUATERNION_X = 4,
  44. QUATERNION_Y = 5,
  45. QUATERNION_Z = 6,
  46. QUATERNION_W = 7,
  47. COLOR_R = 8,
  48. COLOR_G = 9,
  49. COLOR_B = 10,
  50. COLOR_A = 11,
  51. TEXCOORD0_U = 12,
  52. TEXCOORD0_V = 13,
  53. TEXCOORD1_U = 14,
  54. TEXCOORD1_V = 15,
  55. TEXCOORD0_W = 16,
  56. VIEW_X = 18,
  57. VIEW_Y = 19,
  58. VIEW_Z = 20,
  59. TEXCOORD2_U = 22,
  60. TEXCOORD2_V = 23,
  61. INVALID = 31,
  62. };
  63. BitField<0, 5, Semantic> map_x;
  64. BitField<8, 5, Semantic> map_y;
  65. BitField<16, 5, Semantic> map_z;
  66. BitField<24, 5, Semantic> map_w;
  67. } vs_output_attributes[7];
  68. INSERT_PADDING_WORDS(0xe);
  69. enum class ScissorMode : u32 {
  70. Disabled = 0,
  71. Exclude = 1, // Exclude pixels inside the scissor box
  72. Include = 3 // Exclude pixels outside the scissor box
  73. };
  74. struct {
  75. BitField<0, 2, ScissorMode> mode;
  76. union {
  77. BitField<0, 10, u32> x1;
  78. BitField<16, 10, u32> y1;
  79. };
  80. union {
  81. BitField<0, 10, u32> x2;
  82. BitField<16, 10, u32> y2;
  83. };
  84. } scissor_test;
  85. union {
  86. BitField<0, 10, s32> x;
  87. BitField<16, 10, s32> y;
  88. } viewport_corner;
  89. INSERT_PADDING_WORDS(0x1);
  90. // TODO: early depth
  91. INSERT_PADDING_WORDS(0x1);
  92. INSERT_PADDING_WORDS(0x2);
  93. enum DepthBuffering : u32 {
  94. WBuffering = 0,
  95. ZBuffering = 1,
  96. };
  97. BitField<0, 1, DepthBuffering> depthmap_enable;
  98. INSERT_PADDING_WORDS(0x12);
  99. };
  100. static_assert(sizeof(RasterizerRegs) == 0x40 * sizeof(u32),
  101. "RasterizerRegs struct has incorrect size");
  102. } // namespace Pica