Can now configure Vulkan with JSON. ENJOY!
This commit is contained in:
parent
a996440c61
commit
883f683ce4
6 changed files with 96 additions and 15 deletions
|
|
@ -1,4 +1,40 @@
|
|||
#include <vk_initializers.h>
|
||||
#include <vulkan/vk_enum_string_helper.h>
|
||||
#include "trash_test.hpp"
|
||||
|
||||
nlohmann::json DATA = nlohmann::json::parse(R"(
|
||||
{
|
||||
"VkSemaphoreCreateInfo": {
|
||||
"draw": {
|
||||
"sType": 9
|
||||
}
|
||||
},
|
||||
"VkFenceCreateInfo": {
|
||||
"draw": {
|
||||
"sType": 8
|
||||
}
|
||||
},
|
||||
"VkImageViewCreateInfo": {
|
||||
"draw": {
|
||||
"sType": 15,
|
||||
"viewType": 1,
|
||||
"subresourceRange.baseMipLevel": 0,
|
||||
"subresourceRange.levelCount": 1,
|
||||
"subresourceRange.baseArrayLayer": 0,
|
||||
"subresourceRange.layerCount": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
)");
|
||||
|
||||
template<typename COMPONENT> COMPONENT load(nlohmann::json &data, const std::string& profile) {
|
||||
COMPONENT result{};
|
||||
auto& type_stuff = data[NameOf<COMPONENT>::name];
|
||||
auto& profile_data = type_stuff[profile];
|
||||
nlohmann::from_json(profile_data, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
VkCommandPoolCreateInfo vkinit::command_pool_create_info(uint32_t queueFamilyIndex,
|
||||
VkCommandPoolCreateFlags flags /*= 0*/)
|
||||
|
|
@ -27,19 +63,16 @@ VkCommandBufferAllocateInfo vkinit::command_buffer_allocate_info(
|
|||
|
||||
VkFenceCreateInfo vkinit::fence_create_info(VkFenceCreateFlags flags /*=0*/)
|
||||
{
|
||||
VkFenceCreateInfo info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
|
||||
info.pNext = nullptr;
|
||||
auto info = load<VkFenceCreateInfo>(DATA, "draw");
|
||||
info.flags = flags;
|
||||
return info;
|
||||
}
|
||||
|
||||
VkSemaphoreCreateInfo vkinit::semaphore_create_info(VkSemaphoreCreateFlags flags/*=0*/)
|
||||
{
|
||||
VkSemaphoreCreateInfo info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
|
||||
info.pNext = nullptr;
|
||||
auto info = load<VkSemaphoreCreateInfo>(DATA, "draw");
|
||||
info.flags = flags;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
@ -133,17 +166,10 @@ VkImageCreateInfo vkinit::image_create_info(VkFormat format, VkImageUsageFlags u
|
|||
|
||||
VkImageViewCreateInfo vkinit::imageview_create_info(VkFormat format, VkImage image, VkImageAspectFlags aspectFlags)
|
||||
{
|
||||
VkImageViewCreateInfo info{};
|
||||
info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||
info.pNext = nullptr;
|
||||
auto info = load<VkImageViewCreateInfo>(DATA, "draw");
|
||||
|
||||
info.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
||||
info.image = image;
|
||||
info.format = format;
|
||||
info.subresourceRange.baseMipLevel = 0;
|
||||
info.subresourceRange.levelCount = 1;
|
||||
info.subresourceRange.baseArrayLayer = 0;
|
||||
info.subresourceRange.layerCount = 1;
|
||||
info.subresourceRange.aspectMask = aspectFlags;
|
||||
|
||||
return info;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue