* determines the subranges in [0, n-1] that are to be minified or magnified.
*/
static INLINE void
-compute_min_mag_ranges( GLfloat minMagThresh, GLuint n, const GLfloat lambda[],
- GLuint *minStart, GLuint *minEnd,
- GLuint *magStart, GLuint *magEnd )
+compute_min_mag_ranges(const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat lambda[],
+ GLuint *minStart, GLuint *minEnd,
+ GLuint *magStart, GLuint *magEnd)
{
- ASSERT(lambda != NULL);
+ GLfloat minMagThresh;
+
+ /* we shouldn't be here if minfilter == magfilter */
+ ASSERT(tObj->MinFilter != tObj->MagFilter);
+
+ /* This bit comes from the OpenGL spec: */
+ if (tObj->MagFilter == GL_LINEAR
+ && (tObj->MinFilter == GL_NEAREST_MIPMAP_NEAREST ||
+ tObj->MinFilter == GL_NEAREST_MIPMAP_LINEAR)) {
+ minMagThresh = 0.5F;
+ }
+ else {
+ minMagThresh = 0.0F;
+ }
#if 0
/* DEBUG CODE: Verify that lambda[] is monotonic.
static void
-sample_nearest_1d( GLcontext *ctx, GLuint texUnit,
+sample_nearest_1d( GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4] )
{
GLuint i;
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
- (void) texUnit;
(void) lambda;
for (i=0;i<n;i++) {
sample_1d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
static void
-sample_linear_1d( GLcontext *ctx, GLuint texUnit,
+sample_linear_1d( GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4] )
{
GLuint i;
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
- (void) texUnit;
(void) lambda;
for (i=0;i<n;i++) {
sample_1d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
*
*/
static void
-sample_lambda_1d( GLcontext *ctx, GLuint texUnit,
+sample_lambda_1d( GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
GLuint i;
ASSERT(lambda != NULL);
- compute_min_mag_ranges(SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit],
- n, lambda, &minStart, &minEnd, &magStart, &magEnd);
+ compute_min_mag_ranges(tObj, n, lambda,
+ &minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
static void
-sample_nearest_2d( GLcontext *ctx, GLuint texUnit,
+sample_nearest_2d( GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
GLuint i;
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
- (void) texUnit;
(void) lambda;
for (i=0;i<n;i++) {
sample_2d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
static void
-sample_linear_2d( GLcontext *ctx, GLuint texUnit,
+sample_linear_2d( GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
GLuint i;
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
- (void) texUnit;
(void) lambda;
if (tObj->WrapS == GL_REPEAT && tObj->WrapT == GL_REPEAT) {
for (i=0;i<n;i++) {
* Format = GL_RGB
*/
static void
-opt_sample_rgb_2d( GLcontext *ctx, GLuint texUnit,
+opt_sample_rgb_2d( GLcontext *ctx,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
const GLint shift = img->WidthLog2;
GLuint k;
(void) ctx;
- (void) texUnit;
(void) lambda;
ASSERT(tObj->WrapS==GL_REPEAT);
ASSERT(tObj->WrapT==GL_REPEAT);
* Format = GL_RGBA
*/
static void
-opt_sample_rgba_2d( GLcontext *ctx, GLuint texUnit,
+opt_sample_rgba_2d( GLcontext *ctx,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
const GLint shift = img->WidthLog2;
GLuint i;
(void) ctx;
- (void) texUnit;
(void) lambda;
ASSERT(tObj->WrapS==GL_REPEAT);
ASSERT(tObj->WrapT==GL_REPEAT);
* values, return an array of texture sample.
*/
static void
-sample_lambda_2d( GLcontext *ctx, GLuint texUnit,
+sample_lambda_2d( GLcontext *ctx,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
&& tImg->_IsPowerOfTwo;
ASSERT(lambda != NULL);
- compute_min_mag_ranges(SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit],
- n, lambda, &minStart, &minEnd, &magStart, &magEnd);
+ compute_min_mag_ranges(tObj, n, lambda,
+ &minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
case MESA_FORMAT_RGB:
case MESA_FORMAT_RGB888:
/*case MESA_FORMAT_BGR888:*/
- opt_sample_rgb_2d(ctx, texUnit, tObj, m, texcoords + minStart,
+ opt_sample_rgb_2d(ctx, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
break;
case MESA_FORMAT_RGBA:
case MESA_FORMAT_ARGB8888:
/*case MESA_FORMAT_ABGR8888:*/
/*case MESA_FORMAT_BGRA8888:*/
- opt_sample_rgba_2d(ctx, texUnit, tObj, m, texcoords + minStart,
+ opt_sample_rgba_2d(ctx, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
break;
default:
- sample_nearest_2d(ctx, texUnit, tObj, m, texcoords + minStart,
+ sample_nearest_2d(ctx, tObj, m, texcoords + minStart,
NULL, rgba + minStart );
}
}
else {
- sample_nearest_2d(ctx, texUnit, tObj, m, texcoords + minStart,
+ sample_nearest_2d(ctx, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
}
break;
case GL_LINEAR:
- sample_linear_2d(ctx, texUnit, tObj, m, texcoords + minStart,
+ sample_linear_2d(ctx, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_NEAREST:
case MESA_FORMAT_RGB:
case MESA_FORMAT_RGB888:
/*case MESA_FORMAT_BGR888:*/
- opt_sample_rgb_2d(ctx, texUnit, tObj, m, texcoords + magStart,
+ opt_sample_rgb_2d(ctx, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
break;
case MESA_FORMAT_RGBA:
case MESA_FORMAT_ARGB8888:
/*case MESA_FORMAT_ABGR8888:*/
/*case MESA_FORMAT_BGRA8888:*/
- opt_sample_rgba_2d(ctx, texUnit, tObj, m, texcoords + magStart,
+ opt_sample_rgba_2d(ctx, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
break;
default:
- sample_nearest_2d(ctx, texUnit, tObj, m, texcoords + magStart,
+ sample_nearest_2d(ctx, tObj, m, texcoords + magStart,
NULL, rgba + magStart );
}
}
else {
- sample_nearest_2d(ctx, texUnit, tObj, m, texcoords + magStart,
+ sample_nearest_2d(ctx, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
}
break;
case GL_LINEAR:
- sample_linear_2d(ctx, texUnit, tObj, m, texcoords + magStart,
+ sample_linear_2d(ctx, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
break;
default:
static void
-sample_nearest_3d(GLcontext *ctx, GLuint texUnit,
+sample_nearest_3d(GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4])
{
GLuint i;
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
- (void) texUnit;
(void) lambda;
for (i=0;i<n;i++) {
sample_3d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
static void
-sample_linear_3d( GLcontext *ctx, GLuint texUnit,
+sample_linear_3d( GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
GLuint i;
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
- (void) texUnit;
(void) lambda;
for (i=0;i<n;i++) {
sample_3d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
* return a texture sample.
*/
static void
-sample_lambda_3d( GLcontext *ctx, GLuint texUnit,
+sample_lambda_3d( GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4] )
GLuint i;
ASSERT(lambda != NULL);
- compute_min_mag_ranges(SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit],
- n, lambda, &minStart, &minEnd, &magStart, &magEnd);
+ compute_min_mag_ranges(tObj, n, lambda,
+ &minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
static void
-sample_nearest_cube(GLcontext *ctx, GLuint texUnit,
+sample_nearest_cube(GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4])
{
GLuint i;
- (void) texUnit;
(void) lambda;
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
static void
-sample_linear_cube(GLcontext *ctx, GLuint texUnit,
+sample_linear_cube(GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
- (void) texUnit;
(void) lambda;
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
static void
-sample_cube_nearest_mipmap_nearest(GLcontext *ctx, GLuint texUnit,
+sample_cube_nearest_mipmap_nearest(GLcontext *ctx,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
- (void) texUnit;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
static void
-sample_cube_linear_mipmap_nearest(GLcontext *ctx, GLuint texUnit,
+sample_cube_linear_mipmap_nearest(GLcontext *ctx,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
- (void) texUnit;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
static void
-sample_cube_nearest_mipmap_linear(GLcontext *ctx, GLuint texUnit,
+sample_cube_nearest_mipmap_linear(GLcontext *ctx,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
- (void) texUnit;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
static void
-sample_cube_linear_mipmap_linear(GLcontext *ctx, GLuint texUnit,
+sample_cube_linear_mipmap_linear(GLcontext *ctx,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
- (void) texUnit;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
static void
-sample_lambda_cube( GLcontext *ctx, GLuint texUnit,
+sample_lambda_cube( GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4])
GLuint magStart, magEnd; /* texels with magnification */
ASSERT(lambda != NULL);
- compute_min_mag_ranges(SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit],
- n, lambda, &minStart, &minEnd, &magStart, &magEnd);
+ compute_min_mag_ranges(tObj, n, lambda,
+ &minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
const GLuint m = minEnd - minStart;
switch (tObj->MinFilter) {
case GL_NEAREST:
- sample_nearest_cube(ctx, texUnit, tObj, m, texcoords + minStart,
+ sample_nearest_cube(ctx, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR:
- sample_linear_cube(ctx, texUnit, tObj, m, texcoords + minStart,
+ sample_linear_cube(ctx, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_cube_nearest_mipmap_nearest(ctx, texUnit, tObj, m,
+ sample_cube_nearest_mipmap_nearest(ctx, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_cube_linear_mipmap_nearest(ctx, texUnit, tObj, m,
+ sample_cube_linear_mipmap_nearest(ctx, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_cube_nearest_mipmap_linear(ctx, texUnit, tObj, m,
+ sample_cube_nearest_mipmap_linear(ctx, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_cube_linear_mipmap_linear(ctx, texUnit, tObj, m,
+ sample_cube_linear_mipmap_linear(ctx, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
const GLuint m = magEnd - magStart;
switch (tObj->MagFilter) {
case GL_NEAREST:
- sample_nearest_cube(ctx, texUnit, tObj, m, texcoords + magStart,
+ sample_nearest_cube(ctx, tObj, m, texcoords + magStart,
lambda + magStart, rgba + magStart);
break;
case GL_LINEAR:
- sample_linear_cube(ctx, texUnit, tObj, m, texcoords + magStart,
+ sample_linear_cube(ctx, tObj, m, texcoords + magStart,
lambda + magStart, rgba + magStart);
break;
default:
/**********************************************************************/
static void
-sample_nearest_rect(GLcontext *ctx, GLuint texUnit,
+sample_nearest_rect(GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4])
GLuint i;
(void) ctx;
- (void) texUnit;
(void) lambda;
ASSERT(tObj->WrapS == GL_CLAMP ||
static void
-sample_linear_rect(GLcontext *ctx, GLuint texUnit,
+sample_linear_rect(GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4])
GLuint i;
(void) ctx;
- (void) texUnit;
(void) lambda;
ASSERT(tObj->WrapS == GL_CLAMP ||
static void
-sample_lambda_rect( GLcontext *ctx, GLuint texUnit,
+sample_lambda_rect( GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4])
/* We only need lambda to decide between minification and magnification.
* There is no mipmapping with rectangular textures.
*/
- compute_min_mag_ranges(SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit],
- n, lambda, &minStart, &minEnd, &magStart, &magEnd);
+ compute_min_mag_ranges(tObj, n, lambda,
+ &minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
if (tObj->MinFilter == GL_NEAREST) {
- sample_nearest_rect( ctx, texUnit, tObj, minEnd - minStart,
+ sample_nearest_rect( ctx, tObj, minEnd - minStart,
texcoords + minStart, NULL, rgba + minStart);
}
else {
- sample_linear_rect( ctx, texUnit, tObj, minEnd - minStart,
+ sample_linear_rect( ctx, tObj, minEnd - minStart,
texcoords + minStart, NULL, rgba + minStart);
}
}
if (magStart < magEnd) {
if (tObj->MagFilter == GL_NEAREST) {
- sample_nearest_rect( ctx, texUnit, tObj, magEnd - magStart,
+ sample_nearest_rect( ctx, tObj, magEnd - magStart,
texcoords + magStart, NULL, rgba + magStart);
}
else {
- sample_linear_rect( ctx, texUnit, tObj, magEnd - magStart,
+ sample_linear_rect( ctx, tObj, magEnd - magStart,
texcoords + magStart, NULL, rgba + magStart);
}
}
* Sample a shadow/depth texture.
*/
static void
-sample_depth_texture( GLcontext *ctx, GLuint unit,
+sample_depth_texture( GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan texel[][4] )
GLchan result;
(void) lambda;
- (void) unit;
ASSERT(tObj->Image[0][tObj->BaseLevel]->Format == GL_DEPTH_COMPONENT);
ASSERT(tObj->Target == GL_TEXTURE_1D ||
* Note: fragment programss don't observe the texture enable/disable flags.
*/
static void
-null_sample_func( GLcontext *ctx, GLuint texUnit,
+null_sample_func( GLcontext *ctx,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4])
{
GLuint i;
(void) ctx;
- (void) texUnit;
(void) tObj;
(void) texcoords;
(void) lambda;