emit_glsl_composite.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. // Copyright 2021 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <string_view>
  5. #include "shader_recompiler/backend/glsl/emit_context.h"
  6. #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h"
  7. #include "shader_recompiler/frontend/ir/value.h"
  8. #include "shader_recompiler/profile.h"
  9. namespace Shader::Backend::GLSL {
  10. static constexpr std::string_view SWIZZLE{"xyzw"};
  11. void EmitCompositeConstructU32x2(EmitContext& ctx, IR::Inst& inst, std::string_view e1,
  12. std::string_view e2) {
  13. ctx.AddU32x2("{}=uvec2({},{});", inst, e1, e2);
  14. }
  15. void EmitCompositeConstructU32x3([[maybe_unused]] EmitContext& ctx,
  16. [[maybe_unused]] std::string_view e1,
  17. [[maybe_unused]] std::string_view e2,
  18. [[maybe_unused]] std::string_view e3) {
  19. throw NotImplementedException("GLSL Instruction");
  20. }
  21. void EmitCompositeConstructU32x4([[maybe_unused]] EmitContext& ctx,
  22. [[maybe_unused]] std::string_view e1,
  23. [[maybe_unused]] std::string_view e2,
  24. [[maybe_unused]] std::string_view e3,
  25. [[maybe_unused]] std::string_view e4) {
  26. throw NotImplementedException("GLSL Instruction");
  27. }
  28. void EmitCompositeExtractU32x2(EmitContext& ctx, IR::Inst& inst, std::string_view composite,
  29. u32 index) {
  30. ctx.AddU32("{}={}.{};", inst, composite, SWIZZLE[index]);
  31. }
  32. void EmitCompositeExtractU32x3([[maybe_unused]] EmitContext& ctx,
  33. [[maybe_unused]] std::string_view composite,
  34. [[maybe_unused]] u32 index) {
  35. throw NotImplementedException("GLSL Instruction");
  36. }
  37. void EmitCompositeExtractU32x4([[maybe_unused]] EmitContext& ctx,
  38. [[maybe_unused]] std::string_view composite,
  39. [[maybe_unused]] u32 index) {
  40. throw NotImplementedException("GLSL Instruction");
  41. }
  42. void EmitCompositeInsertU32x2([[maybe_unused]] EmitContext& ctx,
  43. [[maybe_unused]] std::string_view composite,
  44. [[maybe_unused]] std::string_view object,
  45. [[maybe_unused]] u32 index) {
  46. throw NotImplementedException("GLSL Instruction");
  47. }
  48. void EmitCompositeInsertU32x3([[maybe_unused]] EmitContext& ctx,
  49. [[maybe_unused]] std::string_view composite,
  50. [[maybe_unused]] std::string_view object,
  51. [[maybe_unused]] u32 index) {
  52. throw NotImplementedException("GLSL Instruction");
  53. }
  54. void EmitCompositeInsertU32x4([[maybe_unused]] EmitContext& ctx,
  55. [[maybe_unused]] std::string_view composite,
  56. [[maybe_unused]] std::string_view object,
  57. [[maybe_unused]] u32 index) {
  58. throw NotImplementedException("GLSL Instruction");
  59. }
  60. void EmitCompositeConstructF16x2([[maybe_unused]] EmitContext& ctx,
  61. [[maybe_unused]] std::string_view e1,
  62. [[maybe_unused]] std::string_view e2) {
  63. throw NotImplementedException("GLSL Instruction");
  64. }
  65. void EmitCompositeConstructF16x3([[maybe_unused]] EmitContext& ctx,
  66. [[maybe_unused]] std::string_view e1,
  67. [[maybe_unused]] std::string_view e2,
  68. [[maybe_unused]] std::string_view e3) {
  69. throw NotImplementedException("GLSL Instruction");
  70. }
  71. void EmitCompositeConstructF16x4([[maybe_unused]] EmitContext& ctx,
  72. [[maybe_unused]] std::string_view e1,
  73. [[maybe_unused]] std::string_view e2,
  74. [[maybe_unused]] std::string_view e3,
  75. [[maybe_unused]] std::string_view e4) {
  76. throw NotImplementedException("GLSL Instruction");
  77. }
  78. void EmitCompositeExtractF16x2([[maybe_unused]] EmitContext& ctx,
  79. [[maybe_unused]] std::string_view composite,
  80. [[maybe_unused]] u32 index) {
  81. throw NotImplementedException("GLSL Instruction");
  82. }
  83. void EmitCompositeExtractF16x3([[maybe_unused]] EmitContext& ctx,
  84. [[maybe_unused]] std::string_view composite,
  85. [[maybe_unused]] u32 index) {
  86. throw NotImplementedException("GLSL Instruction");
  87. }
  88. void EmitCompositeExtractF16x4([[maybe_unused]] EmitContext& ctx,
  89. [[maybe_unused]] std::string_view composite,
  90. [[maybe_unused]] u32 index) {
  91. throw NotImplementedException("GLSL Instruction");
  92. }
  93. void EmitCompositeInsertF16x2([[maybe_unused]] EmitContext& ctx,
  94. [[maybe_unused]] std::string_view composite,
  95. [[maybe_unused]] std::string_view object,
  96. [[maybe_unused]] u32 index) {
  97. throw NotImplementedException("GLSL Instruction");
  98. }
  99. void EmitCompositeInsertF16x3([[maybe_unused]] EmitContext& ctx,
  100. [[maybe_unused]] std::string_view composite,
  101. [[maybe_unused]] std::string_view object,
  102. [[maybe_unused]] u32 index) {
  103. throw NotImplementedException("GLSL Instruction");
  104. }
  105. void EmitCompositeInsertF16x4([[maybe_unused]] EmitContext& ctx,
  106. [[maybe_unused]] std::string_view composite,
  107. [[maybe_unused]] std::string_view object,
  108. [[maybe_unused]] u32 index) {
  109. throw NotImplementedException("GLSL Instruction");
  110. }
  111. void EmitCompositeConstructF32x2(EmitContext& ctx, IR::Inst& inst, std::string_view e1,
  112. std::string_view e2) {
  113. ctx.AddF32x2("{}=vec2({},{});", inst, e1, e2);
  114. }
  115. void EmitCompositeConstructF32x3([[maybe_unused]] EmitContext& ctx,
  116. [[maybe_unused]] std::string_view e1,
  117. [[maybe_unused]] std::string_view e2,
  118. [[maybe_unused]] std::string_view e3) {
  119. throw NotImplementedException("GLSL Instruction");
  120. }
  121. void EmitCompositeConstructF32x4([[maybe_unused]] EmitContext& ctx,
  122. [[maybe_unused]] std::string_view e1,
  123. [[maybe_unused]] std::string_view e2,
  124. [[maybe_unused]] std::string_view e3,
  125. [[maybe_unused]] std::string_view e4) {
  126. throw NotImplementedException("GLSL Instruction");
  127. }
  128. void EmitCompositeExtractF32x2(EmitContext& ctx, IR::Inst& inst, std::string_view composite,
  129. u32 index) {
  130. ctx.AddF32("{}={}.{};", inst, composite, SWIZZLE[index]);
  131. }
  132. void EmitCompositeExtractF32x3(EmitContext& ctx, IR::Inst& inst, std::string_view composite,
  133. u32 index) {
  134. ctx.AddF32("{}={}.{};", inst, composite, SWIZZLE[index]);
  135. }
  136. void EmitCompositeExtractF32x4(EmitContext& ctx, IR::Inst& inst, std::string_view composite,
  137. u32 index) {
  138. ctx.AddF32("{}={}.{};", inst, composite, SWIZZLE[index]);
  139. }
  140. void EmitCompositeInsertF32x2([[maybe_unused]] EmitContext& ctx,
  141. [[maybe_unused]] std::string_view composite,
  142. [[maybe_unused]] std::string_view object,
  143. [[maybe_unused]] u32 index) {
  144. throw NotImplementedException("GLSL Instruction");
  145. }
  146. void EmitCompositeInsertF32x3([[maybe_unused]] EmitContext& ctx,
  147. [[maybe_unused]] std::string_view composite,
  148. [[maybe_unused]] std::string_view object,
  149. [[maybe_unused]] u32 index) {
  150. throw NotImplementedException("GLSL Instruction");
  151. }
  152. void EmitCompositeInsertF32x4([[maybe_unused]] EmitContext& ctx,
  153. [[maybe_unused]] std::string_view composite,
  154. [[maybe_unused]] std::string_view object,
  155. [[maybe_unused]] u32 index) {
  156. throw NotImplementedException("GLSL Instruction");
  157. }
  158. void EmitCompositeConstructF64x2([[maybe_unused]] EmitContext& ctx) {
  159. throw NotImplementedException("GLSL Instruction");
  160. }
  161. void EmitCompositeConstructF64x3([[maybe_unused]] EmitContext& ctx) {
  162. throw NotImplementedException("GLSL Instruction");
  163. }
  164. void EmitCompositeConstructF64x4([[maybe_unused]] EmitContext& ctx) {
  165. throw NotImplementedException("GLSL Instruction");
  166. }
  167. void EmitCompositeExtractF64x2([[maybe_unused]] EmitContext& ctx) {
  168. throw NotImplementedException("GLSL Instruction");
  169. }
  170. void EmitCompositeExtractF64x3([[maybe_unused]] EmitContext& ctx) {
  171. throw NotImplementedException("GLSL Instruction");
  172. }
  173. void EmitCompositeExtractF64x4([[maybe_unused]] EmitContext& ctx) {
  174. throw NotImplementedException("GLSL Instruction");
  175. }
  176. void EmitCompositeInsertF64x2([[maybe_unused]] EmitContext& ctx,
  177. [[maybe_unused]] std::string_view composite,
  178. [[maybe_unused]] std::string_view object,
  179. [[maybe_unused]] u32 index) {
  180. throw NotImplementedException("GLSL Instruction");
  181. }
  182. void EmitCompositeInsertF64x3([[maybe_unused]] EmitContext& ctx,
  183. [[maybe_unused]] std::string_view composite,
  184. [[maybe_unused]] std::string_view object,
  185. [[maybe_unused]] u32 index) {
  186. throw NotImplementedException("GLSL Instruction");
  187. }
  188. void EmitCompositeInsertF64x4([[maybe_unused]] EmitContext& ctx,
  189. [[maybe_unused]] std::string_view composite,
  190. [[maybe_unused]] std::string_view object,
  191. [[maybe_unused]] u32 index) {
  192. throw NotImplementedException("GLSL Instruction");
  193. }
  194. } // namespace Shader::Backend::GLSL