Skip to content

Commit 36a9a03

Browse files
committed
Leave extension structs in place
1 parent cce3357 commit 36a9a03

File tree

3 files changed

+16
-70
lines changed

3 files changed

+16
-70
lines changed

docs/extension_support.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,22 @@ the `injectedExtensions` list, although the layer will probably want to cache
3535
this check to reduce performance overhead.
3636

3737
If the driver beneath the layer does not support the extension, the extended
38-
API parameters must be rewritten to remove the extension before passing down
38+
API parameters should be rewritten to remove the extension before passing down
3939
to the driver. User structure inputs to the Vulkan API are usually marked as
4040
`const`, so we must take a safe-struct copy which we can modify and pass
4141
that copy to the driver.
4242

43+
Note that Vulkan specifies that components must ignore structures in the
44+
`pNext` chain that they do not understand:
45+
46+
> Any component of the implementation (the loader, any enabled layers, and
47+
> drivers) must skip over, without processing (other than reading the `sType`
48+
> and `pNext` members) any extending structures in the chain not defined by
49+
> core versions or extensions supported by that component.
50+
51+
Any extension structures can therefore be left in-situ when being emulated, but
52+
any other API parameter modifications must be unpicked to hide the emulation.
53+
4354
## Common extension notes
4455

4556
This section is a set of brief notes about extensions that we have implemented,

layer_gpu_timeline/source/layer_device_functions_queue.cpp

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -131,37 +131,6 @@ static void checkManualFrameBoundary(
131131
}
132132
}
133133

134-
/**
135-
* @brief Remove emulated frame boundaries from the pNext chain.
136-
*
137-
* @param layer The layer context.
138-
* @param pSubmits The list of user-supplied submits.
139-
* @param submitCount The number of submits in the list.
140-
* @param safeSubmits Storage for allocated copies if we need to patch.
141-
* @param pSubmitsForCall Pointer passed to the API call.
142-
*/
143-
template <typename T, typename U>
144-
static void stripManualFrameBoundary(
145-
Device* layer,
146-
const T* pSubmits,
147-
uint32_t submitCount,
148-
std::vector<U>& safeSubmits,
149-
const T** pSubmitsForCall
150-
) {
151-
if (layer->isEmulatingExtFrameBoundary)
152-
{
153-
safeSubmits.reserve(submitCount);
154-
155-
for (uint32_t i = 0; i < submitCount; i++)
156-
{
157-
safeSubmits.emplace_back(pSubmits + i);
158-
vku::RemoveFromPnext(safeSubmits[i], VK_STRUCTURE_TYPE_FRAME_BOUNDARY_EXT);
159-
}
160-
161-
*pSubmitsForCall = reinterpret_cast<T*>(safeSubmits.data());
162-
}
163-
}
164-
165134
/* See Vulkan API for documentation. */
166135
template<>
167136
VKAPI_ATTR VkResult VKAPI_CALL layer_vkQueuePresentKHR<user_tag>(VkQueue queue, const VkPresentInfoKHR* pPresentInfo)
@@ -228,17 +197,9 @@ VKAPI_ATTR VkResult VKAPI_CALL
228197
checkManualFrameBoundary(layer, queue, submit.pNext, isLast, workloadVisitor);
229198
}
230199

231-
// Remove emulated frame boundaries
232-
const VkSubmitInfo* newSubmits = pSubmits;
233-
std::vector<vku::safe_VkSubmitInfo> safeSubmits;
234-
235-
stripManualFrameBoundary<VkSubmitInfo, vku::safe_VkSubmitInfo>(
236-
layer, pSubmits, submitCount,
237-
safeSubmits, &newSubmits);
238-
239200
// Release the lock to call into the driver
240201
lock.unlock();
241-
return layer->driver.vkQueueSubmit(queue, submitCount, newSubmits, fence);
202+
return layer->driver.vkQueueSubmit(queue, submitCount, pSubmits, fence);
242203
}
243204

