Skip to content

Commit a7f2240

Browse files
authored
Merge branch 'xd_dev' into linux-merge
2 parents 6357979 + 523f754 commit a7f2240

30 files changed

+351
-256
lines changed

src/Layers/xrRender/FVisual.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ void Fvisual::Load(const char* N, IReader* data, u32 dwFlags)
6060
p_rm_Indices->AddRef();
6161
#endif
6262
#endif
63-
#if (RENDER == R_R2) || (RENDER == R_R3) || (RENDER == R_R4) || (RENDER == R_GL)
6463
// check for fast-vertices
64+
#if RENDER == R_R1
65+
if (data->find_chunk(OGF_FASTPATH) && ps_r1_force_geomx)
66+
#else
6567
if (data->find_chunk(OGF_FASTPATH))
68+
#endif
6669
{
6770
destructor<IReader> geomdef(data->open_chunk(OGF_FASTPATH));
6871
destructor<IReader> def(geomdef().open_chunk(OGF_GCONTAINER));
@@ -97,7 +100,6 @@ void Fvisual::Load(const char* N, IReader* data, u32 dwFlags)
97100
// geom
98101
m_fast->rm_geom.create(fmt, m_fast->p_rm_Vertices, m_fast->p_rm_Indices);
99102
}
100-
#endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER==R_GL)
101103
}
102104

103105
// read vertices
@@ -222,8 +224,11 @@ void Fvisual::Load(const char* N, IReader* data, u32 dwFlags)
222224

223225
void Fvisual::Render(float)
224226
{
225-
#if (RENDER == R_R2) || (RENDER == R_R3) || (RENDER == R_R4) || (RENDER==R_GL)
226-
if (m_fast && RImplementation.phase == CRender::PHASE_SMAP && !RCache.is_TessEnabled())
227+
#if RENDER == R_R1
228+
if (m_fast && ps_r1_force_geomx)
229+
#else
230+
if (m_fast && (ps_r1_force_geomx || RImplementation.phase == CRender::PHASE_SMAP && !RCache.is_TessEnabled()))
231+
#endif
227232
{
228233
RCache.set_Geometry(m_fast->rm_geom);
229234
RCache.Render(D3DPT_TRIANGLELIST, m_fast->vBase, 0, m_fast->vCount, m_fast->iBase, m_fast->dwPrimitives);
@@ -235,11 +240,6 @@ void Fvisual::Render(float)
235240
RCache.Render(D3DPT_TRIANGLELIST, vBase, 0, vCount, iBase, dwPrimitives);
236241
RCache.stat.r.s_static.add(vCount);
237242
}
238-
#else // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER==R_GL)
239-
RCache.set_Geometry(rm_geom);
240-
RCache.Render(D3DPT_TRIANGLELIST, vBase, 0, vCount, iBase, dwPrimitives);
241-
RCache.stat.r.s_static.add(vCount);
242-
#endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER==R_GL)
243243
}
244244

245245
#define PCOPY(a) a = pFrom->a

src/Layers/xrRender/HW.h

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,20 @@ class CHW
3838
BOOL support(D3DFORMAT fmt, DWORD type, DWORD usage);
3939
#endif // !USE_OGL
4040

41-
#ifdef DEBUG
42-
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
43-
void Validate(void){};
44-
#else // USE_DX10
45-
void Validate(void)
41+
#if defined(DEBUG) && defined(USE_DX9)
42+
void Validate()
4643
{
4744
VERIFY(pDevice);
4845
VERIFY(pD3D);
4946
};
50-
#endif // USE_DX10
5147
#else
52-
void Validate(void){};
48+
void Validate() {}
5349
#endif
5450

55-
// Variables section
51+
// Variables section
52+
public:
53+
CHWCaps Caps;
54+
5655
#if defined(USE_OGL)
5756
CHW* pDevice;
5857
CHW* pContext;
@@ -63,62 +62,40 @@ class CHW
6362
GLuint pFB;
6463
GLuint pCFB;
6564

