Instruction.cs 4.0 KB

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