aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/texparam.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main/texparam.c')
-rw-r--r--mesalib/src/mesa/main/texparam.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index bbdbc2763..bfb2e1b9f 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -451,6 +451,20 @@ set_tex_parameteri(struct gl_context *ctx,
}
goto invalid_pname;
+ case GL_DEPTH_STENCIL_TEXTURE_MODE:
+ if (_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_stencil_texturing) {
+ bool stencil = params[0] == GL_STENCIL_INDEX;
+ if (!stencil && params[0] != GL_DEPTH_COMPONENT)
+ goto invalid_param;
+
+ if (texObj->StencilSampling == stencil)
+ return GL_FALSE;
+
+ texObj->StencilSampling = stencil;
+ return GL_TRUE;
+ }
+ goto invalid_pname;
+
case GL_TEXTURE_CROP_RECT_OES:
if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture)
goto invalid_pname;
@@ -707,6 +721,7 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
case GL_TEXTURE_COMPARE_MODE_ARB:
case GL_TEXTURE_COMPARE_FUNC_ARB:
case GL_DEPTH_TEXTURE_MODE_ARB:
+ case GL_DEPTH_STENCIL_TEXTURE_MODE:
case GL_TEXTURE_SRGB_DECODE_EXT:
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
case GL_TEXTURE_SWIZZLE_R_EXT:
@@ -762,6 +777,7 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
case GL_TEXTURE_COMPARE_MODE_ARB:
case GL_TEXTURE_COMPARE_FUNC_ARB:
case GL_DEPTH_TEXTURE_MODE_ARB:
+ case GL_DEPTH_STENCIL_TEXTURE_MODE:
case GL_TEXTURE_SRGB_DECODE_EXT:
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
{
@@ -1038,9 +1054,16 @@ get_tex_level_parameter_image(struct gl_context *ctx,
img = _mesa_select_tex_image(ctx, texObj, target, level);
if (!img || img->TexFormat == MESA_FORMAT_NONE) {
- /* undefined texture image */
- if (pname == GL_TEXTURE_COMPONENTS)
- *params = 1;
+ /* In case of undefined texture image return the default values.
+ *
+ * From OpenGL 4.0 spec, page 398:
+ * "The initial internal format of a texel array is RGBA
+ * instead of 1. TEXTURE_COMPONENTS is deprecated; always
+ * use TEXTURE_INTERNAL_FORMAT."
+ */
+
+ if (pname == GL_TEXTURE_INTERNAL_FORMAT)
+ *params = GL_RGBA;
else
*params = 0;
return;
@@ -1452,6 +1475,12 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
goto invalid_pname;
*params = (GLfloat) obj->DepthMode;
break;
+ case GL_DEPTH_STENCIL_TEXTURE_MODE:
+ if (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_stencil_texturing)
+ goto invalid_pname;
+ *params = (GLfloat)
+ (obj->StencilSampling ? GL_STENCIL_INDEX : GL_DEPTH_COMPONENT);
+ break;
case GL_TEXTURE_LOD_BIAS:
if (_mesa_is_gles(ctx))
goto invalid_pname;
@@ -1666,6 +1695,12 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
goto invalid_pname;
*params = (GLint) obj->DepthMode;
break;
+ case GL_DEPTH_STENCIL_TEXTURE_MODE:
+ if (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_stencil_texturing)
+ goto invalid_pname;
+ *params = (GLint)
+ (obj->StencilSampling ? GL_STENCIL_INDEX : GL_DEPTH_COMPONENT);
+ break;
case GL_TEXTURE_LOD_BIAS:
if (_mesa_is_gles(ctx))
goto invalid_pname;