Handle LPCWSTR in framework
authorPiotr Byszewski <piotr.byszewski@mobica.com>
Fri, 11 Oct 2019 09:43:19 +0000 (11:43 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 18 Oct 2019 09:12:39 +0000 (05:12 -0400)
Components: Framework

VK-GL-CTS issue: 1703

Affects:
dEQP-VK.*

Change-Id: I2061de4eac657aa9453bc3143306d1670eb271aa

external/vulkancts/framework/vulkan/vkBasicTypes.inl
external/vulkancts/framework/vulkan/vkStrUtil.cpp
external/vulkancts/framework/vulkan/vkStrUtilImpl.inl
external/vulkancts/framework/vulkan/vkStructTypes.inl
external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp
external/vulkancts/modules/vulkan/synchronization/vktSynchronizationWin32KeyedMutexTests.cpp
external/vulkancts/modules/vulkan/util/vktExternalMemoryUtil.cpp
external/vulkancts/scripts/gen_framework.py

index 3f03a730de36b2300b446cb988f40252afb49517..916180009745a806389d58c703879c29408a2353 100644 (file)
@@ -2827,6 +2827,7 @@ VK_DEFINE_PLATFORM_TYPE(Win32Handle,                              void*);
 VK_DEFINE_PLATFORM_TYPE(Win32SecurityAttributesPtr,    const void*);
 VK_DEFINE_PLATFORM_TYPE(AndroidHardwareBufferPtr,      void*);
 VK_DEFINE_PLATFORM_TYPE(Win32MonitorHandle,                    void*);
+VK_DEFINE_PLATFORM_TYPE(Win32LPCWSTR,                          const void*);
 VK_DEFINE_PLATFORM_TYPE(RROutput,                                      void*);
 VK_DEFINE_PLATFORM_TYPE(zx_handle_t,                           deInt32);
 VK_DEFINE_PLATFORM_TYPE(GgpFrameToken,                         deInt32);
index cfcae945f7fa476ea4d04444d56c01214c96b3e8..26f9b19f81e7a4d73fda2032d59b021f0ac19910 100644 (file)
@@ -46,6 +46,47 @@ inline CharPtr getCharPtrStr (const char* ptr)
        return CharPtr(ptr);
 }
 
+
+#if (DE_OS == DE_OS_WIN32)
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+struct WStr
+{
+       LPCWSTR wstr;
+
+       WStr (LPCWSTR wstr_) : wstr(wstr_) {}
+};
+
+std::ostream& operator<< (std::ostream& str, const WStr& wstr)
+{
+       int len = WideCharToMultiByte(CP_UTF8, 0, wstr.wstr, -1, NULL, 0, 0, 0);
+       if (len < 1)
+               return str << "(null)";
+
+       std::string result;
+       result.resize(len + 1);
+       WideCharToMultiByte(CP_UTF8, 0, wstr.wstr, -1, &result[0], len, 0, 0);
+
+       return str << '"' << result << '"';
+}
+
+inline WStr getWStr (pt::Win32LPCWSTR pt_wstr)
+{
+       return WStr(static_cast<LPCWSTR>(pt_wstr.internal));
+}
+
+#else
+
+inline CharPtr getWStr (pt::Win32LPCWSTR pt_wstr)
+{
+       return CharPtr(static_cast<const char*>(pt_wstr.internal));
+}
+
+#endif
+
+
 #include "vkStrUtilImpl.inl"
 
 } // vk
