Skip to content

Commit 31e5596

Browse files
committed
Readbacks proof of concept shadps4-emu#2668
1 parent 25d9d81 commit 31e5596

File tree

14 files changed

+415
-198
lines changed

14 files changed

+415
-198
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp
892892
src/video_core/buffer_cache/buffer.h
893893
src/video_core/buffer_cache/buffer_cache.cpp
894894
src/video_core/buffer_cache/buffer_cache.h
895-
src/video_core/buffer_cache/memory_tracker_base.h
895+
src/video_core/buffer_cache/memory_tracker.h
896896
src/video_core/buffer_cache/range_set.h
897897
src/video_core/buffer_cache/word_manager.h
898898
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();
@@ -815,8 +819,8 @@ Liverpool::Task Liverpool::ProcessCompute(const u32* acb, u32 acb_dwords, u32 vq
815819
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
816820
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
817821
dma_data->dst_sel == DmaDataDst::Gds) {
818-
rasterizer->InlineData(dma_data->dst_addr_lo, dma_data->SrcAddress<const void*>(),
819-
dma_data->NumBytes(), true);
822+
rasterizer->CopyBuffer(dma_data->dst_addr_lo, dma_data->SrcAddress<VAddr>(),
823+
dma_data->NumBytes(), true, false);
820824
} else if (dma_data->src_sel == DmaDataSrc::Data &&
821825
(dma_data->dst_sel == DmaDataDst::Memory ||
822826
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
@@ -825,14 +829,14 @@ Liverpool::Task Liverpool::ProcessCompute(const u32* acb, u32 acb_dwords, u32 vq
825829
} else if (dma_data->src_sel == DmaDataSrc::Gds &&
826830
(dma_data->dst_sel == DmaDataDst::Memory ||
827831
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
828-
// LOG_WARNING(Render_Vulkan, "GDS memory read");
832+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->src_addr_lo,
833+
dma_data->NumBytes(), false, true);
829834
} else if ((dma_data->src_sel == DmaDataSrc::Memory ||
830835
dma_data->src_sel == DmaDataSrc::MemoryUsingL2) &&
831836
(dma_data->dst_sel == DmaDataDst::Memory ||
832837
dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) {
833-
rasterizer->InlineData(dma_data->DstAddress<VAddr>(),
834-
dma_data->SrcAddress<const void*>(), dma_data->NumBytes(),
835-
false);
838+
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->SrcAddress<VAddr>(),
839+
dma_data->NumBytes(), false, false);
836840
} else {
837841
UNREACHABLE_MSG("WriteData src_sel = {}, dst_sel = {}",
838842
u32(dma_data->src_sel.Value()), u32(dma_data->dst_sel.Value()));
@@ -843,6 +847,9 @@ Liverpool::Task Liverpool::ProcessCompute(const u32* acb, u32 acb_dwords, u32 vq
843847
break;
844848
}
845849
case PM4ItOpcode::Rewind: {
850+
if (!rasterizer) {
851+
break;
852+
}
846853
const PM4CmdRewind* rewind = reinterpret_cast<const PM4CmdRewind*>(header);
847854
while (!rewind->Valid()) {
848855
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)