build: silence type shortening warnings under clang

This commit is contained in:
Danny Robson 2018-01-18 11:57:08 +11:00
parent 3d2e7e647c
commit 41fb2a0284
2 changed files with 11 additions and 11 deletions

View File

@ -51,17 +51,18 @@ namespace cruft::vk {
static auto static auto
try_func (FuncT &&func, Args &&...args) try_func (FuncT &&func, Args &&...args)
{ {
if constexpr (std::is_same_v< constexpr bool returns_vkresult = std::is_same_v<
typename func_traits<FuncT>::return_type, typename func_traits<FuncT>::return_type,
VkResult VkResult
>) >;
{
if constexpr (returns_vkresult) {
try_code (func (maybe_native (args)...)); try_code (func (maybe_native (args)...));
return; return;
} } else {
else
return func (maybe_native (args)...); return func (maybe_native (args)...);
} }
}
/// returns a ValueT using an invokable FuncT with arguments /// returns a ValueT using an invokable FuncT with arguments

View File

@ -19,6 +19,7 @@
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h> #include <GLFW/glfw3native.h>
#include <cruft/util/cast.hpp>
#include <cruft/util/extent.hpp> #include <cruft/util/extent.hpp>
#include <cruft/util/io.hpp> #include <cruft/util/io.hpp>
#include <cruft/util/log.hpp> #include <cruft/util/log.hpp>
@ -355,13 +356,13 @@ main (void)
auto queues = pdevice.queue_families (); auto queues = pdevice.queue_families ();
int graphics_queue_id = -1, present_queue_id = -1; int graphics_queue_id = -1, present_queue_id = -1;
for (size_t i = 0, last = queues.size (); i != last; ++i) for (int i = 0, last = util::cast::lossless<int> (queues.size ()); i != last; ++i)
if (queues[i].queueCount > 0 && queues[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { if (queues[i].queueCount > 0 && queues[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
graphics_queue_id = i; graphics_queue_id = i;
break; break;
} }
for (size_t i = 0, last = queues.size (); i != last; ++i) { for (uint32_t i = 0, last = util::cast::narrow<uint32_t> (queues.size ()); i != last; ++i) {
if (cruft::vk::error::try_query (vkGetPhysicalDeviceSurfaceSupportKHR, if (cruft::vk::error::try_query (vkGetPhysicalDeviceSurfaceSupportKHR,
pdevice.native (), i, surface)) { pdevice.native (), i, surface)) {
present_queue_id = i; present_queue_id = i;
@ -732,7 +733,6 @@ main (void)
ldevice, VK_NULL_HANDLE, 1, &pipeline_info, nullptr ldevice, VK_NULL_HANDLE, 1, &pipeline_info, nullptr
); );
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
using framebuffer_ptr = cruft::vk::owned_ptr<cruft::vk::framebuffer>; using framebuffer_ptr = cruft::vk::owned_ptr<cruft::vk::framebuffer>;
std::vector<framebuffer_ptr> swapchain_framebuffers; std::vector<framebuffer_ptr> swapchain_framebuffers;
@ -880,6 +880,5 @@ main (void)
} }
cruft::vk::error::try_func (vkDeviceWaitIdle, ldevice.native ()); cruft::vk::error::try_func (vkDeviceWaitIdle, ldevice.native ());
LOG_INFO ("terminating"); LOG_INFO ("terminating");
} }