static void r300SetTexWrap(r300TexObjPtr t, GLenum swrap, GLenum twrap,
GLenum rwrap)
{
- GLboolean is_clamp = GL_FALSE;
- GLboolean is_clamp_to_border = GL_FALSE;
+ unsigned long hw_swrap=0, hw_twrap=0, hw_qwrap=0;
t->filter &=
- ~(R200_CLAMP_S_MASK | R200_CLAMP_T_MASK | R200_BORDER_MODE_D3D);
+ ~(R300_TX_WRAP_S_MASK | R300_TX_WRAP_T_MASK | R300_TX_WRAP_Q_MASK);
switch (swrap) {
case GL_REPEAT:
- t->filter |= R200_CLAMP_S_WRAP;
+ hw_swrap |= R300_TX_REPEAT;
break;
case GL_CLAMP:
- t->filter |= R200_CLAMP_S_CLAMP_GL;
- is_clamp = GL_TRUE;
+ hw_swrap |= R300_TX_CLAMP;
break;
case GL_CLAMP_TO_EDGE:
- t->filter |= R200_CLAMP_S_CLAMP_LAST;
+ hw_swrap |= R300_TX_CLAMP_TO_EDGE;
break;
case GL_CLAMP_TO_BORDER:
- t->filter |= R200_CLAMP_S_CLAMP_GL;
- is_clamp_to_border = GL_TRUE;
+ hw_swrap |= R300_TX_CLAMP_TO_BORDER;
break;
case GL_MIRRORED_REPEAT:
- t->filter |= R200_CLAMP_S_MIRROR;
+ hw_swrap |= R300_TX_REPEAT | R300_TX_MIRRORED;
break;
case GL_MIRROR_CLAMP_EXT:
- t->filter |= R200_CLAMP_S_MIRROR_CLAMP_GL;
- is_clamp = GL_TRUE;
+ hw_swrap |= R300_TX_CLAMP | R300_TX_MIRRORED;
break;
case GL_MIRROR_CLAMP_TO_EDGE_EXT:
- t->filter |= R200_CLAMP_S_MIRROR_CLAMP_LAST;
+ hw_swrap |= R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
break;
case GL_MIRROR_CLAMP_TO_BORDER_EXT:
- t->filter |= R200_CLAMP_S_MIRROR_CLAMP_GL;
- is_clamp_to_border = GL_TRUE;
+ hw_swrap |= R300_TX_CLAMP_TO_BORDER | R300_TX_MIRRORED;
break;
default:
_mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__);
switch (twrap) {
case GL_REPEAT:
- t->filter |= R200_CLAMP_T_WRAP;
+ hw_twrap |= R300_TX_REPEAT;
break;
case GL_CLAMP:
- t->filter |= R200_CLAMP_T_CLAMP_GL;
- is_clamp = GL_TRUE;
+ hw_twrap |= R300_TX_CLAMP;
break;
case GL_CLAMP_TO_EDGE:
- t->filter |= R200_CLAMP_T_CLAMP_LAST;
+ hw_twrap |= R300_TX_CLAMP_TO_EDGE;
break;
case GL_CLAMP_TO_BORDER:
- t->filter |= R200_CLAMP_T_CLAMP_GL | R200_BORDER_MODE_D3D;
- is_clamp_to_border = GL_TRUE;
+ hw_twrap |= R300_TX_CLAMP_TO_BORDER;
break;
case GL_MIRRORED_REPEAT:
- t->filter |= R200_CLAMP_T_MIRROR;
+ hw_twrap |= R300_TX_REPEAT | R300_TX_MIRRORED;
break;
case GL_MIRROR_CLAMP_EXT:
- t->filter |= R200_CLAMP_T_MIRROR_CLAMP_GL;
- is_clamp = GL_TRUE;
+ hw_twrap |= R300_TX_CLAMP | R300_TX_MIRRORED;
break;
case GL_MIRROR_CLAMP_TO_EDGE_EXT:
- t->filter |= R200_CLAMP_T_MIRROR_CLAMP_LAST;
+ hw_twrap |= R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
break;
case GL_MIRROR_CLAMP_TO_BORDER_EXT:
- t->filter |= R200_CLAMP_T_MIRROR_CLAMP_GL;
- is_clamp_to_border = GL_TRUE;
+ hw_twrap |= R300_TX_CLAMP_TO_BORDER | R300_TX_MIRRORED;
break;
default:
_mesa_problem(NULL, "bad T wrap mode in %s", __FUNCTION__);
}
- #if 0 /* Which field is this ? */
- t->pp_txformat_x &= ~R200_CLAMP_Q_MASK;
-
switch (rwrap) {
case GL_REPEAT:
- t->pp_txformat_x |= R200_CLAMP_Q_WRAP;
+ hw_qwrap |= R300_TX_REPEAT;
break;
case GL_CLAMP:
- t->pp_txformat_x |= R200_CLAMP_Q_CLAMP_GL;
- is_clamp = GL_TRUE;
+ hw_qwrap |= R300_TX_CLAMP;
break;
case GL_CLAMP_TO_EDGE:
- t->pp_txformat_x |= R200_CLAMP_Q_CLAMP_LAST;
+ hw_qwrap |= R300_TX_CLAMP_TO_EDGE;
break;
case GL_CLAMP_TO_BORDER:
- t->pp_txformat_x |= R200_CLAMP_Q_CLAMP_GL;
- is_clamp_to_border = GL_TRUE;
+ hw_qwrap |= R300_TX_CLAMP_TO_BORDER;
break;
case GL_MIRRORED_REPEAT:
- t->pp_txformat_x |= R200_CLAMP_Q_MIRROR;
+ hw_qwrap |= R300_TX_REPEAT | R300_TX_MIRRORED;
break;
case GL_MIRROR_CLAMP_EXT:
- t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_GL;
- is_clamp = GL_TRUE;
+ hw_qwrap |= R300_TX_CLAMP | R300_TX_MIRRORED;
break;
case GL_MIRROR_CLAMP_TO_EDGE_EXT:
- t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_LAST;
+ hw_qwrap |= R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
break;
case GL_MIRROR_CLAMP_TO_BORDER_EXT:
- t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_GL;
- is_clamp_to_border = GL_TRUE;
+ hw_qwrap |= R300_TX_CLAMP_TO_BORDER | R300_TX_MIRRORED;
break;
default:
_mesa_problem(NULL, "bad R wrap mode in %s", __FUNCTION__);
}
- #endif
-
- if (is_clamp_to_border) {
- t->filter |= R200_BORDER_MODE_D3D;
- }
+ t->filter |= hw_swrap << R300_TX_WRAP_S_SHIFT;
+ t->filter |= hw_twrap << R300_TX_WRAP_T_SHIFT;
+ t->filter |= hw_qwrap << R300_TX_WRAP_Q_SHIFT;
+
+#if 0
+ t->format_x &= ~R200_CLAMP_Q_MASK;
t->border_fallback = (is_clamp && is_clamp_to_border);
+#endif
}
static void r300SetTexMaxAnisotropy(r300TexObjPtr t, GLfloat max)
{
- t->filter &= ~R200_MAX_ANISO_MASK;
- if (max == 1.0) {
- t->filter |= R200_MAX_ANISO_1_TO_1;
+ t->filter &= ~R300_TX_MAX_ANISO_MASK;
+
+ if (max <= 1.0) {
+ t->filter |= R300_TX_MAX_ANISO_1_TO_1;
} else if (max <= 2.0) {
- t->filter |= R200_MAX_ANISO_2_TO_1;
+ t->filter |= R300_TX_MAX_ANISO_2_TO_1;
} else if (max <= 4.0) {
- t->filter |= R200_MAX_ANISO_4_TO_1;
+ t->filter |= R300_TX_MAX_ANISO_4_TO_1;
} else if (max <= 8.0) {
- t->filter |= R200_MAX_ANISO_8_TO_1;
+ t->filter |= R300_TX_MAX_ANISO_8_TO_1;
} else {
- t->filter |= R200_MAX_ANISO_16_TO_1;
+ t->filter |= R300_TX_MAX_ANISO_16_TO_1;
}
}
static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf)
{
- GLuint anisotropy = (t->filter & R200_MAX_ANISO_MASK);
+ GLuint anisotropy = (t->filter & R300_TX_MAX_ANISO_MASK);
- t->filter &= ~(R200_MIN_FILTER_MASK | R200_MAG_FILTER_MASK);
- #if 0
- t->pp_txformat_x &= ~R200_VOLUME_FILTER_MASK;
- #endif
-
- if (anisotropy == R200_MAX_ANISO_1_TO_1) {
+ t->filter &= ~(R300_TX_MIN_FILTER_MASK | R300_TX_MAG_FILTER_MASK);
+#if 0
+ //t->format_x &= ~R200_VOLUME_FILTER_MASK;
+#endif
+
+ if (anisotropy == R300_TX_MAX_ANISO_1_TO_1) {
switch (minf) {
case GL_NEAREST:
- t->filter |= R200_MIN_FILTER_NEAREST;
+ t->filter |= R300_TX_MIN_FILTER_NEAREST;
break;
case GL_LINEAR:
- t->filter |= R200_MIN_FILTER_LINEAR;
+ t->filter |= R300_TX_MIN_FILTER_LINEAR;
break;
case GL_NEAREST_MIPMAP_NEAREST:
- t->filter |= R200_MIN_FILTER_NEAREST_MIP_NEAREST;
+ t->filter |= R300_TX_MIN_FILTER_NEAREST_MIP_NEAREST;
break;
case GL_NEAREST_MIPMAP_LINEAR:
- t->filter |= R200_MIN_FILTER_LINEAR_MIP_NEAREST;
+ t->filter |= R300_TX_MIN_FILTER_NEAREST_MIP_LINEAR;
break;
case GL_LINEAR_MIPMAP_NEAREST:
- t->filter |= R200_MIN_FILTER_NEAREST_MIP_LINEAR;
+ t->filter |= R300_TX_MIN_FILTER_LINEAR_MIP_NEAREST;
break;
case GL_LINEAR_MIPMAP_LINEAR:
- t->filter |= R200_MIN_FILTER_LINEAR_MIP_LINEAR;
+ t->filter |= R300_TX_MIN_FILTER_LINEAR_MIP_LINEAR;
break;
}
} else {
switch (minf) {
case GL_NEAREST:
- t->filter |= R200_MIN_FILTER_ANISO_NEAREST;
+ t->filter |= R300_TX_MIN_FILTER_ANISO_NEAREST;
break;
case GL_LINEAR:
- t->filter |= R200_MIN_FILTER_ANISO_LINEAR;
+ t->filter |= R300_TX_MIN_FILTER_ANISO_LINEAR;
break;
case GL_NEAREST_MIPMAP_NEAREST:
case GL_LINEAR_MIPMAP_NEAREST:
t->filter |=
- R200_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST;
+ R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST;
break;
case GL_NEAREST_MIPMAP_LINEAR:
case GL_LINEAR_MIPMAP_LINEAR:
t->filter |=
- R200_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR;
+ R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR;
break;
}
}
*/
switch (magf) {
case GL_NEAREST:
- t->filter |= R200_MAG_FILTER_NEAREST;
- #if 0
- t->pp_txformat_x |= R200_VOLUME_FILTER_NEAREST;
- #endif
+ t->filter |= R300_TX_MAG_FILTER_NEAREST;
+ /*t->format_x |= R200_VOLUME_FILTER_NEAREST;*/
break;
case GL_LINEAR:
- t->filter |= R200_MAG_FILTER_LINEAR;
- #if 0
- t->pp_txformat_x |= R200_VOLUME_FILTER_LINEAR;
- #endif
+ t->filter |= R300_TX_MAG_FILTER_LINEAR;
+ /*t->format_x |= R200_VOLUME_FILTER_LINEAR;*/
break;
}
}
static void r300SetTexBorderColor(r300TexObjPtr t, GLubyte c[4])
{
- #if 0
- t->pp_border_color = radeonPackColor(4, c[0], c[1], c[2], c[3]);
- #endif
+ t->pp_border_color = r300PackColor(4, c[0], c[1], c[2], c[3]);
}
/**
(rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16);
(void)format;
+#if 0
+ fprintf(stderr, "InternalFormat=%s(%d) type=%s format=%s\n",
+ _mesa_lookup_enum_by_nr(internalFormat), internalFormat,
+ _mesa_lookup_enum_by_nr(type),
+ _mesa_lookup_enum_by_nr(format));
+ fprintf(stderr, "do32bpt=%d force16bpt=%d\n",
+ do32bpt, force16bpt);
+#endif
+
switch (internalFormat) {
case 4:
case GL_RGBA:
else
return &_mesa_texformat_ycbcr_rev;
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgb_dxt1;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgba_dxt1;
+
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ return &_mesa_texformat_rgba_dxt3;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return &_mesa_texformat_rgba_dxt5;
+
default:
_mesa_problem(ctx,
"unexpected internalFormat 0x%x in r300ChooseTextureFormat",
t->dirty_images[face] |= (1 << level);
}
+static void r300CompressedTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ if ( t != NULL ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) r300AllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ return;
+ }
+ }
+
+ texImage->IsClientData = GL_FALSE;
+/* can't call this, different parameters. Would never evaluate to true anyway currently
+ if (r300ValidateClientStorage( ctx, target,
+ internalFormat,
+ width, height,
+ format, type, pixels,
+ packing, texObj, texImage)) {
+ if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using client storage\n", __FUNCTION__);
+ }
+ else */{
+ if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__);
+
+ /* Normal path: copy (to cached memory) and eventually upload
+ * via another copy to GART memory and then a blit... Could
+ * eliminate one copy by going straight to (permanent) GART.
+ *
+ * Note, this will call r300ChooseTextureFormat.
+ */
+ _mesa_store_compressed_teximage2d(ctx, target, level, internalFormat, width,
+ height, border, imageSize, data, texObj, texImage);
+
+ t->dirty_images[face] |= (1 << level);
+ }
+}
+
+
+static void r300CompressedTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) r300AllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3D");
+ return;
+ }
+ }
+
+ _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, imageSize, data, texObj, texImage);
+
+ t->dirty_images[face] |= (1 << level);
+}
+
#if ENABLE_HW_3D_TEXTURE
static void r300TexImage3D(GLcontext * ctx, GLenum target, GLint level,
GLint internalFormat,
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
GLuint unit = ctx->Texture.CurrentUnit;
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
if (RADEON_DEBUG & DEBUG_STATE) {
fprintf(stderr, "%s( %s )\n",
__FUNCTION__, _mesa_lookup_enum_by_nr(pname));
}
- fprintf(stderr, "%s:%s I am broken - Fixme !\n", __FILE__, __FUNCTION__);
-
- #if 0
/* This is incorrect: Need to maintain this data for each of
* GL_TEXTURE_{123}D, GL_TEXTURE_RECTANGLE_NV, etc, and switch
* between them according to _ReallyEnabled.
*/
switch (pname) {
case GL_TEXTURE_ENV_COLOR:{
+ WARN_ONCE("I am broken - Fixme !\n");
+ /*
GLubyte c[4];
GLuint envColor;
UNCLAMPED_FLOAT_TO_RGBA_CHAN(c, texUnit->EnvColor);
R200_STATECHANGE(rmesa, tf);
rmesa->hw.tf.cmd[TF_TFACTOR_0 + unit] =
envColor;
- }
+ }*/
break;
}
case GL_TEXTURE_LOD_BIAS_EXT:{
GLfloat bias, min;
GLuint b;
- const int fixed_one = 0x8000000;
- /* The R200's LOD bias is a signed 2's complement value with a
+ /* The R300's LOD bias is a signed 2's complement value with a
* range of -16.0 <= bias < 16.0.
*
* NOTE: Add a small bias to the bias for conform mipsel.c test.
driQueryOptionb(&rmesa->radeon.optionCache,
"no_neg_lod_bias") ? 0.0 : -16.0;
bias = CLAMP(bias, min, 16.0);
- b = (int)(bias * fixed_one) & R200_LOD_BIAS_MASK;
-
- if ((rmesa->hw.tex[unit].
- cmd[TEX_PP_TXFORMAT_X] & R200_LOD_BIAS_MASK) !=
- b) {
- R200_STATECHANGE(rmesa, tex[unit]);
- rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT_X] &=
- ~R200_LOD_BIAS_MASK;
- rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT_X] |= b;
+
+ /* 0.0 - 16.0 == 0x0 - 0x1000 */
+ /* 0.0 - -16.0 == 0x1001 - 0x1fff */
+ b = 0x1000 / 16.0 * bias;
+ b &= R300_LOD_BIAS_MASK;
+
+ if(b != (rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+unit] & R300_LOD_BIAS_MASK)){
+ R300_STATECHANGE(rmesa, tex.unknown1);
+ rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+unit] &= ~R300_LOD_BIAS_MASK;
+ rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+unit] |= b;
}
break;
}
default:
return;
}
- #endif
}
/**
_mesa_delete_texture_object(ctx, texObj);
}
-/* Need:
- * - Same GEN_MODE for all active bits
- * - Same EyePlane/ObjPlane for all active bits when using Eye/Obj
- * - STRQ presumably all supported (matrix means incoming R values
- * can end up in STQ, this has implications for vertex support,
- * presumably ok if maos is used, though?)
- *
- * Basically impossible to do this on the fly - just collect some
- * basic info & do the checks from ValidateState().
- */
-static void r300TexGen(GLcontext * ctx,
- GLenum coord, GLenum pname, const GLfloat * params)
-{
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- GLuint unit = ctx->Texture.CurrentUnit;
- #if 0 /* Disable this for now - looks like we will be recalculating everything
- anyway */
- rmesa->recheck_texgen[unit] = GL_TRUE;
- #endif
-}
-
/**
* Allocate a new texture object.
* Called via ctx->Driver.NewTextureObject.
if (!obj)
return NULL;
obj->MaxAnisotropy = rmesa->initialMaxAnisotropy;
+
r300AllocTexObj(obj);
return obj;
}
functions->TexEnv = r300TexEnv;
functions->TexParameter = r300TexParameter;
- functions->TexGen = r300TexGen;
+
+ functions->CompressedTexImage2D = r300CompressedTexImage2D;
+ functions->CompressedTexSubImage2D = r300CompressedTexSubImage2D;
driInitTextureFormats();
-#if 000
+#if 0
/* moved or obsolete code */
r300ContextPtr rmesa = R300_CONTEXT(ctx);
driInitTextureObjects(ctx, &rmesa->swapped,