Skip to content

Commit

Permalink
debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
doitsujin committed Oct 18, 2024
1 parent 40c9435 commit 5c3b5b5
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 13 deletions.
66 changes: 55 additions & 11 deletions src/dxvk/dxvk_cmdlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ namespace dxvk {


VkResult DxvkCommandList::submit() {
Logger::err(str::format("DxvkCommandList::submit(", this, ") BEGIN"));
VkResult status = VK_SUCCESS;

const auto& graphics = m_device->queues().graphics;
Expand All @@ -223,6 +224,7 @@ namespace dxvk {
if (isFirst) {
// Wait for per-command list semaphores on first submission
for (size_t i = 0; i < m_waitSemaphores.size(); i++) {
Logger::err(str::format("Wait for timeline semaphore ", m_signalSemaphores[i].fence->handle(), " = ", m_signalSemaphores[i].value));
m_commandSubmission.waitSemaphore(m_waitSemaphores[i].fence->handle(),
m_waitSemaphores[i].value, VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT);
}
Expand All @@ -233,58 +235,82 @@ namespace dxvk {
// any prior submissions, then block any subsequent ones. The extra
// submission is only needed on the first iteration since subsequent
// ones will signal the semaphore from the graphics queue anyway.
Logger::err(str::format("Signal binary semaphore"));
m_commandSubmission.signalSemaphore(m_semaphore, 0, VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT);

if ((status = m_commandSubmission.submit(m_device, graphics.queueHandle)))
status = m_commandSubmission.submit(m_device, graphics.queueHandle);
Logger::err(str::format("Submit semaphore signal to graphics queue: ", status));

if (status)
return status;

Logger::err(str::format("Wait for binary semaphore"));
sparseBind->waitSemaphore(m_semaphore, 0);
Logger::err(str::format("Signal binary semaphore"));
sparseBind->signalSemaphore(m_semaphore, 0);

if ((status = sparseBind->submit(m_device, sparse.queueHandle)))
status = sparseBind->submit(m_device, sparse.queueHandle);
Logger::err(str::format("Submit sparse binding operation: ", status));

if (status)
return status;

Logger::err(str::format("Wait for binary semaphore"));
m_commandSubmission.waitSemaphore(m_semaphore, 0, VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT);
}

// Execute transfer command buffer, if any
if (cmd.usedFlags.test(DxvkCmdBuffer::SdmaBuffer))
if (cmd.usedFlags.test(DxvkCmdBuffer::SdmaBuffer)) {
Logger::err("Execute DxvkCmdBuffer::SdmaBuffer");
m_commandSubmission.executeCommandBuffer(cmd.sdmaBuffer);
}

// If we had either a transfer command or a semaphore wait, submit to the
// transfer queue so that all subsequent commands get stalled as necessary.
if (m_device->hasDedicatedTransferQueue() && !m_commandSubmission.isEmpty()) {
Logger::err("Signal binary semaphore");
m_commandSubmission.signalSemaphore(m_semaphore, 0, VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT);

if ((status = m_commandSubmission.submit(m_device, transfer.queueHandle)))
status = m_commandSubmission.submit(m_device, transfer.queueHandle);
Logger::err(str::format("Submit commands to transfer queue: ", status));

if (status)
return status;

Logger::err("Wait for binary semaphore");
m_commandSubmission.waitSemaphore(m_semaphore, 0, VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT);
}

// We promise to never do weird stuff to WSI images on
// the transfer queue, so blocking graphics is sufficient
if (isFirst && m_wsiSemaphores.acquire) {
Logger::err("Wait for WSI semaphore");
m_commandSubmission.waitSemaphore(m_wsiSemaphores.acquire,
0, VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT);
}

// Submit graphics commands
if (cmd.usedFlags.test(DxvkCmdBuffer::InitBuffer))
if (cmd.usedFlags.test(DxvkCmdBuffer::InitBuffer)) {
Logger::err("Execute DxvkCmdBuffer::InitBuffer");
m_commandSubmission.executeCommandBuffer(cmd.initBuffer);
}

if (cmd.usedFlags.test(DxvkCmdBuffer::ExecBuffer))
if (cmd.usedFlags.test(DxvkCmdBuffer::ExecBuffer)) {
Logger::err("Execute DxvkCmdBuffer::ExecBuffer");
m_commandSubmission.executeCommandBuffer(cmd.execBuffer);
}

if (isLast) {
// Signal per-command list semaphores on the final submission
for (size_t i = 0; i < m_signalSemaphores.size(); i++) {
Logger::err(str::format("Signal timeline semaphore ", m_signalSemaphores[i].fence->handle(), " = ", m_signalSemaphores[i].value));
m_commandSubmission.signalSemaphore(m_signalSemaphores[i].fence->handle(),
m_signalSemaphores[i].value, VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT);
}

// Signal WSI semaphore on the final submission
if (m_wsiSemaphores.present) {
Logger::err("Signal WSI semaphore");
m_commandSubmission.signalSemaphore(m_wsiSemaphores.present,
0, VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT);
}
Expand All @@ -294,30 +320,42 @@ namespace dxvk {
// through the graphics queue to delay any subsequent commands.
bool stallTransferQueue = m_device->hasDedicatedTransferQueue() && cmd.syncSdma;

if (stallTransferQueue)
if (stallTransferQueue) {
Logger::err("Signal binary semaphore");
m_commandSubmission.signalSemaphore(m_semaphore, 0, VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT);
else if (isLast)
} else if (isLast) {
Logger::err("Signal fence");
m_commandSubmission.signalFence(m_fence);
}

// Submit all graphics commands of the current submission
if ((status = m_commandSubmission.submit(m_device, graphics.queueHandle)))
status = m_commandSubmission.submit(m_device, graphics.queueHandle);
Logger::err(str::format("Submit commands to graphics queue: ", status));

if (status)
return status;

// Finally, submit semaphore wait on the transfer queue. If this
// is not the final iteration, fold the wait into the next one,
// otherwise submit to that queue and signal the fence.
if (stallTransferQueue) {
Logger::err(str::format("Wait for binary semaphore"));
m_commandSubmission.waitSemaphore(m_semaphore, 0, VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT);

if (isLast) {
Logger::err(str::format("Signal fence"));
m_commandSubmission.signalFence(m_fence);

if ((status = m_commandSubmission.submit(m_device, transfer.queueHandle)))
status = m_commandSubmission.submit(m_device, transfer.queueHandle);
Logger::err(str::format("Submit semaphore wait to transfer queue: ", status));

if (status)
return status;
}
}
}

Logger::err(str::format("DxvkCommandList::submit(", this, ") END = VK_SUCCESS"));
return VK_SUCCESS;
}

Expand Down Expand Up @@ -378,11 +416,15 @@ namespace dxvk {


VkResult DxvkCommandList::synchronizeFence() {
return m_vkd->vkWaitForFences(m_vkd->device(), 1, &m_fence, VK_TRUE, ~0ull);
Logger::err(str::format("DxvkCommandList::synchronizeFence(", this, ") BEGIN"));
VkResult vr = m_vkd->vkWaitForFences(m_vkd->device(), 1, &m_fence, VK_TRUE, ~0ull);
Logger::err(str::format("DxvkCommandList::synchronizeFence(", this, ") END = ", vr));
return vr;
}


void DxvkCommandList::reset() {
Logger::err(str::format("DxvkCommandList::reset(", this, ") BEGIN"));
// Free resources and other objects
// that are no longer in use
m_objectTracker.clear();
Expand Down Expand Up @@ -418,6 +460,8 @@ namespace dxvk {
// Reset fence
if (m_vkd->vkResetFences(m_vkd->device(), 1, &m_fence))
Logger::err("DxvkCommandList: Failed to reset fence");

Logger::err(str::format("DxvkCommandList::reset(", this, ") END"));
}


Expand Down
2 changes: 2 additions & 0 deletions src/dxvk/dxvk_cmdlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,10 @@ namespace dxvk {
* \brief Notifies resources and signals
*/
void notifyObjects() {
Logger::err(str::format("DxvkCommandList::notifyObjects(", this, ") BEGIN"));
m_objectTracker.clear();
m_signalTracker.notify();
Logger::err(str::format("DxvkCommandList::notifyObjects(", this, ") END"));
}

/**
Expand Down
13 changes: 11 additions & 2 deletions src/dxvk/dxvk_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6478,11 +6478,15 @@ namespace dxvk {


void DxvkContext::relocateQueuedResources() {
m_cmd->setSubmissionBarrier();
Logger::err("DxvkContext::relocateQueuedResources BEGIN");
constexpr static uint32_t MaxRelocationsPerSubmission = 128u;
auto resourceList = m_common->memoryManager().pollRelocationList(MaxRelocationsPerSubmission);

if (resourceList.empty())
if (resourceList.empty()) {
Logger::err("DxvkContext::relocateQueuedResources END - list empty");
return;
}

std::vector<DxvkRelocateBufferInfo> bufferInfos;
std::vector<DxvkRelocateImageInfo> imageInfos;
Expand Down Expand Up @@ -6510,19 +6514,24 @@ namespace dxvk {
}
}

if (bufferInfos.empty() && imageInfos.empty())
if (bufferInfos.empty() && imageInfos.empty()) {
Logger::err("DxvkContext::relocateQueuedResources END - no resources");
return;
}

// If there are any resources to relocate, we have to stall the transfer
// queue so that subsequent resource uploads do not overlap with resource
// copies on the graphics timeline.
this->spillRenderPass(true);

Logger::err("DxvkContext::relocateQueuedResources relocate resources");
relocateResources(
bufferInfos.size(), bufferInfos.data(),
imageInfos.size(), imageInfos.data());

Logger::err("DxvkContext::relocateQueuedResources set barrier");
m_cmd->setSubmissionBarrier();
Logger::err("DxvkContext::relocateQueuedResources END");
}


Expand Down
3 changes: 3 additions & 0 deletions src/dxvk/dxvk_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,7 @@ namespace dxvk {
void DxvkMemoryAllocator::moveDefragChunks(
DxvkMemoryType& type) {
auto& pool = type.devicePool;
Logger::err(str::format("DxvkMemoryAllocator::moveDefragChunks BEGIN"));

DxvkAllocationModes mode(
DxvkAllocationMode::NoAllocation,
Expand Down Expand Up @@ -2089,6 +2090,8 @@ namespace dxvk {
m_relocations.addResource(std::move(resource), mode);
}
}

Logger::err(str::format("DxvkMemoryAllocator::moveDefragChunks END"));
}


Expand Down

0 comments on commit 5c3b5b5

Please sign in to comment.