node.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. // Copyright 2019 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <array>
  6. #include <cstddef>
  7. #include <memory>
  8. #include <optional>
  9. #include <string>
  10. #include <tuple>
  11. #include <utility>
  12. #include <variant>
  13. #include <vector>
  14. #include "common/common_types.h"
  15. #include "video_core/engines/shader_bytecode.h"
  16. namespace VideoCommon::Shader {
  17. enum class OperationCode {
  18. Assign, /// (float& dest, float src) -> void
  19. Select, /// (MetaArithmetic, bool pred, float a, float b) -> float
  20. FAdd, /// (MetaArithmetic, float a, float b) -> float
  21. FMul, /// (MetaArithmetic, float a, float b) -> float
  22. FDiv, /// (MetaArithmetic, float a, float b) -> float
  23. FFma, /// (MetaArithmetic, float a, float b, float c) -> float
  24. FNegate, /// (MetaArithmetic, float a) -> float
  25. FAbsolute, /// (MetaArithmetic, float a) -> float
  26. FClamp, /// (MetaArithmetic, float value, float min, float max) -> float
  27. FCastHalf0, /// (MetaArithmetic, f16vec2 a) -> float
  28. FCastHalf1, /// (MetaArithmetic, f16vec2 a) -> float
  29. FMin, /// (MetaArithmetic, float a, float b) -> float
  30. FMax, /// (MetaArithmetic, float a, float b) -> float
  31. FCos, /// (MetaArithmetic, float a) -> float
  32. FSin, /// (MetaArithmetic, float a) -> float
  33. FExp2, /// (MetaArithmetic, float a) -> float
  34. FLog2, /// (MetaArithmetic, float a) -> float
  35. FInverseSqrt, /// (MetaArithmetic, float a) -> float
  36. FSqrt, /// (MetaArithmetic, float a) -> float
  37. FRoundEven, /// (MetaArithmetic, float a) -> float
  38. FFloor, /// (MetaArithmetic, float a) -> float
  39. FCeil, /// (MetaArithmetic, float a) -> float
  40. FTrunc, /// (MetaArithmetic, float a) -> float
  41. FCastInteger, /// (MetaArithmetic, int a) -> float
  42. FCastUInteger, /// (MetaArithmetic, uint a) -> float
  43. FSwizzleAdd, /// (float a, float b, uint mask) -> float
  44. IAdd, /// (MetaArithmetic, int a, int b) -> int
  45. IMul, /// (MetaArithmetic, int a, int b) -> int
  46. IDiv, /// (MetaArithmetic, int a, int b) -> int
  47. INegate, /// (MetaArithmetic, int a) -> int
  48. IAbsolute, /// (MetaArithmetic, int a) -> int
  49. IMin, /// (MetaArithmetic, int a, int b) -> int
  50. IMax, /// (MetaArithmetic, int a, int b) -> int
  51. ICastFloat, /// (MetaArithmetic, float a) -> int
  52. ICastUnsigned, /// (MetaArithmetic, uint a) -> int
  53. ILogicalShiftLeft, /// (MetaArithmetic, int a, uint b) -> int
  54. ILogicalShiftRight, /// (MetaArithmetic, int a, uint b) -> int
  55. IArithmeticShiftRight, /// (MetaArithmetic, int a, uint b) -> int
  56. IBitwiseAnd, /// (MetaArithmetic, int a, int b) -> int
  57. IBitwiseOr, /// (MetaArithmetic, int a, int b) -> int
  58. IBitwiseXor, /// (MetaArithmetic, int a, int b) -> int
  59. IBitwiseNot, /// (MetaArithmetic, int a) -> int
  60. IBitfieldInsert, /// (MetaArithmetic, int base, int insert, int offset, int bits) -> int
  61. IBitfieldExtract, /// (MetaArithmetic, int value, int offset, int offset) -> int
  62. IBitCount, /// (MetaArithmetic, int) -> int
  63. IBitMSB, /// (MetaArithmetic, int) -> int
  64. UAdd, /// (MetaArithmetic, uint a, uint b) -> uint
  65. UMul, /// (MetaArithmetic, uint a, uint b) -> uint
  66. UDiv, /// (MetaArithmetic, uint a, uint b) -> uint
  67. UMin, /// (MetaArithmetic, uint a, uint b) -> uint
  68. UMax, /// (MetaArithmetic, uint a, uint b) -> uint
  69. UCastFloat, /// (MetaArithmetic, float a) -> uint
  70. UCastSigned, /// (MetaArithmetic, int a) -> uint
  71. ULogicalShiftLeft, /// (MetaArithmetic, uint a, uint b) -> uint
  72. ULogicalShiftRight, /// (MetaArithmetic, uint a, uint b) -> uint
  73. UArithmeticShiftRight, /// (MetaArithmetic, uint a, uint b) -> uint
  74. UBitwiseAnd, /// (MetaArithmetic, uint a, uint b) -> uint
  75. UBitwiseOr, /// (MetaArithmetic, uint a, uint b) -> uint
  76. UBitwiseXor, /// (MetaArithmetic, uint a, uint b) -> uint
  77. UBitwiseNot, /// (MetaArithmetic, uint a) -> uint
  78. UBitfieldInsert, /// (MetaArithmetic, uint base, uint insert, int offset, int bits) -> uint
  79. UBitfieldExtract, /// (MetaArithmetic, uint value, int offset, int offset) -> uint
  80. UBitCount, /// (MetaArithmetic, uint) -> uint
  81. UBitMSB, /// (MetaArithmetic, uint) -> uint
  82. HAdd, /// (MetaArithmetic, f16vec2 a, f16vec2 b) -> f16vec2
  83. HMul, /// (MetaArithmetic, f16vec2 a, f16vec2 b) -> f16vec2
  84. HFma, /// (MetaArithmetic, f16vec2 a, f16vec2 b, f16vec2 c) -> f16vec2
  85. HAbsolute, /// (f16vec2 a) -> f16vec2
  86. HNegate, /// (f16vec2 a, bool first, bool second) -> f16vec2
  87. HClamp, /// (f16vec2 src, float min, float max) -> f16vec2
  88. HCastFloat, /// (MetaArithmetic, float a) -> f16vec2
  89. HUnpack, /// (Tegra::Shader::HalfType, T value) -> f16vec2
  90. HMergeF32, /// (f16vec2 src) -> float
  91. HMergeH0, /// (f16vec2 dest, f16vec2 src) -> f16vec2
  92. HMergeH1, /// (f16vec2 dest, f16vec2 src) -> f16vec2
  93. HPack2, /// (float a, float b) -> f16vec2
  94. LogicalAssign, /// (bool& dst, bool src) -> void
  95. LogicalAnd, /// (bool a, bool b) -> bool
  96. LogicalOr, /// (bool a, bool b) -> bool
  97. LogicalXor, /// (bool a, bool b) -> bool
  98. LogicalNegate, /// (bool a) -> bool
  99. LogicalPick2, /// (bool2 pair, uint index) -> bool
  100. LogicalAnd2, /// (bool2 a) -> bool
  101. LogicalFLessThan, /// (float a, float b) -> bool
  102. LogicalFEqual, /// (float a, float b) -> bool
  103. LogicalFLessEqual, /// (float a, float b) -> bool
  104. LogicalFGreaterThan, /// (float a, float b) -> bool
  105. LogicalFNotEqual, /// (float a, float b) -> bool
  106. LogicalFGreaterEqual, /// (float a, float b) -> bool
  107. LogicalFIsNan, /// (float a) -> bool
  108. LogicalILessThan, /// (int a, int b) -> bool
  109. LogicalIEqual, /// (int a, int b) -> bool
  110. LogicalILessEqual, /// (int a, int b) -> bool
  111. LogicalIGreaterThan, /// (int a, int b) -> bool
  112. LogicalINotEqual, /// (int a, int b) -> bool
  113. LogicalIGreaterEqual, /// (int a, int b) -> bool
  114. LogicalULessThan, /// (uint a, uint b) -> bool
  115. LogicalUEqual, /// (uint a, uint b) -> bool
  116. LogicalULessEqual, /// (uint a, uint b) -> bool
  117. LogicalUGreaterThan, /// (uint a, uint b) -> bool
  118. LogicalUNotEqual, /// (uint a, uint b) -> bool
  119. LogicalUGreaterEqual, /// (uint a, uint b) -> bool
  120. Logical2HLessThan, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2
  121. Logical2HEqual, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2
  122. Logical2HLessEqual, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2
  123. Logical2HGreaterThan, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2
  124. Logical2HNotEqual, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2
  125. Logical2HGreaterEqual, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2
  126. Logical2HLessThanWithNan, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2
  127. Logical2HEqualWithNan, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2
  128. Logical2HLessEqualWithNan, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2
  129. Logical2HGreaterThanWithNan, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2
  130. Logical2HNotEqualWithNan, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2
  131. Logical2HGreaterEqualWithNan, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2
  132. Texture, /// (MetaTexture, float[N] coords) -> float4
  133. TextureLod, /// (MetaTexture, float[N] coords) -> float4
  134. TextureGather, /// (MetaTexture, float[N] coords) -> float4
  135. TextureQueryDimensions, /// (MetaTexture, float a) -> float4
  136. TextureQueryLod, /// (MetaTexture, float[N] coords) -> float4
  137. TexelFetch, /// (MetaTexture, int[N], int) -> float4
  138. TextureGradient, /// (MetaTexture, float[N] coords, float[N*2] derivates) -> float4
  139. ImageLoad, /// (MetaImage, int[N] coords) -> void
  140. ImageStore, /// (MetaImage, int[N] coords) -> void
  141. AtomicImageAdd, /// (MetaImage, int[N] coords) -> void
  142. AtomicImageAnd, /// (MetaImage, int[N] coords) -> void
  143. AtomicImageOr, /// (MetaImage, int[N] coords) -> void
  144. AtomicImageXor, /// (MetaImage, int[N] coords) -> void
  145. AtomicImageExchange, /// (MetaImage, int[N] coords) -> void
  146. Branch, /// (uint branch_target) -> void
  147. BranchIndirect, /// (uint branch_target) -> void
  148. PushFlowStack, /// (uint branch_target) -> void
  149. PopFlowStack, /// () -> void
  150. Exit, /// () -> void
  151. Discard, /// () -> void
  152. EmitVertex, /// () -> void
  153. EndPrimitive, /// () -> void
  154. InvocationId, /// () -> int
  155. YNegate, /// () -> float
  156. LocalInvocationIdX, /// () -> uint
  157. LocalInvocationIdY, /// () -> uint
  158. LocalInvocationIdZ, /// () -> uint
  159. WorkGroupIdX, /// () -> uint
  160. WorkGroupIdY, /// () -> uint
  161. WorkGroupIdZ, /// () -> uint
  162. BallotThread, /// (bool) -> uint
  163. VoteAll, /// (bool) -> bool
  164. VoteAny, /// (bool) -> bool
  165. VoteEqual, /// (bool) -> bool
  166. ThreadId, /// () -> uint
  167. ShuffleIndexed, /// (uint value, uint index) -> uint
  168. MemoryBarrierGL, /// () -> void
  169. Amount,
  170. };
  171. enum class InternalFlag {
  172. Zero = 0,
  173. Sign = 1,
  174. Carry = 2,
  175. Overflow = 3,
  176. Amount = 4,
  177. };
  178. enum class MetaStackClass {
  179. Ssy,
  180. Pbk,
  181. };
  182. class OperationNode;
  183. class ConditionalNode;
  184. class GprNode;
  185. class ImmediateNode;
  186. class InternalFlagNode;
  187. class PredicateNode;
  188. class AbufNode;
  189. class CbufNode;
  190. class LmemNode;
  191. class PatchNode;
  192. class SmemNode;
  193. class GmemNode;
  194. class CommentNode;
  195. using NodeData = std::variant<OperationNode, ConditionalNode, GprNode, ImmediateNode,
  196. InternalFlagNode, PredicateNode, AbufNode, PatchNode, CbufNode,
  197. LmemNode, SmemNode, GmemNode, CommentNode>;
  198. using Node = std::shared_ptr<NodeData>;
  199. using Node4 = std::array<Node, 4>;
  200. using NodeBlock = std::vector<Node>;
  201. class Sampler {
  202. public:
  203. /// This constructor is for bound samplers
  204. constexpr explicit Sampler(u32 index, u32 offset, Tegra::Shader::TextureType type,
  205. bool is_array, bool is_shadow, bool is_buffer)
  206. : index{index}, offset{offset}, type{type}, is_array{is_array}, is_shadow{is_shadow},
  207. is_buffer{is_buffer} {}
  208. /// This constructor is for bindless samplers
  209. constexpr explicit Sampler(u32 index, u32 offset, u32 buffer, Tegra::Shader::TextureType type,
  210. bool is_array, bool is_shadow, bool is_buffer)
  211. : index{index}, offset{offset}, buffer{buffer}, type{type}, is_array{is_array},
  212. is_shadow{is_shadow}, is_buffer{is_buffer}, is_bindless{true} {}
  213. constexpr u32 GetIndex() const {
  214. return index;
  215. }
  216. constexpr u32 GetOffset() const {
  217. return offset;
  218. }
  219. constexpr u32 GetBuffer() const {
  220. return buffer;
  221. }
  222. constexpr Tegra::Shader::TextureType GetType() const {
  223. return type;
  224. }
  225. constexpr bool IsArray() const {
  226. return is_array;
  227. }
  228. constexpr bool IsShadow() const {
  229. return is_shadow;
  230. }
  231. constexpr bool IsBuffer() const {
  232. return is_buffer;
  233. }
  234. constexpr bool IsBindless() const {
  235. return is_bindless;
  236. }
  237. private:
  238. u32 index{}; ///< Emulated index given for the this sampler.
  239. u32 offset{}; ///< Offset in the const buffer from where the sampler is being read.
  240. u32 buffer{}; ///< Buffer where the bindless sampler is being read (unused on bound samplers).
  241. Tegra::Shader::TextureType type{}; ///< The type used to sample this texture (Texture2D, etc)
  242. bool is_array{}; ///< Whether the texture is being sampled as an array texture or not.
  243. bool is_shadow{}; ///< Whether the texture is being sampled as a depth texture or not.
  244. bool is_buffer{}; ///< Whether the texture is a texture buffer without sampler.
  245. bool is_bindless{}; ///< Whether this sampler belongs to a bindless texture or not.
  246. };
  247. class Image final {
  248. public:
  249. /// This constructor is for bound images
  250. constexpr explicit Image(u32 index, u32 offset, Tegra::Shader::ImageType type)
  251. : index{index}, offset{offset}, type{type} {}
  252. /// This constructor is for bindless samplers
  253. constexpr explicit Image(u32 index, u32 offset, u32 buffer, Tegra::Shader::ImageType type)
  254. : index{index}, offset{offset}, buffer{buffer}, type{type}, is_bindless{true} {}
  255. void MarkWrite() {
  256. is_written = true;
  257. }
  258. void MarkRead() {
  259. is_read = true;
  260. }
  261. void MarkAtomic() {
  262. MarkWrite();
  263. MarkRead();
  264. is_atomic = true;
  265. }
  266. constexpr u32 GetIndex() const {
  267. return index;
  268. }
  269. constexpr u32 GetOffset() const {
  270. return offset;
  271. }
  272. constexpr u32 GetBuffer() const {
  273. return buffer;
  274. }
  275. constexpr Tegra::Shader::ImageType GetType() const {
  276. return type;
  277. }
  278. constexpr bool IsBindless() const {
  279. return is_bindless;
  280. }
  281. constexpr bool IsWritten() const {
  282. return is_written;
  283. }
  284. constexpr bool IsRead() const {
  285. return is_read;
  286. }
  287. constexpr bool IsAtomic() const {
  288. return is_atomic;
  289. }
  290. private:
  291. u32 index{};
  292. u32 offset{};
  293. u32 buffer{};
  294. Tegra::Shader::ImageType type{};
  295. bool is_bindless{};
  296. bool is_written{};
  297. bool is_read{};
  298. bool is_atomic{};
  299. };
  300. struct GlobalMemoryBase {
  301. u32 cbuf_index{};
  302. u32 cbuf_offset{};
  303. bool operator<(const GlobalMemoryBase& rhs) const {
  304. return std::tie(cbuf_index, cbuf_offset) < std::tie(rhs.cbuf_index, rhs.cbuf_offset);
  305. }
  306. };
  307. /// Parameters describing an arithmetic operation
  308. struct MetaArithmetic {
  309. bool precise{}; ///< Whether the operation can be constraint or not
  310. };
  311. /// Parameters describing a texture sampler
  312. struct MetaTexture {
  313. const Sampler& sampler;
  314. Node array;
  315. Node depth_compare;
  316. std::vector<Node> aoffi;
  317. std::vector<Node> ptp;
  318. std::vector<Node> derivates;
  319. Node bias;
  320. Node lod;
  321. Node component{};
  322. u32 element{};
  323. };
  324. struct MetaImage {
  325. const Image& image;
  326. std::vector<Node> values;
  327. u32 element{};
  328. };
  329. /// Parameters that modify an operation but are not part of any particular operand
  330. using Meta =
  331. std::variant<MetaArithmetic, MetaTexture, MetaImage, MetaStackClass, Tegra::Shader::HalfType>;
  332. /// Holds any kind of operation that can be done in the IR
  333. class OperationNode final {
  334. public:
  335. explicit OperationNode(OperationCode code) : OperationNode(code, Meta{}) {}
  336. explicit OperationNode(OperationCode code, Meta meta)
  337. : OperationNode(code, std::move(meta), std::vector<Node>{}) {}
  338. explicit OperationNode(OperationCode code, std::vector<Node> operands)
  339. : OperationNode(code, Meta{}, std::move(operands)) {}
  340. explicit OperationNode(OperationCode code, Meta meta, std::vector<Node> operands)
  341. : code{code}, meta{std::move(meta)}, operands{std::move(operands)} {}
  342. template <typename... Args>
  343. explicit OperationNode(OperationCode code, Meta meta, Args&&... operands)
  344. : code{code}, meta{std::move(meta)}, operands{operands...} {}
  345. OperationCode GetCode() const {
  346. return code;
  347. }
  348. const Meta& GetMeta() const {
  349. return meta;
  350. }
  351. std::size_t GetOperandsCount() const {
  352. return operands.size();
  353. }
  354. const Node& operator[](std::size_t operand_index) const {
  355. return operands.at(operand_index);
  356. }
  357. private:
  358. OperationCode code{};
  359. Meta meta{};
  360. std::vector<Node> operands;
  361. };
  362. /// Encloses inside any kind of node that returns a boolean conditionally-executed code
  363. class ConditionalNode final {
  364. public:
  365. explicit ConditionalNode(Node condition, std::vector<Node>&& code)
  366. : condition{std::move(condition)}, code{std::move(code)} {}
  367. const Node& GetCondition() const {
  368. return condition;
  369. }
  370. const std::vector<Node>& GetCode() const {
  371. return code;
  372. }
  373. private:
  374. Node condition; ///< Condition to be satisfied
  375. std::vector<Node> code; ///< Code to execute
  376. };
  377. /// A general purpose register
  378. class GprNode final {
  379. public:
  380. explicit constexpr GprNode(Tegra::Shader::Register index) : index{index} {}
  381. u32 GetIndex() const {
  382. return static_cast<u32>(index);
  383. }
  384. private:
  385. Tegra::Shader::Register index{};
  386. };
  387. /// A 32-bits value that represents an immediate value
  388. class ImmediateNode final {
  389. public:
  390. explicit constexpr ImmediateNode(u32 value) : value{value} {}
  391. u32 GetValue() const {
  392. return value;
  393. }
  394. private:
  395. u32 value{};
  396. };
  397. /// One of Maxwell's internal flags
  398. class InternalFlagNode final {
  399. public:
  400. explicit constexpr InternalFlagNode(InternalFlag flag) : flag{flag} {}
  401. InternalFlag GetFlag() const {
  402. return flag;
  403. }
  404. private:
  405. InternalFlag flag{};
  406. };
  407. /// A predicate register, it can be negated without additional nodes
  408. class PredicateNode final {
  409. public:
  410. explicit constexpr PredicateNode(Tegra::Shader::Pred index, bool negated)
  411. : index{index}, negated{negated} {}
  412. Tegra::Shader::Pred GetIndex() const {
  413. return index;
  414. }
  415. bool IsNegated() const {
  416. return negated;
  417. }
  418. private:
  419. Tegra::Shader::Pred index{};
  420. bool negated{};
  421. };
  422. /// Attribute buffer memory (known as attributes or varyings in GLSL terms)
  423. class AbufNode final {
  424. public:
  425. // Initialize for standard attributes (index is explicit).
  426. explicit AbufNode(Tegra::Shader::Attribute::Index index, u32 element, Node buffer = {})
  427. : buffer{std::move(buffer)}, index{index}, element{element} {}
  428. // Initialize for physical attributes (index is a variable value).
  429. explicit AbufNode(Node physical_address, Node buffer = {})
  430. : physical_address{std::move(physical_address)}, buffer{std::move(buffer)} {}
  431. Tegra::Shader::Attribute::Index GetIndex() const {
  432. return index;
  433. }
  434. u32 GetElement() const {
  435. return element;
  436. }
  437. const Node& GetBuffer() const {
  438. return buffer;
  439. }
  440. bool IsPhysicalBuffer() const {
  441. return static_cast<bool>(physical_address);
  442. }
  443. const Node& GetPhysicalAddress() const {
  444. return physical_address;
  445. }
  446. private:
  447. Node physical_address;
  448. Node buffer;
  449. Tegra::Shader::Attribute::Index index{};
  450. u32 element{};
  451. };
  452. /// Patch memory (used to communicate tessellation stages).
  453. class PatchNode final {
  454. public:
  455. explicit PatchNode(u32 offset) : offset{offset} {}
  456. u32 GetOffset() const {
  457. return offset;
  458. }
  459. private:
  460. u32 offset{};
  461. };
  462. /// Constant buffer node, usually mapped to uniform buffers in GLSL
  463. class CbufNode final {
  464. public:
  465. explicit CbufNode(u32 index, Node offset) : index{index}, offset{std::move(offset)} {}
  466. u32 GetIndex() const {
  467. return index;
  468. }
  469. const Node& GetOffset() const {
  470. return offset;
  471. }
  472. private:
  473. u32 index{};
  474. Node offset;
  475. };
  476. /// Local memory node
  477. class LmemNode final {
  478. public:
  479. explicit LmemNode(Node address) : address{std::move(address)} {}
  480. const Node& GetAddress() const {
  481. return address;
  482. }
  483. private:
  484. Node address;
  485. };
  486. /// Shared memory node
  487. class SmemNode final {
  488. public:
  489. explicit SmemNode(Node address) : address{std::move(address)} {}
  490. const Node& GetAddress() const {
  491. return address;
  492. }
  493. private:
  494. Node address;
  495. };
  496. /// Global memory node
  497. class GmemNode final {
  498. public:
  499. explicit GmemNode(Node real_address, Node base_address, const GlobalMemoryBase& descriptor)
  500. : real_address{std::move(real_address)}, base_address{std::move(base_address)},
  501. descriptor{descriptor} {}
  502. const Node& GetRealAddress() const {
  503. return real_address;
  504. }
  505. const Node& GetBaseAddress() const {
  506. return base_address;
  507. }
  508. const GlobalMemoryBase& GetDescriptor() const {
  509. return descriptor;
  510. }
  511. private:
  512. Node real_address;
  513. Node base_address;
  514. GlobalMemoryBase descriptor;
  515. };
  516. /// Commentary, can be dropped
  517. class CommentNode final {
  518. public:
  519. explicit CommentNode(std::string text) : text{std::move(text)} {}
  520. const std::string& GetText() const {
  521. return text;
  522. }
  523. private:
  524. std::string text;
  525. };
  526. } // namespace VideoCommon::Shader