Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Should Vulkan WriteTexture need vkFlushMappedMemoryRanges? #39

Open
BlurryLight opened this issue Oct 28, 2023 · 0 comments
Open

Comments

@BlurryLight
Copy link
Contributor

m_UploadManager->suballocateBuffer(
deviceMemSize,
&uploadBuffer,
&uploadOffset,
&uploadCpuVA,
MakeVersion(m_CurrentCmdBuf->recordingID, m_CommandListParameters.queueType, false));
size_t minRowPitch = std::min(size_t(deviceRowPitch), rowPitch);
uint8_t* mappedPtr = (uint8_t*)uploadCpuVA;
for (uint32_t slice = 0; slice < mipDepth; slice++)
{
const uint8_t* sourcePtr = (const uint8_t*)data + depthPitch * slice;
for (uint32_t row = 0; row < deviceNumRows; row++)
{
memcpy(mappedPtr, sourcePtr, minRowPitch);
mappedPtr += deviceRowPitch;
sourcePtr += rowPitch;
}
}
auto imageCopy = vk::BufferImageCopy()

the code snippnet is trying to first transfer data to upload heap and then using vkCopyBufferToImage to transfer data into device-local memory.
However, the staging buffer is created with eHostVisible instead of eHostCoherent.

case CpuAccessMode::Write:
flags = vk::MemoryPropertyFlagBits::eHostVisible;
break;

Taking Vulkan-Docs:Transfer-dependencies as reference, it seems there should be a vkFlushMappedMemoryRanges between the memcpy and the vkCopyBufferToImage, to ensure the host write is visible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant