-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVulkanCompute.cpp
47 lines (39 loc) · 1.34 KB
/
VulkanCompute.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
/******************************************************************************
This file is part of the Newcastle Vulkan Tutorial Series
Author:Rich Davison
Contact:[email protected]
License: MIT (see LICENSE file at the top of the source tree)
*//////////////////////////////////////////////////////////////////////////////
#include "VulkanCompute.h"
#include "Assets.h"
using namespace NCL;
using namespace Rendering;
using namespace Vulkan;
VulkanCompute::VulkanCompute(vk::Device device, const std::string& filename) : localThreadSize{ 0,0,0 } {
char* data;
size_t dataSize = 0;
Assets::ReadBinaryFile(Assets::SHADERDIR + "VK/" + filename, &data, dataSize);
if (dataSize > 0) {
computeModule = device.createShaderModuleUnique(//vk::ShaderModuleCreateInfo(
{
.flags = {},
.codeSize = dataSize,
.pCode = (uint32_t*)data
}
//vk::ShaderModuleCreateFlags(), dataSize, (uint32_t*)data)
);
}
else {
std::cout << __FUNCTION__ << " Problem loading shader file " << filename << "!\n";
return;
}
info.stage = vk::ShaderStageFlagBits::eCompute;
info.module = *computeModule;
info.pName = "main";
AddReflectionData(dataSize, data, vk::ShaderStageFlagBits::eCompute);
BuildLayouts(device);
delete data;
}
void VulkanCompute::FillShaderStageCreateInfo(vk::ComputePipelineCreateInfo& pipeInfo) const {
pipeInfo.setStage(info);
}