emit_glsl_select.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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/frontend/ir/value.h"
  7. namespace Shader::Backend::GLSL {
  8. void EmitSelectU1(EmitContext& ctx, IR::Inst& inst, std::string_view cond,
  9. std::string_view true_value, std::string_view false_value) {
  10. ctx.AddU1("{}={}?{}:{};", inst, cond, true_value, false_value);
  11. }
  12. void EmitSelectU8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view cond,
  13. [[maybe_unused]] std::string_view true_value,
  14. [[maybe_unused]] std::string_view false_value) {
  15. throw NotImplementedException("GLSL Instruction");
  16. }
  17. void EmitSelectU16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view cond,
  18. [[maybe_unused]] std::string_view true_value,
  19. [[maybe_unused]] std::string_view false_value) {
  20. throw NotImplementedException("GLSL Instruction");
  21. }
  22. void EmitSelectU32(EmitContext& ctx, IR::Inst& inst, std::string_view cond,
  23. std::string_view true_value, std::string_view false_value) {
  24. ctx.AddU32("{}={}?{}:{};", inst, cond, true_value, false_value);
  25. }
  26. void EmitSelectU64(EmitContext& ctx, IR::Inst& inst, std::string_view cond,
  27. std::string_view true_value, std::string_view false_value) {
  28. ctx.AddU64("{}={}?{}:{};", inst, cond, true_value, false_value);
  29. }
  30. void EmitSelectF16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view cond,
  31. [[maybe_unused]] std::string_view true_value,
  32. [[maybe_unused]] std::string_view false_value) {
  33. throw NotImplementedException("GLSL Instruction");
  34. }
  35. void EmitSelectF32(EmitContext& ctx, IR::Inst& inst, std::string_view cond,
  36. std::string_view true_value, std::string_view false_value) {
  37. ctx.AddF32("{}={}?{}:{};", inst, cond, true_value, false_value);
  38. }
  39. void EmitSelectF64(EmitContext& ctx, IR::Inst& inst, std::string_view cond,
  40. std::string_view true_value, std::string_view false_value) {
  41. ctx.AddF64("{}={}?{}:{};", inst, cond, true_value, false_value);
  42. }
  43. } // namespace Shader::Backend::GLSL