#include "main/colormac.h"
#include "main/imports.h"
#include "main/texobj.h"
+#include "main/samplerobj.h"
#include "s_context.h"
#include "s_texfilter.h"
* NOTE: only used for depth texture sampling.
*/
static inline void
-nearest_texcoord(const struct gl_texture_object *texObj,
+nearest_texcoord(const struct gl_sampler_object *samp,
+ const struct gl_texture_object *texObj,
GLuint level,
const GLfloat texcoord[4],
GLint *i, GLint *j, GLint *k)
switch (texObj->Target) {
case GL_TEXTURE_RECTANGLE_ARB:
- *i = clamp_rect_coord_nearest(texObj->Sampler.WrapS, texcoord[0], width);
- *j = clamp_rect_coord_nearest(texObj->Sampler.WrapT, texcoord[1], height);
+ *i = clamp_rect_coord_nearest(samp->WrapS, texcoord[0], width);
+ *j = clamp_rect_coord_nearest(samp->WrapT, texcoord[1], height);
*k = 0;
break;
case GL_TEXTURE_1D:
- *i = nearest_texel_location(texObj->Sampler.WrapS, img, width, texcoord[0]);
+ *i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
*j = 0;
*k = 0;
break;
case GL_TEXTURE_2D:
- *i = nearest_texel_location(texObj->Sampler.WrapS, img, width, texcoord[0]);
- *j = nearest_texel_location(texObj->Sampler.WrapT, img, height, texcoord[1]);
+ *i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
+ *j = nearest_texel_location(samp->WrapT, img, height, texcoord[1]);
*k = 0;
break;
case GL_TEXTURE_1D_ARRAY_EXT:
- *i = nearest_texel_location(texObj->Sampler.WrapS, img, width, texcoord[0]);
+ *i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
*j = tex_array_slice(texcoord[1], height);
*k = 0;
break;
case GL_TEXTURE_2D_ARRAY_EXT:
- *i = nearest_texel_location(texObj->Sampler.WrapS, img, width, texcoord[0]);
- *j = nearest_texel_location(texObj->Sampler.WrapT, img, height, texcoord[1]);
+ *i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
+ *j = nearest_texel_location(samp->WrapT, img, height, texcoord[1]);
*k = tex_array_slice(texcoord[2], depth);
break;
default:
* NOTE: only used for depth texture sampling.
*/
static inline void
-linear_texcoord(const struct gl_texture_object *texObj,
+linear_texcoord(const struct gl_sampler_object *samp,
+ const struct gl_texture_object *texObj,
GLuint level,
const GLfloat texcoord[4],
GLint *i0, GLint *i1, GLint *j0, GLint *j1, GLint *slice,
switch (texObj->Target) {
case GL_TEXTURE_RECTANGLE_ARB:
- clamp_rect_coord_linear(texObj->Sampler.WrapS, texcoord[0],
+ clamp_rect_coord_linear(samp->WrapS, texcoord[0],
width, i0, i1, wi);
- clamp_rect_coord_linear(texObj->Sampler.WrapT, texcoord[1],
+ clamp_rect_coord_linear(samp->WrapT, texcoord[1],
height, j0, j1, wj);
*slice = 0;
break;
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
- linear_texel_locations(texObj->Sampler.WrapS, img, width,
+ linear_texel_locations(samp->WrapS, img, width,
texcoord[0], i0, i1, wi);
- linear_texel_locations(texObj->Sampler.WrapT, img, height,
+ linear_texel_locations(samp->WrapT, img, height,
texcoord[1], j0, j1, wj);
*slice = 0;
break;
case GL_TEXTURE_1D_ARRAY_EXT:
- linear_texel_locations(texObj->Sampler.WrapS, img, width,
+ linear_texel_locations(samp->WrapS, img, width,
texcoord[0], i0, i1, wi);
*j0 = tex_array_slice(texcoord[1], height);
*j1 = *j0;
break;
case GL_TEXTURE_2D_ARRAY_EXT:
- linear_texel_locations(texObj->Sampler.WrapS, img, width,
+ linear_texel_locations(samp->WrapS, img, width,
texcoord[0], i0, i1, wi);
- linear_texel_locations(texObj->Sampler.WrapT, img, height,
+ linear_texel_locations(samp->WrapT, img, height,
texcoord[1], j0, j1, wj);
*slice = tex_array_slice(texcoord[2], depth);
break;
* determines the subranges in [0, n-1] that are to be minified or magnified.
*/
static inline void
-compute_min_mag_ranges(const struct gl_texture_object *tObj,
+compute_min_mag_ranges(const struct gl_sampler_object *samp,
GLuint n, const GLfloat lambda[],
GLuint *minStart, GLuint *minEnd,
GLuint *magStart, GLuint *magEnd)
GLfloat minMagThresh;
/* we shouldn't be here if minfilter == magfilter */
- ASSERT(tObj->Sampler.MinFilter != tObj->Sampler.MagFilter);
+ ASSERT(samp->MinFilter != samp->MagFilter);
/* This bit comes from the OpenGL spec: */
- if (tObj->Sampler.MagFilter == GL_LINEAR
- && (tObj->Sampler.MinFilter == GL_NEAREST_MIPMAP_NEAREST ||
- tObj->Sampler.MinFilter == GL_NEAREST_MIPMAP_LINEAR)) {
+ if (samp->MagFilter == GL_LINEAR
+ && (samp->MinFilter == GL_NEAREST_MIPMAP_NEAREST ||
+ samp->MinFilter == GL_NEAREST_MIPMAP_LINEAR)) {
minMagThresh = 0.5F;
}
else {
* we return (0,0,0,BorderAlpha).
*/
static inline void
-get_border_color(const struct gl_texture_object *tObj,
+get_border_color(const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
GLfloat rgba[4])
{
switch (img->_BaseFormat) {
case GL_RGB:
- rgba[0] = tObj->Sampler.BorderColor.f[0];
- rgba[1] = tObj->Sampler.BorderColor.f[1];
- rgba[2] = tObj->Sampler.BorderColor.f[2];
+ rgba[0] = samp->BorderColor.f[0];
+ rgba[1] = samp->BorderColor.f[1];
+ rgba[2] = samp->BorderColor.f[2];
rgba[3] = 1.0F;
break;
case GL_ALPHA:
rgba[0] = rgba[1] = rgba[2] = 0.0;
- rgba[3] = tObj->Sampler.BorderColor.f[3];
+ rgba[3] = samp->BorderColor.f[3];
break;
case GL_LUMINANCE:
- rgba[0] = rgba[1] = rgba[2] = tObj->Sampler.BorderColor.f[0];
+ rgba[0] = rgba[1] = rgba[2] = samp->BorderColor.f[0];
rgba[3] = 1.0;
break;
case GL_LUMINANCE_ALPHA:
- rgba[0] = rgba[1] = rgba[2] = tObj->Sampler.BorderColor.f[0];
- rgba[3] = tObj->Sampler.BorderColor.f[3];
+ rgba[0] = rgba[1] = rgba[2] = samp->BorderColor.f[0];
+ rgba[3] = samp->BorderColor.f[3];
break;
case GL_INTENSITY:
- rgba[0] = rgba[1] = rgba[2] = rgba[3] = tObj->Sampler.BorderColor.f[0];
+ rgba[0] = rgba[1] = rgba[2] = rgba[3] = samp->BorderColor.f[0];
break;
default:
- COPY_4V(rgba, tObj->Sampler.BorderColor.f);
+ COPY_4V(rgba, samp->BorderColor.f);
break;
}
}
*/
static inline void
sample_1d_nearest(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4], GLfloat rgba[4])
{
const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width2; /* without border, power of two */
GLint i;
- i = nearest_texel_location(tObj->Sampler.WrapS, img, width, texcoord[0]);
+ i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
/* skip over the border, if any */
i += img->Border;
if (i < 0 || i >= (GLint) img->Width) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- get_border_color(tObj, img, rgba);
+ get_border_color(samp, img, rgba);
}
else {
swImg->FetchTexel(swImg, i, 0, 0, rgba);
*/
static inline void
sample_1d_linear(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4], GLfloat rgba[4])
{
GLfloat a;
GLfloat t0[4], t1[4]; /* texels */
- linear_texel_locations(tObj->Sampler.WrapS, img, width, texcoord[0], &i0, &i1, &a);
+ linear_texel_locations(samp->WrapS, img, width, texcoord[0], &i0, &i1, &a);
if (img->Border) {
i0 += img->Border;
/* fetch texel colors */
if (useBorderColor & I0BIT) {
- get_border_color(tObj, img, t0);
+ get_border_color(samp, img, t0);
}
else {
swImg->FetchTexel(swImg, i0, 0, 0, t0);
}
if (useBorderColor & I1BIT) {
- get_border_color(tObj, img, t1);
+ get_border_color(samp, img, t1);
}
else {
swImg->FetchTexel(swImg, i1, 0, 0, t1);
static void
sample_1d_nearest_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_1d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ sample_1d_nearest(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
static void
sample_1d_linear_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_1d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ sample_1d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
static void
sample_1d_nearest_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_1d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_1d_nearest(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4];
const GLfloat f = FRAC(lambda[i]);
- sample_1d_nearest(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_1d_nearest(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_1d_nearest(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_1d_nearest(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
static void
sample_1d_linear_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_1d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_1d_linear(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4];
const GLfloat f = FRAC(lambda[i]);
- sample_1d_linear(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_1d_linear(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_1d_linear(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_1d_linear(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
/** Sample 1D texture, nearest filtering for both min/magnification */
static void
sample_nearest_1d( struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4] )
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_1d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_1d_nearest(ctx, samp, image, texcoords[i], rgba[i]);
}
}
/** Sample 1D texture, linear filtering for both min/magnification */
static void
sample_linear_1d( struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4] )
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_1d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_1d_linear(ctx, samp, image, texcoords[i], rgba[i]);
}
}
/** Sample 1D texture, using lambda to choose between min/magnification */
static void
sample_lambda_1d( struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4] )
GLuint i;
ASSERT(lambda != NULL);
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
const GLuint m = minEnd - minStart;
- switch (tObj->Sampler.MinFilter) {
+ switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_1d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_1d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_1d_nearest_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_1d_nearest_mipmap_nearest(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_1d_linear_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_1d_linear_mipmap_nearest(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_1d_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_1d_nearest_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_1d_linear_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_1d_linear_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
default:
if (magStart < magEnd) {
/* do the magnified texels */
- switch (tObj->Sampler.MagFilter) {
+ switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_1d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_1d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
default:
*/
static inline void
sample_2d_nearest(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[])
GLint i, j;
(void) ctx;
- i = nearest_texel_location(tObj->Sampler.WrapS, img, width, texcoord[0]);
- j = nearest_texel_location(tObj->Sampler.WrapT, img, height, texcoord[1]);
+ i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
+ j = nearest_texel_location(samp->WrapT, img, height, texcoord[1]);
/* skip over the border, if any */
i += img->Border;
if (i < 0 || i >= (GLint) img->Width || j < 0 || j >= (GLint) img->Height) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- get_border_color(tObj, img, rgba);
+ get_border_color(samp, img, rgba);
}
else {
swImg->FetchTexel(swImg, i, j, 0, rgba);
*/
static inline void
sample_2d_linear(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[])
GLfloat a, b;
GLfloat t00[4], t10[4], t01[4], t11[4]; /* sampled texel colors */
- linear_texel_locations(tObj->Sampler.WrapS, img, width, texcoord[0], &i0, &i1, &a);
- linear_texel_locations(tObj->Sampler.WrapT, img, height, texcoord[1], &j0, &j1, &b);
+ linear_texel_locations(samp->WrapS, img, width, texcoord[0], &i0, &i1, &a);
+ linear_texel_locations(samp->WrapT, img, height, texcoord[1], &j0, &j1, &b);
if (img->Border) {
i0 += img->Border;
/* fetch four texel colors */
if (useBorderColor & (I0BIT | J0BIT)) {
- get_border_color(tObj, img, t00);
+ get_border_color(samp, img, t00);
}
else {
swImg->FetchTexel(swImg, i0, j0, 0, t00);
}
if (useBorderColor & (I1BIT | J0BIT)) {
- get_border_color(tObj, img, t10);
+ get_border_color(samp, img, t10);
}
else {
swImg->FetchTexel(swImg, i1, j0, 0, t10);
}
if (useBorderColor & (I0BIT | J1BIT)) {
- get_border_color(tObj, img, t01);
+ get_border_color(samp, img, t01);
}
else {
swImg->FetchTexel(swImg, i0, j1, 0, t01);
}
if (useBorderColor & (I1BIT | J1BIT)) {
- get_border_color(tObj, img, t11);
+ get_border_color(samp, img, t11);
}
else {
swImg->FetchTexel(swImg, i1, j1, 0, t11);
*/
static inline void
sample_2d_linear_repeat(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[])
(void) ctx;
- ASSERT(tObj->Sampler.WrapS == GL_REPEAT);
- ASSERT(tObj->Sampler.WrapT == GL_REPEAT);
+ ASSERT(samp->WrapS == GL_REPEAT);
+ ASSERT(samp->WrapT == GL_REPEAT);
ASSERT(img->Border == 0);
ASSERT(swImg->_IsPowerOfTwo);
static void
sample_2d_nearest_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
GLuint i;
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_2d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ sample_2d_nearest(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
static void
sample_2d_linear_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_2d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ sample_2d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
static void
sample_2d_nearest_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_2d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_2d_nearest(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_2d_nearest(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_2d_nearest(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_2d_nearest(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_2d_nearest(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
static void
sample_2d_linear_mipmap_linear( struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4] )
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_2d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_2d_linear(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_2d_linear(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_2d_linear(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_2d_linear(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_2d_linear(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
static void
sample_2d_linear_mipmap_linear_repeat(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
ASSERT(lambda != NULL);
- ASSERT(tObj->Sampler.WrapS == GL_REPEAT);
- ASSERT(tObj->Sampler.WrapT == GL_REPEAT);
+ 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) {
- sample_2d_linear_repeat(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_2d_linear_repeat(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_2d_linear_repeat(ctx, tObj, tObj->Image[0][level ],
+ sample_2d_linear_repeat(ctx, samp, tObj->Image[0][level ],
texcoord[i], t0);
- sample_2d_linear_repeat(ctx, tObj, tObj->Image[0][level+1],
+ sample_2d_linear_repeat(ctx, samp, tObj->Image[0][level+1],
texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
/** Sample 2D texture, nearest filtering for both min/magnification */
static void
sample_nearest_2d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_2d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_2d_nearest(ctx, samp, image, texcoords[i], rgba[i]);
}
}
/** Sample 2D texture, linear filtering for both min/magnification */
static void
sample_linear_2d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
const struct swrast_texture_image *swImg = swrast_texture_image_const(image);
(void) lambda;
- if (tObj->Sampler.WrapS == GL_REPEAT &&
- tObj->Sampler.WrapT == GL_REPEAT &&
+ if (samp->WrapS == GL_REPEAT &&
+ samp->WrapT == GL_REPEAT &&
swImg->_IsPowerOfTwo &&
image->Border == 0) {
for (i = 0; i < n; i++) {
- sample_2d_linear_repeat(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_2d_linear_repeat(ctx, samp, image, texcoords[i], rgba[i]);
}
}
else {
for (i = 0; i < n; i++) {
- sample_2d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_2d_linear(ctx, samp, image, texcoords[i], rgba[i]);
}
}
}
*/
static void
opt_sample_rgb_2d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
GLuint k;
(void) ctx;
(void) lambda;
- ASSERT(tObj->Sampler.WrapS==GL_REPEAT);
- ASSERT(tObj->Sampler.WrapT==GL_REPEAT);
+ ASSERT(samp->WrapS==GL_REPEAT);
+ ASSERT(samp->WrapT==GL_REPEAT);
ASSERT(img->Border==0);
ASSERT(img->TexFormat == MESA_FORMAT_RGB888);
ASSERT(swImg->_IsPowerOfTwo);
*/
static void
opt_sample_rgba_2d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
GLuint i;
(void) ctx;
(void) lambda;
- ASSERT(tObj->Sampler.WrapS==GL_REPEAT);
- ASSERT(tObj->Sampler.WrapT==GL_REPEAT);
+ ASSERT(samp->WrapS==GL_REPEAT);
+ ASSERT(samp->WrapT==GL_REPEAT);
ASSERT(img->Border==0);
ASSERT(img->TexFormat == MESA_FORMAT_RGBA8888);
ASSERT(swImg->_IsPowerOfTwo);
/** Sample 2D texture, using lambda to choose between min/magnification */
static void
sample_lambda_2d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
GLuint minStart, minEnd; /* texels with minification */
GLuint magStart, magEnd; /* texels with magnification */
- const GLboolean repeatNoBorderPOT = (tObj->Sampler.WrapS == GL_REPEAT)
- && (tObj->Sampler.WrapT == GL_REPEAT)
+ const GLboolean repeatNoBorderPOT = (samp->WrapS == GL_REPEAT)
+ && (samp->WrapT == GL_REPEAT)
&& (tImg->Border == 0 && (tImg->Width == swImg->RowStride))
&& swImg->_IsPowerOfTwo;
ASSERT(lambda != NULL);
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
const GLuint m = minEnd - minStart;
- switch (tObj->Sampler.MinFilter) {
+ switch (samp->MinFilter) {
case GL_NEAREST:
if (repeatNoBorderPOT) {
switch (tImg->TexFormat) {
case MESA_FORMAT_RGB888:
- opt_sample_rgb_2d(ctx, tObj, m, texcoords + minStart,
+ opt_sample_rgb_2d(ctx, samp, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
break;
case MESA_FORMAT_RGBA8888:
- opt_sample_rgba_2d(ctx, tObj, m, texcoords + minStart,
+ opt_sample_rgba_2d(ctx, samp, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
break;
default:
- sample_nearest_2d(ctx, tObj, m, texcoords + minStart,
+ sample_nearest_2d(ctx, samp, tObj, m, texcoords + minStart,
NULL, rgba + minStart );
}
}
else {
- sample_nearest_2d(ctx, tObj, m, texcoords + minStart,
+ sample_nearest_2d(ctx, samp, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
}
break;
case GL_LINEAR:
- sample_linear_2d(ctx, tObj, m, texcoords + minStart,
+ sample_linear_2d(ctx, samp, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_2d_nearest_mipmap_nearest(ctx, tObj, m,
+ sample_2d_nearest_mipmap_nearest(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_2d_linear_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_2d_linear_mipmap_nearest(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_2d_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_2d_nearest_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
if (repeatNoBorderPOT)
- sample_2d_linear_mipmap_linear_repeat(ctx, tObj, m,
+ sample_2d_linear_mipmap_linear_repeat(ctx, samp, tObj, m,
texcoords + minStart, lambda + minStart, rgba + minStart);
else
- sample_2d_linear_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_2d_linear_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
default:
/* do the magnified texels */
const GLuint m = magEnd - magStart;
- switch (tObj->Sampler.MagFilter) {
+ switch (samp->MagFilter) {
case GL_NEAREST:
if (repeatNoBorderPOT) {
switch (tImg->TexFormat) {
case MESA_FORMAT_RGB888:
- opt_sample_rgb_2d(ctx, tObj, m, texcoords + magStart,
+ opt_sample_rgb_2d(ctx, samp, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
break;
case MESA_FORMAT_RGBA8888:
- opt_sample_rgba_2d(ctx, tObj, m, texcoords + magStart,
+ opt_sample_rgba_2d(ctx, samp, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
break;
default:
- sample_nearest_2d(ctx, tObj, m, texcoords + magStart,
+ sample_nearest_2d(ctx, samp, tObj, m, texcoords + magStart,
NULL, rgba + magStart );
}
}
else {
- sample_nearest_2d(ctx, tObj, m, texcoords + magStart,
+ sample_nearest_2d(ctx, samp, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
}
break;
case GL_LINEAR:
- sample_linear_2d(ctx, tObj, m, texcoords + magStart,
+ sample_linear_2d(ctx, samp, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
break;
default:
*/
static void
sample_2d_ewa(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
const GLfloat texcoord[4],
const GLfloat dudx, const GLfloat dvdx,
newCoord[0] = u / ((GLfloat) img->Width2);
newCoord[1] = v / ((GLfloat) img->Height2);
- sample_2d_nearest(ctx, tObj, img, newCoord, rgba);
+ sample_2d_nearest(ctx, samp, img, newCoord, rgba);
num[0] += weight * rgba[0];
num[1] += weight * rgba[1];
num[2] += weight * rgba[2];
rgba[2]=0;
rgba[3]=0;*/
/* not enough pixels in resampling, resort to direct interpolation */
- sample_2d_linear(ctx, tObj, img, texcoord, rgba);
+ sample_2d_linear(ctx, samp, img, texcoord, rgba);
return;
}
*/
static void
sample_2d_footprint(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
const GLfloat texcoord[4],
const GLfloat dudx, const GLfloat dvdx,
newCoord[0] = texcoord[0] + ds * ((GLfloat)(s+1) / (numSamples+1) -0.5);
newCoord[1] = texcoord[1] + dt * ((GLfloat)(s+1) / (numSamples+1) -0.5);
- sample_2d_linear(ctx, tObj, img, newCoord, rgba);
+ sample_2d_linear(ctx, samp, img, newCoord, rgba);
num[0] += rgba[0];
num[1] += rgba[1];
num[2] += rgba[2];
*/
static void
sample_lambda_2d_aniso(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
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 swrast_texture_image *swImg = swrast_texture_image_const(tImg);
const GLfloat maxEccentricity =
- tObj->Sampler.MaxAnisotropy * tObj->Sampler.MaxAnisotropy;
+ samp->MaxAnisotropy * samp->MaxAnisotropy;
/* re-calculate the lambda values so that they are usable with anisotropic
* filtering
/* from swrast/s_texcombine.c _swrast_texture_span */
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
const GLboolean adjustLOD =
- (texUnit->LodBias + tObj->Sampler.LodBias != 0.0F)
- || (tObj->Sampler.MinLod != -1000.0 || tObj->Sampler.MaxLod != 1000.0);
+ (texUnit->LodBias + samp->LodBias != 0.0F)
+ || (samp->MinLod != -1000.0 || samp->MaxLod != 1000.0);
GLuint i;
if (adjustLOD) {
/* from swrast/s_texcombine.c _swrast_texture_span */
- if (texUnit->LodBias + tObj->Sampler.LodBias != 0.0F) {
+ if (texUnit->LodBias + samp->LodBias != 0.0F) {
/* apply LOD bias, but don't clamp yet */
const GLfloat bias =
- CLAMP(texUnit->LodBias + tObj->Sampler.LodBias,
+ CLAMP(texUnit->LodBias + samp->LodBias,
-ctx->Const.MaxTextureLodBias,
ctx->Const.MaxTextureLodBias);
lod += bias;
- if (tObj->Sampler.MinLod != -1000.0 ||
- tObj->Sampler.MaxLod != 1000.0) {
+ if (samp->MinLod != -1000.0 ||
+ samp->MaxLod != 1000.0) {
/* apply LOD clamping to lambda */
- lod = CLAMP(lod, tObj->Sampler.MinLod, tObj->Sampler.MaxLod);
+ lod = CLAMP(lod, samp->MinLod, samp->MaxLod);
}
}
}
* simply return the average of the whole image.
*/
if (lod >= tObj->_MaxLevel) {
- sample_2d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_2d_linear(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoords[i], rgba[i]);
}
else {
/* don't bother interpolating between multiple LODs; it doesn't
* seem to be worth the extra running time.
*/
- sample_2d_ewa(ctx, tObj, texcoords[i],
+ sample_2d_ewa(ctx, samp, tObj, texcoords[i],
dudx, dvdx, dudy, dvdy, floor(lod), rgba[i]);
/* unused: */
*/
static inline void
sample_3d_nearest(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[4])
GLint i, j, k;
(void) ctx;
- i = nearest_texel_location(tObj->Sampler.WrapS, img, width, texcoord[0]);
- j = nearest_texel_location(tObj->Sampler.WrapT, img, height, texcoord[1]);
- k = nearest_texel_location(tObj->Sampler.WrapR, img, depth, texcoord[2]);
+ i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
+ j = nearest_texel_location(samp->WrapT, img, height, texcoord[1]);
+ k = nearest_texel_location(samp->WrapR, img, depth, texcoord[2]);
if (i < 0 || i >= (GLint) img->Width ||
j < 0 || j >= (GLint) img->Height ||
k < 0 || k >= (GLint) img->Depth) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- get_border_color(tObj, img, rgba);
+ get_border_color(samp, img, rgba);
}
else {
swImg->FetchTexel(swImg, i, j, k, rgba);
*/
static void
sample_3d_linear(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[4])
GLfloat t000[4], t010[4], t001[4], t011[4];
GLfloat t100[4], t110[4], t101[4], t111[4];
- linear_texel_locations(tObj->Sampler.WrapS, img, width, texcoord[0], &i0, &i1, &a);
- linear_texel_locations(tObj->Sampler.WrapT, img, height, texcoord[1], &j0, &j1, &b);
- linear_texel_locations(tObj->Sampler.WrapR, img, depth, texcoord[2], &k0, &k1, &c);
+ linear_texel_locations(samp->WrapS, img, width, texcoord[0], &i0, &i1, &a);
+ linear_texel_locations(samp->WrapT, img, height, texcoord[1], &j0, &j1, &b);
+ linear_texel_locations(samp->WrapR, img, depth, texcoord[2], &k0, &k1, &c);
if (img->Border) {
i0 += img->Border;
/* Fetch texels */
if (useBorderColor & (I0BIT | J0BIT | K0BIT)) {
- get_border_color(tObj, img, t000);
+ get_border_color(samp, img, t000);
}
else {
swImg->FetchTexel(swImg, i0, j0, k0, t000);
}
if (useBorderColor & (I1BIT | J0BIT | K0BIT)) {
- get_border_color(tObj, img, t100);
+ get_border_color(samp, img, t100);
}
else {
swImg->FetchTexel(swImg, i1, j0, k0, t100);
}
if (useBorderColor & (I0BIT | J1BIT | K0BIT)) {
- get_border_color(tObj, img, t010);
+ get_border_color(samp, img, t010);
}
else {
swImg->FetchTexel(swImg, i0, j1, k0, t010);
}
if (useBorderColor & (I1BIT | J1BIT | K0BIT)) {
- get_border_color(tObj, img, t110);
+ get_border_color(samp, img, t110);
}
else {
swImg->FetchTexel(swImg, i1, j1, k0, t110);
}
if (useBorderColor & (I0BIT | J0BIT | K1BIT)) {
- get_border_color(tObj, img, t001);
+ get_border_color(samp, img, t001);
}
else {
swImg->FetchTexel(swImg, i0, j0, k1, t001);
}
if (useBorderColor & (I1BIT | J0BIT | K1BIT)) {
- get_border_color(tObj, img, t101);
+ get_border_color(samp, img, t101);
}
else {
swImg->FetchTexel(swImg, i1, j0, k1, t101);
}
if (useBorderColor & (I0BIT | J1BIT | K1BIT)) {
- get_border_color(tObj, img, t011);
+ get_border_color(samp, img, t011);
}
else {
swImg->FetchTexel(swImg, i0, j1, k1, t011);
}
if (useBorderColor & (I1BIT | J1BIT | K1BIT)) {
- get_border_color(tObj, img, t111);
+ get_border_color(samp, img, t111);
}
else {
swImg->FetchTexel(swImg, i1, j1, k1, t111);
static void
sample_3d_nearest_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4] )
GLuint i;
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_3d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ sample_3d_nearest(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
static void
sample_3d_linear_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_3d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ sample_3d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
static void
sample_3d_nearest_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_3d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_3d_nearest(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_3d_nearest(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_3d_nearest(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_3d_nearest(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_3d_nearest(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
static void
sample_3d_linear_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_3d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_3d_linear(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_3d_linear(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_3d_linear(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_3d_linear(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_3d_linear(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
/** Sample 3D texture, nearest filtering for both min/magnification */
static void
sample_nearest_3d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_3d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_3d_nearest(ctx, samp, image, texcoords[i], rgba[i]);
}
}
/** Sample 3D texture, linear filtering for both min/magnification */
static void
sample_linear_3d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_3d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_3d_linear(ctx, samp, image, texcoords[i], rgba[i]);
}
}
/** Sample 3D texture, using lambda to choose between min/magnification */
static void
sample_lambda_3d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
GLuint i;
ASSERT(lambda != NULL);
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
GLuint m = minEnd - minStart;
- switch (tObj->Sampler.MinFilter) {
+ switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_3d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_3d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_3d_nearest_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_3d_nearest_mipmap_nearest(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_3d_linear_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_3d_linear_mipmap_nearest(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_3d_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_3d_nearest_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_3d_linear_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_3d_linear_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
default:
if (magStart < magEnd) {
/* do the magnified texels */
- switch (tObj->Sampler.MagFilter) {
+ switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_3d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_3d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
default:
static void
sample_nearest_cube(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
const struct gl_texture_image **images;
GLfloat newCoord[4];
images = choose_cube_face(tObj, texcoords[i], newCoord);
- sample_2d_nearest(ctx, tObj, images[tObj->BaseLevel],
+ sample_2d_nearest(ctx, samp, images[tObj->BaseLevel],
newCoord, rgba[i]);
}
}
static void
sample_linear_cube(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
const struct gl_texture_image **images;
GLfloat newCoord[4];
images = choose_cube_face(tObj, texcoords[i], newCoord);
- sample_2d_linear(ctx, tObj, images[tObj->BaseLevel],
+ sample_2d_linear(ctx, samp, images[tObj->BaseLevel],
newCoord, rgba[i]);
}
}
static void
sample_cube_nearest_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
level = nearest_mipmap_level(tObj, lambda[i]);
level = MAX2(level - 1, 0);
- sample_2d_nearest(ctx, tObj, images[level], newCoord, rgba[i]);
+ sample_2d_nearest(ctx, samp, images[level], newCoord, rgba[i]);
}
}
static void
sample_cube_linear_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
GLint level = nearest_mipmap_level(tObj, lambda[i]);
level = MAX2(level - 1, 0); /* see comment above */
images = choose_cube_face(tObj, texcoord[i], newCoord);
- sample_2d_linear(ctx, tObj, images[level], newCoord, rgba[i]);
+ sample_2d_linear(ctx, samp, images[level], newCoord, rgba[i]);
}
}
static void
sample_cube_nearest_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
level = MAX2(level - 1, 0); /* see comment above */
images = choose_cube_face(tObj, texcoord[i], newCoord);
if (level >= tObj->_MaxLevel) {
- sample_2d_nearest(ctx, tObj, images[tObj->_MaxLevel],
+ sample_2d_nearest(ctx, samp, images[tObj->_MaxLevel],
newCoord, rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_2d_nearest(ctx, tObj, images[level ], newCoord, t0);
- sample_2d_nearest(ctx, tObj, images[level+1], newCoord, t1);
+ sample_2d_nearest(ctx, samp, images[level ], newCoord, t0);
+ sample_2d_nearest(ctx, samp, images[level+1], newCoord, t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
static void
sample_cube_linear_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
level = MAX2(level - 1, 0); /* see comment above */
images = choose_cube_face(tObj, texcoord[i], newCoord);
if (level >= tObj->_MaxLevel) {
- sample_2d_linear(ctx, tObj, images[tObj->_MaxLevel],
+ sample_2d_linear(ctx, samp, images[tObj->_MaxLevel],
newCoord, rgba[i]);
}
else {
GLfloat t0[4], t1[4];
const GLfloat f = FRAC(lambda[i]);
- sample_2d_linear(ctx, tObj, images[level ], newCoord, t0);
- sample_2d_linear(ctx, tObj, images[level+1], newCoord, t1);
+ sample_2d_linear(ctx, samp, images[level ], newCoord, t0);
+ sample_2d_linear(ctx, samp, images[level+1], newCoord, t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
/** Sample cube texture, using lambda to choose between min/magnification */
static void
sample_lambda_cube(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
GLuint magStart, magEnd; /* texels with magnification */
ASSERT(lambda != NULL);
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
const GLuint m = minEnd - minStart;
- switch (tObj->Sampler.MinFilter) {
+ switch (samp->MinFilter) {
case GL_NEAREST:
- sample_nearest_cube(ctx, tObj, m, texcoords + minStart,
+ sample_nearest_cube(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR:
- sample_linear_cube(ctx, tObj, m, texcoords + minStart,
+ sample_linear_cube(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_cube_nearest_mipmap_nearest(ctx, tObj, m,
+ sample_cube_nearest_mipmap_nearest(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_cube_linear_mipmap_nearest(ctx, tObj, m,
+ sample_cube_linear_mipmap_nearest(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_cube_nearest_mipmap_linear(ctx, tObj, m,
+ sample_cube_nearest_mipmap_linear(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_cube_linear_mipmap_linear(ctx, tObj, m,
+ sample_cube_linear_mipmap_linear(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
if (magStart < magEnd) {
/* do the magnified texels */
const GLuint m = magEnd - magStart;
- switch (tObj->Sampler.MagFilter) {
+ switch (samp->MagFilter) {
case GL_NEAREST:
- sample_nearest_cube(ctx, tObj, m, texcoords + magStart,
+ sample_nearest_cube(ctx, samp, tObj, m, texcoords + magStart,
lambda + magStart, rgba + magStart);
break;
case GL_LINEAR:
- sample_linear_cube(ctx, tObj, m, texcoords + magStart,
+ sample_linear_cube(ctx, samp, tObj, m, texcoords + magStart,
lambda + magStart, rgba + magStart);
break;
default:
static void
sample_nearest_rect(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
(void) ctx;
(void) lambda;
- ASSERT(tObj->Sampler.WrapS == GL_CLAMP ||
- tObj->Sampler.WrapS == GL_CLAMP_TO_EDGE ||
- tObj->Sampler.WrapS == GL_CLAMP_TO_BORDER);
- ASSERT(tObj->Sampler.WrapT == GL_CLAMP ||
- tObj->Sampler.WrapT == GL_CLAMP_TO_EDGE ||
- tObj->Sampler.WrapT == GL_CLAMP_TO_BORDER);
+ ASSERT(samp->WrapS == GL_CLAMP ||
+ samp->WrapS == GL_CLAMP_TO_EDGE ||
+ samp->WrapS == GL_CLAMP_TO_BORDER);
+ ASSERT(samp->WrapT == GL_CLAMP ||
+ samp->WrapT == GL_CLAMP_TO_EDGE ||
+ samp->WrapT == GL_CLAMP_TO_BORDER);
for (i = 0; i < n; i++) {
GLint row, col;
- col = clamp_rect_coord_nearest(tObj->Sampler.WrapS, texcoords[i][0], width);
- row = clamp_rect_coord_nearest(tObj->Sampler.WrapT, texcoords[i][1], height);
+ col = clamp_rect_coord_nearest(samp->WrapS, texcoords[i][0], width);
+ row = clamp_rect_coord_nearest(samp->WrapT, texcoords[i][1], height);
if (col < 0 || col >= width || row < 0 || row >= height)
- get_border_color(tObj, img, rgba[i]);
+ get_border_color(samp, img, rgba[i]);
else
swImg->FetchTexel(swImg, col, row, 0, rgba[i]);
}
static void
sample_linear_rect(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
(void) ctx;
(void) lambda;
- ASSERT(tObj->Sampler.WrapS == GL_CLAMP ||
- tObj->Sampler.WrapS == GL_CLAMP_TO_EDGE ||
- tObj->Sampler.WrapS == GL_CLAMP_TO_BORDER);
- ASSERT(tObj->Sampler.WrapT == GL_CLAMP ||
- tObj->Sampler.WrapT == GL_CLAMP_TO_EDGE ||
- tObj->Sampler.WrapT == GL_CLAMP_TO_BORDER);
+ ASSERT(samp->WrapS == GL_CLAMP ||
+ samp->WrapS == GL_CLAMP_TO_EDGE ||
+ samp->WrapS == GL_CLAMP_TO_BORDER);
+ ASSERT(samp->WrapT == GL_CLAMP ||
+ samp->WrapT == GL_CLAMP_TO_EDGE ||
+ samp->WrapT == GL_CLAMP_TO_BORDER);
for (i = 0; i < n; i++) {
GLint i0, j0, i1, j1;
GLfloat a, b;
GLbitfield useBorderColor = 0x0;
- clamp_rect_coord_linear(tObj->Sampler.WrapS, texcoords[i][0], width,
+ clamp_rect_coord_linear(samp->WrapS, texcoords[i][0], width,
&i0, &i1, &a);
- clamp_rect_coord_linear(tObj->Sampler.WrapT, texcoords[i][1], height,
+ clamp_rect_coord_linear(samp->WrapT, texcoords[i][1], height,
&j0, &j1, &b);
/* compute integer rows/columns */
/* get four texel samples */
if (useBorderColor & (I0BIT | J0BIT))
- get_border_color(tObj, img, t00);
+ get_border_color(samp, img, t00);
else
swImg->FetchTexel(swImg, i0, j0, 0, t00);
if (useBorderColor & (I1BIT | J0BIT))
- get_border_color(tObj, img, t10);
+ get_border_color(samp, img, t10);
else
swImg->FetchTexel(swImg, i1, j0, 0, t10);
if (useBorderColor & (I0BIT | J1BIT))
- get_border_color(tObj, img, t01);
+ get_border_color(samp, img, t01);
else
swImg->FetchTexel(swImg, i0, j1, 0, t01);
if (useBorderColor & (I1BIT | J1BIT))
- get_border_color(tObj, img, t11);
+ get_border_color(samp, img, t11);
else
swImg->FetchTexel(swImg, i1, j1, 0, t11);
/** Sample Rect texture, using lambda to choose between min/magnification */
static void
sample_lambda_rect(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
/* We only need lambda to decide between minification and magnification.
* There is no mipmapping with rectangular textures.
*/
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
- if (tObj->Sampler.MinFilter == GL_NEAREST) {
- sample_nearest_rect(ctx, tObj, minEnd - minStart,
+ if (samp->MinFilter == GL_NEAREST) {
+ sample_nearest_rect(ctx, samp, tObj, minEnd - minStart,
texcoords + minStart, NULL, rgba + minStart);
}
else {
- sample_linear_rect(ctx, tObj, minEnd - minStart,
+ sample_linear_rect(ctx, samp, tObj, minEnd - minStart,
texcoords + minStart, NULL, rgba + minStart);
}
}
if (magStart < magEnd) {
- if (tObj->Sampler.MagFilter == GL_NEAREST) {
- sample_nearest_rect(ctx, tObj, magEnd - magStart,
+ if (samp->MagFilter == GL_NEAREST) {
+ sample_nearest_rect(ctx, samp, tObj, magEnd - magStart,
texcoords + magStart, NULL, rgba + magStart);
}
else {
- sample_linear_rect(ctx, tObj, magEnd - magStart,
+ sample_linear_rect(ctx, samp, tObj, magEnd - magStart,
texcoords + magStart, NULL, rgba + magStart);
}
}
*/
static void
sample_2d_array_nearest(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[4])
GLint array;
(void) ctx;
- i = nearest_texel_location(tObj->Sampler.WrapS, img, width, texcoord[0]);
- j = nearest_texel_location(tObj->Sampler.WrapT, img, height, texcoord[1]);
+ i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
+ j = nearest_texel_location(samp->WrapT, img, height, texcoord[1]);
array = tex_array_slice(texcoord[2], depth);
if (i < 0 || i >= (GLint) img->Width ||
j < 0 || j >= (GLint) img->Height ||
array < 0 || array >= (GLint) img->Depth) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- get_border_color(tObj, img, rgba);
+ get_border_color(samp, img, rgba);
}
else {
swImg->FetchTexel(swImg, i, j, array, rgba);
*/
static void
sample_2d_array_linear(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[4])
GLfloat a, b;
GLfloat t00[4], t01[4], t10[4], t11[4];
- linear_texel_locations(tObj->Sampler.WrapS, img, width, texcoord[0], &i0, &i1, &a);
- linear_texel_locations(tObj->Sampler.WrapT, img, height, texcoord[1], &j0, &j1, &b);
+ linear_texel_locations(samp->WrapS, img, width, texcoord[0], &i0, &i1, &a);
+ linear_texel_locations(samp->WrapT, img, height, texcoord[1], &j0, &j1, &b);
array = tex_array_slice(texcoord[2], depth);
if (array < 0 || array >= depth) {
- COPY_4V(rgba, tObj->Sampler.BorderColor.f);
+ COPY_4V(rgba, samp->BorderColor.f);
}
else {
if (img->Border) {
/* Fetch texels */
if (useBorderColor & (I0BIT | J0BIT)) {
- get_border_color(tObj, img, t00);
+ get_border_color(samp, img, t00);
}
else {
swImg->FetchTexel(swImg, i0, j0, array, t00);
}
if (useBorderColor & (I1BIT | J0BIT)) {
- get_border_color(tObj, img, t10);
+ get_border_color(samp, img, t10);
}
else {
swImg->FetchTexel(swImg, i1, j0, array, t10);
}
if (useBorderColor & (I0BIT | J1BIT)) {
- get_border_color(tObj, img, t01);
+ get_border_color(samp, img, t01);
}
else {
swImg->FetchTexel(swImg, i0, j1, array, t01);
}
if (useBorderColor & (I1BIT | J1BIT)) {
- get_border_color(tObj, img, t11);
+ get_border_color(samp, img, t11);
}
else {
swImg->FetchTexel(swImg, i1, j1, array, t11);
static void
sample_2d_array_nearest_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
GLuint i;
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_2d_array_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i],
+ sample_2d_array_nearest(ctx, samp, tObj->Image[0][level], texcoord[i],
rgba[i]);
}
}
static void
sample_2d_array_linear_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_2d_array_linear(ctx, tObj, tObj->Image[0][level],
+ sample_2d_array_linear(ctx, samp, tObj->Image[0][level],
texcoord[i], rgba[i]);
}
}
static void
sample_2d_array_nearest_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_2d_array_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_2d_array_nearest(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_2d_array_nearest(ctx, tObj, tObj->Image[0][level ],
+ sample_2d_array_nearest(ctx, samp, tObj->Image[0][level ],
texcoord[i], t0);
- sample_2d_array_nearest(ctx, tObj, tObj->Image[0][level+1],
+ sample_2d_array_nearest(ctx, samp, tObj->Image[0][level+1],
texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
static void
sample_2d_array_linear_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_2d_array_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_2d_array_linear(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_2d_array_linear(ctx, tObj, tObj->Image[0][level ],
+ sample_2d_array_linear(ctx, samp, tObj->Image[0][level ],
texcoord[i], t0);
- sample_2d_array_linear(ctx, tObj, tObj->Image[0][level+1],
+ sample_2d_array_linear(ctx, samp, tObj->Image[0][level+1],
texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
/** Sample 2D Array texture, nearest filtering for both min/magnification */
static void
sample_nearest_2d_array(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_2d_array_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_2d_array_nearest(ctx, samp, image, texcoords[i], rgba[i]);
}
}
/** Sample 2D Array texture, linear filtering for both min/magnification */
static void
sample_linear_2d_array(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_2d_array_linear(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_2d_array_linear(ctx, samp, image, texcoords[i], rgba[i]);
}
}
/** Sample 2D Array texture, using lambda to choose between min/magnification */
static void
sample_lambda_2d_array(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
GLuint i;
ASSERT(lambda != NULL);
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
GLuint m = minEnd - minStart;
- switch (tObj->Sampler.MinFilter) {
+ switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_2d_array_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_2d_array_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_2d_array_nearest_mipmap_nearest(ctx, tObj, m,
+ sample_2d_array_nearest_mipmap_nearest(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart,
rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_2d_array_linear_mipmap_nearest(ctx, tObj, m,
+ sample_2d_array_linear_mipmap_nearest(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart,
rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_2d_array_nearest_mipmap_linear(ctx, tObj, m,
+ sample_2d_array_nearest_mipmap_linear(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart,
rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_2d_array_linear_mipmap_linear(ctx, tObj, m,
+ sample_2d_array_linear_mipmap_linear(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart,
rgba + minStart);
if (magStart < magEnd) {
/* do the magnified texels */
- switch (tObj->Sampler.MagFilter) {
+ switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_2d_array_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_2d_array_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
default:
*/
static void
sample_1d_array_nearest(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[4])
GLint array;
(void) ctx;
- i = nearest_texel_location(tObj->Sampler.WrapS, img, width, texcoord[0]);
+ i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
array = tex_array_slice(texcoord[1], height);
if (i < 0 || i >= (GLint) img->Width ||
array < 0 || array >= (GLint) img->Height) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- get_border_color(tObj, img, rgba);
+ get_border_color(samp, img, rgba);
}
else {
swImg->FetchTexel(swImg, i, array, 0, rgba);
*/
static void
sample_1d_array_linear(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[4])
GLfloat a;
GLfloat t0[4], t1[4];
- linear_texel_locations(tObj->Sampler.WrapS, img, width, texcoord[0], &i0, &i1, &a);
+ linear_texel_locations(samp->WrapS, img, width, texcoord[0], &i0, &i1, &a);
array = tex_array_slice(texcoord[1], height);
if (img->Border) {
/* Fetch texels */
if (useBorderColor & (I0BIT | K0BIT)) {
- get_border_color(tObj, img, t0);
+ get_border_color(samp, img, t0);
}
else {
swImg->FetchTexel(swImg, i0, array, 0, t0);
}
if (useBorderColor & (I1BIT | K0BIT)) {
- get_border_color(tObj, img, t1);
+ get_border_color(samp, img, t1);
}
else {
swImg->FetchTexel(swImg, i1, array, 0, t1);
static void
sample_1d_array_nearest_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
GLuint i;
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_1d_array_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i],
+ sample_1d_array_nearest(ctx, samp, tObj->Image[0][level], texcoord[i],
rgba[i]);
}
}
static void
sample_1d_array_linear_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_1d_array_linear(ctx, tObj, tObj->Image[0][level],
+ sample_1d_array_linear(ctx, samp, tObj->Image[0][level],
texcoord[i], rgba[i]);
}
}
static void
sample_1d_array_nearest_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_1d_array_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_1d_array_nearest(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_1d_array_nearest(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_1d_array_nearest(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_1d_array_nearest(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_1d_array_nearest(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
static void
sample_1d_array_linear_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_1d_array_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_1d_array_linear(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_1d_array_linear(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_1d_array_linear(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_1d_array_linear(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_1d_array_linear(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
/** Sample 1D Array texture, nearest filtering for both min/magnification */
static void
sample_nearest_1d_array(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_1d_array_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_1d_array_nearest(ctx, samp, image, texcoords[i], rgba[i]);
}
}
/** Sample 1D Array texture, linear filtering for both min/magnification */
static void
sample_linear_1d_array(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_1d_array_linear(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_1d_array_linear(ctx, samp, image, texcoords[i], rgba[i]);
}
}
/** Sample 1D Array texture, using lambda to choose between min/magnification */
static void
sample_lambda_1d_array(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
GLuint i;
ASSERT(lambda != NULL);
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
GLuint m = minEnd - minStart;
- switch (tObj->Sampler.MinFilter) {
+ switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_1d_array_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_1d_array_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_1d_array_nearest_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_1d_array_nearest_mipmap_nearest(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_1d_array_linear_mipmap_nearest(ctx, tObj, m,
+ sample_1d_array_linear_mipmap_nearest(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart,
rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_1d_array_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_1d_array_nearest_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_1d_array_linear_mipmap_linear(ctx, tObj, m,
+ sample_1d_array_linear_mipmap_linear(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart,
rgba + minStart);
if (magStart < magEnd) {
/* do the magnified texels */
- switch (tObj->Sampler.MagFilter) {
+ switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_1d_array_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_1d_array_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
default:
* Choose the mipmap level to use when sampling from a depth texture.
*/
static int
-choose_depth_texture_level(const struct gl_texture_object *tObj, GLfloat lambda)
+choose_depth_texture_level(const struct gl_sampler_object *samp,
+ const struct gl_texture_object *tObj, GLfloat lambda)
{
GLint level;
- if (tObj->Sampler.MinFilter == GL_NEAREST || tObj->Sampler.MinFilter == GL_LINEAR) {
+ if (samp->MinFilter == GL_NEAREST || samp->MinFilter == GL_LINEAR) {
/* no mipmapping - use base level */
level = tObj->BaseLevel;
}
else {
/* choose mipmap level */
- lambda = CLAMP(lambda, tObj->Sampler.MinLod, tObj->Sampler.MaxLod);
+ lambda = CLAMP(lambda, samp->MinLod, samp->MaxLod);
level = (GLint) lambda;
level = CLAMP(level, tObj->BaseLevel, tObj->_MaxLevel);
}
*/
static void
sample_depth_texture( struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat texel[][4] )
{
- const GLint level = choose_depth_texture_level(tObj, lambda[0]);
+ const GLint level = choose_depth_texture_level(samp, tObj, lambda[0]);
const struct gl_texture_image *img = tObj->Image[0][level];
const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width;
tObj->Target == GL_TEXTURE_2D_ARRAY_EXT ||
tObj->Target == GL_TEXTURE_CUBE_MAP);
- ambient = tObj->Sampler.CompareFailValue;
+ ambient = samp->CompareFailValue;
- /* XXXX if tObj->Sampler.MinFilter != tObj->Sampler.MagFilter, we're ignoring lambda */
+ /* XXXX if samp->MinFilter != samp->MagFilter, we're ignoring lambda */
- function = (tObj->Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) ?
- tObj->Sampler.CompareFunc : GL_NONE;
+ function = (samp->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) ?
+ samp->CompareFunc : GL_NONE;
- if (tObj->Sampler.MagFilter == GL_NEAREST) {
+ if (samp->MagFilter == GL_NEAREST) {
GLuint i;
for (i = 0; i < n; i++) {
GLfloat depthSample, depthRef;
GLint col, row, slice;
- nearest_texcoord(tObj, level, texcoords[i], &col, &row, &slice);
+ nearest_texcoord(samp, tObj, level, texcoords[i], &col, &row, &slice);
if (col >= 0 && row >= 0 && col < width && row < height &&
slice >= 0 && slice < depth) {
swImg->FetchTexel(swImg, col, row, slice, &depthSample);
}
else {
- depthSample = tObj->Sampler.BorderColor.f[0];
+ depthSample = samp->BorderColor.f[0];
}
depthRef = CLAMP(texcoords[i][compare_coord], 0.0F, 1.0F);
}
else {
GLuint i;
- ASSERT(tObj->Sampler.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;
GLfloat wi, wj;
GLuint useBorderTexel;
- linear_texcoord(tObj, level, texcoords[i], &i0, &i1, &j0, &j1, &slice,
+ linear_texcoord(samp, tObj, level, texcoords[i], &i0, &i1, &j0, &j1, &slice,
&wi, &wj);
useBorderTexel = 0;
}
if (slice < 0 || slice >= (GLint) depth) {
- depth00 = tObj->Sampler.BorderColor.f[0];
- depth01 = tObj->Sampler.BorderColor.f[0];
- depth10 = tObj->Sampler.BorderColor.f[0];
- depth11 = tObj->Sampler.BorderColor.f[0];
+ depth00 = samp->BorderColor.f[0];
+ depth01 = samp->BorderColor.f[0];
+ depth10 = samp->BorderColor.f[0];
+ depth11 = samp->BorderColor.f[0];
}
else {
/* get four depth samples from the texture */
if (useBorderTexel & (I0BIT | J0BIT)) {
- depth00 = tObj->Sampler.BorderColor.f[0];
+ depth00 = samp->BorderColor.f[0];
}
else {
swImg->FetchTexel(swImg, i0, j0, slice, &depth00);
}
if (useBorderTexel & (I1BIT | J0BIT)) {
- depth10 = tObj->Sampler.BorderColor.f[0];
+ depth10 = samp->BorderColor.f[0];
}
else {
swImg->FetchTexel(swImg, i1, j0, slice, &depth10);
if (tObj->Target != GL_TEXTURE_1D_ARRAY_EXT) {
if (useBorderTexel & (I0BIT | J1BIT)) {
- depth01 = tObj->Sampler.BorderColor.f[0];
+ depth01 = samp->BorderColor.f[0];
}
else {
swImg->FetchTexel(swImg, i0, j1, slice, &depth01);
}
if (useBorderTexel & (I1BIT | J1BIT)) {
- depth11 = tObj->Sampler.BorderColor.f[0];
+ depth11 = samp->BorderColor.f[0];
}
else {
swImg->FetchTexel(swImg, i1, j1, slice, &depth11);
*/
static void
null_sample_func( struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
(void) tObj;
(void) texcoords;
(void) lambda;
+ (void) samp;
for (i = 0; i < n; i++) {
rgba[i][RCOMP] = 0;
rgba[i][GCOMP] = 0;
}
else {
const GLboolean needLambda =
- (GLboolean) (t->Sampler.MinFilter != t->Sampler.MagFilter);
+ (GLboolean) (sampler->MinFilter != sampler->MagFilter);
const GLenum format = t->Image[0][t->BaseLevel]->_BaseFormat;
switch (t->Target) {
else if (needLambda) {
return &sample_lambda_1d;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_1d;
}
else {
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
return &sample_nearest_1d;
}
case GL_TEXTURE_2D:
}
else if (needLambda) {
/* Anisotropic filtering extension. Activated only if mipmaps are used */
- if (t->Sampler.MaxAnisotropy > 1.0 &&
- t->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
+ if (sampler->MaxAnisotropy > 1.0 &&
+ sampler->MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
return &sample_lambda_2d_aniso;
}
return &sample_lambda_2d;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_2d;
}
else {
swrast_texture_image_const(img);
texture_sample_func func;
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
func = &sample_nearest_2d;
- if (t->Sampler.WrapS == GL_REPEAT &&
- t->Sampler.WrapT == GL_REPEAT &&
+ if (sampler->WrapS == GL_REPEAT &&
+ sampler->WrapT == GL_REPEAT &&
swImg->_IsPowerOfTwo &&
img->Border == 0) {
if (img->TexFormat == MESA_FORMAT_RGB888)
if (needLambda) {
return &sample_lambda_3d;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_3d;
}
else {
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
return &sample_nearest_3d;
}
case GL_TEXTURE_CUBE_MAP:
else if (needLambda) {
return &sample_lambda_cube;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_cube;
}
else {
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
return &sample_nearest_cube;
}
case GL_TEXTURE_RECTANGLE_NV:
else if (needLambda) {
return &sample_lambda_rect;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_rect;
}
else {
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
return &sample_nearest_rect;
}
case GL_TEXTURE_1D_ARRAY_EXT:
else if (needLambda) {
return &sample_lambda_1d_array;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_1d_array;
}
else {
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
return &sample_nearest_1d_array;
}
case GL_TEXTURE_2D_ARRAY_EXT:
else if (needLambda) {
return &sample_lambda_2d_array;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_2d_array;
}
else {
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
return &sample_nearest_2d_array;
}
default: