5 #if defined(LUG_SYSTEM_ANDROID) 6 #include <android/asset_manager.h> 24 #if defined(LUG_SYSTEM_ANDROID) 29 LUG_LOG.error(
"Builder::ShaderModule: Can't open Android asset \"{}\"", filename);
36 LUG_LOG.error(
"Builder::ShaderModule: Android asset \"{}\" is empty", filename);
42 AAsset_read(asset, reinterpret_cast<char*>(
_data.data()),
_codeSize);
45 std::ifstream shaderFile(filename, std::ios::binary);
47 if (!shaderFile.good()) {
48 LUG_LOG.error(
"Builder::ShaderModule: Can't open file \"{}\"", filename);
52 shaderFile.seekg(0, shaderFile.end);
54 shaderFile.seekg(0, shaderFile.beg);
66 _codeSize = data.size() *
sizeof(uint32_t);
71 const VkShaderModuleCreateInfo createInfo{
72 VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
79 VkShaderModule vkShaderModule = VK_NULL_HANDLE;
80 VkResult result = vkCreateShaderModule(static_cast<VkDevice>(
_device), &createInfo,
nullptr, &vkShaderModule);
83 *returnResult = result;
86 if (result != VK_SUCCESS) {
96 std::unique_ptr<API::ShaderModule> shaderModule = std::make_unique<API::ShaderModule>();
97 return build(*shaderModule, returnResult) ? std::move(shaderModule) :
nullptr;
bool loadFromFile(const std::string &filename)
const API::Device & _device
std::vector< uint32_t > _data
static ANativeActivity * activity
bool build(API::ShaderModule &instance, VkResult *returnResult=nullptr)
ShaderModule(const API::Device &device)
void loadFromData(const std::vector< uint32_t > &data)