diff options
author | Sven Göthel <[email protected]> | 2024-01-25 09:21:54 +0100 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-01-25 09:21:54 +0100 |
commit | b711ae5239b8581a197d468b2804cfeb8c4d6c94 (patch) | |
tree | fa39595d737a433d6382355e9b9d5c914cd93027 /src/jogl/classes/com/jogamp/graph/curve | |
parent | 4cbf5297af18f541baa5cd5b85017b1a7a5c19c0 (diff) |
Bug 1488: Complete/Fix producing the 64-bit shaderKey: Use long values in bit-shift expressions and simplify it
commit 1dcfdf71c09c6d774ac47012c05e09da4a085d7b
- still used the 'hash code' bit shift pattern, not necessary -> simplified
- the value as not ensured to be long, hence conversion occured
This caused Graph's MSAA not being picked up properly using the shaderKey.
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve')
-rw-r--r-- | src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java | 64 |
1 files changed, 28 insertions, 36 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java index 9ed2c1d77..87e1c4385 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java @@ -98,7 +98,7 @@ public final class RegionRenderer { * to set the proper {@link GL#glBlendFuncSeparate(int, int, int, int) blend-function} * and the clear-color to <i>transparent-black</i> in case of {@link Region#isTwoPass(int) multipass} FBO rendering. * </p> - * @see #create(Vertex.Factory<? extends Vertex>, RenderState, GLCallback, GLCallback) + * @see #create(GLCallback, GLCallback) * @see #enable(GL2ES2, boolean) */ public static final GLCallback defaultBlendEnable = new GLCallback() { @@ -122,7 +122,7 @@ public final class RegionRenderer { * <p> * Implementation also clears {@link RegionRenderer#getRenderState() RenderState}'s {@link RenderState#BITHINT_BLENDING_ENABLED blending bit-hint}. * </p> - * @see #create(Vertex.Factory<? extends Vertex>, RenderState, GLCallback, GLCallback) + * @see #create(GLCallback, GLCallback) * @see #enable(GL2ES2, boolean) */ public static final GLCallback defaultBlendDisable = new GLCallback() { @@ -618,13 +618,13 @@ public final class RegionRenderer { // 8 | 1 | hasColorChannel // 9 | 1 | hasColorTexture // 32 | 32 | colorTexSeqHash - long hash = ( isTwoPass ? 1 : 0 ); - hash = ( hash << 1 ) | ( pass1 ? 1 : 0 ) ; - hash = ( hash << 1 ) | sms.ordinal(); // incl. pass2Quality + sampleCount - hash = ( hash << 5 ) | ( hasFrustumClipping ? 1 : 0 ); - hash = ( hash << 1 ) | ( hasColorChannel ? 1 : 0 ); - hash = ( hash << 1 ) | ( hasColorTexture ? 1 : 0 ); - hash = ( hash << 1 ) | ( ( colorTexSeqHash & 0xFFFFFFL ) << 32 ); + long hash = isTwoPass ? 1L : 0L; + hash |= ( pass1 ? 1L : 0L ) << 1; + hash |= (long)( sms.ordinal() & 0b11111 ) << 2; // incl. pass2Quality + sampleCount + hash |= ( hasFrustumClipping ? 1L : 0L ) << 7; + hash |= ( hasColorChannel ? 1L : 0L ) << 8; + hash |= ( hasColorTexture ? 1L : 0L ) << 9; + hash |= ( colorTexSeqHash & 0xFFFFFFL ) << 32; return hash; } private static int getShaderKey1(final boolean isTwoPass, final boolean pass1, @@ -704,41 +704,33 @@ public final class RegionRenderer { if( spChanged ) { System.err.printf("RegionRenderer.useShaderProgram0.X1: GOT renderModes %s, %s -> sp %d / %d (changed)%n", Region.getRenderModeString(renderModes), - shaderKeyToString(shaderKey, isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms), - sp.program(), sp.id()); + shaderKeyToString(shaderKey, isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms), sp.program(), sp.id()); } else if( DEBUG_ALL_EVENT ) { System.err.printf("RegionRenderer.useShaderProgram0.X1: GOT renderModes %s, %s -> sp %d / %d (keep)%n", Region.getRenderModeString(renderModes), - shaderKeyToString(shaderKey, isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms), - sp.program(), sp.id()); + shaderKeyToString(shaderKey, isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms), sp.program(), sp.id()); } } return spChanged; } sp = createShaderProgram(gl, renderModes, isTwoPass, pass1, sms, hasFrustumClipping, hasColorChannel, hasColorTexture, colorTexSeq, colTexLookupFuncName, colorTexSeqHash); - rs.setShaderProgram(gl, sp); - { - // shaderPrograms0.containsKey(shaderHashCode); - final ShaderProgram spOld = (ShaderProgram) shaderPrograms0.put(shaderKey, sp); - if( null != spOld ) { - // COLLISION! - final String msg = String.format((Locale)null, - "RegionRenderer.useShaderProgram0: WARNING Shader-HashCode Collision: hash 0x%s: %s, %s -> sp %d / %d (changed, new)%n", - Long.toHexString(shaderKey), - Region.getRenderModeString(renderModes), - shaderKeyToString(shaderKey, isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms), - sp.program(), sp.id()); - throw new RuntimeException(msg); - } - } - if( DEBUG_SHADER_MAP ) { - System.err.printf("RegionRenderer.useShaderProgram0.X1: PUT renderModes %s, %s -> sp %d / %d (changed, new)%n", - Region.getRenderModeString(renderModes), shaderKey, sp.program(), sp.id()); - // rsFp.dumpShaderSource(System.err); + System.err.printf("RegionRenderer.useShaderProgram0.X2: NEW renderModes %s, %s -> sp %d / %d (new)%n", + Region.getRenderModeString(renderModes), + shaderKeyToString(shaderKey, isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms), sp.program(), sp.id()); + // sp.dumpSource(System.err); + } + final ShaderProgram spOld = (ShaderProgram) shaderPrograms0.put(shaderKey, sp); + if( null != spOld ) { + // COLLISION! + final String msg = String.format((Locale)null, + "RegionRenderer.useShaderProgram0: WARNING Shader-HashCode Collision: hash 0x%s: %s, %s -> sp %d / %d (new)%n", + Long.toHexString(shaderKey), Region.getRenderModeString(renderModes), + shaderKeyToString(shaderKey, isTwoPass, pass1, hasFrustumClipping, hasColorChannel, hasColorTexture, sms), sp.program(), sp.id()); + throw new RuntimeException(msg); } return true; } @@ -770,15 +762,15 @@ public final class RegionRenderer { } sp = createShaderProgram(gl, renderModes, isTwoPass, pass1, sms, hasFrustumClipping, hasColorChannel, hasColorTexture, colorTexSeq, colTexLookupFuncName, colorTexSeqHash); - rs.setShaderProgram(gl, sp); - shaderPrograms1.put(shaderKey, sp); if( DEBUG_SHADER_MAP ) { - System.err.printf("RegionRenderer.useShaderProgram1.X1: PUT renderModes %s, %s -> sp %d / %d (changed, new)%n", + System.err.printf("RegionRenderer.useShaderProgram1.X2: NEW renderModes %s, %s -> sp %d / %d (new)%n", Region.getRenderModeString(renderModes), shaderKey, sp.program(), sp.id()); - // rsFp.dumpShaderSource(System.err); + // sp.dumpSource(System.err); } + + shaderPrograms1.put(shaderKey, sp); return true; } @SuppressWarnings("unused") |