-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
layer: Use Vulkan-Utility-Libraries for dispatch tables
The Vulkan-Utility-Libraries now provides the necessary dispatch tables for the profiles layer. This removes the dependency on ValidationLayers. To accomplish the switch, the StringAPIVersion function was added locally, since it used to come from the ValidationLayers but is not currently available in the Utility-Libraries.
- Loading branch information
1 parent
5f0a98f
commit 8c8af0d
Showing
8 changed files
with
50 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,22 +19,26 @@ | |
* Author: Tobin Ehlis <[email protected]> | ||
*/ | ||
#include <assert.h> | ||
#include <sstream> | ||
#include <iomanip> | ||
#include <unordered_map> | ||
#include "generated/vk_dispatch_table_helper.h" | ||
#include "vulkan/utility/vul_dispatch_table.h" | ||
#include "vulkan/vk_layer.h" | ||
#include "vk_layer_table.h" | ||
static device_table_map tableMap; | ||
static instance_table_map tableInstanceMap; | ||
|
||
dispatch_key get_dispatch_key(const void *object) { return (dispatch_key) * (VulDeviceDispatchTable **)object; } | ||
|
||
// Map lookup must be thread safe | ||
VkLayerDispatchTable *device_dispatch_table(void *object) { | ||
VulDeviceDispatchTable *device_dispatch_table(void *object) { | ||
dispatch_key key = get_dispatch_key(object); | ||
device_table_map::const_iterator it = tableMap.find((void *)key); | ||
assert(it != tableMap.end() && "Not able to find device dispatch entry"); | ||
return it->second.get(); | ||
} | ||
|
||
VkLayerInstanceDispatchTable *instance_dispatch_table(void *object) { | ||
VulInstanceDispatchTable *instance_dispatch_table(void *object) { | ||
dispatch_key key = get_dispatch_key(object); | ||
instance_table_map::const_iterator it = tableInstanceMap.find((void *)key); | ||
assert(it != tableInstanceMap.end() && "Not able to find instance dispatch entry"); | ||
|
@@ -59,14 +63,14 @@ void destroy_device_dispatch_table(dispatch_key key) { destroy_dispatch_table(ta | |
|
||
void destroy_instance_dispatch_table(dispatch_key key) { destroy_dispatch_table(tableInstanceMap, key); } | ||
|
||
VkLayerDispatchTable *get_dispatch_table(device_table_map &map, void *object) { | ||
VulDeviceDispatchTable *get_dispatch_table(device_table_map &map, void *object) { | ||
dispatch_key key = get_dispatch_key(object); | ||
device_table_map::const_iterator it = map.find((void *)key); | ||
assert(it != map.end() && "Not able to find device dispatch entry"); | ||
return it->second.get(); | ||
} | ||
|
||
VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, void *object) { | ||
VulInstanceDispatchTable *get_dispatch_table(instance_table_map &map, void *object) { | ||
dispatch_key key = get_dispatch_key(object); | ||
instance_table_map::const_iterator it = map.find((void *)key); | ||
assert(it != map.end() && "Not able to find instance dispatch entry"); | ||
|
@@ -98,20 +102,20 @@ VkLayerDeviceCreateInfo *get_chain_info(const VkDeviceCreateInfo *pCreateInfo, V | |
* Device -> CommandBuffer or Queue | ||
* If use the object themselves as key to map then implies Create entrypoints have to be intercepted | ||
* and a new key inserted into map */ | ||
VkLayerInstanceDispatchTable *initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa, instance_table_map &map) { | ||
VkLayerInstanceDispatchTable *pTable; | ||
VulInstanceDispatchTable *initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa, instance_table_map &map) { | ||
VulInstanceDispatchTable *pTable; | ||
dispatch_key key = get_dispatch_key(instance); | ||
instance_table_map::const_iterator it = map.find((void *)key); | ||
|
||
if (it == map.end()) { | ||
auto table = std::make_unique<VkLayerInstanceDispatchTable>(); | ||
auto table = std::make_unique<VulInstanceDispatchTable>(); | ||
pTable = table.get(); | ||
map[(void *)key] = std::move(table); | ||
} else { | ||
return it->second.get(); | ||
} | ||
|
||
layer_init_instance_dispatch_table(instance, pTable, gpa); | ||
vulInitInstanceDispatchTable(instance, pTable, gpa); | ||
|
||
// Setup func pointers that are required but not externally exposed. These won't be added to the instance dispatch table by | ||
// default. | ||
|
@@ -120,28 +124,39 @@ VkLayerInstanceDispatchTable *initInstanceTable(VkInstance instance, const PFN_v | |
return pTable; | ||
} | ||
|
||
VkLayerInstanceDispatchTable *initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa) { | ||
VulInstanceDispatchTable *initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa) { | ||
return initInstanceTable(instance, gpa, tableInstanceMap); | ||
} | ||
|
||
VkLayerDispatchTable *initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa, device_table_map &map) { | ||
VkLayerDispatchTable *pTable; | ||
VulDeviceDispatchTable *initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa, device_table_map &map) { | ||
VulDeviceDispatchTable *pTable; | ||
dispatch_key key = get_dispatch_key(device); | ||
device_table_map::const_iterator it = map.find((void *)key); | ||
|
||
if (it == map.end()) { | ||
auto table = std::make_unique<VkLayerDispatchTable>(); | ||
auto table = std::make_unique<VulDeviceDispatchTable>(); | ||
pTable = table.get(); | ||
map[(void *)key] = std::move(table); | ||
} else { | ||
return it->second.get(); | ||
} | ||
|
||
layer_init_device_dispatch_table(device, pTable, gpa); | ||
vulInitDeviceDispatchTable(device, pTable, gpa); | ||
|
||
return pTable; | ||
} | ||
|
||
VkLayerDispatchTable *initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa) { | ||
VulDeviceDispatchTable *initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa) { | ||
return initDeviceTable(device, gpa, tableMap); | ||
} | ||
|
||
// Convert integer API version to a string | ||
std::string StringAPIVersion(uint32_t version) { | ||
std::stringstream version_name; | ||
if (version == 0) { | ||
return "<unrecognized>"; | ||
} | ||
version_name << VK_API_VERSION_MAJOR(version) << "." << VK_API_VERSION_MINOR(version) << "." << VK_API_VERSION_PATCH(version) | ||
<< " (0x" << std::setfill('0') << std::setw(8) << std::hex << version << ")"; | ||
return version_name.str(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters