diff options
| author | Tony Barbour <tony@LunarG.com> | 2015-06-24 16:06:58 -0600 |
|---|---|---|
| committer | Tony Barbour <tony@LunarG.com> | 2015-06-25 15:17:05 -0600 |
| commit | ecf1b2ba983f3b19aae99608064a2a3762860556 (patch) | |
| tree | 50987e481bb165732f7c53c40533f0b1fa59f00b | |
| parent | 46c90248a677f09c2124aa45614113cf09f2cf08 (diff) | |
| download | usermoji-ecf1b2ba983f3b19aae99608064a2a3762860556.tar.xz | |
vulkan.h: V108 -- Static Types, Bug# 13919
| -rw-r--r-- | demos/cube.c | 58 | ||||
| -rw-r--r-- | demos/tri.c | 56 | ||||
| -rw-r--r-- | demos/vulkaninfo.c | 59 | ||||
| -rw-r--r-- | icd/nulldrv/VK_nulldrv.def | 3 | ||||
| -rw-r--r-- | icd/nulldrv/nulldrv.c | 306 | ||||
| -rw-r--r-- | icd/nulldrv/nulldrv.h | 3 | ||||
| -rw-r--r-- | include/vkLayer.h | 14 | ||||
| -rw-r--r-- | include/vulkan.h | 121 | ||||
| -rw-r--r-- | layers/basic.cpp | 43 | ||||
| -rw-r--r-- | layers/draw_state.cpp | 95 | ||||
| -rw-r--r-- | layers/image.cpp | 92 | ||||
| -rw-r--r-- | layers/mem_tracker.cpp | 119 | ||||
| -rw-r--r-- | layers/multi.cpp | 53 | ||||
| -rw-r--r-- | layers/object_track.h | 50 | ||||
| -rw-r--r-- | layers/param_checker.cpp | 141 | ||||
| -rw-r--r-- | layers/screenshot.cpp | 117 | ||||
| -rw-r--r-- | layers/shader_checker.cpp | 88 | ||||
| -rw-r--r-- | loader/gpa_helper.h | 54 | ||||
| -rw-r--r-- | loader/loader.c | 273 | ||||
| -rw-r--r-- | loader/loader.h | 61 | ||||
| -rw-r--r-- | loader/table_ops.h | 39 | ||||
| -rw-r--r-- | loader/trampoline.c | 101 | ||||
| -rwxr-xr-x | loader/vk-loader-generate.py | 15 | ||||
| -rwxr-xr-x | vk-generate.py | 5 | ||||
| -rwxr-xr-x | vk-layer-generate.py | 292 | ||||
| -rwxr-xr-x | vulkan.py | 56 |
26 files changed, 1038 insertions, 1276 deletions
diff --git a/demos/cube.c b/demos/cube.c index 3a4c4179..eeb888f9 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -297,7 +297,7 @@ struct demo { VkDevice device; VkQueue queue; uint32_t graphics_queue_node_index; - VkPhysicalDeviceProperties *gpu_props; + VkPhysicalDeviceProperties gpu_props; VkPhysicalDeviceQueueProperties *queue_props; VkFramebuffer framebuffer; @@ -678,7 +678,6 @@ static void demo_prepare_depth(struct demo *demo) }; VkMemoryRequirements mem_reqs; - size_t mem_reqs_size = sizeof(VkMemoryRequirements); VkResult U_ASSERT_ONLY err; demo->depth.format = depth_format; @@ -688,10 +687,8 @@ static void demo_prepare_depth(struct demo *demo) &demo->depth.image); assert(!err); - err = vkGetObjectInfo(demo->device, - VK_OBJECT_TYPE_IMAGE, demo->depth.image, - VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS, - &mem_reqs_size, &mem_reqs); + err = vkGetObjectMemoryRequirements(demo->device, + VK_OBJECT_TYPE_IMAGE, demo->depth.image, &mem_reqs); mem_alloc.allocationSize = mem_reqs.size; /* allocate memory */ @@ -912,17 +909,14 @@ static void demo_prepare_texture_image(struct demo *demo, }; VkMemoryRequirements mem_reqs; - size_t mem_reqs_size = sizeof(VkMemoryRequirements); err = vkCreateImage(demo->device, &image_create_info, &tex_obj->image); assert(!err); - err = vkGetObjectInfo(demo->device, - VK_OBJECT_TYPE_IMAGE, tex_obj->image, - VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS, - &mem_reqs_size, &mem_reqs); - assert(!err && mem_reqs_size == sizeof(VkMemoryRequirements)); + err = vkGetObjectMemoryRequirements(demo->device, + VK_OBJECT_TYPE_IMAGE, tex_obj->image, &mem_reqs); + assert(!err); mem_alloc.allocationSize = mem_reqs.size; @@ -944,13 +938,10 @@ static void demo_prepare_texture_image(struct demo *demo, .arraySlice = 0, }; VkSubresourceLayout layout; - size_t layout_size = sizeof(VkSubresourceLayout); void *data; - err = vkGetImageSubresourceInfo(demo->device, tex_obj->image, &subres, - VK_SUBRESOURCE_INFO_TYPE_LAYOUT, - &layout_size, &layout); - assert(!err && layout_size == sizeof(layout)); + err = vkGetImageSubresourceLayout(demo->device, tex_obj->image, &subres, &layout); + assert(!err); err = vkMapMemory(demo->device, tex_obj->mem, 0, 0, 0, &data); assert(!err); @@ -1122,15 +1113,12 @@ void demo_prepare_cube_data_buffer(struct demo *demo) memset(&buf_info, 0, sizeof(buf_info)); buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; - buf_info.size = sizeof(data); buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; err = vkCreateBuffer(demo->device, &buf_info, &demo->uniform_data.buf); assert(!err); - err = vkGetObjectInfo(demo->device, - VK_OBJECT_TYPE_BUFFER, demo->uniform_data.buf, - VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS, - &mem_reqs_size, &mem_reqs); + err = vkGetObjectMemoryRequirements(demo->device, + VK_OBJECT_TYPE_BUFFER, demo->uniform_data.buf, &mem_reqs); assert(!err && mem_reqs_size == sizeof(mem_reqs)); alloc_info.allocationSize = mem_reqs.size; @@ -1868,18 +1856,16 @@ static void demo_init_vk(struct demo *demo) uint32_t instance_extension_count = 0; VkExtensionProperties *device_extensions; uint32_t device_extension_count = 0; - size_t extSize = sizeof(uint32_t); uint32_t total_extension_count = 0; - err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_COUNT, 0, &extSize, &total_extension_count); + err = vkGetGlobalExtensionCount(&total_extension_count); assert(!err); VkExtensionProperties extProp; - extSize = sizeof(VkExtensionProperties); bool32_t WSIextFound = 0; instance_extensions = malloc(sizeof(VkExtensionProperties) * total_extension_count); device_extensions = malloc(sizeof(VkExtensionProperties) * total_extension_count); for (uint32_t i = 0; i < total_extension_count; i++) { - err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_PROPERTIES, i, &extSize, &extProp); + err = vkGetGlobalExtensionProperties(i, &extProp); if (!strcmp("VK_WSI_LunarG", extProp.name)) { WSIextFound = 1; memcpy(&instance_extensions[instance_extension_count++], &extProp, sizeof(VkExtensionProperties)); @@ -1890,7 +1876,7 @@ static void demo_init_vk(struct demo *demo) } } if (!WSIextFound) { - ERR_EXIT("vkGetGlobalExtensionInfo failed to find the " + ERR_EXIT("vkGetGlobalExtensionProperties failed to find the " "\"VK_WSI_LunarG\" extension.\n\nDo you have a compatible " "Vulkan installable client driver (ICD) installed?\nPlease " "look at the Getting Started guide for additional " @@ -1930,7 +1916,6 @@ static void demo_init_vk(struct demo *demo) }; uint32_t gpu_count; uint32_t i; - size_t data_size; uint32_t queue_count; if (demo->validate) { @@ -1999,24 +1984,15 @@ static void demo_init_vk(struct demo *demo) GET_DEVICE_PROC_ADDR(demo->device, GetSwapChainInfoWSI); GET_DEVICE_PROC_ADDR(demo->device, QueuePresentWSI); - err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_PROPERTIES, - &data_size, NULL); - assert(!err); - - demo->gpu_props = (VkPhysicalDeviceProperties *) malloc(data_size); - err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_PROPERTIES, - &data_size, demo->gpu_props); + err = vkGetPhysicalDeviceProperties(demo->gpu, &demo->gpu_props); assert(!err); - err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_QUEUE_PROPERTIES, - &data_size, NULL); + err = vkGetPhysicalDeviceQueueCount(demo->gpu, &queue_count); assert(!err); - demo->queue_props = (VkPhysicalDeviceQueueProperties *) malloc(data_size); - err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_QUEUE_PROPERTIES, - &data_size, demo->queue_props); + demo->queue_props = (VkPhysicalDeviceQueueProperties *) malloc(queue_count * sizeof(VkPhysicalDeviceQueueProperties)); + err = vkGetPhysicalDeviceQueueProperties(demo->gpu, queue_count, demo->queue_props); assert(!err); - queue_count = (uint32_t)(data_size / sizeof(VkPhysicalDeviceQueueProperties)); assert(queue_count >= 1); // Graphics queue and MemMgr queue can be separate. diff --git a/demos/tri.c b/demos/tri.c index f9233c9f..49e323be 100644 --- a/demos/tri.c +++ b/demos/tri.c @@ -119,7 +119,7 @@ struct demo { VkPhysicalDevice gpu; VkDevice device; VkQueue queue; - VkPhysicalDeviceProperties *gpu_props; + VkPhysicalDeviceProperties gpu_props; VkPhysicalDeviceQueueProperties *queue_props; uint32_t graphics_queue_node_index; @@ -476,7 +476,6 @@ static void demo_prepare_depth(struct demo *demo) }; VkMemoryRequirements mem_reqs; - size_t mem_reqs_size = sizeof(VkMemoryRequirements); VkResult U_ASSERT_ONLY err; demo->depth.format = depth_format; @@ -486,10 +485,8 @@ static void demo_prepare_depth(struct demo *demo) &demo->depth.image); assert(!err); - err = vkGetObjectInfo(demo->device, - VK_OBJECT_TYPE_IMAGE, demo->depth.image, - VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS, - &mem_reqs_size, &mem_reqs); + err = vkGetObjectMemoryRequirements(demo->device, + VK_OBJECT_TYPE_IMAGE, demo->depth.image, &mem_reqs); mem_alloc.allocationSize = mem_reqs.size; /* allocate memory */ @@ -550,16 +547,13 @@ static void demo_prepare_texture_image(struct demo *demo, }; VkMemoryRequirements mem_reqs; - size_t mem_reqs_size = sizeof(VkMemoryRequirements); err = vkCreateImage(demo->device, &image_create_info, &tex_obj->image); assert(!err); - err = vkGetObjectInfo(demo->device, - VK_OBJECT_TYPE_IMAGE, tex_obj->image, - VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS, - &mem_reqs_size, &mem_reqs); + err = vkGetObjectMemoryRequirements(demo->device, + VK_OBJECT_TYPE_IMAGE, tex_obj->image, &mem_reqs); mem_alloc.allocationSize = mem_reqs.size; /* allocate memory */ @@ -579,14 +573,11 @@ static void demo_prepare_texture_image(struct demo *demo, .arraySlice = 0, }; VkSubresourceLayout layout; - size_t layout_size = sizeof(VkSubresourceLayout); void *data; int32_t x, y; - err = vkGetImageSubresourceInfo(demo->device, tex_obj->image, &subres, - VK_SUBRESOURCE_INFO_TYPE_LAYOUT, - &layout_size, &layout); - assert(!err && layout_size == sizeof(layout)); + err = vkGetImageSubresourceLayout(demo->device, tex_obj->image, &subres, &layout); + assert(!err); err = vkMapMemory(demo->device, tex_obj->mem, 0, 0, 0, &data); assert(!err); @@ -747,7 +738,6 @@ static void demo_prepare_vertices(struct demo *demo) .memProps = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, }; VkMemoryRequirements mem_reqs; - size_t mem_reqs_size = sizeof(VkMemoryRequirements); VkResult U_ASSERT_ONLY err; void *data; @@ -756,10 +746,8 @@ static void demo_prepare_vertices(struct demo *demo) err = vkCreateBuffer(demo->device, &buf_info, &demo->vertices.buf); assert(!err); - err = vkGetObjectInfo(demo->device, - VK_OBJECT_TYPE_BUFFER, demo->vertices.buf, - VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS, - &mem_reqs_size, &mem_reqs); + err = vkGetObjectMemoryRequirements(demo->device, + VK_OBJECT_TYPE_BUFFER, demo->vertices.buf, &mem_reqs); mem_alloc.allocationSize = mem_reqs.size; @@ -1364,18 +1352,16 @@ static void demo_init_vk(struct demo *demo) uint32_t instance_extension_count = 0; VkExtensionProperties *device_extensions; uint32_t device_extension_count = 0; - size_t extSize = sizeof(uint32_t); uint32_t total_extension_count = 0; - err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_COUNT, 0, &extSize, &total_extension_count); + err = vkGetGlobalExtensionCount(&total_extension_count); assert(!err); VkExtensionProperties extProp; - extSize = sizeof(VkExtensionProperties); bool32_t WSIextFound = 0; instance_extensions = malloc(sizeof(VkExtensionProperties) * total_extension_count); device_extensions = malloc(sizeof(VkExtensionProperties) * total_extension_count); for (uint32_t i = 0; i < total_extension_count; i++) { - err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_PROPERTIES, i, &extSize, &extProp); + err = vkGetGlobalExtensionProperties(i, &extProp); if (!strcmp("VK_WSI_LunarG", extProp.name)) { WSIextFound = 1; memcpy(&instance_extensions[instance_extension_count++], &extProp, sizeof(VkExtensionProperties)); @@ -1383,7 +1369,7 @@ static void demo_init_vk(struct demo *demo) } } if (!WSIextFound) { - ERR_EXIT("vkGetGlobalExtensionInfo failed to find the " + ERR_EXIT("vkGetGlobalExtensionProperties failed to find the " "\"VK_WSI_LunarG\" extension.\n\nDo you have a compatible " "Vulkan installable client driver (ICD) installed?\nPlease " "look at the Getting Started guide for additional " @@ -1422,7 +1408,6 @@ static void demo_init_vk(struct demo *demo) }; uint32_t gpu_count; uint32_t i; - size_t data_size; uint32_t queue_count; err = vkCreateInstance(&inst_info, &demo->inst); @@ -1451,24 +1436,15 @@ static void demo_init_vk(struct demo *demo) GET_DEVICE_PROC_ADDR(demo->device, GetSwapChainInfoWSI); GET_DEVICE_PROC_ADDR(demo->device, QueuePresentWSI); - err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_PROPERTIES, - &data_size, NULL); - assert(!err); - - demo->gpu_props = (VkPhysicalDeviceProperties *) malloc(data_size); - err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_PROPERTIES, - &data_size, demo->gpu_props); + err = vkGetPhysicalDeviceProperties(demo->gpu, &demo->gpu_props); assert(!err); - err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_QUEUE_PROPERTIES, - &data_size, NULL); + err = vkGetPhysicalDeviceQueueCount(demo->gpu, &queue_count); assert(!err); - demo->queue_props = (VkPhysicalDeviceQueueProperties *) malloc(data_size); - err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_QUEUE_PROPERTIES, - &data_size, demo->queue_props); + demo->queue_props = (VkPhysicalDeviceQueueProperties *) malloc(queue_count * sizeof(VkPhysicalDeviceQueueProperties)); + err = vkGetPhysicalDeviceQueueProperties(demo->gpu, queue_count, demo->queue_props); assert(!err); - queue_count = (uint32_t) (data_size / sizeof(VkPhysicalDeviceQueueProperties)); assert(queue_count >= 1); for (i = 0; i < queue_count; i++) { diff --git a/demos/vulkaninfo.c b/demos/vulkaninfo.c index 9c1d1fc9..fc0f83f7 100644 --- a/demos/vulkaninfo.c +++ b/demos/vulkaninfo.c @@ -378,9 +378,9 @@ static void app_dev_init(struct app_dev *dev, struct app_gpu *gpu) static char *known_extensions[] = { "Validation", }; - size_t extSize = sizeof(uint32_t); - uint32_t extCount = 0; - err = vkGetPhysicalDeviceExtensionInfo(gpu->obj, VK_EXTENSION_INFO_TYPE_COUNT, 0, &extSize, &extCount); + + uint32_t extCount; + err = vkGetPhysicalDeviceExtensionCount(gpu->obj, &extCount); assert(!err); enable_extension_list = malloc(sizeof(VkExtensionProperties) * extCount); @@ -389,15 +389,12 @@ static void app_dev_init(struct app_dev *dev, struct app_gpu *gpu) } VkExtensionProperties extProp; - extSize = sizeof(VkExtensionProperties); gpu->device_extension_count = 0; bool32_t U_ASSERT_ONLY extFound = 0; // TODO : Need to enhance this if/when we enable multiple extensions for (uint32_t i = 0; i < ARRAY_SIZE(known_extensions); i++) { for (uint32_t j = 0; j < extCount; j++) { - err = vkGetPhysicalDeviceExtensionInfo( - gpu->obj, VK_EXTENSION_INFO_TYPE_PROPERTIES, - j, &extSize, - &extProp); + err = vkGetPhysicalDeviceExtensionProperties( + gpu->obj, j, &extProp); if (!strcmp(known_extensions[i], extProp.name)) { extFound = 1; memcpy(&enable_extension_list[gpu->device_extension_count], &extProp, sizeof(extProp)); @@ -451,13 +448,13 @@ static void app_create_instance(struct app_instance *inst) static char *known_extensions[] = { "VK_WSI_LunarG", }; - size_t extSize = sizeof(uint32_t); + uint32_t extCount = 0; VkExtensionProperties extProp; VkExtensionProperties *enable_extension_list; uint32_t global_extension_count = 0; - err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_COUNT, 0, &extSize, &extCount); + err = vkGetGlobalExtensionCount(&extCount); assert(!err); enable_extension_list = malloc(sizeof(VkExtensionProperties) * extCount); @@ -465,11 +462,10 @@ static void app_create_instance(struct app_instance *inst) ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); } - extSize = sizeof(VkExtensionProperties); bool32_t U_ASSERT_ONLY extFound = 0; // TODO : Need to enhance this if/when we enable multiple extensions for (uint32_t i = 0; i < ARRAY_SIZE(known_extensions); i++) { for (uint32_t j = 0; j < extCount; j++) { - err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_PROPERTIES, j, &extSize, &extProp); + err = vkGetGlobalExtensionProperties(j, &extProp); if (!strcmp(known_extensions[i], extProp.name)) { extFound = 1; memcpy(&enable_extension_list[global_extension_count], &extProp, sizeof(extProp)); @@ -503,7 +499,6 @@ static void app_destroy_instance(struct app_instance *inst) static void app_gpu_init(struct app_gpu *gpu, uint32_t id, VkPhysicalDevice obj) { - size_t size; VkResult err; uint32_t i; @@ -511,41 +506,30 @@ static void app_gpu_init(struct app_gpu *gpu, uint32_t id, VkPhysicalDevice obj) gpu->id = id; gpu->obj = obj; - size = sizeof(gpu->props); - err = vkGetPhysicalDeviceInfo(gpu->obj, - VK_PHYSICAL_DEVICE_INFO_TYPE_PROPERTIES, - &size, &gpu->props); - if (err || size != sizeof(gpu->props)) + + err = vkGetPhysicalDeviceProperties(gpu->obj, &gpu->props); + if (err) ERR_EXIT(err); - size = sizeof(gpu->perf); - err = vkGetPhysicalDeviceInfo(gpu->obj, - VK_PHYSICAL_DEVICE_INFO_TYPE_PERFORMANCE, - &size, &gpu->perf); - if (err || size != sizeof(gpu->perf)) + err = vkGetPhysicalDevicePerformance(gpu->obj, &gpu->perf); + if (err) ERR_EXIT(err); /* get queue count */ - err = vkGetPhysicalDeviceInfo(gpu->obj, - VK_PHYSICAL_DEVICE_INFO_TYPE_QUEUE_PROPERTIES, - &size, NULL); - if (err || size % sizeof(gpu->queue_props[0])) + err = vkGetPhysicalDeviceQueueCount(gpu->obj, &gpu->queue_count); + if (err) ERR_EXIT(err); - gpu->queue_count = (uint32_t) (size / sizeof(gpu->queue_props[0])); gpu->queue_props = malloc(sizeof(gpu->queue_props[0]) * gpu->queue_count); - size = sizeof(gpu->queue_props[0]) * gpu->queue_count; + if (!gpu->queue_props) ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); - err = vkGetPhysicalDeviceInfo(gpu->obj, - VK_PHYSICAL_DEVICE_INFO_TYPE_QUEUE_PROPERTIES, - &size, gpu->queue_props); - if (err || size != sizeof(gpu->queue_props[0]) * gpu->queue_count) + err = vkGetPhysicalDeviceQueueProperties(gpu->obj, gpu->queue_count, gpu->queue_props); + if (err) ERR_EXIT(err); /* set up queue requests */ - size = sizeof(*gpu->queue_reqs) * gpu->queue_count; gpu->queue_reqs = malloc(sizeof(*gpu->queue_reqs) * gpu->queue_count); if (!gpu->queue_reqs) ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); @@ -554,11 +538,8 @@ static void app_gpu_init(struct app_gpu *gpu, uint32_t id, VkPhysicalDevice obj) gpu->queue_reqs[i].queueCount = gpu->queue_props[i].queueCount; } - size = sizeof(gpu->memory_props); - err = vkGetPhysicalDeviceInfo(gpu->obj, - VK_PHYSICAL_DEVICE_INFO_TYPE_MEMORY_PROPERTIES, - &size, &gpu->memory_props); - if (err || size != sizeof(gpu->memory_props)) + err = vkGetPhysicalDeviceMemoryProperties(gpu->obj, &gpu->memory_props); + if (err) ERR_EXIT(err); app_dev_init(&gpu->dev, gpu); diff --git a/icd/nulldrv/VK_nulldrv.def b/icd/nulldrv/VK_nulldrv.def index 8c3fb262..604416fc 100644 --- a/icd/nulldrv/VK_nulldrv.def +++ b/icd/nulldrv/VK_nulldrv.def @@ -30,7 +30,8 @@ EXPORTS vkCreateInstance vkDestroyInstance vkEnumeratePhysicalDevices - vkGetGlobalExtensionInfo + vkGetGlobalExtensionProperties + vkGetGlobalExtensionCount xcbCreateWindow xcbDestroyWindow xcbGetMessage diff --git a/icd/nulldrv/nulldrv.c b/icd/nulldrv/nulldrv.c index f726b670..599e84c4 100644 --- a/icd/nulldrv/nulldrv.c +++ b/icd/nulldrv/nulldrv.c @@ -56,30 +56,6 @@ static struct nulldrv_base *nulldrv_base(VkObject base) return (struct nulldrv_base *) base; } -static VkResult nulldrv_base_get_info(struct nulldrv_base *base, int type, - size_t *size, void *data) -{ - VkResult ret = VK_SUCCESS; - size_t s; - - switch (type) { - case VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS: - { - s = sizeof(VkMemoryRequirements); - *size = s; - if (data == NULL) - return ret; - memset(data, 0, s); - break; - } - default: - ret = VK_ERROR_INVALID_VALUE; - break; - } - - return ret; -} - static struct nulldrv_base *nulldrv_base_create( struct nulldrv_dev *dev, size_t obj_size, @@ -110,7 +86,7 @@ static struct nulldrv_base *nulldrv_base_create( } - base->get_info = NULL; + base->get_memory_requirements = NULL; return base; } @@ -303,28 +279,14 @@ static struct nulldrv_img *nulldrv_img_from_base(struct nulldrv_base *base) } -static VkResult img_get_info(struct nulldrv_base *base, int type, - size_t *size, void *data) +static VkResult img_get_memory_requirements(struct nulldrv_base *base, + VkMemoryRequirements *pRequirements) { struct nulldrv_img *img = nulldrv_img_from_base(base); VkResult ret = VK_SUCCESS; - switch (type) { - case VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS: - { - VkMemoryRequirements *mem_req = data; - - *size = sizeof(VkMemoryRequirements); - if (data == NULL) - return ret; - mem_req->size = img->total_size; - mem_req->alignment = 4096; - } - break; - default: - ret = nulldrv_base_get_info(base, type, size, data); - break; - } + pRequirements->size = img->total_size; + pRequirements->alignment = 4096; return ret; } @@ -348,7 +310,7 @@ static VkResult nulldrv_img_create(struct nulldrv_dev *dev, img->usage = info->usage; img->samples = info->samples; - img->obj.base.get_info = img_get_info; + img->obj.base.get_memory_requirements = img_get_memory_requirements; *img_ret = img; @@ -457,32 +419,18 @@ static struct nulldrv_buf *nulldrv_buf_from_base(struct nulldrv_base *base) return (struct nulldrv_buf *) base; } -static VkResult buf_get_info(struct nulldrv_base *base, int type, - size_t *size, void *data) +static VkResult buf_get_memory_requirements(struct nulldrv_base *base, + VkMemoryRequirements* pMemoryRequirements) { struct nulldrv_buf *buf = nulldrv_buf_from_base(base); - VkResult ret = VK_SUCCESS; - - switch (type) { - case VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS: - { - VkMemoryRequirements *mem_req = data; - *size = sizeof(VkMemoryRequirements); - if (data == NULL) - return ret; + if (pMemoryRequirements == NULL) + return VK_SUCCESS; - mem_req->size = buf->size; - mem_req->alignment = 4096; + pMemoryRequirements->size = buf->size; + pMemoryRequirements->alignment = 4096; - } - break; - default: - ret = nulldrv_base_get_info(base, type, size, data); - break; - } - - return ret; + return VK_SUCCESS; } static VkResult nulldrv_buf_create(struct nulldrv_dev *dev, @@ -499,7 +447,7 @@ static VkResult nulldrv_buf_create(struct nulldrv_dev *dev, buf->size = info->size; buf->usage = info->usage; - buf->obj.base.get_info = buf_get_info; + buf->obj.base.get_memory_requirements = buf_get_memory_requirements; *buf_ret = buf; @@ -1404,70 +1352,24 @@ ICD_EXPORT VkResult VKAPI vkWaitForFences( return VK_SUCCESS; } -ICD_EXPORT VkResult VKAPI vkGetPhysicalDeviceInfo( - VkPhysicalDevice gpu_, - VkPhysicalDeviceInfoType infoType, - size_t* pDataSize, - void* pData) +ICD_EXPORT VkResult VKAPI vkGetPhysicalDeviceProperties( + VkPhysicalDevice gpu_, + VkPhysicalDeviceProperties* pProperties) { NULLDRV_LOG_FUNC; VkResult ret = VK_SUCCESS; - switch (infoType) { - case VK_PHYSICAL_DEVICE_INFO_TYPE_PROPERTIES: - { - VkPhysicalDeviceProperties *props = - (VkPhysicalDeviceProperties *) pData; - *pDataSize = sizeof(VkPhysicalDeviceProperties); - if (pData == NULL) { - return ret; - } - props->apiVersion = VK_API_VERSION; - props->driverVersion = 0; // Appropriate that the nulldrv have 0's - props->vendorId = 0; - props->deviceId = 0; - props->deviceType = VK_PHYSICAL_DEVICE_TYPE_OTHER; - strncpy(props->deviceName, "nulldrv", strlen("nulldrv")); - props->maxInlineMemoryUpdateSize = 0; - props->maxBoundDescriptorSets = 0; - props->maxThreadGroupSize = 0; - props->timestampFrequency = 0; - props->multiColorAttachmentClears = false; - break; - } - case VK_PHYSICAL_DEVICE_INFO_TYPE_PERFORMANCE: - { - VkPhysicalDevicePerformance *perf = - (VkPhysicalDevicePerformance *) pData; - *pDataSize = sizeof(VkPhysicalDevicePerformance); - if (pData == NULL) { - return ret; - } - perf->maxDeviceClock = 1.0f; - perf->aluPerClock = 1.0f; - perf->texPerClock = 1.0f; - perf->primsPerClock = 1.0f; - perf->pixelsPerClock = 1.0f; - break; - } - case VK_PHYSICAL_DEVICE_INFO_TYPE_QUEUE_PROPERTIES: - { - VkPhysicalDeviceQueueProperties *props = - (VkPhysicalDeviceQueueProperties *) pData; - *pDataSize = sizeof(VkPhysicalDeviceQueueProperties); - if (pData == NULL) { - return ret; - } - props->queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_SPARSE_MEMMGR_BIT; - props->queueCount = 1; - props->maxAtomicCounters = 1; - props->supportsTimestamps = false; - break; - } - default: -/* FIXME: WRITE THE REAL CODE*/return ret; - break; - } + pProperties->apiVersion = VK_API_VERSION; + pProperties->driverVersion = 0; // Appropriate that the nulldrv have 0's + pProperties->vendorId = 0; + pProperties->deviceId = 0; + pProperties->deviceType = VK_PHYSICAL_DEVICE_TYPE_OTHER; + strncpy(pProperties->deviceName, "nulldrv", strlen("nulldrv")); + pProperties->maxInlineMemoryUpdateSize = 0; + pProperties->maxBoundDescriptorSets = 0; + pProperties->maxThreadGroupSize = 0; + pProperties->timestampFrequency = 0; + pProperties->multiColorAttachmentClears = false; return ret; } @@ -1512,73 +1414,71 @@ ICD_EXPORT VkResult VKAPI vkGetPhysicalDeviceLimits( return ret; } -ICD_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( - VkExtensionInfoType infoType, - uint32_t extensionIndex, - size_t* pDataSize, - void* pData) +ICD_EXPORT VkResult VKAPI vkGetPhysicalDevicePerformance( + VkPhysicalDevice gpu_, + VkPhysicalDevicePerformance* pPerformance) { - uint32_t *count; + pPerformance->maxDeviceClock = 1.0f; + pPerformance->aluPerClock = 1.0f; + pPerformance->texPerClock = 1.0f; + pPerformance->primsPerClock = 1.0f; + pPerformance->pixelsPerClock = 1.0f; - if (pDataSize == NULL) - return VK_ERROR_INVALID_POINTER; + return VK_SUCCESS; +} - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) - return VK_SUCCESS; - count = (uint32_t *) pData; - *count = NULLDRV_EXT_COUNT; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) - return VK_SUCCESS; - else { - if (extensionIndex >= NULLDRV_EXT_COUNT) - return VK_ERROR_INVALID_VALUE; +ICD_EXPORT VkResult VKAPI vkGetPhysicalDeviceQueueCount( + VkPhysicalDevice gpu_, + uint32_t* pCount) +{ + *pCount = 1; + return VK_SUCCESS; +} - memcpy((VkExtensionProperties *) pData, &intel_gpu_exts[extensionIndex], sizeof(VkExtensionProperties)); - return VK_SUCCESS; - } - break; - default: - return VK_ERROR_INVALID_VALUE; - }; +ICD_EXPORT VkResult VKAPI vkGetPhysicalDeviceQueueProperties( + VkPhysicalDevice gpu_, + uint32_t count, + VkPhysicalDeviceQueueProperties* pProperties) + { + pProperties->queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_SPARSE_MEMMGR_BIT; + pProperties->queueCount = 1; + pProperties->maxAtomicCounters = 1; + pProperties->supportsTimestamps = false; return VK_SUCCESS; } -VkResult VKAPI vkGetPhysicalDeviceExtensionInfo( - VkPhysicalDevice gpu, - VkExtensionInfoType infoType, - uint32_t extensionIndex, - size_t* pDataSize, - void* pData) +ICD_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( + uint32_t extensionIndex, + VkExtensionProperties* pProperties) { - uint32_t *count; + if (extensionIndex >= NULLDRV_EXT_COUNT) + return VK_ERROR_INVALID_VALUE; - if (pDataSize == NULL) - return VK_ERROR_INVALID_POINTER; + memcpy(pProperties, &intel_gpu_exts[extensionIndex], sizeof(VkExtensionProperties)); + return VK_SUCCESS; +} - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) - return VK_SUCCESS; - count = (uint32_t *) pData; - *count = 0; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = 0; - if (pData == NULL) - return VK_SUCCESS; - return VK_ERROR_INVALID_EXTENSION; - break; - default: - return VK_ERROR_INVALID_VALUE; - }; +ICD_EXPORT VkResult VKAPI vkGetGlobalExtensionCount(uint32_t *pCount) +{ + *pCount = NULLDRV_EXT_COUNT; + + return VK_SUCCESS; +} + +VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( + VkPhysicalDevice gpu, + uint32_t extesnionIndex, + VkExtensionProperties* pProperties) +{ + return VK_ERROR_INVALID_EXTENSION; +} + +VkResult VKAPI vkGetPhysicalDeviceExtensionCount( + VkPhysicalDevice gpu, + uint32_t* pCount) +{ + *pCount = 0; return VK_SUCCESS; } @@ -1594,38 +1494,20 @@ ICD_EXPORT VkResult VKAPI vkCreateImage( (struct nulldrv_img **) pImage); } -ICD_EXPORT VkResult VKAPI vkGetImageSubresourceInfo( +ICD_EXPORT VkResult VKAPI vkGetImageSubresourceLayout( VkDevice device, VkImage image, const VkImageSubresource* pSubresource, - VkSubresourceInfoType infoType, - size_t* pDataSize, - void* pData) + VkSubresourceLayout* pLayout) { NULLDRV_LOG_FUNC; - VkResult ret = VK_SUCCESS; - switch (infoType) { - case VK_SUBRESOURCE_INFO_TYPE_LAYOUT: - { - VkSubresourceLayout *layout = (VkSubresourceLayout *) pData; + pLayout->offset = 0; + pLayout->size = 1; + pLayout->rowPitch = 4; + pLayout->depthPitch = 4; - *pDataSize = sizeof(VkSubresourceLayout); - - if (pData == NULL) - return ret; - layout->offset = 0; - layout->size = 1; - layout->rowPitch = 4; - layout->depthPitch = 4; - } - break; - default: - ret = VK_ERROR_INVALID_VALUE; - break; - } - - return ret; + return VK_SUCCESS; } ICD_EXPORT VkResult VKAPI vkAllocMemory( @@ -1702,7 +1584,7 @@ ICD_EXPORT VkResult VKAPI vkCreateInstance( if (!inst) return VK_ERROR_OUT_OF_HOST_MEMORY; - inst->obj.base.get_info = NULL; + inst->obj.base.get_memory_requirements = NULL; *pInstance = (VkInstance) inst; @@ -1751,18 +1633,16 @@ ICD_EXPORT VkResult VKAPI vkDestroyObject( return VK_SUCCESS; } -ICD_EXPORT VkResult VKAPI vkGetObjectInfo( +ICD_EXPORT VkResult VKAPI vkGetObjectMemoryRequirements( VkDevice device, VkObjectType objType, VkObject object, - VkObjectInfoType infoType, - size_t* pDataSize, - void* pData) + VkMemoryRequirements* pMemoryRequirements) { NULLDRV_LOG_FUNC; struct nulldrv_base *base = nulldrv_base(object); - return base->get_info(base, infoType, pDataSize, pData); + return base->get_memory_requirements(base, pMemoryRequirements); } ICD_EXPORT VkResult VKAPI vkBindObjectMemory( diff --git a/icd/nulldrv/nulldrv.h b/icd/nulldrv/nulldrv.h index 07cca401..6f3158c2 100644 --- a/icd/nulldrv/nulldrv.h +++ b/icd/nulldrv/nulldrv.h @@ -43,8 +43,7 @@ struct nulldrv_base { void *loader_data; uint32_t magic; - VkResult (*get_info)(struct nulldrv_base *base, int type1, - size_t *size, void *data); + VkResult (*get_memory_requirements)(struct nulldrv_base *base, VkMemoryRequirements *pMemoryRequirements); }; struct nulldrv_obj { diff --git a/include/vkLayer.h b/include/vkLayer.h index 43e44783..971f0307 100644 --- a/include/vkLayer.h +++ b/include/vkLayer.h @@ -41,7 +41,7 @@ typedef struct VkLayerDispatchTable_ PFN_vkFlushMappedMemoryRanges FlushMappedMemoryRanges; PFN_vkInvalidateMappedMemoryRanges InvalidateMappedMemoryRanges; PFN_vkDestroyObject DestroyObject; - PFN_vkGetObjectInfo GetObjectInfo; + PFN_vkGetObjectMemoryRequirements GetObjectMemoryRequirements; PFN_vkBindObjectMemory BindObjectMemory; PFN_vkQueueBindSparseBufferMemory QueueBindSparseBufferMemory; PFN_vkQueueBindSparseImageMemory QueueBindSparseImageMemory; @@ -61,7 +61,7 @@ typedef struct VkLayerDispatchTable_ PFN_vkCreateBuffer CreateBuffer; PFN_vkCreateBufferView CreateBufferView; PFN_vkCreateImage CreateImage; - PFN_vkGetImageSubresourceInfo GetImageSubresourceInfo; + PFN_vkGetImageSubresourceLayout GetImageSubresourceLayout; PFN_vkCreateImageView CreateImageView; PFN_vkCreateColorAttachmentView CreateColorAttachmentView; PFN_vkCreateDepthStencilView CreateDepthStencilView; @@ -141,13 +141,17 @@ typedef struct VkLayerInstanceDispatchTable_ PFN_vkCreateInstance CreateInstance; PFN_vkDestroyInstance DestroyInstance; PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; - PFN_vkGetPhysicalDeviceInfo GetPhysicalDeviceInfo; PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures; PFN_vkGetPhysicalDeviceFormatInfo GetPhysicalDeviceFormatInfo; PFN_vkGetPhysicalDeviceLimits GetPhysicalDeviceLimits; PFN_vkCreateDevice CreateDevice; - /* PFN_vkGetGlobalExtensionInfo GetGlobalExtensionInfo; non-dispatchable */ - PFN_vkGetPhysicalDeviceExtensionInfo GetPhysicalDeviceExtensionInfo; + PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties; + PFN_vkGetPhysicalDevicePerformance GetPhysicalDevicePerformance; + PFN_vkGetPhysicalDeviceQueueCount GetPhysicalDeviceQueueCount; + PFN_vkGetPhysicalDeviceQueueProperties GetPhysicalDeviceQueueProperties; + PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties; + PFN_vkGetPhysicalDeviceExtensionCount GetPhysicalDeviceExtensionCount; + PFN_vkGetPhysicalDeviceExtensionProperties GetPhysicalDeviceExtensionProperties; PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback; PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback; PFN_vkDbgStringCallback DbgStringCallback; diff --git a/include/vulkan.h b/include/vulkan.h index 4052629d..ab03c59d 100644 --- a/include/vulkan.h +++ b/include/vulkan.h @@ -33,7 +33,7 @@ #include "vk_platform.h" // Vulkan API version supported by this file -#define VK_API_VERSION VK_MAKE_VERSION(0, 107, 0) +#define VK_API_VERSION VK_MAKE_VERSION(0, 108, 0) #ifdef __cplusplus extern "C" @@ -535,42 +535,6 @@ typedef enum VkPhysicalDeviceType_ VK_ENUM_RANGE(PHYSICAL_DEVICE_TYPE, OTHER, CPU) } VkPhysicalDeviceType; -typedef enum VkPhysicalDeviceInfoType_ -{ - // Info type for vkGetPhysicalDeviceInfo() - VK_PHYSICAL_DEVICE_INFO_TYPE_PROPERTIES = 0x00000000, - VK_PHYSICAL_DEVICE_INFO_TYPE_PERFORMANCE = 0x00000001, - VK_PHYSICAL_DEVICE_INFO_TYPE_QUEUE_PROPERTIES = 0x00000002, - VK_PHYSICAL_DEVICE_INFO_TYPE_MEMORY_PROPERTIES = 0x00000003, - - VK_ENUM_RANGE(PHYSICAL_DEVICE_INFO_TYPE, PROPERTIES, MEMORY_PROPERTIES) -} VkPhysicalDeviceInfoType; - -typedef enum VkExtensionInfoType_ -{ - // Info type for vkGetGlobalExtensionInfo() and vkGetPhysicalDeviceExtensionInfo() - VK_EXTENSION_INFO_TYPE_COUNT = 0x00000000, - VK_EXTENSION_INFO_TYPE_PROPERTIES = 0x00000001, - - VK_ENUM_RANGE(EXTENSION_INFO_TYPE, COUNT, PROPERTIES) -} VkExtensionInfoType; - -typedef enum VkSubresourceInfoType_ -{ - // Info type for vkGetImageSubresourceInfo() - VK_SUBRESOURCE_INFO_TYPE_LAYOUT = 0x00000000, - - VK_ENUM_RANGE(SUBRESOURCE_INFO_TYPE, LAYOUT, LAYOUT) -} VkSubresourceInfoType; - -typedef enum VkObjectInfoType_ -{ - // Info type for vkGetObjectInfo() - VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS = 0x00000000, - - VK_ENUM_RANGE(OBJECT_INFO_TYPE, MEMORY_REQUIREMENTS, MEMORY_REQUIREMENTS) -} VkObjectInfoType; - typedef enum VkVertexInputStepRate_ { VK_VERTEX_INPUT_STEP_RATE_VERTEX = 0x0, @@ -2060,7 +2024,6 @@ typedef struct VkDispatchIndirectCmd_ typedef VkResult (VKAPI *PFN_vkCreateInstance)(const VkInstanceCreateInfo* pCreateInfo, VkInstance* pInstance); typedef VkResult (VKAPI *PFN_vkDestroyInstance)(VkInstance instance); typedef VkResult (VKAPI *PFN_vkEnumeratePhysicalDevices)(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); -typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceInfo)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceInfoType infoType, size_t* pDataSize, void* pData); typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures); typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceFormatInfo)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties *pFormatInfo); typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceLimits)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceLimits* pLimits); @@ -2068,8 +2031,15 @@ typedef void * (VKAPI *PFN_vkGetInstanceProcAddr)(VkInstance instance, const c typedef void * (VKAPI *PFN_vkGetDeviceProcAddr)(VkDevice device, const char * pName); typedef VkResult (VKAPI *PFN_vkCreateDevice)(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice); typedef VkResult (VKAPI *PFN_vkDestroyDevice)(VkDevice device); -typedef VkResult (VKAPI *PFN_vkGetGlobalExtensionInfo)(VkExtensionInfoType infoType, uint32_t extensionIndex, size_t* pDataSize, void* pData); -typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceExtensionInfo)(VkPhysicalDevice physicalDevice, VkExtensionInfoType infoType, uint32_t extensionIndex, size_t* pDataSize, void* pData); +typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties); +typedef VkResult (VKAPI *PFN_vkGetPhysicalDevicePerformance)(VkPhysicalDevice physicalDevice, VkPhysicalDevicePerformance* pPerformance); +typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceQueueCount)(VkPhysicalDevice physicalDevice, uint32_t* pCount); +typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceQueueProperties)(VkPhysicalDevice physicalDevice, uint32_t count, VkPhysicalDeviceQueueProperties* pQueueProperties); +typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperies); +typedef VkResult (VKAPI *PFN_vkGetGlobalExtensionCount)(uint32_t* pCount); +typedef VkResult (VKAPI *PFN_vkGetGlobalExtensionProperties)(uint32_t extensionIndex, VkExtensionProperties* pProperties); +typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceExtensionCount)(VkPhysicalDevice physicalDevice, uint32_t* pCount); +typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceExtensionProperties)(VkPhysicalDevice physicalDevice, uint32_t extensionIndex, VkExtensionProperties* pProperties); typedef VkResult (VKAPI *PFN_vkGetDeviceQueue)(VkDevice device, uint32_t queueNodeIndex, uint32_t queueIndex, VkQueue* pQueue); typedef VkResult (VKAPI *PFN_vkQueueSubmit)(VkQueue queue, uint32_t cmdBufferCount, const VkCmdBuffer* pCmdBuffers, VkFence fence); typedef VkResult (VKAPI *PFN_vkQueueWaitIdle)(VkQueue queue); @@ -2081,7 +2051,7 @@ typedef VkResult (VKAPI *PFN_vkUnmapMemory)(VkDevice device, VkDeviceMemory mem) typedef VkResult (VKAPI *PFN_vkFlushMappedMemoryRanges)(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges); typedef VkResult (VKAPI *PFN_vkInvalidateMappedMemoryRanges)(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges); typedef VkResult (VKAPI *PFN_vkDestroyObject)(VkDevice device, VkObjectType objType, VkObject object); -typedef VkResult (VKAPI *PFN_vkGetObjectInfo)(VkDevice device, VkObjectType objType, VkObject object, VkObjectInfoType infoType, size_t* pDataSize, void* pData); +typedef VkResult (VKAPI *PFN_vkGetObjectMemoryRequirements)(VkDevice device, VkObjectType objType, VkObject object, VkMemoryRequirements* pMemoryRequirements); typedef VkResult (VKAPI *PFN_vkBindObjectMemory)(VkDevice device, VkObjectType objType, VkObject object, VkDeviceMemory mem, VkDeviceSize offset); typedef VkResult (VKAPI *PFN_vkQueueBindSparseBufferMemory)(VkQueue queue, VkBuffer buffer, VkDeviceSize rangeOffset, VkDeviceSize rangeSize, VkDeviceMemory mem, VkDeviceSize memOffset); typedef VkResult (VKAPI *PFN_vkQueueBindSparseImageMemory)(VkQueue queue, VkImage image, const VkImageMemoryBindInfo* pBindInfo, VkDeviceMemory mem, VkDeviceSize memOffset); @@ -2101,7 +2071,7 @@ typedef VkResult (VKAPI *PFN_vkGetQueryPoolResults)(VkDevice device, VkQueryPool typedef VkResult (VKAPI *PFN_vkCreateBuffer)(VkDevice device, const VkBufferCreateInfo* pCreateInfo, VkBuffer* pBuffer); typedef VkResult (VKAPI *PFN_vkCreateBufferView)(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, VkBufferView* pView); typedef VkResult (VKAPI *PFN_vkCreateImage)(VkDevice device, const VkImageCreateInfo* pCreateInfo, VkImage* pImage); -typedef VkResult (VKAPI *PFN_vkGetImageSubresourceInfo)(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceInfoType infoType, size_t* pDataSize, void* pData); +typedef VkResult (VKAPI *PFN_vkGetImageSubresourceLayout)(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout); typedef VkResult (VKAPI *PFN_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView); typedef VkResult (VKAPI *PFN_vkCreateColorAttachmentView)(VkDevice device, const VkColorAttachmentViewCreateInfo* pCreateInfo, VkColorAttachmentView* pView); typedef VkResult (VKAPI *PFN_vkCreateDepthStencilView)(VkDevice device, const VkDepthStencilViewCreateInfo* pCreateInfo, VkDepthStencilView* pView); @@ -2182,12 +2152,6 @@ VkResult VKAPI vkEnumeratePhysicalDevices( uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); -VkResult VKAPI vkGetPhysicalDeviceInfo( - VkPhysicalDevice physicalDevice, - VkPhysicalDeviceInfoType infoType, - size_t* pDataSize, - void* pData); - VkResult VKAPI vkGetPhysicalDeviceFeatures( VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures); @@ -2201,7 +2165,6 @@ VkResult VKAPI vkGetPhysicalDeviceLimits( VkPhysicalDevice physicalDevice, VkPhysicalDeviceLimits* pLimits); - void * VKAPI vkGetInstanceProcAddr( VkInstance instance, const char* pName); @@ -2219,20 +2182,44 @@ VkResult VKAPI vkCreateDevice( VkResult VKAPI vkDestroyDevice( VkDevice device); +VkResult VKAPI vkGetPhysicalDeviceProperties( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceProperties* pProperties); + +VkResult VKAPI vkGetPhysicalDevicePerformance( + VkPhysicalDevice physicalDevice, + VkPhysicalDevicePerformance* pPerformance); + +VkResult VKAPI vkGetPhysicalDeviceQueueCount( + VkPhysicalDevice physicalDevice, + uint32_t* pCount); + +VkResult VKAPI vkGetPhysicalDeviceQueueProperties( + VkPhysicalDevice physicalDevice, + uint32_t count, + VkPhysicalDeviceQueueProperties* pQueueProperties); + +VkResult VKAPI vkGetPhysicalDeviceMemoryProperties( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceMemoryProperties* pMemoryProperies); + // Extension discovery functions -VkResult VKAPI vkGetGlobalExtensionInfo( - VkExtensionInfoType infoType, +VkResult VKAPI vkGetGlobalExtensionCount( + uint32_t* pCount); + +VkResult VKAPI vkGetGlobalExtensionProperties( uint32_t extensionIndex, - size_t* pDataSize, - void* pData); + VkExtensionProperties* pProperties); + +VkResult VKAPI vkGetPhysicalDeviceExtensionCount( + VkPhysicalDevice physicalDevice, + uint32_t* pCount); -VkResult VKAPI vkGetPhysicalDeviceExtensionInfo( +VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( VkPhysicalDevice physicalDevice, - VkExtensionInfoType infoType, uint32_t extensionIndex, - size_t* pDataSize, - void* pData); + VkExtensionProperties* pProperties); // Queue functions @@ -2294,14 +2281,6 @@ VkResult VKAPI vkDestroyObject( VkObjectType objType, VkObject object); -VkResult VKAPI vkGetObjectInfo( - VkDevice device, - VkObjectType objType, - VkObject object, - VkObjectInfoType infoType, - size_t* pDataSize, - void* pData); - // Memory management API functions VkResult VKAPI vkBindObjectMemory( @@ -2311,6 +2290,12 @@ VkResult VKAPI vkBindObjectMemory( VkDeviceMemory mem, VkDeviceSize memOffset); +VkResult VKAPI vkGetObjectMemoryRequirements( + VkDevice device, + VkObjectType objType, + VkObject object, + VkMemoryRequirements* pMemoryRequirements); + VkResult VKAPI vkQueueBindSparseBufferMemory( VkQueue queue, VkBuffer buffer, @@ -2420,13 +2405,11 @@ VkResult VKAPI vkCreateImage( const VkImageCreateInfo* pCreateInfo, VkImage* pImage); -VkResult VKAPI vkGetImageSubresourceInfo( +VkResult VKAPI vkGetImageSubresourceLayout( VkDevice device, VkImage image, const VkImageSubresource* pSubresource, - VkSubresourceInfoType infoType, - size_t* pDataSize, - void* pData); + VkSubresourceLayout* pLayout); // Image view functions diff --git a/layers/basic.cpp b/layers/basic.cpp index 59ec08d4..990f6697 100644 --- a/layers/basic.cpp +++ b/layers/basic.cpp @@ -61,41 +61,26 @@ static const VkExtensionProperties basicExts[BASIC_LAYER_EXT_ARRAY_SIZE] = { } }; -VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( - VkExtensionInfoType infoType, +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( uint32_t extensionIndex, - size_t* pDataSize, - void* pData) + VkExtensionProperties* pData) { /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ uint32_t *count; - if (pDataSize == NULL) - return VK_ERROR_INVALID_POINTER; - - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) - return VK_SUCCESS; - count = (uint32_t *) pData; - *count = BASIC_LAYER_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) - return VK_SUCCESS; - if (extensionIndex >= BASIC_LAYER_EXT_ARRAY_SIZE) - return VK_ERROR_INVALID_VALUE; - memcpy((VkExtensionProperties *) pData, &basicExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - }; + if (extensionIndex >= BASIC_LAYER_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; + memcpy((VkExtensionProperties *) pData, &basicExts[extensionIndex], sizeof(VkExtensionProperties)); return VK_SUCCESS; } +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionCount(uint32_t* pCount) +{ + *pCount = BASIC_LAYER_EXT_ARRAY_SIZE; + return VK_SUCCESS; +} + VK_LAYER_EXPORT VkResult VKAPI vkEnumeratePhysicalDevices( VkInstance instance, uint32_t* pPhysicalDeviceCount, @@ -181,8 +166,10 @@ VK_LAYER_EXPORT void * VKAPI vkGetInstanceProcAddr(VkInstance instance, const ch return (void *) vkDestroyInstance; if (!strcmp("vkEnumeratePhysicalDevices", pName)) return (void*) vkEnumeratePhysicalDevices; - if (!strcmp("vkGetGlobalExtensionInfo", pName)) - return (void*) vkGetGlobalExtensionInfo; + if (!strcmp("vkGetGlobalExtensionCount", pName)) + return (void*) vkGetGlobalExtensionCount; + if (!strcmp("vkGetGlobalExtensionProperties", pName)) + return (void*) vkGetGlobalExtensionProperties; if (!strcmp("vkCreateDevice", pName)) return (void *) vkCreateDevice; else diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index 3d6cccf8..94c471fe 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -1641,41 +1641,22 @@ static const VkExtensionProperties dsDevExts[DRAW_STATE_LAYER_DEV_EXT_ARRAY_SIZE }; //TODO add DEBUG_MARKER to device extension list -VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionInfo( - VkPhysicalDevice physical_device, - VkExtensionInfoType infoType, - uint32_t extensionIndex, - size_t *pDataSize, - void *pData) +VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionCount( + VkPhysicalDevice gpu, + uint32_t* pCount) { - uint32_t *count; - - if (pDataSize == NULL) { - return VK_ERROR_INVALID_POINTER; - } + *pCount = DRAW_STATE_LAYER_DEV_EXT_ARRAY_SIZE; + return VK_SUCCESS; +} - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) { - return VK_SUCCESS; - } - count = (uint32_t *) pData; - *count = DRAW_STATE_LAYER_DEV_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) { - return VK_SUCCESS; - } - if (extensionIndex >= DRAW_STATE_LAYER_DEV_EXT_ARRAY_SIZE) { - return VK_ERROR_INVALID_VALUE; - } - memcpy((VkExtensionProperties *) pData, &dsDevExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - } +VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( + VkPhysicalDevice gpu, + uint32_t extensionIndex, + VkExtensionProperties* pProperties) +{ + if (extensionIndex >= DRAW_STATE_LAYER_DEV_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; + memcpy(pProperties, &dsDevExts[extensionIndex], sizeof(VkExtensionProperties)); return VK_SUCCESS; } @@ -1695,38 +1676,22 @@ static const VkExtensionProperties dsExts[DRAW_STATE_LAYER_EXT_ARRAY_SIZE] = { "Sample layer: DrawState", } }; +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionCount( + uint32_t* pCount) +{ + *pCount = DRAW_STATE_LAYER_EXT_ARRAY_SIZE; + return VK_SUCCESS; +} -VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( - VkExtensionInfoType infoType, +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( uint32_t extensionIndex, - size_t* pDataSize, - void* pData) + VkExtensionProperties* pProperties) { /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ - uint32_t *count; - - if (pDataSize == NULL) - return VK_ERROR_INVALID_POINTER; - - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) - return VK_SUCCESS; - count = (uint32_t *) pData; - *count = DRAW_STATE_LAYER_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) - return VK_SUCCESS; - if (extensionIndex >= DRAW_STATE_LAYER_EXT_ARRAY_SIZE) - return VK_ERROR_INVALID_VALUE; - memcpy((VkExtensionProperties *) pData, &dsExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - }; + if (extensionIndex >= DRAW_STATE_LAYER_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; + + memcpy(pProperties, &dsExts[extensionIndex], sizeof(VkExtensionProperties)); return VK_SUCCESS; } @@ -2931,6 +2896,10 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr(VkDevice dev, const char* funcNa return (void*) vkEndCommandBuffer; if (!strcmp(funcName, "vkResetCommandBuffer")) return (void*) vkResetCommandBuffer; + if (!strcmp(funcName, "vkGetGlobalExtensionCount")) + return (void*) vkGetGlobalExtensionCount; + if (!strcmp(funcName, "vkGetGlobalExtensionProperties")) + return (void*) vkGetGlobalExtensionProperties; if (!strcmp(funcName, "vkCmdBindPipeline")) return (void*) vkCmdBindPipeline; if (!strcmp(funcName, "vkCmdBindDynamicStateObject")) @@ -3044,6 +3013,10 @@ VK_LAYER_EXPORT void * VKAPI vkGetInstanceProcAddr(VkInstance instance, const ch return (void *) vkDestroyInstance; if (!strcmp(funcName, "vkCreateDevice")) return (void*) vkCreateDevice; + if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionCount")) + return (void*) vkGetPhysicalDeviceExtensionCount; + if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionProperties")) + return (void*) vkGetPhysicalDeviceExtensionProperties; layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); fptr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); diff --git a/layers/image.cpp b/layers/image.cpp index b1fc81f6..bde0a953 100644 --- a/layers/image.cpp +++ b/layers/image.cpp @@ -215,78 +215,44 @@ static const VkExtensionProperties pcExts[IMAGE_LAYER_EXT_ARRAY_SIZE] = { "Sample layer: Image", } }; +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionCount( + uint32_t* pCount) +{ + *pCount = IMAGE_LAYER_EXT_ARRAY_SIZE; + return VK_SUCCESS; +} -VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( - VkExtensionInfoType infoType, +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( uint32_t extensionIndex, - size_t* pDataSize, - void* pData) + VkExtensionProperties* pProperties) { /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ - uint32_t *count = NULL; - if (pDataSize == NULL) - { - return VK_ERROR_INVALID_POINTER; - } + if (extensionIndex >= IMAGE_LAYER_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; + memcpy(pProperties, &pcExts[extensionIndex], sizeof(VkExtensionProperties)); - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) - return VK_SUCCESS; - count = (uint32_t *) pData; - *count = IMAGE_LAYER_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) - return VK_SUCCESS; - if (extensionIndex >= IMAGE_LAYER_EXT_ARRAY_SIZE) - return VK_ERROR_INVALID_VALUE; - memcpy((VkExtensionProperties *) pData, &pcExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - }; + return VK_SUCCESS; +} +VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionCount( + VkPhysicalDevice gpu, + uint32_t* pCount) +{ + *pCount = IMAGE_LAYER_EXT_ARRAY_SIZE; return VK_SUCCESS; } -VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionInfo( +VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( VkPhysicalDevice gpu, - VkExtensionInfoType infoType, uint32_t extensionIndex, - size_t* pDataSize, - void* pData) + VkExtensionProperties* pProperties) { /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ - uint32_t *count = NULL; - - if (pDataSize == NULL) - { - return VK_ERROR_INVALID_POINTER; - } - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) - return VK_SUCCESS; - count = (uint32_t *) pData; - *count = IMAGE_LAYER_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) - return VK_SUCCESS; - if (extensionIndex >= IMAGE_LAYER_EXT_ARRAY_SIZE) - return VK_ERROR_INVALID_VALUE; - memcpy((VkExtensionProperties *) pData, &pcExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - }; + if (extensionIndex >= IMAGE_LAYER_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; + memcpy(pProperties, &pcExts[extensionIndex], sizeof(VkExtensionProperties)); return VK_SUCCESS; } @@ -426,6 +392,10 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr(VkDevice device, const char* fun return (void*) vkCreateImage; if (!strcmp(funcName, "vkCreateRenderPass")) return (void*) vkCreateRenderPass; + if (!strcmp(funcName, "vkGetGlobalExtensionProperties")) + return (void*) vkGetGlobalExtensionProperties; + if (!strcmp(funcName, "vkGetGlobalExtensionCount")) + return (void*) vkGetGlobalExtensionCount; { if (get_dispatch_table(image_device_table_map, device)->GetDeviceProcAddr == NULL) @@ -452,10 +422,10 @@ VK_LAYER_EXPORT void* VKAPI vkGetInstanceProcAddr(VkInstance instance, const cha return (void *) vkDestroyInstance; if (!strcmp(funcName, "vkCreateDevice")) return (void*) vkCreateDevice; - if (!strcmp(funcName, "vkGetGlobalExtensionInfo")) - return (void*) vkGetGlobalExtensionInfo; - if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionInfo")) - return (void*) vkGetPhysicalDeviceExtensionInfo; + if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionProperties")) + return (void*) vkGetPhysicalDeviceExtensionProperties; + if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionCount")) + return (void*) vkGetPhysicalDeviceExtensionCount; layer_data *data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); void* fptr = debug_report_get_instance_proc_addr(data->report_data, funcName); diff --git a/layers/mem_tracker.cpp b/layers/mem_tracker.cpp index 099a6b2e..7aebf420 100644 --- a/layers/mem_tracker.cpp +++ b/layers/mem_tracker.cpp @@ -969,41 +969,22 @@ static const VkExtensionProperties mtExts[MEM_TRACKER_LAYER_EXT_ARRAY_SIZE] = { } }; -VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( - VkExtensionInfoType infoType, - uint32_t extensionIndex, - size_t *pDataSize, - void *pData) +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( + uint32_t extensionIndex, + VkExtensionProperties* pData) { - // This entrypoint is NOT going to init its own dispatch table since loader calls here early - uint32_t *count; + /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ - if (pDataSize == NULL) { - return VK_ERROR_INVALID_POINTER; - } + if (extensionIndex >= MEM_TRACKER_LAYER_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; + memcpy((VkExtensionProperties *) pData, &mtExts[extensionIndex], sizeof(VkExtensionProperties)); - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) { - return VK_SUCCESS; - } - count = (uint32_t *) pData; - *count = MEM_TRACKER_LAYER_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) { - return VK_SUCCESS; - } - if (extensionIndex >= MEM_TRACKER_LAYER_EXT_ARRAY_SIZE) { - return VK_ERROR_INVALID_VALUE; - } - memcpy((VkExtensionProperties *) pData, &mtExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - }; + return VK_SUCCESS; +} + +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionCount(uint32_t* pCount) +{ + *pCount = MEM_TRACKER_LAYER_EXT_ARRAY_SIZE; return VK_SUCCESS; } @@ -1030,41 +1011,23 @@ static const VkExtensionProperties mtDevExts[MEM_TRACKER_LAYER_DEV_EXT_ARRAY_SIZ } }; -VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionInfo( - VkPhysicalDevice physical_device, - VkExtensionInfoType infoType, - uint32_t extensionIndex, - size_t *pDataSize, - void *pData) -{ - uint32_t *count; - if (pDataSize == NULL) { - return VK_ERROR_INVALID_POINTER; - } +VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionCount( + VkPhysicalDevice gpu, + uint32_t* pCount) +{ + *pCount = MEM_TRACKER_LAYER_DEV_EXT_ARRAY_SIZE; + return VK_SUCCESS; +} - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) { - return VK_SUCCESS; - } - count = (uint32_t *) pData; - *count = MEM_TRACKER_LAYER_DEV_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) { - return VK_SUCCESS; - } - if (extensionIndex >= MEM_TRACKER_LAYER_DEV_EXT_ARRAY_SIZE) { - return VK_ERROR_INVALID_VALUE; - } - memcpy((VkExtensionProperties *) pData, &mtDevExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - } +VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( + VkPhysicalDevice gpu, + uint32_t extensionIndex, + VkExtensionProperties* pProperties) +{ + if (extensionIndex >= MEM_TRACKER_LAYER_DEV_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; + memcpy(pProperties, &mtDevExts[extensionIndex], sizeof(VkExtensionProperties)); return VK_SUCCESS; } @@ -1219,19 +1182,17 @@ VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject( return result; } -VK_LAYER_EXPORT VkResult VKAPI vkGetObjectInfo( - VkDevice device, - VkObjectType objType, - VkObject object, - VkObjectInfoType infoType, - size_t *pDataSize, - void *pData) +VK_LAYER_EXPORT VkResult VKAPI vkGetObjectMemoryRequirements( + VkDevice device, + VkObjectType objType, + VkObject object, + VkMemoryRequirements* pRequirements) { // TODO : What to track here? // Could potentially save returned mem requirements and validate values passed into BindObjectMemory for this object // From spec : The only objects that are guaranteed to have no external memory requirements are devices, queues, // command buffers, shaders and memory objects. - VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->GetObjectInfo(device, objType, object, infoType, pDataSize, pData); + VkResult result = get_dispatch_table(mem_tracker_device_table_map, device)->GetObjectMemoryRequirements(device, objType, object, pRequirements); return result; } @@ -2207,8 +2168,8 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr( return (void*) vkUnmapMemory; if (!strcmp(funcName, "vkDestroyObject")) return (void*) vkDestroyObject; - if (!strcmp(funcName, "vkGetObjectInfo")) - return (void*) vkGetObjectInfo; + if (!strcmp(funcName, "vkGetObjectMemoryRequirements")) + return (void*) vkGetObjectMemoryRequirements; if (!strcmp(funcName, "vkBindObjectMemory")) return (void*) vkBindObjectMemory; if (!strcmp(funcName, "vkQueueBindSparseBufferMemory")) @@ -2309,6 +2270,10 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr( return (void*) vkCmdResetQueryPool; if (!strcmp(funcName, "vkGetDeviceQueue")) return (void*) vkGetDeviceQueue; + if (!strcmp(funcName, "vkGetGlobalExtensionCount")) + return (void*) vkGetGlobalExtensionCount; + if (!strcmp(funcName, "vkGetGlobalExtensionProperties")) + return (void*) vkGetGlobalExtensionProperties; VkLayerDispatchTable *pDisp = get_dispatch_table(mem_tracker_device_table_map, dev); if (deviceExtMap.size() == 0 || deviceExtMap[pDisp].wsi_lunarg_enabled) @@ -2349,6 +2314,10 @@ VK_LAYER_EXPORT void* VKAPI vkGetInstanceProcAddr( return (void*) vkCreateInstance; if (!strcmp(funcName, "vkCreateDevice")) return (void*) vkCreateDevice; + if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionCount")) + return (void*) vkGetGlobalExtensionCount; + if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionProperties")) + return (void*) vkGetGlobalExtensionProperties; layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); fptr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); diff --git a/layers/multi.cpp b/layers/multi.cpp index fc0bb38e..5f86b88a 100644 --- a/layers/multi.cpp +++ b/layers/multi.cpp @@ -199,8 +199,10 @@ VK_LAYER_EXPORT void * VKAPI multi1GetInstanceProcAddr(VkInstance inst, const ch } if (!strcmp("vkDestroyInstance", pName)) return (void *) multi1DestroyInstance; - if (!strcmp("GetGlobalExtensionInfo", pName)) - return (void*) vkGetGlobalExtensionInfo; + if (!strcmp("GetGlobalExtensionProperties", pName)) + return (void*) vkGetGlobalExtensionProperties; + if (!strcmp("GetGlobalExtensionCount", pName)) + return (void*) vkGetGlobalExtensionCount; else { VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) inst; VkLayerInstanceDispatchTable* pTable = instance_dispatch_table1(inst); @@ -376,8 +378,10 @@ VK_LAYER_EXPORT void * VKAPI multi2GetInstanceProcAddr(VkInstance inst, const ch return (void *) multi2DestroyInstance; if (!strcmp("vkCreateDevice", pName)) return (void *) multi2CreateDevice; - else if (!strcmp("GetGlobalExtensionInfo", pName)) - return (void*) vkGetGlobalExtensionInfo; + else if (!strcmp("GetGlobalExtensionProperties", pName)) + return (void*) vkGetGlobalExtensionProperties; + else if (!strcmp("GetGlobalExtensionCount", pName)) + return (void*) vkGetGlobalExtensionCount; else { VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) inst; VkLayerInstanceDispatchTable* pTable = instance_dispatch_table2(inst); @@ -414,37 +418,22 @@ static const VkExtensionProperties multiExts[MULTI_LAYER_EXT_ARRAY_SIZE] = { } }; -VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( - VkExtensionInfoType infoType, +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionCount( + uint32_t* pCount) +{ + *pCount = MULTI_LAYER_EXT_ARRAY_SIZE; + return VK_SUCCESS; +} + +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( uint32_t extensionIndex, - size_t* pDataSize, - void* pData) + VkExtensionProperties* pProperties) { /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ - uint32_t *count; - - if (pDataSize == NULL) - return VK_ERROR_INVALID_POINTER; - - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) - return VK_SUCCESS; - count = (uint32_t *) pData; - *count = MULTI_LAYER_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) - return VK_SUCCESS; - if (extensionIndex >= MULTI_LAYER_EXT_ARRAY_SIZE) - return VK_ERROR_INVALID_VALUE; - memcpy((VkExtensionProperties *) pData, &multiExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - }; + if (extensionIndex >= MULTI_LAYER_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; + + memcpy(pProperties, &multiExts[extensionIndex], sizeof(VkExtensionProperties)); return VK_SUCCESS; } diff --git a/layers/object_track.h b/layers/object_track.h index 428bee39..c52862f0 100644 --- a/layers/object_track.h +++ b/layers/object_track.h @@ -350,13 +350,13 @@ reset_status( static void setGpuQueueInfoState( - size_t *pDataSize, - void *pData) + uint32_t count, + void *pData) { - queueCount = ((uint32_t)*pDataSize / sizeof(VkPhysicalDeviceQueueProperties)); - queueInfo = (VkPhysicalDeviceQueueProperties*)realloc((void*)queueInfo, *pDataSize); + queueCount = count; + queueInfo = (VkPhysicalDeviceQueueProperties*)realloc((void*)queueInfo, count * sizeof(VkPhysicalDeviceQueueProperties)); if (queueInfo != NULL) { - memcpy(queueInfo, pData, *pDataSize); + memcpy(queueInfo, pData, count * sizeof(VkPhysicalDeviceQueueProperties)); } } @@ -519,20 +519,16 @@ explicit_DestroyInstance( } VkResult -explicit_GetPhysicalDeviceInfo( - VkPhysicalDevice gpu, - VkPhysicalDeviceInfoType infoType, - size_t *pDataSize, - void *pData) -{ - VkResult result = get_dispatch_table(ObjectTracker_instance_table_map, gpu)->GetPhysicalDeviceInfo(gpu, infoType, pDataSize, pData); - if (infoType == VK_PHYSICAL_DEVICE_INFO_TYPE_QUEUE_PROPERTIES) { - if (pData != NULL) { - loader_platform_thread_lock_mutex(&objLock); - setGpuQueueInfoState(pDataSize, pData); - loader_platform_thread_unlock_mutex(&objLock); - } - } +explicit_GetPhysicalDeviceQueueProperties( + VkPhysicalDevice gpu, + uint32_t count, + VkPhysicalDeviceQueueProperties* pProperties) +{ + VkResult result = get_dispatch_table(ObjectTracker_instance_table_map, gpu)->GetPhysicalDeviceQueueProperties(gpu, count, pProperties); + + loader_platform_thread_lock_mutex(&objLock); + setGpuQueueInfoState(count, pProperties); + loader_platform_thread_unlock_mutex(&objLock); return result; } @@ -685,21 +681,19 @@ explicit_DestroyObject( } VkResult -explicit_GetObjectInfo( - VkDevice device, - VkObjectType objType, - VkObject object, - VkObjectInfoType infoType, - size_t *pDataSize, - void *pData) +explicit_GetObjectMemoryRequirements( + VkDevice device, + VkObjectType objType, + VkObject object, + VkMemoryRequirements* pMemoryRequirements) { loader_platform_thread_lock_mutex(&objLock); - validateObjectType(device, "vkGetObjectInfo", objType, object); + validateObjectType(device, "vkGetObjectMemoryRequirements", objType, object); validate_object(device, device); validate_object(device, object); loader_platform_thread_unlock_mutex(&objLock); - VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->GetObjectInfo(device, objType, object, infoType, pDataSize, pData); + VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->GetObjectMemoryRequirements(device, objType, object, pMemoryRequirements); return result; } diff --git a/layers/param_checker.cpp b/layers/param_checker.cpp index 0bed8691..e845c4cf 100644 --- a/layers/param_checker.cpp +++ b/layers/param_checker.cpp @@ -153,17 +153,6 @@ VK_LAYER_EXPORT VkResult VKAPI vkDestroyInstance(VkInstance instance) return res; } -VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceInfo(VkPhysicalDevice gpu, VkPhysicalDeviceInfoType infoType, size_t* pDataSize, void* pData) -{ - char str[1024]; - if (!validate_VkPhysicalDeviceInfoType(infoType)) { - sprintf(str, "Parameter infoType to function GetPhysicalDeviceInfo has invalid value of %i.", (int)infoType); - layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str); - } - VkResult result = instance_dispatch_table(gpu)->GetPhysicalDeviceInfo(gpu, infoType, pDataSize, pData); - return result; -} - void PreCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo) { if(gpu == nullptr) @@ -295,37 +284,22 @@ static const VkExtensionProperties pcExts[PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE] = } }; -VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( - VkExtensionInfoType infoType, - uint32_t extensionIndex, - size_t* pDataSize, - void* pData) +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionCount( + uint32_t* pCount) +{ + *pCount = PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE; + return VK_SUCCESS; +} + +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( + uint32_t extensionIndex, + VkExtensionProperties* pProperties) { /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ - uint32_t *count; - - if (pDataSize == NULL) - return VK_ERROR_INVALID_POINTER; - - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) - return VK_SUCCESS; - count = (uint32_t *) pData; - *count = PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) - return VK_SUCCESS; - if (extensionIndex >= PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE) - return VK_ERROR_INVALID_VALUE; - memcpy((VkExtensionProperties *) pData, &pcExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - }; + + if (extensionIndex >= PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; + memcpy(pProperties, &pcExts[extensionIndex], sizeof(VkExtensionProperties)); return VK_SUCCESS; } @@ -357,38 +331,25 @@ static const VkExtensionProperties pcDevExts[PARAM_CHECKER_LAYER_DEV_EXT_ARRAY_S "Sample layer: ParamChecker", } }; -VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionInfo( + +VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionCount( + VkPhysicalDevice gpu, + uint32_t* pCount) +{ + *pCount = PARAM_CHECKER_LAYER_DEV_EXT_ARRAY_SIZE; + return VK_SUCCESS; +} + +VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( VkPhysicalDevice gpu, - VkExtensionInfoType infoType, uint32_t extensionIndex, - size_t* pDataSize, - void* pData) + VkExtensionProperties* pProperties) { /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ - uint32_t *count; - - if (pDataSize == NULL) - return VK_ERROR_INVALID_POINTER; - - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) - return VK_SUCCESS; - count = (uint32_t *) pData; - *count = PARAM_CHECKER_LAYER_DEV_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) - return VK_SUCCESS; - if (extensionIndex >= PARAM_CHECKER_LAYER_DEV_EXT_ARRAY_SIZE) - return VK_ERROR_INVALID_VALUE; - memcpy((VkExtensionProperties *) pData, &pcDevExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - }; + + if (extensionIndex >= PARAM_CHECKER_LAYER_DEV_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; + memcpy(pProperties, &pcDevExts[extensionIndex], sizeof(VkExtensionProperties)); return VK_SUCCESS; } @@ -481,14 +442,9 @@ VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject(VkDevice device, VkObjectType obj return result; } -VK_LAYER_EXPORT VkResult VKAPI vkGetObjectInfo(VkDevice device, VkObjectType objType, VkObject object, VkObjectInfoType infoType, size_t* pDataSize, void* pData) +VK_LAYER_EXPORT VkResult VKAPI vkGetObjectMemoryRequirements(VkDevice device, VkObjectType objType, VkObject object, VkMemoryRequirements* pData) { - char str[1024]; - if (!validate_VkObjectInfoType(infoType)) { - sprintf(str, "Parameter infoType to function GetObjectInfo has invalid value of %i.", (int)infoType); - layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str); - } - VkResult result = device_dispatch_table(device)->GetObjectInfo(device, objType, object, infoType, pDataSize, pData); + VkResult result = device_dispatch_table(device)->GetObjectMemoryRequirements(device, objType, object, pData); return result; } @@ -785,21 +741,18 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateImage(VkDevice device, const VkImageCreat return result; } -VK_LAYER_EXPORT VkResult VKAPI vkGetImageSubresourceInfo(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceInfoType infoType, size_t* pDataSize, void* pData) +VK_LAYER_EXPORT VkResult VKAPI vkGetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) { char str[1024]; if (!pSubresource) { - sprintf(str, "Struct ptr parameter pSubresource to function GetImageSubresourceInfo is NULL."); + sprintf(str, "Struct ptr parameter pSubresource to function GetImageSubresourceLayout is NULL."); layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str); } else if (!vk_validate_vkimagesubresource(pSubresource)) { - sprintf(str, "Parameter pSubresource to function GetImageSubresourceInfo contains an invalid value."); + sprintf(str, "Parameter pSubresource to function GetImageSubresourceLayout contains an invalid value."); layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str); } - if (!validate_VkSubresourceInfoType(infoType)) { - sprintf(str, "Parameter infoType to function GetImageSubresourceInfo has invalid value of %i.", (int)infoType); - layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str); - } - VkResult result = device_dispatch_table(device)->GetImageSubresourceInfo(device, image, pSubresource, infoType, pDataSize, pData); + + VkResult result = device_dispatch_table(device)->GetImageSubresourceLayout(device, image, pSubresource, pLayout); return result; } @@ -1922,8 +1875,8 @@ static inline void* layer_intercept_proc(const char *name) return (void*) vkInvalidateMappedMemoryRanges; if (!strcmp(name, "DestroyObject")) return (void*) vkDestroyObject; - if (!strcmp(name, "GetObjectInfo")) - return (void*) vkGetObjectInfo; + if (!strcmp(name, "GetObjectMemoryRequirements")) + return (void*) vkGetObjectMemoryRequirements; if (!strcmp(name, "CreateFence")) return (void*) vkCreateFence; if (!strcmp(name, "ResetFences")) @@ -1956,8 +1909,8 @@ static inline void* layer_intercept_proc(const char *name) return (void*) vkCreateBufferView; if (!strcmp(name, "CreateImage")) return (void*) vkCreateImage; - if (!strcmp(name, "GetImageSubresourceInfo")) - return (void*) vkGetImageSubresourceInfo; + if (!strcmp(name, "GetImageSubresourceLayout")) + return (void*) vkGetImageSubresourceLayout; if (!strcmp(name, "CreateImageView")) return (void*) vkCreateImageView; if (!strcmp(name, "CreateColorAttachmentView")) @@ -2006,6 +1959,10 @@ static inline void* layer_intercept_proc(const char *name) return (void*) vkEndCommandBuffer; if (!strcmp(name, "ResetCommandBuffer")) return (void*) vkResetCommandBuffer; + if (!strcmp(name, "GetGlobalExtensionProperties")) + return (void*) vkGetGlobalExtensionProperties; + if (!strcmp(name, "GetGlobalExtensionCount")) + return (void*) vkGetGlobalExtensionCount; if (!strcmp(name, "CmdBindPipeline")) return (void*) vkCmdBindPipeline; if (!strcmp(name, "CmdBindDynamicStateObject")) @@ -2094,16 +2051,14 @@ static inline void* layer_intercept_instance_proc(const char *name) return (void*) vkCreateInstance; if (!strcmp(name, "DestroyInstance")) return (void*) vkDestroyInstance; - if (!strcmp(name, "GetPhysicalDeviceInfo")) - return (void*) vkGetPhysicalDeviceInfo; if (!strcmp(name, "CreateDevice")) return (void*) vkCreateDevice; - if (!strcmp(name, "GetGlobalExtensionInfo")) - return (void*) vkGetGlobalExtensionInfo; - if (!strcmp(name, "GetPhysicalDeviceExtensionInfo")) - return (void*) vkGetPhysicalDeviceExtensionInfo; if (!strcmp(name, "GetPhysicalDeviceFormatInfo")) return (void*) vkGetPhysicalDeviceFormatInfo; + if (!strcmp(name, "GetPhysicalDeviceExtensionProperties")) + return (void*) vkGetPhysicalDeviceExtensionProperties; + if (!strcmp(name, "GetPhysicalDeviceExtensionCount")) + return (void*) vkGetPhysicalDeviceExtensionCount; return NULL; } diff --git a/layers/screenshot.cpp b/layers/screenshot.cpp index 757c00c4..a1021698 100644 --- a/layers/screenshot.cpp +++ b/layers/screenshot.cpp @@ -119,7 +119,6 @@ static void writePPM( const char *filename, VkImage image1) VkFormat format = imageMap[image1]->format; const VkImageSubresource sr = {VK_IMAGE_ASPECT_COLOR, 0, 0}; VkSubresourceLayout sr_layout; - size_t data_size = sizeof(sr_layout); const VkImageCreateInfo imgCreateInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, NULL, @@ -162,7 +161,6 @@ static void writePPM( const char *filename, VkImage image1) {width, height, 1} }; VkMemoryRequirements memRequirements; - size_t memRequirementsSize = sizeof(memRequirements); uint32_t num_allocations = 0; size_t num_alloc_size = sizeof(num_allocations); VkLayerDispatchTable* pTableDevice = screenshot_device_table_map[device]; @@ -183,10 +181,9 @@ static void writePPM( const char *filename, VkImage image1) err = pTableDevice->CreateImage(device, &imgCreateInfo, &image2); assert(!err); - err = pTableDevice->GetObjectInfo(device, + err = pTableDevice->GetObjectMemoryRequirements(device, VK_OBJECT_TYPE_IMAGE, image2, - VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS, - &memRequirementsSize, &memRequirements); + &memRequirements); assert(!err); memAllocInfo.allocationSize = memRequirements.size; @@ -220,9 +217,7 @@ static void writePPM( const char *filename, VkImage image1) err = pTableDevice->DeviceWaitIdle(device); assert(!err); - err = pTableDevice->GetImageSubresourceInfo(device, image2, &sr, - VK_SUBRESOURCE_INFO_TYPE_LAYOUT, - &data_size, &sr_layout); + err = pTableDevice->GetImageSubresourceLayout(device, image2, &sr, &sr_layout); assert(!err); err = pTableDevice->MapMemory(device, mem2, 0, 0, 0, (void **) &ptr ); @@ -342,81 +337,43 @@ static const VkExtensionProperties ssExts[SCREENSHOT_LAYER_EXT_ARRAY_SIZE] = { } }; +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionCount( + uint32_t* pCount) +{ + *pCount = SCREENSHOT_LAYER_EXT_ARRAY_SIZE; + return VK_SUCCESS; +} -VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( - VkExtensionInfoType infoType, - uint32_t extensionIndex, - size_t *pDataSize, - void *pData) +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( + uint32_t extensionIndex, + VkExtensionProperties* pProperties) { - // This entrypoint is NOT going to init its own dispatch table since loader calls here early - uint32_t *count; + /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ + if (extensionIndex >= SCREENSHOT_LAYER_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; - if (pDataSize == NULL) { - return VK_ERROR_INVALID_POINTER; - } - - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) { - return VK_SUCCESS; - } - count = (uint32_t *) pData; - *count = SCREENSHOT_LAYER_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) { - return VK_SUCCESS; - } - if (extensionIndex >= SCREENSHOT_LAYER_EXT_ARRAY_SIZE) { - return VK_ERROR_INVALID_VALUE; - } - memcpy((VkExtensionProperties *) pData, &ssExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - }; + memcpy(pProperties, &ssExts[extensionIndex], sizeof(VkExtensionProperties)); return VK_SUCCESS; } - -VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionInfo( - VkPhysicalDevice physical_device, - VkExtensionInfoType infoType, - uint32_t extensionIndex, - size_t *pDataSize, - void *pData) +VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionCount( + VkPhysicalDevice gpu, + uint32_t* pCount) { - uint32_t *count; + *pCount = SCREENSHOT_LAYER_EXT_ARRAY_SIZE; + return VK_SUCCESS; +} - if (pDataSize == NULL) { - return VK_ERROR_INVALID_POINTER; - } +VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( + VkPhysicalDevice gpu, + uint32_t extensionIndex, + VkExtensionProperties* pProperties) +{ + /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) { - return VK_SUCCESS; - } - count = (uint32_t *) pData; - *count = SCREENSHOT_LAYER_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) { - return VK_SUCCESS; - } - if (extensionIndex >= SCREENSHOT_LAYER_EXT_ARRAY_SIZE) { - return VK_ERROR_INVALID_VALUE; - } - memcpy((VkExtensionProperties *) pData, &ssExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - } + if (extensionIndex >= SCREENSHOT_LAYER_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; + memcpy(pProperties, &ssExts[extensionIndex], sizeof(VkExtensionProperties)); return VK_SUCCESS; } @@ -613,6 +570,18 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr( if (!strcmp(funcName, "vkGetDeviceQueue")) return (void*) vkGetDeviceQueue; + if (!strcmp(funcName, "vkGetGlobalExtensionCount")) + return (void*) vkGetGlobalExtensionCount; + + if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionCount")) + return (void*) vkGetPhysicalDeviceExtensionCount; + + if (!strcmp(funcName, "vkGetGlobalExtensionProperties")) + return (void*) vkGetGlobalExtensionProperties; + + if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionProperties")) + return (void*) vkGetPhysicalDeviceExtensionProperties; + VkLayerDispatchTable *pDisp = get_dispatch_table(screenshot_device_table_map, dev); if (deviceExtMap.size() == 0 || deviceExtMap[pDisp].wsi_lunarg_enabled) { diff --git a/layers/shader_checker.cpp b/layers/shader_checker.cpp index 4ab46c3c..62511227 100644 --- a/layers/shader_checker.cpp +++ b/layers/shader_checker.cpp @@ -157,74 +157,44 @@ static const VkExtensionProperties shaderCheckerExts[SHADER_CHECKER_LAYER_EXT_AR "Sample layer: ShaderChecker", } }; +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionCount( + uint32_t* pCount) +{ + *pCount = SHADER_CHECKER_LAYER_EXT_ARRAY_SIZE; + return VK_SUCCESS; +} -VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( - VkExtensionInfoType infoType, +VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( uint32_t extensionIndex, - size_t* pDataSize, - void* pData) + VkExtensionProperties* pProperties) { /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ - uint32_t *count; - - if (pDataSize == NULL) - return VK_ERROR_INVALID_POINTER; - - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) - return VK_SUCCESS; - count = (uint32_t *) pData; - *count = SHADER_CHECKER_LAYER_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) - return VK_SUCCESS; - if (extensionIndex >= SHADER_CHECKER_LAYER_EXT_ARRAY_SIZE) - return VK_ERROR_INVALID_VALUE; - memcpy((VkExtensionProperties *) pData, &shaderCheckerExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - }; + if (extensionIndex >= SHADER_CHECKER_LAYER_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; + memcpy(pProperties, &shaderCheckerExts[extensionIndex], sizeof(VkExtensionProperties)); + + return VK_SUCCESS; +} + +VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionCount( + VkPhysicalDevice gpu, + uint32_t* pCount) +{ + *pCount = SHADER_CHECKER_LAYER_EXT_ARRAY_SIZE; return VK_SUCCESS; } -VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionInfo( +VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( VkPhysicalDevice gpu, - VkExtensionInfoType infoType, uint32_t extensionIndex, - size_t* pDataSize, - void* pData) + VkExtensionProperties* pProperties) { /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ - uint32_t *count; - - if (pDataSize == NULL) - return VK_ERROR_INVALID_POINTER; - - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) - return VK_SUCCESS; - count = (uint32_t *) pData; - *count = SHADER_CHECKER_LAYER_EXT_ARRAY_SIZE; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) - return VK_SUCCESS; - if (extensionIndex >= SHADER_CHECKER_LAYER_EXT_ARRAY_SIZE) - return VK_ERROR_INVALID_VALUE; - memcpy((VkExtensionProperties *) pData, &shaderCheckerExts[extensionIndex], sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - }; + + if (extensionIndex >= SHADER_CHECKER_LAYER_EXT_ARRAY_SIZE) + return VK_ERROR_INVALID_VALUE; + memcpy(pProperties, &shaderCheckerExts[extensionIndex], sizeof(VkExtensionProperties)); return VK_SUCCESS; } @@ -1029,8 +999,10 @@ VK_LAYER_EXPORT void * VKAPI vkGetInstanceProcAddr(VkInstance inst, const char* ADD_HOOK(vkCreateInstance); ADD_HOOK(vkDestroyInstance); - ADD_HOOK(vkGetGlobalExtensionInfo); - ADD_HOOK(vkGetPhysicalDeviceExtensionInfo); + ADD_HOOK(vkGetGlobalExtensionProperties); + ADD_HOOK(vkGetGlobalExtensionCount); + ADD_HOOK(vkGetPhysicalDeviceExtensionProperties); + ADD_HOOK(vkGetPhysicalDeviceExtensionCount); #undef ADD_HOOK fptr = msg_callback_get_proc_addr(pName); diff --git a/loader/gpa_helper.h b/loader/gpa_helper.h index fd300554..a51112ce 100644 --- a/loader/gpa_helper.h +++ b/loader/gpa_helper.h @@ -37,8 +37,22 @@ static inline void* globalGetProcAddr(const char *name) return (void*) vkDestroyInstance; if (!strcmp(name, "EnumeratePhysicalDevices")) return (void*) vkEnumeratePhysicalDevices; - if (!strcmp(name, "GetPhysicalDeviceInfo")) - return (void*) vkGetPhysicalDeviceInfo; + if (!strcmp(name, "GetPhysicalDeviceProperties")) + return (void*) vkGetPhysicalDeviceProperties; + if (!strcmp(name, "GetPhysicalDevicePerformance")) + return (void*) vkGetPhysicalDevicePerformance; + if (!strcmp(name, "GetPhysicalDeviceQueueCount")) + return (void*) vkGetPhysicalDeviceQueueCount; + if (!strcmp(name, "GetPhysicalDeviceQueueProperties")) + return (void*) vkGetPhysicalDeviceQueueProperties; + if (!strcmp(name, "GetPhysicalDeviceMemoryProperties")) + return (void*) vkGetPhysicalDeviceMemoryProperties; + if (!strcmp(name, "GetPhysicalDeviceFeatures")) + return (void*) vkGetPhysicalDeviceFeatures; + if (!strcmp(name, "GetPhysicalDeviceFormatInfo")) + return (void*) vkGetPhysicalDeviceFormatInfo; + if (!strcmp(name, "GetPhysicalDeviceLimits")) + return (void*) vkGetPhysicalDeviceLimits; if (!strcmp(name, "GetInstanceProcAddr")) return (void*) vkGetInstanceProcAddr; if (!strcmp(name, "GetDeviceProcAddr")) @@ -47,10 +61,14 @@ static inline void* globalGetProcAddr(const char *name) return (void*) vkCreateDevice; if (!strcmp(name, "DestroyDevice")) return (void*) vkDestroyDevice; - if (!strcmp(name, "GetGlobalExtensionInfo")) - return (void*) vkGetGlobalExtensionInfo; - if (!strcmp(name, "GetPhysicalDeviceExtensionInfo")) - return (void*) vkGetPhysicalDeviceExtensionInfo; + if (!strcmp(name, "GetGlobalExtensionProperties")) + return (void*) vkGetGlobalExtensionProperties; + if (!strcmp(name, "GetGlobalExtensionCount")) + return (void*) vkGetGlobalExtensionCount; + if (!strcmp(name, "GetPhysicalDeviceExtensionProperties")) + return (void*) vkGetPhysicalDeviceExtensionProperties; + if (!strcmp(name, "GetPhysicalDeviceExtensionCount")) + return (void*) vkGetPhysicalDeviceExtensionCount; if (!strcmp(name, "GetDeviceQueue")) return (void*) vkGetDeviceQueue; if (!strcmp(name, "QueueSubmit")) @@ -73,8 +91,8 @@ static inline void* globalGetProcAddr(const char *name) return (void*) vkInvalidateMappedMemoryRanges; if (!strcmp(name, "DestroyObject")) return (void*) vkDestroyObject; - if (!strcmp(name, "GetObjectInfo")) - return (void*) vkGetObjectInfo; + if (!strcmp(name, "GetObjectMemoryRequirements")) + return (void*) vkGetObjectMemoryRequirements; if (!strcmp(name, "BindObjectMemory")) return (void*) vkBindObjectMemory; if (!strcmp(name, "QueueBindSparseBufferMemory")) @@ -113,8 +131,8 @@ static inline void* globalGetProcAddr(const char *name) return (void*) vkCreateBufferView; if (!strcmp(name, "CreateImage")) return (void*) vkCreateImage; - if (!strcmp(name, "GetImageSubresourceInfo")) - return (void*) vkGetImageSubresourceInfo; + if (!strcmp(name, "GetImageSubresourceLayout")) + return (void*) vkGetImageSubresourceLayout; if (!strcmp(name, "CreateImageView")) return (void*) vkCreateImageView; if (!strcmp(name, "CreateColorAttachmentView")) @@ -259,22 +277,30 @@ static inline void *loader_non_passthrough_gpa(const char *name) return (void*) vkDestroyInstance; if (!strcmp(name, "EnumeratePhysicalDevices")) return (void*) vkEnumeratePhysicalDevices; - if (!strcmp(name, "GetPhysicalDeviceInfo")) - return (void*) vkGetPhysicalDeviceInfo; if (!strcmp(name, "GetPhysicalDeviceFeatures")) return (void*) vkGetPhysicalDeviceFeatures; if (!strcmp(name, "GetPhysicalDeviceFormatInfo")) return (void*) vkGetPhysicalDeviceFormatInfo; if (!strcmp(name, "GetPhysicalDeviceLimits")) return (void*) vkGetPhysicalDeviceLimits; + if (!strcmp(name, "GetPhysicalDevicePerformance")) + return (void*) vkGetPhysicalDevicePerformance; + if (!strcmp(name, "GetPhysicalDeviceQueueCount")) + return (void*) vkGetPhysicalDeviceQueueCount; + if (!strcmp(name, "GetPhysicalDeviceQueueProperties")) + return (void*) vkGetPhysicalDeviceQueueProperties; + if (!strcmp(name, "GetPhysicalDeviceMemoryProperties")) + return (void*) vkGetPhysicalDeviceMemoryProperties; + if (!strcmp(name, "GetPhysicalDeviceProperties")) + return (void*) vkGetPhysicalDeviceProperties; if (!strcmp(name, "GetInstanceProcAddr")) return (void*) vkGetInstanceProcAddr; if (!strcmp(name, "GetDeviceProcAddr")) return (void*) vkGetDeviceProcAddr; if (!strcmp(name, "CreateDevice")) return (void*) vkCreateDevice; - if (!strcmp(name, "GetGlobalExtensionInfo")) - return (void*) vkGetGlobalExtensionInfo; + if (!strcmp(name, "GetPhysicalDeviceExtensionProperties")) + return (void*) vkGetPhysicalDeviceExtensionProperties; if (!strcmp(name, "GetDeviceQueue")) return (void*) vkGetDeviceQueue; if (!strcmp(name, "CreateCommandBuffer")) diff --git a/loader/loader.c b/loader/loader.c index 70f2a059..01750468 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -89,12 +89,17 @@ const VkLayerInstanceDispatchTable instance_disp = { .CreateInstance = loader_CreateInstance, .DestroyInstance = loader_DestroyInstance, .EnumeratePhysicalDevices = loader_EnumeratePhysicalDevices, - .GetPhysicalDeviceInfo = loader_GetPhysicalDeviceInfo, .GetPhysicalDeviceFeatures = loader_GetPhysicalDeviceFeatures, .GetPhysicalDeviceFormatInfo = loader_GetPhysicalDeviceFormatInfo, .GetPhysicalDeviceLimits = loader_GetPhysicalDeviceLimits, .CreateDevice = loader_CreateDevice, - .GetPhysicalDeviceExtensionInfo = loader_GetPhysicalDeviceExtensionInfo, + .GetPhysicalDeviceProperties = loader_GetPhysicalDeviceProperties, + .GetPhysicalDevicePerformance = loader_GetPhysicalDevicePerformance, + .GetPhysicalDeviceQueueCount = loader_GetPhysicalDeviceQueueCount, + .GetPhysicalDeviceQueueProperties = loader_GetPhysicalDeviceQueueProperties, + .GetPhysicalDeviceMemoryProperties = loader_GetPhysicalDeviceMemoryProperties, + .GetPhysicalDeviceExtensionCount = loader_GetPhysicalDeviceExtensionCount, + .GetPhysicalDeviceExtensionProperties = loader_GetPhysicalDeviceExtensionProperties, .DbgCreateMsgCallback = loader_DbgCreateMsgCallback, .DbgDestroyMsgCallback = loader_DbgDestroyMsgCallback, }; @@ -266,7 +271,8 @@ static struct loader_extension_property *get_extension_property_from_vkext( } static void loader_get_global_extensions( - const PFN_vkGetGlobalExtensionInfo fp_get, + const PFN_vkGetGlobalExtensionCount fp_get_count, + const PFN_vkGetGlobalExtensionProperties fp_get_props, const PFN_vkGPA get_proc_addr, const char *lib_name, const loader_platform_dl_handle lib_handle, @@ -274,13 +280,12 @@ static void loader_get_global_extensions( struct loader_extension_list *ext_list) { uint32_t i, count; - size_t siz = sizeof(count); struct loader_extension_property ext_props; VkResult res; PFN_vkGPA ext_get_proc_addr; PFN_vkGetInstanceProcAddr get_instance_proc_addr; - res = fp_get(VK_EXTENSION_INFO_TYPE_COUNT, 0, &siz, &count); + res = fp_get_count(&count); if (res != VK_SUCCESS) { loader_log(VK_DBG_REPORT_WARN_BIT, 0, "Error getting global extension count from ICD"); return; @@ -288,10 +293,10 @@ static void loader_get_global_extensions( if (get_proc_addr == NULL) get_instance_proc_addr = (PFN_vkGetInstanceProcAddr) loader_platform_get_proc_address(lib_handle, "vkGetInstanceProcAddr"); - siz = sizeof(VkExtensionProperties); + for (i = 0; i < count; i++) { memset(&ext_props, 0, sizeof(ext_props)); - res = fp_get(VK_EXTENSION_INFO_TYPE_PROPERTIES, i, &siz, &ext_props.info); + res = fp_get_props(i, &ext_props.info); if (res == VK_SUCCESS) { //TODO eventually get this from the layer config file if (get_proc_addr == NULL) { @@ -318,10 +323,10 @@ static void loader_get_physical_device_layer_extensions( struct loader_extension_list *ext_list) { uint32_t i, count; - size_t siz = sizeof(count); VkResult res; loader_platform_dl_handle lib_handle; - PFN_vkGetPhysicalDeviceExtensionInfo get_phys_dev_ext_info; + PFN_vkGetPhysicalDeviceExtensionProperties get_phys_dev_ext_props; + PFN_vkGetPhysicalDeviceExtensionCount get_phys_dev_ext_count; struct loader_extension_property ext_props; PFN_vkGPA ext_get_proc_addr; PFN_vkGetDeviceProcAddr get_device_proc_addr; @@ -336,15 +341,15 @@ static void loader_get_physical_device_layer_extensions( lib_handle = loader_add_layer_lib("device", &ext_props); - get_phys_dev_ext_info = (PFN_vkGetPhysicalDeviceExtensionInfo) loader_platform_get_proc_address(lib_handle, "vkGetPhysicalDeviceExtensionInfo"); + get_phys_dev_ext_props = (PFN_vkGetPhysicalDeviceExtensionProperties) loader_platform_get_proc_address(lib_handle, "vkGetPhysicalDeviceExtensionProperties"); + get_phys_dev_ext_count = (PFN_vkGetPhysicalDeviceExtensionCount) loader_platform_get_proc_address(lib_handle, "vkGetPhysicalDeviceExtensionCount"); get_device_proc_addr = (PFN_vkGetDeviceProcAddr) loader_platform_get_proc_address(lib_handle, "vkGetDeviceProcAddr"); - if (get_phys_dev_ext_info) { - res = get_phys_dev_ext_info(physical_device, VK_EXTENSION_INFO_TYPE_COUNT, 0, &siz, &count); + if (get_phys_dev_ext_count) { + res = get_phys_dev_ext_count(physical_device, &count); if (res == VK_SUCCESS) { - siz = sizeof(VkExtensionProperties); for (i = 0; i < count; i++) { memset(&ext_props, 0, sizeof(ext_props)); - res = get_phys_dev_ext_info(physical_device, VK_EXTENSION_INFO_TYPE_PROPERTIES, i, &siz, &ext_props.info); + res = get_phys_dev_ext_props(physical_device, i, &ext_props.info); if (res == VK_SUCCESS && (ext_props.info.sType == VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES)) { ext_props.origin = VK_EXTENSION_ORIGIN_LAYER; //TODO eventually get this from the layer config file @@ -647,8 +652,10 @@ static void loader_scanned_icd_add(const char *filename) { loader_platform_dl_handle handle; void *fp_create_inst; - void *fp_get_global_ext_info; - void *fp_get_device_ext_info; + void *fp_get_global_ext_props; + void *fp_get_global_ext_count; + void *fp_get_device_ext_props; + void *fp_get_device_ext_count; PFN_vkGPA fp_get_proc_addr; struct loader_scanned_icds *new_node; @@ -668,8 +675,10 @@ static void loader_scanned_icd_add(const char *filename) } while (0) LOOKUP(fp_create_inst, CreateInstance); - LOOKUP(fp_get_global_ext_info, GetGlobalExtensionInfo); - LOOKUP(fp_get_device_ext_info, GetPhysicalDeviceExtensionInfo); + LOOKUP(fp_get_global_ext_props, GetGlobalExtensionProperties); + LOOKUP(fp_get_global_ext_count, GetGlobalExtensionCount); + LOOKUP(fp_get_device_ext_props, GetPhysicalDeviceExtensionProperties); + LOOKUP(fp_get_device_ext_count, GetPhysicalDeviceExtensionCount); LOOKUP(fp_get_proc_addr, GetDeviceProcAddr); #undef LOOKUP @@ -682,7 +691,8 @@ static void loader_scanned_icd_add(const char *filename) new_node->handle = handle; new_node->CreateInstance = fp_create_inst; - new_node->GetGlobalExtensionInfo = fp_get_global_ext_info; + new_node->GetGlobalExtensionProperties = fp_get_global_ext_props; + new_node->GetGlobalExtensionCount = fp_get_global_ext_count; loader_init_ext_list(&new_node->global_extension_list); loader_init_ext_list(&new_node->device_extension_list); new_node->next = loader.scanned_icd_list; @@ -697,7 +707,8 @@ static void loader_scanned_icd_add(const char *filename) loader.scanned_icd_list = new_node; loader_get_global_extensions( - (PFN_vkGetGlobalExtensionInfo) fp_get_global_ext_info, + (PFN_vkGetGlobalExtensionCount) fp_get_global_ext_count, + (PFN_vkGetGlobalExtensionProperties) fp_get_global_ext_props, fp_get_proc_addr, new_node->lib_name, handle, @@ -722,12 +733,17 @@ static void loader_icd_init_entrys(struct loader_icd *icd, LOOKUP(GetDeviceProcAddr); LOOKUP(DestroyInstance); LOOKUP(EnumeratePhysicalDevices); - LOOKUP(GetPhysicalDeviceInfo); LOOKUP(GetPhysicalDeviceFeatures); LOOKUP(GetPhysicalDeviceFormatInfo); LOOKUP(GetPhysicalDeviceLimits); LOOKUP(CreateDevice); - LOOKUP(GetPhysicalDeviceExtensionInfo); + LOOKUP(GetPhysicalDeviceProperties); + LOOKUP(GetPhysicalDeviceMemoryProperties); + LOOKUP(GetPhysicalDevicePerformance); + LOOKUP(GetPhysicalDeviceQueueCount); + LOOKUP(GetPhysicalDeviceQueueProperties); + LOOKUP(GetPhysicalDeviceExtensionProperties); + LOOKUP(GetPhysicalDeviceExtensionCount); LOOKUP(DbgCreateMsgCallback); LOOKUP(DbgDestroyMsgCallback); #undef LOOKUP @@ -889,7 +905,8 @@ void layer_lib_scan(void) size_t len, i; char temp_str[1024]; uint32_t count; - PFN_vkGetGlobalExtensionInfo fp_get_ext; + PFN_vkGetGlobalExtensionProperties fp_get_props; + PFN_vkGetGlobalExtensionCount fp_get_count; #if defined(WIN32) bool must_free_libPaths; @@ -994,10 +1011,11 @@ void layer_lib_scan(void) break; } - fp_get_ext = loader_platform_get_proc_address(handle, "vkGetGlobalExtensionInfo"); - if (!fp_get_ext) { + fp_get_count = loader_platform_get_proc_address(handle, "vkGetGlobalExtensionCount"); + fp_get_props = loader_platform_get_proc_address(handle, "vkGetGlobalExtensionProperties"); + if (!fp_get_props || !fp_get_count) { loader_log(VK_DBG_REPORT_WARN_BIT, 0, - "Couldn't dlsym vkGetGlobalExtensionInfo from library %s", + "Couldn't dlsym vkGetGlobalExtensionCount and/or vkGetGlobalExtensionProperties from library %s", temp_str); dent = readdir(curdir); loader_platform_close_library(handle); @@ -1015,16 +1033,19 @@ void layer_lib_scan(void) loader_log(VK_DBG_REPORT_DEBUG_BIT, 0, "Collecting global extensions for %s", temp_str); loader_get_global_extensions( - fp_get_ext, + fp_get_count, + fp_get_props, NULL, loader.scanned_layers[count].lib_name, handle, VK_EXTENSION_ORIGIN_LAYER, &loader.scanned_layers[count].global_extension_list); - fp_get_ext = loader_platform_get_proc_address(handle, - "vkGetPhysicalDeviceExtensionInfo"); - if (fp_get_ext) { + fp_get_count = loader_platform_get_proc_address(handle, + "vkGetPhysicalDeviceExtensionCount"); + fp_get_props = loader_platform_get_proc_address(handle, + "vkGetPhysicalDeviceExtensionProperties"); + if (fp_get_props && fp_get_count) { loader.scanned_layers[count].physical_device_extensions_supported = true; } @@ -1616,21 +1637,18 @@ VkResult loader_init_physical_device_info( /* TODO: Add cleanup code here */ res = VK_ERROR_OUT_OF_HOST_MEMORY; } - if (res == VK_SUCCESS && icd->GetPhysicalDeviceExtensionInfo) { - size_t data_size; + if (res == VK_SUCCESS && icd->GetPhysicalDeviceExtensionProperties && icd->GetPhysicalDeviceExtensionCount) { uint32_t extension_count; - data_size = sizeof(extension_count); - res = icd->GetPhysicalDeviceExtensionInfo(icd->gpus[i], VK_EXTENSION_INFO_TYPE_COUNT, 0, &data_size, &extension_count); - if (data_size == sizeof(extension_count) && res == VK_SUCCESS) { + res = icd->GetPhysicalDeviceExtensionCount(icd->gpus[i], &extension_count); + if (res == VK_SUCCESS) { struct loader_extension_property ext_props; /* Gather all the ICD extensions */ for (uint32_t extension_id = 0; extension_id < extension_count; extension_id++) { - data_size = sizeof(VkExtensionProperties); - res = icd->GetPhysicalDeviceExtensionInfo(icd->gpus[i], VK_EXTENSION_INFO_TYPE_PROPERTIES, - extension_id, &data_size, &ext_props.info); - if (data_size == sizeof(VkExtensionProperties) && res == VK_SUCCESS) { + res = icd->GetPhysicalDeviceExtensionProperties(icd->gpus[i], + extension_id, &ext_props.info); + if (res == VK_SUCCESS) { ext_props.origin = VK_EXTENSION_ORIGIN_ICD; ext_props.lib_name = icd->scanned_icds->lib_name; ext_props.get_proc_addr = icd->GetDeviceProcAddr; @@ -1691,18 +1709,73 @@ VkResult loader_EnumeratePhysicalDevices( return VK_SUCCESS; } -VkResult loader_GetPhysicalDeviceInfo( +VkResult loader_GetPhysicalDeviceProperties( VkPhysicalDevice gpu, - VkPhysicalDeviceInfoType infoType, - size_t* pDataSize, - void* pData) + VkPhysicalDeviceProperties* pProperties) { uint32_t gpu_index; struct loader_icd *icd = loader_get_icd(gpu, &gpu_index); VkResult res = VK_ERROR_INITIALIZATION_FAILED; - if (icd->GetPhysicalDeviceInfo) - res = icd->GetPhysicalDeviceInfo(gpu, infoType, pDataSize, pData); + if (icd->GetPhysicalDeviceProperties) + res = icd->GetPhysicalDeviceProperties(gpu, pProperties); + + return res; +} + +VkResult loader_GetPhysicalDevicePerformance( + VkPhysicalDevice gpu, + VkPhysicalDevicePerformance* pPerformance) +{ + uint32_t gpu_index; + struct loader_icd *icd = loader_get_icd(gpu, &gpu_index); + VkResult res = VK_ERROR_INITIALIZATION_FAILED; + + if (icd->GetPhysicalDevicePerformance) + res = icd->GetPhysicalDevicePerformance(gpu, pPerformance); + + return res; +} + +VkResult loader_GetPhysicalDeviceQueueCount( + VkPhysicalDevice gpu, + uint32_t* pCount) +{ + uint32_t gpu_index; + struct loader_icd *icd = loader_get_icd(gpu, &gpu_index); + VkResult res = VK_ERROR_INITIALIZATION_FAILED; + + if (icd->GetPhysicalDeviceQueueCount) + res = icd->GetPhysicalDeviceQueueCount(gpu, pCount); + + return res; +} + +VkResult loader_GetPhysicalDeviceQueueProperties ( + VkPhysicalDevice gpu, + uint32_t count, + VkPhysicalDeviceQueueProperties * pProperties) +{ + uint32_t gpu_index; + struct loader_icd *icd = loader_get_icd(gpu, &gpu_index); + VkResult res = VK_ERROR_INITIALIZATION_FAILED; + + if (icd->GetPhysicalDeviceQueueProperties) + res = icd->GetPhysicalDeviceQueueProperties(gpu, count, pProperties); + + return res; +} + +VkResult loader_GetPhysicalDeviceMemoryProperties ( + VkPhysicalDevice gpu, + VkPhysicalDeviceMemoryProperties* pProperties) +{ + uint32_t gpu_index; + struct loader_icd *icd = loader_get_icd(gpu, &gpu_index); + VkResult res = VK_ERROR_INITIALIZATION_FAILED; + + if (icd->GetPhysicalDeviceMemoryProperties) + res = icd->GetPhysicalDeviceMemoryProperties(gpu, pProperties); return res; } @@ -1889,14 +1962,28 @@ LOADER_EXPORT void * VKAPI vkGetDeviceProcAddr(VkDevice device, const char * pNa return loader_GetDeviceProcAddr(device, pName); } -LOADER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( - VkExtensionInfoType infoType, - uint32_t extensionIndex, - size_t* pDataSize, - void* pData) +LOADER_EXPORT VkResult VKAPI vkGetGlobalExtensionCount( + uint32_t* pCount) +{ + /* Scan/discover all ICD libraries in a single-threaded manner */ + loader_platform_thread_once(&once_icd, loader_icd_scan); + + /* get layer libraries in a single-threaded manner */ + loader_platform_thread_once(&once_layer, layer_lib_scan); + + /* merge any duplicate extensions */ + loader_platform_thread_once(&once_exts, loader_coalesce_extensions); + + loader_platform_thread_lock_mutex(&loader_lock); + *pCount = loader.global_extensions.count; + loader_platform_thread_unlock_mutex(&loader_lock); + return VK_SUCCESS; +} + +LOADER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( + uint32_t extensionIndex, + VkExtensionProperties* pProperties) { - uint32_t *count; - VkResult res = VK_SUCCESS; /* Scan/discover all ICD libraries in a single-threaded manner */ loader_platform_thread_once(&once_icd, loader_icd_scan); @@ -1907,75 +1994,43 @@ LOADER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( /* merge any duplicate extensions */ loader_platform_thread_once(&once_exts, loader_coalesce_extensions); - if (pDataSize == NULL) - return VK_ERROR_INVALID_POINTER; + if (extensionIndex >= loader.global_extensions.count) + return VK_ERROR_INVALID_VALUE; loader_platform_thread_lock_mutex(&loader_lock); - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) { - loader_platform_thread_unlock_mutex(&loader_lock); - return VK_SUCCESS; - } - count = (uint32_t *) pData; - *count = loader.global_extensions.count; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) { - loader_platform_thread_unlock_mutex(&loader_lock); - return VK_SUCCESS; - } - if (extensionIndex >= loader.global_extensions.count) - return VK_ERROR_INVALID_VALUE; - memcpy((VkExtensionProperties *) pData, - &loader.global_extensions.list[extensionIndex], - sizeof(VkExtensionProperties)); - break; - default: - loader_log(VK_DBG_REPORT_WARN_BIT, 0, "Invalid infoType in vkGetGlobalExtensionInfo"); - res = VK_ERROR_INVALID_VALUE; - }; + memcpy(pProperties, + &loader.global_extensions.list[extensionIndex], + sizeof(VkExtensionProperties)); + loader_platform_thread_unlock_mutex(&loader_lock); - return res; + return VK_SUCCESS; +} + +VkResult loader_GetPhysicalDeviceExtensionCount( + VkPhysicalDevice gpu, + uint32_t* pCount) +{ + uint32_t gpu_index; + struct loader_icd *icd = loader_get_icd(gpu, &gpu_index); + *pCount = icd->device_extension_cache[gpu_index].count; + + return VK_SUCCESS; } -VkResult loader_GetPhysicalDeviceExtensionInfo( +VkResult loader_GetPhysicalDeviceExtensionProperties( VkPhysicalDevice gpu, - VkExtensionInfoType infoType, uint32_t extensionIndex, - size_t* pDataSize, - void* pData) + VkExtensionProperties* pProperties) { uint32_t gpu_index; - uint32_t *count; struct loader_icd *icd = loader_get_icd(gpu, &gpu_index); - if (pDataSize == NULL) - return VK_ERROR_INVALID_POINTER; + if (extensionIndex >= icd->device_extension_cache[gpu_index].count) + return VK_ERROR_INVALID_VALUE; - switch (infoType) { - case VK_EXTENSION_INFO_TYPE_COUNT: - *pDataSize = sizeof(uint32_t); - if (pData == NULL) - return VK_SUCCESS; - count = (uint32_t *) pData; - *count = icd->device_extension_cache[gpu_index].count; - break; - case VK_EXTENSION_INFO_TYPE_PROPERTIES: - *pDataSize = sizeof(VkExtensionProperties); - if (pData == NULL) - return VK_SUCCESS; - if (extensionIndex >= icd->device_extension_cache[gpu_index].count) - return VK_ERROR_INVALID_VALUE; - memcpy((VkExtensionProperties *) pData, - &icd->device_extension_cache[gpu_index].list[extensionIndex], - sizeof(VkExtensionProperties)); - break; - default: - return VK_ERROR_INVALID_VALUE; - }; + memcpy( pProperties, + &icd->device_extension_cache[gpu_index].list[extensionIndex], + sizeof(VkExtensionProperties)); return VK_SUCCESS; } diff --git a/loader/loader.h b/loader/loader.h index 7019da8f..a854485a 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -116,18 +116,23 @@ struct loader_icd { PFN_vkGetDeviceProcAddr GetDeviceProcAddr; PFN_vkDestroyInstance DestroyInstance; PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; - PFN_vkGetPhysicalDeviceInfo GetPhysicalDeviceInfo; PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures; PFN_vkGetPhysicalDeviceFormatInfo GetPhysicalDeviceFormatInfo; PFN_vkGetPhysicalDeviceLimits GetPhysicalDeviceLimits; PFN_vkCreateDevice CreateDevice; - PFN_vkGetPhysicalDeviceExtensionInfo GetPhysicalDeviceExtensionInfo; + PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties; + PFN_vkGetPhysicalDevicePerformance GetPhysicalDevicePerformance; + PFN_vkGetPhysicalDeviceQueueCount GetPhysicalDeviceQueueCount; + PFN_vkGetPhysicalDeviceQueueProperties GetPhysicalDeviceQueueProperties; + PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties; + PFN_vkGetPhysicalDeviceExtensionCount GetPhysicalDeviceExtensionCount; + PFN_vkGetPhysicalDeviceExtensionProperties GetPhysicalDeviceExtensionProperties; PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback; PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback; /* * Fill in the cache of available extensions from all layers that * operate with this physical device. - * This cache will be used to satisfy calls to GetPhysicalDeviceExtensionInfo + * This cache will be used to satisfy calls to GetPhysicalDeviceExtensionProperties */ struct loader_extension_list device_extension_cache[MAX_GPUS_PER_ICD]; struct loader_icd *next; @@ -243,7 +248,7 @@ struct loader_struct { size_t scanned_ext_list_capacity; struct loader_scanned_layers scanned_layers[MAX_LAYER_LIBRARIES]; - /* Keep track of all the extensions available via GetGlobalExtensionInfo */ + /* Keep track of all the extensions available via GetGlobalExtensionProperties */ struct loader_extension_list global_extensions; }; @@ -254,8 +259,10 @@ struct loader_scanned_icds { PFN_vkCreateInstance CreateInstance; PFN_vkDestroyInstance DestroyInstance; PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; - PFN_vkGetGlobalExtensionInfo GetGlobalExtensionInfo; - PFN_vkGetPhysicalDeviceExtensionInfo GetPhysicalDeviceExtensionInfo; + PFN_vkGetGlobalExtensionCount GetGlobalExtensionCount; + PFN_vkGetGlobalExtensionProperties GetGlobalExtensionProperties; + PFN_vkGetPhysicalDeviceExtensionCount GetPhysicalDeviceExtensionCount; + PFN_vkGetPhysicalDeviceExtensionProperties GetPhysicalDeviceExtensionProperties; VkInstance instance; struct loader_scanned_icds *next; @@ -324,12 +331,6 @@ VkResult loader_EnumeratePhysicalDevices( uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); -VkResult loader_GetPhysicalDeviceInfo( - VkPhysicalDevice gpu, - VkPhysicalDeviceInfoType infoType, - size_t* pDataSize, - void* pData); - VkResult loader_GetPhysicalDeviceFeatures( VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures); @@ -343,12 +344,36 @@ VkResult loader_GetPhysicalDeviceLimits( VkPhysicalDevice physicalDevice, VkPhysicalDeviceLimits* pLimits); -VkResult loader_GetPhysicalDeviceExtensionInfo( - VkPhysicalDevice gpu, - VkExtensionInfoType infoType, - uint32_t extensionIndex, - size_t* pDataSize, - void* pData); + +VkResult loader_GetPhysicalDeviceProperties ( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceProperties* pProperties); + +VkResult loader_GetPhysicalDevicePerformance ( + VkPhysicalDevice physicalDevice, + VkPhysicalDevicePerformance* pPerformance); + +VkResult loader_GetPhysicalDeviceExtensionProperties ( + VkPhysicalDevice physicalDevice, + uint32_t extensionIndex, + VkExtensionProperties* pProperties); + +VkResult loader_GetPhysicalDeviceExtensionCount ( + VkPhysicalDevice physicalDevice, + uint32_t* pCount); + +VkResult loader_GetPhysicalDeviceQueueCount ( + VkPhysicalDevice physicalDevice, + uint32_t* pCount); + +VkResult loader_GetPhysicalDeviceQueueProperties ( + VkPhysicalDevice physicalDevice, + uint32_t count, + VkPhysicalDeviceQueueProperties * pProperties); + +VkResult loader_GetPhysicalDeviceMemoryProperties ( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceMemoryProperties * pProperties); VkResult loader_CreateDevice( VkPhysicalDevice gpu, diff --git a/loader/table_ops.h b/loader/table_ops.h index f1cbc22f..6d159507 100644 --- a/loader/table_ops.h +++ b/loader/table_ops.h @@ -49,7 +49,7 @@ static inline void loader_init_device_dispatch_table(VkLayerDispatchTable *table table->FlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges) gpa(dev, "vkFlushMappedMemoryRanges"); table->InvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges) gpa(dev, "vkInvalidateMappedMemoryRanges"); table->DestroyObject = (PFN_vkDestroyObject) gpa(dev, "vkDestroyObject"); - table->GetObjectInfo = (PFN_vkGetObjectInfo) gpa(dev, "vkGetObjectInfo"); + table->GetObjectMemoryRequirements = (PFN_vkGetObjectMemoryRequirements) gpa(dev, "vkGetObjectMemoryRequirements"); table->BindObjectMemory = (PFN_vkBindObjectMemory) gpa(dev, "vkBindObjectMemory"); table->QueueBindSparseBufferMemory = (PFN_vkQueueBindSparseBufferMemory) gpa(dev, "vkQueueBindSparseBufferMemory"); table->QueueBindSparseImageMemory = (PFN_vkQueueBindSparseImageMemory) gpa(dev, "vkQueueBindSparseImageMemory"); @@ -69,7 +69,7 @@ static inline void loader_init_device_dispatch_table(VkLayerDispatchTable *table table->CreateBuffer = (PFN_vkCreateBuffer) gpa(dev, "vkCreateBuffer"); table->CreateBufferView = (PFN_vkCreateBufferView) gpa(dev, "vkCreateBufferView"); table->CreateImage = (PFN_vkCreateImage) gpa(dev, "vkCreateImage"); - table->GetImageSubresourceInfo = (PFN_vkGetImageSubresourceInfo) gpa(dev, "vkGetImageSubresourceInfo"); + table->GetImageSubresourceLayout = (PFN_vkGetImageSubresourceLayout) gpa(dev, "vkGetImageSubresourceLayout"); table->CreateImageView = (PFN_vkCreateImageView) gpa(dev, "vkCreateImageView"); table->CreateColorAttachmentView = (PFN_vkCreateColorAttachmentView) gpa(dev, "vkCreateColorAttachmentView"); table->CreateDepthStencilView = (PFN_vkCreateDepthStencilView) gpa(dev, "vkCreateDepthStencilView"); @@ -175,8 +175,8 @@ static inline void *loader_lookup_device_dispatch_table( return (void *) table->InvalidateMappedMemoryRanges; if (!strcmp(name, "DestroyObject")) return (void *) table->DestroyObject; - if (!strcmp(name, "GetObjectInfo")) - return (void *) table->GetObjectInfo; + if (!strcmp(name, "GetObjectMemoryRequirements")) + return (void *) table->GetObjectMemoryRequirements; if (!strcmp(name, "BindObjectMemory")) return (void *) table->BindObjectMemory; if (!strcmp(name, "QueueBindSparseBufferMemory")) @@ -215,8 +215,8 @@ static inline void *loader_lookup_device_dispatch_table( return (void *) table->CreateBufferView; if (!strcmp(name, "CreateImage")) return (void *) table->CreateImage; - if (!strcmp(name, "GetImageSubresourceInfo")) - return (void *) table->GetImageSubresourceInfo; + if (!strcmp(name, "GetImageSubresourceLayout")) + return (void *) table->GetImageSubresourceLayout; if (!strcmp(name, "CreateImageView")) return (void *) table->CreateImageView; if (!strcmp(name, "CreateColorAttachmentView")) @@ -357,12 +357,17 @@ static inline void loader_init_instance_core_dispatch_table(VkLayerInstanceDispa table->CreateInstance = (PFN_vkCreateInstance) gpa(inst, "vkCreateInstance"); table->DestroyInstance = (PFN_vkDestroyInstance) gpa(inst, "vkDestroyInstance"); table->EnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices) gpa(inst, "vkEnumeratePhysicalDevices"); - table->GetPhysicalDeviceInfo = (PFN_vkGetPhysicalDeviceInfo) gpa(inst, "vkGetPhysicalDeviceInfo"); table->GetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures) gpa(inst, "vkGetPhysicalDeviceFeatures"); table->GetPhysicalDeviceFormatInfo = (PFN_vkGetPhysicalDeviceFormatInfo) gpa(inst, "vkGetPhysicalDeviceFormatInfo"); table->GetPhysicalDeviceLimits = (PFN_vkGetPhysicalDeviceLimits) gpa(inst, "vkGetPhysicalDeviceLimits"); table->CreateDevice = (PFN_vkCreateDevice) gpa(inst, "vkCreateDevice"); - table->GetPhysicalDeviceExtensionInfo = (PFN_vkGetPhysicalDeviceExtensionInfo) gpa(inst, "vkGetPhysicalDeviceExtensionInfo"); + table->GetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties) gpa(inst, "vkGetPhysicalDeviceProperties"); + table->GetPhysicalDevicePerformance = (PFN_vkGetPhysicalDevicePerformance) gpa(inst, "vkGetPhysicalDevicePerformance"); + table->GetPhysicalDeviceQueueCount = (PFN_vkGetPhysicalDeviceQueueCount) gpa(inst, "vkGetPhysicalDeviceQueueCount"); + table->GetPhysicalDeviceQueueProperties = (PFN_vkGetPhysicalDeviceQueueProperties) gpa(inst, "vkGetPhysicalDeviceQueueProperties"); + table->GetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties) gpa(inst, "vkGetPhysicalDeviceMemoryProperties"); + table->GetPhysicalDeviceExtensionProperties = (PFN_vkGetPhysicalDeviceExtensionProperties) gpa(inst, "vkGetPhysicalDeviceExtensionProperties"); + table->GetPhysicalDeviceExtensionCount = (PFN_vkGetPhysicalDeviceExtensionCount) gpa(inst, "vkGetPhysicalDeviceExtensionCount"); } static inline void loader_init_instance_extension_dispatch_table( @@ -388,20 +393,30 @@ static inline void *loader_lookup_instance_dispatch_table( return (void *) table->DestroyInstance; if (!strcmp(name, "EnumeratePhysicalDevices")) return (void *) table->EnumeratePhysicalDevices; - if (!strcmp(name, "GetPhysicalDeviceInfo")) - return (void *) table->GetPhysicalDeviceInfo; if (!strcmp(name, "GetPhysicalDeviceFeatures")) return (void *) table->GetPhysicalDeviceFeatures; if (!strcmp(name, "GetPhysicalDeviceFormatInfo")) return (void *) table->GetPhysicalDeviceFormatInfo; if (!strcmp(name, "GetPhysicalDeviceLimits")) return (void *) table->GetPhysicalDeviceLimits; + if (!strcmp(name, "GetPhysicalDeviceProperties")) + return (void *) table->GetPhysicalDeviceProperties; + if (!strcmp(name, "GetPhysicalDevicePerformance")) + return (void *) table->GetPhysicalDevicePerformance; + if (!strcmp(name, "GetPhysicalDeviceQueueCount")) + return (void *) table->GetPhysicalDeviceQueueCount; + if (!strcmp(name, "GetPhysicalDeviceQueueProperties")) + return (void *) table->GetPhysicalDeviceQueueProperties; + if (!strcmp(name, "GetPhysicalDeviceMemoryProperties")) + return (void *) table->GetPhysicalDeviceMemoryProperties; if (!strcmp(name, "GetInstanceProcAddr")) return (void *) table->GetInstanceProcAddr; if (!strcmp(name, "CreateDevice")) return (void *) table->CreateDevice; - if (!strcmp(name, "GetPhysicalDeviceExtensionInfo")) - return (void *) table->GetPhysicalDeviceExtensionInfo; + if (!strcmp(name, "GetPhysicalDeviceExtensionCount")) + return (void *) table->GetPhysicalDeviceExtensionCount; + if (!strcmp(name, "GetPhysicalDeviceExtensionProperties")) + return (void *) table->GetPhysicalDeviceExtensionProperties; if (!strcmp(name, "DbgCreateMsgCallback")) return (void *) table->DbgCreateMsgCallback; if (!strcmp(name, "DbgDestroyMsgCallback")) diff --git a/loader/trampoline.c b/loader/trampoline.c index b5e5d7af..ec363732 100644 --- a/loader/trampoline.c +++ b/loader/trampoline.c @@ -146,11 +146,9 @@ LOADER_EXPORT VkResult VKAPI vkEnumeratePhysicalDevices( return res; } -LOADER_EXPORT VkResult VKAPI vkGetPhysicalDeviceInfo( +LOADER_EXPORT VkResult VKAPI vkGetPhysicalDeviceProperties( VkPhysicalDevice gpu, - VkPhysicalDeviceInfoType infoType, - size_t* pDataSize, - void* pData) + VkPhysicalDeviceProperties* pProperties) { const VkLayerInstanceDispatchTable *disp; VkResult res; @@ -158,7 +156,72 @@ LOADER_EXPORT VkResult VKAPI vkGetPhysicalDeviceInfo( disp = loader_get_instance_dispatch(gpu); loader_platform_thread_lock_mutex(&loader_lock); - res = disp->GetPhysicalDeviceInfo(gpu, infoType, pDataSize, pData); + res = disp->GetPhysicalDeviceProperties(gpu, pProperties); + loader_platform_thread_unlock_mutex(&loader_lock); + + return res; +} + +LOADER_EXPORT VkResult VKAPI vkGetPhysicalDevicePerformance( + VkPhysicalDevice gpu, + VkPhysicalDevicePerformance* pPerformance) +{ + const VkLayerInstanceDispatchTable *disp; + VkResult res; + + disp = loader_get_instance_dispatch(gpu); + + loader_platform_thread_lock_mutex(&loader_lock); + res = disp->GetPhysicalDevicePerformance(gpu, pPerformance); + loader_platform_thread_unlock_mutex(&loader_lock); + + return res; +} + +LOADER_EXPORT VkResult VKAPI vkGetPhysicalDeviceQueueCount( + VkPhysicalDevice gpu, + uint32_t* pCount) +{ + const VkLayerInstanceDispatchTable *disp; + VkResult res; + + disp = loader_get_instance_dispatch(gpu); + + loader_platform_thread_lock_mutex(&loader_lock); + res = disp->GetPhysicalDeviceQueueCount(gpu, pCount); + loader_platform_thread_unlock_mutex(&loader_lock); + + return res; +} + +LOADER_EXPORT VkResult VKAPI vkGetPhysicalDeviceQueueProperties( + VkPhysicalDevice gpu, + uint32_t count, + VkPhysicalDeviceQueueProperties* pQueueProperties) +{ + const VkLayerInstanceDispatchTable *disp; + VkResult res; + + disp = loader_get_instance_dispatch(gpu); + + loader_platform_thread_lock_mutex(&loader_lock); + res = disp->GetPhysicalDeviceQueueProperties(gpu, count, pQueueProperties); + loader_platform_thread_unlock_mutex(&loader_lock); + + return res; +} + +LOADER_EXPORT VkResult VKAPI vkGetPhysicalDeviceMemoryProperties( + VkPhysicalDevice gpu, + VkPhysicalDeviceMemoryProperties* pMemoryProperties) +{ + const VkLayerInstanceDispatchTable *disp; + VkResult res; + + disp = loader_get_instance_dispatch(gpu); + + loader_platform_thread_lock_mutex(&loader_lock); + res = disp->GetPhysicalDeviceMemoryProperties(gpu, pMemoryProperties); loader_platform_thread_unlock_mutex(&loader_lock); return res; @@ -244,17 +307,27 @@ LOADER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device) return res; } -LOADER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionInfo( +LOADER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( VkPhysicalDevice gpu, - VkExtensionInfoType infoType, uint32_t extensionIndex, - size_t* pDataSize, - void* pData) + VkExtensionProperties* pProperties) +{ + VkResult res; + + loader_platform_thread_lock_mutex(&loader_lock); + res = loader_GetPhysicalDeviceExtensionProperties(gpu, extensionIndex, pProperties); + loader_platform_thread_unlock_mutex(&loader_lock); + return res; +} + +LOADER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionCount( + VkPhysicalDevice gpu, + uint32_t* pCount) { VkResult res; loader_platform_thread_lock_mutex(&loader_lock); - res = loader_GetPhysicalDeviceExtensionInfo(gpu, infoType, extensionIndex, pDataSize, pData); + res = loader_GetPhysicalDeviceExtensionCount(gpu, pCount); loader_platform_thread_unlock_mutex(&loader_lock); return res; } @@ -364,13 +437,13 @@ LOADER_EXPORT VkResult VKAPI vkDestroyObject(VkDevice device, VkObjectType objTy return disp->DestroyObject(device, objType, object); } -LOADER_EXPORT VkResult VKAPI vkGetObjectInfo(VkDevice device, VkObjectType objType, VkObject object, VkObjectInfoType infoType, size_t* pDataSize, void* pData) +LOADER_EXPORT VkResult VKAPI vkGetObjectMemoryRequirements(VkDevice device, VkObjectType objType, VkObject object, VkMemoryRequirements* pMemoryRequirements) { const VkLayerDispatchTable *disp; disp = loader_get_dispatch(device); - return disp->GetObjectInfo(device, objType, object, infoType, pDataSize, pData); + return disp->GetObjectMemoryRequirements(device, objType, object, pMemoryRequirements); } LOADER_EXPORT VkResult VKAPI vkBindObjectMemory(VkDevice device, VkObjectType objType, VkObject object, VkDeviceMemory mem, VkDeviceSize offset) @@ -544,13 +617,13 @@ LOADER_EXPORT VkResult VKAPI vkCreateImage(VkDevice device, const VkImageCreateI return disp->CreateImage(device, pCreateInfo, pImage); } -LOADER_EXPORT VkResult VKAPI vkGetImageSubresourceInfo(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceInfoType infoType, size_t* pDataSize, void* pData) +LOADER_EXPORT VkResult VKAPI vkGetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) { const VkLayerDispatchTable *disp; disp = loader_get_dispatch(device); - return disp->GetImageSubresourceInfo(device, image, pSubresource, infoType, pDataSize, pData); + return disp->GetImageSubresourceLayout(device, image, pSubresource, pLayout); } LOADER_EXPORT VkResult VKAPI vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView) diff --git a/loader/vk-loader-generate.py b/loader/vk-loader-generate.py index d1a50825..eed42dfa 100755 --- a/loader/vk-loader-generate.py +++ b/loader/vk-loader-generate.py @@ -48,7 +48,7 @@ class Subcommand(object): def _requires_special_trampoline_code(self, name): # Dont be cute trying to use a general rule to programmatically populate this list # it just obsfucates what is going on! - wsi_creates_dispatchable_object = ["GetPhysicalDeviceInfo", "CreateSwapChainWSI"] + wsi_creates_dispatchable_object = ["CreateSwapChainWSI"] creates_dispatchable_object = ["CreateDevice", "GetDeviceQueue", "CreateCommandBuffer"] + wsi_creates_dispatchable_object if name in creates_dispatchable_object: return True @@ -136,18 +136,7 @@ class LoaderEntrypointsSubcommand(Subcommand): if "Get" in proto.name: method = "loader_set_dispatch" - if proto.name == "GetPhysicalDeviceInfo": - ptype = proto.params[-3].name - psize = proto.params[-2].name - pdata = proto.params[-1].name - cond = ("%s == VK_PHYSICAL_DEVICE_INFO_TYPE_DISPLAY_PROPERTIES_WSI && " - "%s && %s" % (ptype, pdata, cond)) - setup.append("VkDisplayPropertiesWSI *info = %s;" % pdata) - setup.append("size_t count = *%s / sizeof(*info), i;" % psize) - setup.append("for (i = 0; i < count; i++) {") - setup.append(" %s(info[i].display, disp);" % method) - setup.append("}") - elif proto.name == "GetSwapChainInfoWSI": + if proto.name == "GetSwapChainInfoWSI": ptype = proto.params[-3].name psize = proto.params[-2].name pdata = proto.params[-1].name diff --git a/vk-generate.py b/vk-generate.py index 6f136b7b..b40bb227 100755 --- a/vk-generate.py +++ b/vk-generate.py @@ -121,7 +121,7 @@ class DispatchTableOpsSubcommand(Subcommand): stmts.append("// GPA has to be first entry inited and uses wrapped object since it triggers init") stmts.append("table->GetDeviceProcAddr =(PFN_vkGetDeviceProcAddr) gpa(device,\"vkGetDeviceProcAddr\");") for proto in self.protos: - if proto.name == "CreateInstance" or proto.name == "GetGlobalExtensionInfo" or proto.params[0].ty == "VkInstance" or proto.params[0].ty == "VkPhysicalDevice": + if proto.name == "CreateInstance" or proto.name == "GetGlobalExtensionProperties" or proto.name == "GetGlobalExtensionCount" or proto.params[0].ty == "VkInstance" or proto.params[0].ty == "VkPhysicalDevice": continue if proto.name != "GetDeviceProcAddr": stmts.append("table->%s = (PFN_vk%s) gpa(baseDevice, \"vk%s\");" % @@ -248,7 +248,8 @@ class WinDefFileSubcommand(Subcommand): "GetInstanceProcAddr", "GetDeviceProcAddr", "EnumerateLayers", - "GetGlobalExtensionInfo", + "GetGlobalExtensionCount", + "GetGlobalExtensionProperties" ], } diff --git a/vk-layer-generate.py b/vk-layer-generate.py index bbe6e989..8427707b 100755 --- a/vk-layer-generate.py +++ b/vk-layer-generate.py @@ -34,7 +34,7 @@ import vk_helper from source_line_info import sourcelineinfo def proto_is_global(proto): - if proto.params[0].ty == "VkInstance" or proto.params[0].ty == "VkPhysicalDevice" or proto.name == "CreateInstance" or proto.name == "GetGlobalExtensionInfo" or proto.name == "GetPhysicalDeviceExtensionInfo": + if proto.params[0].ty == "VkInstance" or proto.params[0].ty == "VkPhysicalDevice" or proto.name == "CreateInstance" or proto.name == "GetGlobalExtensionCount" or proto.name == "GetGlobalExtensionProperties" or proto.name == "GetPhysicalDeviceExtensionCount" or proto.name == "GetPhysicalDeviceExtensionProperties": return True else: return False @@ -197,154 +197,134 @@ class Subcommand(object): r_body.append('}') return "\n".join(r_body) - def _gen_layer_get_global_extension_info(self, layer="Generic"): - ggei_body = [] + def _gen_layer_get_global_extension_props(self, layer="Generic"): + ggep_body = [] if layer == 'APIDump' or layer == 'Generic': - ggei_body.append('%s' % self.lineinfo.get()) - ggei_body.append('#define LAYER_EXT_ARRAY_SIZE 1') - ggei_body.append('static const VkExtensionProperties layerExts[LAYER_EXT_ARRAY_SIZE] = {') - ggei_body.append(' {') - ggei_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') - ggei_body.append(' "%s",' % layer) - ggei_body.append(' 0x10,') - ggei_body.append(' "layer: %s",' % layer) - ggei_body.append(' }') - ggei_body.append('};') + ggep_body.append('%s' % self.lineinfo.get()) + ggep_body.append('#define LAYER_EXT_ARRAY_SIZE 1') + ggep_body.append('static const VkExtensionProperties layerExts[LAYER_EXT_ARRAY_SIZE] = {') + ggep_body.append(' {') + ggep_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') + ggep_body.append(' "%s",' % layer) + ggep_body.append(' 0x10,') + ggep_body.append(' "layer: %s",' % layer) + ggep_body.append(' }') + ggep_body.append('};') else: - ggei_body.append('%s' % self.lineinfo.get()) - ggei_body.append('#define LAYER_EXT_ARRAY_SIZE 2') - ggei_body.append('static const VkExtensionProperties layerExts[LAYER_EXT_ARRAY_SIZE] = {') - ggei_body.append(' {') - ggei_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') - ggei_body.append(' "%s",' % layer) - ggei_body.append(' 0x10,') - ggei_body.append(' "layer: %s",' % layer) - ggei_body.append(' },') - ggei_body.append(' {') - ggei_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') - ggei_body.append(' "Validation",') - ggei_body.append(' 0x10,') - ggei_body.append(' "layer: %s",' % layer) - ggei_body.append(' }') - ggei_body.append('};') - ggei_body.append('') - ggei_body.append('%s' % self.lineinfo.get()) - ggei_body.append('VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo(VkExtensionInfoType infoType, uint32_t extensionIndex, size_t* pDataSize, void* pData)') - ggei_body.append('{') - ggei_body.append(' uint32_t *count;') - ggei_body.append('') - ggei_body.append(' if (pDataSize == NULL)') - ggei_body.append(' return VK_ERROR_INVALID_POINTER;') - ggei_body.append('') - ggei_body.append(' switch (infoType) {') - ggei_body.append(' case VK_EXTENSION_INFO_TYPE_COUNT:') - ggei_body.append(' *pDataSize = sizeof(uint32_t);') - ggei_body.append(' if (pData == NULL)') - ggei_body.append(' return VK_SUCCESS;') - ggei_body.append(' count = (uint32_t *) pData;') - ggei_body.append(' *count = LAYER_EXT_ARRAY_SIZE;') - ggei_body.append(' break;') - ggei_body.append(' case VK_EXTENSION_INFO_TYPE_PROPERTIES:') - ggei_body.append(' *pDataSize = sizeof(VkExtensionProperties);') - ggei_body.append(' if (pData == NULL)') - ggei_body.append(' return VK_SUCCESS;') - ggei_body.append(' if (extensionIndex >= LAYER_EXT_ARRAY_SIZE)') - ggei_body.append(' return VK_ERROR_INVALID_VALUE;') - ggei_body.append(' memcpy((VkExtensionProperties *) pData, &layerExts[extensionIndex], sizeof(VkExtensionProperties));') - ggei_body.append(' break;') - ggei_body.append(' default:') - ggei_body.append(' return VK_ERROR_INVALID_VALUE;') - ggei_body.append(' };') - ggei_body.append(' return VK_SUCCESS;') - ggei_body.append('}') - return "\n".join(ggei_body) - - def _gen_layer_get_physical_device_extension_info(self, layer="Generic"): - ggei_body = [] + ggep_body.append('%s' % self.lineinfo.get()) + ggep_body.append('#define LAYER_EXT_ARRAY_SIZE 2') + ggep_body.append('static const VkExtensionProperties layerExts[LAYER_EXT_ARRAY_SIZE] = {') + ggep_body.append(' {') + ggep_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') + ggep_body.append(' "%s",' % layer) + ggep_body.append(' 0x10,') + ggep_body.append(' "layer: %s",' % layer) + ggep_body.append(' },') + ggep_body.append(' {') + ggep_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') + ggep_body.append(' "Validation",') + ggep_body.append(' 0x10,') + ggep_body.append(' "layer: %s",' % layer) + ggep_body.append(' }') + ggep_body.append('};') + ggep_body.append('') + ggep_body.append('%s' % self.lineinfo.get()) + + ggep_body.append('') + ggep_body.append('VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties(uint32_t extensionIndex, VkExtensionProperties* pProperties)') + ggep_body.append('{') + ggep_body.append(' if (extensionIndex >= LAYER_EXT_ARRAY_SIZE)') + ggep_body.append(' return VK_ERROR_INVALID_VALUE;') + ggep_body.append(' memcpy(pProperties, &layerExts[extensionIndex], sizeof(VkExtensionProperties));') + ggep_body.append(' return VK_SUCCESS;') + ggep_body.append('}') + return "\n".join(ggep_body) + + def _gen_layer_get_global_extension_count(self, layer="Generic"): + ggec_body = [] + ggec_body.append('VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionCount(uint32_t* pCount)') + ggec_body.append('{') + ggec_body.append(' *pCount = LAYER_EXT_ARRAY_SIZE;') + ggec_body.append(' return VK_SUCCESS;') + ggec_body.append('}') + return "\n".join(ggec_body) + + def _gen_layer_get_physical_device_extension_props(self, layer="Generic"): + gpdep_body = [] if layer == 'APIDump' or layer == 'Generic': - ggei_body.append('#define LAYER_DEV_EXT_ARRAY_SIZE 2') - ggei_body.append('static const VkExtensionProperties layerDevExts[LAYER_DEV_EXT_ARRAY_SIZE] = {') - ggei_body.append(' {') - ggei_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') - ggei_body.append(' "%s",' % layer) - ggei_body.append(' 0x10,') - ggei_body.append(' "layer: %s",' % layer) - ggei_body.append(' },') - ggei_body.append(' {') - ggei_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') - ggei_body.append(' VK_WSI_LUNARG_EXTENSION_NAME,') - ggei_body.append(' 0x10,') - ggei_body.append(' "layer: %s",' % layer) - ggei_body.append(' }') - ggei_body.append('};') + gpdep_body.append('#define LAYER_DEV_EXT_ARRAY_SIZE 2') + gpdep_body.append('static const VkExtensionProperties layerDevExts[LAYER_DEV_EXT_ARRAY_SIZE] = {') + gpdep_body.append(' {') + gpdep_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') + gpdep_body.append(' "%s",' % layer) + gpdep_body.append(' 0x10,') + gpdep_body.append(' "layer: %s",' % layer) + gpdep_body.append(' },') + gpdep_body.append(' {') + gpdep_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') + gpdep_body.append(' VK_WSI_LUNARG_EXTENSION_NAME,') + gpdep_body.append(' 0x10,') + gpdep_body.append(' "layer: %s",' % layer) + gpdep_body.append(' }') + gpdep_body.append('};') elif layer == 'ObjectTracker': - ggei_body.append('#define LAYER_DEV_EXT_ARRAY_SIZE 3') - ggei_body.append('static const VkExtensionProperties layerDevExts[LAYER_DEV_EXT_ARRAY_SIZE] = {') - ggei_body.append(' {') - ggei_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') - ggei_body.append(' "%s",' % layer) - ggei_body.append(' 0x10,') - ggei_body.append(' "layer: %s",' % layer) - ggei_body.append(' },') - ggei_body.append(' {') - ggei_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') - ggei_body.append(' VK_WSI_LUNARG_EXTENSION_NAME,') - ggei_body.append(' 0x10,') - ggei_body.append(' "layer: %s",' % layer) - ggei_body.append(' },') - ggei_body.append(' {') - ggei_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') - ggei_body.append(' "Validation",') - ggei_body.append(' 0x10,') - ggei_body.append(' "layer: %s",' % layer) - ggei_body.append(' }') - ggei_body.append('};') + gpdep_body.append('#define LAYER_DEV_EXT_ARRAY_SIZE 3') + gpdep_body.append('static const VkExtensionProperties layerDevExts[LAYER_DEV_EXT_ARRAY_SIZE] = {') + gpdep_body.append(' {') + gpdep_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') + gpdep_body.append(' "%s",' % layer) + gpdep_body.append(' 0x10,') + gpdep_body.append(' "layer: %s",' % layer) + gpdep_body.append(' },') + gpdep_body.append(' {') + gpdep_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') + gpdep_body.append(' VK_WSI_LUNARG_EXTENSION_NAME,') + gpdep_body.append(' 0x10,') + gpdep_body.append(' "layer: %s",' % layer) + gpdep_body.append(' },') + gpdep_body.append(' {') + gpdep_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') + gpdep_body.append(' "Validation",') + gpdep_body.append(' 0x10,') + gpdep_body.append(' "layer: %s",' % layer) + gpdep_body.append(' }') + gpdep_body.append('};') else: - ggei_body.append('#define LAYER_DEV_EXT_ARRAY_SIZE 2') - ggei_body.append('static const VkExtensionProperties layerDevExts[LAYER_DEV_EXT_ARRAY_SIZE] = {') - ggei_body.append(' {') - ggei_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') - ggei_body.append(' "%s",' % layer) - ggei_body.append(' 0x10,') - ggei_body.append(' "layer: %s",' % layer) - ggei_body.append(' },') - ggei_body.append(' {') - ggei_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') - ggei_body.append(' "Validation",') - ggei_body.append(' 0x10,') - ggei_body.append(' "layer: %s",' % layer) - ggei_body.append(' }') - ggei_body.append('};') - ggei_body.append('') - ggei_body.append('VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionInfo(VkPhysicalDevice physicalDevice, VkExtensionInfoType infoType, uint32_t extensionIndex, size_t* pDataSize, void* pData)') - ggei_body.append('{') - ggei_body.append(' uint32_t *count;') - ggei_body.append('') - ggei_body.append(' if (pDataSize == NULL)') - ggei_body.append(' return VK_ERROR_INVALID_POINTER;') - ggei_body.append('') - ggei_body.append(' switch (infoType) {') - ggei_body.append(' case VK_EXTENSION_INFO_TYPE_COUNT:') - ggei_body.append(' *pDataSize = sizeof(uint32_t);') - ggei_body.append(' if (pData == NULL)') - ggei_body.append(' return VK_SUCCESS;') - ggei_body.append(' count = (uint32_t *) pData;') - ggei_body.append(' *count = LAYER_DEV_EXT_ARRAY_SIZE;') - ggei_body.append(' break;') - ggei_body.append(' case VK_EXTENSION_INFO_TYPE_PROPERTIES:') - ggei_body.append(' *pDataSize = sizeof(VkExtensionProperties);') - ggei_body.append(' if (pData == NULL)') - ggei_body.append(' return VK_SUCCESS;') - ggei_body.append(' if (extensionIndex >= LAYER_DEV_EXT_ARRAY_SIZE)') - ggei_body.append(' return VK_ERROR_INVALID_VALUE;') - ggei_body.append(' memcpy((VkExtensionProperties *) pData, &layerDevExts[extensionIndex], sizeof(VkExtensionProperties));') - ggei_body.append(' break;') - ggei_body.append(' default:') - ggei_body.append(' return VK_ERROR_INVALID_VALUE;') - ggei_body.append(' };') - ggei_body.append(' return VK_SUCCESS;') - ggei_body.append('}') - return "\n".join(ggei_body) + gpdep_body.append('#define LAYER_DEV_EXT_ARRAY_SIZE 2') + gpdep_body.append('static const VkExtensionProperties layerDevExts[LAYER_DEV_EXT_ARRAY_SIZE] = {') + gpdep_body.append(' {') + gpdep_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') + gpdep_body.append(' "%s",' % layer) + gpdep_body.append(' 0x10,') + gpdep_body.append(' "layer: %s",' % layer) + gpdep_body.append(' },') + gpdep_body.append(' {') + gpdep_body.append(' VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,') + gpdep_body.append(' "Validation",') + gpdep_body.append(' 0x10,') + gpdep_body.append(' "layer: %s",' % layer) + gpdep_body.append(' }') + gpdep_body.append('};') + gpdep_body.append('VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionProperties(VkPhysicalDevice physicalDevice, uint32_t extensionIndex, VkExtensionProperties* pProperties)') + gpdep_body.append('{') + gpdep_body.append(' if (extensionIndex >= LAYER_DEV_EXT_ARRAY_SIZE)') + gpdep_body.append(' return VK_ERROR_INVALID_VALUE;') + gpdep_body.append(' memcpy(pProperties, &layerDevExts[extensionIndex], sizeof(VkExtensionProperties));') + gpdep_body.append(' return VK_SUCCESS;') + gpdep_body.append('}') + gpdep_body.append('') + return "\n".join(gpdep_body) + + def _gen_layer_get_physical_device_extension_count(self, layer="Generic"): + gpdec_body = [] + gpdec_body.append('VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionCount(VkPhysicalDevice physicalDevice, uint32_t* pCount)') + gpdec_body.append('{') + gpdec_body.append(' *pCount = LAYER_DEV_EXT_ARRAY_SIZE;') + gpdec_body.append(' return VK_SUCCESS;') + gpdec_body.append('}') + gpdec_body.append('') + return "\n".join(gpdec_body) + def _generate_dispatch_entrypoints(self, qual=""): if qual: @@ -365,10 +345,16 @@ class Subcommand(object): intercept = self._gen_layer_dbg_destroy_msg_callback() elif 'CreateDevice' == proto.name: funcs.append('/* CreateDevice HERE */') - elif 'GetGlobalExtensionInfo' == proto.name: - intercept = self._gen_layer_get_global_extension_info(self.layer_name) - elif 'GetPhysicalDeviceExtensionInfo' == proto.name: - intercept = self._gen_layer_get_physical_device_extension_info(self.layer_name) + elif 'GetGlobalExtensionProperties' == proto.name: + intercept = self._gen_layer_get_global_extension_props(self.layer_name) + elif 'GetGlobalExtensionCount' == proto.name: + intercept = self._gen_layer_get_global_extension_count(self.layer_name) + elif 'GetPhysicalDeviceExtensionProperties' == proto.name: + intercept = self._gen_layer_get_physical_device_extension_props(self.layer_name) + elif 'GetPhysicalDeviceExtensionCount' == proto.name: + intercept = self._gen_layer_get_physical_device_extension_count(self.layer_name) + + if intercept is not None: funcs.append(intercept) if not "WSI" in proto.name: @@ -647,7 +633,7 @@ class GenericLayerSubcommand(Subcommand): gen_header.append('') return "\n".join(gen_header) def generate_intercept(self, proto, qual): - if proto.name in [ 'GetGlobalExtensionInfo', 'GetPhysicalDeviceExtensionInfo' ]: + if proto.name in [ 'GetGlobalExtensionCount', 'GetGlobalExtensionProperties', 'GetPhysicalDeviceExtensionCount', 'GetPhysicalDeviceExtensionProperties' ]: # use default version return None decl = proto.c_func(prefix="vk", attr="VKAPI") @@ -895,7 +881,7 @@ class APIDumpSubcommand(Subcommand): return "\n".join(func_body) def generate_intercept(self, proto, qual): - if proto.name in [ 'GetGlobalExtensionInfo', 'GetPhysicalDeviceExtensionInfo']: + if proto.name in [ 'GetGlobalExtensionCount','GetGlobalExtensionProperties','GetPhysicalDeviceExtensionCount','GetPhysicalDeviceExtensionProperties']: return None decl = proto.c_func(prefix="vk", attr="VKAPI") ret_val = '' @@ -1110,7 +1096,7 @@ class ObjectTrackerSubcommand(Subcommand): return "\n".join(header_txt) def generate_intercept(self, proto, qual): - if proto.name in [ 'DbgCreateMsgCallback', 'GetGlobalExtensionInfo', 'GetPhysicalDeviceExtensionInfo' ]: + if proto.name in [ 'DbgCreateMsgCallback', 'GetGlobalExtensionCount', 'GetGlobalExtensionProperties','GetPhysicalDeviceExtensionCount', 'GetPhysicalDeviceExtensionProperties' ]: # use default version return None @@ -1125,13 +1111,13 @@ class ObjectTrackerSubcommand(Subcommand): explicit_object_tracker_functions = [ "CreateInstance", "DestroyInstance", - "GetPhysicalDeviceInfo", + "GetPhysicalDeviceQueueProperties", "CreateDevice", "DestroyDevice", "GetDeviceQueue", "QueueSubmit", "DestroyObject", - "GetObjectInfo", + "GetObjectMemoryRequirements", "QueueBindSparseImageMemory", "QueueBindSparseBufferMemory", "GetFenceStatus", @@ -229,11 +229,26 @@ core = Extension( Param("uint32_t*", "pPhysicalDeviceCount"), Param("VkPhysicalDevice*", "pPhysicalDevices")]), - Proto("VkResult", "GetPhysicalDeviceInfo", + Proto("VkResult", "GetPhysicalDeviceProperties", [Param("VkPhysicalDevice", "gpu"), - Param("VkPhysicalDeviceInfoType", "infoType"), - Param("size_t*", "pDataSize"), - Param("void*", "pData")]), + Param("VkPhysicalDeviceProperties*", "pProperties")]), + + Proto("VkResult", "GetPhysicalDevicePerformance", + [Param("VkPhysicalDevice", "gpu"), + Param("VkPhysicalDevicePerformance*", "pPerformance")]), + + Proto("VkResult", "GetPhysicalDeviceQueueCount", + [Param("VkPhysicalDevice", "gpu"), + Param("uint32_t*", "pCount")]), + + Proto("VkResult", "GetPhysicalDeviceQueueProperties", + [Param("VkPhysicalDevice", "gpu"), + Param("uint32_t", "count"), + Param("VkPhysicalDeviceQueueProperties*", "pProperties")]), + + Proto("VkResult", "GetPhysicalDeviceMemoryProperties", + [Param("VkPhysicalDevice", "gpu"), + Param("VkPhysicalDeviceMemoryProperties*", "pProperties")]), Proto("VkResult", "GetPhysicalDeviceFeatures", [Param("VkPhysicalDevice", "physicalDevice"), @@ -264,18 +279,21 @@ core = Extension( Proto("VkResult", "DestroyDevice", [Param("VkDevice", "device")]), - Proto("VkResult", "GetGlobalExtensionInfo", - [Param("VkExtensionInfoType", "infoType"), + Proto("VkResult", "GetPhysicalDeviceExtensionProperties", + [Param("VkPhysicalDevice", "gpu"), Param("uint32_t", "extensionIndex"), - Param("size_t*", "pDataSize"), - Param("void*", "pData")]), + Param("VkExtensionProperties*", "pProperties")]), - Proto("VkResult", "GetPhysicalDeviceExtensionInfo", + Proto("VkResult", "GetPhysicalDeviceExtensionCount", [Param("VkPhysicalDevice", "gpu"), - Param("VkExtensionInfoType", "infoType"), - Param("uint32_t", "extensionIndex"), - Param("size_t*", "pDataSize"), - Param("void*", "pData")]), + Param("uint32_t*", "pCount")]), + + Proto("VkResult", "GetGlobalExtensionProperties", + [Param("uint32_t", "extensionIndex"), + Param("VkExtensionProperties*", "pProperties")]), + + Proto("VkResult", "GetGlobalExtensionCount", + [Param("uint32_t*", "pCount")]), Proto("VkResult", "GetDeviceQueue", [Param("VkDevice", "device"), @@ -331,13 +349,11 @@ core = Extension( Param("VkObjectType", "objType"), Param("VkObject", "object")]), - Proto("VkResult", "GetObjectInfo", + Proto("VkResult", "GetObjectMemoryRequirements", [Param("VkDevice", "device"), Param("VkObjectType", "objType"), Param("VkObject", "object"), - Param("VkObjectInfoType", "infoType"), - Param("size_t*", "pDataSize"), - Param("void*", "pData")]), + Param("VkMemoryRequirements*", "pMemoryRequirements")]), Proto("VkResult", "BindObjectMemory", [Param("VkDevice", "device"), @@ -441,13 +457,11 @@ core = Extension( Param("const VkImageCreateInfo*", "pCreateInfo"), Param("VkImage*", "pImage")]), - Proto("VkResult", "GetImageSubresourceInfo", + Proto("VkResult", "GetImageSubresourceLayout", [Param("VkDevice", "device"), Param("VkImage", "image"), Param("const VkImageSubresource*", "pSubresource"), - Param("VkSubresourceInfoType", "infoType"), - Param("size_t*", "pDataSize"), - Param("void*", "pData")]), + Param("VkSubresourceLayout*", "pLayout")]), Proto("VkResult", "CreateImageView", [Param("VkDevice", "device"), |
