maxwell_3d.h 49 KB

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