summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2018-12-21 02:36:17 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-01-15 21:54:49 +0100
commit4aaa2192b993411f63d46a57b93e9e787b6a836d (patch)
tree879a467c5f3ba30d4417372dda2148011392adc9 /src/video_core/shader
parentshader_ir: Initial implementation (diff)
downloadyuzu-4aaa2192b993411f63d46a57b93e9e787b6a836d.tar
yuzu-4aaa2192b993411f63d46a57b93e9e787b6a836d.tar.gz
yuzu-4aaa2192b993411f63d46a57b93e9e787b6a836d.tar.bz2
yuzu-4aaa2192b993411f63d46a57b93e9e787b6a836d.tar.lz
yuzu-4aaa2192b993411f63d46a57b93e9e787b6a836d.tar.xz
yuzu-4aaa2192b993411f63d46a57b93e9e787b6a836d.tar.zst
yuzu-4aaa2192b993411f63d46a57b93e9e787b6a836d.zip
Diffstat (limited to 'src/video_core/shader')
-rw-r--r--src/video_core/shader/shader_ir.cpp16
-rw-r--r--src/video_core/shader/shader_ir.h19
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) {
return StoreNode(CommentNode(text));
}
+Node ShaderIR::Immediate(u32 value) {
+ return StoreNode(ImmediateNode(value));
+}
+
+Node ShaderIR::GetImmediate19(Instruction instr) {
+ return Immediate(instr.alu.GetImm20_19());
+}
+
+Node ShaderIR::GetImmediate32(Instruction instr) {
+ return Immediate(instr.alu.GetImm20_32());
+}
+
Node ShaderIR::GetPredicate(u64 pred_, bool negated) {
const auto pred = static_cast<Pred>(pred_);
if (pred != Pred::UnusedIndex && pred != Pred::NeverExecute) {
@@ -44,6 +56,10 @@ Node ShaderIR::GetPredicate(u64 pred_, bool negated) {
return StoreNode(PredicateNode(pred, negated));
}
+Node ShaderIR::GetPredicate(bool immediate) {
+ return GetPredicate(static_cast<u64>(immediate ? Pred::UnusedIndex : Pred::NeverExecute));
+}
+
/*static*/ OperationCode ShaderIR::SignedToUnsignedCode(OperationCode operation_code,
bool is_signed) {
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:
Node Conditional(Node condition, std::vector<Node>&& code);
/// Creates a commentary
Node Comment(const std::string& text);
-
+ /// Creates an u32 immediate
+ Node Immediate(u32 value);
+ /// Creates a s32 immediate
+ Node Immediate(s32 value) {
+ return Immediate(static_cast<u32>(value));
+ }
+ /// Creates a f32 immediate
+ Node Immediate(f32 value) {
+ // TODO(Rodrigo): Replace this with bit_cast when C++20 releases
+ return Immediate(*reinterpret_cast<const u32*>(&value));
+ }
+
+ /// Generates a node representing a 19-bit immediate value
+ Node GetImmediate19(Tegra::Shader::Instruction instr);
+ /// Generates a node representing a 32-bit immediate value
+ Node GetImmediate32(Tegra::Shader::Instruction instr);
/// Generates a node for a passed predicate. It can be optionally negated
Node GetPredicate(u64 pred, bool negated = false);
+ /// Generates a predicate node for an immediate true or false value
+ Node GetPredicate(bool immediate);
template <typename... T>
inline Node Operation(OperationCode code, const T*... operands) {