Mesa (master): zink/codegen: codegen-ize load_instance_extensions()
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Jan 17 15:31:08 UTC 2021
Module: Mesa
Branch: master
Commit: a454c562d6710d5405f7567909d67df20f36efc5
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a454c562d6710d5405f7567909d67df20f36efc5
Author: Hoe Hao Cheng <haochengho12907 at gmail.com>
Date: Fri Jan 15 17:16:54 2021 +0800
zink/codegen: codegen-ize load_instance_extensions()
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8521>
---
src/gallium/drivers/zink/zink_instance.py | 37 +++++++++++++++++++++++++++++++
src/gallium/drivers/zink/zink_screen.c | 37 +------------------------------
2 files changed, 38 insertions(+), 36 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_instance.py b/src/gallium/drivers/zink/zink_instance.py
index ddabd335023..551ee3895f4 100644
--- a/src/gallium/drivers/zink/zink_instance.py
+++ b/src/gallium/drivers/zink/zink_instance.py
@@ -59,6 +59,9 @@ struct zink_instance_info {
VkInstance
zink_create_instance(struct zink_screen *screen);
+bool
+zink_load_instance_extensions(struct zink_screen *screen);
+
#endif
"""
@@ -193,6 +196,40 @@ zink_create_instance(struct zink_screen *screen)
return instance;
}
+
+bool
+zink_load_instance_extensions(struct zink_screen *screen)
+{
+ if (zink_debug & ZINK_DEBUG_VALIDATION) {
+ printf("zink: Loader %d.%d.%d \\n", VK_VERSION_MAJOR(screen->loader_version), VK_VERSION_MINOR(screen->loader_version), VK_VERSION_PATCH(screen->loader_version));
+ }
+
+%for ext in extensions:
+%if bool(ext.instance_funcs) and not ext.core_since:
+ if (screen->instance_info.have_${ext.name_with_vendor()}) {
+ %for func in ext.instance_funcs:
+ GET_PROC_ADDR_INSTANCE_LOCAL(screen->instance, ${func}${ext.vendor()});
+ screen->vk_${func} = vk_${func}${ext.vendor()};
+ %endfor
+ }
+%elif bool(ext.instance_funcs):
+ if (screen->instance_info.have_${ext.name_with_vendor()}) {
+ if (screen->loader_version < ${ext.core_since.version()}) {
+ %for func in ext.instance_funcs:
+ GET_PROC_ADDR_INSTANCE_LOCAL(screen->instance, ${func}${ext.vendor()});
+ screen->vk_${func} = vk_${func}${ext.vendor()};
+ %endfor
+ } else {
+ %for func in ext.instance_funcs:
+ GET_PROC_ADDR_INSTANCE(${func});
+ %endfor
+ }
+ }
+%endif
+%endfor
+
+ return true;
+}
"""
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 2f3967be8e8..2e4735923cb 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -827,41 +827,6 @@ zink_get_format(struct zink_screen *screen, enum pipe_format format)
return ret;
}
-static bool
-load_instance_extensions(struct zink_screen *screen)
-{
- if (zink_debug & ZINK_DEBUG_VALIDATION) {
- printf("zink: Loader %d.%d.%d \n", VK_VERSION_MAJOR(screen->loader_version), VK_VERSION_MINOR(screen->loader_version), VK_VERSION_PATCH(screen->loader_version));
- }
-
- if (screen->instance_info.have_KHR_get_physical_device_properties2 &&
- !(VK_MAKE_VERSION(1,1,0) <= screen->loader_version)) {
- // Not Vk 1.1+ so if VK_KHR_get_physical_device_properties2 the use it
- GET_PROC_ADDR_INSTANCE_LOCAL(screen->instance, GetPhysicalDeviceFeatures2KHR);
- GET_PROC_ADDR_INSTANCE_LOCAL(screen->instance, GetPhysicalDeviceProperties2KHR);
- screen->vk_GetPhysicalDeviceFeatures2 = vk_GetPhysicalDeviceFeatures2KHR;
- screen->vk_GetPhysicalDeviceProperties2 = vk_GetPhysicalDeviceProperties2KHR;
- } else if (VK_MAKE_VERSION(1,1,0) <= screen->loader_version) {
- // Get Vk 1.1+ Instance functions
- GET_PROC_ADDR_INSTANCE(GetPhysicalDeviceFeatures2);
- GET_PROC_ADDR_INSTANCE(GetPhysicalDeviceProperties2);
- }
-
- if (screen->instance_info.have_KHR_draw_indirect_count &&
- !(VK_MAKE_VERSION(1,1,0) <= screen->loader_version)) {
- GET_PROC_ADDR_INSTANCE_LOCAL(screen->instance, CmdDrawIndirectCountKHR);
- GET_PROC_ADDR_INSTANCE_LOCAL(screen->instance, CmdDrawIndexedIndirectCountKHR);
- screen->vk_CmdDrawIndirectCount = vk_CmdDrawIndirectCountKHR;
- screen->vk_CmdDrawIndexedIndirectCount = vk_CmdDrawIndexedIndirectCountKHR;
- } else if (VK_MAKE_VERSION(1,2,0) <= screen->loader_version) {
- // Get Vk 1.1+ Instance functions
- GET_PROC_ADDR_INSTANCE(CmdDrawIndirectCount);
- GET_PROC_ADDR_INSTANCE(CmdDrawIndexedIndirectCount);
- }
-
- return true;
-}
-
static bool
load_device_extensions(struct zink_screen *screen)
{
@@ -1094,7 +1059,7 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
if (!screen->instance)
goto fail;
- if (!load_instance_extensions(screen))
+ if (!zink_load_instance_extensions(screen))
goto fail;
if (screen->instance_info.have_EXT_debug_utils && !create_debug(screen))
More information about the mesa-commit
mailing list