summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2018-10-05 23:46:40 -0400
committerGravatar bunnei2018-10-06 03:20:04 -0400
commit9aec85d39c0c95419bd086ccac158dbb77c20002 (patch)
tree3140c57d26f721f3a0fb8045e52b15cbb898db8d
parentgl_rasterizer: Add rasterizer cache code to handle accerated fermi copies. (diff)
downloadyuzu-9aec85d39c0c95419bd086ccac158dbb77c20002.tar.gz
yuzu-9aec85d39c0c95419bd086ccac158dbb77c20002.tar.xz
yuzu-9aec85d39c0c95419bd086ccac158dbb77c20002.zip
fermi_2d: Implement simple copies with AccelerateSurfaceCopy.
Diffstat (limited to '')
-rw-r--r--src/video_core/engines/fermi_2d.cpp50
-rw-r--r--src/video_core/engines/fermi_2d.h8
-rw-r--r--src/video_core/gpu.cpp2
3 files changed, 36 insertions, 24 deletions
diff --git a/src/video_core/engines/fermi_2d.cpp b/src/video_core/engines/fermi_2d.cpp
index ea1555c5d..912e785b9 100644
--- a/src/video_core/engines/fermi_2d.cpp
+++ b/src/video_core/engines/fermi_2d.cpp
@@ -4,11 +4,13 @@
4 4
5#include "core/memory.h" 5#include "core/memory.h"
6#include "video_core/engines/fermi_2d.h" 6#include "video_core/engines/fermi_2d.h"
7#include "video_core/rasterizer_interface.h"
7#include "video_core/textures/decoders.h" 8#include "video_core/textures/decoders.h"
8 9
9namespace Tegra::Engines { 10namespace Tegra::Engines {
10 11
11Fermi2D::Fermi2D(MemoryManager& memory_manager) : memory_manager(memory_manager) {} 12Fermi2D::Fermi2D(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager)
13 : memory_manager(memory_manager), rasterizer{rasterizer} {}
12 14
13void Fermi2D::WriteReg(u32 method, u32 value) { 15void Fermi2D::WriteReg(u32 method, u32 value) {
14 ASSERT_MSG(method < Regs::NUM_REGS, 16 ASSERT_MSG(method < Regs::NUM_REGS,
@@ -44,27 +46,31 @@ void Fermi2D::HandleSurfaceCopy() {
44 u32 src_bytes_per_pixel = RenderTargetBytesPerPixel(regs.src.format); 46 u32 src_bytes_per_pixel = RenderTargetBytesPerPixel(regs.src.format);
45 u32 dst_bytes_per_pixel = RenderTargetBytesPerPixel(regs.dst.format); 47 u32 dst_bytes_per_pixel = RenderTargetBytesPerPixel(regs.dst.format);
46 48
47 if (regs.src.linear == regs.dst.linear) { 49 if (!rasterizer.AccelerateSurfaceCopy(regs.src, regs.dst)) {
48 // If the input layout and the output layout are the same, just perform a raw copy. 50 // TODO(bunnei): The below implementation currently will not get hit, as
49 ASSERT(regs.src.BlockHeight() == regs.dst.BlockHeight()); 51 // AccelerateSurfaceCopy tries to always copy and will always return success. This should be
50 Memory::CopyBlock(dest_cpu, source_cpu, 52 // changed once we properly support flushing.
51 src_bytes_per_pixel * regs.dst.width * regs.dst.height); 53
52 return; 54 if (regs.src.linear == regs.dst.linear) {
53 } 55 // If the input layout and the output layout are the same, just perform a raw copy.
54 56 ASSERT(regs.src.BlockHeight() == regs.dst.BlockHeight());
55 u8* src_buffer = Memory::GetPointer(source_cpu); 57 Memory::CopyBlock(dest_cpu, source_cpu,
56 u8* dst_buffer = Memory::GetPointer(dest_cpu); 58 src_bytes_per_pixel * regs.dst.width * regs.dst.height);
57 59 return;
58 if (!regs.src.linear && regs.dst.linear) { 60 }
59 // If the input is tiled and the output is linear, deswizzle the input and copy it over. 61 u8* src_buffer = Memory::GetPointer(source_cpu);
60 Texture::CopySwizzledData(regs.src.width, regs.src.height, src_bytes_per_pixel, 62 u8* dst_buffer = Memory::GetPointer(dest_cpu);
61 dst_bytes_per_pixel, src_buffer, dst_buffer, true, 63 if (!regs.src.linear && regs.dst.linear) {
62 regs.src.BlockHeight()); 64 // If the input is tiled and the output is linear, deswizzle the input and copy it over.
63 } else { 65 Texture::CopySwizzledData(regs.src.width, regs.src.height, src_bytes_per_pixel,
64 // If the input is linear and the output is tiled, swizzle the input and copy it over. 66 dst_bytes_per_pixel, src_buffer, dst_buffer, true,
65 Texture::CopySwizzledData(regs.src.width, regs.src.height, src_bytes_per_pixel, 67 regs.src.BlockHeight());
66 dst_bytes_per_pixel, dst_buffer, src_buffer, false, 68 } else {
67 regs.dst.BlockHeight()); 69 // If the input is linear and the output is tiled, swizzle the input and copy it over.
70 Texture::CopySwizzledData(regs.src.width, regs.src.height, src_bytes_per_pixel,
71 dst_bytes_per_pixel, dst_buffer, src_buffer, false,
72 regs.dst.BlockHeight());
73 }
68 } 74 }
69} 75}
70 76
diff --git a/src/video_core/engines/fermi_2d.h b/src/video_core/engines/fermi_2d.h
index 021b83eaa..81d15c62a 100644
--- a/src/video_core/engines/fermi_2d.h
+++ b/src/video_core/engines/fermi_2d.h
@@ -12,6 +12,10 @@
12#include "video_core/gpu.h" 12#include "video_core/gpu.h"
13#include "video_core/memory_manager.h" 13#include "video_core/memory_manager.h"
14 14
15namespace VideoCore {
16class RasterizerInterface;
17}
18
15namespace Tegra::Engines { 19namespace Tegra::Engines {
16 20
17#define FERMI2D_REG_INDEX(field_name) \ 21#define FERMI2D_REG_INDEX(field_name) \
@@ -19,7 +23,7 @@ namespace Tegra::Engines {
19 23
20class Fermi2D final { 24class Fermi2D final {
21public: 25public:
22 explicit Fermi2D(MemoryManager& memory_manager); 26 explicit Fermi2D(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager);
23 ~Fermi2D() = default; 27 ~Fermi2D() = default;
24 28
25 /// Write the value to the register identified by method. 29 /// Write the value to the register identified by method.
@@ -94,6 +98,8 @@ public:
94 MemoryManager& memory_manager; 98 MemoryManager& memory_manager;
95 99
96private: 100private:
101 VideoCore::RasterizerInterface& rasterizer;
102
97 /// Performs the copy from the source surface to the destination surface as configured in the 103 /// Performs the copy from the source surface to the destination surface as configured in the
98 /// registers. 104 /// registers.
99 void HandleSurfaceCopy(); 105 void HandleSurfaceCopy();
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index baa8b63b7..9ba7e3533 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -25,7 +25,7 @@ u32 FramebufferConfig::BytesPerPixel(PixelFormat format) {
25GPU::GPU(VideoCore::RasterizerInterface& rasterizer) { 25GPU::GPU(VideoCore::RasterizerInterface& rasterizer) {
26 memory_manager = std::make_unique<Tegra::MemoryManager>(); 26 memory_manager = std::make_unique<Tegra::MemoryManager>();
27 maxwell_3d = std::make_unique<Engines::Maxwell3D>(rasterizer, *memory_manager); 27 maxwell_3d = std::make_unique<Engines::Maxwell3D>(rasterizer, *memory_manager);
28 fermi_2d = std::make_unique<Engines::Fermi2D>(*memory_manager); 28 fermi_2d = std::make_unique<Engines::Fermi2D>(rasterizer, *memory_manager);
29 maxwell_compute = std::make_unique<Engines::MaxwellCompute>(); 29 maxwell_compute = std::make_unique<Engines::MaxwellCompute>();
30 maxwell_dma = std::make_unique<Engines::MaxwellDMA>(*memory_manager); 30 maxwell_dma = std::make_unique<Engines::MaxwellDMA>(*memory_manager);
31 kepler_memory = std::make_unique<Engines::KeplerMemory>(*memory_manager); 31 kepler_memory = std::make_unique<Engines::KeplerMemory>(*memory_manager);