Skip to content

Commit 5e01798

Browse files
committed
Readbacks proof of concept shadps4-emu#2668
1 parent b743484 commit 5e01798

File tree

14 files changed

+413
-201
lines changed

14 files changed

+413
-201
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp
897897
src/video_core/buffer_cache/buffer.h
898898
src/video_core/buffer_cache/buffer_cache.cpp
899899
src/video_core/buffer_cache/buffer_cache.h
900-
src/video_core/buffer_cache/memory_tracker_base.h
900+
src/video_core/buffer_cache/memory_tracker.h
901901
src/video_core/buffer_cache/range_set.h
902902
src/video_core/buffer_cache/word_manager.h
903903
src/video_core/renderer_vulkan/liverpool_to_vk.cpp

src/core/address_space.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,15 @@ struct AddressSpace::Impl {
302302
new_flags = PAGE_READWRITE;
303303
} else if (read && !write) {
304304
new_flags = PAGE_READONLY;
305-
} else if (execute && !read && not write) {
305+
} else if (execute && !read && !write) {
306306
new_flags = PAGE_EXECUTE;
307307
} else if (!read && !write && !execute) {
308308
new_flags = PAGE_NOACCESS;
309309
} else {
310310
LOG_CRITICAL(Common_Memory,
311-
"Unsupported protection flag combination for address {:#x}, size {}",
312-
virtual_addr, size);
311+
"Unsupported protection flag combination for address {:#x}, size {}, "
312+
"read={}, write={}, execute={}",
313+
virtual_addr, size, read, write, execute);
313314
return;
314315
}
315316

src/core/address_space.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespace Core {
1212

1313
enum class MemoryPermission : u32 {
14+
None = 0,
1415
Read = 1 << 0,
1516
Write = 1 << 1,
1617
ReadWrite = Read | Write,

src/video_core/amdgpu/liverpool.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Liverpool::~Liverpool() {
7474

7575
void Liverpool::Process(std::stop_token stoken) {
7676
Common::SetCurrentThreadName("shadPS4:GpuCommandProcessor");
77+
gpu_id = std::this_thread::get_id();
7778

7879
while (!stoken.stop_requested()) {
7980
{
@@ -627,9 +628,8 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
627628
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
628629
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
629630
dma_data->dst_sel == DmaDataDst::Gds) {
630-
rasterizer->InlineData(dma_data->dst_addr_lo,
631-
dma_data->SrcAddress<const void*>(),
632-
dma_data->NumBytes(), true);
631+
rasterizer->CopyBuffer(dma_data->dst_addr_lo, dma_data->SrcAddress<VAddr>(),
632+
dma_data->NumBytes(), true, false);
633633
} else if (dma_data->src_sel == DmaDataSrc::Data &&
634634
(dma_data->dst_sel == DmaDataDst::Memory ||
635635
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
@@ -638,14 +638,15 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
638638
} else if (dma_data->src_sel == DmaDataSrc::Gds &&
639639
(dma_data->dst_sel == DmaDataDst::Memory ||
640640
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
641-
// LOG_WARNING(Render_Vulkan, "GDS memory read");
641+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->src_addr_lo,
642+
dma_data->NumBytes(), false, true);
642643
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
643644
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
644645
(dma_data->dst_sel == DmaDataDst::Memory ||
645646
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
646-
rasterizer->InlineData(dma_data->DstAddress<VAddr>(),
647-
dma_data->SrcAddress<const void*>(),
648-
dma_data->NumBytes(), false);
647+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(),
648+
dma_data->SrcAddress<VAddr>(), dma_data->NumBytes(),
649+
false, false);
649650
} else {
650651
UNREACHABLE_MSG("WriteData src_sel = {}, dst_sel = {}",
651652
u32(dma_data->src_sel.Value()), u32(dma_data->dst_sel.Value()));
@@ -681,6 +682,9 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
681682
break;
682683
}
683684
case PM4ItOpcode::Rewind: {
685+
if (!rasterizer) {
686+
break;
687+
}
684688
const PM4CmdRewind* rewind = reinterpret_cast<const PM4CmdRewind*>(header);
685689
while (!rewind->Valid()) {
686690
YIELD_GFX();
@@ -817,8 +821,8 @@ Liverpool::Task Liverpool::ProcessCompute(const u32* acb, u32 acb_dwords, u32 vq
817821
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
818822
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
819823
dma_data->dst_sel == DmaDataDst::Gds) {
820-
rasterizer->InlineData(dma_data->dst_addr_lo, dma_data->SrcAddress<const void*>(),
821-
dma_data->NumBytes(), true);
824+
rasterizer->CopyBuffer(dma_data->dst_addr_lo, dma_data->SrcAddress<VAddr>(),
825+
dma_data->NumBytes(), true, false);
822826
} else if (dma_data->src_sel == DmaDataSrc::Data &&
823827
(dma_data->dst_sel == DmaDataDst::Memory ||
824828
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
@@ -827,14 +831,14 @@ Liverpool::Task Liverpool::ProcessCompute(const u32* acb, u32 acb_dwords, u32 vq
827831
} else if (dma_data->src_sel == DmaDataSrc::Gds &&
828832
(dma_data->dst_sel == DmaDataDst::Memory ||
829833
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
830-
// LOG_WARNING(Render_Vulkan, "GDS memory read");
834+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->src_addr_lo,
835+
dma_data->NumBytes(), false, true);
831836
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
832837
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
833838
(dma_data->dst_sel == DmaDataDst::Memory ||
834839
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
835-
rasterizer->InlineData(dma_data->DstAddress<VAddr>(),
836-
dma_data->SrcAddress<const void*>(), dma_data->NumBytes(),
837-
false);
840+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->SrcAddress<VAddr>(),
841+
dma_data->NumBytes(), false, false);
838842
} else {
839843
UNREACHABLE_MSG("WriteData src_sel = {}, dst_sel = {}",
840844
u32(dma_data->src_sel.Value()), u32(dma_data->dst_sel.Value()));
@@ -845,6 +849,9 @@ Liverpool::Task Liverpool::ProcessCompute(const u32* acb, u32 acb_dwords, u32 vq
845849
break;
846850
}
847851
case PM4ItOpcode::Rewind: {
852+
if (!rasterizer) {
853+
break;
854+
}
848855
const PM4CmdRewind* rewind = reinterpret_cast<const PM4CmdRewind*>(header);
849856
while (!rewind->Valid()) {
850857
YIELD_ASC(vqid);

src/video_core/amdgpu/liverpool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,7 @@ struct Liverpool {
15121512
u32 tmp_dwords;
15131513
};
15141514
Common::SlotVector<AscQueueInfo> asc_queues{};
1515+
std::thread::id gpu_id;
15151516

15161517
private:
15171518
struct Task {

0 commit comments

Comments
 (0)