From 080857b60e78836901cf6e9601f48613812fcd04 Mon Sep 17 00:00:00 2001
From: FernandoS27 <fsahmkow27@gmail.com>
Date: Sat, 17 Apr 2021 12:51:43 +0200
Subject: shader: Add coarse derivatives

---
 src/shader_recompiler/frontend/ir/ir_emitter.cpp | 8 ++++++++
 src/shader_recompiler/frontend/ir/ir_emitter.h   | 4 ++++
 src/shader_recompiler/frontend/ir/opcodes.inc    | 2 ++
 3 files changed, 14 insertions(+)

(limited to 'src/shader_recompiler/frontend/ir')

diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
index 845a57b1e9..b3c9fe72a6 100644
--- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp
+++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
@@ -1933,4 +1933,12 @@ F32 IREmitter::DPdyFine(const F32& a) {
     return Inst<F32>(Opcode::DPdyFine, a);
 }
 
+F32 IREmitter::DPdxCoarse(const F32& a) {
+    return Inst<F32>(Opcode::DPdxCoarse, a);
+}
+
+F32 IREmitter::DPdyCoarse(const F32& a) {
+    return Inst<F32>(Opcode::DPdyCoarse, a);
+}
+
 } // namespace Shader::IR
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h
index c7101d668d..4441c495d3 100644
--- a/src/shader_recompiler/frontend/ir/ir_emitter.h
+++ b/src/shader_recompiler/frontend/ir/ir_emitter.h
@@ -357,6 +357,10 @@ public:
 
     [[nodiscard]] F32 DPdyFine(const F32& a);
 
+    [[nodiscard]] F32 DPdxCoarse(const F32& a);
+
+    [[nodiscard]] F32 DPdyCoarse(const F32& a);
+
 private:
     IR::Block::iterator insertion_point;
 
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc
index e4cb8964ad..b6869d4e46 100644
--- a/src/shader_recompiler/frontend/ir/opcodes.inc
+++ b/src/shader_recompiler/frontend/ir/opcodes.inc
@@ -513,3 +513,5 @@ OPCODE(ShuffleButterfly,                                    U32,            U32,
 OPCODE(FSwizzleAdd,                                         F32,            F32,            F32,            U32,                                            )
 OPCODE(DPdxFine,                                            F32,            F32,                                                                            )
 OPCODE(DPdyFine,                                            F32,            F32,                                                                            )
+OPCODE(DPdxCoarse,                                          F32,            F32,                                                                            )
+OPCODE(DPdyCoarse,                                          F32,            F32,                                                                            )
-- 
cgit v1.2.3-70-g09d2