From d8583b2c7adbe8596e78e6bc78acc31e5a63b4ff Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 12 Dec 2018 15:25:39 +0300 Subject: [PATCH] dnn: fix vulkan backend builds with Clang --- modules/dnn/src/vkcom/include/op_pool.hpp | 2 +- modules/dnn/src/vkcom/src/context.cpp | 10 +++++++--- modules/dnn/src/vkcom/src/context.hpp | 3 ++- modules/dnn/src/vkcom/src/op_base.cpp | 6 ++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/dnn/src/vkcom/include/op_pool.hpp b/modules/dnn/src/vkcom/include/op_pool.hpp index fa4acc1a76..50f8fc0682 100644 --- a/modules/dnn/src/vkcom/include/op_pool.hpp +++ b/modules/dnn/src/vkcom/include/op_pool.hpp @@ -59,7 +59,7 @@ private: int avg_pool_padded_area_; int need_mask_; PaddingMode padding_mode_; - int activation_; + //int activation_; PoolShaderConfig config_; }; diff --git a/modules/dnn/src/vkcom/src/context.cpp b/modules/dnn/src/vkcom/src/context.cpp index 6f203cf889..01f8eda668 100644 --- a/modules/dnn/src/vkcom/src/context.cpp +++ b/modules/dnn/src/vkcom/src/context.cpp @@ -281,10 +281,14 @@ Context::~Context() if (enableValidationLayers) { auto func = (PFN_vkDestroyDebugReportCallbackEXT) vkGetInstanceProcAddr(kInstance, "vkDestroyDebugReportCallbackEXT"); - if (func == nullptr) { - throw std::runtime_error("Could not load vkDestroyDebugReportCallbackEXT"); + if (func == nullptr) + { + CV_LOG_FATAL(NULL, "Could not load vkDestroyDebugReportCallbackEXT"); + } + else + { + func(kInstance, kDebugReportCallback, NULL); } - func(kInstance, kDebugReportCallback, NULL); } kShaders.clear(); vkDestroyInstance(kInstance, NULL); diff --git a/modules/dnn/src/vkcom/src/context.hpp b/modules/dnn/src/vkcom/src/context.hpp index a9d9d4de27..fbf2d8e9a1 100644 --- a/modules/dnn/src/vkcom/src/context.hpp +++ b/modules/dnn/src/vkcom/src/context.hpp @@ -12,8 +12,9 @@ namespace cv { namespace dnn { namespace vkcom { #ifdef HAVE_VULKAN -struct Context +class Context { +public: Context(); ~Context(); }; diff --git a/modules/dnn/src/vkcom/src/op_base.cpp b/modules/dnn/src/vkcom/src/op_base.cpp index f72e7bbe08..4a3a6b7923 100644 --- a/modules/dnn/src/vkcom/src/op_base.cpp +++ b/modules/dnn/src/vkcom/src/op_base.cpp @@ -45,7 +45,9 @@ void OpBase::initVulkanThing(int buffer_num) void OpBase::createDescriptorSetLayout(int buffer_num) { - VkDescriptorSetLayoutBinding bindings[buffer_num] = {}; + if (buffer_num <= 0) + return; + std::vector bindings(buffer_num); for (int i = 0; i < buffer_num; i++) { bindings[i].binding = i; @@ -56,7 +58,7 @@ void OpBase::createDescriptorSetLayout(int buffer_num) VkDescriptorSetLayoutCreateInfo info = {}; info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; info.bindingCount = buffer_num; - info.pBindings = bindings; + info.pBindings = &bindings[0]; VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device_, &info, NULL, &descriptor_set_layout_)); }