Update shader bundling to be included in binary
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "Device.hpp"
|
||||
#include "Base/Utils.hpp"
|
||||
#include "Shader/Shaders.h"
|
||||
|
||||
namespace openVulkanoCpp::Vulkan
|
||||
{
|
||||
@@ -88,8 +89,27 @@ namespace openVulkanoCpp::Vulkan
|
||||
|
||||
vk::ShaderModule Device::CreateShaderModule(const std::string& filename) const
|
||||
{
|
||||
Array<char> buffer = Utils::ReadFile(filename);
|
||||
vk::ShaderModuleCreateInfo smci = { {}, buffer.Size(), reinterpret_cast<const uint32_t*>(buffer.Data()) };
|
||||
Array<char> buffer;
|
||||
void* data = nullptr;
|
||||
size_t size = 0;
|
||||
if (Utils::StartsWith(filename, "Shader/"))
|
||||
{
|
||||
for(uint32_t i = 0; i < fileTableSize; i++)
|
||||
{
|
||||
if (Utils::EndsWith(filename, fileTable[i].entryName))
|
||||
{
|
||||
data = const_cast<unsigned char*>(fileTable[i].data);
|
||||
size = fileTable[i].size;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!data)
|
||||
{
|
||||
buffer = Utils::ReadFile(filename);
|
||||
size = buffer.Size();
|
||||
data = buffer.Data();
|
||||
}
|
||||
vk::ShaderModuleCreateInfo smci = {{}, size, static_cast<const uint32_t*>(data) };
|
||||
return CreateShaderModule(smci);
|
||||
}
|
||||
|
||||
@@ -217,4 +237,4 @@ namespace openVulkanoCpp::Vulkan
|
||||
device.destroyCommandPool(graphicsCommandPool);
|
||||
//TODO fill
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user