Updated to include and work with cpp header shaders

This commit is contained in:
Alejandro Saucedo 2020-08-23 13:51:26 +01:00
parent bb90806d79
commit 8b07c9b39c
2 changed files with 21 additions and 2 deletions

View file

@ -1,6 +1,8 @@
#ifndef OPMULT_CPP
#define OPMULT_CPP
#include <fstream>
#include "Tensor.hpp"
#include <shaders/opmult.hpp>
@ -98,9 +100,26 @@ OpMult<tX, tY, tZ>::init(std::vector<std::shared_ptr<Tensor>> tensors)
this->mDevice,
this->mCommandBuffer);
#if RELEASE
std::vector<char> shaderFileData(
shader_data::shaders_glsl_opmult_comp_spv,
shader_data::shaders_glsl_opmult_comp_spv + shader_data::shaders_glsl_opmult_comp_spv_len);
shader_data::shaders_glsl_opmult_comp_spv + kp::shader_data::shaders_glsl_opmult_comp_spv_len);
#else
// TODO: Move to utility function
std::string shaderFilePath = "shaders/glsl/opmult.comp.spv";
std::ifstream fileStream(shaderFilePath,
std::ios::binary | std::ios::in | std::ios::ate);
size_t shaderFileSize = fileStream.tellg();
fileStream.seekg(0, std::ios::beg);
char* shaderDataRaw = new char[shaderFileSize];
fileStream.read(shaderDataRaw, shaderFileSize);
fileStream.close();
std::vector<char> shaderFileData(shaderDataRaw, shaderDataRaw + shaderFileSize);
#endif
this->mAlgorithm->init(shaderFileData, tensors);
}

View file

@ -1,6 +1,6 @@
// Defining OPMULT_H to ensure cpp class doesn't reimport
#pragma once
#define OPMULT_HPP
#pragma once
#include <vulkan/vulkan.h>
#include <vulkan/vulkan.hpp>