66-
CHWCaps Caps;
67-
6865
SDL_Window* m_hWnd;
6966
HDC m_hDC;
7067
SDL_GLContext m_hRC;
71-
#elif defined(USE_DX11)
72-
public:
73-
IDXGIFactory1* m_pFactory = nullptr;
74-
IDXGIAdapter1* m_pAdapter = nullptr; // pD3D equivalent
75-
ID3D11Device* pDevice = nullptr; // combine with DX9 pDevice via typedef
76-
ID3D11DeviceContext* pContext = nullptr; // combine with DX9 pDevice via typedef
77-
IDXGISwapChain* m_pSwapChain = nullptr;
78-
ID3D11RenderTargetView* pBaseRT = nullptr; // combine with DX9 pBaseRT via typedef
79-
ID3D11DepthStencilView* pBaseZB = nullptr;
80-
81-
CHWCaps Caps;
68+
#else // General DirectX
69+
ID3DDevice* pDevice = nullptr; // render device
70+
ID3DRenderTargetView* pBaseRT = nullptr; // base render target
71+
ID3DDepthStencilView* pBaseZB = nullptr; // base depth-stencil buffer
8272

8373
D3D_DRIVER_TYPE m_DriverType;
84-
DXGI_SWAP_CHAIN_DESC m_ChainDesc; // DevPP equivalent
85-
D3D_FEATURE_LEVEL FeatureLevel;
86-
#elif defined(USE_DX10)
87-
public:
74+
#ifndef USE_DX9
8875
IDXGIFactory1* m_pFactory = nullptr;
89-
IDXGIAdapter1* m_pAdapter = nullptr; // pD3D equivalent
90-
ID3D10Device1* pDevice1 = nullptr; // combine with DX9 pDevice via typedef
91-
ID3D10Device* pDevice = nullptr; // combine with DX9 pDevice via typedef
92-
ID3D10Device1* pContext1 = nullptr; // combine with DX9 pDevice via typedef
93-
ID3D10Device* pContext = nullptr; // combine with DX9 pDevice via typedef
76+
IDXGIAdapter1* m_pAdapter = nullptr; // pD3D equivalent
77+
ID3DDeviceContext* pContext = nullptr;
9478
IDXGISwapChain* m_pSwapChain = nullptr;
95-
ID3D10RenderTargetView* pBaseRT = nullptr; // combine with DX9 pBaseRT via typedef
96-
ID3D10DepthStencilView* pBaseZB = nullptr;
97-
98-
CHWCaps Caps;
99-
100-
D3D10_DRIVER_TYPE m_DriverType;
101-
DXGI_SWAP_CHAIN_DESC m_ChainDesc; // DevPP equivalent
79+
DXGI_SWAP_CHAIN_DESC m_ChainDesc; // DevPP equivalent
10280
D3D_FEATURE_LEVEL FeatureLevel;
103-
#else
104-
private:
81+
#if defined(USE_DX10)
82+
ID3D10Device1* pDevice1 = nullptr;
83+
ID3D10Device1* pContext1 = nullptr;
84+
#endif
85+
#else // USE_DX9
10586
#ifdef DEBUG
10687
IDirect3DStateBlock9* dwDebugSB = nullptr;
10788
#endif
89+
private:
10890
XRay::Module hD3D = nullptr;
10991

11092
public:
11193
IDirect3D9* pD3D = nullptr; // D3D
112-
IDirect3DDevice9* pDevice = nullptr; // render device
113-
IDirect3DSurface9* pBaseRT = nullptr;
114-
IDirect3DSurface9* pBaseZB = nullptr;
115-
116-
CHWCaps Caps;
11794

11895
UINT DevAdapter;
119-
D3DDEVTYPE m_DriverType;
12096
D3DPRESENT_PARAMETERS DevPP;
121-
#endif // USE_DX10
97+
#endif // USE_DX9
98+
#endif // USE_OGL
12299

123100
#if !defined(_MAYA_EXPORT) && !defined(USE_OGL)
124101
stats_manager stats_manager;
@@ -128,7 +105,7 @@ class CHW
128105
void UpdateViews();
129106
#endif
130107
#if defined(USE_DX10) || defined(USE_DX11)
131-
bool CheckFormatSupport(DXGI_FORMAT format, D3D_FORMAT_SUPPORT feature) const;
108+
bool CheckFormatSupport(DXGI_FORMAT format, UINT feature) const;
132109
DXGI_FORMAT SelectFormat(D3D_FORMAT_SUPPORT feature, const DXGI_FORMAT formats[], size_t count) const;
133110
virtual void OnAppActivate();
134111
virtual void OnAppDeactivate();

