Skip to content

Commit d86f256

Browse files
committed
Added dedicated maxStateSlot and maxViewSlot numbers to enable individual sizing of the State::stateStacks and viewStateStacks.
1 parent bac0ae0 commit d86f256

19 files changed

Lines changed: 76 additions & 53 deletions

include/vsg/app/CommandGraph.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ namespace vsg
3939

4040
int queueFamily = -1;
4141
int presentFamily = -1;
42-
uint32_t maxSlot = 2;
42+
uint32_t maxStateSlot = 0;
43+
uint32_t maxViewSlot = 0;
4344
int submitOrder = 0;
4445

4546
ref_ptr<RecordTraversal> getOrCreateRecordTraversal();

include/vsg/app/CompileManager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ namespace vsg
2727
{
2828
int result = VK_INCOMPLETE;
2929
std::string message;
30-
uint32_t maxSlot = 0;
30+
uint32_t maxStateSlot = 0;
31+
uint32_t maxViewSlot = 0;
3132
bool containsPagedLOD = false;
3233
ResourceRequirements::Views views;
3334
ResourceRequirements::DynamicData dynamicData;

include/vsg/app/RecordTraversal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace vsg
6969
class VSG_DECLSPEC RecordTraversal : public Object
7070
{
7171
public:
72-
explicit RecordTraversal(uint32_t in_maxSlot = 2, const std::set<Bin*>& in_bins = {});
72+
explicit RecordTraversal(uint32_t in_maxStateSlot = 2, uint32_t in_maxViewSlot = 8, const std::set<Bin*>& in_bins = {}); // TODO
7373

7474
RecordTraversal(const RecordTraversal&) = delete;
7575
RecordTraversal& operator=(const RecordTraversal& rhs) = delete;

include/vsg/state/ResourceHints.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ namespace vsg
3030
public:
3131
ResourceHints();
3232

33-
bool empty() const noexcept { return maxSlot == 0 && numDescriptorSets == 0 && descriptorPoolSizes.empty(); }
33+
bool empty() const noexcept { return maxStateSlot == 0 && maxViewSlot == 0 && numDescriptorSets == 0 && descriptorPoolSizes.empty(); }
3434

35-
uint32_t maxSlot = 0;
35+
uint32_t maxStateSlot = 0;
36+
uint32_t maxViewSlot = 0;
3637
uint32_t numDescriptorSets = 0;
3738
DescriptorPoolSizes descriptorPoolSizes;
3839

include/vsg/vk/ResourceRequirements.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ namespace vsg
8888
Views views;
8989
ViewDetailStack viewDetailsStack;
9090

91-
uint32_t maxSlot = 0;
91+
uint32_t maxStateSlot = 0;
92+
uint32_t maxViewSlot = 0;
9293
uint32_t externalNumDescriptorSets = 0;
9394
bool containsPagedLOD = false;
9495

include/vsg/vk/State.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ namespace vsg
228228
class State : public Inherit<Object, State>
229229
{
230230
public:
231-
explicit State(uint32_t maxSlot);
231+
explicit State(uint32_t maxStateSlot, uint32_t maxViewSlot);
232232

233233
using StateCommandStack = StateStack<StateCommand>;
234234
using StateStacks = std::vector<StateCommandStack>;
@@ -254,7 +254,7 @@ namespace vsg
254254
MatrixStack projectionMatrixStack{0};
255255
MatrixStack modelviewMatrixStack{64};
256256

257-
void reserve(uint32_t maxSlot);
257+
void reserve(uint32_t maxStateSlot, uint32_t maxViewSlot);
258258

259259
void setInhertiedViewProjectionAndViewMatrix(const dmat4& projMatrix, const dmat4& viewMatrix)
260260
{

src/vsg/app/CommandGraph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ ref_ptr<RecordTraversal> CommandGraph::getOrCreateRecordTraversal()
6666
{
6767
//CPU_INSTRUMENTATION_L1(instrumentation);
6868
if (!recordTraversal)
69-
recordTraversal = RecordTraversal::create(maxSlot);
69+
recordTraversal = RecordTraversal::create(maxStateSlot, maxViewSlot);
7070
else
71-
recordTraversal->getState()->reserve(maxSlot);
71+
recordTraversal->getState()->reserve(maxStateSlot, maxViewSlot);
7272

7373
return recordTraversal;
7474
}

src/vsg/app/CompileManager.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ using namespace vsg;
2424
void CompileResult::reset()
2525
{
2626
result = VK_INCOMPLETE;
27-
maxSlot = 0;
27+
maxStateSlot = 0;
28+
maxViewSlot = 0;
2829
containsPagedLOD = false;
2930
views.clear();
3031
dynamicData.clear();
@@ -37,7 +38,8 @@ void CompileResult::add(const CompileResult& cr)
3738
result = cr.result;
3839
}
3940

40-
if (cr.maxSlot > maxSlot) maxSlot = cr.maxSlot;
41+
if (cr.maxStateSlot > maxStateSlot) maxStateSlot = cr.maxStateSlot;
42+
if (cr.maxViewSlot > maxViewSlot) maxViewSlot = cr.maxViewSlot;
4143
if (!containsPagedLOD) containsPagedLOD = cr.containsPagedLOD;
4244

4345
for (auto& [src_view, src_binDetails] : cr.views)
@@ -175,7 +177,8 @@ CompileResult CompileManager::compile(ref_ptr<Object> object, ContextSelectionFu
175177
auto& viewDetailsStack = requirements.viewDetailsStack;
176178

177179
CompileResult result;
178-
result.maxSlot = requirements.maxSlot;
180+
result.maxStateSlot = requirements.maxStateSlot;
181+
result.maxViewSlot = requirements.maxViewSlot;
179182
result.containsPagedLOD = requirements.containsPagedLOD;
180183
result.views = requirements.views;
181184
result.dynamicData = requirements.dynamicData;

src/vsg/app/CompileTraversal.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,8 @@ void CompileTraversal::apply(CommandGraph& commandGraph)
323323

324324
for (const auto& context : contexts)
325325
{
326-
if (context->resourceRequirements.maxSlot > commandGraph.maxSlot)
327-
{
328-
commandGraph.maxSlot = context->resourceRequirements.maxSlot;
329-
}
326+
if (context->resourceRequirements.maxStateSlot > commandGraph.maxStateSlot) commandGraph.maxStateSlot = context->resourceRequirements.maxStateSlot;
327+
if (context->resourceRequirements.maxViewSlot > commandGraph.maxViewSlot) commandGraph.maxViewSlot = context->resourceRequirements.maxViewSlot;
330328
}
331329

332330
commandGraph.traverse(*this);
@@ -340,10 +338,8 @@ void CompileTraversal::apply(SecondaryCommandGraph& secondaryCommandGraph)
340338

341339
for (auto& context : contexts)
342340
{
343-
if (context->resourceRequirements.maxSlot > secondaryCommandGraph.maxSlot)
344-
{
345-
secondaryCommandGraph.maxSlot = context->resourceRequirements.maxSlot;
346-
}
341+
if (context->resourceRequirements.maxStateSlot > secondaryCommandGraph.maxStateSlot) secondaryCommandGraph.maxStateSlot = context->resourceRequirements.maxStateSlot;
342+
if (context->resourceRequirements.maxViewSlot > secondaryCommandGraph.maxViewSlot) secondaryCommandGraph.maxViewSlot = context->resourceRequirements.maxViewSlot;
347343

348344
// save previous states to be restored after traversal
349345
auto previousRenderPass = context->renderPass;

src/vsg/app/RecordAndSubmitTask.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,8 @@ void vsg::updateTasks(RecordAndSubmitTasks& tasks, ref_ptr<CompileManager> compi
298298
{
299299
for (const auto& commandGraph : task->commandGraphs)
300300
{
301-
if (compileResult.maxSlot > commandGraph->maxSlot)
302-
{
303-
commandGraph->maxSlot = compileResult.maxSlot;
304-
}
301+
if (compileResult.maxStateSlot > commandGraph->maxStateSlot) commandGraph->maxStateSlot = compileResult.maxStateSlot;
302+
if (compileResult.maxViewSlot > commandGraph->maxViewSlot) commandGraph->maxViewSlot = compileResult.maxViewSlot;
305303
}
306304
}
307305

0 commit comments

Comments
 (0)