From dfef2e3f3eb2ca51e47ac26ee58c5569892d0128 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 24 Mar 2017 14:16:32 +0100 Subject: [PATCH] Clarify the front face winding order in the Vulkan examples After applying the correction matrix the front face is CW, not CCW. The examples work either way but fix them up to avoid reader confusion. Change-Id: I491e6dc17c21897a59f36d32061e937f2b6c4c9d Reviewed-by: Andy Nichols --- examples/vulkan/hellovulkantexture/hellovulkantexture.cpp | 4 ++-- examples/vulkan/shared/trianglerenderer.cpp | 2 +- src/gui/vulkan/qvulkanwindow.cpp | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp b/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp index 9953352e28c..5e52d5e006f 100644 --- a/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp +++ b/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp @@ -612,8 +612,8 @@ void VulkanRenderer::initResources() memset(&rs, 0, sizeof(rs)); rs.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rs.polygonMode = VK_POLYGON_MODE_FILL; - rs.cullMode = VK_CULL_MODE_NONE; // we want the back face as well - rs.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; + rs.cullMode = VK_CULL_MODE_BACK_BIT; + rs.frontFace = VK_FRONT_FACE_CLOCKWISE; rs.lineWidth = 1.0f; pipelineInfo.pRasterizationState = &rs; diff --git a/examples/vulkan/shared/trianglerenderer.cpp b/examples/vulkan/shared/trianglerenderer.cpp index f2e636bbe61..a0800080a06 100644 --- a/examples/vulkan/shared/trianglerenderer.cpp +++ b/examples/vulkan/shared/trianglerenderer.cpp @@ -337,7 +337,7 @@ void TriangleRenderer::initResources() rs.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rs.polygonMode = VK_POLYGON_MODE_FILL; rs.cullMode = VK_CULL_MODE_NONE; // we want the back face as well - rs.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; + rs.frontFace = VK_FRONT_FACE_CLOCKWISE; rs.lineWidth = 1.0f; pipelineInfo.pRasterizationState = &rs; diff --git a/src/gui/vulkan/qvulkanwindow.cpp b/src/gui/vulkan/qvulkanwindow.cpp index d5af71cd4be..b158fa7e942 100644 --- a/src/gui/vulkan/qvulkanwindow.cpp +++ b/src/gui/vulkan/qvulkanwindow.cpp @@ -2692,6 +2692,10 @@ QImage QVulkanWindow::grab() without any further corrections to the vertex Z positions, while using the projection matrices retrieved from the QMatrix4x4 functions, such as QMatrix4x4::perspective(), as-is. + + \note With vertex data following the default OpenGL rules (that is, the + front face being CCW), the correct winding order in the rasterization state + after applying this matrix is clockwise (\c{VK_FRONT_FACE_CLOCKWISE}). */ const QMatrix4x4 *QVulkanWindow::clipCorrectionMatrix() {