Skip to content

Commit

Permalink
remove blahs
Browse files Browse the repository at this point in the history
  • Loading branch information
sinomsinom committed Sep 2, 2023
1 parent 52488cd commit 0f20997
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 54 deletions.
1 change: 0 additions & 1 deletion src/ConstantHandlerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ bool ConstantHandlerBase::UpdateConstantEntries(command_list* cmd_list, CommandL
if (slot_size == 0)
return false;

const auto& blah = cmdData.stateTracker.GetPushConstantsState()->current_constants[index];
size_t const_buffer_size = static_cast<uint32_t>(cmdData.stateTracker.GetPushConstantsState()->current_constants[index].at(slot).size());

if (const_buffer_size == 0)
Expand Down
110 changes: 57 additions & 53 deletions src/PipelineStateTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void PipelineStateTracker::ApplyBoundDescriptorSets(command_list* cmd_list, shad

void PipelineStateTracker::ReApplyState(command_list* cmd_list, const unordered_map<uint64_t, vector<bool>>& transient_mask)
{
vector<PipelineBindingBase*> blah = {
vector<PipelineBindingBase*> states = {
&_descriptorSetsState,
&_renderTargetState,
&_scissorRectsState,
Expand All @@ -47,70 +47,74 @@ void PipelineStateTracker::ReApplyState(command_list* cmd_list, const unordered_
&_pipelineState
};

if (blah.size() > 1)
if (states.size() > 1)
{
std::sort(blah.begin(), blah.end(), [](const auto& lhs, const auto& rhs)
std::sort(states.begin(), states.end(), [](const auto& lhs, const auto& rhs)
{
return lhs->callIndex < rhs->callIndex;
});
}

for (auto b : blah)
for (auto state : states)
{
if (b->GetType() == PipelineBindingTypes::bind_descriptor_sets)
switch (state->GetType())
{
if (_descriptorSetsState.cmd_list != nullptr)
case PipelineBindingTypes::bind_descriptor_sets:
{
vector<bool> emptyMask;
const vector<bool>* mask_graphics = &emptyMask;
const vector<bool>* mask_compute = &emptyMask;

if (transient_mask.contains(_descriptorSetsState.current_layout[0].handle))
if (_descriptorSetsState.cmd_list != nullptr)
{
mask_graphics = &transient_mask.at(_descriptorSetsState.current_layout[0].handle);
vector<bool> emptyMask;
const vector<bool>* mask_graphics = &emptyMask;
const vector<bool>* mask_compute = &emptyMask;

if (transient_mask.contains(_descriptorSetsState.current_layout[0].handle))
{
mask_graphics = &transient_mask.at(_descriptorSetsState.current_layout[0].handle);
}

if (transient_mask.contains(_descriptorSetsState.current_layout[1].handle))
{
mask_compute = &transient_mask.at(_descriptorSetsState.current_layout[1].handle);
}

ApplyBoundDescriptorSets(cmd_list, shader_stage::all_graphics, _descriptorSetsState.current_layout[0],
_descriptorSetsState.current_sets[0], *mask_graphics);
ApplyBoundDescriptorSets(cmd_list, shader_stage::all_compute, _descriptorSetsState.current_layout[1],
_descriptorSetsState.current_sets[1], *mask_compute);
}

if (transient_mask.contains(_descriptorSetsState.current_layout[1].handle))
{
mask_compute = &transient_mask.at(_descriptorSetsState.current_layout[1].handle);
}

ApplyBoundDescriptorSets(cmd_list, shader_stage::all_graphics, _descriptorSetsState.current_layout[0],
_descriptorSetsState.current_sets[0], *mask_graphics);
ApplyBoundDescriptorSets(cmd_list, shader_stage::all_compute, _descriptorSetsState.current_layout[1],
_descriptorSetsState.current_sets[1], *mask_compute);
break;
}
case PipelineBindingTypes::bind_render_target:
{
if (_renderTargetState.cmd_list != nullptr)
cmd_list->bind_render_targets_and_depth_stencil(_renderTargetState.count, _renderTargetState.rtvs.data(), _renderTargetState.dsv);
break;
}
case PipelineBindingTypes::bind_scissor_rect:
{
if (_scissorRectsState.cmd_list != nullptr)
cmd_list->bind_scissor_rects(_scissorRectsState.first, _scissorRectsState.count, _scissorRectsState.rects.data());
break;
}
case PipelineBindingTypes::bind_viewport:
{
if (_viewportsState.cmd_list != nullptr)
cmd_list->bind_viewports(_viewportsState.first, _viewportsState.count, _viewportsState.viewports.data());
break;
}
case PipelineBindingTypes::bind_pipeline_states:
{
BindPipelineStatesState* ss = static_cast<BindPipelineStatesState*>(state);
if (ss->cmd_list != nullptr)
cmd_list->bind_pipeline_states(1, &ss->state, &ss->value);
break;
}
case PipelineBindingTypes::bind_pipeline:
{
if (_pipelineState.cmd_list != nullptr)
cmd_list->bind_pipeline(_pipelineState.stages, _pipelineState.pipeline);
break;
}
}

if (b->GetType() == PipelineBindingTypes::bind_render_target)
{
if (_renderTargetState.cmd_list != nullptr)
cmd_list->bind_render_targets_and_depth_stencil(_renderTargetState.count, _renderTargetState.rtvs.data(), _renderTargetState.dsv);
}

if (b->GetType() == PipelineBindingTypes::bind_scissor_rect)
{
if (_scissorRectsState.cmd_list != nullptr)
cmd_list->bind_scissor_rects(_scissorRectsState.first, _scissorRectsState.count, _scissorRectsState.rects.data());
}

if (b->GetType() == PipelineBindingTypes::bind_viewport)
{
if (_viewportsState.cmd_list != nullptr)
cmd_list->bind_viewports(_viewportsState.first, _viewportsState.count, _viewportsState.viewports.data());
}

if (b->GetType() == PipelineBindingTypes::bind_pipeline_states)
{
BindPipelineStatesState* ss = static_cast<BindPipelineStatesState*>(b);
if (ss->cmd_list != nullptr)
cmd_list->bind_pipeline_states(1, &ss->state, &ss->value);
}

if (b->GetType() == PipelineBindingTypes::bind_pipeline)
{
if (_pipelineState.cmd_list != nullptr)
cmd_list->bind_pipeline(_pipelineState.stages, _pipelineState.pipeline);
}
}
}
Expand Down

0 comments on commit 0f20997

Please sign in to comment.