From 2020a71cf1922f2e0fee1e15a196ba0599d9dcc8 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 21 Jun 2022 12:47:18 +0100 Subject: [PATCH] Account for flip in face culling winding for GL clip origin * The GL clip origin when changed from lower left to upper left will also invert the face culling sense. This is deliberate to counteract the fact that otherwise CW wound triangles would be CCW wound, so the flip means that if GL_CCW is the front face state and back faces are culled, then visibly CCW wound triangles will be culled. --- qrenderdoc/Code/QRDUtils.cpp | 5 ++- .../PipelineState/GLPipelineStateViewer.cpp | 35 +++++++++++++++++-- .../PipelineState/GLPipelineStateViewer.ui | 22 ++++++------ 3 files changed, 49 insertions(+), 13 deletions(-) diff --git a/qrenderdoc/Code/QRDUtils.cpp b/qrenderdoc/Code/QRDUtils.cpp index daa5a5294..bd65da02b 100644 --- a/qrenderdoc/Code/QRDUtils.cpp +++ b/qrenderdoc/Code/QRDUtils.cpp @@ -2386,7 +2386,8 @@ bool QCollatorSortFilterProxyModel::lessThan(const QModelIndex &source_left, void addGridLines(QGridLayout *grid, QColor gridColor) { QString style = - QFormatStr("border: solid #%1%2%3; border-bottom-width: 1px; border-right-width: 1px;") + QFormatStr( + "QLabel { border: solid #%1%2%3; border-bottom-width: 1px; border-right-width: 1px;") .arg(gridColor.red(), 2, 16, QLatin1Char('0')) .arg(gridColor.green(), 2, 16, QLatin1Char('0')) .arg(gridColor.blue(), 2, 16, QLatin1Char('0')); @@ -2412,6 +2413,8 @@ void addGridLines(QGridLayout *grid, QColor gridColor) if(y == 0) cellStyle += lit("border-top-width: 1px;"); + cellStyle += lit(" };"); + w->setStyleSheet(cellStyle); } } diff --git a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp index adc56e5ee..ae61e9c71 100644 --- a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp @@ -686,7 +686,8 @@ void GLPipelineStateViewer::clearState() ui->fillMode->setText(tr("Solid", "Fill Mode")); ui->cullMode->setText(tr("Front", "Cull Mode")); - ui->frontCCW->setPixmap(tick); + ui->frontFace->setText(tr("CCW")); + ui->frontFace->setToolTip(QString()); ui->scissorEnabled->setPixmap(tick); ui->provoking->setText(tr("Last")); @@ -1788,7 +1789,37 @@ void GLPipelineStateViewer::setState() ui->fillMode->setText(ToQStr(state.rasterizer.state.fillMode)); ui->cullMode->setText(ToQStr(state.rasterizer.state.cullMode)); - ui->frontCCW->setPixmap(state.rasterizer.state.frontCCW ? tick : cross); + + if(state.rasterizer.state.frontCCW) + { + if(state.vertexProcessing.clipOriginLowerLeft) + { + ui->frontFace->setText(tr("CCW")); + ui->frontFace->setToolTip(QString()); + } + else + { + ui->frontFace->setText(tr("CW (clip origin flipped)")); + ui->frontFace->setToolTip( + tr("The GL state specifies that front faces have CCW winding,\n" + "but this is inverted by the upper-left clip origin.")); + } + } + else + { + if(state.vertexProcessing.clipOriginLowerLeft) + { + ui->frontFace->setText(tr("CW")); + ui->frontFace->setToolTip(QString()); + } + else + { + ui->frontFace->setText(tr("CCW (clip origin flipped)")); + ui->frontFace->setToolTip( + tr("The GL state specifies that front faces have CW winding,\n" + "but this is inverted by the upper-left clip origin.")); + } + } ui->scissorEnabled->setPixmap(anyScissorEnable ? tick : cross); ui->provoking->setText(state.vertexInput.provokingVertexLast ? tr("Last") : tr("First")); diff --git a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.ui b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.ui index 0d991427b..43fbf14b9 100644 --- a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.ui +++ b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.ui @@ -2552,9 +2552,9 @@ - + - Front CCW: + Rasterizer Discard: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -2565,7 +2565,7 @@ - + @@ -2581,9 +2581,9 @@ - + - Rasterizer Discard: + Front: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -2594,12 +2594,14 @@ - - - + + + + 12 + - - :/cross.png + + CCW Qt::AlignCenter