15 auto bind(
const std::shared_ptr<Context>& ctx,
16 const std::shared_ptr<vk::Shader>& shader,
17 const ::vk::CommandBuffer& cmd,
const math::Mat4f& model_mat) {
18 if (!
mesh_.has_value())
return;
20 mesh_->load(ctx->graphics_context->Device(),
21 ctx->graphics_context->allocator());
29 ubo.model = model_mat;
33 if (
ubo_ ==
nullptr) {
35 ctx->graphics_context->allocator(),
sizeof(ubo),
36 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
37 VmaAllocationCreateFlagBits::
38 VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
41 ubo_->set_data_raw(&ubo,
sizeof(LOCALS));
43 ::vk::DescriptorBufferInfo buffer_info(
ubo_->get(), 0,
sizeof(LOCALS));
44 std::array writes = {::vk::WriteDescriptorSet{
45 {}, 1, 0, ::vk::DescriptorType::eUniformBuffer, {}, buffer_info}};
47 cmd.pushDescriptorSetKHR(::vk::PipelineBindPoint::eGraphics,
48 shader->pipeline_layout(), 0, writes);