This repository has been archived on 2024-03-23. You can view files and clone it, but cannot push or open issues or pull requests.
2022-04-23 08:59:50 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2021-04-16 01:46:11 +00:00
|
|
|
|
|
|
|
#include "shader_recompiler/exception.h"
|
2021-05-25 21:58:52 +00:00
|
|
|
#include "shader_recompiler/frontend/ir/patch.h"
|
2021-04-16 01:46:11 +00:00
|
|
|
|
|
|
|
namespace Shader::IR {
|
|
|
|
|
|
|
|
bool IsGeneric(Patch patch) noexcept {
|
|
|
|
return patch >= Patch::Component0 && patch <= Patch::Component119;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GenericPatchIndex(Patch patch) {
|
|
|
|
if (!IsGeneric(patch)) {
|
|
|
|
throw InvalidArgument("Patch {} is not generic", patch);
|
|
|
|
}
|
|
|
|
return (static_cast<u32>(patch) - static_cast<u32>(Patch::Component0)) / 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GenericPatchElement(Patch patch) {
|
|
|
|
if (!IsGeneric(patch)) {
|
|
|
|
throw InvalidArgument("Patch {} is not generic", patch);
|
|
|
|
}
|
|
|
|
return (static_cast<u32>(patch) - static_cast<u32>(Patch::Component0)) % 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Shader::IR
|