2 * IWineD3DTexture implementation
4 * Copyright 2002-2005 Jason Edmeades
5 * Copyright 2002-2005 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 /* Context activation is done by the caller. */
31 static HRESULT texture_bind(IWineD3DBaseTextureImpl *texture, BOOL srgb)
33 BOOL set_gl_texture_desc;
36 TRACE("texture %p, srgb %#x.\n", texture, srgb);
38 hr = basetexture_bind(texture, srgb, &set_gl_texture_desc);
39 if (set_gl_texture_desc && SUCCEEDED(hr))
42 struct gl_texture *gl_tex;
44 if (texture->baseTexture.is_srgb)
45 gl_tex = &texture->baseTexture.texture_srgb;
47 gl_tex = &texture->baseTexture.texture_rgb;
49 for (i = 0; i < texture->baseTexture.level_count; ++i)
51 IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)texture->baseTexture.sub_resources[i];
52 surface_set_texture_name(surface, gl_tex->name, texture->baseTexture.is_srgb);
55 /* Conditinal non power of two textures use a different clamping
56 * default. If we're using the GL_WINE_normalized_texrect partial
57 * driver emulation, we're dealing with a GL_TEXTURE_2D texture which
58 * has the address mode set to repeat - something that prevents us
59 * from hitting the accelerated codepath. Thus manually set the GL
60 * state. The same applies to filtering. Even if the texture has only
61 * one mip level, the default LINEAR_MIPMAP_LINEAR filter causes a SW
62 * fallback on macos. */
63 if (IWineD3DBaseTexture_IsCondNP2((IWineD3DBaseTexture *)texture))
65 GLenum target = texture->baseTexture.target;
68 glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
69 checkGLcall("glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)");
70 glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
71 checkGLcall("glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)");
72 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
73 checkGLcall("glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST)");
74 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
75 checkGLcall("glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST)");
77 gl_tex->states[WINED3DTEXSTA_ADDRESSU] = WINED3DTADDRESS_CLAMP;
78 gl_tex->states[WINED3DTEXSTA_ADDRESSV] = WINED3DTADDRESS_CLAMP;
79 gl_tex->states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
80 gl_tex->states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
81 gl_tex->states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
88 /* Do not call while under the GL lock. */
89 static void texture_preload(IWineD3DBaseTextureImpl *texture, enum WINED3DSRGB srgb)
91 IWineD3DDeviceImpl *device = texture->resource.device;
92 struct wined3d_context *context = NULL;
97 TRACE("texture %p, srgb %#x.\n", texture, srgb);
106 texture_preload(texture, SRGB_RGB);
114 srgb_mode = texture->baseTexture.is_srgb;
117 dirty = srgb_mode ? &texture->baseTexture.texture_srgb.dirty : &texture->baseTexture.texture_rgb.dirty;
119 if (!device->isInDraw)
121 /* context_acquire() sets isInDraw to TRUE when loading a pbuffer into a texture,
122 * thus no danger of recursive calls. */
123 context = context_acquire(device, NULL);
126 if (texture->resource.format->id == WINED3DFMT_P8_UINT
127 || texture->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM)
129 for (i = 0; i < texture->baseTexture.level_count; ++i)
131 IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)texture->baseTexture.sub_resources[i];
132 if (palette9_changed(surface))
134 TRACE("Reloading surface because the d3d8/9 palette was changed.\n");
135 /* TODO: This is not necessarily needed with hw palettized texture support. */
136 surface_load_location(surface, SFLAG_INSYSMEM, NULL);
137 /* Make sure the texture is reloaded because of the palette change, this kills performance though :( */
138 surface_modify_location(surface, SFLAG_INTEXTURE, FALSE);
143 /* If the texture is marked dirty or the srgb sampler setting has changed
144 * since the last load then reload the surfaces. */
147 for (i = 0; i < texture->baseTexture.level_count; ++i)
149 surface_load((IWineD3DSurfaceImpl *)texture->baseTexture.sub_resources[i], srgb_mode);
154 TRACE("Texture %p not dirty, nothing to do.\n", texture);
157 if (context) context_release(context);
159 /* No longer dirty. */
163 static const struct wined3d_texture_ops texture_ops =
169 static void texture_cleanup(IWineD3DTextureImpl *This)
173 TRACE("(%p) : Cleaning up\n", This);
175 for (i = 0; i < This->baseTexture.level_count; ++i)
177 IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)This->baseTexture.sub_resources[i];
180 /* Clean out the texture name we gave to the surface so that the
181 * surface doesn't try and release it */
182 surface_set_texture_name(surface, 0, TRUE);
183 surface_set_texture_name(surface, 0, FALSE);
184 surface_set_texture_target(surface, 0);
185 surface_set_container(surface, WINED3D_CONTAINER_NONE, NULL);
186 IWineD3DSurface_Release((IWineD3DSurface *)surface);
190 TRACE("(%p) : Cleaning up base texture\n", This);
191 basetexture_cleanup((IWineD3DBaseTextureImpl *)This);
194 /* *******************************************
195 IWineD3DTexture IUnknown parts follow
196 ******************************************* */
198 static HRESULT WINAPI IWineD3DTextureImpl_QueryInterface(IWineD3DTexture *iface, REFIID riid, LPVOID *ppobj)
200 IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
201 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
202 if (IsEqualGUID(riid, &IID_IUnknown)
203 || IsEqualGUID(riid, &IID_IWineD3DBase)
204 || IsEqualGUID(riid, &IID_IWineD3DResource)
205 || IsEqualGUID(riid, &IID_IWineD3DBaseTexture)
206 || IsEqualGUID(riid, &IID_IWineD3DTexture)){
207 IUnknown_AddRef(iface);
212 return E_NOINTERFACE;
215 static ULONG WINAPI IWineD3DTextureImpl_AddRef(IWineD3DTexture *iface) {
216 IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
217 TRACE("(%p) : AddRef increasing from %d\n", This, This->resource.ref);
218 return InterlockedIncrement(&This->resource.ref);
221 /* Do not call while under the GL lock. */
222 static ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
223 IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
225 TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
226 ref = InterlockedDecrement(&This->resource.ref);
229 texture_cleanup(This);
230 This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
231 HeapFree(GetProcessHeap(), 0, This);
237 /* ****************************************************
238 IWineD3DTexture IWineD3DResource parts follow
239 **************************************************** */
240 static HRESULT WINAPI IWineD3DTextureImpl_SetPrivateData(IWineD3DTexture *iface,
241 REFGUID riid, const void *data, DWORD data_size, DWORD flags)
243 return resource_set_private_data((IWineD3DResourceImpl *)iface, riid, data, data_size, flags);
246 static HRESULT WINAPI IWineD3DTextureImpl_GetPrivateData(IWineD3DTexture *iface,
247 REFGUID guid, void *data, DWORD *data_size)
249 return resource_get_private_data((IWineD3DResourceImpl *)iface, guid, data, data_size);
252 static HRESULT WINAPI IWineD3DTextureImpl_FreePrivateData(IWineD3DTexture *iface, REFGUID refguid)
254 return resource_free_private_data((IWineD3DResourceImpl *)iface, refguid);
257 static DWORD WINAPI IWineD3DTextureImpl_SetPriority(IWineD3DTexture *iface, DWORD priority)
259 return resource_set_priority((IWineD3DResourceImpl *)iface, priority);
262 static DWORD WINAPI IWineD3DTextureImpl_GetPriority(IWineD3DTexture *iface)
264 return resource_get_priority((IWineD3DResourceImpl *)iface);
267 /* Do not call while under the GL lock. */
268 static void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface)
270 texture_preload((IWineD3DBaseTextureImpl *)iface, SRGB_ANY);
273 /* Do not call while under the GL lock. */
274 static void WINAPI IWineD3DTextureImpl_UnLoad(IWineD3DTexture *iface) {
276 IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
277 TRACE("(%p)\n", This);
279 /* Unload all the surfaces and reset the texture name. If UnLoad was called on the
280 * surface before, this one will be a NOP and vice versa. Unloading an unloaded
283 for (i = 0; i < This->baseTexture.level_count; ++i)
285 IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)This->baseTexture.sub_resources[i];
286 IWineD3DSurface_UnLoad((IWineD3DSurface *)surface);
287 surface_set_texture_name(surface, 0, FALSE); /* Delete rgb name */
288 surface_set_texture_name(surface, 0, TRUE); /* delete srgb name */
291 basetexture_unload((IWineD3DBaseTextureImpl *)This);
294 static WINED3DRESOURCETYPE WINAPI IWineD3DTextureImpl_GetType(IWineD3DTexture *iface)
296 return resource_get_type((IWineD3DResourceImpl *)iface);
299 static void * WINAPI IWineD3DTextureImpl_GetParent(IWineD3DTexture *iface)
301 TRACE("iface %p.\n", iface);
303 return ((IWineD3DTextureImpl *)iface)->resource.parent;
306 /* ******************************************************
307 IWineD3DTexture IWineD3DBaseTexture parts follow
308 ****************************************************** */
309 static DWORD WINAPI IWineD3DTextureImpl_SetLOD(IWineD3DTexture *iface, DWORD LODNew) {
310 return basetexture_set_lod((IWineD3DBaseTextureImpl *)iface, LODNew);
313 static DWORD WINAPI IWineD3DTextureImpl_GetLOD(IWineD3DTexture *iface) {
314 return basetexture_get_lod((IWineD3DBaseTextureImpl *)iface);
317 static DWORD WINAPI IWineD3DTextureImpl_GetLevelCount(IWineD3DTexture *iface)
319 return basetexture_get_level_count((IWineD3DBaseTextureImpl *)iface);
322 static HRESULT WINAPI IWineD3DTextureImpl_SetAutoGenFilterType(IWineD3DTexture *iface,
323 WINED3DTEXTUREFILTERTYPE FilterType)
325 return basetexture_set_autogen_filter_type((IWineD3DBaseTextureImpl *)iface, FilterType);
328 static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DTextureImpl_GetAutoGenFilterType(IWineD3DTexture *iface)
330 return basetexture_get_autogen_filter_type((IWineD3DBaseTextureImpl *)iface);
333 static void WINAPI IWineD3DTextureImpl_GenerateMipSubLevels(IWineD3DTexture *iface)
335 basetexture_generate_mipmaps((IWineD3DBaseTextureImpl *)iface);
338 static BOOL WINAPI IWineD3DTextureImpl_IsCondNP2(IWineD3DTexture *iface) {
339 IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
340 TRACE("(%p)\n", This);
342 return This->cond_np2;
345 static HRESULT WINAPI IWineD3DTextureImpl_GetLevelDesc(IWineD3DTexture *iface,
346 UINT sub_resource_idx, WINED3DSURFACE_DESC *desc)
348 IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
349 IWineD3DSurface *surface;
351 TRACE("iface %p, sub_resource_idx %u, desc %p.\n", iface, sub_resource_idx, desc);
353 if (!(surface = (IWineD3DSurface *)basetexture_get_sub_resource(texture, sub_resource_idx)))
355 WARN("Failed to get sub-resource.\n");
356 return WINED3DERR_INVALIDCALL;
359 IWineD3DSurface_GetDesc(surface, desc);
364 static HRESULT WINAPI IWineD3DTextureImpl_GetSurfaceLevel(IWineD3DTexture *iface,
365 UINT sub_resource_idx, IWineD3DSurface **surface)
367 IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
370 TRACE("iface %p, sub_resource_idx %u, surface %p.\n", iface, sub_resource_idx, surface);
372 if (!(s = (IWineD3DSurface *)basetexture_get_sub_resource(texture, sub_resource_idx)))
374 WARN("Failed to get sub-resource.\n");
375 return WINED3DERR_INVALIDCALL;
378 IWineD3DSurface_AddRef(s);
381 TRACE("Returning surface %p.\n", *surface);
386 static HRESULT WINAPI IWineD3DTextureImpl_Map(IWineD3DTexture *iface,
387 UINT sub_resource_idx, WINED3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
389 IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
390 IWineD3DSurface *surface;
392 TRACE("iface %p, sub_resource_idx %u, locked_rect %p, rect %s, flags %#x.\n",
393 iface, sub_resource_idx, locked_rect, wine_dbgstr_rect(rect), flags);
395 if (!(surface = (IWineD3DSurface *)basetexture_get_sub_resource(texture, sub_resource_idx)))
397 WARN("Failed to get sub-resource.\n");
398 return WINED3DERR_INVALIDCALL;
401 return IWineD3DSurface_Map(surface, locked_rect, rect, flags);
404 static HRESULT WINAPI IWineD3DTextureImpl_Unmap(IWineD3DTexture *iface, UINT sub_resource_idx)
406 IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
407 IWineD3DSurface *surface;
409 TRACE("iface %p, sub_resource_idx %u.\n", iface, sub_resource_idx);
411 if (!(surface = (IWineD3DSurface *)basetexture_get_sub_resource(texture, sub_resource_idx)))
413 WARN("Failed to get sub-resource.\n");
414 return WINED3DERR_INVALIDCALL;
417 return IWineD3DSurface_Unmap(surface);
420 static HRESULT WINAPI IWineD3DTextureImpl_AddDirtyRect(IWineD3DTexture *iface, const RECT *dirty_rect)
422 IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
423 IWineD3DSurfaceImpl *surface;
425 TRACE("iface %p, dirty_rect %s.\n", iface, wine_dbgstr_rect(dirty_rect));
427 if (!(surface = (IWineD3DSurfaceImpl *)basetexture_get_sub_resource(texture, 0)))
429 WARN("Failed to get sub-resource.\n");
430 return WINED3DERR_INVALIDCALL;
433 texture->baseTexture.texture_rgb.dirty = TRUE;
434 texture->baseTexture.texture_srgb.dirty = TRUE;
435 surface_add_dirty_rect(surface, dirty_rect);
440 static const IWineD3DTextureVtbl IWineD3DTexture_Vtbl =
443 IWineD3DTextureImpl_QueryInterface,
444 IWineD3DTextureImpl_AddRef,
445 IWineD3DTextureImpl_Release,
446 /* IWineD3DResource */
447 IWineD3DTextureImpl_GetParent,
448 IWineD3DTextureImpl_SetPrivateData,
449 IWineD3DTextureImpl_GetPrivateData,
450 IWineD3DTextureImpl_FreePrivateData,
451 IWineD3DTextureImpl_SetPriority,
452 IWineD3DTextureImpl_GetPriority,
453 IWineD3DTextureImpl_PreLoad,
454 IWineD3DTextureImpl_UnLoad,
455 IWineD3DTextureImpl_GetType,
456 /* IWineD3DBaseTexture */
457 IWineD3DTextureImpl_SetLOD,
458 IWineD3DTextureImpl_GetLOD,
459 IWineD3DTextureImpl_GetLevelCount,
460 IWineD3DTextureImpl_SetAutoGenFilterType,
461 IWineD3DTextureImpl_GetAutoGenFilterType,
462 IWineD3DTextureImpl_GenerateMipSubLevels,
463 IWineD3DTextureImpl_IsCondNP2,
464 /* IWineD3DTexture */
465 IWineD3DTextureImpl_GetLevelDesc,
466 IWineD3DTextureImpl_GetSurfaceLevel,
467 IWineD3DTextureImpl_Map,
468 IWineD3DTextureImpl_Unmap,
469 IWineD3DTextureImpl_AddDirtyRect
472 HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT levels,
473 IWineD3DDeviceImpl *device, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool,
474 void *parent, const struct wined3d_parent_ops *parent_ops)
476 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
477 const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
478 UINT pow2_width, pow2_height;
483 /* TODO: It should only be possible to create textures for formats
484 * that are reported as supported. */
485 if (WINED3DFMT_UNKNOWN >= format_id)
487 WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
488 return WINED3DERR_INVALIDCALL;
491 /* Non-power2 support. */
492 if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
495 pow2_height = height;
499 /* Find the nearest pow2 match. */
500 pow2_width = pow2_height = 1;
501 while (pow2_width < width) pow2_width <<= 1;
502 while (pow2_height < height) pow2_height <<= 1;
504 if (pow2_width != width || pow2_height != height)
508 WARN("Attempted to create a mipmapped np2 texture without unconditional np2 support.\n");
509 return WINED3DERR_INVALIDCALL;
515 /* Calculate levels for mip mapping. */
516 if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
518 if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
520 WARN("No mipmap generation support, returning WINED3DERR_INVALIDCALL.\n");
521 return WINED3DERR_INVALIDCALL;
526 WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning WINED3DERR_INVALIDCALL.\n");
527 return WINED3DERR_INVALIDCALL;
534 levels = wined3d_log2i(max(width, height)) + 1;
535 TRACE("Calculated levels = %u.\n", levels);
538 texture->lpVtbl = &IWineD3DTexture_Vtbl;
540 hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, &texture_ops,
541 1, levels, WINED3DRTYPE_TEXTURE, device, usage, format, pool,
545 WARN("Failed to initialize basetexture, returning %#x.\n", hr);
549 /* Precalculated scaling for 'faked' non power of two texture coords.
550 * Second also don't use ARB_TEXTURE_RECTANGLE in case the surface format is P8 and EXT_PALETTED_TEXTURE
551 * is used in combination with texture uploads (RTL_READTEX). The reason is that EXT_PALETTED_TEXTURE
552 * doesn't work in combination with ARB_TEXTURE_RECTANGLE. */
553 if (gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] && (width != pow2_width || height != pow2_height))
555 texture->baseTexture.pow2Matrix[0] = 1.0f;
556 texture->baseTexture.pow2Matrix[5] = 1.0f;
557 texture->baseTexture.pow2Matrix[10] = 1.0f;
558 texture->baseTexture.pow2Matrix[15] = 1.0f;
559 texture->baseTexture.target = GL_TEXTURE_2D;
560 texture->cond_np2 = TRUE;
561 texture->baseTexture.minMipLookup = minMipLookup_noFilter;
563 else if (gl_info->supported[ARB_TEXTURE_RECTANGLE] && (width != pow2_width || height != pow2_height)
564 && !(format->id == WINED3DFMT_P8_UINT && gl_info->supported[EXT_PALETTED_TEXTURE]
565 && wined3d_settings.rendertargetlock_mode == RTL_READTEX))
567 if ((width != 1) || (height != 1)) texture->baseTexture.pow2Matrix_identity = FALSE;
569 texture->baseTexture.pow2Matrix[0] = (float)width;
570 texture->baseTexture.pow2Matrix[5] = (float)height;
571 texture->baseTexture.pow2Matrix[10] = 1.0f;
572 texture->baseTexture.pow2Matrix[15] = 1.0f;
573 texture->baseTexture.target = GL_TEXTURE_RECTANGLE_ARB;
574 texture->cond_np2 = TRUE;
576 if (texture->resource.format->flags & WINED3DFMT_FLAG_FILTERING)
578 texture->baseTexture.minMipLookup = minMipLookup_noMip;
582 texture->baseTexture.minMipLookup = minMipLookup_noFilter;
587 if ((width != pow2_width) || (height != pow2_height))
589 texture->baseTexture.pow2Matrix_identity = FALSE;
590 texture->baseTexture.pow2Matrix[0] = (((float)width) / ((float)pow2_width));
591 texture->baseTexture.pow2Matrix[5] = (((float)height) / ((float)pow2_height));
595 texture->baseTexture.pow2Matrix[0] = 1.0f;
596 texture->baseTexture.pow2Matrix[5] = 1.0f;
599 texture->baseTexture.pow2Matrix[10] = 1.0f;
600 texture->baseTexture.pow2Matrix[15] = 1.0f;
601 texture->baseTexture.target = GL_TEXTURE_2D;
602 texture->cond_np2 = FALSE;
604 TRACE("xf(%f) yf(%f)\n", texture->baseTexture.pow2Matrix[0], texture->baseTexture.pow2Matrix[5]);
606 /* Generate all the surfaces. */
609 for (i = 0; i < texture->baseTexture.level_count; ++i)
611 IWineD3DSurface *surface;
613 /* Use the callback to create the texture surface. */
614 hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_h,
615 format->id, usage, pool, i, 0, &surface);
618 FIXME("Failed to create surface %p, hr %#x\n", texture, hr);
619 texture_cleanup(texture);
623 surface_set_container((IWineD3DSurfaceImpl *)surface, WINED3D_CONTAINER_TEXTURE, (IWineD3DBase *)texture);
624 surface_set_texture_target((IWineD3DSurfaceImpl *)surface, texture->baseTexture.target);
625 texture->baseTexture.sub_resources[i] = (IWineD3DResourceImpl *)surface;
626 TRACE("Created surface level %u @ %p.\n", i, surface);
627 /* Calculate the next mipmap level. */
628 tmp_w = max(1, tmp_w >> 1);
629 tmp_h = max(1, tmp_h >> 1);