index b11daf53faeb798541fc47db1662cb9850f922d3..759a5967ed68a39a4ab96324491d53e0384a0acd 100644 (file)
@@ -59,6 +59,7 @@ std::ostream& operator<< (std::ostream& s, Win32Handle                                        v) { return s << tcu:
 std::ostream& operator<< (std::ostream& s, Win32SecurityAttributesPtr  v) { return s << tcu::toHex(v.internal); }
 std::ostream& operator<< (std::ostream& s, AndroidHardwareBufferPtr            v) { return s << tcu::toHex(v.internal); }
 std::ostream& operator<< (std::ostream& s, Win32MonitorHandle                  v) { return s << tcu::toHex(v.internal); }
+std::ostream& operator<< (std::ostream& s, Win32LPCWSTR                                        v) { return s << tcu::toHex(v.internal); }
 std::ostream& operator<< (std::ostream& s, RROutput                                            v) { return s << tcu::toHex(v.internal); }
 std::ostream& operator<< (std::ostream& s, zx_handle_t                                 v) { return s << tcu::toHex(v.internal); }
 std::ostream& operator<< (std::ostream& s, GgpFrameToken                               v) { return s << tcu::toHex(v.internal); }
@@ -8965,7 +8966,7 @@ std::ostream& operator<< (std::ostream& s, const VkImportMemoryWin32HandleInfoKH
        s << "\tpNext = " << value.pNext << '\n';
        s << "\thandleType = " << value.handleType << '\n';
        s << "\thandle = " << value.handle << '\n';
-       s << "\tname = " << getCharPtrStr(value.name) << '\n';
+       s << "\tname = " << getWStr(value.name) << '\n';
        s << '}';
        return s;
 }
@@ -8977,7 +8978,7 @@ std::ostream& operator<< (std::ostream& s, const VkExportMemoryWin32HandleInfoKH
        s << "\tpNext = " << value.pNext << '\n';
        s << "\tpAttributes = " << value.pAttributes << '\n';
        s << "\tdwAccess = " << value.dwAccess << '\n';
-       s << "\tname = " << getCharPtrStr(value.name) << '\n';
+       s << "\tname = " << getWStr(value.name) << '\n';
        s << '}';
        return s;
 }
@@ -9028,7 +9029,7 @@ std::ostream& operator<< (std::ostream& s, const VkImportSemaphoreWin32HandleInf
        s << "\tflags = " << getSemaphoreImportFlagsStr(value.flags) << '\n';
        s << "\thandleType = " << value.handleType << '\n';
        s << "\thandle = " << value.handle << '\n';
-       s << "\tname = " << getCharPtrStr(value.name) << '\n';
+       s << "\tname = " << getWStr(value.name) << '\n';
        s << '}';
        return s;
 }
@@ -9040,7 +9041,7 @@ std::ostream& operator<< (std::ostream& s, const VkExportSemaphoreWin32HandleInf
        s << "\tpNext = " << value.pNext << '\n';
        s << "\tpAttributes = " << value.pAttributes << '\n';
        s << "\tdwAccess = " << value.dwAccess << '\n';
-       s << "\tname = " << getCharPtrStr(value.name) << '\n';
+       s << "\tname = " << getWStr(value.name) << '\n';
        s << '}';
        return s;
 }
@@ -9078,7 +9079,7 @@ std::ostream& operator<< (std::ostream& s, const VkImportFenceWin32HandleInfoKHR
        s << "\tflags = " << getFenceImportFlagsStr(value.flags) << '\n';
        s << "\thandleType = " << value.handleType << '\n';
        s << "\thandle = " << value.handle << '\n';
-       s << "\tname = " << getCharPtrStr(value.name) << '\n';
+       s << "\tname = " << getWStr(value.name) << '\n';
        s << '}';
        return s;
 }
@@ -9090,7 +9091,7 @@ std::ostream& operator<< (std::ostream& s, const VkExportFenceWin32HandleInfoKHR
        s << "\tpNext = " << value.pNext << '\n';
        s << "\tpAttributes = " << value.pAttributes << '\n';
        s << "\tdwAccess = " << value.dwAccess << '\n';
-       s << "\tname = " << getCharPtrStr(value.name) << '\n';
+       s << "\tname = " << getWStr(value.name) << '\n';
        s << '}';
        return s;
 }
index d30d6aba880b8a267644841e4864a169958b0141..6ba3656a85d08fa2bf2a43675aa8c0416ab32efe 100644 (file)
@@ -4265,7 +4265,7 @@ struct VkImportMemoryWin32HandleInfoKHR
        const void*                                                     pNext;
        VkExternalMemoryHandleTypeFlagBits      handleType;
        pt::Win32Handle                                         handle;
-       char*                                                           name;
+       pt::Win32LPCWSTR                                        name;
 };
 
 struct VkExportMemoryWin32HandleInfoKHR
