Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5beb2ac5 authored by Chia-I Wu's avatar Chia-I Wu
Browse files

vulkan: use Logger in the generated code

Except for INIT_PROC, where ALOGE is still used for layer/HAL bugs.

Bug: 28120066
Change-Id: Icd9ce99b6bfb77816b11c05f6c8b197a6782b7cd
parent bc011fc4
Loading
Loading
Loading
Loading
+33 −28
Original line number Original line Diff line number Diff line
@@ -51,56 +51,56 @@ namespace {


// clang-format off
// clang-format off


VKAPI_ATTR void disabledDestroySurfaceKHR(VkInstance, VkSurfaceKHR, const VkAllocationCallbacks*) {
VKAPI_ATTR void disabledDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR, const VkAllocationCallbacks*) {
    ALOGE("VK_KHR_surface not enabled. vkDestroySurfaceKHR not executed.");
    driver::Logger(instance).Err(instance, "VK_KHR_surface not enabled. Exported vkDestroySurfaceKHR not executed.");
}
}


VKAPI_ATTR VkResult disabledGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice, uint32_t, VkSurfaceKHR, VkBool32*) {
VKAPI_ATTR VkResult disabledGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t, VkSurfaceKHR, VkBool32*) {
    ALOGE("VK_KHR_surface not enabled. vkGetPhysicalDeviceSurfaceSupportKHR not executed.");
    driver::Logger(physicalDevice).Err(physicalDevice, "VK_KHR_surface not enabled. Exported vkGetPhysicalDeviceSurfaceSupportKHR not executed.");
    return VK_SUCCESS;
    return VK_SUCCESS;
}
}


VKAPI_ATTR VkResult disabledGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice, VkSurfaceKHR, VkSurfaceCapabilitiesKHR*) {
VKAPI_ATTR VkResult disabledGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR, VkSurfaceCapabilitiesKHR*) {
    ALOGE("VK_KHR_surface not enabled. vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed.");
    driver::Logger(physicalDevice).Err(physicalDevice, "VK_KHR_surface not enabled. Exported vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed.");
    return VK_SUCCESS;
    return VK_SUCCESS;
}
}


VKAPI_ATTR VkResult disabledGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice, VkSurfaceKHR, uint32_t*, VkSurfaceFormatKHR*) {
VKAPI_ATTR VkResult disabledGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR, uint32_t*, VkSurfaceFormatKHR*) {
    ALOGE("VK_KHR_surface not enabled. vkGetPhysicalDeviceSurfaceFormatsKHR not executed.");
    driver::Logger(physicalDevice).Err(physicalDevice, "VK_KHR_surface not enabled. Exported vkGetPhysicalDeviceSurfaceFormatsKHR not executed.");
    return VK_SUCCESS;
    return VK_SUCCESS;
}
}


VKAPI_ATTR VkResult disabledGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice, VkSurfaceKHR, uint32_t*, VkPresentModeKHR*) {
VKAPI_ATTR VkResult disabledGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR, uint32_t*, VkPresentModeKHR*) {
    ALOGE("VK_KHR_surface not enabled. vkGetPhysicalDeviceSurfacePresentModesKHR not executed.");
    driver::Logger(physicalDevice).Err(physicalDevice, "VK_KHR_surface not enabled. Exported vkGetPhysicalDeviceSurfacePresentModesKHR not executed.");
    return VK_SUCCESS;
    return VK_SUCCESS;
}
}


VKAPI_ATTR VkResult disabledCreateSwapchainKHR(VkDevice, const VkSwapchainCreateInfoKHR*, const VkAllocationCallbacks*, VkSwapchainKHR*) {
VKAPI_ATTR VkResult disabledCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR*, const VkAllocationCallbacks*, VkSwapchainKHR*) {
    ALOGE("VK_KHR_swapchain not enabled. vkCreateSwapchainKHR not executed.");
    driver::Logger(device).Err(device, "VK_KHR_swapchain not enabled. Exported vkCreateSwapchainKHR not executed.");
    return VK_SUCCESS;
    return VK_SUCCESS;
}
}


