Page MenuHome

GPU: add mechanism for splitting up big gpu_shader_material.glsl file
ClosedPublic

Authored by Brecht Van Lommel (brecht) on Fri, Aug 23, 3:58 PM.

Details

Summary

Compiling this big file for every Eevee material is bad for performance, and
now that we are adding more nodes it gets worse. This patch adds a simple
mechanism to split up that file, and use only the parts used by shader nodes.

When a function is used by GPU_link, we detect which GLSL file it came from
and use it in GLSL code generation automatically.

This does not handle dependencies between GLSL files, so each file must be
self contained and not have conflicting function names.

Diff Detail

Repository
rB Blender

Event Timeline

I don't have really have more time to spend on this so wouldn't mind if @Clément Foucault (fclem) or @Omar Emara (OmarSquircleArt) can take over. Mainly I would like something in place for the new nodes from T68823: GSoC 2019 - Cycles/EEVEE Improvements to start using.

@Brecht Van Lommel (brecht) Should this be done first before landing the code for GSoC?

Regarding dependencies, the hashing code is used by the noise code, and the noise code is used by the musgrave code, does this mean all of those should be in the same file? The same goes for the voronoi and white noise code, which depends on the hashing code.

Add basic dependencies system.

It's not strictly required to do this before committing the nodes. But I would like to see it done soon after at least.

For dependencies, I updated the patch with some simple code for that.

@Brecht Van Lommel (brecht) Ok, I can work on this. How do you want me to take over?

The remaining works is moving code out of gpu_shader_material.glsl into smaller files, so any help with that is welcome.

If @Clément Foucault (fclem) is fine with this patch we can also just commit it and do remaining work in master.

Looks good to me.

source/blender/gpu/intern/gpu_codegen.c
1787

We could bypass dependencies if library is already in the set. Removing the need to do some more gset lookups.

This revision is now accepted and ready to land.Mon, Aug 26, 6:58 PM

@Brecht Van Lommel (brecht) Ok. I will do that as soon as this patch lands in master. Do you want multiple smaller patches or just one big patch?

Brecht Van Lommel (brecht) marked an inline comment as done.Mon, Aug 26, 7:12 PM