Skip to content

Commit 9e0ca32

Browse files
committed
Renderers: type aliases instead of type defs
#pragma once in correct place
1 parent f02b913 commit 9e0ca32

File tree

4 files changed

+74
-61
lines changed

4 files changed

+74
-61
lines changed

src/Include/xrRender/EnvironmentRender.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
#pragma once
12
#ifndef EnvironmentRender_included
23
#define EnvironmentRender_included
3-
#pragma once
44

55
namespace particles_systems
66
{

src/Layers/xrRender/Shader.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "sh_constant.h"
1616
#include "sh_rt.h"
1717

18-
typedef xr_vector<shared_str> sh_list;
18+
using sh_list = xr_vector<shared_str>;
1919
class CBlender_Compile;
2020
class IBlender;
2121
#define SHADER_PASSES_MAX 2
@@ -25,7 +25,7 @@ class IBlender;
2525
//////////////////////////////////////////////////////////////////////////
2626
struct ECORE_API STextureList : public xr_resource_flagged, public xr_vector<std::pair<u32, ref_texture>>
2727
{
28-
typedef xr_vector<std::pair<u32, ref_texture>> inherited_vec;
28+
using inherited_vec = xr_vector<std::pair<u32, ref_texture>>;
2929
~STextureList();
3030

3131
BOOL equal(const STextureList& base) const
@@ -114,7 +114,6 @@ typedef resptr_core<SPass, resptr_base<SPass>> ref_pass;
114114
//////////////////////////////////////////////////////////////////////////
115115
struct ECORE_API ShaderElement : public xr_resource_flagged
116116
{
117-
public:
118117
struct Sflags
119118
{
120119
u32 iPriority : 2;
@@ -124,7 +123,6 @@ struct ECORE_API ShaderElement : public xr_resource_flagged
124123
u32 bWmark : 1;
125124
};
126125

127-
public:
128126
Sflags flags;
129127
svector<ref_pass, SHADER_PASSES_MAX> passes;
130128

@@ -133,25 +131,26 @@ struct ECORE_API ShaderElement : public xr_resource_flagged
133131
BOOL equal(ShaderElement& S);
134132
BOOL equal(ShaderElement* S);
135133
};
136-
typedef resptr_core<ShaderElement, resptr_base<ShaderElement>> ref_selement;
134+
using ref_selement = resptr_core<ShaderElement, resptr_base<ShaderElement>>;
137135

138136
//////////////////////////////////////////////////////////////////////////
139137
struct ECORE_API Shader : public xr_resource_flagged
140138
{
141-
public:
142139
ref_selement E[6]; // R1 - 0=norm_lod0(det), 1=norm_lod1(normal), 2=L_point, 3=L_spot, 4=L_for_models,
143140
// R2 - 0=deffer, 1=norm_lod1(normal), 2=psm, 3=ssm, 4=dsm
144141
~Shader();
145142
BOOL equal(Shader& S);
146143
BOOL equal(Shader* S);
147144
};
145+
148146
struct ECORE_API resptrcode_shader : public resptr_base<Shader>
149147
{
150148
void create(LPCSTR s_shader = nullptr, LPCSTR s_textures = nullptr, LPCSTR s_constants = nullptr, LPCSTR s_matrices = nullptr);
151149
void create(IBlender* B, LPCSTR s_shader = nullptr, LPCSTR s_textures = nullptr, LPCSTR s_constants = nullptr, LPCSTR s_matrices = nullptr);
152150
void destroy() { _set(nullptr); }
153151
};
154-
typedef resptr_core<Shader, resptrcode_shader> ref_shader;
152+
153+
using ref_shader = resptr_core<Shader, resptrcode_shader>;
155154

156155
enum SE_R1
157156
{

src/Layers/xrRender/r__dsgraph_types.h

Lines changed: 66 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,45 @@ template <class T>
77
class doug_lea_alloc
88
{
99
public:
10-
typedef size_t size_type;
11-
typedef ptrdiff_t difference_type;
12-
typedef T* pointer;
13-
typedef const T* const_pointer;
14-
typedef T& reference;
15-
typedef const T& const_reference;
16-
typedef T value_type;
10+
using size_type = size_t;
11+
using difference_type = ptrdiff_t;
12+
using pointer = T*;
13+
using const_pointer = const T*;
14+
using reference = T&;
15+
using const_reference = const T&;
16+
using value_type = T;
1717

18-
public:
1918
template <class _Other>
2019
struct rebind
2120
{
22-
typedef doug_lea_alloc<_Other> other;
21+
using other = doug_lea_alloc<_Other>;
2322
};
2423

25-
public:
2624
pointer address(reference _Val) const { return (&_Val); }
2725
const_pointer address(const_reference _Val) const { return (&_Val); }
2826
doug_lea_alloc() {}
2927
doug_lea_alloc(const doug_lea_alloc<T>&) {}
28+
3029
template <class _Other>
31-
doug_lea_alloc(const doug_lea_alloc<_Other>&)
32-
{
33-
}
30+
doug_lea_alloc(const doug_lea_alloc<_Other>&) {}
31+
3432
template <class _Other>
3533
doug_lea_alloc<T>& operator=(const doug_lea_alloc<_Other>&)
3634
{
3735
return (*this);
3836
}
37+
3938
pointer allocate(size_type n, const void* /*p*/ = nullptr) const
4039
{
4140
return (T*)g_render_allocator.malloc_impl(sizeof(T) * (u32)n);
4241
}
42+
4343
void deallocate(pointer p, size_type) const { g_render_allocator.free_impl((void*&)p); }
4444
void deallocate(void* p, size_type n) const { g_render_allocator.free_impl(p); }
4545
char* __charalloc(size_type n) { return (char*)allocate(n); }
4646
void construct(pointer p, const T& _Val) { new(p) T(_Val); }
4747
void destroy(pointer p) { p->~T(); }
48+
4849
size_type max_size() const
4950
{
5051
size_type _Count = (size_type)(-1) / sizeof(T);
@@ -57,6 +58,7 @@ bool operator==(const doug_lea_alloc<_Ty>&, const doug_lea_alloc<_Other>&)
5758
{
5859
return (true);
5960
}
61+
6062
template <class _Ty, class _Other>
6163
bool operator!=(const doug_lea_alloc<_Ty>&, const doug_lea_alloc<_Other>&)
6264
{
@@ -68,10 +70,11 @@ struct doug_lea_allocator_wrapper
6870
template <typename T>
6971
struct helper
7072
{
71-
typedef doug_lea_alloc<T> result;
73+
using result = doug_lea_alloc<T>;
7274
};
7375

7476
static void* alloc(const u32& n) { return g_render_allocator.malloc_impl((u32)n); }
77+
7578
template <typename T>
7679
static void dealloc(T*& p)
7780
{
@@ -80,7 +83,7 @@ struct doug_lea_allocator_wrapper
8083
};
8184

8285
#define render_alloc doug_lea_alloc
83-
typedef doug_lea_allocator_wrapper render_allocator;
86+
using render_allocator = doug_lea_allocator_wrapper;
8487

8588
class dxRender_Visual;
8689

@@ -115,54 +118,61 @@ struct _LodItem
115118
};
116119

117120
#ifdef USE_RESOURCE_DEBUGGER
118-
typedef ref_vs vs_type;
119-
typedef ref_ps ps_type;
121+
using vs_type = ref_vs;
122+
using ps_type = ref_ps;
120123
#if defined(USE_DX10) || defined(USE_DX11)
121-
typedef ref_gs gs_type;
124+
using gs_type = ref_gs;
122125
#ifdef USE_DX11
123-
typedef ref_hs hs_type;
124-
typedef ref_ds ds_type;
126+
using hs_type = ref_hs;
127+
using ds_type = ref_ds;
125128
#endif
126129
#endif // USE_DX10
127130
#else
128-
#if defined(USE_DX10) || defined(USE_DX11) // DX10 needs shader signature to propperly bind deometry to shader
129-
typedef SVS* vs_type;
130-
typedef ID3DGeometryShader* gs_type;
131+
132+
#if defined(USE_DX10) || defined(USE_DX11) // DX10 needs shader signature to properly bind geometry to shader
133+
using vs_type = SVS*;
134+
using gs_type = ID3DGeometryShader*;
131135
#ifdef USE_DX11
132-
typedef ID3D11HullShader* hs_type;
133-
typedef ID3D11DomainShader* ds_type;
136+
using hs_type = ID3D11HullShader*;
137+
using ds_type = ID3D11DomainShader*;
134138
#endif
135139
#else // USE_DX10
136-
typedef ID3DVertexShader* vs_type;
140+
using vs_type = ID3DVertexShader* ;
137141
#endif // USE_DX10
138-
typedef ID3DPixelShader* ps_type;
142+
using ps_type = ID3DPixelShader* ;
139143
#endif
140144

141145
// NORMAL
142-
typedef xr_vector<_NormalItem, render_allocator::helper<_NormalItem>::result> mapNormalDirect;
146+
using mapNormalDirect = xr_vector<_NormalItem, render_allocator::helper<_NormalItem>::result>;
147+
143148
struct mapNormalItems : public mapNormalDirect
144149
{
145150
float ssa;
146151
};
152+
147153
struct mapNormalTextures : public FixedMAP<STextureList*, mapNormalItems, render_allocator>
148154
{
149155
float ssa;
150156
};
157+
151158
struct mapNormalStates : public FixedMAP<ID3DState*, mapNormalTextures, render_allocator>
152159
{
153160
float ssa;
154161
};
162+
155163
struct mapNormalCS : public FixedMAP<R_constant_table*, mapNormalStates, render_allocator>
156164
{
157165
float ssa;
158166
};
167+
159168
#ifdef USE_DX11
160169
struct mapNormalAdvStages
161170
{
162171
hs_type hs;
163172
ds_type ds;
164173
mapNormalCS mapCS;
165174
};
175+
166176
struct mapNormalPS : public FixedMAP<ps_type, mapNormalAdvStages, render_allocator>
167177
{
168178
float ssa;
@@ -173,47 +183,52 @@ struct mapNormalPS : public FixedMAP<ps_type, mapNormalCS, render_allocator>
173183
float ssa;
174184
};
175185
#endif // USE_DX11
186+
176187
#if defined(USE_DX10) || defined(USE_DX11)
177188
struct mapNormalGS : public FixedMAP<gs_type, mapNormalPS, render_allocator>
178189
{
179190
float ssa;
180191
};
181-
struct mapNormalVS : public FixedMAP<vs_type, mapNormalGS, render_allocator>
182-
{
183-
};
192+
193+
struct mapNormalVS : public FixedMAP<vs_type, mapNormalGS, render_allocator> {};
184194
#else // USE_DX10
185-
struct mapNormalVS : public FixedMAP<vs_type, mapNormalPS, render_allocator>
186-
{
187-
};
195+
struct mapNormalVS : public FixedMAP<vs_type, mapNormalPS, render_allocator> {};
188196
#endif // USE_DX10
189-
typedef mapNormalVS mapNormal_T;
190-
typedef mapNormal_T mapNormalPasses_T[SHADER_PASSES_MAX];
197+
198+
using mapNormal_T = mapNormalVS;
199+
using mapNormalPasses_T = mapNormal_T[SHADER_PASSES_MAX];
191200

192201
// MATRIX
193-
typedef xr_vector<_MatrixItem, render_allocator::helper<_MatrixItem>::result> mapMatrixDirect;
202+
using mapMatrixDirect = xr_vector<_MatrixItem, render_allocator::helper<_MatrixItem>::result>;
203+
194204
struct mapMatrixItems : public mapMatrixDirect
195205
{
196206
float ssa;
197207
};
208+
198209
struct mapMatrixTextures : public FixedMAP<STextureList*, mapMatrixItems, render_allocator>
199210
{
200211
float ssa;
201212
};
213+
202214
struct mapMatrixStates : public FixedMAP<ID3DState*, mapMatrixTextures, render_allocator>
203215
{
204216
float ssa;
205217
};
218+
206219
struct mapMatrixCS : public FixedMAP<R_constant_table*, mapMatrixStates, render_allocator>
207220
{
208221
float ssa;
209222
};
223+
210224
#ifdef USE_DX11
211225
struct mapMatrixAdvStages
212226
{
213227
hs_type hs;
214228
ds_type ds;
215229
mapMatrixCS mapCS;
216230
};
231+
217232
struct mapMatrixPS : public FixedMAP<ps_type, mapMatrixAdvStages, render_allocator>
218233
{
219234
float ssa;
@@ -224,29 +239,28 @@ struct mapMatrixPS : public FixedMAP<ps_type, mapMatrixCS, render_allocator>
224239
float ssa;
225240
};
226241
#endif // USE_DX11
242+
227243
#if defined(USE_DX10) || defined(USE_DX11)
228244
struct mapMatrixGS : public FixedMAP<gs_type, mapMatrixPS, render_allocator>
229245
{
230246
float ssa;
231247
};
232-
struct mapMatrixVS : public FixedMAP<vs_type, mapMatrixGS, render_allocator>
233-
{
234-
};
248+
249+
struct mapMatrixVS : public FixedMAP<vs_type, mapMatrixGS, render_allocator> {};
235250
#else // USE_DX10
236-
struct mapMatrixVS : public FixedMAP<vs_type, mapMatrixPS, render_allocator>
237-
{
238-
};
251+
struct mapMatrixVS : public FixedMAP<vs_type, mapMatrixPS, render_allocator> {};
239252
#endif // USE_DX10
240-
typedef mapMatrixVS mapMatrix_T;
241-
typedef mapMatrix_T mapMatrixPasses_T[SHADER_PASSES_MAX];
253+
254+
using mapMatrix_T = mapMatrixVS;
255+
using mapMatrixPasses_T = mapMatrix_T[SHADER_PASSES_MAX];
242256

243257
// Top level
244-
typedef FixedMAP<float, _MatrixItemS, render_allocator> mapSorted_T;
245-
typedef mapSorted_T::TNode mapSorted_Node;
258+
using mapSorted_T = FixedMAP<float, _MatrixItemS, render_allocator>;
259+
using mapSorted_Node = mapSorted_T::TNode;
246260

247-
typedef FixedMAP<float, _MatrixItemS, render_allocator> mapHUD_T;
248-
typedef mapHUD_T::TNode mapHUD_Node;
261+
using mapHUD_T = FixedMAP<float, _MatrixItemS, render_allocator>;
262+
using mapHUD_Node = mapHUD_T::TNode;
249263

250-
typedef FixedMAP<float, _LodItem, render_allocator> mapLOD_T;
251-
typedef mapLOD_T::TNode mapLOD_Node;
252-
};
264+
using mapLOD_T = FixedMAP<float, _LodItem, render_allocator>;
265+
using mapLOD_Node = mapLOD_T::TNode;
266+
}

src/Layers/xrRender/xrD3DDefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
#pragma once
12
#ifndef xrD3DDefs_included
23
#define xrD3DDefs_included
3-
#pragma once
44

55
#if defined(USE_DX11) || defined(USE_DX10)
66
#include "Layers/xrRenderDX10/DXCommonTypes.h"

0 commit comments

Comments
 (0)