Skip to content

Commit

Permalink
liverpool: Correct compute queue context switches
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelthegreat committed Dec 9, 2024
1 parent f1b23c6 commit edfedec
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/video_core/amdgpu/liverpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ Liverpool::Task Liverpool::ProcessCeUpdate(std::span<const u32> ccb) {
const auto* indirect_buffer = reinterpret_cast<const PM4CmdIndirectBuffer*>(header);
auto task =
ProcessCeUpdate({indirect_buffer->Address<const u32>(), indirect_buffer->ib_size});
task.handle.resume();
while (!task.handle.done()) {
task.handle.resume();

TracyFiberLeave;
co_yield {};
TracyFiberEnter(ccb_task_name);
task.handle.resume();
};
break;
}
Expand Down Expand Up @@ -583,6 +583,8 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
} else if (dma_data->src_sel == DmaDataSrc::Gds &&
dma_data->dst_sel == DmaDataDst::Memory) {
// LOG_WARNING(Render_Vulkan, "GDS memory read");
const u32 data = rasterizer->ReadDataFromGds(dma_data->src_addr_lo);
std::memcpy(dma_data->DstAddress<void*>(), &data, sizeof(data));
} else if (dma_data->src_sel == DmaDataSrc::Memory &&
dma_data->dst_sel == DmaDataDst::Memory) {
rasterizer->InlineData(dma_data->DstAddress<VAddr>(),
Expand Down Expand Up @@ -667,6 +669,7 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c

Liverpool::Task Liverpool::ProcessCompute(std::span<const u32> acb, int vqid) {
TracyFiberEnter(acb_task_name);
regs.cs_program = mapped_queues[vqid].cs_state;

auto base_addr = reinterpret_cast<uintptr_t>(acb.data());
while (!acb.empty()) {
Expand All @@ -689,12 +692,14 @@ Liverpool::Task Liverpool::ProcessCompute(std::span<const u32> acb, int vqid) {
const auto* indirect_buffer = reinterpret_cast<const PM4CmdIndirectBuffer*>(header);
auto task = ProcessCompute(
{indirect_buffer->Address<const u32>(), indirect_buffer->ib_size}, vqid);
task.handle.resume();
while (!task.handle.done()) {
task.handle.resume();

mapped_queues[vqid].cs_state = regs.cs_program;
TracyFiberLeave;
co_yield {};
TracyFiberEnter(acb_task_name);
regs.cs_program = mapped_queues[vqid].cs_state;
task.handle.resume();
};
break;
}
Expand All @@ -716,6 +721,8 @@ Liverpool::Task Liverpool::ProcessCompute(std::span<const u32> acb, int vqid) {
} else if (dma_data->src_sel == DmaDataSrc::Gds &&
dma_data->dst_sel == DmaDataDst::Memory) {
// LOG_WARNING(Render_Vulkan, "GDS memory read");
const u32 data = rasterizer->ReadDataFromGds(dma_data->src_addr_lo);
std::memcpy(dma_data->DstAddress<void*>(), &data, sizeof(data));
} else if (dma_data->src_sel == DmaDataSrc::Memory &&
dma_data->dst_sel == DmaDataDst::Memory) {
rasterizer->InlineData(dma_data->DstAddress<VAddr>(),
Expand Down Expand Up @@ -789,6 +796,8 @@ Liverpool::Task Liverpool::ProcessCompute(std::span<const u32> acb, int vqid) {
acb = NextPacket(acb, header->type3.NumWords() + 1);
}

LOG_WARNING(Render_Vulkan, "Done compute queue {}", vqid);
mapped_queues[vqid].cs_state = regs.cs_program;
TracyFiberLeave;
}

Expand Down Expand Up @@ -847,7 +856,7 @@ void Liverpool::SubmitGfx(std::span<const u32> dcb, std::span<const u32> ccb) {
}

void Liverpool::SubmitAsc(u32 vqid, std::span<const u32> acb) {
ASSERT_MSG(vqid >= 0 && vqid < NumTotalQueues, "Invalid virtual ASC queue index");
ASSERT_MSG(vqid > 0 && vqid < NumTotalQueues, "Invalid virtual ASC queue index");
auto& queue = mapped_queues[vqid];

const auto& task = ProcessCompute(acb, vqid);
Expand Down

0 comments on commit edfedec

Please sign in to comment.