Reputation: 55
I'm trying to inverse to viewport of vulkan instead of inversing everything else, but this result in a black screen. The black screen looks like it's coming from one of my shader.
Code to inverse the viewport:
VkRect2D renderArea = {};
renderArea.offset = {0, 0};
renderArea.extent = {
static_cast<uint32_t>(renderStage.GetSize().x),
static_cast<uint32_t>(renderStage.GetSize().y)
};
VkViewport viewport;
viewport.x = 0.0f;
viewport.y = static_cast<float>(renderArea.extent.height);
viewport.width = static_cast<float>(renderArea.extent.width);
viewport.height = -static_cast<float>(renderArea.extent.height);
viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f;
vkCmdSetViewport(
*commandBuffers_[swapchain_->GetActiveImageIndex()],
0,
1,
&viewport);
In render doc I see that stuff are drawn to framebuffer, but at one point after a specific shader everything is black (it works just fine if I'm not doing the inversion). The vertex shader (light pass in deferred rendering)
void main()
{
outUV = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
gl_Position = vec4(outUV * 2.0f - 1.0f, 0.0f, 1.0f);
}
Upvotes: 2
Views: 870
Reputation: 5808
The black output is probably your clear color, which means your geometry is either discarded or outside of the viewport.
If you flip the viewport in Vulkan 1.0 you also need to enable VK_KHR_maintenance1
(in Vulkan 1.1. this was promoted to the core).
And if you have culling enabled, you either need to flip the culling mode or the front face information of your pipeline's rasterization state. Otherwise your geometry gets discarded because it faces away from the screen after flipping the viewport.
Upvotes: 1