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>
|
|
|
|
#include <cruft/util/debug.hpp>
|
|
|
|
|
2017-05-26 16:30:48 +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
|
2017-09-08 17:11:54 +10:00
|
|
|
device::queue (uint32_t idx)
|
2017-09-05 17:20:17 +10:00
|
|
|
{
|
2017-09-08 17:11:54 +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-01-16 15:12:54 +11:00
|
|
|
auto err = vkFlushMappedMemoryRanges (native (), util::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-01-16 15:12:54 +11:00
|
|
|
auto err = vkInvalidateMappedMemoryRanges (native (), util::cast::lossless<uint32_t> (last - first), first);
|
2016-02-24 11:11:41 +11:00
|
|
|
error::try_code (err);
|
|
|
|
}
|
|
|
|
|