From b36b501f5e88543f2466024702c87134aef67b92 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Thu, 23 Nov 2017 17:22:23 -0500 Subject: [PATCH] Build the Vulkan backend on CI --- .appveyor.yml | 2 +- .travis.yml | 5 ++++- src/backend/vulkan/BufferUploader.cpp | 2 +- src/backend/vulkan/VulkanBackend.cpp | 21 +++++++++++++-------- src/backend/vulkan/VulkanBackend.h | 17 +++++++++-------- src/utils/VulkanBinding.cpp | 4 +--- 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 93bcd1704d..3997fd230f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -13,7 +13,7 @@ install: build_script: - mkdir build - cd build - - cmake -DNXT_USE_WERROR=1 .. + - cmake -DNXT_USE_WERROR=1 -DNXT_ENABLE_VULKAN=1 .. - cmake --build . # TODO(cwallez@chromium.org) test on more than Debug. diff --git a/.travis.yml b/.travis.yml index cbf6046ed9..bc3cb3ba04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,11 +53,14 @@ script: # Use the more recent compilers we just installed - if [ "$TRAVIS_OS_NAME" == "linux" ] && [ "$CXX" == "clang++" ]; then export CXX="clang++-5.0" CC="clang-5.0"; fi + # Build the Vulkan backend on Linux + - if [ "$TRAVIS_OS_NAME" == "linux" ]; then export BUILD_VULKAN=1; else export BUILD_VULKAN=0; fi + # Build - mkdir -p build - cd build - cmake --version - - cmake -G "Ninja" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DNXT_USE_WERROR=1 .. + - cmake -G "Ninja" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DNXT_USE_WERROR=1 -DNXT_ENABLE_VULKAN=$BUILD_VULKAN .. - cmake --build . # Test diff --git a/src/backend/vulkan/BufferUploader.cpp b/src/backend/vulkan/BufferUploader.cpp index cf92dca957..9e05199ae7 100644 --- a/src/backend/vulkan/BufferUploader.cpp +++ b/src/backend/vulkan/BufferUploader.cpp @@ -69,7 +69,7 @@ namespace backend { namespace vulkan { // Write to the staging buffer ASSERT(allocation.GetMappedPointer() != nullptr); - memcpy(allocation.GetMappedPointer(), data, size); + memcpy(allocation.GetMappedPointer(), data, static_cast(size)); // Enqueue host write -> transfer src barrier and copy command VkCommandBuffer commands = mDevice->GetPendingCommandBuffer(); diff --git a/src/backend/vulkan/VulkanBackend.cpp b/src/backend/vulkan/VulkanBackend.cpp index c9a92527fc..938b71fdda 100644 --- a/src/backend/vulkan/VulkanBackend.cpp +++ b/src/backend/vulkan/VulkanBackend.cpp @@ -339,6 +339,10 @@ namespace backend { namespace vulkan { usedKnobs->debugReport = true; } #endif + if (mGlobalInfo.surface) { + extensionsToRequest.push_back(kExtensionNameKhrSurface); + usedKnobs->surface = true; + } VkApplicationInfo appInfo; appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; @@ -448,14 +452,15 @@ namespace backend { namespace vulkan { return true; } - VkBool32 Device::OnDebugReportCallback(VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT /*objectType*/, - uint64_t /*object*/, - size_t /*location*/, - int32_t /*messageCode*/, - const char* /*pLayerPrefix*/, - const char* pMessage, - void* /*pUserdata*/) { + VKAPI_ATTR VkBool32 VKAPI_CALL + Device::OnDebugReportCallback(VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT /*objectType*/, + uint64_t /*object*/, + size_t /*location*/, + int32_t /*messageCode*/, + const char* /*pLayerPrefix*/, + const char* pMessage, + void* /*pUserdata*/) { std::cout << pMessage << std::endl; ASSERT((flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) == 0); diff --git a/src/backend/vulkan/VulkanBackend.h b/src/backend/vulkan/VulkanBackend.h index 73731bf59c..9a66b78e43 100644 --- a/src/backend/vulkan/VulkanBackend.h +++ b/src/backend/vulkan/VulkanBackend.h @@ -147,14 +147,15 @@ namespace backend { namespace vulkan { void GatherQueueFromDevice(); bool RegisterDebugReport(); - static VkBool32 OnDebugReportCallback(VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objectType, - uint64_t object, - size_t location, - int32_t messageCode, - const char* pLayerPrefix, - const char* pMessage, - void* pUserdata); + static VKAPI_ATTR VkBool32 VKAPI_CALL + OnDebugReportCallback(VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT objectType, + uint64_t object, + size_t location, + int32_t messageCode, + const char* pLayerPrefix, + const char* pMessage, + void* pUserdata); // To make it easier to use fn it is a public const member. However // the Device is allowed to mutate them through these private methods. diff --git a/src/utils/VulkanBinding.cpp b/src/utils/VulkanBinding.cpp index e783f412f7..f5b982bf9b 100644 --- a/src/utils/VulkanBinding.cpp +++ b/src/utils/VulkanBinding.cpp @@ -32,9 +32,7 @@ namespace utils { } private: - GLFWwindow* window = nullptr; - - SwapChainImplVulkan(GLFWwindow* window) : window(window) { + SwapChainImplVulkan(GLFWwindow* /*window*/) { } ~SwapChainImplVulkan() {