}
+/**
+ * Put z into texel according to GL_DEPTH_MODE.
+ */
+static INLINE void
+apply_depth_mode(GLenum depthMode, GLfloat z, GLfloat texel[4])
+{
+ switch (depthMode) {
+ case GL_LUMINANCE:
+ ASSIGN_4V(texel, z, z, z, 1.0F);
+ break;
+ case GL_INTENSITY:
+ ASSIGN_4V(texel, z, z, z, z);
+ break;
+ case GL_ALPHA:
+ ASSIGN_4V(texel, 0.0F, 0.0F, 0.0F, z);
+ break;
+ case GL_RED:
+ ASSIGN_4V(texel, z, 0.0F, 0.0F, 1.0F);
+ break;
+ default:
+ _mesa_problem(NULL, "Bad depth texture mode");
+ }
+}
+
+
+/**
+ * Is the given texture a depth (or depth/stencil) texture?
+ */
+static GLboolean
+is_depth_texture(const struct gl_texture_object *tObj)
+{
+ GLenum format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat;
+ return format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT;
+}
+
+
/**********************************************************************/
/* 1-D Texture Sampling Functions */
/**********************************************************************/
sample_2d_nearest(ctx, samp, images[tObj->BaseLevel],
newCoord, rgba[i]);
}
+ if (is_depth_texture(tObj)) {
+ for (i = 0; i < n; i++) {
+ apply_depth_mode(tObj->DepthMode, rgba[i][0], rgba[i]);
+ }
+ }
}
sample_2d_linear(ctx, samp, images[tObj->BaseLevel],
newCoord, rgba[i]);
}
+ if (is_depth_texture(tObj)) {
+ for (i = 0; i < n; i++) {
+ apply_depth_mode(tObj->DepthMode, rgba[i][0], rgba[i]);
+ }
+ }
}
sample_2d_nearest(ctx, samp, images[level], newCoord, rgba[i]);
}
+ if (is_depth_texture(tObj)) {
+ for (i = 0; i < n; i++) {
+ apply_depth_mode(tObj->DepthMode, rgba[i][0], rgba[i]);
+ }
+ }
}
images = choose_cube_face(tObj, texcoord[i], newCoord);
sample_2d_linear(ctx, samp, images[level], newCoord, rgba[i]);
}
+ if (is_depth_texture(tObj)) {
+ for (i = 0; i < n; i++) {
+ apply_depth_mode(tObj->DepthMode, rgba[i][0], rgba[i]);
+ }
+ }
}
lerp_rgba(rgba[i], f, t0, t1);
}
}
+ if (is_depth_texture(tObj)) {
+ for (i = 0; i < n; i++) {
+ apply_depth_mode(tObj->DepthMode, rgba[i][0], rgba[i]);
+ }
+ }
}
lerp_rgba(rgba[i], f, t0, t1);
}
}
+ if (is_depth_texture(tObj)) {
+ for (i = 0; i < n; i++) {
+ apply_depth_mode(tObj->DepthMode, rgba[i][0], rgba[i]);
+ }
+ }
}
result = shadow_compare(function, depthRef, depthSample);
- switch (tObj->DepthMode) {
- case GL_LUMINANCE:
- ASSIGN_4V(texel[i], result, result, result, 1.0F);
- break;
- case GL_INTENSITY:
- ASSIGN_4V(texel[i], result, result, result, result);
- break;
- case GL_ALPHA:
- ASSIGN_4V(texel[i], 0.0F, 0.0F, 0.0F, result);
- break;
- case GL_RED:
- ASSIGN_4V(texel[i], result, 0.0F, 0.0F, 1.0F);
- break;
- default:
- _mesa_problem(ctx, "Bad depth texture mode");
- break;
- }
+ apply_depth_mode(tObj->DepthMode, result, texel[i]);
}
}
else {
depth00, depth01, depth10, depth11,
wi, wj);
- switch (tObj->DepthMode) {
- case GL_LUMINANCE:
- ASSIGN_4V(texel[i], result, result, result, 1.0F);
- break;
- case GL_INTENSITY:
- ASSIGN_4V(texel[i], result, result, result, result);
- break;
- case GL_ALPHA:
- ASSIGN_4V(texel[i], 0.0F, 0.0F, 0.0F, result);
- break;
- default:
- _mesa_problem(ctx, "Bad depth texture mode");
- }
-
+ apply_depth_mode(tObj->DepthMode, result, texel[i]);
} /* for */
} /* if filter */
}
else {
const GLboolean needLambda =
(GLboolean) (sampler->MinFilter != sampler->MagFilter);
- const GLenum format = t->Image[0][t->BaseLevel]->_BaseFormat;
switch (t->Target) {
case GL_TEXTURE_1D:
- if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT) {
+ if (is_depth_texture(t)) {
return &sample_depth_texture;
}
else if (needLambda) {
return &sample_nearest_1d;
}
case GL_TEXTURE_2D:
- if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT) {
+ if (is_depth_texture(t)) {
return &sample_depth_texture;
}
else if (needLambda) {
return &sample_nearest_3d;
}
case GL_TEXTURE_CUBE_MAP:
- if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT) {
- return &sample_depth_texture;
- }
- else if (needLambda) {
+ if (needLambda) {
return &sample_lambda_cube;
}
else if (sampler->MinFilter == GL_LINEAR) {
return &sample_nearest_cube;
}
case GL_TEXTURE_RECTANGLE_NV:
- if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT) {
+ if (is_depth_texture(t)) {
return &sample_depth_texture;
}
else if (needLambda) {
return &sample_nearest_rect;
}
case GL_TEXTURE_1D_ARRAY_EXT:
- if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT) {
+ if (is_depth_texture(t)) {
return &sample_depth_texture;
}
else if (needLambda) {
return &sample_nearest_1d_array;
}
case GL_TEXTURE_2D_ARRAY_EXT:
- if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT) {
+ if (is_depth_texture(t)) {
return &sample_depth_texture;
}
else if (needLambda) {