maxwell_3d.h 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515
  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 <bitset>
  7. #include <type_traits>
  8. #include <unordered_map>
  9. #include <vector>
  10. #include "common/assert.h"
  11. #include "common/bit_field.h"
  12. #include "common/common_funcs.h"
  13. #include "common/common_types.h"
  14. #include "common/math_util.h"
  15. #include "video_core/engines/const_buffer_engine_interface.h"
  16. #include "video_core/engines/const_buffer_info.h"
  17. #include "video_core/engines/engine_upload.h"
  18. #include "video_core/engines/shader_type.h"
  19. #include "video_core/gpu.h"
  20. #include "video_core/macro_interpreter.h"
  21. #include "video_core/textures/texture.h"
  22. namespace Core {
  23. class System;
  24. }
  25. namespace Tegra {
  26. class MemoryManager;
  27. }
  28. namespace VideoCore {
  29. class RasterizerInterface;
  30. }
  31. namespace Tegra::Engines {
  32. /**
  33. * This Engine is known as GF100_3D. Documentation can be found in:
  34. * https://github.com/envytools/envytools/blob/master/rnndb/graph/gf100_3d.xml
  35. * https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h
  36. */
  37. #define MAXWELL3D_REG_INDEX(field_name) \
  38. (offsetof(Tegra::Engines::Maxwell3D::Regs, field_name) / sizeof(u32))
  39. class Maxwell3D final : public ConstBufferEngineInterface {
  40. public:
  41. explicit Maxwell3D(Core::System& system, VideoCore::RasterizerInterface& rasterizer,
  42. MemoryManager& memory_manager);
  43. ~Maxwell3D() = default;
  44. /// Register structure of the Maxwell3D engine.
  45. /// TODO(Subv): This structure will need to be made bigger as more registers are discovered.
  46. struct Regs {
  47. static constexpr std::size_t NUM_REGS = 0xE00;
  48. static constexpr std::size_t NumRenderTargets = 8;
  49. static constexpr std::size_t NumViewports = 16;
  50. static constexpr std::size_t NumCBData = 16;
  51. static constexpr std::size_t NumVertexArrays = 32;
  52. static constexpr std::size_t NumVertexAttributes = 32;
  53. static constexpr std::size_t NumVaryings = 31;
  54. static constexpr std::size_t NumImages = 8; // TODO(Rodrigo): Investigate this number
  55. static constexpr std::size_t NumClipDistances = 8;
  56. static constexpr std::size_t MaxShaderProgram = 6;
  57. static constexpr std::size_t MaxShaderStage = 5;
  58. // Maximum number of const buffers per shader stage.
  59. static constexpr std::size_t MaxConstBuffers = 18;
  60. static constexpr std::size_t MaxConstBufferSize = 0x10000;
  61. enum class QueryMode : u32 {
  62. Write = 0,
  63. Sync = 1,
  64. // TODO(Subv): It is currently unknown what the difference between method 2 and method 0
  65. // is.
  66. Write2 = 2,
  67. };
  68. enum class QueryUnit : u32 {
  69. VFetch = 1,
  70. VP = 2,
  71. Rast = 4,
  72. StrmOut = 5,
  73. GP = 6,
  74. ZCull = 7,
  75. Prop = 10,
  76. Crop = 15,
  77. };
  78. enum class QuerySelect : u32 {
  79. Zero = 0,
  80. TimeElapsed = 2,
  81. TransformFeedbackPrimitivesGenerated = 11,
  82. PrimitivesGenerated = 18,
  83. SamplesPassed = 21,
  84. TransformFeedbackUnknown = 26,
  85. };
  86. struct QueryCompare {
  87. u32 initial_sequence;
  88. u32 initial_mode;
  89. u32 unknown1;
  90. u32 unknown2;
  91. u32 current_sequence;
  92. u32 current_mode;
  93. };
  94. enum class QuerySyncCondition : u32 {
  95. NotEqual = 0,
  96. GreaterThan = 1,
  97. };
  98. enum class ConditionMode : u32 {
  99. Never = 0,
  100. Always = 1,
  101. ResNonZero = 2,
  102. Equal = 3,
  103. NotEqual = 4,
  104. };
  105. enum class ShaderProgram : u32 {
  106. VertexA = 0,
  107. VertexB = 1,
  108. TesselationControl = 2,
  109. TesselationEval = 3,
  110. Geometry = 4,
  111. Fragment = 5,
  112. };
  113. struct VertexAttribute {
  114. enum class Size : u32 {
  115. Invalid = 0x0,
  116. Size_32_32_32_32 = 0x01,
  117. Size_32_32_32 = 0x02,
  118. Size_16_16_16_16 = 0x03,
  119. Size_32_32 = 0x04,
  120. Size_16_16_16 = 0x05,
  121. Size_8_8_8_8 = 0x0a,
  122. Size_16_16 = 0x0f,
  123. Size_32 = 0x12,
  124. Size_8_8_8 = 0x13,
  125. Size_8_8 = 0x18,
  126. Size_16 = 0x1b,
  127. Size_8 = 0x1d,
  128. Size_10_10_10_2 = 0x30,
  129. Size_11_11_10 = 0x31,
  130. };
  131. enum class Type : u32 {
  132. SignedNorm = 1,
  133. UnsignedNorm = 2,
  134. SignedInt = 3,
  135. UnsignedInt = 4,
  136. UnsignedScaled = 5,
  137. SignedScaled = 6,
  138. Float = 7,
  139. };
  140. union {
  141. BitField<0, 5, u32> buffer;
  142. BitField<6, 1, u32> constant;
  143. BitField<7, 14, u32> offset;
  144. BitField<21, 6, Size> size;
  145. BitField<27, 3, Type> type;
  146. BitField<31, 1, u32> bgra;
  147. u32 hex;
  148. };
  149. u32 ComponentCount() const {
  150. switch (size) {
  151. case Size::Size_32_32_32_32:
  152. return 4;
  153. case Size::Size_32_32_32:
  154. return 3;
  155. case Size::Size_16_16_16_16:
  156. return 4;
  157. case Size::Size_32_32:
  158. return 2;
  159. case Size::Size_16_16_16:
  160. return 3;
  161. case Size::Size_8_8_8_8:
  162. return 4;
  163. case Size::Size_16_16:
  164. return 2;
  165. case Size::Size_32:
  166. return 1;
  167. case Size::Size_8_8_8:
  168. return 3;
  169. case Size::Size_8_8:
  170. return 2;
  171. case Size::Size_16:
  172. return 1;
  173. case Size::Size_8:
  174. return 1;
  175. case Size::Size_10_10_10_2:
  176. return 4;
  177. case Size::Size_11_11_10:
  178. return 3;
  179. default:
  180. UNREACHABLE();
  181. return 1;
  182. }
  183. }
  184. u32 SizeInBytes() const {
  185. switch (size) {
  186. case Size::Size_32_32_32_32:
  187. return 16;
  188. case Size::Size_32_32_32:
  189. return 12;
  190. case Size::Size_16_16_16_16:
  191. return 8;
  192. case Size::Size_32_32:
  193. return 8;
  194. case Size::Size_16_16_16:
  195. return 6;
  196. case Size::Size_8_8_8_8:
  197. return 4;
  198. case Size::Size_16_16:
  199. return 4;
  200. case Size::Size_32:
  201. return 4;
  202. case Size::Size_8_8_8:
  203. return 3;
  204. case Size::Size_8_8:
  205. return 2;
  206. case Size::Size_16:
  207. return 2;
  208. case Size::Size_8:
  209. return 1;
  210. case Size::Size_10_10_10_2:
  211. return 4;
  212. case Size::Size_11_11_10:
  213. return 4;
  214. default:
  215. UNREACHABLE();
  216. }
  217. }
  218. std::string SizeString() const {
  219. switch (size) {
  220. case Size::Size_32_32_32_32:
  221. return "32_32_32_32";
  222. case Size::Size_32_32_32:
  223. return "32_32_32";
  224. case Size::Size_16_16_16_16:
  225. return "16_16_16_16";
  226. case Size::Size_32_32:
  227. return "32_32";
  228. case Size::Size_16_16_16:
  229. return "16_16_16";
  230. case Size::Size_8_8_8_8:
  231. return "8_8_8_8";
  232. case Size::Size_16_16:
  233. return "16_16";
  234. case Size::Size_32:
  235. return "32";
  236. case Size::Size_8_8_8:
  237. return "8_8_8";
  238. case Size::Size_8_8:
  239. return "8_8";
  240. case Size::Size_16:
  241. return "16";
  242. case Size::Size_8:
  243. return "8";
  244. case Size::Size_10_10_10_2:
  245. return "10_10_10_2";
  246. case Size::Size_11_11_10:
  247. return "11_11_10";
  248. default:
  249. UNREACHABLE();
  250. return {};
  251. }
  252. }
  253. std::string TypeString() const {
  254. switch (type) {
  255. case Type::SignedNorm:
  256. return "SNORM";
  257. case Type::UnsignedNorm:
  258. return "UNORM";
  259. case Type::SignedInt:
  260. return "SINT";
  261. case Type::UnsignedInt:
  262. return "UINT";
  263. case Type::UnsignedScaled:
  264. return "USCALED";
  265. case Type::SignedScaled:
  266. return "SSCALED";
  267. case Type::Float:
  268. return "FLOAT";
  269. }
  270. UNREACHABLE();
  271. return {};
  272. }
  273. bool IsNormalized() const {
  274. return (type == Type::SignedNorm) || (type == Type::UnsignedNorm);
  275. }
  276. bool IsValid() const {
  277. return size != Size::Invalid;
  278. }
  279. bool operator<(const VertexAttribute& other) const {
  280. return hex < other.hex;
  281. }
  282. };
  283. enum class PrimitiveTopology : u32 {
  284. Points = 0x0,
  285. Lines = 0x1,
  286. LineLoop = 0x2,
  287. LineStrip = 0x3,
  288. Triangles = 0x4,
  289. TriangleStrip = 0x5,
  290. TriangleFan = 0x6,
  291. Quads = 0x7,
  292. QuadStrip = 0x8,
  293. Polygon = 0x9,
  294. LinesAdjacency = 0xa,
  295. LineStripAdjacency = 0xb,
  296. TrianglesAdjacency = 0xc,
  297. TriangleStripAdjacency = 0xd,
  298. Patches = 0xe,
  299. };
  300. enum class IndexFormat : u32 {
  301. UnsignedByte = 0x0,
  302. UnsignedShort = 0x1,
  303. UnsignedInt = 0x2,
  304. };
  305. enum class ComparisonOp : u32 {
  306. // These values are used by Nouveau and most games, they correspond to the OpenGL token
  307. // values for these operations.
  308. Never = 0x200,
  309. Less = 0x201,
  310. Equal = 0x202,
  311. LessEqual = 0x203,
  312. Greater = 0x204,
  313. NotEqual = 0x205,
  314. GreaterEqual = 0x206,
  315. Always = 0x207,
  316. // These values are used by some games, they seem to be NV04 values.
  317. NeverOld = 1,
  318. LessOld = 2,
  319. EqualOld = 3,
  320. LessEqualOld = 4,
  321. GreaterOld = 5,
  322. NotEqualOld = 6,
  323. GreaterEqualOld = 7,
  324. AlwaysOld = 8,
  325. };
  326. enum class LogicOperation : u32 {
  327. Clear = 0x1500,
  328. And = 0x1501,
  329. AndReverse = 0x1502,
  330. Copy = 0x1503,
  331. AndInverted = 0x1504,
  332. NoOp = 0x1505,
  333. Xor = 0x1506,
  334. Or = 0x1507,
  335. Nor = 0x1508,
  336. Equiv = 0x1509,
  337. Invert = 0x150A,
  338. OrReverse = 0x150B,
  339. CopyInverted = 0x150C,
  340. OrInverted = 0x150D,
  341. Nand = 0x150E,
  342. Set = 0x150F,
  343. };
  344. enum class StencilOp : u32 {
  345. Keep = 1,
  346. Zero = 2,
  347. Replace = 3,
  348. Incr = 4,
  349. Decr = 5,
  350. Invert = 6,
  351. IncrWrap = 7,
  352. DecrWrap = 8,
  353. KeepOGL = 0x1E00,
  354. ZeroOGL = 0,
  355. ReplaceOGL = 0x1E01,
  356. IncrOGL = 0x1E02,
  357. DecrOGL = 0x1E03,
  358. InvertOGL = 0x150A,
  359. IncrWrapOGL = 0x8507,
  360. DecrWrapOGL = 0x8508,
  361. };
  362. enum class MemoryLayout : u32 {
  363. Linear = 0,
  364. BlockLinear = 1,
  365. };
  366. enum class InvMemoryLayout : u32 {
  367. BlockLinear = 0,
  368. Linear = 1,
  369. };
  370. struct Cull {
  371. enum class FrontFace : u32 {
  372. ClockWise = 0x0900,
  373. CounterClockWise = 0x0901,
  374. };
  375. enum class CullFace : u32 {
  376. Front = 0x0404,
  377. Back = 0x0405,
  378. FrontAndBack = 0x0408,
  379. };
  380. u32 enabled;
  381. FrontFace front_face;
  382. CullFace cull_face;
  383. };
  384. struct Blend {
  385. enum class Equation : u32 {
  386. Add = 1,
  387. Subtract = 2,
  388. ReverseSubtract = 3,
  389. Min = 4,
  390. Max = 5,
  391. // These values are used by Nouveau and some games.
  392. AddGL = 0x8006,
  393. SubtractGL = 0x8007,
  394. ReverseSubtractGL = 0x8008,
  395. MinGL = 0x800a,
  396. MaxGL = 0x800b
  397. };
  398. enum class Factor : u32 {
  399. Zero = 0x1,
  400. One = 0x2,
  401. SourceColor = 0x3,
  402. OneMinusSourceColor = 0x4,
  403. SourceAlpha = 0x5,
  404. OneMinusSourceAlpha = 0x6,
  405. DestAlpha = 0x7,
  406. OneMinusDestAlpha = 0x8,
  407. DestColor = 0x9,
  408. OneMinusDestColor = 0xa,
  409. SourceAlphaSaturate = 0xb,
  410. Source1Color = 0x10,
  411. OneMinusSource1Color = 0x11,
  412. Source1Alpha = 0x12,
  413. OneMinusSource1Alpha = 0x13,
  414. ConstantColor = 0x61,
  415. OneMinusConstantColor = 0x62,
  416. ConstantAlpha = 0x63,
  417. OneMinusConstantAlpha = 0x64,
  418. // These values are used by Nouveau and some games.
  419. ZeroGL = 0x4000,
  420. OneGL = 0x4001,
  421. SourceColorGL = 0x4300,
  422. OneMinusSourceColorGL = 0x4301,
  423. SourceAlphaGL = 0x4302,
  424. OneMinusSourceAlphaGL = 0x4303,
  425. DestAlphaGL = 0x4304,
  426. OneMinusDestAlphaGL = 0x4305,
  427. DestColorGL = 0x4306,
  428. OneMinusDestColorGL = 0x4307,
  429. SourceAlphaSaturateGL = 0x4308,
  430. ConstantColorGL = 0xc001,
  431. OneMinusConstantColorGL = 0xc002,
  432. ConstantAlphaGL = 0xc003,
  433. OneMinusConstantAlphaGL = 0xc004,
  434. Source1ColorGL = 0xc900,
  435. OneMinusSource1ColorGL = 0xc901,
  436. Source1AlphaGL = 0xc902,
  437. OneMinusSource1AlphaGL = 0xc903,
  438. };
  439. u32 separate_alpha;
  440. Equation equation_rgb;
  441. Factor factor_source_rgb;
  442. Factor factor_dest_rgb;
  443. Equation equation_a;
  444. Factor factor_source_a;
  445. Factor factor_dest_a;
  446. INSERT_UNION_PADDING_WORDS(1);
  447. };
  448. enum class DepthMode : u32 {
  449. MinusOneToOne = 0,
  450. ZeroToOne = 1,
  451. };
  452. enum class TessellationPrimitive : u32 {
  453. Isolines = 0,
  454. Triangles = 1,
  455. Quads = 2,
  456. };
  457. enum class TessellationSpacing : u32 {
  458. Equal = 0,
  459. FractionalOdd = 1,
  460. FractionalEven = 2,
  461. };
  462. struct RenderTargetConfig {
  463. u32 address_high;
  464. u32 address_low;
  465. u32 width;
  466. u32 height;
  467. Tegra::RenderTargetFormat format;
  468. union {
  469. BitField<0, 3, u32> block_width;
  470. BitField<4, 3, u32> block_height;
  471. BitField<8, 3, u32> block_depth;
  472. BitField<12, 1, InvMemoryLayout> type;
  473. } memory_layout;
  474. union {
  475. BitField<0, 16, u32> array_mode;
  476. BitField<16, 1, u32> volume;
  477. };
  478. u32 layer_stride;
  479. u32 base_layer;
  480. INSERT_UNION_PADDING_WORDS(7);
  481. GPUVAddr Address() const {
  482. return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) |
  483. address_low);
  484. }
  485. };
  486. struct ColorMask {
  487. union {
  488. u32 raw;
  489. BitField<0, 4, u32> R;
  490. BitField<4, 4, u32> G;
  491. BitField<8, 4, u32> B;
  492. BitField<12, 4, u32> A;
  493. };
  494. };
  495. struct ViewportTransform {
  496. f32 scale_x;
  497. f32 scale_y;
  498. f32 scale_z;
  499. f32 translate_x;
  500. f32 translate_y;
  501. f32 translate_z;
  502. INSERT_UNION_PADDING_WORDS(2);
  503. Common::Rectangle<s32> GetRect() const {
  504. return {
  505. GetX(), // left
  506. GetY() + GetHeight(), // top
  507. GetX() + GetWidth(), // right
  508. GetY() // bottom
  509. };
  510. };
  511. s32 GetX() const {
  512. return static_cast<s32>(std::max(0.0f, translate_x - std::fabs(scale_x)));
  513. }
  514. s32 GetY() const {
  515. return static_cast<s32>(std::max(0.0f, translate_y - std::fabs(scale_y)));
  516. }
  517. s32 GetWidth() const {
  518. return static_cast<s32>(translate_x + std::fabs(scale_x)) - GetX();
  519. }
  520. s32 GetHeight() const {
  521. return static_cast<s32>(translate_y + std::fabs(scale_y)) - GetY();
  522. }
  523. };
  524. struct ScissorTest {
  525. u32 enable;
  526. union {
  527. BitField<0, 16, u32> min_x;
  528. BitField<16, 16, u32> max_x;
  529. };
  530. union {
  531. BitField<0, 16, u32> min_y;
  532. BitField<16, 16, u32> max_y;
  533. };
  534. u32 fill;
  535. };
  536. struct ViewPort {
  537. union {
  538. BitField<0, 16, u32> x;
  539. BitField<16, 16, u32> width;
  540. };
  541. union {
  542. BitField<0, 16, u32> y;
  543. BitField<16, 16, u32> height;
  544. };
  545. float depth_range_near;
  546. float depth_range_far;
  547. };
  548. bool IsShaderConfigEnabled(std::size_t index) const {
  549. // The VertexB is always enabled.
  550. if (index == static_cast<std::size_t>(Regs::ShaderProgram::VertexB)) {
  551. return true;
  552. }
  553. return shader_config[index].enable != 0;
  554. }
  555. union {
  556. struct {
  557. INSERT_UNION_PADDING_WORDS(0x45);
  558. struct {
  559. u32 upload_address;
  560. u32 data;
  561. u32 entry;
  562. u32 bind;
  563. } macros;
  564. INSERT_UNION_PADDING_WORDS(0x17);
  565. Upload::Registers upload;
  566. struct {
  567. union {
  568. BitField<0, 1, u32> linear;
  569. };
  570. } exec_upload;
  571. u32 data_upload;
  572. INSERT_UNION_PADDING_WORDS(0x44);
  573. struct {
  574. union {
  575. BitField<0, 16, u32> sync_point;
  576. BitField<16, 1, u32> unknown;
  577. BitField<20, 1, u32> increment;
  578. };
  579. } sync_info;
  580. INSERT_UNION_PADDING_WORDS(0x15);
  581. union {
  582. BitField<0, 2, TessellationPrimitive> prim;
  583. BitField<4, 2, TessellationSpacing> spacing;
  584. BitField<8, 1, u32> cw;
  585. BitField<9, 1, u32> connected;
  586. } tess_mode;
  587. std::array<f32, 4> tess_level_outer;
  588. std::array<f32, 2> tess_level_inner;
  589. INSERT_UNION_PADDING_WORDS(0x102);
  590. u32 tfb_enabled;
  591. INSERT_UNION_PADDING_WORDS(0x2E);
  592. std::array<RenderTargetConfig, NumRenderTargets> rt;
  593. std::array<ViewportTransform, NumViewports> viewport_transform;
  594. std::array<ViewPort, NumViewports> viewports;
  595. INSERT_UNION_PADDING_WORDS(0x1D);
  596. struct {
  597. u32 first;
  598. u32 count;
  599. } vertex_buffer;
  600. INSERT_UNION_PADDING_WORDS(1);
  601. float clear_color[4];
  602. float clear_depth;
  603. INSERT_UNION_PADDING_WORDS(0x3);
  604. s32 clear_stencil;
  605. INSERT_UNION_PADDING_WORDS(0x7);
  606. u32 polygon_offset_point_enable;
  607. u32 polygon_offset_line_enable;
  608. u32 polygon_offset_fill_enable;
  609. u32 patch_vertices;
  610. INSERT_UNION_PADDING_WORDS(0xC);
  611. std::array<ScissorTest, NumViewports> scissor_test;
  612. INSERT_UNION_PADDING_WORDS(0x15);
  613. s32 stencil_back_func_ref;
  614. u32 stencil_back_func_mask;
  615. u32 stencil_back_mask;
  616. INSERT_UNION_PADDING_WORDS(0xC);
  617. u32 color_mask_common;
  618. INSERT_UNION_PADDING_WORDS(0x6);
  619. u32 rt_separate_frag_data;
  620. f32 depth_bounds[2];
  621. INSERT_UNION_PADDING_WORDS(0xA);
  622. struct {
  623. u32 address_high;
  624. u32 address_low;
  625. Tegra::DepthFormat format;
  626. union {
  627. BitField<0, 4, u32> block_width;
  628. BitField<4, 4, u32> block_height;
  629. BitField<8, 4, u32> block_depth;
  630. BitField<20, 1, InvMemoryLayout> type;
  631. } memory_layout;
  632. u32 layer_stride;
  633. GPUVAddr Address() const {
  634. return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) |
  635. address_low);
  636. }
  637. } zeta;
  638. INSERT_UNION_PADDING_WORDS(0x41);
  639. union {
  640. BitField<0, 4, u32> stencil;
  641. BitField<4, 4, u32> unknown;
  642. BitField<8, 4, u32> scissor;
  643. BitField<12, 4, u32> viewport;
  644. } clear_flags;
  645. INSERT_UNION_PADDING_WORDS(0x19);
  646. std::array<VertexAttribute, NumVertexAttributes> vertex_attrib_format;
  647. INSERT_UNION_PADDING_WORDS(0xF);
  648. struct {
  649. union {
  650. BitField<0, 4, u32> count;
  651. BitField<4, 3, u32> map_0;
  652. BitField<7, 3, u32> map_1;
  653. BitField<10, 3, u32> map_2;
  654. BitField<13, 3, u32> map_3;
  655. BitField<16, 3, u32> map_4;
  656. BitField<19, 3, u32> map_5;
  657. BitField<22, 3, u32> map_6;
  658. BitField<25, 3, u32> map_7;
  659. };
  660. u32 GetMap(std::size_t index) const {
  661. const std::array<u32, NumRenderTargets> maps{map_0, map_1, map_2, map_3,
  662. map_4, map_5, map_6, map_7};
  663. ASSERT(index < maps.size());
  664. return maps[index];
  665. }
  666. } rt_control;
  667. INSERT_UNION_PADDING_WORDS(0x2);
  668. u32 zeta_width;
  669. u32 zeta_height;
  670. INSERT_UNION_PADDING_WORDS(0x27);
  671. u32 depth_test_enable;
  672. INSERT_UNION_PADDING_WORDS(0x5);
  673. u32 independent_blend_enable;
  674. u32 depth_write_enabled;
  675. u32 alpha_test_enabled;
  676. INSERT_UNION_PADDING_WORDS(0x6);
  677. u32 d3d_cull_mode;
  678. ComparisonOp depth_test_func;
  679. float alpha_test_ref;
  680. ComparisonOp alpha_test_func;
  681. u32 draw_tfb_stride;
  682. struct {
  683. float r;
  684. float g;
  685. float b;
  686. float a;
  687. } blend_color;
  688. INSERT_UNION_PADDING_WORDS(0x4);
  689. struct {
  690. u32 separate_alpha;
  691. Blend::Equation equation_rgb;
  692. Blend::Factor factor_source_rgb;
  693. Blend::Factor factor_dest_rgb;
  694. Blend::Equation equation_a;
  695. Blend::Factor factor_source_a;
  696. INSERT_UNION_PADDING_WORDS(1);
  697. Blend::Factor factor_dest_a;
  698. u32 enable_common;
  699. u32 enable[NumRenderTargets];
  700. } blend;
  701. u32 stencil_enable;
  702. StencilOp stencil_front_op_fail;
  703. StencilOp stencil_front_op_zfail;
  704. StencilOp stencil_front_op_zpass;
  705. ComparisonOp stencil_front_func_func;
  706. s32 stencil_front_func_ref;
  707. u32 stencil_front_func_mask;
  708. u32 stencil_front_mask;
  709. INSERT_UNION_PADDING_WORDS(0x2);
  710. u32 frag_color_clamp;
  711. union {
  712. BitField<0, 1, u32> y_negate;
  713. BitField<4, 1, u32> triangle_rast_flip;
  714. } screen_y_control;
  715. INSERT_UNION_PADDING_WORDS(0x21);
  716. u32 vb_element_base;
  717. u32 vb_base_instance;
  718. INSERT_UNION_PADDING_WORDS(0x35);
  719. union {
  720. BitField<0, 1, u32> c0;
  721. BitField<1, 1, u32> c1;
  722. BitField<2, 1, u32> c2;
  723. BitField<3, 1, u32> c3;
  724. BitField<4, 1, u32> c4;
  725. BitField<5, 1, u32> c5;
  726. BitField<6, 1, u32> c6;
  727. BitField<7, 1, u32> c7;
  728. } clip_distance_enabled;
  729. INSERT_UNION_PADDING_WORDS(0x1);
  730. float point_size;
  731. INSERT_UNION_PADDING_WORDS(0x7);
  732. u32 zeta_enable;
  733. union {
  734. BitField<0, 1, u32> alpha_to_coverage;
  735. BitField<4, 1, u32> alpha_to_one;
  736. } multisample_control;
  737. INSERT_UNION_PADDING_WORDS(0x4);
  738. struct {
  739. u32 address_high;
  740. u32 address_low;
  741. ConditionMode mode;
  742. GPUVAddr Address() const {
  743. return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) |
  744. address_low);
  745. }
  746. } condition;
  747. struct {
  748. u32 tsc_address_high;
  749. u32 tsc_address_low;
  750. u32 tsc_limit;
  751. GPUVAddr TSCAddress() const {
  752. return static_cast<GPUVAddr>(
  753. (static_cast<GPUVAddr>(tsc_address_high) << 32) | tsc_address_low);
  754. }
  755. } tsc;
  756. INSERT_UNION_PADDING_WORDS(0x1);
  757. float polygon_offset_factor;
  758. INSERT_UNION_PADDING_WORDS(0x1);
  759. struct {
  760. u32 tic_address_high;
  761. u32 tic_address_low;
  762. u32 tic_limit;
  763. GPUVAddr TICAddress() const {
  764. return static_cast<GPUVAddr>(
  765. (static_cast<GPUVAddr>(tic_address_high) << 32) | tic_address_low);
  766. }
  767. } tic;
  768. INSERT_UNION_PADDING_WORDS(0x5);
  769. u32 stencil_two_side_enable;
  770. StencilOp stencil_back_op_fail;
  771. StencilOp stencil_back_op_zfail;
  772. StencilOp stencil_back_op_zpass;
  773. ComparisonOp stencil_back_func_func;
  774. INSERT_UNION_PADDING_WORDS(0x4);
  775. u32 framebuffer_srgb;
  776. float polygon_offset_units;
  777. INSERT_UNION_PADDING_WORDS(0x11);
  778. union {
  779. BitField<2, 1, u32> coord_origin;
  780. BitField<3, 10, u32> enable;
  781. } point_coord_replace;
  782. struct {
  783. u32 code_address_high;
  784. u32 code_address_low;
  785. GPUVAddr CodeAddress() const {
  786. return static_cast<GPUVAddr>(
  787. (static_cast<GPUVAddr>(code_address_high) << 32) | code_address_low);
  788. }
  789. } code_address;
  790. INSERT_UNION_PADDING_WORDS(1);
  791. struct {
  792. u32 vertex_end_gl;
  793. union {
  794. u32 vertex_begin_gl;
  795. BitField<0, 16, PrimitiveTopology> topology;
  796. BitField<26, 1, u32> instance_next;
  797. BitField<27, 1, u32> instance_cont;
  798. };
  799. } draw;
  800. INSERT_UNION_PADDING_WORDS(0xA);
  801. struct {
  802. u32 enabled;
  803. u32 index;
  804. } primitive_restart;
  805. INSERT_UNION_PADDING_WORDS(0x5F);
  806. struct {
  807. u32 start_addr_high;
  808. u32 start_addr_low;
  809. u32 end_addr_high;
  810. u32 end_addr_low;
  811. IndexFormat format;
  812. u32 first;
  813. u32 count;
  814. unsigned FormatSizeInBytes() const {
  815. switch (format) {
  816. case IndexFormat::UnsignedByte:
  817. return 1;
  818. case IndexFormat::UnsignedShort:
  819. return 2;
  820. case IndexFormat::UnsignedInt:
  821. return 4;
  822. }
  823. UNREACHABLE();
  824. return 1;
  825. }
  826. GPUVAddr StartAddress() const {
  827. return static_cast<GPUVAddr>(
  828. (static_cast<GPUVAddr>(start_addr_high) << 32) | start_addr_low);
  829. }
  830. GPUVAddr EndAddress() const {
  831. return static_cast<GPUVAddr>((static_cast<GPUVAddr>(end_addr_high) << 32) |
  832. end_addr_low);
  833. }
  834. /// Adjust the index buffer offset so it points to the first desired index.
  835. GPUVAddr IndexStart() const {
  836. return StartAddress() + static_cast<size_t>(first) *
  837. static_cast<size_t>(FormatSizeInBytes());
  838. }
  839. } index_array;
  840. INSERT_UNION_PADDING_WORDS(0x7);
  841. INSERT_UNION_PADDING_WORDS(0x1F);
  842. float polygon_offset_clamp;
  843. struct {
  844. u32 is_instanced[NumVertexArrays];
  845. /// Returns whether the vertex array specified by index is supposed to be
  846. /// accessed per instance or not.
  847. bool IsInstancingEnabled(u32 index) const {
  848. return is_instanced[index];
  849. }
  850. } instanced_arrays;
  851. INSERT_UNION_PADDING_WORDS(0x6);
  852. Cull cull;
  853. u32 pixel_center_integer;
  854. INSERT_UNION_PADDING_WORDS(0x1);
  855. u32 viewport_transform_enabled;
  856. INSERT_UNION_PADDING_WORDS(0x3);
  857. union {
  858. BitField<0, 1, u32> depth_range_0_1;
  859. BitField<3, 1, u32> depth_clamp_near;
  860. BitField<4, 1, u32> depth_clamp_far;
  861. } view_volume_clip_control;
  862. INSERT_UNION_PADDING_WORDS(0x21);
  863. struct {
  864. u32 enable;
  865. LogicOperation operation;
  866. } logic_op;
  867. INSERT_UNION_PADDING_WORDS(0x1);
  868. union {
  869. u32 raw;
  870. BitField<0, 1, u32> Z;
  871. BitField<1, 1, u32> S;
  872. BitField<2, 1, u32> R;
  873. BitField<3, 1, u32> G;
  874. BitField<4, 1, u32> B;
  875. BitField<5, 1, u32> A;
  876. BitField<6, 4, u32> RT;
  877. BitField<10, 11, u32> layer;
  878. } clear_buffers;
  879. INSERT_UNION_PADDING_WORDS(0xB);
  880. std::array<ColorMask, NumRenderTargets> color_mask;
  881. INSERT_UNION_PADDING_WORDS(0x38);
  882. struct {
  883. u32 query_address_high;
  884. u32 query_address_low;
  885. u32 query_sequence;
  886. union {
  887. u32 raw;
  888. BitField<0, 2, QueryMode> mode;
  889. BitField<4, 1, u32> fence;
  890. BitField<12, 4, QueryUnit> unit;
  891. BitField<16, 1, QuerySyncCondition> sync_cond;
  892. BitField<23, 5, QuerySelect> select;
  893. BitField<28, 1, u32> short_query;
  894. } query_get;
  895. GPUVAddr QueryAddress() const {
  896. return static_cast<GPUVAddr>(
  897. (static_cast<GPUVAddr>(query_address_high) << 32) | query_address_low);
  898. }
  899. } query;
  900. INSERT_UNION_PADDING_WORDS(0x3C);
  901. struct {
  902. union {
  903. BitField<0, 12, u32> stride;
  904. BitField<12, 1, u32> enable;
  905. };
  906. u32 start_high;
  907. u32 start_low;
  908. u32 divisor;
  909. GPUVAddr StartAddress() const {
  910. return static_cast<GPUVAddr>((static_cast<GPUVAddr>(start_high) << 32) |
  911. start_low);
  912. }
  913. bool IsEnabled() const {
  914. return enable != 0 && StartAddress() != 0;
  915. }
  916. } vertex_array[NumVertexArrays];
  917. Blend independent_blend[NumRenderTargets];
  918. struct {
  919. u32 limit_high;
  920. u32 limit_low;
  921. GPUVAddr LimitAddress() const {
  922. return static_cast<GPUVAddr>((static_cast<GPUVAddr>(limit_high) << 32) |
  923. limit_low);
  924. }
  925. } vertex_array_limit[NumVertexArrays];
  926. struct {
  927. union {
  928. BitField<0, 1, u32> enable;
  929. BitField<4, 4, ShaderProgram> program;
  930. };
  931. u32 offset;
  932. INSERT_UNION_PADDING_WORDS(14);
  933. } shader_config[MaxShaderProgram];
  934. INSERT_UNION_PADDING_WORDS(0x60);
  935. u32 firmware[0x20];
  936. struct {
  937. u32 cb_size;
  938. u32 cb_address_high;
  939. u32 cb_address_low;
  940. u32 cb_pos;
  941. u32 cb_data[NumCBData];
  942. GPUVAddr BufferAddress() const {
  943. return static_cast<GPUVAddr>(
  944. (static_cast<GPUVAddr>(cb_address_high) << 32) | cb_address_low);
  945. }
  946. } const_buffer;
  947. INSERT_UNION_PADDING_WORDS(0x10);
  948. struct {
  949. union {
  950. u32 raw_config;
  951. BitField<0, 1, u32> valid;
  952. BitField<4, 5, u32> index;
  953. };
  954. INSERT_UNION_PADDING_WORDS(7);
  955. } cb_bind[MaxShaderStage];
  956. INSERT_UNION_PADDING_WORDS(0x56);
  957. u32 tex_cb_index;
  958. INSERT_UNION_PADDING_WORDS(0x395);
  959. struct {
  960. /// Compressed address of a buffer that holds information about bound SSBOs.
  961. /// This address is usually bound to c0 in the shaders.
  962. u32 buffer_address;
  963. GPUVAddr BufferAddress() const {
  964. return static_cast<GPUVAddr>(buffer_address) << 8;
  965. }
  966. } ssbo_info;
  967. INSERT_UNION_PADDING_WORDS(0x11);
  968. struct {
  969. u32 address[MaxShaderStage];
  970. u32 size[MaxShaderStage];
  971. } tex_info_buffers;
  972. INSERT_UNION_PADDING_WORDS(0xCC);
  973. };
  974. std::array<u32, NUM_REGS> reg_array;
  975. };
  976. } regs{};
  977. static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Maxwell3D Regs has wrong size");
  978. static_assert(std::is_trivially_copyable_v<Regs>, "Maxwell3D Regs must be trivially copyable");
  979. struct State {
  980. struct ShaderStageInfo {
  981. std::array<ConstBufferInfo, Regs::MaxConstBuffers> const_buffers;
  982. };
  983. std::array<ShaderStageInfo, Regs::MaxShaderStage> shader_stages;
  984. u32 current_instance = 0; ///< Current instance to be used to simulate instanced rendering.
  985. };
  986. State state{};
  987. struct DirtyRegs {
  988. static constexpr std::size_t NUM_REGS = 256;
  989. static_assert(NUM_REGS - 1 <= std::numeric_limits<u8>::max());
  990. union {
  991. struct {
  992. bool null_dirty;
  993. // Vertex Attributes
  994. bool vertex_attrib_format;
  995. // Vertex Arrays
  996. std::array<bool, 32> vertex_array;
  997. bool vertex_array_buffers;
  998. // Vertex Instances
  999. std::array<bool, 32> vertex_instance;
  1000. bool vertex_instances;
  1001. // Render Targets
  1002. std::array<bool, 8> render_target;
  1003. bool depth_buffer;
  1004. bool render_settings;
  1005. // Shaders
  1006. bool shaders;
  1007. // Rasterizer State
  1008. bool viewport;
  1009. bool clip_coefficient;
  1010. bool cull_mode;
  1011. bool primitive_restart;
  1012. bool depth_test;
  1013. bool stencil_test;
  1014. bool blend_state;
  1015. bool scissor_test;
  1016. bool transform_feedback;
  1017. bool color_mask;
  1018. bool polygon_offset;
  1019. bool depth_bounds_values;
  1020. // Complementary
  1021. bool viewport_transform;
  1022. bool screen_y_control;
  1023. bool memory_general;
  1024. };
  1025. std::array<bool, NUM_REGS> regs;
  1026. };
  1027. void ResetVertexArrays() {
  1028. vertex_array.fill(true);
  1029. vertex_array_buffers = true;
  1030. }
  1031. void ResetRenderTargets() {
  1032. depth_buffer = true;
  1033. render_target.fill(true);
  1034. render_settings = true;
  1035. }
  1036. void OnMemoryWrite() {
  1037. shaders = true;
  1038. memory_general = true;
  1039. ResetRenderTargets();
  1040. ResetVertexArrays();
  1041. }
  1042. } dirty{};
  1043. std::array<u8, Regs::NUM_REGS> dirty_pointers{};
  1044. /// Reads a register value located at the input method address
  1045. u32 GetRegisterValue(u32 method) const;
  1046. /// Write the value to the register identified by method.
  1047. void CallMethod(const GPU::MethodCall& method_call);
  1048. /// Write the value to the register identified by method.
  1049. void CallMethodFromMME(const GPU::MethodCall& method_call);
  1050. void FlushMMEInlineDraw();
  1051. /// Given a texture handle, returns the TSC and TIC entries.
  1052. Texture::FullTextureInfo GetTextureInfo(Texture::TextureHandle tex_handle) const;
  1053. /// Returns the texture information for a specific texture in a specific shader stage.
  1054. Texture::FullTextureInfo GetStageTexture(ShaderType stage, std::size_t offset) const;
  1055. u32 AccessConstBuffer32(ShaderType stage, u64 const_buffer, u64 offset) const override;
  1056. SamplerDescriptor AccessBoundSampler(ShaderType stage, u64 offset) const override;
  1057. SamplerDescriptor AccessBindlessSampler(ShaderType stage, u64 const_buffer,
  1058. u64 offset) const override;
  1059. u32 GetBoundBuffer() const override {
  1060. return regs.tex_cb_index;
  1061. }
  1062. /// Memory for macro code - it's undetermined how big this is, however 1MB is much larger than
  1063. /// we've seen used.
  1064. using MacroMemory = std::array<u32, 0x40000>;
  1065. /// Gets a reference to macro memory.
  1066. const MacroMemory& GetMacroMemory() const {
  1067. return macro_memory;
  1068. }
  1069. bool ShouldExecute() const {
  1070. return execute_on;
  1071. }
  1072. enum class MMEDrawMode : u32 {
  1073. Undefined,
  1074. Array,
  1075. Indexed,
  1076. };
  1077. struct MMEDrawState {
  1078. MMEDrawMode current_mode{MMEDrawMode::Undefined};
  1079. u32 current_count{};
  1080. u32 instance_count{};
  1081. bool instance_mode{};
  1082. bool gl_begin_consume{};
  1083. u32 gl_end_count{};
  1084. } mme_draw;
  1085. private:
  1086. void InitializeRegisterDefaults();
  1087. Core::System& system;
  1088. VideoCore::RasterizerInterface& rasterizer;
  1089. MemoryManager& memory_manager;
  1090. /// Start offsets of each macro in macro_memory
  1091. std::array<u32, 0x80> macro_positions = {};
  1092. std::array<bool, Regs::NUM_REGS> mme_inline{};
  1093. /// Memory for macro code
  1094. MacroMemory macro_memory;
  1095. /// Macro method that is currently being executed / being fed parameters.
  1096. u32 executing_macro = 0;
  1097. /// Parameters that have been submitted to the macro call so far.
  1098. std::vector<u32> macro_params;
  1099. /// Interpreter for the macro codes uploaded to the GPU.
  1100. MacroInterpreter macro_interpreter;
  1101. static constexpr u32 null_cb_data = 0xFFFFFFFF;
  1102. struct {
  1103. std::array<std::array<u32, 0x4000>, 16> buffer;
  1104. u32 current{null_cb_data};
  1105. u32 id{null_cb_data};
  1106. u32 start_pos{};
  1107. u32 counter{};
  1108. } cb_data_state;
  1109. Upload::State upload_state;
  1110. bool execute_on{true};
  1111. /// Retrieves information about a specific TIC entry from the TIC buffer.
  1112. Texture::TICEntry GetTICEntry(u32 tic_index) const;
  1113. /// Retrieves information about a specific TSC entry from the TSC buffer.
  1114. Texture::TSCEntry GetTSCEntry(u32 tsc_index) const;
  1115. void InitDirtySettings();
  1116. /**
  1117. * Call a macro on this engine.
  1118. * @param method Method to call
  1119. * @param num_parameters Number of arguments
  1120. * @param parameters Arguments to the method call
  1121. */
  1122. void CallMacroMethod(u32 method, std::size_t num_parameters, const u32* parameters);
  1123. /// Handles writes to the macro uploading register.
  1124. void ProcessMacroUpload(u32 data);
  1125. /// Handles writes to the macro bind register.
  1126. void ProcessMacroBind(u32 data);
  1127. /// Handles firmware blob 4
  1128. void ProcessFirmwareCall4();
  1129. /// Handles a write to the CLEAR_BUFFERS register.
  1130. void ProcessClearBuffers();
  1131. /// Handles a write to the QUERY_GET register.
  1132. void ProcessQueryGet();
  1133. // Handles Conditional Rendering
  1134. void ProcessQueryCondition();
  1135. /// Handles writes to syncing register.
  1136. void ProcessSyncPoint();
  1137. /// Handles a write to the CB_DATA[i] register.
  1138. void StartCBData(u32 method);
  1139. void ProcessCBData(u32 value);
  1140. void FinishCBData();
  1141. /// Handles a write to the CB_BIND register.
  1142. void ProcessCBBind(std::size_t stage_index);
  1143. /// Handles a write to the VERTEX_END_GL register, triggering a draw.
  1144. void DrawArrays();
  1145. // Handles a instance drawcall from MME
  1146. void StepInstance(MMEDrawMode expected_mode, u32 count);
  1147. };
  1148. #define ASSERT_REG_POSITION(field_name, position) \
  1149. static_assert(offsetof(Maxwell3D::Regs, field_name) == position * 4, \
  1150. "Field " #field_name " has invalid position")
  1151. ASSERT_REG_POSITION(macros, 0x45);
  1152. ASSERT_REG_POSITION(upload, 0x60);
  1153. ASSERT_REG_POSITION(exec_upload, 0x6C);
  1154. ASSERT_REG_POSITION(data_upload, 0x6D);
  1155. ASSERT_REG_POSITION(sync_info, 0xB2);
  1156. ASSERT_REG_POSITION(tess_mode, 0xC8);
  1157. ASSERT_REG_POSITION(tess_level_outer, 0xC9);
  1158. ASSERT_REG_POSITION(tess_level_inner, 0xCD);
  1159. ASSERT_REG_POSITION(tfb_enabled, 0x1D1);
  1160. ASSERT_REG_POSITION(rt, 0x200);
  1161. ASSERT_REG_POSITION(viewport_transform, 0x280);
  1162. ASSERT_REG_POSITION(viewports, 0x300);
  1163. ASSERT_REG_POSITION(vertex_buffer, 0x35D);
  1164. ASSERT_REG_POSITION(clear_color[0], 0x360);
  1165. ASSERT_REG_POSITION(clear_depth, 0x364);
  1166. ASSERT_REG_POSITION(clear_stencil, 0x368);
  1167. ASSERT_REG_POSITION(polygon_offset_point_enable, 0x370);
  1168. ASSERT_REG_POSITION(polygon_offset_line_enable, 0x371);
  1169. ASSERT_REG_POSITION(polygon_offset_fill_enable, 0x372);
  1170. ASSERT_REG_POSITION(patch_vertices, 0x373);
  1171. ASSERT_REG_POSITION(scissor_test, 0x380);
  1172. ASSERT_REG_POSITION(stencil_back_func_ref, 0x3D5);
  1173. ASSERT_REG_POSITION(stencil_back_func_mask, 0x3D6);
  1174. ASSERT_REG_POSITION(stencil_back_mask, 0x3D7);
  1175. ASSERT_REG_POSITION(color_mask_common, 0x3E4);
  1176. ASSERT_REG_POSITION(rt_separate_frag_data, 0x3EB);
  1177. ASSERT_REG_POSITION(depth_bounds, 0x3EC);
  1178. ASSERT_REG_POSITION(zeta, 0x3F8);
  1179. ASSERT_REG_POSITION(clear_flags, 0x43E);
  1180. ASSERT_REG_POSITION(vertex_attrib_format, 0x458);
  1181. ASSERT_REG_POSITION(rt_control, 0x487);
  1182. ASSERT_REG_POSITION(zeta_width, 0x48a);
  1183. ASSERT_REG_POSITION(zeta_height, 0x48b);
  1184. ASSERT_REG_POSITION(depth_test_enable, 0x4B3);
  1185. ASSERT_REG_POSITION(independent_blend_enable, 0x4B9);
  1186. ASSERT_REG_POSITION(depth_write_enabled, 0x4BA);
  1187. ASSERT_REG_POSITION(alpha_test_enabled, 0x4BB);
  1188. ASSERT_REG_POSITION(d3d_cull_mode, 0x4C2);
  1189. ASSERT_REG_POSITION(depth_test_func, 0x4C3);
  1190. ASSERT_REG_POSITION(alpha_test_ref, 0x4C4);
  1191. ASSERT_REG_POSITION(alpha_test_func, 0x4C5);
  1192. ASSERT_REG_POSITION(draw_tfb_stride, 0x4C6);
  1193. ASSERT_REG_POSITION(blend_color, 0x4C7);
  1194. ASSERT_REG_POSITION(blend, 0x4CF);
  1195. ASSERT_REG_POSITION(stencil_enable, 0x4E0);
  1196. ASSERT_REG_POSITION(stencil_front_op_fail, 0x4E1);
  1197. ASSERT_REG_POSITION(stencil_front_op_zfail, 0x4E2);
  1198. ASSERT_REG_POSITION(stencil_front_op_zpass, 0x4E3);
  1199. ASSERT_REG_POSITION(stencil_front_func_func, 0x4E4);
  1200. ASSERT_REG_POSITION(stencil_front_func_ref, 0x4E5);
  1201. ASSERT_REG_POSITION(stencil_front_func_mask, 0x4E6);
  1202. ASSERT_REG_POSITION(stencil_front_mask, 0x4E7);
  1203. ASSERT_REG_POSITION(frag_color_clamp, 0x4EA);
  1204. ASSERT_REG_POSITION(screen_y_control, 0x4EB);
  1205. ASSERT_REG_POSITION(vb_element_base, 0x50D);
  1206. ASSERT_REG_POSITION(vb_base_instance, 0x50E);
  1207. ASSERT_REG_POSITION(clip_distance_enabled, 0x544);
  1208. ASSERT_REG_POSITION(point_size, 0x546);
  1209. ASSERT_REG_POSITION(zeta_enable, 0x54E);
  1210. ASSERT_REG_POSITION(multisample_control, 0x54F);
  1211. ASSERT_REG_POSITION(condition, 0x554);
  1212. ASSERT_REG_POSITION(tsc, 0x557);
  1213. ASSERT_REG_POSITION(polygon_offset_factor, 0x55b);
  1214. ASSERT_REG_POSITION(tic, 0x55D);
  1215. ASSERT_REG_POSITION(stencil_two_side_enable, 0x565);
  1216. ASSERT_REG_POSITION(stencil_back_op_fail, 0x566);
  1217. ASSERT_REG_POSITION(stencil_back_op_zfail, 0x567);
  1218. ASSERT_REG_POSITION(stencil_back_op_zpass, 0x568);
  1219. ASSERT_REG_POSITION(stencil_back_func_func, 0x569);
  1220. ASSERT_REG_POSITION(framebuffer_srgb, 0x56E);
  1221. ASSERT_REG_POSITION(polygon_offset_units, 0x56F);
  1222. ASSERT_REG_POSITION(point_coord_replace, 0x581);
  1223. ASSERT_REG_POSITION(code_address, 0x582);
  1224. ASSERT_REG_POSITION(draw, 0x585);
  1225. ASSERT_REG_POSITION(primitive_restart, 0x591);
  1226. ASSERT_REG_POSITION(index_array, 0x5F2);
  1227. ASSERT_REG_POSITION(polygon_offset_clamp, 0x61F);
  1228. ASSERT_REG_POSITION(instanced_arrays, 0x620);
  1229. ASSERT_REG_POSITION(cull, 0x646);
  1230. ASSERT_REG_POSITION(pixel_center_integer, 0x649);
  1231. ASSERT_REG_POSITION(viewport_transform_enabled, 0x64B);
  1232. ASSERT_REG_POSITION(view_volume_clip_control, 0x64F);
  1233. ASSERT_REG_POSITION(logic_op, 0x671);
  1234. ASSERT_REG_POSITION(clear_buffers, 0x674);
  1235. ASSERT_REG_POSITION(color_mask, 0x680);
  1236. ASSERT_REG_POSITION(query, 0x6C0);
  1237. ASSERT_REG_POSITION(vertex_array[0], 0x700);
  1238. ASSERT_REG_POSITION(independent_blend, 0x780);
  1239. ASSERT_REG_POSITION(vertex_array_limit[0], 0x7C0);
  1240. ASSERT_REG_POSITION(shader_config[0], 0x800);
  1241. ASSERT_REG_POSITION(firmware, 0x8C0);
  1242. ASSERT_REG_POSITION(const_buffer, 0x8E0);
  1243. ASSERT_REG_POSITION(cb_bind[0], 0x904);
  1244. ASSERT_REG_POSITION(tex_cb_index, 0x982);
  1245. ASSERT_REG_POSITION(ssbo_info, 0xD18);
  1246. ASSERT_REG_POSITION(tex_info_buffers.address[0], 0xD2A);
  1247. ASSERT_REG_POSITION(tex_info_buffers.size[0], 0xD2F);
  1248. #undef ASSERT_REG_POSITION
  1249. } // namespace Tegra::Engines