VKAPI_ATTR void disabledDestroySwapchainKHR(VkDevice, VkSwapchainKHR, const VkAllocationCallbacks*) {
VKAPI_ATTR void disabledDestroySwapchainKHR(VkDevice device, VkSwapchainKHR, const VkAllocationCallbacks*) {
    ALOGE("VK_KHR_swapchain not enabled. vkDestroySwapchainKHR not executed.");
    driver::Logger(device).Err(device, "VK_KHR_swapchain not enabled. Exported vkDestroySwapchainKHR not executed.");
}
}


VKAPI_ATTR VkResult disabledGetSwapchainImagesKHR(VkDevice, VkSwapchainKHR, uint32_t*, VkImage*) {
VKAPI_ATTR VkResult disabledGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR, uint32_t*, VkImage*) {
    ALOGE("VK_KHR_swapchain not enabled. vkGetSwapchainImagesKHR not executed.");
    driver::Logger(device).Err(device, "VK_KHR_swapchain not enabled. Exported vkGetSwapchainImagesKHR not executed.");
    return VK_SUCCESS;
    return VK_SUCCESS;
}
}


VKAPI_ATTR VkResult disabledAcquireNextImageKHR(VkDevice, VkSwapchainKHR, uint64_t, VkSemaphore, VkFence, uint32_t*) {
VKAPI_ATTR VkResult disabledAcquireNextImageKHR(VkDevice device, VkSwapchainKHR, uint64_t, VkSemaphore, VkFence, uint32_t*) {
    ALOGE("VK_KHR_swapchain not enabled. vkAcquireNextImageKHR not executed.");
    driver::Logger(device).Err(device, "VK_KHR_swapchain not enabled. Exported vkAcquireNextImageKHR not executed.");
    return VK_SUCCESS;
    return VK_SUCCESS;
}
}


VKAPI_ATTR VkResult disabledQueuePresentKHR(VkQueue, const VkPresentInfoKHR*) {
VKAPI_ATTR VkResult disabledQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR*) {
    ALOGE("VK_KHR_swapchain not enabled. vkQueuePresentKHR not executed.");
    driver::Logger(queue).Err(queue, "VK_KHR_swapchain not enabled. Exported vkQueuePresentKHR not executed.");
    return VK_SUCCESS;
    return VK_SUCCESS;
}
}


VKAPI_ATTR VkResult disabledCreateAndroidSurfaceKHR(VkInstance, const VkAndroidSurfaceCreateInfoKHR*, const VkAllocationCallbacks*, VkSurfaceKHR*) {
VKAPI_ATTR VkResult disabledCreateAndroidSurfaceKHR(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR*, const VkAllocationCallbacks*, VkSurfaceKHR*) {
    ALOGE("VK_KHR_android_surface not enabled. vkCreateAndroidSurfaceKHR not executed.");
    driver::Logger(instance).Err(instance, "VK_KHR_android_surface not enabled. Exported vkCreateAndroidSurfaceKHR not executed.");
    return VK_SUCCESS;
    return VK_SUCCESS;
}
}


