Skip to content

Commit

Permalink
Remove faked frame boundary extension feature struct from replay.
Browse files Browse the repository at this point in the history
Also add back feature/ext print calls on replay failure to create
vulkan device that had gone missing, and print a warning on capture
failure using the python wrapper script.
  • Loading branch information
per-mathisen-arm committed Sep 2, 2024
1 parent eed9aee commit 3de3271
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 12 deletions.
2 changes: 1 addition & 1 deletion external/tracetooltests
Submodule tracetooltests updated 87 files
+9 −3 CMakeLists.txt
+2 −2 benchmarking/gles_bindbufferrange_1.bench
+2 −2 benchmarking/gles_compute_1.bench
+2 −2 benchmarking/gles_compute_2.bench
+2 −2 benchmarking/gles_compute_3.bench
+2 −2 benchmarking/gles_copy_image_1.bench
+2 −2 benchmarking/gles_copytexsubimage3d.bench
+2 −2 benchmarking/gles_draw_1.bench
+2 −2 benchmarking/gles_draw_2.bench
+2 −2 benchmarking/gles_drawrange_1.bench
+2 −2 benchmarking/gles_drawrange_2.bench
+2 −2 benchmarking/gles_dummy_1.bench
+2 −2 benchmarking/gles_ext_gpu_shader5.bench
+2 −2 benchmarking/gles_ext_tessellation_shader.bench
+2 −2 benchmarking/gles_ext_texture_border_clamp.bench
+2 −2 benchmarking/gles_ext_texture_buffer.bench
+2 −2 benchmarking/gles_ext_texture_cube_map_array.bench
+2 −2 benchmarking/gles_ext_texture_sRGB_decode.bench
+2 −2 benchmarking/gles_extension_pack_es31a.bench
+2 −2 benchmarking/gles_geometry_shader_1.bench
+2 −2 benchmarking/gles_imagetex_1.bench
+2 −2 benchmarking/gles_indirectdraw_1.bench
+2 −2 benchmarking/gles_indirectdraw_2.bench
+2 −2 benchmarking/gles_khr_blend_equation_advanced.bench
+2 −2 benchmarking/gles_khr_debug.bench
+2 −2 benchmarking/gles_multisample_1.bench
+2 −2 benchmarking/gles_multisurface_1.bench
+2 −2 benchmarking/gles_multithread_1.bench
+2 −2 benchmarking/gles_multithread_2.bench
+2 −2 benchmarking/gles_multithread_3.bench
+2 −2 benchmarking/gles_oes_sample_shading.bench
+2 −2 benchmarking/gles_oes_texture_stencil8.bench
+2 −2 benchmarking/gles_programs_1.bench
+2 −2 benchmarking/gles_texsubimage3d.bench
+2 −2 benchmarking/gles_uninit_texture_1.bench
+2 −2 benchmarking/gles_uninit_texture_2.bench
+2 −2 benchmarking/gles_vertexbuffer_1.bench
+2 −2 benchmarking/vulkan_as_1.bench
+2 −2 benchmarking/vulkan_as_2.bench
+2 −2 benchmarking/vulkan_as_3.bench
+2 −2 benchmarking/vulkan_as_4.bench
+2 −2 benchmarking/vulkan_as_5.bench
+3 −2 benchmarking/vulkan_compute_1.bench
+3 −2 benchmarking/vulkan_compute_2.bench
+18 −0 benchmarking/vulkan_compute_3.bench
+18 −0 benchmarking/vulkan_compute_bda_sc.bench
+2 −2 benchmarking/vulkan_copying_1.bench
+2 −2 benchmarking/vulkan_copying_2.bench
+2 −2 benchmarking/vulkan_copying_3.bench
+2 −2 benchmarking/vulkan_debug_marker.bench
+2 −2 benchmarking/vulkan_debug_report.bench
+2 −2 benchmarking/vulkan_feature_1.bench
+17 −0 benchmarking/vulkan_feature_2.bench
+2 −2 benchmarking/vulkan_init.bench
+2 −2 benchmarking/vulkan_memory_1.bench
+2 −2 benchmarking/vulkan_memory_1_1.bench
+2 −2 benchmarking/vulkan_multidevice_1.bench
+2 −2 benchmarking/vulkan_multiinstance.bench
+2 −2 benchmarking/vulkan_pipelinecache_1.bench
+2 −2 benchmarking/vulkan_pnext_chain.bench
+2 −2 benchmarking/vulkan_stress_1.bench
+2 −2 benchmarking/vulkan_thread_1.bench
+2 −2 benchmarking/vulkan_thread_2.bench
+2 −2 benchmarking/vulkan_thread_3.bench
+2 −2 benchmarking/vulkan_tool_1.bench
+2 −2 benchmarking/vulkan_xfb.bench
+26 −22 doc/BenchmarkingStandard.md
+2 −1 scripts/demo_list.sh
+10 −1 src/util.cpp
+3 −1 src/util.h
+54 −52 src/vulkan_common.cpp
+13 −1 src/vulkan_common.h
+6 −6 src/vulkan_compute_1.comp
+69 −283 src/vulkan_compute_1.cpp
+309 −291 src/vulkan_compute_1.inc
+1 −1 src/vulkan_compute_2.comp
+7 −3 src/vulkan_compute_2.cpp
+102 −0 src/vulkan_compute_3.cpp
+57 −0 src/vulkan_compute_bda_sc.comp
+198 −0 src/vulkan_compute_bda_sc.cpp
+ src/vulkan_compute_bda_sc.spirv
+283 −0 src/vulkan_compute_common.cpp
+29 −0 src/vulkan_compute_common.h
+24 −0 src/vulkan_feature_2.cpp
+15 −10 src/vulkan_general.cpp
+1 −1 src/vulkan_pipelinecache_1.cpp
+2 −2 src/vulkan_stress_1.cpp
2 changes: 2 additions & 0 deletions scripts/lava-capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,6 @@ def PrintEnvVar(envVar):
result = subprocess.run(['gdb', '-q', '-ex', 'run', '--args'] + args.programAndArgs)
else:
result = subprocess.run(args.programAndArgs)
if result.returncode != 0:
print('Captured program returned an error value!')
sys.exit(result.returncode)
2 changes: 1 addition & 1 deletion scripts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def print_load(self, name, owner): # called for each parameter
elif self.funcname == 'VkInstanceCreateInfo' and self.name == 'ppEnabledLayerNames':
z.do('%s = instance_layers(reader, sptr->%s);' % (varname, len))
elif self.funcname == 'VkDeviceCreateInfo' and self.name == 'ppEnabledExtensionNames':
z.do('%s = device_extensions(reader, physicalDevice, sptr->%s);' % (varname, len))
z.do('%s = device_extensions(sptr, reader, physicalDevice, sptr->%s);' % (varname, len))
elif self.funcname == 'VkDeviceCreateInfo' and self.name == 'ppEnabledLayerNames':
z.do('%s = device_layers(reader, sptr->%s);' % (varname, len))
else:
Expand Down
4 changes: 4 additions & 0 deletions scripts/vk_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ def print_wrapper_cpp(name):
print('\t// Setup next layer', file=w)
print('\tPFN_vkCreateDevice createDeviceNext = reinterpret_cast<PFN_vkCreateDevice>(gipa(VK_NULL_HANDLE, "vkCreateDevice"));', file=w)
print('\tVkResult retval = createDeviceNext(physicalDevice, pCreateInfo, pAllocator, pDevice);', file=w)
print('\tif (retval == VK_ERROR_FEATURE_NOT_PRESENT) print_feature_mismatch(physicalDevice, pCreateInfo);', file=w)
print('\telse if (retval == VK_ERROR_EXTENSION_NOT_PRESENT) print_extension_mismatch(physicalDevice, pCreateInfo);', file=w)
print('\tif (retval != VK_SUCCESS) ABORT("Failed to create device: %s", errorString(retval));', file=w)
print('\tassert(*pDevice);', file=w)
print(file=w)
build_device_table(w)
print(file=w)
Expand Down
3 changes: 2 additions & 1 deletion src/hardcode_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ void replay_post_vkCreateInstance(lava_file_reader& reader, VkResult result, con
}
}

