Skip to content

Commit f351ad4

Browse files
committed
Link xrRender_R4 and xrRender_GL to xr_3da
1 parent 1196cac commit f351ad4

File tree

16 files changed

+131
-144
lines changed

16 files changed

+131
-144
lines changed

src/Include/xrRender/xrRender.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#pragma once
2+
3+
#include "xrEngine/EngineAPI.h"
4+
5+
#ifdef XRAY_STATIC_BUILD
6+
# define XRRENDER_R4_API
7+
# define XRRENDER_GL_API
8+
#else
9+
# ifdef XRRENDER_R4_EXPORTS
10+
# define XRRENDER_R4_API XR_EXPORT
11+
# else
12+
# define XRRENDER_R4_API XR_IMPORT
13+
# endif
14+
# ifdef XRRENDER_GL_EXPORTS
15+
# define XRRENDER_GL_API XR_EXPORT
16+
# else
17+
# define XRRENDER_GL_API XR_IMPORT
18+
# endif
19+
#endif
20+
21+
namespace xray::render
22+
{
23+
#ifdef XR_PLATFORM_WINDOWS
24+
namespace render_r4
25+
{
26+
XRRENDER_R4_API RendererModule* GetRendererModule();
27+
}
28+
#endif
29+
namespace render_gl
30+
{
31+
XRRENDER_GL_API RendererModule* GetRendererModule();
32+
}
33+
} // namespace xray::render

