mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
d3d9: Add a separate function for volume texture initialization.
This commit is contained in:
parent
83b3d4f27a
commit
5b7b4f59d2
3 changed files with 54 additions and 40 deletions
|
@ -200,9 +200,6 @@ extern UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(IDirect3DDevice9Ex
|
||||||
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(IDirect3DDevice9Ex *iface,
|
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(IDirect3DDevice9Ex *iface,
|
||||||
UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
|
UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
|
||||||
IDirect3DTexture9 **ppTexture, HANDLE *pSharedHandle) DECLSPEC_HIDDEN;
|
IDirect3DTexture9 **ppTexture, HANDLE *pSharedHandle) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(IDirect3DDevice9Ex *iface,
|
|
||||||
UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format,
|
|
||||||
D3DPOOL Pool, IDirect3DVolumeTexture9 **ppVolumeTexture, HANDLE *pSharedHandle) DECLSPEC_HIDDEN;
|
|
||||||
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(IDirect3DDevice9Ex *iface,
|
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(IDirect3DDevice9Ex *iface,
|
||||||
UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
|
UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
|
||||||
IDirect3DCubeTexture9 **ppCubeTexture, HANDLE *pSharedHandle) DECLSPEC_HIDDEN;
|
IDirect3DCubeTexture9 **ppCubeTexture, HANDLE *pSharedHandle) DECLSPEC_HIDDEN;
|
||||||
|
@ -465,6 +462,9 @@ typedef struct IDirect3DVolumeTexture9Impl
|
||||||
LPDIRECT3DDEVICE9EX parentDevice;
|
LPDIRECT3DDEVICE9EX parentDevice;
|
||||||
} IDirect3DVolumeTexture9Impl;
|
} IDirect3DVolumeTexture9Impl;
|
||||||
|
|
||||||
|
HRESULT volumetexture_init(IDirect3DVolumeTexture9Impl *texture, IDirect3DDevice9Impl *device,
|
||||||
|
UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/* ----------------------- */
|
/* ----------------------- */
|
||||||
/* IDirect3DStateBlock9 */
|
/* IDirect3DStateBlock9 */
|
||||||
/* ----------------------- */
|
/* ----------------------- */
|
||||||
|
|
|
@ -644,6 +644,40 @@ static void WINAPI IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9EX iface,
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(IDirect3DDevice9Ex *iface,
|
||||||
|
UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format,
|
||||||
|
D3DPOOL pool, IDirect3DVolumeTexture9 **texture, HANDLE *shared_handle)
|
||||||
|
{
|
||||||
|
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
||||||
|
IDirect3DVolumeTexture9Impl *object;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
TRACE("iface %p, width %u, height %u, depth %u, levels %u\n",
|
||||||
|
iface, width, height, depth, levels);
|
||||||
|
TRACE("usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
|
||||||
|
usage, format, pool, texture, shared_handle);
|
||||||
|
|
||||||
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
||||||
|
if (!object)
|
||||||
|
{
|
||||||
|
ERR("Failed to allocate volume texture memory.\n");
|
||||||
|
return D3DERR_OUTOFVIDEOMEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = volumetexture_init(object, This, width, height, depth, levels, usage, format, pool);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
WARN("Failed to initialize volume texture, hr %#x.\n", hr);
|
||||||
|
HeapFree(GetProcessHeap(), 0, object);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE("Created volume texture %p.\n", object);
|
||||||
|
*texture = (IDirect3DVolumeTexture9 *)object;
|
||||||
|
|
||||||
|
return D3D_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static HRESULT IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height,
|
static HRESULT IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height,
|
||||||
D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface9 **ppSurface,
|
D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface9 **ppSurface,
|
||||||
UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality)
|
UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality)
|
||||||
|
|
|
@ -403,47 +403,27 @@ static const IDirect3DVolumeTexture9Vtbl Direct3DVolumeTexture9_Vtbl =
|
||||||
IDirect3DVolumeTexture9Impl_AddDirtyBox
|
IDirect3DVolumeTexture9Impl_AddDirtyBox
|
||||||
};
|
};
|
||||||
|
|
||||||
|
HRESULT volumetexture_init(IDirect3DVolumeTexture9Impl *texture, IDirect3DDevice9Impl *device,
|
||||||
/* IDirect3DDevice9 IDirect3DVolumeTexture9 Methods follow: */
|
UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
|
||||||
HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(IDirect3DDevice9Ex *iface,
|
|
||||||
UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format,
|
|
||||||
D3DPOOL Pool, IDirect3DVolumeTexture9 **ppVolumeTexture, HANDLE *pSharedHandle)
|
|
||||||
{
|
{
|
||||||
IDirect3DVolumeTexture9Impl *object;
|
HRESULT hr;
|
||||||
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
|
||||||
HRESULT hrc = D3D_OK;
|
|
||||||
|
|
||||||
TRACE("(%p) Relay\n", This);
|
texture->lpVtbl = &Direct3DVolumeTexture9_Vtbl;
|
||||||
|
texture->ref = 1;
|
||||||
/* Allocate the storage for the device */
|
|
||||||
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture9Impl));
|
|
||||||
if (NULL == object) {
|
|
||||||
ERR("(%p) allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n", This);
|
|
||||||
return D3DERR_OUTOFVIDEOMEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
object->lpVtbl = &Direct3DVolumeTexture9_Vtbl;
|
|
||||||
object->ref = 1;
|
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
|
hr = IWineD3DDevice_CreateVolumeTexture(device->WineD3DDevice, width, height, depth, levels,
|
||||||
hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels,
|
usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format),
|
||||||
Usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(Format),
|
pool, &texture->wineD3DVolumeTexture, (IUnknown *)texture);
|
||||||
Pool, &object->wineD3DVolumeTexture, (IUnknown *)object);
|
|
||||||
|
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
if (FAILED(hr))
|
||||||
if (hrc != D3D_OK) {
|
{
|
||||||
|
WARN("Failed to create wined3d volume texture, hr %#x.\n", hr);
|
||||||
/* free up object */
|
return hr;
|
||||||
WARN("(%p) call to IWineD3DDevice_CreateVolumeTexture failed\n", This);
|
|
||||||
HeapFree(GetProcessHeap(), 0, object);
|
|
||||||
} else {
|
|
||||||
IDirect3DDevice9Ex_AddRef(iface);
|
|
||||||
object->parentDevice = iface;
|
|
||||||
*ppVolumeTexture = (LPDIRECT3DVOLUMETEXTURE9) object;
|
|
||||||
TRACE("(%p) : Created volume texture %p\n", This, object);
|
|
||||||
}
|
}
|
||||||
TRACE("(%p) returning %p\n", This , *ppVolumeTexture);
|
|
||||||
return hrc;
|
texture->parentDevice = (IDirect3DDevice9Ex *)device;
|
||||||
|
IDirect3DDevice9Ex_AddRef(texture->parentDevice);
|
||||||
|
|
||||||
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue