Skip to content

Commit 6d94a10

Browse files
committed
Merge remote-tracking branch 'intorr/intorr_dev' into xd_dev
2 parents 917cf8c + dd7e5e8 commit 6d94a10

File tree

16 files changed

+164
-330
lines changed

16 files changed

+164
-330
lines changed

src/Layers/xrRenderPC_R1/FStaticRender.cpp

Lines changed: 80 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
// CRender.cpp: implementation of the CRender class.
2-
//
3-
//////////////////////////////////////////////////////////////////////
4-
51
#include "stdafx.h"
6-
#include "xrEngine/IGame_Persistent.h"
7-
#include "xrEngine/Environment.h"
2+
#include "FStaticRender.h"
83
#include "Layers/xrRender/FBasicVisual.h"
9-
#include "xrEngine/CustomHUD.h"
104
#include "xrEngine/xr_object.h"
5+
#include "xrEngine/CustomHUD.h"
6+
#include "xrEngine/IGame_Persistent.h"
7+
#include "xrEngine/Environment.h"
118
#include "xrEngine/GameFont.h"
129
#include "xrEngine/PerformanceAlert.hpp"
13-
#include "xrCore/FMesh.hpp"
1410
#include "Layers/xrRender/SkeletonCustom.h"
15-
#include "Layers/xrRender/lighttrack.h"
11+
#include "Layers/xrRender/LightTrack.h"
1612
#include "Layers/xrRender/dxWallMarkArray.h"
1713
#include "Layers/xrRender/dxUIShader.h"
1814

19-
using namespace R_dsgraph;
20-
2115
CRender RImplementation;
2216

2317
//////////////////////////////////////////////////////////////////////////
@@ -98,10 +92,8 @@ void CRender::create()
9892

9993
m_bMakeAsyncSS = false;
10094

101-
//---------
102-
Target = new CRenderTarget();
103-
//---------
104-
//
95+
Target = new CRenderTarget(); // Main target
96+
10597
Models = new CModelPool();
10698
L_Dynamic = new CLightR_Manager();
10799
PSLibrary.OnCreate();
@@ -124,7 +116,6 @@ void CRender::destroy()
124116
//*** Components
125117
xr_delete(Target);
126118
Device.seqFrame.Remove(this);
127-
128119
r_dsgraph_destroy();
129120
}
130121

@@ -153,7 +144,11 @@ void CRender::reset_end()
153144
m_bFirstFrameAfterReset = true;
154145
}
155146

