mesa: Add core API support for GL_ARB_stencil_texturing (from 4.3).
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 24 Feb 2014 05:59:24 +0000 (21:59 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 5 Mar 2014 01:21:06 +0000 (17:21 -0800)
commit23e81b93bbe3966a842de507988eeaa7342e12ca
treebda28d42e69a723cf1fd10745d2ff177339202a5
parent5f23a2d9c2df7e7b860246be37b495e7fbea76ca
mesa: Add core API support for GL_ARB_stencil_texturing (from 4.3).

While the GL_ARB_stencil_texturing extension does not allow the creation
of stencil textures, it does allow shaders to sample stencil values
stored in packed depth/stencil textures.

Specifically, applications can call glTexParameter* with a pname of
GL_DEPTH_STENCIL_TEXTURE_MODE and value of either GL_DEPTH_COMPONENT or
GL_STENCIL_INDEX to select which component they wish to sample.  The
default value is GL_DEPTH_COMPONENT (for traditional depth sampling).

Shaders should use an unsigned integer sampler (presumably usampler2D)
to access stencil data.  Otherwise, results are undefined.  Using shadow
samplers with GL_STENCIL_INDEX selected also is undefined behavior.

This patch creates a new gl_texture_object field, StencilSampling, to
indicate that stencil should be sampled rather than depth.  (I chose to
use a boolean since I figured it would be more convenient for drivers.)
It also introduces the [Get]TexParameter code to get and set the value,
and of course the extension plumbing.

v2: Also consider textures incomplete when sampling stencil with
    non-NEAREST min/mag filters (caught by Eric Anholt).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
docs/GL3.txt
src/mapi/glapi/gen/GL4x.xml
src/mesa/main/extensions.c
src/mesa/main/mtypes.h
src/mesa/main/texobj.c
src/mesa/main/texobj.h
src/mesa/main/texparam.c