From c574ab5aa1d3ff81b28ddfbba3818b3ce724aa32 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Sat, 4 Jul 2020 18:42:10 -0300 Subject: 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. --- src/video_core/engines/maxwell_dma.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/video_core/engines') 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, } void MaxwellDMA::Launch() { - LOG_TRACE(HW_GPU, "Requested a DMA copy"); + LOG_TRACE(Render_OpenGL, "DMA copy 0x{:x} -> 0x{:x}", static_cast(regs.offset_in), + static_cast(regs.offset_out)); // TODO(Subv): Perform more research and implement all features of this engine. const LaunchDMA& launch = regs.launch_dma; @@ -97,7 +98,7 @@ void MaxwellDMA::CopyBlockLinearToPitch() { // Optimized path for micro copies. const size_t dst_size = static_cast(regs.pitch_out) * regs.line_count; - if (dst_size < GetGOBSize() && regs.pitch_out <= 64) { + if (dst_size < GOB_SIZE && regs.pitch_out <= GOB_SIZE_X) { FastCopyBlockLinearToPitch(); return; } @@ -130,18 +131,15 @@ void MaxwellDMA::CopyBlockLinearToPitch() { memory_manager.ReadBlockUnsafe(regs.offset_out, write_buffer.data(), dst_size); } - UnswizzleSubrect(regs.line_length_in, regs.line_count, regs.pitch_out, src_params.width, - bytes_per_pixel, read_buffer.data() + src_layer_size * src_params.layer, - write_buffer.data(), src_params.block_size.height, src_params.origin.x, - src_params.origin.y); + UnswizzleSubrect(regs.line_length_in, regs.line_count, regs.pitch_out, width, bytes_per_pixel, + read_buffer.data() + src_layer_size * src_params.layer, write_buffer.data(), + block_height, src_params.origin.x, src_params.origin.y); memory_manager.WriteBlock(regs.offset_out, write_buffer.data(), dst_size); } void MaxwellDMA::CopyPitchToBlockLinear() { const auto& dst_params = regs.dst_params; - ASSERT(dst_params.block_size.depth == 0); - const u32 bytes_per_pixel = regs.pitch_in / regs.line_length_in; const u32 width = dst_params.width; const u32 height = dst_params.height; @@ -171,17 +169,23 @@ void MaxwellDMA::CopyPitchToBlockLinear() { } // If the input is linear and the output is tiled, swizzle the input and copy it over. - SwizzleSubrect(regs.line_length_in, regs.line_count, regs.pitch_in, dst_params.width, - bytes_per_pixel, write_buffer.data() + dst_layer_size * dst_params.layer, - read_buffer.data(), dst_params.block_size.height, dst_params.origin.x, - dst_params.origin.y); + if (regs.dst_params.block_size.depth > 0) { + ASSERT(dst_params.layer == 0); + SwizzleSliceToVoxel(regs.line_length_in, regs.line_count, regs.pitch_in, width, height, + bytes_per_pixel, block_height, block_depth, dst_params.origin.x, + dst_params.origin.y, write_buffer.data(), read_buffer.data()); + } else { + SwizzleSubrect(regs.line_length_in, regs.line_count, regs.pitch_in, width, bytes_per_pixel, + write_buffer.data() + dst_layer_size * dst_params.layer, read_buffer.data(), + block_height, dst_params.origin.x, dst_params.origin.y); + } memory_manager.WriteBlock(regs.offset_out, write_buffer.data(), dst_size); } void MaxwellDMA::FastCopyBlockLinearToPitch() { const u32 bytes_per_pixel = regs.pitch_out / regs.line_length_in; - const size_t src_size = GetGOBSize(); + const size_t src_size = GOB_SIZE; const size_t dst_size = static_cast(regs.pitch_out) * regs.line_count; u32 pos_x = regs.src_params.origin.x; u32 pos_y = regs.src_params.origin.y; -- cgit v1.2.3