OpenBarnyard
 
Loading...
Searching...
No Matches
TOrderTable.h
Go to the documentation of this file.
1#pragma once
2#include "TRenderPacket.h"
3#include "Toshi/TNodeList.h"
4
6
7class TOrderTable;
8
9//-----------------------------------------------------------------------------
10// Purpose: tracks all of the buffered render commands of specified TMaterial
11//-----------------------------------------------------------------------------
12class TRegMaterial : public TNodeList<TRegMaterial>::TNode
13{
14public:
15 typedef TUINT32 State;
17 {
20 };
21
22public:
24 {
25 m_State = 0;
26 m_pOrderTable = TNULL;
27 m_pMaterial = TNULL;
28 m_pLastRenderPacket = TNULL;
29 m_pNextRegMat = TNULL;
30 }
31
32 // Renders all of the render packets attached to this registered material
33 void Render();
34
35 // Allocates new render packet (command) for the specified mesh
37
38 State GetFlags() const { return m_State; }
39 void SetFlags( State a_eFlags ) { m_State = a_eFlags; }
40
41 TOrderTable* GetOrderTable() const { return m_pOrderTable; }
42 void SetOrderTable( TOrderTable* a_pOrderTable ) { m_pOrderTable = a_pOrderTable; }
43
44 TMaterial* GetMaterial() const { return m_pMaterial; }
45 void SetMaterial( TMaterial* a_pMaterial ) { m_pMaterial = a_pMaterial; }
46
47 TRegMaterial* GetNextRegMat() const { return m_pNextRegMat; }
48 void SetNextRegMat( TRegMaterial* a_pRegMat ) { m_pNextRegMat = a_pRegMat; }
49
50#ifndef TOSHI_SDK
51private:
52#endif
53 State m_State;
54 TOrderTable* m_pOrderTable;
55 TMaterial* m_pMaterial;
56 TRenderPacket* m_pLastRenderPacket;
57 TRegMaterial* m_pNextRegMat;
58};
59
60//-----------------------------------------------------------------------------
61// Purpose: helps to order rendering models of specified shader using priority.
62// Registers TMaterial instances to render all render packets attached to them.
63//-----------------------------------------------------------------------------
64class TOrderTable : public TPriList<TOrderTable>::TNode
65{
66public:
67 using t_PreFlushCallback = void ( * )( void* a_pCustomData );
68 using t_PostFlushCallback = void ( * )( void* a_pCustomData );
69
70public:
73
74 // Renders all render packets of registered materials
75 void Render();
76
77 // Flushes the shader before rendering
78 void Flush();
79
80 // Registers material and returns registered material which can be used to alloc render commands
82
83 static void DeregisterMaterial( TRegMaterial* a_pRegMat );
84 static void DeregisterAllMaterials();
85
86 // Marks the registered material as used and links it to this order table.
87 // Note: before registered material is used, it won't render
88 void UseMaterial( TRegMaterial* a_pRegMat );
89
90 // Registers this order table in the renderer and assigns priority to it
91 TBOOL Create( TShader* a_pShader, TINT a_iPriority );
92
93 // Allocate memory for storing render packets and registered materials
94 static void CreateStaticData( TUINT a_uiMaxMaterials, TUINT a_uiMaxRenderPackets );
95
96 // Deallocates memory used fror storing render packets and registered materials
97 static void DestroyStaticData();
98
99 // Allocates render packet from the memory allocated by CreateStaticData
101
102 // Returns bound shader
103 TShader* GetShader() const { return m_pShader; }
104
105public:
106 inline static TUINT s_uiMaxRenderPackets = 0;
107 inline static TUINT s_uiNumRenderPackets = 0;
111
112 inline static TUINT s_uiMaxMaterials = 0;
117
118#ifndef TOSHI_SDK
119private:
120#endif
121 TShader* m_pShader;
122 TRegMaterial* m_pLastRegMat;
123};
124
#define BITFLAG(x)
Definition Defines.h:10
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
unsigned int TUINT
Definition Typedefs.h:8
#define TNULL
Definition Typedefs.h:23
uint32_t TUINT32
Definition Typedefs.h:13
int TINT
Definition Typedefs.h:7
bool TBOOL
Definition Typedefs.h:6
Definition TMesh.h:9
State GetFlags() const
Definition TOrderTable.h:38
void SetMaterial(TMaterial *a_pMaterial)
Definition TOrderTable.h:45
TOrderTable * GetOrderTable() const
Definition TOrderTable.h:41
void SetFlags(State a_eFlags)
Definition TOrderTable.h:39
TRenderPacket * AddRenderPacket(TMesh *a_pMesh)
TUINT32 State
Definition TOrderTable.h:15
TRegMaterial * GetNextRegMat() const
Definition TOrderTable.h:47
void SetNextRegMat(TRegMaterial *a_pRegMat)
Definition TOrderTable.h:48
void SetOrderTable(TOrderTable *a_pOrderTable)
Definition TOrderTable.h:42
TMaterial * GetMaterial() const
Definition TOrderTable.h:44
TBOOL Create(TShader *a_pShader, TINT a_iPriority)
static TRenderPacket * s_pRenderPackets
static TUINT s_uiMaxMaterials
static TNodeList< TRegMaterial > s_llRegMatRegisteredList
static void CreateStaticData(TUINT a_uiMaxMaterials, TUINT a_uiMaxRenderPackets)
static void DeregisterMaterial(TRegMaterial *a_pRegMat)
void(*)(void *a_pCustomData) t_PreFlushCallback
Definition TOrderTable.h:67
static TUINT s_uiOrigMaxRenderPackets
static TUINT s_uiNumRenderPackets
static void DeregisterAllMaterials()
static void DestroyStaticData()
static TUINT s_uiMaxNumRenderPackets
TShader * GetShader() const
void UseMaterial(TRegMaterial *a_pRegMat)
static TUINT s_uiNumRegisteredMaterials
static TUINT s_uiMaxRenderPackets
static TNodeList< TRegMaterial > s_llRegMatFreeList
static TRegMaterial * s_pRegMaterials
void(*)(void *a_pCustomData) t_PostFlushCallback
Definition TOrderTable.h:68
static TRenderPacket * AllocRenderPacket()
TRegMaterial * RegisterMaterial(TMaterial *a_pMat)
constexpr TNode()
Definition TNodeList.h:15