2005-01-17 14:44:57 +01:00
|
|
|
/*
|
|
|
|
* IWineD3DVolume implementation
|
|
|
|
*
|
|
|
|
* Copyright 2002-2005 Jason Edmeades
|
2005-03-29 21:01:00 +02:00
|
|
|
* Copyright 2002-2005 Raphael Junqueira
|
2005-07-13 16:15:54 +02:00
|
|
|
* Copyright 2005 Oliver Stieber
|
2009-09-16 08:37:16 +02:00
|
|
|
* Copyright 2009 Henri Verbeet for CodeWeavers
|
2005-01-17 14:44:57 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-01-17 14:44:57 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wined3d_private.h"
|
|
|
|
|
2008-09-17 17:51:44 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
|
2010-05-24 09:56:36 +02:00
|
|
|
|
2009-06-26 10:07:12 +02:00
|
|
|
/* Context activation is done by the caller. */
|
2008-09-17 17:50:40 +02:00
|
|
|
static void volume_bind_and_dirtify(IWineD3DVolume *iface) {
|
|
|
|
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
2009-12-09 20:32:08 +01:00
|
|
|
const struct wined3d_gl_info *gl_info = &This->resource.device->adapter->gl_info;
|
2009-08-17 09:39:07 +02:00
|
|
|
DWORD active_sampler;
|
2008-09-17 17:50:40 +02:00
|
|
|
|
|
|
|
/* We don't need a specific texture unit, but after binding the texture the current unit is dirty.
|
|
|
|
* Read the unit back instead of switching to 0, this avoids messing around with the state manager's
|
|
|
|
* gl states. The current texture unit should always be a valid one.
|
|
|
|
*
|
|
|
|
* To be more specific, this is tricky because we can implicitly be called
|
|
|
|
* from sampler() in state.c. This means we can't touch anything other than
|
|
|
|
* whatever happens to be the currently active texture, or we would risk
|
|
|
|
* marking already applied sampler states dirty again.
|
|
|
|
*
|
|
|
|
* TODO: Track the current active texture per GL context instead of using glGet
|
|
|
|
*/
|
2009-10-29 10:37:11 +01:00
|
|
|
if (gl_info->supported[ARB_MULTITEXTURE])
|
|
|
|
{
|
2008-09-17 17:50:40 +02:00
|
|
|
GLint active_texture;
|
|
|
|
ENTER_GL();
|
|
|
|
glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
|
|
|
|
LEAVE_GL();
|
2009-12-09 20:32:08 +01:00
|
|
|
active_sampler = This->resource.device->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB];
|
2008-09-17 17:50:40 +02:00
|
|
|
} else {
|
|
|
|
active_sampler = 0;
|
|
|
|
}
|
|
|
|
|
2009-08-17 09:39:07 +02:00
|
|
|
if (active_sampler != WINED3D_UNMAPPED_STAGE)
|
|
|
|
{
|
2009-12-09 20:32:08 +01:00
|
|
|
IWineD3DDeviceImpl_MarkStateDirty(This->resource.device, STATE_SAMPLER(active_sampler));
|
2008-09-17 17:50:40 +02:00
|
|
|
}
|
|
|
|
|
2010-08-16 20:00:24 +02:00
|
|
|
IWineD3DVolumeTexture_BindTexture((IWineD3DVolumeTexture *)This->container, FALSE);
|
2008-09-17 17:50:40 +02:00
|
|
|
}
|
|
|
|
|
2009-01-14 10:01:10 +01:00
|
|
|
void volume_add_dirty_box(IWineD3DVolume *iface, const WINED3DBOX *dirty_box)
|
|
|
|
{
|
|
|
|
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
|
|
|
|
|
|
|
This->dirty = TRUE;
|
|
|
|
if (dirty_box)
|
|
|
|
{
|
|
|
|
This->lockedBox.Left = min(This->lockedBox.Left, dirty_box->Left);
|
|
|
|
This->lockedBox.Top = min(This->lockedBox.Top, dirty_box->Top);
|
|
|
|
This->lockedBox.Front = min(This->lockedBox.Front, dirty_box->Front);
|
|
|
|
This->lockedBox.Right = max(This->lockedBox.Right, dirty_box->Right);
|
|
|
|
This->lockedBox.Bottom = max(This->lockedBox.Bottom, dirty_box->Bottom);
|
|
|
|
This->lockedBox.Back = max(This->lockedBox.Back, dirty_box->Back);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
This->lockedBox.Left = 0;
|
|
|
|
This->lockedBox.Top = 0;
|
|
|
|
This->lockedBox.Front = 0;
|
|
|
|
This->lockedBox.Right = This->currentDesc.Width;
|
|
|
|
This->lockedBox.Bottom = This->currentDesc.Height;
|
|
|
|
This->lockedBox.Back = This->currentDesc.Depth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-16 20:00:24 +02:00
|
|
|
void volume_set_container(IWineD3DVolumeImpl *volume, struct IWineD3DVolumeTextureImpl *container)
|
2010-08-16 20:00:22 +02:00
|
|
|
{
|
|
|
|
TRACE("volume %p, container %p.\n", volume, container);
|
|
|
|
|
|
|
|
volume->container = container;
|
|
|
|
}
|
|
|
|
|
2005-01-17 14:44:57 +01:00
|
|
|
/* *******************************************
|
|
|
|
IWineD3DVolume IUnknown parts follow
|
|
|
|
******************************************* */
|
2009-12-21 23:17:24 +01:00
|
|
|
static HRESULT WINAPI IWineD3DVolumeImpl_QueryInterface(IWineD3DVolume *iface, REFIID riid, void **object)
|
2005-01-17 14:44:57 +01:00
|
|
|
{
|
2009-12-21 23:17:24 +01:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IWineD3DVolume)
|
|
|
|
|| IsEqualGUID(riid, &IID_IWineD3DResource)
|
|
|
|
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
2005-03-02 14:44:58 +01:00
|
|
|
IUnknown_AddRef(iface);
|
2009-12-21 23:17:24 +01:00
|
|
|
*object = iface;
|
2006-04-25 23:59:12 +02:00
|
|
|
return S_OK;
|
2005-03-02 14:44:58 +01:00
|
|
|
}
|
2009-12-21 23:17:24 +01:00
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
*object = NULL;
|
2005-01-17 14:44:57 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2006-06-10 13:15:32 +02:00
|
|
|
static ULONG WINAPI IWineD3DVolumeImpl_AddRef(IWineD3DVolume *iface) {
|
2005-01-17 14:44:57 +01:00
|
|
|
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
2006-10-01 05:20:10 +02:00
|
|
|
TRACE("(%p) : AddRef increasing from %d\n", This, This->resource.ref);
|
2005-03-29 21:01:00 +02:00
|
|
|
return InterlockedIncrement(&This->resource.ref);
|
2005-01-17 14:44:57 +01:00
|
|
|
}
|
|
|
|
|
2006-06-10 13:15:32 +02:00
|
|
|
static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
|
2005-01-17 14:44:57 +01:00
|
|
|
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
|
|
|
ULONG ref;
|
2006-10-01 05:20:10 +02:00
|
|
|
TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
|
2005-03-29 21:01:00 +02:00
|
|
|
ref = InterlockedDecrement(&This->resource.ref);
|
2005-01-17 14:44:57 +01:00
|
|
|
if (ref == 0) {
|
2008-12-02 18:41:33 +01:00
|
|
|
resource_cleanup((IWineD3DResource *)iface);
|
2009-09-17 23:03:33 +02:00
|
|
|
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
|
2005-01-17 14:44:57 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2005-03-29 21:01:00 +02:00
|
|
|
/* ****************************************************
|
2005-07-13 16:15:54 +02:00
|
|
|
IWineD3DVolume IWineD3DResource parts follow
|
2005-03-29 21:01:00 +02:00
|
|
|
**************************************************** */
|
2006-06-10 13:15:32 +02:00
|
|
|
static HRESULT WINAPI IWineD3DVolumeImpl_GetParent(IWineD3DVolume *iface, IUnknown **pParent) {
|
2008-12-02 18:41:33 +01:00
|
|
|
return resource_get_parent((IWineD3DResource *)iface, pParent);
|
2005-01-17 14:44:57 +01:00
|
|
|
}
|
|
|
|
|
2006-06-10 13:15:32 +02:00
|
|
|
static HRESULT WINAPI IWineD3DVolumeImpl_SetPrivateData(IWineD3DVolume *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
|
2008-12-02 18:41:33 +01:00
|
|
|
return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
|
2005-01-17 14:44:57 +01:00
|
|
|
}
|
|
|
|
|
2006-06-10 13:15:32 +02:00
|
|
|
static HRESULT WINAPI IWineD3DVolumeImpl_GetPrivateData(IWineD3DVolume *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
|
2008-12-02 18:41:33 +01:00
|
|
|
return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
|
2005-01-17 14:44:57 +01:00
|
|
|
}
|
|
|
|
|
2006-06-10 13:15:32 +02:00
|
|
|
static HRESULT WINAPI IWineD3DVolumeImpl_FreePrivateData(IWineD3DVolume *iface, REFGUID refguid) {
|
2008-12-02 18:41:33 +01:00
|
|
|
return resource_free_private_data((IWineD3DResource *)iface, refguid);
|
2005-03-29 21:01:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 13:15:32 +02:00
|
|
|
static DWORD WINAPI IWineD3DVolumeImpl_SetPriority(IWineD3DVolume *iface, DWORD PriorityNew) {
|
2008-12-02 18:41:33 +01:00
|
|
|
return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
|
2005-03-29 21:01:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 13:15:32 +02:00
|
|
|
static DWORD WINAPI IWineD3DVolumeImpl_GetPriority(IWineD3DVolume *iface) {
|
2008-12-02 18:41:33 +01:00
|
|
|
return resource_get_priority((IWineD3DResource *)iface);
|
2005-03-29 21:01:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 13:15:32 +02:00
|
|
|
static void WINAPI IWineD3DVolumeImpl_PreLoad(IWineD3DVolume *iface) {
|
2008-12-01 15:32:15 +01:00
|
|
|
FIXME("iface %p stub!\n", iface);
|
2005-01-17 14:44:57 +01:00
|
|
|
}
|
|
|
|
|
2010-08-15 23:21:42 +02:00
|
|
|
static void WINAPI IWineD3DVolumeImpl_UnLoad(IWineD3DVolume *iface)
|
|
|
|
{
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
/* The whole content is shadowed on This->resource.allocatedMemory, and
|
|
|
|
* the texture name is managed by the VolumeTexture container. */
|
|
|
|
|
|
|
|
resource_unload((IWineD3DResourceImpl *)iface);
|
2008-01-12 22:56:30 +01:00
|
|
|
}
|
|
|
|
|
2006-06-10 13:15:32 +02:00
|
|
|
static WINED3DRESOURCETYPE WINAPI IWineD3DVolumeImpl_GetType(IWineD3DVolume *iface) {
|
2008-12-02 18:41:33 +01:00
|
|
|
return resource_get_type((IWineD3DResource *)iface);
|
2005-03-29 21:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* *******************************************
|
|
|
|
IWineD3DVolume parts follow
|
|
|
|
******************************************* */
|
2006-06-10 13:15:32 +02:00
|
|
|
static HRESULT WINAPI IWineD3DVolumeImpl_GetContainer(IWineD3DVolume *iface, REFIID riid, void** ppContainer) {
|
2005-01-17 14:44:57 +01:00
|
|
|
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
2006-02-07 12:26:10 +01:00
|
|
|
|
|
|
|
TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
|
|
|
|
|
|
|
|
if (!ppContainer) {
|
|
|
|
ERR("Called without a valid ppContainer.\n");
|
2009-11-23 22:35:15 +01:00
|
|
|
return E_FAIL;
|
2006-02-07 12:26:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Although surfaces can be standalone, volumes can't */
|
|
|
|
if (!This->container) {
|
|
|
|
ERR("Volume without an container. Should not happen.\n");
|
2009-11-23 22:35:15 +01:00
|
|
|
return E_FAIL;
|
2006-02-07 12:26:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Relaying to QueryInterface\n");
|
2010-08-16 20:00:24 +02:00
|
|
|
return IUnknown_QueryInterface((IWineD3DVolumeTexture *)This->container, riid, ppContainer);
|
2005-01-17 14:44:57 +01:00
|
|
|
}
|
|
|
|
|
2006-06-10 13:15:32 +02:00
|
|
|
static HRESULT WINAPI IWineD3DVolumeImpl_GetDesc(IWineD3DVolume *iface, WINED3DVOLUME_DESC* pDesc) {
|
2005-01-17 14:44:57 +01:00
|
|
|
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
|
|
|
TRACE("(%p) : copying into %p\n", This, pDesc);
|
2005-07-13 16:15:54 +02:00
|
|
|
|
2009-06-09 10:47:20 +02:00
|
|
|
pDesc->Format = This->resource.format_desc->format;
|
|
|
|
pDesc->Type = This->resource.resourceType;
|
|
|
|
pDesc->Usage = This->resource.usage;
|
|
|
|
pDesc->Pool = This->resource.pool;
|
|
|
|
pDesc->Size = This->resource.size; /* dx8 only */
|
|
|
|
pDesc->Width = This->currentDesc.Width;
|
|
|
|
pDesc->Height = This->currentDesc.Height;
|
|
|
|
pDesc->Depth = This->currentDesc.Depth;
|
|
|
|
|
2006-04-07 12:51:12 +02:00
|
|
|
return WINED3D_OK;
|
2005-01-17 14:44:57 +01:00
|
|
|
}
|
|
|
|
|
2006-06-10 13:15:32 +02:00
|
|
|
static HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, WINED3DLOCKED_BOX* pLockedVolume, CONST WINED3DBOX* pBox, DWORD Flags) {
|
2005-01-17 14:44:57 +01:00
|
|
|
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
2005-07-13 16:15:54 +02:00
|
|
|
FIXME("(%p) : pBox=%p stub\n", This, pBox);
|
2005-01-17 14:44:57 +01:00
|
|
|
|
2007-02-20 23:02:30 +01:00
|
|
|
if(!This->resource.allocatedMemory) {
|
|
|
|
This->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->resource.size);
|
|
|
|
}
|
|
|
|
|
2005-01-17 14:44:57 +01:00
|
|
|
/* fixme: should we really lock as such? */
|
2005-03-29 21:01:00 +02:00
|
|
|
TRACE("(%p) : box=%p, output pbox=%p, allMem=%p\n", This, pBox, pLockedVolume, This->resource.allocatedMemory);
|
2005-01-17 14:44:57 +01:00
|
|
|
|
2009-03-24 10:09:23 +01:00
|
|
|
pLockedVolume->RowPitch = This->resource.format_desc->byte_count * This->currentDesc.Width; /* Bytes / row */
|
|
|
|
pLockedVolume->SlicePitch = This->resource.format_desc->byte_count
|
|
|
|
* This->currentDesc.Width * This->currentDesc.Height; /* Bytes / slice */
|
2005-01-17 14:44:57 +01:00
|
|
|
if (!pBox) {
|
|
|
|
TRACE("No box supplied - all is ok\n");
|
2005-03-29 21:01:00 +02:00
|
|
|
pLockedVolume->pBits = This->resource.allocatedMemory;
|
2005-01-17 14:44:57 +01:00
|
|
|
This->lockedBox.Left = 0;
|
|
|
|
This->lockedBox.Top = 0;
|
|
|
|
This->lockedBox.Front = 0;
|
|
|
|
This->lockedBox.Right = This->currentDesc.Width;
|
|
|
|
This->lockedBox.Bottom = This->currentDesc.Height;
|
|
|
|
This->lockedBox.Back = This->currentDesc.Depth;
|
|
|
|
} else {
|
|
|
|
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);
|
2009-03-24 10:09:23 +01:00
|
|
|
pLockedVolume->pBits = This->resource.allocatedMemory
|
|
|
|
+ (pLockedVolume->SlicePitch * pBox->Front) /* FIXME: is front < back or vica versa? */
|
|
|
|
+ (pLockedVolume->RowPitch * pBox->Top)
|
|
|
|
+ (pBox->Left * This->resource.format_desc->byte_count);
|
2005-01-17 14:44:57 +01:00
|
|
|
This->lockedBox.Left = pBox->Left;
|
|
|
|
This->lockedBox.Top = pBox->Top;
|
|
|
|
This->lockedBox.Front = pBox->Front;
|
|
|
|
This->lockedBox.Right = pBox->Right;
|
|
|
|
This->lockedBox.Bottom = pBox->Bottom;
|
|
|
|
This->lockedBox.Back = pBox->Back;
|
|
|
|
}
|
2005-07-13 16:15:54 +02:00
|
|
|
|
2006-03-08 00:11:28 +01:00
|
|
|
if (Flags & (WINED3DLOCK_NO_DIRTY_UPDATE | WINED3DLOCK_READONLY)) {
|
2005-01-17 14:44:57 +01:00
|
|
|
/* Don't dirtify */
|
2010-08-16 20:00:24 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
volume_add_dirty_box(iface, &This->lockedBox);
|
|
|
|
This->container->baseTexture.texture_rgb.dirty = TRUE;
|
|
|
|
This->container->baseTexture.texture_srgb.dirty = TRUE;
|
2005-01-17 14:44:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
This->locked = TRUE;
|
|
|
|
TRACE("returning memory@%p rpitch(%d) spitch(%d)\n", pLockedVolume->pBits, pLockedVolume->RowPitch, pLockedVolume->SlicePitch);
|
2006-04-07 12:51:12 +02:00
|
|
|
return WINED3D_OK;
|
2005-01-17 14:44:57 +01:00
|
|
|
}
|
|
|
|
|
2006-06-10 13:15:32 +02:00
|
|
|
static HRESULT WINAPI IWineD3DVolumeImpl_UnlockBox(IWineD3DVolume *iface) {
|
2005-01-17 14:44:57 +01:00
|
|
|
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
2009-12-16 19:55:57 +01:00
|
|
|
if (!This->locked)
|
|
|
|
{
|
|
|
|
WARN("Trying to unlock unlocked volume %p.\n", iface);
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
2005-01-17 14:44:57 +01:00
|
|
|
}
|
|
|
|
TRACE("(%p) : unlocking volume\n", This);
|
|
|
|
This->locked = FALSE;
|
|
|
|
memset(&This->lockedBox, 0, sizeof(RECT));
|
2006-04-07 12:51:12 +02:00
|
|
|
return WINED3D_OK;
|
2005-01-17 14:44:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Internal use functions follow : */
|
|
|
|
|
2009-06-26 10:07:12 +02:00
|
|
|
/* Context activation is done by the caller. */
|
2010-05-24 09:56:36 +02:00
|
|
|
static HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, int gl_level, BOOL srgb_mode)
|
|
|
|
{
|
|
|
|
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
|
|
|
|
const struct wined3d_gl_info *gl_info = &This->resource.device->adapter->gl_info;
|
2010-03-19 13:19:51 +01:00
|
|
|
const struct wined3d_format_desc *glDesc = This->resource.format_desc;
|
2007-04-23 22:03:00 +02:00
|
|
|
|
2009-03-13 10:44:18 +01:00
|
|
|
TRACE("(%p) : level %u, format %s (0x%08x)\n", This, gl_level, debug_d3dformat(glDesc->format), glDesc->format);
|
2005-03-14 11:12:52 +01:00
|
|
|
|
2008-09-17 17:50:40 +02:00
|
|
|
volume_bind_and_dirtify(iface);
|
|
|
|
|
2007-10-26 13:44:16 +02:00
|
|
|
TRACE("Calling glTexImage3D %x level=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%x, Mem=%p\n",
|
|
|
|
GL_TEXTURE_3D,
|
|
|
|
gl_level,
|
|
|
|
glDesc->glInternal,
|
|
|
|
This->currentDesc.Width,
|
|
|
|
This->currentDesc.Height,
|
|
|
|
This->currentDesc.Depth,
|
|
|
|
0,
|
|
|
|
glDesc->glFormat,
|
|
|
|
glDesc->glType,
|
|
|
|
This->resource.allocatedMemory);
|
2008-10-19 02:07:49 +02:00
|
|
|
|
|
|
|
ENTER_GL();
|
2007-10-26 13:44:16 +02:00
|
|
|
GL_EXTCALL(glTexImage3DEXT(GL_TEXTURE_3D,
|
2006-08-05 00:11:17 +02:00
|
|
|
gl_level,
|
2007-07-23 11:13:37 +02:00
|
|
|
glDesc->glInternal,
|
2006-08-05 00:11:17 +02:00
|
|
|
This->currentDesc.Width,
|
|
|
|
This->currentDesc.Height,
|
|
|
|
This->currentDesc.Depth,
|
|
|
|
0,
|
2007-07-23 11:13:37 +02:00
|
|
|
glDesc->glFormat,
|
|
|
|
glDesc->glType,
|
2007-10-26 13:44:16 +02:00
|
|
|
This->resource.allocatedMemory));
|
|
|
|
checkGLcall("glTexImage3D");
|
2008-10-19 02:07:49 +02:00
|
|
|
LEAVE_GL();
|
2007-03-31 23:02:37 +02:00
|
|
|
|
|
|
|
/* When adding code releasing This->resource.allocatedMemory to save data keep in mind that
|
|
|
|
* GL_UNPACK_CLIENT_STORAGE_APPLE is enabled by default if supported(GL_APPLE_client_storage).
|
|
|
|
* Thus do not release This->resource.allocatedMemory if GL_APPLE_client_storage is supported.
|
|
|
|
*/
|
2006-04-07 12:51:12 +02:00
|
|
|
return WINED3D_OK;
|
2005-07-13 16:15:54 +02:00
|
|
|
|
2005-03-14 11:12:52 +01:00
|
|
|
}
|
|
|
|
|
2009-09-16 08:37:16 +02:00
|
|
|
static const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl =
|
2005-01-17 14:44:57 +01:00
|
|
|
{
|
2005-03-14 11:12:52 +01:00
|
|
|
/* IUnknown */
|
2005-01-17 14:44:57 +01:00
|
|
|
IWineD3DVolumeImpl_QueryInterface,
|
|
|
|
IWineD3DVolumeImpl_AddRef,
|
|
|
|
IWineD3DVolumeImpl_Release,
|
2005-03-29 21:01:00 +02:00
|
|
|
/* IWineD3DResource */
|
2005-01-17 14:44:57 +01:00
|
|
|
IWineD3DVolumeImpl_GetParent,
|
|
|
|
IWineD3DVolumeImpl_SetPrivateData,
|
|
|
|
IWineD3DVolumeImpl_GetPrivateData,
|
|
|
|
IWineD3DVolumeImpl_FreePrivateData,
|
2005-03-29 21:01:00 +02:00
|
|
|
IWineD3DVolumeImpl_SetPriority,
|
|
|
|
IWineD3DVolumeImpl_GetPriority,
|
|
|
|
IWineD3DVolumeImpl_PreLoad,
|
2008-01-12 22:56:30 +01:00
|
|
|
IWineD3DVolumeImpl_UnLoad,
|
2005-03-29 21:01:00 +02:00
|
|
|
IWineD3DVolumeImpl_GetType,
|
|
|
|
/* IWineD3DVolume */
|
2005-01-17 14:44:57 +01:00
|
|
|
IWineD3DVolumeImpl_GetContainer,
|
|
|
|
IWineD3DVolumeImpl_GetDesc,
|
|
|
|
IWineD3DVolumeImpl_LockBox,
|
|
|
|
IWineD3DVolumeImpl_UnlockBox,
|
2005-07-13 16:15:54 +02:00
|
|
|
/* Internal interface */
|
2005-03-14 11:12:52 +01:00
|
|
|
IWineD3DVolumeImpl_LoadTexture,
|
2005-01-17 14:44:57 +01:00
|
|
|
};
|
2009-09-16 08:37:16 +02:00
|
|
|
|
2009-09-16 08:37:19 +02:00
|
|
|
HRESULT volume_init(IWineD3DVolumeImpl *volume, IWineD3DDeviceImpl *device, UINT width,
|
2010-08-23 18:28:10 +02:00
|
|
|
UINT height, UINT depth, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool,
|
2009-09-16 08:37:19 +02:00
|
|
|
IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
|
2009-09-16 08:37:16 +02:00
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
2010-08-23 18:28:10 +02:00
|
|
|
const struct wined3d_format_desc *format_desc = getFormatDescEntry(format_id, gl_info);
|
2009-09-16 08:37:16 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!gl_info->supported[EXT_TEXTURE3D])
|
|
|
|
{
|
|
|
|
WARN("Volume cannot be created - no volume texture support.\n");
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
volume->lpVtbl = &IWineD3DVolume_Vtbl;
|
|
|
|
|
|
|
|
hr = resource_init((IWineD3DResource *)volume, WINED3DRTYPE_VOLUME, device,
|
2009-09-17 23:03:33 +02:00
|
|
|
width * height * depth * format_desc->byte_count, usage, format_desc, pool, parent, parent_ops);
|
2009-09-16 08:37:16 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize resource, returning %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
volume->currentDesc.Width = width;
|
|
|
|
volume->currentDesc.Height = height;
|
|
|
|
volume->currentDesc.Depth = depth;
|
|
|
|
volume->lockable = TRUE;
|
|
|
|
volume->locked = FALSE;
|
|
|
|
memset(&volume->lockedBox, 0, sizeof(volume->lockedBox));
|
|
|
|
volume->dirty = TRUE;
|
|
|
|
|
|
|
|
volume_add_dirty_box((IWineD3DVolume *)volume, NULL);
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|