mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05:52:11 +01:00
[dxvk] Create a separate command buffer for initialization tasks
We'll use this to reset query pools without having to spill the active render pass. Required to fix a query-related bug.
This commit is contained in:
parent
581e505f54
commit
3135359ee9
@ -34,7 +34,8 @@ namespace dxvk {
|
||||
cmdInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
||||
cmdInfo.commandBufferCount = 1;
|
||||
|
||||
if (m_vkd->vkAllocateCommandBuffers(m_vkd->device(), &cmdInfo, &m_buffer) != VK_SUCCESS)
|
||||
if (m_vkd->vkAllocateCommandBuffers(m_vkd->device(), &cmdInfo, &m_execBuffer) != VK_SUCCESS
|
||||
|| m_vkd->vkAllocateCommandBuffers(m_vkd->device(), &cmdInfo, &m_initBuffer) != VK_SUCCESS)
|
||||
throw DxvkError("DxvkCommandList: Failed to allocate command buffer");
|
||||
}
|
||||
|
||||
@ -51,6 +52,9 @@ namespace dxvk {
|
||||
VkQueue queue,
|
||||
VkSemaphore waitSemaphore,
|
||||
VkSemaphore wakeSemaphore) {
|
||||
std::array<VkCommandBuffer, 2> cmdBuffers
|
||||
= {{ m_initBuffer, m_execBuffer }};
|
||||
|
||||
const VkPipelineStageFlags waitStageMask
|
||||
= VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
||||
|
||||
@ -60,8 +64,8 @@ namespace dxvk {
|
||||
info.waitSemaphoreCount = waitSemaphore == VK_NULL_HANDLE ? 0 : 1;
|
||||
info.pWaitSemaphores = &waitSemaphore;
|
||||
info.pWaitDstStageMask = &waitStageMask;
|
||||
info.commandBufferCount = 1;
|
||||
info.pCommandBuffers = &m_buffer;
|
||||
info.commandBufferCount = cmdBuffers.size();
|
||||
info.pCommandBuffers = cmdBuffers.data();
|
||||
info.signalSemaphoreCount = wakeSemaphore == VK_NULL_HANDLE ? 0 : 1;
|
||||
info.pSignalSemaphores = &wakeSemaphore;
|
||||
|
||||
@ -92,7 +96,8 @@ namespace dxvk {
|
||||
if (m_vkd->vkResetCommandPool(m_vkd->device(), m_pool, 0) != VK_SUCCESS)
|
||||
Logger::err("DxvkCommandList: Failed to reset command buffer");
|
||||
|
||||
if (m_vkd->vkBeginCommandBuffer(m_buffer, &info) != VK_SUCCESS)
|
||||
if (m_vkd->vkBeginCommandBuffer(m_execBuffer, &info) != VK_SUCCESS
|
||||
|| m_vkd->vkBeginCommandBuffer(m_initBuffer, &info) != VK_SUCCESS)
|
||||
Logger::err("DxvkCommandList: Failed to begin command buffer");
|
||||
|
||||
if (m_vkd->vkResetFences(m_vkd->device(), 1, &m_fence) != VK_SUCCESS)
|
||||
@ -101,7 +106,8 @@ namespace dxvk {
|
||||
|
||||
|
||||
void DxvkCommandList::endRecording() {
|
||||
if (m_vkd->vkEndCommandBuffer(m_buffer) != VK_SUCCESS)
|
||||
if (m_vkd->vkEndCommandBuffer(m_execBuffer) != VK_SUCCESS
|
||||
|| m_vkd->vkEndCommandBuffer(m_initBuffer) != VK_SUCCESS)
|
||||
Logger::err("DxvkCommandList::endRecording: Failed to record command buffer");
|
||||
}
|
||||
|
||||
@ -132,7 +138,7 @@ namespace dxvk {
|
||||
region.dstOffset = dstOffset;
|
||||
region.size = dataSize;
|
||||
|
||||
m_vkd->vkCmdCopyBuffer(m_buffer,
|
||||
m_vkd->vkCmdCopyBuffer(m_execBuffer,
|
||||
dataSlice.buffer, dstBuffer, 1, ®ion);
|
||||
}
|
||||
|
||||
@ -142,7 +148,7 @@ namespace dxvk {
|
||||
VkImageLayout dstImageLayout,
|
||||
const VkBufferImageCopy& dstImageRegion,
|
||||
const DxvkStagingBufferSlice& dataSlice) {
|
||||
m_vkd->vkCmdCopyBufferToImage(m_buffer,
|
||||
m_vkd->vkCmdCopyBufferToImage(m_execBuffer,
|
||||
dataSlice.buffer, dstImage, dstImageLayout,
|
||||
1, &dstImageRegion);
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ namespace dxvk {
|
||||
VkQueryPool queryPool,
|
||||
uint32_t query,
|
||||
VkQueryControlFlags flags) {
|
||||
m_vkd->vkCmdBeginQuery(m_buffer,
|
||||
m_vkd->vkCmdBeginQuery(m_execBuffer,
|
||||
queryPool, query, flags);
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ namespace dxvk {
|
||||
void cmdBeginRenderPass(
|
||||
const VkRenderPassBeginInfo* pRenderPassBegin,
|
||||
VkSubpassContents contents) {
|
||||
m_vkd->vkCmdBeginRenderPass(m_buffer,
|
||||
m_vkd->vkCmdBeginRenderPass(m_execBuffer,
|
||||
pRenderPassBegin, contents);
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ namespace dxvk {
|
||||
VkPipelineBindPoint pipeline,
|
||||
VkPipelineLayout pipelineLayout,
|
||||
VkDescriptorSet descriptorSet) {
|
||||
m_vkd->vkCmdBindDescriptorSets(m_buffer,
|
||||
m_vkd->vkCmdBindDescriptorSets(m_execBuffer,
|
||||
pipeline, pipelineLayout, 0, 1,
|
||||
&descriptorSet, 0, nullptr);
|
||||
}
|
||||
@ -231,7 +231,7 @@ namespace dxvk {
|
||||
VkBuffer buffer,
|
||||
VkDeviceSize offset,
|
||||
VkIndexType indexType) {
|
||||
m_vkd->vkCmdBindIndexBuffer(m_buffer,
|
||||
m_vkd->vkCmdBindIndexBuffer(m_execBuffer,
|
||||
buffer, offset, indexType);
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ namespace dxvk {
|
||||
void cmdBindPipeline(
|
||||
VkPipelineBindPoint pipelineBindPoint,
|
||||
VkPipeline pipeline) {
|
||||
m_vkd->vkCmdBindPipeline(m_buffer,
|
||||
m_vkd->vkCmdBindPipeline(m_execBuffer,
|
||||
pipelineBindPoint, pipeline);
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ namespace dxvk {
|
||||
uint32_t bindingCount,
|
||||
const VkBuffer* pBuffers,
|
||||
const VkDeviceSize* pOffsets) {
|
||||
m_vkd->vkCmdBindVertexBuffers(m_buffer,
|
||||
m_vkd->vkCmdBindVertexBuffers(m_execBuffer,
|
||||
firstBinding, bindingCount, pBuffers, pOffsets);
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ namespace dxvk {
|
||||
uint32_t regionCount,
|
||||
const VkImageBlit* pRegions,
|
||||
VkFilter filter) {
|
||||
m_vkd->vkCmdBlitImage(m_buffer,
|
||||
m_vkd->vkCmdBlitImage(m_execBuffer,
|
||||
srcImage, srcImageLayout,
|
||||
dstImage, dstImageLayout,
|
||||
regionCount, pRegions, filter);
|
||||
@ -274,7 +274,7 @@ namespace dxvk {
|
||||
const VkClearAttachment* pAttachments,
|
||||
uint32_t rectCount,
|
||||
const VkClearRect* pRects) {
|
||||
m_vkd->vkCmdClearAttachments(m_buffer,
|
||||
m_vkd->vkCmdClearAttachments(m_execBuffer,
|
||||
attachmentCount, pAttachments,
|
||||
rectCount, pRects);
|
||||
}
|
||||
@ -286,7 +286,7 @@ namespace dxvk {
|
||||
const VkClearColorValue* pColor,
|
||||
uint32_t rangeCount,
|
||||
const VkImageSubresourceRange* pRanges) {
|
||||
m_vkd->vkCmdClearColorImage(m_buffer,
|
||||
m_vkd->vkCmdClearColorImage(m_execBuffer,
|
||||
image, imageLayout, pColor,
|
||||
rangeCount, pRanges);
|
||||
}
|
||||
@ -298,7 +298,7 @@ namespace dxvk {
|
||||
const VkClearDepthStencilValue* pDepthStencil,
|
||||
uint32_t rangeCount,
|
||||
const VkImageSubresourceRange* pRanges) {
|
||||
m_vkd->vkCmdClearDepthStencilImage(m_buffer,
|
||||
m_vkd->vkCmdClearDepthStencilImage(m_execBuffer,
|
||||
image, imageLayout, pDepthStencil,
|
||||
rangeCount, pRanges);
|
||||
}
|
||||
@ -309,7 +309,7 @@ namespace dxvk {
|
||||
VkBuffer dstBuffer,
|
||||
uint32_t regionCount,
|
||||
const VkBufferCopy* pRegions) {
|
||||
m_vkd->vkCmdCopyBuffer(m_buffer,
|
||||
m_vkd->vkCmdCopyBuffer(m_execBuffer,
|
||||
srcBuffer, dstBuffer,
|
||||
regionCount, pRegions);
|
||||
}
|
||||
@ -321,7 +321,7 @@ namespace dxvk {
|
||||
VkImageLayout dstImageLayout,
|
||||
uint32_t regionCount,
|
||||
const VkBufferImageCopy* pRegions) {
|
||||
m_vkd->vkCmdCopyBufferToImage(m_buffer,
|
||||
m_vkd->vkCmdCopyBufferToImage(m_execBuffer,
|
||||
srcBuffer, dstImage, dstImageLayout,
|
||||
regionCount, pRegions);
|
||||
}
|
||||
@ -334,7 +334,7 @@ namespace dxvk {
|
||||
VkImageLayout dstImageLayout,
|
||||
uint32_t regionCount,
|
||||
const VkImageCopy* pRegions) {
|
||||
m_vkd->vkCmdCopyImage(m_buffer,
|
||||
m_vkd->vkCmdCopyImage(m_execBuffer,
|
||||
srcImage, srcImageLayout,
|
||||
dstImage, dstImageLayout,
|
||||
regionCount, pRegions);
|
||||
@ -347,7 +347,7 @@ namespace dxvk {
|
||||
VkBuffer dstBuffer,
|
||||
uint32_t regionCount,
|
||||
const VkBufferImageCopy* pRegions) {
|
||||
m_vkd->vkCmdCopyImageToBuffer(m_buffer,
|
||||
m_vkd->vkCmdCopyImageToBuffer(m_execBuffer,
|
||||
srcImage, srcImageLayout, dstBuffer,
|
||||
regionCount, pRegions);
|
||||
}
|
||||
@ -357,7 +357,7 @@ namespace dxvk {
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t z) {
|
||||
m_vkd->vkCmdDispatch(m_buffer, x, y, z);
|
||||
m_vkd->vkCmdDispatch(m_execBuffer, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@ -365,7 +365,7 @@ namespace dxvk {
|
||||
VkBuffer buffer,
|
||||
VkDeviceSize offset) {
|
||||
m_vkd->vkCmdDispatchIndirect(
|
||||
m_buffer, buffer, offset);
|
||||
m_execBuffer, buffer, offset);
|
||||
}
|
||||
|
||||
|
||||
@ -374,7 +374,7 @@ namespace dxvk {
|
||||
uint32_t instanceCount,
|
||||
uint32_t firstVertex,
|
||||
uint32_t firstInstance) {
|
||||
m_vkd->vkCmdDraw(m_buffer,
|
||||
m_vkd->vkCmdDraw(m_execBuffer,
|
||||
vertexCount, instanceCount,
|
||||
firstVertex, firstInstance);
|
||||
}
|
||||
@ -385,7 +385,7 @@ namespace dxvk {
|
||||
VkDeviceSize offset,
|
||||
uint32_t drawCount,
|
||||
uint32_t stride) {
|
||||
m_vkd->vkCmdDrawIndirect(m_buffer,
|
||||
m_vkd->vkCmdDrawIndirect(m_execBuffer,
|
||||
buffer, offset, drawCount, stride);
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ namespace dxvk {
|
||||
uint32_t firstIndex,
|
||||
uint32_t vertexOffset,
|
||||
uint32_t firstInstance) {
|
||||
m_vkd->vkCmdDrawIndexed(m_buffer,
|
||||
m_vkd->vkCmdDrawIndexed(m_execBuffer,
|
||||
indexCount, instanceCount,
|
||||
firstIndex, vertexOffset,
|
||||
firstInstance);
|
||||
@ -408,7 +408,7 @@ namespace dxvk {
|
||||
VkDeviceSize offset,
|
||||
uint32_t drawCount,
|
||||
uint32_t stride) {
|
||||
m_vkd->vkCmdDrawIndexedIndirect(m_buffer,
|
||||
m_vkd->vkCmdDrawIndexedIndirect(m_execBuffer,
|
||||
buffer, offset, drawCount, stride);
|
||||
}
|
||||
|
||||
@ -416,12 +416,12 @@ namespace dxvk {
|
||||
void cmdEndQuery(
|
||||
VkQueryPool queryPool,
|
||||
uint32_t query) {
|
||||
m_vkd->vkCmdEndQuery(m_buffer, queryPool, query);
|
||||
m_vkd->vkCmdEndQuery(m_execBuffer, queryPool, query);
|
||||
}
|
||||
|
||||
|
||||
void cmdEndRenderPass() {
|
||||
m_vkd->vkCmdEndRenderPass(m_buffer);
|
||||
m_vkd->vkCmdEndRenderPass(m_execBuffer);
|
||||
}
|
||||
|
||||
|
||||
@ -430,7 +430,7 @@ namespace dxvk {
|
||||
VkDeviceSize dstOffset,
|
||||
VkDeviceSize size,
|
||||
uint32_t data) {
|
||||
m_vkd->vkCmdFillBuffer(m_buffer,
|
||||
m_vkd->vkCmdFillBuffer(m_execBuffer,
|
||||
dstBuffer, dstOffset, size, data);
|
||||
}
|
||||
|
||||
@ -445,7 +445,7 @@ namespace dxvk {
|
||||
const VkBufferMemoryBarrier* pBufferMemoryBarriers,
|
||||
uint32_t imageMemoryBarrierCount,
|
||||
const VkImageMemoryBarrier* pImageMemoryBarriers) {
|
||||
m_vkd->vkCmdPipelineBarrier(m_buffer,
|
||||
m_vkd->vkCmdPipelineBarrier(m_execBuffer,
|
||||
srcStageMask, dstStageMask, dependencyFlags,
|
||||
memoryBarrierCount, pMemoryBarriers,
|
||||
bufferMemoryBarrierCount, pBufferMemoryBarriers,
|
||||
@ -459,7 +459,7 @@ namespace dxvk {
|
||||
uint32_t offset,
|
||||
uint32_t size,
|
||||
const void* pValues) {
|
||||
m_vkd->vkCmdPushConstants(m_buffer,
|
||||
m_vkd->vkCmdPushConstants(m_execBuffer,
|
||||
layout, stageFlags, offset, size, pValues);
|
||||
}
|
||||
|
||||
@ -468,7 +468,7 @@ namespace dxvk {
|
||||
VkQueryPool queryPool,
|
||||
uint32_t firstQuery,
|
||||
uint32_t queryCount) {
|
||||
m_vkd->vkCmdResetQueryPool(m_buffer,
|
||||
m_vkd->vkCmdResetQueryPool(m_execBuffer,
|
||||
queryPool, firstQuery, queryCount);
|
||||
}
|
||||
|
||||
@ -480,7 +480,7 @@ namespace dxvk {
|
||||
VkImageLayout dstImageLayout,
|
||||
uint32_t regionCount,
|
||||
const VkImageResolve* pRegions) {
|
||||
m_vkd->vkCmdResolveImage(m_buffer,
|
||||
m_vkd->vkCmdResolveImage(m_execBuffer,
|
||||
srcImage, srcImageLayout,
|
||||
dstImage, dstImageLayout,
|
||||
regionCount, pRegions);
|
||||
@ -492,13 +492,13 @@ namespace dxvk {
|
||||
VkDeviceSize dstOffset,
|
||||
VkDeviceSize dataSize,
|
||||
const void* pData) {
|
||||
m_vkd->vkCmdUpdateBuffer(m_buffer,
|
||||
m_vkd->vkCmdUpdateBuffer(m_execBuffer,
|
||||
dstBuffer, dstOffset, dataSize, pData);
|
||||
}
|
||||
|
||||
|
||||
void cmdSetBlendConstants(const float blendConstants[4]) {
|
||||
m_vkd->vkCmdSetBlendConstants(m_buffer, blendConstants);
|
||||
m_vkd->vkCmdSetBlendConstants(m_execBuffer, blendConstants);
|
||||
}
|
||||
|
||||
|
||||
@ -506,7 +506,7 @@ namespace dxvk {
|
||||
uint32_t firstScissor,
|
||||
uint32_t scissorCount,
|
||||
const VkRect2D* scissors) {
|
||||
m_vkd->vkCmdSetScissor(m_buffer,
|
||||
m_vkd->vkCmdSetScissor(m_execBuffer,
|
||||
firstScissor, scissorCount, scissors);
|
||||
}
|
||||
|
||||
@ -514,7 +514,7 @@ namespace dxvk {
|
||||
void cmdSetStencilReference(
|
||||
VkStencilFaceFlags faceMask,
|
||||
uint32_t reference) {
|
||||
m_vkd->vkCmdSetStencilReference(m_buffer,
|
||||
m_vkd->vkCmdSetStencilReference(m_execBuffer,
|
||||
faceMask, reference);
|
||||
}
|
||||
|
||||
@ -523,7 +523,7 @@ namespace dxvk {
|
||||
uint32_t firstViewport,
|
||||
uint32_t viewportCount,
|
||||
const VkViewport* viewports) {
|
||||
m_vkd->vkCmdSetViewport(m_buffer,
|
||||
m_vkd->vkCmdSetViewport(m_execBuffer,
|
||||
firstViewport, viewportCount, viewports);
|
||||
}
|
||||
|
||||
@ -532,7 +532,7 @@ namespace dxvk {
|
||||
VkPipelineStageFlagBits pipelineStage,
|
||||
VkQueryPool queryPool,
|
||||
uint32_t query) {
|
||||
m_vkd->vkCmdWriteTimestamp(m_buffer,
|
||||
m_vkd->vkCmdWriteTimestamp(m_execBuffer,
|
||||
pipelineStage, queryPool, query);
|
||||
}
|
||||
|
||||
@ -561,7 +561,8 @@ namespace dxvk {
|
||||
VkFence m_fence;
|
||||
|
||||
VkCommandPool m_pool;
|
||||
VkCommandBuffer m_buffer;
|
||||
VkCommandBuffer m_execBuffer;
|
||||
VkCommandBuffer m_initBuffer;
|
||||
|
||||
DxvkLifetimeTracker m_resources;
|
||||
DxvkDescriptorAlloc m_descAlloc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user