void debug_report_create_instance(struct loader_instance *ptr_instance,
const VkInstanceCreateInfo *pCreateInfo) {
- ptr_instance->debug_report_enabled = false;
+ ptr_instance->enabled_known_extensions.ext_debug_report = 0;
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == 0) {
- ptr_instance->debug_report_enabled = true;
+ ptr_instance->enabled_known_extensions.ext_debug_report = 1;
return;
}
}
return VK_SUCCESS;
}
-static VKAPI_ATTR VkResult VKAPI_CALL debug_report_CreateDebugReportCallback(
- VkInstance instance, VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
- VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback) {
+static VKAPI_ATTR VkResult VKAPI_CALL debug_report_CreateDebugReportCallbackEXT(
+ VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkDebugReportCallbackEXT *pCallback) {
struct loader_instance *inst = loader_get_instance(instance);
loader_platform_thread_lock_mutex(&loader_lock);
VkResult result = inst->disp->CreateDebugReportCallbackEXT(
}
static VKAPI_ATTR void VKAPI_CALL
-debug_report_DestroyDebugReportCallback(VkInstance instance,
- VkDebugReportCallbackEXT callback,
- VkAllocationCallbacks *pAllocator) {
+debug_report_DestroyDebugReportCallbackEXT(
+ VkInstance instance, VkDebugReportCallbackEXT callback,
+ const VkAllocationCallbacks *pAllocator) {
struct loader_instance *inst = loader_get_instance(instance);
loader_platform_thread_lock_mutex(&loader_lock);
loader_platform_thread_unlock_mutex(&loader_lock);
}
-static VKAPI_ATTR void VKAPI_CALL debug_report_DebugReportMessage(
+static VKAPI_ATTR void VKAPI_CALL debug_report_DebugReportMessageEXT(
VkInstance instance, VkDebugReportFlagsEXT flags,
VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location,
int32_t msgCode, const char *pLayerPrefix, const char *pMsg) {
*addr = NULL;
if (!strcmp("vkCreateDebugReportCallbackEXT", name)) {
- *addr = ptr_instance->debug_report_enabled
- ? (void *)debug_report_CreateDebugReportCallback
+ *addr = (ptr_instance->enabled_known_extensions.ext_debug_report == 1)
+ ? (void *)debug_report_CreateDebugReportCallbackEXT
: NULL;
return true;
}
if (!strcmp("vkDestroyDebugReportCallbackEXT", name)) {
- *addr = ptr_instance->debug_report_enabled
- ? (void *)debug_report_DestroyDebugReportCallback
+ *addr = (ptr_instance->enabled_known_extensions.ext_debug_report == 1)
+ ? (void *)debug_report_DestroyDebugReportCallbackEXT
: NULL;
return true;
}
if (!strcmp("vkDebugReportMessageEXT", name)) {
- *addr = ptr_instance->debug_report_enabled
- ? (void *)debug_report_DebugReportMessage
+ *addr = (ptr_instance->enabled_known_extensions.ext_debug_report == 1)
+ ? (void *)debug_report_DebugReportMessageEXT
: NULL;
return true;
}
#include "extensions.h"
#include <vulkan/vk_icd.h>
- // Definitions for the VK_NV_external_memory_capabilities extension
+// Definitions for EXT_debug_marker extension
+
+VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectTagEXT(
+ VkDevice device, VkDebugMarkerObjectTagInfoEXT *pTagInfo) {
+ struct loader_dev_dispatch_table *disp = loader_get_dev_dispatch(device);
+ if (0 == disp->enabled_known_extensions.ext_debug_marker ||
+ NULL == disp->core_dispatch.DebugMarkerSetObjectTagEXT) {
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ } else {
+ return disp->core_dispatch.DebugMarkerSetObjectTagEXT(device, pTagInfo);
+ }
+}
+
+VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectNameEXT(
+ VkDevice device, VkDebugMarkerObjectNameInfoEXT *pNameInfo) {
+ struct loader_dev_dispatch_table *disp = loader_get_dev_dispatch(device);
+ if (0 == disp->enabled_known_extensions.ext_debug_marker ||
+ NULL == disp->core_dispatch.DebugMarkerSetObjectNameEXT) {
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ } else {
+ return disp->core_dispatch.DebugMarkerSetObjectNameEXT(device,
+ pNameInfo);
+ }
+}
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerBeginEXT(
+ VkCommandBuffer commandBuffer, VkDebugMarkerMarkerInfoEXT *pMarkerInfo) {
+ struct loader_dev_dispatch_table *disp =
+ loader_get_dev_dispatch(commandBuffer);
+ if (1 == disp->enabled_known_extensions.ext_debug_marker &&
+ NULL != disp->core_dispatch.CmdDebugMarkerBeginEXT) {
+ disp->core_dispatch.CmdDebugMarkerBeginEXT(commandBuffer, pMarkerInfo);
+ }
+}
+
+VKAPI_ATTR void VKAPI_CALL
+vkCmdDebugMarkerEndEXT(VkCommandBuffer commandBuffer) {
+ struct loader_dev_dispatch_table *disp =
+ loader_get_dev_dispatch(commandBuffer);
+ if (1 == disp->enabled_known_extensions.ext_debug_marker &&
+ NULL != disp->core_dispatch.CmdDebugMarkerEndEXT) {
+ disp->core_dispatch.CmdDebugMarkerEndEXT(commandBuffer);
+ }
+}
-static const VkExtensionProperties
- nv_external_memory_capabilities_extension_info = {
- .extensionName = VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME,
- .specVersion = VK_NV_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION,
-};
+VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerInsertEXT(
+ VkCommandBuffer commandBuffer, VkDebugMarkerMarkerInfoEXT *pMarkerInfo) {
+ struct loader_dev_dispatch_table *disp =
+ loader_get_dev_dispatch(commandBuffer);
+ if (1 == disp->enabled_known_extensions.ext_debug_marker &&
+ NULL != disp->core_dispatch.CmdDebugMarkerInsertEXT) {
+ disp->core_dispatch.CmdDebugMarkerInsertEXT(commandBuffer, pMarkerInfo);
+ }
+}
+
+// Definitions for the VK_NV_external_memory_capabilities extension
LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
vkGetPhysicalDeviceExternalImageFormatPropertiesNV(
VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) {
const VkLayerInstanceDispatchTable *disp;
+ struct loader_physical_device_tramp *phys_dev =
+ (struct loader_physical_device_tramp *)physicalDevice;
+ struct loader_instance *inst = phys_dev->this_instance;
VkPhysicalDevice unwrapped_phys_dev =
loader_unwrap_physical_device(physicalDevice);
disp = loader_get_instance_dispatch(physicalDevice);
- return disp->GetPhysicalDeviceExternalImageFormatPropertiesNV(
- unwrapped_phys_dev, format, type, tiling, usage, flags,
- externalHandleType, pExternalImageFormatProperties);
+ if (0 == inst->enabled_known_extensions.nv_external_memory_capabilities ||
+ NULL == disp->GetPhysicalDeviceExternalImageFormatPropertiesNV) {
+ loader_log(
+ inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
+ "vkGetPhysicalDeviceExternalImageFormatPropertiesNV called without"
+ " NV_external_memory_capabilities extension being enabled");
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ } else {
+ return disp->GetPhysicalDeviceExternalImageFormatPropertiesNV(
+ unwrapped_phys_dev, format, type, tiling, usage, flags,
+ externalHandleType, pExternalImageFormatProperties);
+ }
}
VKAPI_ATTR VkResult VKAPI_CALL
// Definitions for the VK_AMD_draw_indirect_count extension
-static const VkExtensionProperties amd_draw_indirect_count_extension_info = {
- .extensionName = VK_AMD_EXTENSION_DRAW_INDIRECT_COUNT_EXTENSION_NAME,
- .specVersion = VK_AMD_EXTENSION_DRAW_INDIRECT_COUNT_SPEC_VERSION,
-};
-
VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountAMD(
VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
uint32_t stride) {
- const VkLayerDispatchTable *disp;
-
- disp = loader_get_dispatch(commandBuffer);
- disp->CmdDrawIndirectCountAMD(commandBuffer, buffer, offset, countBuffer,
- countBufferOffset, maxDrawCount, stride);
+ struct loader_dev_dispatch_table *disp =
+ loader_get_dev_dispatch(commandBuffer);
+ if (1 == disp->enabled_known_extensions.amd_draw_indirect_count &&
+ NULL != disp->core_dispatch.CmdDrawIndirectCountAMD) {
+ disp->core_dispatch.CmdDrawIndirectCountAMD(
+ commandBuffer, buffer, offset, countBuffer, countBufferOffset,
+ maxDrawCount, stride);
+ }
}
VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountAMD(
VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
uint32_t stride) {
- const VkLayerDispatchTable *disp;
-
- disp = loader_get_dispatch(commandBuffer);
- disp->CmdDrawIndexedIndirectCountAMD(commandBuffer, buffer, offset,
- countBuffer, countBufferOffset,
- maxDrawCount, stride);
+ struct loader_dev_dispatch_table *disp =
+ loader_get_dev_dispatch(commandBuffer);
+ if (1 == disp->enabled_known_extensions.amd_draw_indirect_count &&
+ NULL != disp->core_dispatch.CmdDrawIndexedIndirectCountAMD) {
+ disp->core_dispatch.CmdDrawIndexedIndirectCountAMD(
+ commandBuffer, buffer, offset, countBuffer, countBufferOffset,
+ maxDrawCount, stride);
+ }
}
#ifdef VK_USE_PLATFORM_WIN32_KHR
// Definitions for the VK_NV_external_memory_win32 extension
-static const VkExtensionProperties nv_external_memory_win32_extension_info = {
- .extensionName = VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME,
- .specVersion = VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION,
-};
-
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV(
VkDevice device, VkDeviceMemory memory,
VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE *pHandle) {
- const VkLayerDispatchTable *disp;
-
- disp = loader_get_dispatch(device);
- return disp->GetMemoryWin32HandleNV(device, memory, handleType, pHandle);
+ struct loader_dev_dispatch_table *disp = loader_get_dev_dispatch(device);
+ if (0 == disp->enabled_known_extensions.nv_external_memory_win32 ||
+ NULL == disp->core_dispatch.GetMemoryWin32HandleNV) {
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ } else {
+ return disp->core_dispatch.GetMemoryWin32HandleNV(device, memory,
+ handleType, pHandle);
+ }
}
#endif // VK_USE_PLATFORM_WIN32_KHR
const char *name, void **addr) {
*addr = NULL;
+ // Functions for the EXT_debug_marker extension
+
+ if (!strcmp("vkDebugMarkerSetObjectTagEXT", name)) {
+ *addr = (void *)vkDebugMarkerSetObjectTagEXT;
+ return true;
+ }
+ if (!strcmp("vkDebugMarkerSetObjectNameEXT", name)) {
+ *addr = (void *)vkDebugMarkerSetObjectNameEXT;
+ return true;
+ }
+ if (!strcmp("vkCmdDebugMarkerBeginEXT", name)) {
+ *addr = (void *)vkCmdDebugMarkerBeginEXT;
+ return true;
+ }
+ if (!strcmp("vkCmdDebugMarkerEndEXT", name)) {
+ *addr = (void *)vkCmdDebugMarkerEndEXT;
+ return true;
+ }
+ if (!strcmp("vkCmdDebugMarkerInsertEXT", name)) {
+ *addr = (void *)vkCmdDebugMarkerInsertEXT;
+ return true;
+ }
+
// Functions for the VK_NV_external_memory_capabilities extension
if (!strcmp("vkGetPhysicalDeviceExternalImageFormatPropertiesNV", name)) {
- *addr = (void *)vkGetPhysicalDeviceExternalImageFormatPropertiesNV;
+ *addr = (ptr_instance->enabled_known_extensions
+ .nv_external_memory_capabilities == 1)
+ ? (void *)vkGetPhysicalDeviceExternalImageFormatPropertiesNV
+ : NULL;
return true;
}
void extensions_create_instance(struct loader_instance *ptr_instance,
const VkInstanceCreateInfo *pCreateInfo) {
+ ptr_instance->enabled_known_extensions.nv_external_memory_capabilities = 0;
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME) == 0) {
- // Nothing to do;
+ ptr_instance->enabled_known_extensions
+ .nv_external_memory_capabilities = 1;
+ return;
+ }
+ }
+}
+
+void extensions_create_device(struct loader_device *dev,
+ const VkDeviceCreateInfo *pCreateInfo) {
+ dev->loader_dispatch.enabled_known_extensions.ext_debug_marker = 0;
+ dev->loader_dispatch.enabled_known_extensions.amd_draw_indirect_count = 0;
+ dev->loader_dispatch.enabled_known_extensions.nv_external_memory_win32 = 0;
+
+ for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
+ VK_EXT_DEBUG_MARKER_EXTENSION_NAME) == 0) {
+ dev->loader_dispatch.enabled_known_extensions.ext_debug_marker = 1;
return;
}
if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
VK_AMD_EXTENSION_DRAW_INDIRECT_COUNT_EXTENSION_NAME) == 0) {
- // Nothing to do;
+ dev->loader_dispatch.enabled_known_extensions
+ .amd_draw_indirect_count = 1;
return;
}
#ifdef VK_USE_PLATFORM_WIN32_KHR
if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME) == 0) {
- // Nothing to do;
+ dev->loader_dispatch.enabled_known_extensions
+ .nv_external_memory_win32 = 1;
return;
}
#endif // VK_USE_PLATFORM_WIN32_KHR
#include "loader.h"
bool extension_instance_gpa(struct loader_instance *ptr_instance,
- const char *name, void **addr);
+ const char *name, void **addr);
void extensions_create_instance(struct loader_instance *ptr_instance,
const VkInstanceCreateInfo *pCreateInfo);
+void extensions_create_device(struct loader_device *dev,
+ const VkDeviceCreateInfo *pCreateInfo);
+
// Definitions for the VK_NV_external_memory_capabilities extension
VKAPI_ATTR VkResult VKAPI_CALL
if (pAllocator) {
dev->alloc_callbacks = *pAllocator;
}
- if (NULL != dev->app_extension_props) {
- loader_device_heap_free(dev, dev->app_extension_props);
- }
if (NULL != dev->activated_layer_list.list) {
loader_deactivate_layers(inst, dev, &dev->activated_layer_list);
}
}
}
+ extensions_create_device(dev, pCreateInfo);
+
// TODO: Why does fpCreateDevice behave differently than
// this_icd->CreateDevice?
// VkResult res = fpCreateDevice(phys_dev->phys_dev, &localCreateInfo,
PFN_vkDevExt dev_ext[MAX_NUM_DEV_EXTS];
};
+union loader_device_extension_enables {
+ struct {
+ uint8_t ext_debug_marker : 1;
+ uint8_t amd_draw_indirect_count : 1;
+ uint8_t nv_external_memory_win32 : 1;
+ };
+ uint64_t padding[4];
+};
+
struct loader_dev_dispatch_table {
VkLayerDispatchTable core_dispatch;
struct loader_dev_ext_dispatch_table ext_dispatch;
+ union loader_device_extension_enables enabled_known_extensions;
};
-/* per CreateDevice structure */
+// per CreateDevice structure
struct loader_device {
struct loader_dev_dispatch_table loader_dispatch;
VkDevice device; // device object from the icd
- uint32_t app_extension_count;
- VkExtensionProperties *app_extension_props;
-
struct loader_layer_list activated_layer_list;
VkAllocationCallbacks alloc_callbacks;
struct loader_icd *next;
};
-/* per ICD library structure */
+// per ICD library structure
struct loader_icd_libs {
size_t capacity;
uint32_t count;
struct loader_scanned_icds *list;
};
-/* per instance structure */
+union loader_instance_extension_enables {
+ struct {
+ uint8_t ext_debug_report : 1;
+ uint8_t nv_external_memory_capabilities : 1;
+ };
+ uint64_t padding[4];
+};
+
+// per instance structure
struct loader_instance {
VkLayerInstanceDispatchTable *disp; // must be first entry in structure
struct loader_icd *icds;
struct loader_instance *next;
struct loader_extension_list ext_list; // icds and loaders extensions
+ union loader_instance_extension_enables enabled_known_extensions;
struct loader_icd_libs icd_libs;
struct loader_layer_list instance_layer_list;
struct loader_dispatch_hash_entry disp_hash[MAX_NUM_DEV_EXTS];
bool activated_layers_are_std_val;
VkInstance instance; // layers/ICD instance returned to trampoline
- bool debug_report_enabled;
VkLayerDbgFunctionNode *DbgFunctionHead;
uint32_t num_tmp_callbacks;
VkDebugReportCallbackCreateInfoEXT *tmp_dbg_create_infos;
if sys.argv[1] == 'AllPlatforms':
extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface, ext_khr_xcb_surface,
ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface, ext_khr_display,
- ext_khr_android_surface, ext_amd_extension_draw_indirect_count,
- ext_nv_external_memory_capabilities, ext_nv_external_memory_win32,
- ext_khr_display_swapchain]
+ ext_khr_android_surface, ext_khr_display_swapchain]
extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface,
ext_khr_xcb_surface, ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface,
ext_khr_display, ext_khr_android_surface, ext_amd_extension_draw_indirect_count,
if len(sys.argv) > 3:
if (sys.platform.startswith('win32') or sys.platform.startswith('msys')) and sys.argv[1] != 'Android':
extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface,
- ext_khr_display, ext_amd_extension_draw_indirect_count,
- ext_nv_external_memory_capabilities, ext_nv_external_memory_win32,
- ext_khr_display_swapchain]
+ ext_khr_display, ext_khr_display_swapchain]
extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface,
ext_khr_display, ext_amd_extension_draw_indirect_count,
ext_nv_external_memory_capabilities, ext_nv_external_memory_win32,
elif sys.platform.startswith('linux') and sys.argv[1] != 'Android':
extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_xcb_surface,
ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface, ext_khr_display,
- ext_amd_extension_draw_indirect_count, ext_nv_external_memory_capabilities,
ext_khr_display_swapchain]
extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_xcb_surface,
ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface,
ext_debug_report, ext_debug_marker]
else: # android
extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_android_surface,
- ext_amd_extension_draw_indirect_count, ext_nv_external_memory_capabilities,
ext_khr_display_swapchain]
extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_android_surface,
ext_amd_extension_draw_indirect_count, ext_nv_external_memory_capabilities,
else :
if sys.argv[1] == 'Win32' or sys.argv[1] == 'msys':
extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface,
- ext_khr_display, ext_amd_extension_draw_indirect_count,
- ext_nv_external_memory_capabilities, ext_nv_external_memory_win32,
- ext_khr_display_swapchain]
+ ext_khr_display, ext_khr_display_swapchain]
extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_win32_surface,
ext_khr_display, ext_amd_extension_draw_indirect_count,
ext_nv_external_memory_capabilities, ext_nv_external_memory_win32,
ext_khr_display_swapchain, ext_debug_report, ext_debug_marker]
elif sys.argv[1] == 'Android':
extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_android_surface,
- ext_amd_extension_draw_indirect_count, ext_nv_external_memory_capabilities,
ext_khr_display_swapchain]
extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_android_surface,
ext_amd_extension_draw_indirect_count, ext_nv_external_memory_capabilities,
elif sys.argv[1] == 'Xcb' or sys.argv[1] == 'Xlib' or sys.argv[1] == 'Wayland' or sys.argv[1] == 'Mir' or sys.argv[1] == 'Display':
extensions = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_xcb_surface,
ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface,
- ext_khr_display, ext_amd_extension_draw_indirect_count,
- ext_nv_external_memory_capabilities, ext_khr_display_swapchain]
+ ext_khr_display, ext_khr_display_swapchain]
extensions_all = [core, ext_khr_surface, ext_khr_device_swapchain, ext_khr_xcb_surface,
ext_khr_xlib_surface, ext_khr_wayland_surface, ext_khr_mir_surface,
ext_khr_display, ext_amd_extension_draw_indirect_count,