| 4930 | } |
| 4931 | |
| 4932 | virtual CompiledShaderSource GenerateShaderWorld(CompileResult & result, SymbolTable * /*symbols*/, CompiledWorld * shaderWorld, Dictionary<String, ImportOperatorHandler*>& opHandlers, Dictionary<String, ExportOperatorHandler*>& exportHandlers) override |
| 4933 | { |
| 4934 | |
| 4935 | currentExecutionModel = ExecutionModel::Invalid; |
| 4936 | if (shaderWorld->ExportOperator.Content == "fragmentExport") |
| 4937 | currentExecutionModel = ExecutionModel::Fragment; |
| 4938 | else if (shaderWorld->BackendParameters.ContainsKey("vertex")) |
| 4939 | currentExecutionModel = ExecutionModel::Vertex; |
| 4940 | else if (shaderWorld->ExportOperator.Content == "bufferExport") |
| 4941 | currentExecutionModel = ExecutionModel::GLCompute; |
| 4942 | |
| 4943 | CompiledFunction mainFunction; |
| 4944 | mainFunction.Name = "main"; |
| 4945 | mainFunction.ReturnType = nullptr; |
| 4946 | mainFunction.Code = shaderWorld->Code; |
| 4947 | |
| 4948 | SpirvModule spvModule; |
| 4949 | spvModule.Initiate(currentExecutionModel, shaderWorld); |
| 4950 | spvModule.GenerateFunctionDeclaration(&mainFunction); |
| 4951 | |
| 4952 | for (auto funcName : shaderWorld->ReferencedFunctions) |
| 4953 | for(auto & func : result.Program->Functions) |
| 4954 | if (funcName == func->Name) |
| 4955 | spvModule.GenerateFunctionDeclaration(func.Ptr()); |
| 4956 | |
| 4957 | for (auto funcName : shaderWorld->ReferencedFunctions) |
| 4958 | for (auto & func : result.Program->Functions) |
| 4959 | if (funcName == func->Name) |
| 4960 | spvModule.GenerateFunctionDefinition(func.Ptr()); |
| 4961 | |
| 4962 | for (auto & inputBlock : shaderWorld->WorldInputs) |
| 4963 | { |
| 4964 | auto block = inputBlock.Value.Block; |
| 4965 | if (!block->UserWorlds.Contains(shaderWorld->WorldName)) |
| 4966 | continue; |
| 4967 | String impOpName = inputBlock.Value.ImportOperator.Name.Content; |
| 4968 | |
| 4969 | if (impOpName == "standardImport") |
| 4970 | { |
| 4971 | List<RefPtr<ILType>> memberTypes; |
| 4972 | List<String> memberNames; |
| 4973 | for (auto & ent : block->Entries) |
| 4974 | { |
| 4975 | memberTypes.Add(ent.Value.Type); |
| 4976 | memberNames.Add(ent.Value.Name); |
| 4977 | } |
| 4978 | spvModule.GenerateInterfaceForStructVariable( |
| 4979 | block->Name, |
| 4980 | "blk"+block->Name, |
| 4981 | memberTypes, |
| 4982 | memberNames, |
| 4983 | 0, |
| 4984 | StorageClass::Input, |
| 4985 | 0 |
| 4986 | ); |
| 4987 | } |
| 4988 | |
| 4989 | else if (impOpName == "vertexImport") |
nothing calls this directly
no test coverage detected