maxwell_3d.h 45 KB

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