Instruction.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using System;
  2. namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
  3. {
  4. [Flags]
  5. enum Instruction
  6. {
  7. Absolute = 1,
  8. Add,
  9. AtomicAdd,
  10. AtomicAnd,
  11. AtomicCompareAndSwap,
  12. AtomicMinS32,
  13. AtomicMinU32,
  14. AtomicMaxS32,
  15. AtomicMaxU32,
  16. AtomicOr,
  17. AtomicSwap,
  18. AtomicXor,
  19. Ballot,
  20. Barrier,
  21. BitCount,
  22. BitfieldExtractS32,
  23. BitfieldExtractU32,
  24. BitfieldInsert,
  25. BitfieldReverse,
  26. BitwiseAnd,
  27. BitwiseExclusiveOr,
  28. BitwiseNot,
  29. BitwiseOr,
  30. Branch,
  31. BranchIfFalse,
  32. BranchIfTrue,
  33. Call,
  34. Ceiling,
  35. Clamp,
  36. ClampU32,
  37. Comment,
  38. CompareEqual,
  39. CompareGreater,
  40. CompareGreaterOrEqual,
  41. CompareGreaterOrEqualU32,
  42. CompareGreaterU32,
  43. CompareLess,
  44. CompareLessOrEqual,
  45. CompareLessOrEqualU32,
  46. CompareLessU32,
  47. CompareNotEqual,
  48. ConditionalSelect,
  49. ConvertFP32ToFP64,
  50. ConvertFP64ToFP32,
  51. ConvertFPToS32,
  52. ConvertFPToU32,
  53. ConvertS32ToFP,
  54. ConvertU32ToFP,
  55. Copy,
  56. Cosine,
  57. Ddx,
  58. Ddy,
  59. Discard,
  60. Divide,
  61. EmitVertex,
  62. EndPrimitive,
  63. ExponentB2,
  64. FSIBegin,
  65. FSIEnd,
  66. FindFirstSetS32,
  67. FindFirstSetU32,
  68. Floor,
  69. FusedMultiplyAdd,
  70. GroupMemoryBarrier,
  71. ImageLoad,
  72. ImageStore,
  73. ImageAtomic,
  74. IsNan,
  75. LoadAttribute,
  76. LoadConstant,
  77. LoadGlobal,
  78. LoadLocal,
  79. LoadShared,
  80. LoadStorage,
  81. Lod,
  82. LogarithmB2,
  83. LogicalAnd,
  84. LogicalExclusiveOr,
  85. LogicalNot,
  86. LogicalOr,
  87. LoopBreak,
  88. LoopContinue,
  89. MarkLabel,
  90. Maximum,
  91. MaximumU32,
  92. MemoryBarrier,
  93. Minimum,
  94. MinimumU32,
  95. Multiply,
  96. MultiplyHighS32,
  97. MultiplyHighU32,
  98. Negate,
  99. PackDouble2x32,
  100. PackHalf2x16,
  101. ReciprocalSquareRoot,
  102. Return,
  103. Round,
  104. ShiftLeft,
  105. ShiftRightS32,
  106. ShiftRightU32,
  107. Shuffle,
  108. ShuffleDown,
  109. ShuffleUp,
  110. ShuffleXor,
  111. Sine,
  112. SquareRoot,
  113. StoreAttribute,
  114. StoreGlobal,
  115. StoreGlobal16,
  116. StoreGlobal8,
  117. StoreLocal,
  118. StoreShared,
  119. StoreShared16,
  120. StoreShared8,
  121. StoreStorage,
  122. StoreStorage16,
  123. StoreStorage8,
  124. Subtract,
  125. SwizzleAdd,
  126. TextureSample,
  127. TextureSize,
  128. Truncate,
  129. UnpackDouble2x32,
  130. UnpackHalf2x16,
  131. VoteAll,
  132. VoteAllEqual,
  133. VoteAny,
  134. Count,
  135. FP32 = 1 << 16,
  136. FP64 = 1 << 17,
  137. MrShift = 18,
  138. MrGlobal = 0 << MrShift,
  139. MrShared = 1 << MrShift,
  140. MrStorage = 2 << MrShift,
  141. MrMask = 3 << MrShift,
  142. Mask = 0xffff
  143. }
  144. static class InstructionExtensions
  145. {
  146. public static bool IsAtomic(this Instruction inst)
  147. {
  148. switch (inst & Instruction.Mask)
  149. {
  150. case Instruction.AtomicAdd:
  151. case Instruction.AtomicAnd:
  152. case Instruction.AtomicCompareAndSwap:
  153. case Instruction.AtomicMaxS32:
  154. case Instruction.AtomicMaxU32:
  155. case Instruction.AtomicMinS32:
  156. case Instruction.AtomicMinU32:
  157. case Instruction.AtomicOr:
  158. case Instruction.AtomicSwap:
  159. case Instruction.AtomicXor:
  160. return true;
  161. }
  162. return false;
  163. }
  164. public static bool IsTextureQuery(this Instruction inst)
  165. {
  166. inst &= Instruction.Mask;
  167. return inst == Instruction.Lod || inst == Instruction.TextureSize;
  168. }
  169. }
  170. }