Skip to content

Commit

Permalink
ARM Mali: Report "es" as part of GLSL versions
Browse files Browse the repository at this point in the history
Fixes:
P0007: Language version '300' unknown, this compiler only supports up to version '320 es'
  • Loading branch information
gohai committed Apr 18, 2018
1 parent 78e376a commit 24bb799
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
31 changes: 17 additions & 14 deletions core/src/processing/opengl/PGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -1287,9 +1287,9 @@ protected PGL initTex2DShader() {
PGL ppgl = primaryPGL ? this : graphics.getPrimaryPGL();

if (!ppgl.loadedTex2DShader || ppgl.tex2DShaderContext != ppgl.glContext) {
String[] preprocVertSrc = preprocessVertexSource(texVertShaderSource, getGLSLVersion());
String[] preprocVertSrc = preprocessVertexSource(texVertShaderSource, getGLSLVersion(), getGLSLVersionSuffix());
String vertSource = PApplet.join(preprocVertSrc, "\n");
String[] preprocFragSrc = preprocessFragmentSource(tex2DFragShaderSource, getGLSLVersion());
String[] preprocFragSrc = preprocessFragmentSource(tex2DFragShaderSource, getGLSLVersion(), getGLSLVersionSuffix());
String fragSource = PApplet.join(preprocFragSrc, "\n");
ppgl.tex2DVertShader = createShader(VERTEX_SHADER, vertSource);
ppgl.tex2DFragShader = createShader(FRAGMENT_SHADER, fragSource);
Expand Down Expand Up @@ -1419,9 +1419,9 @@ protected PGL initTexRectShader() {
PGL ppgl = primaryPGL ? this : graphics.getPrimaryPGL();

if (!ppgl.loadedTexRectShader || ppgl.texRectShaderContext != ppgl.glContext) {
String[] preprocVertSrc = preprocessVertexSource(texVertShaderSource, getGLSLVersion());
String[] preprocVertSrc = preprocessVertexSource(texVertShaderSource, getGLSLVersion(), getGLSLVersionSuffix());
String vertSource = PApplet.join(preprocVertSrc, "\n");
String[] preprocFragSrc = preprocessFragmentSource(texRectFragShaderSource, getGLSLVersion());
String[] preprocFragSrc = preprocessFragmentSource(texRectFragShaderSource, getGLSLVersion(), getGLSLVersionSuffix());
String fragSource = PApplet.join(preprocFragSrc, "\n");
ppgl.texRectVertShader = createShader(VERTEX_SHADER, vertSource);
ppgl.texRectFragShader = createShader(FRAGMENT_SHADER, fragSource);
Expand Down Expand Up @@ -1848,6 +1848,7 @@ protected static int qualityToSamples(int quality) {


abstract protected int getGLSLVersion();
abstract protected String getGLSLVersionSuffix();


protected String[] loadVertexShader(String filename) {
Expand Down Expand Up @@ -1880,28 +1881,29 @@ protected String[] loadVertexShader(URL url) {
}


protected String[] loadVertexShader(String filename, int version) {
protected String[] loadVertexShader(String filename, int version, String versionSuffix) {
return loadVertexShader(filename);
}


protected String[] loadFragmentShader(String filename, int version) {
protected String[] loadFragmentShader(String filename, int version, String versionSuffix) {
return loadFragmentShader(filename);
}


protected String[] loadFragmentShader(URL url, int version) {
protected String[] loadFragmentShader(URL url, int version, String versionSuffix) {
return loadFragmentShader(url);
}


protected String[] loadVertexShader(URL url, int version) {
protected String[] loadVertexShader(URL url, int version, String versionSuffix) {
return loadVertexShader(url);
}


protected static String[] preprocessFragmentSource(String[] fragSrc0,
int version) {
int version,
String versionSuffix) {
if (containsVersionDirective(fragSrc0)) {
// The user knows what she or he is doing
return fragSrc0;
Expand All @@ -1915,7 +1917,7 @@ protected static String[] preprocessFragmentSource(String[] fragSrc0,
int offset = 1;

fragSrc = preprocessShaderSource(fragSrc0, search, replace, offset);
fragSrc[0] = "#version " + version;
fragSrc[0] = "#version " + version + versionSuffix;
} else {
// We need to replace 'texture' uniform by 'texMap' uniform and
// 'textureXXX()' functions by 'texture()' functions. Order of these
Expand All @@ -1932,15 +1934,16 @@ protected static String[] preprocessFragmentSource(String[] fragSrc0,
int offset = 2;

fragSrc = preprocessShaderSource(fragSrc0, search, replace, offset);
fragSrc[0] = "#version " + version;
fragSrc[0] = "#version " + version + versionSuffix;
fragSrc[1] = "out vec4 _fragColor;";
}

return fragSrc;
}

protected static String[] preprocessVertexSource(String[] vertSrc0,
int version) {
int version,
String versionSuffix) {
if (containsVersionDirective(vertSrc0)) {
// The user knows what she or he is doing
return vertSrc0;
Expand All @@ -1954,7 +1957,7 @@ protected static String[] preprocessVertexSource(String[] vertSrc0,
int offset = 1;

vertSrc = preprocessShaderSource(vertSrc0, search, replace, offset);
vertSrc[0] = "#version " + version;
vertSrc[0] = "#version " + version + versionSuffix;
} else {
// We need to replace 'texture' uniform by 'texMap' uniform and
// 'textureXXX()' functions by 'texture()' functions. Order of these
Expand All @@ -1971,7 +1974,7 @@ protected static String[] preprocessVertexSource(String[] vertSrc0,
int offset = 1;

vertSrc = preprocessShaderSource(vertSrc0, search, replace, offset);
vertSrc[0] = "#version " + version;
vertSrc[0] = "#version " + version + versionSuffix;
}

return vertSrc;
Expand Down
32 changes: 20 additions & 12 deletions core/src/processing/opengl/PJOGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -509,50 +509,58 @@ protected int getGLSLVersion() {
return vn.getMajor() * 100 + vn.getMinor();
}

protected String getGLSLVersionSuffix() {
if (context.isGLESProfile()) {
return " es";
} else {
return "";
}
}


@Override
protected String[] loadVertexShader(String filename) {
return loadVertexShader(filename, getGLSLVersion());
return loadVertexShader(filename, getGLSLVersion(), getGLSLVersionSuffix());
}


@Override
protected String[] loadFragmentShader(String filename) {
return loadFragmentShader(filename, getGLSLVersion());
return loadFragmentShader(filename, getGLSLVersion(), getGLSLVersionSuffix());
}


@Override
protected String[] loadVertexShader(URL url) {
return loadVertexShader(url, getGLSLVersion());
return loadVertexShader(url, getGLSLVersion(), getGLSLVersionSuffix());
}


@Override
protected String[] loadFragmentShader(URL url) {
return loadFragmentShader(url, getGLSLVersion());
return loadFragmentShader(url, getGLSLVersion(), getGLSLVersionSuffix());
}


@Override
protected String[] loadFragmentShader(String filename, int version) {
protected String[] loadFragmentShader(String filename, int version, String versionSuffix) {
String[] fragSrc0 = sketch.loadStrings(filename);
return preprocessFragmentSource(fragSrc0, version);
return preprocessFragmentSource(fragSrc0, version, versionSuffix);
}


@Override
protected String[] loadVertexShader(String filename, int version) {
protected String[] loadVertexShader(String filename, int version, String versionSuffix) {
String[] vertSrc0 = sketch.loadStrings(filename);
return preprocessVertexSource(vertSrc0, version);
return preprocessVertexSource(vertSrc0, version, versionSuffix);
}


@Override
protected String[] loadFragmentShader(URL url, int version) {
protected String[] loadFragmentShader(URL url, int version, String versionSuffix) {
try {
String[] fragSrc0 = PApplet.loadStrings(url.openStream());
return preprocessFragmentSource(fragSrc0, version);
return preprocessFragmentSource(fragSrc0, version, versionSuffix);
} catch (IOException e) {
PGraphics.showException("Cannot load fragment shader " + url.getFile());
}
Expand All @@ -561,10 +569,10 @@ protected String[] loadFragmentShader(URL url, int version) {


@Override
protected String[] loadVertexShader(URL url, int version) {
protected String[] loadVertexShader(URL url, int version, String versionSuffix) {
try {
String[] vertSrc0 = PApplet.loadStrings(url.openStream());
return preprocessVertexSource(vertSrc0, version);
return preprocessVertexSource(vertSrc0, version, versionSuffix);
} catch (IOException e) {
PGraphics.showException("Cannot load vertex shader " + url.getFile());
}
Expand Down

0 comments on commit 24bb799

Please sign in to comment.