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

Cache shaders #588

Closed
kkaefer opened this issue Nov 11, 2014 · 15 comments
Closed

Cache shaders #588

kkaefer opened this issue Nov 11, 2014 · 15 comments
Labels
performance Speed, stability, CPU usage, memory usage, or power usage

Comments

@kkaefer
Copy link
Contributor

kkaefer commented Nov 11, 2014

We should use GL_ARB_get_program_binary and GL_OES_get_program_binary if available to cache the compiled shaders so a subsequent launch is a lot faster.

@kkaefer kkaefer added the performance Speed, stability, CPU usage, memory usage, or power usage label Nov 11, 2014
@ljbade
Copy link
Contributor

ljbade commented Nov 11, 2014

Good idea.

@ljbade
Copy link
Contributor

ljbade commented Nov 17, 2014

On Android we can save this to the cache dir, or on API 21+ we can use the code cache dir.

@ljbade
Copy link
Contributor

ljbade commented Nov 21, 2014

Will have a go at this on Linux tomorrow: https://github.com/mapbox/mapbox-gl-native/tree/cache-shaders

@ljbade
Copy link
Contributor

ljbade commented Nov 23, 2014

I have added shader binary saving and loading to Shader

It runs on my machine, but unfortunately my GL driver (Intel Haswell) uses Mesa which does not support program binaries yet. It always returns 0 binary length.

So can someone with a Linux machine and either an ATI or NVIDIA driver test this branch?

@incanus can you check my branch works on iOS and OSX. You will need to load the program binary extensions in your iOS code, same place as vertex array objects are loaded.

@ljbade
Copy link
Contributor

ljbade commented Nov 23, 2014

Once this gets merged into master I then need to add the extension loading to android-mason.

@ljbade
Copy link
Contributor

ljbade commented Nov 23, 2014

@kkaefer I just remembered that you are supposed to render some stuff before you retrieve the program binary so the compiler actually compiles all variants of the shader that are needed.

Is it possible to save the binary to disk during the Shader's destructor? That way we know we have done rendering with it.

@kkaefer
Copy link
Contributor Author

kkaefer commented Nov 24, 2014

Yeah, we could do the save on destruct method, so it's completely transparent to the application.

@ljbade
Copy link
Contributor

ljbade commented Nov 24, 2014

I had a problem when I experimented with save on destruct, is that it hanged on Linux for some reason. Haven't got to the bottom of the hang yet.

Plus have the problem that on Android where GL context is deleted before Map gets destroyed, so wouldn't be able to call the GL methods to save the shader.

@ljbade
Copy link
Contributor

ljbade commented Dec 1, 2014

OK, just got a NVIDIA GPU, will be able to test Linux now.

@ljbade
Copy link
Contributor

ljbade commented Dec 1, 2014

Seems to work fine on my NVIDIA GPU, except for the crash from #659

@ljbade
Copy link
Contributor

ljbade commented Dec 1, 2014

Do we have someone with an ATI GPU with support for GL_ARB_get_program_binary to test?

Also can someone implement needed code for iOS and OSX so this can be merged into master?

@ljbade
Copy link
Contributor

ljbade commented Dec 5, 2014

I am just going to merge instead of waiting.

Can someone hook up OSX and iOS please.

@ljbade
Copy link
Contributor

ljbade commented Dec 9, 2014

@incanus did you manage to hook up iOS?

@ljbade
Copy link
Contributor

ljbade commented Dec 22, 2014

Moving to cutting-room-floor/mapbox-gl-cocoa#76

@ljbade
Copy link
Contributor

ljbade commented Jan 27, 2015

We decided to remove this due to many issues with it. #778

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
performance Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

No branches or pull requests

3 participants