-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipeline.cpp
52 lines (34 loc) · 1.06 KB
/
pipeline.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "pipeline.hpp"
#include<fstream>
#include<iostream>
#include<stdexcept>
using namespace std;
namespace Vulketa
{
Pipeline::Pipeline(const string& vertFile, const string& fragFile)
{
createGraphicsPipeline(vertFile, fragFile);
}
vector<char> Pipeline::readFile(const string& filePath)
{
// create the file with bit flags for binary files
ifstream file{ filePath, ios::ate | ios::binary };
if (!file.is_open())
throw runtime_error("failed to open file " + filePath);
size_t fileSize = static_cast<size_t>(file.tellg());
vector<char> buffer(fileSize);
// Start reading from the start
file.seekg(0);
// Transfer all to the buffer
file.read(buffer.data(), fileSize);
file.close();
return buffer;
}
void Pipeline::createGraphicsPipeline(const string& vertFile, const string& fragFile)
{
vector<char> vertCode = readFile(vertFile);
vector<char> fragCode = readFile(fragFile);
cout << "Vertex Shader SPIR-V length " << vertCode.size() << endl;
cout << "Fragment Shaser SPIR-V length " << fragCode.size() << endl;
}
}