maxwell_3d.h 136 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <array>
  5. #include <bitset>
  6. #include <cmath>
  7. #include <limits>
  8. #include <optional>
  9. #include <type_traits>
  10. #include <vector>
  11. #include "common/assert.h"
  12. #include "common/bit_field.h"
  13. #include "common/common_funcs.h"
  14. #include "common/common_types.h"
  15. #include "common/math_util.h"
  16. #include "video_core/engines/const_buffer_info.h"
  17. #include "video_core/engines/engine_interface.h"
  18. #include "video_core/engines/engine_upload.h"
  19. #include "video_core/gpu.h"
  20. #include "video_core/macro/macro.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. class DrawManager;
  33. /**
  34. * This Engine is known as GF100_3D. Documentation can be found in:
  35. * https://github.com/NVIDIA/open-gpu-doc/blob/master/classes/3d/clb197.h
  36. * https://github.com/envytools/envytools/blob/master/rnndb/graph/gf100_3d.xml
  37. * https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h
  38. *
  39. * Note: nVidia have confirmed that their open docs have had parts redacted, so this list is
  40. * currently incomplete, and the gaps are still worth exploring.
  41. */
  42. #define MAXWELL3D_REG_INDEX(field_name) (offsetof(Maxwell3D::Regs, field_name) / sizeof(u32))
  43. class Maxwell3D final : public EngineInterface {
  44. public:
  45. explicit Maxwell3D(Core::System& system, MemoryManager& memory_manager);
  46. ~Maxwell3D();
  47. /// Binds a rasterizer to this engine.
  48. void BindRasterizer(VideoCore::RasterizerInterface* rasterizer);
  49. /// Register structure of the Maxwell3D engine.
  50. struct Regs {
  51. static constexpr std::size_t NUM_REGS = 0xE00;
  52. static constexpr std::size_t NumRenderTargets = 8;
  53. static constexpr std::size_t NumViewports = 16;
  54. static constexpr std::size_t NumCBData = 16;
  55. static constexpr std::size_t NumVertexArrays = 32;
  56. static constexpr std::size_t NumVertexAttributes = 32;
  57. static constexpr std::size_t NumVaryings = 31;
  58. static constexpr std::size_t NumImages = 8; // TODO(Rodrigo): Investigate this number
  59. static constexpr std::size_t NumClipDistances = 8;
  60. static constexpr std::size_t NumTransformFeedbackBuffers = 4;
  61. static constexpr std::size_t MaxShaderProgram = 6;
  62. static constexpr std::size_t MaxShaderStage = 5;
  63. // Maximum number of const buffers per shader stage.
  64. static constexpr std::size_t MaxConstBuffers = 18;
  65. static constexpr std::size_t MaxConstBufferSize = 0x10000;
  66. struct ID {
  67. union {
  68. BitField<0, 16, u32> cls;
  69. BitField<16, 5, u32> engine;
  70. };
  71. };
  72. struct LoadMME {
  73. u32 instruction_ptr;
  74. u32 instruction;
  75. u32 start_address_ptr;
  76. u32 start_address;
  77. };
  78. struct Notify {
  79. u32 address_high;
  80. u32 address_low;
  81. u32 type;
  82. GPUVAddr Address() const {
  83. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  84. }
  85. };
  86. struct PeerSemaphore {
  87. u32 address_high;
  88. u32 address_low;
  89. GPUVAddr Address() const {
  90. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  91. }
  92. };
  93. struct GlobalRender {
  94. enum class Mode : u32 {
  95. False = 0,
  96. True = 1,
  97. Conditional = 2,
  98. IfEqual = 3,
  99. IfNotEqual = 4,
  100. };
  101. u32 offset_high;
  102. u32 offset_low;
  103. Mode mode;
  104. GPUVAddr Address() const {
  105. return (GPUVAddr{offset_high} << 32) | GPUVAddr{offset_low};
  106. }
  107. };
  108. enum class ReductionOp : u32 {
  109. RedAdd = 0,
  110. RedMin = 1,
  111. RedMax = 2,
  112. RedInc = 3,
  113. RedDec = 4,
  114. RedAnd = 5,
  115. RedOr = 6,
  116. RedXor = 7,
  117. };
  118. struct LaunchDMA {
  119. enum class Layout : u32 {
  120. Blocklinear = 0,
  121. Pitch = 1,
  122. };
  123. enum class CompletionType : u32 {
  124. FlushDisable = 0,
  125. FlushOnly = 1,
  126. Release = 2,
  127. };
  128. union {
  129. BitField<0, 1, Layout> memory_layout;
  130. BitField<4, 2, CompletionType> completion_type;
  131. BitField<8, 2, u32> interrupt_type;
  132. BitField<12, 1, u32> sem_size;
  133. BitField<1, 1, u32> reduction_enable;
  134. BitField<13, 3, ReductionOp> reduction_op;
  135. BitField<2, 2, u32> reduction_format;
  136. BitField<6, 1, u32> sysmembar_disable;
  137. };
  138. };
  139. struct I2M {
  140. u32 address_high;
  141. u32 address_low;
  142. u32 payload;
  143. INSERT_PADDING_BYTES_NOINIT(0x8);
  144. u32 nop0;
  145. u32 nop1;
  146. u32 nop2;
  147. u32 nop3;
  148. };
  149. struct OpportunisticEarlyZ {
  150. BitField<0, 5, u32> threshold;
  151. u32 Threshold() const {
  152. switch (threshold) {
  153. case 0x0:
  154. return 0;
  155. case 0x1F:
  156. return 0x1F;
  157. default:
  158. // Thresholds begin at 0x10 (1 << 4)
  159. // Threshold is in the range 0x1 to 0x13
  160. return 1U << (4 + threshold.Value() - 1);
  161. }
  162. }
  163. };
  164. struct GeometryShaderDmFifo {
  165. union {
  166. BitField<0, 13, u32> raster_on;
  167. BitField<16, 13, u32> raster_off;
  168. BitField<31, 1, u32> spill_enabled;
  169. };
  170. };
  171. struct L2CacheControl {
  172. enum class EvictPolicy : u32 {
  173. First = 0,
  174. Normal = 1,
  175. Last = 2,
  176. };
  177. union {
  178. BitField<4, 2, EvictPolicy> policy;
  179. };
  180. };
  181. struct InvalidateShaderCache {
  182. union {
  183. BitField<0, 1, u32> instruction;
  184. BitField<4, 1, u32> data;
  185. BitField<12, 1, u32> constant;
  186. BitField<1, 1, u32> locks;
  187. BitField<2, 1, u32> flush_data;
  188. };
  189. };
  190. struct SyncInfo {
  191. enum class Condition : u32 {
  192. StreamOutWritesDone = 0,
  193. RopWritesDone = 1,
  194. };
  195. union {
  196. BitField<0, 16, u32> sync_point;
  197. BitField<16, 1, u32> clean_l2;
  198. BitField<20, 1, Condition> condition;
  199. };
  200. };
  201. struct SurfaceClipBlockId {
  202. union {
  203. BitField<0, 4, u32> block_width;
  204. BitField<4, 4, u32> block_height;
  205. BitField<8, 4, u32> block_depth;
  206. };
  207. };
  208. struct DecompressSurface {
  209. union {
  210. BitField<0, 3, u32> mrt_select;
  211. BitField<4, 16, u32> rt_array_index;
  212. };
  213. };
  214. struct ZCullRopBypass {
  215. union {
  216. BitField<0, 1, u32> enable;
  217. BitField<4, 1, u32> no_stall;
  218. BitField<8, 1, u32> cull_everything;
  219. BitField<12, 4, u32> threshold;
  220. };
  221. };
  222. struct ZCullSubregion {
  223. union {
  224. BitField<0, 1, u32> enable;
  225. BitField<4, 24, u32> normalized_aliquots;
  226. };
  227. };
  228. struct RasterBoundingBox {
  229. enum class Mode : u32 {
  230. BoundingBox = 0,
  231. FullViewport = 1,
  232. };
  233. union {
  234. u32 raw;
  235. BitField<0, 1, Mode> mode;
  236. BitField<4, 8, u32> pad;
  237. };
  238. };
  239. struct IteratedBlendOptimization {
  240. enum class Noop : u32 {
  241. Never = 0,
  242. SourceRGBA0000 = 1,
  243. SourceAlpha = 2,
  244. SourceRGBA0001 = 3,
  245. };
  246. union {
  247. BitField<0, 1, Noop> noop;
  248. };
  249. };
  250. struct ZCullSubregionAllocation {
  251. enum class Format : u32 {
  252. Z_16x16x2_4x4 = 0,
  253. ZS_16x16_4x4 = 1,
  254. Z_16x16_4x2 = 2,
  255. Z_16x16_2x4 = 3,
  256. Z_16x8_4x4 = 4,
  257. Z_8x8_4x2 = 5,
  258. Z_8x8_2x4 = 6,
  259. Z_16x16_4x8 = 7,
  260. Z_4x8_2x2 = 8,
  261. ZS_16x8_4x2 = 9,
  262. ZS_16x8_2x4 = 10,
  263. ZS_8x8_2x2 = 11,
  264. Z_4x8_1x1 = 12,
  265. None = 15,
  266. };
  267. union {
  268. BitField<0, 8, u32> id;
  269. BitField<8, 16, u32> aliquots;
  270. BitField<24, 4, Format> format;
  271. };
  272. };
  273. enum class ZCullSubregionAlgorithm : u32 {
  274. Static = 0,
  275. Adaptive = 1,
  276. };
  277. struct PixelShaderOutputSampleMaskUsage {
  278. union {
  279. BitField<0, 1, u32> enable;
  280. BitField<1, 1, u32> qualify_by_aa;
  281. };
  282. };
  283. struct L1Configuration {
  284. enum class AddressableMemory : u32 {
  285. Size16Kb = 0,
  286. Size48Kb = 3,
  287. };
  288. union {
  289. BitField<0, 3, AddressableMemory> direct_addressable_memory;
  290. };
  291. };
  292. struct SPAVersion {
  293. union {
  294. BitField<0, 8, u32> minor;
  295. BitField<8, 8, u32> major;
  296. };
  297. };
  298. struct SnapGrid {
  299. enum class Location : u32 {
  300. Pixel2x2 = 1,
  301. Pixel4x4 = 2,
  302. Pixel8x8 = 3,
  303. Pixel16x16 = 4,
  304. Pixel32x32 = 5,
  305. Pixel64x64 = 6,
  306. Pixel128x128 = 7,
  307. Pixel256x256 = 8,
  308. };
  309. enum class Mode : u32 {
  310. RTNE = 0,
  311. Tesla = 1,
  312. };
  313. struct {
  314. union {
  315. BitField<0, 4, Location> location;
  316. BitField<8, 1, Mode> rounding_mode;
  317. };
  318. } line;
  319. struct {
  320. union {
  321. BitField<0, 4, Location> location;
  322. BitField<8, 1, Mode> rounding_mode;
  323. };
  324. } non_line;
  325. };
  326. struct Tessellation {
  327. enum class DomainType : u32 {
  328. Isolines = 0,
  329. Triangles = 1,
  330. Quads = 2,
  331. };
  332. enum class Spacing : u32 {
  333. Integer = 0,
  334. FractionalOdd = 1,
  335. FractionalEven = 2,
  336. };
  337. enum class OutputPrimitives : u32 {
  338. Points = 0,
  339. Lines = 1,
  340. Triangles_CW = 2,
  341. Triangles_CCW = 3,
  342. };
  343. struct Parameters {
  344. union {
  345. BitField<0, 2, DomainType> domain_type;
  346. BitField<4, 2, Spacing> spacing;
  347. BitField<8, 2, OutputPrimitives> output_primitives;
  348. };
  349. } params;
  350. struct LOD {
  351. std::array<f32, 4> outer;
  352. std::array<f32, 2> inner;
  353. } lod;
  354. std::array<u32, 9> reserved;
  355. };
  356. struct SubTilingPerf {
  357. struct {
  358. union {
  359. BitField<0, 8, u32> spm_triangle_register_file_per;
  360. BitField<8, 8, u32> spm_pixel_output_buffer_per;
  361. BitField<16, 8, u32> spm_triangle_ram_per;
  362. BitField<24, 8, u32> max_quads_per;
  363. };
  364. } knob_a;
  365. struct {
  366. union {
  367. BitField<0, 8, u32> max_primitives_per;
  368. };
  369. } knob_b;
  370. u32 knob_c;
  371. };
  372. struct ZCullSubregionReport {
  373. enum class ReportType : u32 {
  374. DepthTest = 0,
  375. DepthTestNoAccept = 1,
  376. DepthTestLateZ = 2,
  377. StencilTest = 3,
  378. };
  379. union {
  380. BitField<0, 1, u32> enabled;
  381. BitField<4, 8, u32> subregion_id;
  382. } to_report;
  383. union {
  384. BitField<0, 1, u32> enabled;
  385. BitField<4, 3, ReportType> type;
  386. } report_type;
  387. };
  388. struct BalancedPrimitiveWorkload {
  389. union {
  390. BitField<0, 1, u32> unpartitioned_mode;
  391. BitField<4, 1, u32> timesliced_mode;
  392. };
  393. };
  394. struct TransformFeedback {
  395. struct Buffer {
  396. u32 enable;
  397. u32 address_high;
  398. u32 address_low;
  399. s32 size;
  400. s32 start_offset;
  401. INSERT_PADDING_BYTES_NOINIT(0xC);
  402. GPUVAddr Address() const {
  403. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  404. }
  405. };
  406. static_assert(sizeof(Buffer) == 0x20);
  407. struct Control {
  408. u32 stream;
  409. u32 varying_count;
  410. u32 stride;
  411. INSERT_PADDING_BYTES_NOINIT(0x4);
  412. };
  413. static_assert(sizeof(Control) == 0x10);
  414. std::array<TransformFeedback::Buffer, NumTransformFeedbackBuffers> buffers;
  415. INSERT_PADDING_BYTES_NOINIT(0x300);
  416. std::array<TransformFeedback::Control, NumTransformFeedbackBuffers> controls;
  417. };
  418. struct HybridAntiAliasControl {
  419. enum class Centroid : u32 {
  420. PerFragment = 0,
  421. PerPass = 1,
  422. };
  423. union {
  424. BitField<0, 4, u32> passes;
  425. BitField<4, 1, Centroid> centroid;
  426. BitField<5, 1, u32> passes_extended;
  427. };
  428. };
  429. struct ShaderLocalMemory {
  430. u32 base_address;
  431. INSERT_PADDING_BYTES_NOINIT(0x10);
  432. u32 address_high;
  433. u32 address_low;
  434. u32 size_high;
  435. u32 size_low;
  436. u32 default_size_per_warp;
  437. GPUVAddr Address() const {
  438. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  439. }
  440. u64 Size() const {
  441. return (u64{size_high} << 32) | u64{size_low};
  442. }
  443. };
  444. struct ZCullRegion {
  445. u32 width;
  446. u32 height;
  447. u32 depth;
  448. u32 offset;
  449. INSERT_PADDING_BYTES_NOINIT(0xC);
  450. u32 fetch_streams_once;
  451. union {
  452. BitField<0, 16, u32> start_aliquot;
  453. BitField<16, 16, u32> aliquot_count;
  454. } location;
  455. u32 aliquots_per_layer;
  456. u32 storage_address_high;
  457. u32 storage_address_low;
  458. u32 storage_limit_address_high;
  459. u32 storage_limit_address_low;
  460. GPUVAddr StorageAddress() const {
  461. return (GPUVAddr{storage_address_high} << 32) | GPUVAddr{storage_address_low};
  462. }
  463. GPUVAddr StorageLimitAddress() const {
  464. return (GPUVAddr{storage_limit_address_high} << 32) |
  465. GPUVAddr{storage_limit_address_low};
  466. }
  467. };
  468. struct ZetaReadOnly {
  469. union {
  470. BitField<0, 1, u32> enable_z;
  471. BitField<4, 1, u32> enable_stencil;
  472. };
  473. };
  474. struct VertexAttribute {
  475. enum class Size : u32 {
  476. Invalid = 0x0,
  477. Size_R32_G32_B32_A32 = 0x01,
  478. Size_R32_G32_B32 = 0x02,
  479. Size_R16_G16_B16_A16 = 0x03,
  480. Size_R32_G32 = 0x04,
  481. Size_R16_G16_B16 = 0x05,
  482. Size_R8_G8_B8_A8 = 0x0A,
  483. Size_R16_G16 = 0x0F,
  484. Size_R32 = 0x12,
  485. Size_R8_G8_B8 = 0x13,
  486. Size_R8_G8 = 0x18,
  487. Size_R16 = 0x1B,
  488. Size_R8 = 0x1D,
  489. Size_A2_B10_G10_R10 = 0x30,
  490. Size_B10_G11_R11 = 0x31,
  491. Size_G8_R8 = 0x32,
  492. Size_X8_B8_G8_R8 = 0x33,
  493. Size_A8 = 0x34,
  494. };
  495. enum class Type : u32 {
  496. UnusedEnumDoNotUseBecauseItWillGoAway = 0,
  497. SNorm = 1,
  498. UNorm = 2,
  499. SInt = 3,
  500. UInt = 4,
  501. UScaled = 5,
  502. SScaled = 6,
  503. Float = 7,
  504. };
  505. union {
  506. BitField<0, 5, u32> buffer;
  507. BitField<6, 1, u32> constant;
  508. BitField<7, 14, u32> offset;
  509. BitField<21, 6, Size> size;
  510. BitField<27, 3, Type> type;
  511. BitField<31, 1, u32> bgra;
  512. u32 hex;
  513. };
  514. u32 ComponentCount() const {
  515. switch (size) {
  516. case Size::Size_R32_G32_B32_A32:
  517. return 4;
  518. case Size::Size_R32_G32_B32:
  519. return 3;
  520. case Size::Size_R16_G16_B16_A16:
  521. return 4;
  522. case Size::Size_R32_G32:
  523. return 2;
  524. case Size::Size_R16_G16_B16:
  525. return 3;
  526. case Size::Size_R8_G8_B8_A8:
  527. case Size::Size_X8_B8_G8_R8:
  528. return 4;
  529. case Size::Size_R16_G16:
  530. return 2;
  531. case Size::Size_R32:
  532. return 1;
  533. case Size::Size_R8_G8_B8:
  534. return 3;
  535. case Size::Size_R8_G8:
  536. case Size::Size_G8_R8:
  537. return 2;
  538. case Size::Size_R16:
  539. return 1;
  540. case Size::Size_R8:
  541. case Size::Size_A8:
  542. return 1;
  543. case Size::Size_A2_B10_G10_R10:
  544. return 4;
  545. case Size::Size_B10_G11_R11:
  546. return 3;
  547. default:
  548. ASSERT(false);
  549. return 1;
  550. }
  551. }
  552. u32 SizeInBytes() const {
  553. switch (size) {
  554. case Size::Size_R32_G32_B32_A32:
  555. return 16;
  556. case Size::Size_R32_G32_B32:
  557. return 12;
  558. case Size::Size_R16_G16_B16_A16:
  559. return 8;
  560. case Size::Size_R32_G32:
  561. return 8;
  562. case Size::Size_R16_G16_B16:
  563. return 6;
  564. case Size::Size_R8_G8_B8_A8:
  565. case Size::Size_X8_B8_G8_R8:
  566. return 4;
  567. case Size::Size_R16_G16:
  568. return 4;
  569. case Size::Size_R32:
  570. return 4;
  571. case Size::Size_R8_G8_B8:
  572. return 3;
  573. case Size::Size_R8_G8:
  574. case Size::Size_G8_R8:
  575. return 2;
  576. case Size::Size_R16:
  577. return 2;
  578. case Size::Size_R8:
  579. case Size::Size_A8:
  580. return 1;
  581. case Size::Size_A2_B10_G10_R10:
  582. return 4;
  583. case Size::Size_B10_G11_R11:
  584. return 4;
  585. default:
  586. ASSERT(false);
  587. return 1;
  588. }
  589. }
  590. std::string SizeString() const {
  591. switch (size) {
  592. case Size::Size_R32_G32_B32_A32:
  593. return "32_32_32_32";
  594. case Size::Size_R32_G32_B32:
  595. return "32_32_32";
  596. case Size::Size_R16_G16_B16_A16:
  597. return "16_16_16_16";
  598. case Size::Size_R32_G32:
  599. return "32_32";
  600. case Size::Size_R16_G16_B16:
  601. return "16_16_16";
  602. case Size::Size_R8_G8_B8_A8:
  603. return "8_8_8_8";
  604. case Size::Size_R16_G16:
  605. return "16_16";
  606. case Size::Size_R32:
  607. return "32";
  608. case Size::Size_R8_G8_B8:
  609. return "8_8_8";
  610. case Size::Size_R8_G8:
  611. case Size::Size_G8_R8:
  612. return "8_8";
  613. case Size::Size_R16:
  614. return "16";
  615. case Size::Size_R8:
  616. case Size::Size_A8:
  617. return "8";
  618. case Size::Size_A2_B10_G10_R10:
  619. return "2_10_10_10";
  620. case Size::Size_B10_G11_R11:
  621. return "10_11_11";
  622. default:
  623. ASSERT(false);
  624. return {};
  625. }
  626. }
  627. std::string TypeString() const {
  628. switch (type) {
  629. case Type::UnusedEnumDoNotUseBecauseItWillGoAway:
  630. return "Unused";
  631. case Type::SNorm:
  632. return "SNORM";
  633. case Type::UNorm:
  634. return "UNORM";
  635. case Type::SInt:
  636. return "SINT";
  637. case Type::UInt:
  638. return "UINT";
  639. case Type::UScaled:
  640. return "USCALED";
  641. case Type::SScaled:
  642. return "SSCALED";
  643. case Type::Float:
  644. return "FLOAT";
  645. }
  646. ASSERT(false);
  647. return {};
  648. }
  649. bool IsNormalized() const {
  650. return (type == Type::SNorm) || (type == Type::UNorm);
  651. }
  652. bool IsValid() const {
  653. return size != Size::Invalid;
  654. }
  655. bool operator<(const VertexAttribute& other) const {
  656. return hex < other.hex;
  657. }
  658. };
  659. static_assert(sizeof(VertexAttribute) == 0x4);
  660. struct MsaaSampleLocation {
  661. union {
  662. BitField<0, 4, u32> x0;
  663. BitField<4, 4, u32> y0;
  664. BitField<8, 4, u32> x1;
  665. BitField<12, 4, u32> y1;
  666. BitField<16, 4, u32> x2;
  667. BitField<20, 4, u32> y2;
  668. BitField<24, 4, u32> x3;
  669. BitField<28, 4, u32> y3;
  670. };
  671. constexpr std::pair<u32, u32> Location(int index) const {
  672. switch (index) {
  673. case 0:
  674. return {x0, y0};
  675. case 1:
  676. return {x1, y1};
  677. case 2:
  678. return {x2, y2};
  679. case 3:
  680. return {x3, y3};
  681. default:
  682. ASSERT(false);
  683. return {0, 0};
  684. }
  685. }
  686. };
  687. struct MultisampleCoverageToColor {
  688. union {
  689. BitField<0, 1, u32> enable;
  690. BitField<4, 3, u32> target;
  691. };
  692. };
  693. struct DecompressZetaSurface {
  694. union {
  695. BitField<0, 1, u32> z_enable;
  696. BitField<4, 1, u32> stencil_enable;
  697. };
  698. };
  699. struct ZetaSparse {
  700. enum class UnmappedCompare : u32 {
  701. Unmapped = 0,
  702. FailAlways = 1,
  703. };
  704. union {
  705. BitField<0, 1, u32> enable;
  706. BitField<1, 1, UnmappedCompare> unmapped_compare;
  707. };
  708. };
  709. struct RtControl {
  710. union {
  711. BitField<0, 4, u32> count;
  712. BitField<4, 3, u32> target0;
  713. BitField<7, 3, u32> target1;
  714. BitField<10, 3, u32> target2;
  715. BitField<13, 3, u32> target3;
  716. BitField<16, 3, u32> target4;
  717. BitField<19, 3, u32> target5;
  718. BitField<22, 3, u32> target6;
  719. BitField<25, 3, u32> target7;
  720. };
  721. u32 Map(std::size_t index) const {
  722. const std::array<u32, NumRenderTargets> maps{target0, target1, target2, target3,
  723. target4, target5, target6, target7};
  724. ASSERT(index < maps.size());
  725. return maps[index];
  726. }
  727. };
  728. struct CompressionThresholdSamples {
  729. u32 samples;
  730. u32 Samples() const {
  731. if (samples == 0) {
  732. return 0;
  733. }
  734. return 1U << (samples - 1);
  735. }
  736. };
  737. struct PixelShaderInterlockControl {
  738. enum class TileMode : u32 {
  739. NoConflictDetect = 0,
  740. DetectSampleConflict = 1,
  741. DetectPixelConflict = 2,
  742. };
  743. enum class TileSize : u32 {
  744. Size_16x16 = 0,
  745. Size_8x8 = 1,
  746. };
  747. enum class FragmentOrder : u32 {
  748. FragmentOrdered = 0,
  749. FragmentUnordered = 1,
  750. };
  751. union {
  752. BitField<0, 2, TileMode> tile_mode;
  753. BitField<2, 1, TileSize> tile_size;
  754. BitField<3, 1, FragmentOrder> fragment_order;
  755. };
  756. };
  757. struct ZetaSize {
  758. enum class DimensionControl : u32 {
  759. DepthDefinesArray = 0,
  760. ArraySizeOne = 1,
  761. };
  762. u32 width;
  763. u32 height;
  764. union {
  765. BitField<0, 16, u32> depth;
  766. BitField<16, 1, DimensionControl> dim_control;
  767. };
  768. };
  769. enum class PrimitiveTopology : u32 {
  770. Points = 0x0,
  771. Lines = 0x1,
  772. LineLoop = 0x2,
  773. LineStrip = 0x3,
  774. Triangles = 0x4,
  775. TriangleStrip = 0x5,
  776. TriangleFan = 0x6,
  777. Quads = 0x7,
  778. QuadStrip = 0x8,
  779. Polygon = 0x9,
  780. LinesAdjacency = 0xA,
  781. LineStripAdjacency = 0xB,
  782. TrianglesAdjacency = 0xC,
  783. TriangleStripAdjacency = 0xD,
  784. Patches = 0xE,
  785. };
  786. struct VertexArray {
  787. union {
  788. BitField<0, 16, u32> start;
  789. BitField<16, 12, u32> count;
  790. BitField<28, 3, PrimitiveTopology> topology;
  791. };
  792. };
  793. enum class PrimitiveTopologyOverride : u32 {
  794. None = 0x0,
  795. Points = 0x1,
  796. Lines = 0x2,
  797. LineStrip = 0x3,
  798. Triangles = 0x4,
  799. TriangleStrip = 0x5,
  800. LinesAdjacency = 0xA,
  801. LineStripAdjacency = 0xB,
  802. TrianglesAdjacency = 0xC,
  803. TriangleStripAdjacency = 0xD,
  804. Patches = 0xE,
  805. LegacyPoints = 0x1001,
  806. LegacyIndexedLines = 0x1002,
  807. LegacyIndexedTriangles = 0x1003,
  808. LegacyLines = 0x100F,
  809. LegacyLineStrip = 0x1010,
  810. LegacyIndexedLineStrip = 0x1011,
  811. LegacyTriangles = 0x1012,
  812. LegacyTriangleStrip = 0x1013,
  813. LegacyIndexedTriangleStrip = 0x1014,
  814. LegacyTriangleFan = 0x1015,
  815. LegacyIndexedTriangleFan = 0x1016,
  816. LegacyTriangleFanImm = 0x1017,
  817. LegacyLinesImm = 0x1018,
  818. LegacyIndexedTriangles2 = 0x101A,
  819. LegacyIndexedLines2 = 0x101B,
  820. };
  821. enum class DepthMode : u32 {
  822. MinusOneToOne = 0,
  823. ZeroToOne = 1,
  824. };
  825. enum class IndexFormat : u32 {
  826. UnsignedByte = 0x0,
  827. UnsignedShort = 0x1,
  828. UnsignedInt = 0x2,
  829. };
  830. enum class ComparisonOp : u32 {
  831. Never_D3D = 1,
  832. Less_D3D = 2,
  833. Equal_D3D = 3,
  834. LessEqual_D3D = 4,
  835. Greater_D3D = 5,
  836. NotEqual_D3D = 6,
  837. GreaterEqual_D3D = 7,
  838. Always_D3D = 8,
  839. Never_GL = 0x200,
  840. Less_GL = 0x201,
  841. Equal_GL = 0x202,
  842. LessEqual_GL = 0x203,
  843. Greater_GL = 0x204,
  844. NotEqual_GL = 0x205,
  845. GreaterEqual_GL = 0x206,
  846. Always_GL = 0x207,
  847. };
  848. enum class ClearReport : u32 {
  849. ZPassPixelCount = 0x01,
  850. ZCullStats = 0x02,
  851. StreamingPrimitvesNeededMinusSucceeded = 0x03,
  852. AlphaBetaClocks = 0x04,
  853. StreamingPrimitivesSucceeded = 0x10,
  854. StreamingPrimitivesNeeded = 0x11,
  855. VerticesGenerated = 0x12,
  856. PrimitivesGenerated = 0x13,
  857. VertexShaderInvocations = 0x15,
  858. TessellationInitInvocations = 0x16,
  859. TessellationShaderInvocations = 0x17,
  860. TessellationShaderPrimitivesGenerated = 0x18,
  861. GeometryShaderInvocations = 0x1A,
  862. GeometryShaderPrimitivesGenerated = 0x1B,
  863. ClipperInvocations = 0x1C,
  864. ClipperPrimitivesGenerated = 0x1D,
  865. PixelShaderInvocations = 0x1E,
  866. VtgPrimitivesOut = 0x1F,
  867. };
  868. enum class FrontFace : u32 {
  869. ClockWise = 0x900,
  870. CounterClockWise = 0x901,
  871. };
  872. enum class CullFace : u32 {
  873. Front = 0x404,
  874. Back = 0x405,
  875. FrontAndBack = 0x408,
  876. };
  877. struct Blend {
  878. enum class Equation : u32 {
  879. Add_D3D = 1,
  880. Subtract_D3D = 2,
  881. ReverseSubtract_D3D = 3,
  882. Min_D3D = 4,
  883. Max_D3D = 5,
  884. Add_GL = 0x8006,
  885. Min_GL = 0x8007,
  886. Max_GL = 0x8008,
  887. Subtract_GL = 0x800A,
  888. ReverseSubtract_GL = 0x800B
  889. };
  890. enum class Factor : u32 {
  891. Zero_D3D = 0x1,
  892. One_D3D = 0x2,
  893. SourceColor_D3D = 0x3,
  894. OneMinusSourceColor_D3D = 0x4,
  895. SourceAlpha_D3D = 0x5,
  896. OneMinusSourceAlpha_D3D = 0x6,
  897. DestAlpha_D3D = 0x7,
  898. OneMinusDestAlpha_D3D = 0x8,
  899. DestColor_D3D = 0x9,
  900. OneMinusDestColor_D3D = 0xA,
  901. SourceAlphaSaturate_D3D = 0xB,
  902. BothSourceAlpha_D3D = 0xC,
  903. OneMinusBothSourceAlpha_D3D = 0xD,
  904. BlendFactor_D3D = 0xE,
  905. OneMinusBlendFactor_D3D = 0xF,
  906. Source1Color_D3D = 0x10,
  907. OneMinusSource1Color_D3D = 0x11,
  908. Source1Alpha_D3D = 0x12,
  909. OneMinusSource1Alpha_D3D = 0x13,
  910. Zero_GL = 0x4000,
  911. One_GL = 0x4001,
  912. SourceColor_GL = 0x4300,
  913. OneMinusSourceColor_GL = 0x4301,
  914. SourceAlpha_GL = 0x4302,
  915. OneMinusSourceAlpha_GL = 0x4303,
  916. DestAlpha_GL = 0x4304,
  917. OneMinusDestAlpha_GL = 0x4305,
  918. DestColor_GL = 0x4306,
  919. OneMinusDestColor_GL = 0x4307,
  920. SourceAlphaSaturate_GL = 0x4308,
  921. ConstantColor_GL = 0xC001,
  922. OneMinusConstantColor_GL = 0xC002,
  923. ConstantAlpha_GL = 0xC003,
  924. OneMinusConstantAlpha_GL = 0xC004,
  925. Source1Color_GL = 0xC900,
  926. OneMinusSource1Color_GL = 0xC901,
  927. Source1Alpha_GL = 0xC902,
  928. OneMinusSource1Alpha_GL = 0xC903,
  929. };
  930. u32 separate_alpha;
  931. Equation color_op;
  932. Factor color_source;
  933. Factor color_dest;
  934. Equation alpha_op;
  935. Factor alpha_source;
  936. u32 enable_global_color_key;
  937. Factor alpha_dest;
  938. u32 single_rop_control_enable;
  939. u32 enable[NumRenderTargets];
  940. };
  941. struct BlendPerTarget {
  942. u32 separate_alpha;
  943. Blend::Equation color_op;
  944. Blend::Factor color_source;
  945. Blend::Factor color_dest;
  946. Blend::Equation alpha_op;
  947. Blend::Factor alpha_source;
  948. Blend::Factor alpha_dest;
  949. INSERT_PADDING_BYTES_NOINIT(0x4);
  950. };
  951. static_assert(sizeof(BlendPerTarget) == 0x20);
  952. enum class PolygonMode : u32 {
  953. Point = 0x1B00,
  954. Line = 0x1B01,
  955. Fill = 0x1B02,
  956. };
  957. enum class ShadowRamControl : u32 {
  958. // write value to shadow ram
  959. Track = 0,
  960. // write value to shadow ram ( with validation ??? )
  961. TrackWithFilter = 1,
  962. // only write to real hw register
  963. Passthrough = 2,
  964. // write value from shadow ram to real hw register
  965. Replay = 3,
  966. };
  967. enum class ViewportSwizzle : u32 {
  968. PositiveX = 0,
  969. NegativeX = 1,
  970. PositiveY = 2,
  971. NegativeY = 3,
  972. PositiveZ = 4,
  973. NegativeZ = 5,
  974. PositiveW = 6,
  975. NegativeW = 7,
  976. };
  977. enum class SamplerBinding : u32 {
  978. Independently = 0,
  979. ViaHeaderBinding = 1,
  980. };
  981. struct TileMode {
  982. enum class DimensionControl : u32 {
  983. DepthDefinesArray = 0,
  984. DepthDefinesDepth = 1,
  985. };
  986. union {
  987. BitField<0, 4, u32> block_width;
  988. BitField<4, 4, u32> block_height;
  989. BitField<8, 4, u32> block_depth;
  990. BitField<12, 1, u32> is_pitch_linear;
  991. BitField<16, 1, DimensionControl> dim_control;
  992. };
  993. };
  994. static_assert(sizeof(TileMode) == 4);
  995. struct RenderTargetConfig {
  996. u32 address_high;
  997. u32 address_low;
  998. u32 width;
  999. u32 height;
  1000. Tegra::RenderTargetFormat format;
  1001. TileMode tile_mode;
  1002. union {
  1003. BitField<0, 16, u32> depth;
  1004. BitField<16, 1, u32> volume;
  1005. };
  1006. u32 array_pitch;
  1007. u32 base_layer;
  1008. u32 mark_ieee_clean;
  1009. INSERT_PADDING_BYTES_NOINIT(0x18);
  1010. GPUVAddr Address() const {
  1011. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  1012. }
  1013. };
  1014. static_assert(sizeof(RenderTargetConfig) == 0x40);
  1015. struct ColorMask {
  1016. union {
  1017. u32 raw;
  1018. BitField<0, 1, u32> R;
  1019. BitField<4, 1, u32> G;
  1020. BitField<8, 1, u32> B;
  1021. BitField<12, 1, u32> A;
  1022. };
  1023. };
  1024. struct ViewportTransform {
  1025. f32 scale_x;
  1026. f32 scale_y;
  1027. f32 scale_z;
  1028. f32 translate_x;
  1029. f32 translate_y;
  1030. f32 translate_z;
  1031. union {
  1032. u32 raw;
  1033. BitField<0, 3, ViewportSwizzle> x;
  1034. BitField<4, 3, ViewportSwizzle> y;
  1035. BitField<8, 3, ViewportSwizzle> z;
  1036. BitField<12, 3, ViewportSwizzle> w;
  1037. } swizzle;
  1038. union {
  1039. BitField<0, 5, u32> x;
  1040. BitField<8, 5, u32> y;
  1041. } snap_grid_precision;
  1042. Common::Rectangle<f32> GetRect() const {
  1043. return {
  1044. GetX(), // left
  1045. GetY() + GetHeight(), // top
  1046. GetX() + GetWidth(), // right
  1047. GetY() // bottom
  1048. };
  1049. }
  1050. f32 GetX() const {
  1051. return std::max(0.0f, translate_x - std::fabs(scale_x));
  1052. }
  1053. f32 GetY() const {
  1054. return std::max(0.0f, translate_y - std::fabs(scale_y));
  1055. }
  1056. f32 GetWidth() const {
  1057. return translate_x + std::fabs(scale_x) - GetX();
  1058. }
  1059. f32 GetHeight() const {
  1060. return translate_y + std::fabs(scale_y) - GetY();
  1061. }
  1062. };
  1063. static_assert(sizeof(ViewportTransform) == 0x20);
  1064. struct Viewport {
  1065. enum class PixelCenter : u32 {
  1066. HalfIntegers = 0,
  1067. Integers = 1,
  1068. };
  1069. union {
  1070. BitField<0, 16, u32> x;
  1071. BitField<16, 16, u32> width;
  1072. };
  1073. union {
  1074. BitField<0, 16, u32> y;
  1075. BitField<16, 16, u32> height;
  1076. };
  1077. float depth_range_near;
  1078. float depth_range_far;
  1079. };
  1080. static_assert(sizeof(Viewport) == 0x10);
  1081. struct Window {
  1082. union {
  1083. u32 raw_1;
  1084. BitField<0, 16, u32> x_min;
  1085. BitField<16, 16, u32> x_max;
  1086. };
  1087. union {
  1088. u32 raw_2;
  1089. BitField<0, 16, u32> y_min;
  1090. BitField<16, 16, u32> y_max;
  1091. };
  1092. };
  1093. static_assert(sizeof(Window) == 0x8);
  1094. struct ClipIdExtent {
  1095. union {
  1096. BitField<0, 16, u32> x;
  1097. BitField<16, 16, u32> width;
  1098. };
  1099. union {
  1100. BitField<0, 16, u32> y;
  1101. BitField<16, 16, u32> height;
  1102. };
  1103. };
  1104. static_assert(sizeof(ClipIdExtent) == 0x8);
  1105. enum class VisibleCallLimit : u32 {
  1106. Limit0 = 0,
  1107. Limit1 = 1,
  1108. Limit2 = 2,
  1109. Limit4 = 3,
  1110. Limit8 = 4,
  1111. Limit16 = 5,
  1112. Limit32 = 6,
  1113. Limit64 = 7,
  1114. Limit128 = 8,
  1115. None = 15,
  1116. };
  1117. struct StatisticsCounter {
  1118. union {
  1119. BitField<0, 1, u32> da_vertices;
  1120. BitField<1, 1, u32> da_primitives;
  1121. BitField<2, 1, u32> vs_invocations;
  1122. BitField<3, 1, u32> gs_invocations;
  1123. BitField<4, 1, u32> gs_primitives;
  1124. BitField<5, 1, u32> streaming_primitives_succeeded;
  1125. BitField<6, 1, u32> streaming_primitives_needed;
  1126. BitField<7, 1, u32> clipper_invocations;
  1127. BitField<8, 1, u32> clipper_primitives;
  1128. BitField<9, 1, u32> ps_invocations;
  1129. BitField<11, 1, u32> ti_invocations;
  1130. BitField<12, 1, u32> ts_invocations;
  1131. BitField<13, 1, u32> ts_primitives;
  1132. BitField<14, 1, u32> total_streaming_primitives_needed_succeeded;
  1133. BitField<10, 1, u32> vtg_primitives_out;
  1134. BitField<15, 1, u32> alpha_beta_clocks;
  1135. };
  1136. };
  1137. struct ClearRect {
  1138. union {
  1139. BitField<0, 16, u32> x_min;
  1140. BitField<16, 16, u32> x_max;
  1141. };
  1142. union {
  1143. BitField<0, 16, u32> y_min;
  1144. BitField<16, 16, u32> y_max;
  1145. };
  1146. };
  1147. struct VertexBuffer {
  1148. u32 first;
  1149. u32 count;
  1150. };
  1151. struct InvalidateShaderCacheNoWFI {
  1152. union {
  1153. BitField<0, 1, u32> instruction;
  1154. BitField<4, 1, u32> global_data;
  1155. BitField<12, 1, u32> constant;
  1156. };
  1157. };
  1158. struct ZCullSerialization {
  1159. enum class Applied : u32 {
  1160. Always = 0,
  1161. LateZ = 1,
  1162. OutOfGamutZ = 2,
  1163. LateZOrOutOfGamutZ = 3,
  1164. };
  1165. union {
  1166. BitField<0, 1, u32> enable;
  1167. BitField<4, 2, Applied> applied;
  1168. };
  1169. };
  1170. struct ZCullDirFormat {
  1171. enum class Zdir : u32 {
  1172. Less = 0,
  1173. Greater = 1,
  1174. };
  1175. enum class Zformat : u32 {
  1176. MSB = 0,
  1177. FP = 1,
  1178. Ztrick = 2,
  1179. Zf32 = 3,
  1180. };
  1181. union {
  1182. BitField<0, 16, Zdir> dir;
  1183. BitField<16, 16, Zformat> format;
  1184. };
  1185. };
  1186. struct IteratedBlend {
  1187. union {
  1188. BitField<0, 1, u32> enable;
  1189. BitField<1, 1, u32> enable_alpha;
  1190. };
  1191. u32 pass_count;
  1192. };
  1193. struct ZCullCriterion {
  1194. enum class Sfunc : u32 {
  1195. Never = 0,
  1196. Less = 1,
  1197. Equal = 2,
  1198. LessOrEqual = 3,
  1199. Greater = 4,
  1200. NotEqual = 5,
  1201. GreaterOrEqual = 6,
  1202. Always = 7,
  1203. };
  1204. union {
  1205. BitField<0, 8, Sfunc> sfunc;
  1206. BitField<8, 1, u32> no_invalidate;
  1207. BitField<9, 1, u32> force_match;
  1208. BitField<16, 8, u32> sref;
  1209. BitField<24, 8, u32> smask;
  1210. };
  1211. };
  1212. struct LoadIteratedBlend {
  1213. enum class Test : u32 {
  1214. False = 0,
  1215. True = 1,
  1216. Equal = 2,
  1217. NotEqual = 3,
  1218. LessThan = 4,
  1219. LessOrEqual = 5,
  1220. Greater = 6,
  1221. GreaterOrEqual = 7,
  1222. };
  1223. enum class Operation : u32 {
  1224. AddProducts = 0,
  1225. SubProducts = 1,
  1226. Min = 2,
  1227. Max = 3,
  1228. Reciprocal = 4,
  1229. Add = 5,
  1230. Sub = 6,
  1231. };
  1232. enum class OperandA : u32 {
  1233. SrcRGB = 0,
  1234. DstRGB = 1,
  1235. SrcAAA = 2,
  1236. DstAAA = 3,
  1237. Temp0_RGB = 4,
  1238. Temp1_RGB = 5,
  1239. Temp2_RGB = 6,
  1240. PBR_RGB = 7,
  1241. };
  1242. enum class OperandB : u32 {
  1243. Zero = 0,
  1244. One = 1,
  1245. SrcRGB = 2,
  1246. SrcAAA = 3,
  1247. OneMinusSrcAAA = 4,
  1248. DstRGB = 5,
  1249. DstAAA = 6,
  1250. OneMinusDstAAA = 7,
  1251. Temp0_RGB = 9,
  1252. Temp1_RGB = 10,
  1253. Temp2_RGB = 11,
  1254. PBR_RGB = 12,
  1255. ConstRGB = 13,
  1256. ZeroATimesB = 14,
  1257. };
  1258. enum class Swizzle : u32 {
  1259. RGB = 0,
  1260. GBR = 1,
  1261. RRR = 2,
  1262. GGG = 3,
  1263. BBB = 4,
  1264. RToA = 5,
  1265. };
  1266. enum class WriteMask : u32 {
  1267. RGB = 0,
  1268. ROnly = 1,
  1269. GOnly = 2,
  1270. BOnly = 3,
  1271. };
  1272. enum class Pass : u32 {
  1273. Temp0 = 0,
  1274. Temp1 = 1,
  1275. Temp2 = 2,
  1276. None = 3,
  1277. };
  1278. u32 instruction_ptr;
  1279. union {
  1280. BitField<0, 3, Test> test;
  1281. BitField<3, 3, Operation> operation;
  1282. BitField<6, 3, u32> const_input;
  1283. BitField<9, 3, OperandA> operand_a;
  1284. BitField<12, 4, OperandB> operand_b;
  1285. BitField<16, 3, OperandA> operand_c;
  1286. BitField<19, 4, OperandB> operand_d;
  1287. BitField<23, 3, Swizzle> output_swizzle;
  1288. BitField<26, 2, WriteMask> output_mask;
  1289. BitField<28, 2, Pass> output_pass;
  1290. BitField<31, 1, u32> test_enabled;
  1291. };
  1292. };
  1293. struct ScissorTest {
  1294. u32 enable;
  1295. union {
  1296. BitField<0, 16, u32> min_x;
  1297. BitField<16, 16, u32> max_x;
  1298. };
  1299. union {
  1300. BitField<0, 16, u32> min_y;
  1301. BitField<16, 16, u32> max_y;
  1302. };
  1303. INSERT_PADDING_BYTES_NOINIT(0x4);
  1304. };
  1305. static_assert(sizeof(ScissorTest) == 0x10);
  1306. struct VPCPerf {
  1307. union {
  1308. BitField<0, 8, u32> culled_small_lines;
  1309. BitField<8, 8, u32> culled_small_triangles;
  1310. BitField<16, 8, u32> nonculled_lines_and_points;
  1311. BitField<24, 8, u32> nonculled_triangles;
  1312. };
  1313. };
  1314. struct ConstantColorRendering {
  1315. u32 enabled;
  1316. u32 red;
  1317. u32 green;
  1318. u32 blue;
  1319. u32 alpha;
  1320. };
  1321. struct VertexStreamSubstitute {
  1322. u32 address_high;
  1323. u32 address_low;
  1324. GPUVAddr Address() const {
  1325. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  1326. }
  1327. };
  1328. struct VTGWarpWatermarks {
  1329. union {
  1330. BitField<0, 16, u32> low;
  1331. BitField<16, 16, u32> high;
  1332. };
  1333. };
  1334. struct SampleMask {
  1335. struct Target {
  1336. union {
  1337. BitField<0, 1, u32> raster_out;
  1338. BitField<4, 1, u32> color_target;
  1339. };
  1340. u32 target;
  1341. };
  1342. struct Pos {
  1343. u32 x0_y0;
  1344. u32 x1_y0;
  1345. u32 x0_y1;
  1346. u32 x1_y1;
  1347. };
  1348. };
  1349. enum class NonMultisampledZ : u32 {
  1350. PerSample = 0,
  1351. PixelCenter = 1,
  1352. };
  1353. enum class TIRMode : u32 {
  1354. Disabled = 0,
  1355. RasterNTargetM = 1,
  1356. };
  1357. enum class AntiAliasRaster : u32 {
  1358. Mode1x1 = 0,
  1359. Mode2x2 = 2,
  1360. Mode4x2_D3D = 4,
  1361. Mode2x1_D3D = 5,
  1362. Mode4x4 = 6,
  1363. };
  1364. struct SurfaceClipIDMemory {
  1365. u32 address_high;
  1366. u32 address_low;
  1367. GPUVAddr Address() const {
  1368. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  1369. }
  1370. };
  1371. struct TIRModulation {
  1372. enum class Component : u32 {
  1373. None = 0,
  1374. RGB = 1,
  1375. AlphaOnly = 2,
  1376. RGBA = 3,
  1377. };
  1378. enum class Function : u32 {
  1379. Linear = 0,
  1380. Table = 1,
  1381. };
  1382. Component component;
  1383. Function function;
  1384. };
  1385. struct Zeta {
  1386. u32 address_high;
  1387. u32 address_low;
  1388. Tegra::DepthFormat format;
  1389. TileMode tile_mode;
  1390. u32 array_pitch;
  1391. GPUVAddr Address() const {
  1392. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  1393. }
  1394. };
  1395. struct SurfaceClip {
  1396. union {
  1397. BitField<0, 16, u32> x;
  1398. BitField<16, 16, u32> width;
  1399. };
  1400. union {
  1401. BitField<0, 16, u32> y;
  1402. BitField<16, 16, u32> height;
  1403. };
  1404. };
  1405. enum class L2CacheControlPolicy : u32 {
  1406. First = 0,
  1407. Normal = 1,
  1408. Last = 2,
  1409. };
  1410. struct L2CacheVAFRequests {
  1411. union {
  1412. BitField<0, 1, u32> system_memory_volatile;
  1413. BitField<4, 2, L2CacheControlPolicy> policy;
  1414. };
  1415. };
  1416. enum class ViewportMulticast : u32 {
  1417. ViewportOrder = 0,
  1418. PrimitiveOrder = 1,
  1419. };
  1420. struct TIRModulationCoeff {
  1421. union {
  1422. BitField<0, 8, u32> table_v0;
  1423. BitField<8, 8, u32> table_v1;
  1424. BitField<16, 8, u32> table_v2;
  1425. BitField<24, 8, u32> table_v3;
  1426. };
  1427. };
  1428. static_assert(sizeof(TIRModulationCoeff) == 0x4);
  1429. struct ReduceColorThreshold {
  1430. union {
  1431. BitField<0, 8, u32> all_hit_once;
  1432. BitField<16, 8, u32> all_covered;
  1433. };
  1434. };
  1435. struct ClearControl {
  1436. union {
  1437. BitField<0, 1, u32> respect_stencil_mask;
  1438. BitField<4, 1, u32> use_clear_rect;
  1439. BitField<8, 1, u32> use_scissor;
  1440. BitField<12, 1, u32> use_viewport_clip0;
  1441. };
  1442. };
  1443. struct L2CacheRopNonInterlockedReads {
  1444. union {
  1445. BitField<4, 2, L2CacheControlPolicy> policy;
  1446. };
  1447. };
  1448. struct VertexOutputAttributeSkipMasks {
  1449. struct Attributes {
  1450. union {
  1451. BitField<0, 1, u32> attribute0_comp0;
  1452. BitField<1, 1, u32> attribute0_comp1;
  1453. BitField<2, 1, u32> attribute0_comp2;
  1454. BitField<3, 1, u32> attribute0_comp3;
  1455. BitField<4, 1, u32> attribute1_comp0;
  1456. BitField<5, 1, u32> attribute1_comp1;
  1457. BitField<6, 1, u32> attribute1_comp2;
  1458. BitField<7, 1, u32> attribute1_comp3;
  1459. BitField<8, 1, u32> attribute2_comp0;
  1460. BitField<9, 1, u32> attribute2_comp1;
  1461. BitField<10, 1, u32> attribute2_comp2;
  1462. BitField<11, 1, u32> attribute2_comp3;
  1463. BitField<12, 1, u32> attribute3_comp0;
  1464. BitField<13, 1, u32> attribute3_comp1;
  1465. BitField<14, 1, u32> attribute3_comp2;
  1466. BitField<15, 1, u32> attribute3_comp3;
  1467. BitField<16, 1, u32> attribute4_comp0;
  1468. BitField<17, 1, u32> attribute4_comp1;
  1469. BitField<18, 1, u32> attribute4_comp2;
  1470. BitField<19, 1, u32> attribute4_comp3;
  1471. BitField<20, 1, u32> attribute5_comp0;
  1472. BitField<21, 1, u32> attribute5_comp1;
  1473. BitField<22, 1, u32> attribute5_comp2;
  1474. BitField<23, 1, u32> attribute5_comp3;
  1475. BitField<24, 1, u32> attribute6_comp0;
  1476. BitField<25, 1, u32> attribute6_comp1;
  1477. BitField<26, 1, u32> attribute6_comp2;
  1478. BitField<27, 1, u32> attribute6_comp3;
  1479. BitField<28, 1, u32> attribute7_comp0;
  1480. BitField<29, 1, u32> attribute7_comp1;
  1481. BitField<30, 1, u32> attribute7_comp2;
  1482. BitField<31, 1, u32> attribute7_comp3;
  1483. };
  1484. };
  1485. std::array<Attributes, 2> a;
  1486. std::array<Attributes, 2> b;
  1487. };
  1488. struct TIRControl {
  1489. union {
  1490. BitField<0, 1, u32> z_pass_pixel_count_use_raster_samples;
  1491. BitField<4, 1, u32> alpha_coverage_use_raster_samples;
  1492. BitField<1, 1, u32> reduce_coverage;
  1493. };
  1494. };
  1495. enum class FillViaTriangleMode : u32 {
  1496. Disabled = 0,
  1497. FillAll = 1,
  1498. FillBoundingBox = 2,
  1499. };
  1500. struct PsTicketDispenserValue {
  1501. union {
  1502. BitField<0, 8, u32> index;
  1503. BitField<8, 16, u32> value;
  1504. };
  1505. };
  1506. struct RegisterWatermarks {
  1507. union {
  1508. BitField<0, 16, u32> low;
  1509. BitField<16, 16, u32> high;
  1510. };
  1511. };
  1512. enum class InvalidateCacheLines : u32 {
  1513. All = 0,
  1514. One = 1,
  1515. };
  1516. struct InvalidateTextureDataCacheNoWfi {
  1517. union {
  1518. BitField<0, 1, InvalidateCacheLines> lines;
  1519. BitField<4, 22, u32> tag;
  1520. };
  1521. };
  1522. struct ZCullRegionEnable {
  1523. union {
  1524. BitField<0, 1, u32> enable_z;
  1525. BitField<4, 1, u32> enable_stencil;
  1526. BitField<1, 1, u32> rect_clear;
  1527. BitField<2, 1, u32> use_rt_array_index;
  1528. BitField<5, 16, u32> rt_array_index;
  1529. BitField<3, 1, u32> make_conservative;
  1530. };
  1531. };
  1532. enum class FillMode : u32 {
  1533. Point = 1,
  1534. Wireframe = 2,
  1535. Solid = 3,
  1536. };
  1537. enum class ShadeMode : u32 {
  1538. Flat = 0x1,
  1539. Gouraud = 0x2,
  1540. GL_Flat = 0x1D00,
  1541. GL_Smooth = 0x1D01,
  1542. };
  1543. enum class AlphaToCoverageDither : u32 {
  1544. Footprint_1x1 = 0,
  1545. Footprint_2x2 = 1,
  1546. Footprint_1x1_Virtual = 2,
  1547. };
  1548. struct InlineIndex4x8 {
  1549. union {
  1550. BitField<0, 30, u32> count;
  1551. BitField<30, 2, u32> start;
  1552. };
  1553. union {
  1554. BitField<0, 8, u32> index0;
  1555. BitField<8, 8, u32> index1;
  1556. BitField<16, 8, u32> index2;
  1557. BitField<24, 8, u32> index3;
  1558. };
  1559. };
  1560. enum class D3DCullMode : u32 {
  1561. None = 0,
  1562. CW = 1,
  1563. CCW = 2,
  1564. };
  1565. struct BlendColor {
  1566. f32 r;
  1567. f32 g;
  1568. f32 b;
  1569. f32 a;
  1570. };
  1571. struct StencilOp {
  1572. enum class Op : u32 {
  1573. Keep_D3D = 1,
  1574. Zero_D3D = 2,
  1575. Replace_D3D = 3,
  1576. IncrSaturate_D3D = 4,
  1577. DecrSaturate_D3D = 5,
  1578. Invert_D3D = 6,
  1579. Incr_D3D = 7,
  1580. Decr_D3D = 8,
  1581. Keep_GL = 0x1E00,
  1582. Zero_GL = 0,
  1583. Replace_GL = 0x1E01,
  1584. IncrSaturate_GL = 0x1E02,
  1585. DecrSaturate_GL = 0x1E03,
  1586. Invert_GL = 0x150A,
  1587. Incr_GL = 0x8507,
  1588. Decr_GL = 0x8508,
  1589. };
  1590. Op fail;
  1591. Op zfail;
  1592. Op zpass;
  1593. ComparisonOp func;
  1594. };
  1595. struct PsSaturate {
  1596. // Opposite of DepthMode
  1597. enum class Depth : u32 {
  1598. ZeroToOne = 0,
  1599. MinusOneToOne = 1,
  1600. };
  1601. union {
  1602. BitField<0, 1, u32> output0_enable;
  1603. BitField<1, 1, Depth> output0_range;
  1604. BitField<4, 1, u32> output1_enable;
  1605. BitField<5, 1, Depth> output1_range;
  1606. BitField<8, 1, u32> output2_enable;
  1607. BitField<9, 1, Depth> output2_range;
  1608. BitField<12, 1, u32> output3_enable;
  1609. BitField<13, 1, Depth> output3_range;
  1610. BitField<16, 1, u32> output4_enable;
  1611. BitField<17, 1, Depth> output4_range;
  1612. BitField<20, 1, u32> output5_enable;
  1613. BitField<21, 1, Depth> output5_range;
  1614. BitField<24, 1, u32> output6_enable;
  1615. BitField<25, 1, Depth> output6_range;
  1616. BitField<28, 1, u32> output7_enable;
  1617. BitField<29, 1, Depth> output7_range;
  1618. };
  1619. bool AnyEnabled() const {
  1620. return output0_enable || output1_enable || output2_enable || output3_enable ||
  1621. output4_enable || output5_enable || output6_enable || output7_enable;
  1622. }
  1623. };
  1624. struct WindowOrigin {
  1625. enum class Mode : u32 {
  1626. UpperLeft = 0,
  1627. LowerLeft = 1,
  1628. };
  1629. union {
  1630. BitField<0, 1, Mode> mode;
  1631. BitField<4, 1, u32> flip_y;
  1632. };
  1633. };
  1634. struct IteratedBlendConstants {
  1635. u32 r;
  1636. u32 g;
  1637. u32 b;
  1638. INSERT_PADDING_BYTES_NOINIT(0x4);
  1639. };
  1640. static_assert(sizeof(IteratedBlendConstants) == 0x10);
  1641. struct UserClip {
  1642. struct Enable {
  1643. union {
  1644. u32 raw;
  1645. BitField<0, 1, u32> plane0;
  1646. BitField<1, 1, u32> plane1;
  1647. BitField<2, 1, u32> plane2;
  1648. BitField<3, 1, u32> plane3;
  1649. BitField<4, 1, u32> plane4;
  1650. BitField<5, 1, u32> plane5;
  1651. BitField<6, 1, u32> plane6;
  1652. BitField<7, 1, u32> plane7;
  1653. };
  1654. bool AnyEnabled() const {
  1655. return plane0 || plane1 || plane2 || plane3 || plane4 || plane5 || plane6 ||
  1656. plane7;
  1657. }
  1658. };
  1659. struct Op {
  1660. enum class ClipOrCull : u32 {
  1661. Clip = 0,
  1662. Cull = 1,
  1663. };
  1664. union {
  1665. u32 raw;
  1666. BitField<0, 1, ClipOrCull> plane0;
  1667. BitField<4, 1, ClipOrCull> plane1;
  1668. BitField<8, 1, ClipOrCull> plane2;
  1669. BitField<12, 1, ClipOrCull> plane3;
  1670. BitField<16, 1, ClipOrCull> plane4;
  1671. BitField<20, 1, ClipOrCull> plane5;
  1672. BitField<24, 1, ClipOrCull> plane6;
  1673. BitField<28, 1, ClipOrCull> plane7;
  1674. };
  1675. };
  1676. };
  1677. struct AntiAliasAlphaControl {
  1678. union {
  1679. BitField<0, 1, u32> alpha_to_coverage;
  1680. BitField<4, 1, u32> alpha_to_one;
  1681. };
  1682. };
  1683. struct RenderEnable {
  1684. enum class Override : u32 {
  1685. UseRenderEnable = 0,
  1686. AlwaysRender = 1,
  1687. NeverRender = 2,
  1688. };
  1689. enum class Mode : u32 {
  1690. False = 0,
  1691. True = 1,
  1692. Conditional = 2,
  1693. IfEqual = 3,
  1694. IfNotEqual = 4,
  1695. };
  1696. u32 address_high;
  1697. u32 address_low;
  1698. Mode mode;
  1699. GPUVAddr Address() const {
  1700. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  1701. }
  1702. };
  1703. struct TexSampler {
  1704. u32 address_high;
  1705. u32 address_low;
  1706. u32 limit;
  1707. GPUVAddr Address() const {
  1708. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  1709. }
  1710. };
  1711. struct TexHeader {
  1712. u32 address_high;
  1713. u32 address_low;
  1714. u32 limit;
  1715. GPUVAddr Address() const {
  1716. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  1717. }
  1718. };
  1719. enum class ZCullRegionFormat : u32 {
  1720. Z_4x4 = 0,
  1721. ZS_4x4 = 1,
  1722. Z_4x2 = 2,
  1723. Z_2x4 = 3,
  1724. Z_16x8_4x4 = 4,
  1725. Z_8x8_4x2 = 5,
  1726. Z_8x8_2x4 = 6,
  1727. Z_16x16_4x8 = 7,
  1728. Z_4x8_2x2 = 8,
  1729. ZS_16x8_4x2 = 9,
  1730. ZS_16x8_2x4 = 10,
  1731. ZS_8x8_2x2 = 11,
  1732. Z_4x8_1x1 = 12,
  1733. };
  1734. struct RtLayer {
  1735. enum class Control {
  1736. LayerSelectsLayer = 0,
  1737. GeometryShaderSelectsLayer = 1,
  1738. };
  1739. union {
  1740. BitField<0, 16, u32> layer;
  1741. BitField<16, 1, u32> control;
  1742. };
  1743. };
  1744. struct InlineIndex2x16 {
  1745. union {
  1746. BitField<0, 31, u32> count;
  1747. BitField<31, 1, u32> start_odd;
  1748. };
  1749. union {
  1750. BitField<0, 16, u32> even;
  1751. BitField<16, 16, u32> odd;
  1752. };
  1753. };
  1754. struct VertexGlobalBaseOffset {
  1755. u32 address_high;
  1756. u32 address_low;
  1757. GPUVAddr Address() const {
  1758. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  1759. }
  1760. };
  1761. struct ZCullRegionPixelOffset {
  1762. u32 width;
  1763. u32 height;
  1764. };
  1765. struct PointSprite {
  1766. enum class RMode : u32 {
  1767. Zero = 0,
  1768. FromR = 1,
  1769. FromS = 2,
  1770. };
  1771. enum class Origin : u32 {
  1772. Bottom = 0,
  1773. Top = 1,
  1774. };
  1775. enum class Texture : u32 {
  1776. Passthrough = 0,
  1777. Generate = 1,
  1778. };
  1779. union {
  1780. BitField<0, 2, RMode> rmode;
  1781. BitField<2, 1, Origin> origin;
  1782. BitField<3, 1, Texture> texture0;
  1783. BitField<4, 1, Texture> texture1;
  1784. BitField<5, 1, Texture> texture2;
  1785. BitField<6, 1, Texture> texture3;
  1786. BitField<7, 1, Texture> texture4;
  1787. BitField<8, 1, Texture> texture5;
  1788. BitField<9, 1, Texture> texture6;
  1789. BitField<10, 1, Texture> texture7;
  1790. BitField<11, 1, Texture> texture8;
  1791. BitField<12, 1, Texture> texture9;
  1792. };
  1793. };
  1794. struct ProgramRegion {
  1795. u32 address_high;
  1796. u32 address_low;
  1797. GPUVAddr Address() const {
  1798. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  1799. }
  1800. };
  1801. struct DefaultAttributes {
  1802. enum class Diffuse : u32 {
  1803. Vector_0001 = 0,
  1804. Vector_1111 = 1,
  1805. };
  1806. enum class Specular : u32 {
  1807. Vector_0000 = 0,
  1808. Vector_0001 = 1,
  1809. };
  1810. enum class Vector : u32 {
  1811. Vector_0000 = 0,
  1812. Vector_0001 = 1,
  1813. };
  1814. enum class FixedFncTexture : u32 {
  1815. Vector_0000 = 0,
  1816. Vector_0001 = 1,
  1817. };
  1818. enum class DX9Color0 : u32 {
  1819. Vector_0000 = 0,
  1820. Vector_1111 = 1,
  1821. };
  1822. enum class DX9Color1To15 : u32 {
  1823. Vector_0000 = 0,
  1824. Vector_0001 = 1,
  1825. };
  1826. union {
  1827. BitField<0, 1, Diffuse> color_front_diffuse;
  1828. BitField<1, 1, Specular> color_front_specular;
  1829. BitField<2, 1, Vector> generic_vector;
  1830. BitField<3, 1, FixedFncTexture> fixed_fnc_texture;
  1831. BitField<4, 1, DX9Color0> dx9_color0;
  1832. BitField<5, 1, DX9Color1To15> dx9_color1_to_15;
  1833. };
  1834. };
  1835. struct Draw {
  1836. enum class PrimitiveId : u32 {
  1837. First = 0,
  1838. Unchanged = 1,
  1839. };
  1840. enum class InstanceId : u32 {
  1841. First = 0,
  1842. Subsequent = 1,
  1843. Unchanged = 2,
  1844. };
  1845. enum class SplitMode : u32 {
  1846. NormalBeginNormal = 0,
  1847. NormalBeginOpen = 1,
  1848. OpenBeginOpen = 2,
  1849. OpenBeginNormal = 3,
  1850. };
  1851. u32 end;
  1852. union {
  1853. u32 begin;
  1854. BitField<0, 16, PrimitiveTopology> topology;
  1855. BitField<24, 1, PrimitiveId> primitive_id;
  1856. BitField<26, 2, InstanceId> instance_id;
  1857. BitField<29, 2, SplitMode> split_mode;
  1858. };
  1859. };
  1860. struct VertexIdCopy {
  1861. union {
  1862. BitField<0, 1, u32> enable;
  1863. BitField<4, 8, u32> attribute_slot;
  1864. };
  1865. };
  1866. struct ShaderBasedCull {
  1867. union {
  1868. BitField<1, 1, u32> batch_cull_enable;
  1869. BitField<0, 1, u32> before_fetch_enable;
  1870. };
  1871. };
  1872. struct ClassVersion {
  1873. union {
  1874. BitField<0, 16, u32> current;
  1875. BitField<16, 16, u32> oldest_supported;
  1876. };
  1877. };
  1878. struct PrimitiveRestart {
  1879. u32 enabled;
  1880. u32 index;
  1881. };
  1882. struct OutputVertexId {
  1883. union {
  1884. BitField<12, 1, u32> uses_array_start;
  1885. };
  1886. };
  1887. enum class PointCenterMode : u32 {
  1888. GL = 0,
  1889. D3D = 1,
  1890. };
  1891. enum class LineSmoothParams : u32 {
  1892. Falloff_1_00 = 0,
  1893. Falloff_1_33 = 1,
  1894. Falloff_1_66 = 2,
  1895. };
  1896. struct LineSmoothEdgeTable {
  1897. union {
  1898. BitField<0, 8, u32> v0;
  1899. BitField<8, 8, u32> v1;
  1900. BitField<16, 8, u32> v2;
  1901. BitField<24, 8, u32> v3;
  1902. };
  1903. };
  1904. struct LineStippleParams {
  1905. union {
  1906. BitField<0, 8, u32> factor;
  1907. BitField<8, 16, u32> pattern;
  1908. };
  1909. };
  1910. enum class ProvokingVertex : u32 {
  1911. First = 0,
  1912. Last = 1,
  1913. };
  1914. struct ShaderControl {
  1915. enum class Partial : u32 {
  1916. Zero = 0,
  1917. Infinity = 1,
  1918. };
  1919. enum class FP32NanBehavior : u32 {
  1920. Legacy = 0,
  1921. FP64Compatible = 1,
  1922. };
  1923. enum class FP32F2INanBehavior : u32 {
  1924. PassZero = 0,
  1925. PassIndefinite = 1,
  1926. };
  1927. union {
  1928. BitField<0, 1, Partial> default_partial;
  1929. BitField<1, 1, FP32NanBehavior> fp32_nan_behavior;
  1930. BitField<2, 1, FP32F2INanBehavior> fp32_f2i_nan_behavior;
  1931. };
  1932. };
  1933. struct SphVersion {
  1934. union {
  1935. BitField<0, 16, u32> current;
  1936. BitField<16, 16, u32> oldest_supported;
  1937. };
  1938. };
  1939. struct AlphaToCoverageOverride {
  1940. union {
  1941. BitField<0, 1, u32> qualify_by_anti_alias_enable;
  1942. BitField<1, 1, u32> qualify_by_ps_sample_mask_enable;
  1943. };
  1944. };
  1945. struct AamVersion {
  1946. union {
  1947. BitField<0, 16, u32> current;
  1948. BitField<16, 16, u32> oldest_supported;
  1949. };
  1950. };
  1951. struct IndexBuffer {
  1952. u32 start_addr_high;
  1953. u32 start_addr_low;
  1954. u32 limit_addr_high;
  1955. u32 limit_addr_low;
  1956. IndexFormat format;
  1957. u32 first;
  1958. u32 count;
  1959. unsigned FormatSizeInBytes() const {
  1960. switch (format) {
  1961. case IndexFormat::UnsignedByte:
  1962. return 1;
  1963. case IndexFormat::UnsignedShort:
  1964. return 2;
  1965. case IndexFormat::UnsignedInt:
  1966. return 4;
  1967. }
  1968. ASSERT(false);
  1969. return 1;
  1970. }
  1971. GPUVAddr StartAddress() const {
  1972. return (GPUVAddr{start_addr_high} << 32) | GPUVAddr{start_addr_low};
  1973. }
  1974. GPUVAddr EndAddress() const {
  1975. return (GPUVAddr{limit_addr_high} << 32) | GPUVAddr{limit_addr_low};
  1976. }
  1977. /// Adjust the index buffer offset so it points to the first desired index.
  1978. GPUVAddr IndexStart() const {
  1979. return StartAddress() + size_t{first} * size_t{FormatSizeInBytes()};
  1980. }
  1981. };
  1982. struct IndexBufferSmall {
  1983. union {
  1984. u32 raw;
  1985. BitField<0, 16, u32> first;
  1986. BitField<16, 12, u32> count;
  1987. BitField<28, 4, PrimitiveTopology> topology;
  1988. };
  1989. };
  1990. struct VertexStreamInstances {
  1991. std::array<u32, NumVertexArrays> is_instanced;
  1992. /// Returns whether the vertex array specified by index is supposed to be
  1993. /// accessed per instance or not.
  1994. bool IsInstancingEnabled(std::size_t index) const {
  1995. return is_instanced[index];
  1996. }
  1997. };
  1998. struct AttributePointSize {
  1999. union {
  2000. BitField<0, 1, u32> enabled;
  2001. BitField<4, 8, u32> slot;
  2002. };
  2003. };
  2004. struct ViewportClipControl {
  2005. enum class GeometryGuardband : u32 {
  2006. Scale256 = 0,
  2007. Scale1 = 1,
  2008. };
  2009. enum class GeometryClip : u32 {
  2010. WZero = 0,
  2011. Passthrough = 1,
  2012. FrustumXY = 2,
  2013. FrustumXYZ = 3,
  2014. WZeroNoZCull = 4,
  2015. FrustumZ = 5,
  2016. WZeroTriFillOrClip = 6,
  2017. };
  2018. enum class GeometryGuardbandZ : u32 {
  2019. SameAsXY = 0,
  2020. Scale256 = 1,
  2021. Scale1 = 2,
  2022. };
  2023. union {
  2024. BitField<0, 1, u32> depth_0_to_1;
  2025. BitField<3, 1, u32> pixel_min_z;
  2026. BitField<4, 1, u32> pixel_max_z;
  2027. BitField<7, 1, GeometryGuardband> geometry_guardband;
  2028. BitField<11, 3, GeometryClip> geometry_clip;
  2029. BitField<1, 2, GeometryGuardbandZ> geometry_guardband_z;
  2030. };
  2031. };
  2032. enum class PrimitiveTopologyControl : u32 {
  2033. UseInBeginMethods = 0,
  2034. UseSeparateState = 1,
  2035. };
  2036. struct WindowClip {
  2037. enum class Type : u32 {
  2038. Inclusive = 0,
  2039. Exclusive = 1,
  2040. ClipAll = 2,
  2041. };
  2042. u32 enable;
  2043. Type type;
  2044. };
  2045. enum class InvalidateZCull : u32 {
  2046. Invalidate = 0,
  2047. };
  2048. struct ZCull {
  2049. union {
  2050. BitField<0, 1, u32> z_enable;
  2051. BitField<1, 1, u32> stencil_enable;
  2052. };
  2053. union {
  2054. BitField<0, 1, u32> z_min_enbounded;
  2055. BitField<1, 1, u32> z_max_unbounded;
  2056. };
  2057. };
  2058. struct LogicOp {
  2059. enum class Op : u32 {
  2060. Clear = 0x1500,
  2061. And = 0x1501,
  2062. AndReverse = 0x1502,
  2063. Copy = 0x1503,
  2064. AndInverted = 0x1504,
  2065. NoOp = 0x1505,
  2066. Xor = 0x1506,
  2067. Or = 0x1507,
  2068. Nor = 0x1508,
  2069. Equiv = 0x1509,
  2070. Invert = 0x150A,
  2071. OrReverse = 0x150B,
  2072. CopyInverted = 0x150C,
  2073. OrInverted = 0x150D,
  2074. Nand = 0x150E,
  2075. Set = 0x150F,
  2076. };
  2077. u32 enable;
  2078. Op op;
  2079. };
  2080. struct ClearSurface {
  2081. union {
  2082. u32 raw;
  2083. BitField<0, 1, u32> Z;
  2084. BitField<1, 1, u32> S;
  2085. BitField<2, 1, u32> R;
  2086. BitField<3, 1, u32> G;
  2087. BitField<4, 1, u32> B;
  2088. BitField<5, 1, u32> A;
  2089. BitField<6, 4, u32> RT;
  2090. BitField<10, 16, u32> layer;
  2091. };
  2092. };
  2093. struct ReportSemaphore {
  2094. struct Compare {
  2095. u32 initial_sequence;
  2096. u32 initial_mode;
  2097. u32 unknown1;
  2098. u32 unknown2;
  2099. u32 current_sequence;
  2100. u32 current_mode;
  2101. };
  2102. enum class Operation : u32 {
  2103. Release = 0,
  2104. Acquire = 1,
  2105. ReportOnly = 2,
  2106. Trap = 3,
  2107. };
  2108. enum class Release : u32 {
  2109. AfterAllPreceedingReads = 0,
  2110. AfterAllPreceedingWrites = 1,
  2111. };
  2112. enum class Acquire : u32 {
  2113. BeforeAnyFollowingWrites = 0,
  2114. BeforeAnyFollowingReads = 1,
  2115. };
  2116. enum class Location : u32 {
  2117. None = 0,
  2118. VertexFetch = 1,
  2119. VertexShader = 2,
  2120. VPC = 4,
  2121. StreamingOutput = 5,
  2122. GeometryShader = 6,
  2123. ZCull = 7,
  2124. TessellationInit = 8,
  2125. TessellationShader = 9,
  2126. PixelShader = 10,
  2127. DepthTest = 12,
  2128. All = 15,
  2129. };
  2130. enum class Comparison : u32 {
  2131. NotEqual = 0,
  2132. GreaterOrEqual = 1,
  2133. };
  2134. enum class Report : u32 {
  2135. Payload = 0, // "None" in docs, but confirmed via hardware to return the payload
  2136. VerticesGenerated = 1,
  2137. ZPassPixelCount = 2,
  2138. PrimitivesGenerated = 3,
  2139. AlphaBetaClocks = 4,
  2140. VertexShaderInvocations = 5,
  2141. StreamingPrimitivesNeededMinusSucceeded = 6,
  2142. GeometryShaderInvocations = 7,
  2143. GeometryShaderPrimitivesGenerated = 9,
  2144. ZCullStats0 = 10,
  2145. StreamingPrimitivesSucceeded = 11,
  2146. ZCullStats1 = 12,
  2147. StreamingPrimitivesNeeded = 13,
  2148. ZCullStats2 = 14,
  2149. ClipperInvocations = 15,
  2150. ZCullStats3 = 16,
  2151. ClipperPrimitivesGenerated = 17,
  2152. VtgPrimitivesOut = 18,
  2153. PixelShaderInvocations = 19,
  2154. ZPassPixelCount64 = 21,
  2155. IEEECleanColorTarget = 24,
  2156. IEEECleanZetaTarget = 25,
  2157. StreamingByteCount = 26,
  2158. TessellationInitInvocations = 27,
  2159. BoundingRectangle = 28,
  2160. TessellationShaderInvocations = 29,
  2161. TotalStreamingPrimitivesNeededMinusSucceeded = 30,
  2162. TessellationShaderPrimitivesGenerated = 31,
  2163. };
  2164. u32 address_high;
  2165. u32 address_low;
  2166. u32 payload;
  2167. union {
  2168. u32 raw;
  2169. BitField<0, 2, Operation> operation;
  2170. BitField<4, 1, Release> release;
  2171. BitField<8, 1, Acquire> acquire;
  2172. BitField<12, 4, Location> location;
  2173. BitField<16, 1, Comparison> comparison;
  2174. BitField<20, 1, u32> awaken_enable;
  2175. BitField<23, 5, Report> report;
  2176. BitField<28, 1, u32> short_query;
  2177. BitField<5, 3, u32> sub_report;
  2178. BitField<21, 1, u32> dword_number;
  2179. BitField<2, 1, u32> disable_flush;
  2180. BitField<3, 1, u32> reduction_enable;
  2181. BitField<9, 3, ReductionOp> reduction_op;
  2182. BitField<17, 2, u32> format_signed;
  2183. } query;
  2184. GPUVAddr Address() const {
  2185. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  2186. }
  2187. };
  2188. struct VertexStream {
  2189. union {
  2190. BitField<0, 12, u32> stride;
  2191. BitField<12, 1, u32> enable;
  2192. };
  2193. u32 address_high;
  2194. u32 address_low;
  2195. u32 frequency;
  2196. GPUVAddr Address() const {
  2197. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  2198. }
  2199. bool IsEnabled() const {
  2200. return enable != 0 && Address() != 0;
  2201. }
  2202. };
  2203. static_assert(sizeof(VertexStream) == 0x10);
  2204. struct VertexStreamLimit {
  2205. u32 address_high;
  2206. u32 address_low;
  2207. GPUVAddr Address() const {
  2208. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  2209. }
  2210. };
  2211. static_assert(sizeof(VertexStreamLimit) == 0x8);
  2212. enum class ShaderType : u32 {
  2213. VertexA = 0,
  2214. VertexB = 1,
  2215. TessellationInit = 2,
  2216. Tessellation = 3,
  2217. Geometry = 4,
  2218. Pixel = 5,
  2219. };
  2220. struct Pipeline {
  2221. union {
  2222. BitField<0, 1, u32> enable;
  2223. BitField<4, 4, ShaderType> program;
  2224. };
  2225. u32 offset;
  2226. u32 reservedA;
  2227. u32 register_count;
  2228. u32 binding_group;
  2229. std::array<u32, 4> reserved;
  2230. INSERT_PADDING_BYTES_NOINIT(0x1C);
  2231. };
  2232. static_assert(sizeof(Pipeline) == 0x40);
  2233. bool IsShaderConfigEnabled(std::size_t index) const {
  2234. // The VertexB is always enabled.
  2235. if (index == static_cast<std::size_t>(ShaderType::VertexB)) {
  2236. return true;
  2237. }
  2238. return pipelines[index].enable != 0;
  2239. }
  2240. bool IsShaderConfigEnabled(ShaderType type) const {
  2241. return IsShaderConfigEnabled(static_cast<std::size_t>(type));
  2242. }
  2243. struct ConstantBuffer {
  2244. u32 size;
  2245. u32 address_high;
  2246. u32 address_low;
  2247. u32 offset;
  2248. std::array<u32, NumCBData> buffer;
  2249. GPUVAddr Address() const {
  2250. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  2251. }
  2252. };
  2253. struct BindGroup {
  2254. std::array<u32, 4> reserved;
  2255. union {
  2256. u32 raw_config;
  2257. BitField<0, 1, u32> valid;
  2258. BitField<4, 5, u32> shader_slot;
  2259. };
  2260. INSERT_PADDING_BYTES_NOINIT(0xC);
  2261. };
  2262. static_assert(sizeof(BindGroup) == 0x20);
  2263. struct StreamOutLayout {
  2264. union {
  2265. BitField<0, 8, u32> attribute0;
  2266. BitField<8, 8, u32> attribute1;
  2267. BitField<16, 8, u32> attribute2;
  2268. BitField<24, 8, u32> attribute3;
  2269. };
  2270. };
  2271. struct ShaderPerformance {
  2272. struct ControlA {
  2273. union {
  2274. BitField<0, 2, u32> event0;
  2275. BitField<2, 3, u32> bit0;
  2276. BitField<5, 2, u32> event1;
  2277. BitField<7, 3, u32> bit1;
  2278. BitField<10, 2, u32> event2;
  2279. BitField<12, 3, u32> bit2;
  2280. BitField<15, 2, u32> event3;
  2281. BitField<17, 3, u32> bit3;
  2282. BitField<20, 2, u32> event4;
  2283. BitField<22, 3, u32> bit4;
  2284. BitField<25, 2, u32> event5;
  2285. BitField<27, 3, u32> bit5;
  2286. BitField<30, 2, u32> spare;
  2287. };
  2288. };
  2289. struct ControlB {
  2290. union {
  2291. BitField<0, 1, u32> edge;
  2292. BitField<1, 2, u32> mode;
  2293. BitField<3, 1, u32> windowed;
  2294. BitField<4, 16, u32> func;
  2295. };
  2296. };
  2297. std::array<u32, 8> values_upper;
  2298. std::array<u32, 8> values;
  2299. std::array<u32, 8> events;
  2300. std::array<ControlA, 8> control_a;
  2301. std::array<ControlB, 8> control_b;
  2302. u32 trap_control_mask;
  2303. u32 start_shader_mask;
  2304. u32 stop_shader_mask;
  2305. };
  2306. // clang-format off
  2307. union {
  2308. struct {
  2309. ID object_id; ///< 0x0000
  2310. INSERT_PADDING_BYTES_NOINIT(0xFC);
  2311. u32 nop; ///< 0x0100
  2312. Notify notify; ///< 0x0104
  2313. u32 wait_for_idle; ///< 0x0110
  2314. LoadMME load_mme; ///< 0x0114
  2315. ShadowRamControl shadow_ram_control; ///< 0x0124
  2316. PeerSemaphore peer; ///< 0x0128
  2317. GlobalRender global_render; ///< 0x0130
  2318. u32 go_idle; ///< 0x013C
  2319. u32 trigger; ///< 0x0140
  2320. u32 trigger_wfi; ///< 0x0144
  2321. INSERT_PADDING_BYTES_NOINIT(0x8);
  2322. u32 instrumentation_method_header; ///< 0x0150
  2323. u32 instrumentation_method_data; ///< 0x0154
  2324. INSERT_PADDING_BYTES_NOINIT(0x28);
  2325. Upload::Registers upload; ///< 0x0180
  2326. LaunchDMA launch_dma; ///< 0x01B0
  2327. u32 inline_data; ///< 0x01B4
  2328. INSERT_PADDING_BYTES_NOINIT(0x24);
  2329. I2M i2m; ///< 0x01DC
  2330. u32 run_ds_now; ///< 0x0200
  2331. OpportunisticEarlyZ opportunistic_early_z; ///< 0x0204
  2332. INSERT_PADDING_BYTES_NOINIT(0x4);
  2333. u32 aliased_line_width_enabled; ///< 0x020C
  2334. u32 mandated_early_z; ///< 0x0210
  2335. GeometryShaderDmFifo gs_dm_fifo; ///< 0x0214
  2336. L2CacheControl l2_cache_control; ///< 0x0218
  2337. InvalidateShaderCache invalidate_shader_cache; ///< 0x021C
  2338. INSERT_PADDING_BYTES_NOINIT(0xA8);
  2339. SyncInfo sync_info; ///< 0x02C8
  2340. INSERT_PADDING_BYTES_NOINIT(0x4);
  2341. u32 prim_circular_buffer_throttle; ///< 0x02D0
  2342. u32 flush_invalidate_rop_mini_cache; ///< 0x02D4
  2343. SurfaceClipBlockId surface_clip_block_id; ///< 0x02D8
  2344. u32 alpha_circular_buffer_size; ///< 0x02DC
  2345. DecompressSurface decompress_surface; ///< 0x02E0
  2346. ZCullRopBypass zcull_rop_bypass; ///< 0x02E4
  2347. ZCullSubregion zcull_subregion; ///< 0x02E8
  2348. RasterBoundingBox raster_bounding_box; ///< 0x02EC
  2349. u32 peer_semaphore_release; ///< 0x02F0
  2350. u32 iterated_blend_optimization; ///< 0x02F4
  2351. ZCullSubregionAllocation zcull_subregion_allocation; ///< 0x02F8
  2352. ZCullSubregionAlgorithm zcull_subregion_algorithm; ///< 0x02FC
  2353. PixelShaderOutputSampleMaskUsage ps_output_sample_mask_usage; ///< 0x0300
  2354. u32 draw_zero_index; ///< 0x0304
  2355. L1Configuration l1_configuration; ///< 0x0308
  2356. u32 render_enable_control_load_const_buffer; ///< 0x030C
  2357. SPAVersion spa_version; ///< 0x0310
  2358. u32 ieee_clean_update; ///< 0x0314
  2359. SnapGrid snap_grid; ///< 0x0318
  2360. Tessellation tessellation; ///< 0x0320
  2361. SubTilingPerf sub_tiling_perf; ///< 0x0360
  2362. ZCullSubregionReport zcull_subregion_report; ///< 0x036C
  2363. BalancedPrimitiveWorkload balanced_primitive_workload; ///< 0x0374
  2364. u32 max_patches_per_batch; ///< 0x0378
  2365. u32 rasterize_enable; ///< 0x037C
  2366. TransformFeedback transform_feedback; ///< 0x0380
  2367. u32 raster_input; ///< 0x0740
  2368. u32 transform_feedback_enabled; ///< 0x0744
  2369. u32 primitive_restart_topology_change_enable; ///< 0x0748
  2370. u32 alpha_fraction; ///< 0x074C
  2371. INSERT_PADDING_BYTES_NOINIT(0x4);
  2372. HybridAntiAliasControl hybrid_aa_control; ///< 0x0754
  2373. INSERT_PADDING_BYTES_NOINIT(0x24);
  2374. ShaderLocalMemory shader_local_memory; ///< 0x077C
  2375. u32 color_zero_bandwidth_clear; ///< 0x07A4
  2376. u32 z_zero_bandwidth_clear; ///< 0x07A8
  2377. u32 isbe_save_restore_program_offset; ///< 0x07AC
  2378. INSERT_PADDING_BYTES_NOINIT(0x10);
  2379. ZCullRegion zcull_region; ///< 0x07C0
  2380. ZetaReadOnly zeta_read_only; ///< 0x07F8
  2381. INSERT_PADDING_BYTES_NOINIT(0x4);
  2382. std::array<RenderTargetConfig, NumRenderTargets> rt; ///< 0x0800
  2383. std::array<ViewportTransform, NumViewports> viewport_transform; ///< 0x0A00
  2384. std::array<Viewport, NumViewports> viewports; ///< 0x0C00
  2385. std::array<Window, 8> windows; ///< 0x0D00
  2386. std::array<ClipIdExtent, 4> clip_id_extent; ///< 0x0D40
  2387. u32 max_geometry_instances_per_task; ///< 0x0D60
  2388. VisibleCallLimit visible_call_limit; ///< 0x0D64
  2389. StatisticsCounter statistics_count; ///< 0x0D68
  2390. ClearRect clear_rect; ///< 0x0D6C
  2391. VertexBuffer vertex_buffer; ///< 0x0D74
  2392. DepthMode depth_mode; ///< 0x0D7C
  2393. std::array<f32, 4> clear_color; ///< 0x0D80
  2394. f32 clear_depth; ///< 0x0D90
  2395. u32 shader_cache_icache_prefetch; ///< 0x0D94
  2396. u32 force_transition_to_beta; ///< 0x0D98
  2397. u32 reduce_colour_thresholds; ///< 0x0D9C
  2398. s32 clear_stencil; ///< 0x0DA0
  2399. InvalidateShaderCacheNoWFI invalidate_shader_cache_no_wfi; ///< 0x0DA4
  2400. ZCullSerialization zcull_serialization; ///< 0x0DA8
  2401. PolygonMode polygon_mode_front; ///< 0x0DAC
  2402. PolygonMode polygon_mode_back; ///< 0x0DB0
  2403. u32 polygon_smooth; ///< 0x0DB4
  2404. u32 zeta_mark_clean_ieee; ///< 0x0DB8
  2405. ZCullDirFormat zcull_dir_format; ///< 0x0DBC
  2406. u32 polygon_offset_point_enable; ///< 0x0DC0
  2407. u32 polygon_offset_line_enable; ///< 0x0DC4
  2408. u32 polygon_offset_fill_enable; ///< 0x0DC8
  2409. u32 patch_vertices; ///< 0x0DCC
  2410. IteratedBlend iterated_blend; ///< 0x0DD0
  2411. ZCullCriterion zcull_criteria; ///< 0x0DD8
  2412. INSERT_PADDING_BYTES_NOINIT(0x4);
  2413. u32 fragment_barrier; ///< 0x0DE0
  2414. u32 sm_timeout; ///< 0x0DE4
  2415. u32 primitive_restart_array; ///< 0x0DE8
  2416. INSERT_PADDING_BYTES_NOINIT(0x4);
  2417. LoadIteratedBlend load_iterated_blend; ///< 0x0DF0
  2418. u32 window_offset_x; ///< 0x0DF8
  2419. u32 window_offset_y; ///< 0x0DFC
  2420. std::array<ScissorTest, NumViewports> scissor_test; ///< 0x0E00
  2421. INSERT_PADDING_BYTES_NOINIT(0x10);
  2422. u32 select_texture_headers; ///< 0x0F10
  2423. VPCPerf vpc_perf; ///< 0x0F14
  2424. u32 pm_local_trigger; ///< 0x0F18
  2425. u32 post_z_pixel_imask; ///< 0x0F1C
  2426. INSERT_PADDING_BYTES_NOINIT(0x20);
  2427. ConstantColorRendering const_color_rendering; ///< 0x0F40
  2428. u32 stencil_back_ref; ///< 0x0F54
  2429. u32 stencil_back_mask; ///< 0x0F58
  2430. u32 stencil_back_func_mask; ///< 0x0F5C
  2431. INSERT_PADDING_BYTES_NOINIT(0x14);
  2432. u32 invalidate_texture_data_cache; ///< 0x0F74 Assumed - Not in official docs.
  2433. INSERT_PADDING_BYTES_NOINIT(0x4);
  2434. u32 tiled_cache_barrier; ///< 0x0F7C Assumed - Not in official docs.
  2435. INSERT_PADDING_BYTES_NOINIT(0x4);
  2436. VertexStreamSubstitute vertex_stream_substitute; ///< 0x0F84
  2437. u32 line_mode_clip_generated_edge_do_not_draw; ///< 0x0F8C
  2438. u32 color_mask_common; ///< 0x0F90
  2439. INSERT_PADDING_BYTES_NOINIT(0x4);
  2440. VTGWarpWatermarks vtg_warp_watermarks; ///< 0x0F98
  2441. f32 depth_bounds[2]; ///< 0x0F9C
  2442. SampleMask::Target sample_mask_target; ///< 0x0FA4
  2443. u32 color_target_mrt_enable; ///< 0x0FAC
  2444. NonMultisampledZ non_multisampled_z; ///< 0x0FB0
  2445. TIRMode tir_mode; ///< 0x0FB4
  2446. AntiAliasRaster anti_alias_raster; ///< 0x0FB8
  2447. SampleMask::Pos sample_mask_pos; ///< 0x0FBC
  2448. SurfaceClipIDMemory surface_clip_id_memory; ///< 0x0FCC
  2449. TIRModulation tir_modulation; ///< 0x0FD4
  2450. u32 blend_control_allow_float_pixel_kills; ///< 0x0FDC
  2451. Zeta zeta; ///< 0x0FE0
  2452. SurfaceClip surface_clip; ///< 0x0FF4
  2453. u32 tiled_cache_treat_heavy_as_light; ///< 0x0FFC
  2454. L2CacheVAFRequests l2_cache_vaf; ///< 0x1000
  2455. ViewportMulticast viewport_multicast; ///< 0x1004
  2456. u32 tessellation_cut_height; ///< 0x1008
  2457. u32 max_gs_instances_per_task; ///< 0x100C
  2458. u32 max_gs_output_vertices_per_task; ///< 0x1010
  2459. u32 reserved_sw_method0; ///< 0x1014
  2460. u32 gs_output_cb_storage_multiplier; ///< 0x1018
  2461. u32 beta_cb_storage_constant; ///< 0x101C
  2462. u32 ti_output_cb_storage_multiplier; ///< 0x1020
  2463. u32 alpha_cb_storage_constraint; ///< 0x1024
  2464. u32 reserved_sw_method1; ///< 0x1028
  2465. u32 reserved_sw_method2; ///< 0x102C
  2466. std::array<TIRModulationCoeff, 5> tir_modulation_coeff; ///< 0x1030
  2467. std::array<u32, 15> spare_nop; ///< 0x1044
  2468. INSERT_PADDING_BYTES_NOINIT(0x30);
  2469. std::array<u32, 7> reserved_sw_method3_to_7; ///< 0x10B0
  2470. ReduceColorThreshold reduce_color_thresholds_unorm8; ///< 0x10CC
  2471. std::array<u32, 4> reserved_sw_method10_to_13; ///< 0x10D0
  2472. ReduceColorThreshold reduce_color_thresholds_unorm10; ///< 0x10E0
  2473. ReduceColorThreshold reduce_color_thresholds_unorm16; ///< 0x10E4
  2474. ReduceColorThreshold reduce_color_thresholds_fp11; ///< 0x10E8
  2475. ReduceColorThreshold reduce_color_thresholds_fp16; ///< 0x10EC
  2476. ReduceColorThreshold reduce_color_thresholds_srgb8; ///< 0x10F0
  2477. u32 unbind_all_constant_buffers; ///< 0x10F4
  2478. ClearControl clear_control; ///< 0x10F8
  2479. L2CacheRopNonInterlockedReads l2_cache_rop_non_interlocked_reads; ///< 0x10FC
  2480. u32 reserved_sw_method14; ///< 0x1100
  2481. u32 reserved_sw_method15; ///< 0x1104
  2482. INSERT_PADDING_BYTES_NOINIT(0x4);
  2483. u32 no_operation_data_high; ///< 0x110C
  2484. u32 depth_bias_control; ///< 0x1110
  2485. u32 pm_trigger_end; ///< 0x1114
  2486. u32 vertex_id_base; ///< 0x1118
  2487. u32 stencil_compression_enabled; ///< 0x111C
  2488. VertexOutputAttributeSkipMasks vertex_output_attribute_skip_masks; ///< 0x1120
  2489. TIRControl tir_control; ///< 0x1130
  2490. u32 mutable_method_treat_mutable_as_heavy; ///< 0x1134
  2491. u32 post_ps_use_pre_ps_coverage; ///< 0x1138
  2492. FillViaTriangleMode fill_via_triangle_mode; ///< 0x113C
  2493. u32 blend_per_format_snorm8_unorm16_snorm16_enabled; ///< 0x1140
  2494. u32 flush_pending_writes_sm_gloal_store; ///< 0x1144
  2495. u32 conservative_raster_enable; ///< 0x1148 Assumed - Not in official docs.
  2496. INSERT_PADDING_BYTES_NOINIT(0x14);
  2497. std::array<VertexAttribute, NumVertexAttributes> vertex_attrib_format; ///< 0x1160
  2498. std::array<MsaaSampleLocation, 4> multisample_sample_locations; ///< 0x11E0
  2499. u32 offset_render_target_index_by_viewport_index; ///< 0x11F0
  2500. u32 force_heavy_method_sync; ///< 0x11F4
  2501. MultisampleCoverageToColor multisample_coverage_to_color; ///< 0x11F8
  2502. DecompressZetaSurface decompress_zeta_surface; ///< 0x11FC
  2503. INSERT_PADDING_BYTES_NOINIT(0x8);
  2504. ZetaSparse zeta_sparse; ///< 0x1208
  2505. u32 invalidate_sampler_cache; ///< 0x120C
  2506. u32 invalidate_texture_header_cache; ///< 0x1210
  2507. VertexArray vertex_array_instance_first; ///< 0x1214
  2508. VertexArray vertex_array_instance_subsequent; ///< 0x1218
  2509. RtControl rt_control; ///< 0x121C
  2510. CompressionThresholdSamples compression_threshold_samples; ///< 0x1220
  2511. PixelShaderInterlockControl ps_interlock_control; ///< 0x1224
  2512. ZetaSize zeta_size; ///< 0x1228
  2513. SamplerBinding sampler_binding; ///< 0x1234
  2514. INSERT_PADDING_BYTES_NOINIT(0x4);
  2515. u32 draw_auto_byte_count; ///< 0x123C
  2516. std::array<u32, 8> post_vtg_shader_attrib_skip_mask; ///< 0x1240
  2517. PsTicketDispenserValue ps_ticket_dispenser_value; ///< 0x1260
  2518. INSERT_PADDING_BYTES_NOINIT(0x1C);
  2519. u32 circular_buffer_size; ///< 0x1280
  2520. RegisterWatermarks vtg_register_watermarks; ///< 0x1284
  2521. InvalidateTextureDataCacheNoWfi invalidate_texture_cache_no_wfi; ///< 0x1288
  2522. INSERT_PADDING_BYTES_NOINIT(0x4);
  2523. L2CacheRopNonInterlockedReads l2_cache_rop_interlocked_reads; ///< 0x1290
  2524. INSERT_PADDING_BYTES_NOINIT(0x10);
  2525. u32 primitive_restart_topology_change_index; ///< 0x12A4
  2526. INSERT_PADDING_BYTES_NOINIT(0x20);
  2527. ZCullRegionEnable zcull_region_enable; ///< 0x12C8
  2528. u32 depth_test_enable; ///< 0x12CC
  2529. FillMode fill_mode; ///< 0x12D0
  2530. ShadeMode shade_mode; ///< 0x12D4
  2531. L2CacheRopNonInterlockedReads l2_cache_rop_non_interlocked_writes; ///< 0x12D8
  2532. L2CacheRopNonInterlockedReads l2_cache_rop_interlocked_writes; ///< 0x12DC
  2533. AlphaToCoverageDither alpha_to_coverage_dither; ///< 0x12E0
  2534. u32 blend_per_target_enabled; ///< 0x12E4
  2535. u32 depth_write_enabled; ///< 0x12E8
  2536. u32 alpha_test_enabled; ///< 0x12EC
  2537. INSERT_PADDING_BYTES_NOINIT(0x10);
  2538. InlineIndex4x8 inline_index_4x8; ///< 0x1300
  2539. D3DCullMode d3d_cull_mode; ///< 0x1308
  2540. ComparisonOp depth_test_func; ///< 0x130C
  2541. f32 alpha_test_ref; ///< 0x1310
  2542. ComparisonOp alpha_test_func; ///< 0x1314
  2543. u32 draw_auto_stride; ///< 0x1318
  2544. BlendColor blend_color; ///< 0x131C
  2545. INSERT_PADDING_BYTES_NOINIT(0x4);
  2546. InvalidateCacheLines invalidate_sampler_cache_lines; ///< 0x1330
  2547. InvalidateCacheLines invalidate_texture_header_cache_lines; ///< 0x1334
  2548. InvalidateCacheLines invalidate_texture_data_cache_lines; ///< 0x1338
  2549. Blend blend; ///< 0x133C
  2550. u32 stencil_enable; ///< 0x1380
  2551. StencilOp stencil_front_op; ///< 0x1384
  2552. u32 stencil_front_ref; ///< 0x1394
  2553. u32 stencil_front_func_mask; ///< 0x1398
  2554. u32 stencil_front_mask; ///< 0x139C
  2555. INSERT_PADDING_BYTES_NOINIT(0x4);
  2556. u32 draw_auto_start_byte_count; ///< 0x13A4
  2557. PsSaturate frag_color_clamp; ///< 0x13A8
  2558. WindowOrigin window_origin; ///< 0x13AC
  2559. f32 line_width_smooth; ///< 0x13B0
  2560. f32 line_width_aliased; ///< 0x13B4
  2561. INSERT_PADDING_BYTES_NOINIT(0x60);
  2562. u32 line_override_multisample; ///< 0x1418
  2563. INSERT_PADDING_BYTES_NOINIT(0x4);
  2564. u32 alpha_hysteresis_rounds; ///< 0x1420
  2565. InvalidateCacheLines invalidate_sampler_cache_no_wfi; ///< 0x1424
  2566. InvalidateCacheLines invalidate_texture_header_cache_no_wfi; ///< 0x1428
  2567. INSERT_PADDING_BYTES_NOINIT(0x8);
  2568. u32 global_base_vertex_index; ///< 0x1434
  2569. u32 global_base_instance_index; ///< 0x1438
  2570. INSERT_PADDING_BYTES_NOINIT(0x14);
  2571. RegisterWatermarks ps_warp_watermarks; ///< 0x1450
  2572. RegisterWatermarks ps_regster_watermarks; ///< 0x1454
  2573. INSERT_PADDING_BYTES_NOINIT(0xC);
  2574. u32 store_zcull; ///< 0x1464
  2575. INSERT_PADDING_BYTES_NOINIT(0x18);
  2576. std::array<IteratedBlendConstants, NumRenderTargets>
  2577. iterated_blend_constants; ///< 0x1480
  2578. u32 load_zcull; ///< 0x1500
  2579. u32 surface_clip_id_height; ///< 0x1504
  2580. Window surface_clip_id_clear_rect; ///< 0x1508
  2581. UserClip::Enable user_clip_enable; ///< 0x1510
  2582. u32 zpass_pixel_count_enable; ///< 0x1514
  2583. f32 point_size; ///< 0x1518
  2584. u32 zcull_stats_enable; ///< 0x151C
  2585. u32 point_sprite_enable; ///< 0x1520
  2586. INSERT_PADDING_BYTES_NOINIT(0x4);
  2587. u32 shader_exceptions_enable; ///< 0x1528
  2588. INSERT_PADDING_BYTES_NOINIT(0x4);
  2589. ClearReport clear_report_value; ///< 0x1530
  2590. u32 anti_alias_enable; ///< 0x1534
  2591. u32 zeta_enable; ///< 0x1538
  2592. AntiAliasAlphaControl anti_alias_alpha_control; ///< 0x153C
  2593. INSERT_PADDING_BYTES_NOINIT(0x10);
  2594. RenderEnable render_enable; ///< 0x1550
  2595. TexSampler tex_sampler; ///< 0x155C
  2596. INSERT_PADDING_BYTES_NOINIT(0x4);
  2597. f32 slope_scale_depth_bias; ///< 0x156C
  2598. u32 line_anti_alias_enable; ///< 0x1570
  2599. TexHeader tex_header; ///< 0x1574
  2600. INSERT_PADDING_BYTES_NOINIT(0x10);
  2601. u32 active_zcull_region_id; ///< 0x1590
  2602. u32 stencil_two_side_enable; ///< 0x1594
  2603. StencilOp stencil_back_op; ///< 0x1598
  2604. INSERT_PADDING_BYTES_NOINIT(0x10);
  2605. u32 framebuffer_srgb; ///< 0x15B8
  2606. f32 depth_bias; ///< 0x15BC
  2607. INSERT_PADDING_BYTES_NOINIT(0x8);
  2608. ZCullRegionFormat zcull_region_format; ///< 0x15C8
  2609. RtLayer rt_layer; ///< 0x15CC
  2610. Tegra::Texture::MsaaMode anti_alias_samples_mode; ///< 0x15D0
  2611. INSERT_PADDING_BYTES_NOINIT(0x10);
  2612. u32 edge_flag; ///< 0x15E4
  2613. u32 draw_inline_index; ///< 0x15E8
  2614. InlineIndex2x16 inline_index_2x16; ///< 0x15EC
  2615. VertexGlobalBaseOffset vertex_global_base_offset; ///< 0x15F4
  2616. ZCullRegionPixelOffset zcull_region_pixel_offset; ///< 0x15FC
  2617. PointSprite point_sprite; ///< 0x1604
  2618. ProgramRegion program_region; ///< 0x1608
  2619. DefaultAttributes default_attributes; ///< 0x1610
  2620. Draw draw; ///< 0x1614
  2621. VertexIdCopy vertex_id_copy; ///< 0x161C
  2622. u32 add_to_primitive_id; ///< 0x1620
  2623. u32 load_to_primitive_id; ///< 0x1624
  2624. INSERT_PADDING_BYTES_NOINIT(0x4);
  2625. ShaderBasedCull shader_based_cull; ///< 0x162C
  2626. INSERT_PADDING_BYTES_NOINIT(0x8);
  2627. ClassVersion class_version; ///< 0x1638
  2628. INSERT_PADDING_BYTES_NOINIT(0x8);
  2629. PrimitiveRestart primitive_restart; ///< 0x1644
  2630. OutputVertexId output_vertex_id; ///< 0x164C
  2631. INSERT_PADDING_BYTES_NOINIT(0x8);
  2632. u32 anti_alias_point_enable; ///< 0x1658
  2633. PointCenterMode point_center_mode; ///< 0x165C
  2634. INSERT_PADDING_BYTES_NOINIT(0x8);
  2635. LineSmoothParams line_smooth_params; ///< 0x1668
  2636. u32 line_stipple_enable; ///< 0x166C
  2637. std::array<LineSmoothEdgeTable, 4> line_smooth_edge_table; ///< 0x1670
  2638. LineStippleParams line_stipple_params; ///< 0x1680
  2639. ProvokingVertex provoking_vertex; ///< 0x1684
  2640. u32 two_sided_light_enabled; ///< 0x1688
  2641. u32 polygon_stipple_enabled; ///< 0x168C
  2642. ShaderControl shader_control; ///< 0x1690
  2643. INSERT_PADDING_BYTES_NOINIT(0xC);
  2644. ClassVersion class_version_check; ///< 0x16A0
  2645. SphVersion sph_version; ///< 0x16A4
  2646. SphVersion sph_version_check; ///< 0x16A8
  2647. INSERT_PADDING_BYTES_NOINIT(0x8);
  2648. AlphaToCoverageOverride alpha_to_coverage_override; ///< 0x16B4
  2649. INSERT_PADDING_BYTES_NOINIT(0x48);
  2650. std::array<u32, 32> polygon_stipple_pattern; ///< 0x1700
  2651. INSERT_PADDING_BYTES_NOINIT(0x10);
  2652. AamVersion aam_version; ///< 0x1790
  2653. AamVersion aam_version_check; ///< 0x1794
  2654. INSERT_PADDING_BYTES_NOINIT(0x4);
  2655. u32 zeta_layer_offset; ///< 0x179C
  2656. INSERT_PADDING_BYTES_NOINIT(0x28);
  2657. IndexBuffer index_buffer; ///< 0x17C8
  2658. IndexBufferSmall index_buffer32_first; ///< 0x17E4
  2659. IndexBufferSmall index_buffer16_first; ///< 0x17E8
  2660. IndexBufferSmall index_buffer8_first; ///< 0x17EC
  2661. IndexBufferSmall index_buffer32_subsequent; ///< 0x17F0
  2662. IndexBufferSmall index_buffer16_subsequent; ///< 0x17F4
  2663. IndexBufferSmall index_buffer8_subsequent; ///< 0x17F8
  2664. INSERT_PADDING_BYTES_NOINIT(0x80);
  2665. f32 depth_bias_clamp; ///< 0x187C
  2666. VertexStreamInstances vertex_stream_instances; ///< 0x1880
  2667. INSERT_PADDING_BYTES_NOINIT(0x10);
  2668. AttributePointSize point_size_attribute; ///< 0x1910
  2669. INSERT_PADDING_BYTES_NOINIT(0x4);
  2670. u32 gl_cull_test_enabled; ///< 0x1918
  2671. FrontFace gl_front_face; ///< 0x191C
  2672. CullFace gl_cull_face; ///< 0x1920
  2673. Viewport::PixelCenter viewport_pixel_center; ///< 0x1924
  2674. INSERT_PADDING_BYTES_NOINIT(0x4);
  2675. u32 viewport_scale_offset_enabled; ///< 0x192C
  2676. INSERT_PADDING_BYTES_NOINIT(0xC);
  2677. ViewportClipControl viewport_clip_control; ///< 0x193C
  2678. UserClip::Op user_clip_op; ///< 0x1940
  2679. RenderEnable::Override render_enable_override; ///< 0x1944
  2680. PrimitiveTopologyControl primitive_topology_control; ///< 0x1948
  2681. WindowClip window_clip_enable; ///< 0x194C
  2682. INSERT_PADDING_BYTES_NOINIT(0x4);
  2683. InvalidateZCull invalidate_zcull; ///< 0x1958
  2684. INSERT_PADDING_BYTES_NOINIT(0xC);
  2685. ZCull zcull; ///< 0x1968
  2686. PrimitiveTopologyOverride topology_override; ///< 0x1970
  2687. INSERT_PADDING_BYTES_NOINIT(0x4);
  2688. u32 zcull_sync; ///< 0x1978
  2689. u32 clip_id_test_enable; ///< 0x197C
  2690. u32 surface_clip_id_width; ///< 0x1980
  2691. u32 clip_id; ///< 0x1984
  2692. INSERT_PADDING_BYTES_NOINIT(0x34);
  2693. u32 depth_bounds_enable; ///< 0x19BC
  2694. u32 blend_float_zero_times_anything_is_zero; ///< 0x19C0
  2695. LogicOp logic_op; ///< 0x19C4
  2696. u32 z_compression_enable; ///< 0x19CC
  2697. ClearSurface clear_surface; ///< 0x19D0
  2698. u32 clear_clip_id_surface; ///< 0x19D4
  2699. INSERT_PADDING_BYTES_NOINIT(0x8);
  2700. std::array<u32, NumRenderTargets> color_compression_enable; ///< 0x19E0
  2701. std::array<ColorMask, NumRenderTargets> color_mask; ///< 0x1A00
  2702. INSERT_PADDING_BYTES_NOINIT(0xC);
  2703. u32 pipe_nop; ///< 0x1A2C
  2704. std::array<u32, 4> spare; ///< 0x1A30
  2705. INSERT_PADDING_BYTES_NOINIT(0xC0);
  2706. ReportSemaphore report_semaphore; ///< 0x1B00
  2707. INSERT_PADDING_BYTES_NOINIT(0xF0);
  2708. std::array<VertexStream, NumVertexArrays> vertex_streams; ///< 0x1C00
  2709. BlendPerTarget blend_per_target[NumRenderTargets]; ///< 0x1E00
  2710. std::array<VertexStreamLimit, NumVertexArrays> vertex_stream_limits; ///< 0x1F00
  2711. std::array<Pipeline, MaxShaderProgram> pipelines; ///< 0x2000
  2712. INSERT_PADDING_BYTES_NOINIT(0x180);
  2713. u32 falcon[32]; ///< 0x2300
  2714. ConstantBuffer const_buffer; ///< 0x2380
  2715. INSERT_PADDING_BYTES_NOINIT(0x30);
  2716. BindGroup bind_groups[MaxShaderStage]; ///< 0x2400
  2717. INSERT_PADDING_BYTES_NOINIT(0x160);
  2718. u32 color_clamp_enable; ///< 0x2600
  2719. INSERT_PADDING_BYTES_NOINIT(0x4);
  2720. u32 bindless_texture_const_buffer_slot; ///< 0x2608
  2721. u32 trap_handler; ///< 0x260C
  2722. INSERT_PADDING_BYTES_NOINIT(0x1F0);
  2723. std::array<std::array<StreamOutLayout, 32>, NumTransformFeedbackBuffers>
  2724. stream_out_layout; ///< 0x2800
  2725. INSERT_PADDING_BYTES_NOINIT(0x93C);
  2726. ShaderPerformance shader_performance; ///< 0x333C
  2727. INSERT_PADDING_BYTES_NOINIT(0x18);
  2728. std::array<u32, 0x100> shadow_scratch; ///< 0x3400
  2729. };
  2730. std::array<u32, NUM_REGS> reg_array;
  2731. };
  2732. };
  2733. // clang-format on
  2734. Regs regs{};
  2735. /// Store temporary hw register values, used by some calls to restore state after a operation
  2736. Regs shadow_state;
  2737. // None Engine
  2738. enum class EngineHint : u32 {
  2739. None = 0x0,
  2740. OnHLEMacro = 0x1,
  2741. };
  2742. EngineHint engine_state{EngineHint::None};
  2743. enum class HLEReplaceName : u32 {
  2744. BaseVertex = 0x0,
  2745. BaseInstance = 0x1,
  2746. };
  2747. void setHLEReplacementName(u32 bank, u32 offset, HLEReplaceName name);
  2748. std::unordered_map<u64, HLEReplaceName> replace_table;
  2749. static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Maxwell3D Regs has wrong size");
  2750. static_assert(std::is_trivially_copyable_v<Regs>, "Maxwell3D Regs must be trivially copyable");
  2751. struct State {
  2752. struct ShaderStageInfo {
  2753. std::array<ConstBufferInfo, Regs::MaxConstBuffers> const_buffers;
  2754. };
  2755. std::array<ShaderStageInfo, Regs::MaxShaderStage> shader_stages;
  2756. };
  2757. State state{};
  2758. /// Reads a register value located at the input method address
  2759. u32 GetRegisterValue(u32 method) const;
  2760. /// Write the value to the register identified by method.
  2761. void CallMethod(u32 method, u32 method_argument, bool is_last_call) override;
  2762. /// Write multiple values to the register identified by method.
  2763. void CallMultiMethod(u32 method, const u32* base_start, u32 amount,
  2764. u32 methods_pending) override;
  2765. bool ShouldExecute() const {
  2766. return execute_on;
  2767. }
  2768. VideoCore::RasterizerInterface& Rasterizer() {
  2769. return *rasterizer;
  2770. }
  2771. const VideoCore::RasterizerInterface& Rasterizer() const {
  2772. return *rasterizer;
  2773. }
  2774. struct DirtyState {
  2775. using Flags = std::bitset<std::numeric_limits<u8>::max()>;
  2776. using Table = std::array<u8, Regs::NUM_REGS>;
  2777. using Tables = std::array<Table, 2>;
  2778. Flags flags;
  2779. Tables tables{};
  2780. } dirty;
  2781. std::unique_ptr<DrawManager> draw_manager;
  2782. friend class DrawManager;
  2783. std::vector<u8> inline_index_draw_indexes;
  2784. GPUVAddr getMacroAddress(size_t index) const {
  2785. return macro_addresses[index];
  2786. }
  2787. void RefreshParameters() {
  2788. if (!current_macro_dirty) {
  2789. return;
  2790. }
  2791. RefreshParametersImpl();
  2792. }
  2793. bool AnyParametersDirty() {
  2794. return current_macro_dirty;
  2795. }
  2796. u32 GetMaxCurrentVertices();
  2797. size_t EstimateIndexBufferSize();
  2798. /// Handles a write to the CLEAR_BUFFERS register.
  2799. void ProcessClearBuffers(u32 layer_count);
  2800. /// Handles a write to the CB_BIND register.
  2801. void ProcessCBBind(size_t stage_index);
  2802. private:
  2803. void InitializeRegisterDefaults();
  2804. void ProcessMacro(u32 method, const u32* base_start, u32 amount, bool is_last_call);
  2805. u32 ProcessShadowRam(u32 method, u32 argument);
  2806. void ProcessDirtyRegisters(u32 method, u32 argument);
  2807. void ConsumeSinkImpl() override;
  2808. void ProcessMethodCall(u32 method, u32 argument, u32 nonshadow_argument, bool is_last_call);
  2809. /// Retrieves information about a specific TIC entry from the TIC buffer.
  2810. Texture::TICEntry GetTICEntry(u32 tic_index) const;
  2811. /// Retrieves information about a specific TSC entry from the TSC buffer.
  2812. Texture::TSCEntry GetTSCEntry(u32 tsc_index) const;
  2813. /**
  2814. * Call a macro on this engine.
  2815. *
  2816. * @param method Method to call
  2817. * @param parameters Arguments to the method call
  2818. */
  2819. void CallMacroMethod(u32 method, const std::vector<u32>& parameters);
  2820. /// Handles writes to the macro uploading register.
  2821. void ProcessMacroUpload(u32 data);
  2822. /// Handles writes to the macro bind register.
  2823. void ProcessMacroBind(u32 data);
  2824. /// Handles firmware blob 4
  2825. void ProcessFirmwareCall4();
  2826. /// Handles a write to the QUERY_GET register.
  2827. void ProcessQueryGet();
  2828. /// Writes the query result accordingly.
  2829. void StampQueryResult(u64 payload, bool long_query);
  2830. /// Handles conditional rendering.
  2831. void ProcessQueryCondition();
  2832. /// Handles counter resets.
  2833. void ProcessCounterReset();
  2834. /// Handles writes to syncing register.
  2835. void ProcessSyncPoint();
  2836. /// Handles a write to the CB_DATA[i] register.
  2837. void ProcessCBData(u32 value);
  2838. void ProcessCBMultiData(const u32* start_base, u32 amount);
  2839. /// Returns a query's value or an empty object if the value will be deferred through a cache.
  2840. std::optional<u64> GetQueryResult();
  2841. void RefreshParametersImpl();
  2842. bool IsMethodExecutable(u32 method);
  2843. Core::System& system;
  2844. MemoryManager& memory_manager;
  2845. VideoCore::RasterizerInterface* rasterizer = nullptr;
  2846. /// Start offsets of each macro in macro_memory
  2847. std::array<u32, 0x80> macro_positions{};
  2848. /// Macro method that is currently being executed / being fed parameters.
  2849. u32 executing_macro = 0;
  2850. /// Parameters that have been submitted to the macro call so far.
  2851. std::vector<u32> macro_params;
  2852. /// Interpreter for the macro codes uploaded to the GPU.
  2853. std::unique_ptr<MacroEngine> macro_engine;
  2854. Upload::State upload_state;
  2855. bool execute_on{true};
  2856. std::array<bool, Regs::NUM_REGS> draw_command{};
  2857. std::vector<u32> deferred_draw_method;
  2858. enum class DrawMode : u32 { General = 0, Instance, InlineIndex };
  2859. DrawMode draw_mode{DrawMode::General};
  2860. bool draw_indexed{};
  2861. std::vector<std::pair<GPUVAddr, size_t>> macro_segments;
  2862. std::vector<GPUVAddr> macro_addresses;
  2863. bool current_macro_dirty{};
  2864. };
  2865. #define ASSERT_REG_POSITION(field_name, position) \
  2866. static_assert(offsetof(Maxwell3D::Regs, field_name) == position, \
  2867. "Field " #field_name " has invalid position")
  2868. ASSERT_REG_POSITION(object_id, 0x0000);
  2869. ASSERT_REG_POSITION(nop, 0x0100);
  2870. ASSERT_REG_POSITION(notify, 0x0104);
  2871. ASSERT_REG_POSITION(wait_for_idle, 0x0110);
  2872. ASSERT_REG_POSITION(load_mme, 0x0114);
  2873. ASSERT_REG_POSITION(shadow_ram_control, 0x0124);
  2874. ASSERT_REG_POSITION(peer, 0x0128);
  2875. ASSERT_REG_POSITION(global_render, 0x0130);
  2876. ASSERT_REG_POSITION(go_idle, 0x013C);
  2877. ASSERT_REG_POSITION(trigger, 0x0140);
  2878. ASSERT_REG_POSITION(trigger_wfi, 0x0144);
  2879. ASSERT_REG_POSITION(instrumentation_method_header, 0x0150);
  2880. ASSERT_REG_POSITION(instrumentation_method_data, 0x0154);
  2881. ASSERT_REG_POSITION(upload, 0x0180);
  2882. ASSERT_REG_POSITION(launch_dma, 0x01B0);
  2883. ASSERT_REG_POSITION(inline_data, 0x01B4);
  2884. ASSERT_REG_POSITION(i2m, 0x01DC);
  2885. ASSERT_REG_POSITION(run_ds_now, 0x0200);
  2886. ASSERT_REG_POSITION(opportunistic_early_z, 0x0204);
  2887. ASSERT_REG_POSITION(aliased_line_width_enabled, 0x020C);
  2888. ASSERT_REG_POSITION(mandated_early_z, 0x0210);
  2889. ASSERT_REG_POSITION(gs_dm_fifo, 0x0214);
  2890. ASSERT_REG_POSITION(l2_cache_control, 0x0218);
  2891. ASSERT_REG_POSITION(invalidate_shader_cache, 0x021C);
  2892. ASSERT_REG_POSITION(sync_info, 0x02C8);
  2893. ASSERT_REG_POSITION(prim_circular_buffer_throttle, 0x02D0);
  2894. ASSERT_REG_POSITION(flush_invalidate_rop_mini_cache, 0x02D4);
  2895. ASSERT_REG_POSITION(surface_clip_block_id, 0x02D8);
  2896. ASSERT_REG_POSITION(alpha_circular_buffer_size, 0x02DC);
  2897. ASSERT_REG_POSITION(decompress_surface, 0x02E0);
  2898. ASSERT_REG_POSITION(zcull_rop_bypass, 0x02E4);
  2899. ASSERT_REG_POSITION(zcull_subregion, 0x02E8);
  2900. ASSERT_REG_POSITION(raster_bounding_box, 0x02EC);
  2901. ASSERT_REG_POSITION(peer_semaphore_release, 0x02F0);
  2902. ASSERT_REG_POSITION(iterated_blend_optimization, 0x02F4);
  2903. ASSERT_REG_POSITION(zcull_subregion_allocation, 0x02F8);
  2904. ASSERT_REG_POSITION(zcull_subregion_algorithm, 0x02FC);
  2905. ASSERT_REG_POSITION(ps_output_sample_mask_usage, 0x0300);
  2906. ASSERT_REG_POSITION(draw_zero_index, 0x0304);
  2907. ASSERT_REG_POSITION(l1_configuration, 0x0308);
  2908. ASSERT_REG_POSITION(render_enable_control_load_const_buffer, 0x030C);
  2909. ASSERT_REG_POSITION(spa_version, 0x0310);
  2910. ASSERT_REG_POSITION(ieee_clean_update, 0x0314);
  2911. ASSERT_REG_POSITION(snap_grid, 0x0318);
  2912. ASSERT_REG_POSITION(tessellation, 0x0320);
  2913. ASSERT_REG_POSITION(sub_tiling_perf, 0x0360);
  2914. ASSERT_REG_POSITION(zcull_subregion_report, 0x036C);
  2915. ASSERT_REG_POSITION(balanced_primitive_workload, 0x0374);
  2916. ASSERT_REG_POSITION(max_patches_per_batch, 0x0378);
  2917. ASSERT_REG_POSITION(rasterize_enable, 0x037C);
  2918. ASSERT_REG_POSITION(transform_feedback, 0x0380);
  2919. ASSERT_REG_POSITION(transform_feedback.controls, 0x0700);
  2920. ASSERT_REG_POSITION(raster_input, 0x0740);
  2921. ASSERT_REG_POSITION(transform_feedback_enabled, 0x0744);
  2922. ASSERT_REG_POSITION(primitive_restart_topology_change_enable, 0x0748);
  2923. ASSERT_REG_POSITION(alpha_fraction, 0x074C);
  2924. ASSERT_REG_POSITION(hybrid_aa_control, 0x0754);
  2925. ASSERT_REG_POSITION(shader_local_memory, 0x077C);
  2926. ASSERT_REG_POSITION(color_zero_bandwidth_clear, 0x07A4);
  2927. ASSERT_REG_POSITION(z_zero_bandwidth_clear, 0x07A8);
  2928. ASSERT_REG_POSITION(isbe_save_restore_program_offset, 0x07AC);
  2929. ASSERT_REG_POSITION(zcull_region, 0x07C0);
  2930. ASSERT_REG_POSITION(zeta_read_only, 0x07F8);
  2931. ASSERT_REG_POSITION(rt, 0x0800);
  2932. ASSERT_REG_POSITION(viewport_transform, 0x0A00);
  2933. ASSERT_REG_POSITION(viewports, 0x0C00);
  2934. ASSERT_REG_POSITION(windows, 0x0D00);
  2935. ASSERT_REG_POSITION(clip_id_extent, 0x0D40);
  2936. ASSERT_REG_POSITION(max_geometry_instances_per_task, 0x0D60);
  2937. ASSERT_REG_POSITION(visible_call_limit, 0x0D64);
  2938. ASSERT_REG_POSITION(statistics_count, 0x0D68);
  2939. ASSERT_REG_POSITION(clear_rect, 0x0D6C);
  2940. ASSERT_REG_POSITION(vertex_buffer, 0x0D74);
  2941. ASSERT_REG_POSITION(depth_mode, 0x0D7C);
  2942. ASSERT_REG_POSITION(clear_color, 0x0D80);
  2943. ASSERT_REG_POSITION(clear_depth, 0x0D90);
  2944. ASSERT_REG_POSITION(shader_cache_icache_prefetch, 0x0D94);
  2945. ASSERT_REG_POSITION(force_transition_to_beta, 0x0D98);
  2946. ASSERT_REG_POSITION(reduce_colour_thresholds, 0x0D9C);
  2947. ASSERT_REG_POSITION(clear_stencil, 0x0DA0);
  2948. ASSERT_REG_POSITION(invalidate_shader_cache_no_wfi, 0x0DA4);
  2949. ASSERT_REG_POSITION(zcull_serialization, 0x0DA8);
  2950. ASSERT_REG_POSITION(polygon_mode_front, 0x0DAC);
  2951. ASSERT_REG_POSITION(polygon_mode_back, 0x0DB0);
  2952. ASSERT_REG_POSITION(polygon_smooth, 0x0DB4);
  2953. ASSERT_REG_POSITION(zeta_mark_clean_ieee, 0x0DB8);
  2954. ASSERT_REG_POSITION(zcull_dir_format, 0x0DBC);
  2955. ASSERT_REG_POSITION(polygon_offset_point_enable, 0x0DC0);
  2956. ASSERT_REG_POSITION(polygon_offset_line_enable, 0x0DC4);
  2957. ASSERT_REG_POSITION(polygon_offset_fill_enable, 0x0DC8);
  2958. ASSERT_REG_POSITION(patch_vertices, 0x0DCC);
  2959. ASSERT_REG_POSITION(iterated_blend, 0x0DD0);
  2960. ASSERT_REG_POSITION(zcull_criteria, 0x0DD8);
  2961. ASSERT_REG_POSITION(fragment_barrier, 0x0DE0);
  2962. ASSERT_REG_POSITION(sm_timeout, 0x0DE4);
  2963. ASSERT_REG_POSITION(primitive_restart_array, 0x0DE8);
  2964. ASSERT_REG_POSITION(load_iterated_blend, 0x0DF0);
  2965. ASSERT_REG_POSITION(window_offset_x, 0x0DF8);
  2966. ASSERT_REG_POSITION(window_offset_y, 0x0DFC);
  2967. ASSERT_REG_POSITION(scissor_test, 0x0E00);
  2968. ASSERT_REG_POSITION(select_texture_headers, 0x0F10);
  2969. ASSERT_REG_POSITION(vpc_perf, 0x0F14);
  2970. ASSERT_REG_POSITION(pm_local_trigger, 0x0F18);
  2971. ASSERT_REG_POSITION(post_z_pixel_imask, 0x0F1C);
  2972. ASSERT_REG_POSITION(const_color_rendering, 0x0F40);
  2973. ASSERT_REG_POSITION(stencil_back_ref, 0x0F54);
  2974. ASSERT_REG_POSITION(stencil_back_mask, 0x0F58);
  2975. ASSERT_REG_POSITION(stencil_back_func_mask, 0x0F5C);
  2976. ASSERT_REG_POSITION(invalidate_texture_data_cache, 0x0F74);
  2977. ASSERT_REG_POSITION(tiled_cache_barrier, 0x0F7C);
  2978. ASSERT_REG_POSITION(vertex_stream_substitute, 0x0F84);
  2979. ASSERT_REG_POSITION(line_mode_clip_generated_edge_do_not_draw, 0x0F8C);
  2980. ASSERT_REG_POSITION(color_mask_common, 0x0F90);
  2981. ASSERT_REG_POSITION(vtg_warp_watermarks, 0x0F98);
  2982. ASSERT_REG_POSITION(depth_bounds, 0x0F9C);
  2983. ASSERT_REG_POSITION(sample_mask_target, 0x0FA4);
  2984. ASSERT_REG_POSITION(color_target_mrt_enable, 0x0FAC);
  2985. ASSERT_REG_POSITION(non_multisampled_z, 0x0FB0);
  2986. ASSERT_REG_POSITION(tir_mode, 0x0FB4);
  2987. ASSERT_REG_POSITION(anti_alias_raster, 0x0FB8);
  2988. ASSERT_REG_POSITION(sample_mask_pos, 0x0FBC);
  2989. ASSERT_REG_POSITION(surface_clip_id_memory, 0x0FCC);
  2990. ASSERT_REG_POSITION(tir_modulation, 0x0FD4);
  2991. ASSERT_REG_POSITION(blend_control_allow_float_pixel_kills, 0x0FDC);
  2992. ASSERT_REG_POSITION(zeta, 0x0FE0);
  2993. ASSERT_REG_POSITION(surface_clip, 0x0FF4);
  2994. ASSERT_REG_POSITION(tiled_cache_treat_heavy_as_light, 0x0FFC);
  2995. ASSERT_REG_POSITION(l2_cache_vaf, 0x1000);
  2996. ASSERT_REG_POSITION(viewport_multicast, 0x1004);
  2997. ASSERT_REG_POSITION(tessellation_cut_height, 0x1008);
  2998. ASSERT_REG_POSITION(max_gs_instances_per_task, 0x100C);
  2999. ASSERT_REG_POSITION(max_gs_output_vertices_per_task, 0x1010);
  3000. ASSERT_REG_POSITION(reserved_sw_method0, 0x1014);
  3001. ASSERT_REG_POSITION(gs_output_cb_storage_multiplier, 0x1018);
  3002. ASSERT_REG_POSITION(beta_cb_storage_constant, 0x101C);
  3003. ASSERT_REG_POSITION(ti_output_cb_storage_multiplier, 0x1020);
  3004. ASSERT_REG_POSITION(alpha_cb_storage_constraint, 0x1024);
  3005. ASSERT_REG_POSITION(reserved_sw_method1, 0x1028);
  3006. ASSERT_REG_POSITION(reserved_sw_method2, 0x102C);
  3007. ASSERT_REG_POSITION(tir_modulation_coeff, 0x1030);
  3008. ASSERT_REG_POSITION(spare_nop, 0x1044);
  3009. ASSERT_REG_POSITION(reserved_sw_method3_to_7, 0x10B0);
  3010. ASSERT_REG_POSITION(reduce_color_thresholds_unorm8, 0x10CC);
  3011. ASSERT_REG_POSITION(reserved_sw_method10_to_13, 0x10D0);
  3012. ASSERT_REG_POSITION(reduce_color_thresholds_unorm10, 0x10E0);
  3013. ASSERT_REG_POSITION(reduce_color_thresholds_unorm16, 0x10E4);
  3014. ASSERT_REG_POSITION(reduce_color_thresholds_fp11, 0x10E8);
  3015. ASSERT_REG_POSITION(reduce_color_thresholds_fp16, 0x10EC);
  3016. ASSERT_REG_POSITION(reduce_color_thresholds_srgb8, 0x10F0);
  3017. ASSERT_REG_POSITION(unbind_all_constant_buffers, 0x10F4);
  3018. ASSERT_REG_POSITION(clear_control, 0x10F8);
  3019. ASSERT_REG_POSITION(l2_cache_rop_non_interlocked_reads, 0x10FC);
  3020. ASSERT_REG_POSITION(reserved_sw_method14, 0x1100);
  3021. ASSERT_REG_POSITION(reserved_sw_method15, 0x1104);
  3022. ASSERT_REG_POSITION(no_operation_data_high, 0x110C);
  3023. ASSERT_REG_POSITION(depth_bias_control, 0x1110);
  3024. ASSERT_REG_POSITION(pm_trigger_end, 0x1114);
  3025. ASSERT_REG_POSITION(vertex_id_base, 0x1118);
  3026. ASSERT_REG_POSITION(stencil_compression_enabled, 0x111C);
  3027. ASSERT_REG_POSITION(vertex_output_attribute_skip_masks, 0x1120);
  3028. ASSERT_REG_POSITION(tir_control, 0x1130);
  3029. ASSERT_REG_POSITION(mutable_method_treat_mutable_as_heavy, 0x1134);
  3030. ASSERT_REG_POSITION(post_ps_use_pre_ps_coverage, 0x1138);
  3031. ASSERT_REG_POSITION(fill_via_triangle_mode, 0x113C);
  3032. ASSERT_REG_POSITION(blend_per_format_snorm8_unorm16_snorm16_enabled, 0x1140);
  3033. ASSERT_REG_POSITION(flush_pending_writes_sm_gloal_store, 0x1144);
  3034. ASSERT_REG_POSITION(conservative_raster_enable, 0x1148);
  3035. ASSERT_REG_POSITION(vertex_attrib_format, 0x1160);
  3036. ASSERT_REG_POSITION(multisample_sample_locations, 0x11E0);
  3037. ASSERT_REG_POSITION(offset_render_target_index_by_viewport_index, 0x11F0);
  3038. ASSERT_REG_POSITION(force_heavy_method_sync, 0x11F4);
  3039. ASSERT_REG_POSITION(multisample_coverage_to_color, 0x11F8);
  3040. ASSERT_REG_POSITION(decompress_zeta_surface, 0x11FC);
  3041. ASSERT_REG_POSITION(zeta_sparse, 0x1208);
  3042. ASSERT_REG_POSITION(invalidate_sampler_cache, 0x120C);
  3043. ASSERT_REG_POSITION(invalidate_texture_header_cache, 0x1210);
  3044. ASSERT_REG_POSITION(vertex_array_instance_first, 0x1214);
  3045. ASSERT_REG_POSITION(vertex_array_instance_subsequent, 0x1218);
  3046. ASSERT_REG_POSITION(rt_control, 0x121C);
  3047. ASSERT_REG_POSITION(compression_threshold_samples, 0x1220);
  3048. ASSERT_REG_POSITION(ps_interlock_control, 0x1224);
  3049. ASSERT_REG_POSITION(zeta_size, 0x1228);
  3050. ASSERT_REG_POSITION(sampler_binding, 0x1234);
  3051. ASSERT_REG_POSITION(draw_auto_byte_count, 0x123C);
  3052. ASSERT_REG_POSITION(post_vtg_shader_attrib_skip_mask, 0x1240);
  3053. ASSERT_REG_POSITION(ps_ticket_dispenser_value, 0x1260);
  3054. ASSERT_REG_POSITION(circular_buffer_size, 0x1280);
  3055. ASSERT_REG_POSITION(vtg_register_watermarks, 0x1284);
  3056. ASSERT_REG_POSITION(invalidate_texture_cache_no_wfi, 0x1288);
  3057. ASSERT_REG_POSITION(l2_cache_rop_interlocked_reads, 0x1290);
  3058. ASSERT_REG_POSITION(primitive_restart_topology_change_index, 0x12A4);
  3059. ASSERT_REG_POSITION(zcull_region_enable, 0x12C8);
  3060. ASSERT_REG_POSITION(depth_test_enable, 0x12CC);
  3061. ASSERT_REG_POSITION(fill_mode, 0x12D0);
  3062. ASSERT_REG_POSITION(shade_mode, 0x12D4);
  3063. ASSERT_REG_POSITION(l2_cache_rop_non_interlocked_writes, 0x12D8);
  3064. ASSERT_REG_POSITION(l2_cache_rop_interlocked_writes, 0x12DC);
  3065. ASSERT_REG_POSITION(alpha_to_coverage_dither, 0x12E0);
  3066. ASSERT_REG_POSITION(blend_per_target_enabled, 0x12E4);
  3067. ASSERT_REG_POSITION(depth_write_enabled, 0x12E8);
  3068. ASSERT_REG_POSITION(alpha_test_enabled, 0x12EC);
  3069. ASSERT_REG_POSITION(inline_index_4x8, 0x1300);
  3070. ASSERT_REG_POSITION(d3d_cull_mode, 0x1308);
  3071. ASSERT_REG_POSITION(depth_test_func, 0x130C);
  3072. ASSERT_REG_POSITION(alpha_test_ref, 0x1310);
  3073. ASSERT_REG_POSITION(alpha_test_func, 0x1314);
  3074. ASSERT_REG_POSITION(draw_auto_stride, 0x1318);
  3075. ASSERT_REG_POSITION(blend_color, 0x131C);
  3076. ASSERT_REG_POSITION(invalidate_sampler_cache_lines, 0x1330);
  3077. ASSERT_REG_POSITION(invalidate_texture_header_cache_lines, 0x1334);
  3078. ASSERT_REG_POSITION(invalidate_texture_data_cache_lines, 0x1338);
  3079. ASSERT_REG_POSITION(blend, 0x133C);
  3080. ASSERT_REG_POSITION(stencil_enable, 0x1380);
  3081. ASSERT_REG_POSITION(stencil_front_op, 0x1384);
  3082. ASSERT_REG_POSITION(stencil_front_ref, 0x1394);
  3083. ASSERT_REG_POSITION(stencil_front_func_mask, 0x1398);
  3084. ASSERT_REG_POSITION(stencil_front_mask, 0x139C);
  3085. ASSERT_REG_POSITION(draw_auto_start_byte_count, 0x13A4);
  3086. ASSERT_REG_POSITION(frag_color_clamp, 0x13A8);
  3087. ASSERT_REG_POSITION(window_origin, 0x13AC);
  3088. ASSERT_REG_POSITION(line_width_smooth, 0x13B0);
  3089. ASSERT_REG_POSITION(line_width_aliased, 0x13B4);
  3090. ASSERT_REG_POSITION(line_override_multisample, 0x1418);
  3091. ASSERT_REG_POSITION(alpha_hysteresis_rounds, 0x1420);
  3092. ASSERT_REG_POSITION(invalidate_sampler_cache_no_wfi, 0x1424);
  3093. ASSERT_REG_POSITION(invalidate_texture_header_cache_no_wfi, 0x1428);
  3094. ASSERT_REG_POSITION(global_base_vertex_index, 0x1434);
  3095. ASSERT_REG_POSITION(global_base_instance_index, 0x1438);
  3096. ASSERT_REG_POSITION(ps_warp_watermarks, 0x1450);
  3097. ASSERT_REG_POSITION(ps_regster_watermarks, 0x1454);
  3098. ASSERT_REG_POSITION(store_zcull, 0x1464);
  3099. ASSERT_REG_POSITION(iterated_blend_constants, 0x1480);
  3100. ASSERT_REG_POSITION(load_zcull, 0x1500);
  3101. ASSERT_REG_POSITION(surface_clip_id_height, 0x1504);
  3102. ASSERT_REG_POSITION(surface_clip_id_clear_rect, 0x1508);
  3103. ASSERT_REG_POSITION(user_clip_enable, 0x1510);
  3104. ASSERT_REG_POSITION(zpass_pixel_count_enable, 0x1514);
  3105. ASSERT_REG_POSITION(point_size, 0x1518);
  3106. ASSERT_REG_POSITION(zcull_stats_enable, 0x151C);
  3107. ASSERT_REG_POSITION(point_sprite_enable, 0x1520);
  3108. ASSERT_REG_POSITION(shader_exceptions_enable, 0x1528);
  3109. ASSERT_REG_POSITION(clear_report_value, 0x1530);
  3110. ASSERT_REG_POSITION(anti_alias_enable, 0x1534);
  3111. ASSERT_REG_POSITION(zeta_enable, 0x1538);
  3112. ASSERT_REG_POSITION(anti_alias_alpha_control, 0x153C);
  3113. ASSERT_REG_POSITION(render_enable, 0x1550);
  3114. ASSERT_REG_POSITION(tex_sampler, 0x155C);
  3115. ASSERT_REG_POSITION(slope_scale_depth_bias, 0x156C);
  3116. ASSERT_REG_POSITION(line_anti_alias_enable, 0x1570);
  3117. ASSERT_REG_POSITION(tex_header, 0x1574);
  3118. ASSERT_REG_POSITION(active_zcull_region_id, 0x1590);
  3119. ASSERT_REG_POSITION(stencil_two_side_enable, 0x1594);
  3120. ASSERT_REG_POSITION(stencil_back_op, 0x1598);
  3121. ASSERT_REG_POSITION(framebuffer_srgb, 0x15B8);
  3122. ASSERT_REG_POSITION(depth_bias, 0x15BC);
  3123. ASSERT_REG_POSITION(zcull_region_format, 0x15C8);
  3124. ASSERT_REG_POSITION(rt_layer, 0x15CC);
  3125. ASSERT_REG_POSITION(anti_alias_samples_mode, 0x15D0);
  3126. ASSERT_REG_POSITION(edge_flag, 0x15E4);
  3127. ASSERT_REG_POSITION(draw_inline_index, 0x15E8);
  3128. ASSERT_REG_POSITION(inline_index_2x16, 0x15EC);
  3129. ASSERT_REG_POSITION(vertex_global_base_offset, 0x15F4);
  3130. ASSERT_REG_POSITION(zcull_region_pixel_offset, 0x15FC);
  3131. ASSERT_REG_POSITION(point_sprite, 0x1604);
  3132. ASSERT_REG_POSITION(program_region, 0x1608);
  3133. ASSERT_REG_POSITION(default_attributes, 0x1610);
  3134. ASSERT_REG_POSITION(draw, 0x1614);
  3135. ASSERT_REG_POSITION(vertex_id_copy, 0x161C);
  3136. ASSERT_REG_POSITION(add_to_primitive_id, 0x1620);
  3137. ASSERT_REG_POSITION(load_to_primitive_id, 0x1624);
  3138. ASSERT_REG_POSITION(shader_based_cull, 0x162C);
  3139. ASSERT_REG_POSITION(class_version, 0x1638);
  3140. ASSERT_REG_POSITION(primitive_restart, 0x1644);
  3141. ASSERT_REG_POSITION(output_vertex_id, 0x164C);
  3142. ASSERT_REG_POSITION(anti_alias_point_enable, 0x1658);
  3143. ASSERT_REG_POSITION(point_center_mode, 0x165C);
  3144. ASSERT_REG_POSITION(line_smooth_params, 0x1668);
  3145. ASSERT_REG_POSITION(line_stipple_enable, 0x166C);
  3146. ASSERT_REG_POSITION(line_smooth_edge_table, 0x1670);
  3147. ASSERT_REG_POSITION(line_stipple_params, 0x1680);
  3148. ASSERT_REG_POSITION(provoking_vertex, 0x1684);
  3149. ASSERT_REG_POSITION(two_sided_light_enabled, 0x1688);
  3150. ASSERT_REG_POSITION(polygon_stipple_enabled, 0x168C);
  3151. ASSERT_REG_POSITION(shader_control, 0x1690);
  3152. ASSERT_REG_POSITION(class_version_check, 0x16A0);
  3153. ASSERT_REG_POSITION(sph_version, 0x16A4);
  3154. ASSERT_REG_POSITION(sph_version_check, 0x16A8);
  3155. ASSERT_REG_POSITION(alpha_to_coverage_override, 0x16B4);
  3156. ASSERT_REG_POSITION(polygon_stipple_pattern, 0x1700);
  3157. ASSERT_REG_POSITION(aam_version, 0x1790);
  3158. ASSERT_REG_POSITION(aam_version_check, 0x1794);
  3159. ASSERT_REG_POSITION(zeta_layer_offset, 0x179C);
  3160. ASSERT_REG_POSITION(index_buffer, 0x17C8);
  3161. ASSERT_REG_POSITION(index_buffer32_first, 0x17E4);
  3162. ASSERT_REG_POSITION(index_buffer16_first, 0x17E8);
  3163. ASSERT_REG_POSITION(index_buffer8_first, 0x17EC);
  3164. ASSERT_REG_POSITION(index_buffer32_subsequent, 0x17F0);
  3165. ASSERT_REG_POSITION(index_buffer16_subsequent, 0x17F4);
  3166. ASSERT_REG_POSITION(index_buffer8_subsequent, 0x17F8);
  3167. ASSERT_REG_POSITION(depth_bias_clamp, 0x187C);
  3168. ASSERT_REG_POSITION(vertex_stream_instances, 0x1880);
  3169. ASSERT_REG_POSITION(point_size_attribute, 0x1910);
  3170. ASSERT_REG_POSITION(gl_cull_test_enabled, 0x1918);
  3171. ASSERT_REG_POSITION(gl_front_face, 0x191C);
  3172. ASSERT_REG_POSITION(gl_cull_face, 0x1920);
  3173. ASSERT_REG_POSITION(viewport_pixel_center, 0x1924);
  3174. ASSERT_REG_POSITION(viewport_scale_offset_enabled, 0x192C);
  3175. ASSERT_REG_POSITION(viewport_clip_control, 0x193C);
  3176. ASSERT_REG_POSITION(user_clip_op, 0x1940);
  3177. ASSERT_REG_POSITION(render_enable_override, 0x1944);
  3178. ASSERT_REG_POSITION(primitive_topology_control, 0x1948);
  3179. ASSERT_REG_POSITION(window_clip_enable, 0x194C);
  3180. ASSERT_REG_POSITION(invalidate_zcull, 0x1958);
  3181. ASSERT_REG_POSITION(zcull, 0x1968);
  3182. ASSERT_REG_POSITION(topology_override, 0x1970);
  3183. ASSERT_REG_POSITION(zcull_sync, 0x1978);
  3184. ASSERT_REG_POSITION(clip_id_test_enable, 0x197C);
  3185. ASSERT_REG_POSITION(surface_clip_id_width, 0x1980);
  3186. ASSERT_REG_POSITION(clip_id, 0x1984);
  3187. ASSERT_REG_POSITION(depth_bounds_enable, 0x19BC);
  3188. ASSERT_REG_POSITION(blend_float_zero_times_anything_is_zero, 0x19C0);
  3189. ASSERT_REG_POSITION(logic_op, 0x19C4);
  3190. ASSERT_REG_POSITION(z_compression_enable, 0x19CC);
  3191. ASSERT_REG_POSITION(clear_surface, 0x19D0);
  3192. ASSERT_REG_POSITION(clear_clip_id_surface, 0x19D4);
  3193. ASSERT_REG_POSITION(color_compression_enable, 0x19E0);
  3194. ASSERT_REG_POSITION(color_mask, 0x1A00);
  3195. ASSERT_REG_POSITION(pipe_nop, 0x1A2C);
  3196. ASSERT_REG_POSITION(spare, 0x1A30);
  3197. ASSERT_REG_POSITION(report_semaphore, 0x1B00);
  3198. ASSERT_REG_POSITION(vertex_streams, 0x1C00);
  3199. ASSERT_REG_POSITION(blend_per_target, 0x1E00);
  3200. ASSERT_REG_POSITION(vertex_stream_limits, 0x1F00);
  3201. ASSERT_REG_POSITION(pipelines, 0x2000);
  3202. ASSERT_REG_POSITION(falcon, 0x2300);
  3203. ASSERT_REG_POSITION(const_buffer, 0x2380);
  3204. ASSERT_REG_POSITION(bind_groups, 0x2400);
  3205. ASSERT_REG_POSITION(color_clamp_enable, 0x2600);
  3206. ASSERT_REG_POSITION(bindless_texture_const_buffer_slot, 0x2608);
  3207. ASSERT_REG_POSITION(trap_handler, 0x260C);
  3208. ASSERT_REG_POSITION(stream_out_layout, 0x2800);
  3209. ASSERT_REG_POSITION(shader_performance, 0x333C);
  3210. ASSERT_REG_POSITION(shadow_scratch, 0x3400);
  3211. #undef ASSERT_REG_POSITION
  3212. } // namespace Tegra::Engines