Sfoglia il codice sorgente

shader_ir: Add constant buffer getters

ReinUsesLisp 7 anni fa
parent
commit
864e8f55cf
2 ha cambiato i file con 25 aggiunte e 0 eliminazioni
  1. 21 0
      src/video_core/shader/shader_ir.cpp
  2. 4 0
      src/video_core/shader/shader_ir.h

+ 21 - 0
src/video_core/shader/shader_ir.cpp

@@ -54,6 +54,27 @@ Node ShaderIR::GetImmediate32(Instruction instr) {
     return Immediate(instr.alu.GetImm20_32());
     return Immediate(instr.alu.GetImm20_32());
 }
 }
 
 
+Node ShaderIR::GetConstBuffer(u64 index_, u64 offset_) {
+    const auto index = static_cast<u32>(index_);
+    const auto offset = static_cast<u32>(offset_);
+
+    const auto [entry, is_new] = used_cbufs.try_emplace(index);
+    entry->second.MarkAsUsed(offset);
+
+    return StoreNode(CbufNode(index, Immediate(offset)));
+}
+
+Node ShaderIR::GetConstBufferIndirect(u64 index_, u64 offset_, Node node) {
+    const auto index = static_cast<u32>(index_);
+    const auto offset = static_cast<u32>(offset_);
+
+    const auto [entry, is_new] = used_cbufs.try_emplace(index);
+    entry->second.MarkAsUsedIndirect();
+
+    const Node final_offset = Operation(OperationCode::UAdd, NO_PRECISE, node, Immediate(offset));
+    return StoreNode(CbufNode(index, final_offset));
+}
+
 Node ShaderIR::GetPredicate(u64 pred_, bool negated) {
 Node ShaderIR::GetPredicate(u64 pred_, bool negated) {
     const auto pred = static_cast<Pred>(pred_);
     const auto pred = static_cast<Pred>(pred_);
     if (pred != Pred::UnusedIndex && pred != Pred::NeverExecute) {
     if (pred != Pred::UnusedIndex && pred != Pred::NeverExecute) {

+ 4 - 0
src/video_core/shader/shader_ir.h

@@ -616,6 +616,10 @@ private:
     Node GetImmediate19(Tegra::Shader::Instruction instr);
     Node GetImmediate19(Tegra::Shader::Instruction instr);
     /// Generates a node representing a 32-bit immediate value
     /// Generates a node representing a 32-bit immediate value
     Node GetImmediate32(Tegra::Shader::Instruction instr);
     Node GetImmediate32(Tegra::Shader::Instruction instr);
+    /// Generates a node representing a constant buffer
+    Node GetConstBuffer(u64 index, u64 offset);
+    /// Generates a node representing a constant buffer with a variadic offset
+    Node GetConstBufferIndirect(u64 index, u64 offset, Node node);
     /// Generates a node for a passed predicate. It can be optionally negated
     /// Generates a node for a passed predicate. It can be optionally negated
     Node GetPredicate(u64 pred, bool negated = false);
     Node GetPredicate(u64 pred, bool negated = false);
     /// Generates a predicate node for an immediate true or false value
     /// Generates a predicate node for an immediate true or false value