Skip to content

Commit 70f6033

Browse files
ziga-lunargspencer-lunarg
authored andcommitted
layers: Fix invalidating descriptor mode
1 parent efdf2e4 commit 70f6033

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

layers/state_tracker/cmd_buffer_state.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,19 @@ void CommandBuffer::SetDescriptorMode(vvl::DescriptorMode new_mode, vvl::Func fu
276276
}
277277
}
278278

279+
// Some functions like vkCmdPushConstant are valid in Classic/Buffer, but invalid in Heap
280+
// So calling it doesn't "set" a mode, but instead only "invalidates"
281+
void CommandBuffer::InvalidateDescriptorMode(vvl::DescriptorMode invalidate_mode, vvl::DescriptorMode new_mode,
282+
vvl::Func function) {
283+
for (uint32_t i = 0; i < vvl::BindPointCount; i++) {
284+
const vvl::DescriptorMode current_mode = lastBound[i].GetDescriptorMode();
285+
if (current_mode == invalidate_mode) {
286+
SetDescriptorMode(new_mode, function);
287+
break;
288+
}
289+
}
290+
}
291+
279292
// Reset the command buffer state
280293
// Maintain the createInfo and set state to CB_NEW, but clear all other state
281294
void CommandBuffer::ResetCBState() {

layers/state_tracker/cmd_buffer_state.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ class CommandBuffer : public RefcountedStateObject, public SubStateManager<Comma
593593
} descriptor_heap;
594594

595595
void SetDescriptorMode(vvl::DescriptorMode new_mode, vvl::Func function);
596+
void InvalidateDescriptorMode(vvl::DescriptorMode invalidate_mode, vvl::DescriptorMode new_mode, vvl::Func function);
596597

597598
mutable std::shared_mutex lock;
598599
ReadLockGuard ReadLock() const { return ReadLockGuard(lock); }

layers/state_tracker/state_tracker.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3301,11 +3301,12 @@ void DeviceState::PostCallRecordCmdPushConstants(VkCommandBuffer commandBuffer,
33013301
auto pipeline_layout_state = Get<PipelineLayout>(layout);
33023302
ASSERT_AND_RETURN(cb_state && pipeline_layout_state);
33033303

3304-
const DescriptorMode descriptor_mode =
3305-
pipeline_layout_state->has_descriptor_buffer ? vvl::DescriptorModeBuffer : vvl::DescriptorModeClassic;
3306-
cb_state->SetDescriptorMode(descriptor_mode, record_obj.location.function);
33073304
cb_state->RecordCommand(record_obj.location);
33083305
cb_state->RecordPushConstants(*pipeline_layout_state, stageFlags, offset, size, pValues);
3306+
3307+
const DescriptorMode descriptor_mode =
3308+
pipeline_layout_state->has_descriptor_buffer ? vvl::DescriptorModeBuffer : vvl::DescriptorModeClassic;
3309+
cb_state->InvalidateDescriptorMode(vvl::DescriptorModeHeap, descriptor_mode, record_obj.location.function);
33093310
}
33103311

33113312
void DeviceState::PostCallRecordCmdPushConstants2(VkCommandBuffer commandBuffer, const VkPushConstantsInfo* pPushConstantsInfo,

0 commit comments

Comments
 (0)