vulkan - create array of ubo and present each at a time to its shader -


i want create array of ubo object in cpu update , upload gpu in 1 call that. (for example lets have 2 objects).

    std::vector<uniformbufferobject> ubo(m_allobject.size());      int index = 0;     (renderableobject* rendobj : m_allobject)     {         ubo[index].proj = m_camera->getprojection();         ubo[index].view = m_camera->getview();         ubo[index].model = rendobj->gettransform().getmodel();         ubo[index].proj[1][1] *= -1;         index++;     }      int size = sizeof(uniformbufferobject) *m_allobject.size();     void* data;     m_instance->getlogicaldevice().mapmemory(ykengine::buffer::m_uniformbuffer.m_buffermemory, 0, size , vk::memorymapflags(), &data);     memcpy(data, ubo.data(), size);     m_instance->getlogicaldevice().unmapmemory(ykengine::buffer::m_uniformbuffer.m_buffermemory); 

i created 1 buffer size of 2 ubo. (the create work because work ubo in size one).

        vk::devicesize buffersize = sizeof(uniformbufferobject) * 2;          createbuffer(logicaldevice, buffersize, vk::bufferusageflagbits::euniformbuffer, vk::memorypropertyflagbits::ehostvisible | vk::memorypropertyflagbits::ehostcoherent, m_uniformbuffer.m_buffer, m_uniformbuffer.m_buffermemory); 

and put offset in descriptor set creation :

    vk::descriptorbufferinfo bufferinfo;     bufferinfo.buffer = uniformbuffer;     bufferinfo.offset = offsetforubo;     bufferinfo.range = sizeof(uniformbufferobject); 

the offset size of uniformbufferobject * index of object.

every object have own descriptorsetlayout samepipline

when try update descriptor set error :

enter image description here

i couldnt find aligment enum specify information.

if know how alot.

thanks.

i couldnt find aligment enum specify information.

vulkan not opengl; don't use enums query limits. limits defined vkphysicaldevicelimits struct, queried via vkgetphysicaldeviceproperties/2khr.

the error tells limitation violated: minuniformbufferoffsetalignment. implementation set 0x100, provided offset insufficient this.

also, should not map buffers in middle of frame. mapping in vulkan "persistent"; map once , leave way until you're ready delete memory.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -