X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fdri%2Fi915%2Fi830_texstate.c;h=f186faca09d2fa757668b45e35c708057a307724;hb=4df1b986d3e44dc035227054000a1d0e1846ef07;hp=b3bb8837ccadcb943a067d836f0607c402af6ec0;hpb=cd6a31cd4a9ea6deef4778c2eaef2d47240c3a6e;p=mesa.git diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c b/src/mesa/drivers/dri/i915/i830_texstate.c index b3bb8837cca..f186faca09d 100644 --- a/src/mesa/drivers/dri/i915/i830_texstate.c +++ b/src/mesa/drivers/dri/i915/i830_texstate.c @@ -28,17 +28,19 @@ #include "main/mtypes.h" #include "main/enums.h" #include "main/colormac.h" +#include "main/macros.h" +#include "main/samplerobj.h" #include "intel_mipmap_tree.h" #include "intel_tex.h" #include "i830_context.h" #include "i830_reg.h" - +#include "intel_chipset.h" static GLuint -translate_texture_format(GLuint mesa_format, GLuint internal_format) +translate_texture_format(GLuint mesa_format) { switch (mesa_format) { case MESA_FORMAT_L8: @@ -74,7 +76,8 @@ translate_texture_format(GLuint mesa_format, GLuint internal_format) case MESA_FORMAT_RGBA_DXT5: return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5); default: - fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, mesa_format); + fprintf(stderr, "%s: bad image format %s\n", __FUNCTION__, + _mesa_get_format_name(mesa_format)); abort(); return 0; } @@ -110,7 +113,7 @@ translate_wrap_mode(GLenum wrap) * efficient, but this has gotten complex enough that we need * something which is understandable and reliable. */ -static GLboolean +static bool i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) { struct gl_context *ctx = &intel->ctx; @@ -119,12 +122,13 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) struct gl_texture_object *tObj = tUnit->_Current; struct intel_texture_object *intelObj = intel_texture_object(tObj); struct gl_texture_image *firstImage; + struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit); GLuint *state = i830->state.Tex[unit], format, pitch; GLint lodbias; GLubyte border[4]; GLuint dst_x, dst_y; - memset(state, 0, sizeof(state)); + memset(state, 0, sizeof(*state)); /*We need to refcount these. */ @@ -134,27 +138,26 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) } if (!intel_finalize_mipmap_tree(intel, unit)) - return GL_FALSE; + return false; /* Get first image here, since intelObj->firstLevel will get set in * the intel_finalize_mipmap_tree() call above. */ - firstImage = tObj->Image[0][intelObj->firstLevel]; + firstImage = tObj->Image[0][tObj->BaseLevel]; - intel_miptree_get_image_offset(intelObj->mt, intelObj->firstLevel, 0, 0, + intel_miptree_get_image_offset(intelObj->mt, tObj->BaseLevel, 0, &dst_x, &dst_y); - drm_intel_bo_reference(intelObj->mt->region->buffer); - i830->state.tex_buffer[unit] = intelObj->mt->region->buffer; - pitch = intelObj->mt->region->pitch * intelObj->mt->cpp; + drm_intel_bo_reference(intelObj->mt->region->bo); + i830->state.tex_buffer[unit] = intelObj->mt->region->bo; + pitch = intelObj->mt->region->pitch; /* XXX: This calculation is probably broken for tiled images with * a non-page-aligned offset. */ i830->state.tex_offset[unit] = dst_x * intelObj->mt->cpp + dst_y * pitch; - format = translate_texture_format(firstImage->TexFormat, - firstImage->InternalFormat); + format = translate_texture_format(firstImage->TexFormat); state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 | (LOAD_TEXTURE_MAP0 << unit) | 4); @@ -189,8 +192,10 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) { GLuint minFilt, mipFilt, magFilt; + float maxlod; + uint32_t minlod_fixed, maxlod_fixed; - switch (tObj->MinFilter) { + switch (sampler->MinFilter) { case GL_NEAREST: minFilt = FILTER_NEAREST; mipFilt = MIPFILTER_NONE; @@ -216,15 +221,15 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) mipFilt = MIPFILTER_LINEAR; break; default: - return GL_FALSE; + return false; } - if (tObj->MaxAnisotropy > 1.0) { + if (sampler->MaxAnisotropy > 1.0) { minFilt = FILTER_ANISOTROPIC; magFilt = FILTER_ANISOTROPIC; } else { - switch (tObj->MagFilter) { + switch (sampler->MagFilter) { case GL_NEAREST: magFilt = FILTER_NEAREST; break; @@ -232,11 +237,11 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) magFilt = FILTER_LINEAR; break; default: - return GL_FALSE; + return false; } } - lodbias = (int) ((tUnit->LodBias + tObj->LodBias) * 16.0); + lodbias = (int) ((tUnit->LodBias + sampler->LodBias) * 16.0); if (lodbias < -64) lodbias = -64; if (lodbias > 63) @@ -252,24 +257,38 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) state[I830_TEXREG_TM0S3] |= SS2_COLORSPACE_CONVERSION; #endif - state[I830_TEXREG_TM0S3] |= ((intelObj->lastLevel - - intelObj->firstLevel) * - 4) << TM0S3_MIN_MIP_SHIFT; - + /* We get one field with fraction bits for the maximum + * addressable (smallest resolution) LOD. Use it to cover both + * MAX_LEVEL and MAX_LOD. + */ + minlod_fixed = U_FIXED(CLAMP(sampler->MinLod, 0.0, 11), 4); + maxlod = MIN2(sampler->MaxLod, tObj->_MaxLevel - tObj->BaseLevel); + if (intel->intelScreen->deviceID == PCI_CHIP_I855_GM || + intel->intelScreen->deviceID == PCI_CHIP_I865_G) { + maxlod_fixed = U_FIXED(CLAMP(maxlod, 0.0, 11.75), 2); + maxlod_fixed = MAX2(maxlod_fixed, (minlod_fixed + 3) >> 2); + state[I830_TEXREG_TM0S3] |= maxlod_fixed << TM0S3_MIN_MIP_SHIFT; + state[I830_TEXREG_TM0S2] |= TM0S2_LOD_PRECLAMP; + } else { + maxlod_fixed = U_FIXED(CLAMP(maxlod, 0.0, 11), 0); + maxlod_fixed = MAX2(maxlod_fixed, (minlod_fixed + 15) >> 4); + state[I830_TEXREG_TM0S3] |= maxlod_fixed << TM0S3_MIN_MIP_SHIFT_830; + } + state[I830_TEXREG_TM0S3] |= minlod_fixed << TM0S3_MAX_MIP_SHIFT; state[I830_TEXREG_TM0S3] |= ((minFilt << TM0S3_MIN_FILTER_SHIFT) | (mipFilt << TM0S3_MIP_FILTER_SHIFT) | (magFilt << TM0S3_MAG_FILTER_SHIFT)); } { - GLenum ws = tObj->WrapS; - GLenum wt = tObj->WrapT; + GLenum ws = sampler->WrapS; + GLenum wt = sampler->WrapT; /* 3D textures not available on i830 */ if (tObj->Target == GL_TEXTURE_3D) - return GL_FALSE; + return false; state[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD | MAP_UNIT(unit) | @@ -283,22 +302,22 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) } /* convert border color from float to ubyte */ - CLAMPED_FLOAT_TO_UBYTE(border[0], tObj->BorderColor.f[0]); - CLAMPED_FLOAT_TO_UBYTE(border[1], tObj->BorderColor.f[1]); - CLAMPED_FLOAT_TO_UBYTE(border[2], tObj->BorderColor.f[2]); - CLAMPED_FLOAT_TO_UBYTE(border[3], tObj->BorderColor.f[3]); + CLAMPED_FLOAT_TO_UBYTE(border[0], sampler->BorderColor.f[0]); + CLAMPED_FLOAT_TO_UBYTE(border[1], sampler->BorderColor.f[1]); + CLAMPED_FLOAT_TO_UBYTE(border[2], sampler->BorderColor.f[2]); + CLAMPED_FLOAT_TO_UBYTE(border[3], sampler->BorderColor.f[3]); state[I830_TEXREG_TM0S4] = PACK_COLOR_8888(border[3], border[0], border[1], border[2]); - I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(unit), GL_TRUE); + I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(unit), true); /* memcmp was already disabled, but definitely won't work as the * region might now change and that wouldn't be detected: */ I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit)); - return GL_TRUE; + return true; } @@ -308,7 +327,7 @@ void i830UpdateTextureState(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); - GLboolean ok = GL_TRUE; + bool ok = true; GLuint i; for (i = 0; i < I830_TEX_UNITS && ok; i++) { @@ -324,7 +343,7 @@ i830UpdateTextureState(struct intel_context *intel) case 0:{ struct i830_context *i830 = i830_context(&intel->ctx); if (i830->state.active & I830_UPLOAD_TEX(i)) - I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(i), GL_FALSE); + I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(i), false); if (i830->state.tex_buffer[i] != NULL) { drm_intel_bo_unreference(i830->state.tex_buffer[i]); @@ -334,7 +353,7 @@ i830UpdateTextureState(struct intel_context *intel) } case TEXTURE_3D_BIT: default: - ok = GL_FALSE; + ok = false; break; } }