layers: Remove wrapping of GPU objects by loader and layers
Loader only wraps GPU objects for creating a layer chain. After layer activation
layers and loader use unwrapped gpu object returned by the driver.
This is a large simplification.
This fixes a nasty bug where layers intercepting entrypoints with gpu objects
but not all these entrypoints would fail. These would cause non-uniform
unwrapping of gpu objects by the time the driver was called with a gpu object.
Fixes issue in loader_get_icd where it was trying to compare a wrapped GPU
against a non-wrapped GPU.
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp
index cb3e683..1de84b1 100644
--- a/layers/draw_state.cpp
+++ b/layers/draw_state.cpp
@@ -1443,10 +1443,9 @@
VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- pCurObj = gpuw;
+ pCurObj = (VkBaseLayerObject *) gpu;
loader_platform_thread_once(&g_initOnce, initDrawState);
- VkResult result = nextTable.CreateDevice((VkPhysicalGpu)gpuw->nextObject, pCreateInfo, pDevice);
+ VkResult result = nextTable.CreateDevice(gpu, pCreateInfo, pDevice);
return result;
}
@@ -1469,8 +1468,8 @@
VK_LAYER_EXPORT VkResult VKAPI vkGetExtensionSupport(VkPhysicalGpu gpu, const char* pExtName)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
VkResult result;
+
/* This entrypoint is NOT going to init its own dispatch table since loader calls here early */
if (!strcmp(pExtName, "DrawState") || !strcmp(pExtName, "drawStateDumpDotFile") ||
!strcmp(pExtName, "drawStateDumpCommandBufferDotFile") || !strcmp(pExtName, "drawStateDumpPngFile"))
@@ -1478,9 +1477,8 @@
result = VK_SUCCESS;
} else if (nextTable.GetExtensionSupport != NULL)
{
- result = nextTable.GetExtensionSupport((VkPhysicalGpu)gpuw->nextObject, pExtName);
- } else
- {
+ result = nextTable.GetExtensionSupport(gpu, pExtName);
+ } else {
result = VK_ERROR_INVALID_EXTENSION;
}
return result;
@@ -1490,13 +1488,11 @@
{
if (gpu != NULL)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- pCurObj = gpuw;
+ pCurObj = (VkBaseLayerObject *) gpu;
loader_platform_thread_once(&g_initOnce, initDrawState);
- VkResult result = nextTable.EnumerateLayers((VkPhysicalGpu)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
+ VkResult result = nextTable.EnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
return result;
- } else
- {
+ } else {
if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL)
return VK_ERROR_INVALID_POINTER;
// This layer compatible with all GPUs