src/Layers/xrRender/LightTrack.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,8 @@ void CROS_impl::update_smooth(IRenderable* O)
365365

366366
void CROS_impl::calc_sun_value(Fvector& position, IGameObject* _object)
367367
{
368-
#if RENDER == R_R1
369-
light* sun = (light*)RImplementation.L_DB->sun._get();
370-
#else
371368
light* sun = (light*)RImplementation.Lights.sun._get();
372-
#endif
369+
373370
if (MODE & IRender_ObjectSpecific::TRACE_SUN)
374371
{
375372
if (--result_sun < 0)
@@ -530,7 +527,7 @@ void CROS_impl::prepare_lights(Fvector& position, IRenderable* O)
530527
}
531528

532529
#if RENDER == R_R1
533-
light* sun = (light*)RImplementation.L_DB->sun._get();
530+
light* sun = (light*)RImplementation.Lights.sun._get();
534531

535532
// Sun
536533
float E = sun_smooth * sun->color.intensity();

src/Layers/xrRender/ResourceManager_Resources.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ void CResourceManager::DBG_VerifyGeoms()
286286
*/
287287
}
288288

289-
SGeometry* CResourceManager::CreateGeom(D3DVERTEXELEMENT9* decl, IDirect3DVertexBuffer9* vb, IDirect3DIndexBuffer9* ib)
289+
SGeometry* CResourceManager::CreateGeom(D3DVERTEXELEMENT9* decl, ID3DVertexBuffer* vb, ID3DIndexBuffer* ib)
290290
{
291291
R_ASSERT(decl && vb);
292292

@@ -310,7 +310,7 @@ SGeometry* CResourceManager::CreateGeom(D3DVERTEXELEMENT9* decl, IDirect3DVertex
310310
v_geoms.push_back(Geom);
311311
return Geom;
312312
}
313-
SGeometry* CResourceManager::CreateGeom(u32 FVF, IDirect3DVertexBuffer9* vb, IDirect3DIndexBuffer9* ib)
313+
SGeometry* CResourceManager::CreateGeom(u32 FVF, ID3DVertexBuffer* vb, ID3DIndexBuffer* ib)
314314
{
315315
D3DVERTEXELEMENT9 dcl[MAX_FVF_DECL_SIZE];
316316
CHK_DX(D3DXDeclaratorFromFVF(FVF, dcl));

src/Layers/xrRender/r__sector.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,41 +34,47 @@ void CPortal::OnRender()
3434
VERIFY(poly.size());
3535
// draw rect
3636
static xr_vector<FVF::L> V;
37-
V.resize(poly.size() + 2);
38-
Fvector C = {0, 0, 0};
39-
for (u32 k = 0; k < poly.size(); k++)
37+
V.resize(poly.size()*3);
38+
Fvector vCenter = { 0.0f, 0.0f, 0.0f };
39+
static u32 portalColor = 0x800000FF;
40+
for (u32 k = 0; k < poly.size(); ++k)
4041
{
41-
C.add(poly[k]);
42-
V[k + 1].set(poly[k], 0x800000FF);
42+
vCenter.add(poly[k]);
43+
V[k * 3 + 1].set(poly[k], portalColor);
44+
45+
if (k + 1 == poly.size())
46+
V[k * 3 + 2].set(poly[0], portalColor);
47+
else
48+
V[k * 3 + 2].set(poly[k + 1], portalColor);
4349
}
44-
V.back().set(poly[0], 0x800000FF);
45-
C.div((float)poly.size());
46-
V[0].set(C, 0x800000FF);
50+
51+
vCenter.div((float)poly.size());
52+
53+
for (u32 k = 0; k < poly.size(); ++k)
54+
V[k * 3].set(vCenter, portalColor);
4755

4856
RCache.set_xform_world(Fidentity);
4957
// draw solid
5058
RCache.set_Shader(RImplementation.m_SelectionShader);
51-
RCache.dbg_Draw(D3DPT_TRIANGLEFAN, &*V.begin(), V.size() - 2);
59+
RCache.dbg_Draw(D3DPT_TRIANGLELIST, &*V.begin(), V.size() / 3);
5260

5361
// draw wire
62+
V.resize(poly.size()+1); // SkyLoader: change vertex array for wire
63+
for (u32 k = 0; k < poly.size(); ++k)
64+
V[k].set(poly[k], portalColor);
65+
V.back().set(poly[0], portalColor);
66+
5467
if (bDebug)
55-
{
5668
RImplementation.rmNear();
57-
}
5869
else
59-
{
6070
Device.SetNearer(TRUE);
61-
}
71+
6272
RCache.set_Shader(RImplementation.m_WireShader);
63-
RCache.dbg_Draw(D3DPT_LINESTRIP, &*(V.begin() + 1), V.size() - 2);
73+
RCache.dbg_Draw(D3DPT_LINESTRIP, &*V.begin(), V.size() - 1);
6474
if (bDebug)
65-
{
6675
RImplementation.rmNormal();
67-
}
6876
else
69-
{
7077
Device.SetNearer(FALSE);
71-
}
7278
}
7379
}
7480
#endif

