ray_tracing_motionblur/hello_vulkan.cpp
void HelloVulkan::rasterize(const VkCommandBuffer& cmdBuf)
{
  VkDeviceSize offset{0};

  m_debug.beginLabel(cmdBuf, "Rasterize");

  // Dynamic Viewport
  setViewport(cmdBuf);

  // Drawing all triangles
  vkCmdBindPipeline(cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, m_graphicsPipeline);
  vkCmdBindDescriptorSets(cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineLayout, 0, 1, &m_descSet, 0, nullptr);


  for(const HelloVulkan::ObjInstance& inst : m_instances)
  {
    auto& model            = m_objModel[inst.objIndex];
    m_pcRaster.objIndex    = inst.objIndex;  // Telling which object is drawn
    m_pcRaster.modelMatrix = inst.transform;

    vkCmdPushConstants(cmdBuf, m_pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0,
                       sizeof(PushConstantRaster), &m_pcRaster);
    vkCmdBindVertexBuffers(cmdBuf, 0, 1, &model.vertexBuffer.buffer, &offset);
    vkCmdBindIndexBuffer(cmdBuf, model.indexBuffer.buffer, 0, VK_INDEX_TYPE_UINT32);
    vkCmdDrawIndexed(cmdBuf, model.nbIndices, 1, 0, 0, 0);
  }
  m_debug.endLabel(cmdBuf);
}
//--------------------------------------------------------------------------------------------------
// Drawing the scene in raster mode
//
Drawing the scene in raster mode
Drawing the scene in raster mode
void HelloVulkan::rasterize(const VkCommandBuffer& cmdBuf)
{
  VkDeviceSize offset{0};
  m_debug.beginLabel(cmdBuf, "Rasterize");
  setViewport(cmdBuf);
  vkCmdBindPipeline(cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, m_graphicsPipeline);
  vkCmdBindDescriptorSets(cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineLayout, 0, 1, &m_descSet, 0, nullptr);
  for(const HelloVulkan::ObjInstance& inst : m_instances)
  {
    auto& model            = m_objModel[inst.objIndex];
    m_pcRaster.objIndex    = inst.objIndex;  
    m_pcRaster.modelMatrix = inst.transform;
    vkCmdPushConstants(cmdBuf, m_pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0,
                       sizeof(PushConstantRaster), &m_pcRaster);
    vkCmdBindVertexBuffers(cmdBuf, 0, 1, &model.vertexBuffer.buffer, &offset);
    vkCmdBindIndexBuffer(cmdBuf, model.indexBuffer.buffer, 0, VK_INDEX_TYPE_UINT32);
    vkCmdDrawIndexed(cmdBuf, model.nbIndices, 1, 0, 0, 0);
  }
  m_debug.endLabel(cmdBuf);
}
void HelloVulkan :: rasterize ( const VkCommandBuffer & cmdBuf ) { VkDeviceSize offset { 0 } ; m_debug . beginLabel ( cmdBuf , " " ) ; setViewport ( cmdBuf ) ; vkCmdBindPipeline ( cmdBuf , VK_PIPELINE_BIND_POINT_GRAPHICS , m_graphicsPipeline ) ; vkCmdBindDescriptorSets ( cmdBuf , VK_PIPELINE_BIND_POINT_GRAPHICS , m_pipelineLayout , 0 , 1 , & m_descSet , 0 , nullptr ) ; for ( const HelloVulkan :: ObjInstance & inst : m_instances ) { auto & model = m_objModel [ inst . objIndex ] ; m_pcRaster . objIndex = inst . objIndex ; m_pcRaster . modelMatrix = inst . transform ; vkCmdPushConstants ( cmdBuf , m_pipelineLayout , VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT , 0 , sizeof ( PushConstantRaster ) , & m_pcRaster ) ; vkCmdBindVertexBuffers ( cmdBuf , 0 , 1 , & model . vertexBuffer . buffer , & offset ) ; vkCmdBindIndexBuffer ( cmdBuf , model . indexBuffer . buffer , 0 , VK_INDEX_TYPE_UINT32 ) ; vkCmdDrawIndexed ( cmdBuf , model . nbIndices , 1 , 0 , 0 , 0 ) ; } m_debug . endLabel ( cmdBuf ) ; }
Drawing the scene in raster mode
Drawing the scene in raster mode
// Dynamic Viewport // Drawing all triangles // Telling which object is drawn