/*
* Mesa 3-D graphics library
- * Version: 7.3
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
*/
+#include "c99_math.h"
#include "main/glheader.h"
#include "main/context.h"
-#include "main/colormac.h"
#include "main/imports.h"
-#include "main/texobj.h"
+#include "main/macros.h"
#include "main/samplerobj.h"
+#include "main/teximage.h"
+#include "main/texobj.h"
#include "s_context.h"
#include "s_texfilter.h"
* Do 3D/trilinear interpolation of float values.
* \sa lerp_2d
*/
-static inline GLfloat
+static GLfloat
lerp_3d(GLfloat a, GLfloat b, GLfloat c,
GLfloat v000, GLfloat v100, GLfloat v010, GLfloat v110,
GLfloat v001, GLfloat v101, GLfloat v011, GLfloat v111)
/**
* Do linear interpolation of colors.
*/
-static inline void
+static void
lerp_rgba(GLfloat result[4], GLfloat t, const GLfloat a[4], const GLfloat b[4])
{
result[0] = LERP(t, a[0], b[0]);
/**
* Do bilinear interpolation of colors.
*/
-static inline void
+static void
lerp_rgba_2d(GLfloat result[4], GLfloat a, GLfloat b,
const GLfloat t00[4], const GLfloat t10[4],
const GLfloat t01[4], const GLfloat t11[4])
/**
* Do trilinear interpolation of colors.
*/
-static inline void
+static void
lerp_rgba_3d(GLfloat result[4], GLfloat a, GLfloat b, GLfloat c,
const GLfloat t000[4], const GLfloat t100[4],
const GLfloat t010[4], const GLfloat t110[4],
* i0, i1 = returns two nearest texel indexes
* weight = returns blend factor between texels
*/
-static inline void
+static void
linear_texel_locations(GLenum wrapMode,
const struct gl_texture_image *img,
GLint size, GLfloat s,
}
break;
case GL_MIRROR_CLAMP_EXT:
- u = FABSF(s);
+ u = fabsf(s);
if (u >= 1.0F)
u = (GLfloat) size;
else
*i1 = *i0 + 1;
break;
case GL_MIRROR_CLAMP_TO_EDGE_EXT:
- u = FABSF(s);
+ u = fabsf(s);
if (u >= 1.0F)
u = (GLfloat) size;
else
{
const GLfloat min = -1.0F / (2.0F * size);
const GLfloat max = 1.0F - min;
- u = FABSF(s);
+ u = fabsf(s);
if (u <= min)
u = min * size;
else if (u >= max)
break;
default:
_mesa_problem(NULL, "Bad wrap mode");
+ *i0 = *i1 = 0;
u = 0.0F;
break;
}
/**
* Used to compute texel location for nearest sampling.
*/
-static inline GLint
+static GLint
nearest_texel_location(GLenum wrapMode,
const struct gl_texture_image *img,
GLint size, GLfloat s)
{
/* s limited to [0,1] */
/* i limited to [0,size-1] */
- const GLfloat u = FABSF(s);
+ const GLfloat u = fabsf(s);
if (u <= 0.0F)
i = 0;
else if (u >= 1.0F)
/* i limited to [0, size-1] */
const GLfloat min = 1.0F / (2.0F * size);
const GLfloat max = 1.0F - min;
- const GLfloat u = FABSF(s);
+ const GLfloat u = fabsf(s);
if (u < min)
i = 0;
else if (u > max)
/* i limited to [0, size-1] */
const GLfloat min = -1.0F / (2.0F * size);
const GLfloat max = 1.0F - min;
- const GLfloat u = FABSF(s);
+ const GLfloat u = fabsf(s);
if (u < min)
i = -1;
else if (u > max)
/* Power of two image sizes only */
-static inline void
+static void
linear_repeat_texel_location(GLuint size, GLfloat s,
GLint *i0, GLint *i1, GLfloat *weight)
{
/**
* Do clamp/wrap for a texture rectangle coord, GL_NEAREST filter mode.
*/
-static inline GLint
+static GLint
clamp_rect_coord_nearest(GLenum wrapMode, GLfloat coord, GLint max)
{
switch (wrapMode) {
/**
* As above, but GL_LINEAR filtering.
*/
-static inline void
+static void
clamp_rect_coord_linear(GLenum wrapMode, GLfloat coord, GLint max,
GLint *i0out, GLint *i1out, GLfloat *weight)
{
/**
* Compute slice/image to use for 1D or 2D array texture.
*/
-static inline GLint
+static GLint
tex_array_slice(GLfloat coord, GLsizei size)
{
GLint slice = IFLOOR(coord + 0.5f);
* Compute nearest integer texcoords for given texobj and coordinate.
* NOTE: only used for depth texture sampling.
*/
-static inline void
+static void
nearest_texcoord(const struct gl_sampler_object *samp,
const struct gl_texture_object *texObj,
GLuint level,
* Compute linear integer texcoords for given texobj and coordinate.
* NOTE: only used for depth texture sampling.
*/
-static inline void
+static void
linear_texcoord(const struct gl_sampler_object *samp,
const struct gl_texture_object *texObj,
GLuint level,
* For linear interpolation between mipmap levels N and N+1, this function
* computes N.
*/
-static inline GLint
+static GLint
linear_mipmap_level(const struct gl_texture_object *tObj, GLfloat lambda)
{
if (lambda < 0.0F)
/**
* Compute the nearest mipmap level to take texels from.
*/
-static inline GLint
+static GLint
nearest_mipmap_level(const struct gl_texture_object *tObj, GLfloat lambda)
{
GLfloat l;
* will be minified, magnified, or split between the two. This function
* determines the subranges in [0, n-1] that are to be minified or magnified.
*/
-static inline void
+static void
compute_min_mag_ranges(const struct gl_sampler_object *samp,
GLuint n, const GLfloat lambda[],
GLuint *minStart, GLuint *minEnd,
GLfloat minMagThresh;
/* we shouldn't be here if minfilter == magfilter */
- ASSERT(samp->MinFilter != samp->MagFilter);
+ assert(samp->MinFilter != samp->MagFilter);
/* This bit comes from the OpenGL spec: */
if (samp->MagFilter == GL_LINEAR
printf("lambda delta = %g\n", lambda[0] - lambda[n-1]);
if (lambda[0] >= lambda[n-1]) { /* decreasing */
for (i = 0; i < n - 1; i++) {
- ASSERT((GLint) (lambda[i] * 10) >= (GLint) (lambda[i+1] * 10));
+ assert((GLint) (lambda[i] * 10) >= (GLint) (lambda[i+1] * 10));
}
}
else { /* increasing */
for (i = 0; i < n - 1; i++) {
- ASSERT((GLint) (lambda[i] * 10) <= (GLint) (lambda[i+1] * 10));
+ assert((GLint) (lambda[i] * 10) <= (GLint) (lambda[i+1] * 10));
}
}
}
for (i = 0; i < n; i++) {
if (lambda[i] > minMagThresh) {
/* minification */
- ASSERT(i >= *minStart);
- ASSERT(i < *minEnd);
+ assert(i >= *minStart);
+ assert(i < *minEnd);
}
else {
/* magnification */
- ASSERT(i >= *magStart);
- ASSERT(i < *magEnd);
+ assert(i >= *magStart);
+ assert(i < *magEnd);
}
}
}
* the base texture format. Ex: if the texture base format it GL_ALPHA,
* we return (0,0,0,BorderAlpha).
*/
-static inline void
+static void
get_border_color(const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
GLfloat rgba[4])
/**
* Put z into texel according to GL_DEPTH_MODE.
*/
-static INLINE void
+static void
apply_depth_mode(GLenum depthMode, GLfloat z, GLfloat texel[4])
{
switch (depthMode) {
static GLboolean
is_depth_texture(const struct gl_texture_object *tObj)
{
- GLenum format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat;
+ GLenum format = _mesa_texture_base_format(tObj);
return format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT;
}
/**
* Return the texture sample for coordinate (s) using GL_NEAREST filter.
*/
-static inline void
+static void
sample_1d_nearest(struct gl_context *ctx,
const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
/**
* Return the texture sample for coordinate (s) using GL_LINEAR filter.
*/
-static inline void
+static void
sample_1d_linear(struct gl_context *ctx,
const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
sample_1d_nearest(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
sample_1d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
GLfloat rgba[][4] )
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_1d_nearest(ctx, samp, image, texcoords[i], rgba[i]);
GLfloat rgba[][4] )
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_1d_linear(ctx, samp, image, texcoords[i], rgba[i]);
GLuint magStart, magEnd; /* texels with magnification */
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_1d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_1d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_1d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_1d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
default:
/**
* Return the texture sample for coordinate (s,t) using GL_NEAREST filter.
*/
-static inline void
+static void
sample_2d_nearest(struct gl_context *ctx,
const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
* Return the texture sample for coordinate (s,t) using GL_LINEAR filter.
* New sampling code contributed by Lynn Quam <quam@ai.sri.com>.
*/
-static inline void
+static void
sample_2d_linear(struct gl_context *ctx,
const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
* As above, but we know WRAP_S == REPEAT and WRAP_T == REPEAT.
* We don't have to worry about the texture border.
*/
-static inline void
+static void
sample_2d_linear_repeat(struct gl_context *ctx,
const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
(void) ctx;
- ASSERT(samp->WrapS == GL_REPEAT);
- ASSERT(samp->WrapT == GL_REPEAT);
- ASSERT(img->Border == 0);
- ASSERT(swImg->_IsPowerOfTwo);
+ assert(samp->WrapS == GL_REPEAT);
+ assert(samp->WrapT == GL_REPEAT);
+ assert(img->Border == 0);
+ assert(swImg->_IsPowerOfTwo);
linear_repeat_texel_location(width, texcoord[0], &i0, &i1, &wi);
linear_repeat_texel_location(height, texcoord[1], &j0, &j1, &wj);
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
sample_2d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
const GLfloat lambda[], GLfloat rgba[][4] )
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
- ASSERT(samp->WrapS == GL_REPEAT);
- ASSERT(samp->WrapT == GL_REPEAT);
+ assert(lambda != NULL);
+ assert(samp->WrapS == GL_REPEAT);
+ assert(samp->WrapT == GL_REPEAT);
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_2d_nearest(ctx, samp, image, texcoords[i], rgba[i]);
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
const struct swrast_texture_image *swImg = swrast_texture_image_const(image);
(void) lambda;
if (samp->WrapS == GL_REPEAT &&
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
{
- const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *img = _mesa_base_tex_image(tObj);
const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLfloat width = (GLfloat) img->Width;
const GLfloat height = (GLfloat) img->Height;
GLuint k;
(void) ctx;
(void) lambda;
- ASSERT(samp->WrapS==GL_REPEAT);
- ASSERT(samp->WrapT==GL_REPEAT);
- ASSERT(img->Border==0);
- ASSERT(img->TexFormat == MESA_FORMAT_RGB888);
- ASSERT(swImg->_IsPowerOfTwo);
+ assert(samp->WrapS==GL_REPEAT);
+ assert(samp->WrapT==GL_REPEAT);
+ assert(img->Border==0);
+ assert(img->TexFormat == MESA_FORMAT_BGR_UNORM8);
+ assert(swImg->_IsPowerOfTwo);
(void) swImg;
for (k=0; k<n; k++) {
GLint i = IFLOOR(texcoords[k][0] * width) & colMask;
GLint j = IFLOOR(texcoords[k][1] * height) & rowMask;
GLint pos = (j << shift) | i;
- GLubyte *texel = swImg->Map + 3 * pos;
+ GLubyte *texel = (GLubyte *) swImg->ImageSlices[0] + 3 * pos;
rgba[k][RCOMP] = UBYTE_TO_FLOAT(texel[2]);
rgba[k][GCOMP] = UBYTE_TO_FLOAT(texel[1]);
rgba[k][BCOMP] = UBYTE_TO_FLOAT(texel[0]);
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
{
- const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *img = _mesa_base_tex_image(tObj);
const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLfloat width = (GLfloat) img->Width;
const GLfloat height = (GLfloat) img->Height;
GLuint i;
(void) ctx;
(void) lambda;
- ASSERT(samp->WrapS==GL_REPEAT);
- ASSERT(samp->WrapT==GL_REPEAT);
- ASSERT(img->Border==0);
- ASSERT(img->TexFormat == MESA_FORMAT_RGBA8888);
- ASSERT(swImg->_IsPowerOfTwo);
+ assert(samp->WrapS==GL_REPEAT);
+ assert(samp->WrapT==GL_REPEAT);
+ assert(img->Border==0);
+ assert(img->TexFormat == MESA_FORMAT_A8B8G8R8_UNORM);
+ assert(swImg->_IsPowerOfTwo);
(void) swImg;
for (i = 0; i < n; i++) {
const GLint col = IFLOOR(texcoords[i][0] * width) & colMask;
const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask;
const GLint pos = (row << shift) | col;
- const GLuint texel = *((GLuint *) swImg->Map + pos);
+ const GLuint texel = *((GLuint *) swImg->ImageSlices[0] + pos);
rgba[i][RCOMP] = UBYTE_TO_FLOAT( (texel >> 24) );
rgba[i][GCOMP] = UBYTE_TO_FLOAT( (texel >> 16) & 0xff );
rgba[i][BCOMP] = UBYTE_TO_FLOAT( (texel >> 8) & 0xff );
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
{
- const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *tImg = _mesa_base_tex_image(tObj);
const struct swrast_texture_image *swImg = swrast_texture_image_const(tImg);
GLuint minStart, minEnd; /* texels with minification */
GLuint magStart, magEnd; /* texels with magnification */
const GLboolean repeatNoBorderPOT = (samp->WrapS == GL_REPEAT)
&& (samp->WrapT == GL_REPEAT)
- && (tImg->Border == 0 && (tImg->Width == swImg->RowStride))
+ && (tImg->Border == 0)
+ && (_mesa_format_row_stride(tImg->TexFormat, tImg->Width) ==
+ swImg->RowStride)
&& swImg->_IsPowerOfTwo;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
case GL_NEAREST:
if (repeatNoBorderPOT) {
switch (tImg->TexFormat) {
- case MESA_FORMAT_RGB888:
+ case MESA_FORMAT_BGR_UNORM8:
opt_sample_rgb_2d(ctx, samp, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
break;
- case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_A8B8G8R8_UNORM:
opt_sample_rgba_2d(ctx, samp, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
break;
case GL_NEAREST:
if (repeatNoBorderPOT) {
switch (tImg->TexFormat) {
- case MESA_FORMAT_RGB888:
+ case MESA_FORMAT_BGR_UNORM8:
opt_sample_rgb_2d(ctx, samp, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
break;
- case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_A8B8G8R8_UNORM:
opt_sample_rgba_2d(ctx, samp, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
break;
GLfloat scaling = 1.0f / (1 << level);
const struct gl_texture_image *img = tObj->Image[0][level];
const struct gl_texture_image *mostDetailedImage =
- tObj->Image[0][tObj->BaseLevel];
+ _mesa_base_tex_image(tObj);
const struct swrast_texture_image *swImg =
swrast_texture_image_const(mostDetailedImage);
GLfloat tex_u = -0.5f + texcoord[0] * swImg->WidthScale * scaling;
GLfloat F = A*C-B*B/4.0f;
/* check if it is an ellipse */
- /* ASSERT(F > 0.0); */
+ /* assert(F > 0.0); */
/* Compute the ellipse's (u,v) bounding box in texture space */
GLfloat d = -B*B+4.0f*C*A;
* Returns the index of the specified texture object in the
* gl_context texture unit array.
*/
-static inline GLuint
+static GLuint
texture_unit_index(const struct gl_context *ctx,
const struct gl_texture_object *tObj)
{
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda_iso[], GLfloat rgba[][4])
{
- const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *tImg = _mesa_base_tex_image(tObj);
const struct swrast_texture_image *swImg = swrast_texture_image_const(tImg);
const GLfloat maxEccentricity =
samp->MaxAnisotropy * samp->MaxAnisotropy;
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
const GLboolean adjustLOD =
(texUnit->LodBias + samp->LodBias != 0.0F)
- || (samp->MinLod != -1000.0 || samp->MaxLod != 1000.0);
+ || (samp->MinLod != -1000.0F || samp->MaxLod != 1000.0F);
GLuint i;
ctx->Const.MaxTextureLodBias);
lod += bias;
- if (samp->MinLod != -1000.0 ||
- samp->MaxLod != 1000.0) {
+ if (samp->MinLod != -1000.0F ||
+ samp->MaxLod != 1000.0F) {
/* apply LOD clamping to lambda */
lod = CLAMP(lod, samp->MinLod, samp->MaxLod);
}
/**
* Return the texture sample for coordinate (s,t,r) using GL_NEAREST filter.
*/
-static inline void
+static void
sample_3d_nearest(struct gl_context *ctx,
const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
sample_3d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_3d_nearest(ctx, samp, image, texcoords[i], rgba[i]);
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_3d_linear(ctx, samp, image, texcoords[i], rgba[i]);
GLuint magStart, magEnd; /* texels with magnification */
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_3d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_3d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_3d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_3d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
default:
const GLfloat rx = texcoord[0];
const GLfloat ry = texcoord[1];
const GLfloat rz = texcoord[2];
- const GLfloat arx = FABSF(rx), ary = FABSF(ry), arz = FABSF(rz);
+ const GLfloat arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz);
GLuint face;
GLfloat sc, tc, ma;
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
GLfloat newCoord[4];
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
GLfloat newCoord[4];
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
GLfloat newCoord[4];
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
GLfloat newCoord[4];
GLuint minStart, minEnd; /* texels with minification */
GLuint magStart, magEnd; /* texels with magnification */
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
(void) ctx;
(void) lambda;
- ASSERT(samp->WrapS == GL_CLAMP ||
+ assert(samp->WrapS == GL_CLAMP ||
samp->WrapS == GL_CLAMP_TO_EDGE ||
samp->WrapS == GL_CLAMP_TO_BORDER);
- ASSERT(samp->WrapT == GL_CLAMP ||
+ assert(samp->WrapT == GL_CLAMP ||
samp->WrapT == GL_CLAMP_TO_EDGE ||
samp->WrapT == GL_CLAMP_TO_BORDER);
(void) ctx;
(void) lambda;
- ASSERT(samp->WrapS == GL_CLAMP ||
+ assert(samp->WrapS == GL_CLAMP ||
samp->WrapS == GL_CLAMP_TO_EDGE ||
samp->WrapS == GL_CLAMP_TO_BORDER);
- ASSERT(samp->WrapT == GL_CLAMP ||
+ assert(samp->WrapT == GL_CLAMP ||
samp->WrapT == GL_CLAMP_TO_EDGE ||
samp->WrapT == GL_CLAMP_TO_BORDER);
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
sample_2d_array_linear(ctx, samp, tObj->Image[0][level],
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_2d_array_nearest(ctx, samp, image, texcoords[i], rgba[i]);
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_2d_array_linear(ctx, samp, image, texcoords[i], rgba[i]);
GLuint magStart, magEnd; /* texels with magnification */
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_2d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_2d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_2d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_2d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
default:
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
sample_1d_array_linear(ctx, samp, tObj->Image[0][level],
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_1d_array_nearest(ctx, samp, image, texcoords[i], rgba[i]);
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_1d_array_linear(ctx, samp, image, texcoords[i], rgba[i]);
GLuint magStart, magEnd; /* texels with magnification */
GLuint i;
- ASSERT(lambda != NULL);
+ assert(lambda != NULL);
compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_1d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_1d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_1d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_1d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
default:
/**
* Compare texcoord against depth sample. Return 1.0 or 0.0 value.
*/
-static inline GLfloat
+static GLfloat
shadow_compare(GLenum function, GLfloat coord, GLfloat depthSample)
{
switch (function) {
/**
* Compare texcoord against four depth samples.
*/
-static inline GLfloat
+static GLfloat
shadow_compare4(GLenum function, GLfloat coord,
GLfloat depth00, GLfloat depth01,
GLfloat depth10, GLfloat depth11,
GLenum function;
GLfloat result;
- ASSERT(img->_BaseFormat == GL_DEPTH_COMPONENT ||
+ assert(img->_BaseFormat == GL_DEPTH_COMPONENT ||
img->_BaseFormat == GL_DEPTH_STENCIL_EXT);
- ASSERT(tObj->Target == GL_TEXTURE_1D ||
+ assert(tObj->Target == GL_TEXTURE_1D ||
tObj->Target == GL_TEXTURE_2D ||
tObj->Target == GL_TEXTURE_RECTANGLE_NV ||
tObj->Target == GL_TEXTURE_1D_ARRAY_EXT ||
}
else {
GLuint i;
- ASSERT(samp->MagFilter == GL_LINEAR);
+ assert(samp->MagFilter == GL_LINEAR);
for (i = 0; i < n; i++) {
GLfloat depth00, depth01, depth10, depth11, depthRef;
GLint i0, i1, j0, j1;
const struct gl_sampler_object *sampler)
{
if (!t || !_mesa_is_texture_complete(t, sampler)) {
- return &null_sample_func;
+ return null_sample_func;
}
else {
const GLboolean needLambda =
switch (t->Target) {
case GL_TEXTURE_1D:
if (is_depth_texture(t)) {
- return &sample_depth_texture;
+ return sample_depth_texture;
}
else if (needLambda) {
- return &sample_lambda_1d;
+ return sample_lambda_1d;
}
else if (sampler->MinFilter == GL_LINEAR) {
- return &sample_linear_1d;
+ return sample_linear_1d;
}
else {
- ASSERT(sampler->MinFilter == GL_NEAREST);
- return &sample_nearest_1d;
+ assert(sampler->MinFilter == GL_NEAREST);
+ return sample_nearest_1d;
}
case GL_TEXTURE_2D:
if (is_depth_texture(t)) {
- return &sample_depth_texture;
+ return sample_depth_texture;
}
else if (needLambda) {
/* Anisotropic filtering extension. Activated only if mipmaps are used */
- if (sampler->MaxAnisotropy > 1.0 &&
+ if (sampler->MaxAnisotropy > 1.0F &&
sampler->MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
- return &sample_lambda_2d_aniso;
+ return sample_lambda_2d_aniso;
}
- return &sample_lambda_2d;
+ return sample_lambda_2d;
}
else if (sampler->MinFilter == GL_LINEAR) {
- return &sample_linear_2d;
+ return sample_linear_2d;
}
else {
/* check for a few optimized cases */
- const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
+ const struct gl_texture_image *img = _mesa_base_tex_image(t);
const struct swrast_texture_image *swImg =
swrast_texture_image_const(img);
texture_sample_func func;
- ASSERT(sampler->MinFilter == GL_NEAREST);
+ assert(sampler->MinFilter == GL_NEAREST);
func = &sample_nearest_2d;
if (sampler->WrapS == GL_REPEAT &&
sampler->WrapT == GL_REPEAT &&
swImg->_IsPowerOfTwo &&
img->Border == 0) {
- if (img->TexFormat == MESA_FORMAT_RGB888)
+ if (img->TexFormat == MESA_FORMAT_BGR_UNORM8)
func = &opt_sample_rgb_2d;
- else if (img->TexFormat == MESA_FORMAT_RGBA8888)
+ else if (img->TexFormat == MESA_FORMAT_A8B8G8R8_UNORM)
func = &opt_sample_rgba_2d;
}
}
case GL_TEXTURE_3D:
if (needLambda) {
- return &sample_lambda_3d;
+ return sample_lambda_3d;
}
else if (sampler->MinFilter == GL_LINEAR) {
- return &sample_linear_3d;
+ return sample_linear_3d;
}
else {
- ASSERT(sampler->MinFilter == GL_NEAREST);
- return &sample_nearest_3d;
+ assert(sampler->MinFilter == GL_NEAREST);
+ return sample_nearest_3d;
}
case GL_TEXTURE_CUBE_MAP:
if (needLambda) {
- return &sample_lambda_cube;
+ return sample_lambda_cube;
}
else if (sampler->MinFilter == GL_LINEAR) {
- return &sample_linear_cube;
+ return sample_linear_cube;
}
else {
- ASSERT(sampler->MinFilter == GL_NEAREST);
- return &sample_nearest_cube;
+ assert(sampler->MinFilter == GL_NEAREST);
+ return sample_nearest_cube;
}
case GL_TEXTURE_RECTANGLE_NV:
if (is_depth_texture(t)) {
- return &sample_depth_texture;
+ return sample_depth_texture;
}
else if (needLambda) {
- return &sample_lambda_rect;
+ return sample_lambda_rect;
}
else if (sampler->MinFilter == GL_LINEAR) {
- return &sample_linear_rect;
+ return sample_linear_rect;
}
else {
- ASSERT(sampler->MinFilter == GL_NEAREST);
- return &sample_nearest_rect;
+ assert(sampler->MinFilter == GL_NEAREST);
+ return sample_nearest_rect;
}
case GL_TEXTURE_1D_ARRAY_EXT:
if (is_depth_texture(t)) {
- return &sample_depth_texture;
+ return sample_depth_texture;
}
else if (needLambda) {
- return &sample_lambda_1d_array;
+ return sample_lambda_1d_array;
}
else if (sampler->MinFilter == GL_LINEAR) {
- return &sample_linear_1d_array;
+ return sample_linear_1d_array;
}
else {
- ASSERT(sampler->MinFilter == GL_NEAREST);
- return &sample_nearest_1d_array;
+ assert(sampler->MinFilter == GL_NEAREST);
+ return sample_nearest_1d_array;
}
case GL_TEXTURE_2D_ARRAY_EXT:
if (is_depth_texture(t)) {
- return &sample_depth_texture;
+ return sample_depth_texture;
}
else if (needLambda) {
- return &sample_lambda_2d_array;
+ return sample_lambda_2d_array;
}
else if (sampler->MinFilter == GL_LINEAR) {
- return &sample_linear_2d_array;
+ return sample_linear_2d_array;
}
else {
- ASSERT(sampler->MinFilter == GL_NEAREST);
- return &sample_nearest_2d_array;
+ assert(sampler->MinFilter == GL_NEAREST);
+ return sample_nearest_2d_array;
}
default:
_mesa_problem(ctx,
"invalid target in _swrast_choose_texture_sample_func");
- return &null_sample_func;
+ return null_sample_func;
}
}
}