From c01a4ad712cfa2d1f8746daf161d9052c8acfccd Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 15 Mar 2023 03:26:30 +0100 Subject: Fix ShaderProgram ownership bug, introduced in commit 67a723477ecd818fbc5859fe20ee536a3b4efae5 (reverting and clarifying) All Graph ShaderPrograms used are owned by RegionRenderer, not RenderState nor [GL]Region*, hence [GL]Region* shall only nullify the resources but not destroy the shader currently in use. One RegionRenderer maybe used for multuple Regions. --- .../jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java | 17 ++++------------- .../jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java | 16 +++------------- .../jogamp/graph/curve/opengl/VBORegionSPES2.java | 11 ++--------- 3 files changed, 9 insertions(+), 35 deletions(-) (limited to 'src/jogl/classes/jogamp/graph/curve') diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java index c09e75b53..bc87b3faa 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java @@ -40,6 +40,7 @@ import com.jogamp.opengl.GLUniformData; import jogamp.graph.curve.opengl.shader.AttributeNames; import jogamp.graph.curve.opengl.shader.UniformNames; +import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.RenderState; @@ -322,7 +323,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion { /** *

* Since multiple {@link Region}s may share one - * {@link ShaderProgram}, the uniform data must always be updated. + * {@link ShaderProgram} managed and owned by {@link RegionRendered}, the uniform data must always be updated. *

* * @param gl @@ -628,18 +629,6 @@ public final class VBORegion2PMSAAES2 extends GLRegion { gca_VerticesAttr.enableBuffer(gl, false); } - @Override - protected void clearShaderImpl(final GL2ES2 gl) { - if( null != spPass1 ) { - spPass1.destroy(gl); - spPass1 = null; - } - if( null != spPass2 ) { - spPass2.destroy(gl); - spPass2 = null; - } - } - @Override protected void destroyImpl(final GL2ES2 gl) { if(DEBUG_INSTANCE) { @@ -677,5 +666,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion { indicesFbo.destroy(gl); indicesFbo = null; } + spPass1 = null; // owned by RegionRenderer + spPass2 = null; // owned by RegionRenderer } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java index 96247c61a..21f454655 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java @@ -128,7 +128,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion { /** *

* Since multiple {@link Region}s may share one - * {@link ShaderProgram}, the uniform data must always be updated. + * {@link ShaderProgram} managed and owned by {@link RegionRendered}, the uniform data must always be updated. *

* * @param gl @@ -761,18 +761,6 @@ public final class VBORegion2PVBAAES2 extends GLRegion { gca_VerticesAttr.enableBuffer(gl, false); } - @Override - protected void clearShaderImpl(final GL2ES2 gl) { - if( null != spPass1 ) { - spPass1.destroy(gl); - spPass1 = null; - } - if( null != spPass2 ) { - spPass2.destroy(gl); - spPass2 = null; - } - } - @Override protected void destroyImpl(final GL2ES2 gl) { if(DEBUG_INSTANCE) { @@ -813,5 +801,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion { indicesFbo.destroy(gl); indicesFbo = null; } + spPass1 = null; // owned by RegionRenderer + spPass2 = null; // owned by RegionRenderer } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java index b8bdfbe37..0077186e6 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -265,7 +265,7 @@ public final class VBORegionSPES2 extends GLRegion { /** *

* Since multiple {@link Region}s may share one - * {@link ShaderProgram}, the uniform data must always be updated. + * {@link ShaderProgram} managed and owned by {@link RegionRendered}, the uniform data must always be updated. *

* * @param gl @@ -344,14 +344,6 @@ public final class VBORegionSPES2 extends GLRegion { gca_VerticesAttr.enableBuffer(gl, false); } - @Override - protected void clearShaderImpl(final GL2ES2 gl) { - if( null != spPass1 ) { - spPass1.destroy(gl); - spPass1 = null; - } - } - @Override protected void destroyImpl(final GL2ES2 gl) { if(DEBUG_INSTANCE) { @@ -373,5 +365,6 @@ public final class VBORegionSPES2 extends GLRegion { indicesBuffer.destroy(gl); indicesBuffer = null; } + spPass1 = null; // owned by RegionRenderer } } -- cgit v1.2.3