GLSL: factor out the emission of struct members.
This will be needed for emitting UBO and SSBO interface blocks. Bug: tint:1223 Change-Id: I1cdc75b67a4fe612dcf8094a7d73b8bf1f85f40a Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67242 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
parent
8fca34546b
commit
38ed53ce8f
|
@ -2450,7 +2450,13 @@ bool GeneratorImpl::EmitTypeAndName(std::ostream& out,
|
|||
bool GeneratorImpl::EmitStructType(TextBuffer* b, const sem::Struct* str) {
|
||||
auto storage_class_uses = str->StorageClassUsage();
|
||||
line(b) << "struct " << StructName(str) << " {";
|
||||
{
|
||||
EmitStructMembers(b, str);
|
||||
line(b) << "};";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GeneratorImpl::EmitStructMembers(TextBuffer* b, const sem::Struct* str) {
|
||||
ScopedIndent si(b);
|
||||
for (auto* mem : str->Members()) {
|
||||
auto name = builder_.Symbols().NameFor(mem->Name());
|
||||
|
@ -2482,10 +2488,6 @@ bool GeneratorImpl::EmitStructType(TextBuffer* b, const sem::Struct* str) {
|
|||
}
|
||||
out << post << ";";
|
||||
}
|
||||
}
|
||||
|
||||
line(b) << "};";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -322,6 +322,11 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// @param ty the struct to generate
|
||||
/// @returns true if the struct is emitted
|
||||
bool EmitStructType(TextBuffer* buffer, const sem::Struct* ty);
|
||||
/// Handles generating the members of a structure
|
||||
/// @param buffer the text buffer that the struct members will be written to
|
||||
/// @param ty the struct to generate
|
||||
/// @returns true if the struct members are emitted
|
||||
bool EmitStructMembers(TextBuffer* buffer, const sem::Struct* ty);
|
||||
/// Handles a unary op expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the expression to emit
|
||||
|
|
Loading…
Reference in New Issue