struct device_data {
VkInstance instance;
VkPhysicalDeviceProperties phy_device_props;
+ std::unordered_map<VkFormat, VkFormatProperties, std::hash<int> > format_properties_map;
};
static std::unordered_map<VkPhysicalDevice, struct device_data> device_profile_api_dev_data_map;
// device_profile_api Layer EXT APIs
typedef void(VKAPI_PTR *PFN_vkGetOriginalPhysicalDeviceLimitsEXT)(VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceLimits *limits);
-
typedef void(VKAPI_PTR *PFN_vkSetPhysicalDeviceLimitsEXT)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceLimits *newLimits);
+typedef void(VKAPI_PTR *PFN_vkGetOriginalPhysicalDeviceFormatPropertiesEXT)(VkPhysicalDevice physicalDevice, VkFormat format,
+ const VkFormatProperties *properties);
+typedef void(VKAPI_PTR *PFN_vkSetPhysicalDeviceFormatPropertiesEXT)(VkPhysicalDevice physicalDevice, VkFormat format,
+ const VkFormatProperties newProperties);
VKAPI_ATTR void VKAPI_CALL GetOriginalPhysicalDeviceLimitsEXT(VkPhysicalDevice physicalDevice, VkPhysicalDeviceLimits *orgLimits) {
std::lock_guard<std::mutex> lock(global_lock);
}
}
+VKAPI_ATTR void VKAPI_CALL GetOriginalPhysicalDeviceFormatPropertiesEXT(VkPhysicalDevice physicalDevice, VkFormat format,
+ VkFormatProperties *properties) {
+ std::lock_guard<std::mutex> lock(global_lock);
+ auto device_profile_api_data_it = device_profile_api_dev_data_map.find(physicalDevice);
+ if (device_profile_api_data_it != device_profile_api_dev_data_map.end()) {
+ layer_data *device_profile_data =
+ GetLayerDataPtr(get_dispatch_key(device_profile_api_dev_data_map[physicalDevice].instance), layer_data_map);
+ device_profile_data->instance_dispatch_table->GetPhysicalDeviceFormatProperties(physicalDevice, format, properties);
+ }
+}
+
+VKAPI_ATTR void VKAPI_CALL SetPhysicalDeviceFormatPropertiesEXT(VkPhysicalDevice physicalDevice, VkFormat format,
+ const VkFormatProperties newProperties) {
+ std::lock_guard<std::mutex> lock(global_lock);
+
+ // search if we got the device limits for this device and stored in device_profile_api layer
+ auto device_profile_api_data_it = device_profile_api_dev_data_map.find(physicalDevice);
+ if (device_profile_api_data_it != device_profile_api_dev_data_map.end()) {
+ memcpy(&(device_profile_api_dev_data_map[physicalDevice].format_properties_map[format]), &newProperties,
+ sizeof(VkFormatProperties));
+ }
+}
+
VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
VkInstance *pInstance) {
VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
}
}
+VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format,
+ VkFormatProperties *pProperties) {
+ {
+ std::lock_guard<std::mutex> lock(global_lock);
+
+ // Search if we got the device limits for this device and stored in device_profile_api layer
+ auto device_profile_api_data_it = device_profile_api_dev_data_map.find(physicalDevice);
+ if (device_profile_api_data_it != device_profile_api_dev_data_map.end()) {
+ auto device_format_map_it = device_profile_api_dev_data_map[physicalDevice].format_properties_map.find(format);
+ if (device_format_map_it != device_profile_api_dev_data_map[physicalDevice].format_properties_map.end()) {
+ memcpy(pProperties, &device_profile_api_dev_data_map[physicalDevice].format_properties_map[format],
+ sizeof(VkFormatProperties));
+ } else {
+ layer_data *device_profile_data =
+ GetLayerDataPtr(get_dispatch_key(device_profile_api_dev_data_map[physicalDevice].instance), layer_data_map);
+ device_profile_data->instance_dispatch_table->GetPhysicalDeviceFormatProperties(physicalDevice, format,
+ pProperties);
+ }
+ }
+ }
+}
+
static const VkLayerProperties device_profile_api_LayerProps = {
"VK_LAYER_LUNARG_device_profile_api", VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION), // specVersion
1, // implementationVersion
if (!strcmp(name, "vkSetPhysicalDeviceLimitsEXT")) return (PFN_vkVoidFunction)SetPhysicalDeviceLimitsEXT;
if (!strcmp(name, "vkGetOriginalPhysicalDeviceLimitsEXT")) return (PFN_vkVoidFunction)GetOriginalPhysicalDeviceLimitsEXT;
+ if (!strcmp(name, "vkSetPhysicalDeviceFormatPropertiesEXT")) return (PFN_vkVoidFunction)SetPhysicalDeviceFormatPropertiesEXT;
+ if (!strcmp(name, "vkGetOriginalPhysicalDeviceFormatPropertiesEXT"))
+ return (PFN_vkVoidFunction)GetOriginalPhysicalDeviceFormatPropertiesEXT;
if (instance_dispatch_table(instance)->GetPhysicalDeviceProcAddr == NULL) return NULL;
return instance_dispatch_table(instance)->GetPhysicalDeviceProcAddr(instance, name);
if (!strcmp(name, "vkCreateInstance")) return (PFN_vkVoidFunction)CreateInstance;
if (!strcmp(name, "vkGetPhysicalDeviceProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceProperties;
+ if (!strcmp(name, "vkGetPhysicalDeviceFormatProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceFormatProperties;
if (!strcmp(name, "vkGetInstanceProcAddr")) return (PFN_vkVoidFunction)GetInstanceProcAddr;
if (!strcmp(name, "vkEnumerateInstanceExtensionProperties")) return (PFN_vkVoidFunction)EnumerateInstanceExtensionProperties;
if (!strcmp(name, "vkEnumerateInstanceLayerProperties")) return (PFN_vkVoidFunction)EnumerateInstanceLayerProperties;
if (!strcmp(name, "vkSetPhysicalDeviceLimitsEXT")) return (PFN_vkVoidFunction)SetPhysicalDeviceLimitsEXT;
if (!strcmp(name, "vkGetOriginalPhysicalDeviceLimitsEXT")) return (PFN_vkVoidFunction)GetOriginalPhysicalDeviceLimitsEXT;
+ if (!strcmp(name, "vkSetPhysicalDeviceFormatPropertiesEXT")) return (PFN_vkVoidFunction)SetPhysicalDeviceFormatPropertiesEXT;
+ if (!strcmp(name, "vkGetOriginalPhysicalDeviceFormatPropertiesEXT"))
+ return (PFN_vkVoidFunction)GetOriginalPhysicalDeviceFormatPropertiesEXT;
assert(instance);