244205
/* See Vulkan API for documentation. */
@@ -274,17 +235,9 @@ VKAPI_ATTR VkResult VKAPI_CALL
274235
checkManualFrameBoundary(layer, queue, submit.pNext, isLast, workloadVisitor);
275236
}
276237

277-
// Remove emulated frame boundaries
278-
const VkSubmitInfo2* newSubmits = pSubmits;
279-
std::vector<vku::safe_VkSubmitInfo2> safeSubmits;
280-
281-
stripManualFrameBoundary<VkSubmitInfo2, vku::safe_VkSubmitInfo2>(
282-
layer, pSubmits, submitCount,
283-
safeSubmits, &newSubmits);
284-
285238
// Release the lock to call into the driver
286239
lock.unlock();
287-
return layer->driver.vkQueueSubmit2(queue, submitCount, newSubmits, fence);
240+
return layer->driver.vkQueueSubmit2(queue, submitCount, pSubmits, fence);
288241
}
289242

290243
/* See Vulkan API for documentation. */
@@ -320,16 +273,9 @@ VKAPI_ATTR VkResult VKAPI_CALL
320273
checkManualFrameBoundary(layer, queue, submit.pNext, isLast, workloadVisitor);
321274
}
322275

323-
// Remove emulated frame boundaries
324-
const VkSubmitInfo2* newSubmits = pSubmits;
325-
std::vector<vku::safe_VkSubmitInfo2> safeSubmits;
326-
stripManualFrameBoundary<VkSubmitInfo2, vku::safe_VkSubmitInfo2>(
327-
layer, pSubmits, submitCount,
328-
safeSubmits, &newSubmits);
329-
330276
// Release the lock to call into the driver
331277
lock.unlock();
332-
return layer->driver.vkQueueSubmit2KHR(queue, submitCount, newSubmits, fence);
278+
return layer->driver.vkQueueSubmit2KHR(queue, submitCount, pSubmits, fence);
333279
}
334280

335281
/**
@@ -367,14 +313,7 @@ VKAPI_ATTR VkResult VKAPI_CALL layer_vkQueueBindSparse<user_tag>(
367313
}
368314
}
369315

370-
// Remove emulated frame boundaries
371-
const VkBindSparseInfo* newBindInfo = pBindInfo;
372-
std::vector<vku::safe_VkBindSparseInfo> safeInfos;
373-
stripManualFrameBoundary<VkBindSparseInfo, vku::safe_VkBindSparseInfo>(
374-
layer, pBindInfo, bindInfoCount,
375-
safeInfos, &newBindInfo);
376-
377316
// Release the lock to call into the driver
378317
lock.unlock();
379-
return layer->driver.vkQueueBindSparse(queue, bindInfoCount, newBindInfo, fence);
318+
return layer->driver.vkQueueBindSparse(queue, bindInfoCount, pBindInfo, fence);
380319
}

layer_gpu_timeline/source/layer_instance_functions.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ VKAPI_ATTR void VKAPI_CALL layer_vkGetPhysicalDeviceFeatures2<user_tag>(
8181
layer->driver.vkGetPhysicalDeviceFeatures2(physicalDevice, pFeatures);
8282

8383
// Patch the query response to show that it is supported
84-
// TODO: We should hide this when calling down to the driver, and then
85-
// copy results back to the user structure
8684
auto* ext = vku::FindStructInPNextChain<VkPhysicalDeviceFrameBoundaryFeaturesEXT>(pFeatures->pNext);
8785
if (ext)
8886
{
@@ -107,8 +105,6 @@ VKAPI_ATTR void VKAPI_CALL layer_vkGetPhysicalDeviceFeatures2KHR<user_tag>(
107105
layer->driver.vkGetPhysicalDeviceFeatures2KHR(physicalDevice, pFeatures);
108106

109107
// Patch the query response to show that it is supported
110-
// TODO: We should hide this when calling down to the driver, and then
111-
// copy results back to the user structure
112108
auto* ext = vku::FindStructInPNextChain<VkPhysicalDeviceFrameBoundaryFeaturesEXT>(pFeatures->pNext);
113109
if (ext)
114110
{

0 commit comments

Comments
 (0)