summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-01-04 20:05:17 +0100
committerGitHub <noreply@github.com>2020-01-04 20:05:17 +0100
commitcd0a7dfdbc3ed3ce83a2ad5bb143f46e4f92dfb8 (patch)
treee60c9786f929a2b35c7f23ee7a7dbebcc14eb7a7 /src/video_core/shader
parentMerge pull request #3247 from FernandoS27/remap-fix (diff)
parentShader_IR: Address Feedback (diff)
downloadyuzu-cd0a7dfdbc3ed3ce83a2ad5bb143f46e4f92dfb8.tar
yuzu-cd0a7dfdbc3ed3ce83a2ad5bb143f46e4f92dfb8.tar.gz
yuzu-cd0a7dfdbc3ed3ce83a2ad5bb143f46e4f92dfb8.tar.bz2
yuzu-cd0a7dfdbc3ed3ce83a2ad5bb143f46e4f92dfb8.tar.lz
yuzu-cd0a7dfdbc3ed3ce83a2ad5bb143f46e4f92dfb8.tar.xz
yuzu-cd0a7dfdbc3ed3ce83a2ad5bb143f46e4f92dfb8.tar.zst
yuzu-cd0a7dfdbc3ed3ce83a2ad5bb143f46e4f92dfb8.zip
Diffstat (limited to 'src/video_core/shader')
-rw-r--r--src/video_core/shader/node.h26
-rw-r--r--src/video_core/shader/shader_ir.cpp6
-rw-r--r--src/video_core/shader/shader_ir.h8
3 files changed, 38 insertions, 2 deletions
diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h
index 4d2f4d6a8..4e155542a 100644
--- a/src/video_core/shader/node.h
+++ b/src/video_core/shader/node.h
@@ -392,8 +392,30 @@ struct MetaImage {
using Meta =
std::variant<MetaArithmetic, MetaTexture, MetaImage, MetaStackClass, Tegra::Shader::HalfType>;
+class AmendNode {
+public:
+ std::optional<std::size_t> GetAmendIndex() const {
+ if (amend_index == amend_null_index) {
+ return std::nullopt;
+ }
+ return {amend_index};
+ }
+
+ void SetAmendIndex(std::size_t index) {
+ amend_index = index;
+ }
+
+ void ClearAmend() {
+ amend_index = amend_null_index;
+ }
+
+private:
+ static constexpr std::size_t amend_null_index = 0xFFFFFFFFFFFFFFFFULL;
+ std::size_t amend_index{amend_null_index};
+};
+
/// Holds any kind of operation that can be done in the IR
-class OperationNode final {
+class OperationNode final : public AmendNode {
public:
explicit OperationNode(OperationCode code) : OperationNode(code, Meta{}) {}
@@ -433,7 +455,7 @@ private:
};
/// Encloses inside any kind of node that returns a boolean conditionally-executed code
-class ConditionalNode final {
+class ConditionalNode final : public AmendNode {
public:
explicit ConditionalNode(Node condition, std::vector<Node>&& code)
: condition{std::move(condition)}, code{std::move(code)} {}
diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp
index 1d9825c76..31eecb3f4 100644
--- a/src/video_core/shader/shader_ir.cpp
+++ b/src/video_core/shader/shader_ir.cpp
@@ -446,4 +446,10 @@ Node ShaderIR::BitfieldInsert(Node base, Node insert, u32 offset, u32 bits) {
Immediate(bits));
}
+std::size_t ShaderIR::DeclareAmend(Node new_amend) {
+ const std::size_t id = amend_code.size();
+ amend_code.push_back(new_amend);
+ return id;
+}
+
} // namespace VideoCommon::Shader
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h
index baed06ccd..aacd0a0da 100644
--- a/src/video_core/shader/shader_ir.h
+++ b/src/video_core/shader/shader_ir.h
@@ -176,6 +176,10 @@ public:
/// Returns a condition code evaluated from internal flags
Node GetConditionCode(Tegra::Shader::ConditionCode cc) const;
+ const Node& GetAmendNode(std::size_t index) const {
+ return amend_code[index];
+ }
+
private:
friend class ASTDecoder;
@@ -392,6 +396,9 @@ private:
Tegra::Shader::Instruction instr,
bool is_write);
+ /// Register new amending code and obtain the reference id.
+ std::size_t DeclareAmend(Node new_amend);
+
const ProgramCode& program_code;
const u32 main_offset;
const CompilerSettings settings;
@@ -406,6 +413,7 @@ private:
std::map<u32, NodeBlock> basic_blocks;
NodeBlock global_code;
ASTManager program_manager{true, true};
+ std::vector<Node> amend_code;
std::set<u32> used_registers;
std::set<Tegra::Shader::Pred> used_predicates;