Skip to content

Commit

Permalink
Add new OpenGL extensions
Browse files Browse the repository at this point in the history
- AMD_shader_explicit_vertex_parameter
- NV_clip_space_w_scaling
- NV_conservative_raster_pre_snap_triangles
- NV_robustness_video_memory_purge
- NV_shader_atomic_float64
- NV_stereo_view_rendering
  • Loading branch information
Spasi committed Jun 3, 2016
1 parent c614278 commit 9bebd53
Show file tree
Hide file tree
Showing 6 changed files with 306 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: http://lwjgl.org/license.php
*/
package org.lwjgl.egl.templates

import org.lwjgl.egl.*
import org.lwjgl.generator.*

val NV_robustness_video_memory_purge = "NVRobustnessVideoMemoryPurge".nativeClassEGL("NV_robustness_video_memory_purge", postfix = NV) {
documentation =
"Native bindings to the {@code EGL_NV_robustness_video_memory_purge} extension."

IntConstant(
"Accepted as an attribute name in the {@code *attrib_list} argument of eglCreateContext.",

"GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV"..0x334C
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,20 @@ val AMD_shader_atomic_counter_ops = EXT_FLAG.nativeClassGL("AMD_shader_atomic_co
Requires ${GL42.core} or ${ARB_shader_atomic_counters.cap}.
"""
}
val AMD_shader_explicit_vertex_parameter = EXT_FLAG.nativeClassGL("AMD_shader_explicit_vertex_parameter", postfix = AMD) {
documentation =
"""
When true, the $registryLink extension is supported.
Unextended GLSL provides a set of fixed function interpolation modes and even those are limited to certain types of interpolants (for example,
interpolation of integer and double isn't supported).
This extension introduces new built-in functions allowing access to vertex parameters explicitly in the fragment shader. It also exposes barycentric
coordinates as new built-in variables, which can be used to implement custom interpolation algorithms using shader code.
Requires ${GL20.core} or ${ARB_shader_objects.link}.
"""
}
val AMD_shader_stencil_export = EXT_FLAG.nativeClassGL("AMD_shader_stencil_export", postfix = AMD) {
documentation =
"""
Expand Down Expand Up @@ -1118,6 +1132,22 @@ val NV_shader_atomic_float = EXT_FLAG.nativeClassGL("NV_shader_atomic_float", po
for these operations is also provided if ${registryLink("NV", "gpu_program5")} is supported.
"""
}
val NV_shader_atomic_float64 = EXT_FLAG.nativeClassGL("NV_shader_atomic_float64", postfix = NV) {
documentation =
"""
When true, the $registryLink extension is supported.
This extension provides GLSL built-in functions and assembly opcodes allowing shaders to perform atomic read-modify-write operations to buffer or
shared memory with double-precision floating-point components. The set of atomic operations provided by this extension is limited to adds and
exchanges. Providing atomic add support allows shaders to atomically accumulate the sum of double-precision floating-point values into buffer memory
across multiple (possibly concurrent) shader invocations.
This extension provides GLSL support for atomics targeting double-precision floating-point pointers (if ${NV_gpu_shader5.link} is supported).
Additionally, assembly opcodes for these operations are also provided if {@code NV_gpu_program5} is supported.
Requires ${ARB_gpu_shader_fp64.link} or {@code NV_gpu_program_fp64}.
"""
}
val NV_shader_atomic_fp16_vector = EXT_FLAG.nativeClassGL("NV_shader_atomic_fp16_vector", postfix = NV) {
documentation =
"""
Expand Down Expand Up @@ -1150,6 +1180,27 @@ val NV_shader_thread_shuffle = EXT_FLAG.nativeClassGL("NV_shader_thread_shuffle"
Requires ${GL43.core} and GLSL 4.3.
"""
}
val NV_stereo_view_rendering = EXT_FLAG.nativeClassGL("NV_stereo_view_rendering", postfix = NV) {
documentation =
"""
When true, the $registryLink extension is supported.
Virtual reality (VR) applications often render a single logical scene from multiple views corresponding to a pair of eyes. The views (eyes) are
separated by a fixed offset in the X direction.
Traditionally, multiple views are rendered via multiple rendering passes. This is expensive for the GPU because the objects in the scene must be
transformed, rasterized, shaded, and fragment processed redundantly. This is expensive for the CPU because the scene graph needs to be visited multiple
times and driver validation happens for each view. Rendering N passes tends to take N times longer than a single pass.
This extension provides a mechanism to render binocular (stereo) views from a single stream of OpenGL rendering commands. Vertex, tessellation, and
geometry (VTG) shaders can output two positions for each vertex corresponding to the two eye views. A built-in "gl_SecondaryPositionNV" is added to
specify the second position. The positions from each view may be sent to different viewports and/or layers. A built-in "gl_SecondaryViewportMaskNV[]"
is also added to specify the viewport mask for the second view. A new layout-qualifier "secondary_view_offset" is added for built-in output "gl_Layer"
which allows for the geometry from each view to be sent to different layers for rendering.
Requires {@link \\#GL_NV_viewport_array2 NV_viewport_array2}.
"""
}
val NV_texture_compression_vtc = EXT_FLAG.nativeClassGL("NV_texture_compression_vtc", postfix = NV) {
documentation =
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: http://lwjgl.org/license.php
*/
package org.lwjgl.opengl.templates

import org.lwjgl.generator.*
import org.lwjgl.opengl.*

val NV_clip_space_w_scaling = "NVClipSpaceWScaling".nativeClassGL("NV_clip_space_w_scaling", postfix = NV) {
documentation =
"""
Virtual Reality (VR) applications often involve a post-processing step to apply a "barrel" distortion to the rendered image to correct the "pincushion"
distortion introduced by the optics in a VR device. The barrel distorted image has lower resolution along the edges compared to the center. Since the
original image is rendered at high resolution, which is uniform across the complete image, a lot of pixels towards the edges do not make it to the
final post-processed image.
This extension also provides a mechanism to render VR scenes at a non-uniform resolution, in particular a resolution that falls linearly from the
center towards the edges. This is achieved by scaling the "w" coordinate of the vertices in the clip space before perspective divide. The clip space
"w" coordinate of the vertices may be offset as of a function of "x" and "y" coordinates as follows:
${codeBlock("""
w' = w + Ax + By""")}
In the intended use case for viewport position scaling, an application should use a set of 4 viewports, one for each of the 4 quadrants of a Cartesian
coordinate system. Each viewport is set to the dimension of the image, but is scissored to the quadrant it represents. The application should specify A
and B coefficients of the w-scaling equation above, that have the same value, but different signs, for each of the viewports. The signs of A and B
should match the signs of X and Y for the quadrant that they represent such that the value of "w'" will always be greater than or equal to the original
"w" value for the entire image. Since the offset to "w", (Ax + By), is always positive and increases with the absolute values of "x" and "y", the
effective resolution will fall off linearly from the center of the image to its edges.
"""

IntConstant(
"Accepted by the {@code cap} parameter of Enable, Disable, IsEnabled.",

"VIEWPORT_POSITION_W_SCALE_NV"..0x937C
)

IntConstant(
"Accepted by the {@code pname} parameter of GetBooleani_v, GetDoublei_v, GetIntegeri_v, GetFloati_v, and GetInteger64i_v.",

"VIEWPORT_POSITION_W_SCALE_X_COEFF"..0x937D,
"VIEWPORT_POSITION_W_SCALE_Y_COEFF"..0x937E
)

void(
"ViewportPositionWScaleNV",
"""
If #VIEWPORT_POSITION_W_SCALE_NV is enabled, the w coordinates for each primitive sent to a given viewport will be scaled as a function of its x and y
coordinates using the following equation:
${codeBlock("""
w' = xcoeff * x + ycoeff * y + w;""")}
The coefficients for "x" and "y" used in the above equation depend on the viewport index, and are controlled by this command.
The viewport specified by {@code index} has its coefficients for "x" and "y" set to the {@code xcoeff} and {@code ycoeff} values. Specifying these
coefficients enables rendering images at a non-uniform resolution, in particular a resolution that falls off linearly from the center towards the
edges, which is useful for VR applications. VR applications often involve a post-processing step to apply a "barrel" distortion to the rendered image
to correct the "pincushion" distortion introduced by the optics in a VR device. The barrel distorted image, has lower resolution along the edges
compared to the center. Since the original image is rendered at high resolution, which is uniform across the complete image, a lot of pixels towards
the edges do not make it to the final post-processed image. VR applications may use the w-scaling to minimize the processing of unused fragments. To
achieve the intended effect, applications should use a set of 4 viewports one for each of the 4 quadrants of a Cartesian coordinate system. Each
viewport is set to the dimension of the image, but is scissored to the quadrant it represents. The application should specify the x and y coefficients
of the w-scaling equation above, that have the same value, but different signs, for each of the viewports. The signs of {@code xcoeff} and
{@code ycoeff} should match the signs of X and Y for the quadrant that they represent such that the value of "w'" will always be greater than or equal
to the original "w" value for the entire image. Since the offset to "w", (Ax + By), is always positive and increases with the absolute values of "x"
and "y", the effective resolution will fall off linearly from the center of the image to its edges.
""",

GLuint.IN("index", "the viewport index"),
GLfloat.IN("xcoeff", "the x coefficient"),
GLfloat.IN("ycoeff", "the y coefficient")
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: http://lwjgl.org/license.php
*/
package org.lwjgl.opengl.templates

import org.lwjgl.generator.*
import org.lwjgl.opengl.*

val NV_conservative_raster_pre_snap_triangles = "NVConservativeRasterPreSnapTriangles".nativeClassGL("NV_conservative_raster_pre_snap_triangles", postfix = NV) {
documentation =
"""
When #CONSERVATIVE_RASTERIZATION_NV is enabled, the fragments generated for a primitive are conservative with respect to the primitive after snapping
to sub-pixel grid. This extension provides a new mode of rasterization for triangles where the fragments generated are conservative with respect to the
primitive at infinite precision before vertex snapping.
When the conservative raster mode is set to #CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV, triangles are rasterized more conservatively, and may
generate fragments not generated when the mode is #CONSERVATIVE_RASTER_MODE_POST_SNAP_NV (default). In particular it may generate fragments for pixels
covered by triangles with zero area, or for pixels that are adjacent to but not covered by any triangle. This modified behavior may be useful in
compensating for rounding errors caused by snapping vertex positions to a sub-pixel grid during rasterization. It's possible that a non-degenerate
triangle becomes degenerate due to snapping. It's additionally possible that rounding errors in computing the position of a vertex or from snapping may
cause a primitive that would cover a pixel at infinite precision to fail to cover the pixel post-snap. Rasterizing such primitives more conservatively
may be useful for "binning" algorithms described in ${NV_conservative_raster.link}.
"""

IntConstant(
"Accepted by the {@code pname} parameter of ConservativeRasterParameteriNV.",

"CONSERVATIVE_RASTER_MODE_NV"..0x954D
)

val Modes = IntConstant(
"Accepted by the {@code param} parameter of ConservativeRasterParameteriNV.",

"CONSERVATIVE_RASTER_MODE_POST_SNAP_NV"..0x954E,
"CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV"..0x954F
).javaDocLinks

void(
"ConservativeRasterParameteriNV",
"""
When #CONSERVATIVE_RASTERIZATION_NV is enabled, the rasterization behavior may be controlled by calling the this command.
If the mode is set to #CONSERVATIVE_RASTER_MODE_POST_SNAP_NV, the generated fragments are conservative w.r.t the primitive after it is snapped to
sub-pixel grid. If the mode is set to #CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV the fragments generated for triangles will be conservative w.r.t
the triangle at infinite precision. Since non-degenerate triangles may become degenerate due to vertex snapping, this mode will generate fragments for
zero area triangles that are otherwise culled when the mode is #CONSERVATIVE_RASTER_MODE_POST_SNAP_NV. This mode may also generate fragments for pixels
that are within half a sub-pixel distance away from a triangle's infinite precision boundary. The default mode is set to
#CONSERVATIVE_RASTER_MODE_POST_SNAP_NV.
""",

GLenum.IN("pname", "the parameter to set", "#CONSERVATIVE_RASTER_MODE_NV"),
GLint.IN("param", "specifies the conservative raster mode to be used", Modes)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: http://lwjgl.org/license.php
*/
package org.lwjgl.opengl.templates

import org.lwjgl.generator.*
import org.lwjgl.opengl.*

val NV_robustness_video_memory_purge = "NVRobustnessVideoMemoryPurge".nativeClassGL("NV_robustness_video_memory_purge", postfix = NV) {
documentation =
"""
Native bindings to the $registryLink extension.
This extension allows applications to be notified when video memory has been purged.
The NVIDIA OpenGL driver architecture on Linux has a limitation: resources located in video memory are not persistent across certain events. VT
switches, suspend/resume events, and mode switching events may erase the contents of video memory. Any resource that is located exclusively in video
memory, such as framebuffer objects (FBOs), will be lost. As the OpenGL specification makes no mention of events where the video memory is allowed to
be cleared, the driver attempts to hide this fact from the application, but cannot do it for all resources.
This extension provides a way for applications to discover when video memory content has been lost, so that the application can re-populate the video
memory content as necessary.
This extension will have a limited lifespan, as planned architectural evolutions in the NVIDIA Linux driver stack will allow video memory to be
persistent. Any driver that exposes this extension is a driver that considers video memory to be volatile. Once the driver stack has been improved, the
extension will no longer be exposed.
"""

IntConstant(
"Returned by GetGraphicsResetStatusARB, in addition to other tokens defined in ARB_robustness.",

"PURGED_CONTEXT_RESET_NV"..0x92BB
)
}

val GLX_NV_robustness_video_memory_purge = "GLXNVRobustnessVideoMemoryPurge".nativeClassGLX("GLX_NV_robustness_video_memory_purge", postfix = NV) {
documentation =
"""
Native bindings to the ${registryLinkTo("NV", "robustness_video_memory_purge", "GLX_NV_robustness_video_memory_purge")} extension.
GLX functionality for ${NV_robustness_video_memory_purge.link}.
"""

IntConstant(
"Accepted as an attribute name in the {@code *attrib_list} argument of glXCreateContextAttribsARB.",

"GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV"..0x20F7
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: http://lwjgl.org/license.php
*/
package org.lwjgl.opengles.templates

import org.lwjgl.generator.*
import org.lwjgl.opengles.*

val NV_conservative_raster_pre_snap_triangles = "NVConservativeRasterPreSnapTriangles".nativeClassGLES(
"NV_conservative_raster_pre_snap_triangles",
postfix = NV
) {
documentation =
"""
When #CONSERVATIVE_RASTERIZATION_NV is enabled, the fragments generated for a primitive are conservative with respect to the primitive after snapping
to sub-pixel grid. This extension provides a new mode of rasterization for triangles where the fragments generated are conservative with respect to the
primitive at infinite precision before vertex snapping.
When the conservative raster mode is set to #CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV, triangles are rasterized more conservatively, and may
generate fragments not generated when the mode is #CONSERVATIVE_RASTER_MODE_POST_SNAP_NV (default). In particular it may generate fragments for pixels
covered by triangles with zero area, or for pixels that are adjacent to but not covered by any triangle. This modified behavior may be useful in
compensating for rounding errors caused by snapping vertex positions to a sub-pixel grid during rasterization. It's possible that a non-degenerate
triangle becomes degenerate due to snapping. It's additionally possible that rounding errors in computing the position of a vertex or from snapping may
cause a primitive that would cover a pixel at infinite precision to fail to cover the pixel post-snap. Rasterizing such primitives more conservatively
may be useful for "binning" algorithms described in ${NV_conservative_raster.link}.
"""

IntConstant(
"Accepted by the {@code pname} parameter of ConservativeRasterParameteriNV.",

"CONSERVATIVE_RASTER_MODE_NV"..0x954D
)

val Modes = IntConstant(
"Accepted by the {@code param} parameter of ConservativeRasterParameteriNV.",

"CONSERVATIVE_RASTER_MODE_POST_SNAP_NV"..0x954E,
"CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV"..0x954F
).javaDocLinks

void(
"ConservativeRasterParameteriNV",
"""
When #CONSERVATIVE_RASTERIZATION_NV is enabled, the rasterization behavior may be controlled by calling the this command.
If the mode is set to #CONSERVATIVE_RASTER_MODE_POST_SNAP_NV, the generated fragments are conservative w.r.t the primitive after it is snapped to
sub-pixel grid. If the mode is set to #CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV the fragments generated for triangles will be conservative w.r.t
the triangle at infinite precision. Since non-degenerate triangles may become degenerate due to vertex snapping, this mode will generate fragments for
zero area triangles that are otherwise culled when the mode is #CONSERVATIVE_RASTER_MODE_POST_SNAP_NV. This mode may also generate fragments for pixels
that are within half a sub-pixel distance away from a triangle's infinite precision boundary. The default mode is set to
#CONSERVATIVE_RASTER_MODE_POST_SNAP_NV.
""",

GLenum.IN("pname", "the parameter to set", "#CONSERVATIVE_RASTER_MODE_NV"),
GLint.IN("param", "specifies the conservative raster mode to be used", Modes)
)
}

0 comments on commit 9bebd53

Please sign in to comment.