/*---------------------------------------------------------------------------

    NN texture api header for DXG20

    Copyright (C) 2004 - 2005 SEGA Corporation Creative Center Graphics Sect.
    All Rights Reserved.

    Module  : NN texture api header for DXG20
    File    : nnltexturexb.h
    Create  : 2004/03/24
    Modify  : 2004/07/12 nnCalcDDSTextureSize,nnCreateDDSTexture追加
    Modify  : 2004/07/20 XENON用に修正
    Modify  : 2004/10/25 nnLoadTextureMemoryOneDX追加
    Modify  : 2005/02/17 NNS_TEXSTATEMODE_DX構造体削除
    Modify  : 2008/11/26 NND_TEXFMT_DXG20 追加
	                     nnCreateTextureDXG20 関数を追加
    Modify  : 2008/12/08 NND_TEXUSAGE_DXG20_DYNAMIC を追加
	                     テクスチャのメモリ管理追加
						 nnCreateTextureDXG20関数 の引数にテクスチャ管理追加
						 nnCreateD3DTextureFromFileInMemoryDXG20 関数を外部関数に変更
						 nnCreateD3DTextureFromFileInMemoryExDXG20 関数を追加
						 nnLoadTextureMemoryOneExDXG20 関数を追加
    Modify  : 2009/05/12 ヘッダ整理
	Version : 1.18.43
    Note    : 

---------------------------------------------------------------------------*/

#ifndef __NNLTEXTUREDXG20_H__
#define __NNLTEXTUREDXG20_H__

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

typedef Uint32 NNF_TEXFMT_DXG20;

/* テクスチャのフォーマット */
#if defined(D3D_DISABLE_9EX)
#define DXG20_DISABLE_9EX
#endif

#define NND_TEXFMT_DXG20_UNKNOWN		D3DFMT_UNKNOWN

#define NND_TEXFMT_DXG20_R8G8B8			D3DFMT_R8G8B8
#define NND_TEXFMT_DXG20_A8R8G8B8		D3DFMT_A8R8G8B8
#define NND_TEXFMT_DXG20_X8R8G8B8		D3DFMT_X8R8G8B8
#define NND_TEXFMT_DXG20_R5G6B5			D3DFMT_R5G6B5
#define NND_TEXFMT_DXG20_X1R5G5B5		D3DFMT_X1R5G5B5
#define NND_TEXFMT_DXG20_A1R5G5B5		D3DFMT_A1R5G5B5
#define NND_TEXFMT_DXG20_A4R4G4B4		D3DFMT_A4R4G4B4
#define NND_TEXFMT_DXG20_R3G3B2			D3DFMT_R3G3B2
#define NND_TEXFMT_DXG20_A8				D3DFMT_A8
#define NND_TEXFMT_DXG20_A8R3G3B2		D3DFMT_A8R3G3B2
#define NND_TEXFMT_DXG20_X4R4G4B4		D3DFMT_X4R4G4B4
#define NND_TEXFMT_DXG20_A2B10G10R10	D3DFMT_A2B10G10R10
#define NND_TEXFMT_DXG20_A8B8G8R8		D3DFMT_A8B8G8R8
#define NND_TEXFMT_DXG20_X8B8G8R8		D3DFMT_X8B8G8R8
#define NND_TEXFMT_DXG20_G16R16			D3DFMT_G16R16
#define NND_TEXFMT_DXG20_A2R10G10B10	D3DFMT_A2R10G10B10
#define NND_TEXFMT_DXG20_A16B16G16R16	D3DFMT_A16B16G16R16

#define NND_TEXFMT_DXG20_A8P8			D3DFMT_A8P8
#define NND_TEXFMT_DXG20_P8				D3DFMT_P8

#define NND_TEXFMT_DXG20_L8				D3DFMT_L8
#define NND_TEXFMT_DXG20_A8L8			D3DFMT_A8L8
#define NND_TEXFMT_DXG20_A4L4			D3DFMT_A4L4

