-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkslicer_def.cpp
72 lines (61 loc) · 1.99 KB
/
kslicer_def.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "kslicer.h"
#include <array>
static std::array<std::string,7> POSSIBLE_KERNEL_NAMES = {"kernel_", "kernel1D_", "kernel2D_", "kernel3D_", "kernelBE1D_", "kernelBE2D_", "kernelBE3D_"};
static std::array<std::string,8> POSSIBLE_IMAGE_NAMES = {"Texture1D", "Texture2D", "Texture3D", "TextureCube", "Image1D", "Image2D", "Image3D", "ImageCube"};
bool kslicer::MainClassInfo::IsKernel(const std::string& a_funcName) const
{
for(const auto& name : POSSIBLE_KERNEL_NAMES)
if(a_funcName.find(name) != std::string::npos)
return true;
return false;
}
std::string kslicer::MainClassInfo::RemoveKernelPrefix(const std::string& a_funcName) const
{
std::string name = a_funcName;
for(const auto& namePossible : POSSIBLE_KERNEL_NAMES)
if(ReplaceFirst(name, namePossible, ""))
return name;
return a_funcName;
}
uint32_t kslicer::IPV_Pattern::GetKernelDim(const kslicer::KernelInfo& a_kernel) const
{
const std::string& a_funcName = a_kernel.name;
auto pos1 = a_funcName.find("1D_");
auto pos2 = a_funcName.find("2D_");
auto pos3 = a_funcName.find("3D_");
if(pos1 != std::string::npos )
return 1;
else if(pos2 != std::string::npos)
return 2;
else if(pos3 != std::string::npos)
return 3;
else
return 0;
}
bool kslicer::IsTextureContainer(const std::string& a_typeName)
{
for(const auto& name : POSSIBLE_IMAGE_NAMES)
if(a_typeName == name)
return true;
return false;
}
bool kslicer::IsSamplerTypeName(const std::string& a_typeName)
{
if(a_typeName == "struct Sampler")
return true;
auto posOfXX = a_typeName.find_last_of("::");
auto name2 = a_typeName.substr(posOfXX+1);
if(name2 == "Sampler")
return true;
return false;
}
bool kslicer::IsCombinedImageSamplerTypeName(const std::string& a_typeName)
{
if(a_typeName == "struct ICombinedImageSampler")
return true;
auto posOfXX = a_typeName.find_last_of("::");
auto name2 = a_typeName.substr(posOfXX+1);
if(name2 == "ICombinedImageSampler")
return true;
return false;
}