Skip to content

Commit 73062e0

Browse files
committed
Merge remote-tracking branch 'upstream/xd_dev' into xd_dev
2 parents e7bd549 + e90204d commit 73062e0

File tree

9 files changed

+59
-51
lines changed

9 files changed

+59
-51
lines changed

src/Layers/xrRender/HOM.cpp

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
//////////////////////////////////////////////////////////////////////
44

55
#include "stdafx.h"
6+
7+
#include <tbb/blocked_range.h>
8+
#include <tbb/parallel_for.h>
9+
610
#include "HOM.h"
711
#include "occRasterizer.h"
812
#include "xrEngine/GameFont.h"
@@ -93,26 +97,30 @@ void CHOM::Load()
9397

9498
// Create RASTER-triangles
9599
m_pTris = xr_alloc<occTri>(u32(CL.getTS()));
96-
for (u32 it = 0; it < CL.getTS(); it++)
100+
101+
tbb::parallel_for(tbb::blocked_range<u32>(0, CL.getTS()), [&](const auto& range)
97102
{
98-
CDB::TRI& clT = CL.getT()[it];
99-
occTri& rT = m_pTris[it];
100-
Fvector& v0 = CL.getV()[clT.verts[0]];
101-
Fvector& v1 = CL.getV()[clT.verts[1]];
102-
Fvector& v2 = CL.getV()[clT.verts[2]];
103-
rT.adjacent[0] = (0xffffffff == adjacency[3 * it + 0]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 0]);
104-
rT.adjacent[1] = (0xffffffff == adjacency[3 * it + 1]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 1]);
105-
rT.adjacent[2] = (0xffffffff == adjacency[3 * it + 2]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 2]);
106-
rT.flags = clT.dummy;
107-
rT.area = Area(v0, v1, v2);
108-
if (rT.area < EPS_L)
103+
for (u32 it = range.begin(); it != range.end(); ++it)
109104
{
110-
Msg("! Invalid HOM triangle (%f,%f,%f)-(%f,%f,%f)-(%f,%f,%f)", VPUSH(v0), VPUSH(v1), VPUSH(v2));
105+
CDB::TRI& clT = CL.getT()[it];
106+
occTri& rT = m_pTris[it];
107+
Fvector& v0 = CL.getV()[clT.verts[0]];
108+
Fvector& v1 = CL.getV()[clT.verts[1]];
109+
Fvector& v2 = CL.getV()[clT.verts[2]];
110+
rT.adjacent[0] = (0xffffffff == adjacency[3 * it + 0]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 0]);
111+
rT.adjacent[1] = (0xffffffff == adjacency[3 * it + 1]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 1]);
112+
rT.adjacent[2] = (0xffffffff == adjacency[3 * it + 2]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 2]);
113+
rT.flags = clT.dummy;
114+
rT.area = Area(v0, v1, v2);
115+
116+
if (rT.area < EPS_L)
117+
Msg("! Invalid HOM triangle (%f,%f,%f)-(%f,%f,%f)-(%f,%f,%f)", VPUSH(v0), VPUSH(v1), VPUSH(v2));
118+
119+
rT.plane.build(v0, v1, v2);
120+
rT.skip = 0;
121+
rT.center.add(v0, v1).add(v2).div(3.f);
111122
}
112-
rT.plane.build(v0, v1, v2);
113-
rT.skip = 0;
114-
rT.center.add(v0, v1).add(v2).div(3.f);
115-
}
123+
});
116124

117125
// Create AABB-tree
118126
m_pModel = new CDB::MODEL();

src/Layers/xrRender/ModelPool.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "stdafx.h"
2-
#pragma hdrstop
32

43
#include "ModelPool.h"
54

