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

Crash when Renderer::AddMesh() is called on empty mesh #120

Open
MrDmitry opened this issue Feb 14, 2018 · 0 comments
Open

Crash when Renderer::AddMesh() is called on empty mesh #120

MrDmitry opened this issue Feb 14, 2018 · 0 comments
Labels

Comments

@MrDmitry
Copy link
Member

Mesh has VerticesUpdated signal that is listened by VkMesh however when you create a fresh mesh and try to add it to the Renderer you get a crash here:

void VkMesh::AllocateOnGPU()
{
    m_vertexBuffer.Destroy();
    m_indexBuffer.Destroy();
    Buffer stagingBuffer;
    //Vertexes filling
    auto size = sizeof(m_mesh.GetVertices()[0]) * m_mesh.GetVertices().size();
    stagingBuffer.Create(m_physicalDevice, m_device, vk::BufferUsageFlagBits::eTransferSrc, vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent, size);
    m_vertexBuffer.Create(m_physicalDevice, m_device, vk::BufferUsageFlagBits::eVertexBuffer | vk::BufferUsageFlagBits::eTransferDst, vk::MemoryPropertyFlagBits::eDeviceLocal, size);

    stagingBuffer.Map();
<crash>

stagingBuffer.Create leads to an error LOG_ERROR("Can't allocate zero Vulkan buffer on gpu!"); and returns false but this return value is never checked

Also consider a case where mesh is updated with 0 vertices, this should also be properly handled (old information shall be freed)

@MrDmitry MrDmitry added the bug label Feb 14, 2018
@krupitskas krupitskas removed their assignment Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants