Instruction.cs 3.9 KB

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