524
524
/* Set the texture environment state. Isn't this nice and clean?
525
525
* The chip will automagically set the texture alpha to 0xff when
526
* the texture format does not include an alpha component. This
526
* the texture format does not include an alpha component. This
527
527
* reduces the amount of special-casing we have to do, alpha-only
528
* textures being a notable exception.
528
* textures being a notable exception. Doesn't work for luminance
529
* textures realized with I8 and ALPHA_IN_MAP not set neither (on r100).
530
531
/* Don't cache these results.
575
579
case GL_TEXTURE0:
576
580
case GL_TEXTURE1:
582
GLuint txunit = srcRGBi - GL_TEXTURE0;
583
if (ctx->Texture.Unit[txunit]._Current->Image[0][0]->_BaseFormat == GL_ALPHA)
584
color_arg[i] = radeon_zero_color[op];
578
586
/* implement ogl 1.4/1.5 core spec here, not specification of
579
587
* GL_ARB_texture_env_crossbar (which would require disabling blending
580
588
* instead of undefined results when referencing not enabled texunit) */
581
color_arg[i] = radeon_texture_color[op][srcRGBi - GL_TEXTURE0];
589
color_arg[i] = radeon_texture_color[op][txunit];
848
865
radeonTexObjPtr texobj )
850
GLuint *cmd = RADEON_DB_STATE( tex[unit] );
867
/* do not use RADEON_DB_STATE to avoid stale texture caches */
868
int *cmd = &rmesa->hw.tex[unit].cmd[TEX_CMD_0];
869
GLuint se_coord_fmt = rmesa->hw.set.cmd[SET_SE_COORDFMT];
871
RADEON_STATECHANGE( rmesa, tex[unit] );
852
873
cmd[TEX_PP_TXFILTER] &= ~TEXOBJ_TXFILTER_MASK;
853
874
cmd[TEX_PP_TXFILTER] |= texobj->pp_txfilter & TEXOBJ_TXFILTER_MASK;
856
877
cmd[TEX_PP_TXOFFSET] = texobj->pp_txoffset;
857
878
cmd[TEX_PP_BORDER_COLOR] = texobj->pp_border_color;
859
if (texobj->base.tObj->Target == GL_TEXTURE_CUBE_MAP) {
860
GLuint *cube_cmd = RADEON_DB_STATE( cube[unit] );
861
GLuint bytesPerFace = texobj->base.totalSize / 6;
862
ASSERT(texobj->base.totalSize % 6 == 0);
864
cube_cmd[CUBE_PP_CUBIC_FACES] = texobj->pp_cubic_faces;
865
/* dont know if this setup conforms to OpenGL..
866
* at least it matches the behavior of mesa software renderer
868
cube_cmd[CUBE_PP_CUBIC_OFFSET_0] = texobj->pp_txoffset; /* right */
869
cube_cmd[CUBE_PP_CUBIC_OFFSET_1] = texobj->pp_txoffset + 1 * bytesPerFace; /* left */
870
cube_cmd[CUBE_PP_CUBIC_OFFSET_2] = texobj->pp_txoffset + 2 * bytesPerFace; /* top */
871
cube_cmd[CUBE_PP_CUBIC_OFFSET_3] = texobj->pp_txoffset + 3 * bytesPerFace; /* bottom */
872
cube_cmd[CUBE_PP_CUBIC_OFFSET_4] = texobj->pp_txoffset + 4 * bytesPerFace; /* front */
873
RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.cube[unit] );
874
cmd[TEX_PP_TXOFFSET] = texobj->pp_txoffset + 5 * bytesPerFace; /* back */
876
else if (texobj->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
880
if (texobj->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
877
881
GLuint *txr_cmd = RADEON_DB_STATE( txr[unit] );
878
882
txr_cmd[TXR_PP_TEX_SIZE] = texobj->pp_txsize; /* NPOT only! */
879
883
txr_cmd[TXR_PP_TEX_PITCH] = texobj->pp_txpitch; /* NPOT only! */
880
884
RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.txr[unit] );
883
RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.tex[unit] );
885
se_coord_fmt |= RADEON_VTX_ST0_NONPARAMETRIC << unit;
888
se_coord_fmt &= ~(RADEON_VTX_ST0_NONPARAMETRIC << unit);
890
if (texobj->base.tObj->Target == GL_TEXTURE_CUBE_MAP) {
891
int *cube_cmd = &rmesa->hw.cube[unit].cmd[CUBE_CMD_0];
892
GLuint bytesPerFace = texobj->base.totalSize / 6;
893
ASSERT(texobj->base.totalSize % 6 == 0);
895
RADEON_STATECHANGE( rmesa, cube[unit] );
896
cube_cmd[CUBE_PP_CUBIC_FACES] = texobj->pp_cubic_faces;
897
/* dont know if this setup conforms to OpenGL..
898
* at least it matches the behavior of mesa software renderer
900
cube_cmd[CUBE_PP_CUBIC_OFFSET_0] = texobj->pp_txoffset; /* right */
901
cube_cmd[CUBE_PP_CUBIC_OFFSET_1] = texobj->pp_txoffset + 1 * bytesPerFace; /* left */
902
cube_cmd[CUBE_PP_CUBIC_OFFSET_2] = texobj->pp_txoffset + 2 * bytesPerFace; /* top */
903
cube_cmd[CUBE_PP_CUBIC_OFFSET_3] = texobj->pp_txoffset + 3 * bytesPerFace; /* bottom */
904
cube_cmd[CUBE_PP_CUBIC_OFFSET_4] = texobj->pp_txoffset + 4 * bytesPerFace; /* front */
905
cmd[TEX_PP_TXOFFSET] = texobj->pp_txoffset + 5 * bytesPerFace; /* back */
909
if (se_coord_fmt != rmesa->hw.set.cmd[SET_SE_COORDFMT]) {
910
RADEON_STATECHANGE( rmesa, set );
911
rmesa->hw.set.cmd[SET_SE_COORDFMT] = se_coord_fmt;
885
914
texobj->dirty_state &= ~(1<<unit);