const char* const* device_extensions(lava_file_reader& reader, VkPhysicalDevice physicalDevice, uint32_t& len)
const char* const* device_extensions(VkDeviceCreateInfo* sptr, lava_file_reader& reader, VkPhysicalDevice physicalDevice, uint32_t& len)
{
bool host_has_frame_boundary = false;
bool trace_has_frame_boundary = false;
Expand Down Expand Up @@ -700,6 +700,7 @@ const char* const* device_extensions(lava_file_reader& reader, VkPhysicalDevice
if (!host_has_frame_boundary && trace_has_frame_boundary)
{
ILOG("Replay host does not have frame boundary but trace does -- removing it from the replay!");
purge_extension_parent(sptr, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAME_BOUNDARY_FEATURES_EXT);
}
else if (trace_has_frame_boundary)
{
Expand Down
19 changes: 11 additions & 8 deletions src/hardcode_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,9 @@ static void trace_pre_vkCreateDevice(VkPhysicalDevice physicalDevice, VkDeviceCr
// -- Modify app request --

bool has_VK_EXT_tooling_info = false;
bool has_VK_KHR_external_memory = false;
bool has_VK_EXT_external_memory_host = false;
bool add_VK_KHR_external_memory = false;
bool add_VK_EXT_external_memory_host = false;
bool has_VK_EXT_frame_boundary = false;
uint32_t propertyCount = 0;
[[maybe_unused]] VkResult result = wrap_vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &propertyCount, nullptr); // call first to get correct count on host
assert(result == VK_SUCCESS);
Expand All @@ -932,14 +933,15 @@ static void trace_pre_vkCreateDevice(VkPhysicalDevice physicalDevice, VkDeviceCr
{
std::string name = ext.extensionName;
if (name == VK_EXT_TOOLING_INFO_EXTENSION_NAME) has_VK_EXT_tooling_info = true;
if (name == VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME) has_VK_KHR_external_memory = true;
if (name == VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME) has_VK_EXT_external_memory_host = true;
if (name == VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME) add_VK_KHR_external_memory = true;
if (name == VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME) add_VK_EXT_external_memory_host = true;
if (name == VK_EXT_FRAME_BOUNDARY_EXTENSION_NAME) has_VK_EXT_frame_boundary = true;
}

// Extra extensions to add
std::vector<std::string> extra_exts;
if (has_VK_KHR_external_memory) { extra_exts.push_back(VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME); }
if (has_VK_EXT_external_memory_host) { extra_exts.push_back(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME); }
if (add_VK_KHR_external_memory) { extra_exts.push_back(VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME); }
if (add_VK_EXT_external_memory_host) { extra_exts.push_back(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME); }

// Remove built-in extensions before sending the requested extension list to the driver
char** nameptrs = writer.pool.allocate<char*>(pCreateInfo->enabledExtensionCount + extra_exts.size()); // reserve space for all
Expand All @@ -959,8 +961,9 @@ static void trace_pre_vkCreateDevice(VkPhysicalDevice physicalDevice, VkDeviceCr
}
if (strcmp(name, VK_TRACETOOLTEST_CHECKSUM_VALIDATION_EXTENSION_NAME) == 0) continue; // do not pass to host
if (strcmp(name, VK_TRACETOOLTEST_OBJECT_PROPERTY_EXTENSION_NAME) == 0) continue; // do not pass to host
if (strcmp(name, VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME) == 0) has_VK_KHR_external_memory = false; // do not need to add, already there
if (strcmp(name, VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME) == 0) has_VK_EXT_external_memory_host = false; // ditto
if (!has_VK_EXT_frame_boundary && strcmp(name, VK_EXT_FRAME_BOUNDARY_EXTENSION_NAME) == 0) continue; // do not pass to host
if (strcmp(name, VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME) == 0 && add_VK_KHR_external_memory) continue; // do not need to add twice
if (strcmp(name, VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME) == 0 && add_VK_EXT_external_memory_host) continue;; // ditto
nameptrs[newcount++] = name;
DLOG(" %s", name);
}
Expand Down
14 changes: 14 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,20 @@ void* find_extension(void* sptr, VkStructureType sType)
return ptr;
}

void purge_extension_parent(void* sptr, VkStructureType sType)
{
VkBaseOutStructure* ptr = (VkBaseOutStructure*)sptr;
while (ptr != nullptr && ptr->pNext != nullptr)
{
if (ptr->pNext->sType == sType)
{
ptr->pNext = ptr->pNext->pNext;
return;
}
ptr = ptr->pNext;
}
}

const void* find_extension(const void* sptr, VkStructureType sType)
{
const VkBaseOutStructure* ptr = (VkBaseOutStructure*)sptr;
Expand Down
5 changes: 4 additions & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@ struct buffer
static __attribute__((const)) inline uint64_t aligned_size(uint64_t size, uint64_t alignment) { return size + alignment - 1ull - (size + alignment - 1ull) % alignment; }
static __attribute__((const)) inline uint64_t aligned_start(uint64_t size, uint64_t alignment) { return (size & ~(alignment - 1)); }

void* find_extension_parent(void* sptr, VkStructureType sType);
void* find_extension(void* sptr, VkStructureType sType);
const void* find_extension(const void* sptr, VkStructureType sType);

// "parent" methods require you to pass the owner of the pNext chain
void* find_extension_parent(void* sptr, VkStructureType sType); // returns the parent object to the searched for type
void purge_extension_parent(void* sptr, VkStructureType sType); // removes this extension from a pNext chain

const char* pretty_print_VkObjectType(VkObjectType val);

0 comments on commit 3de3271

Please sign in to comment.