Nebula
Loading...
Searching...
No Matches
visibilitycontext.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
9//------------------------------------------------------------------------------
11#include "visibility.h"
12#include "jobs/jobs.h"
14#include "models/model.h"
16#include "materials/materialtemplates.h"
18#include "math/clipstatus.h"
19#include "coregraphics/mesh.h"
20
21namespace Models
22{
23 class ModelContext;
24}
25
26namespace Visibility
27{
28
29enum
30{
40};
41
42enum
43{
50};
51
52enum
53{
56};
57
59{
60 DependencyMode_Total, // if B depends on A, and A doesn't see B, B sees nothing either
61 DependencyMode_Masked // visibility of B is dependent on A for each result
62};
63
65{
67public:
68
70 static void Setup(const Graphics::GraphicsEntityId id, VisibilityEntityType entityType, bool isOrtho = false);
73
75 static void RunVisibilityTests(const Graphics::FrameContext& ctx);
77 static void GenerateDrawLists(const Graphics::FrameContext& ctx);
78
80 static void Create();
82 static void Discard();
83
94
96 static void WaitForVisibility(const Graphics::FrameContext& ctx);
97
98#ifndef PUBLIC_BUILD
100 static void OnRenderDebug(uint32_t flags);
101#endif
102
104
116
123
131
137
140
146
147private:
148
149 friend class ObservableContext;
152
153 typedef Ids::IdAllocator<
154 Math::mat4 // transform of observer camera
155 , bool // observer is an orthogonal camera
156 , Graphics::GraphicsEntityId // entity id
157 , VisibilityEntityType // type of object so we know how to get the transform
158 , VisibilityResultArray // visibility lookup table
159 , Graphics::GraphicsEntityId // dependency
160 , DependencyMode // dependency mode
161 , VisibilityDrawList // draw list
162 , Memory::ArenaAllocator<1024> // memory allocator for draw commands
165
169 static void Dealloc(Graphics::ContextEntityId id);
170
173};
174
176{
178public:
179
181 static void Setup(const Graphics::GraphicsEntityId id, VisibilityEntityType entityType);
182
184 static void Create();
185private:
186
187 friend class ObserverContext;
189
191 using AtomIsActive = bool;
192
193 // observable corresponds to a single entity
194 typedef Ids::IdAllocator<
195 Graphics::GraphicsEntityId, // The entity id that this component is bound to
196 uint32 // Node instance range
198
200
204 static void Dealloc(Graphics::ContextEntityId id);
205};
206
207} // namespace Visibility
Defines a group of primitives as a subset of a vertex buffer and index buffer plus the primitive topo...
Definition primitivegroup.h:20
Definition graphicscontext.h:165
An ID allocator associates an id with a slice in an N number of arrays.
Definition idallocator.h:39
Allocates memory in chunks.
Definition arenaallocator.h:36
Definition modelcontext.h:58
Nebula's dynamic array class.
Definition array.h:60
Organizes key/value pairs by a hash code.
Definition hashtable.h:42
Nebula's queue class (a FIFO container).
Definition queue.h:28
A StringAtom.
Definition stringatom.h:22
Definition visibilitycontext.h:176
Ids::IdAllocator< Graphics::GraphicsEntityId, uint32 > ObservableAllocator
Definition visibilitycontext.h:197
static Graphics::ContextEntityId Alloc()
allocate a new slice for this context
Definition visibilitycontext.cc:677
static ObservableAllocator observableAllocator
Definition visibilitycontext.h:199
static void Setup(const Graphics::GraphicsEntityId id, VisibilityEntityType entityType)
setup entity
Definition visibilitycontext.cc:634
bool AtomIsActive
Definition visibilitycontext.h:191
static void Dealloc(Graphics::ContextEntityId id)
deallocate a slice
Definition visibilitycontext.cc:688
static void Create()
create context
Definition visibilitycontext.cc:667
Definition visibilitycontext.h:65
static Util::Queue< Jobs::JobId > runningJobs
Definition visibilitycontext.h:145
Ids::Id32 ModelAllocId
Definition visibilitycontext.h:103
static Jobs::JobSyncId jobInternalSync3
Definition visibilitycontext.h:143
static VisibilitySystem * CreateBruteforceSystem(const BruteforceSystemLoadInfo &info)
create brute force system
Definition visibilitycontext.cc:477
static Jobs::JobSyncId jobHostSync
Definition visibilitycontext.h:144
static void WaitForVisibility(const Graphics::FrameContext &ctx)
wait for all visibility jobs
Definition visibilitycontext.cc:489
static Util::Array< VisibilitySystem * > systems
keep as ordinary array of pointers, no need to have them cache aligned
Definition visibilitycontext.h:172
static Graphics::ContextEntityId Alloc()
allocate a new slice for this context
Definition visibilitycontext.cc:611
Ids::IdAllocator< Math::mat4, bool, Graphics::GraphicsEntityId, VisibilityEntityType, VisibilityResultArray, Graphics::GraphicsEntityId, DependencyMode, VisibilityDrawList, Memory::ArenaAllocator< 1024 > > ObserverAllocator
Definition visibilitycontext.h:163
static VisibilitySystem * CreateBoxSystem(const BoxSystemLoadInfo &info)
create a box system
Definition visibilitycontext.cc:429
static const VisibilityDrawList * GetVisibilityDrawList(const Graphics::GraphicsEntityId id)
get visibility draw list
Definition visibilitycontext.cc:598
static Jobs::JobSyncId jobInternalSync2
Definition visibilitycontext.h:142
static void Discard()
discard context
Definition visibilitycontext.cc:414
static void GenerateDrawLists(const Graphics::FrameContext &ctx)
runs before frame is updated
Definition visibilitycontext.cc:390
static void Create()
create context
Definition visibilitycontext.cc:399
friend struct ObservableGlobalState
Definition visibilitycontext.h:150
static VisibilitySystem * CreateQuadtreeSystem(const QuadtreeSystemLoadInfo &info)
create quadtree system
Definition visibilitycontext.cc:465
static VisibilitySystem * CreatePortalSystem(const PortalSystemLoadInfo &info)
create a portal system
Definition visibilitycontext.cc:441
Util::Array< Math::ClipStatus::Type > VisibilityResultArray
Definition visibilitycontext.h:151
static VisibilitySystem * CreateOctreeSystem(const OctreeSystemLoadInfo &info)
create octree system
Definition visibilitycontext.cc:453
static void Dealloc(Graphics::ContextEntityId id)
deallocate a slice
Definition visibilitycontext.cc:620
static Jobs::JobSyncId jobInternalSync
Definition visibilitycontext.h:141
static void OnRenderDebug(uint32_t flags)
render debug
Definition visibilitycontext.cc:504
static void Setup(const Graphics::GraphicsEntityId id, VisibilityEntityType entityType, bool isOrtho=false)
setup entity
Definition visibilitycontext.cc:54
static void MakeDependency(const Graphics::GraphicsEntityId a, const Graphics::GraphicsEntityId b, const DependencyMode mode)
setup a dependency between observers
Definition visibilitycontext.cc:67
static ObserverAllocator observerAllocator
Definition visibilitycontext.h:164
static void RunVisibilityTests(const Graphics::FrameContext &ctx)
run visibility testing
Definition visibilitycontext.cc:78
Definition visibilitysystem.h:84
uint32_t Id32
Definition id.h:138
A model resource consists of nodes, each of which inhibit some information read from an ....
Definition model.cc:10
Implements a resource loader for models.
Definition modelcontext.h:35
@ Observer_DrawListAllocator
Definition visibilitycontext.h:39
@ Observer_IsOrtho
Definition visibilitycontext.h:32
@ Observer_DependencyMode
Definition visibilitycontext.h:37
@ Observer_DrawList
Definition visibilitycontext.h:38
@ Observer_EntityId
Definition visibilitycontext.h:33
@ Observer_ResultArray
Definition visibilitycontext.h:35
@ Observer_EntityType
Definition visibilitycontext.h:34
@ Observer_Dependency
Definition visibilitycontext.h:36
@ Observer_Matrix
Definition visibilitycontext.h:31
DependencyMode
Definition visibilitycontext.h:59
@ DependencyMode_Masked
Definition visibilitycontext.h:61
@ DependencyMode_Total
Definition visibilitycontext.h:60
@ Observable_NumNodes
Definition visibilitycontext.h:55
@ Observable_EntityId
Definition visibilitycontext.h:54
@ ObservableAtom_VisibilityEntityType
Definition visibilitycontext.h:48
@ ObservableAtom_NodeInstanceRange
Definition visibilitycontext.h:44
@ ObservableAtom_Instance
Definition visibilitycontext.h:47
@ ObservableAtom_GraphicsEntityId
Definition visibilitycontext.h:45
@ ObservableAtom_Active
Definition visibilitycontext.h:49
@ ObservableAtom_Transform
Definition visibilitycontext.h:46
VisibilityEntityType
Definition visibility.h:36
Definition mesh.h:29
Definition graphicscontext.h:133
Definition graphicsserver.h:31
The graphics entity is only an Id, to which we can attach GraphicsContexts.
Definition graphicsentity.h:16
Definition jobs.h:164
Definition material.h:30
A 4x4 single point precision float matrix.
Definition mat4.h:49
Definition visibilitysystem.h:53
Definition visibilitysystem.h:79
Definition visibilitycontext.h:125
Util::Array< VisibilityModelCommand, 256 > models
Definition visibilitycontext.h:128
uint32 packetOffset
Definition visibilitycontext.h:126
uint32 numDrawPackets
Definition visibilitycontext.h:127
Util::Array< VisibilityDrawCommand, 1024 > draws
Definition visibilitycontext.h:129
Definition visibilitycontext.h:118
uint32 offset
Definition visibilitycontext.h:119
uint32 baseInstance
Definition visibilitycontext.h:121
uint32 numInstances
Definition visibilitycontext.h:120
Definition visibilitycontext.h:133
Util::HashTable< const MaterialTemplates::Entry *, VisibilityBatchCommand > visibilityTable
Definition visibilitycontext.h:134
Util::Array< Models::ShaderStateNode::DrawPacket * > drawPackets
Definition visibilitycontext.h:135
Definition visibilitycontext.h:106
uint32 offset
Definition visibilitycontext.h:107
CoreGraphics::MeshId mesh
Definition visibilitycontext.h:108
Materials::MaterialId material
Definition visibilitycontext.h:110
CoreGraphics::PrimitiveGroup primitiveGroup
Definition visibilitycontext.h:109
Definition visibilitysystem.h:63
Definition visibilitysystem.h:58
Definition visibilitysystem.h:71
uint32_t uint32
Definition types.h:38