src/Layers/xrRender/xrD3DDefs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ typedef IDirect3DVertexShader9 ID3DVertexShader;
3737
typedef IDirect3DPixelShader9 ID3DPixelShader;
3838
typedef ID3DXBuffer ID3DBlob;
3939
typedef D3DXMACRO D3D_SHADER_MACRO;
40+
typedef D3DDEVTYPE D3D_DRIVER_TYPE;
4041
typedef IDirect3DQuery9 ID3DQuery;
4142
typedef D3DVIEWPORT9 D3D_VIEWPORT;
4243
typedef ID3DXInclude ID3DInclude;
4344
typedef IDirect3DTexture9 ID3DTexture2D;
4445
typedef IDirect3DSurface9 ID3DRenderTargetView;
4546
typedef IDirect3DSurface9 ID3DDepthStencilView;
47+
typedef IDirect3DDevice9 ID3DDevice;
4648
typedef IDirect3DBaseTexture9 ID3DBaseTexture;
4749
typedef D3DSURFACE_DESC D3D_TEXTURE2D_DESC;
4850
typedef IDirect3DVertexBuffer9 ID3DVertexBuffer;

src/Layers/xrRender/xrRender_console.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ float ps_r1_lmodel_lerp = 0.1f;
116116
float ps_r1_dlights_clip = 40.f;
117117
float ps_r1_pps_u = 0.f;
118118
float ps_r1_pps_v = 0.f;
119+
int ps_r1_force_geomx = 0;
119120

120121
// R1-specific
121122
int ps_r1_GlowsPerFrame = 16; // r1-only
@@ -752,6 +753,7 @@ void xrRender_initconsole()
752753
CMD4(CCC_Float, "r1_dlights_clip", &ps_r1_dlights_clip, 10.f, 150.f);
753754
CMD4(CCC_Float, "r1_pps_u", &ps_r1_pps_u, -1.f, +1.f);
754755
CMD4(CCC_Float, "r1_pps_v", &ps_r1_pps_v, -1.f, +1.f);
756+
CMD4(CCC_Integer, "r1_force_geomx", &ps_r1_force_geomx, 0, 1);
755757

756758
// R1-specific
757759
CMD4(CCC_Integer, "r1_glows_per_frame", &ps_r1_GlowsPerFrame, 2, 32);

src/Layers/xrRender/xrRender_console.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ extern ECORE_API float ps_r1_lmodel_lerp;
6363
extern ECORE_API float ps_r1_dlights_clip;
6464
extern ECORE_API float ps_r1_pps_u;
6565
extern ECORE_API float ps_r1_pps_v;
66+
extern ECORE_API int ps_r1_force_geomx;
6667

6768
// R1-specific
6869
extern ECORE_API int ps_r1_GlowsPerFrame; // r1-only

src/Layers/xrRenderDX10/DXCommonTypes.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ typedef ID3D11DeviceContext ID3DDeviceContext;
150150
#define D3D_FILL_WIREFRAME D3D11_FILL_WIREFRAME
151151

152152
#define D3D_FORMAT_SUPPORT D3D11_FORMAT_SUPPORT
153+
#define D3D_FORMAT_SUPPORT_TEXTURE2D D3D11_FORMAT_SUPPORT_TEXTURE2D
154+
#define D3D_FORMAT_SUPPORT_RENDER_TARGET D3D11_FORMAT_SUPPORT_RENDER_TARGET
153155
#define D3D_FORMAT_SUPPORT_DEPTH_STENCIL D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
154156
#define D3D_FORMAT_SUPPORT_DISPLAY D3D11_FORMAT_SUPPORT_DISPLAY
155157

