Skip to content

Commit b8bd60e

Browse files
committed
ARM Mali: Report "es" as part of GLSL versions
Fixes: P0007: Language version '300' unknown, this compiler only supports up to version '320 es'
1 parent 6ff3e48 commit b8bd60e

2 files changed

Lines changed: 37 additions & 26 deletions

File tree

core/src/processing/opengl/PGL.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,9 +1287,9 @@ protected PGL initTex2DShader() {
12871287
PGL ppgl = primaryPGL ? this : graphics.getPrimaryPGL();
12881288

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

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

18491849

18501850
abstract protected int getGLSLVersion();
1851+
abstract protected String getGLSLVersionSuffix();
18511852

18521853

18531854
protected String[] loadVertexShader(String filename) {
@@ -1880,28 +1881,29 @@ protected String[] loadVertexShader(URL url) {
18801881
}
18811882

18821883

1883-
protected String[] loadVertexShader(String filename, int version) {
1884+
protected String[] loadVertexShader(String filename, int version, String versionSuffix) {
18841885
return loadVertexShader(filename);
18851886
}
18861887

18871888

1888-
protected String[] loadFragmentShader(String filename, int version) {
1889+
protected String[] loadFragmentShader(String filename, int version, String versionSuffix) {
18891890
return loadFragmentShader(filename);
18901891
}
18911892

18921893

1893-
protected String[] loadFragmentShader(URL url, int version) {
1894+
protected String[] loadFragmentShader(URL url, int version, String versionSuffix) {
18941895
return loadFragmentShader(url);
18951896
}
18961897

18971898

1898-
protected String[] loadVertexShader(URL url, int version) {
1899+
protected String[] loadVertexShader(URL url, int version, String versionSuffix) {
18991900
return loadVertexShader(url);
19001901
}
19011902

19021903

19031904
protected static String[] preprocessFragmentSource(String[] fragSrc0,
1904-
int version) {
1905+
int version,
1906+
String versionSuffix) {
19051907
if (containsVersionDirective(fragSrc0)) {
19061908
// The user knows what she or he is doing
19071909
return fragSrc0;
@@ -1915,7 +1917,7 @@ protected static String[] preprocessFragmentSource(String[] fragSrc0,
19151917
int offset = 1;
19161918

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

19341936
fragSrc = preprocessShaderSource(fragSrc0, search, replace, offset);
1935-
fragSrc[0] = "#version " + version;
1937+
fragSrc[0] = "#version " + version + versionSuffix;
19361938
fragSrc[1] = "out vec4 _fragColor;";
19371939
}
19381940

19391941
return fragSrc;
19401942
}
19411943

19421944
protected static String[] preprocessVertexSource(String[] vertSrc0,
1943-
int version) {
1945+
int version,
1946+
String versionSuffix) {
19441947
if (containsVersionDirective(vertSrc0)) {
19451948
// The user knows what she or he is doing
19461949
return vertSrc0;
@@ -1954,7 +1957,7 @@ protected static String[] preprocessVertexSource(String[] vertSrc0,
19541957
int offset = 1;
19551958

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

19731976
vertSrc = preprocessShaderSource(vertSrc0, search, replace, offset);
1974-
vertSrc[0] = "#version " + version;
1977+
vertSrc[0] = "#version " + version + versionSuffix;
19751978
}
19761979

19771980
return vertSrc;

core/src/processing/opengl/PJOGL.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -509,50 +509,58 @@ protected int getGLSLVersion() {
509509
return vn.getMajor() * 100 + vn.getMinor();
510510
}
511511

512+
protected String getGLSLVersionSuffix() {
513+
if (context.isGLESProfile()) {
514+
return " es";
515+
} else {
516+
return "";
517+
}
518+
}
519+
512520

513521
@Override
514522
protected String[] loadVertexShader(String filename) {
515-
return loadVertexShader(filename, getGLSLVersion());
523+
return loadVertexShader(filename, getGLSLVersion(), getGLSLVersionSuffix());
516524
}
517525

518526

519527
@Override
520528
protected String[] loadFragmentShader(String filename) {
521-
return loadFragmentShader(filename, getGLSLVersion());
529+
return loadFragmentShader(filename, getGLSLVersion(), getGLSLVersionSuffix());
522530
}
523531

524532

525533
@Override
526534
protected String[] loadVertexShader(URL url) {
527-
return loadVertexShader(url, getGLSLVersion());
535+
return loadVertexShader(url, getGLSLVersion(), getGLSLVersionSuffix());
528536
}
529537

530538

531539
@Override
532540
protected String[] loadFragmentShader(URL url) {
533-
return loadFragmentShader(url, getGLSLVersion());
541+
return loadFragmentShader(url, getGLSLVersion(), getGLSLVersionSuffix());
534542
}
535543

536544

537545
@Override
538-
protected String[] loadFragmentShader(String filename, int version) {
546+
protected String[] loadFragmentShader(String filename, int version, String versionSuffix) {
539547
String[] fragSrc0 = sketch.loadStrings(filename);
540-
return preprocessFragmentSource(fragSrc0, version);
548+
return preprocessFragmentSource(fragSrc0, version, versionSuffix);
541549
}
542550

543551

544552
@Override
545-
protected String[] loadVertexShader(String filename, int version) {
553+
protected String[] loadVertexShader(String filename, int version, String versionSuffix) {
546554
String[] vertSrc0 = sketch.loadStrings(filename);
547-
return preprocessVertexSource(vertSrc0, version);
555+
return preprocessVertexSource(vertSrc0, version, versionSuffix);
548556
}
549557

550558

551559
@Override
552-
protected String[] loadFragmentShader(URL url, int version) {
560+
protected String[] loadFragmentShader(URL url, int version, String versionSuffix) {
553561
try {
554562
String[] fragSrc0 = PApplet.loadStrings(url.openStream());
555-
return preprocessFragmentSource(fragSrc0, version);
563+
return preprocessFragmentSource(fragSrc0, version, versionSuffix);
556564
} catch (IOException e) {
557565
PGraphics.showException("Cannot load fragment shader " + url.getFile());
558566
}
@@ -561,10 +569,10 @@ protected String[] loadFragmentShader(URL url, int version) {
561569

562570

563571
@Override
564-
protected String[] loadVertexShader(URL url, int version) {
572+
protected String[] loadVertexShader(URL url, int version, String versionSuffix) {
565573
try {
566574
String[] vertSrc0 = PApplet.loadStrings(url.openStream());
567-
return preprocessVertexSource(vertSrc0, version);
575+
return preprocessVertexSource(vertSrc0, version, versionSuffix);
568576
} catch (IOException e) {
569577
PGraphics.showException("Cannot load vertex shader " + url.getFile());
570578
}

0 commit comments

Comments
 (0)