summaryrefslogtreecommitdiff
path: root/src/video_core/engines
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-07-04 18:42:10 -0300
committerGravatar ReinUsesLisp2020-07-10 04:09:32 -0300
commitc574ab5aa1d3ff81b28ddfbba3818b3ce724aa32 (patch)
treebfd4107fc64c09c767be6bfe79c4904075ce0307 /src/video_core/engines
parentmaxwell_dma: Rename registers to match official docs and reorder (diff)
downloadyuzu-c574ab5aa1d3ff81b28ddfbba3818b3ce724aa32.tar.gz
yuzu-c574ab5aa1d3ff81b28ddfbba3818b3ce724aa32.tar.xz
yuzu-c574ab5aa1d3ff81b28ddfbba3818b3ce724aa32.zip
video_core/textures: Add and use SwizzleSliceToVoxel, and minor style changes
Change GOB sizes from free-functions to constexpr constants. Add SwizzleSliceToVoxel, a function that swizzles a 2D array of pixels into a 3D texture and use it for 3D copies.
Diffstat (limited to 'src/video_core/engines')
-rw-r--r--src/video_core/engines/maxwell_dma.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp
index 28faad9ff..a2d3d7823 100644
--- a/src/video_core/engines/maxwell_dma.cpp
+++ b/src/video_core/engines/maxwell_dma.cpp
@@ -37,7 +37,8 @@ void MaxwellDMA::CallMultiMethod(u32 method, const u32* base_start, u32 amount,
37} 37}
38 38
39void MaxwellDMA::Launch() { 39void MaxwellDMA::Launch() {
40 LOG_TRACE(HW_GPU, "Requested a DMA copy"); 40 LOG_TRACE(Render_OpenGL, "DMA copy 0x{:x} -> 0x{:x}", static_cast<GPUVAddr>(regs.offset_in),
41 static_cast<GPUVAddr>(regs.offset_out));
41 42
42 // TODO(Subv): Perform more research and implement all features of this engine. 43 // TODO(Subv): Perform more research and implement all features of this engine.
43 const LaunchDMA& launch = regs.launch_dma; 44 const LaunchDMA& launch = regs.launch_dma;
@@ -97,7 +98,7 @@ void MaxwellDMA::CopyBlockLinearToPitch() {
97 98
98 // Optimized path for micro copies. 99 // Optimized path for micro copies.
99 const size_t dst_size = static_cast<size_t>(regs.pitch_out) * regs.line_count; 100 const size_t dst_size = static_cast<size_t>(regs.pitch_out) * regs.line_count;
100 if (dst_size < GetGOBSize() && regs.pitch_out <= 64) { 101 if (dst_size < GOB_SIZE && regs.pitch_out <= GOB_SIZE_X) {
101 FastCopyBlockLinearToPitch(); 102 FastCopyBlockLinearToPitch();
102 return; 103 return;
103 } 104 }
@@ -130,18 +131,15 @@ void MaxwellDMA::CopyBlockLinearToPitch() {
130 memory_manager.ReadBlockUnsafe(regs.offset_out, write_buffer.data(), dst_size); 131 memory_manager.ReadBlockUnsafe(regs.offset_out, write_buffer.data(), dst_size);
131 } 132 }
132 133
133 UnswizzleSubrect(regs.line_length_in, regs.line_count, regs.pitch_out, src_params.width, 134 UnswizzleSubrect(regs.line_length_in, regs.line_count, regs.pitch_out, width, bytes_per_pixel,
134 bytes_per_pixel, read_buffer.data() + src_layer_size * src_params.layer, 135 read_buffer.data() + src_layer_size * src_params.layer, write_buffer.data(),
135 write_buffer.data(), src_params.block_size.height, src_params.origin.x, 136 block_height, src_params.origin.x, src_params.origin.y);
136 src_params.origin.y);
137 137
138 memory_manager.WriteBlock(regs.offset_out, write_buffer.data(), dst_size); 138 memory_manager.WriteBlock(regs.offset_out, write_buffer.data(), dst_size);
139} 139}
140 140
141void MaxwellDMA::CopyPitchToBlockLinear() { 141void MaxwellDMA::CopyPitchToBlockLinear() {
142 const auto& dst_params = regs.dst_params; 142 const auto& dst_params = regs.dst_params;
143 ASSERT(dst_params.block_size.depth == 0);
144
145 const u32 bytes_per_pixel = regs.pitch_in / regs.line_length_in; 143 const u32 bytes_per_pixel = regs.pitch_in / regs.line_length_in;
146 const u32 width = dst_params.width; 144 const u32 width = dst_params.width;
147 const u32 height = dst_params.height; 145 const u32 height = dst_params.height;
@@ -171,17 +169,23 @@ void MaxwellDMA::CopyPitchToBlockLinear() {
171 } 169 }
172 170
173 // If the input is linear and the output is tiled, swizzle the input and copy it over. 171 // If the input is linear and the output is tiled, swizzle the input and copy it over.
174 SwizzleSubrect(regs.line_length_in, regs.line_count, regs.pitch_in, dst_params.width, 172 if (regs.dst_params.block_size.depth > 0) {
175 bytes_per_pixel, write_buffer.data() + dst_layer_size * dst_params.layer, 173 ASSERT(dst_params.layer == 0);
176 read_buffer.data(), dst_params.block_size.height, dst_params.origin.x, 174 SwizzleSliceToVoxel(regs.line_length_in, regs.line_count, regs.pitch_in, width, height,
177 dst_params.origin.y); 175 bytes_per_pixel, block_height, block_depth, dst_params.origin.x,
176 dst_params.origin.y, write_buffer.data(), read_buffer.data());
177 } else {
178 SwizzleSubrect(regs.line_length_in, regs.line_count, regs.pitch_in, width, bytes_per_pixel,
179 write_buffer.data() + dst_layer_size * dst_params.layer, read_buffer.data(),
180 block_height, dst_params.origin.x, dst_params.origin.y);
181 }
178 182
179 memory_manager.WriteBlock(regs.offset_out, write_buffer.data(), dst_size); 183 memory_manager.WriteBlock(regs.offset_out, write_buffer.data(), dst_size);
180} 184}
181 185
182void MaxwellDMA::FastCopyBlockLinearToPitch() { 186void MaxwellDMA::FastCopyBlockLinearToPitch() {
183 const u32 bytes_per_pixel = regs.pitch_out / regs.line_length_in; 187 const u32 bytes_per_pixel = regs.pitch_out / regs.line_length_in;
184 const size_t src_size = GetGOBSize(); 188 const size_t src_size = GOB_SIZE;
185 const size_t dst_size = static_cast<size_t>(regs.pitch_out) * regs.line_count; 189 const size_t dst_size = static_cast<size_t>(regs.pitch_out) * regs.line_count;
186 u32 pos_x = regs.src_params.origin.x; 190 u32 pos_x = regs.src_params.origin.x;
187 u32 pos_y = regs.src_params.origin.y; 191 u32 pos_y = regs.src_params.origin.y;