@@ -395,7 +394,7 @@ void CModelPool::Prefetch()
395394
// prefetch visuals
396395
string256 section;
397396
strconcat(sizeof(section), section, "prefetch_visuals_", g_pGamePersistent->m_game_params.m_game_type);
398-
CInifile::Sect& sect = pSettings->r_section(section);
397+
const CInifile::Sect& sect = pSettings->r_section(section);
399398
for (auto I = sect.Data.cbegin(); I != sect.Data.cend(); I++)
400399
{
401400
const CInifile::Item& item = *I;

src/Layers/xrRender/PSLibrary.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "stdafx.h"
2-
#pragma hdrstop
2+
33
#include "PSLibrary.h"
44
#include "ParticleEffect.h"
55
#include "ParticleGroup.h"
@@ -8,8 +8,6 @@
88
#include "editors/ECore/Editor/ui_main.h"
99
#endif
1010

11-
#define _game_data_ "$game_data$"
12-
1311
bool ped_sort_pred(const PS::CPEDef* a, const PS::CPEDef* b) { return xr_strcmp(a->Name(), b->Name()) < 0; }
1412
bool pgd_sort_pred(const PS::CPGDef* a, const PS::CPGDef* b) { return xr_strcmp(a->m_Name, b->m_Name) < 0; }
1513
bool ped_find_pred(const PS::CPEDef* a, LPCSTR b) { return xr_strcmp(a->Name(), b) < 0; }

src/Layers/xrRender/ResourceManager.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,23 +348,12 @@ void CResourceManager::DeferredUpload()
348348
if (!RDEVICE.b_is_Ready)
349349
return;
350350

351-
#ifndef MASTER_GOLD
352-
Msg("%s, amount of textures: %d", __FUNCTION__, m_textures.size());
353-
354-
CTimer timer;
355-
timer.Start();
356-
#endif
357-
358351
#ifndef USE_OGL
359352
tbb::parallel_for_each(m_textures, [&](auto m_tex) { m_tex.second->Load(); });
360353
#else
361354
for (auto& texture : m_textures)
362355
texture.second->Load();
363356
#endif
364-
365-
#ifndef MASTER_GOLD
366-
Msg("%s, texture loading time: %d ms", __FUNCTION__, timer.GetElapsed_ms());
367-
#endif
368357
}
369358
/*
370359
void CResourceManager::DeferredUnload ()

src/Layers/xrRender/ResourceManager_Loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#pragma hdrstop
33

44
#include "ResourceManager.h"
5-
#include "blenders\blender.h"
5+
#include "blenders/blender.h"
66

77
void CResourceManager::OnDeviceDestroy(BOOL)
88
{

src/Layers/xrRender/ResourceManager_Resources.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "stdafx.h"
2-
#pragma hdrstop
2+
33

44
#pragma warning(push)
55
#pragma warning(disable : 4995)
@@ -12,8 +12,8 @@
1212

1313
#include "ResourceManager.h"
1414
#include "tss.h"
15-
#include "blenders\blender.h"
16-
#include "blenders\blender_recorder.h"
15+
#include "blenders/blender.h"
16+
#include "blenders/blender_recorder.h"
1717

1818
void fix_texture_name(LPSTR fn);
1919

src/Layers/xrRenderPC_R1/FStaticRender.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ void CRender::reset_end()
147147
void CRender::OnFrame()
148148
{
149149
Models->DeleteQueue();
150+
151+
if (ps_r2_ls_flags.test(R2FLAG_EXP_MT_CALC))
152+
{
153+
// MT-details (@front)
154+
Device.seqParallel.insert(
155+
Device.seqParallel.begin(), fastdelegate::FastDelegate0<>(Details, &CDetailManager::MT_CALC));
156+
157+
// MT-HOM (@front)
158+
Device.seqParallel.insert(Device.seqParallel.begin(), fastdelegate::FastDelegate0<>(&HOM, &CHOM::MT_RENDER));
159+
}
150160
}
151161

152162
// Перед началом рендера мира --#SM+#-- +SecondVP+
@@ -426,8 +436,11 @@ void CRender::Calculate()
426436
// Frustum & HOM rendering
427437
ViewBase.CreateFromMatrix(Device.mFullTransform, FRUSTUM_P_LRTB | FRUSTUM_P_FAR);
428438
View = nullptr;
429-
HOM.Enable();
430-
HOM.Render(ViewBase);
439+
if (!ps_r2_ls_flags.test(R2FLAG_EXP_MT_CALC))
440+
{
441+
HOM.Enable();
442+
HOM.Render(ViewBase);
443+
}
431444
gm_SetNearer(FALSE);
432445
phase = PHASE_NORMAL;
433446

@@ -469,7 +482,7 @@ void CRender::Calculate()
469482
PortalTraverser.traverse(pLastSector, ViewBase, Device.vCameraPosition, Device.mFullTransform,
470483
CPortalTraverser::VQ_HOM + CPortalTraverser::VQ_SSA + CPortalTraverser::VQ_FADE);
471484

472-
// Determine visibility for static geometry hierrarhy
485+
// Determine visibility for static geometry hierarchy
473486
if (psDeviceFlags.test(rsDrawStatic))
474487
{
475488
for (u32 s_it = 0; s_it < PortalTraverser.r_sectors.size(); s_it++)
@@ -597,7 +610,7 @@ void CRender::Calculate()
597610
}
598611
}
599612

600-
// Calculate miscelaneous stuff
613+
// Calculate miscellaneous stuff
601614
BasicStats.ShadowsCalc.Begin();
602615
L_Shadows->calculate();
603616
BasicStats.ShadowsCalc.End();
@@ -645,7 +658,7 @@ void CRender::Render()
645658
r_pmask(true, false); // disable priority "1"
646659
o.vis_intersect = TRUE;
647660
HOM.Disable();
648-
L_Dynamic->render(0); // addititional light sources
661+
L_Dynamic->render(0); // additional light sources
649662
if (Wallmarks)
650663
{
651664
g_r = 0;
@@ -661,7 +674,7 @@ void CRender::Render()
661674
BasicStats.ShadowsRender.End();
662675
r_dsgraph_render_lods(false, true); // lods - FB
663676
r_dsgraph_render_graph(1); // normal level, secondary priority
664-
L_Dynamic->render(1); // addititional light sources, secondary priority
677+
L_Dynamic->render(1); // additional light sources, secondary priority
665678
PortalTraverser.fade_render(); // faded-portals
666679
r_dsgraph_render_sorted(); // strict-sorted geoms
667680
BasicStats.Glows.Begin();

src/xrEngine/IGame_Persistent.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,21 +138,23 @@ void IGame_Persistent::OnGameStart()
138138
void IGame_Persistent::Prefetch()
139139
{
140140
// prefetch game objects & models
141-
float p_time = 1000.f * Device.GetTimerGlobal()->GetElapsed_sec();
142-
u32 mem_0 = Memory.mem_usage();
141+
CTimer timer;
142+
timer.Start();
143+
const auto memoryBefore = Memory.mem_usage();
143144

144145
Log("Loading objects...");
145146
ObjectPool.prefetch();
147+
146148
Log("Loading models...");
147149
GEnv.Render->models_Prefetch();
150+
148151
Log("Loading textures...");
149152
GEnv.Render->ResourcesDeferredUpload();
150153

151-
p_time = 1000.f * Device.GetTimerGlobal()->GetElapsed_sec() - p_time;
152-
u32 p_mem = Memory.mem_usage() - mem_0;
154+
const auto memoryAfter = Memory.mem_usage() - memoryBefore;
153155

154-
Msg("* [prefetch] time: %d ms", iFloor(p_time));
155-
Msg("* [prefetch] memory: %dKb", p_mem / 1024);
156+
Msg("* [prefetch] time: %d ms", timer.GetElapsed_ms());
157+
Msg("* [prefetch] memory: %d Kb", memoryAfter / 1024);
156158
}
157159
#endif
158160

src/xrEngine/device.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
#include "xrCore/FTimer.h"
1515
#include "Stats.h"
16+
#include "xrCommon/xr_list.h"
1617
#include "xrCore/Threading/Event.hpp"
1718
#include "xrCore/fastdelegate.h"
18-
#include "xrCommon/xr_list.h"
1919
#include "xrCore/ModuleLookup.hpp"
2020

2121
#define VIEWPORT_NEAR 0.2f
@@ -26,7 +26,6 @@
2626
#include "Include/xrRender/FactoryPtr.h"
2727
#include "Render.h"
2828

29-
3029
class engine_impl;
3130

3231
#pragma pack(push, 4)

0 commit comments

Comments
 (0)