Skip to content

Commit

Permalink
Merge branch 'KhronosGroup:main' into clang-tidy-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-lunarg authored Oct 1, 2024
2 parents e4923bc + fae9549 commit 2764fdf
Show file tree
Hide file tree
Showing 11 changed files with 326 additions and 52 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
uses: github/codeql-action/init@e2b3eafc8d227b0241d48be5f425d47c2d750a13 # v3.26.10
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -68,7 +68,7 @@ jobs:
# If this step fails, then you should remove it and run the build manually
- name: Autobuild
if: matrix.language == 'python'
uses: github/codeql-action/autobuild@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
uses: github/codeql-action/autobuild@e2b3eafc8d227b0241d48be5f425d47c2d750a13 # v3.26.10

- uses: actions/setup-python@v5
if: matrix.language == 'cpp'
Expand Down Expand Up @@ -96,6 +96,6 @@ jobs:
run: cmake --build build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
uses: github/codeql-action/analyze@e2b3eafc8d227b0241d48be5f425d47c2d750a13 # v3.26.10
with:
category: "/language:${{matrix.language}}"
12 changes: 8 additions & 4 deletions loader/debug_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ VkResult util_CreateDebugUtilsMessengers(struct loader_instance *inst, const voi
const VkAllocationCallbacks *pAllocator) {
const void *pNext = pChain;
while (pNext) {
if (((const VkBaseInStructure *)pNext)->sType == VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT) {
VkBaseInStructure in_structure = {0};
memcpy(&in_structure, pNext, sizeof(VkBaseInStructure));
if (in_structure.sType == VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT) {
// Assign a unique handle to each messenger (just use the address of the VkDebugUtilsMessengerCreateInfoEXT)
// This is only being used this way due to it being for an 'anonymous' callback during instance creation
VkDebugUtilsMessengerEXT messenger_handle = (VkDebugUtilsMessengerEXT)(uintptr_t)pNext;
Expand All @@ -140,7 +142,7 @@ VkResult util_CreateDebugUtilsMessengers(struct loader_instance *inst, const voi
return ret;
}
}
pNext = (void *)((VkBaseInStructure *)pNext)->pNext;
pNext = in_structure.pNext;
}
return VK_SUCCESS;
}
Expand Down Expand Up @@ -405,7 +407,9 @@ VkResult util_CreateDebugReportCallbacks(struct loader_instance *inst, const voi
const VkAllocationCallbacks *pAllocator) {
const void *pNext = pChain;
while (pNext) {
if (((VkBaseInStructure *)pNext)->sType == VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT) {
VkBaseInStructure in_structure = {0};
memcpy(&in_structure, pNext, sizeof(VkBaseInStructure));
if (in_structure.sType == VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT) {
// Assign a unique handle to each callback (just use the address of the VkDebugReportCallbackCreateInfoEXT):
// This is only being used this way due to it being for an 'anonymous' callback during instance creation
VkDebugReportCallbackEXT report_handle = (VkDebugReportCallbackEXT)(uintptr_t)pNext;
Expand All @@ -415,7 +419,7 @@ VkResult util_CreateDebugReportCallbacks(struct loader_instance *inst, const voi
return ret;
}
}
pNext = (void *)((VkBaseInStructure *)pNext)->pNext;
pNext = in_structure.pNext;
}
return VK_SUCCESS;
}
Expand Down
42 changes: 25 additions & 17 deletions loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1666,13 +1666,15 @@ VkResult loader_scan_for_direct_drivers(const struct loader_instance *inst, cons
}
const VkDirectDriverLoadingListLUNARG *ddl_list = NULL;
// Find the VkDirectDriverLoadingListLUNARG struct in the pNext chain of vkInstanceCreateInfo
const VkBaseOutStructure *chain = pCreateInfo->pNext;
while (chain) {
if (chain->sType == VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_LIST_LUNARG) {
ddl_list = (VkDirectDriverLoadingListLUNARG *)chain;
const void *pNext = pCreateInfo->pNext;
while (pNext) {
VkBaseInStructure out_structure = {0};
memcpy(&out_structure, pNext, sizeof(VkBaseInStructure));
if (out_structure.sType == VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_LIST_LUNARG) {
ddl_list = (VkDirectDriverLoadingListLUNARG *)pNext;
break;
}
chain = (const VkBaseOutStructure *)chain->pNext;
pNext = out_structure.pNext;
}
if (NULL == ddl_list) {
if (direct_driver_loading_enabled) {
Expand Down Expand Up @@ -5467,14 +5469,18 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateI
#endif // LOADER_ENABLE_LINUX_SORT

// Determine if vkGetPhysicalDeviceProperties2 is available to this Instance
// Also determine if VK_EXT_surface_maintenance1 is available on the ICD
if (icd_term->scanned_icd->api_version >= VK_API_VERSION_1_1) {
icd_term->supports_get_dev_prop_2 = true;
} else {
for (uint32_t j = 0; j < icd_create_info.enabledExtensionCount; j++) {
if (!strcmp(filtered_extension_names[j], VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) {
icd_term->supports_get_dev_prop_2 = true;
break;
}
}
for (uint32_t j = 0; j < icd_create_info.enabledExtensionCount; j++) {
if (!strcmp(filtered_extension_names[j], VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) {
icd_term->supports_get_dev_prop_2 = true;
continue;
}
if (!strcmp(filtered_extension_names[j], VK_EXT_SURFACE_MAINTENANCE_1_EXTENSION_NAME)) {
icd_term->supports_ext_surface_maintenance_1 = true;
continue;
}
}

Expand Down Expand Up @@ -5861,7 +5867,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical
{
const void *pNext = localCreateInfo.pNext;
while (pNext != NULL) {
switch (*(VkStructureType *)pNext) {
VkBaseInStructure pNext_in_structure = {0};
memcpy(&pNext_in_structure, pNext, sizeof(VkBaseInStructure));
switch (pNext_in_structure.sType) {
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2: {
const VkPhysicalDeviceFeatures2KHR *features = pNext;

Expand Down Expand Up @@ -5913,8 +5921,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical
// Multiview properties are also allowed, but since VK_KHX_multiview is a device extension, we'll just let the
// ICD handle that error when the user enables the extension here
default: {
const VkBaseInStructure *header = pNext;
pNext = header->pNext;
pNext = pNext_in_structure.pNext;
break;
}
}
Expand All @@ -5926,7 +5933,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical
{
const void *pNext = localCreateInfo.pNext;
while (pNext != NULL) {
switch (*(VkStructureType *)pNext) {
VkBaseInStructure pNext_in_structure = {0};
memcpy(&pNext_in_structure, pNext, sizeof(VkBaseInStructure));
switch (pNext_in_structure.sType) {
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR: {
const VkPhysicalDeviceMaintenance5FeaturesKHR *maintenance_features = pNext;
if (maintenance_features->maintenance5 == VK_TRUE) {
Expand All @@ -5937,8 +5946,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical
}

default: {
const VkBaseInStructure *header = pNext;
pNext = header->pNext;
pNext = pNext_in_structure.pNext;
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions loader/loader_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ struct loader_icd_term {

PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS];
bool supports_get_dev_prop_2;
bool supports_ext_surface_maintenance_1;

uint32_t physical_device_count;

Expand Down
8 changes: 4 additions & 4 deletions loader/loader_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ VkResult linux_read_sorted_physical_devices(struct loader_instance *inst, uint32
if (sorted_device_info[index].has_pci_bus_info) {
VkPhysicalDevicePCIBusInfoPropertiesEXT pci_props = (VkPhysicalDevicePCIBusInfoPropertiesEXT){
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT};
VkPhysicalDeviceProperties2 dev_props2 = (VkPhysicalDeviceProperties2){
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, .pNext = (VkBaseInStructure *)&pci_props};
VkPhysicalDeviceProperties2 dev_props2 =
(VkPhysicalDeviceProperties2){.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, .pNext = &pci_props};

PFN_vkGetPhysicalDeviceProperties2 GetPhysDevProps2 = NULL;
if (app_is_vulkan_1_1 && device_is_1_1_capable) {
Expand Down Expand Up @@ -395,8 +395,8 @@ VkResult linux_sort_physical_device_groups(struct loader_instance *inst, uint32_
if (sorted_group_term[group].internal_device_info[gpu].has_pci_bus_info) {
VkPhysicalDevicePCIBusInfoPropertiesEXT pci_props = (VkPhysicalDevicePCIBusInfoPropertiesEXT){
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT};
VkPhysicalDeviceProperties2 dev_props2 = (VkPhysicalDeviceProperties2){
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, .pNext = (VkBaseInStructure *)&pci_props};
VkPhysicalDeviceProperties2 dev_props2 =
(VkPhysicalDeviceProperties2){.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, .pNext = &pci_props};

PFN_vkGetPhysicalDeviceProperties2 GetPhysDevProps2 = NULL;
if (app_is_vulkan_1_1 && device_is_1_1_capable) {
Expand Down
16 changes: 10 additions & 6 deletions loader/terminator.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures2(VkPhysicalDevic
// Write to the VkPhysicalDeviceFeatures2 struct
icd_term->dispatch.GetPhysicalDeviceFeatures(phys_dev_term->phys_dev, &pFeatures->features);

const VkBaseInStructure *pNext = pFeatures->pNext;
void *pNext = pFeatures->pNext;
while (pNext != NULL) {
switch (pNext->sType) {
VkBaseOutStructure pNext_in_structure = {0};
memcpy(&pNext_in_structure, pNext, sizeof(VkBaseOutStructure));
switch (pNext_in_structure.sType) {
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES: {
// Skip the check if VK_KHR_multiview is enabled because it's a device extension
// Write to the VkPhysicalDeviceMultiviewFeaturesKHR struct
Expand All @@ -175,7 +177,7 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures2(VkPhysicalDevic
"vkGetPhysicalDeviceFeatures2: Emulation found unrecognized structure type in pFeatures->pNext - "
"this struct will be ignored");

pNext = pNext->pNext;
pNext = pNext_in_structure.pNext;
break;
}
}
Expand Down Expand Up @@ -212,9 +214,11 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties2(VkPhysicalDev
// Write to the VkPhysicalDeviceProperties2 struct
icd_term->dispatch.GetPhysicalDeviceProperties(phys_dev_term->phys_dev, &pProperties->properties);

const VkBaseInStructure *pNext = pProperties->pNext;
void *pNext = pProperties->pNext;
while (pNext != NULL) {
switch (pNext->sType) {
VkBaseOutStructure pNext_in_structure = {0};
memcpy(&pNext_in_structure, pNext, sizeof(VkBaseOutStructure));
switch (pNext_in_structure.sType) {
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES: {
VkPhysicalDeviceIDPropertiesKHR *id_properties = (VkPhysicalDeviceIDPropertiesKHR *)pNext;

Expand All @@ -238,7 +242,7 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties2(VkPhysicalDev
"vkGetPhysicalDeviceProperties2KHR: Emulation found unrecognized structure type in "
"pProperties->pNext - this struct will be ignored");

pNext = pNext->pNext;
pNext = pNext_in_structure.pNext;
break;
}
}
Expand Down
Loading

0 comments on commit 2764fdf

Please sign in to comment.