From: Brian Paul Date: Fri, 2 Jan 2015 23:56:12 +0000 (-0700) Subject: swrast: use new _mesa_base_tex_image() helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=05279fa5636bc1354c34ef043183d56f730b7f8e;p=mesa.git swrast: use new _mesa_base_tex_image() helper Reviewed-by: Eric Anholt --- diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c index b4e05ff8018..6aea9d54571 100644 --- a/src/mesa/swrast/s_aaline.c +++ b/src/mesa/swrast/s_aaline.c @@ -27,6 +27,7 @@ #include "main/imports.h" #include "main/macros.h" #include "main/mtypes.h" +#include "main/teximage.h" #include "swrast/s_aaline.h" #include "swrast/s_context.h" #include "swrast/s_span.h" diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index 670b663bdae..f1d078fd89b 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -179,7 +179,8 @@ NAME(line)(struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1) if (attr >= VARYING_SLOT_TEX0 && attr < VARYING_SLOT_VAR0) { const GLuint u = attr - VARYING_SLOT_TEX0; const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; - const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; + const struct gl_texture_image *texImage = + _mesa_base_tex_image(obj); line.texWidth[attr] = (GLfloat) texImage->Width; line.texHeight[attr] = (GLfloat) texImage->Height; } diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 21699f3ea68..1d7c33619dc 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -25,6 +25,7 @@ #include "main/glheader.h" #include "main/colormac.h" #include "main/samplerobj.h" +#include "main/teximage.h" #include "program/prog_instruction.h" #include "s_context.h" @@ -116,8 +117,7 @@ fetch_texel_deriv( struct gl_context *ctx, const GLfloat texcoord[4], const struct gl_texture_object *texObj = texUnit->_Current; if (texObj) { - const struct gl_texture_image *texImg = - texObj->Image[0][texObj->BaseLevel]; + const struct gl_texture_image *texImg = _mesa_base_tex_image(texObj); const struct swrast_texture_image *swImg = swrast_texture_image_const(texImg); const struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, unit); diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 10aa33c6f83..caea673f2f0 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -39,6 +39,7 @@ #include "main/imports.h" #include "main/image.h" #include "main/samplerobj.h" +#include "main/teximage.h" #include "s_atifragshader.h" #include "s_alpha.h" @@ -495,7 +496,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span) GLfloat q = span->attrStart[attr][3] + span->leftClip * dqdx; if (obj) { - const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel]; + const struct gl_texture_image *img = _mesa_base_tex_image(obj); const struct swrast_texture_image *swImg = swrast_texture_image_const(img); const struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, u); diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index faeccae7c9a..8a1b045c2ff 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -27,8 +27,9 @@ #include "main/context.h" #include "main/colormac.h" #include "main/imports.h" -#include "main/texobj.h" #include "main/samplerobj.h" +#include "main/teximage.h" +#include "main/texobj.h" #include "s_context.h" #include "s_texfilter.h" @@ -1004,7 +1005,7 @@ sample_nearest_1d( struct gl_context *ctx, 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]); @@ -1021,7 +1022,7 @@ sample_linear_1d( struct gl_context *ctx, 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]); @@ -1051,12 +1052,12 @@ sample_lambda_1d( struct gl_context *ctx, 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: @@ -1086,12 +1087,12 @@ sample_lambda_1d( struct gl_context *ctx, 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: @@ -1364,7 +1365,7 @@ sample_nearest_2d(struct gl_context *ctx, 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]); @@ -1381,7 +1382,7 @@ sample_linear_2d(struct gl_context *ctx, 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 && @@ -1415,7 +1416,7 @@ opt_sample_rgb_2d(struct gl_context *ctx, 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; @@ -1460,7 +1461,7 @@ opt_sample_rgba_2d(struct gl_context *ctx, 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; @@ -1498,7 +1499,7 @@ sample_lambda_2d(struct gl_context *ctx, 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 */ @@ -1653,7 +1654,7 @@ sample_2d_ewa(struct gl_context *ctx, 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; @@ -1865,7 +1866,7 @@ sample_lambda_2d_aniso(struct gl_context *ctx, 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; @@ -2232,7 +2233,7 @@ sample_nearest_3d(struct gl_context *ctx, 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]); @@ -2249,7 +2250,7 @@ sample_linear_3d(struct gl_context *ctx, 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]); @@ -2279,12 +2280,12 @@ sample_lambda_3d(struct gl_context *ctx, 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: @@ -2314,12 +2315,12 @@ sample_lambda_3d(struct gl_context *ctx, 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: @@ -3020,7 +3021,7 @@ sample_nearest_2d_array(struct gl_context *ctx, 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]); @@ -3038,7 +3039,7 @@ sample_linear_2d_array(struct gl_context *ctx, 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]); @@ -3068,12 +3069,12 @@ sample_lambda_2d_array(struct gl_context *ctx, 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: @@ -3111,12 +3112,12 @@ sample_lambda_2d_array(struct gl_context *ctx, 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: @@ -3311,7 +3312,7 @@ sample_nearest_1d_array(struct gl_context *ctx, 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]); @@ -3328,7 +3329,7 @@ sample_linear_1d_array(struct gl_context *ctx, 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]); @@ -3358,12 +3359,12 @@ sample_lambda_1d_array(struct gl_context *ctx, 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: @@ -3397,12 +3398,12 @@ sample_lambda_1d_array(struct gl_context *ctx, 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: @@ -3749,7 +3750,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, } 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; diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index 16490664322..1d8e31c2e19 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -37,6 +37,7 @@ #include "main/mtypes.h" #include "main/state.h" #include "main/samplerobj.h" +#include "main/teximage.h" #include "program/prog_instruction.h" #include "s_aatriangle.h" @@ -127,7 +128,7 @@ _swrast_culltriangle( struct gl_context *ctx, const struct gl_texture_object *obj = \ ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ const struct gl_texture_image *texImg = \ - obj->Image[0][obj->BaseLevel]; \ + _mesa_base_tex_image(obj); \ const struct swrast_texture_image *swImg = \ swrast_texture_image_const(texImg); \ const GLfloat twidth = (GLfloat) texImg->Width; \ @@ -185,7 +186,7 @@ _swrast_culltriangle( struct gl_context *ctx, const struct gl_texture_object *obj = \ ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ const struct gl_texture_image *texImg = \ - obj->Image[0][obj->BaseLevel]; \ + _mesa_base_tex_image(obj); \ const struct swrast_texture_image *swImg = \ swrast_texture_image_const(texImg); \ const GLfloat twidth = (GLfloat) texImg->Width; \ @@ -542,7 +543,7 @@ affine_span(struct gl_context *ctx, SWspan *span, const struct gl_texture_object *obj = \ ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ const struct gl_texture_image *texImg = \ - obj->Image[0][obj->BaseLevel]; \ + _mesa_base_tex_image(obj); \ const struct swrast_texture_image *swImg = \ swrast_texture_image_const(texImg); \ const GLfloat twidth = (GLfloat) texImg->Width; \ @@ -811,7 +812,7 @@ fast_persp_span(struct gl_context *ctx, SWspan *span, const struct gl_texture_object *obj = \ ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ const struct gl_texture_image *texImg = \ - obj->Image[0][obj->BaseLevel]; \ + _mesa_base_tex_image(obj); \ const struct swrast_texture_image *swImg = \ swrast_texture_image_const(texImg); \ info.texture = (const GLchan *) swImg->ImageSlices[0]; \ @@ -1059,7 +1060,7 @@ _swrast_choose_triangle( struct gl_context *ctx ) else samp = NULL; - texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL; + texImg = texObj2D ? _mesa_base_tex_image(texObj2D) : NULL; swImg = swrast_texture_image_const(texImg); format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE;