gsdx: Remove hash_{map,set} macros

Also use auto when appropriate.
This commit is contained in:
Jonathan Li 2017-05-26 16:41:52 +01:00 committed by Gregory Hainaut
parent d57b812f36
commit 2aeb406e38
14 changed files with 74 additions and 80 deletions

View File

@ -145,17 +145,17 @@ public: // TODO
// Shaders...
hash_map<uint32, GSVertexShader11 > m_vs;
std::unordered_map<uint32, GSVertexShader11> m_vs;
CComPtr<ID3D11Buffer> m_vs_cb;
hash_map<uint32, CComPtr<ID3D11GeometryShader> > m_gs;
std::unordered_map<uint32, CComPtr<ID3D11GeometryShader>> m_gs;
CComPtr<ID3D11Buffer> m_gs_cb;
hash_map<uint64, CComPtr<ID3D11PixelShader> > m_ps;
std::unordered_map<uint64, CComPtr<ID3D11PixelShader>> m_ps;
CComPtr<ID3D11Buffer> m_ps_cb;
hash_map<uint32, CComPtr<ID3D11SamplerState> > m_ps_ss;
std::unordered_map<uint32, CComPtr<ID3D11SamplerState>> m_ps_ss;
CComPtr<ID3D11SamplerState> m_palette_ss;
CComPtr<ID3D11SamplerState> m_rt_ss;
hash_map<uint32, CComPtr<ID3D11DepthStencilState> > m_om_dss;
hash_map<uint32, CComPtr<ID3D11BlendState> > m_om_bs;
std::unordered_map<uint32, CComPtr<ID3D11DepthStencilState>> m_om_dss;
std::unordered_map<uint32, CComPtr<ID3D11BlendState>> m_om_bs;
VSConstantBuffer m_vs_cb_cache;
GSConstantBuffer m_gs_cb_cache;

View File

@ -172,12 +172,12 @@ public: // TODO
// Shaders...
hash_map<uint32, GSVertexShader9 > m_vs;
hash_map<uint64, CComPtr<IDirect3DPixelShader9> > m_ps;
hash_map<uint32, Direct3DSamplerState9* > m_ps_ss;
hash_map<uint32, Direct3DDepthStencilState9* > m_om_dss;
hash_map<uint32, Direct3DBlendState9* > m_om_bs;
hash_map<uint32, GSTexture*> m_mskfix;
std::unordered_map<uint32, GSVertexShader9> m_vs;
std::unordered_map<uint64, CComPtr<IDirect3DPixelShader9>> m_ps;
std::unordered_map<uint32, Direct3DSamplerState9*> m_ps_ss;
std::unordered_map<uint32, Direct3DDepthStencilState9*> m_om_dss;
std::unordered_map<uint32, Direct3DBlendState9*> m_om_bs;
std::unordered_map<uint32, GSTexture*> m_mskfix;
GSTexture* CreateMskFix(uint32 size, uint32 msk, uint32 fix);

View File

@ -478,7 +478,7 @@ public:
GLuint m_gs[1<<3];
GLuint m_ps_ss[1<<7];
GSDepthStencilOGL* m_om_dss[1<<5];
hash_map<uint64, GLuint > m_ps;
std::unordered_map<uint64, GLuint> m_ps;
GLuint m_apitrace;
GLuint m_palette_ss;

View File

@ -38,8 +38,8 @@ protected:
VALUE f;
};
hash_map<KEY, VALUE> m_map;
hash_map<KEY, ActivePtr*> m_map_active;
std::unordered_map<KEY, VALUE> m_map;
std::unordered_map<KEY, ActivePtr*> m_map_active;
ActivePtr* m_active;
@ -60,15 +60,15 @@ public:
{
m_active = NULL;
typename hash_map<KEY, ActivePtr*>::iterator i = m_map_active.find(key);
auto it = m_map_active.find(key);
if(i != m_map_active.end())
if(it != m_map_active.end())
{
m_active = i->second;
m_active = it->second;
}
else
{
typename hash_map<KEY, VALUE>::iterator i = m_map.find(key);
auto i = m_map.find(key);
ActivePtr* p = new ActivePtr();
@ -108,11 +108,9 @@ public:
{
uint64 ttpf = 0;
typename hash_map<KEY, ActivePtr*>::iterator i;
for(i = m_map_active.begin(); i != m_map_active.end(); ++i)
for(const auto &i : m_map_active)
{
ActivePtr* p = i->second;
ActivePtr* p = i.second;
if(p->frames)
{
@ -122,10 +120,10 @@ public:
printf("GS stats\n");
for(i = m_map_active.begin(); i != m_map_active.end(); ++i)
for (const auto &i : m_map_active)
{
KEY key = i->first;
ActivePtr* p = i->second;
KEY key = i.first;
ActivePtr* p = i.second;
if(p->frames && ttpf)
{
@ -161,7 +159,7 @@ class GSCodeGeneratorFunctionMap : public GSFunctionMap<KEY, VALUE>
{
std::string m_name;
void* m_param;
hash_map<uint64, VALUE> m_cgmap;
std::unordered_map<uint64, VALUE> m_cgmap;
GSCodeBuffer m_cb;
size_t m_total_code_size;
@ -186,7 +184,7 @@ public:
{
VALUE ret = NULL;
typename hash_map<uint64, VALUE>::iterator i = m_cgmap.find(key);
auto i = m_cgmap.find(key);
if(i != m_cgmap.end())
{

View File

@ -498,9 +498,9 @@ GSLocalMemory::~GSLocalMemory()
for(auto &i : m_pomap) _aligned_free(i.second);
for(auto &i : m_po4map) _aligned_free(i.second);
for(hash_map<uint64, vector<GSVector2i>*>::iterator i = m_p2tmap.begin(); i != m_p2tmap.end(); ++i)
for(auto &i : m_p2tmap)
{
delete [] i->second;
delete [] i.second;
}
}
@ -508,7 +508,7 @@ GSOffset* GSLocalMemory::GetOffset(uint32 bp, uint32 bw, uint32 psm)
{
uint32 hash = bp | (bw << 14) | (psm << 20);
hash_map<uint32, GSOffset*>::iterator i = m_omap.find(hash);
auto i = m_omap.find(hash);
if(i != m_omap.end())
{
@ -539,11 +539,11 @@ GSPixelOffset* GSLocalMemory::GetPixelOffset(const GIFRegFRAME& FRAME, const GIF
uint32 hash = (FRAME.FBP << 0) | (ZBUF.ZBP << 9) | (bw << 18) | (fpsm_hash << 24) | (zpsm_hash << 28);
hash_map<uint32, GSPixelOffset*>::iterator i = m_pomap.find(hash);
auto it = m_pomap.find(hash);
if(i != m_pomap.end())
if(it != m_pomap.end())
{
return i->second;
return it->second;
}
GSPixelOffset* off = (GSPixelOffset*)_aligned_malloc(sizeof(GSPixelOffset), 32);
@ -595,11 +595,11 @@ GSPixelOffset4* GSLocalMemory::GetPixelOffset4(const GIFRegFRAME& FRAME, const G
uint32 hash = (FRAME.FBP << 0) | (ZBUF.ZBP << 9) | (bw << 18) | (fpsm_hash << 24) | (zpsm_hash << 28);
hash_map<uint32, GSPixelOffset4*>::iterator i = m_po4map.find(hash);
auto it = m_po4map.find(hash);
if(i != m_po4map.end())
if(it != m_po4map.end())
{
return i->second;
return it->second;
}
GSPixelOffset4* off = (GSPixelOffset4*)_aligned_malloc(sizeof(GSPixelOffset4), 32);
@ -640,11 +640,11 @@ vector<GSVector2i>* GSLocalMemory::GetPage2TileMap(const GIFRegTEX0& TEX0)
{
uint64 hash = TEX0.u64 & 0x3ffffffffull; // TBP0 TBW PSM TW TH
hash_map<uint64, vector<GSVector2i>*>::iterator i = m_p2tmap.find(hash);
auto it = m_p2tmap.find(hash);
if(i != m_p2tmap.end())
if(it != m_p2tmap.end())
{
return i->second;
return it->second;
}
GSVector2i bs = m_psm[TEX0.PSM].bs;
@ -654,7 +654,7 @@ vector<GSVector2i>* GSLocalMemory::GetPage2TileMap(const GIFRegTEX0& TEX0)
const GSOffset* off = GetOffset(TEX0.TBP0, TEX0.TBW, TEX0.PSM);
hash_map<uint32, hash_set<uint32> > tmp; // key = page, value = y:x, 7 bits each, max 128x128 tiles for the worst case (1024x1024 32bpp 8x8 blocks)
std::unordered_map<uint32, std::unordered_set<uint32>> tmp; // key = page, value = y:x, 7 bits each, max 128x128 tiles for the worst case (1024x1024 32bpp 8x8 blocks)
for(int y = 0; y < th; y += bs.y)
{
@ -672,22 +672,20 @@ vector<GSVector2i>* GSLocalMemory::GetPage2TileMap(const GIFRegTEX0& TEX0)
vector<GSVector2i>* p2t = new vector<GSVector2i>[MAX_PAGES];
for(hash_map<uint32, hash_set<uint32> >::iterator i = tmp.begin(); i != tmp.end(); ++i)
for(const auto &i : tmp)
{
uint32 page = i->first;
uint32 page = i.first;
hash_set<uint32>& tiles = i->second;
auto& tiles = i.second;
hash_map<uint32, uint32> m;
std::unordered_map<uint32, uint32> m;
for(hash_set<uint32>::iterator j = tiles.begin(); j != tiles.end(); ++j)
for(const auto addr : tiles)
{
uint32 addr = *j;
uint32 row = addr >> 5;
uint32 col = 1 << (addr & 31);
hash_map<uint32, uint32>::iterator k = m.find(row);
auto k = m.find(row);
if(k != m.end())
{
@ -704,9 +702,9 @@ vector<GSVector2i>* GSLocalMemory::GetPage2TileMap(const GIFRegTEX0& TEX0)
// sort by x and flip the mask (it will be used to erase a lot of bits in a loop, [x] &= ~y)
for(hash_map<uint32, uint32>::iterator j = m.begin(); j != m.end(); ++j)
for(const auto &j : m)
{
p2t[page].push_back(GSVector2i(j->first, ~j->second));
p2t[page].push_back(GSVector2i(j.first, ~j.second));
}
std::sort(p2t[page].begin(), p2t[page].end(), cmp_vec2x);

View File

@ -173,10 +173,10 @@ protected:
//
hash_map<uint32, GSOffset*> m_omap;
hash_map<uint32, GSPixelOffset*> m_pomap;
hash_map<uint32, GSPixelOffset4*> m_po4map;
hash_map<uint64, vector<GSVector2i>*> m_p2tmap;
std::unordered_map<uint32, GSOffset*> m_omap;
std::unordered_map<uint32, GSPixelOffset*> m_pomap;
std::unordered_map<uint32, GSPixelOffset4*> m_po4map;
std::unordered_map<uint64, std::vector<GSVector2i>*> m_p2tmap;
public:
GSLocalMemory();

View File

@ -501,7 +501,7 @@ void GSRendererCS::Draw()
{
GSVertexShader11 vs;
hash_map<uint32, GSVertexShader11>::const_iterator i = m_vs.find(vs_sel);
auto i = std::as_const(m_vs).find(vs_sel);
if(i != m_vs.end())
{
@ -558,7 +558,7 @@ void GSRendererCS::Draw()
{
gs_sel.prim = j == 0 ? m_vt.m_primclass : GS_SPRITE_CLASS;
hash_map<uint32, CComPtr<ID3D11GeometryShader> >::const_iterator i = m_gs.find(gs_sel);
auto i = std::as_const(m_gs).find(gs_sel);
if(i != m_gs.end())
{
@ -597,7 +597,7 @@ void GSRendererCS::Draw()
CComPtr<ID3D11PixelShader> ps[2] = {m_ps0, NULL};
hash_map<uint64, CComPtr<ID3D11PixelShader> >::const_iterator i = m_ps1.find(ps_sel);
auto i = std::as_const(m_ps1).find(ps_sel);
if(i != m_ps1.end())
{
@ -825,7 +825,7 @@ bool GSRendererCS::GetOffsetBuffer(OffsetBuffer** fzbo)
D3D11_SHADER_RESOURCE_VIEW_DESC srvd;
D3D11_SUBRESOURCE_DATA data;
hash_map<uint32, OffsetBuffer>::iterator i = m_offset.find(m_context->offset.fzb->hash);
auto i = m_offset.find(m_context->offset.fzb->hash);
if(i == m_offset.end())
{

View File

@ -107,11 +107,11 @@ class GSRendererCS : public GSRenderer
uint32 m_vm_valid[16];
CComPtr<ID3D11Buffer> m_pb;
//CComPtr<ID3D11Texture2D> m_pb;
hash_map<uint32, GSVertexShader11 > m_vs;
std::unordered_map<uint32, GSVertexShader11> m_vs;
CComPtr<ID3D11Buffer> m_vs_cb;
hash_map<uint32, CComPtr<ID3D11GeometryShader> > m_gs;
std::unordered_map<uint32, CComPtr<ID3D11GeometryShader>> m_gs;
CComPtr<ID3D11PixelShader> m_ps0;
hash_map<uint64, CComPtr<ID3D11PixelShader> > m_ps1;
std::unordered_map<uint64, CComPtr<ID3D11PixelShader>> m_ps1;
CComPtr<ID3D11Buffer> m_ps_cb;
void Write(GSOffset* off, const GSVector4i& r);
@ -123,7 +123,7 @@ class GSRendererCS : public GSRenderer
CComPtr<ID3D11ShaderResourceView> row_srv, col_srv;
};
hash_map<uint32, OffsetBuffer> m_offset;
std::unordered_map<uint32, OffsetBuffer> m_offset;
bool GetOffsetBuffer(OffsetBuffer** fzbo);

View File

@ -23,7 +23,7 @@
class GSShaderOGL {
GLuint m_pipeline;
hash_map<uint32, GLuint> m_program;
std::unordered_map<uint32, GLuint> m_program;
const bool m_debug_shader;
std::vector<GLuint> m_shad_to_delete;

View File

@ -108,7 +108,7 @@ public:
class SourceMap
{
public:
hash_set<Source*> m_surfaces;
std::unordered_set<Source*> m_surfaces;
std::array<FastList<Source*>, MAX_PAGES> m_map;
uint32 m_pages[16]; // bitmap of all pages
bool m_used;

View File

@ -58,7 +58,7 @@ public:
protected:
GSState* m_state;
hash_set<Texture*> m_textures;
std::unordered_set<Texture*> m_textures;
std::array<FastList<Texture*>, MAX_PAGES> m_map;
public:

View File

@ -99,7 +99,7 @@ bool GSDevice11::CreateTextureFX()
void GSDevice11::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
{
hash_map<uint32, GSVertexShader11 >::const_iterator i = m_vs.find(sel);
auto i = std::as_const(m_vs).find(sel);
if(i == m_vs.end())
{
@ -160,7 +160,7 @@ void GSDevice11::SetupGS(GSSelector sel, const GSConstantBuffer* cb)
bool Unscale_GSShader = (sel.point == 1 || sel.line == 1) && UserHacks_unscale_pt_ln;
if((sel.prim > 0 && (sel.iip == 0 || sel.prim == 3)) || Unscale_GSShader) // geometry shader works in every case, but not needed
{
hash_map<uint32, CComPtr<ID3D11GeometryShader> >::const_iterator i = m_gs.find(sel);
auto i = std::as_const(m_gs).find(sel);
if(i != m_gs.end())
{
@ -205,7 +205,7 @@ void GSDevice11::SetupGS(GSSelector sel, const GSConstantBuffer* cb)
void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel)
{
hash_map<uint64, CComPtr<ID3D11PixelShader> >::const_iterator i = m_ps.find(sel);
auto i = std::as_const(m_ps).find(sel);
if(i == m_ps.end())
{
@ -286,7 +286,7 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe
ssel.ltf = 0;
}
hash_map<uint32, CComPtr<ID3D11SamplerState> >::const_iterator i = m_ps_ss.find(ssel);
auto i = std::as_const(m_ps_ss).find(ssel);
if(i != m_ps_ss.end())
{
@ -327,7 +327,7 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe
void GSDevice11::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix)
{
hash_map<uint32, CComPtr<ID3D11DepthStencilState> >::const_iterator i = m_om_dss.find(dssel);
auto i = std::as_const(m_om_dss).find(dssel);
if(i == m_om_dss.end())
{
@ -376,7 +376,7 @@ void GSDevice11::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uin
OMSetDepthStencilState(i->second, 1);
hash_map<uint32, CComPtr<ID3D11BlendState> >::const_iterator j = m_om_bs.find(bsel);
auto j = std::as_const(m_om_bs).find(bsel);
if(j == m_om_bs.end())
{

View File

@ -30,7 +30,7 @@ GSTexture* GSDevice9::CreateMskFix(uint32 size, uint32 msk, uint32 fix)
uint32 hash = (size << 20) | (msk << 10) | fix;
hash_map<uint32, GSTexture*>::iterator i = m_mskfix.find(hash);
auto i = m_mskfix.find(hash);
if(i != m_mskfix.end())
{
@ -63,7 +63,7 @@ GSTexture* GSDevice9::CreateMskFix(uint32 size, uint32 msk, uint32 fix)
void GSDevice9::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
{
hash_map<uint32, GSVertexShader9>::const_iterator i = m_vs.find(sel);
auto i = std::as_const(m_vs).find(sel);
if(i == m_vs.end())
{
@ -133,7 +133,7 @@ void GSDevice9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSel
}
}
hash_map<uint64, CComPtr<IDirect3DPixelShader9> >::const_iterator i = m_ps.find(sel);
auto i = std::as_const(m_ps).find(sel);
if(i == m_ps.end())
{
@ -203,7 +203,7 @@ void GSDevice9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSel
ssel.ltf = 0;
}
hash_map<uint32, Direct3DSamplerState9* >::const_iterator i = m_ps_ss.find(ssel);
auto i = std::as_const(m_ps_ss).find(ssel);
if(i != m_ps_ss.end())
{
@ -240,7 +240,7 @@ void GSDevice9::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint
{
Direct3DDepthStencilState9* dss = NULL;
hash_map<uint32, Direct3DDepthStencilState9*>::const_iterator i = m_om_dss.find(dssel);
auto i = std::as_const(m_om_dss).find(dssel);
if(i == m_om_dss.end())
{
@ -282,7 +282,7 @@ void GSDevice9::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint
OMSetDepthStencilState(i->second);
hash_map<uint32, Direct3DBlendState9*>::const_iterator j = m_om_bs.find(bsel);
auto j = std::as_const(m_om_bs).find(bsel);
if(j == m_om_bs.end())
{

View File

@ -127,8 +127,6 @@ using namespace std;
#include <unordered_map>
#include <unordered_set>
#define hash_map unordered_map
#define hash_set unordered_set
#ifdef _WIN32