| 2667 | "needs to be a 3-component 32-bit int vector")))); |
| 2668 | |
| 2669 | CodeGenerator GetArrayedVariableCodeGenerator(const char* const built_in, |
| 2670 | const char* const execution_model, |
| 2671 | const char* const storage_class, |
| 2672 | const char* const data_type) { |
| 2673 | CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator(); |
| 2674 | |
| 2675 | generator.before_types_ = "OpDecorate %built_in_var BuiltIn "; |
| 2676 | generator.before_types_ += built_in; |
| 2677 | generator.before_types_ += "\n"; |
| 2678 | |
| 2679 | std::ostringstream after_types; |
| 2680 | after_types << "%built_in_array = OpTypeArray " << data_type << " %u32_3\n"; |
| 2681 | if (InitializerRequired(storage_class)) { |
| 2682 | after_types << "%built_in_array_null = OpConstantNull %built_in_array\n"; |
| 2683 | } |
| 2684 | |
| 2685 | after_types << "%built_in_ptr = OpTypePointer " << storage_class |
| 2686 | << " %built_in_array\n"; |
| 2687 | after_types << "%built_in_var = OpVariable %built_in_ptr " << storage_class; |
| 2688 | if (InitializerRequired(storage_class)) { |
| 2689 | after_types << " %built_in_array_null"; |
| 2690 | } |
| 2691 | after_types << "\n"; |
| 2692 | generator.after_types_ = after_types.str(); |
| 2693 | |
| 2694 | EntryPoint entry_point; |
| 2695 | entry_point.name = "main"; |
| 2696 | entry_point.execution_model = execution_model; |
| 2697 | entry_point.interfaces = "%built_in_var"; |
| 2698 | // Any kind of reference would do. |
| 2699 | entry_point.body = R"( |
| 2700 | %val = OpCopyObject %built_in_ptr %built_in_var |
| 2701 | )"; |
| 2702 | |
| 2703 | std::ostringstream execution_modes; |
| 2704 | if (0 == std::strcmp(execution_model, "Fragment")) { |
| 2705 | execution_modes << "OpExecutionMode %" << entry_point.name |
| 2706 | << " OriginUpperLeft\n"; |
| 2707 | if (0 == std::strcmp(built_in, "FragDepth")) { |
| 2708 | execution_modes << "OpExecutionMode %" << entry_point.name |
| 2709 | << " DepthReplacing\n"; |
| 2710 | } |
| 2711 | } |
| 2712 | if (0 == std::strcmp(execution_model, "Geometry")) { |
| 2713 | execution_modes << "OpExecutionMode %" << entry_point.name |
| 2714 | << " InputPoints\n"; |
| 2715 | execution_modes << "OpExecutionMode %" << entry_point.name |
| 2716 | << " OutputPoints\n"; |
| 2717 | } |
| 2718 | if (0 == std::strcmp(execution_model, "GLCompute") || |
| 2719 | 0 == std::strcmp(execution_model, "MeshEXT") || |
| 2720 | 0 == std::strcmp(execution_model, "MeshNV") || |
| 2721 | 0 == std::strcmp(execution_model, "MeshEXT") || |
| 2722 | 0 == std::strcmp(execution_model, "TaskNV")) { |
| 2723 | execution_modes << "OpExecutionMode %" << entry_point.name |
| 2724 | << " LocalSize 1 1 1\n"; |
| 2725 | } |
| 2726 | entry_point.execution_modes = execution_modes.str(); |
no test coverage detected