summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2018-12-20 22:45:34 -0300
committerGravatar ReinUsesLisp2019-01-15 17:54:49 -0300
commit15f431f0cb9f8d9d142ce631c59335ca99eb9ab4 (patch)
treec3302bb20bd5311d10612e1e254444f15bf60543 /src
parentshader_ir: Add constant buffer getters (diff)
downloadyuzu-15f431f0cb9f8d9d142ce631c59335ca99eb9ab4.tar.gz
yuzu-15f431f0cb9f8d9d142ce631c59335ca99eb9ab4.tar.xz
yuzu-15f431f0cb9f8d9d142ce631c59335ca99eb9ab4.zip
shader_ir: Add attribute getters
Diffstat (limited to 'src')
-rw-r--r--src/video_core/shader/shader_ir.cpp21
-rw-r--r--src/video_core/shader/shader_ir.h5
2 files changed, 26 insertions, 0 deletions
diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp
index 3bc9f72f5..0c814fc80 100644
--- a/src/video_core/shader/shader_ir.cpp
+++ b/src/video_core/shader/shader_ir.cpp
@@ -88,6 +88,27 @@ Node ShaderIR::GetPredicate(bool immediate) {
88 return GetPredicate(static_cast<u64>(immediate ? Pred::UnusedIndex : Pred::NeverExecute)); 88 return GetPredicate(static_cast<u64>(immediate ? Pred::UnusedIndex : Pred::NeverExecute));
89} 89}
90 90
91Node ShaderIR::GetInputAttribute(Attribute::Index index, u64 element,
92 const Tegra::Shader::IpaMode& input_mode, Node buffer) {
93 const auto [entry, is_new] =
94 used_input_attributes.emplace(std::make_pair(index, std::set<Tegra::Shader::IpaMode>{}));
95 entry->second.insert(input_mode);
96
97 return StoreNode(AbufNode(index, static_cast<u32>(element), input_mode, buffer));
98}
99
100Node ShaderIR::GetOutputAttribute(Attribute::Index index, u64 element, Node buffer) {
101 if (index == Attribute::Index::ClipDistances0123 ||
102 index == Attribute::Index::ClipDistances4567) {
103 const auto clip_index =
104 static_cast<u32>((index == Attribute::Index::ClipDistances4567 ? 1 : 0) + element);
105 used_clip_distances.at(clip_index) = true;
106 }
107 used_output_attributes.insert(index);
108
109 return StoreNode(AbufNode(index, static_cast<u32>(element), buffer));
110}
111
91/*static*/ OperationCode ShaderIR::SignedToUnsignedCode(OperationCode operation_code, 112/*static*/ OperationCode ShaderIR::SignedToUnsignedCode(OperationCode operation_code,
92 bool is_signed) { 113 bool is_signed) {
93 if (is_signed) { 114 if (is_signed) {
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h
index 4e786a344..fde1594aa 100644
--- a/src/video_core/shader/shader_ir.h
+++ b/src/video_core/shader/shader_ir.h
@@ -624,6 +624,11 @@ private:
624 Node GetPredicate(u64 pred, bool negated = false); 624 Node GetPredicate(u64 pred, bool negated = false);
625 /// Generates a predicate node for an immediate true or false value 625 /// Generates a predicate node for an immediate true or false value
626 Node GetPredicate(bool immediate); 626 Node GetPredicate(bool immediate);
627 /// Generates a node representing an input atttribute. Keeps track of used attributes.
628 Node GetInputAttribute(Tegra::Shader::Attribute::Index index, u64 element,
629 const Tegra::Shader::IpaMode& input_mode, Node buffer = {});
630 /// Generates a node representing an output atttribute. Keeps track of used attributes.
631 Node GetOutputAttribute(Tegra::Shader::Attribute::Index index, u64 element, Node buffer);
627 632
628 template <typename... T> 633 template <typename... T>
629 inline Node Operation(OperationCode code, const T*... operands) { 634 inline Node Operation(OperationCode code, const T*... operands) {