diff options
author | Feng Chen <vonchenplus@gmail.com> | 2021-09-03 17:52:20 +0200 |
---|---|---|
committer | Feng Chen <vonchenplus@gmail.com> | 2021-09-03 17:52:20 +0200 |
commit | a7bbaa489755c9847416c8c96f0eefb9e78a50a0 (patch) | |
tree | 341ab621a49becca148157877d6e57e2a31ba770 /src/shader_recompiler/frontend | |
parent | Fix create GraphicsPipelines crash (diff) | |
download | yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.tar yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.tar.gz yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.tar.bz2 yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.tar.lz yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.tar.xz yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.tar.zst yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.zip |
Diffstat (limited to 'src/shader_recompiler/frontend')
-rw-r--r-- | src/shader_recompiler/frontend/ir/attribute.cpp | 14 | ||||
-rw-r--r-- | src/shader_recompiler/frontend/ir/attribute.h | 6 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/shader_recompiler/frontend/ir/attribute.cpp b/src/shader_recompiler/frontend/ir/attribute.cpp index dc2bec06d..5b3694f65 100644 --- a/src/shader_recompiler/frontend/ir/attribute.cpp +++ b/src/shader_recompiler/frontend/ir/attribute.cpp @@ -9,11 +9,21 @@ namespace Shader::IR { -u32 TxtCoordAttributeIndex(Attribute attribute) { +bool IsFixedFncTexture(Attribute attribute) { + return attribute >= Attribute::FixedFncTexture0S && attribute <= Attribute::FixedFncTexture9Q; +} + +u32 FixedFncTextureAttributeIndex(Attribute attribute) { + if (!IsFixedFncTexture(attribute)) { + throw InvalidArgument("Attribute is not fixedfnctexture {}", attribute); + } return (static_cast<u32>(attribute) - static_cast<u32>(Attribute::FixedFncTexture0S)) / 4u; } -u32 TxtCoordAttributeElement(Attribute attribute) { +u32 FixedFncTextureAttributeElement(Attribute attribute) { + if (!IsFixedFncTexture(attribute)) { + throw InvalidArgument("Attribute is not fixedfnctexture {}", attribute); + } return static_cast<u32>(attribute) % 4; } diff --git a/src/shader_recompiler/frontend/ir/attribute.h b/src/shader_recompiler/frontend/ir/attribute.h index 6957fb43b..3f07fd7ac 100644 --- a/src/shader_recompiler/frontend/ir/attribute.h +++ b/src/shader_recompiler/frontend/ir/attribute.h @@ -222,12 +222,12 @@ enum class Attribute : u64 { FrontFace = 255, }; -constexpr size_t NUM_TXT_COORD = 10; +constexpr size_t NUM_FIXEDFNCTEXTURE = 10; constexpr size_t NUM_GENERICS = 32; -[[nodiscard]] u32 TxtCoordAttributeIndex(Attribute attribute); +[[nodiscard]] u32 FixedFncTextureAttributeIndex(Attribute attribute); -[[nodiscard]] u32 TxtCoordAttributeElement(Attribute attribute); +[[nodiscard]] u32 FixedFncTextureAttributeElement(Attribute attribute); [[nodiscard]] bool IsGeneric(Attribute attribute) noexcept; |