summaryrefslogtreecommitdiff
path: root/lib/mesa/src/intel/vulkan
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2019-01-29 11:08:07 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2019-01-29 11:08:07 +0000
commit6b139c2063623e9310025247cd966490b9aa57ea (patch)
tree375acfd898ca3d721250aa17291bbb90a8d7250a /lib/mesa/src/intel/vulkan
parentcce99579dcfb1d54c54cff65573be3430e77f2c5 (diff)
Import Mesa 18.3.2
Diffstat (limited to 'lib/mesa/src/intel/vulkan')
-rw-r--r--lib/mesa/src/intel/vulkan/anv_android.c44
-rw-r--r--lib/mesa/src/intel/vulkan/anv_extensions.c534
-rw-r--r--lib/mesa/src/intel/vulkan/anv_extensions.h122
-rw-r--r--lib/mesa/src/intel/vulkan/anv_extensions.py232
-rw-r--r--lib/mesa/src/intel/vulkan/anv_extensions_gen.py215
-rw-r--r--lib/mesa/src/intel/vulkan/anv_icd.py5
-rw-r--r--lib/mesa/src/intel/vulkan/anv_nir_add_base_work_group_id.c93
-rw-r--r--lib/mesa/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c71
-rw-r--r--lib/mesa/src/intel/vulkan/anv_wsi_display.c317
-rw-r--r--lib/mesa/src/intel/vulkan/meson.build242
10 files changed, 1282 insertions, 593 deletions
diff --git a/lib/mesa/src/intel/vulkan/anv_android.c b/lib/mesa/src/intel/vulkan/anv_android.c
index b1bbbb682..cdca9f95c 100644
--- a/lib/mesa/src/intel/vulkan/anv_android.c
+++ b/lib/mesa/src/intel/vulkan/anv_android.c
@@ -128,7 +128,13 @@ anv_image_from_gralloc(VkDevice device_h,
*/
int dma_buf = gralloc_info->handle->data[0];
- result = anv_bo_cache_import(device, &device->bo_cache, dma_buf, &bo);
+ uint64_t bo_flags = ANV_BO_EXTERNAL;
+ if (device->instance->physicalDevice.supports_48bit_addresses)
+ bo_flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
+ if (device->instance->physicalDevice.use_softpin)
+ bo_flags |= EXEC_OBJECT_PINNED;
+
+ result = anv_bo_cache_import(device, &device->bo_cache, dma_buf, bo_flags, &bo);
if (result != VK_SUCCESS) {
return vk_errorf(device->instance, device, result,
"failed to import dma-buf from VkNativeBufferANDROID");
@@ -174,7 +180,7 @@ anv_image_from_gralloc(VkDevice device_h,
goto fail_create;
if (bo->size < image->size) {
- result = vk_errorf(device, device->instance,
+ result = vk_errorf(device->instance, device,
VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR,
"dma-buf from VkNativeBufferANDROID is too small for "
"VkImage: %"PRIu64"B < %"PRIu64"B",
@@ -183,9 +189,9 @@ anv_image_from_gralloc(VkDevice device_h,
}
assert(image->n_planes == 1);
- assert(image->planes[0].bo_offset == 0);
+ assert(image->planes[0].address.offset == 0);
- image->planes[0].bo = bo;
+ image->planes[0].address.bo = bo;
image->planes[0].bo_is_owned = true;
/* We need to set the WRITE flag on window system buffers so that GEM will
@@ -228,7 +234,7 @@ VkResult anv_GetSwapchainGrallocUsageANDROID(
*grallocUsage = 0;
intel_logd("%s: format=%d, usage=0x%x", __func__, format, imageUsage);
- /* WARNING: Android Nougat's libvulkan.so hardcodes the VkImageUsageFlags
+ /* WARNING: Android's libvulkan.so hardcodes the VkImageUsageFlags
* returned to applications via VkSurfaceCapabilitiesKHR::supportedUsageFlags.
* The relevant code in libvulkan/swapchain.cpp contains this fun comment:
*
@@ -254,27 +260,21 @@ VkResult anv_GetSwapchainGrallocUsageANDROID(
};
/* Check that requested format and usage are supported. */
- result = anv_GetPhysicalDeviceImageFormatProperties2KHR(phys_dev_h,
+ result = anv_GetPhysicalDeviceImageFormatProperties2(phys_dev_h,
&image_format_info, &image_format_props);
if (result != VK_SUCCESS) {
return vk_errorf(device->instance, device, result,
- "anv_GetPhysicalDeviceImageFormatProperties2KHR failed "
+ "anv_GetPhysicalDeviceImageFormatProperties2 failed "
"inside %s", __func__);
}
- /* Reject STORAGE here to avoid complexity elsewhere. */
- if (imageUsage & VK_IMAGE_USAGE_STORAGE_BIT) {
- return vk_errorf(device->instance, device, VK_ERROR_FORMAT_NOT_SUPPORTED,
- "VK_IMAGE_USAGE_STORAGE_BIT unsupported for gralloc "
- "swapchain");
- }
-
if (unmask32(&imageUsage, VK_IMAGE_USAGE_TRANSFER_DST_BIT |
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT))
*grallocUsage |= GRALLOC_USAGE_HW_RENDER;
if (unmask32(&imageUsage, VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
VK_IMAGE_USAGE_SAMPLED_BIT |
+ VK_IMAGE_USAGE_STORAGE_BIT |
VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT))
*grallocUsage |= GRALLOC_USAGE_HW_TEXTURE;
@@ -294,11 +294,17 @@ VkResult anv_GetSwapchainGrallocUsageANDROID(
*
* FINISHME: Advertise all display-supported formats.
*/
- if (format == VK_FORMAT_B8G8R8A8_UNORM ||
- format == VK_FORMAT_B5G6R5_UNORM_PACK16) {
- *grallocUsage |= GRALLOC_USAGE_HW_FB |
- GRALLOC_USAGE_HW_COMPOSER |
- GRALLOC_USAGE_EXTERNAL_DISP;
+ switch (format) {
+ case VK_FORMAT_B8G8R8A8_UNORM:
+ case VK_FORMAT_B5G6R5_UNORM_PACK16:
+ case VK_FORMAT_R8G8B8A8_UNORM:
+ case VK_FORMAT_R8G8B8A8_SRGB:
+ *grallocUsage |= GRALLOC_USAGE_HW_FB |
+ GRALLOC_USAGE_HW_COMPOSER |
+ GRALLOC_USAGE_EXTERNAL_DISP;
+ break;
+ default:
+ intel_logw("%s: unsupported format=%d", __func__, format);
}
if (*grallocUsage == 0)
diff --git a/lib/mesa/src/intel/vulkan/anv_extensions.c b/lib/mesa/src/intel/vulkan/anv_extensions.c
index a5c1ea68a..0d939a0e7 100644
--- a/lib/mesa/src/intel/vulkan/anv_extensions.c
+++ b/lib/mesa/src/intel/vulkan/anv_extensions.c
@@ -51,6 +51,18 @@
#else
# define VK_USE_PLATFORM_XLIB_KHR false
#endif
+#ifdef VK_USE_PLATFORM_DISPLAY_KHR
+# undef VK_USE_PLATFORM_DISPLAY_KHR
+# define VK_USE_PLATFORM_DISPLAY_KHR true
+#else
+# define VK_USE_PLATFORM_DISPLAY_KHR false
+#endif
+#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
+# undef VK_USE_PLATFORM_XLIB_XRANDR_EXT
+# define VK_USE_PLATFORM_XLIB_XRANDR_EXT true
+#else
+# define VK_USE_PLATFORM_XLIB_XRANDR_EXT false
+#endif
/* And ANDROID too */
#ifdef ANDROID
@@ -60,388 +72,166 @@
# define ANDROID false
#endif
-#define ANV_HAS_SURFACE (VK_USE_PLATFORM_WAYLAND_KHR || VK_USE_PLATFORM_XCB_KHR || VK_USE_PLATFORM_XLIB_KHR)
+#define ANV_HAS_SURFACE (VK_USE_PLATFORM_WAYLAND_KHR || VK_USE_PLATFORM_XCB_KHR || VK_USE_PLATFORM_XLIB_KHR || VK_USE_PLATFORM_DISPLAY_KHR)
-bool
-anv_instance_extension_supported(const char *name)
-{
- if (strcmp(name, "VK_KHR_external_fence_capabilities") == 0)
- return true;
- if (strcmp(name, "VK_KHR_external_memory_capabilities") == 0)
- return true;
- if (strcmp(name, "VK_KHR_external_semaphore_capabilities") == 0)
- return true;
- if (strcmp(name, "VK_KHR_get_physical_device_properties2") == 0)
- return true;
- if (strcmp(name, "VK_KHR_get_surface_capabilities2") == 0)
- return ANV_HAS_SURFACE;
- if (strcmp(name, "VK_KHR_surface") == 0)
- return ANV_HAS_SURFACE;
- if (strcmp(name, "VK_KHR_wayland_surface") == 0)
- return VK_USE_PLATFORM_WAYLAND_KHR;
- if (strcmp(name, "VK_KHR_xcb_surface") == 0)
- return VK_USE_PLATFORM_XCB_KHR;
- if (strcmp(name, "VK_KHR_xlib_surface") == 0)
- return VK_USE_PLATFORM_XLIB_KHR;
- if (strcmp(name, "VK_EXT_debug_report") == 0)
- return true;
- return false;
-}
+static const uint32_t MAX_API_VERSION = VK_MAKE_VERSION(1, 1, 90);
-VkResult anv_EnumerateInstanceExtensionProperties(
- const char* pLayerName,
- uint32_t* pPropertyCount,
- VkExtensionProperties* pProperties)
+VkResult anv_EnumerateInstanceVersion(
+ uint32_t* pApiVersion)
{
- VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
+ *pApiVersion = MAX_API_VERSION;
+ return VK_SUCCESS;
+}
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_external_fence_capabilities",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_external_memory_capabilities",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_external_semaphore_capabilities",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_get_physical_device_properties2",
- .specVersion = 1,
- };
- }
- }
- if (ANV_HAS_SURFACE) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_get_surface_capabilities2",
- .specVersion = 1,
- };
- }
- }
- if (ANV_HAS_SURFACE) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_surface",
- .specVersion = 25,
- };
- }
- }
- if (VK_USE_PLATFORM_WAYLAND_KHR) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_wayland_surface",
- .specVersion = 6,
- };
- }
- }
- if (VK_USE_PLATFORM_XCB_KHR) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_xcb_surface",
- .specVersion = 6,
- };
- }
- }
- if (VK_USE_PLATFORM_XLIB_KHR) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_xlib_surface",
- .specVersion = 6,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_EXT_debug_report",
- .specVersion = 8,
- };
- }
- }
+const VkExtensionProperties anv_instance_extensions[ANV_INSTANCE_EXTENSION_COUNT] = {
+ {"VK_KHR_device_group_creation", 1},
+ {"VK_KHR_external_fence_capabilities", 1},
+ {"VK_KHR_external_memory_capabilities", 1},
+ {"VK_KHR_external_semaphore_capabilities", 1},
+ {"VK_KHR_get_display_properties2", 1},
+ {"VK_KHR_get_physical_device_properties2", 1},
+ {"VK_KHR_get_surface_capabilities2", 1},
+ {"VK_KHR_surface", 25},
+ {"VK_KHR_wayland_surface", 6},
+ {"VK_KHR_xcb_surface", 6},
+ {"VK_KHR_xlib_surface", 6},
+ {"VK_KHR_display", 23},
+ {"VK_EXT_acquire_xlib_display", 1},
+ {"VK_EXT_debug_report", 8},
+ {"VK_EXT_direct_mode_display", 1},
+ {"VK_EXT_display_surface_counter", 1},
+};
- return vk_outarray_status(&out);
-}
+const struct anv_instance_extension_table anv_instance_extensions_supported = {
+ .KHR_device_group_creation = true,
+ .KHR_external_fence_capabilities = true,
+ .KHR_external_memory_capabilities = true,
+ .KHR_external_semaphore_capabilities = true,
+ .KHR_get_display_properties2 = VK_USE_PLATFORM_DISPLAY_KHR,
+ .KHR_get_physical_device_properties2 = true,
+ .KHR_get_surface_capabilities2 = ANV_HAS_SURFACE,
+ .KHR_surface = ANV_HAS_SURFACE,
+ .KHR_wayland_surface = VK_USE_PLATFORM_WAYLAND_KHR,
+ .KHR_xcb_surface = VK_USE_PLATFORM_XCB_KHR,
+ .KHR_xlib_surface = VK_USE_PLATFORM_XLIB_KHR,
+ .KHR_display = VK_USE_PLATFORM_DISPLAY_KHR,
+ .EXT_acquire_xlib_display = VK_USE_PLATFORM_XLIB_XRANDR_EXT,
+ .EXT_debug_report = true,
+ .EXT_direct_mode_display = VK_USE_PLATFORM_DISPLAY_KHR,
+ .EXT_display_surface_counter = VK_USE_PLATFORM_DISPLAY_KHR,
+};
uint32_t
-anv_physical_device_api_version(struct anv_physical_device *dev)
+anv_physical_device_api_version(struct anv_physical_device *device)
{
- return VK_MAKE_VERSION(1, 0, 57);
-}
+ uint32_t version = 0;
-bool
-anv_physical_device_extension_supported(struct anv_physical_device *device,
- const char *name)
-{
- if (strcmp(name, "VK_ANDROID_native_buffer") == 0)
- return ANDROID;
- if (strcmp(name, "VK_KHR_bind_memory2") == 0)
- return true;
- if (strcmp(name, "VK_KHR_dedicated_allocation") == 0)
- return true;
- if (strcmp(name, "VK_KHR_descriptor_update_template") == 0)
- return true;
- if (strcmp(name, "VK_KHR_external_fence") == 0)
- return device->has_syncobj_wait;
- if (strcmp(name, "VK_KHR_external_fence_fd") == 0)
- return device->has_syncobj_wait;
- if (strcmp(name, "VK_KHR_external_memory") == 0)
- return true;
- if (strcmp(name, "VK_KHR_external_memory_fd") == 0)
- return true;
- if (strcmp(name, "VK_KHR_external_semaphore") == 0)
- return true;
- if (strcmp(name, "VK_KHR_external_semaphore_fd") == 0)
- return true;
- if (strcmp(name, "VK_KHR_get_memory_requirements2") == 0)
- return true;
- if (strcmp(name, "VK_KHR_image_format_list") == 0)
- return true;
- if (strcmp(name, "VK_KHR_incremental_present") == 0)
- return true;
- if (strcmp(name, "VK_KHR_maintenance1") == 0)
- return true;
- if (strcmp(name, "VK_KHR_maintenance2") == 0)
- return true;
- if (strcmp(name, "VK_KHR_push_descriptor") == 0)
- return true;
- if (strcmp(name, "VK_KHR_relaxed_block_layout") == 0)
- return true;
- if (strcmp(name, "VK_KHR_sampler_mirror_clamp_to_edge") == 0)
- return true;
- if (strcmp(name, "VK_KHR_sampler_ycbcr_conversion") == 0)
- return true;
- if (strcmp(name, "VK_KHR_shader_draw_parameters") == 0)
- return true;
- if (strcmp(name, "VK_KHR_storage_buffer_storage_class") == 0)
- return true;
- if (strcmp(name, "VK_KHR_swapchain") == 0)
- return ANV_HAS_SURFACE;
- if (strcmp(name, "VK_KHR_variable_pointers") == 0)
- return true;
- if (strcmp(name, "VK_KHX_multiview") == 0)
- return false;
- return false;
-}
+ uint32_t override = vk_get_version_override();
+ if (override)
+ return MIN2(override, MAX_API_VERSION);
-VkResult anv_EnumerateDeviceExtensionProperties(
- VkPhysicalDevice physicalDevice,
- const char* pLayerName,
- uint32_t* pPropertyCount,
- VkExtensionProperties* pProperties)
-{
- ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
- VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
- (void)device;
+ if (!(true))
+ return version;
+ version = VK_MAKE_VERSION(1, 0, 90);
- if (ANDROID) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_ANDROID_native_buffer",
- .specVersion = 5,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_bind_memory2",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_dedicated_allocation",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_descriptor_update_template",
- .specVersion = 1,
- };
- }
- }
- if (device->has_syncobj_wait) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_external_fence",
- .specVersion = 1,
- };
- }
- }
- if (device->has_syncobj_wait) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_external_fence_fd",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_external_memory",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_external_memory_fd",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_external_semaphore",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_external_semaphore_fd",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_get_memory_requirements2",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_image_format_list",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_incremental_present",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_maintenance1",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_maintenance2",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_push_descriptor",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_relaxed_block_layout",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_sampler_mirror_clamp_to_edge",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_sampler_ycbcr_conversion",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_shader_draw_parameters",
- .specVersion = 1,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_storage_buffer_storage_class",
- .specVersion = 1,
- };
- }
- }
- if (ANV_HAS_SURFACE) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_swapchain",
- .specVersion = 68,
- };
- }
- }
- if (true) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHR_variable_pointers",
- .specVersion = 1,
- };
- }
- }
- if (false) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "VK_KHX_multiview",
- .specVersion = 1,
- };
- }
- }
+ if (!(device->has_syncobj_wait))
+ return version;
+ version = VK_MAKE_VERSION(1, 1, 90);
- return vk_outarray_status(&out);
+ return version;
+}
+
+const VkExtensionProperties anv_device_extensions[ANV_DEVICE_EXTENSION_COUNT] = {
+ {"VK_ANDROID_native_buffer", 5},
+ {"VK_KHR_16bit_storage", 1},
+ {"VK_KHR_8bit_storage", 1},
+ {"VK_KHR_bind_memory2", 1},
+ {"VK_KHR_create_renderpass2", 1},
+ {"VK_KHR_dedicated_allocation", 1},
+ {"VK_KHR_descriptor_update_template", 1},
+ {"VK_KHR_device_group", 1},
+ {"VK_KHR_driver_properties", 1},
+ {"VK_KHR_external_fence", 1},
+ {"VK_KHR_external_fence_fd", 1},
+ {"VK_KHR_external_memory", 1},
+ {"VK_KHR_external_memory_fd", 1},
+ {"VK_KHR_external_semaphore", 1},
+ {"VK_KHR_external_semaphore_fd", 1},
+ {"VK_KHR_get_memory_requirements2", 1},
+ {"VK_KHR_image_format_list", 1},
+ {"VK_KHR_incremental_present", 1},
+ {"VK_KHR_maintenance1", 1},
+ {"VK_KHR_maintenance2", 1},
+ {"VK_KHR_maintenance3", 1},
+ {"VK_KHR_push_descriptor", 1},
+ {"VK_KHR_relaxed_block_layout", 1},
+ {"VK_KHR_sampler_mirror_clamp_to_edge", 1},
+ {"VK_KHR_sampler_ycbcr_conversion", 1},
+ {"VK_KHR_shader_draw_parameters", 1},
+ {"VK_KHR_storage_buffer_storage_class", 1},
+ {"VK_KHR_swapchain", 68},
+ {"VK_KHR_variable_pointers", 1},
+ {"VK_KHR_multiview", 1},
+ {"VK_EXT_display_control", 1},
+ {"VK_EXT_external_memory_dma_buf", 1},
+ {"VK_EXT_global_priority", 1},
+ {"VK_EXT_pci_bus_info", 1},
+ {"VK_EXT_shader_viewport_index_layer", 1},
+ {"VK_EXT_shader_stencil_export", 1},
+ {"VK_EXT_vertex_attribute_divisor", 3},
+ {"VK_EXT_post_depth_coverage", 1},
+ {"VK_EXT_sampler_filter_minmax", 1},
+ {"VK_EXT_calibrated_timestamps", 1},
+ {"VK_GOOGLE_decorate_string", 1},
+ {"VK_GOOGLE_hlsl_functionality1", 1},
+};
+
+void
+anv_physical_device_get_supported_extensions(const struct anv_physical_device *device,
+ struct anv_device_extension_table *extensions)
+{
+ *extensions = (struct anv_device_extension_table) {
+ .ANDROID_native_buffer = ANDROID,
+ .KHR_16bit_storage = device->info.gen >= 8,
+ .KHR_8bit_storage = device->info.gen >= 8,
+ .KHR_bind_memory2 = true,
+ .KHR_create_renderpass2 = true,
+ .KHR_dedicated_allocation = true,
+ .KHR_descriptor_update_template = true,
+ .KHR_device_group = true,
+ .KHR_driver_properties = true,
+ .KHR_external_fence = device->has_syncobj_wait,
+ .KHR_external_fence_fd = device->has_syncobj_wait,
+ .KHR_external_memory = true,
+ .KHR_external_memory_fd = true,
+ .KHR_external_semaphore = true,
+ .KHR_external_semaphore_fd = true,
+ .KHR_get_memory_requirements2 = true,
+ .KHR_image_format_list = true,
+ .KHR_incremental_present = ANV_HAS_SURFACE,
+ .KHR_maintenance1 = true,
+ .KHR_maintenance2 = true,
+ .KHR_maintenance3 = true,
+ .KHR_push_descriptor = true,
+ .KHR_relaxed_block_layout = true,
+ .KHR_sampler_mirror_clamp_to_edge = true,
+ .KHR_sampler_ycbcr_conversion = true,
+ .KHR_shader_draw_parameters = true,
+ .KHR_storage_buffer_storage_class = true,
+ .KHR_swapchain = ANV_HAS_SURFACE,
+ .KHR_variable_pointers = true,
+ .KHR_multiview = true,
+ .EXT_display_control = VK_USE_PLATFORM_DISPLAY_KHR,
+ .EXT_external_memory_dma_buf = true,
+ .EXT_global_priority = device->has_context_priority,
+ .EXT_pci_bus_info = false,
+ .EXT_shader_viewport_index_layer = true,
+ .EXT_shader_stencil_export = device->info.gen >= 9,
+ .EXT_vertex_attribute_divisor = true,
+ .EXT_post_depth_coverage = device->info.gen >= 9,
+ .EXT_sampler_filter_minmax = device->info.gen >= 9,
+ .EXT_calibrated_timestamps = true,
+ .GOOGLE_decorate_string = true,
+ .GOOGLE_hlsl_functionality1 = true,
+ };
}
diff --git a/lib/mesa/src/intel/vulkan/anv_extensions.h b/lib/mesa/src/intel/vulkan/anv_extensions.h
new file mode 100644
index 000000000..47b4ecf5b
--- /dev/null
+++ b/lib/mesa/src/intel/vulkan/anv_extensions.h
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef ANV_EXTENSIONS_H
+#define ANV_EXTENSIONS_H
+
+#include "stdbool.h"
+
+#define ANV_INSTANCE_EXTENSION_COUNT 16
+
+extern const VkExtensionProperties anv_instance_extensions[];
+
+struct anv_instance_extension_table {
+ union {
+ bool extensions[ANV_INSTANCE_EXTENSION_COUNT];
+ struct {
+ bool KHR_device_group_creation;
+ bool KHR_external_fence_capabilities;
+ bool KHR_external_memory_capabilities;
+ bool KHR_external_semaphore_capabilities;
+ bool KHR_get_display_properties2;
+ bool KHR_get_physical_device_properties2;
+ bool KHR_get_surface_capabilities2;
+ bool KHR_surface;
+ bool KHR_wayland_surface;
+ bool KHR_xcb_surface;
+ bool KHR_xlib_surface;
+ bool KHR_display;
+ bool EXT_acquire_xlib_display;
+ bool EXT_debug_report;
+ bool EXT_direct_mode_display;
+ bool EXT_display_surface_counter;
+ };
+ };
+};
+
+extern const struct anv_instance_extension_table anv_instance_extensions_supported;
+
+
+#define ANV_DEVICE_EXTENSION_COUNT 42
+
+extern const VkExtensionProperties anv_device_extensions[];
+
+struct anv_device_extension_table {
+ union {
+ bool extensions[ANV_DEVICE_EXTENSION_COUNT];
+ struct {
+ bool ANDROID_native_buffer;
+ bool KHR_16bit_storage;
+ bool KHR_8bit_storage;
+ bool KHR_bind_memory2;
+ bool KHR_create_renderpass2;
+ bool KHR_dedicated_allocation;
+ bool KHR_descriptor_update_template;
+ bool KHR_device_group;
+ bool KHR_driver_properties;
+ bool KHR_external_fence;
+ bool KHR_external_fence_fd;
+ bool KHR_external_memory;
+ bool KHR_external_memory_fd;
+ bool KHR_external_semaphore;
+ bool KHR_external_semaphore_fd;
+ bool KHR_get_memory_requirements2;
+ bool KHR_image_format_list;
+ bool KHR_incremental_present;
+ bool KHR_maintenance1;
+ bool KHR_maintenance2;
+ bool KHR_maintenance3;
+ bool KHR_push_descriptor;
+ bool KHR_relaxed_block_layout;
+ bool KHR_sampler_mirror_clamp_to_edge;
+ bool KHR_sampler_ycbcr_conversion;
+ bool KHR_shader_draw_parameters;
+ bool KHR_storage_buffer_storage_class;
+ bool KHR_swapchain;
+ bool KHR_variable_pointers;
+ bool KHR_multiview;
+ bool EXT_display_control;
+ bool EXT_external_memory_dma_buf;
+ bool EXT_global_priority;
+ bool EXT_pci_bus_info;
+ bool EXT_shader_viewport_index_layer;
+ bool EXT_shader_stencil_export;
+ bool EXT_vertex_attribute_divisor;
+ bool EXT_post_depth_coverage;
+ bool EXT_sampler_filter_minmax;
+ bool EXT_calibrated_timestamps;
+ bool GOOGLE_decorate_string;
+ bool GOOGLE_hlsl_functionality1;
+ };
+ };
+};
+
+struct anv_physical_device;
+
+void
+anv_physical_device_get_supported_extensions(const struct anv_physical_device *device,
+ struct anv_device_extension_table *extensions);
+
+#endif /* ANV_EXTENSIONS_H */
diff --git a/lib/mesa/src/intel/vulkan/anv_extensions.py b/lib/mesa/src/intel/vulkan/anv_extensions.py
index 0f66c59e1..e5b6c77a6 100644
--- a/lib/mesa/src/intel/vulkan/anv_extensions.py
+++ b/lib/mesa/src/intel/vulkan/anv_extensions.py
@@ -29,18 +29,39 @@ import copy
import re
import xml.etree.cElementTree as et
-MAX_API_VERSION = '1.0.57'
+def _bool_to_c_expr(b):
+ if b is True:
+ return 'true'
+ if b is False:
+ return 'false'
+ return b
class Extension:
def __init__(self, name, ext_version, enable):
self.name = name
self.ext_version = int(ext_version)
- if enable is True:
- self.enable = 'true';
- elif enable is False:
- self.enable = 'false';
- else:
- self.enable = enable;
+ self.enable = _bool_to_c_expr(enable)
+
+class ApiVersion:
+ def __init__(self, version, enable):
+ self.version = version
+ self.enable = _bool_to_c_expr(enable)
+
+API_PATCH_VERSION = 90
+
+# Supported API versions. Each one is the maximum patch version for the given
+# version. Version come in increasing order and each version is available if
+# it's provided "enable" condition is true and all previous versions are
+# available.
+API_VERSIONS = [
+ ApiVersion('1.0', True),
+
+ # DRM_IOCTL_SYNCOBJ_WAIT is required for VK_KHR_external_fence which is a
+ # required core feature in Vulkan 1.1
+ ApiVersion('1.1', 'device->has_syncobj_wait'),
+]
+
+MAX_API_VERSION = None # Computed later
# On Android, we disable all surface and swapchain extensions. Android's Vulkan
# loader implements VK_KHR_surface and VK_KHR_swapchain, and applications
@@ -49,9 +70,15 @@ class Extension:
# and dEQP-VK.api.info.device fail due to the duplicated strings.
EXTENSIONS = [
Extension('VK_ANDROID_native_buffer', 5, 'ANDROID'),
+ Extension('VK_KHR_16bit_storage', 1, 'device->info.gen >= 8'),
+ Extension('VK_KHR_8bit_storage', 1, 'device->info.gen >= 8'),
Extension('VK_KHR_bind_memory2', 1, True),
+ Extension('VK_KHR_create_renderpass2', 1, True),
Extension('VK_KHR_dedicated_allocation', 1, True),
Extension('VK_KHR_descriptor_update_template', 1, True),
+ Extension('VK_KHR_device_group', 1, True),
+ Extension('VK_KHR_device_group_creation', 1, True),
+ Extension('VK_KHR_driver_properties', 1, True),
Extension('VK_KHR_external_fence', 1,
'device->has_syncobj_wait'),
Extension('VK_KHR_external_fence_capabilities', 1, True),
@@ -63,13 +90,15 @@ EXTENSIONS = [
Extension('VK_KHR_external_semaphore', 1, True),
Extension('VK_KHR_external_semaphore_capabilities', 1, True),
Extension('VK_KHR_external_semaphore_fd', 1, True),
+ Extension('VK_KHR_get_display_properties2', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
Extension('VK_KHR_get_memory_requirements2', 1, True),
Extension('VK_KHR_get_physical_device_properties2', 1, True),
Extension('VK_KHR_get_surface_capabilities2', 1, 'ANV_HAS_SURFACE'),
Extension('VK_KHR_image_format_list', 1, True),
- Extension('VK_KHR_incremental_present', 1, True),
+ Extension('VK_KHR_incremental_present', 1, 'ANV_HAS_SURFACE'),
Extension('VK_KHR_maintenance1', 1, True),
Extension('VK_KHR_maintenance2', 1, True),
+ Extension('VK_KHR_maintenance3', 1, True),
Extension('VK_KHR_push_descriptor', 1, True),
Extension('VK_KHR_relaxed_block_layout', 1, True),
Extension('VK_KHR_sampler_mirror_clamp_to_edge', 1, True),
@@ -82,8 +111,25 @@ EXTENSIONS = [
Extension('VK_KHR_wayland_surface', 6, 'VK_USE_PLATFORM_WAYLAND_KHR'),
Extension('VK_KHR_xcb_surface', 6, 'VK_USE_PLATFORM_XCB_KHR'),
Extension('VK_KHR_xlib_surface', 6, 'VK_USE_PLATFORM_XLIB_KHR'),
- Extension('VK_KHX_multiview', 1, False),
+ Extension('VK_KHR_multiview', 1, True),
+ Extension('VK_KHR_display', 23, 'VK_USE_PLATFORM_DISPLAY_KHR'),
+ Extension('VK_EXT_acquire_xlib_display', 1, 'VK_USE_PLATFORM_XLIB_XRANDR_EXT'),
Extension('VK_EXT_debug_report', 8, True),
+ Extension('VK_EXT_direct_mode_display', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
+ Extension('VK_EXT_display_control', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
+ Extension('VK_EXT_display_surface_counter', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
+ Extension('VK_EXT_external_memory_dma_buf', 1, True),
+ Extension('VK_EXT_global_priority', 1,
+ 'device->has_context_priority'),
+ Extension('VK_EXT_pci_bus_info', 1, False),
+ Extension('VK_EXT_shader_viewport_index_layer', 1, True),
+ Extension('VK_EXT_shader_stencil_export', 1, 'device->info.gen >= 9'),
+ Extension('VK_EXT_vertex_attribute_divisor', 3, True),
+ Extension('VK_EXT_post_depth_coverage', 1, 'device->info.gen >= 9'),
+ Extension('VK_EXT_sampler_filter_minmax', 1, 'device->info.gen >= 9'),
+ Extension('VK_EXT_calibrated_timestamps', 1, True),
+ Extension('VK_GOOGLE_decorate_string', 1, True),
+ Extension('VK_GOOGLE_hlsl_functionality1', 1, True),
]
class VkVersion:
@@ -101,7 +147,7 @@ class VkVersion:
# VK_MAKE_VERSION macro
assert self.major < 1024 and self.minor < 1024
assert self.patch is None or self.patch < 4096
- assert(str(self) == string)
+ assert str(self) == string
def __str__(self):
ver_list = [str(self.major), str(self.minor)]
@@ -110,7 +156,8 @@ class VkVersion:
return '.'.join(ver_list)
def c_vk_version(self):
- ver_list = [str(self.major), str(self.minor), str(self.patch)]
+ patch = self.patch if self.patch is not None else 0
+ ver_list = [str(self.major), str(self.minor), str(patch)]
return 'VK_MAKE_VERSION(' + ', '.join(ver_list) + ')'
def __int_ver(self):
@@ -118,167 +165,20 @@ class VkVersion:
patch = self.patch if self.patch is not None else 0
return (self.major << 22) | (self.minor << 12) | patch
- def __cmp__(self, other):
+ def __gt__(self, other):
# If only one of them has a patch version, "ignore" it by making
# other's patch version match self.
if (self.patch is None) != (other.patch is None):
other = copy.copy(other)
other.patch = self.patch
- return self.__int_ver().__cmp__(other.__int_ver())
-
-MAX_API_VERSION = VkVersion(MAX_API_VERSION)
-
-def _init_exts_from_xml(xml):
- """ Walk the Vulkan XML and fill out extra extension information. """
-
- xml = et.parse(xml)
-
- ext_name_map = {}
- for ext in EXTENSIONS:
- ext_name_map[ext.name] = ext
-
- for ext_elem in xml.findall('.extensions/extension'):
- ext_name = ext_elem.attrib['name']
- if ext_name not in ext_name_map:
- continue
-
- # Workaround for VK_ANDROID_native_buffer. Its <extension> element in
- # vk.xml lists it as supported="disabled" and provides only a stub
- # definition. Its <extension> element in Mesa's custom
- # vk_android_native_buffer.xml, though, lists it as
- # supported='android-vendor' and fully defines the extension. We want
- # to skip the <extension> element in vk.xml.
- if ext_elem.attrib['supported'] == 'disabled':
- assert ext_name == 'VK_ANDROID_native_buffer'
- continue
-
- ext = ext_name_map[ext_name]
- ext.type = ext_elem.attrib['type']
-
-_TEMPLATE = COPYRIGHT + """
-#include "anv_private.h"
-
-#include "vk_util.h"
-
-/* Convert the VK_USE_PLATFORM_* defines to booleans */
-%for platform in ['ANDROID', 'WAYLAND', 'XCB', 'XLIB']:
-#ifdef VK_USE_PLATFORM_${platform}_KHR
-# undef VK_USE_PLATFORM_${platform}_KHR
-# define VK_USE_PLATFORM_${platform}_KHR true
-#else
-# define VK_USE_PLATFORM_${platform}_KHR false
-#endif
-%endfor
-
-/* And ANDROID too */
-#ifdef ANDROID
-# undef ANDROID
-# define ANDROID true
-#else
-# define ANDROID false
-#endif
-
-#define ANV_HAS_SURFACE (VK_USE_PLATFORM_WAYLAND_KHR || \\
- VK_USE_PLATFORM_XCB_KHR || \\
- VK_USE_PLATFORM_XLIB_KHR)
-
-bool
-anv_instance_extension_supported(const char *name)
-{
-%for ext in instance_extensions:
- if (strcmp(name, "${ext.name}") == 0)
- return ${ext.enable};
-%endfor
- return false;
-}
-
-VkResult anv_EnumerateInstanceExtensionProperties(
- const char* pLayerName,
- uint32_t* pPropertyCount,
- VkExtensionProperties* pProperties)
-{
- VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
-
-%for ext in instance_extensions:
- if (${ext.enable}) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "${ext.name}",
- .specVersion = ${ext.ext_version},
- };
- }
- }
-%endfor
-
- return vk_outarray_status(&out);
-}
-
-uint32_t
-anv_physical_device_api_version(struct anv_physical_device *dev)
-{
- return ${MAX_API_VERSION.c_vk_version()};
-}
-
-bool
-anv_physical_device_extension_supported(struct anv_physical_device *device,
- const char *name)
-{
-%for ext in device_extensions:
- if (strcmp(name, "${ext.name}") == 0)
- return ${ext.enable};
-%endfor
- return false;
-}
-
-VkResult anv_EnumerateDeviceExtensionProperties(
- VkPhysicalDevice physicalDevice,
- const char* pLayerName,
- uint32_t* pPropertyCount,
- VkExtensionProperties* pProperties)
-{
- ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
- VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
- (void)device;
-
-%for ext in device_extensions:
- if (${ext.enable}) {
- vk_outarray_append(&out, prop) {
- *prop = (VkExtensionProperties) {
- .extensionName = "${ext.name}",
- .specVersion = ${ext.ext_version},
- };
- }
- }
-%endfor
-
- return vk_outarray_status(&out);
-}
-"""
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser()
- parser.add_argument('--out', help='Output C file.', required=True)
- parser.add_argument('--xml',
- help='Vulkan API XML file.',
- required=True,
- action='append',
- dest='xml_files')
- args = parser.parse_args()
-
- for filename in args.xml_files:
- _init_exts_from_xml(filename)
-
- for ext in EXTENSIONS:
- assert ext.type == 'instance' or ext.type == 'device'
+ return self.__int_ver() > other.__int_ver()
- template_env = {
- 'MAX_API_VERSION': MAX_API_VERSION,
- 'instance_extensions': [e for e in EXTENSIONS if e.type == 'instance'],
- 'device_extensions': [e for e in EXTENSIONS if e.type == 'device'],
- }
- from mako.template import Template
- with open(args.out, 'w') as f:
- f.write(Template(_TEMPLATE).render(**template_env))
+MAX_API_VERSION = VkVersion('0.0.0')
+for version in API_VERSIONS:
+ version.version = VkVersion(version.version)
+ version.version.patch = API_PATCH_VERSION
+ assert version.version > MAX_API_VERSION
+ MAX_API_VERSION = version.version
diff --git a/lib/mesa/src/intel/vulkan/anv_extensions_gen.py b/lib/mesa/src/intel/vulkan/anv_extensions_gen.py
new file mode 100644
index 000000000..a140c2674
--- /dev/null
+++ b/lib/mesa/src/intel/vulkan/anv_extensions_gen.py
@@ -0,0 +1,215 @@
+COPYRIGHT = """\
+/*
+ * Copyright 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+"""
+
+import argparse
+import xml.etree.cElementTree as et
+
+from mako.template import Template
+
+from anv_extensions import *
+
+def _init_exts_from_xml(xml):
+ """ Walk the Vulkan XML and fill out extra extension information. """
+
+ xml = et.parse(xml)
+
+ ext_name_map = {}
+ for ext in EXTENSIONS:
+ ext_name_map[ext.name] = ext
+
+ for ext_elem in xml.findall('.extensions/extension'):
+ ext_name = ext_elem.attrib['name']
+ if ext_name not in ext_name_map:
+ continue
+
+ ext = ext_name_map[ext_name]
+ ext.type = ext_elem.attrib['type']
+
+_TEMPLATE_H = Template(COPYRIGHT + """
+
+#ifndef ANV_EXTENSIONS_H
+#define ANV_EXTENSIONS_H
+
+#include "stdbool.h"
+
+#define ANV_INSTANCE_EXTENSION_COUNT ${len(instance_extensions)}
+
+extern const VkExtensionProperties anv_instance_extensions[];
+
+struct anv_instance_extension_table {
+ union {
+ bool extensions[ANV_INSTANCE_EXTENSION_COUNT];
+ struct {
+%for ext in instance_extensions:
+ bool ${ext.name[3:]};
+%endfor
+ };
+ };
+};
+
+extern const struct anv_instance_extension_table anv_instance_extensions_supported;
+
+
+#define ANV_DEVICE_EXTENSION_COUNT ${len(device_extensions)}
+
+extern const VkExtensionProperties anv_device_extensions[];
+
+struct anv_device_extension_table {
+ union {
+ bool extensions[ANV_DEVICE_EXTENSION_COUNT];
+ struct {
+%for ext in device_extensions:
+ bool ${ext.name[3:]};
+%endfor
+ };
+ };
+};
+
+struct anv_physical_device;
+
+void
+anv_physical_device_get_supported_extensions(const struct anv_physical_device *device,
+ struct anv_device_extension_table *extensions);
+
+#endif /* ANV_EXTENSIONS_H */
+""")
+
+_TEMPLATE_C = Template(COPYRIGHT + """
+#include "anv_private.h"
+
+#include "vk_util.h"
+
+/* Convert the VK_USE_PLATFORM_* defines to booleans */
+%for platform in ['ANDROID_KHR', 'WAYLAND_KHR', 'XCB_KHR', 'XLIB_KHR', 'DISPLAY_KHR', 'XLIB_XRANDR_EXT']:
+#ifdef VK_USE_PLATFORM_${platform}
+# undef VK_USE_PLATFORM_${platform}
+# define VK_USE_PLATFORM_${platform} true
+#else
+# define VK_USE_PLATFORM_${platform} false
+#endif
+%endfor
+
+/* And ANDROID too */
+#ifdef ANDROID
+# undef ANDROID
+# define ANDROID true
+#else
+# define ANDROID false
+#endif
+
+#define ANV_HAS_SURFACE (VK_USE_PLATFORM_WAYLAND_KHR || \\
+ VK_USE_PLATFORM_XCB_KHR || \\
+ VK_USE_PLATFORM_XLIB_KHR || \\
+ VK_USE_PLATFORM_DISPLAY_KHR)
+
+static const uint32_t MAX_API_VERSION = ${MAX_API_VERSION.c_vk_version()};
+
+VkResult anv_EnumerateInstanceVersion(
+ uint32_t* pApiVersion)
+{
+ *pApiVersion = MAX_API_VERSION;
+ return VK_SUCCESS;
+}
+
+const VkExtensionProperties anv_instance_extensions[ANV_INSTANCE_EXTENSION_COUNT] = {
+%for ext in instance_extensions:
+ {"${ext.name}", ${ext.ext_version}},
+%endfor
+};
+
+const struct anv_instance_extension_table anv_instance_extensions_supported = {
+%for ext in instance_extensions:
+ .${ext.name[3:]} = ${ext.enable},
+%endfor
+};
+
+uint32_t
+anv_physical_device_api_version(struct anv_physical_device *device)
+{
+ uint32_t version = 0;
+
+ uint32_t override = vk_get_version_override();
+ if (override)
+ return MIN2(override, MAX_API_VERSION);
+
+%for version in API_VERSIONS:
+ if (!(${version.enable}))
+ return version;
+ version = ${version.version.c_vk_version()};
+
+%endfor
+ return version;
+}
+
+const VkExtensionProperties anv_device_extensions[ANV_DEVICE_EXTENSION_COUNT] = {
+%for ext in device_extensions:
+ {"${ext.name}", ${ext.ext_version}},
+%endfor
+};
+
+void
+anv_physical_device_get_supported_extensions(const struct anv_physical_device *device,
+ struct anv_device_extension_table *extensions)
+{
+ *extensions = (struct anv_device_extension_table) {
+%for ext in device_extensions:
+ .${ext.name[3:]} = ${ext.enable},
+%endfor
+ };
+}
+""")
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--out-c', help='Output C file.')
+ parser.add_argument('--out-h', help='Output H file.')
+ parser.add_argument('--xml',
+ help='Vulkan API XML file.',
+ required=True,
+ action='append',
+ dest='xml_files')
+ args = parser.parse_args()
+
+ for filename in args.xml_files:
+ _init_exts_from_xml(filename)
+
+ for ext in EXTENSIONS:
+ assert ext.type == 'instance' or ext.type == 'device'
+
+ template_env = {
+ 'API_VERSIONS': API_VERSIONS,
+ 'MAX_API_VERSION': MAX_API_VERSION,
+ 'instance_extensions': [e for e in EXTENSIONS if e.type == 'instance'],
+ 'device_extensions': [e for e in EXTENSIONS if e.type == 'device'],
+ }
+
+ if args.out_h:
+ with open(args.out_h, 'w') as f:
+ f.write(_TEMPLATE_H.render(**template_env))
+
+ if args.out_c:
+ with open(args.out_c, 'w') as f:
+ f.write(_TEMPLATE_C.render(**template_env))
diff --git a/lib/mesa/src/intel/vulkan/anv_icd.py b/lib/mesa/src/intel/vulkan/anv_icd.py
index 31bb0687a..73cc6453d 100644
--- a/lib/mesa/src/intel/vulkan/anv_icd.py
+++ b/lib/mesa/src/intel/vulkan/anv_icd.py
@@ -22,8 +22,9 @@
import json
import os.path
+import argparse
-from anv_extensions import *
+from anv_extensions import MAX_API_VERSION
if __name__ == '__main__':
parser = argparse.ArgumentParser()
@@ -44,4 +45,4 @@ if __name__ == '__main__':
}
with open(args.out, 'w') as f:
- json.dump(json_data, f, indent = 4, sort_keys=True)
+ json.dump(json_data, f, indent=4, sort_keys=True, separators=(',', ': '))
diff --git a/lib/mesa/src/intel/vulkan/anv_nir_add_base_work_group_id.c b/lib/mesa/src/intel/vulkan/anv_nir_add_base_work_group_id.c
new file mode 100644
index 000000000..a7c290bb5
--- /dev/null
+++ b/lib/mesa/src/intel/vulkan/anv_nir_add_base_work_group_id.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "anv_nir.h"
+#include "nir/nir_builder.h"
+#include "compiler/brw_compiler.h"
+
+bool
+anv_nir_add_base_work_group_id(nir_shader *shader,
+ struct brw_cs_prog_data *prog_data)
+{
+ assert(shader->info.stage == MESA_SHADER_COMPUTE);
+
+ nir_builder b;
+ int base_id_offset = -1;
+ bool progress = false;
+ nir_foreach_function(function, shader) {
+ if (!function->impl)
+ continue;
+
+ nir_builder_init(&b, function->impl);
+
+ nir_foreach_block(block, function->impl) {
+ nir_foreach_instr_safe(instr, block) {
+ if (instr->type != nir_instr_type_intrinsic)
+ continue;
+
+ nir_intrinsic_instr *load_id = nir_instr_as_intrinsic(instr);
+ if (load_id->intrinsic != nir_intrinsic_load_work_group_id)
+ continue;
+
+ b.cursor = nir_after_instr(&load_id->instr);
+
+ if (base_id_offset < 0) {
+ /* If we don't have a set of BASE_WORK_GROUP_ID params,
+ * add them.
+ */
+ assert(shader->num_uniforms == prog_data->base.nr_params * 4);
+ uint32_t *param =
+ brw_stage_prog_data_add_params(&prog_data->base, 3);
+ param[0] = BRW_PARAM_BUILTIN_BASE_WORK_GROUP_ID_X;
+ param[1] = BRW_PARAM_BUILTIN_BASE_WORK_GROUP_ID_Y;
+ param[2] = BRW_PARAM_BUILTIN_BASE_WORK_GROUP_ID_Z;
+
+ base_id_offset = shader->num_uniforms;
+ shader->num_uniforms += 12;
+ }
+
+ nir_intrinsic_instr *load_base =
+ nir_intrinsic_instr_create(shader, nir_intrinsic_load_uniform);
+ load_base->num_components = 3;
+ load_base->src[0] = nir_src_for_ssa(nir_imm_int(&b, 0));
+ nir_ssa_dest_init(&load_base->instr, &load_base->dest, 3, 32, NULL);
+ nir_intrinsic_set_base(load_base, base_id_offset);
+ nir_intrinsic_set_range(load_base, 3 * sizeof(uint32_t));
+ nir_builder_instr_insert(&b, &load_base->instr);
+
+ nir_ssa_def *id = nir_iadd(&b, &load_id->dest.ssa,
+ &load_base->dest.ssa);
+
+ nir_ssa_def_rewrite_uses_after(&load_id->dest.ssa,
+ nir_src_for_ssa(id),
+ id->parent_instr);
+ progress = true;
+ }
+ }
+
+ nir_metadata_preserve(function->impl, nir_metadata_block_index |
+ nir_metadata_dominance);
+ }
+
+ return progress;
+}
diff --git a/lib/mesa/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c b/lib/mesa/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
index 028f24e2f..71e511f34 100644
--- a/lib/mesa/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
+++ b/lib/mesa/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
@@ -30,6 +30,7 @@ struct ycbcr_state {
nir_builder *builder;
nir_ssa_def *image_size;
nir_tex_instr *origin_tex;
+ nir_deref_instr *tex_deref;
struct anv_ycbcr_conversion *conversion;
};
@@ -40,9 +41,9 @@ y_range(nir_builder *b,
VkSamplerYcbcrRangeKHR range)
{
switch (range) {
- case VK_SAMPLER_YCBCR_RANGE_ITU_FULL_KHR:
+ case VK_SAMPLER_YCBCR_RANGE_ITU_FULL:
return y_channel;
- case VK_SAMPLER_YCBCR_RANGE_ITU_NARROW_KHR:
+ case VK_SAMPLER_YCBCR_RANGE_ITU_NARROW:
return nir_fmul(b,
nir_fadd(b,
nir_fmul(b, y_channel,
@@ -62,10 +63,10 @@ chroma_range(nir_builder *b,
VkSamplerYcbcrRangeKHR range)
{
switch (range) {
- case VK_SAMPLER_YCBCR_RANGE_ITU_FULL_KHR:
+ case VK_SAMPLER_YCBCR_RANGE_ITU_FULL:
return nir_fadd(b, chroma_channel,
nir_imm_float(b, -pow(2, bpc - 1) / (pow(2, bpc) - 1.0f)));
- case VK_SAMPLER_YCBCR_RANGE_ITU_NARROW_KHR:
+ case VK_SAMPLER_YCBCR_RANGE_ITU_NARROW:
return nir_fmul(b,
nir_fadd(b,
nir_fmul(b, chroma_channel,
@@ -82,7 +83,7 @@ static const nir_const_value *
ycbcr_model_to_rgb_matrix(VkSamplerYcbcrModelConversionKHR model)
{
switch (model) {
- case VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601_KHR: {
+ case VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601: {
static const nir_const_value bt601[3] = {
{ .f32 = { 1.402f, 1.0f, 0.0f, 0.0f } },
{ .f32 = { -0.714136286201022f, 1.0f, -0.344136286201022f, 0.0f } },
@@ -91,7 +92,7 @@ ycbcr_model_to_rgb_matrix(VkSamplerYcbcrModelConversionKHR model)
return bt601;
}
- case VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709_KHR: {
+ case VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709: {
static const nir_const_value bt709[3] = {
{ .f32 = { 1.5748031496063f, 1.0f, 0.0, 0.0f } },
{ .f32 = { -0.468125209181067f, 1.0f, -0.187327487470334f, 0.0f } },
@@ -100,7 +101,7 @@ ycbcr_model_to_rgb_matrix(VkSamplerYcbcrModelConversionKHR model)
return bt709;
}
- case VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020_KHR: {
+ case VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020: {
static const nir_const_value bt2020[3] = {
{ .f32 = { 1.4746f, 1.0f, 0.0f, 0.0f } },
{ .f32 = { -0.571353126843658f, 1.0f, -0.164553126843658f, 0.0f } },
@@ -133,7 +134,7 @@ convert_ycbcr(struct ycbcr_state *state,
bpcs[2], conversion->ycbcr_range),
nir_imm_float(b, 1.0f));
- if (conversion->ycbcr_model == VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY_KHR)
+ if (conversion->ycbcr_model == VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY)
return expanded_channels;
const nir_const_value *conversion_matrix =
@@ -152,22 +153,24 @@ convert_ycbcr(struct ycbcr_state *state,
/* TODO: we should probably replace this with a push constant/uniform. */
static nir_ssa_def *
-get_texture_size(struct ycbcr_state *state, nir_deref_var *texture)
+get_texture_size(struct ycbcr_state *state, nir_deref_instr *texture)
{
if (state->image_size)
return state->image_size;
nir_builder *b = state->builder;
- const struct glsl_type *type = nir_deref_tail(&texture->deref)->type;
- nir_tex_instr *tex = nir_tex_instr_create(b->shader, 0);
+ const struct glsl_type *type = texture->type;
+ nir_tex_instr *tex = nir_tex_instr_create(b->shader, 1);
tex->op = nir_texop_txs;
tex->sampler_dim = glsl_get_sampler_dim(type);
tex->is_array = glsl_sampler_type_is_array(type);
tex->is_shadow = glsl_sampler_type_is_shadow(type);
- tex->texture = nir_deref_var_clone(texture, tex);
tex->dest_type = nir_type_int;
+ tex->src[0].src_type = nir_tex_src_texture_deref;
+ tex->src[0].src = nir_src_for_ssa(&texture->dest.ssa);
+
nir_ssa_dest_init(&tex->instr, &tex->dest,
nir_tex_instr_dest_size(tex), 32, NULL);
nir_builder_instr_insert(b, &tex->instr);
@@ -199,14 +202,13 @@ implicit_downsampled_coords(struct ycbcr_state *state,
{
nir_builder *b = state->builder;
struct anv_ycbcr_conversion *conversion = state->conversion;
- nir_ssa_def *image_size = get_texture_size(state,
- state->origin_tex->texture);
+ nir_ssa_def *image_size = get_texture_size(state, state->tex_deref);
nir_ssa_def *comp[4] = { NULL, };
int c;
for (c = 0; c < ARRAY_SIZE(conversion->chroma_offsets); c++) {
if (plane_format->denominator_scales[c] > 1 &&
- conversion->chroma_offsets[c] == VK_CHROMA_LOCATION_COSITED_EVEN_KHR) {
+ conversion->chroma_offsets[c] == VK_CHROMA_LOCATION_COSITED_EVEN) {
comp[c] = implicit_downsampled_coord(b,
nir_channel(b, old_coords, c),
nir_channel(b, image_size, c),
@@ -266,10 +268,7 @@ create_plane_tex_instr_implicit(struct ycbcr_state *state,
tex->texture_index = old_tex->texture_index;
tex->texture_array_size = old_tex->texture_array_size;
- tex->texture = nir_deref_var_clone(old_tex->texture, tex);
-
tex->sampler_index = old_tex->sampler_index;
- tex->sampler = nir_deref_var_clone(old_tex->sampler, tex);
nir_ssa_dest_init(&tex->instr, &tex->dest,
old_tex->dest.ssa.num_components,
@@ -316,13 +315,17 @@ swizzle_channel(struct isl_swizzle swizzle, unsigned channel)
}
static bool
-try_lower_tex_ycbcr(struct anv_pipeline *pipeline,
+try_lower_tex_ycbcr(struct anv_pipeline_layout *layout,
nir_builder *builder,
nir_tex_instr *tex)
{
- nir_variable *var = tex->texture->var;
+ int deref_src_idx = nir_tex_instr_src_index(tex, nir_tex_src_texture_deref);
+ assert(deref_src_idx >= 0);
+ nir_deref_instr *deref = nir_src_as_deref(tex->src[deref_src_idx].src);
+
+ nir_variable *var = nir_deref_instr_get_variable(deref);
const struct anv_descriptor_set_layout *set_layout =
- pipeline->layout->set[var->data.descriptor_set].layout;
+ layout->set[var->data.descriptor_set].layout;
const struct anv_descriptor_set_binding_layout *binding =
&set_layout->binding[var->data.binding];
@@ -337,18 +340,16 @@ try_lower_tex_ycbcr(struct anv_pipeline *pipeline,
if (binding->immutable_samplers == NULL)
return false;
- unsigned texture_index = tex->texture_index;
- if (tex->texture->deref.child) {
- assert(tex->texture->deref.child->deref_type == nir_deref_type_array);
- nir_deref_array *deref_array = nir_deref_as_array(tex->texture->deref.child);
- if (deref_array->deref_array_type != nir_deref_array_type_direct)
+ assert(tex->texture_index == 0);
+ unsigned array_index = 0;
+ if (deref->deref_type != nir_deref_type_var) {
+ assert(deref->deref_type == nir_deref_type_array);
+ nir_const_value *const_index = nir_src_as_const_value(deref->arr.index);
+ if (!const_index)
return false;
- size_t hw_binding_size =
- anv_descriptor_set_binding_layout_get_hw_size(binding);
- texture_index += MIN2(deref_array->base_offset, hw_binding_size - 1);
+ array_index = MIN2(const_index->u32[0], binding->array_size - 1);
}
- const struct anv_sampler *sampler =
- binding->immutable_samplers[texture_index];
+ const struct anv_sampler *sampler = binding->immutable_samplers[array_index];
if (sampler->conversion == NULL)
return false;
@@ -356,6 +357,7 @@ try_lower_tex_ycbcr(struct anv_pipeline *pipeline,
struct ycbcr_state state = {
.builder = builder,
.origin_tex = tex,
+ .tex_deref = deref,
.conversion = sampler->conversion,
};
@@ -430,7 +432,7 @@ try_lower_tex_ycbcr(struct anv_pipeline *pipeline,
}
nir_ssa_def *result = nir_vec(builder, swizzled_comp, 4);
- if (state.conversion->ycbcr_model != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY_KHR)
+ if (state.conversion->ycbcr_model != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY)
result = convert_ycbcr(&state, result, swizzled_bpcs);
nir_ssa_def_rewrite_uses(&tex->dest.ssa, nir_src_for_ssa(result));
@@ -440,7 +442,8 @@ try_lower_tex_ycbcr(struct anv_pipeline *pipeline,
}
bool
-anv_nir_lower_ycbcr_textures(nir_shader *shader, struct anv_pipeline *pipeline)
+anv_nir_lower_ycbcr_textures(nir_shader *shader,
+ struct anv_pipeline_layout *layout)
{
bool progress = false;
@@ -458,7 +461,7 @@ anv_nir_lower_ycbcr_textures(nir_shader *shader, struct anv_pipeline *pipeline)
continue;
nir_tex_instr *tex = nir_instr_as_tex(instr);
- function_progress |= try_lower_tex_ycbcr(pipeline, &builder, tex);
+ function_progress |= try_lower_tex_ycbcr(layout, &builder, tex);
}
}
diff --git a/lib/mesa/src/intel/vulkan/anv_wsi_display.c b/lib/mesa/src/intel/vulkan/anv_wsi_display.c
new file mode 100644
index 000000000..3212c235b
--- /dev/null
+++ b/lib/mesa/src/intel/vulkan/anv_wsi_display.c
@@ -0,0 +1,317 @@
+/*
+ * Copyright © 2017 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "anv_private.h"
+#include "wsi_common.h"
+#include "vk_format_info.h"
+#include "vk_util.h"
+#include "wsi_common_display.h"
+
+VkResult
+anv_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physical_device,
+ uint32_t *property_count,
+ VkDisplayPropertiesKHR *properties)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
+
+ return wsi_display_get_physical_device_display_properties(
+ physical_device,
+ &pdevice->wsi_device,
+ property_count,
+ properties);
+}
+
+VkResult
+anv_GetPhysicalDeviceDisplayProperties2KHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t* pPropertyCount,
+ VkDisplayProperties2KHR* pProperties)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
+
+ return wsi_display_get_physical_device_display_properties2(
+ physicalDevice, &pdevice->wsi_device,
+ pPropertyCount, pProperties);
+}
+
+VkResult
+anv_GetPhysicalDeviceDisplayPlanePropertiesKHR(
+ VkPhysicalDevice physical_device,
+ uint32_t *property_count,
+ VkDisplayPlanePropertiesKHR *properties)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
+
+ return wsi_display_get_physical_device_display_plane_properties(
+ physical_device, &pdevice->wsi_device,
+ property_count, properties);
+}
+
+VkResult
+anv_GetPhysicalDeviceDisplayPlaneProperties2KHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t* pPropertyCount,
+ VkDisplayPlaneProperties2KHR* pProperties)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
+
+ return wsi_display_get_physical_device_display_plane_properties2(
+ physicalDevice, &pdevice->wsi_device,
+ pPropertyCount, pProperties);
+}
+
+VkResult
+anv_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physical_device,
+ uint32_t plane_index,
+ uint32_t *display_count,
+ VkDisplayKHR *displays)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
+
+ return wsi_display_get_display_plane_supported_displays(physical_device,
+ &pdevice->wsi_device,
+ plane_index,
+ display_count,
+ displays);
+}
+
+
+VkResult
+anv_GetDisplayModePropertiesKHR(VkPhysicalDevice physical_device,
+ VkDisplayKHR display,
+ uint32_t *property_count,
+ VkDisplayModePropertiesKHR *properties)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
+
+ return wsi_display_get_display_mode_properties(physical_device,
+ &pdevice->wsi_device,
+ display,
+ property_count,
+ properties);
+}
+
+VkResult
+anv_GetDisplayModeProperties2KHR(
+ VkPhysicalDevice physicalDevice,
+ VkDisplayKHR display,
+ uint32_t* pPropertyCount,
+ VkDisplayModeProperties2KHR* pProperties)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
+
+ return wsi_display_get_display_mode_properties2(physicalDevice,
+ &pdevice->wsi_device,
+ display,
+ pPropertyCount,
+ pProperties);
+}
+
+VkResult
+anv_CreateDisplayModeKHR(VkPhysicalDevice physical_device,
+ VkDisplayKHR display,
+ const VkDisplayModeCreateInfoKHR *create_info,
+ const VkAllocationCallbacks *allocator,
+ VkDisplayModeKHR *mode)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
+
+ return wsi_display_create_display_mode(physical_device,
+ &pdevice->wsi_device,
+ display,
+ create_info,
+ allocator,
+ mode);
+}
+
+VkResult
+anv_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physical_device,
+ VkDisplayModeKHR mode_khr,
+ uint32_t plane_index,
+ VkDisplayPlaneCapabilitiesKHR *capabilities)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
+
+ return wsi_get_display_plane_capabilities(physical_device,
+ &pdevice->wsi_device,
+ mode_khr,
+ plane_index,
+ capabilities);
+}
+
+VkResult
+anv_GetDisplayPlaneCapabilities2KHR(
+ VkPhysicalDevice physicalDevice,
+ const VkDisplayPlaneInfo2KHR* pDisplayPlaneInfo,
+ VkDisplayPlaneCapabilities2KHR* pCapabilities)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
+
+ return wsi_get_display_plane_capabilities2(physicalDevice,
+ &pdevice->wsi_device,
+ pDisplayPlaneInfo,
+ pCapabilities);
+}
+
+VkResult
+anv_CreateDisplayPlaneSurfaceKHR(
+ VkInstance _instance,
+ const VkDisplaySurfaceCreateInfoKHR *create_info,
+ const VkAllocationCallbacks *allocator,
+ VkSurfaceKHR *surface)
+{
+ ANV_FROM_HANDLE(anv_instance, instance, _instance);
+ const VkAllocationCallbacks *alloc;
+
+ if (allocator)
+ alloc = allocator;
+ else
+ alloc = &instance->alloc;
+
+ return wsi_create_display_surface(_instance, alloc, create_info, surface);
+}
+
+VkResult
+anv_ReleaseDisplayEXT(VkPhysicalDevice physical_device,
+ VkDisplayKHR display)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
+
+ return wsi_release_display(physical_device,
+ &pdevice->wsi_device,
+ display);
+}
+
+#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
+VkResult
+anv_AcquireXlibDisplayEXT(VkPhysicalDevice physical_device,
+ Display *dpy,
+ VkDisplayKHR display)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
+
+ return wsi_acquire_xlib_display(physical_device,
+ &pdevice->wsi_device,
+ dpy,
+ display);
+}
+
+VkResult
+anv_GetRandROutputDisplayEXT(VkPhysicalDevice physical_device,
+ Display *dpy,
+ RROutput output,
+ VkDisplayKHR *display)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
+
+ return wsi_get_randr_output_display(physical_device,
+ &pdevice->wsi_device,
+ dpy,
+ output,
+ display);
+}
+#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
+
+/* VK_EXT_display_control */
+
+VkResult
+anv_DisplayPowerControlEXT(VkDevice _device,
+ VkDisplayKHR display,
+ const VkDisplayPowerInfoEXT *display_power_info)
+{
+ ANV_FROM_HANDLE(anv_device, device, _device);
+
+ return wsi_display_power_control(
+ _device, &device->instance->physicalDevice.wsi_device,
+ display, display_power_info);
+}
+
+VkResult
+anv_RegisterDeviceEventEXT(VkDevice _device,
+ const VkDeviceEventInfoEXT *device_event_info,
+ const VkAllocationCallbacks *allocator,
+ VkFence *_fence)
+{
+ ANV_FROM_HANDLE(anv_device, device, _device);
+ struct anv_fence *fence;
+ VkResult ret;
+
+ fence = vk_zalloc2(&device->instance->alloc, allocator, sizeof (*fence), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ if (!fence)
+ return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+
+ fence->permanent.type = ANV_FENCE_TYPE_WSI;
+
+ ret = wsi_register_device_event(_device,
+ &device->instance->physicalDevice.wsi_device,
+ device_event_info,
+ allocator,
+ &fence->permanent.fence_wsi);
+ if (ret == VK_SUCCESS)
+ *_fence = anv_fence_to_handle(fence);
+ else
+ vk_free2(&device->instance->alloc, allocator, fence);
+ return ret;
+}
+
+VkResult
+anv_RegisterDisplayEventEXT(VkDevice _device,
+ VkDisplayKHR display,
+ const VkDisplayEventInfoEXT *display_event_info,
+ const VkAllocationCallbacks *allocator,
+ VkFence *_fence)
+{
+ ANV_FROM_HANDLE(anv_device, device, _device);
+ struct anv_fence *fence;
+ VkResult ret;
+
+ fence = vk_zalloc2(&device->alloc, allocator, sizeof (*fence), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ if (!fence)
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+
+ fence->permanent.type = ANV_FENCE_TYPE_WSI;
+
+ ret = wsi_register_display_event(
+ _device, &device->instance->physicalDevice.wsi_device,
+ display, display_event_info, allocator, &(fence->permanent.fence_wsi));
+
+ if (ret == VK_SUCCESS)
+ *_fence = anv_fence_to_handle(fence);
+ else
+ vk_free2(&device->alloc, allocator, fence);
+ return ret;
+}
+
+VkResult
+anv_GetSwapchainCounterEXT(VkDevice _device,
+ VkSwapchainKHR swapchain,
+ VkSurfaceCounterFlagBitsEXT flag_bits,
+ uint64_t *value)
+{
+ ANV_FROM_HANDLE(anv_device, device, _device);
+
+ return wsi_get_swapchain_counter(
+ _device, &device->instance->physicalDevice.wsi_device,
+ swapchain, flag_bits, value);
+}
diff --git a/lib/mesa/src/intel/vulkan/meson.build b/lib/mesa/src/intel/vulkan/meson.build
new file mode 100644
index 000000000..b08b84fe2
--- /dev/null
+++ b/lib/mesa/src/intel/vulkan/meson.build
@@ -0,0 +1,242 @@
+# Copyright © 2017-2018 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+anv_extensions_py = files('anv_extensions.py')
+
+anv_entrypoints = custom_target(
+ 'anv_entrypoints.[ch]',
+ input : ['anv_entrypoints_gen.py', vk_api_xml],
+ output : ['anv_entrypoints.h', 'anv_entrypoints.c'],
+ command : [
+ prog_python, '@INPUT0@', '--xml', '@INPUT1@',
+ '--outdir', meson.current_build_dir(),
+ ],
+ depend_files : anv_extensions_py,
+)
+
+anv_extensions_c = custom_target(
+ 'anv_extensions.c',
+ input : ['anv_extensions_gen.py', vk_api_xml],
+ output : 'anv_extensions.c',
+ command : [
+ prog_python, '@INPUT0@', '--xml', '@INPUT1@',
+ '--out-c', '@OUTPUT@',
+ ],
+ depend_files : anv_extensions_py,
+)
+
+anv_extensions_h = custom_target(
+ 'anv_extensions.h',
+ input : ['anv_extensions_gen.py', vk_api_xml],
+ output : 'anv_extensions.h',
+ command : [
+ prog_python, '@INPUT0@', '--xml', '@INPUT1@',
+ '--out-h', '@OUTPUT@',
+ ],
+ depend_files : anv_extensions_py,
+)
+
+intel_icd = custom_target(
+ 'intel_icd',
+ input : 'anv_icd.py',
+ output : 'intel_icd.@0@.json'.format(host_machine.cpu()),
+ command : [
+ prog_python, '@INPUT@',
+ '--lib-path', join_paths(get_option('prefix'), get_option('libdir')),
+ '--out', '@OUTPUT@',
+ ],
+ depend_files : anv_extensions_py,
+ build_by_default : true,
+ install_dir : with_vulkan_icd_dir,
+ install : true,
+)
+
+dev_icd = custom_target(
+ 'dev_icd',
+ input : 'anv_icd.py',
+ output : 'dev_icd.@0@.json'.format(host_machine.cpu()),
+ command : [
+ prog_python, '@INPUT@', '--lib-path', meson.current_build_dir(),
+ '--out', '@OUTPUT@'
+ ],
+ depend_files : files('anv_extensions.py'),
+ build_by_default : true,
+ install : false,
+)
+
+libanv_gen_libs = []
+anv_gen_files = files(
+ 'genX_blorp_exec.c',
+ 'genX_cmd_buffer.c',
+ 'genX_gpu_memcpy.c',
+ 'genX_pipeline.c',
+ 'genX_query.c',
+ 'genX_state.c',
+)
+foreach g : [['70', ['gen7_cmd_buffer.c']], ['75', ['gen7_cmd_buffer.c']],
+ ['80', ['gen8_cmd_buffer.c']], ['90', ['gen8_cmd_buffer.c']],
+ ['100', ['gen8_cmd_buffer.c']], ['110', ['gen8_cmd_buffer.c']]]
+ _gen = g[0]
+ libanv_gen_libs += static_library(
+ 'anv_gen@0@'.format(_gen),
+ [anv_gen_files, g[1], anv_entrypoints[0], anv_extensions_h],
+ include_directories : [
+ inc_common, inc_compiler, inc_drm_uapi, inc_intel, inc_vulkan_util,
+ inc_vulkan_wsi,
+ ],
+ c_args : [
+ c_vis_args, no_override_init_args, c_sse2_args,
+ '-DGEN_VERSIONx10=@0@'.format(_gen),
+ ],
+ dependencies : [dep_libdrm, dep_valgrind, idep_nir_headers],
+ )
+endforeach
+
+libanv_files = files(
+ 'anv_allocator.c',
+ 'anv_batch_chain.c',
+ 'anv_blorp.c',
+ 'anv_cmd_buffer.c',
+ 'anv_descriptor_set.c',
+ 'anv_device.c',
+ 'anv_dump.c',
+ 'anv_formats.c',
+ 'anv_genX.h',
+ 'anv_image.c',
+ 'anv_intel.c',
+ 'anv_nir.h',
+ 'anv_nir_add_base_work_group_id.c',
+ 'anv_nir_apply_pipeline_layout.c',
+ 'anv_nir_lower_input_attachments.c',
+ 'anv_nir_lower_multiview.c',
+ 'anv_nir_lower_push_constants.c',
+ 'anv_nir_lower_ycbcr_textures.c',
+ 'anv_pass.c',
+ 'anv_pipeline.c',
+ 'anv_pipeline_cache.c',
+ 'anv_private.h',
+ 'anv_queue.c',
+ 'anv_util.c',
+ 'anv_wsi.c',
+ 'vk_format_info.h',
+)
+
+anv_deps = [
+ dep_libdrm,
+ dep_valgrind,
+ idep_nir_headers,
+]
+anv_flags = [
+ c_vis_args,
+ no_override_init_args,
+ c_sse2_args,
+]
+
+if with_platform_x11
+ anv_deps += dep_xcb_dri3
+ anv_flags += [
+ '-DVK_USE_PLATFORM_XCB_KHR',
+ '-DVK_USE_PLATFORM_XLIB_KHR',
+ ]
+ libanv_files += files('anv_wsi_x11.c')
+endif
+
+if with_platform_wayland
+ anv_deps += dep_wayland_client
+ anv_flags += '-DVK_USE_PLATFORM_WAYLAND_KHR'
+ libanv_files += files('anv_wsi_wayland.c')
+endif
+
+if with_platform_drm
+ anv_flags += '-DVK_USE_PLATFORM_DISPLAY_KHR'
+ libanv_files += files('anv_wsi_display.c')
+endif
+
+if with_xlib_lease
+ anv_deps += [dep_xcb_xrandr, dep_xlib_xrandr]
+ anv_flags += '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT'
+endif
+
+libanv_common = static_library(
+ 'anv_common',
+ [libanv_files, anv_entrypoints, anv_extensions_c, anv_extensions_h, sha1_h],
+ include_directories : [
+ inc_common, inc_intel, inc_compiler, inc_drm_uapi, inc_vulkan_util,
+ inc_vulkan_wsi,
+ ],
+ c_args : anv_flags,
+ dependencies : anv_deps,
+)
+
+libvulkan_intel = shared_library(
+ 'vulkan_intel',
+ [files('anv_gem.c'), anv_entrypoints[0], anv_extensions_h],
+ include_directories : [
+ inc_common, inc_intel, inc_compiler, inc_drm_uapi, inc_vulkan_util,
+ inc_vulkan_wsi,
+ ],
+ link_whole : [libanv_common, libanv_gen_libs],
+ link_with : [
+ libintel_compiler, libintel_common, libintel_dev, libisl, libblorp,
+ libvulkan_util, libvulkan_wsi, libmesa_util,
+ ],
+ dependencies : [
+ dep_thread, dep_dl, dep_m, anv_deps, idep_nir,
+ ],
+ c_args : anv_flags,
+ link_args : ['-Wl,--build-id=sha1', ld_args_bsymbolic, ld_args_gc_sections],
+ install : true,
+)
+
+if with_tests
+ libvulkan_intel_test = static_library(
+ 'vulkan_intel_test',
+ [files('anv_gem_stubs.c'), anv_entrypoints[0], anv_extensions_h],
+ include_directories : [
+ inc_common, inc_intel, inc_compiler, inc_drm_uapi, inc_vulkan_util,
+ inc_vulkan_wsi,
+ ],
+ link_whole : libanv_common,
+ link_with : [
+ libanv_gen_libs, libintel_compiler, libintel_common, libintel_dev,
+ libisl, libblorp, libvulkan_util, libvulkan_wsi, libmesa_util,
+ ],
+ dependencies : [
+ dep_thread, dep_dl, dep_m, anv_deps, idep_nir,
+ ],
+ c_args : anv_flags,
+ )
+
+ foreach t : ['block_pool_no_free', 'state_pool_no_free',
+ 'state_pool_free_list_only', 'state_pool']
+ test(
+ 'anv_@0@'.format(t),
+ executable(
+ t,
+ ['tests/@0@.c'.format(t), anv_entrypoints[0], anv_extensions_h],
+ link_with : libvulkan_intel_test,
+ dependencies : [dep_libdrm, dep_thread, dep_m, dep_valgrind],
+ include_directories : [
+ inc_common, inc_intel, inc_compiler, inc_vulkan_util, inc_vulkan_wsi,
+ ],
+ )
+ )
+ endforeach
+endif