src/Layers/xrRender/r__occlusion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
namespace xray::render::RENDER_NAMESPACE
77
{
8-
R_occlusion::R_occlusion(void) { enabled = strstr(Core.Params, "-no_occq") ? false : true; }
98
R_occlusion::~R_occlusion(void) { occq_destroy(); }
109
void R_occlusion::occq_create(u32 limit)
1110
{
1211
ZoneScoped;
12+
enabled = strstr(Core.Params, "-no_occq") ? false : true;
1313
pool.reserve(limit);
1414
used.reserve(limit);
1515
fids.reserve(limit);

src/Layers/xrRender/r__occlusion.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class R_occlusion
3232

3333
static constexpr u32 iInvalidHandle = 0xFFFFFFFF;
3434

35-
bool enabled;
35+
bool enabled{ true };
3636
xr_vector<Query> pool; // sorted (max ... min), insertions are usually at the end
3737
xr_vector<Query> used; // id's are generated from this and it is cleared from back only
3838
xr_vector<u32> fids; // free id's
@@ -47,7 +47,6 @@ class R_occlusion
4747
# error No graphics API selected or enabled!
4848
#endif
4949
public:
50-
R_occlusion();
5150
~R_occlusion();
5251

5352
void occq_create(u32 limit);

src/Layers/xrRenderDX11/3DFluid/dx113DFluidEmitters.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77

88
namespace xray::render::RENDER_NAMESPACE
99
{
10-
namespace
11-
{
12-
shared_str strImpulseSize("size");
13-
shared_str strImpulseCenter("center");
14-
shared_str strSplatColor("splatColor");
15-
}
16-
1710
dx113DFluidEmitters::dx113DFluidEmitters(int gridWidth, int gridHeight, int gridDepth, dx113DFluidGrid* pGrid)
1811
: m_pGrid(pGrid)
1912
{
@@ -79,6 +72,10 @@ void dx113DFluidEmitters::RenderVelocity(const dx113DFluidData& FluidData)
7972

8073
void dx113DFluidEmitters::ApplyDensity(const CEmitter& Emitter)
8174
{
75+
static shared_str strImpulseSize{ "size" };
76+
static shared_str strImpulseCenter{ "center" };
77+
static shared_str strSplatColor{ "splatColor" };
78+
8279
// Draw gaussian ball of color
8380
RCache.set_Element(m_EmitterTechnique[ET_SimpleGausian]);
8481

@@ -120,6 +117,10 @@ void dx113DFluidEmitters::ApplyDensity(const CEmitter& Emitter)
120117
static float lilrand() { return (rand() / float(RAND_MAX) - 0.5f) * 5.0f; }
121118
void dx113DFluidEmitters::ApplyVelocity(const CEmitter& Emitter)
122119
{
120+
static shared_str strImpulseSize{ "size" };
121+
static shared_str strImpulseCenter{ "center" };
122+
static shared_str strSplatColor{ "splatColor" };
123+
123124
// Draw gaussian ball of velocity
124125
RCache.set_Element(m_EmitterTechnique[ET_SimpleGausian]);
125126

src/Layers/xrRenderDX11/3DFluid/dx113DFluidManager.cpp

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,6 @@ namespace xray::render::RENDER_NAMESPACE
1111
{
1212
dx113DFluidManager FluidManager;
1313

14-
namespace
15-
{
16-
// For render call
17-
// DrawTextureShaderVariable = pEffect->GetVariableByName( "textureNumber")->AsScalar();
18-
shared_str strDrawTexture("textureNumber");
19-
// For project, advect
20-
// ModulateShaderVariable = pEffect->GetVariableByName( "modulate")->AsScalar();
21-
shared_str strModulate("modulate");
22-
// For gaussian
23-
//ImpulseSizeShaderVariable = pEffect->GetVariableByName("size")->AsScalar();
24-
//shared_str strImpulseSize("size");
25-
//ImpulseCenterShaderVariable = pEffect->GetVariableByName("center")->AsVector();
26-
//shared_str strImpulseCenter("center");
27-
//SplatColorShaderVariable = pEffect->GetVariableByName("splatColor")->AsVector();
28-
//shared_str strSplatColor("splatColor");
29-
// For confinement
30-
// EpsilonShaderVariable = pEffect->GetVariableByName( "epsilon")->AsScalar();
31-
shared_str strEpsilon("epsilon");
32-
// For confinement, advect
33-
shared_str strTimeStep("timestep");
34-
// For advect BFECC
35-
// ForwardShaderVariable = pEffect->GetVariableByName( "forward")->AsScalar();
36-
shared_str strForward("forward");
37-
// HalfVolumeDimShaderVariable = pEffect->GetVariableByName( "halfVolumeDim")->AsVector();
38-
shared_str strHalfVolumeDim("halfVolumeDim");
39-
40-
shared_str strGravityBuoyancy("GravityBuoyancy");
41-
}
42-
4314
LPCSTR dx113DFluidManager::m_pEngineTextureNames[NUM_RENDER_TARGETS] = {
4415
"$user$Texture_velocity1", //RENDER_TARGET_VELOCITY1 = 0,
4516
// Swap with object's
@@ -387,6 +358,11 @@ void dx113DFluidManager::DetachAndSwapFluidData(dx113DFluidData& FluidData)
387358

388359
void dx113DFluidManager::AdvectColorBFECC(float timestep, bool bTeperature)
389360
{
361+
static shared_str strModulate("modulate");
362+
static shared_str strTimeStep("timestep");
363+
static shared_str strForward("forward");
364+
static shared_str strHalfVolumeDim("halfVolumeDim");
365+
390366
PIX_EVENT(AdvectColorBFECC);
391367

392368
// Clear to zero
@@ -485,6 +461,10 @@ void dx113DFluidManager::AdvectColorBFECC(float timestep, bool bTeperature)
485461

486462
void dx113DFluidManager::AdvectColor(float timestep, bool bTeperature)
487463
{
464+
static shared_str strModulate("modulate");
465+
static shared_str strTimeStep("timestep");
466+
static shared_str strForward("forward");
467+
488468
PIX_EVENT(AdvectColor);
489469
// if(ColorTextureNumber == 0)
490470
//{
@@ -519,6 +499,11 @@ void dx113DFluidManager::AdvectColor(float timestep, bool bTeperature)
519499

520500
void dx113DFluidManager::AdvectVelocity(float timestep, float fGravity)
521501
{
502+
static shared_str strModulate("modulate");
503+
static shared_str strTimeStep("timestep");
504+
static shared_str strForward("forward");
505+
static shared_str strGravityBuoyancy("GravityBuoyancy");
506+
522507
PIX_EVENT(AdvectVelocity);
523508

524509
// pShaderResourceVariables[RENDER_TARGET_VELOCITY1]->SetResource( NULL );
@@ -549,6 +534,9 @@ void dx113DFluidManager::AdvectVelocity(float timestep, float fGravity)
549534

550535
void dx113DFluidManager::ApplyVorticityConfinement(float timestep)
551536
{
537+
static shared_str strEpsilon("epsilon");
538+
static shared_str strTimeStep("timestep");
539+
552540
PIX_EVENT(ApplyVorticityConfinement);
553541

554542
// Compute vorticity
@@ -683,6 +671,8 @@ void dx113DFluidManager::ComputePressure(float /*timestep*/)
683671

684672
void dx113DFluidManager::ProjectVelocity(float /*timestep*/)
685673
{
674+
static shared_str strModulate("modulate");
675+
686676
PIX_EVENT(ProjectVelocity);
687677

688678
// pShaderResourceVariables[RENDER_TARGET_VELOCITY0]->SetResource( NULL );

src/Layers/xrRenderDX11/3DFluid/dx113DFluidObstacles.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,7 @@ sizeof(aabb_id)/(2*sizeof(u16)), color);
4040

4141
namespace
4242
{
43-
// For OOBB
44-
// shared_str strBoxLBDcorner("boxLBDcorner");
45-
// shared_str strBoxRTUcorner("boxRTUcorner");
46-
shared_str strOOBBClipPlane("OOBBClipPlane");
47-
48-
// For velocity calculation
49-
shared_str strWorldToLocal("WorldToLocal");
50-
shared_str strLocalToWorld("LocalToWorld");
51-
shared_str strMassCenter("MassCenter");
52-
shared_str strOOBBWorldAngularVelocity("OOBBWorldAngularVelocity");
53-
shared_str strOOBBWorldTranslationVelocity("OOBBWorldTranslationVelocity");
54-
55-
Fvector4 UnitClipPlanes[] = {
43+
constexpr Fvector4 UnitClipPlanes[] = {
5644
{-1.f, 0.0f, 0.0f, 0.5f}, //
5745
{1.f, 0.0f, 0.0f, 0.5f}, //
5846
{0.0f, -1.f, 0.0f, 0.5f}, // Top
@@ -136,6 +124,8 @@ void dx113DFluidObstacles::ProcessObstacles(const dx113DFluidData& FluidData, fl
136124

137125
void dx113DFluidObstacles::RenderStaticOOBB(const Fmatrix& Transform)
138126
{
127+
static shared_str strOOBBClipPlane("OOBBClipPlane");
128+
139129
PIX_EVENT(RenderObstacle);
140130

141131
// Shader must be already set up!
@@ -173,6 +163,9 @@ void dx113DFluidObstacles::ProcessStaticObstacles(const dx113DFluidData& FluidDa
173163
void dx113DFluidObstacles::ProcessDynamicObstacles(
174164
const dx113DFluidData& FluidData, const Fmatrix& WorldToFluid, float timestep)
175165
{
166+
static shared_str strWorldToLocal("WorldToLocal");
167+
static shared_str strLocalToWorld("LocalToWorld");
168+
176169
m_lstRenderables.clear();
177170
m_lstShells.clear();
178171
m_lstElements.clear();
@@ -260,6 +253,10 @@ void dx113DFluidObstacles::RenderPhysicsShell(const IPhysicsShell* pShell, const
260253
void dx113DFluidObstacles::RenderPhysicsElement(
261254
const IPhysicsElement& Element, const Fmatrix& WorldToFluid, float timestep)
262255
{
256+
static shared_str strMassCenter("MassCenter");
257+
static shared_str strOOBBWorldAngularVelocity("OOBBWorldAngularVelocity");
258+
static shared_str strOOBBWorldTranslationVelocity("OOBBWorldTranslationVelocity");
259+
263260
// Shader must be already set up!
264261
const Fvector3& MassCenter3 = Element.mass_Center();
265262
Fvector3 AngularVelocity3;
@@ -313,6 +310,8 @@ void dx113DFluidObstacles::RenderPhysicsElement(
313310
void dx113DFluidObstacles::RenderDynamicOOBB( const IPhysicsElement &Element, const Fmatrix &WorldToFluid, float
314311
timestep)
315312
{
313+
static shared_str strOOBBClipPlane("OOBBClipPlane");
314+
316315
PIX_EVENT(RenderDynamicObstacle);
317316
318317
// dsdad;
@@ -383,6 +382,8 @@ timestep)
383382
void dx113DFluidObstacles::RenderDynamicOOBB(
384383
const IPhysicsGeometry& Geometry, const Fmatrix& WorldToFluid, float /*timestep*/)
385384
{
385+
static shared_str strOOBBClipPlane("OOBBClipPlane");
386+
386387
PIX_EVENT(RenderDynamicObstacle);
387388

388389
// dsdad;

src/Layers/xrRenderDX11/3DFluid/dx113DFluidRenderer.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,6 @@ struct VsInput
1616
Fvector pos;
1717
};
1818

19-
namespace
20-
{
21-
// For render call
22-
shared_str strZNear("ZNear");
23-
shared_str strZFar("ZFar");
24-
shared_str strGridScaleFactor("gridScaleFactor");
25-
shared_str strEyeOnGrid("eyeOnGrid");
26-
shared_str strWorldViewProjection("WorldViewProjection");
27-
shared_str strInvWorldViewProjection("InvWorldViewProjection");
28-
shared_str strRTWidth("RTWidth");
29-
shared_str strRTHeight("RTHeight");
30-
31-
shared_str strDiffuseLight("DiffuseLight");
32-
}
33-
3419
LPCSTR dx113DFluidRenderer::m_pRTNames[RRT_NumRT] = {
3520
"$user$rayDataTex", "$user$rayDataTexSmall", "$user$rayCastTex", "$user$edgeTex"};
3621

@@ -319,6 +304,8 @@ void dx113DFluidRenderer::CreateRayDataResources(int width, int height)
319304

320305
void dx113DFluidRenderer::Draw(const dx113DFluidData& FluidData)
321306
{
307+
static shared_str strDiffuseLight("DiffuseLight");
308+
322309
// We don't need ZB anyway
323310
RCache.set_ZB(nullptr);
324311

@@ -514,6 +501,15 @@ void dx113DFluidRenderer::CalculateLighting(const dx113DFluidData& FluidData, Fo
514501

515502
void dx113DFluidRenderer::PrepareCBuffer(const dx113DFluidData &FluidData, u32 RTWidth, u32 RTHeight)
516503
{
504+
static shared_str strZNear("ZNear");
505+
static shared_str strZFar("ZFar");
506+
static shared_str strGridScaleFactor("gridScaleFactor");
507+
static shared_str strEyeOnGrid("eyeOnGrid");
508+
static shared_str strWorldViewProjection("WorldViewProjection");
509+
static shared_str strInvWorldViewProjection("InvWorldViewProjection");
510+
static shared_str strRTWidth("RTWidth");
511+
static shared_str strRTHeight("RTHeight");
512+
517513
const Fmatrix& transform = FluidData.GetTransform();
518514
RCache.set_xform_world(transform);
519515

src/Layers/xrRenderPC_GL/xrRender_GL.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#include "stdafx.h"
2+
23
#include "Layers/xrRender/dxRenderFactory.h"
34
#include "Layers/xrRender/dxUIRender.h"
45
#include "Layers/xrRender/dxDebugRender.h"
56
#include "Layers/xrRender/D3DUtils.h"
67

8+
#include "Include/xrRender/xrRender.h"
9+
710
namespace xray::render::RENDER_NAMESPACE
811
{
912
constexpr pcstr RENDERER_R2_MODE = "renderer_r2"; // id 2
@@ -109,12 +112,9 @@ class RGLRendererModule final : public RendererModule
109112
}
110113
}
111114
} static s_rgl_module;
112-
} // namespace xray::render::RENDER_NAMESPACE
113115

114-
extern "C"
116+
RendererModule* GetRendererModule()
115117
{
116-
XR_EXPORT RendererModule* GetRendererModule()
117-
{
118-
return &xray::render::RENDER_NAMESPACE::s_rgl_module;
119-
}
118+
return &s_rgl_module;
120119
}
120+
} // namespace xray::render::RENDER_NAMESPACE

src/Layers/xrRenderPC_R4/xrRender_R4.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "Layers/xrRender/dxDebugRender.h"
66
#include "Layers/xrRender/D3DUtils.h"
77

8+
#include "Include/xrRender/xrRender.h"
9+
810
namespace xray::render::RENDER_NAMESPACE
911
{
1012
constexpr pcstr RENDERER_R2A_MODE = "renderer_r2a"; // id 1
@@ -118,12 +120,10 @@ class R4RendererModule final : public RendererModule
118120
}
119121
}
120122
} static s_r4_module;
121-
} // namespace xray::render::RENDER_NAMESPACE
122123

123-
extern "C"
124-
{
125-
XR_EXPORT RendererModule* GetRendererModule()
124+
RendererModule* GetRendererModule()
126125
{
127-
return &xray::render::RENDER_NAMESPACE::s_r4_module;
128-
}
126+
return &s_r4_module;
129127
}
128+
} // namespace xray::render::RENDER_NAMESPACE
129+

0 commit comments

Comments
 (0)