aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Lentine <mlentine@google.com>2016-01-27 15:43:43 -0600
committerMark Lobodzinski <mark@lunarg.com>2016-01-27 17:44:08 -0700
commit3943d717e54c6f4618ea9866215b70d20b62863d (patch)
tree6864f5aa66ba39cfbf475a982513c551577741a3
parent9ea8f8458d466b4576f924da559045a5e6196ca3 (diff)
downloadusermoji-3943d717e54c6f4618ea9866215b70d20b62863d.tar.xz
layers: MR170, Validate queue paramters when getting a queue in param_checker
-rw-r--r--layers/param_checker.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/layers/param_checker.cpp b/layers/param_checker.cpp
index 732ac27c..e2301977 100644
--- a/layers/param_checker.cpp
+++ b/layers/param_checker.cpp
@@ -51,6 +51,11 @@ struct layer_data {
debug_report_data *report_data;
std::vector<VkDebugReportCallbackEXT> logging_callback;
+ //TODO: Split instance/device structs
+ //Device Data
+ //Map for queue family index to queue count
+ std::unordered_map<uint32_t, uint32_t> queueFamilyIndexMap;
+
layer_data() :
report_data(nullptr)
{};
@@ -2079,6 +2084,14 @@ void validateDeviceCreateInfo(VkPhysicalDevice physicalDevice, const VkDeviceCre
}
}
+void storeCreateDeviceData(VkDevice device, const VkDeviceCreateInfo* pCreateInfo) {
+ layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
+ for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
+ my_device_data->queueFamilyIndexMap.insert(
+ std::make_pair(pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex, pCreateInfo->pQueueCreateInfos[i].queueCount));
+ }
+}
+
VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(
VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo* pCreateInfo,
@@ -2118,6 +2131,7 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(
get_dispatch_table(pc_instance_table_map, physicalDevice)->GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &count, &properties[0]);
validateDeviceCreateInfo(physicalDevice, pCreateInfo, properties);
+ storeCreateDeviceData(*pDevice, pCreateInfo);
return result;
}
@@ -2137,6 +2151,26 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(
pc_device_table_map.erase(key);
}
+bool PreGetDeviceQueue(
+ VkDevice device,
+ uint32_t queueFamilyIndex,
+ uint32_t queueIndex)
+{
+ layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
+ auto queue_data = my_device_data->queueFamilyIndexMap.find(queueFamilyIndex);
+ if (queue_data == my_device_data->queueFamilyIndexMap.end()) {
+ log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK",
+ "VkGetDeviceQueue parameter, uint32_t queueFamilyIndex %d, must have been given when the device was created.", queueFamilyIndex);
+ return false;
+ }
+ if (queue_data->second <= queueIndex) {
+ log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK",
+ "VkGetDeviceQueue parameter, uint32_t queueIndex %d, must be less than the number of queues given when the device was created.", queueIndex);
+ return false;
+ }
+ return true;
+}
+
bool PostGetDeviceQueue(
VkDevice device,
uint32_t queueFamilyIndex,
@@ -2159,6 +2193,8 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(
uint32_t queueIndex,
VkQueue* pQueue)
{
+ PreGetDeviceQueue(device, queueFamilyIndex, queueIndex);
+
get_dispatch_table(pc_device_table_map, device)->GetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue);
PostGetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue);