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

Is it a bug that callingfromHost without vkFlushMappedMemoryRanges #48

Open
jcao-ai opened this issue May 30, 2020 · 2 comments
Open

Is it a bug that callingfromHost without vkFlushMappedMemoryRanges #48

jcao-ai opened this issue May 30, 2020 · 2 comments

Comments

@jcao-ai
Copy link

jcao-ai commented May 30, 2020

Hi, I was trying to understand how vulkan works from your src code.

When I looked into file: deviceArray.hpp in branch: vuh2,

auto fromHost(It1 begin, It2 end)-> void {
    if(Base::isHostVisible()){
        std::copy(begin, end, host_data());
        Base::_dev.unmapMemory(Base::_mem);
    } else { // memory is not host visible, use staging buffer
        auto stage_buf = HostArray<T, AllocDevice<properties::HostCoherent>>(Base::_dev, begin, end);
        copyBuf(Base::_dev, stage_buf, *this, size_bytes());
    }
}

What I think is that even if isHostVisible() return true, we should check whether the memory buffer underlied includes a flag: VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, or we should call vkFlushMappedMemoryRanges and vkInvalidateMappedMemoryRanges .

This is a note from here

Unmapping non-coherent memory does not implicitly flush the host mapped memory, and host writes that have not been flushed may not ever be visible to the device. However, implementations must ensure that writes that have not been flushed do not become visible to any other memory.

Please correct me if I am wrong, thanks anyway!

@jcao-ai jcao-ai changed the title Is it safe to copy from Host without vkFlushMappedMemoryRanges Is it a bug that callingfromHost without vkFlushMappedMemoryRanges May 30, 2020
@Glavnokoman
Copy link
Owner

I guess you are right. Will you create an MR?

@jcao-ai
Copy link
Author

jcao-ai commented May 30, 2020

Sure, be glad to contribute to vuh. But still I am kind of newbie on Vulkan, try my best.

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

2 participants