patch.cpp 825 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2021 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "shader_recompiler/frontend/ir/patch.h"
  5. #include "shader_recompiler/exception.h"
  6. namespace Shader::IR {
  7. bool IsGeneric(Patch patch) noexcept {
  8. return patch >= Patch::Component0 && patch <= Patch::Component119;
  9. }
  10. u32 GenericPatchIndex(Patch patch) {
  11. if (!IsGeneric(patch)) {
  12. throw InvalidArgument("Patch {} is not generic", patch);
  13. }
  14. return (static_cast<u32>(patch) - static_cast<u32>(Patch::Component0)) / 4;
  15. }
  16. u32 GenericPatchElement(Patch patch) {
  17. if (!IsGeneric(patch)) {
  18. throw InvalidArgument("Patch {} is not generic", patch);
  19. }
  20. return (static_cast<u32>(patch) - static_cast<u32>(Patch::Component0)) % 4;
  21. }
  22. } // namespace Shader::IR