MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / GetInMainCodeGenerator

Function GetInMainCodeGenerator

test/val/val_builtins_test.cpp:80–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80CodeGenerator GetInMainCodeGenerator(const char* const built_in,
81 const char* const execution_model,
82 const char* const storage_class,
83 const char* const capabilities,
84 const char* const extensions,
85 const char* const data_type) {
86 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
87
88 if (capabilities) {
89 generator.capabilities_ += capabilities;
90 }
91 if (extensions) {
92 generator.extensions_ += extensions;
93 }
94
95 generator.before_types_ = R"(OpDecorate %built_in_type Block
96 OpMemberDecorate %built_in_type 0 BuiltIn )";
97 generator.before_types_ += built_in;
98 generator.before_types_ += "\n";
99
100 if (strncmp(built_in, "TessLevel", 9) == 0) {
101 generator.before_types_ += "OpMemberDecorate %built_in_type 0 Patch\n";
102 }
103
104 std::ostringstream after_types;
105
106 after_types << "%built_in_type = OpTypeStruct " << data_type << "\n";
107 if (InitializerRequired(storage_class)) {
108 after_types << "%built_in_null = OpConstantNull %built_in_type\n";
109 }
110 after_types << "%built_in_ptr = OpTypePointer " << storage_class
111 << " %built_in_type\n";
112 after_types << "%built_in_var = OpVariable %built_in_ptr " << storage_class;
113 if (InitializerRequired(storage_class)) {
114 after_types << " %built_in_null";
115 }
116 after_types << "\n";
117 after_types << "%data_ptr = OpTypePointer " << storage_class << " "
118 << data_type << "\n";
119 generator.after_types_ = after_types.str();
120
121 EntryPoint entry_point;
122 entry_point.name = "main";
123 entry_point.execution_model = execution_model;
124 if (strncmp(storage_class, "Input", 5) == 0 ||
125 strncmp(storage_class, "Output", 6) == 0) {
126 entry_point.interfaces = "%built_in_var";
127 }
128
129 std::ostringstream execution_modes;
130 if (0 == std::strcmp(execution_model, "Fragment")) {
131 execution_modes << "OpExecutionMode %" << entry_point.name
132 << " OriginUpperLeft\n";
133 if (0 == std::strcmp(built_in, "FragDepth")) {
134 execution_modes << "OpExecutionMode %" << entry_point.name
135 << " DepthReplacing\n";
136 }
137 }

Callers 1

TEST_PFunction · 0.85

Calls 3

InitializerRequiredFunction · 0.85
strMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected