-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkslicer_def.cpp
More file actions
114 lines (100 loc) · 3.42 KB
/
kslicer_def.cpp
File metadata and controls
114 lines (100 loc) · 3.42 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#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;
}
kslicer::PATTERN_TP kslicer::MainClassInfo::PatternByKernelName(const std::string& a_kernelName)
{
if(a_kernelName.find("kernel_") == 0)
return PATTERN_TP::PATTERN_RTV;
else
return PATTERN_TP::PATTERN_IPV;
}
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::MainClassInfo::GetKernelDim(const kslicer::KernelInfo& a_kernel) const
{
const std::string& a_funcName = a_kernel.name;
if(a_kernel.pattern == kslicer::PATTERN_TP::PATTERN_IPV)
{
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;
}
else if (a_kernel.pattern == kslicer::PATTERN_TP::PATTERN_RTV)
{
return uint32_t(GetKernelTIDArgs(a_kernel).size());
}
return 1;
}
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;
}
bool kslicer::IsMatrixTypeName(const std::string& a_typeName)
{
if(a_typeName == "float2x2" || a_typeName == "double2x2")
return true;
else if(a_typeName == "float3x3" || a_typeName == "double3x3")
return true;
else if(a_typeName == "float4x4" || a_typeName == "double4x4")
return true;
else
return false;
}
kslicer::DATA_KIND kslicer::GetContainerTypeDataKind(const std::string& a_typeName)
{
kslicer::DATA_KIND kind = kslicer::DATA_KIND::KIND_UNKNOWN;
if(a_typeName == "Texture2D" || a_typeName == "Image2D")
kind = kslicer::DATA_KIND::KIND_TEXTURE;
else if(a_typeName == "vector" || a_typeName == "std::vector")
kind = kslicer::DATA_KIND::KIND_VECTOR;
else if(a_typeName == "unordered_map" || a_typeName == "std::unordered_map")
kind = kslicer::DATA_KIND::KIND_HASH_TABLE;
else if((a_typeName == "shared_ptr" || a_typeName == "std::shared_ptr") && kslicer::IsAccelStruct(a_typeName))
kind = kslicer::DATA_KIND::KIND_ACCEL_STRUCT;
return kind;
}