Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] Split layer type specific code in mbgl::Programs #13577

Merged
merged 1 commit into from
Jan 11, 2019

Conversation

pozdnyakov
Copy link
Contributor

@pozdnyakov pozdnyakov commented Dec 13, 2018

Programs code for a certain layer type is encapsulated within
a dedicated <layer type>Programs class, inherited from
the generic base LayerTypePrograms class.

mbgl::Programs::get<layer type>Programs() lazily initializes the
layer type-specific programs code using pointer to the base class,
which allows LTO to remove this code from binaries (if the corresponding
get<layer type>Programs() method can never be invoked).

Tagging #13276

@pozdnyakov pozdnyakov requested a review from kkaefer December 13, 2018 19:05
@pozdnyakov pozdnyakov force-pushed the mikhail_layer_programs branch from a292949 to d51b9c2 Compare December 14, 2018 10:50
@pozdnyakov pozdnyakov added Core The cross-platform C++ core, aka mbgl refactor labels Dec 18, 2018
@pozdnyakov pozdnyakov force-pushed the mikhail_layer_programs branch from e976ba6 to 25ea831 Compare December 18, 2018 15:41
property = std::make_unique<ProgramsType>(context, programParameters); \
} \
return static_cast<ProgramsType&>(*property); \
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to use as little macros as possible. While the macro is a bit shorter, writing out all functions verbatim doesn't look like it'd be too much code either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, will remove it

std::unique_ptr<LayerTypePrograms> fillPrograms;
std::unique_ptr<LayerTypePrograms> fillExtrusionPrograms;
std::unique_ptr<LayerTypePrograms> linePrograms;
std::unique_ptr<LayerTypePrograms> symbolPrograms;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need an abstract base class here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unique_ptr requires a destructor defined, so pointers to the concrete classes would prevent from LTO removing them from the binaries.

@pozdnyakov pozdnyakov force-pushed the mikhail_layer_programs branch from 25ea831 to 2743ef0 Compare January 7, 2019 16:31
@pozdnyakov
Copy link
Contributor Author

@kkaefer thanks for your comments! addressed in the latest patch

@pozdnyakov
Copy link
Contributor Author

@alexshalamov @tmpsantos Could you also take a look?

Progams code for a certain layer type is encapsulted within
a dedicated `<layer type>Programs` class, inherited from
the generic base `LayerTypePrograms` class.

`mbgl::Programs::get<layer type>Programs()` lazily initializes the
layer type-specific programs code using pointer to the base class,
which allows LTO to remove this code from binaries (if the corresponding
`get<layer type>Programs()` method can never be invoked).
@pozdnyakov pozdnyakov force-pushed the mikhail_layer_programs branch from 2743ef0 to 33a98b9 Compare January 10, 2019 16:33
Copy link
Contributor

@alexshalamov alexshalamov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @kkaefer what do you think?

@pozdnyakov pozdnyakov merged commit d37918c into master Jan 11, 2019
@pozdnyakov pozdnyakov deleted the mikhail_layer_programs branch January 11, 2019 14:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants