libcruft-vk/cruft/vk/fence.cpp

66 lines
1.7 KiB
C++
Raw Permalink Normal View History

2016-02-26 13:39:01 +11:00
/*
2018-08-04 15:24:36 +10:00
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
2016-02-26 13:39:01 +11:00
*
* Copyright:
* 2016, Danny Robson <danny@nerdcruft.net>
*/
2016-02-24 11:11:41 +11:00
#include "./fence.hpp"
#include "./device.hpp"
2016-06-29 18:03:11 +10:00
#include <cruft/util/cast.hpp>
2019-05-17 13:33:30 +10:00
#include <cruft/util/debug/assert.hpp>
2016-06-29 18:03:11 +10:00
using cruft::vk::fence;
2016-02-24 11:11:41 +11:00
///////////////////////////////////////////////////////////////////////////////
bool
fence::is_ready (const device &dev)
{
2017-09-08 17:11:35 +10:00
auto res = vkGetFenceStatus (dev.native (), native ());
2016-02-24 11:11:41 +11:00
error::try_code (res);
return res == VK_SUCCESS;
}
///////////////////////////////////////////////////////////////////////////////
void
fence::reset (const device &dev, fence *first, fence *last)
{
2016-06-29 18:03:11 +10:00
CHECK_LE (first, last);
2017-09-06 12:12:10 +10:00
cruft::vk::error::try_func (
2018-08-05 14:51:18 +10:00
vkResetFences, dev.native (), cruft::cast::lossless<uint32_t> (last - first), &first->native ()
2017-09-06 12:12:10 +10:00
);
2016-02-24 11:11:41 +11:00
}
//-----------------------------------------------------------------------------
void
fence::wait (const device &d, fence *first, fence *last, uint64_t timeout)
{
2016-06-29 18:03:11 +10:00
CHECK_LE (first, last);
2017-09-06 12:12:10 +10:00
cruft::vk::error::try_func (
2017-09-08 17:11:35 +10:00
vkWaitForFences,
2018-08-05 14:51:18 +10:00
d.native (), cruft::cast::lossless<uint32_t> (last - first), &first->native (), VK_FALSE, timeout
2017-09-06 12:12:10 +10:00
);
2016-02-24 11:11:41 +11:00
}
//-----------------------------------------------------------------------------
void
fence::wait_all (const device &d, fence *first, fence *last, uint64_t timeout)
{
2016-06-29 18:03:11 +10:00
CHECK_LE (first, last);
2017-09-06 12:12:10 +10:00
cruft::vk::error::try_func (
2017-09-08 17:11:35 +10:00
vkWaitForFences,
2018-08-05 14:51:18 +10:00
d.native (), cruft::cast::lossless<uint32_t> (last - first), &first->native (), VK_TRUE, timeout
2017-09-06 12:12:10 +10:00
);
2016-02-24 11:11:41 +11:00
}