MCPcopy Create free account
hub / github.com/KhronosGroup/glslang / ProcessArguments

Function ProcessArguments

StandAlone/StandAlone.cpp:557–1161  ·  view source on GitHub ↗

Do all command-line argument parsing. This includes building up the work-items to be processed later, and saving all the command-line options. Does not return (it exits) if command-line is fatally flawed.

Source from the content-addressed store, hash-verified

555// Does not return (it exits) if command-line is fatally flawed.
556//
557void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItems, int argc, char* argv[])
558{
559 for (int res = 0; res < glslang::EResCount; ++res)
560 baseBinding[res].fill(0);
561
562 ExecutableName = argv[0];
563 workItems.reserve(argc);
564
565 const auto bumpArg = [&]() {
566 if (argc > 0) {
567 argc--;
568 argv++;
569 }
570 };
571
572 // read a string directly attached to a single-letter option
573 const auto getStringOperand = [&](const char* desc) {
574 if (argv[0][2] == 0) {
575 printf("%s must immediately follow option (no spaces)\n", desc);
576 exit(EFailUsage);
577 }
578 return argv[0] + 2;
579 };
580
581 // read a number attached to a single-letter option
582 const auto getAttachedNumber = [&](const char* desc) {
583 int num = atoi(argv[0] + 2);
584 if (num == 0) {
585 printf("%s: expected attached non-0 number\n", desc);
586 exit(EFailUsage);
587 }
588 return num;
589 };
590
591 // minimum needed (without overriding something else) to target Vulkan SPIR-V
592 const auto setVulkanSpv = []() {
593 if (Client == glslang::EShClientNone)
594 ClientVersion = glslang::EShTargetVulkan_1_0;
595 Client = glslang::EShClientVulkan;
596 Options |= EOptionSpv;
597 Options |= EOptionVulkanRules;
598 Options |= EOptionLinkProgram;
599 };
600
601 // minimum needed (without overriding something else) to target OpenGL SPIR-V
602 const auto setOpenGlSpv = []() {
603 if (Client == glslang::EShClientNone)
604 ClientVersion = glslang::EShTargetOpenGL_450;
605 Client = glslang::EShClientOpenGL;
606 Options |= EOptionSpv;
607 Options |= EOptionLinkProgram;
608 // undo a -H default to Vulkan
609 Options &= ~EOptionVulkanRules;
610 };
611
612 const auto getUniformOverride = [getStringOperand]() {
613 const char *arg = getStringOperand("-u<name>:<location>");
614 const char *split = strchr(arg, ':');

Callers 1

mainFunction · 0.85

Calls 14

ErrorFunction · 0.85
ProcessBlockStorageFunction · 0.85
ProcessBindingBaseFunction · 0.85
usageFunction · 0.85
SetConfigFileFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
c_strMethod · 0.80
addDefMethod · 0.80
addTextMethod · 0.80

Tested by

no test coverage detected