summaryrefslogtreecommitdiff
path: root/src/video_core/shader
diff options
context:
space:
mode:
authorGravatar bunnei2020-01-29 16:49:54 -0500
committerGravatar GitHub2020-01-29 16:49:54 -0500
commit2db7adc42a3d72fe7b02fbf4902b98d69c777b2f (patch)
tree197f2b968aa80756e329d9c76cfe72575e2f2ac5 /src/video_core/shader
parentMerge pull request #3355 from ReinUsesLisp/break-down (diff)
parentshader/memory: Implement ATOM.ADD (diff)
downloadyuzu-2db7adc42a3d72fe7b02fbf4902b98d69c777b2f.tar.gz
yuzu-2db7adc42a3d72fe7b02fbf4902b98d69c777b2f.tar.xz
yuzu-2db7adc42a3d72fe7b02fbf4902b98d69c777b2f.zip
Merge pull request #3350 from ReinUsesLisp/atom
shader/memory: Implement ATOM.ADD
Diffstat (limited to 'src/video_core/shader')
-rw-r--r--src/video_core/shader/decode/memory.cpp22
-rw-r--r--src/video_core/shader/node.h2
2 files changed, 22 insertions, 2 deletions
diff --git a/src/video_core/shader/decode/memory.cpp b/src/video_core/shader/decode/memory.cpp
index 7591a715f..3da833e81 100644
--- a/src/video_core/shader/decode/memory.cpp
+++ b/src/video_core/shader/decode/memory.cpp
@@ -19,6 +19,8 @@ namespace VideoCommon::Shader {
19using Tegra::Shader::AtomicOp; 19using Tegra::Shader::AtomicOp;
20using Tegra::Shader::AtomicType; 20using Tegra::Shader::AtomicType;
21using Tegra::Shader::Attribute; 21using Tegra::Shader::Attribute;
22using Tegra::Shader::GlobalAtomicOp;
23using Tegra::Shader::GlobalAtomicType;
22using Tegra::Shader::Instruction; 24using Tegra::Shader::Instruction;
23using Tegra::Shader::OpCode; 25using Tegra::Shader::OpCode;
24using Tegra::Shader::Register; 26using Tegra::Shader::Register;
@@ -335,6 +337,24 @@ u32 ShaderIR::DecodeMemory(NodeBlock& bb, u32 pc) {
335 } 337 }
336 break; 338 break;
337 } 339 }
340 case OpCode::Id::ATOM: {
341 UNIMPLEMENTED_IF_MSG(instr.atom.operation != GlobalAtomicOp::Add, "operation={}",
342 static_cast<int>(instr.atom.operation.Value()));
343 UNIMPLEMENTED_IF_MSG(instr.atom.type != GlobalAtomicType::S32, "type={}",
344 static_cast<int>(instr.atom.type.Value()));
345
346 const auto [real_address, base_address, descriptor] =
347 TrackGlobalMemory(bb, instr, true, true);
348 if (!real_address || !base_address) {
349 // Tracking failed, skip atomic.
350 break;
351 }
352
353 Node gmem = MakeNode<GmemNode>(real_address, base_address, descriptor);
354 Node value = Operation(OperationCode::AtomicAdd, std::move(gmem), GetRegister(instr.gpr20));
355 SetRegister(bb, instr.gpr0, std::move(value));
356 break;
357 }
338 case OpCode::Id::ATOMS: { 358 case OpCode::Id::ATOMS: {
339 UNIMPLEMENTED_IF_MSG(instr.atoms.operation != AtomicOp::Add, "operation={}", 359 UNIMPLEMENTED_IF_MSG(instr.atoms.operation != AtomicOp::Add, "operation={}",
340 static_cast<int>(instr.atoms.operation.Value())); 360 static_cast<int>(instr.atoms.operation.Value()));
@@ -348,7 +368,7 @@ u32 ShaderIR::DecodeMemory(NodeBlock& bb, u32 pc) {
348 Node memory = GetSharedMemory(std::move(address)); 368 Node memory = GetSharedMemory(std::move(address));
349 Node data = GetRegister(instr.gpr20); 369 Node data = GetRegister(instr.gpr20);
350 370
351 Node value = Operation(OperationCode::UAtomicAdd, std::move(memory), std::move(data)); 371 Node value = Operation(OperationCode::AtomicAdd, std::move(memory), std::move(data));
352 SetRegister(bb, instr.gpr0, std::move(value)); 372 SetRegister(bb, instr.gpr0, std::move(value));
353 break; 373 break;
354 } 374 }
diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h
index 075c7d07c..9af1f0228 100644
--- a/src/video_core/shader/node.h
+++ b/src/video_core/shader/node.h
@@ -162,7 +162,7 @@ enum class OperationCode {
162 AtomicImageXor, /// (MetaImage, int[N] coords) -> void 162 AtomicImageXor, /// (MetaImage, int[N] coords) -> void
163 AtomicImageExchange, /// (MetaImage, int[N] coords) -> void 163 AtomicImageExchange, /// (MetaImage, int[N] coords) -> void
164 164
165 UAtomicAdd, /// (smem, uint) -> uint 165 AtomicAdd, /// (memory, {u}int) -> {u}int
166 166
167 Branch, /// (uint branch_target) -> void 167 Branch, /// (uint branch_target) -> void
168 BranchIndirect, /// (uint branch_target) -> void 168 BranchIndirect, /// (uint branch_target) -> void