Skip to content

Commit

Permalink
Fix delay fence implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
per-mathisen-arm committed Oct 27, 2024
1 parent e0ace9f commit dc4914a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,9 @@ endfunction()

layer_test(general general)
add_test(NAME layer_test_general_fencedelay COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tracetooltests/vulkan_general -f 1)
set_tests_properties(layer_test_general_fencedelay PROPERTIES ENVIRONMENT "VK_LAYER_PATH=${CMAKE_CURRENT_BINARY_DIR}/implicit_layer.d;VK_INSTANCE_LAYERS=VK_LAYER_ARM_lavatube;LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/implicit_layer.d;LAVATUBE_DELAY_FENCE_SUCCESS_FRAMES=1;")
set_tests_properties(layer_test_general_fencedelay PROPERTIES ENVIRONMENT "VK_LAYER_PATH=${CMAKE_CURRENT_BINARY_DIR}/implicit_layer.d;VK_INSTANCE_LAYERS=VK_LAYER_ARM_lavatube;LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/implicit_layer.d;LAVATUBE_DELAY_FENCE_SUCCESS_FRAMES=2;")
add_test(NAME script_test_general COMMAND ${CMAKE_SOURCE_DIR}/scripts/lava-capture.py -o script_test_general.vk --layer-path ${CMAKE_CURRENT_BINARY_DIR}/implicit_layer.d ${CMAKE_CURRENT_BINARY_DIR}/tracetooltests/vulkan_general -f 0 -V 2)
add_test(NAME script_test_general_fencedelay COMMAND ${CMAKE_SOURCE_DIR}/scripts/lava-capture.py -o script_test_general_fencedelay.vk --layer-path ${CMAKE_CURRENT_BINARY_DIR}/implicit_layer.d --delayfence 1 ${CMAKE_CURRENT_BINARY_DIR}/tracetooltests/vulkan_general -f 1)
add_test(NAME script_test_general_fencedelay COMMAND ${CMAKE_SOURCE_DIR}/scripts/lava-capture.py -o script_test_general_fencedelay.vk --layer-path ${CMAKE_CURRENT_BINARY_DIR}/implicit_layer.d --delayfence 2 ${CMAKE_CURRENT_BINARY_DIR}/tracetooltests/vulkan_general -f 1)
add_test(NAME script_test_copying_1 COMMAND ${CMAKE_SOURCE_DIR}/scripts/lava-capture.py -o script_test_copying_1.vk --dedicated-buffer --gpu 0 --layer-path ${CMAKE_CURRENT_BINARY_DIR}/implicit_layer.d ${CMAKE_CURRENT_BINARY_DIR}/tracetooltests/vulkan_copying_1 -V 2)
#layer_test(general_vulkan13 general -V 3) # crashes on replay on privatedata
layer_test(copying_1 copying_1)
Expand Down
8 changes: 4 additions & 4 deletions scripts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,11 +1080,11 @@ def save_add_pre(name): # need to include the resource-creating or resource-dest
z.do('if (p__delay_fence_success_frames > 0) for (unsigned i = 0; i < fenceCount; i++)')
z.brace_begin() # the assumption here is that the function is only called once per frame per fence unless it is in a loop
z.do('auto* tf = writer.parent->records.VkFence_index.at(%s);' % ('pFences[i]' if name == 'vkWaitForFences' else 'fence'))
z.do('if (tf->frame_delay == -1) { tf->frame_delay = p__delay_fence_success_frames - 1; }')
z.do('if (tf->frame_delay == -1) { tf->frame_delay = p__delay_fence_success_frames; }')
if name == 'vkGetFenceStatus':
z.do('if (tf->frame_delay >= 0) { tf->frame_delay--; writer.write_uint32_t(VK_NOT_READY); return VK_NOT_READY; }')
z.do('if (tf->frame_delay > 0) { tf->frame_delay--; writer.write_uint32_t(VK_NOT_READY); return VK_NOT_READY; }')
elif name == 'vkWaitForFences':
z.do('if (tf->frame_delay >= 0 && timeout != UINT32_MAX) { tf->frame_delay--; writer.write_uint32_t(VK_TIMEOUT); return VK_TIMEOUT; }')
z.do('if (tf->frame_delay > 0 && timeout != UINT32_MAX) { tf->frame_delay--; writer.write_uint32_t(VK_TIMEOUT); return VK_TIMEOUT; }')
z.brace_end()
elif name in ['vkUnmapMemory', 'vkUnmapMemory2KHR']:
z.do('writer.parent->memory_mutex.lock();')
Expand Down Expand Up @@ -1119,7 +1119,7 @@ def save_add_tracking(name):
z.do('for (unsigned i = 0; i < fenceCount; i++)')
z.brace_begin()
z.do('auto* tf = writer.parent->records.VkFence_index.at(pFences[i]);')
z.do('tf->frame_delay = -1; // just to be sure')
z.do('tf->frame_delay = -1; // reset delay fuse')
z.do('tf->tid = writer.thread_index();')
z.do('tf->call = writer.local_call_number;')
z.brace_end()
Expand Down
2 changes: 1 addition & 1 deletion src/lavatube.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ struct trackedfence : trackable
VkFenceCreateFlags flags = (VkFenceCreateFlags)0;

// tracer only
int frame_delay = -1; // delay fuse
int frame_delay = -1; // delay fuse uninitialized
};

struct trackedpipeline : trackable
Expand Down

0 comments on commit dc4914a

Please sign in to comment.