Skip to content

Commit

Permalink
Relax command buffe validity check in vulkan state writer
Browse files Browse the repository at this point in the history
  • Loading branch information
panos-lunarg committed Nov 1, 2024
1 parent 23dbad8 commit 6125e91
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 5 deletions.
63 changes: 63 additions & 0 deletions framework/encode/vulkan_state_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,69 @@ enum CommandHandleType : uint32_t
NumHandleTypes // THIS MUST BE THE LAST ENUM VALUE !
};

static const char* CommandHandleTypeToStr(CommandHandleType type)
{
switch (type)
{
case BufferHandle:
return GFXRECON_STR(BufferHandle);
case BufferViewHandle:
return GFXRECON_STR(BufferViewHandle);
case CommandBufferHandle:
return GFXRECON_STR(CommandBufferHandle);
case DescriptorSetHandle:
return GFXRECON_STR(DescriptorSetHandle);
case EventHandle:
return GFXRECON_STR(EventHandle);
case FramebufferHandle:
return GFXRECON_STR(FramebufferHandle);
case ImageHandle:
return GFXRECON_STR(ImageHandle);
case ImageViewHandle:
return GFXRECON_STR(ImageViewHandle);
case PipelineHandle:
return GFXRECON_STR(PipelineHandle);
case PipelineLayoutHandle:
return GFXRECON_STR(PipelineLayoutHandle);
case QueryPoolHandle:
return GFXRECON_STR(QueryPoolHandle);
case RenderPassHandle:
return GFXRECON_STR(RenderPassHandle);
case SamplerHandle:
return GFXRECON_STR(SamplerHandle);
case AccelerationStructureKHRHandle:
return GFXRECON_STR(AccelerationStructureKHRHandle);
case AccelerationStructureNVHandle:
return GFXRECON_STR(AccelerationStructureNVHandle);
case IndirectCommandsLayoutNVHandle:
return GFXRECON_STR(IndirectCommandsLayoutNVHandle);
case DeferredOperationKHRHandle:
return GFXRECON_STR(DeferredOperationKHRHandle);
case MicromapEXTHandle:
return GFXRECON_STR(MicromapEXTHandle);
case OpticalFlowSessionNVHandle:
return GFXRECON_STR(OpticalFlowSessionNVHandle);
case VideoSessionKHRHandle:
return GFXRECON_STR(VideoSessionKHRHandle);
case VideoSessionParametersKHRHandle:
return GFXRECON_STR(VideoSessionParametersKHRHandle);
case ShaderEXTHandle:
return GFXRECON_STR(ShaderEXTHandle);
case DescriptorSetLayoutHandle:
return GFXRECON_STR(DescriptorSetLayoutHandle);
case DescriptorUpdateTemplateHandle:
return GFXRECON_STR(DescriptorUpdateTemplateHandle);
case IndirectCommandsLayoutEXTHandle:
return GFXRECON_STR(IndirectCommandsLayoutEXTHandle);
case IndirectExecutionSetEXTHandle:
return GFXRECON_STR(IndirectExecutionSetEXTHandle);
default:
return "XXXX";
}

return "XXXX";
}

struct ShaderReflectionDescriptorInfo
{
ShaderReflectionDescriptorInfo(
Expand Down
20 changes: 15 additions & 5 deletions framework/encode/vulkan_state_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "format/format_util.h"
#include "util/logging.h"
#include "custom_vulkan_array_size_2d.h"
#include "vulkan/vulkan_core.h"

#include <algorithm>
#include <array>
Expand Down Expand Up @@ -3452,6 +3453,11 @@ void VulkanStateWriter::WriteCommandBufferCommands(const vulkan_wrappers::Comman

assert(offset == data_size);
}
else
{
const char* level_str = wrapper->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY ? "Primary" : "Secondary";
GFXRECON_LOG_ERROR("%s command buffer % " PRIu64 " will not be dumped", level_str, wrapper->handle_id);
}
}

void VulkanStateWriter::WriteDescriptorUpdateCommand(format::HandleId device_id,
Expand Down Expand Up @@ -4174,6 +4180,10 @@ bool VulkanStateWriter::CheckCommandHandles(const vulkan_wrappers::CommandBuffer
{
if (!CheckCommandHandle(static_cast<vulkan_state_info::CommandHandleType>(i), id, state_table))
{
GFXRECON_LOG_ERROR("%s(): Object %" PRIu64 " of type %s is invalid",
__func__,
id,
CommandHandleTypeToStr(static_cast<vulkan_state_info::CommandHandleType>(i)));
return false;
}
}
Expand All @@ -4189,21 +4199,21 @@ bool VulkanStateWriter::CheckCommandHandle(vulkan_state_info::CommandHandleType
switch (handle_type)
{
case vulkan_state_info::CommandHandleType::BufferHandle:
return IsBufferValid(handle_id, state_table);
return (state_table.GetBufferWrapper(handle_id) != nullptr);
case vulkan_state_info::CommandHandleType::BufferViewHandle:
return IsBufferViewValid(handle_id, state_table);
return (state_table.GetBufferViewWrapper(handle_id) != nullptr);
case vulkan_state_info::CommandHandleType::CommandBufferHandle:
return (state_table.GetCommandBufferWrapper(handle_id) != nullptr);
case vulkan_state_info::CommandHandleType::DescriptorSetHandle:
return (state_table.GetDescriptorSetWrapper(handle_id) != nullptr);
case vulkan_state_info::CommandHandleType::EventHandle:
return (state_table.GetEventWrapper(handle_id) != nullptr);
case vulkan_state_info::CommandHandleType::FramebufferHandle:
return IsFramebufferValid(handle_id, state_table);
return (state_table.GetFramebufferWrapper(handle_id) != nullptr);
case vulkan_state_info::CommandHandleType::ImageHandle:
return IsImageValid(handle_id, state_table);
return (state_table.GetImageWrapper(handle_id) != nullptr);
case vulkan_state_info::CommandHandleType::ImageViewHandle:
return IsImageViewValid(handle_id, state_table);
return (state_table.GetImageViewWrapper(handle_id) != nullptr);
case vulkan_state_info::CommandHandleType::PipelineHandle:
return (state_table.GetPipelineWrapper(handle_id) != nullptr);
case vulkan_state_info::CommandHandleType::PipelineLayoutHandle:
Expand Down

0 comments on commit 6125e91

Please sign in to comment.