1 | /*
|
---|
2 | * IWineD3DVolume implementation
|
---|
3 | *
|
---|
4 | * Copyright 2002-2005 Jason Edmeades
|
---|
5 | * Copyright 2002-2005 Raphael Junqueira
|
---|
6 | * Copyright 2005 Oliver Stieber
|
---|
7 | * Copyright 2009 Henri Verbeet 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_surface);
|
---|
37 | #define GLINFO_LOCATION This->resource.device->adapter->gl_info
|
---|
38 |
|
---|
39 | /* Context activation is done by the caller. */
|
---|
40 | static void volume_bind_and_dirtify(IWineD3DVolume *iface) {
|
---|
41 | IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
---|
42 | const struct wined3d_gl_info *gl_info = &This->resource.device->adapter->gl_info;
|
---|
43 | IWineD3DVolumeTexture *texture;
|
---|
44 | DWORD active_sampler;
|
---|
45 |
|
---|
46 | /* We don't need a specific texture unit, but after binding the texture the current unit is dirty.
|
---|
47 | * Read the unit back instead of switching to 0, this avoids messing around with the state manager's
|
---|
48 | * gl states. The current texture unit should always be a valid one.
|
---|
49 | *
|
---|
50 | * To be more specific, this is tricky because we can implicitly be called
|
---|
51 | * from sampler() in state.c. This means we can't touch anything other than
|
---|
52 | * whatever happens to be the currently active texture, or we would risk
|
---|
53 | * marking already applied sampler states dirty again.
|
---|
54 | *
|
---|
55 | * TODO: Track the current active texture per GL context instead of using glGet
|
---|
56 | */
|
---|
57 | if (gl_info->supported[ARB_MULTITEXTURE])
|
---|
58 | {
|
---|
59 | GLint active_texture;
|
---|
60 | ENTER_GL();
|
---|
61 | glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
|
---|
62 | LEAVE_GL();
|
---|
63 | active_sampler = This->resource.device->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB];
|
---|
64 | } else {
|
---|
65 | active_sampler = 0;
|
---|
66 | }
|
---|
67 |
|
---|
68 | if (active_sampler != WINED3D_UNMAPPED_STAGE)
|
---|
69 | {
|
---|
70 | IWineD3DDeviceImpl_MarkStateDirty(This->resource.device, STATE_SAMPLER(active_sampler));
|
---|
71 | }
|
---|
72 |
|
---|
73 | if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DVolumeTexture, (void **)&texture))) {
|
---|
74 | IWineD3DVolumeTexture_BindTexture(texture, FALSE);
|
---|
75 | IWineD3DVolumeTexture_Release(texture);
|
---|
76 | } else {
|
---|
77 | ERR("Volume should be part of a volume texture\n");
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | void volume_add_dirty_box(IWineD3DVolume *iface, const WINED3DBOX *dirty_box)
|
---|
82 | {
|
---|
83 | IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
---|
84 |
|
---|
85 | This->dirty = TRUE;
|
---|
86 | if (dirty_box)
|
---|
87 | {
|
---|
88 | This->lockedBox.Left = min(This->lockedBox.Left, dirty_box->Left);
|
---|
89 | This->lockedBox.Top = min(This->lockedBox.Top, dirty_box->Top);
|
---|
90 | This->lockedBox.Front = min(This->lockedBox.Front, dirty_box->Front);
|
---|
91 | This->lockedBox.Right = max(This->lockedBox.Right, dirty_box->Right);
|
---|
92 | This->lockedBox.Bottom = max(This->lockedBox.Bottom, dirty_box->Bottom);
|
---|
93 | This->lockedBox.Back = max(This->lockedBox.Back, dirty_box->Back);
|
---|
94 | }
|
---|
95 | else
|
---|
96 | {
|
---|
97 | This->lockedBox.Left = 0;
|
---|
98 | This->lockedBox.Top = 0;
|
---|
99 | This->lockedBox.Front = 0;
|
---|
100 | This->lockedBox.Right = This->currentDesc.Width;
|
---|
101 | This->lockedBox.Bottom = This->currentDesc.Height;
|
---|
102 | This->lockedBox.Back = This->currentDesc.Depth;
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | /* *******************************************
|
---|
107 | IWineD3DVolume IUnknown parts follow
|
---|
108 | ******************************************* */
|
---|
109 | static HRESULT WINAPI IWineD3DVolumeImpl_QueryInterface(IWineD3DVolume *iface, REFIID riid, void **object)
|
---|
110 | {
|
---|
111 | TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
---|
112 |
|
---|
113 | if (IsEqualGUID(riid, &IID_IWineD3DVolume)
|
---|
114 | || IsEqualGUID(riid, &IID_IWineD3DResource)
|
---|
115 | || IsEqualGUID(riid, &IID_IWineD3DBase)
|
---|
116 | || IsEqualGUID(riid, &IID_IUnknown))
|
---|
117 | {
|
---|
118 | IUnknown_AddRef(iface);
|
---|
119 | *object = iface;
|
---|
120 | return S_OK;
|
---|
121 | }
|
---|
122 |
|
---|
123 | WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
---|
124 |
|
---|
125 | *object = NULL;
|
---|
126 | return E_NOINTERFACE;
|
---|
127 | }
|
---|
128 |
|
---|
129 | static ULONG WINAPI IWineD3DVolumeImpl_AddRef(IWineD3DVolume *iface) {
|
---|
130 | IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
---|
131 | TRACE("(%p) : AddRef increasing from %d\n", This, This->resource.ref);
|
---|
132 | return InterlockedIncrement(&This->resource.ref);
|
---|
133 | }
|
---|
134 |
|
---|
135 | static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
|
---|
136 | IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
---|
137 | ULONG ref;
|
---|
138 | TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
|
---|
139 | ref = InterlockedDecrement(&This->resource.ref);
|
---|
140 | if (ref == 0) {
|
---|
141 | resource_cleanup((IWineD3DResource *)iface);
|
---|
142 | This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
|
---|
143 | HeapFree(GetProcessHeap(), 0, This);
|
---|
144 | }
|
---|
145 | return ref;
|
---|
146 | }
|
---|
147 |
|
---|
148 | /* ****************************************************
|
---|
149 | IWineD3DVolume IWineD3DResource parts follow
|
---|
150 | **************************************************** */
|
---|
151 | static HRESULT WINAPI IWineD3DVolumeImpl_GetParent(IWineD3DVolume *iface, IUnknown **pParent) {
|
---|
152 | return resource_get_parent((IWineD3DResource *)iface, pParent);
|
---|
153 | }
|
---|
154 |
|
---|
155 | static HRESULT WINAPI IWineD3DVolumeImpl_SetPrivateData(IWineD3DVolume *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
|
---|
156 | return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
|
---|
157 | }
|
---|
158 |
|
---|
159 | static HRESULT WINAPI IWineD3DVolumeImpl_GetPrivateData(IWineD3DVolume *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
|
---|
160 | return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
|
---|
161 | }
|
---|
162 |
|
---|
163 | static HRESULT WINAPI IWineD3DVolumeImpl_FreePrivateData(IWineD3DVolume *iface, REFGUID refguid) {
|
---|
164 | return resource_free_private_data((IWineD3DResource *)iface, refguid);
|
---|
165 | }
|
---|
166 |
|
---|
167 | static DWORD WINAPI IWineD3DVolumeImpl_SetPriority(IWineD3DVolume *iface, DWORD PriorityNew) {
|
---|
168 | return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
|
---|
169 | }
|
---|
170 |
|
---|
171 | static DWORD WINAPI IWineD3DVolumeImpl_GetPriority(IWineD3DVolume *iface) {
|
---|
172 | return resource_get_priority((IWineD3DResource *)iface);
|
---|
173 | }
|
---|
174 |
|
---|
175 | static void WINAPI IWineD3DVolumeImpl_PreLoad(IWineD3DVolume *iface) {
|
---|
176 | FIXME("iface %p stub!\n", iface);
|
---|
177 | }
|
---|
178 |
|
---|
179 | static void WINAPI IWineD3DVolumeImpl_UnLoad(IWineD3DVolume *iface) {
|
---|
180 | /* The whole content is shadowed on This->resource.allocatedMemory, and the
|
---|
181 | * texture name is managed by the VolumeTexture container
|
---|
182 | */
|
---|
183 | TRACE("(%p): Nothing to do\n", iface);
|
---|
184 | }
|
---|
185 |
|
---|
186 | static WINED3DRESOURCETYPE WINAPI IWineD3DVolumeImpl_GetType(IWineD3DVolume *iface) {
|
---|
187 | return resource_get_type((IWineD3DResource *)iface);
|
---|
188 | }
|
---|
189 |
|
---|
190 | /* *******************************************
|
---|
191 | IWineD3DVolume parts follow
|
---|
192 | ******************************************* */
|
---|
193 | static HRESULT WINAPI IWineD3DVolumeImpl_GetContainer(IWineD3DVolume *iface, REFIID riid, void** ppContainer) {
|
---|
194 | IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
---|
195 |
|
---|
196 | TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
|
---|
197 |
|
---|
198 | if (!ppContainer) {
|
---|
199 | ERR("Called without a valid ppContainer.\n");
|
---|
200 | return E_FAIL;
|
---|
201 | }
|
---|
202 |
|
---|
203 | /* Although surfaces can be standalone, volumes can't */
|
---|
204 | if (!This->container) {
|
---|
205 | ERR("Volume without an container. Should not happen.\n");
|
---|
206 | return E_FAIL;
|
---|
207 | }
|
---|
208 |
|
---|
209 | TRACE("Relaying to QueryInterface\n");
|
---|
210 | return IUnknown_QueryInterface(This->container, riid, ppContainer);
|
---|
211 | }
|
---|
212 |
|
---|
213 | static HRESULT WINAPI IWineD3DVolumeImpl_GetDesc(IWineD3DVolume *iface, WINED3DVOLUME_DESC* pDesc) {
|
---|
214 | IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
---|
215 | TRACE("(%p) : copying into %p\n", This, pDesc);
|
---|
216 |
|
---|
217 | pDesc->Format = This->resource.format_desc->format;
|
---|
218 | pDesc->Type = This->resource.resourceType;
|
---|
219 | pDesc->Usage = This->resource.usage;
|
---|
220 | pDesc->Pool = This->resource.pool;
|
---|
221 | pDesc->Size = This->resource.size; /* dx8 only */
|
---|
222 | pDesc->Width = This->currentDesc.Width;
|
---|
223 | pDesc->Height = This->currentDesc.Height;
|
---|
224 | pDesc->Depth = This->currentDesc.Depth;
|
---|
225 |
|
---|
226 | return WINED3D_OK;
|
---|
227 | }
|
---|
228 |
|
---|
229 | static HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, WINED3DLOCKED_BOX* pLockedVolume, CONST WINED3DBOX* pBox, DWORD Flags) {
|
---|
230 | IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
---|
231 | FIXME("(%p) : pBox=%p stub\n", This, pBox);
|
---|
232 |
|
---|
233 | if(!This->resource.allocatedMemory) {
|
---|
234 | This->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->resource.size);
|
---|
235 | }
|
---|
236 |
|
---|
237 | /* fixme: should we really lock as such? */
|
---|
238 | TRACE("(%p) : box=%p, output pbox=%p, allMem=%p\n", This, pBox, pLockedVolume, This->resource.allocatedMemory);
|
---|
239 |
|
---|
240 | pLockedVolume->RowPitch = This->resource.format_desc->byte_count * This->currentDesc.Width; /* Bytes / row */
|
---|
241 | pLockedVolume->SlicePitch = This->resource.format_desc->byte_count
|
---|
242 | * This->currentDesc.Width * This->currentDesc.Height; /* Bytes / slice */
|
---|
243 | if (!pBox) {
|
---|
244 | TRACE("No box supplied - all is ok\n");
|
---|
245 | pLockedVolume->pBits = This->resource.allocatedMemory;
|
---|
246 | This->lockedBox.Left = 0;
|
---|
247 | This->lockedBox.Top = 0;
|
---|
248 | This->lockedBox.Front = 0;
|
---|
249 | This->lockedBox.Right = This->currentDesc.Width;
|
---|
250 | This->lockedBox.Bottom = This->currentDesc.Height;
|
---|
251 | This->lockedBox.Back = This->currentDesc.Depth;
|
---|
252 | } else {
|
---|
253 | TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n", pBox, pBox->Left, pBox->Top, pBox->Right, pBox->Bottom, pBox->Front, pBox->Back);
|
---|
254 | pLockedVolume->pBits = This->resource.allocatedMemory
|
---|
255 | + (pLockedVolume->SlicePitch * pBox->Front) /* FIXME: is front < back or vica versa? */
|
---|
256 | + (pLockedVolume->RowPitch * pBox->Top)
|
---|
257 | + (pBox->Left * This->resource.format_desc->byte_count);
|
---|
258 | This->lockedBox.Left = pBox->Left;
|
---|
259 | This->lockedBox.Top = pBox->Top;
|
---|
260 | This->lockedBox.Front = pBox->Front;
|
---|
261 | This->lockedBox.Right = pBox->Right;
|
---|
262 | This->lockedBox.Bottom = pBox->Bottom;
|
---|
263 | This->lockedBox.Back = pBox->Back;
|
---|
264 | }
|
---|
265 |
|
---|
266 | if (Flags & (WINED3DLOCK_NO_DIRTY_UPDATE | WINED3DLOCK_READONLY)) {
|
---|
267 | /* Don't dirtify */
|
---|
268 | } else {
|
---|
269 | /**
|
---|
270 | * Dirtify on lock
|
---|
271 | * as seen in msdn docs
|
---|
272 | */
|
---|
273 | volume_add_dirty_box(iface, &This->lockedBox);
|
---|
274 |
|
---|
275 | /** Dirtify Container if needed */
|
---|
276 | if (NULL != This->container) {
|
---|
277 |
|
---|
278 | IWineD3DVolumeTexture *cont = (IWineD3DVolumeTexture*) This->container;
|
---|
279 | WINED3DRESOURCETYPE containerType = IWineD3DBaseTexture_GetType((IWineD3DBaseTexture *) cont);
|
---|
280 |
|
---|
281 | if (containerType == WINED3DRTYPE_VOLUMETEXTURE) {
|
---|
282 | IWineD3DBaseTextureImpl* pTexture = (IWineD3DBaseTextureImpl*) cont;
|
---|
283 | pTexture->baseTexture.texture_rgb.dirty = TRUE;
|
---|
284 | pTexture->baseTexture.texture_srgb.dirty = TRUE;
|
---|
285 | } else {
|
---|
286 | FIXME("Set dirty on container type %d\n", containerType);
|
---|
287 | }
|
---|
288 | }
|
---|
289 | }
|
---|
290 |
|
---|
291 | This->locked = TRUE;
|
---|
292 | TRACE("returning memory@%p rpitch(%d) spitch(%d)\n", pLockedVolume->pBits, pLockedVolume->RowPitch, pLockedVolume->SlicePitch);
|
---|
293 | return WINED3D_OK;
|
---|
294 | }
|
---|
295 |
|
---|
296 | static HRESULT WINAPI IWineD3DVolumeImpl_UnlockBox(IWineD3DVolume *iface) {
|
---|
297 | IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
---|
298 | if (!This->locked)
|
---|
299 | {
|
---|
300 | WARN("Trying to unlock unlocked volume %p.\n", iface);
|
---|
301 | return WINED3DERR_INVALIDCALL;
|
---|
302 | }
|
---|
303 | TRACE("(%p) : unlocking volume\n", This);
|
---|
304 | This->locked = FALSE;
|
---|
305 | memset(&This->lockedBox, 0, sizeof(RECT));
|
---|
306 | return WINED3D_OK;
|
---|
307 | }
|
---|
308 |
|
---|
309 | /* Internal use functions follow : */
|
---|
310 |
|
---|
311 | static HRESULT WINAPI IWineD3DVolumeImpl_SetContainer(IWineD3DVolume *iface, IWineD3DBase* container) {
|
---|
312 | IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
---|
313 |
|
---|
314 | TRACE("This %p, container %p\n", This, container);
|
---|
315 |
|
---|
316 | /* We can't keep a reference to the container, since the container already keeps a reference to us. */
|
---|
317 |
|
---|
318 | TRACE("Setting container to %p from %p\n", container, This->container);
|
---|
319 | This->container = container;
|
---|
320 |
|
---|
321 | return WINED3D_OK;
|
---|
322 | }
|
---|
323 |
|
---|
324 | /* Context activation is done by the caller. */
|
---|
325 | static HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, int gl_level, BOOL srgb_mode) {
|
---|
326 | IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
---|
327 | const struct wined3d_format_desc *glDesc = This->resource.format_desc;
|
---|
328 |
|
---|
329 | TRACE("(%p) : level %u, format %s (0x%08x)\n", This, gl_level, debug_d3dformat(glDesc->format), glDesc->format);
|
---|
330 |
|
---|
331 | volume_bind_and_dirtify(iface);
|
---|
332 |
|
---|
333 | TRACE("Calling glTexImage3D %x level=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%x, Mem=%p\n",
|
---|
334 | GL_TEXTURE_3D,
|
---|
335 | gl_level,
|
---|
336 | glDesc->glInternal,
|
---|
337 | This->currentDesc.Width,
|
---|
338 | This->currentDesc.Height,
|
---|
339 | This->currentDesc.Depth,
|
---|
340 | 0,
|
---|
341 | glDesc->glFormat,
|
---|
342 | glDesc->glType,
|
---|
343 | This->resource.allocatedMemory);
|
---|
344 |
|
---|
345 | ENTER_GL();
|
---|
346 | GL_EXTCALL(glTexImage3DEXT(GL_TEXTURE_3D,
|
---|
347 | gl_level,
|
---|
348 | glDesc->glInternal,
|
---|
349 | This->currentDesc.Width,
|
---|
350 | This->currentDesc.Height,
|
---|
351 | This->currentDesc.Depth,
|
---|
352 | 0,
|
---|
353 | glDesc->glFormat,
|
---|
354 | glDesc->glType,
|
---|
355 | This->resource.allocatedMemory));
|
---|
356 | checkGLcall("glTexImage3D");
|
---|
357 | LEAVE_GL();
|
---|
358 |
|
---|
359 | /* When adding code releasing This->resource.allocatedMemory to save data keep in mind that
|
---|
360 | * GL_UNPACK_CLIENT_STORAGE_APPLE is enabled by default if supported(GL_APPLE_client_storage).
|
---|
361 | * Thus do not release This->resource.allocatedMemory if GL_APPLE_client_storage is supported.
|
---|
362 | */
|
---|
363 | return WINED3D_OK;
|
---|
364 |
|
---|
365 | }
|
---|
366 |
|
---|
367 | static const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl =
|
---|
368 | {
|
---|
369 | /* IUnknown */
|
---|
370 | IWineD3DVolumeImpl_QueryInterface,
|
---|
371 | IWineD3DVolumeImpl_AddRef,
|
---|
372 | IWineD3DVolumeImpl_Release,
|
---|
373 | /* IWineD3DResource */
|
---|
374 | IWineD3DVolumeImpl_GetParent,
|
---|
375 | IWineD3DVolumeImpl_SetPrivateData,
|
---|
376 | IWineD3DVolumeImpl_GetPrivateData,
|
---|
377 | IWineD3DVolumeImpl_FreePrivateData,
|
---|
378 | IWineD3DVolumeImpl_SetPriority,
|
---|
379 | IWineD3DVolumeImpl_GetPriority,
|
---|
380 | IWineD3DVolumeImpl_PreLoad,
|
---|
381 | IWineD3DVolumeImpl_UnLoad,
|
---|
382 | IWineD3DVolumeImpl_GetType,
|
---|
383 | /* IWineD3DVolume */
|
---|
384 | IWineD3DVolumeImpl_GetContainer,
|
---|
385 | IWineD3DVolumeImpl_GetDesc,
|
---|
386 | IWineD3DVolumeImpl_LockBox,
|
---|
387 | IWineD3DVolumeImpl_UnlockBox,
|
---|
388 | /* Internal interface */
|
---|
389 | IWineD3DVolumeImpl_LoadTexture,
|
---|
390 | IWineD3DVolumeImpl_SetContainer
|
---|
391 | };
|
---|
392 |
|
---|
393 | HRESULT volume_init(IWineD3DVolumeImpl *volume, IWineD3DDeviceImpl *device, UINT width,
|
---|
394 | UINT height, UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
|
---|
395 | IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
|
---|
396 | {
|
---|
397 | const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
---|
398 | const struct wined3d_format_desc *format_desc = getFormatDescEntry(format, gl_info);
|
---|
399 | HRESULT hr;
|
---|
400 |
|
---|
401 | if (!gl_info->supported[EXT_TEXTURE3D])
|
---|
402 | {
|
---|
403 | WARN("Volume cannot be created - no volume texture support.\n");
|
---|
404 | return WINED3DERR_INVALIDCALL;
|
---|
405 | }
|
---|
406 |
|
---|
407 | volume->lpVtbl = &IWineD3DVolume_Vtbl;
|
---|
408 |
|
---|
409 | hr = resource_init((IWineD3DResource *)volume, WINED3DRTYPE_VOLUME, device,
|
---|
410 | width * height * depth * format_desc->byte_count, usage, format_desc, pool, parent, parent_ops
|
---|
411 | #ifdef VBOX_WITH_WDDM
|
---|
412 | , NULL, NULL
|
---|
413 | #endif
|
---|
414 | );
|
---|
415 | if (FAILED(hr))
|
---|
416 | {
|
---|
417 | WARN("Failed to initialize resource, returning %#x.\n", hr);
|
---|
418 | return hr;
|
---|
419 | }
|
---|
420 |
|
---|
421 | volume->currentDesc.Width = width;
|
---|
422 | volume->currentDesc.Height = height;
|
---|
423 | volume->currentDesc.Depth = depth;
|
---|
424 | volume->lockable = TRUE;
|
---|
425 | volume->locked = FALSE;
|
---|
426 | memset(&volume->lockedBox, 0, sizeof(volume->lockedBox));
|
---|
427 | volume->dirty = TRUE;
|
---|
428 |
|
---|
429 | volume_add_dirty_box((IWineD3DVolume *)volume, NULL);
|
---|
430 |
|
---|
431 | return WINED3D_OK;
|
---|
432 | }
|
---|