Added Vulkan image utils.
authorDae Kim <dae.kimpark@imgtec.com>
Wed, 2 Sep 2015 12:09:44 +0000 (13:09 +0100)
committerDae Kim <dae.kimpark@imgtec.com>
Wed, 2 Sep 2015 12:09:44 +0000 (13:09 +0100)
external/vulkancts/framework/vulkan/CMakeLists.txt
external/vulkancts/framework/vulkan/vkImageUtil.cpp [new file with mode: 0644]
external/vulkancts/framework/vulkan/vkImageUtil.hpp [new file with mode: 0644]

index c39a07f..b4e27ea 100644 (file)
@@ -29,6 +29,8 @@ set(VKUTIL_SRCS
        vkBinaryRegistry.hpp
        vkNullDriver.cpp
        vkNullDriver.hpp
+       vkImageUtil.cpp
+       vkImageUtil.hpp
        )
 
 set(VKUTIL_LIBS
diff --git a/external/vulkancts/framework/vulkan/vkImageUtil.cpp b/external/vulkancts/framework/vulkan/vkImageUtil.cpp
new file mode 100644 (file)
index 0000000..ab76fd0
--- /dev/null
@@ -0,0 +1,319 @@
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2015 The Khronos Group Inc.
+ * Copyright (c) 2015 Imagination Technologies Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice(s) and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * The Materials are Confidential Information as defined by the
+ * Khronos Membership Agreement until designated non-confidential by Khronos,
+ * at which point this condition clause shall be removed.
+ *
+ * THE MATERIALS ARE 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
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//*!
+ * \file
+ * \brief Utilities for images.
+ *//*--------------------------------------------------------------------*/
+
+#include "vkImageUtil.hpp"
+#include "vkMemUtil.hpp"
+#include "vkQueryUtil.hpp"
+#include "vkRefUtil.hpp"
+#include "tcuTextureUtil.hpp"
+
+namespace vk
+{
+
+bool isFloatFormat (VkFormat format)
+{
+       return tcu::getTextureChannelClass(mapVkFormat(format).type) == tcu::TEXTURECHANNELCLASS_FLOATING_POINT;
+}
+
+bool isUnormFormat (VkFormat format)
+{
+       return tcu::getTextureChannelClass(mapVkFormat(format).type) == tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT;
+}
+
+bool isSnormFormat (VkFormat format)
+{
+       return tcu::getTextureChannelClass(mapVkFormat(format).type) == tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT;
+}
+
+bool isIntFormat (VkFormat format)
+{
+       return tcu::getTextureChannelClass(mapVkFormat(format).type) == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER;
+}
+
+bool isUintFormat (VkFormat format)
+{
+       return tcu::getTextureChannelClass(mapVkFormat(format).type) == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
+}
+
+bool isDepthStencilFormat (VkFormat format)
+{
+       const tcu::TextureFormat tcuFormat = mapVkFormat(format);
+       return tcuFormat.order == tcu::TextureFormat::D || tcuFormat.order == tcu::TextureFormat::S || tcuFormat.order == tcu::TextureFormat::DS;
+}
+
+bool isCompressedFormat (VkFormat format)
+{
+       switch (format)
+       {
+               case VK_FORMAT_BC1_RGBA_SRGB:
+               case VK_FORMAT_BC1_RGBA_UNORM:
+               case VK_FORMAT_BC1_RGB_SRGB:
+               case VK_FORMAT_BC1_RGB_UNORM:
+               case VK_FORMAT_BC2_UNORM:
+               case VK_FORMAT_BC2_SRGB:
+               case VK_FORMAT_BC3_UNORM:
+               case VK_FORMAT_BC3_SRGB:
+               case VK_FORMAT_BC4_UNORM:
+               case VK_FORMAT_BC4_SNORM:
+               case VK_FORMAT_BC5_UNORM:
+               case VK_FORMAT_BC5_SNORM:
+               case VK_FORMAT_BC6H_UFLOAT:
+               case VK_FORMAT_BC6H_SFLOAT:
+               case VK_FORMAT_BC7_UNORM:
+               case VK_FORMAT_BC7_SRGB:
+               case VK_FORMAT_ETC2_R8G8B8_UNORM:
+               case VK_FORMAT_ETC2_R8G8B8A1_UNORM:
+               case VK_FORMAT_ETC2_R8G8B8A8_UNORM:
+               case VK_FORMAT_EAC_R11_UNORM:
+               case VK_FORMAT_EAC_R11_SNORM:
+               case VK_FORMAT_EAC_R11G11_UNORM:
+               case VK_FORMAT_EAC_R11G11_SNORM:
+               case VK_FORMAT_ASTC_4x4_UNORM:
+               case VK_FORMAT_ASTC_4x4_SRGB:
+               case VK_FORMAT_ASTC_5x4_UNORM:
+               case VK_FORMAT_ASTC_5x4_SRGB:
+               case VK_FORMAT_ASTC_5x5_UNORM:
+               case VK_FORMAT_ASTC_5x5_SRGB:
+               case VK_FORMAT_ASTC_6x5_UNORM:
+               case VK_FORMAT_ASTC_6x5_SRGB:
+               case VK_FORMAT_ASTC_6x6_UNORM:
+               case VK_FORMAT_ASTC_6x6_SRGB:
+               case VK_FORMAT_ASTC_8x5_UNORM:
+               case VK_FORMAT_ASTC_8x5_SRGB:
+               case VK_FORMAT_ASTC_8x6_UNORM:
+               case VK_FORMAT_ASTC_8x6_SRGB:
+               case VK_FORMAT_ASTC_8x8_UNORM:
+               case VK_FORMAT_ASTC_8x8_SRGB:
+               case VK_FORMAT_ASTC_10x5_UNORM:
+               case VK_FORMAT_ASTC_10x5_SRGB:
+               case VK_FORMAT_ASTC_10x6_UNORM:
+               case VK_FORMAT_ASTC_10x6_SRGB:
+               case VK_FORMAT_ASTC_10x8_UNORM:
+               case VK_FORMAT_ASTC_10x8_SRGB:
+               case VK_FORMAT_ASTC_10x10_UNORM:
+               case VK_FORMAT_ASTC_10x10_SRGB:
+               case VK_FORMAT_ASTC_12x10_UNORM:
+               case VK_FORMAT_ASTC_12x10_SRGB:
+               case VK_FORMAT_ASTC_12x12_UNORM:
+               case VK_FORMAT_ASTC_12x12_SRGB:
+                       return true;
+               default:
+                       break;
+       }
+       return false;
+}
+
+tcu::TextureFormat mapVkFormat (VkFormat format)
+{
+       using tcu::TextureFormat;
+
+       switch (format)
+       {
+               case VK_FORMAT_R5G6B5_UNORM:
+                       return TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_SHORT_565);
+
+               case VK_FORMAT_R5G5B5A1_UNORM:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_SHORT_5551);
+
+               /* R8 */
+               case VK_FORMAT_R8_UNORM:
+                       return TextureFormat(TextureFormat::R, TextureFormat::UNORM_INT8);
+               case VK_FORMAT_R8_SNORM:
+                       return TextureFormat(TextureFormat::R, TextureFormat::SNORM_INT8);
+               case VK_FORMAT_R8_UINT:
+               case VK_FORMAT_R8_USCALED:
+                       return TextureFormat(TextureFormat::R, TextureFormat::UNSIGNED_INT8);
+               case VK_FORMAT_R8_SINT:
+               case VK_FORMAT_R8_SSCALED:
+                       return TextureFormat(TextureFormat::R, TextureFormat::SIGNED_INT8);
+
+               /* R8G8 */
+               case VK_FORMAT_R8G8_UNORM:
+                       return TextureFormat(TextureFormat::RG, TextureFormat::UNORM_INT8);
+               case VK_FORMAT_R8G8_SNORM:
+                       return TextureFormat(TextureFormat::RG, TextureFormat::SNORM_INT8);
+               case VK_FORMAT_R8G8_UINT:
+               case VK_FORMAT_R8G8_USCALED:
+                       return TextureFormat(TextureFormat::RG, TextureFormat::UNSIGNED_INT8);
+               case VK_FORMAT_R8G8_SINT:
+               case VK_FORMAT_R8G8_SSCALED:
+                       return TextureFormat(TextureFormat::RG, TextureFormat::SIGNED_INT8);
+
+               /* R8G8B8 */
+               case VK_FORMAT_R8G8B8_UNORM:
+                       return TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8);
+               case VK_FORMAT_R8G8B8_SNORM:
+                       return TextureFormat(TextureFormat::RGB, TextureFormat::SNORM_INT8);
+               case VK_FORMAT_R8G8B8_UINT:
+               case VK_FORMAT_R8G8B8_USCALED:
+                       return TextureFormat(TextureFormat::RGB, TextureFormat::UNSIGNED_INT8);
+               case VK_FORMAT_R8G8B8_SINT:
+               case VK_FORMAT_R8G8B8_SSCALED:
+                       return TextureFormat(TextureFormat::RGB, TextureFormat::SIGNED_INT8);
+               case VK_FORMAT_R8G8B8_SRGB:
+                       return TextureFormat(TextureFormat::sRGB, TextureFormat::UNORM_INT8);
+
+               /* R8G8B8A8 */
+               case VK_FORMAT_R8G8B8A8_UNORM:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8);
+               case VK_FORMAT_R8G8B8A8_SNORM:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::SNORM_INT8);
+               case VK_FORMAT_R8G8B8A8_UINT:
+               case VK_FORMAT_R8G8B8A8_USCALED:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT8);
+               case VK_FORMAT_R8G8B8A8_SINT:
+               case VK_FORMAT_R8G8B8A8_SSCALED:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::SIGNED_INT8);
+               case VK_FORMAT_R8G8B8A8_SRGB:
+                       return TextureFormat(TextureFormat::sRGBA, TextureFormat::UNORM_INT8);
+
+               /* R10G10B10A2 */
+               case VK_FORMAT_R10G10B10A2_UNORM:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT_1010102_REV);
+               case VK_FORMAT_R10G10B10A2_UINT:
+               case VK_FORMAT_R10G10B10A2_USCALED:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT_1010102_REV);
+
+               /* R16 */
+               case VK_FORMAT_R16_UNORM:
+                       return TextureFormat(TextureFormat::R, TextureFormat::UNORM_INT16);
+               case VK_FORMAT_R16_SNORM:
+                       return TextureFormat(TextureFormat::R, TextureFormat::SNORM_INT16);
+               case VK_FORMAT_R16_UINT:
+               case VK_FORMAT_R16_USCALED:
+                       return TextureFormat(TextureFormat::R, TextureFormat::UNSIGNED_INT16);
+               case VK_FORMAT_R16_SINT:
+               case VK_FORMAT_R16_SSCALED:
+                       return TextureFormat(TextureFormat::R, TextureFormat::SIGNED_INT16);
+               case VK_FORMAT_R16_SFLOAT:
+                       return TextureFormat(TextureFormat::R, TextureFormat::HALF_FLOAT);
+
+               /* R16G16 */
+               case VK_FORMAT_R16G16_UNORM:
+                       return TextureFormat(TextureFormat::RG, TextureFormat::UNORM_INT16);
+               case VK_FORMAT_R16G16_SNORM:
+                       return TextureFormat(TextureFormat::RG, TextureFormat::SNORM_INT16);
+               case VK_FORMAT_R16G16_UINT:
+               case VK_FORMAT_R16G16_USCALED:
+                       return TextureFormat(TextureFormat::RG, TextureFormat::UNSIGNED_INT16);
+               case VK_FORMAT_R16G16_SINT:
+               case VK_FORMAT_R16G16_SSCALED:
+                       return TextureFormat(TextureFormat::RG, TextureFormat::SIGNED_INT16);
+               case VK_FORMAT_R16G16_SFLOAT:
+                       return TextureFormat(TextureFormat::RG, TextureFormat::HALF_FLOAT);
+
+               /* R16G16B16 */
+               case VK_FORMAT_R16G16B16_UNORM:
+                       return TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT16);
+               case VK_FORMAT_R16G16B16_SNORM:
+                       return TextureFormat(TextureFormat::RGB, TextureFormat::SNORM_INT16);
+               case VK_FORMAT_R16G16B16_UINT:
+               case VK_FORMAT_R16G16B16_USCALED:
+                       return TextureFormat(TextureFormat::RGB, TextureFormat::UNSIGNED_INT16);
+               case VK_FORMAT_R16G16B16_SINT:
+               case VK_FORMAT_R16G16B16_SSCALED:
+                       return TextureFormat(TextureFormat::RGB, TextureFormat::SIGNED_INT16);
+               case VK_FORMAT_R16G16B16_SFLOAT:
+                       return TextureFormat(TextureFormat::RGB, TextureFormat::HALF_FLOAT);
+
+               /* R16G16B16A16 */
+               case VK_FORMAT_R16G16B16A16_UNORM:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT16);
+               case VK_FORMAT_R16G16B16A16_SNORM:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::SNORM_INT16);
+               case VK_FORMAT_R16G16B16A16_UINT:
+               case VK_FORMAT_R16G16B16A16_USCALED:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT16);
+               case VK_FORMAT_R16G16B16A16_SINT:
+               case VK_FORMAT_R16G16B16A16_SSCALED:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::SIGNED_INT16);
+               case VK_FORMAT_R16G16B16A16_SFLOAT:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::HALF_FLOAT);
+
+               /* R32 */
+               case VK_FORMAT_R32_UINT:
+                       return TextureFormat(TextureFormat::R, TextureFormat::UNSIGNED_INT32);
+               case VK_FORMAT_R32_SINT:
+                       return TextureFormat(TextureFormat::R, TextureFormat::SIGNED_INT32);
+               case VK_FORMAT_R32_SFLOAT:
+                       return TextureFormat(TextureFormat::R, TextureFormat::FLOAT);
+
+               /* R32G32 */
+               case VK_FORMAT_R32G32_UINT:
+                       return TextureFormat(TextureFormat::RG, TextureFormat::UNSIGNED_INT32);
+               case VK_FORMAT_R32G32_SINT:
+                       return TextureFormat(TextureFormat::RG, TextureFormat::SIGNED_INT32);
+               case VK_FORMAT_R32G32_SFLOAT:
+                       return TextureFormat(TextureFormat::RG, TextureFormat::FLOAT);
+
+               /* R32G32B32 */
+               case VK_FORMAT_R32G32B32_UINT:
+                       return TextureFormat(TextureFormat::RGB, TextureFormat::UNSIGNED_INT32);
+               case VK_FORMAT_R32G32B32_SINT:
+                       return TextureFormat(TextureFormat::RGB, TextureFormat::SIGNED_INT32);
+               case VK_FORMAT_R32G32B32_SFLOAT:
+                       return TextureFormat(TextureFormat::RGB, TextureFormat::FLOAT);
+
+               /* R32G32B32A32 */
+               case VK_FORMAT_R32G32B32A32_UINT:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32);
+               case VK_FORMAT_R32G32B32A32_SINT:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::SIGNED_INT32);
+               case VK_FORMAT_R32G32B32A32_SFLOAT:
+                       return TextureFormat(TextureFormat::RGBA, TextureFormat::FLOAT);
+
+               /* D/S */
+               case VK_FORMAT_D16_UNORM:
+                       return TextureFormat(TextureFormat::D, TextureFormat::UNORM_INT16);
+               case VK_FORMAT_D24_UNORM:
+                       return TextureFormat(TextureFormat::D, TextureFormat::UNORM_INT24);
+               case VK_FORMAT_D32_SFLOAT:
+                       return TextureFormat(TextureFormat::D, TextureFormat::FLOAT);
+               case VK_FORMAT_D16_UNORM_S8_UINT:
+                       return TextureFormat(TextureFormat::DS, TextureFormat::UNSIGNED_INT_16_8);
+               case VK_FORMAT_D24_UNORM_S8_UINT:
+                       return TextureFormat(TextureFormat::DS, TextureFormat::UNSIGNED_INT_24_8);
+               case VK_FORMAT_D32_SFLOAT_S8_UINT:
+                       return TextureFormat(TextureFormat::DS, TextureFormat::FLOAT_UNSIGNED_INT_8);
+               case VK_FORMAT_S8_UINT:
+                       return TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8);
+               default:
+                       break;
+       }
+
+       return TextureFormat(TextureFormat::CHANNELORDER_LAST, TextureFormat::CHANNELTYPE_LAST);
+}
+
+} // vk
diff --git a/external/vulkancts/framework/vulkan/vkImageUtil.hpp b/external/vulkancts/framework/vulkan/vkImageUtil.hpp
new file mode 100644 (file)
index 0000000..9632670
--- /dev/null
@@ -0,0 +1,60 @@
+#ifndef _VKIMAGEUTIL_HPP
+#define _VKIMAGEUTIL_HPP
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2015 The Khronos Group Inc.
+ * Copyright (c) 2015 Imagination Technologies Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice(s) and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * The Materials are Confidential Information as defined by the
+ * Khronos Membership Agreement until designated non-confidential by Khronos,
+ * at which point this condition clause shall be removed.
+ *
+ * THE MATERIALS ARE 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
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//*!
+ * \file
+ * \brief Utilities for images.
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuDefs.hpp"
+#include "vkDefs.hpp"
+#include "vkPlatform.hpp"
+#include "vkMemUtil.hpp"
+#include "vkRef.hpp"
+#include "tcuTexture.hpp"
+
+namespace vk
+{
+
+bool                           isFloatFormat                           (VkFormat format);
+bool                           isUnormFormat                           (VkFormat format);
+bool                           isSnormFormat                           (VkFormat format);
+bool                           isIntFormat                                     (VkFormat format);
+bool                           isUintFormat                            (VkFormat format);
+bool                           isDepthStencilFormat            (VkFormat format);
+bool                           isCompressedFormat                      (VkFormat format);
+
+tcu::TextureFormat     mapVkFormat                                     (VkFormat format);
+
+} // vk
+
+#endif // _VKIMAGEUTIL_HPP