OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
drawcommands.h
Go to the documentation of this file.
1#pragma once
2
3#include <Tempest/RenderPipeline>
4#include <Tempest/StorageBuffer>
5#include <vector>
6
7#include "sceneglobals.h"
8
9class VisualObjects;
10class DrawBuckets;
11class DrawClusters;
12
14 public:
23
24 struct DrawCmd {
25 const Tempest::RenderPipeline* pMain = nullptr;
26 const Tempest::RenderPipeline* pShadow = nullptr;
27 const Tempest::RenderPipeline* pVsm = nullptr;
28 const Tempest::RenderPipeline* pHiZ = nullptr;
30
32 uint32_t firstPayload = 0;
33 uint32_t maxPayload = 0;
34
35 // bindfull only
36 uint32_t bucketId = 0;
37
38 bool isForwardShading() const;
39 bool isShadowmapRequired() const;
40 bool isSceneInfoRequired() const;
41 bool isTextureInShadowPass() const;
42 bool isBindless() const;
43 bool isMeshShader() const;
44 };
45
46 DrawCommands(VisualObjects& owner, DrawBuckets& buckets, DrawClusters& clusters, const SceneGlobals& scene);
48
49 const DrawCmd& operator[](size_t i) const { return cmd[i]; }
50 size_t maxMeshlets() const { return maxPayload; }
51
52 void commit(Tempest::Encoder<Tempest::CommandBuffer>& cmd);
53 uint16_t commandId(const Material& m, Type type, uint32_t bucketId);
54 void addClusters(uint16_t cmdId, uint32_t meshletCount);
55
56 void resetRendering();
57
58 void visibilityPass(Tempest::Encoder<Tempest::CommandBuffer>& cmd, int pass);
59 void visibilityVsm(Tempest::Encoder<Tempest::CommandBuffer>& cmd);
60
61 void drawHiZ(Tempest::Encoder<Tempest::CommandBuffer>& cmd);
62 void drawCommon(Tempest::Encoder<Tempest::CommandBuffer>& cmd, SceneGlobals::VisCamera viewId, Material::AlphaFunc func);
63
64 void drawVsm(Tempest::Encoder<Tempest::CommandBuffer>& cmd);
65
66 private:
67 enum TaskLinkpackage : uint8_t {
68 T_Scene = 0,
69 T_Payload = 1,
70 T_Instance = 2,
71 T_Bucket = 3,
72 T_Indirect = 4,
73 T_Clusters = 5,
74 T_Lights = 6,
75 T_HiZ = 7,
76 T_VsmPages = 8,
77 T_CmdOffsets = 9,
78 };
79
80 enum UboLinkpackage : uint8_t {
81 L_Scene = 0,
82 L_Payload = 1,
83 L_Instance = 2,
84 L_Pfx = L_Instance,
85 L_Bucket = 3,
86 L_Ibo = 4,
87 L_Vbo = 5,
88 L_Diffuse = 6,
89 L_Sampler = 7,
90 L_Shadow0 = 8,
91 L_Shadow1 = 9,
92 L_MorphId = 10,
93 L_Morph = 11,
94 L_SceneClr = 12,
95 L_GDepth = 13,
96 L_CmdOffsets = 14,
97 L_VsmPages = L_Shadow0,
98 L_Lights = L_Shadow1,
99 };
100
101 struct IndirectCmd {
102 uint32_t vertexCount = 0;
103 uint32_t instanceCount = 0;
104 uint32_t firstVertex = 0;
105 uint32_t firstInstance = 0;
106 uint32_t writeOffset = 0;
107 };
108
109 struct View {
111 Tempest::StorageBuffer visClusters, indirectCmd;
112 Tempest::StorageBuffer vsmClusters;
113 };
114
115 bool isViewEnabled(SceneGlobals::VisCamera v) const;
116
117 void setBindings(Tempest::Encoder<Tempest::CommandBuffer>& cmd, const DrawCmd& cx, SceneGlobals::VisCamera viewId);
118
119 VisualObjects& owner;
120 DrawBuckets& buckets;
121 DrawClusters& clusters;
122 const SceneGlobals& scene;
123 size_t maxPayload = 0;
124
125 std::vector<DrawCmd> cmd;
126 std::vector<DrawCmd*> ord;
127 bool cmdDurtyBit = false;
128 View views[SceneGlobals::V_Count];
129
130 const bool vsmSupported;
131 Tempest::StorageBuffer vsmIndirectCmd;
132 };
void addClusters(uint16_t cmdId, uint32_t meshletCount)
void visibilityVsm(Tempest::Encoder< Tempest::CommandBuffer > &cmd)
uint16_t commandId(const Material &m, Type type, uint32_t bucketId)
void drawVsm(Tempest::Encoder< Tempest::CommandBuffer > &cmd)
const DrawCmd & operator[](size_t i) const
void drawHiZ(Tempest::Encoder< Tempest::CommandBuffer > &cmd)
void commit(Tempest::Encoder< Tempest::CommandBuffer > &cmd)
void drawCommon(Tempest::Encoder< Tempest::CommandBuffer > &cmd, SceneGlobals::VisCamera viewId, Material::AlphaFunc func)
size_t maxMeshlets() const
void resetRendering()
void visibilityPass(Tempest::Encoder< Tempest::CommandBuffer > &cmd, int pass)
bool isSceneInfoRequired() const
const Tempest::RenderPipeline * pShadow
bool isTextureInShadowPass() const
const Tempest::RenderPipeline * pMain
const Tempest::RenderPipeline * pHiZ
bool isMeshShader() const
bool isShadowmapRequired() const
const Tempest::RenderPipeline * pVsm
Material::AlphaFunc alpha
bool isForwardShading() const