mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 19:50:11 +01:00
mesa: move gl_texture_image::Width/Height/DepthScale fields to swrast
These fields were only used for swrast so move them into swrast_texture_image. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
parent
eaf376ba35
commit
980f6f1b37
7 changed files with 30 additions and 25 deletions
|
|
@ -1254,9 +1254,6 @@ struct gl_texture_image
|
|||
GLuint HeightLog2; /**< = log2(Height2) */
|
||||
GLuint DepthLog2; /**< = log2(Depth2) */
|
||||
GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */
|
||||
GLfloat WidthScale; /**< used for mipmap LOD computation */
|
||||
GLfloat HeightScale; /**< used for mipmap LOD computation */
|
||||
GLfloat DepthScale; /**< used for mipmap LOD computation */
|
||||
GLboolean IsClientData; /**< Data owned by client? */
|
||||
|
||||
struct gl_texture_object *TexObject; /**< Pointer back to parent object */
|
||||
|
|
|
|||
|
|
@ -1172,19 +1172,6 @@ _mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
|
|||
img->ImageOffsets[i] = i * width * height;
|
||||
}
|
||||
|
||||
/* Compute Width/Height/DepthScale for mipmap lod computation */
|
||||
if (target == GL_TEXTURE_RECTANGLE_NV) {
|
||||
/* scale = 1.0 since texture coords directly map to texels */
|
||||
img->WidthScale = 1.0;
|
||||
img->HeightScale = 1.0;
|
||||
img->DepthScale = 1.0;
|
||||
}
|
||||
else {
|
||||
img->WidthScale = (GLfloat) img->Width;
|
||||
img->HeightScale = (GLfloat) img->Height;
|
||||
img->DepthScale = (GLfloat) img->Depth;
|
||||
}
|
||||
|
||||
img->TexFormat = format;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -141,10 +141,10 @@ struct swrast_texture_image
|
|||
|
||||
GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */
|
||||
|
||||
#if 0
|
||||
/** used for mipmap LOD computation */
|
||||
GLfloat WidthScale, HeightScale, DepthScale;
|
||||
|
||||
#if 0
|
||||
GLubyte *Data; /**< The actual texture data in malloc'd memory */
|
||||
|
||||
GLint TexelSize; /**< bytes per texel block */
|
||||
|
|
|
|||
|
|
@ -103,8 +103,10 @@ fetch_texel_deriv( struct gl_context *ctx, const GLfloat texcoord[4],
|
|||
if (texObj) {
|
||||
const struct gl_texture_image *texImg =
|
||||
texObj->Image[0][texObj->BaseLevel];
|
||||
const GLfloat texW = (GLfloat) texImg->WidthScale;
|
||||
const GLfloat texH = (GLfloat) texImg->HeightScale;
|
||||
const struct swrast_texture_image *swImg =
|
||||
swrast_texture_image_const(texImg);
|
||||
const GLfloat texW = (GLfloat) swImg->WidthScale;
|
||||
const GLfloat texH = (GLfloat) swImg->HeightScale;
|
||||
GLfloat lambda;
|
||||
GLfloat rgba[4];
|
||||
|
||||
|
|
|
|||
|
|
@ -490,6 +490,9 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span)
|
|||
|
||||
if (obj) {
|
||||
const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
|
||||
const struct swrast_texture_image *swImg =
|
||||
swrast_texture_image_const(img);
|
||||
|
||||
needLambda = (obj->Sampler.MinFilter != obj->Sampler.MagFilter)
|
||||
|| ctx->FragmentProgram._Current;
|
||||
/* LOD is calculated directly in the ansiotropic filter, we can
|
||||
|
|
@ -499,8 +502,8 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span)
|
|||
obj->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
|
||||
needLambda = GL_FALSE;
|
||||
}
|
||||
texW = img->WidthScale;
|
||||
texH = img->HeightScale;
|
||||
texW = swImg->WidthScale;
|
||||
texH = swImg->HeightScale;
|
||||
}
|
||||
else {
|
||||
/* using a fragment program */
|
||||
|
|
|
|||
|
|
@ -1585,8 +1585,10 @@ sample_2d_ewa(struct gl_context *ctx,
|
|||
const struct gl_texture_image *img = tObj->Image[0][level];
|
||||
const struct gl_texture_image *mostDetailedImage =
|
||||
tObj->Image[0][tObj->BaseLevel];
|
||||
GLfloat tex_u=-0.5 + texcoord[0] * mostDetailedImage->WidthScale * scaling;
|
||||
GLfloat tex_v=-0.5 + texcoord[1] * mostDetailedImage->HeightScale * scaling;
|
||||
const struct swrast_texture_image *swImg =
|
||||
swrast_texture_image_const(mostDetailedImage);
|
||||
GLfloat tex_u=-0.5 + texcoord[0] * swImg->WidthScale * scaling;
|
||||
GLfloat tex_v=-0.5 + texcoord[1] * swImg->HeightScale * scaling;
|
||||
|
||||
GLfloat ux = dudx * scaling;
|
||||
GLfloat vx = dvdx * scaling;
|
||||
|
|
@ -1793,6 +1795,7 @@ sample_lambda_2d_aniso(struct gl_context *ctx,
|
|||
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;
|
||||
|
||||
|
|
@ -1835,8 +1838,8 @@ sample_lambda_2d_aniso(struct gl_context *ctx,
|
|||
create_filter_table();
|
||||
}
|
||||
|
||||
texW = tImg->WidthScale;
|
||||
texH = tImg->HeightScale;
|
||||
texW = swImg->WidthScale;
|
||||
texH = swImg->HeightScale;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
|
||||
|
|
|
|||
|
|
@ -85,6 +85,19 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
|
|||
else
|
||||
swImg->_IsPowerOfTwo = GL_FALSE;
|
||||
|
||||
/* Compute Width/Height/DepthScale for mipmap lod computation */
|
||||
if (texImage->TexObject->Target == GL_TEXTURE_RECTANGLE_NV) {
|
||||
/* scale = 1.0 since texture coords directly map to texels */
|
||||
swImg->WidthScale = 1.0;
|
||||
swImg->HeightScale = 1.0;
|
||||
swImg->DepthScale = 1.0;
|
||||
}
|
||||
else {
|
||||
swImg->WidthScale = (GLfloat) texImage->Width;
|
||||
swImg->HeightScale = (GLfloat) texImage->Height;
|
||||
swImg->DepthScale = (GLfloat) texImage->Depth;
|
||||
}
|
||||
|
||||
return texImage->Data != NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue