Skip to content

Commit f28b8a9

Browse files
intorrXottab-DUTY
authored andcommitted
Delete USE_RESOURCE_DEBUGGER. Replace FixedMap with xr_unordered_map. A small decrease in FPS is approximately 1-3% in Release. TODO: use an pool allocator with xr_unordered_map (maybe boost or tbb?) to compensate.
1 parent d533f5b commit f28b8a9

File tree

6 files changed

+210
-278
lines changed

6 files changed

+210
-278
lines changed

src/Layers/xrRender/D3DXRenderBase.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,25 @@ class D3DXRenderBase : public IRender, public pureFrame
4848
#endif
4949

5050
// Runtime structures
51-
xr_vector<R_dsgraph::mapNormalVS::TNode*> nrmVS;
51+
xr_vector<R_dsgraph::mapNormalVS::value_type *> nrmVS;
5252
#if defined(USE_DX10) || defined(USE_DX11)
53-
xr_vector<R_dsgraph::mapNormalGS::TNode*> nrmGS;
53+
xr_vector<R_dsgraph::mapNormalGS::value_type *> nrmGS;
5454
#endif // USE_DX10
55-
xr_vector<R_dsgraph::mapNormalPS::TNode*> nrmPS;
56-
xr_vector<R_dsgraph::mapNormalCS::TNode*> nrmCS;
57-
xr_vector<R_dsgraph::mapNormalStates::TNode*> nrmStates;
58-
xr_vector<R_dsgraph::mapNormalTextures::TNode*> nrmTextures;
59-
xr_vector<R_dsgraph::mapNormalTextures::TNode*> nrmTexturesTemp;
55+
xr_vector<R_dsgraph::mapNormalPS::value_type *> nrmPS;
56+
xr_vector<R_dsgraph::mapNormalCS::value_type *> nrmCS;
57+
xr_vector<R_dsgraph::mapNormalStates::value_type *> nrmStates;
58+
xr_vector<R_dsgraph::mapNormalTextures::value_type *> nrmTextures;
59+
xr_vector<R_dsgraph::mapNormalTextures::value_type *> nrmTexturesTemp;
6060

61-
xr_vector<R_dsgraph::mapMatrixVS::TNode*> matVS;
61+
xr_vector<R_dsgraph::mapMatrixVS::value_type *> matVS;
6262
#if defined(USE_DX10) || defined(USE_DX11)
63-
xr_vector<R_dsgraph::mapMatrixGS::TNode*> matGS;
63+
xr_vector<R_dsgraph::mapMatrixGS::value_type *> matGS;
6464
#endif // USE_DX10
65-
xr_vector<R_dsgraph::mapMatrixPS::TNode*> matPS;
66-
xr_vector<R_dsgraph::mapMatrixCS::TNode*> matCS;
67-
xr_vector<R_dsgraph::mapMatrixStates::TNode*> matStates;
68-
xr_vector<R_dsgraph::mapMatrixTextures::TNode*> matTextures;
69-
xr_vector<R_dsgraph::mapMatrixTextures::TNode*> matTexturesTemp;
65+
xr_vector<R_dsgraph::mapMatrixPS::value_type *> matPS;
66+
xr_vector<R_dsgraph::mapMatrixCS::value_type *> matCS;
67+
xr_vector<R_dsgraph::mapMatrixStates::value_type *> matStates;
68+
xr_vector<R_dsgraph::mapMatrixTextures::value_type *> matTextures;
69+
xr_vector<R_dsgraph::mapMatrixTextures::value_type *> matTexturesTemp;
7070
xr_vector<R_dsgraph::_LodItem> lstLODs;
7171
xr_vector<int> lstLODgroups;
7272
xr_vector<ISpatial*> lstRenderables;
@@ -135,10 +135,10 @@ class D3DXRenderBase : public IRender, public pureFrame
135135

136136
for (int i = 0; i < SHADER_PASSES_MAX; ++i)
137137
{
138-
mapNormalPasses[0][i].destroy();
139-
mapNormalPasses[1][i].destroy();
140-
mapMatrixPasses[0][i].destroy();
141-
mapMatrixPasses[1][i].destroy();
138+
mapNormalPasses[0][i].clear();
139+
mapNormalPasses[1][i].clear();
140+
mapMatrixPasses[0][i].clear();
141+
mapMatrixPasses[1][i].clear();
142142
}
143143
mapSorted.destroy();
144144
mapHUD.destroy();

