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

Function GetInFunctionCodeGenerator

test/val/val_builtins_test.cpp:247–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247CodeGenerator GetInFunctionCodeGenerator(const char* const built_in,
248 const char* const execution_model,
249 const char* const storage_class,
250 const char* const capabilities,
251 const char* const extensions,
252 const char* const data_type) {
253 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
254
255 if (capabilities) {
256 generator.capabilities_ += capabilities;
257 }
258 if (extensions) {
259 generator.extensions_ += extensions;
260 }
261
262 generator.before_types_ = R"(OpDecorate %built_in_type Block
263 OpMemberDecorate %built_in_type 0 BuiltIn )";
264 generator.before_types_ += built_in;
265 generator.before_types_ += "\n";
266
267 if (strncmp(built_in, "TessLevel", 9) == 0) {
268 generator.before_types_ += "OpMemberDecorate %built_in_type 0 Patch\n";
269 }
270
271 std::ostringstream after_types;
272 after_types << "%built_in_type = OpTypeStruct " << data_type << "\n";
273 if (InitializerRequired(storage_class)) {
274 after_types << "%built_in_null = OpConstantNull %built_in_type\n";
275 }
276 after_types << "%built_in_ptr = OpTypePointer " << storage_class
277 << " %built_in_type\n";
278 after_types << "%built_in_var = OpVariable %built_in_ptr " << storage_class;
279 if (InitializerRequired(storage_class)) {
280 after_types << " %built_in_null";
281 }
282 after_types << "\n";
283 after_types << "%data_ptr = OpTypePointer " << storage_class << " "
284 << data_type << "\n";
285 generator.after_types_ = after_types.str();
286
287 EntryPoint entry_point;
288 entry_point.name = "main";
289 entry_point.execution_model = execution_model;
290 if (strncmp(storage_class, "Input", 5) == 0 ||
291 strncmp(storage_class, "Output", 6) == 0) {
292 entry_point.interfaces = "%built_in_var";
293 }
294
295 std::ostringstream execution_modes;
296 if (0 == std::strcmp(execution_model, "Fragment")) {
297 execution_modes << "OpExecutionMode %" << entry_point.name
298 << " OriginUpperLeft\n";
299 if (0 == std::strcmp(built_in, "FragDepth")) {
300 execution_modes << "OpExecutionMode %" << entry_point.name
301 << " DepthReplacing\n";
302 }
303 }
304 if (0 == std::strcmp(execution_model, "Geometry")) {

Callers 1

TEST_PFunction · 0.85

Calls 3

InitializerRequiredFunction · 0.85
strMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected