Instruction.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. Load,
  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. Modulo,
  96. Multiply,
  97. MultiplyHighS32,
  98. MultiplyHighU32,
  99. Negate,
  100. PackDouble2x32,
  101. PackHalf2x16,
  102. ReciprocalSquareRoot,
  103. Return,
  104. Round,
  105. ShiftLeft,
  106. ShiftRightS32,
  107. ShiftRightU32,
  108. Shuffle,
  109. ShuffleDown,
  110. ShuffleUp,
  111. ShuffleXor,
  112. Sine,
  113. SquareRoot,
  114. Store,
  115. Subtract,
  116. SwizzleAdd,
  117. TextureSample,
  118. TextureSize,
  119. Truncate,
  120. UnpackDouble2x32,
  121. UnpackHalf2x16,
  122. VectorExtract,
  123. VoteAll,
  124. VoteAllEqual,
  125. VoteAny,
  126. Count,
  127. FP32 = 1 << 16,
  128. FP64 = 1 << 17,
  129. Mask = 0xffff
  130. }
  131. static class InstructionExtensions
  132. {
  133. public static bool IsAtomic(this Instruction inst)
  134. {
  135. switch (inst & Instruction.Mask)
  136. {
  137. case Instruction.AtomicAdd:
  138. case Instruction.AtomicAnd:
  139. case Instruction.AtomicCompareAndSwap:
  140. case Instruction.AtomicMaxS32:
  141. case Instruction.AtomicMaxU32:
  142. case Instruction.AtomicMinS32:
  143. case Instruction.AtomicMinU32:
  144. case Instruction.AtomicOr:
  145. case Instruction.AtomicSwap:
  146. case Instruction.AtomicXor:
  147. return true;
  148. }
  149. return false;
  150. }
  151. public static bool IsTextureQuery(this Instruction inst)
  152. {
  153. inst &= Instruction.Mask;
  154. return inst == Instruction.Lod || inst == Instruction.TextureSize;
  155. }
  156. }
  157. }