Skip to content

Commit

Permalink
Fix some typos and missing vkQueueSubmit2(KHR) references.
Browse files Browse the repository at this point in the history
Add validation to function lists. Add support for
vkCmdPushDescriptorSet2KHR().
  • Loading branch information
per-mathisen-arm committed Dec 28, 2024
1 parent 217fa40 commit 7152a73
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
37 changes: 29 additions & 8 deletions scripts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
if name in detect_words:
feature_detection_structs.append(name)

def validate_funcs(lst):
for x in lst: assert x in spec.valid_functions, '%s is not a valid function' % x

# Set this to zero to enable injecting sentinel values between each real value.
debugcount = -1

Expand Down Expand Up @@ -75,15 +78,18 @@
}

# Need to make extra sure these are externally synchronized
extra_sync = [ 'vkQueueSubmit', 'vkQueueSubmit2', 'vkQueueWaitIdle', 'vkQueueBindSparse', 'vkDestroyDevice' ]
extra_sync = [ 'vkQueueSubmit', 'vkQueueSubmit2', 'vkQueueSubmit2KHR', 'vkQueueWaitIdle', 'vkQueueBindSparse', 'vkDestroyDevice' ]
validate_funcs(extra_sync)

skip_opt_check = ['pAllocator', 'pUserData', 'pfnCallback', 'pfnUserCallback', 'pNext' ]
# for these, thread barrier goes before the function call to sync us up to other threads:
thread_barrier_funcs = [ 'vkQueueSubmit', 'vkResetDescriptorPool', 'vkResetCommandPool', 'vkUnmapMemory', 'vkFlushMappedMemoryRanges', 'vkResetQueryPool',
'vkResetQueryPoolEXT', 'vkQueueSubmit2', 'vkQueueSubmit2EXT', 'vkQueuePresentKHR', 'vkFrameEndTRACETOOLTEST', 'vkUnmapMemory2KHR' ]
'vkResetQueryPoolEXT', 'vkQueueSubmit2', 'vkQueueSubmit2KHR', 'vkQueuePresentKHR', 'vkUnmapMemory2KHR' ]
validate_funcs(thread_barrier_funcs)
# for these, thread barrier goes after the function call to sync other threads up to us:
push_thread_barrier_funcs = [ 'vkQueueWaitIdle', 'vkDeviceWaitIdle', 'vkResetDescriptorPool', 'vkResetQueryPool', 'vkResetQueryPoolEXT', 'vkResetCommandPool',
'vkQueuePresentKHR', 'vkWaitForFences', 'vkGetFenceStatus', 'vkFrameEndTRACETOOLTEST' ]
'vkQueuePresentKHR', 'vkWaitForFences', 'vkGetFenceStatus' ]
validate_funcs(push_thread_barrier_funcs)

# TODO : Add support for these functions and structures
functions_noop = [
Expand All @@ -95,6 +101,7 @@
'vkGetEncodedVideoSessionParametersKHR',
'vkCreatePipelineBinariesKHR', 'vkCreateIndirectCommandsLayoutEXT', 'vkCreateIndirectExecutionSetEXT', 'vkGetPipelineBinaryDataKHR',
]
validate_funcs(functions_noop)
struct_noop = []

# these should skip their native/upstream call and leave everything up to the post-execute callback
Expand All @@ -108,53 +115,66 @@

# make sure we've thought about all the ways virtual swapchains interact with everything else
virtualswap_calls = [ 'vkCreateSwapchainKHR', 'vkDestroySwapchainKHR', 'vkCreateSharedSwapchainsKHR', 'vkGetSwapchainStatusKHR', 'vkGetSwapchainCounterEXT' ]
validate_funcs(virtualswap_calls)

# Set this to true to generate packet statistics. The generated code will be quite a lot more bloated.
debugstats = False