src/Layers/xrRender/r__dsgraph_build.cpp

Lines changed: 69 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -163,91 +163,65 @@ void D3DXRenderBase::r_dsgraph_insert_dynamic(dxRender_Visual* pVisual, Fvector&
163163

164164
for (u32 iPass = 0; iPass < sh->passes.size(); ++iPass)
165165
{
166-
// the most common node
167-
// SPass& pass = *sh->passes.front ();
168-
// mapMatrix_T& map = mapMatrix [sh->flags.iPriority/2];
169-
SPass& pass = *sh->passes[iPass];
170-
mapMatrix_T& map = mapMatrixPasses[sh->flags.iPriority / 2][iPass];
166+
auto &pass = *sh->passes[iPass];
167+
auto &map = mapMatrixPasses[sh->flags.iPriority / 2][iPass];
171168

172-
#ifdef USE_RESOURCE_DEBUGGER
173169
#if defined(USE_DX10) || defined(USE_DX11)
174-
mapMatrixVS::TNode* Nvs = map.insert(pass.vs);
175-
mapMatrixGS::TNode* Ngs = Nvs->val.insert(pass.gs);
176-
mapMatrixPS::TNode* Nps = Ngs->val.insert(pass.ps);
177-
#else // USE_DX10
178-
mapMatrixVS::TNode* Nvs = map.insert(pass.vs);
179-
mapMatrixPS::TNode* Nps = Nvs->val.insert(pass.ps);
180-
#endif // USE_DX10
170+
auto &Nvs = map[&*pass.vs];
171+
auto &Ngs = Nvs[pass.gs->gs];
172+
auto &Nps = Ngs[pass.ps->ps];
181173
#else
182-
#if defined(USE_DX10) || defined(USE_DX11)
183-
mapMatrixVS::TNode* Nvs = map.insert(&*pass.vs);
184-
mapMatrixGS::TNode* Ngs = Nvs->val.insert(pass.gs->gs);
185-
mapMatrixPS::TNode* Nps = Ngs->val.insert(pass.ps->ps);
186-
#else // USE_DX10
187-
mapMatrixVS::TNode* Nvs = map.insert(pass.vs->vs);
188-
mapMatrixPS::TNode* Nps = Nvs->val.insert(pass.ps->ps);
189-
#endif // USE_DX10
174+
auto &Nvs = map[pass.vs->vs];
175+
auto &Nps = Nvs[pass.ps->ps];
190176
#endif
191177

192178
#ifdef USE_DX11
193-
#ifdef USE_RESOURCE_DEBUGGER
194-
Nps->val.hs = pass.hs;
195-
Nps->val.ds = pass.ds;
196-
mapMatrixCS::TNode* Ncs = Nps->val.mapCS.insert(pass.constants._get());
197-
#else
198-
Nps->val.hs = pass.hs->sh;
199-
Nps->val.ds = pass.ds->sh;
200-
mapMatrixCS::TNode* Ncs = Nps->val.mapCS.insert(pass.constants._get());
201-
#endif
179+
Nps.hs = pass.hs->sh;
180+
Nps.ds = pass.ds->sh;
181+
182+
auto &Ncs = Nps.mapCS[pass.constants._get()];
202183
#else
203-
mapMatrixCS::TNode* Ncs = Nps->val.insert(pass.constants._get());
184+
auto &Ncs = Nps[pass.constants._get()];
204185
#endif
205-
mapMatrixStates::TNode* Nstate = Ncs->val.insert(pass.state->state);
206-
mapMatrixTextures::TNode* Ntex = Nstate->val.insert(pass.T._get());
207-
mapMatrixItems& items = Ntex->val;
208-
items.push_back(item);
186+
auto &Nstate = Ncs[pass.state->state];
187+
auto &Ntex = Nstate[pass.T._get()];
188+
Ntex.push_back(item);
209189

210190
// Need to sort for HZB efficient use
211-
if (SSA > Ntex->val.ssa)
191+
if (SSA > Ntex.ssa)
212192
{
213-
Ntex->val.ssa = SSA;
214-
if (SSA > Nstate->val.ssa)
193+
Ntex.ssa = SSA;
194+
if (SSA > Nstate.ssa)
215195
{
216-
Nstate->val.ssa = SSA;
217-
if (SSA > Ncs->val.ssa)
196+
Nstate.ssa = SSA;
197+
if (SSA > Ncs.ssa)
218198
{
219-
Ncs->val.ssa = SSA;
199+
Ncs.ssa = SSA;
220200
#ifdef USE_DX11
221-
if (SSA > Nps->val.mapCS.ssa)
201+
if (SSA > Nps.mapCS.ssa)
222202
{
223-
Nps->val.mapCS.ssa = SSA;
203+
Nps.mapCS.ssa = SSA;
224204
#else
225-
if (SSA > Nps->val.ssa)
205+
if (SSA > Nps.ssa)
226206
{
227-
Nps->val.ssa = SSA;
207+
Nps.ssa = SSA;
228208
#endif
229209
#if defined(USE_DX10) || defined(USE_DX11)
230-
if (SSA > Ngs->val.ssa)
210+
if (SSA > Ngs.ssa)
231211
{
232-
Ngs->val.ssa = SSA;
233-
#endif // USE_DX10
234-
if (SSA > Nvs->val.ssa)
212+
Ngs.ssa = SSA;
213+
#endif
214+
if (SSA > Nvs.ssa)
235215
{
236-
Nvs->val.ssa = SSA;
237-
#if defined(USE_DX10) || defined(USE_DX11)
216+
Nvs.ssa = SSA;
238217
}
218+
#if defined(USE_DX10) || defined(USE_DX11)
239219
}
220+
#endif
240221
}
241222
}
242223
}
243224
}
244-
#else // USE_DX10
245-
}
246-
}
247-
}
248-
}
249-
}
250-
#endif // USE_DX10
251225
}
252226

