libcruft-vk/shader_module.cpp

51 lines
1.3 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:
2017-09-10 13:54:27 +10:00
* 2016-2017, Danny Robson <danny@nerdcruft.net>
2016-02-26 13:39:01 +11:00
*/
2016-02-24 11:11:41 +11:00
#include "./shader_module.hpp"
2017-09-10 13:54:27 +10:00
#include "./device.hpp"
#include <cruft/util/io.hpp>
using cruft::vk::shader_module;
///////////////////////////////////////////////////////////////////////////////
struct cruft::vk::shader_module::cookie : public create_t {
public:
cookie (std::filesystem::path const &src):
2017-09-10 13:54:27 +10:00
create_t {},
2018-08-05 14:51:18 +10:00
m_bytes (cruft::slurp<uint32_t> (src))
2017-09-10 13:54:27 +10:00
{
CHECK_MOD (m_bytes.size (), 4);
sType = cruft::vk::structure_type_v<VkShaderModuleCreateInfo>;
codeSize = m_bytes.size ();
pCode = reinterpret_cast<const uint32_t*> (m_bytes.data ());
}
private:
2018-05-03 21:25:07 +10:00
std::vector<uint32_t> m_bytes;
2017-09-10 13:54:27 +10:00
};
///////////////////////////////////////////////////////////////////////////////
shader_module::shader_module (
device &owner,
std::filesystem::path const &src
):
2017-09-10 13:54:27 +10:00
shader_module (owner, cookie (src))
{ ; }
//-----------------------------------------------------------------------------
shader_module::shader_module (device &owner, const cookie &info):
owned (owner, &info, nullptr)
{ ; }