# These functions are hard-coded in hardcoded_{write|read}.cpp
# These functions are hard-coded in hardcode_{write|read}.cpp
hardcoded = [ 'vkGetSwapchainImagesKHR', 'vkCreateAndroidSurfaceKHR', 'vkGetDeviceProcAddr',
'vkGetInstanceProcAddr', 'vkCreateWaylandSurfaceKHR', 'vkCreateHeadlessSurfaceEXT', 'vkCreateXcbSurfaceKHR', 'vkCreateXlibSurfaceKHR',
'vkDestroySurfaceKHR', 'vkGetDeviceQueue', 'vkGetDeviceQueue2', "vkGetAndroidHardwareBufferPropertiesANDROID", "vkGetMemoryAndroidHardwareBufferANDROID",
'vkEnumerateInstanceLayerProperties', 'vkEnumerateInstanceExtensionProperties', 'vkEnumerateDeviceLayerProperties', 'vkEnumerateDeviceExtensionProperties',
'vkGetPhysicalDeviceXlibPresentationSupportKHR', 'vkCreateWin32SurfaceKHR', 'vkCreateDirectFBSurfaceEXT', 'vkCreateMetalSurfaceEXT' ]
validate_funcs(hardcoded)
hardcoded_write = [ 'vkGetPhysicalDeviceToolPropertiesEXT', 'vkGetPhysicalDeviceToolProperties', 'vkGetPhysicalDeviceQueueFamilyProperties' ]
validate_funcs(hardcoded_write)
hardcoded_read = [ 'vkCmdBuildAccelerationStructuresIndirectKHR' ]
validate_funcs(hardcoded_read)
# For these functions it is ok if the function pointer is missing, since we implement them ourselves
layer_implemented = [ 'vkCreateDebugReportCallbackEXT', 'vkDestroyDebugReportCallbackEXT', 'vkDebugReportMessageEXT', 'vkDebugMarkerSetObjectTagEXT',
'vkDebugMarkerSetObjectNameEXT', 'vkCmdDebugMarkerBeginEXT', 'vkCmdDebugMarkerEndEXT', 'vkCmdDebugMarkerInsertEXT', 'vkSetDebugUtilsObjectNameEXT',
'vkSetDebugUtilsObjectTagEXT', 'vkQueueBeginDebugUtilsLabelEXT', 'vkQueueEndDebugUtilsLabelEXT', 'vkQueueInsertDebugUtilsLabelEXT',
'vkCmdBeginDebugUtilsLabelEXT', 'vkCmdEndDebugUtilsLabelEXT', 'vkCmdInsertDebugUtilsLabelEXT', 'vkCreateDebugUtilsMessengerEXT',
'vkDestroyDebugUtilsMessengerEXT', 'vkSubmitDebugUtilsMessageEXT', 'vkGetPhysicalDeviceToolPropertiesEXT', 'vkGetPhysicalDeviceToolProperties' ]
validate_funcs(layer_implemented)
# functions we should ignore on replay
ignore_on_read = [ 'vkGetMemoryHostPointerPropertiesEXT', 'vkCreateDebugUtilsMessengerEXT', 'vkDestroyDebugUtilsMessengerEXT', 'vkAllocateMemory',
'vkMapMemory', 'vkUnmapMemory', 'vkCreateDebugReportCallbackEXT', 'vkDestroyDebugReportCallbackEXT', 'vkFlushMappedMemoryRanges',
'vkInvalidateMappedMemoryRanges', 'vkFreeMemory', 'vkGetPhysicalDeviceXcbPresentationSupportKHR', 'vkMapMemory2KHR', 'vkUnmapMemory2KHR',
'vkGetImageMemoryRequirements2KHR', 'vkGetBufferMemoryRequirements2KHR', 'vkGetImageSparseMemoryRequirements2KHR', 'vkGetImageMemoryRequirements',
'vkGetBufferMemoryRequirements', 'vkGetImageSparseMemoryRequirements', 'vkGetImageMemoryRequirements2', 'vkGetBufferMemoryRequirements2',
'vkGetImageSparseMemoryRequirements2' ]
validate_funcs(ignore_on_read)
# functions we should not call natively when tracing - let pre or post calls handle it
ignore_on_trace = []
validate_funcs(ignore_on_trace)
# these functions have hard-coded post-execute callbacks
replay_pre_calls = [ 'vkDestroyInstance', 'vkDestroyDevice', 'vkCreateDevice', 'vkCreateSampler', 'vkQueuePresentKHR', 'vkCreateSwapchainKHR',
'vkCreateSharedSwapchainsKHR', 'vkCreateGraphicsPipelines', 'vkCreateComputePipelines', 'vkCreateRayTracingPipelinesKHR', 'vkCmdPushConstants2KHR',
'vkCmdPushConstants2', 'vkQueueSubmit' ]
'vkQueueSubmit', 'vkQueueSubmit2', 'vkQueueSubmit2KHR' ]
validate_funcs(replay_pre_calls)
replay_post_calls = [ 'vkCreateInstance', 'vkDestroyInstance', 'vkQueuePresentKHR', 'vkAcquireNextImageKHR', 'vkAcquireNextImage2KHR',
'vkGetBufferDeviceAddress', 'vkGetBufferDeviceAddressKHR', 'vkGetAccelerationStructureDeviceAddressKHR' ]
replay_postprocess_calls = [ 'vkCmdPushConstants', 'vkCmdPushConstants2', 'vkCmdPushConstants2KHR' ]
validate_funcs(replay_post_calls)
replay_postprocess_calls = [ 'vkCmdPushConstants', 'vkCmdPushConstants2KHR' ]
validate_funcs(replay_postprocess_calls)
trace_pre_calls = [ 'vkQueueSubmit', 'vkCreateInstance', 'vkCreateDevice', 'vkFreeMemory', 'vkQueueSubmit2', 'vkQueueSubmit2KHR' ]
validate_funcs(trace_pre_calls)
trace_post_calls = [ 'vkCreateInstance', 'vkCreateDevice', 'vkDestroyInstance', 'vkGetPhysicalDeviceFeatures', 'vkGetPhysicalDeviceProperties',
'vkGetPhysicalDeviceSurfaceCapabilitiesKHR', 'vkBindImageMemory', 'vkBindBufferMemory', 'vkBindImageMemory2', 'vkBindImageMemory2KHR',
'vkBindBufferMemory2', 'vkUpdateDescriptorSets', 'vkFlushMappedMemoryRanges', 'vkQueuePresentKHR', 'vkMapMemory2KHR',
'vkMapMemory', 'vkCmdBindDescriptorSets', 'vkBindBufferMemory2KHR', 'vkCmdPushDescriptorSet',
'vkMapMemory', 'vkCmdBindDescriptorSets', 'vkBindBufferMemory2KHR', 'vkCmdPushDescriptorSet2KHR',
'vkGetImageMemoryRequirements', 'vkGetPipelineCacheData', 'vkAcquireNextImageKHR', 'vkAcquireNextImage2KHR',
'vkGetBufferMemoryRequirements', 'vkGetBufferMemoryRequirements2', 'vkGetImageMemoryRequirements2', 'vkGetPhysicalDeviceMemoryProperties',
'vkGetPhysicalDeviceFormatProperties', 'vkGetPhysicalDeviceFormatProperties2', 'vkCmdPushDescriptorSetKHR', 'vkCreateSwapchainKHR',
'vkGetBufferMemoryRequirements2KHR', 'vkGetDeviceBufferMemoryRequirements', 'vkGetDeviceBufferMemoryRequirementsKHR',
'vkGetDeviceImageMemoryRequirements', 'vkGetDeviceImageMemoryRequirementsKHR', 'vkGetPhysicalDeviceFeatures2', 'vkGetPhysicalDeviceFeatures2KHR',
'vkGetPhysicalDeviceMemoryProperties2', 'vkGetDeviceImageSparseMemoryRequirementsKHR', 'vkGetDeviceImageSparseMemoryRequirements',
'vkCreateShaderModule', 'vkGetBufferDeviceAddress', 'vkGetBufferDeviceAddressKHR', 'vkGetAccelerationStructureDeviceAddressKHR' ]
validate_funcs(trace_post_calls)
skip_post_calls = [ 'vkGetQueryPoolResults', 'vkGetPhysicalDeviceXcbPresentationSupportKHR' ]
validate_funcs(skip_post_calls)
# Workaround to be able to rewrite parameter inputs while tracing: These input variables are copied and replaced to not be const anymore.
deconstify = {
'vkAllocateMemory' : 'pAllocateInfo',
Expand All @@ -166,6 +186,7 @@
'vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR' : 'pPerformanceQueryCreateInfo',
'vkCreateVideoSessionKHR' : 'pCreateInfo',
}
validate_funcs(deconstify.keys())
# Workaround to deconstify nested structures
deconst_struct = [
'VkDeviceQueueCreateInfo', 'VkDeviceQueueInfo2', 'VkQueryPoolPerformanceCreateInfoKHR', 'VkVideoSessionCreateInfoKHR', 'VkDeviceCreateInfo', 'VkCommandPoolCreateInfo'
Expand Down Expand Up @@ -1574,7 +1595,7 @@ def loadfunc(name, node, target, header):
z.do('if (stored_retval == VK_SUCCESS) { flags |= VK_QUERY_RESULT_WAIT_BIT; flags &= ~VK_QUERY_RESULT_PARTIAL_BIT; }')

# current
z.do(prefix)
z.do(prefix.strip())
z.brace_begin()
z.do('retval = wrap_%s(%s);' % (name, ', '.join(call_list)))

Expand Down
6 changes: 3 additions & 3 deletions src/hardcode_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,17 @@ static uint64_t object_lookup(VkObjectType type, uint32_t index)
return 0;
}

