Skip to content

Commit 558aeec

Browse files
committed
Readbacks proof of concept shadps4-emu#2668
1 parent 2d68a91 commit 558aeec

File tree

15 files changed

+413
-201
lines changed

15 files changed

+413
-201
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp
816816
src/video_core/buffer_cache/buffer.h
817817
src/video_core/buffer_cache/buffer_cache.cpp
818818
src/video_core/buffer_cache/buffer_cache.h
819-
src/video_core/buffer_cache/memory_tracker_base.h
819+
src/video_core/buffer_cache/memory_tracker.h
820820
src/video_core/buffer_cache/range_set.h
821821
src/video_core/buffer_cache/word_manager.h
822822
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
{
@@ -605,9 +606,8 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
605606
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
606607
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
607608
dma_data->dst_sel == DmaDataDst::Gds) {
608-
rasterizer->InlineData(dma_data->dst_addr_lo,
609-
dma_data->SrcAddress<const void*>(),
610-
dma_data->NumBytes(), true);
609+
rasterizer->CopyBuffer(dma_data->dst_addr_lo, dma_data->SrcAddress<VAddr>(),
610+
dma_data->NumBytes(), true, false);
611611
} else if (dma_data->src_sel == DmaDataSrc::Data &&
612612
(dma_data->dst_sel == DmaDataDst::Memory ||
613613
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
@@ -616,14 +616,15 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
616616
} else if (dma_data->src_sel == DmaDataSrc::Gds &&
617617
(dma_data->dst_sel == DmaDataDst::Memory ||
618618
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
619-
// LOG_WARNING(Render_Vulkan, "GDS memory read");
619+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->src_addr_lo,
620+
dma_data->NumBytes(), false, true);
620621
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
621622
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
622623
(dma_data->dst_sel == DmaDataDst::Memory ||
623624
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
624-
rasterizer->InlineData(dma_data->DstAddress<VAddr>(),
625-
dma_data->SrcAddress<const void*>(),
626-
dma_data->NumBytes(), false);
625+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(),
626+
dma_data->SrcAddress<VAddr>(), dma_data->NumBytes(),
627+
false, false);
627628
} else {
628629
UNREACHABLE_MSG("WriteData src_sel = {}, dst_sel = {}",
629630
u32(dma_data->src_sel.Value()), u32(dma_data->dst_sel.Value()));
@@ -659,6 +660,9 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
659660
break;
660661
}
661662
case PM4ItOpcode::Rewind: {
663+
if (!rasterizer) {
664+
break;
665+
}
662666
const PM4CmdRewind* rewind = reinterpret_cast<const PM4CmdRewind*>(header);
663667
while (!rewind->Valid()) {
664668
YIELD_GFX();
@@ -794,8 +798,8 @@ Liverpool::Task Liverpool::ProcessCompute(const u32* acb, u32 acb_dwords, u32 vq
794798
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
795799
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
796800
dma_data->dst_sel == DmaDataDst::Gds) {
797-
rasterizer->InlineData(dma_data->dst_addr_lo, dma_data->SrcAddress<const void*>(),
798-
dma_data->NumBytes(), true);
801+
rasterizer->CopyBuffer(dma_data->dst_addr_lo, dma_data->SrcAddress<VAddr>(),
802+
dma_data->NumBytes(), true, false);
799803
} else if (dma_data->src_sel == DmaDataSrc::Data &&
800804
(dma_data->dst_sel == DmaDataDst::Memory ||
801805
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
@@ -804,14 +808,14 @@ Liverpool::Task Liverpool::ProcessCompute(const u32* acb, u32 acb_dwords, u32 vq
804808
} else if (dma_data->src_sel == DmaDataSrc::Gds &&
805809
(dma_data->dst_sel == DmaDataDst::Memory ||
806810
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
807-
// LOG_WARNING(Render_Vulkan, "GDS memory read");
811+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->src_addr_lo,
812+
dma_data->NumBytes(), false, true);
808813
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
809814
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
810815
(dma_data->dst_sel == DmaDataDst::Memory ||
811816
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
812-
rasterizer->InlineData(dma_data->DstAddress<VAddr>(),
813-
dma_data->SrcAddress<const void*>(), dma_data->NumBytes(),
814-
false);
817+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->SrcAddress<VAddr>(),
818+
dma_data->NumBytes(), false, false);
815819
} else {
816820
UNREACHABLE_MSG("WriteData src_sel = {}, dst_sel = {}",
817821
u32(dma_data->src_sel.Value()), u32(dma_data->dst_sel.Value()));
@@ -822,6 +826,9 @@ Liverpool::Task Liverpool::ProcessCompute(const u32* acb, u32 acb_dwords, u32 vq
822826
break;
823827
}
824828
case PM4ItOpcode::Rewind: {
829+
if (!rasterizer) {
830+
break;
831+
}
825832
const PM4CmdRewind* rewind = reinterpret_cast<const PM4CmdRewind*>(header);
826833
while (!rewind->Valid()) {
827834
YIELD_ASC(vqid);

src/video_core/amdgpu/liverpool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,7 @@ struct Liverpool {
15051505
u32 tmp_dwords;
15061506
};
15071507
Common::SlotVector<AscQueueInfo> asc_queues{};
1508+
std::thread::id gpu_id;
15081509

15091510
private:
15101511
struct Task {

0 commit comments

Comments
 (0)