2 * IWineD3DCubeTexture 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 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 static void cubetexture_internal_preload(IWineD3DBaseTexture
*iface
, enum WINED3DSRGB srgb
)
32 /* Override the IWineD3DResource Preload method. */
33 IWineD3DCubeTextureImpl
*This
= (IWineD3DCubeTextureImpl
*)iface
;
34 UINT sub_count
= This
->baseTexture
.level_count
* This
->baseTexture
.layer_count
;
35 IWineD3DDeviceImpl
*device
= This
->resource
.device
;
36 struct wined3d_context
*context
= NULL
;
48 cubetexture_internal_preload(iface
, SRGB_RGB
);
56 srgb_mode
= This
->baseTexture
.is_srgb
;
59 dirty
= srgb_mode
? &This
->baseTexture
.texture_srgb
.dirty
: &This
->baseTexture
.texture_rgb
.dirty
;
61 TRACE("(%p) : About to load texture: dirtified(%u).\n", This
, *dirty
);
63 /* We only have to activate a context for gl when we're not drawing.
64 * In most cases PreLoad will be called during draw and a context was
65 * activated at the beginning of drawPrimitive. */
66 if (!device
->isInDraw
)
68 /* No danger of recursive calls, context_acquire() sets isInDraw to true
69 * when loading offscreen render targets into their texture. */
70 context
= context_acquire(device
, NULL
);
73 if (This
->resource
.format_desc
->format
== WINED3DFMT_P8_UINT
74 || This
->resource
.format_desc
->format
== WINED3DFMT_P8_UINT_A8_UNORM
)
76 for (i
= 0; i
< sub_count
; ++i
)
78 IWineD3DSurfaceImpl
*surface
= (IWineD3DSurfaceImpl
*)This
->baseTexture
.sub_resources
[i
];
80 if (palette9_changed(surface
))
82 TRACE("Reloading surface %p because the d3d8/9 palette was changed.\n", surface
);
83 /* TODO: This is not necessarily needed with hw palettized texture support. */
84 IWineD3DSurface_LoadLocation((IWineD3DSurface
*)surface
, SFLAG_INSYSMEM
, NULL
);
85 /* Make sure the texture is reloaded because of the palette change,
86 * this kills performance though :( */
87 IWineD3DSurface_ModifyLocation((IWineD3DSurface
*)surface
, SFLAG_INTEXTURE
, FALSE
);
92 /* If the texture is marked dirty or the srgb sampler setting has changed
93 * since the last load then reload the surfaces. */
96 for (i
= 0; i
< sub_count
; ++i
)
98 IWineD3DSurface_LoadTexture((IWineD3DSurface
*)This
->baseTexture
.sub_resources
[i
], srgb_mode
);
103 TRACE("(%p) Texture not dirty, nothing to do.\n" , iface
);
106 /* No longer dirty. */
109 if (context
) context_release(context
);
112 static void cubetexture_cleanup(IWineD3DCubeTextureImpl
*This
)
114 UINT sub_count
= This
->baseTexture
.level_count
* This
->baseTexture
.layer_count
;
117 TRACE("(%p) : Cleaning up.\n", This
);
119 for (i
= 0; i
< sub_count
; ++i
)
121 IWineD3DSurfaceImpl
*surface
= (IWineD3DSurfaceImpl
*)This
->baseTexture
.sub_resources
[i
];
125 /* Clean out the texture name we gave to the surface so that the
126 * surface doesn't try and release it. */
127 surface_set_texture_name(surface
, 0, TRUE
);
128 surface_set_texture_name(surface
, 0, FALSE
);
129 surface_set_texture_target(surface
, 0);
130 IWineD3DSurface_SetContainer((IWineD3DSurface
*)surface
, NULL
);
131 IWineD3DSurface_Release((IWineD3DSurface
*)surface
);
134 basetexture_cleanup((IWineD3DBaseTexture
*)This
);
137 /* *******************************************
138 IWineD3DCubeTexture IUnknown parts follow
139 ******************************************* */
141 static HRESULT WINAPI
IWineD3DCubeTextureImpl_QueryInterface(IWineD3DCubeTexture
*iface
, REFIID riid
, LPVOID
*ppobj
)
143 IWineD3DCubeTextureImpl
*This
= (IWineD3DCubeTextureImpl
*)iface
;
144 TRACE("(%p)->(%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
145 if (IsEqualGUID(riid
, &IID_IUnknown
)
146 || IsEqualGUID(riid
, &IID_IWineD3DBase
)
147 || IsEqualGUID(riid
, &IID_IWineD3DResource
)
148 || IsEqualGUID(riid
, &IID_IWineD3DBaseTexture
)
149 || IsEqualGUID(riid
, &IID_IWineD3DCubeTexture
)) {
150 IUnknown_AddRef(iface
);
155 return E_NOINTERFACE
;
158 static ULONG WINAPI
IWineD3DCubeTextureImpl_AddRef(IWineD3DCubeTexture
*iface
) {
159 IWineD3DCubeTextureImpl
*This
= (IWineD3DCubeTextureImpl
*)iface
;
160 TRACE("(%p) : AddRef increasing from %d\n", This
, This
->resource
.ref
);
161 return InterlockedIncrement(&This
->resource
.ref
);
164 static ULONG WINAPI
IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture
*iface
) {
165 IWineD3DCubeTextureImpl
*This
= (IWineD3DCubeTextureImpl
*)iface
;
167 TRACE("(%p) : Releasing from %d\n", This
, This
->resource
.ref
);
168 ref
= InterlockedDecrement(&This
->resource
.ref
);
171 cubetexture_cleanup(This
);
172 This
->resource
.parent_ops
->wined3d_object_destroyed(This
->resource
.parent
);
173 HeapFree(GetProcessHeap(), 0, This
);
178 /* ****************************************************
179 IWineD3DCubeTexture IWineD3DResource parts follow
180 **************************************************** */
181 static HRESULT WINAPI
IWineD3DCubeTextureImpl_SetPrivateData(IWineD3DCubeTexture
*iface
, REFGUID refguid
, CONST
void* pData
, DWORD SizeOfData
, DWORD Flags
) {
182 return resource_set_private_data((IWineD3DResource
*)iface
, refguid
, pData
, SizeOfData
, Flags
);
185 static HRESULT WINAPI
IWineD3DCubeTextureImpl_GetPrivateData(IWineD3DCubeTexture
*iface
, REFGUID refguid
, void* pData
, DWORD
* pSizeOfData
) {
186 return resource_get_private_data((IWineD3DResource
*)iface
, refguid
, pData
, pSizeOfData
);
189 static HRESULT WINAPI
IWineD3DCubeTextureImpl_FreePrivateData(IWineD3DCubeTexture
*iface
, REFGUID refguid
) {
190 return resource_free_private_data((IWineD3DResource
*)iface
, refguid
);
193 static DWORD WINAPI
IWineD3DCubeTextureImpl_SetPriority(IWineD3DCubeTexture
*iface
, DWORD PriorityNew
) {
194 return resource_set_priority((IWineD3DResource
*)iface
, PriorityNew
);
197 static DWORD WINAPI
IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture
*iface
) {
198 return resource_get_priority((IWineD3DResource
*)iface
);
201 static void WINAPI
IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture
*iface
) {
202 cubetexture_internal_preload((IWineD3DBaseTexture
*) iface
, SRGB_ANY
);
205 static void WINAPI
IWineD3DCubeTextureImpl_UnLoad(IWineD3DCubeTexture
*iface
)
207 IWineD3DCubeTextureImpl
*This
= (IWineD3DCubeTextureImpl
*)iface
;
208 UINT sub_count
= This
->baseTexture
.level_count
* This
->baseTexture
.layer_count
;
211 TRACE("iface %p.\n", iface
);
213 /* Unload all the surfaces and reset the texture name. If UnLoad was called on the
214 * surface before, this one will be a NOP and vice versa. Unloading an unloaded
215 * surface is fine. */
217 for (i
= 0; i
< sub_count
; ++i
)
219 IWineD3DSurfaceImpl
*surface
= (IWineD3DSurfaceImpl
*)This
->baseTexture
.sub_resources
[i
];
221 IWineD3DSurface_UnLoad((IWineD3DSurface
*)surface
);
222 surface_set_texture_name(surface
, 0, TRUE
);
223 surface_set_texture_name(surface
, 0, FALSE
);
226 basetexture_unload((IWineD3DBaseTexture
*)iface
);
229 static WINED3DRESOURCETYPE WINAPI
IWineD3DCubeTextureImpl_GetType(IWineD3DCubeTexture
*iface
) {
230 return resource_get_type((IWineD3DResource
*)iface
);
233 static HRESULT WINAPI
IWineD3DCubeTextureImpl_GetParent(IWineD3DCubeTexture
*iface
, IUnknown
**pParent
) {
234 return resource_get_parent((IWineD3DResource
*)iface
, pParent
);
237 /* ******************************************************
238 IWineD3DCubeTexture IWineD3DBaseTexture parts follow
239 ****************************************************** */
240 static DWORD WINAPI
IWineD3DCubeTextureImpl_SetLOD(IWineD3DCubeTexture
*iface
, DWORD LODNew
) {
241 return basetexture_set_lod((IWineD3DBaseTexture
*)iface
, LODNew
);
244 static DWORD WINAPI
IWineD3DCubeTextureImpl_GetLOD(IWineD3DCubeTexture
*iface
) {
245 return basetexture_get_lod((IWineD3DBaseTexture
*)iface
);
248 static DWORD WINAPI
IWineD3DCubeTextureImpl_GetLevelCount(IWineD3DCubeTexture
*iface
) {
249 return basetexture_get_level_count((IWineD3DBaseTexture
*)iface
);
252 static HRESULT WINAPI
IWineD3DCubeTextureImpl_SetAutoGenFilterType(IWineD3DCubeTexture
*iface
, WINED3DTEXTUREFILTERTYPE FilterType
) {
253 return basetexture_set_autogen_filter_type((IWineD3DBaseTexture
*)iface
, FilterType
);
256 static WINED3DTEXTUREFILTERTYPE WINAPI
IWineD3DCubeTextureImpl_GetAutoGenFilterType(IWineD3DCubeTexture
*iface
) {
257 return basetexture_get_autogen_filter_type((IWineD3DBaseTexture
*)iface
);
260 static void WINAPI
IWineD3DCubeTextureImpl_GenerateMipSubLevels(IWineD3DCubeTexture
*iface
) {
261 basetexture_generate_mipmaps((IWineD3DBaseTexture
*)iface
);
264 /* Internal function, No d3d mapping */
265 static BOOL WINAPI
IWineD3DCubeTextureImpl_SetDirty(IWineD3DCubeTexture
*iface
, BOOL dirty
) {
266 return basetexture_set_dirty((IWineD3DBaseTexture
*)iface
, dirty
);
269 /* Internal function, No d3d mapping */
270 static BOOL WINAPI
IWineD3DCubeTextureImpl_GetDirty(IWineD3DCubeTexture
*iface
) {
271 return basetexture_get_dirty((IWineD3DBaseTexture
*)iface
);
274 /* Context activation is done by the caller. */
275 static HRESULT WINAPI
IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture
*iface
, BOOL srgb
) {
276 IWineD3DCubeTextureImpl
*This
= (IWineD3DCubeTextureImpl
*)iface
;
277 BOOL set_gl_texture_desc
;
280 TRACE("(%p) : relay to BaseTexture\n", This
);
282 hr
= basetexture_bind((IWineD3DBaseTexture
*)iface
, srgb
, &set_gl_texture_desc
);
283 if (set_gl_texture_desc
&& SUCCEEDED(hr
))
285 UINT sub_count
= This
->baseTexture
.level_count
* This
->baseTexture
.layer_count
;
288 for (i
= 0; i
< sub_count
; ++i
)
290 IWineD3DSurfaceImpl
*surface
= (IWineD3DSurfaceImpl
*)This
->baseTexture
.sub_resources
[i
];
292 if (This
->baseTexture
.is_srgb
)
293 surface_set_texture_name(surface
, This
->baseTexture
.texture_srgb
.name
, TRUE
);
295 surface_set_texture_name(surface
, This
->baseTexture
.texture_rgb
.name
, FALSE
);
302 static UINT WINAPI
IWineD3DCubeTextureImpl_GetTextureDimensions(IWineD3DCubeTexture
*iface
)
304 TRACE("iface %p.\n", iface
);
306 return GL_TEXTURE_CUBE_MAP_ARB
;
309 static BOOL WINAPI
IWineD3DCubeTextureImpl_IsCondNP2(IWineD3DCubeTexture
*iface
)
311 TRACE("iface %p.\n", iface
);
316 /* *******************************************
317 IWineD3DCubeTexture IWineD3DCubeTexture parts follow
318 ******************************************* */
319 static HRESULT WINAPI
IWineD3DCubeTextureImpl_GetLevelDesc(IWineD3DCubeTexture
*iface
,
320 UINT level
, WINED3DSURFACE_DESC
*desc
)
322 IWineD3DBaseTextureImpl
*texture
= (IWineD3DBaseTextureImpl
*)iface
;
323 IWineD3DSurface
*surface
;
325 TRACE("iface %p, level %u, desc %p.\n", iface
, level
, desc
);
327 if (!(surface
= (IWineD3DSurface
*)basetexture_get_sub_resource(texture
, 0, level
)))
329 WARN("Failed to get sub-resource.\n");
330 return WINED3DERR_INVALIDCALL
;
333 return IWineD3DSurface_GetDesc(surface
, desc
);
336 static HRESULT WINAPI
IWineD3DCubeTextureImpl_GetCubeMapSurface(IWineD3DCubeTexture
*iface
,
337 WINED3DCUBEMAP_FACES face
, UINT level
, IWineD3DSurface
**surface
)
339 IWineD3DBaseTextureImpl
*texture
= (IWineD3DBaseTextureImpl
*)iface
;
342 TRACE("iface %p, face %u, level %u, surface %p.\n",
343 iface
, face
, level
, surface
);
345 if (!(s
= (IWineD3DSurface
*)basetexture_get_sub_resource(texture
, face
, level
)))
347 WARN("Failed to get sub-resource.\n");
348 return WINED3DERR_INVALIDCALL
;
351 IWineD3DSurface_AddRef(s
);
354 TRACE("Returning surface %p.\n", *surface
);
359 static HRESULT WINAPI
IWineD3DCubeTextureImpl_LockRect(IWineD3DCubeTexture
*iface
,
360 WINED3DCUBEMAP_FACES face
, UINT level
, WINED3DLOCKED_RECT
*locked_rect
, const RECT
*rect
, DWORD flags
)
362 IWineD3DBaseTextureImpl
*texture
= (IWineD3DBaseTextureImpl
*)iface
;
363 IWineD3DSurface
*surface
;
365 TRACE("iface %p, face %u, level %u, locked_rect %p, rect %s, flags %#x.\n",
366 iface
, face
, level
, locked_rect
, wine_dbgstr_rect(rect
), flags
);
368 if (!(surface
= (IWineD3DSurface
*)basetexture_get_sub_resource(texture
, face
, level
)))
370 WARN("Failed to get sub-resource.\n");
371 return WINED3DERR_INVALIDCALL
;
374 return IWineD3DSurface_LockRect(surface
, locked_rect
, rect
, flags
);
377 static HRESULT WINAPI
IWineD3DCubeTextureImpl_UnlockRect(IWineD3DCubeTexture
*iface
,
378 WINED3DCUBEMAP_FACES face
, UINT level
)
380 IWineD3DBaseTextureImpl
*texture
= (IWineD3DBaseTextureImpl
*)iface
;
381 IWineD3DSurface
*surface
;
383 TRACE("iface %p, face %u, level %u.\n",
386 if (!(surface
= (IWineD3DSurface
*)basetexture_get_sub_resource(texture
, face
, level
)))
388 WARN("Failed to get sub-resource.\n");
389 return WINED3DERR_INVALIDCALL
;
392 return IWineD3DSurface_UnlockRect(surface
);
395 static HRESULT WINAPI
IWineD3DCubeTextureImpl_AddDirtyRect(IWineD3DCubeTexture
*iface
,
396 WINED3DCUBEMAP_FACES face
, const RECT
*dirty_rect
)
398 IWineD3DBaseTextureImpl
*texture
= (IWineD3DBaseTextureImpl
*)iface
;
399 IWineD3DSurfaceImpl
*surface
;
401 TRACE("iface %p, face %u, dirty_rect %s.\n",
402 iface
, face
, wine_dbgstr_rect(dirty_rect
));
404 if (!(surface
= (IWineD3DSurfaceImpl
*)basetexture_get_sub_resource(texture
, face
, 0)))
406 WARN("Failed to get sub-resource.\n");
407 return WINED3DERR_INVALIDCALL
;
410 texture
->baseTexture
.texture_rgb
.dirty
= TRUE
;
411 texture
->baseTexture
.texture_srgb
.dirty
= TRUE
;
412 surface_add_dirty_rect(surface
, dirty_rect
);
417 static const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl
=
420 IWineD3DCubeTextureImpl_QueryInterface
,
421 IWineD3DCubeTextureImpl_AddRef
,
422 IWineD3DCubeTextureImpl_Release
,
423 /* IWineD3DResource */
424 IWineD3DCubeTextureImpl_GetParent
,
425 IWineD3DCubeTextureImpl_SetPrivateData
,
426 IWineD3DCubeTextureImpl_GetPrivateData
,
427 IWineD3DCubeTextureImpl_FreePrivateData
,
428 IWineD3DCubeTextureImpl_SetPriority
,
429 IWineD3DCubeTextureImpl_GetPriority
,
430 IWineD3DCubeTextureImpl_PreLoad
,
431 IWineD3DCubeTextureImpl_UnLoad
,
432 IWineD3DCubeTextureImpl_GetType
,
433 /* IWineD3DBaseTexture */
434 IWineD3DCubeTextureImpl_SetLOD
,
435 IWineD3DCubeTextureImpl_GetLOD
,
436 IWineD3DCubeTextureImpl_GetLevelCount
,
437 IWineD3DCubeTextureImpl_SetAutoGenFilterType
,
438 IWineD3DCubeTextureImpl_GetAutoGenFilterType
,
439 IWineD3DCubeTextureImpl_GenerateMipSubLevels
,
440 IWineD3DCubeTextureImpl_SetDirty
,
441 IWineD3DCubeTextureImpl_GetDirty
,
442 IWineD3DCubeTextureImpl_BindTexture
,
443 IWineD3DCubeTextureImpl_GetTextureDimensions
,
444 IWineD3DCubeTextureImpl_IsCondNP2
,
445 /* IWineD3DCubeTexture */
446 IWineD3DCubeTextureImpl_GetLevelDesc
,
447 IWineD3DCubeTextureImpl_GetCubeMapSurface
,
448 IWineD3DCubeTextureImpl_LockRect
,
449 IWineD3DCubeTextureImpl_UnlockRect
,
450 IWineD3DCubeTextureImpl_AddDirtyRect
453 HRESULT
cubetexture_init(IWineD3DCubeTextureImpl
*texture
, UINT edge_length
, UINT levels
,
454 IWineD3DDeviceImpl
*device
, DWORD usage
, WINED3DFORMAT format
, WINED3DPOOL pool
,
455 IUnknown
*parent
, const struct wined3d_parent_ops
*parent_ops
)
457 const struct wined3d_gl_info
*gl_info
= &device
->adapter
->gl_info
;
458 const struct wined3d_format_desc
*format_desc
= getFormatDescEntry(format
, gl_info
);
459 UINT pow2_edge_length
;
464 /* TODO: It should only be possible to create textures for formats
465 * that are reported as supported. */
466 if (WINED3DFMT_UNKNOWN
>= format
)
468 WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture
);
469 return WINED3DERR_INVALIDCALL
;
472 if (!gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
] && pool
!= WINED3DPOOL_SCRATCH
)
474 WARN("(%p) : Tried to create not supported cube texture.\n", texture
);
475 return WINED3DERR_INVALIDCALL
;
478 /* Calculate levels for mip mapping */
479 if (usage
& WINED3DUSAGE_AUTOGENMIPMAP
)
481 if (!gl_info
->supported
[SGIS_GENERATE_MIPMAP
])
483 WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n");
484 return WINED3DERR_INVALIDCALL
;
489 WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning D3DERR_INVALIDCALL.\n");
490 return WINED3DERR_INVALIDCALL
;
497 levels
= wined3d_log2i(edge_length
) + 1;
498 TRACE("Calculated levels = %u.\n", levels
);
501 texture
->lpVtbl
= &IWineD3DCubeTexture_Vtbl
;
503 hr
= basetexture_init((IWineD3DBaseTextureImpl
*)texture
, 6, levels
,
504 WINED3DRTYPE_CUBETEXTURE
, device
, 0, usage
, format_desc
, pool
, parent
, parent_ops
);
507 WARN("Failed to initialize basetexture, returning %#x\n", hr
);
511 /* Find the nearest pow2 match. */
512 pow2_edge_length
= 1;
513 while (pow2_edge_length
< edge_length
) pow2_edge_length
<<= 1;
515 if (gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] || (edge_length
== pow2_edge_length
))
517 /* Precalculated scaling for 'faked' non power of two texture coords. */
518 texture
->baseTexture
.pow2Matrix
[0] = 1.0f
;
519 texture
->baseTexture
.pow2Matrix
[5] = 1.0f
;
520 texture
->baseTexture
.pow2Matrix
[10] = 1.0f
;
521 texture
->baseTexture
.pow2Matrix
[15] = 1.0f
;
525 /* Precalculated scaling for 'faked' non power of two texture coords. */
526 texture
->baseTexture
.pow2Matrix
[0] = ((float)edge_length
) / ((float)pow2_edge_length
);
527 texture
->baseTexture
.pow2Matrix
[5] = ((float)edge_length
) / ((float)pow2_edge_length
);
528 texture
->baseTexture
.pow2Matrix
[10] = ((float)edge_length
) / ((float)pow2_edge_length
);
529 texture
->baseTexture
.pow2Matrix
[15] = 1.0f
;
530 texture
->baseTexture
.pow2Matrix_identity
= FALSE
;
533 /* Generate all the surfaces. */
535 for (i
= 0; i
< texture
->baseTexture
.level_count
; ++i
)
537 /* Create the 6 faces. */
538 for (j
= 0; j
< 6; ++j
)
540 static const GLenum cube_targets
[6] =
542 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
,
543 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
,
544 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
,
545 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
,
546 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
,
547 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
,
549 UINT idx
= j
* texture
->baseTexture
.level_count
+ i
;
550 IWineD3DSurface
*surface
;
552 hr
= IWineD3DDeviceParent_CreateSurface(device
->device_parent
, parent
, tmp_w
, tmp_w
,
553 format
, usage
, pool
, i
/* Level */, j
, &surface
);
556 FIXME("(%p) Failed to create surface, hr %#x.\n", texture
, hr
);
557 cubetexture_cleanup(texture
);
561 IWineD3DSurface_SetContainer(surface
, (IWineD3DBase
*)texture
);
562 surface_set_texture_target((IWineD3DSurfaceImpl
*)surface
, cube_targets
[j
]);
563 texture
->baseTexture
.sub_resources
[idx
] = (IWineD3DResourceImpl
*)surface
;
564 TRACE("Created surface level %u @ %p.\n", i
, surface
);
566 tmp_w
= max(1, tmp_w
>> 1);
568 texture
->baseTexture
.internal_preload
= cubetexture_internal_preload
;