summaryrefslogtreecommitdiff
path: root/lib/mesa/src/vulkan/util
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2020-08-26 05:30:39 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2020-08-26 05:30:39 +0000
commit27c93456b58343162f7c4ad20ca6bea0c9a91646 (patch)
tree945c20b63e0b9975ee40f114c5312f8d8f1a2d0b /lib/mesa/src/vulkan/util
parent875b83a3ee95e248388fbf72271acc80f6f97987 (diff)
Import Mesa 20.1.6
Diffstat (limited to 'lib/mesa/src/vulkan/util')
-rw-r--r--lib/mesa/src/vulkan/util/meson.build3
-rw-r--r--lib/mesa/src/vulkan/util/vk_debug_report.c5
-rw-r--r--lib/mesa/src/vulkan/util/vk_format.c254
-rw-r--r--lib/mesa/src/vulkan/util/vk_format.h33
4 files changed, 293 insertions, 2 deletions
diff --git a/lib/mesa/src/vulkan/util/meson.build b/lib/mesa/src/vulkan/util/meson.build
index 9153878ea..0798913fe 100644
--- a/lib/mesa/src/vulkan/util/meson.build
+++ b/lib/mesa/src/vulkan/util/meson.build
@@ -22,6 +22,7 @@ files_vulkan_util = files(
'vk_alloc.h',
'vk_debug_report.c',
'vk_debug_report.h',
+ 'vk_format.c',
'vk_util.c',
'vk_util.h',
)
@@ -39,7 +40,7 @@ vk_enum_to_str = custom_target(
libvulkan_util = static_library(
'vulkan_util',
[files_vulkan_util, vk_enum_to_str],
- include_directories : inc_common,
+ include_directories : [inc_include, inc_src, inc_gallium],
dependencies : vulkan_wsi_deps,
c_args : [c_vis_args, vulkan_wsi_args],
build_by_default : false,
diff --git a/lib/mesa/src/vulkan/util/vk_debug_report.c b/lib/mesa/src/vulkan/util/vk_debug_report.c
index 22ae4a7d9..78dcfa6e2 100644
--- a/lib/mesa/src/vulkan/util/vk_debug_report.c
+++ b/lib/mesa/src/vulkan/util/vk_debug_report.c
@@ -77,6 +77,9 @@ vk_destroy_debug_report_callback(struct vk_debug_report_instance *instance,
const VkAllocationCallbacks* pAllocator,
const VkAllocationCallbacks* instance_allocator)
{
+ if (_callback == VK_NULL_HANDLE)
+ return;
+
struct vk_debug_report_callback *callback =
(struct vk_debug_report_callback *)(uintptr_t)_callback;
@@ -99,7 +102,7 @@ vk_debug_report(struct vk_debug_report_instance *instance,
const char *pMessage)
{
/* Allow NULL for convinience, return if no callbacks registered. */
- if (!instance || list_empty(&instance->callbacks))
+ if (!instance || list_is_empty(&instance->callbacks))
return;
pthread_mutex_lock(&instance->callbacks_mutex);
diff --git a/lib/mesa/src/vulkan/util/vk_format.c b/lib/mesa/src/vulkan/util/vk_format.c
new file mode 100644
index 000000000..f23575958
--- /dev/null
+++ b/lib/mesa/src/vulkan/util/vk_format.c
@@ -0,0 +1,254 @@
+/*
+ * Copyright © 2019 Google LLC
+ *
+ * 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 "vk_format.h"
+
+/* Note that for packed formats, VK_FORMAT_ lists channels from high to low
+ * bits occupied by the channel, while MESA_FORMAT_* and PIPE_FORMAT_* are
+ * low-to-high.
+ *
+ * Also, missing entries are zero-filled, which happens to be
+ * PIPE_FORMAT_NONE.
+ */
+static const enum pipe_format vk_format_map[] = {
+ /* Missing R4G4 */
+ [VK_FORMAT_R4G4B4A4_UNORM_PACK16] = PIPE_FORMAT_A4B4G4R4_UNORM,
+ [VK_FORMAT_B4G4R4A4_UNORM_PACK16] = PIPE_FORMAT_A4R4G4B4_UNORM,
+ [VK_FORMAT_R5G6B5_UNORM_PACK16] = PIPE_FORMAT_B5G6R5_UNORM,
+ [VK_FORMAT_B5G6R5_UNORM_PACK16] = PIPE_FORMAT_R5G6B5_UNORM,
+ [VK_FORMAT_R5G5B5A1_UNORM_PACK16] = PIPE_FORMAT_A1B5G5R5_UNORM,
+ [VK_FORMAT_B5G5R5A1_UNORM_PACK16] = PIPE_FORMAT_A1R5G5B5_UNORM,
+ [VK_FORMAT_A1R5G5B5_UNORM_PACK16] = PIPE_FORMAT_B5G5R5A1_UNORM,
+
+ [VK_FORMAT_R8_UNORM] = PIPE_FORMAT_R8_UNORM,
+ [VK_FORMAT_R8_SNORM] = PIPE_FORMAT_R8_SNORM,
+ [VK_FORMAT_R8_USCALED] = PIPE_FORMAT_R8_USCALED,
+ [VK_FORMAT_R8_SSCALED] = PIPE_FORMAT_R8_SSCALED,
+ [VK_FORMAT_R8_UINT] = PIPE_FORMAT_R8_UINT,
+ [VK_FORMAT_R8_SINT] = PIPE_FORMAT_R8_SINT,
+ [VK_FORMAT_R8_SRGB] = PIPE_FORMAT_R8_SRGB,
+
+ [VK_FORMAT_R8G8_UNORM] = PIPE_FORMAT_R8G8_UNORM,
+ [VK_FORMAT_R8G8_SNORM] = PIPE_FORMAT_R8G8_SNORM,
+ [VK_FORMAT_R8G8_USCALED] = PIPE_FORMAT_R8G8_USCALED,
+ [VK_FORMAT_R8G8_SSCALED] = PIPE_FORMAT_R8G8_SSCALED,
+ [VK_FORMAT_R8G8_UINT] = PIPE_FORMAT_R8G8_UINT,
+ [VK_FORMAT_R8G8_SINT] = PIPE_FORMAT_R8G8_SINT,
+ [VK_FORMAT_R8G8_SRGB] = PIPE_FORMAT_R8G8_SRGB,
+
+ [VK_FORMAT_R8G8B8_UNORM] = PIPE_FORMAT_R8G8B8_UNORM,
+ [VK_FORMAT_R8G8B8_SNORM] = PIPE_FORMAT_R8G8B8_SNORM,
+ [VK_FORMAT_R8G8B8_USCALED] = PIPE_FORMAT_R8G8B8_USCALED,
+ [VK_FORMAT_R8G8B8_SSCALED] = PIPE_FORMAT_R8G8B8_SSCALED,
+ [VK_FORMAT_R8G8B8_UINT] = PIPE_FORMAT_R8G8B8_UINT,
+ [VK_FORMAT_R8G8B8_SINT] = PIPE_FORMAT_R8G8B8_SINT,
+ [VK_FORMAT_R8G8B8_SRGB] = PIPE_FORMAT_R8G8B8_SRGB,
+
+ [VK_FORMAT_B8G8R8_UNORM] = PIPE_FORMAT_B8G8R8_UNORM,
+ [VK_FORMAT_B8G8R8_SNORM] = PIPE_FORMAT_B8G8R8_SNORM,
+ [VK_FORMAT_B8G8R8_USCALED] = PIPE_FORMAT_B8G8R8_USCALED,
+ [VK_FORMAT_B8G8R8_SSCALED] = PIPE_FORMAT_B8G8R8_SSCALED,
+ [VK_FORMAT_B8G8R8_UINT] = PIPE_FORMAT_B8G8R8_UINT,
+ [VK_FORMAT_B8G8R8_SINT] = PIPE_FORMAT_B8G8R8_SINT,
+ [VK_FORMAT_B8G8R8_SRGB] = PIPE_FORMAT_B8G8R8_SRGB,
+
+ [VK_FORMAT_R8G8B8A8_UNORM] = PIPE_FORMAT_R8G8B8A8_UNORM,
+ [VK_FORMAT_R8G8B8A8_SNORM] = PIPE_FORMAT_R8G8B8A8_SNORM,
+ [VK_FORMAT_R8G8B8A8_USCALED] = PIPE_FORMAT_R8G8B8A8_USCALED,
+ [VK_FORMAT_R8G8B8A8_SSCALED] = PIPE_FORMAT_R8G8B8A8_SSCALED,
+ [VK_FORMAT_R8G8B8A8_UINT] = PIPE_FORMAT_R8G8B8A8_UINT,
+ [VK_FORMAT_R8G8B8A8_SINT] = PIPE_FORMAT_R8G8B8A8_SINT,
+ [VK_FORMAT_R8G8B8A8_SRGB] = PIPE_FORMAT_R8G8B8A8_SRGB,
+
+ [VK_FORMAT_B8G8R8A8_UNORM] = PIPE_FORMAT_B8G8R8A8_UNORM,
+ [VK_FORMAT_B8G8R8A8_SNORM] = PIPE_FORMAT_B8G8R8A8_SNORM,
+ [VK_FORMAT_B8G8R8A8_USCALED] = PIPE_FORMAT_B8G8R8A8_USCALED,
+ [VK_FORMAT_B8G8R8A8_SSCALED] = PIPE_FORMAT_B8G8R8A8_SSCALED,
+ [VK_FORMAT_B8G8R8A8_UINT] = PIPE_FORMAT_B8G8R8A8_UINT,
+ [VK_FORMAT_B8G8R8A8_SINT] = PIPE_FORMAT_B8G8R8A8_SINT,
+ [VK_FORMAT_B8G8R8A8_SRGB] = PIPE_FORMAT_B8G8R8A8_SRGB,
+
+ [VK_FORMAT_A8B8G8R8_UNORM_PACK32] = PIPE_FORMAT_RGBA8888_UNORM,
+ [VK_FORMAT_A8B8G8R8_SNORM_PACK32] = PIPE_FORMAT_RGBA8888_SNORM,
+ [VK_FORMAT_A8B8G8R8_USCALED_PACK32] = PIPE_FORMAT_RGBA8888_USCALED,
+ [VK_FORMAT_A8B8G8R8_SSCALED_PACK32] = PIPE_FORMAT_RGBA8888_SSCALED,
+ [VK_FORMAT_A8B8G8R8_UINT_PACK32] = PIPE_FORMAT_RGBA8888_UINT,
+ [VK_FORMAT_A8B8G8R8_SINT_PACK32] = PIPE_FORMAT_RGBA8888_SINT,
+ [VK_FORMAT_A8B8G8R8_SRGB_PACK32] = PIPE_FORMAT_RGBA8888_SRGB,
+
+ [VK_FORMAT_A2R10G10B10_UNORM_PACK32] = PIPE_FORMAT_B10G10R10A2_UNORM,
+ [VK_FORMAT_A2R10G10B10_SNORM_PACK32] = PIPE_FORMAT_B10G10R10A2_SNORM,
+ [VK_FORMAT_A2R10G10B10_USCALED_PACK32] = PIPE_FORMAT_B10G10R10A2_USCALED,
+ [VK_FORMAT_A2R10G10B10_SSCALED_PACK32] = PIPE_FORMAT_B10G10R10A2_SSCALED,
+ [VK_FORMAT_A2R10G10B10_UINT_PACK32] = PIPE_FORMAT_B10G10R10A2_UINT,
+ [VK_FORMAT_A2R10G10B10_SINT_PACK32] = PIPE_FORMAT_B10G10R10A2_SINT,
+
+ [VK_FORMAT_A2B10G10R10_UNORM_PACK32] = PIPE_FORMAT_R10G10B10A2_UNORM,
+ [VK_FORMAT_A2B10G10R10_SNORM_PACK32] = PIPE_FORMAT_R10G10B10A2_SNORM,
+ [VK_FORMAT_A2B10G10R10_USCALED_PACK32] = PIPE_FORMAT_R10G10B10A2_USCALED,
+ [VK_FORMAT_A2B10G10R10_SSCALED_PACK32] = PIPE_FORMAT_R10G10B10A2_SSCALED,
+ [VK_FORMAT_A2B10G10R10_UINT_PACK32] = PIPE_FORMAT_R10G10B10A2_UINT,
+ [VK_FORMAT_A2B10G10R10_SINT_PACK32] = PIPE_FORMAT_R10G10B10A2_SINT,
+
+ [VK_FORMAT_R16_UNORM] = PIPE_FORMAT_R16_UNORM,
+ [VK_FORMAT_R16_SNORM] = PIPE_FORMAT_R16_SNORM,
+ [VK_FORMAT_R16_USCALED] = PIPE_FORMAT_R16_USCALED,
+ [VK_FORMAT_R16_SSCALED] = PIPE_FORMAT_R16_SSCALED,
+ [VK_FORMAT_R16_UINT] = PIPE_FORMAT_R16_UINT,
+ [VK_FORMAT_R16_SINT] = PIPE_FORMAT_R16_SINT,
+ [VK_FORMAT_R16_SFLOAT] = PIPE_FORMAT_R16_FLOAT,
+
+ [VK_FORMAT_R16G16_UNORM] = PIPE_FORMAT_R16G16_UNORM,
+ [VK_FORMAT_R16G16_SNORM] = PIPE_FORMAT_R16G16_SNORM,
+ [VK_FORMAT_R16G16_USCALED] = PIPE_FORMAT_R16G16_USCALED,
+ [VK_FORMAT_R16G16_SSCALED] = PIPE_FORMAT_R16G16_SSCALED,
+ [VK_FORMAT_R16G16_UINT] = PIPE_FORMAT_R16G16_UINT,
+ [VK_FORMAT_R16G16_SINT] = PIPE_FORMAT_R16G16_SINT,
+ [VK_FORMAT_R16G16_SFLOAT] = PIPE_FORMAT_R16G16_FLOAT,
+
+ [VK_FORMAT_R16G16B16_UNORM] = PIPE_FORMAT_R16G16B16_UNORM,
+ [VK_FORMAT_R16G16B16_SNORM] = PIPE_FORMAT_R16G16B16_SNORM,
+ [VK_FORMAT_R16G16B16_USCALED] = PIPE_FORMAT_R16G16B16_USCALED,
+ [VK_FORMAT_R16G16B16_SSCALED] = PIPE_FORMAT_R16G16B16_SSCALED,
+ [VK_FORMAT_R16G16B16_UINT] = PIPE_FORMAT_R16G16B16_UINT,
+ [VK_FORMAT_R16G16B16_SINT] = PIPE_FORMAT_R16G16B16_SINT,
+ [VK_FORMAT_R16G16B16_SFLOAT] = PIPE_FORMAT_R16G16B16_FLOAT,
+
+ [VK_FORMAT_R16G16B16A16_UNORM] = PIPE_FORMAT_R16G16B16A16_UNORM,
+ [VK_FORMAT_R16G16B16A16_SNORM] = PIPE_FORMAT_R16G16B16A16_SNORM,
+ [VK_FORMAT_R16G16B16A16_USCALED] = PIPE_FORMAT_R16G16B16A16_USCALED,
+ [VK_FORMAT_R16G16B16A16_SSCALED] = PIPE_FORMAT_R16G16B16A16_SSCALED,
+ [VK_FORMAT_R16G16B16A16_UINT] = PIPE_FORMAT_R16G16B16A16_UINT,
+ [VK_FORMAT_R16G16B16A16_SINT] = PIPE_FORMAT_R16G16B16A16_SINT,
+ [VK_FORMAT_R16G16B16A16_SFLOAT] = PIPE_FORMAT_R16G16B16A16_FLOAT,
+
+ [VK_FORMAT_R32_UINT] = PIPE_FORMAT_R32_UINT,
+ [VK_FORMAT_R32_SINT] = PIPE_FORMAT_R32_SINT,
+ [VK_FORMAT_R32_SFLOAT] = PIPE_FORMAT_R32_FLOAT,
+
+ [VK_FORMAT_R32G32_UINT] = PIPE_FORMAT_R32G32_UINT,
+ [VK_FORMAT_R32G32_SINT] = PIPE_FORMAT_R32G32_SINT,
+ [VK_FORMAT_R32G32_SFLOAT] = PIPE_FORMAT_R32G32_FLOAT,
+
+ [VK_FORMAT_R32G32B32_UINT] = PIPE_FORMAT_R32G32B32_UINT,
+ [VK_FORMAT_R32G32B32_SINT] = PIPE_FORMAT_R32G32B32_SINT,
+ [VK_FORMAT_R32G32B32_SFLOAT] = PIPE_FORMAT_R32G32B32_FLOAT,
+
+ [VK_FORMAT_R32G32B32A32_UINT] = PIPE_FORMAT_R32G32B32A32_UINT,
+ [VK_FORMAT_R32G32B32A32_SINT] = PIPE_FORMAT_R32G32B32A32_SINT,
+ [VK_FORMAT_R32G32B32A32_SFLOAT] = PIPE_FORMAT_R32G32B32A32_FLOAT,
+
+ /* Missing 64-bit uint/sint formats */
+ [VK_FORMAT_R64_SFLOAT] = PIPE_FORMAT_R64_FLOAT,
+ [VK_FORMAT_R64G64_SFLOAT] = PIPE_FORMAT_R64G64_FLOAT,
+ [VK_FORMAT_R64G64B64_SFLOAT] = PIPE_FORMAT_R64G64B64_FLOAT,
+ [VK_FORMAT_R64G64B64A64_SFLOAT] = PIPE_FORMAT_R64G64B64A64_FLOAT,
+
+ [VK_FORMAT_B10G11R11_UFLOAT_PACK32] = PIPE_FORMAT_R11G11B10_FLOAT,
+ [VK_FORMAT_E5B9G9R9_UFLOAT_PACK32] = PIPE_FORMAT_R9G9B9E5_FLOAT,
+
+ [VK_FORMAT_D16_UNORM] = PIPE_FORMAT_Z16_UNORM,
+ [VK_FORMAT_X8_D24_UNORM_PACK32] = PIPE_FORMAT_Z24X8_UNORM,
+ [VK_FORMAT_D32_SFLOAT] = PIPE_FORMAT_Z32_FLOAT,
+ [VK_FORMAT_S8_UINT] = PIPE_FORMAT_S8_UINT,
+ /* Missing D16_UNORM_S8_UINT */
+ [VK_FORMAT_D24_UNORM_S8_UINT] = PIPE_FORMAT_Z24_UNORM_S8_UINT,
+ [VK_FORMAT_D32_SFL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6_SRGB,
+ [VK_FORMAT_ASTC_8x5_UNORM_BLOCK] = PIPE_FORMAT_ASTC_8x5,
+ [VK_FORMAT_ASTC_8x5_SRGB_BLOCK] = PIPE_FORMAT_ASTC_8x5_SRGB,
+ [VK_FORMAT_ASTC_8x6_UNORM_BLOCK] = PIPE_FORMAT_ASTC_8x6,
+ [VK_FORMAT_ASTC_8x6_SRGB_BLOCK] = PIPE_FORMAT_ASTC_8x6_SRGB,
+ [VK_FORMAT_ASTC_8x8_UNORM_BLOCK] = PIPE_FORMAT_ASTC_8x8,
+ [VK_FORMAT_ASTC_8x8_SRGB_BLOCK] = PIPE_FORMAT_ASTC_8x8_SRGB,
+ [VK_FORMAT_ASTC_10x5_UNORM_BLOCK] = PIPE_FORMAT_ASTC_10x5,
+ [VK_FORMAT_ASTC_10x5_SRGB_BLOCK] = PIPE_FORMAT_ASTC_10x5_SRGB,
+ [VK_FORMAT_ASTC_10x6_UNORM_BLOCK] = PIPE_FORMAT_ASTC_10x6,
+ [VK_FORMAT_ASTC_10x6_SRGB_BLOCK] = PIPE_FORMAT_ASTC_10x6_SRGB,
+ [VK_FORMAT_ASTC_10x8_UNORM_BLOCK] = PIPE_FORMAT_ASTC_10x8,
+ [VK_FORMAT_ASTC_10x8_SRGB_BLOCK] = PIPE_FORMAT_ASTC_10x8_SRGB,
+ [VK_FORMAT_ASTC_10x10_UNORM_BLOCK] = PIPE_FORMAT_ASTC_10x10,
+ [VK_FORMAT_ASTC_10x10_SRGB_BLOCK] = PIPE_FORMAT_ASTC_10x10_SRGB,
+ [VK_FORMAT_ASTC_12x10_UNORM_BLOCK] = PIPE_FORMAT_ASTC_12x10,
+ [VK_FORMAT_ASTC_12x10_SRGB_BLOCK] = PIPE_FORMAT_ASTC_12x10_SRGB,
+ [VK_FORMAT_ASTC_12x12_UNORM_BLOCK] = PIPE_FORMAT_ASTC_12x12,
+ [VK_FORMAT_ASTC_12x12_SRGB_BLOCK] = PIPE_FORMAT_ASTC_12x12_SRGB,
+
+ /* Missing planes */
+
+ /* Missing PVRTC */
+
+ /* Missing ASTC SFLOAT */
+
+ /* Missing more planes */
+};
+
+enum pipe_format
+vk_format_to_pipe_format(enum VkFormat vkformat)
+{
+ if (vkformat >= ARRAY_SIZE(vk_format_map))
+ return PIPE_FORMAT_NONE;
+
+ /* Unpopulated entries in the table must be PIPE_FORMAT_NONE */
+ STATIC_ASSERT(PIPE_FORMAT_NONE == 0);
+
+ return vk_format_map[vkformat];
+}
diff --git a/lib/mesa/src/vulkan/util/vk_format.h b/lib/mesa/src/vulkan/util/vk_format.h
new file mode 100644
index 000000000..ecc79f7f7
--- /dev/null
+++ b/lib/mesa/src/vulkan/util/vk_format.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2019 Google LLC
+ *
+ * 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.
+ */
+
+#ifndef U_FORMAT_VK_H
+#define U_FORMAT_VK_H
+
+#include <vulkan/vulkan_core.h>
+#include "util/format/u_format.h"
+
+enum pipe_format
+vk_format_to_pipe_format(enum VkFormat vkformat);
+
+#endif