summaryrefslogtreecommitdiff
path: root/src/video_core/engines
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2023-12-25 07:32:16 +0100
committerGravatar Liam2024-01-18 21:12:30 -0500
commit0a2536a0df1f4aea406f2132d3edda0430acc9d1 (patch)
treec0ad53890581c9c7e180c5ccb3b66e3c63e3ba64 /src/video_core/engines
parentSMMU: Implement backing CPU page protect/unprotect (diff)
downloadyuzu-0a2536a0df1f4aea406f2132d3edda0430acc9d1.tar.gz
yuzu-0a2536a0df1f4aea406f2132d3edda0430acc9d1.tar.xz
yuzu-0a2536a0df1f4aea406f2132d3edda0430acc9d1.zip
SMMU: Initial adaptation to video_core.
Diffstat (limited to 'src/video_core/engines')
-rw-r--r--src/video_core/engines/engine_upload.cpp5
-rw-r--r--src/video_core/engines/maxwell_dma.cpp25
-rw-r--r--src/video_core/engines/sw_blitter/blitter.cpp5
3 files changed, 19 insertions, 16 deletions
diff --git a/src/video_core/engines/engine_upload.cpp b/src/video_core/engines/engine_upload.cpp
index bc64d4486..e5cc04ec4 100644
--- a/src/video_core/engines/engine_upload.cpp
+++ b/src/video_core/engines/engine_upload.cpp
@@ -5,8 +5,8 @@
5 5
6#include "common/algorithm.h" 6#include "common/algorithm.h"
7#include "common/assert.h" 7#include "common/assert.h"
8#include "core/memory.h"
9#include "video_core/engines/engine_upload.h" 8#include "video_core/engines/engine_upload.h"
9#include "video_core/guest_memory.h"
10#include "video_core/memory_manager.h" 10#include "video_core/memory_manager.h"
11#include "video_core/rasterizer_interface.h" 11#include "video_core/rasterizer_interface.h"
12#include "video_core/textures/decoders.h" 12#include "video_core/textures/decoders.h"
@@ -68,7 +68,8 @@ void State::ProcessData(std::span<const u8> read_buffer) {
68 true, bytes_per_pixel, width, regs.dest.height, regs.dest.depth, 68 true, bytes_per_pixel, width, regs.dest.height, regs.dest.depth,
69 regs.dest.BlockHeight(), regs.dest.BlockDepth()); 69 regs.dest.BlockHeight(), regs.dest.BlockDepth());
70 70
71 Core::Memory::GpuGuestMemoryScoped<u8, Core::Memory::GuestMemoryFlags::SafeReadCachedWrite> 71 Tegra::Memory::GpuGuestMemoryScoped<u8,
72 Tegra::Memory::GuestMemoryFlags::SafeReadCachedWrite>
72 tmp(memory_manager, address, dst_size, &tmp_buffer); 73 tmp(memory_manager, address, dst_size, &tmp_buffer);
73 74
74 Tegra::Texture::SwizzleSubrect(tmp, read_buffer, bytes_per_pixel, width, regs.dest.height, 75 Tegra::Texture::SwizzleSubrect(tmp, read_buffer, bytes_per_pixel, width, regs.dest.height,
diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp
index 56fbff306..4bf461fb0 100644
--- a/src/video_core/engines/maxwell_dma.cpp
+++ b/src/video_core/engines/maxwell_dma.cpp
@@ -11,6 +11,7 @@
11#include "core/memory.h" 11#include "core/memory.h"
12#include "video_core/engines/maxwell_3d.h" 12#include "video_core/engines/maxwell_3d.h"
13#include "video_core/engines/maxwell_dma.h" 13#include "video_core/engines/maxwell_dma.h"
14#include "video_core/guest_memory.h"
14#include "video_core/memory_manager.h" 15#include "video_core/memory_manager.h"
15#include "video_core/renderer_base.h" 16#include "video_core/renderer_base.h"
16#include "video_core/textures/decoders.h" 17#include "video_core/textures/decoders.h"
@@ -133,8 +134,8 @@ void MaxwellDMA::Launch() {
133 UNIMPLEMENTED_IF(regs.offset_out % 16 != 0); 134 UNIMPLEMENTED_IF(regs.offset_out % 16 != 0);
134 read_buffer.resize_destructive(16); 135 read_buffer.resize_destructive(16);
135 for (u32 offset = 0; offset < regs.line_length_in; offset += 16) { 136 for (u32 offset = 0; offset < regs.line_length_in; offset += 16) {
136 Core::Memory::GpuGuestMemoryScoped< 137 Tegra::Memory::GpuGuestMemoryScoped<
137 u8, Core::Memory::GuestMemoryFlags::SafeReadCachedWrite> 138 u8, Tegra::Memory::GuestMemoryFlags::SafeReadCachedWrite>
138 tmp_write_buffer(memory_manager, 139 tmp_write_buffer(memory_manager,
139 convert_linear_2_blocklinear_addr(regs.offset_in + offset), 140 convert_linear_2_blocklinear_addr(regs.offset_in + offset),
140 16, &read_buffer); 141 16, &read_buffer);
@@ -146,16 +147,16 @@ void MaxwellDMA::Launch() {
146 UNIMPLEMENTED_IF(regs.offset_out % 16 != 0); 147 UNIMPLEMENTED_IF(regs.offset_out % 16 != 0);
147 read_buffer.resize_destructive(16); 148 read_buffer.resize_destructive(16);
148 for (u32 offset = 0; offset < regs.line_length_in; offset += 16) { 149 for (u32 offset = 0; offset < regs.line_length_in; offset += 16) {
149 Core::Memory::GpuGuestMemoryScoped< 150 Tegra::Memory::GpuGuestMemoryScoped<
150 u8, Core::Memory::GuestMemoryFlags::SafeReadCachedWrite> 151 u8, Tegra::Memory::GuestMemoryFlags::SafeReadCachedWrite>
151 tmp_write_buffer(memory_manager, regs.offset_in + offset, 16, &read_buffer); 152 tmp_write_buffer(memory_manager, regs.offset_in + offset, 16, &read_buffer);
152 tmp_write_buffer.SetAddressAndSize( 153 tmp_write_buffer.SetAddressAndSize(
153 convert_linear_2_blocklinear_addr(regs.offset_out + offset), 16); 154 convert_linear_2_blocklinear_addr(regs.offset_out + offset), 16);
154 } 155 }
155 } else { 156 } else {
156 if (!accelerate.BufferCopy(regs.offset_in, regs.offset_out, regs.line_length_in)) { 157 if (!accelerate.BufferCopy(regs.offset_in, regs.offset_out, regs.line_length_in)) {
157 Core::Memory::GpuGuestMemoryScoped< 158 Tegra::Memory::GpuGuestMemoryScoped<
158 u8, Core::Memory::GuestMemoryFlags::SafeReadCachedWrite> 159 u8, Tegra::Memory::GuestMemoryFlags::SafeReadCachedWrite>
159 tmp_write_buffer(memory_manager, regs.offset_in, regs.line_length_in, 160 tmp_write_buffer(memory_manager, regs.offset_in, regs.line_length_in,
160 &read_buffer); 161 &read_buffer);
161 tmp_write_buffer.SetAddressAndSize(regs.offset_out, regs.line_length_in); 162 tmp_write_buffer.SetAddressAndSize(regs.offset_out, regs.line_length_in);
@@ -226,9 +227,9 @@ void MaxwellDMA::CopyBlockLinearToPitch() {
226 227
227 const size_t dst_size = dst_operand.pitch * regs.line_count; 228 const size_t dst_size = dst_operand.pitch * regs.line_count;
228 229
229 Core::Memory::GpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead> tmp_read_buffer( 230 Tegra::Memory::GpuGuestMemory<u8, Tegra::Memory::GuestMemoryFlags::SafeRead> tmp_read_buffer(
230 memory_manager, src_operand.address, src_size, &read_buffer); 231 memory_manager, src_operand.address, src_size, &read_buffer);
231 Core::Memory::GpuGuestMemoryScoped<u8, Core::Memory::GuestMemoryFlags::UnsafeReadCachedWrite> 232 Tegra::Memory::GpuGuestMemoryScoped<u8, Tegra::Memory::GuestMemoryFlags::UnsafeReadCachedWrite>
232 tmp_write_buffer(memory_manager, dst_operand.address, dst_size, &write_buffer); 233 tmp_write_buffer(memory_manager, dst_operand.address, dst_size, &write_buffer);
233 234
234 UnswizzleSubrect(tmp_write_buffer, tmp_read_buffer, bytes_per_pixel, width, height, depth, 235 UnswizzleSubrect(tmp_write_buffer, tmp_read_buffer, bytes_per_pixel, width, height, depth,
@@ -290,9 +291,9 @@ void MaxwellDMA::CopyPitchToBlockLinear() {
290 291
291 GPUVAddr src_addr = regs.offset_in; 292 GPUVAddr src_addr = regs.offset_in;
292 GPUVAddr dst_addr = regs.offset_out; 293 GPUVAddr dst_addr = regs.offset_out;
293 Core::Memory::GpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead> tmp_read_buffer( 294 Tegra::Memory::GpuGuestMemory<u8, Tegra::Memory::GuestMemoryFlags::SafeRead> tmp_read_buffer(
294 memory_manager, src_addr, src_size, &read_buffer); 295 memory_manager, src_addr, src_size, &read_buffer);
295 Core::Memory::GpuGuestMemoryScoped<u8, Core::Memory::GuestMemoryFlags::UnsafeReadCachedWrite> 296 Tegra::Memory::GpuGuestMemoryScoped<u8, Tegra::Memory::GuestMemoryFlags::UnsafeReadCachedWrite>
296 tmp_write_buffer(memory_manager, dst_addr, dst_size, &write_buffer); 297 tmp_write_buffer(memory_manager, dst_addr, dst_size, &write_buffer);
297 298
298 // If the input is linear and the output is tiled, swizzle the input and copy it over. 299 // If the input is linear and the output is tiled, swizzle the input and copy it over.
@@ -344,9 +345,9 @@ void MaxwellDMA::CopyBlockLinearToBlockLinear() {
344 345
345 intermediate_buffer.resize_destructive(mid_buffer_size); 346 intermediate_buffer.resize_destructive(mid_buffer_size);
346 347
347 Core::Memory::GpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead> tmp_read_buffer( 348 Tegra::Memory::GpuGuestMemory<u8, Tegra::Memory::GuestMemoryFlags::SafeRead> tmp_read_buffer(
348 memory_manager, regs.offset_in, src_size, &read_buffer); 349 memory_manager, regs.offset_in, src_size, &read_buffer);
349 Core::Memory::GpuGuestMemoryScoped<u8, Core::Memory::GuestMemoryFlags::SafeReadCachedWrite> 350 Tegra::Memory::GpuGuestMemoryScoped<u8, Tegra::Memory::GuestMemoryFlags::SafeReadCachedWrite>
350 tmp_write_buffer(memory_manager, regs.offset_out, dst_size, &write_buffer); 351 tmp_write_buffer(memory_manager, regs.offset_out, dst_size, &write_buffer);
351 352
352 UnswizzleSubrect(intermediate_buffer, tmp_read_buffer, bytes_per_pixel, src_width, src.height, 353 UnswizzleSubrect(intermediate_buffer, tmp_read_buffer, bytes_per_pixel, src_width, src.height,
diff --git a/src/video_core/engines/sw_blitter/blitter.cpp b/src/video_core/engines/sw_blitter/blitter.cpp
index 67ce9134b..b67589daf 100644
--- a/src/video_core/engines/sw_blitter/blitter.cpp
+++ b/src/video_core/engines/sw_blitter/blitter.cpp
@@ -11,6 +11,7 @@
11#include "video_core/memory_manager.h" 11#include "video_core/memory_manager.h"
12#include "video_core/surface.h" 12#include "video_core/surface.h"
13#include "video_core/textures/decoders.h" 13#include "video_core/textures/decoders.h"
14#include "video_core/guest_memory.h"
14 15
15namespace Tegra { 16namespace Tegra {
16class MemoryManager; 17class MemoryManager;
@@ -160,7 +161,7 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst,
160 const auto dst_bytes_per_pixel = BytesPerBlock(PixelFormatFromRenderTargetFormat(dst.format)); 161 const auto dst_bytes_per_pixel = BytesPerBlock(PixelFormatFromRenderTargetFormat(dst.format));
161 const size_t src_size = get_surface_size(src, src_bytes_per_pixel); 162 const size_t src_size = get_surface_size(src, src_bytes_per_pixel);
162 163
163 Core::Memory::GpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead> tmp_buffer( 164 Tegra::Memory::GpuGuestMemory<u8, Tegra::Memory::GuestMemoryFlags::SafeRead> tmp_buffer(
164 memory_manager, src.Address(), src_size, &impl->tmp_buffer); 165 memory_manager, src.Address(), src_size, &impl->tmp_buffer);
165 166
166 const size_t src_copy_size = src_extent_x * src_extent_y * src_bytes_per_pixel; 167 const size_t src_copy_size = src_extent_x * src_extent_y * src_bytes_per_pixel;
@@ -220,7 +221,7 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst,
220 } 221 }
221 222
222 const size_t dst_size = get_surface_size(dst, dst_bytes_per_pixel); 223 const size_t dst_size = get_surface_size(dst, dst_bytes_per_pixel);
223 Core::Memory::GpuGuestMemoryScoped<u8, Core::Memory::GuestMemoryFlags::SafeReadWrite> 224 Tegra::Memory::GpuGuestMemoryScoped<u8, Tegra::Memory::GuestMemoryFlags::SafeReadWrite>
224 tmp_buffer2(memory_manager, dst.Address(), dst_size, &impl->tmp_buffer); 225 tmp_buffer2(memory_manager, dst.Address(), dst_size, &impl->tmp_buffer);
225 226
226 if (dst.linear == Fermi2D::MemoryLayout::BlockLinear) { 227 if (dst.linear == Fermi2D::MemoryLayout::BlockLinear) {