1adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* 2adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellCopyright (C) The Weather Channel, Inc. 2002. All Rights Reserved. 3adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 4adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellThe Weather Channel (TM) funded Tungsten Graphics to develop the 5adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellinitial release of the Radeon 8500 driver under the XFree86 license. 6adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellThis notice must be preserved. 7adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 8adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellPermission is hereby granted, free of charge, to any person obtaining 9adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwella copy of this software and associated documentation files (the 10adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell"Software"), to deal in the Software without restriction, including 11adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellwithout limitation the rights to use, copy, modify, merge, publish, 12adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwelldistribute, sublicense, and/or sell copies of the Software, and to 13adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellpermit persons to whom the Software is furnished to do so, subject to 14adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellthe following conditions: 15adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 16adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellThe above copyright notice and this permission notice (including the 17adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellnext paragraph) shall be included in all copies or substantial 18adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellportions of the Software. 19adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 20adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellIN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 24adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell*/ 28adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 29adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* 30adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * Authors: 31877128505431adaf817dc8069172ebe4a1cdf5d8José Fonseca * Keith Whitwell <keithw@vmware.com> 32adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */ 33adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 34ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/glheader.h" 35ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/imports.h" 36ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/context.h" 37ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/enums.h" 38ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/image.h" 39ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/teximage.h" 40ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/texobj.h" 416f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen#include "main/samplerobj.h" 42ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul 4361bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie#include "radeon_mipmap_tree.h" 44adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#include "r200_context.h" 45adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#include "r200_ioctl.h" 46adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#include "r200_tex.h" 47adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 48d907a75498360fb96ec2314bb0abb105be74d500Alan Hourihane#include "xmlpool.h" 49d907a75498360fb96ec2314bb0abb105be74d500Alan Hourihane 50adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 51adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 52adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/** 53adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * Set the texture wrap modes. 54adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * 55adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * \param t Texture object whose wrap modes are to be set 56adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * \param swrap Wrap mode for the \a s texture coordinate 57adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * \param twrap Wrap mode for the \a t texture coordinate 58adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */ 59adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 60692ca82116485a9c6191e5265c5b369d5b4f82f3Dave Airliestatic void r200SetTexWrap( radeonTexObjPtr t, GLenum swrap, GLenum twrap, GLenum rwrap ) 61adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell{ 62adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell GLboolean is_clamp = GL_FALSE; 63adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell GLboolean is_clamp_to_border = GL_FALSE; 6461bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie struct gl_texture_object *tObj = &t->base; 65adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 66198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen radeon_print(RADEON_TEXTURE, RADEON_TRACE, 67198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen "%s(tex %p) sw %s, tw %s, rw %s\n", 68198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen __func__, t, 692f11e92cef51c88a09bc778e2ceca4ab50cf0017Kenneth Graunke _mesa_enum_to_string(swrap), 702f11e92cef51c88a09bc778e2ceca4ab50cf0017Kenneth Graunke _mesa_enum_to_string(twrap), 712f11e92cef51c88a09bc778e2ceca4ab50cf0017Kenneth Graunke _mesa_enum_to_string(rwrap)); 72198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen 73adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter &= ~(R200_CLAMP_S_MASK | R200_CLAMP_T_MASK | R200_BORDER_MODE_D3D); 74adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 75adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell switch ( swrap ) { 76adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_REPEAT: 77adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_CLAMP_S_WRAP; 78adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 79adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_CLAMP: 80adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_CLAMP_S_CLAMP_GL; 81adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell is_clamp = GL_TRUE; 82adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 83adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_CLAMP_TO_EDGE: 84adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_CLAMP_S_CLAMP_LAST; 85adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 86adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_CLAMP_TO_BORDER: 87adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_CLAMP_S_CLAMP_GL; 88adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell is_clamp_to_border = GL_TRUE; 89adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 90adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_MIRRORED_REPEAT: 91adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_CLAMP_S_MIRROR; 92adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 93e54f2601707a54be8869fb3b0be26503d1c9916eIan Romanick case GL_MIRROR_CLAMP_EXT: 94adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_CLAMP_S_MIRROR_CLAMP_GL; 95adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell is_clamp = GL_TRUE; 96adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 97e54f2601707a54be8869fb3b0be26503d1c9916eIan Romanick case GL_MIRROR_CLAMP_TO_EDGE_EXT: 98adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_CLAMP_S_MIRROR_CLAMP_LAST; 99adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 100e54f2601707a54be8869fb3b0be26503d1c9916eIan Romanick case GL_MIRROR_CLAMP_TO_BORDER_EXT: 101e54f2601707a54be8869fb3b0be26503d1c9916eIan Romanick t->pp_txfilter |= R200_CLAMP_S_MIRROR_CLAMP_GL; 102e54f2601707a54be8869fb3b0be26503d1c9916eIan Romanick is_clamp_to_border = GL_TRUE; 103e54f2601707a54be8869fb3b0be26503d1c9916eIan Romanick break; 104adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell default: 105d8b14a57a98f4bad6528eda8dd1406c15bdcce75Marius Predut _mesa_problem(NULL, "bad S wrap mode in %s", __func__); 106adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 107adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 10861bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie if (tObj->Target != GL_TEXTURE_1D) { 10985e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle switch ( twrap ) { 11085e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle case GL_REPEAT: 11185e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle t->pp_txfilter |= R200_CLAMP_T_WRAP; 11285e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle break; 11385e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle case GL_CLAMP: 11485e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle t->pp_txfilter |= R200_CLAMP_T_CLAMP_GL; 11585e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle is_clamp = GL_TRUE; 11685e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle break; 11785e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle case GL_CLAMP_TO_EDGE: 11885e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle t->pp_txfilter |= R200_CLAMP_T_CLAMP_LAST; 11985e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle break; 12085e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle case GL_CLAMP_TO_BORDER: 12185e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle t->pp_txfilter |= R200_CLAMP_T_CLAMP_GL; 12285e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle is_clamp_to_border = GL_TRUE; 12385e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle break; 12485e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle case GL_MIRRORED_REPEAT: 12585e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle t->pp_txfilter |= R200_CLAMP_T_MIRROR; 12685e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle break; 12785e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle case GL_MIRROR_CLAMP_EXT: 12885e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle t->pp_txfilter |= R200_CLAMP_T_MIRROR_CLAMP_GL; 12985e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle is_clamp = GL_TRUE; 13085e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle break; 13185e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle case GL_MIRROR_CLAMP_TO_EDGE_EXT: 13285e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle t->pp_txfilter |= R200_CLAMP_T_MIRROR_CLAMP_LAST; 13385e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle break; 13485e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle case GL_MIRROR_CLAMP_TO_BORDER_EXT: 13585e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle t->pp_txfilter |= R200_CLAMP_T_MIRROR_CLAMP_GL; 13685e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle is_clamp_to_border = GL_TRUE; 13785e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle break; 13885e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle default: 139d8b14a57a98f4bad6528eda8dd1406c15bdcce75Marius Predut _mesa_problem(NULL, "bad T wrap mode in %s", __func__); 14085e44fcd51b2f2e0bb0c97161fdde1971767eefdNicolai Hähnle } 141adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 142adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 143adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txformat_x &= ~R200_CLAMP_Q_MASK; 144adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 145adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell switch ( rwrap ) { 146adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_REPEAT: 147adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txformat_x |= R200_CLAMP_Q_WRAP; 148adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 149adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_CLAMP: 150adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txformat_x |= R200_CLAMP_Q_CLAMP_GL; 151adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell is_clamp = GL_TRUE; 152adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 153adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_CLAMP_TO_EDGE: 154adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txformat_x |= R200_CLAMP_Q_CLAMP_LAST; 155adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 156adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_CLAMP_TO_BORDER: 157adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txformat_x |= R200_CLAMP_Q_CLAMP_GL; 158adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell is_clamp_to_border = GL_TRUE; 159adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 160adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_MIRRORED_REPEAT: 161adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txformat_x |= R200_CLAMP_Q_MIRROR; 162adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 163e54f2601707a54be8869fb3b0be26503d1c9916eIan Romanick case GL_MIRROR_CLAMP_EXT: 164adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_GL; 165adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell is_clamp = GL_TRUE; 166adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 167e54f2601707a54be8869fb3b0be26503d1c9916eIan Romanick case GL_MIRROR_CLAMP_TO_EDGE_EXT: 168adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_LAST; 169adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 170e54f2601707a54be8869fb3b0be26503d1c9916eIan Romanick case GL_MIRROR_CLAMP_TO_BORDER_EXT: 171e54f2601707a54be8869fb3b0be26503d1c9916eIan Romanick t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_GL; 172e54f2601707a54be8869fb3b0be26503d1c9916eIan Romanick is_clamp_to_border = GL_TRUE; 173e54f2601707a54be8869fb3b0be26503d1c9916eIan Romanick break; 174adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell default: 175d8b14a57a98f4bad6528eda8dd1406c15bdcce75Marius Predut _mesa_problem(NULL, "bad R wrap mode in %s", __func__); 176adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 177adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 178adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell if ( is_clamp_to_border ) { 179adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_BORDER_MODE_D3D; 180adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 181adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 182adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->border_fallback = (is_clamp && is_clamp_to_border); 183adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell} 184adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 185692ca82116485a9c6191e5265c5b369d5b4f82f3Dave Airliestatic void r200SetTexMaxAnisotropy( radeonTexObjPtr t, GLfloat max ) 186adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell{ 187adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter &= ~R200_MAX_ANISO_MASK; 188198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen radeon_print(RADEON_TEXTURE, RADEON_TRACE, 189198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen "%s(tex %p) max %f.\n", 190198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen __func__, t, max); 191adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 1928452814ec6f536fc4177e6c34ff5b8b6d3102a3aChristoph Brill if ( max <= 1.0 ) { 193adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MAX_ANISO_1_TO_1; 194adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } else if ( max <= 2.0 ) { 195adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MAX_ANISO_2_TO_1; 196adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } else if ( max <= 4.0 ) { 197adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MAX_ANISO_4_TO_1; 198adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } else if ( max <= 8.0 ) { 199adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MAX_ANISO_8_TO_1; 200adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } else { 201adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MAX_ANISO_16_TO_1; 202adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 203adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell} 204adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 205adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/** 206adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * Set the texture magnification and minification modes. 207adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * 208adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * \param t Texture whose filter modes are to be set 209adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * \param minf Texture minification mode 210adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * \param magf Texture magnification mode 211adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */ 212adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 213692ca82116485a9c6191e5265c5b369d5b4f82f3Dave Airliestatic void r200SetTexFilter( radeonTexObjPtr t, GLenum minf, GLenum magf ) 214adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell{ 215adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell GLuint anisotropy = (t->pp_txfilter & R200_MAX_ANISO_MASK); 216adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 217d2fa89140ebc5cfdd93dcb37d6106e78b01c34d8Dave Airlie /* Force revalidation to account for switches from/to mipmapping. */ 218d2fa89140ebc5cfdd93dcb37d6106e78b01c34d8Dave Airlie t->validated = GL_FALSE; 219d2fa89140ebc5cfdd93dcb37d6106e78b01c34d8Dave Airlie 220adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter &= ~(R200_MIN_FILTER_MASK | R200_MAG_FILTER_MASK); 221adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txformat_x &= ~R200_VOLUME_FILTER_MASK; 222adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 223198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen radeon_print(RADEON_TEXTURE, RADEON_TRACE, 224198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen "%s(tex %p) minf %s, maxf %s, anisotropy %d.\n", 225198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen __func__, t, 2262f11e92cef51c88a09bc778e2ceca4ab50cf0017Kenneth Graunke _mesa_enum_to_string(minf), 2272f11e92cef51c88a09bc778e2ceca4ab50cf0017Kenneth Graunke _mesa_enum_to_string(magf), 228198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen anisotropy); 229198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen 230adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell if ( anisotropy == R200_MAX_ANISO_1_TO_1 ) { 231adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell switch ( minf ) { 232adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_NEAREST: 233adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MIN_FILTER_NEAREST; 234adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 235adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_LINEAR: 236adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MIN_FILTER_LINEAR; 237adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 238adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_NEAREST_MIPMAP_NEAREST: 239adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MIN_FILTER_NEAREST_MIP_NEAREST; 240adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 241adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_NEAREST_MIPMAP_LINEAR: 242adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MIN_FILTER_LINEAR_MIP_NEAREST; 243adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 244adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_LINEAR_MIPMAP_NEAREST: 245adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MIN_FILTER_NEAREST_MIP_LINEAR; 246adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 247adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_LINEAR_MIPMAP_LINEAR: 248adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MIN_FILTER_LINEAR_MIP_LINEAR; 249adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 250adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 251adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } else { 252adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell switch ( minf ) { 253adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_NEAREST: 254adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MIN_FILTER_ANISO_NEAREST; 255adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 256adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_LINEAR: 257adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MIN_FILTER_ANISO_LINEAR; 258adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 259adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_NEAREST_MIPMAP_NEAREST: 260adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_LINEAR_MIPMAP_NEAREST: 261adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST; 262adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 263adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_NEAREST_MIPMAP_LINEAR: 264adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_LINEAR_MIPMAP_LINEAR: 265adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR; 266adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 267adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 268adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 269adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 270adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell /* Note we don't have 3D mipmaps so only use the mag filter setting 271adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * to set the 3D texture filter mode. 272adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */ 273adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell switch ( magf ) { 274adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_NEAREST: 275adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MAG_FILTER_NEAREST; 276adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txformat_x |= R200_VOLUME_FILTER_NEAREST; 277adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 278adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_LINEAR: 279adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txfilter |= R200_MAG_FILTER_LINEAR; 280adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell t->pp_txformat_x |= R200_VOLUME_FILTER_LINEAR; 281adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 282adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 283adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell} 284adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 285d1a9b1f513109c975a5a7ed5a2d0c329b280afe4Dave Airliestatic void r200SetTexBorderColor( radeonTexObjPtr t, const GLfloat color[4] ) 286adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell{ 28779c55e55f808d77cb0dff7cda826719d5fda3c7dBrian Paul GLubyte c[4]; 28879c55e55f808d77cb0dff7cda826719d5fda3c7dBrian Paul CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); 28979c55e55f808d77cb0dff7cda826719d5fda3c7dBrian Paul CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); 29079c55e55f808d77cb0dff7cda826719d5fda3c7dBrian Paul CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); 29179c55e55f808d77cb0dff7cda826719d5fda3c7dBrian Paul CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); 292692ca82116485a9c6191e5265c5b369d5b4f82f3Dave Airlie t->pp_border_color = radeonPackColor( 4, c[0], c[1], c[2], c[3] ); 293adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell} 294adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 295f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergstatic void r200TexEnv( struct gl_context *ctx, GLenum target, 296adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell GLenum pname, const GLfloat *param ) 297adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell{ 298adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell r200ContextPtr rmesa = R200_CONTEXT(ctx); 299adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell GLuint unit = ctx->Texture.CurrentUnit; 300adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; 301adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 302198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen radeon_print(RADEON_TEXTURE | RADEON_STATE, RADEON_VERBOSE, "%s( %s )\n", 3032f11e92cef51c88a09bc778e2ceca4ab50cf0017Kenneth Graunke __func__, _mesa_enum_to_string( pname ) ); 304adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 305adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell /* This is incorrect: Need to maintain this data for each of 306adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * GL_TEXTURE_{123}D, GL_TEXTURE_RECTANGLE_NV, etc, and switch 307741f5d58e649cbc35c0d8661616f4e718b4718f0Eric Anholt * between them according to _Current->Target. 308adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */ 309adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell switch ( pname ) { 310adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_TEXTURE_ENV_COLOR: { 311adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell GLubyte c[4]; 312adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell GLuint envColor; 3138530d72c4e6ca8b8c741554ac446dd2ba8150e2eBrian Paul _mesa_unclamped_float_rgba_to_ubyte(c, texUnit->EnvColor); 314692ca82116485a9c6191e5265c5b369d5b4f82f3Dave Airlie envColor = radeonPackColor( 4, c[0], c[1], c[2], c[3] ); 315adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell if ( rmesa->hw.tf.cmd[TF_TFACTOR_0 + unit] != envColor ) { 316adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell R200_STATECHANGE( rmesa, tf ); 317adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell rmesa->hw.tf.cmd[TF_TFACTOR_0 + unit] = envColor; 318adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 319adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 320adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 321adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 322adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_TEXTURE_LOD_BIAS_EXT: { 323effc73931f86c7961b4eb296d2d4c5d91624a9e3Felix Kuehling GLfloat bias, min; 324adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell GLuint b; 32576a9831b2b20d59c49b5f25ba5275f17b4e2067bPauli Nieminen const int fixed_one = R200_LOD_BIAS_FIXED_ONE; 326adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 327adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell /* The R200's LOD bias is a signed 2's complement value with a 328adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * range of -16.0 <= bias < 16.0. 329adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * 330adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * NOTE: Add a small bias to the bias for conform mipsel.c test. 331adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */ 33276a9831b2b20d59c49b5f25ba5275f17b4e2067bPauli Nieminen bias = *param; 3334637235183b80963536f2364e4d50fcb894886ddDave Airlie min = driQueryOptionb (&rmesa->radeon.optionCache, "no_neg_lod_bias") ? 334effc73931f86c7961b4eb296d2d4c5d91624a9e3Felix Kuehling 0.0 : -16.0; 335effc73931f86c7961b4eb296d2d4c5d91624a9e3Felix Kuehling bias = CLAMP( bias, min, 16.0 ); 33676a9831b2b20d59c49b5f25ba5275f17b4e2067bPauli Nieminen b = ((int)(bias * fixed_one) 33776a9831b2b20d59c49b5f25ba5275f17b4e2067bPauli Nieminen + R200_LOD_BIAS_CORRECTION) & R200_LOD_BIAS_MASK; 338adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 339adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell if ( (rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT_X] & R200_LOD_BIAS_MASK) != b ) { 340adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell R200_STATECHANGE( rmesa, tex[unit] ); 341adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT_X] &= ~R200_LOD_BIAS_MASK; 342adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT_X] |= b; 343adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 344adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 345adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 346cb977ae5f4c9fab5753c04bfdd8736978ad4feeeRoland Scheidegger case GL_COORD_REPLACE_ARB: 347cb977ae5f4c9fab5753c04bfdd8736978ad4feeeRoland Scheidegger if (ctx->Point.PointSprite) { 348cb977ae5f4c9fab5753c04bfdd8736978ad4feeeRoland Scheidegger R200_STATECHANGE( rmesa, spr ); 349cb977ae5f4c9fab5753c04bfdd8736978ad4feeeRoland Scheidegger if ((GLenum)param[0]) { 350cb977ae5f4c9fab5753c04bfdd8736978ad4feeeRoland Scheidegger rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] |= R200_PS_GEN_TEX_0 << unit; 351cb977ae5f4c9fab5753c04bfdd8736978ad4feeeRoland Scheidegger } else { 352cb977ae5f4c9fab5753c04bfdd8736978ad4feeeRoland Scheidegger rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] &= ~(R200_PS_GEN_TEX_0 << unit); 353cb977ae5f4c9fab5753c04bfdd8736978ad4feeeRoland Scheidegger } 354cb977ae5f4c9fab5753c04bfdd8736978ad4feeeRoland Scheidegger } 355cb977ae5f4c9fab5753c04bfdd8736978ad4feeeRoland Scheidegger break; 356adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell default: 357adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell return; 358adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 359adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell} 360adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 3616f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminenvoid r200TexUpdateParameters(struct gl_context *ctx, GLuint unit) 3626f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen{ 3636f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, unit); 3646f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen radeonTexObj* t = radeon_tex_obj(ctx->Texture.Unit[unit]._Current); 3656f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen 3666f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen r200SetTexMaxAnisotropy(t , samp->MaxAnisotropy); 3676f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen r200SetTexFilter(t, samp->MinFilter, samp->MagFilter); 3686f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen r200SetTexWrap(t, samp->WrapS, samp->WrapT, samp->WrapR); 3696f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen r200SetTexBorderColor(t, samp->BorderColor.f); 3706f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen} 371adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 372adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/** 373adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * Changes variables and flags for a state update, which will happen at the 374adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * next UpdateTextureState 375adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */ 376a710c21ac200fc1c80a6209862e837f0a75f4cc5Brian Paulstatic void r200TexParameter(struct gl_context *ctx, 377a710c21ac200fc1c80a6209862e837f0a75f4cc5Brian Paul struct gl_texture_object *texObj, 378a710c21ac200fc1c80a6209862e837f0a75f4cc5Brian Paul GLenum pname) 379adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell{ 38061bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie radeonTexObj* t = radeon_tex_obj(texObj); 381adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 382198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen radeon_print(RADEON_TEXTURE | RADEON_STATE, RADEON_VERBOSE, 383deb9dd6e27956c2f9d9402fe70f0ca7bfa529450Brian Paul "%s(%p, tex %p) pname %s\n", 384d8b14a57a98f4bad6528eda8dd1406c15bdcce75Marius Predut __func__, ctx, texObj, 3852f11e92cef51c88a09bc778e2ceca4ab50cf0017Kenneth Graunke _mesa_enum_to_string( pname ) ); 386adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 387adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell switch ( pname ) { 388adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_TEXTURE_MIN_FILTER: 389adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_TEXTURE_MAG_FILTER: 390adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_TEXTURE_MAX_ANISOTROPY_EXT: 391adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_TEXTURE_WRAP_S: 392adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_TEXTURE_WRAP_T: 393adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_TEXTURE_WRAP_R: 394adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_TEXTURE_BORDER_COLOR: 395adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_TEXTURE_BASE_LEVEL: 396adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_TEXTURE_MAX_LEVEL: 397adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_TEXTURE_MIN_LOD: 398adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell case GL_TEXTURE_MAX_LOD: 399afe84fa698eae3e035e967589f0a8d55f6a83698Maciej Cencora t->validated = GL_FALSE; 400adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell break; 401adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 402adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell default: 403adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell return; 404adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 405adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell} 406adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 407adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 408f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergstatic void r200DeleteTexture(struct gl_context * ctx, struct gl_texture_object *texObj) 409adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell{ 410adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell r200ContextPtr rmesa = R200_CONTEXT(ctx); 41161bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie radeonTexObj* t = radeon_tex_obj(texObj); 41261bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie 413198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen radeon_print(RADEON_TEXTURE | RADEON_STATE, RADEON_NORMAL, 414d8b14a57a98f4bad6528eda8dd1406c15bdcce75Marius Predut "%s( %p (target = %s) )\n", __func__, 415198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen (void *)texObj, 4162f11e92cef51c88a09bc778e2ceca4ab50cf0017Kenneth Graunke _mesa_enum_to_string(texObj->Target)); 417afe84fa698eae3e035e967589f0a8d55f6a83698Maciej Cencora 41861bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie if (rmesa) { 41961bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie int i; 4201090d206de011a67d236d8c4ae32d2d42b2f6337Dave Airlie radeon_firevertices(&rmesa->radeon); 4215a63634a136caa905e7a1fa5da8fe5dc9f26add5Brian Paul for ( i = 0 ; i < rmesa->radeon.glCtx.Const.MaxTextureUnits ; i++ ) { 42261bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie if ( t == rmesa->state.texture.unit[i].texobj ) { 42361bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie rmesa->state.texture.unit[i].texobj = NULL; 42461bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie rmesa->hw.tex[i].dirty = GL_FALSE; 42561bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie rmesa->hw.cube[i].dirty = GL_FALSE; 42661bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie } 42761bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie } 428adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell } 429afe84fa698eae3e035e967589f0a8d55f6a83698Maciej Cencora 430afe84fa698eae3e035e967589f0a8d55f6a83698Maciej Cencora radeon_miptree_unreference(&t->mt); 431afe84fa698eae3e035e967589f0a8d55f6a83698Maciej Cencora 4328bc3ce92a2fa1b8b4ae2b928d4102389f2298917Brian Paul _mesa_delete_texture_object(ctx, texObj); 433adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell} 434adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 435adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* Need: 436adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * - Same GEN_MODE for all active bits 437adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * - Same EyePlane/ObjPlane for all active bits when using Eye/Obj 438adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * - STRQ presumably all supported (matrix means incoming R values 439adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * can end up in STQ, this has implications for vertex support, 440adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * presumably ok if maos is used, though?) 441adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * 442adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * Basically impossible to do this on the fly - just collect some 443adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * basic info & do the checks from ValidateState(). 444adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */ 445f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergstatic void r200TexGen( struct gl_context *ctx, 446adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell GLenum coord, 447adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell GLenum pname, 448adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell const GLfloat *params ) 449adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell{ 450adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell r200ContextPtr rmesa = R200_CONTEXT(ctx); 451adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell GLuint unit = ctx->Texture.CurrentUnit; 452adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell rmesa->recheck_texgen[unit] = GL_TRUE; 453adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell} 454adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 455effc73931f86c7961b4eb296d2d4c5d91624a9e3Felix Kuehling 456d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul/** 457d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul * Allocate a new texture object. 458d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul * Called via ctx->Driver.NewTextureObject. 459d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul * Note: this function will be called during context creation to 460d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul * allocate the default texture objects. 461d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul * Fixup MaxAnisotropy according to user preference. 462d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul */ 463f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergstatic struct gl_texture_object *r200NewTextureObject(struct gl_context * ctx, 46461bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie GLuint name, 46561bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie GLenum target) 466adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell{ 467adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell r200ContextPtr rmesa = R200_CONTEXT(ctx); 46861bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie radeonTexObj* t = CALLOC_STRUCT(radeon_tex_obj); 46961bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie 47061bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie 471198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen radeon_print(RADEON_STATE | RADEON_TEXTURE, RADEON_NORMAL, 472198e810a200eab06c662888c7ec85ae2459ec85aPauli Nieminen "%s(%p) target %s, new texture %p.\n", 473d8b14a57a98f4bad6528eda8dd1406c15bdcce75Marius Predut __func__, ctx, 4742f11e92cef51c88a09bc778e2ceca4ab50cf0017Kenneth Graunke _mesa_enum_to_string(target), t); 47561bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie 476a6b1a7c0d269256ffbaf2300710601cde8ac872cMarek Olšák _mesa_initialize_texture_object(ctx, &t->base, name, target); 477ecfaab88b2577bd0395bc05d75a036126806a9c4Brian Paul t->base.Sampler.MaxAnisotropy = rmesa->radeon.initialMaxAnisotropy; 47861bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie 47961bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie /* Initialize hardware state */ 480ecfaab88b2577bd0395bc05d75a036126806a9c4Brian Paul r200SetTexWrap( t, t->base.Sampler.WrapS, t->base.Sampler.WrapT, t->base.Sampler.WrapR ); 481ecfaab88b2577bd0395bc05d75a036126806a9c4Brian Paul r200SetTexMaxAnisotropy( t, t->base.Sampler.MaxAnisotropy ); 482ecfaab88b2577bd0395bc05d75a036126806a9c4Brian Paul r200SetTexFilter(t, t->base.Sampler.MinFilter, t->base.Sampler.MagFilter); 483ecfaab88b2577bd0395bc05d75a036126806a9c4Brian Paul r200SetTexBorderColor(t, t->base.Sampler.BorderColor.f); 48461bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie 48561bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie return &t->base; 486d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul} 487adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 4886f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminenstatic struct gl_sampler_object * 4896f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminenr200NewSamplerObject(struct gl_context *ctx, GLuint name) 4906f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen{ 4916f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen r200ContextPtr rmesa = R200_CONTEXT(ctx); 4926f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen struct gl_sampler_object *samp = _mesa_new_sampler_object(ctx, name); 4936f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen if (samp) 4946f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen samp->MaxAnisotropy = rmesa->radeon.initialMaxAnisotropy; 4956f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen return samp; 4966f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen} 4976f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen 498adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell 49961bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie 5002706bc6a8898c7d7e155440cfa793035e56186b8Maciej Cencoravoid r200InitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *functions ) 501d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul{ 502d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul /* Note: we only plug in the functions we implement in the driver 503d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul * since _mesa_init_driver_functions() was already called. 504d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul */ 505ff68e3d30415712e0c3d36dc48b47345c852da01Eric Anholt 506ff68e3d30415712e0c3d36dc48b47345c852da01Eric Anholt radeon_init_common_texture_funcs(radeon, functions); 507ff68e3d30415712e0c3d36dc48b47345c852da01Eric Anholt 508d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul functions->NewTextureObject = r200NewTextureObject; 50961bb82636f7b1681b5509e1a9038bbcc1feea35cDave Airlie // functions->BindTexture = r200BindTexture; 510d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul functions->DeleteTexture = r200DeleteTexture; 511d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul 512d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul functions->TexEnv = r200TexEnv; 513d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul functions->TexParameter = r200TexParameter; 514d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul functions->TexGen = r200TexGen; 5156f6bd8aedcf2b2f0e1ca9a1fa7ded1cb1f5a88edPauli Nieminen functions->NewSamplerObject = r200NewSamplerObject; 516adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell} 517