From the spec:
VK_KHR_maintenance1
Allow negative height to be specified in the slink::VkViewport::height field to perform y-inversion of the clip-space to framebuffer-space transform. This allows apps to avoid having to use gl_Position.y = -gl_Position.y in shaders also targeting other APIs.
My physical device supports version 1.0.42 and I have enabled the VK_KHR_maintenance1.
I do not get any validation error/warning when I do a negative height in the VkViewport struct.
vkCmdSetViewport(vkContext.commandBuffer, 0, 1, &viewport);
However I do not see anything on the screen either, its black, if I remove the negative value in the viewport everything is rendered as expected. Do I need to do anything else to flip the viewport with the VK_KHR_maintenance1 extension? I am just rendering a red quad on the screen, with a fullscreen viewport.
VkViewport viewport = {};
viewport.x = 0.0f;
viewport.y = 0.0f;
viewport.width = 1024.0f;
viewport.height = -1024.0f;
viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f;
vkCmdSetViewport(vkContext.commandBuffer, 0, 1, &viewport);
Vertex shader:
void main() {
vec4 positions[3] = {
vec4(-1.0, -1.0, 0.0, 1.0),
vec4(3.0, -1.0, 0.0, 1.0),
vec4(-1.0, 3.0, 0.0, 1.0)
};
gl_Position = positions[gl_VertexIndex % 3];
}
Fragment shader:
void main() {
outFragColor = vec4(1,0,0,1);
}