summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texobj.h
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2014-02-23 21:59:24 -0800
committerKenneth Graunke <[email protected]>2014-03-04 17:21:06 -0800
commit23e81b93bbe3966a842de507988eeaa7342e12ca (patch)
treebda28d42e69a723cf1fd10745d2ff177339202a5 /src/mesa/main/texobj.h
parent5f23a2d9c2df7e7b860246be37b495e7fbea76ca (diff)
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 <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/main/texobj.h')
-rw-r--r--src/mesa/main/texobj.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index a4573b399e3..a9de73fff83 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -114,6 +114,20 @@ _mesa_is_texture_complete(const struct gl_texture_object *texObj,
return GL_FALSE;
}
+ /* From the ARB_stencil_texturing specification:
+ * "Add a new bullet point for the conditions that cause the texture
+ * to not be complete:
+ *
+ * * The internal format of the texture is DEPTH_STENCIL, the
+ * DEPTH_STENCIL_TEXTURE_MODE for the texture is STENCIL_INDEX and either
+ * the magnification filter or the minification filter is not NEAREST."
+ */
+ if (texObj->StencilSampling &&
+ texObj->Image[0][texObj->BaseLevel]->_BaseFormat == GL_DEPTH_STENCIL &&
+ (sampler->MagFilter != GL_NEAREST || sampler->MinFilter != GL_NEAREST)) {
+ return GL_FALSE;
+ }
+
if (_mesa_is_mipmap_filter(sampler))
return texObj->_MipmapComplete;
else