VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/basetexture.c@ 30916

Last change on this file since 30916 was 30916, checked in by vboxsync, 15 years ago

wddm/3d: Aero: fix gdi-backend textures update, avoid extra memcpy for sysmem textures Lock/Unlock

  • Property svn:eol-style set to native
File size: 20.3 KB
Line 
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 * Copyright 2009 Henri Verbeet for CodeWeavers
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25/*
26 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
27 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
28 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
29 * a choice of LGPL license versions is made available with the language indicating
30 * that LGPLv2 or any later version may be used, or where a choice of which version
31 * of the LGPL is applied is otherwise unspecified.
32 */
33
34#include "config.h"
35#include "wined3d_private.h"
36
37WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
38
39HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type,
40 IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct wined3d_format_desc *format_desc,
41 WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
42{
43 HRESULT hr;
44
45 hr = resource_init((IWineD3DResource *)texture, resource_type, device,
46 size, usage, format_desc, pool, parent, parent_ops
47#ifdef VBOXWDDM
48 , NULL, NULL /* <- no need this info here */
49#endif
50 );
51 if (FAILED(hr))
52 {
53 WARN("Failed to initialize resource, returning %#x\n", hr);
54 return hr;
55 }
56
57 texture->baseTexture.levels = levels;
58 texture->baseTexture.filterType = (usage & WINED3DUSAGE_AUTOGENMIPMAP) ? WINED3DTEXF_LINEAR : WINED3DTEXF_NONE;
59 texture->baseTexture.LOD = 0;
60 texture->baseTexture.texture_rgb.dirty = TRUE;
61 texture->baseTexture.texture_srgb.dirty = TRUE;
62 texture->baseTexture.is_srgb = FALSE;
63 texture->baseTexture.pow2Matrix_identity = TRUE;
64
65 if (texture->resource.format_desc->Flags & WINED3DFMT_FLAG_FILTERING)
66 {
67 texture->baseTexture.minMipLookup = minMipLookup;
68 texture->baseTexture.magLookup = magLookup;
69 }
70 else
71 {
72 texture->baseTexture.minMipLookup = minMipLookup_noFilter;
73 texture->baseTexture.magLookup = magLookup_noFilter;
74 }
75
76 return WINED3D_OK;
77}
78
79void basetexture_cleanup(IWineD3DBaseTexture *iface)
80{
81 basetexture_unload(iface);
82 resource_cleanup((IWineD3DResource *)iface);
83}
84
85/* A GL context is provided by the caller */
86static void gltexture_delete(struct gl_texture *tex)
87{
88 ENTER_GL();
89 glDeleteTextures(1, &tex->name);
90 LEAVE_GL();
91 tex->name = 0;
92}
93
94void basetexture_unload(IWineD3DBaseTexture *iface)
95{
96 IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
97 IWineD3DDeviceImpl *device = This->resource.device;
98 struct wined3d_context *context = NULL;
99
100 if (This->baseTexture.texture_rgb.name || This->baseTexture.texture_srgb.name)
101 {
102 context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
103 }
104
105 if(This->baseTexture.texture_rgb.name) {
106 gltexture_delete(&This->baseTexture.texture_rgb);
107 }
108 if(This->baseTexture.texture_srgb.name) {
109 gltexture_delete(&This->baseTexture.texture_srgb);
110 }
111
112 if (context) context_release(context);
113
114 This->baseTexture.texture_rgb.dirty = TRUE;
115 This->baseTexture.texture_srgb.dirty = TRUE;
116}
117
118DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD LODNew)
119{
120 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
121 DWORD old = This->baseTexture.LOD;
122
123 /* The d3d9:texture test shows that SetLOD is ignored on non-managed
124 * textures. The call always returns 0, and GetLOD always returns 0
125 */
126 if (This->resource.pool != WINED3DPOOL_MANAGED) {
127 TRACE("Ignoring SetLOD on %s texture, returning 0\n", debug_d3dpool(This->resource.pool));
128 return 0;
129 }
130
131 if(LODNew >= This->baseTexture.levels)
132 LODNew = This->baseTexture.levels - 1;
133
134 if(This->baseTexture.LOD != LODNew) {
135 This->baseTexture.LOD = LODNew;
136
137 This->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
138 This->baseTexture.texture_srgb.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
139 if(This->baseTexture.bindCount) {
140 IWineD3DDeviceImpl_MarkStateDirty(This->resource.device, STATE_SAMPLER(This->baseTexture.sampler));
141 }
142 }
143
144 TRACE("(%p) : set LOD to %d\n", This, This->baseTexture.LOD);
145
146 return old;
147}
148
149DWORD basetexture_get_lod(IWineD3DBaseTexture *iface)
150{
151 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
152
153 TRACE("(%p) : returning %d\n", This, This->baseTexture.LOD);
154
155 return This->baseTexture.LOD;
156}
157
158DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface)
159{
160 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
161 TRACE("(%p) : returning %d\n", This, This->baseTexture.levels);
162 return This->baseTexture.levels;
163}
164
165HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType)
166{
167 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
168 IWineD3DDeviceImpl *device = This->resource.device;
169 UINT textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
170
171 if (!(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)) {
172 TRACE("(%p) : returning invalid call\n", This);
173 return WINED3DERR_INVALIDCALL;
174 }
175 if(This->baseTexture.filterType != FilterType) {
176 /* What about multithreading? Do we want all the context overhead just to set this value?
177 * Or should we delay the applying until the texture is used for drawing? For now, apply
178 * immediately.
179 */
180 struct wined3d_context *context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
181
182 ENTER_GL();
183 glBindTexture(textureDimensions, This->baseTexture.texture_rgb.name);
184 checkGLcall("glBindTexture");
185 switch(FilterType) {
186 case WINED3DTEXF_NONE:
187 case WINED3DTEXF_POINT:
188 glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST);
189 checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST)");
190
191 break;
192 case WINED3DTEXF_LINEAR:
193 glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
194 checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST)");
195
196 break;
197 default:
198 WARN("Unexpected filter type %d, setting to GL_NICEST\n", FilterType);
199 glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
200 checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST)");
201 }
202 LEAVE_GL();
203
204 context_release(context);
205 }
206 This->baseTexture.filterType = FilterType;
207 TRACE("(%p) :\n", This);
208 return WINED3D_OK;
209}
210
211WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface)
212{
213 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
214
215 FIXME("(%p) : stub\n", This);
216
217 return This->baseTexture.filterType;
218}
219
220void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface)
221{
222 /* TODO: Implement filters using GL_SGI_generate_mipmaps. */
223 FIXME("iface %p stub!\n", iface);
224}
225
226BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty)
227{
228 BOOL old;
229 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
230 old = This->baseTexture.texture_rgb.dirty || This->baseTexture.texture_srgb.dirty;
231 This->baseTexture.texture_rgb.dirty = dirty;
232 This->baseTexture.texture_srgb.dirty = dirty;
233 return old;
234}
235
236BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface)
237{
238 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
239 return This->baseTexture.texture_rgb.dirty || This->baseTexture.texture_srgb.dirty;
240}
241
242/* Context activation is done by the caller. */
243HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surface_desc)
244{
245 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
246 HRESULT hr = WINED3D_OK;
247 UINT textureDimensions;
248 BOOL isNewTexture = FALSE;
249 struct gl_texture *gl_tex;
250 TRACE("(%p) : About to bind texture\n", This);
251
252 This->baseTexture.is_srgb = srgb; /* SRGB mode cache for PreLoad calls outside drawprim */
253 if(srgb) {
254 gl_tex = &This->baseTexture.texture_srgb;
255 } else {
256 gl_tex = &This->baseTexture.texture_rgb;
257 }
258
259 textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
260 ENTER_GL();
261 /* Generate a texture name if we don't already have one */
262 if (gl_tex->name == 0) {
263 *set_surface_desc = TRUE;
264 glGenTextures(1, &gl_tex->name);
265 checkGLcall("glGenTextures");
266 TRACE("Generated texture %d\n", gl_tex->name);
267 if (This->resource.pool == WINED3DPOOL_DEFAULT) {
268 /* Tell opengl to try and keep this texture in video ram (well mostly) */
269 GLclampf tmp;
270 tmp = 0.9f;
271 glPrioritizeTextures(1, &gl_tex->name, &tmp);
272
273 }
274 /* Initialise the state of the texture object
275 to the openGL defaults, not the directx defaults */
276 gl_tex->states[WINED3DTEXSTA_ADDRESSU] = WINED3DTADDRESS_WRAP;
277 gl_tex->states[WINED3DTEXSTA_ADDRESSV] = WINED3DTADDRESS_WRAP;
278 gl_tex->states[WINED3DTEXSTA_ADDRESSW] = WINED3DTADDRESS_WRAP;
279 gl_tex->states[WINED3DTEXSTA_BORDERCOLOR] = 0;
280 gl_tex->states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_LINEAR;
281 gl_tex->states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
282 gl_tex->states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
283 gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] = 0;
284 gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] = 1;
285 gl_tex->states[WINED3DTEXSTA_SRGBTEXTURE] = 0;
286 gl_tex->states[WINED3DTEXSTA_ELEMENTINDEX] = 0;
287 gl_tex->states[WINED3DTEXSTA_DMAPOFFSET] = 0;
288 gl_tex->states[WINED3DTEXSTA_TSSADDRESSW] = WINED3DTADDRESS_WRAP;
289 IWineD3DBaseTexture_SetDirty(iface, TRUE);
290 isNewTexture = TRUE;
291
292 if(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP) {
293 /* This means double binding the texture at creation, but keeps the code simpler all
294 * in all, and the run-time path free from additional checks
295 */
296 glBindTexture(textureDimensions, gl_tex->name);
297 checkGLcall("glBindTexture");
298 glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
299 checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_SGIS, GL_TRUE)");
300 }
301 } else {
302 *set_surface_desc = FALSE;
303 }
304
305 /* Bind the texture */
306 if (gl_tex->name != 0) {
307 glBindTexture(textureDimensions, gl_tex->name);
308 checkGLcall("glBindTexture");
309 if (isNewTexture) {
310 /* For a new texture we have to set the textures levels after binding the texture.
311 * In theory this is all we should ever have to do, but because ATI's drivers are broken, we
312 * also need to set the texture dimensions before the texture is set
313 * Beware that texture rectangles do not support mipmapping, but set the maxmiplevel if we're
314 * relying on the partial GL_ARB_texture_non_power_of_two emulation with texture rectangles
315 * (ie, do not care for cond_np2 here, just look for GL_TEXTURE_RECTANGLE_ARB)
316 */
317 if(textureDimensions != GL_TEXTURE_RECTANGLE_ARB) {
318 TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->baseTexture.levels - 1);
319 glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1);
320 checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels)");
321 }
322 if(textureDimensions==GL_TEXTURE_CUBE_MAP_ARB) {
323 /* Cubemaps are always set to clamp, regardless of the sampler state. */
324 glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
325 glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
326 glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
327 }
328 }
329 } else { /* this only happened if we've run out of openGL textures */
330 WARN("This texture doesn't have an openGL texture assigned to it\n");
331 hr = WINED3DERR_INVALIDCALL;
332 }
333
334 LEAVE_GL();
335 return hr;
336}
337
338/* GL locking is done by the caller */
339static void apply_wrap(const struct wined3d_gl_info *gl_info, GLenum target,
340 WINED3DTEXTUREADDRESS d3d_wrap, GLenum param, BOOL cond_np2)
341{
342 GLint gl_wrap;
343
344 if (d3d_wrap < WINED3DTADDRESS_WRAP || d3d_wrap > WINED3DTADDRESS_MIRRORONCE)
345 {
346 FIXME("Unrecognized or unsupported WINED3DTEXTUREADDRESS %#x.\n", d3d_wrap);
347 return;
348 }
349
350 if (target == GL_TEXTURE_CUBE_MAP_ARB
351 || (cond_np2 && d3d_wrap == WINED3DTADDRESS_WRAP))
352 {
353 /* Cubemaps are always set to clamp, regardless of the sampler state. */
354 gl_wrap = GL_CLAMP_TO_EDGE;
355 }
356 else
357 {
358 gl_wrap = gl_info->wrap_lookup[d3d_wrap - WINED3DTADDRESS_WRAP];
359 }
360
361 TRACE("Setting param %#x to %#x for target %#x.\n", param, gl_wrap, target);
362 glTexParameteri(target, param, gl_wrap);
363 checkGLcall("glTexParameteri(target, param, gl_wrap)");
364}
365
366/* GL locking is done by the caller (state handler) */
367void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
368 const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
369 const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1],
370 const struct wined3d_gl_info *gl_info)
371{
372 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
373 DWORD state;
374 GLint textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
375 BOOL cond_np2 = IWineD3DBaseTexture_IsCondNP2(iface);
376 DWORD aniso;
377 struct gl_texture *gl_tex;
378
379 TRACE("iface %p, textureStates %p, samplerStates %p\n", iface, textureStates, samplerStates);
380
381 if(This->baseTexture.is_srgb) {
382 gl_tex = &This->baseTexture.texture_srgb;
383 } else {
384 gl_tex = &This->baseTexture.texture_rgb;
385 }
386
387 /* This function relies on the correct texture being bound and loaded. */
388
389 if(samplerStates[WINED3DSAMP_ADDRESSU] != gl_tex->states[WINED3DTEXSTA_ADDRESSU]) {
390 state = samplerStates[WINED3DSAMP_ADDRESSU];
391 apply_wrap(gl_info, textureDimensions, state, GL_TEXTURE_WRAP_S, cond_np2);
392 gl_tex->states[WINED3DTEXSTA_ADDRESSU] = state;
393 }
394
395 if(samplerStates[WINED3DSAMP_ADDRESSV] != gl_tex->states[WINED3DTEXSTA_ADDRESSV]) {
396 state = samplerStates[WINED3DSAMP_ADDRESSV];
397 apply_wrap(gl_info, textureDimensions, state, GL_TEXTURE_WRAP_T, cond_np2);
398 gl_tex->states[WINED3DTEXSTA_ADDRESSV] = state;
399 }
400
401 if(samplerStates[WINED3DSAMP_ADDRESSW] != gl_tex->states[WINED3DTEXSTA_ADDRESSW]) {
402 state = samplerStates[WINED3DSAMP_ADDRESSW];
403 apply_wrap(gl_info, textureDimensions, state, GL_TEXTURE_WRAP_R, cond_np2);
404 gl_tex->states[WINED3DTEXSTA_ADDRESSW] = state;
405 }
406
407 if(samplerStates[WINED3DSAMP_BORDERCOLOR] != gl_tex->states[WINED3DTEXSTA_BORDERCOLOR]) {
408 float col[4];
409
410 state = samplerStates[WINED3DSAMP_BORDERCOLOR];
411 D3DCOLORTOGLFLOAT4(state, col);
412 TRACE("Setting border color for %u to %x\n", textureDimensions, state);
413 glTexParameterfv(textureDimensions, GL_TEXTURE_BORDER_COLOR, &col[0]);
414 checkGLcall("glTexParameteri(..., GL_TEXTURE_BORDER_COLOR, ...)");
415 gl_tex->states[WINED3DTEXSTA_BORDERCOLOR] = state;
416 }
417
418 if(samplerStates[WINED3DSAMP_MAGFILTER] != gl_tex->states[WINED3DTEXSTA_MAGFILTER]) {
419 GLint glValue;
420 state = samplerStates[WINED3DSAMP_MAGFILTER];
421 if (state > WINED3DTEXF_ANISOTROPIC) {
422 FIXME("Unrecognized or unsupported MAGFILTER* value %d\n", state);
423 }
424
425 glValue = wined3d_gl_mag_filter(This->baseTexture.magLookup,
426 min(max(state, WINED3DTEXF_POINT), WINED3DTEXF_LINEAR));
427 TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
428 glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
429
430 gl_tex->states[WINED3DTEXSTA_MAGFILTER] = state;
431 }
432
433 if((samplerStates[WINED3DSAMP_MINFILTER] != gl_tex->states[WINED3DTEXSTA_MINFILTER] ||
434 samplerStates[WINED3DSAMP_MIPFILTER] != gl_tex->states[WINED3DTEXSTA_MIPFILTER] ||
435 samplerStates[WINED3DSAMP_MAXMIPLEVEL] != gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL])) {
436 GLint glValue;
437
438 gl_tex->states[WINED3DTEXSTA_MIPFILTER] = samplerStates[WINED3DSAMP_MIPFILTER];
439 gl_tex->states[WINED3DTEXSTA_MINFILTER] = samplerStates[WINED3DSAMP_MINFILTER];
440 gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] = samplerStates[WINED3DSAMP_MAXMIPLEVEL];
441
442 if (gl_tex->states[WINED3DTEXSTA_MINFILTER] > WINED3DTEXF_ANISOTROPIC
443 || gl_tex->states[WINED3DTEXSTA_MIPFILTER] > WINED3DTEXF_ANISOTROPIC)
444 {
445
446 FIXME("Unrecognized or unsupported D3DSAMP_MINFILTER value %d D3DSAMP_MIPFILTER value %d\n",
447 gl_tex->states[WINED3DTEXSTA_MINFILTER],
448 gl_tex->states[WINED3DTEXSTA_MIPFILTER]);
449 }
450 glValue = wined3d_gl_min_mip_filter(This->baseTexture.minMipLookup,
451 min(max(samplerStates[WINED3DSAMP_MINFILTER], WINED3DTEXF_POINT), WINED3DTEXF_LINEAR),
452 min(max(samplerStates[WINED3DSAMP_MIPFILTER], WINED3DTEXF_NONE), WINED3DTEXF_LINEAR));
453
454 TRACE("ValueMIN=%d, ValueMIP=%d, setting MINFILTER to %x\n",
455 samplerStates[WINED3DSAMP_MINFILTER],
456 samplerStates[WINED3DSAMP_MIPFILTER], glValue);
457 glTexParameteri(textureDimensions, GL_TEXTURE_MIN_FILTER, glValue);
458 checkGLcall("glTexParameter GL_TEXTURE_MIN_FILTER, ...");
459
460 if(!cond_np2) {
461 if(gl_tex->states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE) {
462 glValue = This->baseTexture.LOD;
463 } else if(gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] >= This->baseTexture.levels) {
464 glValue = This->baseTexture.levels - 1;
465 } else if(gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] < This->baseTexture.LOD) {
466 /* baseTexture.LOD is already clamped in the setter */
467 glValue = This->baseTexture.LOD;
468 } else {
469 glValue = gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL];
470 }
471 /* Note that D3DSAMP_MAXMIPLEVEL specifies the biggest mipmap(default 0), while
472 * GL_TEXTURE_MAX_LEVEL specifies the smallest mimap used(default 1000).
473 * So D3DSAMP_MAXMIPLEVEL is the same as GL_TEXTURE_BASE_LEVEL.
474 */
475 glTexParameteri(textureDimensions, GL_TEXTURE_BASE_LEVEL, glValue);
476 }
477 }
478
479 if ((gl_tex->states[WINED3DTEXSTA_MAGFILTER] != WINED3DTEXF_ANISOTROPIC
480 && gl_tex->states[WINED3DTEXSTA_MINFILTER] != WINED3DTEXF_ANISOTROPIC
481 && gl_tex->states[WINED3DTEXSTA_MIPFILTER] != WINED3DTEXF_ANISOTROPIC)
482 || cond_np2)
483 {
484 aniso = 1;
485 }
486 else
487 {
488 aniso = samplerStates[WINED3DSAMP_MAXANISOTROPY];
489 }
490
491 if (gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] != aniso)
492 {
493 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
494 {
495 glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso);
496 checkGLcall("glTexParameteri(GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso)");
497 }
498 else
499 {
500 WARN("Anisotropic filtering not supported.\n");
501 }
502 gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] = aniso;
503 }
504}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette