Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Split Instance and Device #9311

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions layers/core_checks/cc_android.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 2015-2024 The Khronos Group Inc.
* Copyright (c) 2015-2024 Valve Corporation
* Copyright (c) 2015-2024 LunarG, Inc.
/* Copyright (c) 2015-2025 The Khronos Group Inc.
* Copyright (c) 2015-2025 Valve Corporation
* Copyright (c) 2015-2025 LunarG, Inc.
* Copyright (C) 2015-2024 Google Inc.
* Modifications Copyright (C) 2020-2022 Advanced Micro Devices, Inc. All rights reserved.
*
Expand Down Expand Up @@ -419,9 +419,9 @@ bool CoreChecks::ValidateGetImageMemoryRequirementsANDROID(const VkImage image,
return skip;
}

bool CoreChecks::ValidateGetPhysicalDeviceImageFormatProperties2ANDROID(const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
const VkImageFormatProperties2 *pImageFormatProperties,
const ErrorObject &error_obj) const {
bool core::Instance::ValidateGetPhysicalDeviceImageFormatProperties2ANDROID(
const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, const VkImageFormatProperties2 *pImageFormatProperties,
const ErrorObject &error_obj) const {
bool skip = false;
const auto *ahb_usage = vku::FindStructInPNextChain<VkAndroidHardwareBufferUsageANDROID>(pImageFormatProperties->pNext);
if (ahb_usage) {
Expand Down Expand Up @@ -612,9 +612,9 @@ bool CoreChecks::ValidateAllocateMemoryANDROID(const VkMemoryAllocateInfo &alloc
return false;
}

bool CoreChecks::ValidateGetPhysicalDeviceImageFormatProperties2ANDROID(const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
const VkImageFormatProperties2 *pImageFormatProperties,
const ErrorObject &error_obj) const {
bool core::Instance::ValidateGetPhysicalDeviceImageFormatProperties2ANDROID(
const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, const VkImageFormatProperties2 *pImageFormatProperties,
const ErrorObject &error_obj) const {
return false;
}

Expand Down
10 changes: 5 additions & 5 deletions layers/core_checks/cc_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ bool CoreChecks::PreCallValidateCreateBuffer(VkDevice device, const VkBufferCrea
const bool expect_encode_profile = has_encode_usage && !video_profile_independent;

const auto *video_profiles = vku::FindStructInPNextChain<VkVideoProfileListInfoKHR>(pCreateInfo->pNext);
skip |= ValidateVideoProfileListInfo(video_profiles, device, create_info_loc.pNext(Struct::VkVideoProfileListInfoKHR),
expect_decode_profile, "VUID-VkBufferCreateInfo-usage-04813", expect_encode_profile,
"VUID-VkBufferCreateInfo-usage-04814");
skip |= core::ValidateVideoProfileListInfo(
*this, video_profiles, error_obj, create_info_loc.pNext(Struct::VkVideoProfileListInfoKHR), expect_decode_profile,
"VUID-VkBufferCreateInfo-usage-04813", expect_encode_profile, "VUID-VkBufferCreateInfo-usage-04814");
}

auto external_memory_info = vku::FindStructInPNextChain<VkExternalMemoryBufferCreateInfo>(pCreateInfo->pNext);
Expand All @@ -308,8 +308,8 @@ bool CoreChecks::PreCallValidateCreateBuffer(VkDevice device, const VkBufferCrea
external_buffer_info.usage = VkBufferUsageFlags(pCreateInfo->usage);
external_buffer_info.handleType = static_cast<VkExternalMemoryHandleTypeFlagBits>(any_type);
VkExternalBufferProperties external_buffer_properties = vku::InitStructHelper();
DispatchGetPhysicalDeviceExternalBufferPropertiesHelper(physical_device, &external_buffer_info,
&external_buffer_properties);
instance_state->DispatchGetPhysicalDeviceExternalBufferPropertiesHelper(physical_device, &external_buffer_info,
&external_buffer_properties);
const auto compatible_types = external_buffer_properties.externalMemoryProperties.compatibleHandleTypes;

if ((external_memory_info->handleTypes & compatible_types) != external_memory_info->handleTypes) {
Expand Down
4 changes: 2 additions & 2 deletions layers/core_checks/cc_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3019,8 +3019,8 @@ bool CoreChecks::ValidateGetDescriptorDataSize(const VkDescriptorGetInfoEXT &des
image_format_info.flags = image_info.flags;
VkSamplerYcbcrConversionImageFormatProperties sampler_ycbcr_image_format_info = vku::InitStructHelper();
VkImageFormatProperties2 image_format_properties = vku::InitStructHelper(&sampler_ycbcr_image_format_info);
DispatchGetPhysicalDeviceImageFormatProperties2Helper(physical_device, &image_format_info,
&image_format_properties);
instance_state->DispatchGetPhysicalDeviceImageFormatProperties2Helper(physical_device, &image_format_info,
&image_format_properties);
size *= static_cast<size_t>(sampler_ycbcr_image_format_info.combinedImageSamplerDescriptorCount);
if (size != data_size) {
skip |= LogError("VUID-vkGetDescriptorEXT-descriptorType-09469", device, descriptor_info_loc.dot(Field::type),
Expand Down
47 changes: 23 additions & 24 deletions layers/core_checks/cc_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ bool CoreChecks::GetPhysicalDeviceImageFormatProperties(vvl::Image &image_state,
image_format_info.usage = image_create_info.usage;
image_format_info.flags = image_create_info.flags;
VkImageFormatProperties2 image_format_properties = vku::InitStructHelper();
image_properties_result =
DispatchGetPhysicalDeviceImageFormatProperties2Helper(physical_device, &image_format_info, &image_format_properties);
image_properties_result = instance_state->DispatchGetPhysicalDeviceImageFormatProperties2Helper(
physical_device, &image_format_info, &image_format_properties);
image_state.image_format_properties = image_format_properties.imageFormatProperties;
}
if (image_properties_result != VK_SUCCESS) {
Expand Down Expand Up @@ -160,8 +160,8 @@ bool CoreChecks::ValidateDeviceMaskToRenderPass(const vvl::CommandBuffer &cb_sta
return skip;
}

bool CoreChecks::ValidateQueueFamilyIndex(const vvl::PhysicalDevice &pd_state, uint32_t requested_queue_family, const char *vuid,
const Location &loc) const {
bool core::Instance::ValidateQueueFamilyIndex(const vvl::PhysicalDevice &pd_state, uint32_t requested_queue_family,
const char *vuid, const Location &loc) const {
bool skip = false;

if (requested_queue_family >= pd_state.queue_family_known_count) {
Expand All @@ -177,8 +177,8 @@ bool CoreChecks::ValidateQueueFamilyIndex(const vvl::PhysicalDevice &pd_state, u
return skip;
}

bool CoreChecks::ValidateDeviceQueueCreateInfos(const vvl::PhysicalDevice &pd_state, uint32_t info_count,
const VkDeviceQueueCreateInfo *infos, const Location &loc) const {
bool core::Instance::ValidateDeviceQueueCreateInfos(const vvl::PhysicalDevice &pd_state, uint32_t info_count,
const VkDeviceQueueCreateInfo *infos, const Location &loc) const {
bool skip = false;

const uint32_t not_used = std::numeric_limits<uint32_t>::max();
Expand Down Expand Up @@ -320,15 +320,15 @@ bool CoreChecks::ValidateDeviceQueueCreateInfos(const vvl::PhysicalDevice &pd_st
return skip;
}

bool CoreChecks::PreCallValidateCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice,
const ErrorObject &error_obj) const {
bool core::Instance::PreCallValidateCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice,
const ErrorObject &error_obj) const {
bool skip = false;
// TODO: object_tracker should perhaps do this instead
// and it does not seem to currently work anyway -- the loader just crashes before this point
auto pd_state = Get<vvl::PhysicalDevice>(gpu);
if (!pd_state) {
skip |= LogError("VUID-vkCreateDevice-physicalDevice-parameter", device, error_obj.location,
skip |= LogError("VUID-vkCreateDevice-physicalDevice-parameter", instance, error_obj.location,
"Have not called vkEnumeratePhysicalDevices() yet.");
return skip;
}
Expand Down Expand Up @@ -497,14 +497,15 @@ bool CoreChecks::PreCallValidateGetDeviceQueue2(VkDevice device, const VkDeviceQ
return skip;
}

bool CoreChecks::ValidateGetPhysicalDeviceImageFormatProperties2(const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
VkImageFormatProperties2 *pImageFormatProperties,
const ErrorObject &error_obj) const {
bool core::Instance::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice gpu,
const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
VkImageFormatProperties2 *pImageFormatProperties,
const ErrorObject &error_obj) const {
bool skip = false;
const auto *copy_perf_query = vku::FindStructInPNextChain<VkHostImageCopyDevicePerformanceQuery>(pImageFormatProperties->pNext);
if (copy_perf_query) {
if ((pImageFormatInfo->usage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT) == 0) {
skip |= LogError("VUID-vkGetPhysicalDeviceImageFormatProperties2-pNext-09004", physical_device, error_obj.location,
skip |= LogError("VUID-vkGetPhysicalDeviceImageFormatProperties2-pNext-09004", gpu, error_obj.location,
"pImageFormatProperties includes a chained "
"VkHostImageCopyDevicePerformanceQuery struct, but pImageFormatInfo->usage (%s) does not contain "
"VK_IMAGE_USAGE_HOST_TRANSFER_BIT",
Expand All @@ -514,21 +515,19 @@ bool CoreChecks::ValidateGetPhysicalDeviceImageFormatProperties2(const VkPhysica
return skip;
}

bool CoreChecks::PreCallValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
VkImageFormatProperties2 *pImageFormatProperties,
const ErrorObject &error_obj) const {
bool core::Instance::PreCallValidateGetPhysicalDeviceImageFormatProperties2(
VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
VkImageFormatProperties2 *pImageFormatProperties, const ErrorObject &error_obj) const {
// Can't wrap AHB-specific validation in a device extension check here, but no harm
bool skip = false;
skip |= ValidateGetPhysicalDeviceImageFormatProperties2ANDROID(pImageFormatInfo, pImageFormatProperties, error_obj);
skip |= ValidateGetPhysicalDeviceImageFormatProperties2(pImageFormatInfo, pImageFormatProperties, error_obj);
skip |= ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, error_obj);
return skip;
}

bool CoreChecks::PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
VkImageFormatProperties2 *pImageFormatProperties,
const ErrorObject &error_obj) const {
bool core::Instance::PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
VkImageFormatProperties2 *pImageFormatProperties, const ErrorObject &error_obj) const {
return PreCallValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
error_obj);
}
Expand All @@ -539,7 +538,7 @@ VkFormatProperties3KHR CoreChecks::GetPDFormatProperties(const VkFormat format)
VkFormatProperties2 fmt_props_2 = vku::InitStructHelper(&fmt_props_3);

if (has_format_feature2) {
DispatchGetPhysicalDeviceFormatProperties2Helper(physical_device, format, &fmt_props_2);
instance_state->DispatchGetPhysicalDeviceFormatProperties2Helper(physical_device, format, &fmt_props_2);
fmt_props_3.linearTilingFeatures |= fmt_props_2.formatProperties.linearTilingFeatures;
fmt_props_3.optimalTilingFeatures |= fmt_props_2.formatProperties.optimalTilingFeatures;
fmt_props_3.bufferFeatures |= fmt_props_2.formatProperties.bufferFeatures;
Expand Down
17 changes: 10 additions & 7 deletions layers/core_checks/cc_device_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ bool CoreChecks::HasExternalMemoryImportSupport(const vvl::Buffer &buffer, VkExt
info.usage = buffer.create_info.usage;
info.handleType = handle_type;
VkExternalBufferProperties properties = vku::InitStructHelper();
DispatchGetPhysicalDeviceExternalBufferPropertiesHelper(physical_device, &info, &properties);
instance_state->DispatchGetPhysicalDeviceExternalBufferPropertiesHelper(physical_device, &info, &properties);
return (properties.externalMemoryProperties.externalMemoryFeatures & VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) != 0;
}

Expand All @@ -379,7 +379,8 @@ bool CoreChecks::HasExternalMemoryImportSupport(const vvl::Image &image, VkExter
VkImageFormatProperties2 properties = vku::InitStructHelper(&external_properties);
if (image.create_info.tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
// Can't get into function with using external memory extensions which require GPDP2
if (DispatchGetPhysicalDeviceImageFormatProperties2Helper(physical_device, &info, &properties) != VK_SUCCESS) {
if (instance_state->DispatchGetPhysicalDeviceImageFormatProperties2Helper(physical_device, &info, &properties) !=
VK_SUCCESS) {
return false;
}
} else {
Expand All @@ -394,7 +395,8 @@ bool CoreChecks::HasExternalMemoryImportSupport(const vvl::Image &image, VkExter
return false;
}
drm_format_modifier.drmFormatModifier = drm_format_properties.drmFormatModifier;
if (DispatchGetPhysicalDeviceImageFormatProperties2Helper(physical_device, &info, &properties) != VK_SUCCESS) {
if (instance_state->DispatchGetPhysicalDeviceImageFormatProperties2Helper(physical_device, &info, &properties) !=
VK_SUCCESS) {
return false;
}
}
Expand Down Expand Up @@ -889,7 +891,8 @@ bool CoreChecks::ValidateBindBufferMemory(VkBuffer buffer, VkDeviceMemory memory

auto validate_export_handle_types = [&](VkExternalMemoryHandleTypeFlagBits flag) {
external_info.handleType = flag;
DispatchGetPhysicalDeviceExternalBufferPropertiesHelper(physical_device, &external_info, &external_properties);
instance_state->DispatchGetPhysicalDeviceExternalBufferPropertiesHelper(physical_device, &external_info,
&external_properties);
const auto external_features = external_properties.externalMemoryProperties.externalMemoryFeatures;
if ((external_features & VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT) == 0) {
export_supported = false;
Expand Down Expand Up @@ -1204,7 +1207,7 @@ bool CoreChecks::ValidateMapMemory(const vvl::DeviceMemory &mem_info, VkDeviceSi
}

if (mem_info.multi_instance) {
skip |= LogError(map2 ? "VUID-VkMemoryMapInfo-memory-07963" : "VUID-vkMapMemory-memory-00683", instance, loc,
skip |= LogError(map2 ? "VUID-VkMemoryMapInfo-memory-07963" : "VUID-vkMapMemory-memory-00683", memory, loc,
"Memory allocated with multiple instances.");
}

Expand Down Expand Up @@ -1763,8 +1766,8 @@ bool CoreChecks::ValidateBindImageMemory(uint32_t bindInfoCount, const VkBindIma
drm_format_modifier.drmFormatModifier = drm_modifier_properties.drmFormatModifier;
}
}
auto result =
DispatchGetPhysicalDeviceImageFormatProperties2Helper(physical_device, &image_info, &image_properties);
auto result = instance_state->DispatchGetPhysicalDeviceImageFormatProperties2Helper(
physical_device, &image_info, &image_properties);
if (result != VK_SUCCESS) {
export_supported = false;
const LogObjectList objlist(bind_info.image, bind_info.memory);
Expand Down
11 changes: 6 additions & 5 deletions layers/core_checks/cc_external_object.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 2015-2024 The Khronos Group Inc.
* Copyright (c) 2015-2024 Valve Corporation
* Copyright (c) 2015-2024 LunarG, Inc.
/* Copyright (c) 2015-2025 The Khronos Group Inc.
* Copyright (c) 2015-2025 Valve Corporation
* Copyright (c) 2015-2025 LunarG, Inc.
* Copyright (C) 2015-2024 Google Inc.
* Modifications Copyright (C) 2020-2022 Advanced Micro Devices, Inc. All rights reserved.
*
Expand Down Expand Up @@ -29,7 +29,8 @@ bool CoreChecks::CanSemaphoreExportFromImported(VkExternalSemaphoreHandleTypeFla
VkPhysicalDeviceExternalSemaphoreInfo semaphore_info = vku::InitStructHelper();
semaphore_info.handleType = export_type;
VkExternalSemaphoreProperties semaphore_properties = vku::InitStructHelper();
DispatchGetPhysicalDeviceExternalSemaphorePropertiesHelper(physical_device, &semaphore_info, &semaphore_properties);
instance_state->DispatchGetPhysicalDeviceExternalSemaphorePropertiesHelper(physical_device, &semaphore_info,
&semaphore_properties);
return (imported_type & semaphore_properties.exportFromImportedHandleTypes) != 0;
}

Expand All @@ -38,7 +39,7 @@ bool CoreChecks::CanFenceExportFromImported(VkExternalFenceHandleTypeFlagBits ex
VkPhysicalDeviceExternalFenceInfo fence_info = vku::InitStructHelper();
fence_info.handleType = export_type;
VkExternalFenceProperties fence_properties = vku::InitStructHelper();
DispatchGetPhysicalDeviceExternalFencePropertiesHelper(physical_device, &fence_info, &fence_properties);
instance_state->DispatchGetPhysicalDeviceExternalFencePropertiesHelper(physical_device, &fence_info, &fence_properties);
return (imported_type & fence_properties.exportFromImportedHandleTypes) != 0;
}

Expand Down
Loading
Loading