Refactor terminator_EnumerateDeviceExtensionProperties
authorCharles Giessen <charles@lunarg.com>
Wed, 15 Mar 2023 23:59:07 +0000 (17:59 -0600)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Mon, 20 Mar 2023 15:35:26 +0000 (09:35 -0600)
commit889e6b7223f00e8e97742e482d05db5b962ed7ae
tree5127005a1f02f8c6906f5b3c0900e0380dfb757e
parenta1d42f321a2ed106a4e3765d1b1151cb69a4b9d4
Refactor terminator_EnumerateDeviceExtensionProperties

This refactor accomplishes 2 goals: Clean up the code, and speed it up greatly.

The previous code intermingled two distinct code paths into one, making the logic of the
function extremely difficult to tease out. The logic to handle querying the device
extensions of layers has always been in its own if block, but the logic to handle when the
app queries for the pPropertiesCount and the logic to fill out pProperties were intermingled.

The difficulty of terminator_EnumerateDeviceExtensionProperties is that it has to make sure
to provide the exact count of extensions whenever there are active implicit layers which add
extensions to the overall list. This is because apps do not expect the first call to return
a number larger than the real count.

The speedup mainly comes two changes:
* Only extensions from layers are de-duplicated - assume the driver list is already free of
duplicates, as our search is a brute force linear search of all extensions in the list.
* Do not allocate memory when filling out pProperties - when the app calls this function the
second time, we do not need any extra memory to perform the logic required.
loader/loader.c