Skip to content

Commit 521ff47

Browse files
committed
Readbacks proof of concept shadps4-emu#2668
1 parent 4794d20 commit 521ff47

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
@@ -905,7 +905,7 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp
905905
src/video_core/buffer_cache/buffer.h
906906
src/video_core/buffer_cache/buffer_cache.cpp
907907
src/video_core/buffer_cache/buffer_cache.h
908-
src/video_core/buffer_cache/memory_tracker_base.h
908+
src/video_core/buffer_cache/memory_tracker.h
909909
src/video_core/buffer_cache/range_set.h
910910
src/video_core/buffer_cache/word_manager.h
911911
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
{
@@ -635,9 +636,8 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
635636
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
636637
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
637638
dma_data->dst_sel == DmaDataDst::Gds) {
638-
rasterizer->InlineData(dma_data->dst_addr_lo,
639-
dma_data->SrcAddress<const void*>(),
640-
dma_data->NumBytes(), true);
639+
rasterizer->CopyBuffer(dma_data->dst_addr_lo, dma_data->SrcAddress<VAddr>(),
640+
dma_data->NumBytes(), true, false);
641641
} else if (dma_data->src_sel == DmaDataSrc::Data &&
642642
(dma_data->dst_sel == DmaDataDst::Memory ||
643643
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
@@ -646,14 +646,15 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
646646
} else if (dma_data->src_sel == DmaDataSrc::Gds &&
647647
(dma_data->dst_sel == DmaDataDst::Memory ||
648648
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
649-
// LOG_WARNING(Render_Vulkan, "GDS memory read");
649+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->src_addr_lo,
650+
dma_data->NumBytes(), false, true);
650651
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
651652
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
652653
(dma_data->dst_sel == DmaDataDst::Memory ||
653654
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
654-
rasterizer->InlineData(dma_data->DstAddress<VAddr>(),
655-
dma_data->SrcAddress<const void*>(),
656-
dma_data->NumBytes(), false);
655+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(),
656+
dma_data->SrcAddress<VAddr>(), dma_data->NumBytes(),
657+
false, false);
657658
} else {
658659
UNREACHABLE_MSG("WriteData src_sel = {}, dst_sel = {}",
659660
u32(dma_data->src_sel.Value()), u32(dma_data->dst_sel.Value()));
@@ -689,6 +690,9 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
689690
break;
690691
}
691692
case PM4ItOpcode::Rewind: {
693+
if (!rasterizer) {
694+
break;
695+
}
692696
const PM4CmdRewind* rewind = reinterpret_cast<const PM4CmdRewind*>(header);
693697
while (!rewind->Valid()) {
694698
YIELD_GFX();
@@ -833,8 +837,8 @@ Liverpool::Task Liverpool::ProcessCompute(const u32* acb, u32 acb_dwords, u32 vq
833837
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
834838
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
835839
dma_data->dst_sel == DmaDataDst::Gds) {
836-
rasterizer->InlineData(dma_data->dst_addr_lo, dma_data->SrcAddress<const void*>(),
837-
dma_data->NumBytes(), true);
840+
rasterizer->CopyBuffer(dma_data->dst_addr_lo, dma_data->SrcAddress<VAddr>(),
841+
dma_data->NumBytes(), true, false);
838842
} else if (dma_data->src_sel == DmaDataSrc::Data &&
839843
(dma_data->dst_sel == DmaDataDst::Memory ||
840844
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
@@ -843,14 +847,14 @@ Liverpool::Task Liverpool::ProcessCompute(const u32* acb, u32 acb_dwords, u32 vq
843847
} else if (dma_data->src_sel == DmaDataSrc::Gds &&
844848
(dma_data->dst_sel == DmaDataDst::Memory ||
845849
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
846-
// LOG_WARNING(Render_Vulkan, "GDS memory read");
850+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->src_addr_lo,
851+
dma_data->NumBytes(), false, true);
847852
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
848853
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
849854
(dma_data->dst_sel == DmaDataDst::Memory ||
850855
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
851-
rasterizer->InlineData(dma_data->DstAddress<VAddr>(),
852-
dma_data->SrcAddress<const void*>(), dma_data->NumBytes(),
853-
false);
856+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->SrcAddress<VAddr>(),
857+
dma_data->NumBytes(), false, false);
854858
} else {
855859
UNREACHABLE_MSG("WriteData src_sel = {}, dst_sel = {}",
856860
u32(dma_data->src_sel.Value()), u32(dma_data->dst_sel.Value()));
@@ -861,6 +865,9 @@ Liverpool::Task Liverpool::ProcessCompute(const u32* acb, u32 acb_dwords, u32 vq
861865
break;
862866
}
863867
case PM4ItOpcode::Rewind: {
868+
if (!rasterizer) {
869+
break;
870+
}
864871
const PM4CmdRewind* rewind = reinterpret_cast<const PM4CmdRewind*>(header);
865872
while (!rewind->Valid()) {
866873
YIELD_ASC(vqid);

src/video_core/amdgpu/liverpool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,7 @@ struct Liverpool {
15221522
u32 tmp_dwords;
15231523
};
15241524
Common::SlotVector<AscQueueInfo> asc_queues{};
1525+
std::thread::id gpu_id;
15251526

15261527
private:
15271528
struct Task {

0 commit comments

Comments
 (0)