#define NND_TEXFMT_DXG20_V8U8			D3DFMT_V8U8
#define NND_TEXFMT_DXG20_L6V5U5			D3DFMT_L6V5U5
#define NND_TEXFMT_DXG20_X8L8V8U8		D3DFMT_X8L8V8U8
#define NND_TEXFMT_DXG20_Q8W8V8U8		D3DFMT_Q8W8V8U8
#define NND_TEXFMT_DXG20_V16U16			D3DFMT_V16U16
#define NND_TEXFMT_DXG20_A2W10V10U10	D3DFMT_A2W10V10U10

#define NND_TEXFMT_DXG20_UYVY			D3DFMT_UYVY
#define NND_TEXFMT_DXG20_R8G8_B8G8		D3DFMT_R8G8_B8G8
#define NND_TEXFMT_DXG20_YUY2			D3DFMT_YUY2
#define NND_TEXFMT_DXG20_G8R8_G8B8		D3DFMT_G8R8_G8B8
#define NND_TEXFMT_DXG20_DXT1			D3DFMT_DXT1
#define NND_TEXFMT_DXG20_DXT2			D3DFMT_DXT2
#define NND_TEXFMT_DXG20_DXT3			D3DFMT_DXT3
#define NND_TEXFMT_DXG20_DXT4			D3DFMT_DXT4
#define NND_TEXFMT_DXG20_DXT5			D3DFMT_DXT5

#define NND_TEXFMT_DXG20_D16_LOCKABLE	D3DFMT_D16_LOCKABLE
#define NND_TEXFMT_DXG20_D32			D3DFMT_D32
#define NND_TEXFMT_DXG20_D15S1			D3DFMT_D15S1
#define NND_TEXFMT_DXG20_D24S8			D3DFMT_D24S8
#define NND_TEXFMT_DXG20_D24X8			D3DFMT_D24X8
#define NND_TEXFMT_DXG20_D24X4S4		D3DFMT_D24X4S4
#define NND_TEXFMT_DXG20_D16			D3DFMT_D16

#define NND_TEXFMT_DXG20_D32F_LOCKABLE	D3DFMT_D32F_LOCKABLE
#define NND_TEXFMT_DXG20_D24FS8			D3DFMT_D24FS8

#if !defined(DXG20_DISABLE_9EX)
#define NND_TEXFMT_DXG20_D32_LOCKABLE	D3DFMT_D32_LOCKABLE
#define NND_TEXFMT_DXG20_S8_LOCKABLE	D3DFMT_S8_LOCKABLE
#endif /* !DXG20_DISABLE_9EX */

#define NND_TEXFMT_DXG20_L16			D3DFMT_L16

#define NND_TEXFMT_DXG20_VERTEXDATA		D3DFMT_VERTEXDATA
#define NND_TEXFMT_DXG20_INDEX16		D3DFMT_INDEX16
#define NND_TEXFMT_DXG20_INDEX32		D3DFMT_INDEX32

#define NND_TEXFMT_DXG20_Q16W16V16U16	D3DFMT_Q16W16V16U16

#define NND_TEXFMT_DXG20_MULTI2_ARGB8	D3DFMT_MULTI2_ARGB8

#define NND_TEXFMT_DXG20_R16F			D3DFMT_R16F
#define NND_TEXFMT_DXG20_G16R16F		D3DFMT_G16R16F
#define NND_TEXFMT_DXG20_A16B16G16R16F	D3DFMT_A16B16G16R16F

#define NND_TEXFMT_DXG20_R32F			D3DFMT_R32F
#define NND_TEXFMT_DXG20_G32R32F		D3DFMT_G32R32F
#define NND_TEXFMT_DXG20_A32B32G32R32F	D3DFMT_A32B32G32R32F

#define NND_TEXFMT_DXG20_CxV8U8			D3DFMT_CxV8U8

#if !defined(DXG20_DISABLE_9EX)
#define NND_TEXFMT_DXG20_A1				D3DFMT_A1
#define NND_TEXFMT_DXG20_BINARYBUFFER	D3DFMT_BINARYBUFFER
#endif /* DXG20_DISABLE_9EX */

