diff options
| author | 2021-09-30 12:34:28 -0700 | |
|---|---|---|
| committer | 2021-09-30 12:34:28 -0700 | |
| commit | 8bd5742349007d3faa9d786450a20f31d5db0b94 (patch) | |
| tree | 29c7669c76fcd9ff5dcd3aa204f68b9af88437a2 | |
| parent | Merge pull request #7104 from Morph1984/style (diff) | |
| parent | maxwell_dma: Minor refactoring (diff) | |
| download | yuzu-8bd5742349007d3faa9d786450a20f31d5db0b94.tar.gz yuzu-8bd5742349007d3faa9d786450a20f31d5db0b94.tar.xz yuzu-8bd5742349007d3faa9d786450a20f31d5db0b94.zip | |
Merge pull request #7061 from ameerj/dma-buffer-misc
buffer_cache, maxwell_dma: Minor refactoring and code fixes
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/buffer_cache/buffer_cache.h | 7 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_dma.cpp | 64 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_dma.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_buffer_cache.cpp | 3 |
4 files changed, 37 insertions, 39 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 7bfd57369..d350c9b36 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -570,13 +570,12 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am | |||
| 570 | ForEachWrittenRange(*cpu_src_address, amount, mirror); | 570 | ForEachWrittenRange(*cpu_src_address, amount, mirror); |
| 571 | // This subtraction in this order is important for overlapping copies. | 571 | // This subtraction in this order is important for overlapping copies. |
| 572 | common_ranges.subtract(subtract_interval); | 572 | common_ranges.subtract(subtract_interval); |
| 573 | bool atleast_1_download = tmp_intervals.size() != 0; | 573 | const bool has_new_downloads = tmp_intervals.size() != 0; |
| 574 | for (const IntervalType add_interval : tmp_intervals) { | 574 | for (const IntervalType& add_interval : tmp_intervals) { |
| 575 | common_ranges.add(add_interval); | 575 | common_ranges.add(add_interval); |
| 576 | } | 576 | } |
| 577 | |||
| 578 | runtime.CopyBuffer(dest_buffer, src_buffer, copies); | 577 | runtime.CopyBuffer(dest_buffer, src_buffer, copies); |
| 579 | if (atleast_1_download) { | 578 | if (has_new_downloads) { |
| 580 | dest_buffer.MarkRegionAsGpuModified(*cpu_dest_address, amount); | 579 | dest_buffer.MarkRegionAsGpuModified(*cpu_dest_address, amount); |
| 581 | } | 580 | } |
| 582 | std::vector<u8> tmp_buffer(amount); | 581 | std::vector<u8> tmp_buffer(amount); |
diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index c7ec1eac9..67388d980 100644 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp | |||
| @@ -82,41 +82,41 @@ void MaxwellDMA::Launch() { | |||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | void MaxwellDMA::CopyPitchToPitch() { | 84 | void MaxwellDMA::CopyPitchToPitch() { |
| 85 | // When `multi_line_enable` bit is disabled the copy is performed as if we were copying a 1D | 85 | // When `multi_line_enable` bit is enabled we copy a 2D image of dimensions |
| 86 | // buffer of length `line_length_in`. | 86 | // (line_length_in, line_count). |
| 87 | // Otherwise we copy a 2D image of dimensions (line_length_in, line_count). | 87 | // Otherwise the copy is performed as if we were copying a 1D buffer of length line_length_in. |
| 88 | auto& accelerate = rasterizer->AccessAccelerateDMA(); | 88 | const bool remap_enabled = regs.launch_dma.remap_enable != 0; |
| 89 | if (!regs.launch_dma.multi_line_enable) { | 89 | if (regs.launch_dma.multi_line_enable) { |
| 90 | const bool is_buffer_clear = regs.launch_dma.remap_enable != 0 && | 90 | UNIMPLEMENTED_IF(remap_enabled); |
| 91 | regs.remap_const.dst_x == RemapConst::Swizzle::CONST_A; | 91 | |
| 92 | // TODO: allow multisized components. | 92 | // Perform a line-by-line copy. |
| 93 | if (is_buffer_clear) { | 93 | // We're going to take a subrect of size (line_length_in, line_count) from the source |
| 94 | ASSERT(regs.remap_const.component_size_minus_one == 3); | 94 | // rectangle. There is no need to manually flush/invalidate the regions because CopyBlock |
| 95 | accelerate.BufferClear(regs.offset_out, regs.line_length_in, regs.remap_consta_value); | 95 | // does that for us. |
| 96 | std::vector<u32> tmp_buffer(regs.line_length_in, regs.remap_consta_value); | 96 | for (u32 line = 0; line < regs.line_count; ++line) { |
| 97 | memory_manager.WriteBlockUnsafe(regs.offset_out, | 97 | const GPUVAddr source_line = regs.offset_in + static_cast<size_t>(line) * regs.pitch_in; |
| 98 | reinterpret_cast<u8*>(tmp_buffer.data()), | 98 | const GPUVAddr dest_line = regs.offset_out + static_cast<size_t>(line) * regs.pitch_out; |
| 99 | regs.line_length_in * sizeof(u32)); | 99 | memory_manager.CopyBlock(dest_line, source_line, regs.line_length_in); |
| 100 | return; | ||
| 101 | } | ||
| 102 | UNIMPLEMENTED_IF(regs.launch_dma.remap_enable != 0); | ||
| 103 | if (!accelerate.BufferCopy(regs.offset_in, regs.offset_out, regs.line_length_in)) { | ||
| 104 | std::vector<u8> tmp_buffer(regs.line_length_in); | ||
| 105 | memory_manager.ReadBlockUnsafe(regs.offset_in, tmp_buffer.data(), regs.line_length_in); | ||
| 106 | memory_manager.WriteBlock(regs.offset_out, tmp_buffer.data(), regs.line_length_in); | ||
| 107 | } | 100 | } |
| 108 | return; | 101 | return; |
| 109 | } | 102 | } |
| 110 | 103 | // TODO: allow multisized components. | |
| 111 | UNIMPLEMENTED_IF(regs.launch_dma.remap_enable != 0); | 104 | auto& accelerate = rasterizer->AccessAccelerateDMA(); |
| 112 | 105 | const bool is_const_a_dst = regs.remap_const.dst_x == RemapConst::Swizzle::CONST_A; | |
| 113 | // Perform a line-by-line copy. | 106 | const bool is_buffer_clear = remap_enabled && is_const_a_dst; |
| 114 | // We're going to take a subrect of size (line_length_in, line_count) from the source rectangle. | 107 | if (is_buffer_clear) { |
| 115 | // There is no need to manually flush/invalidate the regions because CopyBlock does that for us. | 108 | ASSERT(regs.remap_const.component_size_minus_one == 3); |
| 116 | for (u32 line = 0; line < regs.line_count; ++line) { | 109 | accelerate.BufferClear(regs.offset_out, regs.line_length_in, regs.remap_consta_value); |
| 117 | const GPUVAddr source_line = regs.offset_in + static_cast<size_t>(line) * regs.pitch_in; | 110 | std::vector<u32> tmp_buffer(regs.line_length_in, regs.remap_consta_value); |
| 118 | const GPUVAddr dest_line = regs.offset_out + static_cast<size_t>(line) * regs.pitch_out; | 111 | memory_manager.WriteBlockUnsafe(regs.offset_out, reinterpret_cast<u8*>(tmp_buffer.data()), |
| 119 | memory_manager.CopyBlock(dest_line, source_line, regs.line_length_in); | 112 | regs.line_length_in * sizeof(u32)); |
| 113 | return; | ||
| 114 | } | ||
| 115 | UNIMPLEMENTED_IF(remap_enabled); | ||
| 116 | if (!accelerate.BufferCopy(regs.offset_in, regs.offset_out, regs.line_length_in)) { | ||
| 117 | std::vector<u8> tmp_buffer(regs.line_length_in); | ||
| 118 | memory_manager.ReadBlockUnsafe(regs.offset_in, tmp_buffer.data(), regs.line_length_in); | ||
| 119 | memory_manager.WriteBlock(regs.offset_out, tmp_buffer.data(), regs.line_length_in); | ||
| 120 | } | 120 | } |
| 121 | } | 121 | } |
| 122 | 122 | ||
diff --git a/src/video_core/engines/maxwell_dma.h b/src/video_core/engines/maxwell_dma.h index 9e457ae16..a04514425 100644 --- a/src/video_core/engines/maxwell_dma.h +++ b/src/video_core/engines/maxwell_dma.h | |||
| @@ -175,7 +175,7 @@ public: | |||
| 175 | static_assert(sizeof(LaunchDMA) == 4); | 175 | static_assert(sizeof(LaunchDMA) == 4); |
| 176 | 176 | ||
| 177 | struct RemapConst { | 177 | struct RemapConst { |
| 178 | enum Swizzle : u32 { | 178 | enum class Swizzle : u32 { |
| 179 | SRC_X = 0, | 179 | SRC_X = 0, |
| 180 | SRC_Y = 1, | 180 | SRC_Y = 1, |
| 181 | SRC_Z = 2, | 181 | SRC_Z = 2, |
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp index 07a995f7d..187a28e4d 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp | |||
| @@ -147,8 +147,7 @@ void BufferCacheRuntime::CopyBuffer(Buffer& dst_buffer, Buffer& src_buffer, | |||
| 147 | 147 | ||
| 148 | void BufferCacheRuntime::ClearBuffer(Buffer& dest_buffer, u32 offset, size_t size, u32 value) { | 148 | void BufferCacheRuntime::ClearBuffer(Buffer& dest_buffer, u32 offset, size_t size, u32 value) { |
| 149 | glClearNamedBufferSubData(dest_buffer.Handle(), GL_R32UI, static_cast<GLintptr>(offset), | 149 | glClearNamedBufferSubData(dest_buffer.Handle(), GL_R32UI, static_cast<GLintptr>(offset), |
| 150 | static_cast<GLsizeiptr>(size / sizeof(u32)), GL_RED, GL_UNSIGNED_INT, | 150 | static_cast<GLsizeiptr>(size), GL_RED, GL_UNSIGNED_INT, &value); |
| 151 | &value); | ||
| 152 | } | 151 | } |
| 153 | 152 | ||
| 154 | void BufferCacheRuntime::BindIndexBuffer(Buffer& buffer, u32 offset, u32 size) { | 153 | void BufferCacheRuntime::BindIndexBuffer(Buffer& buffer, u32 offset, u32 size) { |