libcruft-vk/device.cpp

59 lines
1.5 KiB
C++
Raw 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 "./device.hpp"
#include "./physical_device.hpp"
2017-09-05 17:20:17 +10:00
#include "./queue.hpp"
2016-02-24 11:11:41 +11:00
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::device;
2016-02-24 11:11:41 +11:00
///////////////////////////////////////////////////////////////////////////////
device::device (const physical_device &phys,
const VkDeviceCreateInfo &info):
2017-09-05 17:20:17 +10:00
descendant (phys, &info, nullptr)
2016-02-24 11:11:41 +11:00
{ ; }
2017-09-05 17:20:17 +10:00
///////////////////////////////////////////////////////////////////////////////
cruft::vk::queue
device::queue (uint32_t idx)
2017-09-05 17:20:17 +10:00
{
return ::cruft::vk::queue (*this, idx, 0);
2017-09-05 17:20:17 +10:00
}
2016-02-24 11:11:41 +11:00
///////////////////////////////////////////////////////////////////////////////
void
device::flush (const VkMappedMemoryRange *first,
const VkMappedMemoryRange *last)
{
2016-06-29 18:03:11 +10:00
CHECK_LE (first, last);
2018-08-05 14:51:18 +10:00
auto err = vkFlushMappedMemoryRanges (native (), cruft::cast::lossless<uint32_t> (last - first), first);
2016-02-24 11:11:41 +11:00
error::try_code (err);
}
//-----------------------------------------------------------------------------
void
device::invalidate (const VkMappedMemoryRange *first,
const VkMappedMemoryRange *last)
{
2016-06-29 18:03:11 +10:00
CHECK_LE (first, last);
2018-08-05 14:51:18 +10:00
auto err = vkInvalidateMappedMemoryRanges (native (), cruft::cast::lossless<uint32_t> (last - first), first);
2016-02-24 11:11:41 +11:00
error::try_code (err);
}