/* テクスチャの使用 */
typedef Uint32 NNF_TEXUSAGE_DXG20;
#define NND_TEXUSAGE_DXG20_DEFAULT		0						/* 普通のテクスチャ */
#define NND_TEXUSAGE_DXG20_RENDERTARGET	D3DUSAGE_RENDERTARGET	/* レンダリングターゲット */
#define NND_TEXUSAGE_DXG20_DYNAMIC		D3DUSAGE_DYNAMIC

/* テクスチャのメモリ管理 */
typedef Uint32 NNF_TEXPOOL_DXG20;
#define NND_TEXPOOL_DXG20_DEFAULT		D3DPOOL_DEFAULT
#define NND_TEXPOOL_DXG20_MANAGED		D3DPOOL_MANAGED
#define NND_TEXPOOL_DXG20_SYSTEMMEM		D3DPOOL_SYSTEMMEM
#define NND_TEXPOOL_DXG20_SCRATCH		D3DPOOL_SCRATCH

typedef struct{
	D3DTEXTUREFILTERTYPE MinFilter;
	D3DTEXTUREFILTERTYPE MipFilter;
	Uint32				MaxAnisotropy;
} NNS_MINFILETR_DATA;

typedef struct{
	Sint32 TexelBytes;
	Sint32 Height;
	Sint32 Width;
	Sint32 MipMapCount;
	Sint32 Format;
} NNS_CREATETEXTURE_DATA_DX;

/* 内部関数 */
void nnSetTexFilterCancelDXG20(NNE_BOOL cancel);
void nnSetTexFilterDXG20( Sint32 slot,  NNS_TEXINFO* pTexInfo );
void nnSetTexFilter2DXG20( Sint32 slot,  NNF_TEXFILE_MINFILTER minfilter, NNF_TEXFILE_MAGFILTER magfilter );
void nnSetTexWrapDXG20( Sint32 slot, D3DTEXTUREADDRESS wrap_u, D3DTEXTUREADDRESS wrap_v );
void nnSetTexMipmapBiasDXG20( Sint32 slot, Float bias );
void nnSetTexMaxmipLevelDXG20( Sint32 slot, Sint32 level );
/**/
Sint32 nnCreateTextureDXG20(NNS_TEXINFO *texinfo, Uint16 width, Uint16 height, Uint32 mipmaplevel, NNF_TEXUSAGE_DXG20 usage, NNF_TEXFMT_DXG20 format, NNF_TEXPOOL_DXG20 pool,
							NNF_TEXFILE_MINFILTER minfilter,
							NNF_TEXFILE_MAGFILTER magfilter,
							Uint32 globalindex, Uint32 bank, NNF_TEXFLAG flag);

Sint32 nnCreateD3DTextureFromFileInMemoryExDXG20(const void *pData, Uint32 size, NNF_TEXUSAGE_DXG20 usage, NNF_TEXPOOL_DXG20 pool, void *ppTexture);
Sint32 nnCreateD3DTextureFromFileInMemoryDXG20(const void *pData, Uint32 size, void *ppTexture);

Sint32 nnLoadTextureMemoryOneExDXG20( NNS_TEXINFO *texinfo, const void *tex,
									  NNF_TEXFILE_MINFILTER minfilter,
									  NNF_TEXFILE_MAGFILTER magfilter,
									  Uint32 globalindex, Uint32 bank, NNF_TEXFLAG flag, Uint32 size,
									  NNF_TEXUSAGE_DXG20 usage, NNF_TEXPOOL_DXG20 pool);
Sint32 nnLoadTextureMemoryOneDXG20( NNS_TEXINFO *texinfo, const void *tex,
									NNF_TEXFILE_MINFILTER minfilter,
									NNF_TEXFILE_MAGFILTER magfilter,
									Uint32 globalindex, Uint32 bank, NNF_TEXFLAG flag, Uint32 size );

Uint32 nnCalcDDSTextureSizeToXVRHeader( NVS_XVRHEADER *pXvrHeader );
Uint32 nnCalcDDSTextureSize( Sint32 width, Sint32 height, Uint32 attr );
void nnCreateDDSTextureToXVRTexture( void *pDst, const void *pSrc );
void nnCreateDDSTexture( void *pDst, const void *pSrc , NVS_XVRHEADER *pXvrHeader);

#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /*__NNLTEXTUREDXG20_H__ */
/* End of file */