156-
void CRender::OnFrame() { Models->DeleteQueue(); }
147+
void CRender::OnFrame()
148+
{
149+
Models->DeleteQueue();
150+
}
151+
157152
// Implementation
158153
IRender_ObjectSpecific* CRender::ros_create(IRenderable* parent) { return new CROS_impl(); }
159154
void CRender::ros_destroy(IRender_ObjectSpecific*& p) { xr_delete(p); }
@@ -188,7 +183,6 @@ IRenderVisual* CRender::model_CreatePE(LPCSTR name)
188183
R_ASSERT3(SE, "Particle effect doesn't exist", name);
189184
return Models->CreatePE(SE);
190185
}
191-
192186
IRenderVisual* CRender::model_CreateParticles(LPCSTR name)
193187
{
194188
PS::CPEDef* SE = PSLibrary.FindPED(name);
@@ -239,25 +233,19 @@ IDirect3DIndexBuffer9* CRender::getIB(int id)
239233
VERIFY(id < int(IB.size()));
240234
return IB[id];
241235
}
242-
IRender_Target* CRender::getTarget() { return Target; }
243236
FSlideWindowItem* CRender::getSWI(int id)
244237
{
245238
VERIFY(id < int(SWIs.size()));
246239
return &SWIs[id];
247240
}
248-
241+
IRender_Target* CRender::getTarget() { return Target; }
249242
IRender_Light* CRender::light_create() { return L_DB->Create(); }
250243
IRender_Glow* CRender::glow_create() { return new CGlow(); }
251244
void CRender::flush() { r_dsgraph_render_graph(0); }
252245
BOOL CRender::occ_visible(vis_data& P) { return HOM.visible(P); }
253246
BOOL CRender::occ_visible(sPoly& P) { return HOM.visible(P); }
254247
BOOL CRender::occ_visible(Fbox& P) { return HOM.visible(P); }
255-
ENGINE_API extern BOOL g_bRendering;
256-
void CRender::add_Visual(IRenderVisual* V)
257-
{
258-
VERIFY(g_bRendering);
259-
add_leafs_Dynamic((dxRender_Visual*)V);
260-
}
248+
void CRender::add_Visual(IRenderVisual* V) { add_leafs_Dynamic((dxRender_Visual*)V); }
261249
void CRender::add_Geometry(IRenderVisual* V) { add_Static((dxRender_Visual*)V, View->getMask()); }
262250
void CRender::add_StaticWallmark(ref_shader& S, const Fvector& P, float s, CDB::TRI* T, Fvector* verts)
263251
{
@@ -281,12 +269,7 @@ void CRender::add_StaticWallmark(const wm_shader& S, const Fvector& P, float s,
281269
add_StaticWallmark(pShader->hShader, P, s, T, V);
282270
}
283271

284-
void CRender::clear_static_wallmarks()
285-
{
286-
if (Wallmarks)
287-
Wallmarks->clear();
288-
}
289-
272+
void CRender::clear_static_wallmarks() { Wallmarks->clear(); }
290273
void CRender::add_SkeletonWallmark(intrusive_ptr<CSkeletonWallmark> wm) { Wallmarks->AddSkeletonWallmark(wm); }
291274
void CRender::add_SkeletonWallmark(
292275
const Fmatrix* xf, CKinematics* obj, ref_shader& sh, const Fvector& start, const Fvector& dir, float size)
@@ -301,16 +284,11 @@ void CRender::add_SkeletonWallmark(
301284
if (pShader)
302285
add_SkeletonWallmark(xf, (CKinematics*)obj, *pShader, start, dir, size);
303286
}
304-
void CRender::add_Occluder(Fbox2& bb_screenspace)
305-
{
306-
VERIFY(_valid(bb_screenspace));
307-
HOM.occlude(bb_screenspace);
308-
}
287+
void CRender::add_Occluder(Fbox2& bb_screenspace) { HOM.occlude(bb_screenspace); }
309288

310289
#include "xrEngine/PS_instance.h"
311290
void CRender::set_Object(IRenderable* O)
312291
{
313-
VERIFY(g_bRendering);
314292
val_pObject = O; // NULL is OK, trust me :)
315293
if (val_pObject)
316294
{
@@ -371,6 +349,25 @@ IC void gm_SetNearer(BOOL bNearer)
371349
}
372350
}
373351

352+
void CRender::rmNear()
353+
{
354+
IRender_Target* T = getTarget();
355+
D3DVIEWPORT9 VP = {0, 0, T->get_width(), T->get_height(), 0, 0.02f};
356+
CHK_DX(HW.pDevice->SetViewport(&VP));
357+
}
358+
void CRender::rmFar()
359+
{
360+
IRender_Target* T = getTarget();
361+
D3DVIEWPORT9 VP = {0, 0, T->get_width(), T->get_height(), 0.99999f, 1.f};
362+
CHK_DX(HW.pDevice->SetViewport(&VP));
363+
}
364+
void CRender::rmNormal()
365+
{
366+
IRender_Target* T = getTarget();
367+
D3DVIEWPORT9 VP = {0, 0, T->get_width(), T->get_height(), 0, 1.f};
368+
CHK_DX(HW.pDevice->SetViewport(&VP));
369+
}
370+
374371
//////////////////////////////////////////////////////////////////////
375372
// Construction/Destruction
376373
//////////////////////////////////////////////////////////////////////
@@ -600,25 +597,6 @@ void CRender::Calculate()
600597
BasicStats.Culling.End();
601598
}
602599

