std::map.I just want it be simple for my small demos. Here is how I organazied it:
class TextureManager
{
private:
static class TextureManager *m_TextureManager;
map<wstring, ID3D10ShaderResourceView*, less<wstring> > textures;
map<wstring, ID3D10ShaderResourceView*, less<wstring> >::iterator iter;
ID3D10Device* md3dDevice;
public:
TextureManager (void);
~TextureManager (void);
static TextureManager *GetManager();
bool addTexture(wstring path);
void deleteTexture(wstring path);
void clearTextures();
void setDevice(ID3D10Device* dev);
void checkDevice();
ID3D10ShaderResourceView* GetTextureView(wstring path);
ID3D10Device* getDevice();
ID3D10ShaderResourceView* TexView;
};
[color="#000000"]it's a singleton class, [color="#000000"]addTexture and GetTextureView implemented like this:
bool TextureManager::addTexture(wstring path)
{
checkDevice();
iter=textures.find(path.c_str());
if(iter==textures.end())
{
HRESULT hr=D3DX10CreateShaderResourceViewFromFile(md3dDevice, path.c_str(), NULL, NULL, &TexView, NULL);
if(hr!=S_OK)
return false;
textures.insert( pair<wstring,ID3D10ShaderResourceView*>(path.c_str(),TexView));
return true;
}
return false;
}
ID3D10ShaderResourceView* TextureManager::GetTextureView(wstring path)
{
checkDevice();
iter=textures.find(path.c_str());
if(iter==textures.end())
if(!addTexture(path.c_str()))
return NULL;
return textures[path.c_str()];
}
[color="#000000"]The problem is when I'm using my manager's function GetTextureView to set new texture into shader like this:
[color="#000000"]mfxVar->SetResource(txr_man->GetTextureView(filenames[texIndex].c_str()));
[color="#000000"]I got my application 200-300 FPS down :[color="#000000"]( If I use just an [color="#000000"]ID3D10ShaderResourceView*[color="#000000"]array in application,instead of texture manager FPS looks good. Can't understand why putting [color="#000000"]ID3D10ShaderResourceView [color="#000000"]into <map>decreases FPS. Sure I can get rid of <map> just using an array of [color="#000000"]ID3D10ShaderResourceView [color="#000000"]in my manager while keeping it's functionality, but then I can't resize my texture array. Someone have any ideas about?