From: Jon Ashburn Date: Thu, 17 Sep 2015 21:28:12 +0000 (-0600) Subject: layers: Move some fixed code into header files for APIDump and Generic X-Git-Tag: submit/tizen/20181227.054638~4890 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a147d979425f6cb6a5a32f5e6c645f94af3c726b;p=platform%2Fupstream%2FVulkan-Tools.git layers: Move some fixed code into header files for APIDump and Generic --- diff --git a/layers/apidump.h b/layers/apidump.h index 6905fbd8..7eba182a 100644 --- a/layers/apidump.h +++ b/layers/apidump.h @@ -24,10 +24,9 @@ * Authors: * Courtney Goeltzenleuchter */ +#pragma once -#ifndef GENERIC_H -#define GENERIC_H -#include "vkLayer.h" +#include "vk_layer.h" /* * This file contains static functions for the generated layer Generic @@ -53,6 +52,50 @@ static const VkLayerProperties layerDevProps[LAYER_DEV_PROPS_ARRAY_SIZE] = { } }; +struct devExts { + bool wsi_enabled; +}; + +struct instExts { + bool wsi_enabled; +}; + +static std::unordered_map deviceExtMap; +static std::unordered_map instanceExtMap; + +static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) +{ + uint32_t i; + VkLayerDispatchTable *pDisp = device_dispatch_table(device); + PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr; + pDisp->GetSurfacePropertiesKHR = (PFN_vkGetSurfacePropertiesKHR) gpa(device, "vkGetSurfacePropertiesKHR"); + pDisp->GetSurfaceFormatsKHR = (PFN_vkGetSurfaceFormatsKHR) gpa(device, "vkGetSurfaceFormatsKHR"); + pDisp->GetSurfacePresentModesKHR = (PFN_vkGetSurfacePresentModesKHR) gpa(device, "vkGetSurfacePresentModesKHR"); + pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR"); + pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) gpa(device, "vkDestroySwapchainKHR"); + pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) gpa(device, "vkGetSwapchainImagesKHR"); + pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) gpa(device, "vkAcquireNextImageKHR"); + pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR) gpa(device, "vkQueuePresentKHR"); -#endif // GENERIC_H + deviceExtMap[pDisp].wsi_enabled = false; + for (i = 0; i < pCreateInfo->extensionCount; i++) { + if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NAME) == 0) + deviceExtMap[pDisp].wsi_enabled = true; + + } +} + +static void createInstanceRegisterExtensions(const VkInstanceCreateInfo* pCreateInfo, VkInstance instance) +{ + uint32_t i; + VkLayerInstanceDispatchTable *pDisp = instance_dispatch_table(instance); + PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr; + pDisp->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR"); + instanceExtMap[pDisp].wsi_enabled = false; + for (i = 0; i < pCreateInfo->extensionCount; i++) { + if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) + instanceExtMap[pDisp].wsi_enabled = true; + + } +} diff --git a/layers/generic.h b/layers/generic.h index d74d9858..793281b8 100644 --- a/layers/generic.h +++ b/layers/generic.h @@ -51,6 +51,49 @@ static const VkLayerProperties deviceLayerProps[] = { } }; +struct devExts { + bool wsi_enabled; +}; +struct instExts { + bool wsi_enabled; +}; +static std::unordered_map deviceExtMap; +static std::unordered_map instanceExtMap; + +static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) +{ + uint32_t i; + VkLayerDispatchTable *pDisp = device_dispatch_table(device); + PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr; + pDisp->GetSurfacePropertiesKHR = (PFN_vkGetSurfacePropertiesKHR) gpa(device, "vkGetSurfacePropertiesKHR"); + pDisp->GetSurfaceFormatsKHR = (PFN_vkGetSurfaceFormatsKHR) gpa(device, "vkGetSurfaceFormatsKHR"); + pDisp->GetSurfacePresentModesKHR = (PFN_vkGetSurfacePresentModesKHR) gpa(device, "vkGetSurfacePresentModesKHR"); + pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR"); + pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) gpa(device, "vkDestroySwapchainKHR"); + pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) gpa(device, "vkGetSwapchainImagesKHR"); + pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) gpa(device, "vkAcquireNextImageKHR"); + pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR) gpa(device, "vkQueuePresentKHR"); + + deviceExtMap[pDisp].wsi_enabled = false; + for (i = 0; i < pCreateInfo->extensionCount; i++) { + if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NAME) == 0) + deviceExtMap[pDisp].wsi_enabled = true; + } +} + +static void createInstanceRegisterExtensions(const VkInstanceCreateInfo* pCreateInfo, VkInstance instance) +{ + uint32_t i; + VkLayerInstanceDispatchTable *pDisp = instance_dispatch_table(instance); + PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr; + pDisp->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR"); + instanceExtMap[pDisp].wsi_enabled = false; + for (i = 0; i < pCreateInfo->extensionCount; i++) { + if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) + instanceExtMap[pDisp].wsi_enabled = true; + + } +} #endif // GENERIC_H diff --git a/vk-layer-generate.py b/vk-layer-generate.py index d4a58a94..7fa0cdeb 100755 --- a/vk-layer-generate.py +++ b/vk-layer-generate.py @@ -609,48 +609,6 @@ class GenericLayerSubcommand(Subcommand): gen_header.append('#define LAYER_EXT_ARRAY_SIZE 1') gen_header.append('#define LAYER_DEV_EXT_ARRAY_SIZE 1') gen_header.append('static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(initOnce);') - gen_header.append('struct devExts {') - gen_header.append(' bool wsi_enabled;') - gen_header.append('};') - gen_header.append('struct instExts {') - gen_header.append(' bool wsi_enabled;') - gen_header.append('};') - gen_header.append('static std::unordered_map deviceExtMap;') - gen_header.append('static std::unordered_map instanceExtMap;') - gen_header.append('') - gen_header.append('static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device)') - gen_header.append('{') - gen_header.append(' uint32_t i;') - gen_header.append(' VkLayerDispatchTable *pDisp = device_dispatch_table(device);') - gen_header.append(' PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr;') - gen_header.append(' pDisp->GetSurfacePropertiesKHR = (PFN_vkGetSurfacePropertiesKHR) gpa(device, "vkGetSurfacePropertiesKHR");') - gen_header.append(' pDisp->GetSurfaceFormatsKHR = (PFN_vkGetSurfaceFormatsKHR) gpa(device, "vkGetSurfaceFormatsKHR");') - gen_header.append(' pDisp->GetSurfacePresentModesKHR = (PFN_vkGetSurfacePresentModesKHR) gpa(device, "vkGetSurfacePresentModesKHR");') - gen_header.append(' pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR");') - gen_header.append(' pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) gpa(device, "vkDestroySwapchainKHR");') - gen_header.append(' pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) gpa(device, "vkGetSwapchainImagesKHR");') - gen_header.append(' pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) gpa(device, "vkAcquireNextImageKHR");') - gen_header.append(' pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR) gpa(device, "vkQueuePresentKHR");\n') - gen_header.append(' deviceExtMap[pDisp].wsi_enabled = false;') - gen_header.append(' for (i = 0; i < pCreateInfo->extensionCount; i++) {') - gen_header.append(' if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NAME) == 0)') - gen_header.append(' deviceExtMap[pDisp].wsi_enabled = true;') - gen_header.append('') - gen_header.append(' }') - gen_header.append('}\n') - gen_header.append('static void createInstanceRegisterExtensions(const VkInstanceCreateInfo* pCreateInfo, VkInstance instance)') - gen_header.append('{') - gen_header.append(' uint32_t i;') - gen_header.append(' VkLayerInstanceDispatchTable *pDisp = instance_dispatch_table(instance);') - gen_header.append(' PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr;') - gen_header.append(' pDisp->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR");') - gen_header.append(' instanceExtMap[pDisp].wsi_enabled = false;') - gen_header.append(' for (i = 0; i < pCreateInfo->extensionCount; i++) {') - gen_header.append(' if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME) == 0)') - gen_header.append(' instanceExtMap[pDisp].wsi_enabled = true;') - gen_header.append('') - gen_header.append(' }') - gen_header.append('}') gen_header.append('') return "\n".join(gen_header) @@ -764,6 +722,7 @@ class APIDumpSubcommand(Subcommand): header_txt.append('#include "vk_layer_table.h"') header_txt.append('#include "vk_layer_extension_utils.h"') header_txt.append('#include ') + header_txt.append('#include "apidump.h"') header_txt.append('') header_txt.append('static std::ofstream fileStream;') header_txt.append('static std::string fileName = "vk_apidump.txt";') @@ -827,50 +786,6 @@ class APIDumpSubcommand(Subcommand): header_txt.append(' assert(maxTID < MAX_TID);') header_txt.append(' return retVal;') header_txt.append('}') - header_txt.append('struct devExts {') - header_txt.append(' bool wsi_enabled;') - header_txt.append('};') - header_txt.append('') - header_txt.append('struct instExts {') - header_txt.append(' bool wsi_enabled;') - header_txt.append('};') - header_txt.append('') - header_txt.append('static std::unordered_map deviceExtMap;') - header_txt.append('static std::unordered_map instanceExtMap;') - header_txt.append('') - header_txt.append('static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device)') - header_txt.append('{') - header_txt.append(' uint32_t i;') - header_txt.append(' VkLayerDispatchTable *pDisp = device_dispatch_table(device);') - header_txt.append(' PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr;') - header_txt.append(' pDisp->GetSurfacePropertiesKHR = (PFN_vkGetSurfacePropertiesKHR) gpa(device, "vkGetSurfacePropertiesKHR");') - header_txt.append(' pDisp->GetSurfaceFormatsKHR = (PFN_vkGetSurfaceFormatsKHR) gpa(device, "vkGetSurfaceFormatsKHR");') - header_txt.append(' pDisp->GetSurfacePresentModesKHR = (PFN_vkGetSurfacePresentModesKHR) gpa(device, "vkGetSurfacePresentModesKHR");') - header_txt.append(' pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR");') - header_txt.append(' pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) gpa(device, "vkDestroySwapchainKHR");') - header_txt.append(' pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) gpa(device, "vkGetSwapchainImagesKHR");') - header_txt.append(' pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) gpa(device, "vkAcquireNextImageKHR");') - header_txt.append(' pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR) gpa(device, "vkQueuePresentKHR");\n') - header_txt.append(' deviceExtMap[pDisp].wsi_enabled = false;') - header_txt.append(' for (i = 0; i < pCreateInfo->extensionCount; i++) {') - header_txt.append(' if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NAME) == 0)') - header_txt.append(' deviceExtMap[pDisp].wsi_enabled = true;') - header_txt.append('') - header_txt.append(' }') - header_txt.append('}\n') - header_txt.append('static void createInstanceRegisterExtensions(const VkInstanceCreateInfo* pCreateInfo, VkInstance instance)') - header_txt.append('{') - header_txt.append(' uint32_t i;') - header_txt.append(' VkLayerInstanceDispatchTable *pDisp = instance_dispatch_table(instance);') - header_txt.append(' PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr;') - header_txt.append(' pDisp->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR");') - header_txt.append(' instanceExtMap[pDisp].wsi_enabled = false;') - header_txt.append(' for (i = 0; i < pCreateInfo->extensionCount; i++) {') - header_txt.append(' if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME) == 0)') - header_txt.append(' instanceExtMap[pDisp].wsi_enabled = true;') - header_txt.append('') - header_txt.append(' }') - header_txt.append('}\n') header_txt.append('') header_txt.append('void interpret_memBarriers(const void* const* ppMemBarriers, uint32_t memBarrierCount)') header_txt.append('{')