603-
void CRender::rmNear()
604-
{
605-
IRender_Target* T = getTarget();
606-
D3DVIEWPORT9 VP = {0, 0, T->get_width(), T->get_height(), 0, 0.02f};
607-
CHK_DX(HW.pDevice->SetViewport(&VP));
608-
}
609-
void CRender::rmFar()
610-
{
611-
IRender_Target* T = getTarget();
612-
D3DVIEWPORT9 VP = {0, 0, T->get_width(), T->get_height(), 0.99999f, 1.f};
613-
CHK_DX(HW.pDevice->SetViewport(&VP));
614-
}
615-
void CRender::rmNormal()
616-
{
617-
IRender_Target* T = getTarget();
618-
D3DVIEWPORT9 VP = {0, 0, T->get_width(), T->get_height(), 0, 1.f};
619-
CHK_DX(HW.pDevice->SetViewport(&VP));
620-
}
621-
622600
extern u32 g_r;
623601
void CRender::Render()
624602
{
@@ -745,49 +723,7 @@ void CRender::DumpStatistics(IGameFont& font, IPerformanceAlert* alert)
745723
Sectors_xrc.DumpStatistics(font, alert);
746724
}
747725

748-
#pragma comment(lib, "d3dx9.lib")
749-
750-
static inline bool match_shader_id(
751-
LPCSTR const debug_shader_id, LPCSTR const full_shader_id, FS_FileSet const& file_set, string_path& result);
752-
753-
//--------------------------------------------------------------------------------------------------------------
754-
class includer : public ID3DXInclude
755-
{
756-
public:
757-
HRESULT __stdcall Open(
758-
D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID* ppData, UINT* pBytes)
759-
{
760-
string_path pname;
761-
strconcat(sizeof(pname), pname, GEnv.Render->getShaderPath(), pFileName);
762-
IReader* R = FS.r_open("$game_shaders$", pname);
763-
if (nullptr == R)
764-
{
765-
// possibly in shared directory or somewhere else - open directly
766-
R = FS.r_open("$game_shaders$", pFileName);
767-
if (nullptr == R)
768-
return E_FAIL;
769-
}
770-
771-
// duplicate and zero-terminate
772-
u32 size = R->length();
773-
u8* data = xr_alloc<u8>(size + 1);
774-
CopyMemory(data, R->pointer(), size);
775-
data[size] = 0;
776-
FS.r_close(R);
777-
778-
*ppData = data;
779-
*pBytes = size;
780-
return D3D_OK;
781-
}
782-
HRESULT __stdcall Close(LPCVOID pData)
783-
{
784-
xr_free(pData);
785-
return D3D_OK;
786-
}
787-
};
788-
789-
static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 const buffer_size, LPCSTR const file_name,
790-
void*& result, bool const disasm)
726+
static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 const buffer_size, LPCSTR const file_name, void*& result, bool const disasm)
791727
{
792728
HRESULT _result = E_FAIL;
793729
if (pTarget[0] == 'p')
@@ -814,7 +750,7 @@ static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 cons
814750
Msg("! D3DXFindShaderComment hr == 0x%08x", _result);
815751
}
816752
}
817-
else
753+
else if (pTarget[0] == 'v')
818754
{
819755
SVS* svs_result = (SVS*)result;
820756
_result = HW.pDevice->CreateVertexShader(buffer, &svs_result->vs);
@@ -838,6 +774,10 @@ static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 cons
838774
Msg("! D3DXFindShaderComment hr == 0x%08x", _result);
839775
}
840776
}
777+
else
778+
{
779+
NODEFAULT;
780+
}
841781

842782
if (disasm)
843783
{
@@ -854,6 +794,44 @@ static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 cons
854794
return _result;
855795
}
856796

