diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/shader/shader_ir.cpp | 16 | ||||
| -rw-r--r-- | src/video_core/shader/shader_ir.h | 19 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp index db00c8902..c59ecf457 100644 --- a/src/video_core/shader/shader_ir.cpp +++ b/src/video_core/shader/shader_ir.cpp | |||
| @@ -35,6 +35,18 @@ Node ShaderIR::Comment(const std::string& text) { | |||
| 35 | return StoreNode(CommentNode(text)); | 35 | return StoreNode(CommentNode(text)); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | Node ShaderIR::Immediate(u32 value) { | ||
| 39 | return StoreNode(ImmediateNode(value)); | ||
| 40 | } | ||
| 41 | |||
| 42 | Node ShaderIR::GetImmediate19(Instruction instr) { | ||
| 43 | return Immediate(instr.alu.GetImm20_19()); | ||
| 44 | } | ||
| 45 | |||
| 46 | Node ShaderIR::GetImmediate32(Instruction instr) { | ||
| 47 | return Immediate(instr.alu.GetImm20_32()); | ||
| 48 | } | ||
| 49 | |||
| 38 | Node ShaderIR::GetPredicate(u64 pred_, bool negated) { | 50 | Node ShaderIR::GetPredicate(u64 pred_, bool negated) { |
| 39 | const auto pred = static_cast<Pred>(pred_); | 51 | const auto pred = static_cast<Pred>(pred_); |
| 40 | if (pred != Pred::UnusedIndex && pred != Pred::NeverExecute) { | 52 | if (pred != Pred::UnusedIndex && pred != Pred::NeverExecute) { |
| @@ -44,6 +56,10 @@ Node ShaderIR::GetPredicate(u64 pred_, bool negated) { | |||
| 44 | return StoreNode(PredicateNode(pred, negated)); | 56 | return StoreNode(PredicateNode(pred, negated)); |
| 45 | } | 57 | } |
| 46 | 58 | ||
| 59 | Node ShaderIR::GetPredicate(bool immediate) { | ||
| 60 | return GetPredicate(static_cast<u64>(immediate ? Pred::UnusedIndex : Pred::NeverExecute)); | ||
| 61 | } | ||
| 62 | |||
| 47 | /*static*/ OperationCode ShaderIR::SignedToUnsignedCode(OperationCode operation_code, | 63 | /*static*/ OperationCode ShaderIR::SignedToUnsignedCode(OperationCode operation_code, |
| 48 | bool is_signed) { | 64 | bool is_signed) { |
| 49 | if (is_signed) { | 65 | if (is_signed) { |
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index 300cf1083..db06d51ca 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h | |||
| @@ -598,9 +598,26 @@ private: | |||
| 598 | Node Conditional(Node condition, std::vector<Node>&& code); | 598 | Node Conditional(Node condition, std::vector<Node>&& code); |
| 599 | /// Creates a commentary | 599 | /// Creates a commentary |
| 600 | Node Comment(const std::string& text); | 600 | Node Comment(const std::string& text); |
| 601 | 601 | /// Creates an u32 immediate | |
| 602 | Node Immediate(u32 value); | ||
| 603 | /// Creates a s32 immediate | ||
| 604 | Node Immediate(s32 value) { | ||
| 605 | return Immediate(static_cast<u32>(value)); | ||
| 606 | } | ||
| 607 | /// Creates a f32 immediate | ||
| 608 | Node Immediate(f32 value) { | ||
| 609 | // TODO(Rodrigo): Replace this with bit_cast when C++20 releases | ||
| 610 | return Immediate(*reinterpret_cast<const u32*>(&value)); | ||
| 611 | } | ||
| 612 | |||
| 613 | /// Generates a node representing a 19-bit immediate value | ||
| 614 | Node GetImmediate19(Tegra::Shader::Instruction instr); | ||
| 615 | /// Generates a node representing a 32-bit immediate value | ||
| 616 | Node GetImmediate32(Tegra::Shader::Instruction instr); | ||
| 602 | /// Generates a node for a passed predicate. It can be optionally negated | 617 | /// Generates a node for a passed predicate. It can be optionally negated |
| 603 | Node GetPredicate(u64 pred, bool negated = false); | 618 | Node GetPredicate(u64 pred, bool negated = false); |
| 619 | /// Generates a predicate node for an immediate true or false value | ||
| 620 | Node GetPredicate(bool immediate); | ||
| 604 | 621 | ||
| 605 | template <typename... T> | 622 | template <typename... T> |
| 606 | inline Node Operation(OperationCode code, const T*... operands) { | 623 | inline Node Operation(OperationCode code, const T*... operands) { |