Skip to content

Commit

Permalink
layers: Init extension tables w/ requested API
Browse files Browse the repository at this point in the history
Make the initialization of the extension enable tables consistent
between instance and device creation.  Validation will treat extension
presence based on the lesser of the requested API level and the driver
API level.

Change-Id: I453cbf4b7da35db22c4ffdf03fdf6e361d940b2f
  • Loading branch information
jzulauf-lunarg committed Sep 12, 2018
1 parent 50af071 commit 1909e6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions layers/core_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2310,8 +2310,10 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice gpu, const VkDevice
// Get physical device limits for this device
instance_data->dispatch_table.GetPhysicalDeviceProperties(gpu, &(device_data->phys_dev_properties.properties));

device_data->api_version = device_data->extensions.InitFromDeviceCreateInfo(
&instance_data->extensions, device_data->phys_dev_properties.properties.apiVersion, pCreateInfo);
// Setup the validation tables based on the application API version from the instance and the capabilities of the device driver.
uint32_t effective_api_version = std::min(device_data->phys_dev_properties.properties.apiVersion, instance_data->api_version);
device_data->api_version =
device_data->extensions.InitFromDeviceCreateInfo(&instance_data->extensions, effective_api_version, pCreateInfo);

uint32_t count;
instance_data->dispatch_table.GetPhysicalDeviceQueueFamilyProperties(gpu, &count, nullptr);
Expand Down
10 changes: 5 additions & 5 deletions layers/parameter_validation_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,11 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo *pCre
? pCreateInfo->pApplicationInfo->apiVersion
: VK_API_VERSION_1_0;

uint32_t effective_api_version = my_instance_data->extensions.InitFromInstanceCreateInfo(api_version, pCreateInfo);
my_instance_data->api_version = my_instance_data->extensions.InitFromInstanceCreateInfo(api_version, pCreateInfo);

// Ordinarily we'd check these before calling down the chain, but none of the layer support is in place until now, if we
// survive we can report the issue now.
validate_api_version(my_instance_data, api_version, effective_api_version);
validate_api_version(my_instance_data, api_version, my_instance_data->api_version);
validate_instance_extensions(my_instance_data, pCreateInfo);

parameter_validation_vkCreateInstance(*pInstance, pCreateInfo, pAllocator, pInstance);
Expand Down Expand Up @@ -588,10 +588,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c
VkPhysicalDeviceProperties device_properties = {};
my_instance_data->dispatch_table.GetPhysicalDeviceProperties(physicalDevice, &device_properties);

// Set up the extension structure also for validation.
// Setup the validation tables based on the application API version from the instance and the capabilities of the device driver.
uint32_t effective_api_version = std::min(device_properties.apiVersion, my_instance_data->api_version);
DeviceExtensions extensions;
uint32_t api_version =
extensions.InitFromDeviceCreateInfo(&my_instance_data->extensions, device_properties.apiVersion, pCreateInfo);
uint32_t api_version = extensions.InitFromDeviceCreateInfo(&my_instance_data->extensions, effective_api_version, pCreateInfo);

std::unique_lock<std::mutex> lock(global_lock);

Expand Down

0 comments on commit 1909e6a

Please sign in to comment.