@@ -304,7 +304,7 @@ VKAPI_ATTR VkResult vkEnumeratePhysicalDevices(VkInstance instance, uint32_t* pP
__attribute__((visibility("default")))
__attribute__((visibility("default")))
VKAPI_ATTR PFN_vkVoidFunction vkGetDeviceProcAddr(VkDevice device, const char* pName) {
VKAPI_ATTR PFN_vkVoidFunction vkGetDeviceProcAddr(VkDevice device, const char* pName) {
    if (device == VK_NULL_HANDLE) {
    if (device == VK_NULL_HANDLE) {
        ALOGE("vkGetDeviceProcAddr called with invalid device");
        ALOGE("invalid vkGetDeviceProcAddr(VK_NULL_HANDLE, ...) call");
        return nullptr;
        return nullptr;
    }
    }


@@ -342,7 +342,9 @@ VKAPI_ATTR PFN_vkVoidFunction vkGetDeviceProcAddr(VkDevice device, const char* p
        std::binary_search(
        std::binary_search(
            known_non_device_names, known_non_device_names + count, pName,
            known_non_device_names, known_non_device_names + count, pName,
            [](const char* a, const char* b) { return (strcmp(a, b) < 0); })) {
            [](const char* a, const char* b) { return (strcmp(a, b) < 0); })) {
        ALOGE("vkGetDeviceProcAddr called with %s", (pName) ? pName : "(null)");
        vulkan::driver::Logger(device).Err(
            device, "invalid vkGetDeviceProcAddr(%p, \"%s\") call", device,
            (pName) ? pName : "(null)");
        return nullptr;
        return nullptr;
    }
    }
    // clang-format off
    // clang-format off
@@ -356,12 +358,12 @@ VKAPI_ATTR PFN_vkVoidFunction vkGetDeviceProcAddr(VkDevice device, const char* p
__attribute__((visibility("default")))
__attribute__((visibility("default")))
VKAPI_ATTR PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance instance, const char* pName) {
VKAPI_ATTR PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance instance, const char* pName) {
    // global functions
    // global functions
    if (!instance) {
    if (instance == VK_NULL_HANDLE) {
        if (strcmp(pName, "vkCreateInstance") == 0) return reinterpret_cast<PFN_vkVoidFunction>(vulkan::api::CreateInstance);
        if (strcmp(pName, "vkCreateInstance") == 0) return reinterpret_cast<PFN_vkVoidFunction>(vulkan::api::CreateInstance);
        if (strcmp(pName, "vkEnumerateInstanceLayerProperties") == 0) return reinterpret_cast<PFN_vkVoidFunction>(vulkan::api::EnumerateInstanceLayerProperties);
        if (strcmp(pName, "vkEnumerateInstanceLayerProperties") == 0) return reinterpret_cast<PFN_vkVoidFunction>(vulkan::api::EnumerateInstanceLayerProperties);
        if (strcmp(pName, "vkEnumerateInstanceExtensionProperties") == 0) return reinterpret_cast<PFN_vkVoidFunction>(vulkan::api::EnumerateInstanceExtensionProperties);
        if (strcmp(pName, "vkEnumerateInstanceExtensionProperties") == 0) return reinterpret_cast<PFN_vkVoidFunction>(vulkan::api::EnumerateInstanceExtensionProperties);


        ALOGE("vkGetInstanceProcAddr called with %s without instance",  pName);
        ALOGE("invalid vkGetInstanceProcAddr(VK_NULL_HANDLE, \"%s\") call", pName);
        return nullptr;
        return nullptr;
    }
    }


@@ -510,8 +512,11 @@ VKAPI_ATTR PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance instance, const c
        hooks, hooks + count, pName,
        hooks, hooks + count, pName,
        [](const Hook& h, const char* n) { return strcmp(h.name, n) < 0; });
        [](const Hook& h, const char* n) { return strcmp(h.name, n) < 0; });
    if (hook < hooks + count && strcmp(hook->name, pName) == 0) {
    if (hook < hooks + count && strcmp(hook->name, pName) == 0) {
        if (!hook->proc)
        if (!hook->proc) {
            ALOGE("vkGetInstanceProcAddr called with %s with instance", pName);
            vulkan::driver::Logger(instance).Err(
                instance, "invalid vkGetInstanceProcAddr(%p, \"%s\") call",
                instance, pName);
        }
        return hook->proc;
        return hook->proc;
    }
    }
    // clang-format off
    // clang-format off
+21 −11
Original line number Original line Diff line number Diff line
@@ -482,10 +482,16 @@ bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
    {{$ext_name := index $ext.Arguments 0}}
    {{$ext_name := index $ext.Arguments 0}}


    {{$base := (Macro "BaseName" $)}}
    {{$base := (Macro "BaseName" $)}}
    {{$unnamed_params := (ForEach $.CallParameters "ParameterType" | JoinWith ", ")}}


    VKAPI_ATTR {{Node "Type" $.Return}} disabled{{$base}}({{$unnamed_params}}) {
    {{$p0 := (index $.CallParameters 0)}}
      ALOGE("{{$ext_name}} not enabled. {{$.Name}} not executed.");
    {{$ptail := (Tail 1 $.CallParameters)}}

    {{$first_type := (Macro "Parameter" $p0)}}
    {{$tail_types := (ForEach $ptail "ParameterType" | JoinWith ", ")}}

    VKAPI_ATTR {{Node "Type" $.Return}} disabled{{$base}}({{$first_type}}, {{$tail_types}}) {
      driver::Logger({{$p0.Name}}).Err({{$p0.Name}}, §
        "{{$ext_name}} not enabled. Exported {{$.Name}} not executed.");
      {{if not (IsVoid $.Return.Type)}}return VK_SUCCESS;{{end}}
      {{if not (IsVoid $.Return.Type)}}return VK_SUCCESS;{{end}}
    }
    }


@@ -502,7 +508,7 @@ bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
  {{AssertType $ "API"}}
  {{AssertType $ "API"}}


  // global functions
  // global functions
  if (!instance) {
  if (instance == VK_NULL_HANDLE) {
    {{range $f := AllCommands $}}
    {{range $f := AllCommands $}}
      {{if (Macro "IsGloballyDispatched" $f)}}
      {{if (Macro "IsGloballyDispatched" $f)}}
        if (strcmp(pName, "{{$f.Name}}") == 0) return §
        if (strcmp(pName, "{{$f.Name}}") == 0) return §
@@ -511,7 +517,7 @@ bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
      {{end}}
      {{end}}
    {{end}}
    {{end}}


    ALOGE("vkGetInstanceProcAddr called with %s without instance",  pName);
    ALOGE("invalid vkGetInstanceProcAddr(VK_NULL_HANDLE, \"%s\") call", pName);
    return nullptr;
    return nullptr;
  }
  }


@@ -549,8 +555,11 @@ bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
    hooks, hooks + count, pName,
    hooks, hooks + count, pName,
    [](const Hook& h, const char* n) { return strcmp(h.name, n) < 0; });
    [](const Hook& h, const char* n) { return strcmp(h.name, n) < 0; });
  if (hook <  hooks + count && strcmp(hook->name, pName) == 0) {
  if (hook <  hooks + count && strcmp(hook->name, pName) == 0) {
    if (!hook->proc)
    if (!hook->proc) {
      ALOGE("vkGetInstanceProcAddr called with %s with instance",  pName);
      vulkan::driver::Logger(instance).Err(
        instance, "invalid vkGetInstanceProcAddr(%p, \"%s\") call",
        instance, pName);
    }
    return hook->proc;
    return hook->proc;
  }
  }
  // clang-format off
  // clang-format off
