maxwell_3d.h 47 KB

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