diff options
| author | Jon Ashburn <jon@lunarg.com> | 2016-02-02 12:08:10 -0700 |
|---|---|---|
| committer | Jon Ashburn <jon@lunarg.com> | 2016-02-02 14:38:08 -0700 |
| commit | 385483273efbe58eaeed63bb2de24e76a65405f6 (patch) | |
| tree | 6aaebd672c9574acf6a05a0728f77b33fc279a10 | |
| parent | 752a3d94c4e589c08545a21d651884fd3749977e (diff) | |
| download | usermoji-385483273efbe58eaeed63bb2de24e76a65405f6.tar.xz | |
misc: Remove vktrace and icd from this repository
| -rwxr-xr-x | CMakeLists.txt | 26 | ||||
| -rw-r--r-- | icd/CMakeLists.txt | 19 | ||||
| -rw-r--r-- | icd/README.md | 26 | ||||
| -rw-r--r-- | icd/common/CMakeLists.txt | 25 | ||||
| -rw-r--r-- | icd/common/icd-enumerate-drm.c | 210 | ||||
| -rw-r--r-- | icd/common/icd-enumerate-drm.h | 58 | ||||
| -rw-r--r-- | icd/common/icd-format.c | 751 | ||||
| -rw-r--r-- | icd/common/icd-format.h | 90 | ||||
| -rw-r--r-- | icd/common/icd-instance.c | 198 | ||||
| -rw-r--r-- | icd/common/icd-instance.h | 90 | ||||
| -rw-r--r-- | icd/common/icd-spv.h | 41 | ||||
| -rw-r--r-- | icd/common/icd-utils.c | 85 | ||||
| -rw-r--r-- | icd/common/icd-utils.h | 124 | ||||
| -rw-r--r-- | icd/common/icd.h | 49 | ||||
| -rw-r--r-- | icd/nulldrv/CMakeLists.txt | 41 | ||||
| -rw-r--r-- | icd/nulldrv/README.md | 3 | ||||
| -rw-r--r-- | icd/nulldrv/VK_nulldrv.def | 35 | ||||
| -rw-r--r-- | icd/nulldrv/nulldrv.c | 2222 | ||||
| -rw-r--r-- | icd/nulldrv/nulldrv.h | 223 | ||||
| -rw-r--r-- | icd/nulldrv/nulldrv_icd.json | 7 |
20 files changed, 1 insertions, 4322 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ab8ed7c6..80888e98 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,18 +65,12 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") endif() option(BUILD_LOADER "Build loader" ON) -if(WIN32) - option(BUILD_ICD "Build LunarG intel icd" OFF) -else() - option(BUILD_ICD "Build LunarG intel icd" ON) -endif() option(BUILD_TESTS "Build tests" ON) option(BUILD_LAYERS "Build layers" ON) option(BUILD_DEMOS "Build demos" ON) -option(BUILD_VKTRACE "Build VkTrace" ON) option(BUILD_VKJSON "Build vkjson" ON) -if (BUILD_ICD OR BUILD_TESTS) +if (BUILD_TESTS) # Hard code our glslang path for now get_filename_component(GLSLANG_PREFIX ../glslang ABSOLUTE) @@ -85,15 +79,6 @@ if (BUILD_ICD OR BUILD_TESTS) endif() endif() -if (BUILD_ICD) - # Hard code our LunarGLASS path for now - get_filename_component(LUNARGLASS_PREFIX ../LunarGLASS ABSOLUTE) - - if(NOT EXISTS ${LUNARGLASS_PREFIX}) - message(FATAL_ERROR "Necessary LunarGLASS components do not exist: " ${LUNARGLASS_PREFIX}) - endif() -endif() - if(NOT WIN32) include(GNUInstallDirs) add_definitions(-DSYSCONFDIR="${CMAKE_INSTALL_SYSCONFDIR}") @@ -111,16 +96,11 @@ else() endif() # loader: Generic VULKAN ICD loader -# icd: Device dependent (DD) VULKAN components # tests: VULKAN tests if(BUILD_LOADER) add_subdirectory(loader) endif() -if(BUILD_ICD) - add_subdirectory(icd) -endif() - if(BUILD_TESTS) add_subdirectory(tests) endif() @@ -133,10 +113,6 @@ if(BUILD_DEMOS) add_subdirectory(demos) endif() -if(BUILD_VKTRACE) - add_subdirectory(vktrace) -endif() - if(BUILD_VKJSON) add_subdirectory(libs/vkjson) endif() diff --git a/icd/CMakeLists.txt b/icd/CMakeLists.txt deleted file mode 100644 index ecc2bb6f..00000000 --- a/icd/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -function(add_compiler_flag flag) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE) -endfunction() - -if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - add_compiler_flag("-DPLATFORM_LINUX=1") - add_compiler_flag("-DPLATFORM_POSIX=1") -elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_compiler_flag("-DPLATFORM_WINDOWS=1") -else() - message(FATAL_ERROR "Platform unset, build will fail--stopping at CMake time.") -endif() - -add_subdirectory(common) -add_subdirectory(nulldrv) -if (NOT WIN32) - add_subdirectory(intel) -endif() diff --git a/icd/README.md b/icd/README.md deleted file mode 100644 index 616f978c..00000000 --- a/icd/README.md +++ /dev/null @@ -1,26 +0,0 @@ -This sample driver implementation provide multiple subcomponents required to build and test an Installable Client Driver (ICD): -- [Common Infrastructure](common) -- [Implementation for Intel GPUs](intel) -- [Null driver](nulldrv) -- [*Sample Driver Tests*](../tests) - - Now includes Golden images to verify vk_render_tests rendering. - -common/ provides helper and utility functions, as well as all VK entry points -except vkInitAndEnumerateGpus. Hardware drivers are required to provide that -function, and to embed a "VkLayerDispatchTable *" as the first member of -VkPhysicalDevice and all VkBaseObject. - -Thread safety - - We have these static variables - - - common/icd.c:static struct icd icd; - - intel/gpu.c:static struct intel_gpu *intel_gpus; - - They require that there is no other thread calling the ICD when these - functions are called - - - vkInitAndEnumerateGpus - - vkDbgRegisterMsgCallback - - vkDbgUnregisterMsgCallback - - vkDbgSetGlobalOption diff --git a/icd/common/CMakeLists.txt b/icd/common/CMakeLists.txt deleted file mode 100644 index 4fec186b..00000000 --- a/icd/common/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -if (WIN32) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS") -endif() - -set(sources - icd-format.c - icd-instance.c - icd-utils.c) - -set(include_dirs "") -set(libraries "") - -if(UNIX) - find_package(UDev REQUIRED) - list(APPEND include_dirs ${UDEV_INCLUDE_DIRS}) - list(APPEND libraries ${UDEV_LIBRARIES}) - list(APPEND sources icd-enumerate-drm.c) -endif() - -add_library(icd STATIC ${sources}) -target_include_directories(icd - PRIVATE ${include_dirs} - INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(icd ${libraries}) -set_target_properties(icd PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/icd/common/icd-enumerate-drm.c b/icd/common/icd-enumerate-drm.c deleted file mode 100644 index 9f684551..00000000 --- a/icd/common/icd-enumerate-drm.c +++ /dev/null @@ -1,210 +0,0 @@ -/* - * - * Copyright (C) 2015 Valve 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. - * - * Author: Chia-I Wu <olvaffe@gmail.com> - * - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <libudev.h> - -#include "icd-instance.h" -#include "icd-utils.h" -#include "icd-enumerate-drm.h" - -static enum icd_drm_minor_type get_minor_type(struct udev_device *minor_dev) -{ - const char *minor; - - minor = udev_device_get_property_value(minor_dev, "MINOR"); - if (!minor) - return ICD_DRM_MINOR_INVALID; - - switch (atoi(minor) >> 6) { - case 0: - return ICD_DRM_MINOR_LEGACY; - case 2: - return ICD_DRM_MINOR_RENDER; - default: - return ICD_DRM_MINOR_INVALID; - } -} - -static void get_pci_id(struct udev_device *pci_dev, int *vendor, int *devid) -{ - const char *pci_id; - - pci_id = udev_device_get_property_value(pci_dev, "PCI_ID"); - if (sscanf(pci_id, "%x:%x", vendor, devid) != 2) { - *vendor = 0; - *devid = 0; - } -} - -static struct icd_drm_device *find_dev(struct icd_drm_device *devices, - const char *parent_syspath) -{ - struct icd_drm_device *dev = devices; - - while (dev) { - if (!strcmp((const char *) dev->id, parent_syspath)) - break; - dev = dev->next; - } - - return dev; -} - -static struct icd_drm_device *probe_syspath(const struct icd_instance *instance, - struct icd_drm_device *devices, - struct udev *udev, const char *syspath, - int vendor_id_match) -{ - struct udev_device *minor, *parent; - enum icd_drm_minor_type type; - const char *parent_syspath; - struct icd_drm_device *dev; - int vendor, devid; - - minor = udev_device_new_from_syspath(udev, syspath); - if (!minor) - return devices; - - type = get_minor_type(minor); - if (type == ICD_DRM_MINOR_INVALID) { - udev_device_unref(minor); - return devices; - } - - parent = udev_device_get_parent(minor); - if (!parent) { - udev_device_unref(minor); - return devices; - } - - get_pci_id(parent, &vendor, &devid); - if (vendor_id_match && vendor != vendor_id_match) { - udev_device_unref(minor); - return devices; - } - - parent_syspath = udev_device_get_syspath(parent); - - dev = find_dev(devices, parent_syspath); - if (dev) { - assert(dev->devid == devid); - - assert(!dev->minors[type]); - if (dev->minors[type]) - udev_device_unref((struct udev_device *) dev->minors[type]); - - dev->minors[type] = (void *) minor; - - return devices; - } else { - dev = icd_instance_alloc(instance, sizeof(*dev), sizeof(int), - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); - if (!dev) - return devices; - - memset(dev, 0, sizeof(*dev)); - - dev->id = (const void *) parent_syspath; - dev->devid = devid; - dev->minors[type] = (void *) minor; - - dev->next = devices; - - return dev; - } -} - -struct icd_drm_device *icd_drm_enumerate(const struct icd_instance *instance, - int vendor_id) -{ - struct icd_drm_device *devices = NULL; - struct udev *udev; - struct udev_enumerate *e; - struct udev_list_entry *entry; - - udev = udev_new(); - if (udev == NULL) { - icd_instance_log(instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, - 0, VK_NULL_HANDLE, /* obj_type, object */ - 0, 0, /* location, msg_code */ - "failed to initialize udev context"); - - return NULL; - } - - e = udev_enumerate_new(udev); - if (e == NULL) { - icd_instance_log(instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, - 0, VK_NULL_HANDLE, /* obj_type, object */ - 0, 0, /* location, msg_code */ - "failed to initialize udev enumerate context"); - udev_unref(udev); - - return NULL; - } - - /* we are interested in DRM minors */ - udev_enumerate_add_match_subsystem(e, "drm"); - udev_enumerate_add_match_property(e, "DEVTYPE", "drm_minor"); - udev_enumerate_scan_devices(e); - - udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) { - devices = probe_syspath(instance, devices, udev, - udev_list_entry_get_name(entry), vendor_id); - } - - free(e); - free(udev); - return devices; -} - -void icd_drm_release(const struct icd_instance *instance, - struct icd_drm_device *devices) -{ - struct icd_drm_device *dev = devices; - - while (dev) { - struct icd_drm_device *next = dev->next; - size_t i; - - for (i = 0; i < ARRAY_SIZE(dev->minors); i++) - udev_device_unref((struct udev_device *) dev->minors[i]); - - icd_instance_free(instance, dev); - dev = next; - } -} - -const char *icd_drm_get_devnode(struct icd_drm_device *dev, - enum icd_drm_minor_type minor) -{ - return (dev->minors[minor]) ? - udev_device_get_devnode((struct udev_device *) dev->minors[minor]) : - NULL; -} diff --git a/icd/common/icd-enumerate-drm.h b/icd/common/icd-enumerate-drm.h deleted file mode 100644 index 58a15915..00000000 --- a/icd/common/icd-enumerate-drm.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * Copyright (C) 2015 Valve 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. - * - * Author: Chia-I Wu <olvaffe@gmail.com> - * Author: Chia-I Wu <olv@lunarg.com> - * - */ - -#ifndef ICD_ENUMERATE_DRM_H -#define ICD_ENUMERATE_DRM_H - -enum icd_drm_minor_type { - ICD_DRM_MINOR_LEGACY, - ICD_DRM_MINOR_RENDER, - - ICD_DRM_MINOR_COUNT, - ICD_DRM_MINOR_INVALID, -}; - -struct icd_drm_device { - const void *id; - int devid; - - void *minors[ICD_DRM_MINOR_COUNT]; - - struct icd_drm_device *next; -}; - -struct icd_instance; - -struct icd_drm_device *icd_drm_enumerate(const struct icd_instance *instance, - int vendor_id); -void icd_drm_release(const struct icd_instance *instance, - struct icd_drm_device *devices); - -const char *icd_drm_get_devnode(struct icd_drm_device *dev, - enum icd_drm_minor_type minor); - -#endif /* ICD_ENUMERATE_DRM_H */ diff --git a/icd/common/icd-format.c b/icd/common/icd-format.c deleted file mode 100644 index 1ed56b96..00000000 --- a/icd/common/icd-format.c +++ /dev/null @@ -1,751 +0,0 @@ -/* - * - * Copyright (C) 2015 Valve 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. - * - * Author: Chia-I Wu <olvaffe@gmail.com> - * Author: Chia-I Wu <olv@lunarg.com> - * Author: Jeremy Hayes <jeremy@lunarg.com> - * Author: Jon Ashburn <jon@lunarg.com> - * - */ - -#include <string.h> /* for memcpy */ -#include "icd-utils.h" -#include "icd-format.h" - -static const struct icd_format_info { - size_t size; - uint32_t channel_count; -} icd_format_table[VK_FORMAT_RANGE_SIZE] = { - [VK_FORMAT_UNDEFINED] = { 0, 0 }, - [VK_FORMAT_R4G4_UNORM_PACK8] = { 1, 2 }, - [VK_FORMAT_R4G4B4A4_UNORM_PACK16] = { 2, 4 }, - [VK_FORMAT_B4G4R4A4_UNORM_PACK16] = { 2, 4 }, - [VK_FORMAT_R5G6B5_UNORM_PACK16] = { 2, 3 }, - [VK_FORMAT_B5G6R5_UNORM_PACK16] = { 2, 3 }, - [VK_FORMAT_R5G5B5A1_UNORM_PACK16] = { 2, 4 }, - [VK_FORMAT_B5G5R5A1_UNORM_PACK16] = { 2, 4 }, - [VK_FORMAT_A1R5G5B5_UNORM_PACK16] = { 2, 4 }, - [VK_FORMAT_R8_UNORM] = { 1, 1 }, - [VK_FORMAT_R8_SNORM] = { 1, 1 }, - [VK_FORMAT_R8_USCALED] = { 1, 1 }, - [VK_FORMAT_R8_SSCALED] = { 1, 1 }, - [VK_FORMAT_R8_UINT] = { 1, 1 }, - [VK_FORMAT_R8_SINT] = { 1, 1 }, - [VK_FORMAT_R8_SRGB] = { 1, 1 }, - [VK_FORMAT_R8G8_UNORM] = { 2, 2 }, - [VK_FORMAT_R8G8_SNORM] = { 2, 2 }, - [VK_FORMAT_R8G8_USCALED] = { 2, 2 }, - [VK_FORMAT_R8G8_SSCALED] = { 2, 2 }, - [VK_FORMAT_R8G8_UINT] = { 2, 2 }, - [VK_FORMAT_R8G8_SINT] = { 2, 2 }, - [VK_FORMAT_R8G8_SRGB] = { 2, 2 }, - [VK_FORMAT_R8G8B8_UNORM] = { 3, 3 }, - [VK_FORMAT_R8G8B8_SNORM] = { 3, 3 }, - [VK_FORMAT_R8G8B8_USCALED] = { 3, 3 }, - [VK_FORMAT_R8G8B8_SSCALED] = { 3, 3 }, - [VK_FORMAT_R8G8B8_UINT] = { 3, 3 }, - [VK_FORMAT_R8G8B8_SINT] = { 3, 3 }, - [VK_FORMAT_R8G8B8_SRGB] = { 3, 3 }, - [VK_FORMAT_B8G8R8_UNORM] = { 3, 3 }, - [VK_FORMAT_B8G8R8_SNORM] = { 3, 3 }, - [VK_FORMAT_B8G8R8_USCALED] = { 3, 3 }, - [VK_FORMAT_B8G8R8_SSCALED] = { 3, 3 }, - [VK_FORMAT_B8G8R8_UINT] = { 3, 3 }, - [VK_FORMAT_B8G8R8_SINT] = { 3, 3 }, - [VK_FORMAT_B8G8R8_SRGB] = { 3, 3 }, - [VK_FORMAT_R8G8B8A8_UNORM] = { 4, 4 }, - [VK_FORMAT_R8G8B8A8_SNORM] = { 4, 4 }, - [VK_FORMAT_R8G8B8A8_USCALED] = { 4, 4 }, - [VK_FORMAT_R8G8B8A8_SSCALED] = { 4, 4 }, - [VK_FORMAT_R8G8B8A8_UINT] = { 4, 4 }, - [VK_FORMAT_R8G8B8A8_SINT] = { 4, 4 }, - [VK_FORMAT_R8G8B8A8_SRGB] = { 4, 4 }, - [VK_FORMAT_B8G8R8A8_UNORM] = { 4, 4 }, - [VK_FORMAT_B8G8R8A8_SNORM] = { 4, 4 }, - [VK_FORMAT_B8G8R8A8_USCALED] = { 4, 4 }, - [VK_FORMAT_B8G8R8A8_SSCALED] = { 4, 4 }, - [VK_FORMAT_B8G8R8A8_UINT] = { 4, 4 }, - [VK_FORMAT_B8G8R8A8_SINT] = { 4, 4 }, - [VK_FORMAT_B8G8R8A8_SRGB] = { 4, 4 }, - [VK_FORMAT_A8B8G8R8_UNORM_PACK32] = { 4, 4 }, - [VK_FORMAT_A8B8G8R8_SNORM_PACK32] = { 4, 4 }, - [VK_FORMAT_A8B8G8R8_USCALED_PACK32] = { 4, 4 }, - [VK_FORMAT_A8B8G8R8_SSCALED_PACK32] = { 4, 4 }, - [VK_FORMAT_A8B8G8R8_UINT_PACK32] = { 4, 4 }, - [VK_FORMAT_A8B8G8R8_SINT_PACK32] = { 4, 4 }, - [VK_FORMAT_A8B8G8R8_SRGB_PACK32] = { 4, 4 }, - [VK_FORMAT_A2R10G10B10_UNORM_PACK32] = { 4, 4 }, - [VK_FORMAT_A2R10G10B10_SNORM_PACK32] = { 4, 4 }, - [VK_FORMAT_A2R10G10B10_USCALED_PACK32] = { 4, 4 }, - [VK_FORMAT_A2R10G10B10_SSCALED_PACK32] = { 4, 4 }, - [VK_FORMAT_A2R10G10B10_UINT_PACK32] = { 4, 4 }, - [VK_FORMAT_A2R10G10B10_SINT_PACK32] = { 4, 4 }, - [VK_FORMAT_A2B10G10R10_UNORM_PACK32] = { 4, 4 }, - [VK_FORMAT_A2B10G10R10_SNORM_PACK32] = { 4, 4 }, - [VK_FORMAT_A2B10G10R10_USCALED_PACK32] = { 4, 4 }, - [VK_FORMAT_A2B10G10R10_SSCALED_PACK32] = { 4, 4 }, - [VK_FORMAT_A2B10G10R10_UINT_PACK32] = { 4, 4 }, - [VK_FORMAT_A2B10G10R10_SINT_PACK32] = { 4, 4 }, - [VK_FORMAT_R16_UNORM] = { 2, 1 }, - [VK_FORMAT_R16_SNORM] = { 2, 1 }, - [VK_FORMAT_R16_USCALED] = { 2, 1 }, - [VK_FORMAT_R16_SSCALED] = { 2, 1 }, - [VK_FORMAT_R16_UINT] = { 2, 1 }, - [VK_FORMAT_R16_SINT] = { 2, 1 }, - [VK_FORMAT_R16_SFLOAT] = { 2, 1 }, - [VK_FORMAT_R16G16_UNORM] = { 4, 2 }, - [VK_FORMAT_R16G16_SNORM] = { 4, 2 }, - [VK_FORMAT_R16G16_USCALED] = { 4, 2 }, - [VK_FORMAT_R16G16_SSCALED] = { 4, 2 }, - [VK_FORMAT_R16G16_UINT] = { 4, 2 }, - [VK_FORMAT_R16G16_SINT] = { 4, 2 }, - [VK_FORMAT_R16G16_SFLOAT] = { 4, 2 }, - [VK_FORMAT_R16G16B16_UNORM] = { 6, 3 }, - [VK_FORMAT_R16G16B16_SNORM] = { 6, 3 }, - [VK_FORMAT_R16G16B16_USCALED] = { 6, 3 }, - [VK_FORMAT_R16G16B16_SSCALED] = { 6, 3 }, - [VK_FORMAT_R16G16B16_UINT] = { 6, 3 }, - [VK_FORMAT_R16G16B16_SINT] = { 6, 3 }, - [VK_FORMAT_R16G16B16_SFLOAT] = { 6, 3 }, - [VK_FORMAT_R16G16B16A16_UNORM] = { 8, 4 }, - [VK_FORMAT_R16G16B16A16_SNORM] = { 8, 4 }, - [VK_FORMAT_R16G16B16A16_USCALED] = { 8, 4 }, - [VK_FORMAT_R16G16B16A16_SSCALED] = { 8, 4 }, - [VK_FORMAT_R16G16B16A16_UINT] = { 8, 4 }, - [VK_FORMAT_R16G16B16A16_SINT] = { 8, 4 }, - [VK_FORMAT_R16G16B16A16_SFLOAT] = { 8, 4 }, - [VK_FORMAT_R32_UINT] = { 4, 1 }, - [VK_FORMAT_R32_SINT] = { 4, 1 }, - [VK_FORMAT_R32_SFLOAT] = { 4, 1 }, - [VK_FORMAT_R32G32_UINT] = { 8, 2 }, - [VK_FORMAT_R32G32_SINT] = { 8, 2 }, - [VK_FORMAT_R32G32_SFLOAT] = { 8, 2 }, - [VK_FORMAT_R32G32B32_UINT] = { 12, 3 }, - [VK_FORMAT_R32G32B32_SINT] = { 12, 3 }, - [VK_FORMAT_R32G32B32_SFLOAT] = { 12, 3 }, - [VK_FORMAT_R32G32B32A32_UINT] = { 16, 4 }, - [VK_FORMAT_R32G32B32A32_SINT] = { 16, 4 }, - [VK_FORMAT_R32G32B32A32_SFLOAT] = { 16, 4 }, - [VK_FORMAT_R64_UINT] = { 8, 1 }, - [VK_FORMAT_R64_SINT] = { 8, 1 }, - [VK_FORMAT_R64_SFLOAT] = { 8, 1 }, - [VK_FORMAT_R64G64_UINT] = { 16, 2 }, - [VK_FORMAT_R64G64_SINT] = { 16, 2 }, - [VK_FORMAT_R64G64_SFLOAT] = { 16, 2 }, - [VK_FORMAT_R64G64B64_UINT] = { 24, 3 }, - [VK_FORMAT_R64G64B64_SINT] = { 24, 3 }, - [VK_FORMAT_R64G64B64_SFLOAT] = { 24, 3 }, - [VK_FORMAT_R64G64B64A64_UINT] = { 32, 4 }, - [VK_FORMAT_R64G64B64A64_SINT] = { 32, 4 }, - [VK_FORMAT_R64G64B64A64_SFLOAT] = { 32, 4 }, - [VK_FORMAT_B10G11R11_UFLOAT_PACK32] = { 4, 3 }, - [VK_FORMAT_E5B9G9R9_UFLOAT_PACK32] = { 4, 3 }, - [VK_FORMAT_D16_UNORM] = { 2, 1 }, - [VK_FORMAT_X8_D24_UNORM_PACK32] = { 3, 1 }, - [VK_FORMAT_D32_SFLOAT] = { 4, 1 }, - [VK_FORMAT_S8_UINT] = { 1, 1 }, - [VK_FORMAT_D16_UNORM_S8_UINT] = { 3, 2 }, - [VK_FORMAT_D24_UNORM_S8_UINT] = { 4, 2 }, - [VK_FORMAT_D32_SFLOAT_S8_UINT] = { 4, 2 }, - [VK_FORMAT_BC1_RGB_UNORM_BLOCK] = { 8, 4 }, - [VK_FORMAT_BC1_RGB_SRGB_BLOCK] = { 8, 4 }, - [VK_FORMAT_BC1_RGBA_UNORM_BLOCK] = { 8, 4 }, - [VK_FORMAT_BC1_RGBA_SRGB_BLOCK] = { 8, 4 }, - [VK_FORMAT_BC2_UNORM_BLOCK] = { 16, 4 }, - [VK_FORMAT_BC2_SRGB_BLOCK] = { 16, 4 }, - [VK_FORMAT_BC3_UNORM_BLOCK] = { 16, 4 }, - [VK_FORMAT_BC3_SRGB_BLOCK] = { 16, 4 }, - [VK_FORMAT_BC4_UNORM_BLOCK] = { 8, 4 }, - [VK_FORMAT_BC4_SNORM_BLOCK] = { 8, 4 }, - [VK_FORMAT_BC5_UNORM_BLOCK] = { 16, 4 }, - [VK_FORMAT_BC5_SNORM_BLOCK] = { 16, 4 }, - [VK_FORMAT_BC6H_UFLOAT_BLOCK] = { 16, 4 }, - [VK_FORMAT_BC6H_SFLOAT_BLOCK] = { 16, 4 }, - [VK_FORMAT_BC7_UNORM_BLOCK] = { 16, 4 }, - [VK_FORMAT_BC7_SRGB_BLOCK] = { 16, 4 }, - /* TODO: Initialize remaining compressed formats. */ - [VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_EAC_R11_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_EAC_R11_SNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_EAC_R11G11_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_EAC_R11G11_SNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_4x4_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_4x4_SRGB_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_5x4_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_5x4_SRGB_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_5x5_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_5x5_SRGB_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_6x5_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_6x5_SRGB_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_6x6_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_6x6_SRGB_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_8x5_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_8x5_SRGB_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_8x6_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_8x6_SRGB_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_8x8_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_8x8_SRGB_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_10x5_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_10x5_SRGB_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_10x6_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_10x6_SRGB_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_10x8_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_10x8_SRGB_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_10x10_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_10x10_SRGB_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_12x10_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_12x10_SRGB_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_12x12_UNORM_BLOCK] = { 0, 0 }, - [VK_FORMAT_ASTC_12x12_SRGB_BLOCK] = { 0, 0 }, -}; - -bool icd_format_is_ds(VkFormat format) -{ - bool is_ds = false; - - switch (format) { - case VK_FORMAT_D16_UNORM: - case VK_FORMAT_X8_D24_UNORM_PACK32: - case VK_FORMAT_D32_SFLOAT: - case VK_FORMAT_S8_UINT: - case VK_FORMAT_D16_UNORM_S8_UINT: - case VK_FORMAT_D24_UNORM_S8_UINT: - case VK_FORMAT_D32_SFLOAT_S8_UINT: - is_ds = true; - break; - default: - break; - } - - return is_ds; -} - -bool icd_format_is_norm(VkFormat format) -{ - bool is_norm = false; - - switch (format) { - case VK_FORMAT_R4G4_UNORM_PACK8: - case VK_FORMAT_R4G4B4A4_UNORM_PACK16: - case VK_FORMAT_R5G6B5_UNORM_PACK16: - case VK_FORMAT_R5G5B5A1_UNORM_PACK16: - case VK_FORMAT_A1R5G5B5_UNORM_PACK16: - case VK_FORMAT_R8_UNORM: - case VK_FORMAT_R8_SNORM: - case VK_FORMAT_R8G8_UNORM: - case VK_FORMAT_R8G8_SNORM: - case VK_FORMAT_R8G8B8_UNORM: - case VK_FORMAT_R8G8B8_SNORM: - case VK_FORMAT_R8G8B8A8_UNORM: - case VK_FORMAT_R8G8B8A8_SNORM: - case VK_FORMAT_A8B8G8R8_UNORM_PACK32: - case VK_FORMAT_A8B8G8R8_SNORM_PACK32: - case VK_FORMAT_A2B10G10R10_UNORM_PACK32: - case VK_FORMAT_A2B10G10R10_SNORM_PACK32: - case VK_FORMAT_R16_UNORM: - case VK_FORMAT_R16_SNORM: - case VK_FORMAT_R16G16_UNORM: - case VK_FORMAT_R16G16_SNORM: - case VK_FORMAT_R16G16B16_UNORM: - case VK_FORMAT_R16G16B16_SNORM: - case VK_FORMAT_R16G16B16A16_UNORM: - case VK_FORMAT_R16G16B16A16_SNORM: - case VK_FORMAT_BC1_RGB_UNORM_BLOCK: - case VK_FORMAT_BC2_UNORM_BLOCK: - case VK_FORMAT_BC3_UNORM_BLOCK: - case VK_FORMAT_BC4_UNORM_BLOCK: - case VK_FORMAT_BC4_SNORM_BLOCK: - case VK_FORMAT_BC5_UNORM_BLOCK: - case VK_FORMAT_BC5_SNORM_BLOCK: - case VK_FORMAT_BC7_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: - case VK_FORMAT_EAC_R11_UNORM_BLOCK: - case VK_FORMAT_EAC_R11_SNORM_BLOCK: - case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: - case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: - case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: - case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: - case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: - case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: - case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: - case VK_FORMAT_B5G6R5_UNORM_PACK16: - case VK_FORMAT_B8G8R8_UNORM: - case VK_FORMAT_B8G8R8_SNORM: - case VK_FORMAT_B8G8R8A8_UNORM: - case VK_FORMAT_B8G8R8A8_SNORM: - case VK_FORMAT_A2R10G10B10_UNORM_PACK32: - case VK_FORMAT_A2R10G10B10_SNORM_PACK32: - is_norm = true; - break; - default: - break; - } - - return is_norm; -}; - -bool icd_format_is_int(VkFormat format) -{ - bool is_int = false; - - switch (format) { - case VK_FORMAT_R8_UINT: - case VK_FORMAT_R8_SINT: - case VK_FORMAT_R8G8_UINT: - case VK_FORMAT_R8G8_SINT: - case VK_FORMAT_R8G8B8_UINT: - case VK_FORMAT_R8G8B8_SINT: - case VK_FORMAT_R8G8B8A8_UINT: - case VK_FORMAT_R8G8B8A8_SINT: - case VK_FORMAT_A8B8G8R8_UINT_PACK32: - case VK_FORMAT_A8B8G8R8_SINT_PACK32: - case VK_FORMAT_A2B10G10R10_UINT_PACK32: - case VK_FORMAT_A2B10G10R10_SINT_PACK32: - case VK_FORMAT_R16_UINT: - case VK_FORMAT_R16_SINT: - case VK_FORMAT_R16G16_UINT: - case VK_FORMAT_R16G16_SINT: - case VK_FORMAT_R16G16B16_UINT: - case VK_FORMAT_R16G16B16_SINT: - case VK_FORMAT_R16G16B16A16_UINT: - case VK_FORMAT_R16G16B16A16_SINT: - case VK_FORMAT_R32_UINT: - case VK_FORMAT_R32_SINT: - case VK_FORMAT_R32G32_UINT: - case VK_FORMAT_R32G32_SINT: - case VK_FORMAT_R32G32B32_UINT: - case VK_FORMAT_R32G32B32_SINT: - case VK_FORMAT_R32G32B32A32_UINT: - case VK_FORMAT_R32G32B32A32_SINT: - case VK_FORMAT_R64_UINT: - case VK_FORMAT_R64_SINT: - case VK_FORMAT_R64G64_UINT: - case VK_FORMAT_R64G64_SINT: - case VK_FORMAT_R64G64B64_UINT: - case VK_FORMAT_R64G64B64_SINT: - case VK_FORMAT_R64G64B64A64_UINT: - case VK_FORMAT_R64G64B64A64_SINT: - case VK_FORMAT_B8G8R8_UINT: - case VK_FORMAT_B8G8R8_SINT: - case VK_FORMAT_B8G8R8A8_UINT: - case VK_FORMAT_B8G8R8A8_SINT: - case VK_FORMAT_A2R10G10B10_UINT_PACK32: - case VK_FORMAT_A2R10G10B10_SINT_PACK32: - is_int = true; - break; - default: - break; - } - - return is_int; -} - -bool icd_format_is_float(VkFormat format) -{ - bool is_float = false; - - switch (format) { - case VK_FORMAT_R16_SFLOAT: - case VK_FORMAT_R16G16_SFLOAT: - case VK_FORMAT_R16G16B16_SFLOAT: - case VK_FORMAT_R16G16B16A16_SFLOAT: - case VK_FORMAT_R32_SFLOAT: - case VK_FORMAT_R32G32_SFLOAT: - case VK_FORMAT_R32G32B32_SFLOAT: - case VK_FORMAT_R32G32B32A32_SFLOAT: - case VK_FORMAT_R64_SFLOAT: - case VK_FORMAT_R64G64_SFLOAT: - case VK_FORMAT_R64G64B64_SFLOAT: - case VK_FORMAT_R64G64B64A64_SFLOAT: - case VK_FORMAT_B10G11R11_UFLOAT_PACK32: - case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: - case VK_FORMAT_BC6H_UFLOAT_BLOCK: - case VK_FORMAT_BC6H_SFLOAT_BLOCK: - is_float = true; - break; - default: - break; - } - - return is_float; -} - -bool icd_format_is_srgb(VkFormat format) -{ - bool is_srgb = false; - - switch (format) { - case VK_FORMAT_R8_SRGB: - case VK_FORMAT_R8G8_SRGB: - case VK_FORMAT_R8G8B8_SRGB: - case VK_FORMAT_R8G8B8A8_SRGB: - case VK_FORMAT_A8B8G8R8_SRGB_PACK32: - case VK_FORMAT_BC1_RGB_SRGB_BLOCK: - case VK_FORMAT_BC2_SRGB_BLOCK: - case VK_FORMAT_BC3_SRGB_BLOCK: - case VK_FORMAT_BC7_SRGB_BLOCK: - case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: - case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: - case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: - case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: - case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: - case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: - case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: - case VK_FORMAT_B8G8R8_SRGB: - case VK_FORMAT_B8G8R8A8_SRGB: - is_srgb = true; - break; - default: - break; - } - - return is_srgb; -} - -bool icd_format_is_compressed(VkFormat format) -{ - switch (format) { - case VK_FORMAT_BC1_RGB_UNORM_BLOCK: - case VK_FORMAT_BC1_RGB_SRGB_BLOCK: - case VK_FORMAT_BC2_UNORM_BLOCK: - case VK_FORMAT_BC2_SRGB_BLOCK: - case VK_FORMAT_BC3_UNORM_BLOCK: - case VK_FORMAT_BC3_SRGB_BLOCK: - case VK_FORMAT_BC4_UNORM_BLOCK: - case VK_FORMAT_BC4_SNORM_BLOCK: - case VK_FORMAT_BC5_UNORM_BLOCK: - case VK_FORMAT_BC5_SNORM_BLOCK: - case VK_FORMAT_BC6H_UFLOAT_BLOCK: - case VK_FORMAT_BC6H_SFLOAT_BLOCK: - case VK_FORMAT_BC7_UNORM_BLOCK: - case VK_FORMAT_BC7_SRGB_BLOCK: - case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: - case VK_FORMAT_EAC_R11_UNORM_BLOCK: - case VK_FORMAT_EAC_R11_SNORM_BLOCK: - case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: - case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: - case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: - case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: - case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: - case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: - case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: - case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: - case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: - case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: - case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: - case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: - case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: - return true; - default: - return false; - } -} - -size_t icd_format_get_size(VkFormat format) -{ - return icd_format_table[format].size; -} - -unsigned int icd_format_get_channel_count(VkFormat format) -{ - return icd_format_table[format].channel_count; -} - -/** - * Convert a raw RGBA color to a raw value. \p value must have at least - * icd_format_get_size(format) bytes. - */ -void icd_format_get_raw_value(VkFormat format, - const uint32_t color[4], - void *value) -{ - /* assume little-endian */ - switch (format) { - case VK_FORMAT_UNDEFINED: - break; - case VK_FORMAT_R4G4_UNORM_PACK8: - ((uint8_t *) value)[0] = (color[0] & 0xf) << 0 | - (color[1] & 0xf) << 4; - break; - case VK_FORMAT_R4G4B4A4_UNORM_PACK16: - ((uint16_t *) value)[0] = (color[0] & 0xf) << 0 | - (color[1] & 0xf) << 4 | - (color[2] & 0xf) << 8 | - (color[3] & 0xf) << 12; - break; - case VK_FORMAT_R5G6B5_UNORM_PACK16: - ((uint16_t *) value)[0] = (color[0] & 0x1f) << 0 | - (color[1] & 0x3f) << 5 | - (color[2] & 0x1f) << 11; - break; - case VK_FORMAT_B5G6R5_UNORM_PACK16: - ((uint16_t *) value)[0] = (color[2] & 0x1f) << 0 | - (color[1] & 0x3f) << 5 | - (color[0] & 0x1f) << 11; - break; - case VK_FORMAT_R5G5B5A1_UNORM_PACK16: - ((uint16_t *) value)[0] = (color[0] & 0x1f) << 0 | - (color[1] & 0x1f) << 5 | - (color[2] & 0x1f) << 10 | - (color[3] & 0x1) << 15; - break; - case VK_FORMAT_R8_UNORM: - case VK_FORMAT_R8_SNORM: - case VK_FORMAT_R8_USCALED: - case VK_FORMAT_R8_SSCALED: - case VK_FORMAT_R8_UINT: - case VK_FORMAT_R8_SINT: - case VK_FORMAT_R8_SRGB: - ((uint8_t *) value)[0] = (uint8_t) color[0]; - break; - case VK_FORMAT_R8G8_UNORM: - case VK_FORMAT_R8G8_SNORM: - case VK_FORMAT_R8G8_USCALED: - case VK_FORMAT_R8G8_SSCALED: - case VK_FORMAT_R8G8_UINT: - case VK_FORMAT_R8G8_SINT: - case VK_FORMAT_R8G8_SRGB: - ((uint8_t *) value)[0] = (uint8_t) color[0]; - ((uint8_t *) value)[1] = (uint8_t) color[1]; - break; - case VK_FORMAT_R8G8B8A8_UNORM: - case VK_FORMAT_R8G8B8A8_SNORM: - case VK_FORMAT_R8G8B8A8_USCALED: - case VK_FORMAT_R8G8B8A8_SSCALED: - case VK_FORMAT_R8G8B8A8_UINT: - case VK_FORMAT_R8G8B8A8_SINT: - case VK_FORMAT_R8G8B8A8_SRGB: - ((uint8_t *) value)[0] = (uint8_t) color[0]; - ((uint8_t *) value)[1] = (uint8_t) color[1]; - ((uint8_t *) value)[2] = (uint8_t) color[2]; - ((uint8_t *) value)[3] = (uint8_t) color[3]; - break; - case VK_FORMAT_B8G8R8A8_UNORM: - case VK_FORMAT_B8G8R8A8_SRGB: - ((uint8_t *) value)[0] = (uint8_t) color[2]; - ((uint8_t *) value)[1] = (uint8_t) color[1]; - ((uint8_t *) value)[2] = (uint8_t) color[0]; - ((uint8_t *) value)[3] = (uint8_t) color[3]; - break; - case VK_FORMAT_B10G11R11_UFLOAT_PACK32: - ((uint32_t *) value)[0] = (color[0] & 0x7ff) << 0 | - (color[1] & 0x7ff) << 11 | - (color[2] & 0x3ff) << 22; - break; - case VK_FORMAT_A2B10G10R10_UNORM_PACK32: - case VK_FORMAT_A2B10G10R10_SNORM_PACK32: - case VK_FORMAT_A2B10G10R10_USCALED_PACK32: - case VK_FORMAT_A2B10G10R10_SSCALED_PACK32: - case VK_FORMAT_A2B10G10R10_UINT_PACK32: - case VK_FORMAT_A2B10G10R10_SINT_PACK32: - ((uint32_t *) value)[0] = (color[0] & 0x3ff) << 0 | - (color[1] & 0x3ff) << 10 | - (color[2] & 0x3ff) << 20 | - (color[3] & 0x3) << 30; - break; - case VK_FORMAT_R16_UNORM: - case VK_FORMAT_R16_SNORM: - case VK_FORMAT_R16_USCALED: - case VK_FORMAT_R16_SSCALED: - case VK_FORMAT_R16_UINT: - case VK_FORMAT_R16_SINT: - case VK_FORMAT_R16_SFLOAT: - ((uint16_t *) value)[0] = (uint16_t) color[0]; - break; - case VK_FORMAT_R16G16_UNORM: - case VK_FORMAT_R16G16_SNORM: - case VK_FORMAT_R16G16_USCALED: - case VK_FORMAT_R16G16_SSCALED: - case VK_FORMAT_R16G16_UINT: - case VK_FORMAT_R16G16_SINT: - case VK_FORMAT_R16G16_SFLOAT: - ((uint16_t *) value)[0] = (uint16_t) color[0]; - ((uint16_t *) value)[1] = (uint16_t) color[1]; - break; - case VK_FORMAT_R16G16B16A16_UNORM: - case VK_FORMAT_R16G16B16A16_SNORM: - case VK_FORMAT_R16G16B16A16_USCALED: - case VK_FORMAT_R16G16B16A16_SSCALED: - case VK_FORMAT_R16G16B16A16_UINT: - case VK_FORMAT_R16G16B16A16_SINT: - case VK_FORMAT_R16G16B16A16_SFLOAT: - ((uint16_t *) value)[0] = (uint16_t) color[0]; - ((uint16_t *) value)[1] = (uint16_t) color[1]; - ((uint16_t *) value)[2] = (uint16_t) color[2]; - ((uint16_t *) value)[3] = (uint16_t) color[3]; - break; - case VK_FORMAT_R32_UINT: - case VK_FORMAT_R32_SINT: - case VK_FORMAT_R32_SFLOAT: - ((uint32_t *) value)[0] = color[0]; - break; - case VK_FORMAT_R32G32_UINT: - case VK_FORMAT_R32G32_SINT: - case VK_FORMAT_R32G32_SFLOAT: - ((uint32_t *) value)[0] = color[0]; - ((uint32_t *) value)[1] = color[1]; - break; - case VK_FORMAT_R32G32B32_UINT: - case VK_FORMAT_R32G32B32_SINT: - case VK_FORMAT_R32G32B32_SFLOAT: - ((uint32_t *) value)[0] = color[0]; - ((uint32_t *) value)[1] = color[1]; - ((uint32_t *) value)[2] = color[2]; - break; - case VK_FORMAT_R32G32B32A32_UINT: - case VK_FORMAT_R32G32B32A32_SINT: - case VK_FORMAT_R32G32B32A32_SFLOAT: - ((uint32_t *) value)[0] = color[0]; - ((uint32_t *) value)[1] = color[1]; - ((uint32_t *) value)[2] = color[2]; - ((uint32_t *) value)[3] = color[3]; - break; - case VK_FORMAT_D16_UNORM_S8_UINT: - ((uint16_t *) value)[0] = (uint16_t) color[0]; - ((char *) value)[2] = (uint8_t) color[1]; - break; - case VK_FORMAT_D32_SFLOAT_S8_UINT: - ((uint32_t *) value)[0] = (uint32_t) color[0]; - ((char *) value)[4] = (uint8_t) color[1]; - break; - case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: - ((uint32_t *) value)[0] = (color[0] & 0x1ff) << 0 | - (color[1] & 0x1ff) << 9 | - (color[2] & 0x1ff) << 18 | - (color[3] & 0x1f) << 27; - break; - case VK_FORMAT_BC1_RGB_UNORM_BLOCK: - case VK_FORMAT_BC1_RGB_SRGB_BLOCK: - case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: - case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: - case VK_FORMAT_BC4_UNORM_BLOCK: - case VK_FORMAT_BC4_SNORM_BLOCK: - memcpy(value, color, 8); - break; - case VK_FORMAT_BC2_UNORM_BLOCK: - case VK_FORMAT_BC2_SRGB_BLOCK: - case VK_FORMAT_BC3_UNORM_BLOCK: - case VK_FORMAT_BC3_SRGB_BLOCK: - case VK_FORMAT_BC5_UNORM_BLOCK: - case VK_FORMAT_BC5_SNORM_BLOCK: - case VK_FORMAT_BC6H_UFLOAT_BLOCK: - case VK_FORMAT_BC6H_SFLOAT_BLOCK: - case VK_FORMAT_BC7_UNORM_BLOCK: - case VK_FORMAT_BC7_SRGB_BLOCK: - memcpy(value, color, 16); - break; - case VK_FORMAT_R8G8B8_UNORM: - case VK_FORMAT_R8G8B8_SNORM: - case VK_FORMAT_R8G8B8_USCALED: - case VK_FORMAT_R8G8B8_SSCALED: - case VK_FORMAT_R8G8B8_UINT: - case VK_FORMAT_R8G8B8_SINT: - case VK_FORMAT_R8G8B8_SRGB: - ((uint8_t *) value)[0] = (uint8_t) color[0]; - ((uint8_t *) value)[1] = (uint8_t) color[1]; - ((uint8_t *) value)[2] = (uint8_t) color[2]; - break; - case VK_FORMAT_R16G16B16_UNORM: - case VK_FORMAT_R16G16B16_SNORM: - case VK_FORMAT_R16G16B16_USCALED: - case VK_FORMAT_R16G16B16_SSCALED: - case VK_FORMAT_R16G16B16_UINT: - case VK_FORMAT_R16G16B16_SINT: - case VK_FORMAT_R16G16B16_SFLOAT: - ((uint16_t *) value)[0] = (uint16_t) color[0]; - ((uint16_t *) value)[1] = (uint16_t) color[1]; - ((uint16_t *) value)[2] = (uint16_t) color[2]; - break; - case VK_FORMAT_A2R10G10B10_UNORM_PACK32: - case VK_FORMAT_A2R10G10B10_SNORM_PACK32: - case VK_FORMAT_A2R10G10B10_USCALED_PACK32: - case VK_FORMAT_A2R10G10B10_SSCALED_PACK32: - case VK_FORMAT_A2R10G10B10_UINT_PACK32: - case VK_FORMAT_A2R10G10B10_SINT_PACK32: - ((uint32_t *) value)[0] = (color[2] & 0x3ff) << 0 | - (color[1] & 0x3ff) << 10 | - (color[0] & 0x3ff) << 20 | - (color[3] & 0x3) << 30; - break; - case VK_FORMAT_R64_SFLOAT: - /* higher 32 bits always 0 */ - ((uint64_t *) value)[0] = color[0]; - break; - case VK_FORMAT_R64G64_SFLOAT: - ((uint64_t *) value)[0] = color[0]; - ((uint64_t *) value)[1] = color[1]; - break; - case VK_FORMAT_R64G64B64_SFLOAT: - ((uint64_t *) value)[0] = color[0]; - ((uint64_t *) value)[1] = color[1]; - ((uint64_t *) value)[2] = color[2]; - break; - case VK_FORMAT_R64G64B64A64_SFLOAT: - ((uint64_t *) value)[0] = color[0]; - ((uint64_t *) value)[1] = color[1]; - ((uint64_t *) value)[2] = color[2]; - ((uint64_t *) value)[3] = color[3]; - break; - default: - assert(!"unknown format"); - break; - } -} diff --git a/icd/common/icd-format.h b/icd/common/icd-format.h deleted file mode 100644 index f93e3ea9..00000000 --- a/icd/common/icd-format.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * Copyright (C) 2015 Valve 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. - * - * Author: Chia-I Wu <olvaffe@gmail.com> - * Author: Chia-I Wu <olv@lunarg.com> - * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> - * - */ - -#ifndef ICD_FORMAT_H -#define ICD_FORMAT_H - -#include <stdbool.h> -#include "icd.h" - -static inline bool icd_format_is_undef(VkFormat format) -{ - return (format == VK_FORMAT_UNDEFINED); -} - -bool icd_format_is_ds(VkFormat format); - -static inline bool icd_format_is_color(VkFormat format) -{ - return !(icd_format_is_undef(format) || icd_format_is_ds(format)); -} - -bool icd_format_is_norm(VkFormat format); - -bool icd_format_is_int(VkFormat format); - -bool icd_format_is_float(VkFormat format); - -bool icd_format_is_srgb(VkFormat format); - -bool icd_format_is_compressed(VkFormat format); - -static inline int icd_format_get_block_width(VkFormat format) -{ - /* all compressed formats use 4x4 blocks */ - return (icd_format_is_compressed(format)) ? 4 : 1; -} - -static inline bool icd_blend_mode_is_dual_src(VkBlendFactor mode) -{ - return (mode == VK_BLEND_FACTOR_SRC1_COLOR) || - (mode == VK_BLEND_FACTOR_SRC1_ALPHA) || - (mode == VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR) || - (mode == VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA); -} - -static inline bool icd_pipeline_cb_att_needs_dual_source_blending(const VkPipelineColorBlendAttachmentState *att) -{ - if (icd_blend_mode_is_dual_src(att->srcColorBlendFactor) || - icd_blend_mode_is_dual_src(att->srcAlphaBlendFactor) || - icd_blend_mode_is_dual_src(att->dstColorBlendFactor) || - icd_blend_mode_is_dual_src(att->dstAlphaBlendFactor)) { - return true; - } - return false; -} - -size_t icd_format_get_size(VkFormat format); - -unsigned int icd_format_get_channel_count(VkFormat format); - -void icd_format_get_raw_value(VkFormat format, - const uint32_t color[4], - void *value); - -#endif /* ICD_FORMAT_H */ diff --git a/icd/common/icd-instance.c b/icd/common/icd-instance.c deleted file mode 100644 index e89f0eaf..00000000 --- a/icd/common/icd-instance.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * - * Copyright (C) 2015 Valve 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. - * - * Author: Chia-I Wu <olv@lunarg.com> - * - */ - -#define _ISOC11_SOURCE /* for aligned_alloc() */ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include "icd-instance.h" - -static VKAPI_ATTR void * VKAPI_CALL default_alloc(void *user_data, size_t size, - size_t alignment, - VkSystemAllocationScope allocationScope) -{ - if (alignment <= 1) { - return malloc(size); - } else if (u_is_pow2((unsigned int) alignment)) { - if (alignment < sizeof(void *)) { - assert(u_is_pow2(sizeof(void*))); - alignment = sizeof(void *); - } - - size = (size + alignment - 1) & ~(alignment - 1); - -#if defined(_WIN32) - return _aligned_malloc(alignment, size); -#else - return aligned_alloc(alignment, size); -#endif - } - else { - return NULL; - } -} - -static VKAPI_ATTR void VKAPI_CALL default_free(void *user_data, void *ptr) -{ -#if defined(_WIN32) - _aligned_free(ptr); -#else - free(ptr); -#endif -} - -struct icd_instance *icd_instance_create(const VkApplicationInfo *app_info, - const VkAllocationCallbacks *alloc_cb) -{ - static const VkAllocationCallbacks default_alloc_cb = { - .pfnAllocation = default_alloc, - .pfnFree = default_free, - }; - struct icd_instance *instance; - const char *name; - size_t len; - - if (!alloc_cb) - alloc_cb = &default_alloc_cb; - - instance = alloc_cb->pfnAllocation(alloc_cb->pUserData, sizeof(*instance), sizeof(int), - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (!instance) - return NULL; - - memset(instance, 0, sizeof(*instance)); - - name = (app_info && app_info->pApplicationName) ? app_info->pApplicationName : "unnamed"; - len = strlen(name); - instance->name = alloc_cb->pfnAllocation(alloc_cb->pUserData, len + 1, sizeof(int), - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (!instance->name) { - alloc_cb->pfnFree(alloc_cb->pUserData, instance); - return NULL; - } - - memcpy(instance->name, name, len); - instance->name[len] = '\0'; - - instance->alloc_cb = *alloc_cb; - - return instance; -} - -void icd_instance_destroy(struct icd_instance *instance) -{ - struct icd_instance_logger *logger; - - for (logger = instance->loggers; logger; ) { - struct icd_instance_logger *next = logger->next; - - icd_instance_free(instance, logger); - logger = next; - } - - icd_instance_free(instance, instance->name); - icd_instance_free(instance, instance); -} - -VkResult icd_instance_create_logger( - struct icd_instance *instance, - const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkDebugReportCallbackEXT *msg_obj) -{ - struct icd_instance_logger *logger; - - /* TODOVV: Move this test to a validation layer */ -// if (msg_obj == NULL) { -// return VK_ERROR_INVALID_POINTER; -// } - - logger = icd_instance_alloc(instance, sizeof(*logger), sizeof(int), - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - if (!logger) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - logger->func = pCreateInfo->pfnCallback; - logger->flags = pCreateInfo->flags; - logger->next = instance->loggers; - instance->loggers = logger; - - logger->user_data = pCreateInfo->pUserData; - - *( struct icd_instance_logger **)msg_obj = logger; - - return VK_SUCCESS; -} - -void icd_instance_destroy_logger( - struct icd_instance *instance, - const VkDebugReportCallbackEXT msg_obj, - const VkAllocationCallbacks *pAllocator) -{ - struct icd_instance_logger *logger, *prev; - VkDebugReportCallbackEXT local_msg_obj = msg_obj; - - for (prev = NULL, logger = instance->loggers; logger; - prev = logger, logger = logger->next) { - if (logger == *(struct icd_instance_logger **) &local_msg_obj) - break; - } - - /* TODOVV: Move this to validation layer */ -// if (!logger) -// return VK_ERROR_INVALID_POINTER; - - if (prev) - prev->next = logger->next; - else - instance->loggers = logger->next; - - icd_instance_free(instance, logger); -} - -void icd_instance_log(const struct icd_instance *instance, - VkFlags msg_flags, - VkDebugReportObjectTypeEXT obj_type, - uint64_t src_object, - size_t location, - int32_t msg_code, - const char *msg) -{ - const struct icd_instance_logger *logger; - - if (!instance->loggers) { - fputs(msg, stderr); - fputc('\n', stderr); - return; - } - - for (logger = instance->loggers; logger; logger = logger->next) { - if (msg_flags & logger->flags) { - logger->func(msg_flags, obj_type, (uint64_t)src_object, location, - msg_code, instance->name, msg, logger->user_data); - } - } -} diff --git a/icd/common/icd-instance.h b/icd/common/icd-instance.h deleted file mode 100644 index 5ea5e0c6..00000000 --- a/icd/common/icd-instance.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * Copyright (C) 2015 Valve 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. - * - * Author: Chia-I Wu <olv@lunarg.com> - * - */ - -#ifndef ICD_INSTANCE_H -#define ICD_INSTANCE_H - -#include "icd-utils.h" -#include "icd.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct icd_instance_logger { - PFN_vkDebugReportCallbackEXT func; - void *user_data; - VkFlags flags; - - struct icd_instance_logger *next; -}; - -struct icd_instance { - char *name; - - VkAllocationCallbacks alloc_cb; - - struct icd_instance_logger *loggers; -}; - -struct icd_instance *icd_instance_create(const VkApplicationInfo *app_info, - const VkAllocationCallbacks *alloc_cb); -void icd_instance_destroy(struct icd_instance *instance); - -static inline void *icd_instance_alloc(const struct icd_instance *instance, - size_t size, size_t alignment, - VkSystemAllocationScope scope) -{ - return instance->alloc_cb.pfnAllocation(instance->alloc_cb.pUserData, - size, alignment, scope); -} - -static inline void icd_instance_free(const struct icd_instance *instance, - void *ptr) -{ - instance->alloc_cb.pfnFree(instance->alloc_cb.pUserData, ptr); -} - -VkResult icd_instance_create_logger(struct icd_instance *instance, - const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkDebugReportCallbackEXT *msg_obj); - -void icd_instance_destroy_logger(struct icd_instance *instance, - const VkDebugReportCallbackEXT msg_obj, const VkAllocationCallbacks *pAllocator); - -void icd_instance_log(const struct icd_instance *instance, - VkFlags msg_flags, - VkDebugReportObjectTypeEXT obj_type, - uint64_t src_object, - size_t location, int32_t msg_code, - const char *msg); - -#ifdef __cplusplus -} -#endif - -#endif /* ICD_INSTANCE_H */ diff --git a/icd/common/icd-spv.h b/icd/common/icd-spv.h deleted file mode 100644 index eafe25e6..00000000 --- a/icd/common/icd-spv.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Copyright (C) 2015 Valve 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. - * - * Author: Cody Northrop <cody@lunarg.com> - * - */ - -#ifndef ICD_SPV_H -#define ICD_SPV_H - -#include <stdint.h> - -#define ICD_SPV_MAGIC 0x07230203 -#define ICD_SPV_VERSION 99 - -struct icd_spv_header { - uint32_t magic; - uint32_t version; - uint32_t gen_magic; // Generator's magic number -}; - -#endif /* ICD_SPV_H */ diff --git a/icd/common/icd-utils.c b/icd/common/icd-utils.c deleted file mode 100644 index 22511e2e..00000000 --- a/icd/common/icd-utils.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * Copyright (C) 2015 Valve 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. - * - * Author: Chia-I Wu <olvaffe@gmail.com> - * - */ - -#include "icd-utils.h" - -/* stolen from Mesa */ -uint16_t u_float_to_half(float f) -{ - union fi { - float f; - uint32_t ui; - }; - - uint32_t sign_mask = 0x80000000; - uint32_t round_mask = ~0xfff; - uint32_t f32inf = 0xff << 23; - uint32_t f16inf = 0x1f << 23; - uint32_t sign; - union fi magic; - union fi f32; - uint16_t f16; - - magic.ui = 0xf << 23; - - f32.f = f; - - /* Sign */ - sign = f32.ui & sign_mask; - f32.ui ^= sign; - - if (f32.ui == f32inf) { - /* Inf */ - f16 = 0x7c00; - } else if (f32.ui > f32inf) { - /* NaN */ - f16 = 0x7e00; - } else { - /* Number */ - f32.ui &= round_mask; - f32.f *= magic.f; - f32.ui -= round_mask; - - /* - * Clamp to max finite value if overflowed. - * OpenGL has completely undefined rounding behavior for float to - * half-float conversions, and this matches what is mandated for float - * to fp11/fp10, which recommend round-to-nearest-finite too. - * (d3d10 is deeply unhappy about flushing such values to infinity, and - * while it also mandates round-to-zero it doesn't care nearly as much - * about that.) - */ - if (f32.ui > f16inf) - f32.ui = f16inf - 1; - - f16 = f32.ui >> 13; - } - - /* Sign */ - f16 |= sign >> 16; - - return f16; -} diff --git a/icd/common/icd-utils.h b/icd/common/icd-utils.h deleted file mode 100644 index 40843fa6..00000000 --- a/icd/common/icd-utils.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * - * Copyright (C) 2015 Valve 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. - * - * Author: Chia-I Wu <olvaffe@gmail.com> - * Author: Chia-I Wu <olv@lunarg.com> - * Author: David Pinedo <david@lunarg.com> - * - */ - -#ifndef ICD_UTILS_H -#define ICD_UTILS_H - -#include <stdbool.h> -#include <stdint.h> -#include <assert.h> -#if defined(PLATFORM_LINUX) -#include <strings.h> /* for ffs() */ -#endif -#include "icd.h" - -#if defined(NDEBUG) && defined(__GNUC__) -#define U_ASSERT_ONLY __attribute__((unused)) -#else -#define U_ASSERT_ONLY -#endif - -#if defined(__GNUC__) -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) -#else -#define likely(x) (x) -#define unlikely(x) (x) -#endif - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) - -#define u_popcount(u) __builtin_popcount(u) -#define u_popcountll(u) __builtin_popcountll(u) - -#define STATIC_ASSERT(expr) do { \ - (void) sizeof(char[1 - 2 * !(expr)]); \ -} while (0) - -#define U_CLAMP(val, min, max) \ - ((val) < (min) ? (min) : (val) > (max)? (max) : (val)) - -/** - * Return true if val is power of two, or zero. - */ -static inline bool u_is_pow2(unsigned int val) -{ - return ((val & (val - 1)) == 0); -} - -static inline int u_ffs(int val) -{ -#if defined(PLATFORM_LINUX) - return ffs(val); -#else - return __lzcnt(val) + 1; -#endif -} - -static inline unsigned int u_align(unsigned int val, unsigned alignment) -{ - assert(alignment && u_is_pow2(alignment)); - return (val + alignment - 1) & ~(alignment - 1); -} - -static inline unsigned int u_minify(unsigned int val, unsigned level) -{ - return (val >> level) ? val >> level : 1; -} - -static inline uint32_t u_fui(float f) -{ - union { - float f; - uint32_t ui; - } u = { .f = f }; - - return u.ui; -} - -static inline float u_uif(uint32_t ui) -{ - union { - float f; - uint32_t ui; - } u = { .ui = ui }; - - return u.f; -} - -static inline int u_iround(float f) -{ - if (f >= 0.0f) - return (int) (f + 0.5f); - else - return (int) (f - 0.5f); -} - -uint16_t u_float_to_half(float f); - -#endif /* ICD_UTILS_H */ diff --git a/icd/common/icd.h b/icd/common/icd.h deleted file mode 100644 index f38ea73d..00000000 --- a/icd/common/icd.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Copyright (C) 2015 Valve 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. - * - * Author: Chia-I Wu <olvaffe@gmail.com> - * Author: Cody Northrop <cody@lunarg.com> - * Author: David Pinedo <david@lunarg.com> - * Author: Jon Ashburn <jon@lunarg.com> - * - */ - -#ifndef ICD_H -#define ICD_H - -#include <vulkan/vulkan.h> -#include <vulkan/vk_platform.h> -#include <vulkan/vk_ext_debug_report.h> -#include "vulkan/vk_sdk_platform.h" - -#if defined(__GNUC__) && __GNUC__ >= 4 -# define ICD_EXPORT __attribute__((visibility("default"))) -#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) -# define ICD_EXPORT __attribute__((visibility("default"))) -#else -# define ICD_EXPORT -#endif - -VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr( - VkInstance instance, - const char* pName); -#endif /* ICD_H */ diff --git a/icd/nulldrv/CMakeLists.txt b/icd/nulldrv/CMakeLists.txt deleted file mode 100644 index f0e3f606..00000000 --- a/icd/nulldrv/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Create the nulldrv Vulkan DRI library - -if (WIN32) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS") -else() -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") -endif() - -add_custom_command(OUTPUT nulldrv_gpa.c - COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-generate.py icd-get-proc-addr > nulldrv_gpa.c - DEPENDS ${PROJECT_SOURCE_DIR}/vk-generate.py ${PROJECT_SOURCE_DIR}/vulkan.py) - -set(sources - nulldrv.c - nulldrv_gpa.c - ) - -set(definitions "") - -set(libraries - icd) - -add_library(VK_nulldrv SHARED ${sources}) -target_compile_definitions(VK_nulldrv PRIVATE ${definitions}) -target_include_directories(VK_nulldrv PRIVATE ${include_dirs}) -target_link_libraries(VK_nulldrv ${libraries}) - -if (WIN32) - # Add in the DLL "map" file for vkGetProcAddr() - set_target_properties(VK_nulldrv PROPERTIES - LINK_FLAGS "/DEF:${PROJECT_SOURCE_DIR}/icd/nulldrv/VK_nulldrv.def") -else() - set_target_properties(VK_nulldrv PROPERTIES - LINK_FLAGS "-Wl,-Bsymbolic") - if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) - add_custom_target(nulldrv_icd-json ALL - COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/nulldrv_icd.json - VERBATIM - ) - endif() -endif() diff --git a/icd/nulldrv/README.md b/icd/nulldrv/README.md deleted file mode 100644 index 448d517b..00000000 --- a/icd/nulldrv/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Null VK Driver - -This directory provides a null VK driver diff --git a/icd/nulldrv/VK_nulldrv.def b/icd/nulldrv/VK_nulldrv.def deleted file mode 100644 index 8b531e86..00000000 --- a/icd/nulldrv/VK_nulldrv.def +++ /dev/null @@ -1,35 +0,0 @@ -;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -; Copyright (C) 2015 Valve 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. -;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; The following is required on Windows, for exporting symbols from the DLL - -LIBRARY VK_nulldrv -EXPORTS - vkCreateInstance - vkDestroyInstance - vkEnumeratePhysicalDevices - vkEnumerateInstanceExtensionProperties - xcbCreateWindow - xcbDestroyWindow - xcbGetMessage - xcbQueuePresent diff --git a/icd/nulldrv/nulldrv.c b/icd/nulldrv/nulldrv.c deleted file mode 100644 index 8778c447..00000000 --- a/icd/nulldrv/nulldrv.c +++ /dev/null @@ -1,2222 +0,0 @@ -/* - * - * Copyright (C) 2015 Valve 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. - * - * Author: Cody Northrop <cody@lunarg.com> - * Author: David Pinedo <david@lunarg.com> - * Author: Ian Elliott <ian@LunarG.com> - * Author: Tony Barbour <tony@LunarG.com> - * - */ - -#include "nulldrv.h" -#include <stdio.h> - -#if 0 -#define NULLDRV_LOG_FUNC \ - do { \ - fflush(stdout); \ - fflush(stderr); \ - printf("null driver: %s\n", __FUNCTION__); \ - fflush(stdout); \ - } while (0) -#else - #define NULLDRV_LOG_FUNC do { } while (0) -#endif - -static const VkExtensionProperties nulldrv_instance_extensions[NULLDRV_EXT_COUNT] = { - { - .extensionName = VK_KHR_SURFACE_EXTENSION_NAME, - .specVersion = VK_KHR_SURFACE_SPEC_VERSION, - } -}; - -const VkExtensionProperties nulldrv_device_exts[1] = { - { - .extensionName = VK_KHR_SWAPCHAIN_EXTENSION_NAME, - .specVersion = VK_KHR_SWAPCHAIN_SPEC_VERSION, - } -}; - -static struct nulldrv_base *nulldrv_base(void* base) -{ - return (struct nulldrv_base *) base; -} - -static struct nulldrv_base *nulldrv_base_create( - struct nulldrv_dev *dev, - size_t obj_size, - VkDebugReportObjectTypeEXT type) -{ - struct nulldrv_base *base; - - if (!obj_size) - obj_size = sizeof(*base); - - assert(obj_size >= sizeof(*base)); - - base = (struct nulldrv_base*)malloc(obj_size); - if (!base) - return NULL; - - memset(base, 0, obj_size); - - // Initialize pointer to loader's dispatch table with ICD_LOADER_MAGIC - set_loader_magic_value(base); - - if (dev == NULL) { - /* - * dev is NULL when we are creating the base device object - * Set dev now so that debug setup happens correctly - */ - dev = (struct nulldrv_dev *) base; - } - - - base->get_memory_requirements = NULL; - - return base; -} - -static VkResult nulldrv_gpu_add(int devid, const char *primary_node, - const char *render_node, struct nulldrv_gpu **gpu_ret) -{ - struct nulldrv_gpu *gpu; - - gpu = malloc(sizeof(*gpu)); - if (!gpu) - return VK_ERROR_OUT_OF_HOST_MEMORY; - memset(gpu, 0, sizeof(*gpu)); - - // Initialize pointer to loader's dispatch table with ICD_LOADER_MAGIC - set_loader_magic_value(gpu); - - *gpu_ret = gpu; - - return VK_SUCCESS; -} - -static VkResult nulldrv_queue_create(struct nulldrv_dev *dev, - uint32_t node_index, - struct nulldrv_queue **queue_ret) -{ - struct nulldrv_queue *queue; - - queue = (struct nulldrv_queue *) nulldrv_base_create(dev, sizeof(*queue), - VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT); - if (!queue) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - queue->dev = dev; - - *queue_ret = queue; - - return VK_SUCCESS; -} - -static VkResult dev_create_queues(struct nulldrv_dev *dev, - const VkDeviceQueueCreateInfo *queues, - uint32_t count) -{ - uint32_t i; - - for (i = 0; i < count; i++) { - const VkDeviceQueueCreateInfo *q = &queues[i]; - VkResult ret = VK_SUCCESS; - - if (q->queueCount == 1 && !dev->queues[q->queueFamilyIndex]) { - ret = nulldrv_queue_create(dev, q->queueFamilyIndex, - &dev->queues[q->queueFamilyIndex]); - } - - if (ret != VK_SUCCESS) { - return ret; - } - } - - return VK_SUCCESS; -} - -static enum nulldrv_ext_type nulldrv_gpu_lookup_extension( - const struct nulldrv_gpu *gpu, - const char* extensionName) -{ - enum nulldrv_ext_type type; - - for (type = 0; type < ARRAY_SIZE(nulldrv_device_exts); type++) { - if (strcmp(nulldrv_device_exts[type].extensionName, extensionName) == 0) - break; - } - - assert(type < NULLDRV_EXT_COUNT || type == NULLDRV_EXT_INVALID); - - return type; -} - -static VkResult nulldrv_desc_ooxx_create(struct nulldrv_dev *dev, - struct nulldrv_desc_ooxx **ooxx_ret) -{ - struct nulldrv_desc_ooxx *ooxx; - - ooxx = malloc(sizeof(*ooxx)); - if (!ooxx) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - memset(ooxx, 0, sizeof(*ooxx)); - - ooxx->surface_desc_size = 0; - ooxx->sampler_desc_size = 0; - - *ooxx_ret = ooxx; - - return VK_SUCCESS; -} - -static VkResult nulldrv_dev_create(struct nulldrv_gpu *gpu, - const VkDeviceCreateInfo *info, - struct nulldrv_dev **dev_ret) -{ - struct nulldrv_dev *dev; - uint32_t i; - VkResult ret; - - dev = (struct nulldrv_dev *) nulldrv_base_create(NULL, sizeof(*dev), - VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT); - if (!dev) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - for (i = 0; i < info->enabledExtensionCount; i++) { - const enum nulldrv_ext_type ext = nulldrv_gpu_lookup_extension( - gpu, - info->ppEnabledExtensionNames[i]); - - if (ext == NULLDRV_EXT_INVALID) - return VK_ERROR_EXTENSION_NOT_PRESENT; - - dev->exts[ext] = true; - } - - ret = nulldrv_desc_ooxx_create(dev, &dev->desc_ooxx); - if (ret != VK_SUCCESS) { - return ret; - } - - ret = dev_create_queues(dev, info->pQueueCreateInfos, - info->queueCreateInfoCount); - if (ret != VK_SUCCESS) { - return ret; - } - - *dev_ret = dev; - - return VK_SUCCESS; -} - -static struct nulldrv_gpu *nulldrv_gpu(VkPhysicalDevice gpu) -{ - return (struct nulldrv_gpu *) gpu; -} - -static VkResult nulldrv_fence_create(struct nulldrv_dev *dev, - const VkFenceCreateInfo *info, - struct nulldrv_fence **fence_ret) -{ - struct nulldrv_fence *fence; - - fence = (struct nulldrv_fence *) nulldrv_base_create(dev, sizeof(*fence), - VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT); - if (!fence) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - *fence_ret = fence; - - return VK_SUCCESS; -} - -static struct nulldrv_dev *nulldrv_dev(VkDevice dev) -{ - return (struct nulldrv_dev *) dev; -} - -static struct nulldrv_img *nulldrv_img_from_base(struct nulldrv_base *base) -{ - return (struct nulldrv_img *) base; -} - - -static VkResult img_get_memory_requirements(struct nulldrv_base *base, - VkMemoryRequirements *pRequirements) -{ - struct nulldrv_img *img = nulldrv_img_from_base(base); - VkResult ret = VK_SUCCESS; - - pRequirements->size = img->total_size; - pRequirements->alignment = 4096; - pRequirements->memoryTypeBits = ~0u; /* can use any memory type */ - - return ret; -} - -static VkResult nulldrv_img_create(struct nulldrv_dev *dev, - const VkImageCreateInfo *info, - bool scanout, - struct nulldrv_img **img_ret) -{ - struct nulldrv_img *img; - - img = (struct nulldrv_img *) nulldrv_base_create(dev, sizeof(*img), - VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT); - if (!img) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - img->type = info->imageType; - img->depth = info->extent.depth; - img->mip_levels = info->mipLevels; - img->array_size = info->arrayLayers; - img->usage = info->usage; - img->samples = info->samples; - - img->obj.base.get_memory_requirements = img_get_memory_requirements; - - *img_ret = img; - - return VK_SUCCESS; -} - -static struct nulldrv_img *nulldrv_img(VkImage image) -{ - return *(struct nulldrv_img **) ℑ -} - -static VkResult nulldrv_mem_alloc(struct nulldrv_dev *dev, - const VkMemoryAllocateInfo *info, - struct nulldrv_mem **mem_ret) -{ - struct nulldrv_mem *mem; - - mem = (struct nulldrv_mem *) nulldrv_base_create(dev, sizeof(*mem), - VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT); - if (!mem) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - mem->bo = malloc(info->allocationSize); - if (!mem->bo) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - - mem->size = info->allocationSize; - - *mem_ret = mem; - - return VK_SUCCESS; -} - -static VkResult nulldrv_sampler_create(struct nulldrv_dev *dev, - const VkSamplerCreateInfo *info, - struct nulldrv_sampler **sampler_ret) -{ - struct nulldrv_sampler *sampler; - - sampler = (struct nulldrv_sampler *) nulldrv_base_create(dev, - sizeof(*sampler), VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT); - if (!sampler) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - *sampler_ret = sampler; - - return VK_SUCCESS; -} - -static VkResult nulldrv_img_view_create(struct nulldrv_dev *dev, - const VkImageViewCreateInfo *info, - struct nulldrv_img_view **view_ret) -{ - struct nulldrv_img *img = nulldrv_img(info->image); - struct nulldrv_img_view *view; - - view = (struct nulldrv_img_view *) nulldrv_base_create(dev, sizeof(*view), - VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT); - if (!view) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - view->img = img; - - view->cmd_len = 8; - - *view_ret = view; - - return VK_SUCCESS; -} - -static void *nulldrv_mem_map(struct nulldrv_mem *mem, VkFlags flags) -{ - return mem->bo; -} - -static struct nulldrv_mem *nulldrv_mem(VkDeviceMemory mem) -{ - return *(struct nulldrv_mem **) &mem; -} - -static struct nulldrv_buf *nulldrv_buf_from_base(struct nulldrv_base *base) -{ - return (struct nulldrv_buf *) base; -} - -static VkResult buf_get_memory_requirements(struct nulldrv_base *base, - VkMemoryRequirements* pMemoryRequirements) -{ - struct nulldrv_buf *buf = nulldrv_buf_from_base(base); - - if (pMemoryRequirements == NULL) - return VK_SUCCESS; - - pMemoryRequirements->size = buf->size; - pMemoryRequirements->alignment = 4096; - pMemoryRequirements->memoryTypeBits = 1; /* nulldrv only has one memory type */ - - return VK_SUCCESS; -} - -static VkResult nulldrv_buf_create(struct nulldrv_dev *dev, - const VkBufferCreateInfo *info, - struct nulldrv_buf **buf_ret) -{ - struct nulldrv_buf *buf; - - buf = (struct nulldrv_buf *) nulldrv_base_create(dev, sizeof(*buf), - VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT); - if (!buf) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - buf->size = info->size; - buf->usage = info->usage; - - buf->obj.base.get_memory_requirements = buf_get_memory_requirements; - - *buf_ret = buf; - - return VK_SUCCESS; -} - -static VkResult nulldrv_desc_layout_create(struct nulldrv_dev *dev, - const VkDescriptorSetLayoutCreateInfo *info, - struct nulldrv_desc_layout **layout_ret) -{ - struct nulldrv_desc_layout *layout; - - layout = (struct nulldrv_desc_layout *) - nulldrv_base_create(dev, sizeof(*layout), - VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT); - if (!layout) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - *layout_ret = layout; - - return VK_SUCCESS; -} - -static VkResult nulldrv_pipeline_layout_create(struct nulldrv_dev *dev, - const VkPipelineLayoutCreateInfo* pCreateInfo, - struct nulldrv_pipeline_layout **pipeline_layout_ret) -{ - struct nulldrv_pipeline_layout *pipeline_layout; - - pipeline_layout = (struct nulldrv_pipeline_layout *) - nulldrv_base_create(dev, sizeof(*pipeline_layout), - VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT); - if (!pipeline_layout) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - *pipeline_layout_ret = pipeline_layout; - - return VK_SUCCESS; -} - -static struct nulldrv_desc_layout *nulldrv_desc_layout(const VkDescriptorSetLayout layout) -{ - return *(struct nulldrv_desc_layout **) &layout; -} - -static VkResult graphics_pipeline_create(struct nulldrv_dev *dev, - const VkGraphicsPipelineCreateInfo *info_, - struct nulldrv_pipeline **pipeline_ret) -{ - struct nulldrv_pipeline *pipeline; - - pipeline = (struct nulldrv_pipeline *) - nulldrv_base_create(dev, sizeof(*pipeline), - VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT); - if (!pipeline) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - *pipeline_ret = pipeline; - - return VK_SUCCESS; -} - -static VkResult nulldrv_cmd_create(struct nulldrv_dev *dev, - const VkCommandBufferAllocateInfo *info, - struct nulldrv_cmd **cmd_ret) -{ - struct nulldrv_cmd *cmd; - uint32_t num_allocated = 0; - - for (uint32_t i = 0; i < info->commandBufferCount; i++) { - cmd = (struct nulldrv_cmd *) nulldrv_base_create(dev, sizeof(*cmd), - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT); - if (!cmd) { - for (uint32_t j = 0; j < num_allocated; j++) { - free(cmd_ret[j]); - } - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - num_allocated++; - cmd_ret[i] = cmd; - } - - return VK_SUCCESS; -} - -static VkResult nulldrv_desc_pool_create(struct nulldrv_dev *dev, - const VkDescriptorPoolCreateInfo *info, - struct nulldrv_desc_pool **pool_ret) -{ - struct nulldrv_desc_pool *pool; - - pool = (struct nulldrv_desc_pool *) - nulldrv_base_create(dev, sizeof(*pool), - VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT); - if (!pool) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - pool->dev = dev; - - *pool_ret = pool; - - return VK_SUCCESS; -} - -static VkResult nulldrv_desc_set_create(struct nulldrv_dev *dev, - struct nulldrv_desc_pool *pool, - const struct nulldrv_desc_layout *layout, - struct nulldrv_desc_set **set_ret) -{ - struct nulldrv_desc_set *set; - - set = (struct nulldrv_desc_set *) - nulldrv_base_create(dev, sizeof(*set), - VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT); - if (!set) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - set->ooxx = dev->desc_ooxx; - set->layout = layout; - *set_ret = set; - - return VK_SUCCESS; -} - -static struct nulldrv_desc_pool *nulldrv_desc_pool(VkDescriptorPool pool) -{ - return *(struct nulldrv_desc_pool **) &pool; -} - -static VkResult nulldrv_fb_create(struct nulldrv_dev *dev, - const VkFramebufferCreateInfo* info, - struct nulldrv_framebuffer ** fb_ret) -{ - - struct nulldrv_framebuffer *fb; - fb = (struct nulldrv_framebuffer *) nulldrv_base_create(dev, sizeof(*fb), - VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT); - if (!fb) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - *fb_ret = fb; - - return VK_SUCCESS; - -} - -static VkResult nulldrv_render_pass_create(struct nulldrv_dev *dev, - const VkRenderPassCreateInfo* info, - struct nulldrv_render_pass** rp_ret) -{ - struct nulldrv_render_pass *rp; - rp = (struct nulldrv_render_pass *) nulldrv_base_create(dev, sizeof(*rp), - VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT); - if (!rp) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - *rp_ret = rp; - - return VK_SUCCESS; -} - -static struct nulldrv_buf *nulldrv_buf(VkBuffer buf) -{ - return *(struct nulldrv_buf **) &buf; -} - -static VkResult nulldrv_buf_view_create(struct nulldrv_dev *dev, - const VkBufferViewCreateInfo *info, - struct nulldrv_buf_view **view_ret) -{ - struct nulldrv_buf *buf = nulldrv_buf(info->buffer); - struct nulldrv_buf_view *view; - - view = (struct nulldrv_buf_view *) nulldrv_base_create(dev, sizeof(*view), - VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT); - if (!view) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - view->buf = buf; - - *view_ret = view; - - return VK_SUCCESS; -} - - -//********************************************* -// Driver entry points -//********************************************* - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer( - VkDevice device, - const VkBufferCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkBuffer* pBuffer) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return nulldrv_buf_create(dev, pCreateInfo, (struct nulldrv_buf **) pBuffer); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer( - VkDevice device, - VkBuffer buffer, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool( - VkDevice device, - const VkCommandPoolCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkCommandPool* pCommandPool) -{ - NULLDRV_LOG_FUNC; - static VkCommandPool pool = (VkCommandPool)1; - *pCommandPool = pool; - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool( - VkDevice device, - VkCommandPool commandPool, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool( - VkDevice device, - VkCommandPool commandPool, - VkCommandPoolResetFlags flags) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers( - VkDevice device, - const VkCommandBufferAllocateInfo* pAllocateInfo, - VkCommandBuffer* pCommandBuffers) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return nulldrv_cmd_create(dev, pAllocateInfo, - (struct nulldrv_cmd **) pCommandBuffers); -} - -VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers( - VkDevice device, - VkCommandPool commandPool, - uint32_t commandBufferCount, - const VkCommandBuffer* pCommandBuffers) -{ - NULLDRV_LOG_FUNC; - for (uint32_t i = 0; i < commandBufferCount; i++) { - free(pCommandBuffers[i]); - } -} - -VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer( - VkCommandBuffer commandBuffer, - const VkCommandBufferBeginInfo *info) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer( - VkCommandBuffer commandBuffer) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer( - VkCommandBuffer commandBuffer, - VkCommandBufferResetFlags flags) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -static const VkFormat nulldrv_presentable_formats[] = { - VK_FORMAT_B8G8R8A8_UNORM, -}; - -VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR( - VkInstance instance, - VkSurfaceKHR surface, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - VkSurfaceKHR surface, - VkBool32* pSupported) -{ - NULLDRV_LOG_FUNC; - - *pSupported = VK_TRUE; - - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - VkSurfaceCapabilitiesKHR* pSurfaceCapabilities) -{ - NULLDRV_LOG_FUNC; - - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t* pSurfaceFormatCount, - VkSurfaceFormatKHR* pSurfaceFormats) -{ - NULLDRV_LOG_FUNC; - - if (pSurfaceFormats) { - uint32_t i; - for (i = 0; i < *pSurfaceFormatCount; i++) { - pSurfaceFormats[i].format = nulldrv_presentable_formats[i]; - pSurfaceFormats[i].colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; - } - } - else { - *pSurfaceFormatCount = ARRAY_SIZE(nulldrv_presentable_formats); - } - - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t* pPresentModeCount, - VkPresentModeKHR* pPresentModes) -{ - NULLDRV_LOG_FUNC; - - if (pPresentModes) { - pPresentModes[0] = VK_PRESENT_MODE_IMMEDIATE_KHR; - pPresentModes[1] = VK_PRESENT_MODE_FIFO_KHR; - } else { - *pPresentModeCount = 2; - } - - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR( - VkDevice device, - const VkSwapchainCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSwapchainKHR* pSwapchain) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - struct nulldrv_swap_chain *sc; - - sc = (struct nulldrv_swap_chain *) nulldrv_base_create(dev, sizeof(*sc), - VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT); - if (!sc) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - sc->dev = dev; - - *(VkSwapchainKHR **)pSwapchain = *(VkSwapchainKHR **)≻ - - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR( - VkDevice device, - VkSwapchainKHR swapchain, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_swap_chain *sc = *(struct nulldrv_swap_chain **) &swapchain; - - free(sc); -} - -VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR( - VkDevice device, - VkSwapchainKHR swapchain, - uint32_t* pSwapchainImageCount, - VkImage* pSwapchainImages) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_swap_chain *sc = *(struct nulldrv_swap_chain **) &swapchain; - struct nulldrv_dev *dev = sc->dev; - VkResult ret = VK_SUCCESS; - - *pSwapchainImageCount = 2; - if (pSwapchainImages) { - uint32_t i; - for (i = 0; i < 2; i++) { - struct nulldrv_img *img; - - img = (struct nulldrv_img *) nulldrv_base_create(dev, - sizeof(*img), - VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT); - if (!img) - return VK_ERROR_OUT_OF_HOST_MEMORY; - pSwapchainImages[i] = (VkImage) img; - } - } - - return ret; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR( - VkDevice device, - VkSwapchainKHR swapchain, - uint64_t timeout, - VkSemaphore semaphore, - VkFence fence, - uint32_t* pImageIndex) -{ - NULLDRV_LOG_FUNC; - - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR( - VkQueue queue_, - const VkPresentInfoKHR* pPresentInfo) -{ - NULLDRV_LOG_FUNC; - - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer( - VkCommandBuffer commandBuffer, - VkBuffer srcBuffer, - VkBuffer dstBuffer, - uint32_t regionCount, - const VkBufferCopy* pRegions) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage( - VkCommandBuffer commandBuffer, - VkImage srcImage, - VkImageLayout srcImageLayout, - VkImage dstImage, - VkImageLayout dstImageLayout, - uint32_t regionCount, - const VkImageCopy* pRegions) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage( - VkCommandBuffer commandBuffer, - VkImage srcImage, - VkImageLayout srcImageLayout, - VkImage dstImage, - VkImageLayout dstImageLayout, - uint32_t regionCount, - const VkImageBlit* pRegions, - VkFilter filter) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage( - VkCommandBuffer commandBuffer, - VkBuffer srcBuffer, - VkImage dstImage, - VkImageLayout dstImageLayout, - uint32_t regionCount, - const VkBufferImageCopy* pRegions) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer( - VkCommandBuffer commandBuffer, - VkImage srcImage, - VkImageLayout srcImageLayout, - VkBuffer dstBuffer, - uint32_t regionCount, - const VkBufferImageCopy* pRegions) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer( - VkCommandBuffer commandBuffer, - VkBuffer dstBuffer, - VkDeviceSize dstOffset, - VkDeviceSize dataSize, - const uint32_t* pData) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer( - VkCommandBuffer commandBuffer, - VkBuffer dstBuffer, - VkDeviceSize dstOffset, - VkDeviceSize size, - uint32_t data) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage( - VkCommandBuffer commandBuffer, - VkImage image, - VkImageLayout imageLayout, - const VkClearDepthStencilValue* pDepthStencil, - uint32_t rangeCount, - const VkImageSubresourceRange* pRanges) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdClearAttachments( - VkCommandBuffer commandBuffer, - uint32_t attachmentCount, - const VkClearAttachment* pAttachments, - uint32_t rectCount, - const VkClearRect* pRects) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage( - VkCommandBuffer commandBuffer, - VkImage image, - VkImageLayout imageLayout, - const VkClearColorValue *pColor, - uint32_t rangeCount, - const VkImageSubresourceRange* pRanges) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencil( - VkCommandBuffer commandBuffer, - VkImage image, - VkImageLayout imageLayout, - float depth, - uint32_t stencil, - uint32_t rangeCount, - const VkImageSubresourceRange* pRanges) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage( - VkCommandBuffer commandBuffer, - VkImage srcImage, - VkImageLayout srcImageLayout, - VkImage dstImage, - VkImageLayout dstImageLayout, - uint32_t regionCount, - const VkImageResolve* pRegions) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdBeginQuery( - VkCommandBuffer commandBuffer, - VkQueryPool queryPool, - uint32_t slot, - VkFlags flags) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdEndQuery( - VkCommandBuffer commandBuffer, - VkQueryPool queryPool, - uint32_t slot) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdResetQueryPool( - VkCommandBuffer commandBuffer, - VkQueryPool queryPool, - uint32_t firstQuery, - uint32_t queryCount) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent( - VkCommandBuffer commandBuffer, - VkEvent event_, - VkPipelineStageFlags stageMask) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent( - VkCommandBuffer commandBuffer, - VkEvent event_, - VkPipelineStageFlags stageMask) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdCopyQueryPoolResults( - VkCommandBuffer commandBuffer, - VkQueryPool queryPool, - uint32_t firstQuery, - uint32_t queryCount, - VkBuffer dstBuffer, - VkDeviceSize dstOffset, - VkDeviceSize destStride, - VkFlags flags) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp( - VkCommandBuffer commandBuffer, - VkPipelineStageFlagBits pipelineStage, - VkQueryPool queryPool, - uint32_t slot) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdBindPipeline( - VkCommandBuffer commandBuffer, - VkPipelineBindPoint pipelineBindPoint, - VkPipeline pipeline) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdSetBlendConstants(VkCommandBuffer commandBuffer, const float blendConstants[4]) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilCompareMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilWriteMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorSets( - VkCommandBuffer commandBuffer, - VkPipelineBindPoint pipelineBindPoint, - VkPipelineLayout layout, - uint32_t firstSet, - uint32_t descriptorSetCount, - const VkDescriptorSet* pDescriptorSets, - uint32_t dynamicOffsetCount, - const uint32_t* pDynamicOffsets) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers( - VkCommandBuffer commandBuffer, - uint32_t firstBinding, - uint32_t bindingCount, - const VkBuffer* pBuffers, - const VkDeviceSize* pOffsets) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer( - VkCommandBuffer commandBuffer, - VkBuffer buffer, - VkDeviceSize offset, - VkIndexType indexType) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdDraw( - VkCommandBuffer commandBuffer, - uint32_t vertexCount, - uint32_t instanceCount, - uint32_t firstVertex, - uint32_t firstInstance) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexed( - VkCommandBuffer commandBuffer, - uint32_t indexCount, - uint32_t instanceCount, - uint32_t firstIndex, - int32_t vertexOffset, - uint32_t firstInstance) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirect( - VkCommandBuffer commandBuffer, - VkBuffer buffer, - VkDeviceSize offset, - uint32_t drawCount, - uint32_t stride) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirect( - VkCommandBuffer commandBuffer, - VkBuffer buffer, - VkDeviceSize offset, - uint32_t drawCount, - uint32_t stride) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdDispatch( - VkCommandBuffer commandBuffer, - uint32_t x, - uint32_t y, - uint32_t z) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdDispatchIndirect( - VkCommandBuffer commandBuffer, - VkBuffer buffer, - VkDeviceSize offset) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdWaitEvents( - VkCommandBuffer commandBuffer, - uint32_t eventCount, - const VkEvent* pEvents, - VkPipelineStageFlags sourceStageMask, - VkPipelineStageFlags dstStageMask, - uint32_t memoryBarrierCount, - const VkMemoryBarrier* pMemoryBarriers, - uint32_t bufferMemoryBarrierCount, - const VkBufferMemoryBarrier* pBufferMemoryBarriers, - uint32_t imageMemoryBarrierCount, - const VkImageMemoryBarrier* pImageMemoryBarriers) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier( - VkCommandBuffer commandBuffer, - VkPipelineStageFlags srcStageMask, - VkPipelineStageFlags dstStageMask, - VkDependencyFlags dependencyFlags, - uint32_t memoryBarrierCount, - const VkMemoryBarrier* pMemoryBarriers, - uint32_t bufferMemoryBarrierCount, - const VkBufferMemoryBarrier* pBufferMemoryBarriers, - uint32_t imageMemoryBarrierCount, - const VkImageMemoryBarrier* pImageMemoryBarriers) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice( - VkPhysicalDevice gpu_, - const VkDeviceCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkDevice* pDevice) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_gpu *gpu = nulldrv_gpu(gpu_); - return nulldrv_dev_create(gpu, pCreateInfo, (struct nulldrv_dev**)pDevice); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyDevice( - VkDevice device, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue( - VkDevice device, - uint32_t queueNodeIndex, - uint32_t queueIndex, - VkQueue* pQueue) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - *pQueue = (VkQueue) dev->queues[0]; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle( - VkDevice device) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateEvent( - VkDevice device, - const VkEventCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkEvent* pEvent) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyEvent( - VkDevice device, - VkEvent event, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkGetEventStatus( - VkDevice device, - VkEvent event_) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkSetEvent( - VkDevice device, - VkEvent event_) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkResetEvent( - VkDevice device, - VkEvent event_) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateFence( - VkDevice device, - const VkFenceCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkFence* pFence) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return nulldrv_fence_create(dev, pCreateInfo, - (struct nulldrv_fence **) pFence); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyFence( - VkDevice device, - VkFence fence, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceStatus( - VkDevice device, - VkFence fence_) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkResetFences( - VkDevice device, - uint32_t fenceCount, - const VkFence* pFences) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkWaitForFences( - VkDevice device, - uint32_t fenceCount, - const VkFence* pFences, - VkBool32 waitAll, - uint64_t timeout) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties( - VkPhysicalDevice gpu_, - VkPhysicalDeviceProperties* pProperties) -{ - NULLDRV_LOG_FUNC; - - pProperties->apiVersion = VK_API_VERSION; - pProperties->driverVersion = 0; // Appropriate that the nulldrv have 0's - pProperties->vendorID = 0; - pProperties->deviceID = 0; - pProperties->deviceType = VK_PHYSICAL_DEVICE_TYPE_OTHER; - strncpy(pProperties->deviceName, "nulldrv", strlen("nulldrv")); - - /* TODO: fill out limits */ - memset(&pProperties->limits, 0, sizeof(VkPhysicalDeviceLimits)); - memset(&pProperties->sparseProperties, 0, sizeof(VkPhysicalDeviceSparseProperties)); -} - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures( - VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures* pFeatures) -{ - NULLDRV_LOG_FUNC; - - /* TODO: fill out features */ - memset(pFeatures, 0, sizeof(*pFeatures)); -} - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties( - VkPhysicalDevice physicalDevice, - VkFormat format, - VkFormatProperties* pFormatInfo) -{ - NULLDRV_LOG_FUNC; - - pFormatInfo->linearTilingFeatures = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | - VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; - pFormatInfo->optimalTilingFeatures = pFormatInfo->linearTilingFeatures; - pFormatInfo->bufferFeatures = 0; -} - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties( - VkPhysicalDevice gpu_, - uint32_t* pQueueFamilyPropertyCount, - VkQueueFamilyProperties* pProperties) - { - if (pProperties == NULL) { - *pQueueFamilyPropertyCount = 1; - return; - } - pProperties->queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_SPARSE_BINDING_BIT; - pProperties->queueCount = 1; - pProperties->timestampValidBits = 0; -} - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties( - VkPhysicalDevice gpu_, - VkPhysicalDeviceMemoryProperties* pProperties) -{ - // the null driver pretends to have a single memory type (and single heap); - pProperties->memoryTypeCount = 1; - pProperties->memoryHeapCount = 1; - pProperties->memoryTypes[0].heapIndex = 0; - pProperties->memoryTypes[0].propertyFlags = - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | - VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | - VK_MEMORY_PROPERTY_HOST_CACHED_BIT | - VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT; - pProperties->memoryHeaps[0].flags = 0; /* not device local */ - pProperties->memoryHeaps[0].size = 0; /* it's just malloc-backed memory */ -} - -VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties( - VkPhysicalDevice physicalDevice, - uint32_t* pPropertyCount, - VkLayerProperties* pProperties) -{ - // TODO: Fill in with real data - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties( - const char* pLayerName, - uint32_t* pPropertyCount, - VkExtensionProperties* pProperties) -{ - uint32_t copy_size; - - if (pProperties == NULL) { - *pPropertyCount = NULLDRV_EXT_COUNT; - return VK_SUCCESS; - } - - copy_size = *pPropertyCount < NULLDRV_EXT_COUNT ? *pPropertyCount : NULLDRV_EXT_COUNT; - memcpy(pProperties, nulldrv_instance_extensions, copy_size * sizeof(VkExtensionProperties)); - *pPropertyCount = copy_size; - if (copy_size < NULLDRV_EXT_COUNT) { - return VK_INCOMPLETE; - } - return VK_SUCCESS; -} -VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties( - uint32_t* pPropertyCount, - VkLayerProperties* pProperties) -{ - // TODO: Fill in with real data - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties( - VkPhysicalDevice physicalDevice, - const char* pLayerName, - uint32_t* pPropertyCount, - VkExtensionProperties* pProperties) -{ - uint32_t copy_size; - uint32_t extension_count = ARRAY_SIZE(nulldrv_device_exts); - - if (pProperties == NULL) { - *pPropertyCount = extension_count; - return VK_SUCCESS; - } - - copy_size = *pPropertyCount < extension_count ? *pPropertyCount : extension_count; - memcpy(pProperties, nulldrv_device_exts, copy_size * sizeof(VkExtensionProperties)); - *pPropertyCount = copy_size; - if (copy_size < extension_count) { - return VK_INCOMPLETE; - } - - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage( - VkDevice device, - const VkImageCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkImage* pImage) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return nulldrv_img_create(dev, pCreateInfo, false, - (struct nulldrv_img **) pImage); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyImage( - VkDevice device, - VkImage image, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout( - VkDevice device, - VkImage image, - const VkImageSubresource* pSubresource, - VkSubresourceLayout* pLayout) -{ - NULLDRV_LOG_FUNC; - - pLayout->offset = 0; - pLayout->size = 1; - pLayout->rowPitch = 4; - pLayout->depthPitch = 4; - pLayout->arrayPitch = 4; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory( - VkDevice device, - const VkMemoryAllocateInfo* pAllocateInfo, - const VkAllocationCallbacks* pAllocator, - VkDeviceMemory* pMemory) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return nulldrv_mem_alloc(dev, pAllocateInfo, (struct nulldrv_mem **) pMemory); -} - -VKAPI_ATTR void VKAPI_CALL vkFreeMemory( - VkDevice device, - VkDeviceMemory mem_, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory( - VkDevice device, - VkDeviceMemory mem_, - VkDeviceSize offset, - VkDeviceSize size, - VkFlags flags, - void** ppData) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_mem *mem = nulldrv_mem(mem_); - void *ptr = nulldrv_mem_map(mem, flags); - - *ppData = ptr; - - return (ptr) ? VK_SUCCESS : VK_ERROR_MEMORY_MAP_FAILED; -} - -VKAPI_ATTR void VKAPI_CALL vkUnmapMemory( - VkDevice device, - VkDeviceMemory mem_) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges( - VkDevice device, - uint32_t memoryRangeCount, - const VkMappedMemoryRange* pMemoryRanges) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges( - VkDevice device, - uint32_t memoryRangeCount, - const VkMappedMemoryRange* pMemoryRanges) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment( - VkDevice device, - VkDeviceMemory memory, - VkDeviceSize* pCommittedMemoryInBytes) -{ -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance( - const VkInstanceCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkInstance* pInstance) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_instance *inst; - - inst = (struct nulldrv_instance *) nulldrv_base_create(NULL, sizeof(*inst), - VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT); - if (!inst) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - inst->obj.base.get_memory_requirements = NULL; - - *pInstance = (VkInstance) inst; - - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyInstance( - VkInstance pInstance, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices( - VkInstance instance, - uint32_t* pGpuCount, - VkPhysicalDevice* pGpus) -{ - NULLDRV_LOG_FUNC; - VkResult ret; - struct nulldrv_gpu *gpu; - *pGpuCount = 1; - ret = nulldrv_gpu_add(0, 0, 0, &gpu); - if (ret == VK_SUCCESS && pGpus) - pGpus[0] = (VkPhysicalDevice) gpu; - return ret; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateLayers( - VkPhysicalDevice gpu, - size_t maxStringSize, - size_t* pLayerCount, - char* const* pOutLayers, - void* pReserved) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements( - VkDevice device, - VkBuffer buffer, - VkMemoryRequirements* pMemoryRequirements) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_base *base = nulldrv_base((void*)buffer); - - base->get_memory_requirements(base, pMemoryRequirements); -} - -VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements( - VkDevice device, - VkImage image, - VkMemoryRequirements* pMemoryRequirements) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_base *base = nulldrv_base((void*)image); - - base->get_memory_requirements(base, pMemoryRequirements); -} - -VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory( - VkDevice device, - VkBuffer buffer, - VkDeviceMemory mem_, - VkDeviceSize memoryOffset) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory( - VkDevice device, - VkImage image, - VkDeviceMemory mem_, - VkDeviceSize memoryOffset) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements( - VkDevice device, - VkImage image, - uint32_t* pSparseMemoryRequirementCount, - VkSparseImageMemoryRequirements* pSparseMemoryRequirements) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties( - VkPhysicalDevice physicalDevice, - VkFormat format, - VkImageType type, - VkSampleCountFlagBits samples, - VkImageUsageFlags usage, - VkImageTiling tiling, - uint32_t* pPropertyCount, - VkSparseImageFormatProperties* pProperties) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkQueueBindSparse( - VkQueue queue, - uint32_t bindInfoCount, - const VkBindSparseInfo* pBindInfo, - VkFence fence) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache( - VkDevice device, - const VkPipelineCacheCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkPipelineCache* pPipelineCache) -{ - - NULLDRV_LOG_FUNC; - - struct nulldrv_dev *dev = nulldrv_dev(device); - struct nulldrv_pipeline_cache *pipeline_cache; - - pipeline_cache = (struct nulldrv_pipeline_cache *) nulldrv_base_create(dev, - sizeof(*pipeline_cache), VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT); - if (!pipeline_cache) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - *pPipelineCache = (VkPipelineCache) pipeline_cache; - - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyPipeline( - VkDevice device, - VkPipeline pipeline, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache( - VkDevice device, - VkPipelineCache pipelineCache, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineCacheData( - VkDevice device, - VkPipelineCache pipelineCache, - size_t* pDataSize, - void* pData) -{ - NULLDRV_LOG_FUNC; - return VK_ERROR_INITIALIZATION_FAILED; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkMergePipelineCaches( - VkDevice device, - VkPipelineCache dstCache, - uint32_t srcCacheCount, - const VkPipelineCache* pSrcCaches) -{ - NULLDRV_LOG_FUNC; - return VK_ERROR_INITIALIZATION_FAILED; -} -VKAPI_ATTR VkResult VKAPI_CALL vkCreateGraphicsPipelines( - VkDevice device, - VkPipelineCache pipelineCache, - uint32_t createInfoCount, - const VkGraphicsPipelineCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkPipeline* pPipeline) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return graphics_pipeline_create(dev, pCreateInfo, - (struct nulldrv_pipeline **) pPipeline); -} - - - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines( - VkDevice device, - VkPipelineCache pipelineCache, - uint32_t createInfoCount, - const VkComputePipelineCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkPipeline* pPipeline) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - - - - - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool( - VkDevice device, - const VkQueryPoolCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkQueryPool* pQueryPool) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyQueryPool( - VkDevice device, - VkQueryPool queryPoool, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults( - VkDevice device, - VkQueryPool queryPool, - uint32_t firstQuery, - uint32_t queryCount, - size_t dataSize, - void* pData, - size_t stride, - VkQueryResultFlags flags) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle( - VkQueue queue_) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit( - VkQueue queue_, - uint32_t submitCount, - const VkSubmitInfo* pSubmits, - VkFence fence_) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore( - VkDevice device, - const VkSemaphoreCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSemaphore* pSemaphore) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore( - VkDevice device, - VkSemaphore semaphore, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler( - VkDevice device, - const VkSamplerCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSampler* pSampler) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return nulldrv_sampler_create(dev, pCreateInfo, - (struct nulldrv_sampler **) pSampler); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroySampler( - VkDevice device, - VkSampler sampler, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule( - VkDevice device, - const VkShaderModuleCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkShaderModule* pShaderModule) -{ - NULLDRV_LOG_FUNC; - - struct nulldrv_dev *dev = nulldrv_dev(device); - struct nulldrv_shader_module *shader_module; - - shader_module = (struct nulldrv_shader_module *) nulldrv_base_create(dev, - sizeof(*shader_module), VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT); - if (!shader_module) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - *pShaderModule = (VkShaderModule) shader_module; - - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule( - VkDevice device, - VkShaderModule shaderModule, - const VkAllocationCallbacks* pAllocator) -{ - // TODO: Fill in with real data - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView( - VkDevice device, - const VkBufferViewCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkBufferView* pView) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return nulldrv_buf_view_create(dev, pCreateInfo, - (struct nulldrv_buf_view **) pView); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView( - VkDevice device, - VkBufferView bufferView, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView( - VkDevice device, - const VkImageViewCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkImageView* pView) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return nulldrv_img_view_create(dev, pCreateInfo, - (struct nulldrv_img_view **) pView); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyImageView( - VkDevice device, - VkImageView imageView, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout( - VkDevice device, - const VkDescriptorSetLayoutCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkDescriptorSetLayout* pSetLayout) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return nulldrv_desc_layout_create(dev, pCreateInfo, - (struct nulldrv_desc_layout **) pSetLayout); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout( - VkDevice device, - VkDescriptorSetLayout descriptorSetLayout, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout( - VkDevice device, - const VkPipelineLayoutCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkPipelineLayout* pPipelineLayout) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return nulldrv_pipeline_layout_create(dev, - pCreateInfo, - (struct nulldrv_pipeline_layout **) pPipelineLayout); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout( - VkDevice device, - VkPipelineLayout pipelineLayout, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool( - VkDevice device, - const VkDescriptorPoolCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkDescriptorPool* pDescriptorPool) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return nulldrv_desc_pool_create(dev, pCreateInfo, - (struct nulldrv_desc_pool **) pDescriptorPool); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool( - VkDevice device, - VkDescriptorPool descriptorPool, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkResetDescriptorPool( - VkDevice device, - VkDescriptorPool descriptorPool, - VkDescriptorPoolResetFlags flags) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets( - VkDevice device, - const VkDescriptorSetAllocateInfo* pAllocateInfo, - VkDescriptorSet* pDescriptorSets) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_desc_pool *pool = nulldrv_desc_pool(pAllocateInfo->descriptorPool); - struct nulldrv_dev *dev = pool->dev; - VkResult ret = VK_SUCCESS; - uint32_t i; - - for (i = 0; i < pAllocateInfo->descriptorSetCount; i++) { - const struct nulldrv_desc_layout *layout = - nulldrv_desc_layout(pAllocateInfo->pSetLayouts[i]); - - ret = nulldrv_desc_set_create(dev, pool, layout, - (struct nulldrv_desc_set **) &pDescriptorSets[i]); - if (ret != VK_SUCCESS) - break; - } - - return ret; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets( - VkDevice device, - VkDescriptorPool descriptorPool, - uint32_t descriptorSetCount, - const VkDescriptorSet* pDescriptorSets) -{ - NULLDRV_LOG_FUNC; - return VK_SUCCESS; -} - -VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets( - VkDevice device, - uint32_t descriptorWriteCount, - const VkWriteDescriptorSet* pDescriptorWrites, - uint32_t descriptorCopyCount, - const VkCopyDescriptorSet* pDescriptorCopies) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer( - VkDevice device, - const VkFramebufferCreateInfo* info, - const VkAllocationCallbacks* pAllocator, - VkFramebuffer* fb_ret) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return nulldrv_fb_create(dev, info, (struct nulldrv_framebuffer **) fb_ret); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer( - VkDevice device, - VkFramebuffer framebuffer, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass( - VkDevice device, - const VkRenderPassCreateInfo* info, - const VkAllocationCallbacks* pAllocator, - VkRenderPass* rp_ret) -{ - NULLDRV_LOG_FUNC; - struct nulldrv_dev *dev = nulldrv_dev(device); - - return nulldrv_render_pass_create(dev, info, (struct nulldrv_render_pass **) rp_ret); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass( - VkDevice device, - VkRenderPass renderPass, - const VkAllocationCallbacks* pAllocator) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants( - VkCommandBuffer commandBuffer, - VkPipelineLayout layout, - VkShaderStageFlags stageFlags, - uint32_t offset, - uint32_t size, - const void* pValues) -{ - /* TODO: Implement */ -} - -VKAPI_ATTR void VKAPI_CALL vkGetRenderAreaGranularity( - VkDevice device, - VkRenderPass renderPass, - VkExtent2D* pGranularity) -{ - pGranularity->height = 1; - pGranularity->width = 1; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass( - VkCommandBuffer commandBuffer, - const VkRenderPassBeginInfo* pRenderPassBegin, - VkSubpassContents contents) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass( - VkCommandBuffer commandBuffer, - VkSubpassContents contents) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass( - VkCommandBuffer commandBuffer) -{ - NULLDRV_LOG_FUNC; -} - -VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands( - VkCommandBuffer commandBuffer, - uint32_t commandBuffersCount, - const VkCommandBuffer* pCommandBuffers) -{ - NULLDRV_LOG_FUNC; -} - -void* xcbCreateWindow( - uint16_t width, - uint16_t height) -{ - static uint32_t window; // Kludge to the max - NULLDRV_LOG_FUNC; - return &window; -} - -// May not be needed, if we stub out stuf in tri.c -void xcbDestroyWindow() -{ - NULLDRV_LOG_FUNC; -} - -int xcbGetMessage(void *msg) -{ - NULLDRV_LOG_FUNC; - return 0; -} - -VkResult xcbQueuePresent(void *queue, void *image, void* fence) -{ - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties( - VkPhysicalDevice physicalDevice, - VkFormat format, - VkImageType type, - VkImageTiling tiling, - VkImageUsageFlags usage, - VkImageCreateFlags flags, - VkImageFormatProperties* pImageFormatProperties) -{ - pImageFormatProperties->maxExtent.width = 1024; - pImageFormatProperties->maxExtent.height = 1024; - pImageFormatProperties->maxExtent.depth = 1024; - pImageFormatProperties->maxMipLevels = 10; - pImageFormatProperties->maxArrayLayers = 1024; - pImageFormatProperties->sampleCounts = VK_SAMPLE_COUNT_1_BIT; - pImageFormatProperties->maxResourceSize = 1024*1024*1024; - - return VK_SUCCESS; -} diff --git a/icd/nulldrv/nulldrv.h b/icd/nulldrv/nulldrv.h deleted file mode 100644 index f933a77a..00000000 --- a/icd/nulldrv/nulldrv.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * - * Copyright (C) 2015 Valve 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. - * - * Author: Cody Northrop <cody@lunarg.com> - * Author: David Pinedo <david@lunarg.com> - */ - -#ifndef NULLDRV_H -#define NULLDRV_H -#include <stdlib.h> -#include <stdbool.h> -#include <stdint.h> -#include <string.h> -#include <assert.h> - -#include <vulkan/vulkan.h> -#include <vulkan/vk_ext_debug_report.h> -#include <vulkan/vk_icd.h> - -#include "icd.h" - -#include "icd-format.h" -#include "icd-utils.h" - -struct nulldrv_base { - void *loader_data; - uint32_t magic; - VkResult (*get_memory_requirements)(struct nulldrv_base *base, VkMemoryRequirements *pMemoryRequirements); -}; - -struct nulldrv_obj { - struct nulldrv_base base; -}; - -enum nulldrv_ext_type { - NULLDRV_EXT_KHR_SWAPCHAIN, - NULLDRV_EXT_COUNT, - NULLDRV_EXT_INVALID = NULLDRV_EXT_COUNT, -}; - - -struct nulldrv_instance { - struct nulldrv_obj obj; -}; - -struct nulldrv_gpu { - void *loader_data; -}; - -struct nulldrv_dev { - struct nulldrv_base base; - bool exts[NULLDRV_EXT_COUNT]; - struct nulldrv_desc_ooxx *desc_ooxx; - struct nulldrv_queue *queues[1]; -}; - -struct nulldrv_desc_ooxx { - uint32_t surface_desc_size; - uint32_t sampler_desc_size; -}; - - -struct nulldrv_queue { - struct nulldrv_base base; - struct nulldrv_dev *dev; -}; - -struct nulldrv_rt_view { - struct nulldrv_obj obj; -}; - -struct nulldrv_fence { - struct nulldrv_obj obj; -}; - -struct nulldrv_img { - struct nulldrv_obj obj; - VkImageType type; - int32_t depth; - uint32_t mip_levels; - uint32_t array_size; - VkFlags usage; - VkSampleCountFlagBits samples; - size_t total_size; -}; - -struct nulldrv_mem { - struct nulldrv_base base; - struct nulldrv_bo *bo; - VkDeviceSize size; -}; - -struct nulldrv_sampler { - struct nulldrv_obj obj; -}; - -struct nulldrv_shader_module { - struct nulldrv_obj obj; -}; - -struct nulldrv_pipeline_cache { - struct nulldrv_obj obj; -}; - -struct nulldrv_img_view { - struct nulldrv_obj obj; - struct nulldrv_img *img; - float min_lod; - uint32_t cmd_len; -}; - -struct nulldrv_buf { - struct nulldrv_obj obj; - VkDeviceSize size; - VkFlags usage; -}; - -struct nulldrv_desc_layout { - struct nulldrv_obj obj; -}; - -struct nulldrv_pipeline_layout { - struct nulldrv_obj obj; -}; - -struct nulldrv_shader { - struct nulldrv_obj obj; - -}; - -struct nulldrv_pipeline { - struct nulldrv_obj obj; - struct nulldrv_dev *dev; -}; - -struct nulldrv_dynamic_vp { - struct nulldrv_obj obj; -}; - -struct nulldrv_dynamic_line_width { - struct nulldrv_obj obj; -}; - -struct nulldrv_dynamic_depth_bias { - struct nulldrv_obj obj; -}; - -struct nulldrv_dynamic_blend { - struct nulldrv_obj obj; -}; - -struct nulldrv_dynamic_depth_bounds { - struct nulldrv_obj obj; -}; - -struct nulldrv_dynamic_stencil { - struct nulldrv_obj obj; -}; - -struct nulldrv_cmd { - struct nulldrv_obj obj; -}; - -struct nulldrv_desc_pool { - struct nulldrv_obj obj; - struct nulldrv_dev *dev; -}; - -struct nulldrv_desc_set { - struct nulldrv_obj obj; - struct nulldrv_desc_ooxx *ooxx; - const struct nulldrv_desc_layout *layout; -}; - -struct nulldrv_framebuffer { - struct nulldrv_obj obj; -}; - -struct nulldrv_render_pass { - struct nulldrv_obj obj; -}; - -struct nulldrv_buf_view { - struct nulldrv_obj obj; - - struct nulldrv_buf *buf; - - /* SURFACE_STATE */ - uint32_t cmd[8]; - uint32_t fs_cmd[8]; - uint32_t cmd_len; -}; - -struct nulldrv_display { - struct nulldrv_base base; - struct nulldrv_dev *dev; -}; - -struct nulldrv_swap_chain { - struct nulldrv_base base; - struct nulldrv_dev *dev; -}; - -#endif /* NULLDRV_H */ diff --git a/icd/nulldrv/nulldrv_icd.json b/icd/nulldrv/nulldrv_icd.json deleted file mode 100644 index d77b3d07..00000000 --- a/icd/nulldrv/nulldrv_icd.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "file_format_version": "1.0.0", - "ICD": { - "library_path": "./libVK_nulldrv.so", - "api_version": "1.0.1" - } -} |
