@@ -201,42 +201,33 @@ class FunkinShaderSourceAssembler extends FlxRuntimeShader.FlxShaderSourceAssemb
201201 super (funkinParent = parent );
202202 }
203203
204- override function assembleSource (source : String , ? pragmas : Map <String , String >, ? extensions : Map <String , String >,
205- ? version : String , isVertex : Bool , useCompatibility : Bool = true , precisionHint : ShaderPrecision = FULL ): String
204+ override function __appendIncludes (source : String , isVertex : Bool , ? includedKeys : Map <String , Bool >): String
206205 {
207- if (version == null ) version = Flags . DEFAULT_GLSL_VERSION ;
206+ if (includedKeys == null ) includedKeys = [] ;
208207
209- if (source == null ) {
210- // There's nothing to assemble with, but just return it with a prefix instead anyway.
211- var dataVersion = GLSLSourceAssembler .__getVersion (version );
212- return __appendPrefix (null , dataVersion .versionNumber , dataVersion .versionProfile , extensions , isVertex , precisionHint );
213- }
208+ source = GLSLSourceAssembler .__getIncludeFinder ().map (source , (regex : EReg ) ->
209+ {
210+ var key = regex .matched (1 );
211+ if (includedKeys .get (key )) return ' /*Recursive include $key */ \n ' ;
214212
215- if (pragmas != null ) {
216- source = GLSLSourceAssembler .__getPragmaFinder ().map (source , (glPragmaFinder : EReg ) -> {
217- var pragma = glPragmaFinder .matched (1 );
218- return pragmas .exists (pragma ) ? ' /*pragma $pragma */ \n ' + pragmas .get (pragma ) + ' \n ' : ' pragma $pragma ' ;
219- });
220- }
213+ var include = __getIncludeSource (key , isVertex );
214+ if (include == null ) return ' /*Unknown include $key */ \n ' ;
221215
222- function includeERegCallback (finder : EReg ) {
223- var include = finder .matched (1 );
224- var included = __getIncludeSource (include , isVertex );
225- return included != null ? ' /*include $include */ \n ' + included : ' /*Unknown include $include */ \n ' ;
226- }
216+ includedKeys .set (key , true );
217+ return ' /*include $key */ \n ' + __appendIncludes (include , isVertex , includedKeys );
218+ });
227219
228- source = GLSLSourceAssembler .__getIncludeFinder ().map (source , includeERegCallback );
229- source = __getImportFinder ().map (source , includeERegCallback );
220+ return __getImportFinder ().map (source , (regex : EReg ) ->
221+ {
222+ var key = regex .matched (1 );
223+ if (includedKeys .get (key )) return ' /*Recursive import $key */ \n ' ;
230224
231- var data = GLSLSourceAssembler .__getSource (source , version );
232- extensions = __buildExtensions (GLSLSourceAssembler .__getExtensions (source , extensions == null ? new Map () : extensions .copy ()),
233- data .versionNumber , data .versionProfile , isVertex );
234-
235- if (useCompatibility ) {
236- data .source = __applyCompatibility (data .source , data .versionNumber , data .versionProfile , isVertex );
237- }
225+ var include = __getIncludeSource (key , isVertex );
226+ if (include == null ) return ' /*Unknown import $key */ \n ' ;
238227
239- return __appendPrefix (data .source , data .versionNumber , data .versionProfile , extensions , isVertex , precisionHint );
228+ includedKeys .set (key , true );
229+ return ' /*import $key */ \n ' + __appendIncludes (include , isVertex , includedKeys );
230+ });
240231 }
241232
242233 override function __getIncludeSource (include : String , fromVertex : Bool ): Null <String > {
0 commit comments