797+
class includer : public ID3DXInclude
798+
{
799+
public:
800+
HRESULT __stdcall Open(
801+
D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID* ppData, UINT* pBytes)
802+
{
803+
string_path pname;
804+
strconcat(sizeof(pname), pname, GEnv.Render->getShaderPath(), pFileName);
805+
IReader* R = FS.r_open("$game_shaders$", pname);
806+
if (nullptr == R)
807+
{
808+
// possibly in shared directory or somewhere else - open directly
809+
R = FS.r_open("$game_shaders$", pFileName);
810+
if (nullptr == R)
811+
return E_FAIL;
812+
}
813+
814+
// duplicate and zero-terminate
815+
u32 size = R->length();
816+
u8* data = xr_alloc<u8>(size + 1);
817+
CopyMemory(data, R->pointer(), size);
818+
data[size] = 0;
819+
FS.r_close(R);
820+
821+
*ppData = data;
822+
*pBytes = size;
823+
return D3D_OK;
824+
}
825+
HRESULT __stdcall Close(LPCVOID pData)
826+
{
827+
xr_free(pData);
828+
return D3D_OK;
829+
}
830+
};
831+
832+
static inline bool match_shader_id(
833+
LPCSTR const debug_shader_id, LPCSTR const full_shader_id, FS_FileSet const& file_set, string_path& result);
834+
857835
HRESULT CRender::shader_compile(LPCSTR name, DWORD const* pSrcData, UINT SrcDataLen, LPCSTR pFunctionName,
858836
LPCSTR pTarget, DWORD Flags, void*& result)
859837
{
@@ -862,7 +840,6 @@ HRESULT CRender::shader_compile(LPCSTR name, DWORD const* pSrcData, UINT SrcData
862840

863841
char sh_name[MAX_PATH] = "";
864842
u32 len = 0;
865-
866843
// options
867844
if (o.forceskinw)
868845
{
@@ -873,6 +850,7 @@ HRESULT CRender::shader_compile(LPCSTR name, DWORD const* pSrcData, UINT SrcData
873850
sh_name[len] = '0' + char(o.forceskinw);
874851
++len;
875852

853+
// skinning
876854
if (m_skinning < 0)
877855
{
878856
defines[def_it].Name = "SKIN_NONE";

src/Layers/xrRenderPC_R1/stdafx.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,9 @@
66
#define D3D_DEBUG_INFO
77
#endif
88

9-
#pragma warning(push)
10-
#pragma warning(disable : 4995)
119
#include "xrEngine/stdafx.h"
1210
#include <d3d9.h>
1311
#include <d3dx9.h>
14-
#pragma warning(pop)
15-
16-
#pragma warning(disable : 4714)
17-
#pragma warning(4 : 4018)
18-
#pragma warning(4 : 4244)
1912

2013
#include "Layers/xrRender/xrD3DDefs.h"
2114
#include "Layers/xrRender/HW.h"
@@ -35,8 +28,8 @@
3528
#include "Common/_d3d_extensions.h"
3629
#ifndef _EDITOR
3730
#include "xrEngine/IGame_Level.h"
38-
#include "Layers/xrRender/blenders\Blender.h"
39-
#include "Layers/xrRender/blenders\Blender_CLSID.h"
31+
#include "Layers/xrRender/blenders/Blender.h"
32+
#include "Layers/xrRender/blenders/Blender_CLSID.h"
4033
#include "xrParticles/psystem.h"
4134
#include "Layers/xrRender/xrRender_console.h"
4235
#include "FStaticRender.h"

src/Layers/xrRenderPC_R2/Light_Render_Direct_ComputeXFS.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,5 @@ void CLight_Compute_XFORM_and_VIS::compute_xf_spot(light* L)
8989
// _min(L->cone + deg2rad(4.5f), PI*0.98f) - Here, it is needed to enlarge the shadow map frustum to include also
9090
// displaced pixels and the pixels neighbor to the examining one.
9191
L->X.S.project.build_projection(std::min(L->cone + deg2rad(5.f), PI * 0.98f), 1.f, SMAP_near_plane, L->range + EPS_S);
92-
9392
L->X.S.combine.mul(L->X.S.project, L->X.S.view);
9493
}

0 commit comments

Comments
 (0)