DX11: Add texture dumping and hires texture loading support.
[dolphin.git] / Source / Plugins / Plugin_VideoDX11 / Src / TextureCache.h
blobe1d4d97c6e5ee21f22a2323b5d68a306c600c253
1 // Copyright (C) 2003 Dolphin Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official SVN repository and contact information can be found at
16 // http://code.google.com/p/dolphin-emu/
18 #pragma once
20 #include <map>
22 #include "D3DBase.h"
23 #include "D3DTexture.h"
24 #include "VideoCommon.h"
25 #include "BPMemory.h"
27 class TextureCache
29 public:
30 struct TCacheEntry
32 D3DTexture2D* texture;
34 u32 addr;
35 u32 size_in_bytes;
36 u64 hash;
37 u32 paletteHash;
38 u32 oldpixel;
40 int frameCount;
41 unsigned int w, h, fmt, MipLevels;
42 int Realw, Realh, Scaledw, Scaledh;
44 bool isRenderTarget;
45 bool isNonPow2;
47 TCacheEntry() : texture(NULL), addr(0), size_in_bytes(0), hash(0), paletteHash(0), oldpixel(0),
48 frameCount(0), w(0), h(0), fmt(0), MipLevels(0), Realw(0), Realh(0), Scaledw(0), Scaledh(0),
49 isRenderTarget(false), isNonPow2(true) {}
51 void Destroy(bool shutdown);
52 bool IntersectsMemoryRange(u32 range_address, u32 range_size);
55 static void Init();
56 static void Cleanup();
57 static void Shutdown();
58 static void Invalidate(bool shutdown);
59 static void InvalidateRange(u32 start_address, u32 size);
60 static TCacheEntry* TextureCache::Load(unsigned int stage, u32 address, unsigned int width, unsigned int height, unsigned int tex_format, unsigned int tlutaddr, unsigned int tlutfmt, bool UseNativeMips, unsigned int maxlevel);
61 static void CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, unsigned int bScaleByHalf, const EFBRectangle &source_rect);
63 private:
64 typedef std::map<u32,TCacheEntry> TexCache;
66 static u8* temp;
67 static TexCache textures;