diff options
author | phil <[email protected]> | 2016-11-02 14:30:49 +1300 |
---|---|---|
committer | phil <[email protected]> | 2016-11-02 14:30:49 +1300 |
commit | 619cd54ad1c30665a05c67c6b3dc9417064d1089 (patch) | |
tree | 4f055dbf1762ba0b019b8fd40047f9367d855cf0 /src | |
parent | 5da4049aa53cc1781ea175e98f14e1abcb0d2ece (diff) |
Shader attributes that are compiled away should not throw errors
ShaderProgramRetained was throwing an error in these cases, whereas a
simple system out is sufficient
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderProgramRetained.java | 94 |
1 files changed, 67 insertions, 27 deletions
diff --git a/src/main/java/org/jogamp/java3d/ShaderProgramRetained.java b/src/main/java/org/jogamp/java3d/ShaderProgramRetained.java index b00da71..9245a4d 100644 --- a/src/main/java/org/jogamp/java3d/ShaderProgramRetained.java +++ b/src/main/java/org/jogamp/java3d/ShaderProgramRetained.java @@ -1059,7 +1059,7 @@ private HashSet<ShaderAttribute> shaderAttrErrorSet = null; } - + private static HashSet<String> warningsGiven = new HashSet<String>(); void setShaderAttributes(Canvas3D cv, ShaderAttributeSetRetained attributeSet) { final boolean useSharedCtx = cv.useSharedCtx && cv.screen.renderer.sharedCtx != null; final int cvRdrIndex = useSharedCtx ? cv.screen.renderer.rendererId : cv.canvasId; @@ -1088,32 +1088,72 @@ private HashSet<ShaderAttribute> shaderAttrErrorSet = null; } else { ShaderAttrLoc loc = attrNameInfo.getLocation(); if (loc != null) { - if (saRetained instanceof ShaderAttributeValueRetained) { - ShaderAttributeValueRetained savRetained = (ShaderAttributeValueRetained)saRetained; - if (attrNameInfo.isArray() || - (savRetained.getClassType() != attrNameInfo.getType())) { - String errMsg = "Attribute type mismatch: " + savRetained.getAttributeName(); // TODO: I18N - err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_TYPE_ERROR, errMsg); - } - else { - err = setUniformAttrValue(cv.ctx, shaderProgramId, loc, savRetained); - } - } else if (saRetained instanceof ShaderAttributeArrayRetained) { - ShaderAttributeArrayRetained saaRetained = (ShaderAttributeArrayRetained)saRetained; - if (!attrNameInfo.isArray() || - (saaRetained.getClassType() != attrNameInfo.getType())) { - String errMsg = "Attribute type mismatch: " + saaRetained.getAttributeName(); // TODO: I18N - err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_TYPE_ERROR, errMsg); - } - else { - err = setUniformAttrArray(cv.ctx, shaderProgramId, loc, saaRetained); - } - } else if (saRetained instanceof ShaderAttributeBindingRetained) { - assert false; - throw new RuntimeException("not implemented"); - } else { - assert false; - } + if (saRetained instanceof ShaderAttributeValueRetained) + { + ShaderAttributeValueRetained savRetained = (ShaderAttributeValueRetained) saRetained; + //-1 indicates compiled away + if (attrNameInfo.getType() != -1) + { + if (attrNameInfo.isArray() || (savRetained.getClassType() != attrNameInfo.getType())) + { + //PJPJPJJPJ + String errMsg = "Attribute type mismatch: " + savRetained.getAttributeName() + " attrNameInfo.isArray() " + + attrNameInfo.isArray() + " " + savRetained.getClassType() + " != " + attrNameInfo.getType(); + // TODO: I18N + err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_TYPE_ERROR, errMsg); + } + else + { + err = setUniformAttrValue(cv.ctx, shaderProgramId, loc, savRetained); + } + } + else + { + if (!warningsGiven.contains((ShaderProgram) this.source + " Attr: " + savRetained.getAttributeName())) + { + System.out.println( + "" + (ShaderProgram) this.source + " Attr: " + savRetained.getAttributeName() + " compiled away"); + warningsGiven.add((ShaderProgram) this.source + " Attr: " + savRetained.getAttributeName()); + } + } + } + else if (saRetained instanceof ShaderAttributeArrayRetained) + { + ShaderAttributeArrayRetained saaRetained = (ShaderAttributeArrayRetained) saRetained; + //-1 indicates compiled away + if (attrNameInfo.getType() != -1) + { + if (!attrNameInfo.isArray() || (saaRetained.getClassType() != attrNameInfo.getType())) + { + String errMsg = "Attribute type mismatch: " + saaRetained.getAttributeName() + " attrNameInfo.isArray() " + + attrNameInfo.isArray() + " " + saaRetained.getClassType() + " != " + attrNameInfo.getType(); + // TODO: I18N + err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_TYPE_ERROR, errMsg); + } + else + { + err = setUniformAttrArray(cv.ctx, shaderProgramId, loc, saaRetained); + } + } + else + { + if (!warningsGiven.contains((ShaderProgram) this.source + " Attr: " + saaRetained.getAttributeName())) + { + System.out.println( + "" + (ShaderProgram) this.source + " Attr: " + saaRetained.getAttributeName() + " compiled away"); + warningsGiven.add((ShaderProgram) this.source + " Attr: " + saaRetained.getAttributeName()); + } + } + } + else if (saRetained instanceof ShaderAttributeBindingRetained) + { + assert false; + throw new RuntimeException("not implemented"); + } + else + { + assert false; + } } } |