1'''OpenGL extension NV.shading_rate_image
2
3This module customises the behaviour of the
4OpenGL.raw.GLES2.NV.shading_rate_image to provide a more
5Python-friendly API
6
7Overview (from the spec)
8
9	By default, OpenGL runs a fragment shader once for each pixel covered by a
10	primitive being rasterized.  When using multisampling, the outputs of that
11	fragment shader are broadcast to each covered sample of the fragment's
12	pixel.  When using multisampling, applications can also request that the
13	fragment shader be run once per color sample (when using the "sample"
14	qualifier on one or more active fragment shader inputs), or run a fixed
15	number of times per pixel using SAMPLE_SHADING enable and the
16	MinSampleShading frequency value.  In all of these approaches, the number
17	of fragment shader invocations per pixel is fixed, based on API state.
18
19	This extension allows applications to bind and enable a shading rate image
20	that can be used to vary the number of fragment shader invocations across
21	the framebuffer.  This can be useful for applications like eye tracking
22	for virtual reality, where the portion of the framebuffer that the user is
23	looking at directly can be processed at high frequency, while distant
24	corners of the image can be processed at lower frequency.  The shading
25	rate image is an immutable-format two-dimensional or two-dimensional array
26	texture that uses a format of R8UI.  Each texel represents a fixed-size
27	rectangle in the framebuffer, covering 16x16 pixels in the initial
28	implementation of this extension.  When rasterizing a primitive covering
29	one of these rectangles, the OpenGL implementation reads the texel in the
30	bound shading rate image and looks up the fetched value in a palette of
31	shading rates.  The shading rate used can vary from (finest) 16 fragment
32	shader invocations per pixel to (coarsest) one fragment shader invocation
33	for each 4x4 block of pixels.
34
35	When this extension is advertised by an OpenGL implementation, the
36	implementation must also support the GLSL extension
37	"GL_NV_shading_rate_image" (documented separately), which provides new
38	built-in variables that allow fragment shaders to determine the effective
39	shading rate used for each fragment.  Additionally, the GLSL extension also
40	provides new layout qualifiers allowing the interlock functionality provided
41	by ARB_fragment_shader_interlock to guarantee mutual exclusion across an
42	entire fragment when the shading rate specifies multiple pixels per fragment
43	shader invocation.
44
45	Note that this extension requires the use of a framebuffer object; the
46	shading rate image and related state are ignored when rendering to the
47	default framebuffer.
48
49The official definition of this extension is available here:
50http://www.opengl.org/registry/specs/NV/shading_rate_image.txt
51'''
52from OpenGL import platform, constant, arrays
53from OpenGL import extensions, wrapper
54import ctypes
55from OpenGL.raw.GLES2 import _types, _glgets
56from OpenGL.raw.GLES2.NV.shading_rate_image import *
57from OpenGL.raw.GLES2.NV.shading_rate_image import _EXTENSION_NAME
58
59def glInitShadingRateImageNV():
60    '''Return boolean indicating whether this extension is available'''
61    from OpenGL import extensions
62    return extensions.hasGLExtension( _EXTENSION_NAME )
63
64glGetShadingRateImagePaletteNV=wrapper.wrapper(glGetShadingRateImagePaletteNV).setInputArraySize(
65    'rate', 1
66)
67glGetShadingRateSampleLocationivNV=wrapper.wrapper(glGetShadingRateSampleLocationivNV).setInputArraySize(
68    'location', 3
69)
70# INPUT glShadingRateImagePaletteNV.rates size not checked against count
71glShadingRateImagePaletteNV=wrapper.wrapper(glShadingRateImagePaletteNV).setInputArraySize(
72    'rates', None
73)
74# INPUT glShadingRateSampleOrderCustomNV.locations size not checked against 'rate,samples'
75glShadingRateSampleOrderCustomNV=wrapper.wrapper(glShadingRateSampleOrderCustomNV).setInputArraySize(
76    'locations', None
77)
78### END AUTOGENERATED SECTION