Instruction.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. ConvertFP32ToS32,
  52. ConvertFP32ToU32,
  53. ConvertFP64ToS32,
  54. ConvertFP64ToU32,
  55. ConvertS32ToFP32,
  56. ConvertS32ToFP64,
  57. ConvertU32ToFP32,
  58. ConvertU32ToFP64,
  59. Copy,
  60. Cosine,
  61. Ddx,
  62. Ddy,
  63. Discard,
  64. Divide,
  65. EmitVertex,
  66. EndPrimitive,
  67. ExponentB2,
  68. FSIBegin,
  69. FSIEnd,
  70. FindFirstSetS32,
  71. FindFirstSetU32,
  72. Floor,
  73. FusedMultiplyAdd,
  74. GroupMemoryBarrier,
  75. ImageLoad,
  76. ImageStore,
  77. ImageAtomic,
  78. IsNan,
  79. LoadAttribute,
  80. LoadConstant,
  81. LoadGlobal,
  82. LoadLocal,
  83. LoadShared,
  84. LoadStorage,
  85. Lod,
  86. LogarithmB2,
  87. LogicalAnd,
  88. LogicalExclusiveOr,
  89. LogicalNot,
  90. LogicalOr,
  91. LoopBreak,
  92. LoopContinue,
  93. MarkLabel,
  94. Maximum,
  95. MaximumU32,
  96. MemoryBarrier,
  97. Minimum,
  98. MinimumU32,
  99. Multiply,
  100. MultiplyHighS32,
  101. MultiplyHighU32,
  102. Negate,
  103. PackDouble2x32,
  104. PackHalf2x16,
  105. ReciprocalSquareRoot,
  106. Return,
  107. Round,
  108. ShiftLeft,
  109. ShiftRightS32,
  110. ShiftRightU32,
  111. Shuffle,
  112. ShuffleDown,
  113. ShuffleUp,
  114. ShuffleXor,
  115. Sine,
  116. SquareRoot,
  117. StoreAttribute,
  118. StoreGlobal,
  119. StoreGlobal16,
  120. StoreGlobal8,
  121. StoreLocal,
  122. StoreShared,
  123. StoreShared16,
  124. StoreShared8,
  125. StoreStorage,
  126. StoreStorage16,
  127. StoreStorage8,
  128. Subtract,
  129. SwizzleAdd,
  130. TextureSample,
  131. TextureSize,
  132. Truncate,
  133. UnpackDouble2x32,
  134. UnpackHalf2x16,
  135. VoteAll,
  136. VoteAllEqual,
  137. VoteAny,
  138. Count,
  139. FP32 = 1 << 16,
  140. FP64 = 1 << 17,
  141. MrShift = 18,
  142. MrGlobal = 0 << MrShift,
  143. MrShared = 1 << MrShift,
  144. MrStorage = 2 << MrShift,
  145. MrMask = 3 << MrShift,
  146. Mask = 0xffff
  147. }
  148. static class InstructionExtensions
  149. {
  150. public static bool IsAtomic(this Instruction inst)
  151. {
  152. switch (inst & Instruction.Mask)
  153. {
  154. case Instruction.AtomicAdd:
  155. case Instruction.AtomicAnd:
  156. case Instruction.AtomicCompareAndSwap:
  157. case Instruction.AtomicMaxS32:
  158. case Instruction.AtomicMaxU32:
  159. case Instruction.AtomicMinS32:
  160. case Instruction.AtomicMinU32:
  161. case Instruction.AtomicOr:
  162. case Instruction.AtomicSwap:
  163. case Instruction.AtomicXor:
  164. return true;
  165. }
  166. return false;
  167. }
  168. public static bool IsTextureQuery(this Instruction inst)
  169. {
  170. inst &= Instruction.Mask;
  171. return inst == Instruction.Lod || inst == Instruction.TextureSize;
  172. }
  173. }
  174. }