1 | /*
|
---|
2 | * IWineD3DBaseTexture Implementation
|
---|
3 | *
|
---|
4 | * Copyright 2002-2004 Jason Edmeades
|
---|
5 | * Copyright 2002-2004 Raphael Junqueira
|
---|
6 | * Copyright 2005 Oliver Stieber
|
---|
7 | * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
|
---|
8 | *
|
---|
9 | * This library is free software; you can redistribute it and/or
|
---|
10 | * modify it under the terms of the GNU Lesser General Public
|
---|
11 | * License as published by the Free Software Foundation; either
|
---|
12 | * version 2.1 of the License, or (at your option) any later version.
|
---|
13 | *
|
---|
14 | * This library is distributed in the hope that it will be useful,
|
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
17 | * Lesser General Public License for more details.
|
---|
18 | *
|
---|
19 | * You should have received a copy of the GNU Lesser General Public
|
---|
20 | * License along with this library; if not, write to the Free Software
|
---|
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
---|
22 | */
|
---|
23 |
|
---|
24 | /*
|
---|
25 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
26 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
27 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
28 | * a choice of LGPL license versions is made available with the language indicating
|
---|
29 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
30 | * of the LGPL is applied is otherwise unspecified.
|
---|
31 | */
|
---|
32 |
|
---|
33 | #include "config.h"
|
---|
34 | #include "wined3d_private.h"
|
---|
35 |
|
---|
36 | WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
|
---|
37 | #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
|
---|
38 |
|
---|
39 | void basetexture_cleanup(IWineD3DBaseTexture *iface)
|
---|
40 | {
|
---|
41 | IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
---|
42 | IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
|
---|
43 |
|
---|
44 | TRACE("(%p) : textureName(%d)\n", This, This->baseTexture.textureName);
|
---|
45 | if (This->baseTexture.textureName != 0) {
|
---|
46 | ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
|
---|
47 | ENTER_GL();
|
---|
48 | TRACE("(%p) : Deleting texture %d\n", This, This->baseTexture.textureName);
|
---|
49 | glDeleteTextures(1, &This->baseTexture.textureName);
|
---|
50 | LEAVE_GL();
|
---|
51 | }
|
---|
52 |
|
---|
53 | resource_cleanup((IWineD3DResource *)iface);
|
---|
54 | }
|
---|
55 |
|
---|
56 | void basetexture_unload(IWineD3DBaseTexture *iface)
|
---|
57 | {
|
---|
58 | IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
---|
59 | IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
|
---|
60 |
|
---|
61 | if(This->baseTexture.textureName) {
|
---|
62 | ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
|
---|
63 | ENTER_GL();
|
---|
64 | glDeleteTextures(1, &This->baseTexture.textureName);
|
---|
65 | This->baseTexture.textureName = 0;
|
---|
66 | LEAVE_GL();
|
---|
67 | }
|
---|
68 | This->baseTexture.dirty = TRUE;
|
---|
69 | }
|
---|
70 |
|
---|
71 | /* There is no OpenGL equivalent of setLOD, getLOD. All they do anyway is prioritize texture loading
|
---|
72 | * so just pretend that they work unless something really needs a failure. */
|
---|
73 | DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD LODNew)
|
---|
74 | {
|
---|
75 | IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
---|
76 |
|
---|
77 | if (This->resource.pool != WINED3DPOOL_MANAGED) {
|
---|
78 | return WINED3DERR_INVALIDCALL;
|
---|
79 | }
|
---|
80 |
|
---|
81 | if(LODNew >= This->baseTexture.levels)
|
---|
82 | LODNew = This->baseTexture.levels - 1;
|
---|
83 | This->baseTexture.LOD = LODNew;
|
---|
84 |
|
---|
85 | TRACE("(%p) : set bogus LOD to %d\n", This, This->baseTexture.LOD);
|
---|
86 |
|
---|
87 | return This->baseTexture.LOD;
|
---|
88 | }
|
---|
89 |
|
---|
90 | DWORD basetexture_get_lod(IWineD3DBaseTexture *iface)
|
---|
91 | {
|
---|
92 | IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
---|
93 |
|
---|
94 | if (This->resource.pool != WINED3DPOOL_MANAGED) {
|
---|
95 | return WINED3DERR_INVALIDCALL;
|
---|
96 | }
|
---|
97 |
|
---|
98 | TRACE("(%p) : returning %d\n", This, This->baseTexture.LOD);
|
---|
99 |
|
---|
100 | return This->baseTexture.LOD;
|
---|
101 | }
|
---|
102 |
|
---|
103 | DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface)
|
---|
104 | {
|
---|
105 | IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
---|
106 | TRACE("(%p) : returning %d\n", This, This->baseTexture.levels);
|
---|
107 | return This->baseTexture.levels;
|
---|
108 | }
|
---|
109 |
|
---|
110 | HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType)
|
---|
111 | {
|
---|
112 | IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
---|
113 | IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
|
---|
114 | UINT textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
|
---|
115 |
|
---|
116 | if (!(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)) {
|
---|
117 | TRACE("(%p) : returning invalid call\n", This);
|
---|
118 | return WINED3DERR_INVALIDCALL;
|
---|
119 | }
|
---|
120 | if(This->baseTexture.filterType != FilterType) {
|
---|
121 | /* What about multithreading? Do we want all the context overhead just to set this value?
|
---|
122 | * Or should we delay the applying until the texture is used for drawing? For now, apply
|
---|
123 | * immediately.
|
---|
124 | */
|
---|
125 | ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
|
---|
126 | ENTER_GL();
|
---|
127 | glBindTexture(textureDimensions, This->baseTexture.textureName);
|
---|
128 | checkGLcall("glBindTexture");
|
---|
129 | switch(FilterType) {
|
---|
130 | case WINED3DTEXF_NONE:
|
---|
131 | case WINED3DTEXF_POINT:
|
---|
132 | glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST);
|
---|
133 | checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST)");
|
---|
134 |
|
---|
135 | break;
|
---|
136 | case WINED3DTEXF_LINEAR:
|
---|
137 | glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
|
---|
138 | checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST)");
|
---|
139 |
|
---|
140 | break;
|
---|
141 | default:
|
---|
142 | WARN("Unexpected filter type %d, setting to GL_NICEST\n", FilterType);
|
---|
143 | glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
|
---|
144 | checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST)");
|
---|
145 | }
|
---|
146 | LEAVE_GL();
|
---|
147 | }
|
---|
148 | This->baseTexture.filterType = FilterType;
|
---|
149 | TRACE("(%p) :\n", This);
|
---|
150 | return WINED3D_OK;
|
---|
151 | }
|
---|
152 |
|
---|
153 | WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface)
|
---|
154 | {
|
---|
155 | IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
---|
156 | FIXME("(%p) : stub\n", This);
|
---|
157 | if (!(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)) {
|
---|
158 | return WINED3DTEXF_NONE;
|
---|
159 | }
|
---|
160 | return This->baseTexture.filterType;
|
---|
161 | }
|
---|
162 |
|
---|
163 | void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface)
|
---|
164 | {
|
---|
165 | IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
---|
166 | /* TODO: implement filters using GL_SGI_generate_mipmaps http://oss.sgi.com/projects/ogl-sample/registry/SGIS/generate_mipmap.txt */
|
---|
167 | FIXME("(%p) : stub\n", This);
|
---|
168 | return ;
|
---|
169 | }
|
---|
170 |
|
---|
171 | BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty)
|
---|
172 | {
|
---|
173 | BOOL old;
|
---|
174 | IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
---|
175 | old = This->baseTexture.dirty;
|
---|
176 | This->baseTexture.dirty = dirty;
|
---|
177 | return old;
|
---|
178 | }
|
---|
179 |
|
---|
180 | BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface)
|
---|
181 | {
|
---|
182 | IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
---|
183 | return This->baseTexture.dirty;
|
---|
184 | }
|
---|
185 |
|
---|
186 | HRESULT basetexture_bind(IWineD3DBaseTexture *iface)
|
---|
187 | {
|
---|
188 | IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
---|
189 | HRESULT hr = WINED3D_OK;
|
---|
190 | UINT textureDimensions;
|
---|
191 | BOOL isNewTexture = FALSE;
|
---|
192 | TRACE("(%p) : About to bind texture\n", This);
|
---|
193 |
|
---|
194 | textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
|
---|
195 | ENTER_GL();
|
---|
196 | /* Generate a texture name if we don't already have one */
|
---|
197 | if (This->baseTexture.textureName == 0) {
|
---|
198 | glGenTextures(1, &This->baseTexture.textureName);
|
---|
199 | checkGLcall("glGenTextures");
|
---|
200 | TRACE("Generated texture %d\n", This->baseTexture.textureName);
|
---|
201 | if (This->resource.pool == WINED3DPOOL_DEFAULT) {
|
---|
202 | /* Tell opengl to try and keep this texture in video ram (well mostly) */
|
---|
203 | GLclampf tmp;
|
---|
204 | tmp = 0.9f;
|
---|
205 | glPrioritizeTextures(1, &This->baseTexture.textureName, &tmp);
|
---|
206 |
|
---|
207 | }
|
---|
208 | /* Initialise the state of the texture object
|
---|
209 | to the openGL defaults, not the directx defaults */
|
---|
210 | This->baseTexture.states[WINED3DTEXSTA_ADDRESSU] = WINED3DTADDRESS_WRAP;
|
---|
211 | This->baseTexture.states[WINED3DTEXSTA_ADDRESSV] = WINED3DTADDRESS_WRAP;
|
---|
212 | This->baseTexture.states[WINED3DTEXSTA_ADDRESSW] = WINED3DTADDRESS_WRAP;
|
---|
213 | This->baseTexture.states[WINED3DTEXSTA_BORDERCOLOR] = 0;
|
---|
214 | This->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_LINEAR;
|
---|
215 | This->baseTexture.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
|
---|
216 | This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
|
---|
217 | This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL] = 0;
|
---|
218 | This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY] = 0;
|
---|
219 | This->baseTexture.states[WINED3DTEXSTA_SRGBTEXTURE] = 0;
|
---|
220 | This->baseTexture.states[WINED3DTEXSTA_ELEMENTINDEX] = 0;
|
---|
221 | This->baseTexture.states[WINED3DTEXSTA_DMAPOFFSET] = 0;
|
---|
222 | This->baseTexture.states[WINED3DTEXSTA_TSSADDRESSW] = WINED3DTADDRESS_WRAP;
|
---|
223 | IWineD3DBaseTexture_SetDirty(iface, TRUE);
|
---|
224 | isNewTexture = TRUE;
|
---|
225 |
|
---|
226 | if(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP) {
|
---|
227 | /* This means double binding the texture at creation, but keeps the code simpler all
|
---|
228 | * in all, and the run-time path free from additional checks
|
---|
229 | */
|
---|
230 | glBindTexture(textureDimensions, This->baseTexture.textureName);
|
---|
231 | checkGLcall("glBindTexture");
|
---|
232 | glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
|
---|
233 | checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_SGIS, GL_TRUE)");
|
---|
234 | }
|
---|
235 | }
|
---|
236 |
|
---|
237 | /* Bind the texture */
|
---|
238 | if (This->baseTexture.textureName != 0) {
|
---|
239 | glBindTexture(textureDimensions, This->baseTexture.textureName);
|
---|
240 | checkGLcall("glBindTexture");
|
---|
241 | if (isNewTexture) {
|
---|
242 | /* For a new texture we have to set the textures levels after binding the texture.
|
---|
243 | * In theory this is all we should ever have to do, but because ATI's drivers are broken, we
|
---|
244 | * also need to set the texture dimensions before the texture is set
|
---|
245 | * Beware that texture rectangles do not support mipmapping, but set the maxmiplevel if we're
|
---|
246 | * relying on the partial GL_ARB_texture_non_power_of_two emulation with texture rectangles
|
---|
247 | * (ie, do not care for cond_np2 here, just look for GL_TEXTURE_RECTANGLE_ARB)
|
---|
248 | */
|
---|
249 | if(textureDimensions != GL_TEXTURE_RECTANGLE_ARB) {
|
---|
250 | TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->baseTexture.levels - 1);
|
---|
251 | glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1);
|
---|
252 | checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels)");
|
---|
253 | }
|
---|
254 | if(textureDimensions==GL_TEXTURE_CUBE_MAP_ARB) {
|
---|
255 | /* Cubemaps are always set to clamp, regardless of the sampler state. */
|
---|
256 | glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
---|
257 | glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
---|
258 | glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
---|
259 | }
|
---|
260 | }
|
---|
261 |
|
---|
262 | } else { /* this only happened if we've run out of openGL textures */
|
---|
263 | WARN("This texture doesn't have an openGL texture assigned to it\n");
|
---|
264 | hr = WINED3DERR_INVALIDCALL;
|
---|
265 | }
|
---|
266 |
|
---|
267 | LEAVE_GL();
|
---|
268 | return hr;
|
---|
269 | }
|
---|
270 |
|
---|
271 | static inline void apply_wrap(const GLint textureDimensions, const DWORD state, const GLint type,
|
---|
272 | BOOL cond_np2) {
|
---|
273 | GLint wrapParm;
|
---|
274 |
|
---|
275 | if (state < minLookup[WINELOOKUP_WARPPARAM] || state > maxLookup[WINELOOKUP_WARPPARAM]) {
|
---|
276 | FIXME("Unrecognized or unsupported WINED3DTADDRESS_U value %d\n", state);
|
---|
277 | } else {
|
---|
278 | if(textureDimensions==GL_TEXTURE_CUBE_MAP_ARB) {
|
---|
279 | /* Cubemaps are always set to clamp, regardless of the sampler state. */
|
---|
280 | wrapParm = GL_CLAMP_TO_EDGE;
|
---|
281 | } else if(cond_np2) {
|
---|
282 | if(state == WINED3DTADDRESS_WRAP) {
|
---|
283 | wrapParm = GL_CLAMP_TO_EDGE;
|
---|
284 | } else {
|
---|
285 | wrapParm = stateLookup[WINELOOKUP_WARPPARAM][state - minLookup[WINELOOKUP_WARPPARAM]];
|
---|
286 | }
|
---|
287 | } else {
|
---|
288 | wrapParm = stateLookup[WINELOOKUP_WARPPARAM][state - minLookup[WINELOOKUP_WARPPARAM]];
|
---|
289 | }
|
---|
290 | TRACE("Setting WRAP_S to %d for %x\n", wrapParm, textureDimensions);
|
---|
291 | glTexParameteri(textureDimensions, type, wrapParm);
|
---|
292 | checkGLcall("glTexParameteri(..., type, wrapParm)");
|
---|
293 | }
|
---|
294 | }
|
---|
295 |
|
---|
296 | void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
|
---|
297 | const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
|
---|
298 | const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1])
|
---|
299 | {
|
---|
300 | IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
---|
301 | DWORD state;
|
---|
302 | GLint textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
|
---|
303 | BOOL cond_np2 = IWineD3DBaseTexture_IsCondNP2(iface);
|
---|
304 |
|
---|
305 | /* ApplyStateChanges relies on the correct texture being bound and loaded. */
|
---|
306 |
|
---|
307 | if(samplerStates[WINED3DSAMP_ADDRESSU] != This->baseTexture.states[WINED3DTEXSTA_ADDRESSU]) {
|
---|
308 | state = samplerStates[WINED3DSAMP_ADDRESSU];
|
---|
309 | apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_S, cond_np2);
|
---|
310 | This->baseTexture.states[WINED3DTEXSTA_ADDRESSU] = state;
|
---|
311 | }
|
---|
312 |
|
---|
313 | if(samplerStates[WINED3DSAMP_ADDRESSV] != This->baseTexture.states[WINED3DTEXSTA_ADDRESSV]) {
|
---|
314 | state = samplerStates[WINED3DSAMP_ADDRESSV];
|
---|
315 | apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_T, cond_np2);
|
---|
316 | This->baseTexture.states[WINED3DTEXSTA_ADDRESSV] = state;
|
---|
317 | }
|
---|
318 |
|
---|
319 | if(samplerStates[WINED3DSAMP_ADDRESSW] != This->baseTexture.states[WINED3DTEXSTA_ADDRESSW]) {
|
---|
320 | state = samplerStates[WINED3DSAMP_ADDRESSW];
|
---|
321 | apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_R, cond_np2);
|
---|
322 | This->baseTexture.states[WINED3DTEXSTA_ADDRESSW] = state;
|
---|
323 | }
|
---|
324 |
|
---|
325 | if(samplerStates[WINED3DSAMP_BORDERCOLOR] != This->baseTexture.states[WINED3DTEXSTA_BORDERCOLOR]) {
|
---|
326 | float col[4];
|
---|
327 |
|
---|
328 | state = samplerStates[WINED3DSAMP_BORDERCOLOR];
|
---|
329 | D3DCOLORTOGLFLOAT4(state, col);
|
---|
330 | TRACE("Setting border color for %u to %x\n", textureDimensions, state);
|
---|
331 | glTexParameterfv(textureDimensions, GL_TEXTURE_BORDER_COLOR, &col[0]);
|
---|
332 | checkGLcall("glTexParameteri(..., GL_TEXTURE_BORDER_COLOR, ...)");
|
---|
333 | This->baseTexture.states[WINED3DTEXSTA_BORDERCOLOR] = state;
|
---|
334 | }
|
---|
335 |
|
---|
336 | if(samplerStates[WINED3DSAMP_MAGFILTER] != This->baseTexture.states[WINED3DTEXSTA_MAGFILTER]) {
|
---|
337 | GLint glValue;
|
---|
338 | state = samplerStates[WINED3DSAMP_MAGFILTER];
|
---|
339 | if (state > WINED3DTEXF_ANISOTROPIC) {
|
---|
340 | FIXME("Unrecognized or unsupported MAGFILTER* value %d\n", state);
|
---|
341 | } else {
|
---|
342 | glValue = This->baseTexture.magLookup[state - WINED3DTEXF_NONE];
|
---|
343 | TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
|
---|
344 | glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
|
---|
345 | /* We need to reset the Anisotropic filtering state when we change the mag filter to WINED3DTEXF_ANISOTROPIC (this seems a bit weird, check the documentation to see how it should be switched off. */
|
---|
346 | if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && WINED3DTEXF_ANISOTROPIC == state &&
|
---|
347 | !cond_np2) {
|
---|
348 | glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerStates[WINED3DSAMP_MAXANISOTROPY]);
|
---|
349 | }
|
---|
350 | This->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = state;
|
---|
351 | }
|
---|
352 | }
|
---|
353 |
|
---|
354 | if((samplerStates[WINED3DSAMP_MINFILTER] != This->baseTexture.states[WINED3DTEXSTA_MINFILTER] ||
|
---|
355 | samplerStates[WINED3DSAMP_MIPFILTER] != This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] ||
|
---|
356 | samplerStates[WINED3DSAMP_MAXMIPLEVEL] != This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL])) {
|
---|
357 | GLint glValue;
|
---|
358 |
|
---|
359 | This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] = samplerStates[WINED3DSAMP_MIPFILTER];
|
---|
360 | This->baseTexture.states[WINED3DTEXSTA_MINFILTER] = samplerStates[WINED3DSAMP_MINFILTER];
|
---|
361 | This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL] = samplerStates[WINED3DSAMP_MAXMIPLEVEL];
|
---|
362 |
|
---|
363 | if (This->baseTexture.states[WINED3DTEXSTA_MINFILTER] > WINED3DTEXF_ANISOTROPIC ||
|
---|
364 | This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] > WINED3DTEXF_LINEAR)
|
---|
365 | {
|
---|
366 |
|
---|
367 | FIXME("Unrecognized or unsupported D3DSAMP_MINFILTER value %d D3DSAMP_MIPFILTER value %d\n",
|
---|
368 | This->baseTexture.states[WINED3DTEXSTA_MINFILTER],
|
---|
369 | This->baseTexture.states[WINED3DTEXSTA_MIPFILTER]);
|
---|
370 | }
|
---|
371 | glValue = This->baseTexture.minMipLookup
|
---|
372 | [min(max(samplerStates[WINED3DSAMP_MINFILTER],WINED3DTEXF_NONE), WINED3DTEXF_ANISOTROPIC)]
|
---|
373 | .mip[min(max(samplerStates[WINED3DSAMP_MIPFILTER],WINED3DTEXF_NONE), WINED3DTEXF_LINEAR)];
|
---|
374 |
|
---|
375 | TRACE("ValueMIN=%d, ValueMIP=%d, setting MINFILTER to %x\n",
|
---|
376 | samplerStates[WINED3DSAMP_MINFILTER],
|
---|
377 | samplerStates[WINED3DSAMP_MIPFILTER], glValue);
|
---|
378 | glTexParameteri(textureDimensions, GL_TEXTURE_MIN_FILTER, glValue);
|
---|
379 | checkGLcall("glTexParameter GL_TEXTURE_MIN_FILTER, ...");
|
---|
380 |
|
---|
381 | if(!cond_np2) {
|
---|
382 | if(This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE) {
|
---|
383 | glValue = 0;
|
---|
384 | } else if(This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL] >= This->baseTexture.levels) {
|
---|
385 | glValue = This->baseTexture.levels - 1;
|
---|
386 | } else {
|
---|
387 | glValue = This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL];
|
---|
388 | }
|
---|
389 | glTexParameteri(textureDimensions, GL_TEXTURE_BASE_LEVEL, glValue);
|
---|
390 | }
|
---|
391 | }
|
---|
392 |
|
---|
393 | if(samplerStates[WINED3DSAMP_MAXANISOTROPY] != This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY]) {
|
---|
394 | if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && !cond_np2) {
|
---|
395 | glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerStates[WINED3DSAMP_MAXANISOTROPY]);
|
---|
396 | checkGLcall("glTexParameteri GL_TEXTURE_MAX_ANISOTROPY_EXT ...");
|
---|
397 | } else {
|
---|
398 | WARN("Unsupported in local OpenGL implementation: glTexParameteri GL_TEXTURE_MAX_ANISOTROPY_EXT\n");
|
---|
399 | }
|
---|
400 | This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY] = samplerStates[WINED3DSAMP_MAXANISOTROPY];
|
---|
401 | }
|
---|
402 | }
|
---|