summaryrefslogtreecommitdiffstats
path: root/src/video_core/engines
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-04-22 22:47:05 +0200
committerGitHub <noreply@github.com>2019-04-22 22:47:05 +0200
commit01100f8afdc22cfcc0b94b86b7e352a41120b8d9 (patch)
tree40dc11e843f60d886ff7d4ddecab694cc4ce6451 /src/video_core/engines
parentMerge pull request #2407 from FernandoS27/f2f (diff)
parentApply Const correctness to SwizzleKepler and replace u32 for size_t on iterators. (diff)
downloadyuzu-01100f8afdc22cfcc0b94b86b7e352a41120b8d9.tar
yuzu-01100f8afdc22cfcc0b94b86b7e352a41120b8d9.tar.gz
yuzu-01100f8afdc22cfcc0b94b86b7e352a41120b8d9.tar.bz2
yuzu-01100f8afdc22cfcc0b94b86b7e352a41120b8d9.tar.lz
yuzu-01100f8afdc22cfcc0b94b86b7e352a41120b8d9.tar.xz
yuzu-01100f8afdc22cfcc0b94b86b7e352a41120b8d9.tar.zst
yuzu-01100f8afdc22cfcc0b94b86b7e352a41120b8d9.zip
Diffstat (limited to 'src/video_core/engines')
-rw-r--r--src/video_core/engines/kepler_memory.cpp47
-rw-r--r--src/video_core/engines/kepler_memory.h24
2 files changed, 54 insertions, 17 deletions
diff --git a/src/video_core/engines/kepler_memory.cpp b/src/video_core/engines/kepler_memory.cpp
index cd51a31d7..7387886a3 100644
--- a/src/video_core/engines/kepler_memory.cpp
+++ b/src/video_core/engines/kepler_memory.cpp
@@ -10,6 +10,7 @@
#include "video_core/memory_manager.h"
#include "video_core/rasterizer_interface.h"
#include "video_core/renderer_base.h"
+#include "video_core/textures/decoders.h"
namespace Tegra::Engines {
@@ -27,30 +28,46 @@ void KeplerMemory::CallMethod(const GPU::MethodCall& method_call) {
switch (method_call.method) {
case KEPLERMEMORY_REG_INDEX(exec): {
- state.write_offset = 0;
+ ProcessExec();
break;
}
case KEPLERMEMORY_REG_INDEX(data): {
- ProcessData(method_call.argument);
+ ProcessData(method_call.argument, method_call.IsLastCall());
break;
}
}
}
-void KeplerMemory::ProcessData(u32 data) {
- ASSERT_MSG(regs.exec.linear, "Non-linear uploads are not supported");
- ASSERT(regs.dest.x == 0 && regs.dest.y == 0 && regs.dest.z == 0);
-
- // We have to invalidate the destination region to evict any outdated surfaces from the cache.
- // We do this before actually writing the new data because the destination address might
- // contain a dirty surface that will have to be written back to memory.
- const GPUVAddr address{regs.dest.Address() + state.write_offset * sizeof(u32)};
- rasterizer.InvalidateRegion(ToCacheAddr(memory_manager.GetPointer(address)), sizeof(u32));
- memory_manager.Write<u32>(address, data);
-
- system.GPU().Maxwell3D().dirty_flags.OnMemoryWrite();
+void KeplerMemory::ProcessExec() {
+ state.write_offset = 0;
+ state.copy_size = regs.line_length_in * regs.line_count;
+ state.inner_buffer.resize(state.copy_size);
+}
- state.write_offset++;
+void KeplerMemory::ProcessData(u32 data, bool is_last_call) {
+ const u32 sub_copy_size = std::min(4U, state.copy_size - state.write_offset);
+ std::memcpy(&state.inner_buffer[state.write_offset], &regs.data, sub_copy_size);
+ state.write_offset += sub_copy_size;
+ if (is_last_call) {
+ const GPUVAddr address{regs.dest.Address()};
+ if (regs.exec.linear != 0) {
+ memory_manager.WriteBlock(address, state.inner_buffer.data(), state.copy_size);
+ } else {
+ UNIMPLEMENTED_IF(regs.dest.z != 0);
+ UNIMPLEMENTED_IF(regs.dest.depth != 1);
+ UNIMPLEMENTED_IF(regs.dest.BlockWidth() != 1);
+ UNIMPLEMENTED_IF(regs.dest.BlockDepth() != 1);
+ const std::size_t dst_size = Tegra::Texture::CalculateSize(
+ true, 1, regs.dest.width, regs.dest.height, 1, regs.dest.BlockHeight(), 1);
+ std::vector<u8> tmp_buffer(dst_size);
+ memory_manager.ReadBlock(address, tmp_buffer.data(), dst_size);
+ Tegra::Texture::SwizzleKepler(regs.dest.width, regs.dest.height, regs.dest.x,
+ regs.dest.y, regs.dest.BlockHeight(), state.copy_size,
+ state.inner_buffer.data(), tmp_buffer.data());
+ memory_manager.WriteBlock(address, tmp_buffer.data(), dst_size);
+ }
+ system.GPU().Maxwell3D().dirty_flags.OnMemoryWrite();
+ }
}
} // namespace Tegra::Engines
diff --git a/src/video_core/engines/kepler_memory.h b/src/video_core/engines/kepler_memory.h
index 78b6c3e45..5f892ddad 100644
--- a/src/video_core/engines/kepler_memory.h
+++ b/src/video_core/engines/kepler_memory.h
@@ -6,6 +6,7 @@
#include <array>
#include <cstddef>
+#include <vector>
#include "common/bit_field.h"
#include "common/common_funcs.h"
#include "common/common_types.h"
@@ -51,7 +52,11 @@ public:
u32 address_high;
u32 address_low;
u32 pitch;
- u32 block_dimensions;
+ union {
+ BitField<0, 4, u32> block_width;
+ BitField<4, 4, u32> block_height;
+ BitField<8, 4, u32> block_depth;
+ };
u32 width;
u32 height;
u32 depth;
@@ -63,6 +68,18 @@ public:
return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) |
address_low);
}
+
+ u32 BlockWidth() const {
+ return 1U << block_width.Value();
+ }
+
+ u32 BlockHeight() const {
+ return 1U << block_height.Value();
+ }
+
+ u32 BlockDepth() const {
+ return 1U << block_depth.Value();
+ }
} dest;
struct {
@@ -81,6 +98,8 @@ public:
struct {
u32 write_offset = 0;
+ u32 copy_size = 0;
+ std::vector<u8> inner_buffer;
} state{};
private:
@@ -88,7 +107,8 @@ private:
VideoCore::RasterizerInterface& rasterizer;
MemoryManager& memory_manager;
- void ProcessData(u32 data);
+ void ProcessExec();
+ void ProcessData(u32 data, bool is_last_call);
};
#define ASSERT_REG_POSITION(field_name, position) \