wined3d: Pass a sub-resource index instead of a miplevel to volume texture methods.

For volume textures this is mostly just a conceptual change, it'll only make a
difference for texture arrays and cube textures.
This commit is contained in:
Henri Verbeet 2010-10-21 12:40:46 +02:00 committed by Alexandre Julliard
parent 2b58f80c27
commit 7f8ea7fffc
2 changed files with 31 additions and 21 deletions

View File

@ -249,18 +249,28 @@ static BOOL WINAPI IWineD3DVolumeTextureImpl_IsCondNP2(IWineD3DVolumeTexture *if
return FALSE; return FALSE;
} }
/* ******************************************* static IWineD3DResourceImpl *volumetexture_get_sub_resource(IWineD3DBaseTextureImpl *texture, UINT sub_resource_idx)
IWineD3DVolumeTexture IWineD3DVolumeTexture parts follow {
******************************************* */ UINT sub_count = texture->baseTexture.level_count * texture->baseTexture.layer_count;
if (sub_resource_idx >= sub_count)
{
WARN("sub_resource_idx %u >= sub_count %u.\n", sub_resource_idx, sub_count);
return NULL;
}
return texture->baseTexture.sub_resources[sub_resource_idx];
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetLevelDesc(IWineD3DVolumeTexture *iface, static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetLevelDesc(IWineD3DVolumeTexture *iface,
UINT level, WINED3DVOLUME_DESC *desc) UINT sub_resource_idx, WINED3DVOLUME_DESC *desc)
{ {
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DVolume *volume; IWineD3DVolume *volume;
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc); TRACE("iface %p, sub_resource_idx %u, desc %p.\n", iface, sub_resource_idx, desc);
if (!(volume = (IWineD3DVolume *)basetexture_get_sub_resource(texture, 0, level))) if (!(volume = (IWineD3DVolume *)volumetexture_get_sub_resource(texture, sub_resource_idx)))
{ {
WARN("Failed to get sub-resource.\n"); WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
@ -272,14 +282,14 @@ static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetLevelDesc(IWineD3DVolumeTextu
} }
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetVolumeLevel(IWineD3DVolumeTexture *iface, static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetVolumeLevel(IWineD3DVolumeTexture *iface,
UINT level, IWineD3DVolume **volume) UINT sub_resource_idx, IWineD3DVolume **volume)
{ {
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DVolume *v; IWineD3DVolume *v;
TRACE("iface %p, level %u, volume %p.\n", iface, level, volume); TRACE("iface %p, sub_resource_idx %u, volume %p.\n", iface, sub_resource_idx, volume);
if (!(v = (IWineD3DVolume *)basetexture_get_sub_resource(texture, 0, level))) if (!(v= (IWineD3DVolume *)volumetexture_get_sub_resource(texture, sub_resource_idx)))
{ {
WARN("Failed to get sub-resource.\n"); WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
@ -294,15 +304,15 @@ static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetVolumeLevel(IWineD3DVolumeTex
} }
static HRESULT WINAPI IWineD3DVolumeTextureImpl_Map(IWineD3DVolumeTexture *iface, static HRESULT WINAPI IWineD3DVolumeTextureImpl_Map(IWineD3DVolumeTexture *iface,
UINT level, WINED3DLOCKED_BOX *locked_box, const WINED3DBOX *box, DWORD flags) UINT sub_resource_idx, WINED3DLOCKED_BOX *locked_box, const WINED3DBOX *box, DWORD flags)
{ {
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DVolume *volume; IWineD3DVolume *volume;
TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n", TRACE("iface %p, sub_resource_idx %u, locked_box %p, box %p, flags %#x.\n",
iface, level, locked_box, box, flags); iface, sub_resource_idx, locked_box, box, flags);
if (!(volume = (IWineD3DVolume *)basetexture_get_sub_resource(texture, 0, level))) if (!(volume = (IWineD3DVolume *)volumetexture_get_sub_resource(texture, sub_resource_idx)))
{ {
WARN("Failed to get sub-resource.\n"); WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
@ -311,14 +321,14 @@ static HRESULT WINAPI IWineD3DVolumeTextureImpl_Map(IWineD3DVolumeTexture *iface
return IWineD3DVolume_Map(volume, locked_box, box, flags); return IWineD3DVolume_Map(volume, locked_box, box, flags);
} }
static HRESULT WINAPI IWineD3DVolumeTextureImpl_Unmap(IWineD3DVolumeTexture *iface, UINT level) static HRESULT WINAPI IWineD3DVolumeTextureImpl_Unmap(IWineD3DVolumeTexture *iface, UINT sub_resource_idx)
{ {
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DVolume *volume; IWineD3DVolume *volume;
TRACE("iface %p, level %u.\n", iface, level); TRACE("iface %p, sub_resource_idx %u.\n", iface, sub_resource_idx);
if (!(volume = (IWineD3DVolume *)basetexture_get_sub_resource(texture, 0, level))) if (!(volume = (IWineD3DVolume *)volumetexture_get_sub_resource(texture, sub_resource_idx)))
{ {
WARN("Failed to get sub-resource.\n"); WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
@ -334,7 +344,7 @@ static HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyBox(IWineD3DVolumeTextur
TRACE("iface %p, dirty_box %p.\n", iface, dirty_box); TRACE("iface %p, dirty_box %p.\n", iface, dirty_box);
if (!(volume = (IWineD3DVolume *)basetexture_get_sub_resource(texture, 0, 0))) if (!(volume = (IWineD3DVolume *)volumetexture_get_sub_resource(texture, 0)))
{ {
WARN("Failed to get sub-resource.\n"); WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;

View File

@ -2606,21 +2606,21 @@ interface IWineD3DCubeTexture : IWineD3DBaseTexture
interface IWineD3DVolumeTexture : IWineD3DBaseTexture interface IWineD3DVolumeTexture : IWineD3DBaseTexture
{ {
HRESULT GetLevelDesc( HRESULT GetLevelDesc(
[in] UINT level, [in] UINT sub_resource_idx,
[out] WINED3DVOLUME_DESC *desc [out] WINED3DVOLUME_DESC *desc
); );
HRESULT GetVolumeLevel( HRESULT GetVolumeLevel(
[in] UINT level, [in] UINT sub_resource_idx,
[out] IWineD3DVolume **volume [out] IWineD3DVolume **volume
); );
HRESULT Map( HRESULT Map(
[in] UINT level, [in] UINT sub_resource_idx,
[out] WINED3DLOCKED_BOX *locked_box, [out] WINED3DLOCKED_BOX *locked_box,
[in] const WINED3DBOX *box, [in] const WINED3DBOX *box,
[in] DWORD flags [in] DWORD flags
); );
HRESULT Unmap( HRESULT Unmap(
[in] UINT level [in] UINT sub_resource_idx
); );
HRESULT AddDirtyBox( HRESULT AddDirtyBox(
[in] const WINED3DBOX *dirty_box [in] const WINED3DBOX *dirty_box