aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-01-14 04:19:10 +0100
committerSven Göthel <[email protected]>2024-01-14 04:19:10 +0100
commit6363ae5fb6975a6f2e7c1093ce81f25b699e3e61 (patch)
treee19fb3347ea0562972c87b6b6fbbf771933646ae /src/jogl/classes/jogamp/graph
parent3062f72c7b83cef71d8e6d471846449aba66d861 (diff)
Graph/GraphUI: Revise Graph Region ShaderMapping, fix AABBox-Clipping for Pass2-AA, revise Pass2 AA Quality parameter ..
Misc: - Graph VBORegion2PVBAAES2: Drop unused FBO rescale - Move MIN/MAX QUALITY/SAMPLE from GraphUI Scene -> Graph Region +++ Quality -> Pass2 AA Quality - Drop quality field in region - Pass quality to GLRegion.draw(..) similar to sampleCount for dynamic shader and switch - TODO: Pass quality parameter in TextRegionUtil's functions Fix RegionRenderer Shader Mapping - Use ShaderKey class to properly implement the hash value and equals method - For this, TextureSequence.getTextureFragmentShaderHashID() has been added to provide actual shader-snippet for the equals function - All required criterias are included in the hash value and equals method Fix AABBox Clipping for Pass-2 AA - Clipping in pass2-AA must happen in pass2 on actual gcu_PMVMatrix01 (not ortho) +++ GraphUI GraphShape - Rename: [get,set]{->AA}Quality() GraphUI Scene - Rename: mark{All->}ShapesDirty(), set{AllShapes->}Sharpness(), set{AllShapes->AA}Quality() - Fix setSampleCount(..), i.e. markStatesDirty() not markShapesDirty() - Fix setAAQuality(), markShapesDirty() and markStatesDirty(): Use forAll(..) to traverse through all shapes and groups. GraphUI Group - Add setFixedSize() - Add setClipOnBox() - Document setRelayoutOnDirtyShapes(), isShapeDirty()
Diffstat (limited to 'src/jogl/classes/jogamp/graph')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java174
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java216
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java14
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1.vp5
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl13
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_even.glsl15
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_odd.glsl15
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_flipquad3.glsl12
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2.vp5
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-single.vp1
10 files changed, 250 insertions, 220 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
index 7abcf8818..416cf0b2b 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
@@ -27,6 +27,7 @@
*/
package jogamp.graph.curve.opengl;
+import java.io.File;
import java.nio.FloatBuffer;
import com.jogamp.opengl.GL2ES2;
@@ -47,7 +48,9 @@ import com.jogamp.math.geom.AABBox;
import com.jogamp.math.util.SyncMatrices4f16;
import com.jogamp.opengl.FBObject;
import com.jogamp.opengl.FBObject.Attachment;
+import com.jogamp.opengl.FBObject.TextureAttachment;
import com.jogamp.opengl.util.GLArrayDataServer;
+import com.jogamp.opengl.util.GLReadBufferUtil;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureSequence;
@@ -55,6 +58,7 @@ import com.jogamp.opengl.util.texture.TextureSequence;
public final class VBORegion2PMSAAES2 extends GLRegion {
private static final boolean DEBUG_FBO_1 = false;
private static final boolean DEBUG_FBO_2 = false;
+ private static final boolean SCREENSHOT_FBO = false;
private final RenderState.ProgramLocal rsLocal;
@@ -77,6 +81,8 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
private ShaderProgram spPass2 = null;
private FBObject fbo;
+ private TextureAttachment texA;
+ private GLReadBufferUtil screenshot = SCREENSHOT_FBO ? new GLReadBufferUtil(true, false) : null;
private int fboWidth = 0;
private int fboHeight = 0;
@@ -149,18 +155,9 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
indicesBuffer.enableBuffer(gl, false);
vpc_ileave.seal(gl, true);
vpc_ileave.enableBuffer(gl, false);
-
if( hasColorTexture && null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) {
TextureSequence.setTexCoordBBox(colorTexSeq.getLastTexture().getTexture(), box, isColorTextureLetterbox(), colorTexBBox, false);
}
- gca_FboVerticesAttr.seal(gl, false);
- {
- final FloatBuffer fb = (FloatBuffer)gca_FboVerticesAttr.getBuffer();
- fb.put( 2, box.getMinZ());
- fb.put( 5, box.getMinZ());
- fb.put( 8, box.getMinZ());
- fb.put(11, box.getMinZ());
- }
// Pending gca_FboVerticesAttr-seal and fboPMVMatrix-setup, follow fboDirty
// push data 2 GPU ..
@@ -181,18 +178,18 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
* @param renderer
* @param renderModes
* @param pass1
- * @param quality
+ * @param pass2Quality
* @param sampleCount
*/
- public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final boolean pass1, final int quality, final int sampleCount) {
+ public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final boolean pass1, final int pass2Quality, final int sampleCount) {
final boolean isTwoPass = Region.isTwoPass( curRenderModes );
final boolean hasColorChannel = Region.hasColorChannel( curRenderModes );
final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ) && null != colorTexSeq;
final RenderState rs = renderer.getRenderState();
- final boolean hasAABBoxClipping = null != rs.getClipBBox();
+ final boolean hasAABBoxClipping = null != rs.getClipBBox() && ( ( !isTwoPass && pass1 ) || ( isTwoPass && !pass1 ) );
- final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, pass1, quality, sampleCount, colorTexSeq);
+ final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, pass1, pass2Quality, sampleCount, colorTexSeq);
final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
final boolean updateLocLocal;
if( pass1 ) {
@@ -200,7 +197,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
spPass1 = sp;
if( DEBUG ) {
if( DEBUG_ALL_EVENT || updateLocLocal || updateLocGlobal ) {
- System.err.println("XXX changedSP.p1 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal);
+ System.err.println("XXX changedSP.p1 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal+", sp "+sp.program()+" / "+sp.id());
}
}
if( updateLocLocal ) {
@@ -209,13 +206,12 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
if( hasColorChannel && null != gca_ColorsAttr ) {
rs.updateAttributeLoc(gl, true, gca_ColorsAttr, true);
}
- if( hasAABBoxClipping ) {
- rs.updateUniformLoc(gl, true, gcu_ClipBBox, true);
- }
}
- rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, true);
if( isTwoPass ) {
+ rsLocal.update(gl, rs, updateLocLocal, curRenderModes, false, true, true);
rs.updateUniformLoc(gl, updateLocLocal, gcu_PMVMatrix02, true);
+ } else {
+ rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, true, true);
}
if( hasColorTexture && null != gcu_ColorTexUnit ) {
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, true);
@@ -226,16 +222,19 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
spPass2 = sp;
if( DEBUG ) {
if( DEBUG_ALL_EVENT || updateLocLocal || updateLocGlobal ) {
- System.err.println("XXX changedSP.p2 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal);
+ System.err.println("XXX changedSP.p2 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal+", sp "+sp.program()+" / "+sp.id());
}
}
if( updateLocLocal ) {
rs.updateAttributeLoc(gl, true, gca_FboVerticesAttr, true);
rs.updateAttributeLoc(gl, true, gca_FboTexCoordsAttr, true);
}
- rsLocal.update(gl, rs, updateLocLocal, curRenderModes, false, true);
+ rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, false, true);
rs.updateUniformDataLoc(gl, updateLocLocal, false /* updateData */, gcu_FboTexUnit, true); // FIXME always update if changing tex-unit
}
+ if( hasAABBoxClipping && updateLocLocal ) {
+ rs.updateUniformLoc(gl, true, gcu_ClipBBox, true);
+ }
}
private final AABBox drawWinBox = new AABBox();
@@ -244,7 +243,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
private static final int border = 2; // surrounding border, i.e. width += 2*border, height +=2*border
@Override
- protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int[/*1*/] sampleCount) {
+ protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int pass2Quality, final int[/*1*/] sampleCount) {
if( 0 >= indicesBuffer.getElemCount() ) {
if(DEBUG_INSTANCE) {
System.err.printf("VBORegion2PMSAAES2.drawImpl: Empty%n");
@@ -260,8 +259,8 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
final RenderState rs = renderer.getRenderState();
final int vpWidth = renderer.getWidth();
final int vpHeight = renderer.getHeight();
- if(vpWidth <=0 || vpHeight <= 0 || null==sampleCount || sampleCount[0] <= 0) {
- useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]);
+ if(vpWidth <=0 || vpHeight <= 0 || sampleCount[0] < 0) {
+ useShaderProgram(gl, renderer, curRenderModes, true, pass2Quality, sampleCount[0]);
renderRegion(gl, rs, curRenderModes);
} else {
if(0 > maxTexSize[0]) {
@@ -311,9 +310,9 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
diffObjWidth, diffObjHeight, ratioObjWinWidth, ratioObjWinWidth, diffObjBorderWidth, diffObjBorderHeight);
System.err.printf("XXX.MinMax win %s%n", drawWinBox.toString());
System.err.printf("XXX.MinMax view[%s] -> win[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], r[%f, %f]: FBO i[%d x %d], samples %d%n",
- drawView, drawView,
- winWidth, winHeight, targetWinWidth, targetWinHeight, diffWinWidth,
- diffWinHeight, ratioWinWidth, ratioWinHeight,
+ drawView,
+ winWidth, winHeight, targetWinWidth, targetWinHeight,
+ diffWinWidth, diffWinHeight, ratioWinWidth, ratioWinHeight,
targetFboWidth, targetFboHeight,
sampleCount[0]);
}
@@ -331,30 +330,37 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
System.err.printf("XXX.Scale %d * [%f x %f]: %d x %d%n",
sampleCount[0], winWidth, winHeight, targetFboWidth, targetFboHeight);
}
- if( hasDelta || fboDirty || isShapeDirty() || null == fbo || fbo.getNumSamples() != sampleCount[0] ) {
+ if( hasDelta || fboDirty || isShapeDirty() || null == fbo ) {
// FIXME: rescale
final float minX = box.getMinX()-diffObjBorderWidth;
final float minY = box.getMinY()-diffObjBorderHeight;
final float maxX = box.getMaxX()+diffObjBorderWidth+diffObjWidth;
final float maxY = box.getMaxY()+diffObjBorderHeight+diffObjHeight;
+ final float minZ = box.getMinZ();
gca_FboVerticesAttr.seal(false);
{
final FloatBuffer fb = (FloatBuffer)gca_FboVerticesAttr.getBuffer();
- fb.put(0, minX); fb.put( 1, minY);
- fb.put(3, minX); fb.put( 4, maxY);
- fb.put(6, maxX); fb.put( 7, maxY);
- fb.put(9, maxX); fb.put(10, minY);
+ fb.put(0, minX); fb.put( 1, minY); fb.put( 2, minZ);
+ fb.put(3, minX); fb.put( 4, maxY); fb.put( 5, minZ);
+ fb.put(6, maxX); fb.put( 7, maxY); fb.put( 8, minZ);
+ fb.put(9, maxX); fb.put(10, minY); fb.put(11, minZ);
fb.position(12);
}
gca_FboVerticesAttr.seal(true);
matP.setToOrtho(minX, maxX, minY, maxY, -1, 1);
- useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]);
- renderRegion2FBO(gl, rs, curRenderModes, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount);
+ useShaderProgram(gl, renderer, curRenderModes, true, pass2Quality, sampleCount[0]);
+ renderRegion2FBO(gl, rs, curRenderModes,
+ // (int)drawWinBox.getMinX(), (int)drawWinBox.getMinY(), targetFboWidth, targetFboHeight,
+ 0, 0, targetFboWidth, targetFboHeight,
+ vpWidth, vpHeight, sampleCount);
} else if( isStateDirty() ) {
- useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]);
- renderRegion2FBO(gl, rs, curRenderModes, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount);
+ useShaderProgram(gl, renderer, curRenderModes, true, pass2Quality, sampleCount[0]);
+ renderRegion2FBO(gl, rs, curRenderModes,
+ // (int)drawWinBox.getMinX(), (int)drawWinBox.getMinY(), targetFboWidth, targetFboHeight,
+ 0, 0, targetFboWidth, targetFboHeight,
+ vpWidth, vpHeight, sampleCount);
}
- useShaderProgram(gl, renderer, curRenderModes, false, getQuality(), sampleCount[0]);
+ useShaderProgram(gl, renderer, curRenderModes, false, pass2Quality, sampleCount[0]);
renderFBO(gl, rs, vpWidth, vpHeight, sampleCount[0]);
}
}
@@ -376,9 +382,18 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
}
+ {
+ final AABBox cb = rs.getClipBBox();
+ if( null != cb ) {
+ clipBBox[0] = cb.getMinX(); clipBBox[1] = cb.getMinY(); clipBBox[2] = cb.getMinZ();
+ clipBBox[3] = cb.getMaxX(); clipBBox[4] = cb.getMaxY(); clipBBox[5] = cb.getMaxZ();
+ gl.glUniform(gcu_ClipBBox); // Always update, since program maybe used by multiple regions
+ }
+ }
+
gl.glActiveTexture(GL.GL_TEXTURE0 + gcu_FboTexUnit.intValue());
- fbo.use(gl, fbo.getSamplingSink().getTextureAttachment());
+ fbo.use(gl, texA);
gca_FboVerticesAttr.enableBuffer(gl, true);
gca_FboTexCoordsAttr.enableBuffer(gl, true);
indicesFbo.bindBuffer(gl, true); // keeps VBO binding
@@ -394,44 +409,58 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
}
private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs, final int curRenderModes,
- final int targetFboWidth, final int targetFboHeight,
+ final int fboX, final int fboY, final int targetFboWidth, final int targetFboHeight,
final int vpWidth, final int vpHeight, final int[] sampleCount) {
if( 0 >= targetFboWidth || 0 >= targetFboHeight ) {
- throw new IllegalArgumentException("fboSize must be greater than 0: "+targetFboWidth+"x"+targetFboHeight);
+ throw new IllegalArgumentException("targetFBOSize "+targetFboWidth+"x"+targetFboHeight+" must be greater than 0");
}
-
final boolean blendingEnabled = rs.isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED);
+ final int targetFboSamples = sampleCount[0] > 1 ? sampleCount[0] : 0;
+ final boolean fboSampleTypeMatch;
+ {
+ final int oldSampleCount = null != fbo ? fbo.getNumSamples() : 0;
+ fboSampleTypeMatch = ( oldSampleCount > 1 && targetFboSamples > 1 ) || ( oldSampleCount <= 1 && targetFboSamples <= 1 );
+ }
- if(null == fbo) {
+ if(null == fbo || !fboSampleTypeMatch) {
+ if( null != fbo ) {
+ fbo.destroy(gl);
+ }
fboWidth = targetFboWidth;
fboHeight = targetFboHeight;
fbo = new FBObject();
- fbo.init(gl, fboWidth, fboHeight, sampleCount[0]);
- sampleCount[0] = fbo.getNumSamples();
- fbo.attachColorbuffer(gl, 0, true);
- if( !blendingEnabled ) {
- // no depth-buffer w/ blending
- fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, FBObject.DEFAULT_BITS);
- }
- final FBObject ssink = new FBObject();
- {
- ssink.init(gl, fboWidth, fboHeight, 0);
- // FIXME: shall not use bilinear (GL_LINEAR), due to MSAA ???
- // ssink.attachTexture2D(gl, 0, true, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
- ssink.attachTexture2D(gl, 0, true, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
+ fbo.init(gl, targetFboWidth, targetFboHeight, targetFboSamples);
+ sampleCount[0] = Math.max(1, fbo.getNumSamples());
+ if( 0 == targetFboSamples ) {
+ texA = fbo.attachTexture2D(gl, 0, true, GL.GL_LINEAR, GL.GL_LINEAR, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
if( !blendingEnabled ) {
// no depth-buffer w/ blending
- ssink.attachRenderbuffer(gl, Attachment.Type.DEPTH, FBObject.DEFAULT_BITS);
+ fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, FBObject.DEFAULT_BITS);
}
+ } else {
+ fbo.attachColorbuffer(gl, 0, true);
+ if( !blendingEnabled ) {
+ // no depth-buffer w/ blending
+ fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, FBObject.DEFAULT_BITS);
+ }
+ final FBObject ssink = new FBObject();
+ {
+ ssink.init(gl, targetFboWidth, targetFboHeight, 0);
+ texA = ssink.attachTexture2D(gl, 0, true, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
+ if( !blendingEnabled ) {
+ // no depth-buffer w/ blending
+ ssink.attachRenderbuffer(gl, Attachment.Type.DEPTH, FBObject.DEFAULT_BITS);
+ }
+ }
+ fbo.setSamplingSink(ssink);
+ fbo.resetSamplingSink(gl); // validate
}
- fbo.setSamplingSink(ssink);
- fbo.resetSamplingSink(gl); // validate
if( DEBUG_FBO_1 ) {
- System.err.printf("XXX.createFBO: blending %b, %dx%d%n%s%n", blendingEnabled, fboWidth, fboHeight, fbo.toString());
+ System.err.printf("XXX.createFBO: blending %b, %dx%d%n%s%n", blendingEnabled, targetFboWidth, targetFboHeight, fbo.toString());
}
- } else if( targetFboWidth != fboWidth || targetFboHeight != fboHeight || fbo.getNumSamples() != sampleCount[0] ) {
- fbo.reset(gl, targetFboWidth, targetFboHeight, sampleCount[0]);
- sampleCount[0] = fbo.getNumSamples();
+ } else if( targetFboWidth != fboWidth || targetFboHeight != fboHeight || fbo.getNumSamples() != targetFboSamples ) {
+ fbo.reset(gl, targetFboWidth, targetFboHeight, targetFboSamples);
+ sampleCount[0] = Math.max(1, fbo.getNumSamples());
if( DEBUG_FBO_1 ) {
System.err.printf("XXX.resetFBO: %dx%d -> %dx%d%n%s%n", fboWidth, fboHeight, targetFboWidth, targetFboHeight, fbo );
}
@@ -441,7 +470,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
fbo.bind(gl);
//render texture
- gl.glViewport(0, 0, fboWidth, fboHeight);
+ gl.glViewport(fboX, fboY, targetFboWidth, targetFboHeight);
if( blendingEnabled ) {
gl.glClearColor(0f, 0f, 0f, 0.0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT); // no depth-buffer w/ blending
@@ -460,6 +489,14 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
renderRegion(gl, rs, curRenderModes);
+ if( SCREENSHOT_FBO ) {
+ screenshot.setReadBuffer(GL.GL_COLOR_ATTACHMENT0);
+ if(screenshot.readPixels(gl, fboX, fboY, targetFboWidth, targetFboHeight, false)) {
+ final File f = new File("screenshot_vboregion2pmsaa.png");
+ screenshot.write(f);
+ }
+ }
+
fbo.unbind(gl);
fboDirty = false;
}
@@ -469,14 +506,6 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
final boolean hasColorTexture = Region.hasColorTexture( curRenderModes );
gl.glUniform(gcu_PMVMatrix02);
- {
- final AABBox cb = rs.getClipBBox();
- if( null != cb ) {
- clipBBox[0] = cb.getMinX(); clipBBox[1] = cb.getMinY(); clipBBox[2] = cb.getMinZ();
- clipBBox[3] = cb.getMaxX(); clipBBox[4] = cb.getMaxY(); clipBBox[5] = cb.getMaxZ();
- gl.glUniform(gcu_ClipBBox); // Always update, since program maybe used by multiple regions
- }
- }
vpc_ileave.enableBuffer(gl, true);
indicesBuffer.bindBuffer(gl, true); // keeps VBO binding
@@ -507,6 +536,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
if(null != fbo) {
fbo.destroy(gl);
fbo = null;
+ texA = null;
}
if(null != gca_FboVerticesAttr) {
gca_FboVerticesAttr.destroy(gl);
@@ -520,6 +550,10 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
indicesFbo.destroy(gl);
indicesFbo = null;
}
+ if( null != screenshot ) {
+ screenshot.dispose(gl);
+ screenshot = 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 389a1aca6..3517c7a6b 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
@@ -27,6 +27,7 @@
*/
package jogamp.graph.curve.opengl;
+import java.io.File;
import java.nio.FloatBuffer;
import com.jogamp.opengl.GL2ES2;
@@ -38,7 +39,6 @@ import jogamp.graph.curve.opengl.shader.AttributeNames;
import jogamp.graph.curve.opengl.shader.UniformNames;
import jogamp.opengl.Debug;
-import com.jogamp.common.util.PropertyAccess;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
@@ -51,6 +51,7 @@ import com.jogamp.opengl.FBObject;
import com.jogamp.opengl.FBObject.Attachment;
import com.jogamp.opengl.FBObject.TextureAttachment;
import com.jogamp.opengl.util.GLArrayDataServer;
+import com.jogamp.opengl.util.GLReadBufferUtil;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureSequence;
@@ -58,37 +59,12 @@ import com.jogamp.opengl.util.texture.TextureSequence;
public final class VBORegion2PVBAAES2 extends GLRegion {
private static final boolean DEBUG_FBO_1 = false;
private static final boolean DEBUG_FBO_2 = false;
-
- /**
- * Boundary triggering FBO resize if
- * <pre>
- * fbo[Width|Height] - targetFbo[Width|Height] > RESIZE_BOUNDARY.
- * </pre>
- * <p>
- * Increasing the FBO will add RESIZE_BOUNDARY/2.
- * </p>
- * <p>
- * Reducing FBO resize to gain performance.
- * </p>
- * <p>
- * Defaults to disabled since:
- * - not working properly
- * - FBO texture rendered > than desired size
- * - FBO resize itself should be fast enough ?!
- * </p>
- */
- private static final int RESIZE_BOUNDARY;
+ private static final boolean SCREENSHOT_FBO = false;
static {
Debug.initSingleton();
- final String key = "jogl.debug.graph.curve.vbaa.resizeLowerBoundary";
- RESIZE_BOUNDARY = Math.max(0, PropertyAccess.getIntProperty(key, true, 0));
- if( RESIZE_BOUNDARY > 0 ) {
- System.err.println("key: "+RESIZE_BOUNDARY);
- }
}
-
private final RenderState.ProgramLocal rsLocal;
// Pass-1:
@@ -112,6 +88,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
private FBObject fbo;
private TextureAttachment texA;
+ private GLReadBufferUtil screenshot = SCREENSHOT_FBO ? new GLReadBufferUtil(true, false) : null;
private int fboWidth = 0;
private int fboHeight = 0;
@@ -129,18 +106,18 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
* @param renderer
* @param curRenderModes
* @param pass1
- * @param quality
+ * @param pass2Quality
* @param sampleCount
*/
- public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final boolean pass1, final int quality, final int sampleCount) {
+ public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final boolean pass1, final int pass2Quality, final int sampleCount) {
final boolean isTwoPass = Region.isTwoPass( curRenderModes );
final boolean hasColorChannel = Region.hasColorChannel( curRenderModes );
final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ) && null != colorTexSeq;
final RenderState rs = renderer.getRenderState();
- final boolean hasAABBoxClipping = null != rs.getClipBBox();
+ final boolean hasAABBoxClipping = null != rs.getClipBBox() && ( ( !isTwoPass && pass1 ) || ( isTwoPass && !pass1 ) );
- final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, pass1, quality, sampleCount, colorTexSeq);
+ final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, pass1, pass2Quality, sampleCount, colorTexSeq);
final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
final boolean updateLocLocal;
if( pass1 ) {
@@ -148,7 +125,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
spPass1 = sp;
if( DEBUG ) {
if( DEBUG_ALL_EVENT || updateLocLocal || updateLocGlobal ) {
- System.err.println("XXX changedSP.p1 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal);
+ System.err.println("XXX changedSP.p1 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal+", sp "+sp.program()+" / "+sp.id());
}
}
if( updateLocLocal ) {
@@ -157,13 +134,12 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
if( hasColorChannel && null != gca_ColorsAttr ) {
rs.updateAttributeLoc(gl, true, gca_ColorsAttr, true);
}
- if( hasAABBoxClipping ) {
- rs.updateUniformLoc(gl, true, gcu_ClipBBox, true);
- }
}
- rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, true);
if( isTwoPass ) {
+ rsLocal.update(gl, rs, updateLocLocal, curRenderModes, false, true, true);
rs.updateUniformLoc(gl, updateLocLocal, gcu_PMVMatrix02, true);
+ } else {
+ rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, true, true);
}
if( hasColorTexture && null != gcu_ColorTexUnit ) {
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, true);
@@ -174,17 +150,20 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
spPass2 = sp;
if( DEBUG ) {
if( DEBUG_ALL_EVENT || updateLocLocal || updateLocGlobal ) {
- System.err.println("XXX changedSP.p2 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal);
+ System.err.println("XXX changedSP.p2 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal+", sp "+sp.program()+" / "+sp.id());
}
}
if( updateLocLocal ) {
rs.updateAttributeLoc(gl, true, gca_FboVerticesAttr, true);
rs.updateAttributeLoc(gl, true, gca_FboTexCoordsAttr, true);
}
- rsLocal.update(gl, rs, updateLocLocal, curRenderModes, false, true);
+ rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, false, true);
rs.updateUniformDataLoc(gl, updateLocLocal, false /* updateData */, gcu_FboTexUnit, true); // FIXME always update if changing tex-unit
rs.updateUniformLoc(gl, updateLocLocal, gcu_FboTexSize, sampleCount > 1); // maybe optimized away for sampleCount <= 1
}
+ if( hasAABBoxClipping && updateLocLocal ) {
+ rs.updateUniformLoc(gl, true, gcu_ClipBBox, true);
+ }
}
public VBORegion2PVBAAES2(final GLProfile glp, final int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit,
@@ -254,14 +233,6 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
if( hasColorTexture && null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) {
TextureSequence.setTexCoordBBox(colorTexSeq.getLastTexture().getTexture(), box, isColorTextureLetterbox(), colorTexBBox, false);
}
- gca_FboVerticesAttr.seal(gl, false);
- {
- final FloatBuffer fb = (FloatBuffer)gca_FboVerticesAttr.getBuffer();
- fb.put( 2, box.getMinZ());
- fb.put( 5, box.getMinZ());
- fb.put( 8, box.getMinZ());
- fb.put(11, box.getMinZ());
- }
// Pending gca_FboVerticesAttr-seal and fboPMVMatrix-setup, follow fboDirty
// push data 2 GPU ..
@@ -278,7 +249,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
private static final int border = 2; // surrounding border, i.e. width += 2*border, height +=2*border
@Override
- protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int[/*1*/] sampleCount) {
+ protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int pass2Quality, final int[/*1*/] sampleCount) {
if( 0 >= indicesBuffer.getElemCount() ) {
if(DEBUG_INSTANCE) {
System.err.printf("VBORegion2PVBAAES2.drawImpl: Empty%n");
@@ -294,8 +265,8 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
final RenderState rs = renderer.getRenderState();
final int vpWidth = renderer.getWidth();
final int vpHeight = renderer.getHeight();
- if(vpWidth <=0 || vpHeight <= 0 || null==sampleCount || sampleCount[0] <= 0) {
- useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]);
+ if(vpWidth <=0 || vpHeight <= 0 || sampleCount[0] < 0) {
+ useShaderProgram(gl, renderer, curRenderModes, true, pass2Quality, sampleCount[0]);
renderRegion(gl, rs, curRenderModes);
} else {
if(0 > maxTexSize[0]) {
@@ -355,8 +326,8 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
System.err.printf("XXX.MinMax win %s%n", drawWinBox.toString());
System.err.printf("XXX.MinMax view[%s] -> win[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], r[%f, %f]: FBO f[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], r[%f, %f], samples %d%n",
drawView,
- winWidth, winHeight, targetWinWidth, targetWinHeight, diffWinWidth,
- diffWinHeight, ratioWinWidth, ratioWinHeight,
+ winWidth, winHeight, targetWinWidth, targetWinHeight,
+ diffWinWidth, diffWinHeight, ratioWinWidth, ratioWinHeight,
renderFboWidth, renderFboHeight, targetFboWidth, targetFboHeight,
diffFboWidth, diffFboHeight, ratioFboWidth, ratioFboHeight,
sampleCount[0]);
@@ -400,70 +371,35 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
}
}
- final int newFboWidth, newFboHeight, resizeCase;
- if( 0 >= RESIZE_BOUNDARY ) {
- // Resize w/o optimization
- newFboWidth = targetFboWidth;
- newFboHeight = targetFboHeight;
- resizeCase = 0;
- } else {
- if( 0 >= fboWidth || 0 >= fboHeight || null == fbo ) {
- // Case: New FBO
- newFboWidth = targetFboWidth;
- newFboHeight = targetFboHeight;
- resizeCase = 1;
- } else if( targetFboWidth > fboWidth || targetFboHeight > fboHeight ) {
- // Case: Inscrease FBO Size, add boundary/2 if avail
- newFboWidth = ( targetFboWidth + RESIZE_BOUNDARY/2 < maxTexSize[0] ) ? targetFboWidth + RESIZE_BOUNDARY/2 : targetFboWidth;
- newFboHeight = ( targetFboHeight+ RESIZE_BOUNDARY/2 < maxTexSize[0] ) ? targetFboHeight + RESIZE_BOUNDARY/2 : targetFboHeight;
- resizeCase = 2;
- } else if( targetFboWidth < fboWidth && targetFboHeight < fboHeight &&
- fboWidth - targetFboWidth < RESIZE_BOUNDARY &&
- fboHeight - targetFboHeight < RESIZE_BOUNDARY ) {
- // Case: Decreased FBO Size Request within boundary
- newFboWidth = fboWidth;
- newFboHeight = fboHeight;
- resizeCase = 3;
- } else {
- // Case: Decreased-Size-Beyond-Boundary or No-Resize
- newFboWidth = targetFboWidth;
- newFboHeight = targetFboHeight;
- resizeCase = 4;
- }
- }
- final int dResizeWidth = newFboWidth - targetFboWidth;
- final int dResizeHeight = newFboHeight - targetFboHeight;
- final float diffObjResizeWidth = dResizeWidth*ratioObjWinWidth;
- final float diffObjResizeHeight = dResizeHeight*ratioObjWinHeight;
- if( DEBUG_FBO_1 ) {
- System.err.printf("XXX.resizeFBO: case %d, has %dx%d > target %dx%d, resize: i[%d x %d], f[%.3f x %.3f] -> %dx%d%n",
- resizeCase, fboWidth, fboHeight, targetFboWidth, targetFboHeight,
- dResizeWidth, dResizeHeight, diffObjResizeWidth, diffObjResizeHeight,
- newFboWidth, newFboHeight);
- }
-
final float minX = box.getMinX()-diffObjBorderWidth;
final float minY = box.getMinY()-diffObjBorderHeight;
- final float maxX = box.getMaxX()+diffObjBorderWidth+diffObjWidth+diffObjResizeWidth;
- final float maxY = box.getMaxY()+diffObjBorderHeight+diffObjHeight+diffObjResizeHeight;
+ final float maxX = box.getMaxX()+diffObjBorderWidth+diffObjWidth;
+ final float maxY = box.getMaxY()+diffObjBorderHeight+diffObjHeight;
+ final float minZ = box.getMinZ();
gca_FboVerticesAttr.seal(false);
{
final FloatBuffer fb = (FloatBuffer)gca_FboVerticesAttr.getBuffer();
- fb.put(0, minX); fb.put( 1, minY);
- fb.put(3, minX); fb.put( 4, maxY);
- fb.put(6, maxX); fb.put( 7, maxY);
- fb.put(9, maxX); fb.put(10, minY);
+ fb.put(0, minX); fb.put( 1, minY); fb.put( 2, minZ);
+ fb.put(3, minX); fb.put( 4, maxY); fb.put( 5, minZ);
+ fb.put(6, maxX); fb.put( 7, maxY); fb.put( 8, minZ);
+ fb.put(9, maxX); fb.put(10, minY); fb.put(11, minZ);
fb.position(12);
}
gca_FboVerticesAttr.seal(true);
matP.setToOrtho(minX, maxX, minY, maxY, -1, 1);
- useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]);
- renderRegion2FBO(gl, rs, curRenderModes, targetFboWidth, targetFboHeight, newFboWidth, newFboHeight, vpWidth, vpHeight, sampleCount[0]);
+ useShaderProgram(gl, renderer, curRenderModes, true, pass2Quality, sampleCount[0]);
+ renderRegion2FBO(gl, rs, curRenderModes,
+ // (int)drawWinBox.getMinX(), (int)drawWinBox.getMinY(), targetFboWidth, targetFboHeight,
+ 0, 0, targetFboWidth, targetFboHeight,
+ vpWidth, vpHeight, sampleCount[0]);
} else if( isStateDirty() ) {
- useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]);
- renderRegion2FBO(gl, rs, curRenderModes, targetFboWidth, targetFboHeight, fboWidth, fboHeight, vpWidth, vpHeight, sampleCount[0]);
+ useShaderProgram(gl, renderer, curRenderModes, true, pass2Quality, sampleCount[0]);
+ renderRegion2FBO(gl, rs, curRenderModes,
+ // (int)drawWinBox.getMinX(), (int)drawWinBox.getMinY(), targetFboWidth, targetFboHeight,
+ 0, 0, targetFboWidth, targetFboHeight,
+ vpWidth, vpHeight, sampleCount[0]);
}
- useShaderProgram(gl, renderer, curRenderModes, false, getQuality(), sampleCount[0]);
+ useShaderProgram(gl, renderer, curRenderModes, false, pass2Quality, sampleCount[0]);
renderFBO(gl, rs, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount[0]);
}
}
@@ -483,6 +419,14 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
}
gl.glUniform(gcu_FboTexSize);
+ {
+ final AABBox cb = rs.getClipBBox();
+ if( null != cb ) {
+ clipBBox[0] = cb.getMinX(); clipBBox[1] = cb.getMinY(); clipBBox[2] = cb.getMinZ();
+ clipBBox[3] = cb.getMaxX(); clipBBox[4] = cb.getMaxY(); clipBBox[5] = cb.getMaxZ();
+ gl.glUniform(gcu_ClipBBox); // Always update, since program maybe used by multiple regions
+ }
+ }
gl.glActiveTexture(GL.GL_TEXTURE0 + gcu_FboTexUnit.intValue());
@@ -502,54 +446,56 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
}
private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs, final int curRenderModes,
- final int targetFboWidth, final int targetFboHeight, final int newFboWidth, final int newFboHeight,
+ final int fboX, final int fboY, final int targetFboWidth, final int targetFboHeight,
final int vpWidth, final int vpHeight, final int sampleCount) {
if( 0 >= targetFboWidth || 0 >= targetFboHeight ) {
- throw new IllegalArgumentException("fboSize must be greater than 0: "+targetFboWidth+"x"+targetFboHeight);
+ throw new IllegalArgumentException("targetFBOSize "+targetFboWidth+"x"+targetFboHeight+" must be greater than 0");
}
-
final boolean blendingEnabled = rs.isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED);
if(null == fbo) {
- fboWidth = newFboWidth;
- fboHeight = newFboHeight;
+ fboWidth = targetFboWidth;
+ fboHeight = targetFboHeight;
final FloatBuffer fboTexSize = (FloatBuffer) gcu_FboTexSize.getBuffer();
{
- fboTexSize.put(0, fboWidth);
- fboTexSize.put(1, fboHeight);
+ fboTexSize.put(0, targetFboWidth);
+ fboTexSize.put(1, targetFboHeight);
}
fbo = new FBObject();
- fbo.init(gl, fboWidth, fboHeight, 0);
- // Shall not use bilinear (GL_LINEAR), due to own VBAA. Result is smooth w/o it now!
- // FIXME: FXAA requires bilinear filtering!
- // texA = fbo.attachTexture2D(gl, 0, true, GL.GL_LINEAR, GL.GL_LINEAR, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
- texA = fbo.attachTexture2D(gl, 0, true, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
+ fbo.init(gl, targetFboWidth, targetFboHeight, 0);
+ if( sampleCount > 1 ) {
+ // Shall not use bilinear (GL_LINEAR), due to own VBAA. Result is smooth w/o it now!
+ // FIXME: FXAA requires bilinear filtering!
+ texA = fbo.attachTexture2D(gl, 0, true, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
+ } else {
+ texA = fbo.attachTexture2D(gl, 0, true, GL.GL_LINEAR, GL.GL_LINEAR, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
+ }
if( !blendingEnabled ) {
// no depth-buffer w/ blending
fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, FBObject.DEFAULT_BITS);
}
if( DEBUG_FBO_1 ) {
- System.err.printf("XXX.createFBO: %dx%d%n%s%n", fboWidth, fboHeight, fbo.toString());
+ System.err.printf("XXX.createFBO: %dx%d%n%s%n", targetFboWidth, targetFboHeight, fbo.toString());
}
- } else if( newFboWidth != fboWidth || newFboHeight != fboHeight ) {
- fbo.reset(gl, newFboWidth, newFboHeight, 0);
+ } else if( targetFboWidth != fboWidth || targetFboHeight != fboHeight ) {
+ fbo.reset(gl, targetFboWidth, targetFboHeight, 0);
fbo.bind(gl);
if( DEBUG_FBO_1 ) {
- System.err.printf("XXX.resetFBO: %dx%d -> %dx%d, target %dx%d%n", fboWidth, fboHeight, newFboWidth, newFboHeight, targetFboWidth, targetFboHeight);
+ System.err.printf("XXX.resetFBO: %dx%d -> %dx%d%n%s%n", fboWidth, fboHeight, targetFboWidth, targetFboHeight, fbo.toString());
}
- fboWidth = newFboWidth;
- fboHeight = newFboHeight;
+ fboWidth = targetFboWidth;
+ fboHeight = targetFboHeight;
final FloatBuffer fboTexSize = (FloatBuffer) gcu_FboTexSize.getBuffer();
{
- fboTexSize.put(0, fboWidth);
- fboTexSize.put(1, fboHeight);
+ fboTexSize.put(0, targetFboWidth);
+ fboTexSize.put(1, targetFboHeight);
}
} else {
fbo.bind(gl);
}
//render texture
- gl.glViewport(0, 0, fboWidth, fboHeight);
+ gl.glViewport(fboX, fboY, targetFboWidth, targetFboHeight);
if( blendingEnabled ) {
gl.glClearColor(0f, 0f, 0f, 0.0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT); // no depth-buffer w/ blending
@@ -564,6 +510,14 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
renderRegion(gl, rs, curRenderModes);
+ if( SCREENSHOT_FBO ) {
+ screenshot.setReadBuffer(GL.GL_COLOR_ATTACHMENT0);
+ if(screenshot.readPixels(gl, fboX, fboY, targetFboWidth, targetFboHeight, false)) {
+ final File f = new File("screenshot_vboregion2pvbaa.png");
+ screenshot.write(f);
+ }
+ }
+
fbo.unbind(gl);
fboDirty = false;
}
@@ -573,14 +527,6 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
final boolean hasColorTexture = Region.hasColorTexture( curRenderModes );
gl.glUniform(gcu_PMVMatrix02);
- {
- final AABBox cb = rs.getClipBBox();
- if( null != cb ) {
- clipBBox[0] = cb.getMinX(); clipBBox[1] = cb.getMinY(); clipBBox[2] = cb.getMinZ();
- clipBBox[3] = cb.getMaxX(); clipBBox[4] = cb.getMaxY(); clipBBox[5] = cb.getMaxZ();
- gl.glUniform(gcu_ClipBBox); // Always update, since program maybe used by multiple regions
- }
- }
vpc_ileave.enableBuffer(gl, true);
indicesBuffer.bindBuffer(gl, true); // keeps VBO binding
@@ -627,6 +573,10 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
indicesFbo.destroy(gl);
indicesFbo = null;
}
+ if( null != screenshot ) {
+ screenshot.dispose(gl);
+ screenshot = 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 281757da4..26748136e 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -115,22 +115,22 @@ public final class VBORegionSPES2 extends GLRegion {
* @param gl
* @param renderer
* @param curRenderModes
- * @param quality
+ * @param pass2Quality
*/
- public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int quality) {
+ public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes) {
final boolean hasColorChannel = Region.hasColorChannel( curRenderModes );
final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ) && null != colorTexSeq;
final RenderState rs = renderer.getRenderState();
final boolean hasAABBoxClipping = null != rs.getClipBBox();
- final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, true, quality, 0, colorTexSeq);
+ final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, true, 0 /* pass2Quality */, 0 /* sampleCount */, colorTexSeq);
final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
final boolean updateLocLocal = !sp.equals(spPass1);
spPass1 = sp;
if( DEBUG ) {
if( DEBUG_ALL_EVENT || updateLocLocal || updateLocGlobal ) {
- System.err.println("XXX changedSP.p1 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal);
+ System.err.println("XXX changedSP.p1 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal+", sp "+sp.program()+" / "+sp.id());
}
}
if( updateLocLocal ) {
@@ -143,7 +143,7 @@ public final class VBORegionSPES2 extends GLRegion {
rs.updateUniformLoc(gl, true, gcu_ClipBBox, throwOnError);
}
}
- rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, throwOnError);
+ rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, true, throwOnError);
if( hasColorTexture && null != gcu_ColorTexUnit ) {
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, throwOnError);
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexBBox, throwOnError);
@@ -152,11 +152,11 @@ public final class VBORegionSPES2 extends GLRegion {
@Override
- protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int[/*1*/] sampleCount) {
+ protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int pass2Quality, final int[/*1*/] sampleCount) {
// final boolean hasColorChannel = Region.hasColorChannel( curRenderModes );
final boolean hasColorTexture = Region.hasColorTexture( curRenderModes );
- useShaderProgram(gl, renderer, curRenderModes, getQuality());
+ useShaderProgram(gl, renderer, curRenderModes);
{
final AABBox cb = renderer.getClipBBox();
if( null != cb ) {
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1.vp
index b9974b97d..cfec523e9 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1.vp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1.vp
@@ -23,10 +23,7 @@ void main(void)
gcv_CurveParam = gca_CurveParams;
}
#endif
-#ifdef USE_AABBOX_CLIPPING
- gcv_ClipBBoxCoord = (gcu_PMVMatrix02[1] * gca_Vertices).xyz; // Mv
-#endif
-
+
#ifdef USE_COLOR_TEXTURE
gcv_ColorTexCoord = ( gca_Vertices.xy - gcu_ColorTexBBox[0] ) / ( gcu_ColorTexBBox[1] - gcu_ColorTexBBox[0] );
#endif
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl
index 36d70cbdf..3d4cdc887 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl
@@ -1,4 +1,14 @@
- // Pass-2: Dump Texture
+ // Pass-2: Dump Texture
+#ifdef USE_AABBOX_CLIPPING
+ if( is_inside(gcv_ClipBBoxCoord, gcu_ClipBBox[0], gcu_ClipBBox[1]) < 0.5 ) {
+ #if USE_DISCARD
+ discard; // discard freezes NV tegra2 compiler
+ #else
+ mgl_FragColor = vec4(0);
+ #endif
+ } else
+#endif
+ {
vec4 t = texture2D(gcu_FboTexUnit, gcv_FboTexCoord.st);
#if USE_DISCARD
if( 0.0 == t.a ) {
@@ -9,4 +19,5 @@
#else
mgl_FragColor = t;
#endif
+ }
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_even.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_even.glsl
index e83e21a55..5e14a1a23 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_even.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_even.glsl
@@ -1,6 +1,16 @@
- // Pass-2: AA on Texture
- // Note: gcv_FboTexCoord is in center of sample pixels.
+ // Pass-2: AA on Texture
+ // Note: gcv_FboTexCoord is in center of sample pixels.
+#ifdef USE_AABBOX_CLIPPING
+ if( is_inside(gcv_ClipBBoxCoord, gcu_ClipBBox[0], gcu_ClipBBox[1]) < 0.5 ) {
+ #if USE_DISCARD
+ discard; // discard freezes NV tegra2 compiler
+ #else
+ mgl_FragColor = vec4(0);
+ #endif
+ } else
+#endif
+ {
// float sample_count = gcu_FboTexSize.z;
vec2 psize = 1.0 / gcu_FboTexSize.xy; // pixel size
@@ -97,4 +107,5 @@
#else
mgl_FragColor = t;
#endif
+ }
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_odd.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_odd.glsl
index a3c61e595..b7d2e0e4e 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_odd.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_odd.glsl
@@ -1,6 +1,16 @@
- // Pass-2: AA on Texture
- // Note: gcv_FboTexCoord is in center of sample pixels.
+ // Pass-2: AA on Texture
+ // Note: gcv_FboTexCoord is in center of sample pixels.
+#ifdef USE_AABBOX_CLIPPING
+ if( is_inside(gcv_ClipBBoxCoord, gcu_ClipBBox[0], gcu_ClipBBox[1]) < 0.5 ) {
+ #if USE_DISCARD
+ discard; // discard freezes NV tegra2 compiler
+ #else
+ mgl_FragColor = vec4(0);
+ #endif
+ } else
+#endif
+ {
// float sample_count = gcu_FboTexSize.z;
vec2 psize = 1.0 / gcu_FboTexSize.xy; // pixel size
@@ -88,4 +98,5 @@
#else
mgl_FragColor = t;
#endif
+ }
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_flipquad3.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_flipquad3.glsl
index bc0044aab..da0306425 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_flipquad3.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_flipquad3.glsl
@@ -4,6 +4,16 @@
//
// Same as flipquad - but w/ rgss coordinates
+#ifdef USE_AABBOX_CLIPPING
+ if( is_inside(gcv_ClipBBoxCoord, gcu_ClipBBox[0], gcu_ClipBBox[1]) < 0.5 ) {
+ #if USE_DISCARD
+ discard; // discard freezes NV tegra2 compiler
+ #else
+ mgl_FragColor = vec4(0);
+ #endif
+ } else
+#endif
+ {
// float sample_count = gcu_FboTexSize.z;
vec2 psize = 1.0 / gcu_FboTexSize.xy; // pixel size
@@ -108,4 +118,4 @@
#else
mgl_FragColor = t;
#endif
-
+ }
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2.vp
index 64857c9ce..e4087cbd6 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2.vp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2.vp
@@ -13,5 +13,10 @@ void main(void)
{
// gl_Position = gcu_PMVMatrix01[0] * gcu_PMVMatrix01[1] * vec4(gca_FboVertices, 1);
gl_Position = gcu_PMVMatrix01[0] * gcu_PMVMatrix01[1] * gca_FboVertices;
+
+#ifdef USE_AABBOX_CLIPPING
+ gcv_ClipBBoxCoord = (gcu_PMVMatrix01[1] * gca_FboVertices).xyz; // Mv
+#endif
+
gcv_FboTexCoord = gca_FboTexCoords;
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-single.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-single.vp
index 9518834b0..2f07ad7d0 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-single.vp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-single.vp
@@ -23,6 +23,7 @@ void main(void)
gcv_CurveParam = gca_CurveParams;
}
#endif
+
#ifdef USE_AABBOX_CLIPPING
gcv_ClipBBoxCoord = (gcu_PMVMatrix01[1] * gca_Vertices).xyz; // Mv
#endif