@@ -567,7 +576,7 @@ bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
  {{AssertType $ "API"}}
  {{AssertType $ "API"}}


  if (device == VK_NULL_HANDLE) {
  if (device == VK_NULL_HANDLE) {
    ALOGE("vkGetDeviceProcAddr called with invalid device");
    ALOGE("invalid vkGetDeviceProcAddr(VK_NULL_HANDLE, ...) call");
    return nullptr;
    return nullptr;
  }
  }


@@ -587,7 +596,9 @@ bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
      std::binary_search(
      std::binary_search(
        known_non_device_names, known_non_device_names + count, pName,
        known_non_device_names, known_non_device_names + count, pName,
        [](const char* a, const char* b) { return (strcmp(a, b) < 0); })) {
        [](const char* a, const char* b) { return (strcmp(a, b) < 0); })) {
    ALOGE("vkGetDeviceProcAddr called with %s", (pName) ? pName : "(null)");
    vulkan::driver::Logger(device).Err(§
      device, "invalid vkGetDeviceProcAddr(%p, \"%s\") call", device,§
      (pName) ? pName : "(null)");
    return nullptr;
    return nullptr;
  }
  }
  // clang-format off
  // clang-format off
@@ -775,7 +786,6 @@ VK_KHR_swapchain
    {{$ext_name := index $ext.Arguments 0}}
    {{$ext_name := index $ext.Arguments 0}}


    {{$base := (Macro "BaseName" $)}}
    {{$base := (Macro "BaseName" $)}}
    {{$unnamed_params := (ForEach $.CallParameters "ParameterType" | JoinWith ", ")}}


    VKAPI_ATTR {{Node "Type" $.Return}} checked{{$base}}({{Macro "Parameters" $}}) {
    VKAPI_ATTR {{Node "Type" $.Return}} checked{{$base}}({{Macro "Parameters" $}}) {
      {{$p0 := index $.CallParameters 0}}
      {{$p0 := index $.CallParameters 0}}
@@ -785,7 +795,7 @@ VK_KHR_swapchain
        {{if not (IsVoid $.Return.Type)}}return §{{end}}
        {{if not (IsVoid $.Return.Type)}}return §{{end}}
        {{$base}}({{Macro "Arguments" $}});
        {{$base}}({{Macro "Arguments" $}});
      } else {
      } else {
        ALOGE("{{$ext_name}} not enabled. {{$.Name}} not executed.");
        Logger({{$p0.Name}}).Err({{$p0.Name}}, "{{$ext_name}} not enabled. {{$.Name}} not executed.");
        {{if not (IsVoid $.Return.Type)}}return VK_SUCCESS;{{end}}
        {{if not (IsVoid $.Return.Type)}}return VK_SUCCESS;{{end}}
      }
      }
    }
    }
