diff options
author | bunnei <bunneidev@gmail.com> | 2021-01-23 06:57:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-23 06:57:14 +0100 |
commit | 302a5f00e845cdbf9f95d713e4ab23165d71bdc5 (patch) | |
tree | 32388343658d3f7191e856334de496e2b3cec41e | |
parent | Merge pull request #5765 from ogniK5377/StoreSaveDataThumbnail-stub (diff) | |
parent | Merge remote-tracking branch 'upstream/master' into int-flags (diff) | |
download | yuzu-302a5f00e845cdbf9f95d713e4ab23165d71bdc5.tar yuzu-302a5f00e845cdbf9f95d713e4ab23165d71bdc5.tar.gz yuzu-302a5f00e845cdbf9f95d713e4ab23165d71bdc5.tar.bz2 yuzu-302a5f00e845cdbf9f95d713e4ab23165d71bdc5.tar.lz yuzu-302a5f00e845cdbf9f95d713e4ab23165d71bdc5.tar.xz yuzu-302a5f00e845cdbf9f95d713e4ab23165d71bdc5.tar.zst yuzu-302a5f00e845cdbf9f95d713e4ab23165d71bdc5.zip |
-rw-r--r-- | src/video_core/shader/node.h | 8 | ||||
-rw-r--r-- | src/video_core/shader/shader_ir.cpp | 51 | ||||
-rw-r--r-- | src/video_core/shader/shader_ir.h | 3 |
3 files changed, 59 insertions, 3 deletions
diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h index b54d33763..c9840b75e 100644 --- a/src/video_core/shader/node.h +++ b/src/video_core/shader/node.h @@ -465,6 +465,14 @@ public: return operands.size(); } + NodeBlock& GetOperands() { + return operands; + } + + const NodeBlock& GetOperands() const { + return operands; + } + [[nodiscard]] const Node& operator[](std::size_t operand_index) const { return operands.at(operand_index); } diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp index a4987ffc6..caf5ff362 100644 --- a/src/video_core/shader/shader_ir.cpp +++ b/src/video_core/shader/shader_ir.cpp @@ -388,9 +388,54 @@ void ShaderIR::SetInternalFlagsFromInteger(NodeBlock& bb, Node value, bool sets_ if (!sets_cc) { return; } - Node zerop = Operation(OperationCode::LogicalIEqual, std::move(value), Immediate(0)); - SetInternalFlag(bb, InternalFlag::Zero, std::move(zerop)); - LOG_WARNING(HW_GPU, "Condition codes implementation is incomplete"); + switch (value->index()) { + case 0: // Operation Node + SearchOperands(bb, value); + break; + case 2: // Genral Purpose Node + if (const auto* gpr = std::get_if<GprNode>(value.get())) { + LOG_DEBUG(HW_GPU, "GprNode: index={}", gpr->GetIndex()); + Node zerop = Operation(OperationCode::LogicalIEqual, std::move(value), + Immediate(gpr->GetIndex())); + SetInternalFlag(bb, InternalFlag::Zero, std::move(zerop)); + } + break; + + default: + Node zerop = Operation(OperationCode::LogicalIEqual, std::move(value), Immediate(0)); + SetInternalFlag(bb, InternalFlag::Zero, std::move(zerop)); + LOG_WARNING(HW_GPU, "Node Type: {}", value->index()); + break; + } +} + +void ShaderIR::SearchOperands(NodeBlock& nb, Node var) { + const auto* op = std::get_if<OperationNode>(var.get()); + if (op == nullptr) { + return; + } + + if (op->GetOperandsCount() == 0) { + return; + } + + for (auto& operand : op->GetOperands()) { + switch (operand->index()) { + case 0: // Operation Node + return SearchOperands(nb, operand); + case 2: // General Purpose Node + if (const auto* gpr = std::get_if<GprNode>(operand.get())) { + LOG_DEBUG(HW_GPU, "Child GprNode: index={}", gpr->GetIndex()); + Node zerop = Operation(OperationCode::LogicalIEqual, std::move(operand), + Immediate(gpr->GetIndex())); + SetInternalFlag(nb, InternalFlag::Zero, std::move(zerop)); + } + break; + default: + LOG_WARNING(HW_GPU, "Child Node Type: {}", operand->index()); + break; + } + } } Node ShaderIR::BitfieldExtract(Node value, u32 offset, u32 bits) { diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index 0c6ab0f07..0afa39531 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h @@ -346,6 +346,9 @@ private: /// Access a bindless image sampler. ImageEntry& GetBindlessImage(Tegra::Shader::Register reg, Tegra::Shader::ImageType type); + /// Recursive Iteration over the OperationNode operands, searching for GprNodes. + void SearchOperands(NodeBlock& nb, Node var); + /// Extracts a sequence of bits from a node Node BitfieldExtract(Node value, u32 offset, u32 bits); |