Skip to content

Commit

Permalink
Renderers: type aliases instead of type defs
Browse files Browse the repository at this point in the history
#pragma once in correct place
  • Loading branch information
Xottab-DUTY committed Aug 8, 2017
1 parent f02b913 commit 9e0ca32
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 61 deletions.
2 changes: 1 addition & 1 deletion src/Include/xrRender/EnvironmentRender.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#ifndef EnvironmentRender_included
#define EnvironmentRender_included
#pragma once

namespace particles_systems
{
Expand Down
13 changes: 6 additions & 7 deletions src/Layers/xrRender/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "sh_constant.h"
#include "sh_rt.h"

typedef xr_vector<shared_str> sh_list;
using sh_list = xr_vector<shared_str>;
class CBlender_Compile;
class IBlender;
#define SHADER_PASSES_MAX 2
Expand All @@ -25,7 +25,7 @@ class IBlender;
//////////////////////////////////////////////////////////////////////////
struct ECORE_API STextureList : public xr_resource_flagged, public xr_vector<std::pair<u32, ref_texture>>
{
typedef xr_vector<std::pair<u32, ref_texture>> inherited_vec;
using inherited_vec = xr_vector<std::pair<u32, ref_texture>>;
~STextureList();

BOOL equal(const STextureList& base) const
Expand Down Expand Up @@ -114,7 +114,6 @@ typedef resptr_core<SPass, resptr_base<SPass>> ref_pass;
//////////////////////////////////////////////////////////////////////////
struct ECORE_API ShaderElement : public xr_resource_flagged
{
public:
struct Sflags
{
u32 iPriority : 2;
Expand All @@ -124,7 +123,6 @@ struct ECORE_API ShaderElement : public xr_resource_flagged
u32 bWmark : 1;
};

public:
Sflags flags;
svector<ref_pass, SHADER_PASSES_MAX> passes;

Expand All @@ -133,25 +131,26 @@ struct ECORE_API ShaderElement : public xr_resource_flagged
BOOL equal(ShaderElement& S);
BOOL equal(ShaderElement* S);
};
typedef resptr_core<ShaderElement, resptr_base<ShaderElement>> ref_selement;
using ref_selement = resptr_core<ShaderElement, resptr_base<ShaderElement>>;

//////////////////////////////////////////////////////////////////////////
struct ECORE_API Shader : public xr_resource_flagged
{
public:
ref_selement E[6]; // R1 - 0=norm_lod0(det), 1=norm_lod1(normal), 2=L_point, 3=L_spot, 4=L_for_models,
// R2 - 0=deffer, 1=norm_lod1(normal), 2=psm, 3=ssm, 4=dsm
~Shader();
BOOL equal(Shader& S);
BOOL equal(Shader* S);
};

struct ECORE_API resptrcode_shader : public resptr_base<Shader>
{
void create(LPCSTR s_shader = nullptr, LPCSTR s_textures = nullptr, LPCSTR s_constants = nullptr, LPCSTR s_matrices = nullptr);
void create(IBlender* B, LPCSTR s_shader = nullptr, LPCSTR s_textures = nullptr, LPCSTR s_constants = nullptr, LPCSTR s_matrices = nullptr);
void destroy() { _set(nullptr); }
};
typedef resptr_core<Shader, resptrcode_shader> ref_shader;

using ref_shader = resptr_core<Shader, resptrcode_shader>;

enum SE_R1
{
Expand Down
118 changes: 66 additions & 52 deletions src/Layers/xrRender/r__dsgraph_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,45 @@ template <class T>
class doug_lea_alloc
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T value_type;
using size_type = size_t;
using difference_type = ptrdiff_t;
using pointer = T*;
using const_pointer = const T*;
using reference = T&;
using const_reference = const T&;
using value_type = T;

public:
template <class _Other>
struct rebind
{
typedef doug_lea_alloc<_Other> other;
using other = doug_lea_alloc<_Other>;
};

public:
pointer address(reference _Val) const { return (&_Val); }
const_pointer address(const_reference _Val) const { return (&_Val); }
doug_lea_alloc() {}
doug_lea_alloc(const doug_lea_alloc<T>&) {}

template <class _Other>
doug_lea_alloc(const doug_lea_alloc<_Other>&)
{
}
doug_lea_alloc(const doug_lea_alloc<_Other>&) {}

template <class _Other>
doug_lea_alloc<T>& operator=(const doug_lea_alloc<_Other>&)
{
return (*this);
}

pointer allocate(size_type n, const void* /*p*/ = nullptr) const
{
return (T*)g_render_allocator.malloc_impl(sizeof(T) * (u32)n);
}

void deallocate(pointer p, size_type) const { g_render_allocator.free_impl((void*&)p); }
void deallocate(void* p, size_type n) const { g_render_allocator.free_impl(p); }
char* __charalloc(size_type n) { return (char*)allocate(n); }
void construct(pointer p, const T& _Val) { new(p) T(_Val); }
void destroy(pointer p) { p->~T(); }

size_type max_size() const
{
size_type _Count = (size_type)(-1) / sizeof(T);
Expand All @@ -57,6 +58,7 @@ bool operator==(const doug_lea_alloc<_Ty>&, const doug_lea_alloc<_Other>&)
{
return (true);
}

template <class _Ty, class _Other>
bool operator!=(const doug_lea_alloc<_Ty>&, const doug_lea_alloc<_Other>&)
{
Expand All @@ -68,10 +70,11 @@ struct doug_lea_allocator_wrapper
template <typename T>
struct helper
{
typedef doug_lea_alloc<T> result;
using result = doug_lea_alloc<T>;
};

static void* alloc(const u32& n) { return g_render_allocator.malloc_impl((u32)n); }

template <typename T>
static void dealloc(T*& p)
{
Expand All @@ -80,7 +83,7 @@ struct doug_lea_allocator_wrapper
};

#define render_alloc doug_lea_alloc
typedef doug_lea_allocator_wrapper render_allocator;
using render_allocator = doug_lea_allocator_wrapper;

class dxRender_Visual;

Expand Down Expand Up @@ -115,54 +118,61 @@ struct _LodItem
};

#ifdef USE_RESOURCE_DEBUGGER
typedef ref_vs vs_type;
typedef ref_ps ps_type;
using vs_type = ref_vs;
using ps_type = ref_ps;
#if defined(USE_DX10) || defined(USE_DX11)
typedef ref_gs gs_type;
using gs_type = ref_gs;
#ifdef USE_DX11
typedef ref_hs hs_type;
typedef ref_ds ds_type;
using hs_type = ref_hs;
using ds_type = ref_ds;
#endif
#endif // USE_DX10
#else
#if defined(USE_DX10) || defined(USE_DX11) // DX10 needs shader signature to propperly bind deometry to shader
typedef SVS* vs_type;
typedef ID3DGeometryShader* gs_type;

#if defined(USE_DX10) || defined(USE_DX11) // DX10 needs shader signature to properly bind geometry to shader
using vs_type = SVS*;
using gs_type = ID3DGeometryShader*;
#ifdef USE_DX11
typedef ID3D11HullShader* hs_type;
typedef ID3D11DomainShader* ds_type;
using hs_type = ID3D11HullShader*;
using ds_type = ID3D11DomainShader*;
#endif
#else // USE_DX10
typedef ID3DVertexShader* vs_type;
using vs_type = ID3DVertexShader* ;
#endif // USE_DX10
typedef ID3DPixelShader* ps_type;
using ps_type = ID3DPixelShader* ;
#endif

// NORMAL
typedef xr_vector<_NormalItem, render_allocator::helper<_NormalItem>::result> mapNormalDirect;
using mapNormalDirect = xr_vector<_NormalItem, render_allocator::helper<_NormalItem>::result>;

struct mapNormalItems : public mapNormalDirect
{
float ssa;
};

struct mapNormalTextures : public FixedMAP<STextureList*, mapNormalItems, render_allocator>
{
float ssa;
};

struct mapNormalStates : public FixedMAP<ID3DState*, mapNormalTextures, render_allocator>
{
float ssa;
};

struct mapNormalCS : public FixedMAP<R_constant_table*, mapNormalStates, render_allocator>
{
float ssa;
};

#ifdef USE_DX11
struct mapNormalAdvStages
{
hs_type hs;
ds_type ds;
mapNormalCS mapCS;
};

struct mapNormalPS : public FixedMAP<ps_type, mapNormalAdvStages, render_allocator>
{
float ssa;
Expand All @@ -173,47 +183,52 @@ struct mapNormalPS : public FixedMAP<ps_type, mapNormalCS, render_allocator>
float ssa;
};
#endif // USE_DX11

#if defined(USE_DX10) || defined(USE_DX11)
struct mapNormalGS : public FixedMAP<gs_type, mapNormalPS, render_allocator>
{
float ssa;
};
struct mapNormalVS : public FixedMAP<vs_type, mapNormalGS, render_allocator>
{
};

struct mapNormalVS : public FixedMAP<vs_type, mapNormalGS, render_allocator> {};
#else // USE_DX10
struct mapNormalVS : public FixedMAP<vs_type, mapNormalPS, render_allocator>
{
};
struct mapNormalVS : public FixedMAP<vs_type, mapNormalPS, render_allocator> {};
#endif // USE_DX10
typedef mapNormalVS mapNormal_T;
typedef mapNormal_T mapNormalPasses_T[SHADER_PASSES_MAX];

using mapNormal_T = mapNormalVS;
using mapNormalPasses_T = mapNormal_T[SHADER_PASSES_MAX];

// MATRIX
typedef xr_vector<_MatrixItem, render_allocator::helper<_MatrixItem>::result> mapMatrixDirect;
using mapMatrixDirect = xr_vector<_MatrixItem, render_allocator::helper<_MatrixItem>::result>;

struct mapMatrixItems : public mapMatrixDirect
{
float ssa;
};

struct mapMatrixTextures : public FixedMAP<STextureList*, mapMatrixItems, render_allocator>
{
float ssa;
};

struct mapMatrixStates : public FixedMAP<ID3DState*, mapMatrixTextures, render_allocator>
{
float ssa;
};

struct mapMatrixCS : public FixedMAP<R_constant_table*, mapMatrixStates, render_allocator>
{
float ssa;
};

#ifdef USE_DX11
struct mapMatrixAdvStages
{
hs_type hs;
ds_type ds;
mapMatrixCS mapCS;
};

struct mapMatrixPS : public FixedMAP<ps_type, mapMatrixAdvStages, render_allocator>
{
float ssa;
Expand All @@ -224,29 +239,28 @@ struct mapMatrixPS : public FixedMAP<ps_type, mapMatrixCS, render_allocator>
float ssa;
};
#endif // USE_DX11

#if defined(USE_DX10) || defined(USE_DX11)
struct mapMatrixGS : public FixedMAP<gs_type, mapMatrixPS, render_allocator>
{
float ssa;
};
struct mapMatrixVS : public FixedMAP<vs_type, mapMatrixGS, render_allocator>
{
};

struct mapMatrixVS : public FixedMAP<vs_type, mapMatrixGS, render_allocator> {};
#else // USE_DX10
struct mapMatrixVS : public FixedMAP<vs_type, mapMatrixPS, render_allocator>
{
};
struct mapMatrixVS : public FixedMAP<vs_type, mapMatrixPS, render_allocator> {};
#endif // USE_DX10
typedef mapMatrixVS mapMatrix_T;
typedef mapMatrix_T mapMatrixPasses_T[SHADER_PASSES_MAX];

using mapMatrix_T = mapMatrixVS;
using mapMatrixPasses_T = mapMatrix_T[SHADER_PASSES_MAX];

// Top level
typedef FixedMAP<float, _MatrixItemS, render_allocator> mapSorted_T;
typedef mapSorted_T::TNode mapSorted_Node;
using mapSorted_T = FixedMAP<float, _MatrixItemS, render_allocator>;
using mapSorted_Node = mapSorted_T::TNode;

typedef FixedMAP<float, _MatrixItemS, render_allocator> mapHUD_T;
typedef mapHUD_T::TNode mapHUD_Node;
using mapHUD_T = FixedMAP<float, _MatrixItemS, render_allocator>;
using mapHUD_Node = mapHUD_T::TNode;

typedef FixedMAP<float, _LodItem, render_allocator> mapLOD_T;
typedef mapLOD_T::TNode mapLOD_Node;
};
using mapLOD_T = FixedMAP<float, _LodItem, render_allocator>;
using mapLOD_Node = mapLOD_T::TNode;
}
2 changes: 1 addition & 1 deletion src/Layers/xrRender/xrD3DDefs.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#ifndef xrD3DDefs_included
#define xrD3DDefs_included
#pragma once

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

0 comments on commit 9e0ca32

Please sign in to comment.