summaryrefslogtreecommitdiff
path: root/src/video_core/engines
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2019-01-22 20:49:31 -0300
committerGravatar ReinUsesLisp2019-02-10 19:29:33 -0300
commit1ddcd0e6f03e83d0447f03ac57d5e0bda7a2f4c7 (patch)
tree4d927140ea9fb1a44a0fdeaefdbcf30a7c360f18 /src/video_core/engines
parentMerge pull request #2083 from ReinUsesLisp/shader-ir-cbuf-tracking (diff)
downloadyuzu-1ddcd0e6f03e83d0447f03ac57d5e0bda7a2f4c7.tar.gz
yuzu-1ddcd0e6f03e83d0447f03ac57d5e0bda7a2f4c7.tar.xz
yuzu-1ddcd0e6f03e83d0447f03ac57d5e0bda7a2f4c7.zip
kepler_compute: Fixup assert and rename engines
When I originally added the compute assert I used the wrong documentation. This addresses that. The dispatch register was tested with homebrew against hardware and is triggered by some games (e.g. Super Mario Odyssey). What exactly is missing to get a valid program bound by this engine requires more investigation.
Diffstat (limited to 'src/video_core/engines')
-rw-r--r--src/video_core/engines/kepler_compute.cpp34
-rw-r--r--src/video_core/engines/kepler_compute.h (renamed from src/video_core/engines/maxwell_compute.h)31
-rw-r--r--src/video_core/engines/maxwell_compute.cpp28
3 files changed, 50 insertions, 43 deletions
diff --git a/src/video_core/engines/kepler_compute.cpp b/src/video_core/engines/kepler_compute.cpp
new file mode 100644
index 000000000..4ca856b6b
--- /dev/null
+++ b/src/video_core/engines/kepler_compute.cpp
@@ -0,0 +1,34 @@
1// Copyright 2018 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/logging/log.h"
6#include "core/core.h"
7#include "core/memory.h"
8#include "video_core/engines/kepler_compute.h"
9#include "video_core/memory_manager.h"
10
11namespace Tegra::Engines {
12
13KeplerCompute::KeplerCompute(MemoryManager& memory_manager) : memory_manager{memory_manager} {}
14
15KeplerCompute::~KeplerCompute() = default;
16
17void KeplerCompute::CallMethod(const GPU::MethodCall& method_call) {
18 ASSERT_MSG(method_call.method < Regs::NUM_REGS,
19 "Invalid KeplerCompute register, increase the size of the Regs structure");
20
21 regs.reg_array[method_call.method] = method_call.argument;
22
23 switch (method_call.method) {
24 case KEPLER_COMPUTE_REG_INDEX(launch):
25 // Abort execution since compute shaders can be used to alter game memory (e.g. CUDA
26 // kernels)
27 UNREACHABLE_MSG("Compute shaders are not implemented");
28 break;
29 default:
30 break;
31 }
32}
33
34} // namespace Tegra::Engines
diff --git a/src/video_core/engines/maxwell_compute.h b/src/video_core/engines/kepler_compute.h
index 1d71f11bd..df0a32e0f 100644
--- a/src/video_core/engines/maxwell_compute.h
+++ b/src/video_core/engines/kepler_compute.h
@@ -10,47 +10,48 @@
10#include "common/common_funcs.h" 10#include "common/common_funcs.h"
11#include "common/common_types.h" 11#include "common/common_types.h"
12#include "video_core/gpu.h" 12#include "video_core/gpu.h"
13#include "video_core/memory_manager.h"
13 14
14namespace Tegra::Engines { 15namespace Tegra::Engines {
15 16
16#define MAXWELL_COMPUTE_REG_INDEX(field_name) \ 17#define KEPLER_COMPUTE_REG_INDEX(field_name) \
17 (offsetof(Tegra::Engines::MaxwellCompute::Regs, field_name) / sizeof(u32)) 18 (offsetof(Tegra::Engines::KeplerCompute::Regs, field_name) / sizeof(u32))
18 19
19class MaxwellCompute final { 20class KeplerCompute final {
20public: 21public:
21 MaxwellCompute() = default; 22 explicit KeplerCompute(MemoryManager& memory_manager);
22 ~MaxwellCompute() = default; 23 ~KeplerCompute();
24
25 static constexpr std::size_t NumConstBuffers = 8;
23 26
24 struct Regs { 27 struct Regs {
25 static constexpr std::size_t NUM_REGS = 0xCF8; 28 static constexpr std::size_t NUM_REGS = 0xCF8;
26 29
27 union { 30 union {
28 struct { 31 struct {
29 INSERT_PADDING_WORDS(0x281); 32 INSERT_PADDING_WORDS(0xAF);
30 33
31 union { 34 u32 launch;
32 u32 compute_end;
33 BitField<0, 1, u32> unknown;
34 } compute;
35 35
36 INSERT_PADDING_WORDS(0xA76); 36 INSERT_PADDING_WORDS(0xC48);
37 }; 37 };
38 std::array<u32, NUM_REGS> reg_array; 38 std::array<u32, NUM_REGS> reg_array;
39 }; 39 };
40 } regs{}; 40 } regs{};
41
42 static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), 41 static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32),
43 "MaxwellCompute Regs has wrong size"); 42 "KeplerCompute Regs has wrong size");
43
44 MemoryManager& memory_manager;
44 45
45 /// Write the value to the register identified by method. 46 /// Write the value to the register identified by method.
46 void CallMethod(const GPU::MethodCall& method_call); 47 void CallMethod(const GPU::MethodCall& method_call);
47}; 48};
48 49
49#define ASSERT_REG_POSITION(field_name, position) \ 50#define ASSERT_REG_POSITION(field_name, position) \
50 static_assert(offsetof(MaxwellCompute::Regs, field_name) == position * 4, \ 51 static_assert(offsetof(KeplerCompute::Regs, field_name) == position * 4, \
51 "Field " #field_name " has invalid position") 52 "Field " #field_name " has invalid position")
52 53
53ASSERT_REG_POSITION(compute, 0x281); 54ASSERT_REG_POSITION(launch, 0xAF);
54 55
55#undef ASSERT_REG_POSITION 56#undef ASSERT_REG_POSITION
56 57
diff --git a/src/video_core/engines/maxwell_compute.cpp b/src/video_core/engines/maxwell_compute.cpp
deleted file mode 100644
index 656db6a61..000000000
--- a/src/video_core/engines/maxwell_compute.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
1// Copyright 2018 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/logging/log.h"
6#include "core/core.h"
7#include "video_core/engines/maxwell_compute.h"
8
9namespace Tegra::Engines {
10
11void MaxwellCompute::CallMethod(const GPU::MethodCall& method_call) {
12 ASSERT_MSG(method_call.method < Regs::NUM_REGS,
13 "Invalid MaxwellCompute register, increase the size of the Regs structure");
14
15 regs.reg_array[method_call.method] = method_call.argument;
16
17 switch (method_call.method) {
18 case MAXWELL_COMPUTE_REG_INDEX(compute): {
19 LOG_CRITICAL(HW_GPU, "Compute shaders are not implemented");
20 UNREACHABLE();
21 break;
22 }
23 default:
24 break;
25 }
26}
27
28} // namespace Tegra::Engines