@@ -4274,7 +4274,7 @@ struct VkExportMemoryWin32HandleInfoKHR
        const void*                                             pNext;
        pt::Win32SecurityAttributesPtr  pAttributes;
        deUint32                                                dwAccess;
-       char*                                                   name;
+       pt::Win32LPCWSTR                                name;
 };
 
 struct VkMemoryWin32HandlePropertiesKHR
@@ -4313,7 +4313,7 @@ struct VkImportSemaphoreWin32HandleInfoKHR
        VkSemaphoreImportFlags                                  flags;
        VkExternalSemaphoreHandleTypeFlagBits   handleType;
        pt::Win32Handle                                                 handle;
-       char*                                                                   name;
+       pt::Win32LPCWSTR                                                name;
 };
 
 struct VkExportSemaphoreWin32HandleInfoKHR
@@ -4322,7 +4322,7 @@ struct VkExportSemaphoreWin32HandleInfoKHR
        const void*                                             pNext;
        pt::Win32SecurityAttributesPtr  pAttributes;
        deUint32                                                dwAccess;
-       char*                                                   name;
+       pt::Win32LPCWSTR                                name;
 };
 
 struct VkD3D12FenceSubmitInfoKHR
@@ -4351,7 +4351,7 @@ struct VkImportFenceWin32HandleInfoKHR
        VkFenceImportFlags                                      flags;
        VkExternalFenceHandleTypeFlagBits       handleType;
        pt::Win32Handle                                         handle;
-       char*                                                           name;
+       pt::Win32LPCWSTR                                        name;
 };
 
 struct VkExportFenceWin32HandleInfoKHR
@@ -4360,7 +4360,7 @@ struct VkExportFenceWin32HandleInfoKHR
        const void*                                             pNext;
        pt::Win32SecurityAttributesPtr  pAttributes;
        deUint32                                                dwAccess;
-       char*                                                   name;
+       pt::Win32LPCWSTR                                name;
 };
 
 struct VkFenceGetWin32HandleInfoKHR
