summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/ir
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-04-12 19:41:22 -0300
committerGravatar ameerj2021-07-22 21:51:27 -0400
commitf263760c5a3aff771123b32b15677e1f7a089640 (patch)
tree3d9c41ce708beb8a76f28ceee1c9ebb25108a471 /src/shader_recompiler/frontend/ir
parentshader: Implement OUT (diff)
downloadyuzu-f263760c5a3aff771123b32b15677e1f7a089640.tar.gz
yuzu-f263760c5a3aff771123b32b15677e1f7a089640.tar.xz
yuzu-f263760c5a3aff771123b32b15677e1f7a089640.zip
shader: Implement geometry shaders
Diffstat (limited to 'src/shader_recompiler/frontend/ir')
-rw-r--r--src/shader_recompiler/frontend/ir/ir_emitter.cpp20
-rw-r--r--src/shader_recompiler/frontend/ir/ir_emitter.h6
-rw-r--r--src/shader_recompiler/frontend/ir/opcodes.inc8
-rw-r--r--src/shader_recompiler/frontend/ir/program.h4
4 files changed, 26 insertions, 12 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
index 7d48fa1ba..d66eb17a6 100644
--- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp
+++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
@@ -308,19 +308,27 @@ U1 IREmitter::GetFlowTestResult(FlowTest test) {
308} 308}
309 309
310F32 IREmitter::GetAttribute(IR::Attribute attribute) { 310F32 IREmitter::GetAttribute(IR::Attribute attribute) {
311 return Inst<F32>(Opcode::GetAttribute, attribute); 311 return GetAttribute(attribute, Imm32(0));
312} 312}
313 313
314void IREmitter::SetAttribute(IR::Attribute attribute, const F32& value) { 314F32 IREmitter::GetAttribute(IR::Attribute attribute, const U32& vertex) {
315 Inst(Opcode::SetAttribute, attribute, value); 315 return Inst<F32>(Opcode::GetAttribute, attribute, vertex);
316}
317
318void IREmitter::SetAttribute(IR::Attribute attribute, const F32& value, const U32& vertex) {
319 Inst(Opcode::SetAttribute, attribute, value, vertex);
316} 320}
317 321
318F32 IREmitter::GetAttributeIndexed(const U32& phys_address) { 322F32 IREmitter::GetAttributeIndexed(const U32& phys_address) {
319 return Inst<F32>(Opcode::GetAttributeIndexed, phys_address); 323 return GetAttributeIndexed(phys_address, Imm32(0));
324}
325
326F32 IREmitter::GetAttributeIndexed(const U32& phys_address, const U32& vertex) {
327 return Inst<F32>(Opcode::GetAttributeIndexed, phys_address, vertex);
320} 328}
321 329
322void IREmitter::SetAttributeIndexed(const U32& phys_address, const F32& value) { 330void IREmitter::SetAttributeIndexed(const U32& phys_address, const F32& value, const U32& vertex) {
323 Inst(Opcode::SetAttributeIndexed, phys_address, value); 331 Inst(Opcode::SetAttributeIndexed, phys_address, value, vertex);
324} 332}
325 333
326void IREmitter::SetFragColor(u32 index, u32 component, const F32& value) { 334void IREmitter::SetFragColor(u32 index, u32 component, const F32& value) {
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h
index 033c4332e..e70359eb1 100644
--- a/src/shader_recompiler/frontend/ir/ir_emitter.h
+++ b/src/shader_recompiler/frontend/ir/ir_emitter.h
@@ -77,10 +77,12 @@ public:
77 [[nodiscard]] U1 GetFlowTestResult(FlowTest test); 77 [[nodiscard]] U1 GetFlowTestResult(FlowTest test);
78 78
79 [[nodiscard]] F32 GetAttribute(IR::Attribute attribute); 79 [[nodiscard]] F32 GetAttribute(IR::Attribute attribute);
80 void SetAttribute(IR::Attribute attribute, const F32& value); 80 [[nodiscard]] F32 GetAttribute(IR::Attribute attribute, const U32& vertex);
81 void SetAttribute(IR::Attribute attribute, const F32& value, const U32& vertex);
81 82
82 [[nodiscard]] F32 GetAttributeIndexed(const U32& phys_address); 83 [[nodiscard]] F32 GetAttributeIndexed(const U32& phys_address);
83 void SetAttributeIndexed(const U32& phys_address, const F32& value); 84 [[nodiscard]] F32 GetAttributeIndexed(const U32& phys_address, const U32& vertex);
85 void SetAttributeIndexed(const U32& phys_address, const F32& value, const U32& vertex);
84 86
85 void SetFragColor(u32 index, u32 component, const F32& value); 87 void SetFragColor(u32 index, u32 component, const F32& value);
86 void SetFragDepth(const F32& value); 88 void SetFragDepth(const F32& value);
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc
index 0e487f1a7..7a21fe746 100644
--- a/src/shader_recompiler/frontend/ir/opcodes.inc
+++ b/src/shader_recompiler/frontend/ir/opcodes.inc
@@ -44,10 +44,10 @@ OPCODE(GetCbufS16, U32, U32,
44OPCODE(GetCbufU32, U32, U32, U32, ) 44OPCODE(GetCbufU32, U32, U32, U32, )
45OPCODE(GetCbufF32, F32, U32, U32, ) 45OPCODE(GetCbufF32, F32, U32, U32, )
46OPCODE(GetCbufU32x2, U32x2, U32, U32, ) 46OPCODE(GetCbufU32x2, U32x2, U32, U32, )
47OPCODE(GetAttribute, F32, Attribute, ) 47OPCODE(GetAttribute, F32, Attribute, U32, )
48OPCODE(SetAttribute, Void, Attribute, F32, ) 48OPCODE(SetAttribute, Void, Attribute, F32, U32, )
49OPCODE(GetAttributeIndexed, F32, U32, ) 49OPCODE(GetAttributeIndexed, F32, U32, U32, )
50OPCODE(SetAttributeIndexed, Void, U32, F32, ) 50OPCODE(SetAttributeIndexed, Void, U32, F32, U32, )
51OPCODE(SetFragColor, Void, U32, U32, F32, ) 51OPCODE(SetFragColor, Void, U32, U32, F32, )
52OPCODE(SetFragDepth, Void, F32, ) 52OPCODE(SetFragDepth, Void, F32, )
53OPCODE(GetZFlag, U1, Void, ) 53OPCODE(GetZFlag, U1, Void, )
diff --git a/src/shader_recompiler/frontend/ir/program.h b/src/shader_recompiler/frontend/ir/program.h
index 3a37b3ab9..51e1a8c77 100644
--- a/src/shader_recompiler/frontend/ir/program.h
+++ b/src/shader_recompiler/frontend/ir/program.h
@@ -10,6 +10,7 @@
10#include <boost/container/small_vector.hpp> 10#include <boost/container/small_vector.hpp>
11 11
12#include "shader_recompiler/frontend/ir/basic_block.h" 12#include "shader_recompiler/frontend/ir/basic_block.h"
13#include "shader_recompiler/program_header.h"
13#include "shader_recompiler/shader_info.h" 14#include "shader_recompiler/shader_info.h"
14#include "shader_recompiler/stage.h" 15#include "shader_recompiler/stage.h"
15 16
@@ -21,6 +22,9 @@ struct Program {
21 Info info; 22 Info info;
22 Stage stage{}; 23 Stage stage{};
23 std::array<u32, 3> workgroup_size{}; 24 std::array<u32, 3> workgroup_size{};
25 OutputTopology output_topology{};
26 u32 output_vertices{};
27 u32 invocations{};
24 u32 local_memory_size{}; 28 u32 local_memory_size{};
25 u32 shared_memory_size{}; 29 u32 shared_memory_size{};
26}; 30};