0
\$\begingroup\$

I have been trying to enable multiple viewports in my Vulkan Pipeline but have been unsucsessfull. I used this code sample as a reference point. The problem is that when I attempt to draw two side by side (splitscreen) views of a scene I am unsuccessful.

Pipeline Initialisation

// Viewport state
VkPipelineViewportStateCreateInfo viewport_state = initializers::PipelineViewportStateCreateInfo(CameraComponent::GetCameraCount(), CameraComponent::GetCameraCount());

// Dynamic shader stages
std::vector<VkDynamicState> dynamic_states = {
    VK_DYNAMIC_STATE_VIEWPORT,
    VK_DYNAMIC_STATE_SCISSOR,
    VK_DYNAMIC_STATE_LINE_WIDTH,
};
VkPipelineDynamicStateCreateInfo dynamic_states_info = initializers::PipelineDynamicStateCreateInfo(dynamic_states);

(Using the debuger shows that CameraComponent::GetCameraCount() is 2)

Command Buffer

vkCmdSetViewport(cmd, 0, CameraComponent::GetCameraCount(), CameraComponent::GetViewports());
vkCmdSetScissor(cmd, 0, CameraComponent::GetCameraCount(), CameraComponent::GetScissors());

(Here CameraComponent::GetCameraCount() is 2 aswell as the viewport and scissor methods returning valid data)

When Using Nvidia NSight we can see that both Scissors and Viewports are detected enter image description here

As well as there position data existing within the gpu enter image description here

But when it comes to the result, all that is visible is half of the screen. enter image description here When I flip the cameras around within the code, the second half is rendered instead showing that the first camera is being rendered but not the second one.

\$\endgroup\$
  • \$\begingroup\$ You should really post a complete example. What does your geometry shader look like? Are you doing this to try to implement stereo rendering? If so, you might want to use the VK_KHR_MULTIVIEW extension (core in Vulkan 1.1) instead of viewport arrays, since it requires no geometry shader work. \$\endgroup\$ – Jherico Jul 16 '18 at 23:47
  • \$\begingroup\$ I've not added a geometry shader to this, I did not know it was a requirement for it to work. I will look into the geometry shader now as well as VK_KHR_MULTIVIEW \$\endgroup\$ – 0xen Jul 16 '18 at 23:55
  • \$\begingroup\$ Where is that quote from? \$\endgroup\$ – 0xen Jul 17 '18 at 0:12
  • \$\begingroup\$ Line 277 of the Sascha Willems example you linked to in your question. Also, it's a link to the line in question. \$\endgroup\$ – Jherico Jul 17 '18 at 0:17

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.