Author: gbrunmar
Date: Tue Feb 3 12:55:20 2009
New Revision: 39341
URL:
http://svn.reactos.org/svn/reactos?rev=39341&view=rev
Log:
D3D9:
* Fixed compilation error
* Implemented IDirect3DBaseTexture9's and IDirect3DTexture9's
GetAutoGenFilterType(), GetLOD() and GetLevelCount()
Modified:
trunk/reactos/dll/directx/d3d9/adapter.c
trunk/reactos/dll/directx/d3d9/d3d9_basetexture.h
trunk/reactos/dll/directx/d3d9/d3d9_mipmap.c
trunk/reactos/dll/directx/d3d9/d3d9_resource.h
trunk/reactos/dll/directx/d3d9/d3d9_texture.c
trunk/reactos/dll/directx/d3d9/d3d9_texture.h
Modified: trunk/reactos/dll/directx/d3d9/adapter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/adapter.c…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/adapter.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/adapter.c [iso-8859-1] Tue Feb 3 12:55:20 2009
@@ -6,7 +6,6 @@
* PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
*/
-#define _WIN32_WINNT 0x0502
#include "d3d9_common.h"
#include <d3d9.h>
#include <ddraw.h>
Modified: trunk/reactos/dll/directx/d3d9/d3d9_basetexture.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_base…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_basetexture.h [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_basetexture.h [iso-8859-1] Tue Feb 3 12:55:20
2009
@@ -7,6 +7,8 @@
*/
#ifndef _D3D9_BASETEXTURE_H_
#define _D3D9_BASETEXTURE_H_
+
+#include "d3d9_resource.h"
// Work-around for:
// "warning: 'FilterType' is narrower than values of its type"
@@ -31,9 +33,10 @@
/* 0x005a */ D3DTEXTUREFILTERTYPE FilterType : 8;
struct
{
-/* 0x005a */ DWORD dwFilterType : 8;
-/* 0x005b */ BOOL bIsAutoGenMipMap : 8;
-/* 0x005c */ DWORD MipMapLevels2 : 16;
+/* 0x005a */ DWORD dwFilterType : 8;
+/* 0x005b */ BOOL bIsAutoGenMipMap : 8;
+/* 0x005c */ DWORD MipMapLevels2 : 8;
+/* 0x005d */ DWORD MaxLOD : 8;
};
};
/* 0x005e */ WORD wPaletteIndex;
Modified: trunk/reactos/dll/directx/d3d9/d3d9_mipmap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_mipm…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_mipmap.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_mipmap.c [iso-8859-1] Tue Feb 3 12:55:20 2009
@@ -7,6 +7,7 @@
*/
#include "d3d9_mipmap.h"
#include "debug.h"
+#include "d3d9_texture.h"
#include "d3d9_device.h"
#include "d3d9_helpers.h"
#include <d3d9.h>
@@ -54,7 +55,7 @@
return D3D9BaseObject_Release(&This->BaseTexture.BaseResource.BaseObject);
}
-/* IDirect3DBaseTexture9 */
+/* IDirect3DResource9 */
/*++
* @name IDirect3DTexture9::GetDevice
@@ -74,7 +75,8 @@
* If ppDevice is a bad pointer the return value will be D3DERR_INVALIDCALL.
* If the texture didn't contain any device, the return value will be
D3DERR_INVALIDDEVICE.
*
-*/HRESULT WINAPI D3D9MipMap_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9**
ppDevice)
+*/
+HRESULT WINAPI D3D9MipMap_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9**
ppDevice)
{
LPD3D9MIPMAP This = IDirect3DTexture9ToImpl(iface);
LOCK_D3DDEVICE9();
@@ -132,6 +134,7 @@
UNIMPLEMENTED
}
+/* IDirect3DBaseTexture9 */
D3DRESOURCETYPE WINAPI D3D9MipMap_GetType(LPDIRECT3DTEXTURE9 iface)
{
UNIMPLEMENTED
@@ -144,16 +147,44 @@
return 0;
}
+/*++
+* @name IDirect3DTexture9::GetLOD
+* @implemented
+*
+* The function D3D9MipMap_GetLOD returns the number
+* max LODs for the specified texture, if it's managed.
+*
+* @param LPDIRECT3DTEXTURE9 iface
+* Pointer to a IDirect3DTexture9 object returned from IDirect3D9Device::CreateTexture().
+*
+* @return DWORD
+* Returns the number of LODs in the specified texture if it's managed.
+*
+*/
DWORD WINAPI D3D9MipMap_GetLOD(LPDIRECT3DTEXTURE9 iface)
{
- UNIMPLEMENTED
- return 0;
-}
-
+ LPD3D9MIPMAP This = IDirect3DTexture9ToImpl(iface);
+ return D3D9Texture_GetLOD( (IDirect3DBaseTexture9*)&This->BaseTexture.lpVtbl
);
+}
+
+/*++
+* @name IDirect3DTexture9::GetLevelCount
+* @implemented
+*
+* The function D3D9MipMap_GetLevelCount returns the number of mip map levels
+* in the specified texture.
+*
+* @param LPDIRECT3DTEXTURE9 iface
+* Pointer to a IDirect3DTexture9 object returned from IDirect3D9Device::CreateTexture().
+*
+* @return DWORD
+* Returns the number of levels in the specified texture.
+*
+*/
DWORD WINAPI D3D9MipMap_GetLevelCount(LPDIRECT3DTEXTURE9 iface)
{
- UNIMPLEMENTED
- return 0;
+ LPD3D9MIPMAP This = IDirect3DTexture9ToImpl(iface);
+ return D3D9Texture_GetLevelCount(
(IDirect3DBaseTexture9*)&This->BaseTexture.lpVtbl );
}
HRESULT WINAPI D3D9MipMap_SetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface,
D3DTEXTUREFILTERTYPE FilterType)
@@ -162,10 +193,24 @@
return D3D_OK;
}
+/*++
+* @name IDirect3DTexture9::GetAutoGenFilterType
+* @implemented
+*
+* The function D3D9MipMap_GetAutoGenFilterType returns filter type
+* that is used when automated mipmaping is set.
+*
+* @param LPDIRECT3DTEXTURE9 iface
+* Pointer to a IDirect3DTexture9 object returned from IDirect3D9Device::CreateTexture().
+*
+* @return D3DTEXTUREFILTERTYPE
+* Filter type used when automated mipmaping is set for the specified texture.
+*
+*/
D3DTEXTUREFILTERTYPE WINAPI D3D9MipMap_GetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface)
{
- UNIMPLEMENTED
- return D3DRTYPE_TEXTURE;
+ LPD3D9MIPMAP This = IDirect3DTexture9ToImpl(iface);
+ return D3D9Texture_GetAutoGenFilterType(
(IDirect3DBaseTexture9*)&This->BaseTexture.lpVtbl );
}
void WINAPI D3D9MipMap_GenerateMipSubLevels(LPDIRECT3DTEXTURE9 iface)
@@ -220,6 +265,8 @@
D3D9MipMap_SetPriority,
D3D9MipMap_GetPriority,
D3D9MipMap_PreLoad,
+
+ /* IDirect3DBaseTexture9 methods */
D3D9MipMap_GetType,
D3D9MipMap_SetLOD,
D3D9MipMap_GetLOD,
Modified: trunk/reactos/dll/directx/d3d9/d3d9_resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_reso…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_resource.h [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_resource.h [iso-8859-1] Tue Feb 3 12:55:20 2009
@@ -13,12 +13,12 @@
typedef struct _Direct3DResource9_INT
{
/* 0x0000 */ D3D9BaseObject BaseObject;
-/* 0x0020 */ DWORD dwUnknown20;
+/* 0x0020 */ BOOL bIsManaged;
/* 0x0024 */ DWORD dwUnknown24;
/* 0x0028 */ DWORD dwUnknown28;
/* 0x002c */ DWORD dwUnknown2c;
-/* 0x0030 */ DWORD dwUnknown30;
-/* 0x0034 */ DWORD dwUnknown34;
+/* 0x0030 */ DWORD dwPriority;
+/* 0x0034 */ BOOL bIsDirty;
/* 0x0038 */ D3DPOOL Pool;
/* 0x003c */ LPDWORD dwUnknown3c;
/* 0x0040 */ LPDWORD dwUnknown40;
Modified: trunk/reactos/dll/directx/d3d9/d3d9_texture.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_text…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_texture.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_texture.c [iso-8859-1] Tue Feb 3 12:55:20 2009
@@ -6,6 +6,18 @@
* PROGRAMERS: Gregor Gullwi <gbrunmar (dot) ros (at) gmail (dot) com>
*/
#include "d3d9_texture.h"
+
+#define LOCK_D3DDEVICE9()
D3D9BaseObject_LockDevice(&This->BaseResource.BaseObject)
+#define UNLOCK_D3DDEVICE9()
D3D9BaseObject_UnlockDevice(&This->BaseResource.BaseObject)
+
+/* Convert a IDirect3DBaseTexture9 pointer safely to the internal implementation struct
*/
+Direct3DBaseTexture9_INT* IDirect3DBaseTexture9ToImpl(LPDIRECT3DBASETEXTURE9 iface)
+{
+ if (NULL == iface)
+ return NULL;
+
+ return (Direct3DBaseTexture9_INT*)((ULONG_PTR)iface -
FIELD_OFFSET(Direct3DBaseTexture9_INT, lpVtbl));
+}
void InitDirect3DBaseTexture9(Direct3DBaseTexture9_INT* pBaseTexture,
IDirect3DBaseTexture9Vtbl* pVtbl,
@@ -22,9 +34,88 @@
pBaseTexture->Format = Format;
pBaseTexture->wPaletteIndex = 0xFFFF;
pBaseTexture->Usage = Usage;
- pBaseTexture->MipMapLevels =
- pBaseTexture->MipMapLevels2 = (WORD)Levels;
+ pBaseTexture->MipMapLevels = Levels;
+ pBaseTexture->MipMapLevels2 = Levels;
pBaseTexture->FilterType = D3DTEXF_LINEAR;
pBaseTexture->bIsAutoGenMipMap = (Usage & D3DUSAGE_AUTOGENMIPMAP) != 0;
}
+
+/*++
+* @name IDirect3DBaseTexture9::GetAutoGenFilterType
+* @implemented
+*
+* The function D3D9Texture_GetAutoGenFilterType returns filter type
+* that is used when automated mipmaping is set.
+*
+* @param LPDIRECT3DBASETEXTURE9 iface
+* Pointer to a IDirect3DBaseTexture9 interface
+*
+* @return D3DTEXTUREFILTERTYPE
+* Filter type used when automated mipmaping is set for the specified texture.
+*
+*/
+D3DTEXTUREFILTERTYPE WINAPI D3D9Texture_GetAutoGenFilterType(LPDIRECT3DBASETEXTURE9
iface)
+{
+ D3DTEXTUREFILTERTYPE FilterType;
+ Direct3DBaseTexture9_INT* This = IDirect3DBaseTexture9ToImpl(iface);
+ LOCK_D3DDEVICE9();
+
+ FilterType = This->dwFilterType;
+
+ UNLOCK_D3DDEVICE9();
+ return FilterType;
+}
+
+/*++
+* @name IDirect3DBaseTexture9::GetLOD
+* @implemented
+*
+* The function D3D9Texture_GetLOD returns the number
+* max LODs for the specified texture, if it's managed.
+*
+* @param LPDIRECT3DBASETEXTURE9 iface
+* Pointer to a IDirect3DBaseTexture9 interface
+*
+* @return DWORD
+* Returns the number of LODs in the specified texture if it's managed.
+*
+*/
+DWORD WINAPI D3D9Texture_GetLOD(LPDIRECT3DBASETEXTURE9 iface)
+{
+ DWORD MaxLOD = 0;
+ Direct3DBaseTexture9_INT* This = IDirect3DBaseTexture9ToImpl(iface);
+ LOCK_D3DDEVICE9();
+
+ if (This->BaseResource.bIsManaged)
+ MaxLOD = This->MaxLOD;
+
+ UNLOCK_D3DDEVICE9();
+ return MaxLOD;
+}
+
+/*++
+* @name IDirect3DBaseTexture9::GetLevelCount
+* @implemented
+*
+* The function D3D9Texture_GetLevelCount returns the number of mip map levels
+* in the specified texture.
+*
+* @param LPDIRECT3DBASETEXTURE9 iface
+* Pointer to a IDirect3DBaseTexture9 interface
+*
+* @return DWORD
+* Returns the number of levels in the specified texture.
+*
+*/
+DWORD WINAPI D3D9Texture_GetLevelCount(LPDIRECT3DBASETEXTURE9 iface)
+{
+ DWORD MipMapLevels;
+ Direct3DBaseTexture9_INT* This = IDirect3DBaseTexture9ToImpl(iface);
+ LOCK_D3DDEVICE9();
+
+ MipMapLevels = This->MipMapLevels;
+
+ UNLOCK_D3DDEVICE9();
+ return MipMapLevels;
+}
Modified: trunk/reactos/dll/directx/d3d9/d3d9_texture.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_text…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_texture.h [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_texture.h [iso-8859-1] Tue Feb 3 12:55:20 2009
@@ -22,4 +22,9 @@
struct _Direct3DDevice9_INT* pDevice,
enum REF_TYPE RefType);
+
+D3DTEXTUREFILTERTYPE WINAPI D3D9Texture_GetAutoGenFilterType(struct
IDirect3DBaseTexture9* iface);
+DWORD WINAPI D3D9Texture_GetLOD(struct IDirect3DBaseTexture9* iface);
+DWORD WINAPI D3D9Texture_GetLevelCount(struct IDirect3DBaseTexture9* iface);
+
#endif // _D3D9_TEXTURE_H_