summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp26
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_gpu.h17
-rw-r--r--src/video_core/command_processor.cpp170
-rw-r--r--src/video_core/command_processor.h17
-rw-r--r--src/video_core/engines/maxwell_3d.cpp2
-rw-r--r--src/video_core/gpu.h7
-rw-r--r--src/video_core/rasterizer_interface.h3
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp2
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h1
9 files changed, 121 insertions, 124 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
index 4cdf7f613..8e0f9a9e5 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
@@ -8,6 +8,7 @@
8#include "core/core.h" 8#include "core/core.h"
9#include "core/hle/service/nvdrv/devices/nvhost_gpu.h" 9#include "core/hle/service/nvdrv/devices/nvhost_gpu.h"
10#include "core/memory.h" 10#include "core/memory.h"
11#include "video_core/command_processor.h"
11#include "video_core/gpu.h" 12#include "video_core/gpu.h"
12#include "video_core/memory_manager.h" 13#include "video_core/memory_manager.h"
13 14
@@ -134,17 +135,16 @@ u32 nvhost_gpu::SubmitGPFIFO(const std::vector<u8>& input, std::vector<u8>& outp
134 LOG_WARNING(Service_NVDRV, "(STUBBED) called, gpfifo={:X}, num_entries={:X}, flags={:X}", 135 LOG_WARNING(Service_NVDRV, "(STUBBED) called, gpfifo={:X}, num_entries={:X}, flags={:X}",
135 params.address, params.num_entries, params.flags); 136 params.address, params.num_entries, params.flags);
136 137
137 ASSERT_MSG(input.size() == 138 ASSERT_MSG(input.size() == sizeof(IoctlSubmitGpfifo) +
138 sizeof(IoctlSubmitGpfifo) + params.num_entries * sizeof(IoctlGpfifoEntry), 139 params.num_entries * sizeof(Tegra::CommandListHeader),
139 "Incorrect input size"); 140 "Incorrect input size");
140 141
141 std::vector<IoctlGpfifoEntry> entries(params.num_entries); 142 std::vector<Tegra::CommandListHeader> entries(params.num_entries);
142 std::memcpy(entries.data(), &input[sizeof(IoctlSubmitGpfifo)], 143 std::memcpy(entries.data(), &input[sizeof(IoctlSubmitGpfifo)],
143 params.num_entries * sizeof(IoctlGpfifoEntry)); 144 params.num_entries * sizeof(Tegra::CommandListHeader));
144 for (auto entry : entries) { 145
145 Tegra::GPUVAddr va_addr = entry.Address(); 146 Core::System::GetInstance().GPU().ProcessCommandLists(entries);
146 Core::System::GetInstance().GPU().ProcessCommandList(va_addr, entry.sz); 147
147 }
148 params.fence_out.id = 0; 148 params.fence_out.id = 0;
149 params.fence_out.value = 0; 149 params.fence_out.value = 0;
150 std::memcpy(output.data(), &params, sizeof(IoctlSubmitGpfifo)); 150 std::memcpy(output.data(), &params, sizeof(IoctlSubmitGpfifo));
@@ -160,14 +160,12 @@ u32 nvhost_gpu::KickoffPB(const std::vector<u8>& input, std::vector<u8>& output)
160 LOG_WARNING(Service_NVDRV, "(STUBBED) called, gpfifo={:X}, num_entries={:X}, flags={:X}", 160 LOG_WARNING(Service_NVDRV, "(STUBBED) called, gpfifo={:X}, num_entries={:X}, flags={:X}",
161 params.address, params.num_entries, params.flags); 161 params.address, params.num_entries, params.flags);
162 162
163 std::vector<IoctlGpfifoEntry> entries(params.num_entries); 163 std::vector<Tegra::CommandListHeader> entries(params.num_entries);
164 Memory::ReadBlock(params.address, entries.data(), 164 Memory::ReadBlock(params.address, entries.data(),
165 params.num_entries * sizeof(IoctlGpfifoEntry)); 165 params.num_entries * sizeof(Tegra::CommandListHeader));
166
167 Core::System::GetInstance().GPU().ProcessCommandLists(entries);
166 168
167 for (auto entry : entries) {
168 Tegra::GPUVAddr va_addr = entry.Address();
169 Core::System::GetInstance().GPU().ProcessCommandList(va_addr, entry.sz);
170 }
171 params.fence_out.id = 0; 169 params.fence_out.id = 0;
172 params.fence_out.value = 0; 170 params.fence_out.value = 0;
173 std::memcpy(output.data(), &params, output.size()); 171 std::memcpy(output.data(), &params, output.size());
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
index 03b7356d0..baaefd79a 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
@@ -10,7 +10,6 @@
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "common/swap.h" 11#include "common/swap.h"
12#include "core/hle/service/nvdrv/devices/nvdevice.h" 12#include "core/hle/service/nvdrv/devices/nvdevice.h"
13#include "video_core/memory_manager.h"
14 13
15namespace Service::Nvidia::Devices { 14namespace Service::Nvidia::Devices {
16 15
@@ -151,22 +150,6 @@ private:
151 }; 150 };
152 static_assert(sizeof(IoctlAllocObjCtx) == 16, "IoctlAllocObjCtx is incorrect size"); 151 static_assert(sizeof(IoctlAllocObjCtx) == 16, "IoctlAllocObjCtx is incorrect size");
153 152
154 struct IoctlGpfifoEntry {
155 u32_le entry0; // gpu_va_lo
156 union {
157 u32_le entry1; // gpu_va_hi | (unk_0x02 << 0x08) | (size << 0x0A) | (unk_0x01 << 0x1F)
158 BitField<0, 8, u32_le> gpu_va_hi;
159 BitField<8, 2, u32_le> unk1;
160 BitField<10, 21, u32_le> sz;
161 BitField<31, 1, u32_le> unk2;
162 };
163
164 Tegra::GPUVAddr Address() const {
165 return (static_cast<Tegra::GPUVAddr>(gpu_va_hi) << 32) | entry0;
166 }
167 };
168 static_assert(sizeof(IoctlGpfifoEntry) == 8, "IoctlGpfifoEntry is incorrect size");
169
170 struct IoctlSubmitGpfifo { 153 struct IoctlSubmitGpfifo {
171 u64_le address; // pointer to gpfifo entry structs 154 u64_le address; // pointer to gpfifo entry structs
172 u32_le num_entries; // number of fence objects being submitted 155 u32_le num_entries; // number of fence objects being submitted
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp
index d5831e752..2625ddfdc 100644
--- a/src/video_core/command_processor.cpp
+++ b/src/video_core/command_processor.cpp
@@ -28,98 +28,106 @@ enum class BufferMethods {
28 CountBufferMethods = 0x40, 28 CountBufferMethods = 0x40,
29}; 29};
30 30
31void GPU::WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params) { 31MICROPROFILE_DEFINE(ProcessCommandLists, "GPU", "Execute command buffer", MP_RGB(128, 128, 192));
32 LOG_TRACE(HW_GPU,
33 "Processing method {:08X} on subchannel {} value "
34 "{:08X} remaining params {}",
35 method, subchannel, value, remaining_params);
36
37 ASSERT(subchannel < bound_engines.size());
38
39 if (method == static_cast<u32>(BufferMethods::BindObject)) {
40 // Bind the current subchannel to the desired engine id.
41 LOG_DEBUG(HW_GPU, "Binding subchannel {} to engine {}", subchannel, value);
42 bound_engines[subchannel] = static_cast<EngineID>(value);
43 return;
44 }
45 32
46 if (method < static_cast<u32>(BufferMethods::CountBufferMethods)) { 33void GPU::ProcessCommandLists(const std::vector<CommandListHeader>& commands) {
47 // TODO(Subv): Research and implement these methods. 34 MICROPROFILE_SCOPE(ProcessCommandLists);
48 LOG_ERROR(HW_GPU, "Special buffer methods other than Bind are not implemented");
49 return;
50 }
51 35
52 const EngineID engine = bound_engines[subchannel]; 36 auto WriteReg = [this](u32 method, u32 subchannel, u32 value, u32 remaining_params) {
53 37 LOG_TRACE(HW_GPU,
54 switch (engine) { 38 "Processing method {:08X} on subchannel {} value "
55 case EngineID::FERMI_TWOD_A: 39 "{:08X} remaining params {}",
56 fermi_2d->WriteReg(method, value); 40 method, subchannel, value, remaining_params);
57 break;
58 case EngineID::MAXWELL_B:
59 maxwell_3d->WriteReg(method, value, remaining_params);
60 break;
61 case EngineID::MAXWELL_COMPUTE_B:
62 maxwell_compute->WriteReg(method, value);
63 break;
64 case EngineID::MAXWELL_DMA_COPY_A:
65 maxwell_dma->WriteReg(method, value);
66 break;
67 default:
68 UNIMPLEMENTED_MSG("Unimplemented engine");
69 }
70}
71 41
72void GPU::ProcessCommandList(GPUVAddr address, u32 size) { 42 ASSERT(subchannel < bound_engines.size());
73 const boost::optional<VAddr> head_address = memory_manager->GpuToCpuAddress(address); 43
74 VAddr current_addr = *head_address; 44 if (method == static_cast<u32>(BufferMethods::BindObject)) {
75 while (current_addr < *head_address + size * sizeof(CommandHeader)) { 45 // Bind the current subchannel to the desired engine id.
76 const CommandHeader header = {Memory::Read32(current_addr)}; 46 LOG_DEBUG(HW_GPU, "Binding subchannel {} to engine {}", subchannel, value);
77 current_addr += sizeof(u32); 47 bound_engines[subchannel] = static_cast<EngineID>(value);
78 48 return;
79 switch (header.mode.Value()) {
80 case SubmissionMode::IncreasingOld:
81 case SubmissionMode::Increasing: {
82 // Increase the method value with each argument.
83 for (unsigned i = 0; i < header.arg_count; ++i) {
84 WriteReg(header.method + i, header.subchannel, Memory::Read32(current_addr),
85 header.arg_count - i - 1);
86 current_addr += sizeof(u32);
87 }
88 break;
89 } 49 }
90 case SubmissionMode::NonIncreasingOld: 50
91 case SubmissionMode::NonIncreasing: { 51 if (method < static_cast<u32>(BufferMethods::CountBufferMethods)) {
92 // Use the same method value for all arguments. 52 // TODO(Subv): Research and implement these methods.
93 for (unsigned i = 0; i < header.arg_count; ++i) { 53 LOG_ERROR(HW_GPU, "Special buffer methods other than Bind are not implemented");
94 WriteReg(header.method, header.subchannel, Memory::Read32(current_addr), 54 return;
95 header.arg_count - i - 1); 55 }
96 current_addr += sizeof(u32); 56
97 } 57 const EngineID engine = bound_engines[subchannel];
58
59 switch (engine) {
60 case EngineID::FERMI_TWOD_A:
61 fermi_2d->WriteReg(method, value);
62 break;
63 case EngineID::MAXWELL_B:
64 maxwell_3d->WriteReg(method, value, remaining_params);
98 break; 65 break;
66 case EngineID::MAXWELL_COMPUTE_B:
67 maxwell_compute->WriteReg(method, value);
68 break;
69 case EngineID::MAXWELL_DMA_COPY_A:
70 maxwell_dma->WriteReg(method, value);
71 break;
72 default:
73 UNIMPLEMENTED_MSG("Unimplemented engine");
99 } 74 }
100 case SubmissionMode::IncreaseOnce: { 75 };
101 ASSERT(header.arg_count.Value() >= 1);
102 76
103 // Use the original method for the first argument and then the next method for all other 77 for (auto entry : commands) {
104 // arguments. 78 Tegra::GPUVAddr address = entry.Address();
105 WriteReg(header.method, header.subchannel, Memory::Read32(current_addr), 79 u32 size = entry.sz;
106 header.arg_count - 1); 80 const boost::optional<VAddr> head_address = memory_manager->GpuToCpuAddress(address);
81 VAddr current_addr = *head_address;
82 while (current_addr < *head_address + size * sizeof(CommandHeader)) {
83 const CommandHeader header = {Memory::Read32(current_addr)};
107 current_addr += sizeof(u32); 84 current_addr += sizeof(u32);
108 85
109 for (unsigned i = 1; i < header.arg_count; ++i) { 86 switch (header.mode.Value()) {
110 WriteReg(header.method + 1, header.subchannel, Memory::Read32(current_addr), 87 case SubmissionMode::IncreasingOld:
111 header.arg_count - i - 1); 88 case SubmissionMode::Increasing: {
89 // Increase the method value with each argument.
90 for (unsigned i = 0; i < header.arg_count; ++i) {
91 WriteReg(header.method + i, header.subchannel, Memory::Read32(current_addr),
92 header.arg_count - i - 1);
93 current_addr += sizeof(u32);
94 }
95 break;
96 }
97 case SubmissionMode::NonIncreasingOld:
98 case SubmissionMode::NonIncreasing: {
99 // Use the same method value for all arguments.
100 for (unsigned i = 0; i < header.arg_count; ++i) {
101 WriteReg(header.method, header.subchannel, Memory::Read32(current_addr),
102 header.arg_count - i - 1);
103 current_addr += sizeof(u32);
104 }
105 break;
106 }
107 case SubmissionMode::IncreaseOnce: {
108 ASSERT(header.arg_count.Value() >= 1);
109
110 // Use the original method for the first argument and then the next method for all
111 // other arguments.
112 WriteReg(header.method, header.subchannel, Memory::Read32(current_addr),
113 header.arg_count - 1);
112 current_addr += sizeof(u32); 114 current_addr += sizeof(u32);
115
116 for (unsigned i = 1; i < header.arg_count; ++i) {
117 WriteReg(header.method + 1, header.subchannel, Memory::Read32(current_addr),
118 header.arg_count - i - 1);
119 current_addr += sizeof(u32);
120 }
121 break;
122 }
123 case SubmissionMode::Inline: {
124 // The register value is stored in the bits 16-28 as an immediate
125 WriteReg(header.method, header.subchannel, header.inline_data, 0);
126 break;
127 }
128 default:
129 UNIMPLEMENTED();
113 } 130 }
114 break;
115 }
116 case SubmissionMode::Inline: {
117 // The register value is stored in the bits 16-28 as an immediate
118 WriteReg(header.method, header.subchannel, header.inline_data, 0);
119 break;
120 }
121 default:
122 UNIMPLEMENTED();
123 } 131 }
124 } 132 }
125} 133}
diff --git a/src/video_core/command_processor.h b/src/video_core/command_processor.h
index a01153e0b..bd766e77a 100644
--- a/src/video_core/command_processor.h
+++ b/src/video_core/command_processor.h
@@ -7,6 +7,7 @@
7#include <type_traits> 7#include <type_traits>
8#include "common/bit_field.h" 8#include "common/bit_field.h"
9#include "common/common_types.h" 9#include "common/common_types.h"
10#include "video_core/memory_manager.h"
10 11
11namespace Tegra { 12namespace Tegra {
12 13
@@ -19,6 +20,22 @@ enum class SubmissionMode : u32 {
19 IncreaseOnce = 5 20 IncreaseOnce = 5
20}; 21};
21 22
23struct CommandListHeader {
24 u32 entry0; // gpu_va_lo
25 union {
26 u32 entry1; // gpu_va_hi | (unk_0x02 << 0x08) | (size << 0x0A) | (unk_0x01 << 0x1F)
27 BitField<0, 8, u32> gpu_va_hi;
28 BitField<8, 2, u32> unk1;
29 BitField<10, 21, u32> sz;
30 BitField<31, 1, u32> unk2;
31 };
32
33 GPUVAddr Address() const {
34 return (static_cast<GPUVAddr>(gpu_va_hi) << 32) | entry0;
35 }
36};
37static_assert(sizeof(CommandListHeader) == 8, "CommandListHeader is incorrect size");
38
22union CommandHeader { 39union CommandHeader {
23 u32 hex; 40 u32 hex;
24 41
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 1308080b5..329079ddd 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -135,8 +135,6 @@ void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) {
135 break; 135 break;
136 } 136 }
137 137
138 rasterizer.NotifyMaxwellRegisterChanged(method);
139
140 if (debug_context) { 138 if (debug_context) {
141 debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandProcessed, nullptr); 139 debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandProcessed, nullptr);
142 } 140 }
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index d29f31f52..4f71f99d7 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -6,6 +6,7 @@
6 6
7#include <array> 7#include <array>
8#include <memory> 8#include <memory>
9#include <vector>
9#include "common/common_types.h" 10#include "common/common_types.h"
10#include "core/hle/service/nvflinger/buffer_queue.h" 11#include "core/hle/service/nvflinger/buffer_queue.h"
11#include "video_core/memory_manager.h" 12#include "video_core/memory_manager.h"
@@ -67,6 +68,7 @@ u32 RenderTargetBytesPerPixel(RenderTargetFormat format);
67/// Returns the number of bytes per pixel of each depth format. 68/// Returns the number of bytes per pixel of each depth format.
68u32 DepthFormatBytesPerPixel(DepthFormat format); 69u32 DepthFormatBytesPerPixel(DepthFormat format);
69 70
71struct CommandListHeader;
70class DebugContext; 72class DebugContext;
71 73
72/** 74/**
@@ -115,7 +117,7 @@ public:
115 ~GPU(); 117 ~GPU();
116 118
117 /// Processes a command list stored at the specified address in GPU memory. 119 /// Processes a command list stored at the specified address in GPU memory.
118 void ProcessCommandList(GPUVAddr address, u32 size); 120 void ProcessCommandLists(const std::vector<CommandListHeader>& commands);
119 121
120 /// Returns a reference to the Maxwell3D GPU engine. 122 /// Returns a reference to the Maxwell3D GPU engine.
121 Engines::Maxwell3D& Maxwell3D(); 123 Engines::Maxwell3D& Maxwell3D();
@@ -130,9 +132,6 @@ public:
130 const Tegra::MemoryManager& MemoryManager() const; 132 const Tegra::MemoryManager& MemoryManager() const;
131 133
132private: 134private:
133 /// Writes a single register in the engine bound to the specified subchannel
134 void WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params);
135
136 std::unique_ptr<Tegra::MemoryManager> memory_manager; 135 std::unique_ptr<Tegra::MemoryManager> memory_manager;
137 136
138 /// Mapping of command subchannels to their bound engine ids. 137 /// Mapping of command subchannels to their bound engine ids.
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h
index 9d78e8b6b..cd819d69f 100644
--- a/src/video_core/rasterizer_interface.h
+++ b/src/video_core/rasterizer_interface.h
@@ -20,9 +20,6 @@ public:
20 /// Clear the current framebuffer 20 /// Clear the current framebuffer
21 virtual void Clear() = 0; 21 virtual void Clear() = 0;
22 22
23 /// Notify rasterizer that the specified Maxwell register has been changed
24 virtual void NotifyMaxwellRegisterChanged(u32 method) = 0;
25
26 /// Notify rasterizer that all caches should be flushed to Switch memory 23 /// Notify rasterizer that all caches should be flushed to Switch memory
27 virtual void FlushAll() = 0; 24 virtual void FlushAll() = 0;
28 25
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index c7e2c877c..fdfca767a 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -527,8 +527,6 @@ void RasterizerOpenGL::DrawArrays() {
527 state.Apply(); 527 state.Apply();
528} 528}
529 529
530void RasterizerOpenGL::NotifyMaxwellRegisterChanged(u32 method) {}
531
532void RasterizerOpenGL::FlushAll() {} 530void RasterizerOpenGL::FlushAll() {}
533 531
534void RasterizerOpenGL::FlushRegion(VAddr addr, u64 size) {} 532void RasterizerOpenGL::FlushRegion(VAddr addr, u64 size) {}
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 3d62cc196..eaf31ae96 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -45,7 +45,6 @@ public:
45 45
46 void DrawArrays() override; 46 void DrawArrays() override;
47 void Clear() override; 47 void Clear() override;
48 void NotifyMaxwellRegisterChanged(u32 method) override;
49 void FlushAll() override; 48 void FlushAll() override;
50 void FlushRegion(VAddr addr, u64 size) override; 49 void FlushRegion(VAddr addr, u64 size) override;
51 void InvalidateRegion(VAddr addr, u64 size) override; 50 void InvalidateRegion(VAddr addr, u64 size) override;