Revise an incorrect QVulkanWindow doc note

Applying the transformation in question has no effect on the winding
order. Rewrite that section.

While all the examples are correct, clarify the rules for the geometry
they use since the winding order varies. Fix up the triangle example code
to use front=CCW for clarity (even though it does not matter much since
culling is off there).

Change-Id: Icb968c76cc9fa918a5608d3c66b4fccd5668175e
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
This commit is contained in:
Laszlo Agocs 2018-09-01 19:51:43 +02:00
parent 689a1e186b
commit 85f127cb04
4 changed files with 9 additions and 13 deletions

View File

@ -53,7 +53,7 @@
#include <QtConcurrentRun> #include <QtConcurrentRun>
#include <QTime> #include <QTime>
static float quadVert[] = { static float quadVert[] = { // Y up, front = CW
-1, -1, 0, -1, -1, 0,
-1, 1, 0, -1, 1, 0,
1, -1, 0, 1, -1, 0,

View File

@ -59,7 +59,7 @@
// Vulkan Y is negated in clip space and the near/far plane is at 0/1 instead // Vulkan Y is negated in clip space and the near/far plane is at 0/1 instead
// of -1/1. These will be corrected for by an extra transformation when // of -1/1. These will be corrected for by an extra transformation when
// calculating the modelview-projection matrix. // calculating the modelview-projection matrix.
static float vertexData[] = { static float vertexData[] = { // Y up, front = CW
// x, y, z, u, v // x, y, z, u, v
-1, -1, 0, 0, 1, -1, -1, 0, 0, 1,
-1, 1, 0, 0, 0, -1, 1, 0, 0, 0,

View File

@ -56,7 +56,7 @@
// Vulkan Y is negated in clip space and the near/far plane is at 0/1 instead // Vulkan Y is negated in clip space and the near/far plane is at 0/1 instead
// of -1/1. These will be corrected for by an extra transformation when // of -1/1. These will be corrected for by an extra transformation when
// calculating the modelview-projection matrix. // calculating the modelview-projection matrix.
static float vertexData[] = { static float vertexData[] = { // Y up, front = CCW
0.0f, 0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.5f, 1.0f, 0.0f, 0.0f,
-0.5f, -0.5f, 0.0f, 1.0f, 0.0f, -0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
0.5f, -0.5f, 0.0f, 0.0f, 1.0f 0.5f, -0.5f, 0.0f, 0.0f, 1.0f
@ -337,7 +337,7 @@ void TriangleRenderer::initResources()
rs.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rs.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rs.polygonMode = VK_POLYGON_MODE_FILL; rs.polygonMode = VK_POLYGON_MODE_FILL;
rs.cullMode = VK_CULL_MODE_NONE; // we want the back face as well rs.cullMode = VK_CULL_MODE_NONE; // we want the back face as well
rs.frontFace = VK_FRONT_FACE_CLOCKWISE; rs.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
rs.lineWidth = 1.0f; rs.lineWidth = 1.0f;
pipelineInfo.pRasterizationState = &rs; pipelineInfo.pRasterizationState = &rs;

View File

@ -2694,15 +2694,11 @@ QImage QVulkanWindow::grab()
system differences between OpenGL and Vulkan. system differences between OpenGL and Vulkan.
By pre-multiplying the projection matrix with this matrix, applications can By pre-multiplying the projection matrix with this matrix, applications can
continue to assume OpenGL-style Y coordinates in clip space (i.e. Y pointing continue to assume that Y is pointing upwards, and can set minDepth and
upwards), and can set minDepth and maxDepth to 0 and 1, respectively, maxDepth in the viewport to 0 and 1, respectively, without having to do any
without any further corrections to the vertex Z positions, while using the further corrections to the vertex Z positions. Geometry from OpenGL
projection matrices retrieved from the QMatrix4x4 functions, such as applications can then be used as-is, assuming a rasterization state matching
QMatrix4x4::perspective(), as-is. the OpenGL culling and front face settings.
\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}).
*/ */
QMatrix4x4 QVulkanWindow::clipCorrectionMatrix() QMatrix4x4 QVulkanWindow::clipCorrectionMatrix()
{ {