253227
#if RENDER != R_R1
@@ -345,107 +319,69 @@ void D3DXRenderBase::r_dsgraph_insert_static(dxRender_Visual* pVisual)
345319

346320
counter_S++;
347321

322+
_NormalItem item = {SSA, pVisual};
323+
348324
for (u32 iPass = 0; iPass < sh->passes.size(); ++iPass)
349325
{
350-
// SPass& pass = *sh->passes.front ();
351-
// mapNormal_T& map = mapNormal [sh->flags.iPriority/2];
352-
SPass& pass = *sh->passes[iPass];
353-
mapNormal_T& map = mapNormalPasses[sh->flags.iPriority / 2][iPass];
354-
355-
//#ifdef USE_RESOURCE_DEBUGGER
356-
// mapNormalVS::TNode* Nvs = map.insert (pass.vs);
357-
// mapNormalPS::TNode* Nps = Nvs->val.insert (pass.ps);
358-
//#else
359-
//#if defined(USE_DX10) || defined(USE_DX11)
360-
// mapNormalVS::TNode* Nvs = map.insert (&*pass.vs);
361-
//#else // USE_DX10
362-
// mapNormalVS::TNode* Nvs = map.insert (pass.vs->vs);
363-
//#endif // USE_DX10
364-
// mapNormalPS::TNode* Nps = Nvs->val.insert (pass.ps->ps);
365-
//#endif
366-
367-
#ifdef USE_RESOURCE_DEBUGGER
368-
#if defined(USE_DX10) || defined(USE_DX11)
369-
mapNormalVS::TNode* Nvs = map.insert(pass.vs);
370-
mapNormalGS::TNode* Ngs = Nvs->val.insert(pass.gs);
371-
mapNormalPS::TNode* Nps = Ngs->val.insert(pass.ps);
372-
#else // USE_DX10
373-
mapNormalVS::TNode* Nvs = map.insert(pass.vs);
374-
mapNormalPS::TNode* Nps = Nvs->val.insert(pass.ps);
375-
#endif // USE_DX10
376-
#else // USE_RESOURCE_DEBUGGER
377-
#if defined(USE_DX10) || defined(USE_DX11)
378-
mapNormalVS::TNode* Nvs = map.insert(&*pass.vs);
379-
mapNormalGS::TNode* Ngs = Nvs->val.insert(pass.gs->gs);
380-
mapNormalPS::TNode* Nps = Ngs->val.insert(pass.ps->ps);
381-
#else // USE_DX10
382-
mapNormalVS::TNode* Nvs = map.insert(pass.vs->vs);
383-
mapNormalPS::TNode* Nps = Nvs->val.insert(pass.ps->ps);
384-
#endif // USE_DX10
385-
#endif // USE_RESOURCE_DEBUGGER
326+
auto &pass = *sh->passes[iPass];
327+
auto &map = mapNormalPasses[sh->flags.iPriority / 2][iPass];
386328

387-
#ifdef USE_DX11
388-
#ifdef USE_RESOURCE_DEBUGGER
389-
Nps->val.hs = pass.hs;
390-
Nps->val.ds = pass.ds;
391-
mapNormalCS::TNode* Ncs = Nps->val.mapCS.insert(pass.constants._get());
329+
#if defined(USE_DX10) || defined(USE_DX11)
330+
auto &Nvs = map[&*pass.vs];
331+
auto &Ngs = Nvs[pass.gs->gs];
332+
auto &Nps = Ngs[pass.ps->ps];
392333
#else
393-
Nps->val.hs = pass.hs->sh;
394-
Nps->val.ds = pass.ds->sh;
395-
mapNormalCS::TNode* Ncs = Nps->val.mapCS.insert(pass.constants._get());
334+
auto &Nvs = map[pass.vs->vs];
335+
auto &Nps = Nvs[pass.ps->ps];
396336
#endif
337+
338+
#ifdef USE_DX11
339+
Nps.hs = pass.hs->sh;
340+
Nps.ds = pass.ds->sh;
341+
342+
auto &Ncs = Nps.mapCS[pass.constants._get()];
397343
#else
398-
mapNormalCS::TNode* Ncs = Nps->val.insert(pass.constants._get());
344+
auto &Ncs = Nps[pass.constants._get()];
399345
#endif
400-
mapNormalStates::TNode* Nstate = Ncs->val.insert(pass.state->state);
401-
mapNormalTextures::TNode* Ntex = Nstate->val.insert(pass.T._get());
402-
mapNormalItems& items = Ntex->val;
403-
_NormalItem item = {SSA, pVisual};
404-
items.push_back(item);
346+
auto &Nstate = Ncs[pass.state->state];
347+
auto &Ntex = Nstate[pass.T._get()];
348+
Ntex.push_back(item);
405349

406350
// Need to sort for HZB efficient use
407-
if (SSA > Ntex->val.ssa)
351+
if (SSA > Ntex.ssa)
408352
{
409-
Ntex->val.ssa = SSA;
410-
if (SSA > Nstate->val.ssa)
353+
Ntex.ssa = SSA;
354+
if (SSA > Nstate.ssa)
411355
{
412-
Nstate->val.ssa = SSA;
413-
if (SSA > Ncs->val.ssa)
356+
Nstate.ssa = SSA;
357+
if (SSA > Ncs.ssa)
414358
{
415-
Ncs->val.ssa = SSA;
359+
Ncs.ssa = SSA;
416360
#ifdef USE_DX11
417-
if (SSA > Nps->val.mapCS.ssa)
361+
if (SSA > Nps.mapCS.ssa)
418362
{
419-
Nps->val.mapCS.ssa = SSA;
363+
Nps.mapCS.ssa = SSA;
420364
#else
421-
if (SSA > Nps->val.ssa)
365+
if (SSA > Nps.ssa)
422366
{
423-
Nps->val.ssa = SSA;
367+
Nps.ssa = SSA;
424368
#endif
425-
// if (SSA>Nvs->val.ssa) { Nvs->val.ssa = SSA;
426-
// } } } } }
427369
#if defined(USE_DX10) || defined(USE_DX11)
428-
if (SSA > Ngs->val.ssa)
370+
if (SSA > Ngs.ssa)
429371
{
430-
Ngs->val.ssa = SSA;
431-
#endif // USE_DX10
432-
if (SSA > Nvs->val.ssa)
372+
Ngs.ssa = SSA;
373+
#endif
374+
if (SSA > Nvs.ssa)
433375
{
434-
Nvs->val.ssa = SSA;
435-
#if defined(USE_DX10) || defined(USE_DX11)
376+
Nvs.ssa = SSA;
436377
}
378+
#if defined(USE_DX10) || defined(USE_DX11)
437379
}
380+
#endif
438381
}
439382
}
440383
}
441384
}
442-
#else // USE_DX10
443-
}
444-
}
445-
}
446-
}
447-
}
448-
#endif // USE_DX10
449385
}
450386

451387
#if RENDER != R_R1

0 commit comments

Comments
 (0)