emit_spirv_control_flow.cpp 946 B

123456789101112131415161718192021222324252627
  1. // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "shader_recompiler/backend/spirv/emit_spirv_instructions.h"
  4. #include "shader_recompiler/backend/spirv/spirv_emit_context.h"
  5. namespace Shader::Backend::SPIRV {
  6. void EmitJoin(EmitContext&) {
  7. throw NotImplementedException("Join shouldn't be emitted");
  8. }
  9. void EmitDemoteToHelperInvocation(EmitContext& ctx) {
  10. if (ctx.profile.support_demote_to_helper_invocation) {
  11. ctx.OpDemoteToHelperInvocation();
  12. } else {
  13. const Id kill_label{ctx.OpLabel()};
  14. const Id impossible_label{ctx.OpLabel()};
  15. ctx.OpSelectionMerge(impossible_label, spv::SelectionControlMask::MaskNone);
  16. ctx.OpBranchConditional(ctx.true_value, kill_label, impossible_label);
  17. ctx.AddLabel(kill_label);
  18. ctx.OpKill();
  19. ctx.AddLabel(impossible_label);
  20. }
  21. }
  22. } // namespace Shader::Backend::SPIRV