2021-06-22 19:45:24 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-01-13 12:19:37 -05:00
|
|
|
# Copyright (c) 2016-2023 The Brenwill Workshop Ltd.
|
2021-06-22 19:45:24 -04:00
|
|
|
#
|
|
|
|
# runcts - This script simplifies running Vulkan CTS tests on MoltenVK.
|
|
|
|
#
|
|
|
|
# CTS will save temporary output files to the directory this script is located in. It is
|
|
|
|
# recommended that you copy this file to a location where your testing files will be kept.
|
|
|
|
# By default, this should be a directory beside the VK-GL-CTS directory. See the description
|
|
|
|
# of the --cts option below for information about locations.
|
|
|
|
#
|
|
|
|
# Executing a large case list file of CTS tests can take a long time. It is recommended
|
|
|
|
# that you run this using caffeinate, as follows:
|
|
|
|
# caffeinate -is ./runcts [-o path] [--cts path] [-p] [--portability] case_list_file
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# macOS usage: ./runcts [-o path] [--cts path] [-p] [--portability] case_list_file
|
|
|
|
#
|
|
|
|
# case_list_file
|
|
|
|
# The path to the file that contains a list of the CTS test cases to run.
|
|
|
|
#
|
|
|
|
# -o path
|
|
|
|
# The path to the file to write the test results. If this option is not provided,
|
|
|
|
# the results will be written to an output text file with the same name as the
|
|
|
|
# case_list_file, with "-results.txt" appended. CTS will also output several
|
|
|
|
# working temporary files into the directory holding this script.
|
|
|
|
#
|
|
|
|
# --cts path
|
|
|
|
# The path to the directory containing the built CTS executable.
|
|
|
|
# If this parameter is not provided, it defaults to:
|
|
|
|
# "../../VK-GL-CTS/build/external/vulkancts/modules/vulkan/Debug".
|
2021-09-30 13:45:54 -04:00
|
|
|
#
|
2021-06-22 19:45:24 -04:00
|
|
|
# -p
|
|
|
|
# Same as the --portability option.
|
|
|
|
#
|
|
|
|
# --portability
|
|
|
|
# Indicates that this testing is for testing conformance with the
|
|
|
|
# Vulkan Portability initiative. MoltenVK will advertise support for
|
|
|
|
# only Vulkan 1.0, and only the following extensions:
|
|
|
|
# VK_KHR_get_physical_device_properties2
|
|
|
|
# VK_KHR_portability_subset
|
|
|
|
#
|
|
|
|
|
|
|
|
cts_vk_dir="../../VK-GL-CTS/build/external/vulkancts/modules/vulkan/Debug"
|
|
|
|
caselist_file=""
|
|
|
|
results_file=""
|
|
|
|
is_portability=""
|
|
|
|
|
|
|
|
while (( "$#" )); do
|
|
|
|
case "$1" in
|
|
|
|
-o)
|
|
|
|
results_file="${2}"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
--cts)
|
|
|
|
cts_vk_dir="${2}"
|
|
|
|
shift 2
|
|
|
|
;;
|
2021-06-24 08:27:28 -04:00
|
|
|
-p | --portability)
|
2021-06-22 19:45:24 -04:00
|
|
|
is_portability="Y"
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
-*|--*=)
|
|
|
|
echo "Error: Unsupported option $1. See usage instructions in body of this script." >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
caselist_file="${1}"
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "${caselist_file}" == "" ]; then
|
|
|
|
echo "Error: No caselist file specified. See usage instructions in body of this script." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${results_file}" == "" ]; then
|
|
|
|
results_file="${caselist_file}-results.txt"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# -------------- MoltenVK configuration --------------------
|
|
|
|
|
2021-06-24 08:27:28 -04:00
|
|
|
# As documented above, the portability option restricts to Vulkan 1.0 and a very limited set of extensions.
|
2023-12-13 18:26:42 -05:00
|
|
|
# The values used here are documented in MoltenVK_Configuration_Parameters.md.
|
|
|
|
# - MVK_CONFIG_API_VERSION_TO_ADVERTISE = 4194304 (VK_API_VERSION_1_0).
|
|
|
|
# - MVK_CONFIG_ADVERTISE_EXTENSIONS = 4 (VK_KHR_portability_subset and prerequistes).
|
2021-06-22 19:45:24 -04:00
|
|
|
if [ "${is_portability}" != "" ]; then
|
|
|
|
export MVK_CONFIG_API_VERSION_TO_ADVERTISE=4194304
|
2023-12-13 18:26:42 -05:00
|
|
|
export MVK_CONFIG_ADVERTISE_EXTENSIONS=4
|
2021-06-22 19:45:24 -04:00
|
|
|
fi
|
|
|
|
|
2023-08-15 16:03:31 -04:00
|
|
|
# ----- System settings ------
|
|
|
|
export DYLD_LIBRARY_PATH="/usr/local/lib"
|
|
|
|
|
2023-03-03 10:39:26 -05:00
|
|
|
# ----- Metal validation settings ------
|
2021-06-22 19:45:24 -04:00
|
|
|
export METAL_DEVICE_WRAPPER_TYPE=1
|
|
|
|
export METAL_ERROR_MODE=3
|
|
|
|
export METAL_DEBUG_ERROR_MODE=3
|
|
|
|
|
|
|
|
# ----- MoltenVK config settings ------
|
2023-03-03 10:39:26 -05:00
|
|
|
export MVK_CONFIG_LOG_LEVEL=1 #(1 = Errors only, 3 = Info)
|
2023-09-11 20:14:23 -04:00
|
|
|
export MVK_CONFIG_DEBUG=0
|
2021-06-22 19:45:24 -04:00
|
|
|
|
2023-03-03 10:39:26 -05:00
|
|
|
# Additional MoltenVK configuration can be set here by editing below.
|
2023-12-13 18:26:42 -05:00
|
|
|
# The values used here are documented in MoltenVK_Configuration_Parameters.md.
|
2021-06-22 19:45:24 -04:00
|
|
|
export MVK_CONFIG_RESUME_LOST_DEVICE=1
|
2022-08-18 13:35:35 -04:00
|
|
|
export MVK_CONFIG_FAST_MATH_ENABLED=1
|
2021-06-22 19:45:24 -04:00
|
|
|
export MVK_CONFIG_FORCE_LOW_POWER_GPU=0
|
2023-03-03 10:39:26 -05:00
|
|
|
export MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=0 #(2 = VK_EXT_descriptor_indexing enabled)
|
|
|
|
export MVK_CONFIG_VK_SEMAPHORE_SUPPORT_STYLE=2 #(2 = MTLEvents always)
|
|
|
|
export MVK_CONFIG_SHADER_COMPRESSION_ALGORITHM=0 #(2 = ZLIB, 3 = LZ4)
|
|
|
|
export MVK_CONFIG_PERFORMANCE_TRACKING=0
|
Improve behavior of swapchain image presentation stalls caused by Metal regression.
In a recent Metal regression, Metal sometimes does not trigger the
[CAMetalDrawable addPresentedHandler:] callback on the final few (1-3)
CAMetalDrawable presentations, and retains internal memory associated
with these CAMetalDrawables. This does not occur for any CAMetalDrawable
presentations prior to those final few.
Most apps typically don't care much what happens after the last few
CAMetalDrawables are presented, and typically end shortly after that.
However, for some apps, such as Vulkan CTS WSI tests, which serially create
potentially hundreds, or thousands, of CAMetalLayers and MTLDevices,these
retained device memory allocations can pile up and cause the CTS WSI tests
to stall, block, or crash.
This issue has proven very difficult to debug, or replicate in incrementally
controlled environments. It appears consistently in some scenarios, and never
in other, almost identical scenarios.
For example, the MoltenVK Cube demo consistently runs without encountering
this issue, but CTS WSI test dEQP-VK.wsi.macos.swapchain.render.basic
consistently triggers the issue. Both apps run almost identical Vulkan
command paths, and identical swapchain image presentation paths, and
result in GPU captures that have identical swapchain image presentations.
We may ultimately have to wait for Apple to fix the core issue, but this
update includes workarounds that helps in some cases. During vkQueueWaitIdle()
and vkDeviceWaitIdle(), wait a short while for any in-flight swapchain image
presentations to finish, and attempt to force completion by calling
MVKPresentableSwapchainImage::forcePresentationCompletion(), which releases
the current CAMetalDrawable, and attempts to retrieve a new one, to trigger
the callback on the current CAMetalDrawable.
In exploring possible work-arounds for this issue, this update adds significant
structural improvements in the handling of swapchains, and quite a bit of new
performance and logging functionality that is useful for debugging purposes.
- Add several additional performance trackers, available via logging,
or the mvk_private_api.h API.
- Rename MVKPerformanceTracker members, and refactor performance result
collection, to support tracking and logging memory use, or other measurements,
in addition to just durations.
- Redefine MVKQueuePerformance to add tracking separate performance metrics for
MTLCommandBuffer retrieval, encoding, and execution, plus swapchain presentation.
- Add MVKDevicePerformance as part of MVKPerformanceStatistics to track device
information, including GPU device memory allocated, and update device memory
results whenever performance content is requested.
- Add MVKConfigActivityPerformanceLoggingStyle::
MVK_CONFIG_ACTIVITY_PERFORMANCE_LOGGING_STYLE_DEVICE_LIFETIME_ACCUMULATE
to accumulate performance and memory results across multiple serial
invocations of VkDevices, during the lifetime of the app process. This
is useful for accumulating performance results across multiple CTS tests.
- Log destruction of VkDevice, VkPhysicalDevice, and VkInstance, to bookend
the corresponding logs performed upon their creation.
- Include consumed GPU memory in log when VkPhysicalDevice is destroyed.
- Add mvkGetAvailableMTLDevicesArray() to support consistency when retrieving
MTLDevices available on the system.
- Add mvkVkCommandName() to generically map command use to a command name.
- MVKDevice:
- Support MTLPhysicalDevice.recommendedMaxWorkingSetSize on iOS & tvOS.
- Include available and consumed GPU memory in log of GPU device at
VkInstance creation time.
- MVKQueue:
- Add handleMTLCommandBufferError() to handle errors for all
MTLCommandBuffer executions.
- Track time to retrieve a MTLCommandBuffer.
- If MTLCommandBuffer could not be retrieved during queue submission,
report error, signal queue submission completion, and return
VK_ERROR_OUT_OF_POOL_MEMORY.
- waitIdle() simplify to use [MTLCommandBuffer waitUntilCompleted],
plus also wait for in-flight presentations to complete, and attempt
to force them to complete if they are stuck.
- MVKPresentableSwapchainImage:
- Don't track presenting MTLCommandBuffer.
- Add limit on number of attempts to retrieve a drawable, and report
VK_ERROR_OUT_OF_POOL_MEMORY if drawable cannot be retrieved.
- Return VkResult from acquireAndSignalWhenAvailable() to notify upstream
if MTLCommandBuffer could not be created.
- Track presentation time.
- Notify MVKQueue when presentation has completed.
- Add forcePresentationCompletion(), which releases the current
CAMetalDrawable, and attempts to retrieve a new one, to trigger the
callback on the current CAMetalDrawable. Called when a swapchain is
destroyed, or by queue if waiting for presentation to complete stalls,
- If destroyed while in flight, stop tracking swapchain and
don't notify when presentation completes.
- MVKSwapchain:
- Track active swapchain in MVKSurface to check oldSwapchain
- Track MVKSurface to access layer and detect lost surface.
- Don't track layer and layer observer, since MVKSurface handles these.
- On destruction, wait until all in-flight presentable images have returned.
- Remove empty and unused releaseUndisplayedSurfaces() function.
- MVKSurface:
- Consolidate constructors into initLayer() function.
- Update logic to test for valid layer and to set up layer observer.
- MVKSemaphoreImpl:
- Add getReservationCount()
- MVKBaseObject:
- Add reportResult() and reportWarning() functions to support logging
and reporting Vulkan results that are not actual errors.
- Rename MVKCommandUse::kMVKCommandUseEndCommandBuffer to
kMVKCommandUseBeginCommandBuffer, since that's where it is used.
- Update MVK_CONFIGURATION_API_VERSION and MVK_PRIVATE_API_VERSION to 38.
- Cube Demo support running a maximum number of frames.
2023-09-02 08:51:36 -04:00
|
|
|
export MVK_CONFIG_ACTIVITY_PERFORMANCE_LOGGING_STYLE=3 #(2 = Device lifetime, 3 = Process lifetime)
|
2021-06-22 19:45:24 -04:00
|
|
|
|
|
|
|
# -------------- Operation --------------------
|
|
|
|
|
|
|
|
echo Testing started at `date +%r`
|
|
|
|
start_time=${SECONDS}
|
|
|
|
|
|
|
|
"${cts_vk_dir}/deqp-vk" \
|
|
|
|
--deqp-archive-dir="${cts_vk_dir}/.." \
|
2023-11-06 16:56:06 -05:00
|
|
|
--deqp-log-filename="/dev/null" \
|
2021-06-22 19:45:24 -04:00
|
|
|
--deqp-log-images=disable \
|
|
|
|
--deqp-log-shader-sources=disable \
|
2023-11-06 16:56:06 -05:00
|
|
|
--deqp-shadercache=disable \
|
|
|
|
--deqp-log-decompiled-spirv=disable \
|
|
|
|
--deqp-log-flush=disable \
|
2021-06-22 19:45:24 -04:00
|
|
|
--deqp-caselist-file="${caselist_file}" \
|
|
|
|
&> "${results_file}"
|
|
|
|
|
|
|
|
echo Testing complete in $(($SECONDS - $start_time)) seconds
|