| 398 | } |
| 399 | |
| 400 | void ConstantData::BufferArraySubpass::draw(vkb::core::CommandBufferC &command_buffer) |
| 401 | { |
| 402 | auto &render_frame = get_render_context().get_active_frame(); |
| 403 | |
| 404 | std::vector<MVPUniform> uniforms; |
| 405 | |
| 406 | // Update with all mvp scene data |
| 407 | for (auto &mesh : get_meshes()) |
| 408 | { |
| 409 | for (auto &node : mesh->get_nodes()) |
| 410 | { |
| 411 | for (auto &submesh : mesh->get_submeshes()) |
| 412 | { |
| 413 | uniforms.push_back(fill_mvp(*node, get_camera())); |
| 414 | } |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | auto allocation = render_frame.allocate_buffer(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, sizeof(MVPUniform) * uniforms.size()); |
| 419 | |
| 420 | uint32_t offset = 0; |
| 421 | for (size_t i = 0; i < uniforms.size(); ++i) |
| 422 | { |
| 423 | // Push 128 bytes of data |
| 424 | allocation.update(uniforms[i].model, offset + 0); // Update bytes 0 - 63 |
| 425 | allocation.update(uniforms[i].camera_view_proj, offset + 64); // Update bytes 64 - 127 |
| 426 | allocation.update(uniforms[i].scale, offset + 128); // Update bytes 128 - 191 |
| 427 | allocation.update(uniforms[i].padding, offset + 192); // Update bytes 192 - 255 |
| 428 | offset += 256; |
| 429 | } |
| 430 | |
| 431 | command_buffer.bind_buffer(allocation.get_buffer(), allocation.get_offset(), allocation.get_size(), 0, 1, 0); |
| 432 | |
| 433 | // Reset the instance index back to 0 for each draw call |
| 434 | instance_index = 0; |
| 435 | |
| 436 | allocate_lights<vkb::ForwardLights>(get_scene().get_components<vkb::sg::Light>(), MAX_FORWARD_LIGHT_COUNT); |
| 437 | command_buffer.bind_lighting(get_lighting_state(), 0, 4); |
| 438 | |
| 439 | GeometrySubpass::draw(command_buffer); |
| 440 | } |
| 441 | |
| 442 | void ConstantData::BufferArraySubpass::update_uniform(vkb::core::CommandBufferC &command_buffer, |
| 443 | vkb::scene_graph::NodeC &node, |
no test coverage detected