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());
28 ubo.model = model_mat;
31 if (
ubo_ ==
nullptr) {
33 ctx->graphics_context->allocator(),
sizeof(ubo),
34 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
35 VmaAllocationCreateFlagBits::
36 VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
39 ubo_->set_data_raw(&ubo,
sizeof(LOCALS));
41 ::vk::DescriptorBufferInfo buffer_info(
ubo_->get(), 0,
sizeof(LOCALS));
42 std::array writes = {::vk::WriteDescriptorSet{
43 {}, 1, 0, ::vk::DescriptorType::eUniformBuffer, {}, buffer_info}};
45 cmd.pushDescriptorSetKHR(::vk::PipelineBindPoint::eGraphics,
46 shader->pipeline_layout(), 0, writes);