blob: 6f2f6d48ec579dfa868e006e3b62d9c77710bd53 [file] [log] [blame]
Name String
Graham Sellers, AMD (graham.sellers 'at'
Pierre Boudier, AMD
Graham Sellers, AMD
Copyright (c) 2011-2013 The Khronos Group Inc. Copyright terms at
Specification Update Policy
Khronos-approved extension specifications are updated in response to
issues and bugs prioritized by the Khronos OpenGL Working Group. For
extensions which have been promoted to a core Specification, fixes will
first appear in the latest version of that core Specification, and will
eventually be backported to the extension document. This policy is
described in more detail at
Complete. Approved by the ARB on 2011/06/20.
Approved by the Khronos Promoters on 2011/07/29.
Last Modified Date: 06/20/2010
Author Revision: 6
ARB Extension #111
OpenGL 3.0 is required.
This extension is written against the OpenGL Shading Language Version 4.00.
There is a common optimization for hardware accelerated implementation of
OpenGL which relies on an early depth test to be run before the fragment
shader so that the shader evaluation can be skipped if the fragment ends
up being discarded because it is occluded.
This optimization does not affect the final rendering, and is typically
possible when the fragment does not change the depth programmatically.
(i.e.: it does not write to the built-in gl_FragDepth output). There are,
however a class of operations on the depth in the shader which could
still be performed while allowing the early depth test to operate.
This extension allows the application to pass enough information to the
GL implementation to activate such optimizations safely.
New Procedures and Functions
New Tokens
Additions to the AGL/GLX/WGL Specifications
Modifications to the OpenGL Shading Language Specification version 1.50.9
Additions to Chapter 1 of the OpenGL Shading Language 4.00.08 Specification (Introduction)
Additions to Chapter 2 of the OpenGL Shading Language 4.00.08 Specification (Overview of OpenGL Shading)
Additions to Chapter 3 of the OpenGL Shading Language 4.00.08 Specification (Basics)
Add a new Section 3.3.x, GL_ARB_conservative_depth Extension
Including the following line in a shader can be used to control the language
features described in this extension:
#extension GL_ARB_conservative_depth: <behavior>
where <behavior> is as described in section 3.3.
A new preprocessor #define is added to the OpenGL Shading Language:
#define GL_ARB_conservative_depth 1
Additions to Chapter 4 of the OpenGL Shading Language 4.00.08 Specification (Variables and Types)
Modify Section (Output Layout Qualifiers) page 47
Modify the paragraph beginning: "Fragment shaders allow output layout
qualifiers only..."
Fragment shaders allow output layout qualifiers only on the interface
out, or for the purposes of redeclaring the built-in variable
gl_FragDepth (ses Section 7.2, Fragment Shader Special Variables).
Insert the following before the paragraph beginning: "Geometry shaders can
have three types of output layout qualifiers..."
The built-in fragment shader variable gl_FragDepth may be redeclared using
one of the following layout qualifiers.
For example:
layout (depth_greater) out float gl_FragDepth;
The layout qualifier for gl_FragDepth specifies constraints on the final
value of gl_FragDepth written by any shader invocation. GL implementations
may perform optimizations assuming that the depth test fails (or passes)
for a given fragment if all values of gl_FragDepth consistent with the layout
qualifier would fail (or pass). If the final value of gl_FragDepth
is inconsistent with its layout qualifier, the result of the depth test for
the corresponding fragment is undefined. However, no error will be
generated in this case. When the depth test passes and depth writes are
enabled, the value written to the depth buffer is always the value of
gl_FragDepth, whether or not it is consistent with the layout qualifier.
By default, gl_FragDepth assumes the <depth_any> layout qualifier. When
the layout qualifier for gl_FragDepth is <depth_any>, the shader compiler
will note any assignment to gl_FragDepth modifying it in an unknown way,
and depth testing will always be performed after the shader has executed.
When the layout qualifier is "depth_greater", the GL will assume that the
final value of gl_FragDepth is greater than or equal to the fragment's
interpolated depth value, as given by the <z> component of gl_FragCoord.
When the layout qualifier is <depth_less>, the GL will assume that any
modification of gl_FragDepth will only decrease its value. When the
layout qualifier is <depth_unchanged>, the shader compiler will honor
any modification to gl_FragDepth, but the rest of the GL assume that
gl_FragDepth is not assigned a new value.
Redeclarations of gl_FragDepth are performed as follows:
// redeclaration that changes nothing is allowed
out float gl_FragDepth;
// assume it may be modified in any way
layout (depth_any) out float gl_FragDepth;
// assume it may be modified such that its value will only increase
layout (depth_greater) out float gl_FragDepth;
// assume it may be modified such that its value will only decrease
layout (depth_less) out float gl_FragDepth;
// assume it will not be modified
layout (depth_unchanged) out float gl_FragDepth;
If gl_FragDepth is redeclared in any fragment shader in a program, it must
be redeclared in all fragment shaders in that program that have static
assignments to gl_FragDepth. All redeclarations of gl_FragDepth in all
fragment shaders in a single program must have the same set of qualifiers.
Within any shader, the first redeclarations of gl_FragDepth must appear
before any use of gl_FragDepth. The built-in gl_FragDepth is only
predeclared in fragment shaders, so redeclaring it in any other shader
language will be illegal.
Revision History
Rev. Date Author Changes
---- -------- -------- -----------------------------------------
6 6/20/2011 wwlk approved by ARB
5 1/27/2011 johnk Update with edits from reviews of the core spec.
4 12/17/2010 johnk Correct gl_Depth -> gl_FragDepth
Make the code examples fit within the width of
actual paper.
3 04/01/2010 gsellers Minor cleanup. Update to GLSL 4.00.
2 12/01/2009 gsellers Internal updates
1 11/03/2009 pboudier Initial draft