@@ -328,6 +330,7 @@ typedef ID3D10Resource ID3DResource;
328330

329331
#define D3D_STANDARD_MULTISAMPLE_PATTERN D3D10_STANDARD_MULTISAMPLE_PATTERN
330332

333+
#define D3D_DRIVER_TYPE D3D10_DRIVER_TYPE // There IS already type named D3D_DRIVER_TYPE!!! Fix it later if we would need it
331334
#define D3D_DRIVER_TYPE_REFERENCE D3D10_DRIVER_TYPE_REFERENCE
332335
#define D3D_DRIVER_TYPE_HARDWARE D3D10_DRIVER_TYPE_HARDWARE
333336

@@ -410,6 +413,8 @@ typedef ID3D10Resource ID3DResource;
410413
#define D3D_FILL_WIREFRAME D3D10_FILL_WIREFRAME
411414

412415
#define D3D_FORMAT_SUPPORT D3D10_FORMAT_SUPPORT
416+
#define D3D_FORMAT_SUPPORT_TEXTURE2D D3D10_FORMAT_SUPPORT_TEXTURE2D
417+
#define D3D_FORMAT_SUPPORT_RENDER_TARGET D3D10_FORMAT_SUPPORT_RENDER_TARGET
413418
#define D3D_FORMAT_SUPPORT_DEPTH_STENCIL D3D10_FORMAT_SUPPORT_DEPTH_STENCIL
414419
#define D3D_FORMAT_SUPPORT_DISPLAY D3D10_FORMAT_SUPPORT_DISPLAY
415420

src/Layers/xrRenderDX10/dx10HW.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ void CHW::CreateDevice(SDL_Window* m_sdlWnd)
145145
// TODO: DX10: implement dynamic format selection
146146
constexpr DXGI_FORMAT formats[] =
147147
{
148-
//DXGI_FORMAT_R16G16B16A16_FLOAT,
149-
//DXGI_FORMAT_R10G10B10A2_UNORM,
150-
//DXGI_FORMAT_B8G8R8X8_UNORM,
148+
//DXGI_FORMAT_R16G16B16A16_FLOAT, // Do we even need this?
149+
//DXGI_FORMAT_R10G10B10A2_UNORM, // D3DX11SaveTextureToMemory fails on this format
150+
DXGI_FORMAT_B8G8R8X8_UNORM,
151151
DXGI_FORMAT_R8G8B8A8_UNORM,
152152
};
153153

@@ -260,11 +260,16 @@ void CHW::Reset()
260260
UpdateViews();
261261
}
262262

263-
bool CHW::CheckFormatSupport(const DXGI_FORMAT format, const D3D_FORMAT_SUPPORT feature) const
263+
bool CHW::CheckFormatSupport(const DXGI_FORMAT format, const UINT feature) const
264264
{
265-
UINT feature_bit = feature;
266-
if (SUCCEEDED(pDevice->CheckFormatSupport(format, &feature_bit)))
267-
return true;
265+
UINT supports;
266+
267+
if (SUCCEEDED(pDevice->CheckFormatSupport(format, &supports)))
268+
{
269+
if (supports & feature)
270+
return true;
271+
}
272+
268273
return false;
269274
}
270275

@@ -314,13 +319,12 @@ void CHW::UpdateViews()
314319
descDepth.ArraySize = 1;
315320

316321
// Select depth-stencil format
317-
// TODO: DX10: test and support other formats
318322
constexpr DXGI_FORMAT formats[] =
319323
{
320-
//DXGI_FORMAT_D32_FLOAT_S8X24_UINT,
324+
DXGI_FORMAT_D32_FLOAT_S8X24_UINT,
321325
DXGI_FORMAT_D24_UNORM_S8_UINT,
322-
//DXGI_FORMAT_D32_FLOAT,
323-
//DXGI_FORMAT_D16_UNORM
326+
DXGI_FORMAT_D32_FLOAT,
327+
DXGI_FORMAT_D16_UNORM
324328
};
325329
descDepth.Format = SelectFormat(D3D_FORMAT_SUPPORT_DEPTH_STENCIL, formats, std::size(formats));
326330
Caps.fDepth = dx10TextureUtils::ConvertTextureFormat(descDepth.Format);

0 commit comments

Comments
 (0)