-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tracking and ability to clean up ShaderPrograms.
Also add expired VAO clean up to runtime cleanup code in ContextGarbageCollector.
- Loading branch information
Showing
6 changed files
with
284 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/DeleteShaderProgramsVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) 2008-2024 Bird Dog Games, Inc. | ||
* | ||
* This file is part of Ardor3D. | ||
* | ||
* Ardor3D is free software: you can redistribute it and/or modify it | ||
* under the terms of its license which may be found in the accompanying | ||
* LICENSE file or at <https://git.io/fjRmv>. | ||
*/ | ||
|
||
package com.ardor3d.scenegraph.visitor; | ||
|
||
import com.ardor3d.renderer.material.IShaderUtils; | ||
import com.ardor3d.scenegraph.Mesh; | ||
import com.ardor3d.scenegraph.Spatial; | ||
|
||
/** | ||
* <code>DeleteShaderProgramsVisitor</code> is a visitor that will clear all uploaded | ||
* shader programs associated with RenderMaterials in a given part of the scene graph. | ||
*/ | ||
public class DeleteShaderProgramsVisitor implements Visitor { | ||
final IShaderUtils _utils; | ||
|
||
public DeleteShaderProgramsVisitor(final IShaderUtils utils) { | ||
_utils = utils; | ||
} | ||
|
||
@Override | ||
public void visit(final Spatial spatial) { | ||
if (spatial instanceof Mesh mesh) { | ||
var material = mesh.getRenderMaterial(); | ||
if (material == null) return; | ||
material.getTechniques().forEach(technique -> | ||
technique.getPasses().forEach(pass -> | ||
pass.cleanProgram(_utils))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters