From a65963a5c7edcfd5e44f8d5102e8379ba86916ec Mon Sep 17 00:00:00 2001 From: Jon Ashburn Date: Wed, 8 Apr 2015 21:33:34 -0600 Subject: 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. --- loader/loader.c | 9 +++++++-- loader/loader.h | 9 --------- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'loader') diff --git a/loader/loader.c b/loader/loader.c index 648a2584..dc053761 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -520,11 +520,16 @@ static void loader_init_dispatch_table(VkLayerDispatchTable *tab, PFN_vkGetProcA extern struct loader_icd * loader_get_icd(const VkBaseLayerObject *gpu, uint32_t *gpu_index) { + /* + * NOTE: at this time icd->gpus is pointing to wrapped GPUs, but no where else + * are wrapped gpus used. Should go away. The incoming gpu is NOT wrapped so + * need to test it against the wrapped GPU's base object. + */ for (struct loader_instance *inst = loader.instances; inst; inst = inst->next) { for (struct loader_icd *icd = inst->icds; icd; icd = icd->next) { for (uint32_t i = 0; i < icd->gpu_count; i++) if ((icd->gpus + i) == gpu || (icd->gpus +i)->baseObject == - gpu->baseObject) { + gpu) { *gpu_index = i; return icd; } @@ -1000,7 +1005,7 @@ LOADER_EXPORT VkResult VKAPI vkEnumerateGpus( (wrapped_gpus + i)->baseObject = gpus[i]; (wrapped_gpus + i)->pGPA = get_proc_addr; (wrapped_gpus + i)->nextObject = gpus[i]; - memcpy(pGpus + count, &wrapped_gpus, sizeof(*pGpus)); + memcpy(pGpus + count, gpus, sizeof(*pGpus)); loader_init_dispatch_table(icd->loader_dispatch + i, get_proc_addr, gpus[i]); diff --git a/loader/loader.h b/loader/loader.h index 77c50c9a..0ff9a590 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -65,15 +65,6 @@ static inline void loader_init_data(void *obj, const void *data) loader_set_data(obj, data); } -static inline void *loader_unwrap_gpu(VkPhysicalGpu *gpu) -{ - const VkBaseLayerObject *wrap = (const VkBaseLayerObject *) *gpu; - - *gpu = (VkPhysicalGpu) wrap->nextObject; - - return loader_get_data(wrap->baseObject); -} - struct loader_instance { struct loader_icd *icds; struct loader_instance *next; -- cgit v1.2.3