aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2019-10-23 12:16:22 +0200
committerErik Faye-Lund <[email protected]>2019-10-30 19:40:50 +0000
commit477f0198129abd768cb6d201d4319cdb5fc1d568 (patch)
tree9ebcb1fd97749625596a9dd5caa4e3ef79a149af /src/gallium
parent780c937a5ded1a4586ba4160020200eebe57b311 (diff)
zink: only enable KHR_external_memory_fd if supported
While we're at it, make sure we error out if it's not supported when required. This brings us a bit closer to being able to test on SwiftShader, which doesn't currently support KHR_external_memory_fd.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/zink/zink_resource.c7
-rw-r--r--src/gallium/drivers/zink/zink_screen.c27
-rw-r--r--src/gallium/drivers/zink/zink_screen.h1
3 files changed, 28 insertions, 7 deletions
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index b12d38ec784..0051c891d57 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -355,8 +355,11 @@ zink_screen_resource_init(struct pipe_screen *pscreen)
{
pscreen->resource_create = zink_resource_create;
pscreen->resource_destroy = zink_resource_destroy;
- pscreen->resource_get_handle = zink_resource_get_handle;
- pscreen->resource_from_handle = zink_resource_from_handle;
+
+ if (zink_screen(pscreen)->have_KHR_external_memory_fd) {
+ pscreen->resource_get_handle = zink_resource_get_handle;
+ pscreen->resource_from_handle = zink_resource_from_handle;
+ }
}
static bool
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index a75389257af..59c96ed946f 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -299,6 +299,9 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_TWO_SIDED_COLOR:
return 0;
+ case PIPE_CAP_DMABUF:
+ return screen->have_KHR_external_memory_fd;
+
default:
return u_pipe_screen_get_param_defaults(pscreen, param);
}
@@ -869,8 +872,11 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
for (uint32_t i = 0; i < num_extensions; ++i) {
if (!strcmp(extensions[i].extensionName,
- VK_KHR_MAINTENANCE1_EXTENSION_NAME))
+ VK_KHR_MAINTENANCE1_EXTENSION_NAME))
screen->have_KHR_maintenance1 = true;
+ if (!strcmp(extensions[i].extensionName,
+ VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME))
+ screen->have_KHR_external_memory_fd = true;
}
FREE(extensions);
}
@@ -893,13 +899,24 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
dci.queueCreateInfoCount = 1;
dci.pQueueCreateInfos = &qci;
dci.pEnabledFeatures = &screen->feats;
- const char *extensions[] = {
+ const char *extensions[3] = {
VK_KHR_MAINTENANCE1_EXTENSION_NAME,
- VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME,
- VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME,
};
+ num_extensions = 1;
+
+ if (fd >= 0 && !screen->have_KHR_external_memory_fd) {
+ debug_printf("ZINK: KHR_external_memory_fd required!\n");
+ goto fail;
+ }
+
+ if (screen->have_KHR_external_memory_fd) {
+ extensions[num_extensions++] = VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME;
+ extensions[num_extensions++] = VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME;
+ }
+ assert(num_extensions <= ARRAY_SIZE(extensions));
+
dci.ppEnabledExtensionNames = extensions;
- dci.enabledExtensionCount = ARRAY_SIZE(extensions);
+ dci.enabledExtensionCount = num_extensions;
if (vkCreateDevice(screen->pdev, &dci, NULL, &screen->dev) != VK_SUCCESS)
goto fail;
diff --git a/src/gallium/drivers/zink/zink_screen.h b/src/gallium/drivers/zink/zink_screen.h
index 0b0ee210abb..5bf3fbdda8a 100644
--- a/src/gallium/drivers/zink/zink_screen.h
+++ b/src/gallium/drivers/zink/zink_screen.h
@@ -50,6 +50,7 @@ struct zink_screen {
VkPhysicalDeviceMemoryProperties mem_props;
bool have_KHR_maintenance1;
+ bool have_KHR_external_memory_fd;
bool have_X8_D24_UNORM_PACK32;
bool have_D24_UNORM_S8_UINT;