| 590 | } |
| 591 | |
| 592 | void UpdateModuleLibrary(List<CompileUnit> & units, SpireDiagnosticSink * sink) |
| 593 | { |
| 594 | Spire::Compiler::CompileResult result; |
| 595 | compiler->Compile(result, *compileContext.Last(), units, Options); |
| 596 | for (auto & shader : compileContext.Last()->Symbols.Shaders) |
| 597 | { |
| 598 | if (!states.Last().modules.ContainsKey(shader.Key)) |
| 599 | { |
| 600 | RefPtr<SpireModule> newModule = new SpireModule(); |
| 601 | auto & meta = *newModule; |
| 602 | meta.Id = SpireModule::IdAllocator++; |
| 603 | meta.Name = shader.Key; |
| 604 | int offset = 0; |
| 605 | for (auto attrib : shader.Value->SyntaxNode->GetModifiersOfType<SimpleAttribute>()) |
| 606 | meta.Attribs[attrib->Key] = attrib->Value.Content; |
| 607 | for (auto & comp : shader.Value->Components) |
| 608 | { |
| 609 | if (comp.Value->Implementations.Count() != 1) |
| 610 | continue; |
| 611 | auto impl = comp.Value->Implementations.First(); |
| 612 | if (!impl->SyntaxNode->IsRequire() && !impl->SyntaxNode->IsParam()) |
| 613 | continue; |
| 614 | ComponentMetaData compMeta; |
| 615 | compMeta.Name = comp.Key; |
| 616 | compMeta.Type = comp.Value->Type->DataType; |
| 617 | compMeta.TypeName = compMeta.Type->ToString(); |
| 618 | if (auto specialize = impl->SyntaxNode->FindSpecializeModifier()) |
| 619 | { |
| 620 | for (auto val : specialize->Values) |
| 621 | { |
| 622 | compMeta.Values.Add(dynamic_cast<ConstantExpressionSyntaxNode*>(val.Ptr())->IntValue); |
| 623 | } |
| 624 | compMeta.IsSpecialize = true; |
| 625 | } |
| 626 | if (compMeta.Type->GetBindableResourceType() == BindableResourceType::NonBindable) |
| 627 | { |
| 628 | compMeta.Alignment = (int)GetTypeAlignment(compMeta.Type.Ptr(), LayoutRule::Std140); |
| 629 | compMeta.Size = (int)GetTypeSize(compMeta.Type.Ptr(), LayoutRule::Std140); |
| 630 | offset = RoundToAlignment(offset, compMeta.Alignment); |
| 631 | compMeta.Offset = offset; |
| 632 | offset += compMeta.Size; |
| 633 | } |
| 634 | if (impl->SyntaxNode->IsRequire()) |
| 635 | meta.Requirements.Add(compMeta); |
| 636 | else |
| 637 | meta.Parameters.Add(compMeta); |
| 638 | } |
| 639 | states.Last().modules.Add(shader.Key, newModule); |
| 640 | } |
| 641 | } |
| 642 | if (sink) |
| 643 | { |
| 644 | sink->diagnostics.AddRange(result.sink.diagnostics); |
| 645 | sink->errorCount += result.GetErrorCount(); |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | int LoadModuleSource(CoreLib::String src, CoreLib::String fileName, SpireDiagnosticSink* sink) |
nothing calls this directly
no test coverage detected