recompiler: emit a label right after s_branch to prevent dead code interferrence

This commit is contained in:
Vladislav Mikhalin 2024-12-14 14:00:44 +03:00
parent ec31340b1a
commit 695b9c86d7
4 changed files with 7 additions and 35 deletions

View File

@ -80,6 +80,7 @@ void CFG::EmitLabels() {
if (inst.IsUnconditionalBranch()) {
const u32 target = inst.BranchTarget(pc);
AddLabel(target);
AddLabel(pc + inst.length);
} else if (inst.IsConditionalBranch()) {
const u32 true_label = inst.BranchTarget(pc);
const u32 false_label = pc + inst.length;

View File

@ -569,36 +569,22 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
break;
}
if (dma_data->src_sel == DmaDataSrc::Data && dma_data->dst_sel == DmaDataDst::Gds) {
LOG_CRITICAL(Render_Vulkan, "DmaData Data ({}) -> Gds {:#x}, {} bytes",
dma_data->data, dma_data->dst_addr_lo, dma_data->NumBytes());
rasterizer->InlineData(dma_data->dst_addr_lo, &dma_data->data, sizeof(u32),
true);
} else if (dma_data->src_sel == DmaDataSrc::Memory &&
dma_data->dst_sel == DmaDataDst::Gds) {
LOG_CRITICAL(Render_Vulkan, "DmaData Memory {:#x} -> Gds {:#x}, {} bytes",
dma_data->SrcAddress<VAddr>(), dma_data->dst_addr_lo,
dma_data->NumBytes());
rasterizer->CopyBuffer(dma_data->dst_addr_lo, dma_data->SrcAddress<VAddr>(),
dma_data->NumBytes(), true, false);
} else if (dma_data->src_sel == DmaDataSrc::Data &&
dma_data->dst_sel == DmaDataDst::Memory) {
LOG_CRITICAL(Render_Vulkan, "DmaData Data ({}) -> Memory {:#x}, {} bytes",
dma_data->data, dma_data->DstAddress<uintptr_t>(),
dma_data->NumBytes());
rasterizer->InlineData(dma_data->DstAddress<VAddr>(), &dma_data->data,
sizeof(u32), false);
} else if (dma_data->src_sel == DmaDataSrc::Gds &&
dma_data->dst_sel == DmaDataDst::Memory) {
LOG_CRITICAL(Render_Vulkan, "DmaData Gds {:#x} -> Memory {:#x}, {} bytes",
dma_data->src_addr_lo, dma_data->DstAddress<uintptr_t>(),
dma_data->NumBytes());
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->src_addr_lo,
dma_data->NumBytes(), false, true);
} else if (dma_data->src_sel == DmaDataSrc::Memory &&
dma_data->dst_sel == DmaDataDst::Memory) {
LOG_CRITICAL(Render_Vulkan, "DmaData Memory {:#x} -> Memory {:#x}, {} bytes",
dma_data->SrcAddress<uintptr_t>(),
dma_data->DstAddress<uintptr_t>(), dma_data->NumBytes());
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(),
dma_data->SrcAddress<VAddr>(), dma_data->NumBytes(),
false, false);
@ -742,35 +728,21 @@ Liverpool::Task Liverpool::ProcessCompute(std::span<const u32> acb, int vqid) {
break;
}
if (dma_data->src_sel == DmaDataSrc::Data && dma_data->dst_sel == DmaDataDst::Gds) {
LOG_CRITICAL(Render_Vulkan, "DmaData Data ({}) -> Gds {:#x}, {} bytes",
dma_data->data, dma_data->dst_addr_lo, dma_data->NumBytes());
rasterizer->InlineData(dma_data->dst_addr_lo, &dma_data->data, sizeof(u32), true);
} else if (dma_data->src_sel == DmaDataSrc::Memory &&
dma_data->dst_sel == DmaDataDst::Gds) {
LOG_CRITICAL(Render_Vulkan, "DmaData Memory {:#x} -> Gds {:#x}, {} bytes",
dma_data->SrcAddress<VAddr>(), dma_data->dst_addr_lo,
dma_data->NumBytes());
rasterizer->CopyBuffer(dma_data->dst_addr_lo, dma_data->SrcAddress<VAddr>(),
dma_data->NumBytes(), true, false);
} else if (dma_data->src_sel == DmaDataSrc::Data &&
dma_data->dst_sel == DmaDataDst::Memory) {
LOG_CRITICAL(Render_Vulkan, "DmaData Data ({}) -> Memory {:#x}, {} bytes",
dma_data->data, dma_data->DstAddress<uintptr_t>(),
dma_data->NumBytes());
rasterizer->InlineData(dma_data->DstAddress<VAddr>(), &dma_data->data, sizeof(u32),
false);
} else if (dma_data->src_sel == DmaDataSrc::Gds &&
dma_data->dst_sel == DmaDataDst::Memory) {
LOG_CRITICAL(Render_Vulkan, "DmaData Gds {:#x} -> Memory {:#x}, {} bytes",
dma_data->src_addr_lo, dma_data->DstAddress<uintptr_t>(),
dma_data->NumBytes());
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->src_addr_lo,
dma_data->NumBytes(), false, true);
} else if (dma_data->src_sel == DmaDataSrc::Memory &&
dma_data->dst_sel == DmaDataDst::Memory) {
LOG_CRITICAL(Render_Vulkan, "DmaData Memory {:#x} -> Memory {:#x}, {} bytes",
dma_data->SrcAddress<uintptr_t>(), dma_data->DstAddress<uintptr_t>(),
dma_data->NumBytes());
rasterizer->CopyBuffer(dma_data->DstAddress<VAddr>(), dma_data->SrcAddress<VAddr>(),
dma_data->NumBytes(), false, false);
} else {

View File

@ -336,12 +336,13 @@ void BufferCache::InlineData(VAddr address, const void* value, u32 num_bytes, bo
void BufferCache::CopyBuffer(VAddr dst, VAddr src, u32 num_bytes, bool dst_gds, bool src_gds) {
if (!dst_gds && !IsRegionRegistered(dst, num_bytes)) {
if (src_gds || IsRegionRegistered(src, num_bytes)) {
LOG_CRITICAL(Render_Vulkan, "readback is not implemented");
if (!src_gds && !IsRegionRegistered(src, num_bytes)) {
// Both buffers were not transferred to GPU yet. Can safely copy in host memory.
memcpy(std::bit_cast<void*>(dst), std::bit_cast<void*>(src), num_bytes);
return;
}
memcpy(std::bit_cast<void*>(dst), std::bit_cast<void*>(src), num_bytes);
return;
// Without a readback there's nothing we can do with this
// Fallback to creating dst buffer on GPU to at least have this data there
}
if (!src_gds && !IsRegionRegistered(src, num_bytes)) {
InlineData(dst, std::bit_cast<void*>(src), num_bytes, dst_gds);

View File

@ -263,6 +263,7 @@ void Rasterizer::DrawIndirect(bool is_indexed, VAddr arg_address, u32 offset, u3
}
auto state = PrepareRenderState(pipeline->GetMrtMask());
if (!BindResources(pipeline)) {
return;
}
@ -353,9 +354,6 @@ void Rasterizer::DispatchIndirect(VAddr address, u32 offset, u32 size) {
return;
}
LOG_CRITICAL(Render_Vulkan, "DispatchIndirect addr = {:#x}",
std::bit_cast<uintptr_t>(address + offset));
scheduler.EndRendering();
const auto [buffer, base] = buffer_cache.ObtainBuffer(address + offset, size, false);