index 5425125618756e933822b7a8bb3e7b608f38b3c6..06845fde7032e612e068a148b7bba5b3493bebf4 100644 (file)
@@ -817,7 +817,7 @@ tcu::TestStatus testSemaphoreWin32Create (Context&                                  context,
 
                        (vk::pt::Win32SecurityAttributesPtr)DE_NULL,
                        DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE,
-                       DE_NULL
+                       (vk::pt::Win32LPCWSTR)DE_NULL
                };
                const vk::VkExportSemaphoreCreateInfo                   exportCreateInfo=
                {
@@ -1756,7 +1756,7 @@ tcu::TestStatus testFenceWin32Create (Context&                            context,
 
                        (vk::pt::Win32SecurityAttributesPtr)DE_NULL,
                        DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE,
-                       DE_NULL
+                       (vk::pt::Win32LPCWSTR)DE_NULL
                };
                const vk::VkExportFenceCreateInfo                       exportCreateInfo=
                {
@@ -2879,7 +2879,7 @@ tcu::TestStatus testMemoryWin32Create (Context& context, MemoryTestConfig config
 
                (vk::pt::Win32SecurityAttributesPtr)DE_NULL,
                DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE,
-               DE_NULL
+               (vk::pt::Win32LPCWSTR)DE_NULL
        };
        const vk::VkExportMemoryAllocateInfo            exportInfo                      =
        {
index fcdb9a29e842131e5a29294ce0f7a7a60f94db84..8ae2d88a702b7e330de5dde5178133f370d87d17 100644 (file)
@@ -283,7 +283,7 @@ vk::Move<vk::VkDeviceMemory> importMemory (const vk::DeviceInterface&                               vkd,
                (requiresDedicated) ? &dedicatedInfo : DE_NULL,
                externalType,
                handle.getWin32Handle(),
-               NULL
+               (vk::pt::Win32LPCWSTR)NULL
        };
 
        deUint32 handleCompatibleMemoryTypeBits = ~0u;
index 4b78aa8906c9fcf5ea6beba567137ec63ee0cd86..c9f2a461d52c35bf21aa68fa375262e085961a14 100644 (file)
@@ -668,7 +668,7 @@ void importFence (const vk::DeviceInterface&                                vkd,
                        flags,
                        externalType,
                        handle.getWin32Handle(),
-                       DE_NULL
+                       (vk::pt::Win32LPCWSTR)DE_NULL
                };
 
                VK_CHECK(vkd.importFenceWin32HandleKHR(device, &importInfo));
@@ -851,7 +851,7 @@ void importSemaphore (const vk::DeviceInterface&                                    vkd,
                        flags,
                        externalType,
                        handle.getWin32Handle(),
-                       DE_NULL
+                       (vk::pt::Win32LPCWSTR)DE_NULL
                };
 
                VK_CHECK(vkd.importSemaphoreWin32HandleKHR(device, &importInfo));
@@ -1038,7 +1038,7 @@ static vk::Move<vk::VkDeviceMemory> importMemory (const vk::DeviceInterface&
                        DE_NULL,
                        externalType,
                        handle.getWin32Handle(),
-                       DE_NULL
+                       (vk::pt::Win32LPCWSTR)DE_NULL
                };
                const vk::VkMemoryDedicatedAllocateInfo         dedicatedInfo   =
                {
index 95cc808f5d95a9b7a65faef45638c74afe847eac..4592a7e6fa4ceccf283f4bc7e7a6574a53ad2d5d 100644 (file)
@@ -94,6 +94,7 @@ PLATFORM_TYPES                = [
        (["const", "SECURITY_ATTRIBUTES", "*"], ["Win32SecurityAttributesPtr"], "const void*"),
        (["AHardwareBuffer", "*"],                              ["AndroidHardwareBufferPtr"],   "void*"),
        (["HMONITOR"],                                                  ["Win32MonitorHandle"],                 "void*"),
+       (["LPCWSTR"],                                                   ["Win32LPCWSTR"],                               "const void*"),
 
        # VK_EXT_acquire_xlib_display
        (["RROutput"],                                                  ["RROutput"],                                   "void*"),
@@ -121,7 +122,6 @@ TYPE_SUBSTITUTIONS          = [
        # Platform-specific
        ("DWORD",               "deUint32"),
        ("HANDLE*",             PLATFORM_TYPE_NAMESPACE + "::" + "Win32Handle*"),
-       ("LPCWSTR",             "char*"),
 ]
 
 EXTENSION_POSTFIXES                            = ["KHR", "EXT", "NV", "NVX", "KHX", "NN", "MVK", "FUCHSIA", "GGP", "AMD"]
@@ -1067,6 +1067,8 @@ def writeStrUtilImpl (api, filename):
                                                valFmt = "get%sStr(value.%s)" % (member.getType()[2:], member.name)
                                        elif member.getType() == "const char*" or member.getType() == "char*":
                                                valFmt = "getCharPtrStr(value.%s)" % member.name
+                                       elif member.getType() == PLATFORM_TYPE_NAMESPACE + "::Win32LPCWSTR":
+                                               valFmt = "getWStr(value.%s)" % member.name
                                        elif member.arraySize != '':
                                                if member.name in ["extensionName", "deviceName", "layerName", "description"]:
                                                        valFmt = "(const char*)value.%s" % member.name