aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/swrast
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-08-27 08:17:50 +0200
committermarha <marha@users.sourceforge.net>2012-09-04 14:23:00 +0200
commit02b914d3b9b658a16e17cf2d95deede75dbbacc9 (patch)
tree3757711ab3e1db8e1b59877354096503d9635112 /mesalib/src/mesa/swrast
parentf479a5fc7f844d96b169c399cb1e8ac085de6c2b (diff)
downloadvcxsrv-02b914d3b9b658a16e17cf2d95deede75dbbacc9.tar.gz
vcxsrv-02b914d3b9b658a16e17cf2d95deede75dbbacc9.tar.bz2
vcxsrv-02b914d3b9b658a16e17cf2d95deede75dbbacc9.zip
xwininfo fontconfig libX11 libXau libXext libxcb mesa pixman
xkeyboard-config git update 27 Aug 2012
Diffstat (limited to 'mesalib/src/mesa/swrast')
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.c96
-rw-r--r--mesalib/src/mesa/swrast/s_texfilter.c115
-rw-r--r--mesalib/src/mesa/swrast/s_texture.c5
3 files changed, 125 insertions, 91 deletions
diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c
index db7c887b6..741dd876c 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.c
+++ b/mesalib/src/mesa/swrast/s_texfetch.c
@@ -426,27 +426,27 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
},
{
MESA_FORMAT_SRGB_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_srgb_dxt1,
- NULL
+ _mesa_fetch_texel_srgb_dxt1,
+ _mesa_fetch_texel_srgb_dxt1,
+ _mesa_fetch_texel_srgb_dxt1
},
{
MESA_FORMAT_SRGBA_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_srgba_dxt1,
- NULL
+ _mesa_fetch_texel_srgba_dxt1,
+ _mesa_fetch_texel_srgba_dxt1,
+ _mesa_fetch_texel_srgba_dxt1
},
{
MESA_FORMAT_SRGBA_DXT3,
- NULL,
- _mesa_fetch_texel_2d_f_srgba_dxt3,
- NULL
+ _mesa_fetch_texel_srgba_dxt3,
+ _mesa_fetch_texel_srgba_dxt3,
+ _mesa_fetch_texel_srgba_dxt3
},
{
MESA_FORMAT_SRGBA_DXT5,
- NULL,
- _mesa_fetch_texel_2d_f_srgba_dxt5,
- NULL
+ _mesa_fetch_texel_srgba_dxt5,
+ _mesa_fetch_texel_srgba_dxt5,
+ _mesa_fetch_texel_srgba_dxt5
},
{
@@ -463,27 +463,27 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
},
{
MESA_FORMAT_RGB_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgb_dxt1,
- NULL
+ _mesa_fetch_texel_rgb_dxt1,
+ _mesa_fetch_texel_rgb_dxt1,
+ _mesa_fetch_texel_rgb_dxt1
},
{
MESA_FORMAT_RGBA_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_dxt1,
- NULL
+ _mesa_fetch_texel_rgba_dxt1,
+ _mesa_fetch_texel_rgba_dxt1,
+ _mesa_fetch_texel_rgba_dxt1
},
{
MESA_FORMAT_RGBA_DXT3,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_dxt3,
- NULL
+ _mesa_fetch_texel_rgba_dxt3,
+ _mesa_fetch_texel_rgba_dxt3,
+ _mesa_fetch_texel_rgba_dxt3
},
{
MESA_FORMAT_RGBA_DXT5,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_dxt5,
- NULL
+ _mesa_fetch_texel_rgba_dxt5,
+ _mesa_fetch_texel_rgba_dxt5,
+ _mesa_fetch_texel_rgba_dxt5
},
{
MESA_FORMAT_RGBA_FLOAT32,
@@ -976,51 +976,51 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
},
{
MESA_FORMAT_RED_RGTC1,
- NULL,
- _mesa_fetch_texel_2d_f_red_rgtc1,
- NULL
+ _mesa_fetch_texel_red_rgtc1,
+ _mesa_fetch_texel_red_rgtc1,
+ _mesa_fetch_texel_red_rgtc1
},
{
MESA_FORMAT_SIGNED_RED_RGTC1,
- NULL,
- _mesa_fetch_texel_2d_f_signed_red_rgtc1,
- NULL
+ _mesa_fetch_texel_signed_red_rgtc1,
+ _mesa_fetch_texel_signed_red_rgtc1,
+ _mesa_fetch_texel_signed_red_rgtc1
},
{
MESA_FORMAT_RG_RGTC2,
- NULL,
- _mesa_fetch_texel_2d_f_rg_rgtc2,
- NULL
+ _mesa_fetch_texel_rg_rgtc2,
+ _mesa_fetch_texel_rg_rgtc2,
+ _mesa_fetch_texel_rg_rgtc2
},
{
MESA_FORMAT_SIGNED_RG_RGTC2,
- NULL,
- _mesa_fetch_texel_2d_f_signed_rg_rgtc2,
- NULL
+ _mesa_fetch_texel_signed_rg_rgtc2,
+ _mesa_fetch_texel_signed_rg_rgtc2,
+ _mesa_fetch_texel_signed_rg_rgtc2
},
{
MESA_FORMAT_L_LATC1,
- NULL,
- _mesa_fetch_texel_2d_f_l_latc1,
- NULL
+ _mesa_fetch_texel_l_latc1,
+ _mesa_fetch_texel_l_latc1,
+ _mesa_fetch_texel_l_latc1
},
{
MESA_FORMAT_SIGNED_L_LATC1,
- NULL,
- _mesa_fetch_texel_2d_f_signed_l_latc1,
- NULL
+ _mesa_fetch_texel_signed_l_latc1,
+ _mesa_fetch_texel_signed_l_latc1,
+ _mesa_fetch_texel_signed_l_latc1
},
{
MESA_FORMAT_LA_LATC2,
- NULL,
- _mesa_fetch_texel_2d_f_la_latc2,
- NULL
+ _mesa_fetch_texel_la_latc2,
+ _mesa_fetch_texel_la_latc2,
+ _mesa_fetch_texel_la_latc2
},
{
MESA_FORMAT_SIGNED_LA_LATC2,
- NULL,
- _mesa_fetch_texel_2d_f_signed_la_latc2,
- NULL
+ _mesa_fetch_texel_signed_la_latc2,
+ _mesa_fetch_texel_signed_la_latc2,
+ _mesa_fetch_texel_signed_la_latc2
},
{
MESA_FORMAT_ETC1_RGB8,
diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c
index 3c2aae913..d116a059d 100644
--- a/mesalib/src/mesa/swrast/s_texfilter.c
+++ b/mesalib/src/mesa/swrast/s_texfilter.c
@@ -800,6 +800,42 @@ get_border_color(const struct gl_sampler_object *samp,
}
+/**
+ * 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 */
/**********************************************************************/
@@ -2391,6 +2427,11 @@ sample_nearest_cube(struct gl_context *ctx,
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]);
+ }
+ }
}
@@ -2410,6 +2451,11 @@ sample_linear_cube(struct gl_context *ctx,
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]);
+ }
+ }
}
@@ -2440,6 +2486,11 @@ sample_cube_nearest_mipmap_nearest(struct gl_context *ctx,
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]);
+ }
+ }
}
@@ -2460,6 +2511,11 @@ sample_cube_linear_mipmap_nearest(struct gl_context *ctx,
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]);
+ }
+ }
}
@@ -2490,6 +2546,11 @@ sample_cube_nearest_mipmap_linear(struct gl_context *ctx,
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]);
+ }
+ }
}
@@ -2520,6 +2581,11 @@ sample_cube_linear_mipmap_linear(struct gl_context *ctx,
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]);
+ }
+ }
}
@@ -3520,23 +3586,7 @@ sample_depth_texture( struct gl_context *ctx,
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 {
@@ -3615,20 +3665,7 @@ sample_depth_texture( struct gl_context *ctx,
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 */
}
@@ -3676,11 +3713,10 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
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) {
@@ -3694,7 +3730,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
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) {
@@ -3741,10 +3777,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
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) {
@@ -3755,7 +3788,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
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) {
@@ -3769,7 +3802,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
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) {
@@ -3783,7 +3816,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
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) {
diff --git a/mesalib/src/mesa/swrast/s_texture.c b/mesalib/src/mesa/swrast/s_texture.c
index 8df4b8439..1b73d46e4 100644
--- a/mesalib/src/mesa/swrast/s_texture.c
+++ b/mesalib/src/mesa/swrast/s_texture.c
@@ -29,6 +29,7 @@
#include "main/context.h"
#include "main/fbobject.h"
#include "main/teximage.h"
+#include "main/texobj.h"
#include "swrast/swrast.h"
#include "swrast/s_context.h"
@@ -246,7 +247,7 @@ _swrast_unmap_teximage(struct gl_context *ctx,
void
_swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
{
- const GLuint faces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
+ const GLuint faces = _mesa_num_tex_faces(texObj->Target);
GLuint face, level;
for (face = 0; face < faces; face++) {
@@ -267,7 +268,7 @@ _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
void
_swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
{
- const GLuint faces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
+ const GLuint faces = _mesa_num_tex_faces(texObj->Target);
GLuint face, level;
for (face = 0; face < faces; face++) {