summaryrefslogtreecommitdiff
path: root/Runtime/GfxDevice/d3d/TexturesD3D9.h
blob: 113434cc8214d4dd11a2dd6b04fc49041c1b7b6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#pragma once

#include "D3D9Includes.h"
#include "Runtime/Graphics/TextureFormat.h"
#include "Runtime/Graphics/RenderSurface.h"
#include "Runtime/GfxDevice/GfxDeviceTypes.h"
#include "Runtime/Threads/AtomicOps.h"
#include <map>

class ImageReference;

class TexturesD3D9
{
public:
	TexturesD3D9() {}
	~TexturesD3D9() {}
	bool SetTexture (ShaderType shaderType, int unit, TextureID textureID);
	void SetTextureParams( TextureID texture, TextureDimension texDim, TextureFilterMode filter, TextureWrapMode wrap, int anisoLevel, bool hasMipMap, TextureColorSpace colorSpace );

	void DeleteTexture( TextureID textureID );

	void UploadTexture2D(
		TextureID tid, TextureDimension dimension, UInt8* srcData, int width, int height,
		TextureFormat format, int mipCount, UInt32 uploadFlags, int masterTextureLimit, TextureUsageMode usageMode, TextureColorSpace colorSpace );

	void UploadTextureSubData2D(
		TextureID tid, UInt8* srcData, int mipLevel,
		int x, int y, int width, int height, TextureFormat format, TextureColorSpace colorSpace );

	void UploadTextureCube(
		TextureID tid, UInt8* srcData, int faceDataSize, int size,
		TextureFormat format, int mipCount, UInt32 uploadFlags, TextureColorSpace colorSpace );

	void UploadTexture3D(
		TextureID tid, UInt8* srcData, int width, int height, int depth,
		TextureFormat format, int mipCount, UInt32 uploadFlags );

	void AddTexture( TextureID textureID, IDirect3DBaseTexture9* texture );
	void RemoveTexture( TextureID textureID );
	IDirect3DBaseTexture9* GetTexture( TextureID textureID ) const;

	intptr_t	RegisterNativeTexture(IDirect3DBaseTexture9* texture) const;
	void		UpdateNativeTexture(TextureID textureID, IDirect3DBaseTexture9* texture);
};

struct RenderSurfaceD3D9 : RenderSurfaceBase
{
	RenderSurfaceD3D9()
		: m_Texture(NULL)
		, m_Surface(NULL)
	{
		RenderSurfaceBase_Init(*this);
	}
	void Release() {
		if (m_Texture) {
			REGISTER_EXTERNAL_GFX_DEALLOCATION(m_Texture);
			m_Texture->Release();
			m_Texture = NULL;
		}
		if (m_Surface) {
			REGISTER_EXTERNAL_GFX_DEALLOCATION(m_Surface);
			m_Surface->Release();
			m_Surface = NULL;
		}
	}
	IDirect3DBaseTexture9*	m_Texture;
	IDirect3DSurface9* m_Surface;
};

struct RenderColorSurfaceD3D9 : public RenderSurfaceD3D9
{
	RenderColorSurfaceD3D9()
		: format(kRTFormatARGB32)
		, dim(kTexDim2D)
	{
		RenderSurfaceBase_InitColor(*this);
	}
	RenderTextureFormat	format;
	TextureDimension dim;
};

struct RenderDepthSurfaceD3D9 : public RenderSurfaceD3D9
{
	RenderDepthSurfaceD3D9()
		: depthFormat(kDepthFormatNone)
	{
		RenderSurfaceBase_InitDepth(*this);
	}
	DepthBufferFormat depthFormat;
};