MALE SPEAKER: Are you ready?
SHANEE: Yeah.
MALE SPEAKER: Set?
SHANEE: Yep.
MALE SPEAKER: Go!
SHANEE: Hi, everyone.
I'm a programmer.
How many of you guys are programmers?
Hands, come on, hands!
Hm-- that's a good ratio.
So my presentation is a bit technical.
But they feel it's quite important.
It's about things which we do in our game code
and pretty much [INAUDIBLE] since we can optimize and do
better to improve it.
So I have seven points, "The Seven Sins of Android Game
Developers," and let's get into them.
So number one, Android mobile internal
is pretty much just like PC and console.
So many lessons we have learned, and they still apply.
So there is a lot of common knowledge out there,
and we should use it more in our game.
A lot of what's coming are examples.
So let's take this code, for example.
We have two methods.
They're pretty much the same, iterating an array.
But by one time, we are incrementing by 1,
and the other time, we are incrementing by 16.
So it's pretty much the same.
No tricks, right?
So what happens?
You'd expect for performance it would be exactly the same.
So I've put it into a benchmark.
And the results are quite astonishing.
When you look into the graph, you
see that it's just about five times
slower when you increment the data by 16 bytes at the time.
What's going on here?
So beyond the software, we also have our hardware.
We have our CPU and the cache.
And when you want to send data to be transformed in the cache,
it needs to be laid out in a way so it can read it.
If the cache doesn't have the data, that you get the cache
miss, and it needs to be copied into it.
So that can literally double or times 5 your performance.
And then the end lesson is that's when
you're making your code, you really
need to think about your data.
So make design for the many, not the one.
Always have a lot of physics objects, not just one.
Number three, thou shalt not abuse thy draw calls.
We want to make a huge army, a crowd, a forest, or just
a nice field of grass maybe.
And for doing that, we have a lot of draw calls.
But when we do it, we need to send a command to the GPU.
So we need to sync with another [INAUDIBLE].
We need hardware.
We communicate with the drivers, and always through CPU cycles.
And then we do it again, and again, and again.
And we're not really doing any good work.
To fix that, there's a technique called geometry instancing.
This is available from OpenGL ES 3.0.
So we have our meta data on one platform
and the per-instance data on another.
That's the big world view projection and the color.
And we draw a lot objects at once with just one draw call.
Next, do not decompress on the CPU.
We have PNG, and we have JPG, and WebP,
and we really want to use them to lower our upsize.
But then we need to decompress them
before we can copy them to the GPU.
So not only the decompression doesn't help us,
because it's for size again, we are also
wasting time on loading.
On the other hand, how I accelerate the textures
like ASTC or DXT can just be copied as is.
All you need to do is create a header and copy it.
So not only do you gain time on loading,
because you don't need to decompress
them, you're also gaining your size again.
Your antimemory is smaller.
And sometimes, it's even smaller than PNG can do.
It's [INAUDIBLE], but it's relatively good.
Number five, do not totally redundancy.
You'll have your shader and you have your uniforms.
And you need to do a glGetUniformLocation
my uniform name.
And this is relatively slow.
And if you're doing it on charcoal and not
on [INAUDIBLE], go to your code now and fix it.
Put it on [INAUDIBLE].
But what if we didn't need to do it?
What if we could always know where our uniforms are?
So with OpenGL ES 3.1, we can change the top shader
to the bottom one.
We always know where everything is.
This is deterministic.
Number six, do not dismiss cool new technology.
With Android Extension Pack, we have
compute shaders and [? distillation. ?]
We can use them for amazing levels of detail
or putting in our physics into GPU for a higher performance.
I have a video from ARM here.
This is showing a 3D ASTC texture
all in the GPU with compute shaders
doing the particle physics.
This is all under GPU, nothing else.
And you can expand it and use it for procedurally generated
geometry like terrain and foxholes.
How amazing is that?
Number seven, do not disrespect thy hardware.
Android is quite a new platform.
But if we look at the performance for the past four
years only, we can see the performance is more than
doubling every year.
And the chart is going to up and faster.
That's all.
[APPLAUSE]