New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VideoCommon: Cache native vertex formats #463
Conversation
| @@ -38,6 +38,7 @@ namespace VertexLoaderManager | |||
| { | |||
|
|
|||
| static VertexLoaderMap g_VertexLoaderMap; | |||
| std::map<PortableVertexDeclaration, NativeVertexFormat*> g_native_vertex_cache; | |||
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
galop1n's comments are copied from: degasus@6b42af2 |
| @@ -55,6 +56,11 @@ void Shutdown() | |||
| delete p.second; | |||
| } | |||
| g_VertexLoaderMap.clear(); | |||
| for (auto& v :g_native_vertex_cache) | |||
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
updated to use unique_ptr |
|
updated again to work around vs issue which doesn't know about std::map::emplace_hint |
| @@ -20,6 +23,8 @@ namespace VertexLoaderManager | |||
|
|
|||
| // For debugging | |||
| void AppendListToString(std::string *dest); | |||
|
|
|||
| extern std::map<PortableVertexDeclaration, std::unique_ptr<NativeVertexFormat> > g_native_vertex_cache; | |||
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
Updated with a Get* Function instead of a global |
|
LGTM. |
| @@ -131,6 +135,18 @@ int GetVertexSize(int vtx_attr_group) | |||
| return RefreshLoader(vtx_attr_group)->GetVertexSize(); | |||
| } | |||
|
|
|||
| NativeVertexFormat *GetNativeVertexFormat(const PortableVertexDeclaration& format, u32 components) { | |||
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
@JMC47 care for some performance testing? |
|
I'm guessing higher polygon games would be more affected, right? I tried out both Galaxy games and was unable to determine a difference in speed. Maybe MaJoR could try out Last Story and see if that beast of a game is affected. |
|
The amount of primitives doesn't affect this change. It is only affected if a game engine uses lots of different vertex formats alternatingly which only differs in vertex attribute type. |
|
The game i made the optim first was Donkey Kong ( won 30% of flush ), you On Fri, Jul 4, 2014 at 2:02 PM, Markus Wick notifications@github.com
|
|
I haven't seen any win of flushes (I haven't tried Donkey Kong), but I saw a lot of redundant vertex formats, so imo it's still better for the driver through. -30% of flushes is a nice improvment :) |
|
|
||
| namespace VertexLoaderManager | ||
| { | ||
|
|
||
| static VertexLoaderMap g_VertexLoaderMap; | ||
| static NativeVertexLoaderMap g_native_vertex_map; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
Apart from the two coding style issues, LGTM. |
We are used to have a 1:1 mapping of GX vertex formats and the native (OGL + D3D) ones, but there are by far more GX ones. This new cache maps them directly so that we don't flush on GX vertex format changes as long as the native one doesn't change. The idea is stolen from galop1n.
|
ready for merge |
|
I didn't notice any breakage while testing, so it looks good to me. If someone could actually get some framerate comparisons from DKCR, that'd be great for the progress report. |
VideoCommon: Cache native vertex formats
|
it will change nothing, it was not the optim i was talking about ( On Sun, Jul 6, 2014 at 12:21 PM, JMC47 notifications@github.com wrote:
|
|
Ok, thanks for explanation. |
|
@galop1n It's both. So we likely hit this code less often: https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/VideoCommon/VertexLoader.cpp#L822 |
We are used to have a 1:1 mapping of GX vertex formats and the native (OGL + D3D) ones, but there are by far more GX ones.
This new cache maps them directly so that we don't flush on GX vertex format changes as long as the native one doesn't change.
The idea is stolen from galop1n.