2 * IWineD3DBaseTexture Implementation
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-2010 Henri Verbeet for CodeWeavers
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.
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.
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
26 #include "wined3d_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
30 HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, const struct wined3d_texture_ops *texture_ops,
31 UINT layer_count, UINT level_count, WINED3DRESOURCETYPE resource_type, IWineD3DDeviceImpl *device,
32 DWORD usage, const struct wined3d_format *format, WINED3DPOOL pool, void *parent,
33 const struct wined3d_parent_ops *parent_ops, const struct wined3d_resource_ops *resource_ops)
37 hr = resource_init(&texture->resource, device, resource_type, format,
38 WINED3DMULTISAMPLE_NONE, 0, usage, pool, 0, 0, 0, 0,
39 parent, parent_ops, resource_ops);
42 WARN("Failed to initialize resource, returning %#x\n", hr);
46 texture->baseTexture.texture_ops = texture_ops;
47 texture->baseTexture.sub_resources = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
48 level_count * layer_count * sizeof(*texture->baseTexture.sub_resources));
49 if (!texture->baseTexture.sub_resources)
51 ERR("Failed to allocate sub-resource array.\n");
52 resource_cleanup(&texture->resource);
56 texture->baseTexture.layer_count = layer_count;
57 texture->baseTexture.level_count = level_count;
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;
65 if (texture->resource.format->flags & WINED3DFMT_FLAG_FILTERING)
67 texture->baseTexture.minMipLookup = minMipLookup;
68 texture->baseTexture.magLookup = magLookup;
72 texture->baseTexture.minMipLookup = minMipLookup_noFilter;
73 texture->baseTexture.magLookup = magLookup_noFilter;
79 void basetexture_cleanup(IWineD3DBaseTextureImpl *texture)
81 UINT sub_count = texture->baseTexture.level_count * texture->baseTexture.layer_count;
84 TRACE("texture %p.\n", texture);
86 for (i = 0; i < sub_count; ++i)
88 struct wined3d_resource *sub_resource = texture->baseTexture.sub_resources[i];
91 texture->baseTexture.texture_ops->texture_sub_resource_cleanup(sub_resource);
94 basetexture_unload(texture);
95 HeapFree(GetProcessHeap(), 0, texture->baseTexture.sub_resources);
96 resource_cleanup(&texture->resource);
99 struct wined3d_resource *basetexture_get_sub_resource(IWineD3DBaseTextureImpl *texture, UINT sub_resource_idx)
101 UINT sub_count = texture->baseTexture.level_count * texture->baseTexture.layer_count;
103 if (sub_resource_idx >= sub_count)
105 WARN("sub_resource_idx %u >= sub_count %u.\n", sub_resource_idx, sub_count);
109 return texture->baseTexture.sub_resources[sub_resource_idx];
112 /* A GL context is provided by the caller */
113 static void gltexture_delete(struct gl_texture *tex)
116 glDeleteTextures(1, &tex->name);
121 void basetexture_unload(IWineD3DBaseTextureImpl *texture)
123 IWineD3DDeviceImpl *device = texture->resource.device;
124 struct wined3d_context *context = NULL;
126 if (texture->baseTexture.texture_rgb.name || texture->baseTexture.texture_srgb.name)
128 context = context_acquire(device, NULL);
131 if (texture->baseTexture.texture_rgb.name)
132 gltexture_delete(&texture->baseTexture.texture_rgb);
134 if (texture->baseTexture.texture_srgb.name)
135 gltexture_delete(&texture->baseTexture.texture_srgb);
137 if (context) context_release(context);
139 basetexture_set_dirty(texture, TRUE);
141 resource_unload(&texture->resource);
144 DWORD basetexture_set_lod(IWineD3DBaseTextureImpl *texture, DWORD lod)
146 DWORD old = texture->baseTexture.LOD;
148 TRACE("texture %p, lod %u.\n", texture, lod);
150 /* The d3d9:texture test shows that SetLOD is ignored on non-managed
151 * textures. The call always returns 0, and GetLOD always returns 0. */
152 if (texture->resource.pool != WINED3DPOOL_MANAGED)
154 TRACE("Ignoring SetLOD on %s texture, returning 0.\n", debug_d3dpool(texture->resource.pool));
158 if (lod >= texture->baseTexture.level_count)
159 lod = texture->baseTexture.level_count - 1;
161 if (texture->baseTexture.LOD != lod)
163 texture->baseTexture.LOD = lod;
165 texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
166 texture->baseTexture.texture_srgb.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
167 if (texture->baseTexture.bindCount)
168 IWineD3DDeviceImpl_MarkStateDirty(texture->resource.device, STATE_SAMPLER(texture->baseTexture.sampler));
174 DWORD basetexture_get_lod(IWineD3DBaseTextureImpl *texture)
176 TRACE("texture %p, returning %u.\n", texture, texture->baseTexture.LOD);
178 return texture->baseTexture.LOD;
181 DWORD basetexture_get_level_count(IWineD3DBaseTextureImpl *texture)
183 TRACE("texture %p, returning %u.\n", texture, texture->baseTexture.level_count);
184 return texture->baseTexture.level_count;
187 HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTextureImpl *texture, WINED3DTEXTUREFILTERTYPE filter_type)
189 TRACE("texture %p, filter_type %s.\n", texture, debug_d3dtexturefiltertype(filter_type));
191 if (!(texture->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP))
193 WARN("Texture doesn't have AUTOGENMIPMAP usage.\n");
194 return WINED3DERR_INVALIDCALL;
197 if (texture->baseTexture.filterType != filter_type)
199 GLenum target = texture->baseTexture.target;
200 struct wined3d_context *context;
202 context = context_acquire(texture->resource.device, NULL);
205 glBindTexture(target, texture->baseTexture.texture_rgb.name);
206 checkGLcall("glBindTexture");
209 case WINED3DTEXF_NONE:
210 case WINED3DTEXF_POINT:
211 glTexParameteri(target, GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST);
212 checkGLcall("glTexParameteri(target, GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST)");
215 case WINED3DTEXF_LINEAR:
216 glTexParameteri(target, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
217 checkGLcall("glTexParameteri(target, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST)");
221 WARN("Unexpected filter type %#x, setting to GL_NICEST.\n", filter_type);
222 glTexParameteri(target, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
223 checkGLcall("glTexParameteri(target, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST)");
228 context_release(context);
230 texture->baseTexture.filterType = filter_type;
235 WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTextureImpl *texture)
237 TRACE("texture %p.\n", texture);
239 return texture->baseTexture.filterType;
242 void basetexture_generate_mipmaps(IWineD3DBaseTextureImpl *texture)
244 /* TODO: Implement filters using GL_SGI_generate_mipmaps. */
245 FIXME("texture %p stub!\n", texture);
248 void basetexture_set_dirty(IWineD3DBaseTextureImpl *texture, BOOL dirty)
250 texture->baseTexture.texture_rgb.dirty = dirty;
251 texture->baseTexture.texture_srgb.dirty = dirty;
254 /* Context activation is done by the caller. */
255 HRESULT basetexture_bind(IWineD3DBaseTextureImpl *texture,
256 const struct wined3d_gl_info *gl_info, BOOL srgb, BOOL *set_surface_desc)
258 HRESULT hr = WINED3D_OK;
259 GLenum textureDimensions;
260 BOOL isNewTexture = FALSE;
261 struct gl_texture *gl_tex;
263 TRACE("texture %p, srgb %#x, set_surface_desc %p.\n", texture, srgb, set_surface_desc);
265 texture->baseTexture.is_srgb = srgb; /* SRGB mode cache for PreLoad calls outside drawprim */
266 gl_tex = basetexture_get_gl_texture(texture, gl_info, srgb);
268 textureDimensions = texture->baseTexture.target;
271 /* Generate a texture name if we don't already have one */
274 *set_surface_desc = TRUE;
275 glGenTextures(1, &gl_tex->name);
276 checkGLcall("glGenTextures");
277 TRACE("Generated texture %d\n", gl_tex->name);
278 if (texture->resource.pool == WINED3DPOOL_DEFAULT)
280 /* Tell opengl to try and keep this texture in video ram (well mostly) */
283 glPrioritizeTextures(1, &gl_tex->name, &tmp);
286 /* Initialise the state of the texture object
287 to the openGL defaults, not the directx defaults */
288 gl_tex->states[WINED3DTEXSTA_ADDRESSU] = WINED3DTADDRESS_WRAP;
289 gl_tex->states[WINED3DTEXSTA_ADDRESSV] = WINED3DTADDRESS_WRAP;
290 gl_tex->states[WINED3DTEXSTA_ADDRESSW] = WINED3DTADDRESS_WRAP;
291 gl_tex->states[WINED3DTEXSTA_BORDERCOLOR] = 0;
292 gl_tex->states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_LINEAR;
293 gl_tex->states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
294 gl_tex->states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
295 gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] = 0;
296 gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] = 1;
297 if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
298 gl_tex->states[WINED3DTEXSTA_SRGBTEXTURE] = TRUE;
300 gl_tex->states[WINED3DTEXSTA_SRGBTEXTURE] = srgb;
301 gl_tex->states[WINED3DTEXSTA_SHADOW] = FALSE;
302 basetexture_set_dirty(texture, TRUE);
305 if (texture->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)
307 /* This means double binding the texture at creation, but keeps the code simpler all
308 * in all, and the run-time path free from additional checks
310 glBindTexture(textureDimensions, gl_tex->name);
311 checkGLcall("glBindTexture");
312 glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
313 checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_SGIS, GL_TRUE)");
316 *set_surface_desc = FALSE;
319 /* Bind the texture */
322 glBindTexture(textureDimensions, gl_tex->name);
323 checkGLcall("glBindTexture");
325 /* For a new texture we have to set the textures levels after binding the texture.
326 * In theory this is all we should ever have to do, but because ATI's drivers are broken, we
327 * also need to set the texture dimensions before the texture is set
328 * Beware that texture rectangles do not support mipmapping, but set the maxmiplevel if we're
329 * relying on the partial GL_ARB_texture_non_power_of_two emulation with texture rectangles
330 * (ie, do not care for cond_np2 here, just look for GL_TEXTURE_RECTANGLE_ARB)
332 if (textureDimensions != GL_TEXTURE_RECTANGLE_ARB)
334 TRACE("Setting GL_TEXTURE_MAX_LEVEL to %u.\n", texture->baseTexture.level_count - 1);
335 glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, texture->baseTexture.level_count - 1);
336 checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, texture->baseTexture.level_count)");
338 if(textureDimensions==GL_TEXTURE_CUBE_MAP_ARB) {
339 /* Cubemaps are always set to clamp, regardless of the sampler state. */
340 glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
341 glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
342 glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
345 } else { /* this only happened if we've run out of openGL textures */
346 WARN("This texture doesn't have an openGL texture assigned to it\n");
347 hr = WINED3DERR_INVALIDCALL;
354 HRESULT basetexture_add_dirty_region(IWineD3DBaseTextureImpl *texture,
355 UINT layer, const WINED3DBOX *dirty_region)
357 struct wined3d_resource *sub_resource;
359 TRACE("texture %p, layer %u, dirty_region %p.\n", texture, layer, dirty_region);
361 if (!(sub_resource = basetexture_get_sub_resource(texture, layer * texture->baseTexture.level_count)))
363 WARN("Failed to get sub-resource.\n");
364 return WINED3DERR_INVALIDCALL;
367 basetexture_set_dirty(texture, TRUE);
368 texture->baseTexture.texture_ops->texture_sub_resource_add_dirty_region(sub_resource, dirty_region);
373 /* GL locking is done by the caller */
374 static void apply_wrap(const struct wined3d_gl_info *gl_info, GLenum target,
375 WINED3DTEXTUREADDRESS d3d_wrap, GLenum param, BOOL cond_np2)
379 if (d3d_wrap < WINED3DTADDRESS_WRAP || d3d_wrap > WINED3DTADDRESS_MIRRORONCE)
381 FIXME("Unrecognized or unsupported WINED3DTEXTUREADDRESS %#x.\n", d3d_wrap);
385 if (target == GL_TEXTURE_CUBE_MAP_ARB
386 || (cond_np2 && d3d_wrap == WINED3DTADDRESS_WRAP))
388 /* Cubemaps are always set to clamp, regardless of the sampler state. */
389 gl_wrap = GL_CLAMP_TO_EDGE;
393 gl_wrap = gl_info->wrap_lookup[d3d_wrap - WINED3DTADDRESS_WRAP];
396 TRACE("Setting param %#x to %#x for target %#x.\n", param, gl_wrap, target);
397 glTexParameteri(target, param, gl_wrap);
398 checkGLcall("glTexParameteri(target, param, gl_wrap)");
401 /* GL locking is done by the caller (state handler) */
402 void basetexture_apply_state_changes(IWineD3DBaseTextureImpl *texture,
403 const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1],
404 const struct wined3d_gl_info *gl_info)
406 BOOL cond_np2 = texture->baseTexture.cond_np2;
407 GLenum textureDimensions = texture->baseTexture.target;
410 struct gl_texture *gl_tex;
412 TRACE("texture %p, samplerStates %p\n", texture, samplerStates);
414 gl_tex = basetexture_get_gl_texture(texture, gl_info, texture->baseTexture.is_srgb);
416 /* This function relies on the correct texture being bound and loaded. */
418 if(samplerStates[WINED3DSAMP_ADDRESSU] != gl_tex->states[WINED3DTEXSTA_ADDRESSU]) {
419 state = samplerStates[WINED3DSAMP_ADDRESSU];
420 apply_wrap(gl_info, textureDimensions, state, GL_TEXTURE_WRAP_S, cond_np2);
421 gl_tex->states[WINED3DTEXSTA_ADDRESSU] = state;
424 if(samplerStates[WINED3DSAMP_ADDRESSV] != gl_tex->states[WINED3DTEXSTA_ADDRESSV]) {
425 state = samplerStates[WINED3DSAMP_ADDRESSV];
426 apply_wrap(gl_info, textureDimensions, state, GL_TEXTURE_WRAP_T, cond_np2);
427 gl_tex->states[WINED3DTEXSTA_ADDRESSV] = state;
430 if(samplerStates[WINED3DSAMP_ADDRESSW] != gl_tex->states[WINED3DTEXSTA_ADDRESSW]) {
431 state = samplerStates[WINED3DSAMP_ADDRESSW];
432 apply_wrap(gl_info, textureDimensions, state, GL_TEXTURE_WRAP_R, cond_np2);
433 gl_tex->states[WINED3DTEXSTA_ADDRESSW] = state;
436 if(samplerStates[WINED3DSAMP_BORDERCOLOR] != gl_tex->states[WINED3DTEXSTA_BORDERCOLOR]) {
439 state = samplerStates[WINED3DSAMP_BORDERCOLOR];
440 D3DCOLORTOGLFLOAT4(state, col);
441 TRACE("Setting border color for %u to %x\n", textureDimensions, state);
442 glTexParameterfv(textureDimensions, GL_TEXTURE_BORDER_COLOR, &col[0]);
443 checkGLcall("glTexParameterfv(..., GL_TEXTURE_BORDER_COLOR, ...)");
444 gl_tex->states[WINED3DTEXSTA_BORDERCOLOR] = state;
447 if(samplerStates[WINED3DSAMP_MAGFILTER] != gl_tex->states[WINED3DTEXSTA_MAGFILTER]) {
449 state = samplerStates[WINED3DSAMP_MAGFILTER];
450 if (state > WINED3DTEXF_ANISOTROPIC) {
451 FIXME("Unrecognized or unsupported MAGFILTER* value %d\n", state);
454 glValue = wined3d_gl_mag_filter(texture->baseTexture.magLookup,
455 min(max(state, WINED3DTEXF_POINT), WINED3DTEXF_LINEAR));
456 TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
457 glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
459 gl_tex->states[WINED3DTEXSTA_MAGFILTER] = state;
462 if((samplerStates[WINED3DSAMP_MINFILTER] != gl_tex->states[WINED3DTEXSTA_MINFILTER] ||
463 samplerStates[WINED3DSAMP_MIPFILTER] != gl_tex->states[WINED3DTEXSTA_MIPFILTER] ||
464 samplerStates[WINED3DSAMP_MAXMIPLEVEL] != gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL])) {
467 gl_tex->states[WINED3DTEXSTA_MIPFILTER] = samplerStates[WINED3DSAMP_MIPFILTER];
468 gl_tex->states[WINED3DTEXSTA_MINFILTER] = samplerStates[WINED3DSAMP_MINFILTER];
469 gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] = samplerStates[WINED3DSAMP_MAXMIPLEVEL];
471 if (gl_tex->states[WINED3DTEXSTA_MINFILTER] > WINED3DTEXF_ANISOTROPIC
472 || gl_tex->states[WINED3DTEXSTA_MIPFILTER] > WINED3DTEXF_ANISOTROPIC)
475 FIXME("Unrecognized or unsupported D3DSAMP_MINFILTER value %d D3DSAMP_MIPFILTER value %d\n",
476 gl_tex->states[WINED3DTEXSTA_MINFILTER],
477 gl_tex->states[WINED3DTEXSTA_MIPFILTER]);
479 glValue = wined3d_gl_min_mip_filter(texture->baseTexture.minMipLookup,
480 min(max(samplerStates[WINED3DSAMP_MINFILTER], WINED3DTEXF_POINT), WINED3DTEXF_LINEAR),
481 min(max(samplerStates[WINED3DSAMP_MIPFILTER], WINED3DTEXF_NONE), WINED3DTEXF_LINEAR));
483 TRACE("ValueMIN=%d, ValueMIP=%d, setting MINFILTER to %x\n",
484 samplerStates[WINED3DSAMP_MINFILTER],
485 samplerStates[WINED3DSAMP_MIPFILTER], glValue);
486 glTexParameteri(textureDimensions, GL_TEXTURE_MIN_FILTER, glValue);
487 checkGLcall("glTexParameter GL_TEXTURE_MIN_FILTER, ...");
491 if (gl_tex->states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE)
492 glValue = texture->baseTexture.LOD;
493 else if (gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] >= texture->baseTexture.level_count)
494 glValue = texture->baseTexture.level_count - 1;
495 else if (gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] < texture->baseTexture.LOD)
496 /* baseTexture.LOD is already clamped in the setter */
497 glValue = texture->baseTexture.LOD;
499 glValue = gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL];
501 /* Note that D3DSAMP_MAXMIPLEVEL specifies the biggest mipmap(default 0), while
502 * GL_TEXTURE_MAX_LEVEL specifies the smallest mimap used(default 1000).
503 * So D3DSAMP_MAXMIPLEVEL is the same as GL_TEXTURE_BASE_LEVEL.
505 glTexParameteri(textureDimensions, GL_TEXTURE_BASE_LEVEL, glValue);
509 if ((gl_tex->states[WINED3DTEXSTA_MAGFILTER] != WINED3DTEXF_ANISOTROPIC
510 && gl_tex->states[WINED3DTEXSTA_MINFILTER] != WINED3DTEXF_ANISOTROPIC
511 && gl_tex->states[WINED3DTEXSTA_MIPFILTER] != WINED3DTEXF_ANISOTROPIC)
518 aniso = samplerStates[WINED3DSAMP_MAXANISOTROPY];
521 if (gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] != aniso)
523 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
525 glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso);
526 checkGLcall("glTexParameteri(GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso)");
530 WARN("Anisotropic filtering not supported.\n");
532 gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] = aniso;
535 /* These should always be the same unless EXT_texture_sRGB_decode is supported. */
536 if (samplerStates[WINED3DSAMP_SRGBTEXTURE] != gl_tex->states[WINED3DTEXSTA_SRGBTEXTURE])
538 glTexParameteri(textureDimensions, GL_TEXTURE_SRGB_DECODE_EXT,
539 samplerStates[WINED3DSAMP_SRGBTEXTURE] ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT);
540 checkGLcall("glTexParameteri(GL_TEXTURE_SRGB_DECODE_EXT)");
543 if (!(texture->resource.format->flags & WINED3DFMT_FLAG_SHADOW)
544 != !gl_tex->states[WINED3DTEXSTA_SHADOW])
546 if (texture->resource.format->flags & WINED3DFMT_FLAG_SHADOW)
548 glTexParameteri(textureDimensions, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);
549 glTexParameteri(textureDimensions, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
550 checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB)");
551 gl_tex->states[WINED3DTEXSTA_SHADOW] = TRUE;
555 glTexParameteri(textureDimensions, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
556 checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE)");
557 gl_tex->states[WINED3DTEXSTA_SHADOW] = FALSE;