Skip to content

Commit

Permalink
Second attempt to work around windows+intel driver bugs
Browse files Browse the repository at this point in the history
Tunrs out that the intel driver on windows was more broken than I could
possibly imagine.  Not only does gl_FragDepth interact badly with
gl_PointCoord, but so does gl_FragCoord.  Unclear what to do about this,
other than just blacklist the features on that platform.
  • Loading branch information
c42f committed Aug 10, 2015
1 parent 5e02d90 commit f73b1d0
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 40 deletions.
15 changes: 8 additions & 7 deletions shaders/cylindrical_proj.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ void main()
if (markerShape < 0) // markerShape == -1: discarded.
discard;
// (markerShape == 0: Square shape)
float fragDepth = gl_FragCoord.z;
# ifndef BROKEN_GL_FRAG_COORD
gl_FragDepth = gl_FragCoord.z;
# endif
if (markerShape > 0 && pointScreenSize > pointScreenSizeLimit)
{
float w = markerWidth;
Expand All @@ -174,9 +176,11 @@ void main()
float r = length(p);
if (r > 1)
discard;
fragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w
// TODO: Why is the factor of 0.5 required here?
* 0.5*modifiedPointRadius*sqrt(1-r*r);
# ifndef BROKEN_GL_FRAG_COORD
gl_FragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w
// TODO: Why is the factor of 0.5 required here?
* 0.5*modifiedPointRadius*sqrt(1-r*r);
# endif
}
else if (markerShape == 2) // shape: o
{
Expand All @@ -197,9 +201,6 @@ void main()
discard;
}
}
# ifndef NO_GL_FRAG_DEPTH
gl_FragDepth = fragDepth;
# endif
fragColor = vec4(pointColor, 1);
}

Expand Down
15 changes: 8 additions & 7 deletions shaders/generic_points.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ void main()
if (markerShape2 < 0) // markerShape2 == -1: discarded.
discard;
// (markerShape2 == 1: Square shape)
float fragDepth = gl_FragCoord.z;
# ifndef BROKEN_GL_FRAG_COORD
gl_FragDepth = gl_FragCoord.z;
# endif
if (markerShape2 != 1 && pointScreenSize > pointScreenSizeLimit)
{
float w = markerWidth;
Expand All @@ -103,9 +105,11 @@ void main()
float r = length(p);
if (r > 1)
discard;
fragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w
// TODO: Why is the factor of 0.5 required here?
* 0.5*modifiedPointRadius*sqrt(1-r*r);
# ifndef BROKEN_GL_FRAG_COORD
gl_FragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w
// TODO: Why is the factor of 0.5 required here?
* 0.5*modifiedPointRadius*sqrt(1-r*r);
# endif
}
else if (markerShape2 == 2) // shape: o
{
Expand All @@ -126,9 +130,6 @@ void main()
discard;
}
}
# ifndef NO_GL_FRAG_DEPTH
gl_FragDepth = fragDepth;
# endif
fragColor = vec4(pointColor, 1);
}

Expand Down
15 changes: 8 additions & 7 deletions shaders/las_points.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ void main()
if (markerShape < 0) // markerShape == -1: discarded.
discard;
// (markerShape == 0: Square shape)
float fragDepth = gl_FragCoord.z;
# ifndef BROKEN_GL_FRAG_COORD
gl_FragDepth = gl_FragCoord.z;
# endif
if (markerShape > 0 && pointScreenSize > pointScreenSizeLimit)
{
float w = markerWidth;
Expand All @@ -180,9 +182,11 @@ void main()
float r = length(p);
if (r > 1)
discard;
fragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w
// TODO: Why is the factor of 0.5 required here?
* 0.5*modifiedPointRadius*sqrt(1-r*r);
# ifndef BROKEN_GL_FRAG_COORD
gl_FragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w
// TODO: Why is the factor of 0.5 required here?
* 0.5*modifiedPointRadius*sqrt(1-r*r);
# endif
}
else if (markerShape == 2) // shape: o
{
Expand All @@ -203,9 +207,6 @@ void main()
discard;
}
}
# ifndef NO_GL_FRAG_DEPTH
gl_FragDepth = fragDepth;
# endif
fragColor = vec4(pointColor, 1);
}

Expand Down
15 changes: 8 additions & 7 deletions shaders/las_points_lod.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ void main()
if (stippleThresholds[int(gl_FragCoord.x) % 4 + 4*(int(gl_FragCoord.y) % 4)] > fragCoverage)
discard;
*/
float fragDepth = gl_FragCoord.z;
# ifndef BROKEN_GL_FRAG_COORD
gl_FragDepth = gl_FragCoord.z;
# endif
if (fragMarkerShape > 0 && pointScreenSize > pointScreenSizeLimit)
{
vec2 p = 2*(gl_PointCoord - 0.5);
Expand All @@ -116,14 +118,13 @@ void main()
discard;
if (fragMarkerShape == 1) // shape: sphere
{
fragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w
// TODO: Why is the factor of 0.5 required here?
* 0.5*modifiedPointRadius*sqrt(1-r*r);
# ifndef BROKEN_GL_FRAG_COORD
gl_FragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w
// TODO: Why is the factor of 0.5 required here?
* 0.5*modifiedPointRadius*sqrt(1-r*r);
# endif
}
}
# ifndef NO_GL_FRAG_DEPTH
gl_FragDepth = fragDepth;
# endif
fragColor = vec4(pointColor, 1);
}

Expand Down
15 changes: 8 additions & 7 deletions shaders/lod_debug.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ void main()
if (markerShape < 0) // markerShape == -1: discarded.
discard;
// (markerShape == 0: Square shape)
float fragDepth = gl_FragCoord.z;
# ifndef BROKEN_GL_FRAG_COORD
gl_FragDepth = gl_FragCoord.z;
# endif
if (markerShape > 0 && pointScreenSize > pointScreenSizeLimit)
{
float w = markerWidth;
Expand All @@ -183,9 +185,11 @@ void main()
float r = length(p);
if (r > 1)
discard;
fragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w
// TODO: Why is the factor of 0.5 required here?
* 0.5*modifiedPointRadius*sqrt(1-r*r);
# ifndef BROKEN_GL_FRAG_COORD
gl_FragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w
// TODO: Why is the factor of 0.5 required here?
* 0.5*modifiedPointRadius*sqrt(1-r*r);
# endif
}
else if (markerShape == 2) // shape: o
{
Expand All @@ -206,9 +210,6 @@ void main()
discard;
}
}
# ifndef NO_GL_FRAG_DEPTH
gl_FragDepth = fragDepth;
# endif
fragColor = vec4(pointColor, 1);
}

Expand Down
10 changes: 5 additions & 5 deletions src/shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/// Make shader #define flags for hardware or driver-dependent blacklisted
/// features. Current list:
///
/// NO_GL_FRAG_DEPTH
/// BROKEN_GL_FRAG_COORD
///
static QByteArray makeBlacklistDefines()
{
Expand All @@ -55,11 +55,11 @@ static QByteArray makeBlacklistDefines()
if (vendorStr.contains("intel", Qt::CaseInsensitive))
isIntel = true;
QByteArray defines;
// Blacklist use of gl_FragDepth with Intel drivers on windows - for some
// reason, this interacts badly with any use of gl_FragCoord, leading to
// gross rendering artifacts.
// Blacklist use of gl_FragCoord/gl_FragDepth with Intel drivers on
// windows. For some reason, this interacts badly with any use of
// gl_PointCoord, leading to gross rendering artifacts.
if (isWindows && isIntel)
defines += "#define NO_GL_FRAG_DEPTH\n";
defines += "#define BROKEN_GL_FRAG_COORD\n";
return defines;
}

Expand Down

0 comments on commit f73b1d0

Please sign in to comment.