Cogs.Core
OctAtlas.h
1#pragma once
2#include "Rendering/ITextures.h"
3
4#include <vector>
5
6namespace Cogs
7{
8 namespace Core
9 {
10 struct CameraData;
11 struct DrawContext;
12
13 namespace Volumetric
14 {
15 struct OctComponent;
16 struct OctData;
17 struct Slot;
18
19 struct OctAtlas
20 {
21 struct Slot
22 {
23 enum Flags : uint16_t {
24 None = 0,
26 Invalid = 2,
27 NoData = 4
28 };
29
30 uint64_t tileKey;
31 uint64_t clientData;
32 uint32_t timestampNeeded;
33 uint32_t timestapUpdated;
34 Flags flags;
35 };
36
37 std::vector<Slot> slots;
38 std::list<uint32_t> slotsLRU;
39 std::unordered_map<TileKey, uint32_t> slotsLUT;
40
41 // Source=value, contains normal.xyz + value in w.
42 // Source=valueAlpha, contains normal.xyz + alpha in w
43 Cogs::TextureHandle textureAtlas0;
44
45 // Source=valueAlpha, contains value.
46 Cogs::TextureHandle textureAtlas1;
47
48 // Returns stale-ness of tile. Zero staleness implies no need for issue.
49 unsigned checkTile(const uint64_t tilekey, const uint32_t nodeTimestamp, const uint32_t currentTimestamp);
50
51 void enforceOrder(const uint32_t currentTimestamp);
52
53 glm::uvec4 slotPosition(const OctComponent& octComp, const uint64_t tileKey) const;
54
55 struct Item
56 {
57 Cogs::TextureHandle texture0;
58 Cogs::TextureHandle texture1;
59 uint32_t slot;
60 uint32_t delay;
61 };
62
63 std::vector<Item> toCopy;
64 std::vector<Item> stagingUnused;
65
66 void handleStaging(const DrawContext * renderingContext, OctComponent& octComp, OctData& octData, const uint32_t currentTimestamp, unsigned delay = 3);
67
68 void reset(const DrawContext * renderingContext, const OctData& octData, const uint32_t tileSize, const uint32_t gpuCacheSize, const uint32_t currentTimestamp);
69
70 };
71
72 }
73 }
74}
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
uint32_t timestampNeeded
Timestamp of last time this slot was needed (used for cache eviction).
Definition: OctAtlas.h:32
uint32_t timestapUpdated
Timestamp of most recent update (i.e. age of contents).
Definition: OctAtlas.h:33
@ Invalid
Set when the tile should be rebuilt.
Definition: OctAtlas.h:26
@ NoData
Set when data is for a fresh tile when we don't even have outdated data.
Definition: OctAtlas.h:27
@ InStaging
Set while the tile is in the staging queue. It has updated data, but it isn't available yet.
Definition: OctAtlas.h:25