+5 −5
Original line number Original line Diff line number Diff line
@@ -33,7 +33,7 @@ VKAPI_ATTR VkResult checkedCreateSwapchainKHR(VkDevice device, const VkSwapchain
    if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) {
    if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) {
        return CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
        return CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
    } else {
    } else {
        ALOGE("VK_KHR_swapchain not enabled. vkCreateSwapchainKHR not executed.");
        Logger(device).Err(device, "VK_KHR_swapchain not enabled. vkCreateSwapchainKHR not executed.");
        return VK_SUCCESS;
        return VK_SUCCESS;
    }
    }
}
}
@@ -42,7 +42,7 @@ VKAPI_ATTR void checkedDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapc
    if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) {
    if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) {
        DestroySwapchainKHR(device, swapchain, pAllocator);
        DestroySwapchainKHR(device, swapchain, pAllocator);
    } else {
    } else {
        ALOGE("VK_KHR_swapchain not enabled. vkDestroySwapchainKHR not executed.");
        Logger(device).Err(device, "VK_KHR_swapchain not enabled. vkDestroySwapchainKHR not executed.");
    }
    }
}
}


@@ -50,7 +50,7 @@ VKAPI_ATTR VkResult checkedGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR
    if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) {
    if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) {
        return GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
        return GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
    } else {
    } else {
        ALOGE("VK_KHR_swapchain not enabled. vkGetSwapchainImagesKHR not executed.");
        Logger(device).Err(device, "VK_KHR_swapchain not enabled. vkGetSwapchainImagesKHR not executed.");
        return VK_SUCCESS;
        return VK_SUCCESS;
    }
    }
}
}
@@ -59,7 +59,7 @@ VKAPI_ATTR VkResult checkedAcquireNextImageKHR(VkDevice device, VkSwapchainKHR s
    if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) {
    if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) {
        return AcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex);
        return AcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex);
    } else {
    } else {
        ALOGE("VK_KHR_swapchain not enabled. vkAcquireNextImageKHR not executed.");
        Logger(device).Err(device, "VK_KHR_swapchain not enabled. vkAcquireNextImageKHR not executed.");
        return VK_SUCCESS;
        return VK_SUCCESS;
    }
    }
}
}
@@ -68,7 +68,7 @@ VKAPI_ATTR VkResult checkedQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR
    if (GetData(queue).hook_extensions[ProcHook::KHR_swapchain]) {
    if (GetData(queue).hook_extensions[ProcHook::KHR_swapchain]) {
        return QueuePresentKHR(queue, pPresentInfo);
        return QueuePresentKHR(queue, pPresentInfo);
    } else {
    } else {
        ALOGE("VK_KHR_swapchain not enabled. vkQueuePresentKHR not executed.");
        Logger(queue).Err(queue, "VK_KHR_swapchain not enabled. vkQueuePresentKHR not executed.");
        return VK_SUCCESS;
        return VK_SUCCESS;
    }
    }
}
}