void replay_pre_vkQueueSubmit2(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence)
void replay_pre_vkQueueSubmit2(lava_file_reader& reader, VkQueue queue, uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence)
{
for (uint32_t i = 0; i < submitCount; i++)
{
if (!host_has_frame_boundary) purge_extension_parent(const_cast<VkSubmitInfo2*>(&pSubmits[i]), VK_STRUCTURE_TYPE_FRAME_BOUNDARY_EXT);
}
}

void replay_pre_vkQueueSubmit2KHR(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2KHR* pSubmits, VkFence fence)
void replay_pre_vkQueueSubmit2KHR(lava_file_reader& reader, VkQueue queue, uint32_t submitCount, const VkSubmitInfo2KHR* pSubmits, VkFence fence)
{
replay_pre_vkQueueSubmit2(queue, submitCount, pSubmits, fence);
replay_pre_vkQueueSubmit2(reader, queue, submitCount, pSubmits, fence);
}

void replay_pre_vkQueueSubmit(lava_file_reader& reader, VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence)
Expand Down
4 changes: 2 additions & 2 deletions src/hardcode_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ static void trace_post_vkCmdPushDescriptorSetKHR(lava_file_writer& writer, VkCom
handle_VkWriteDescriptorSets(writer, descriptorWriteCount, pDescriptorWrites, false);
}

static void trace_post_vkCmdPushDescriptorSet(lava_file_writer& writer, VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites)
static void trace_post_vkCmdPushDescriptorSet2KHR(lava_file_writer& writer, VkCommandBuffer commandBuffer, const VkPushDescriptorSetInfoKHR* pPushDescriptorSetInfo)
{
handle_VkWriteDescriptorSets(writer, descriptorWriteCount, pDescriptorWrites, false);
handle_VkWriteDescriptorSets(writer, pPushDescriptorSetInfo->descriptorWriteCount, pPushDescriptorSetInfo->pDescriptorWrites, false);
}

static void trace_post_vkUpdateDescriptorSets(lava_file_writer& writer, VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies)
Expand Down

0 comments on commit 7152a73

Please sign in to comment.