FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge pull request #5475 from gohai/arm-mali · flexilef/processing@6c2971d · GitHub

Repository navigation

Commit 6c2971d

Browse files
authored
Merge pull request processing#5475 from gohai/arm-mali
ARM Mali upbringing
2 parents 67c3fb9 + ed5524c commit 6c2971d

2 files changed

Lines changed: 54 additions & 28 deletions

File tree

‎core/src/processing/opengl/PGL.java‎

Lines changed: 23 additions & 16 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,20 @@ protected static String[] preprocessFragmentSource(String[] fragSrc0,
19321934
int offset = 2;
19331935

19341936
fragSrc = preprocessShaderSource(fragSrc0, search, replace, offset);
1935-
fragSrc[0] = "#version " + version;
1936-
fragSrc[1] = "out vec4 _fragColor;";
1937+
fragSrc[0] = "#version " + version + versionSuffix;
1938+
if (" es".equals(versionSuffix)) {
1939+
fragSrc[1] = "out mediump vec4 _fragColor;";
1940+
} else {
1941+
fragSrc[1] = "out vec4 _fragColor;";
1942+
}
19371943
}
19381944

19391945
return fragSrc;
19401946
}
19411947

19421948
protected static String[] preprocessVertexSource(String[] vertSrc0,
1943-
int version) {
1949+
int version,
1950+
String versionSuffix) {
19441951
if (containsVersionDirective(vertSrc0)) {
19451952
// The user knows what she or he is doing
19461953
return vertSrc0;
@@ -1954,7 +1961,7 @@ protected static String[] preprocessVertexSource(String[] vertSrc0,
19541961
int offset = 1;
19551962

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

19731980
vertSrc = preprocessShaderSource(vertSrc0, search, replace, offset);
1974-
vertSrc[0] = "#version " + version;
1981+
vertSrc[0] = "#version " + version + versionSuffix;
19751982
}
19761983

19771984
return vertSrc;
@@ -2225,7 +2232,7 @@ protected boolean hasPackedDepthStencilSupport() {
22252232

22262233
protected boolean hasAnisoSamplingSupport() {
22272234
int major = getGLVersion()[0];
2228-
if (major < 3) {
2235+
if (isES() || major < 3) {
22292236
String ext = getString(EXTENSIONS);
22302237
return -1 < ext.indexOf("_texture_filter_anisotropic");
22312238
} else {

‎core/src/processing/opengl/PJOGL.java‎

Lines changed: 31 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
}
@@ -1926,6 +1934,8 @@ public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX
19261934
gl2x.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
19271935
} else if (gl3 != null) {
19281936
gl3.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
1937+
} else if (gl3es3 != null) {
1938+
gl3es3.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
19291939
} else {
19301940
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glBlitFramebuffer()"));
19311941
}
@@ -1937,6 +1947,8 @@ public void renderbufferStorageMultisample(int target, int samples, int format,
19371947
gl2x.glRenderbufferStorageMultisample(target, samples, format, width, height);
19381948
} else if (gl3 != null) {
19391949
gl3.glRenderbufferStorageMultisample(target, samples, format, width, height);
1950+
} else if (gl3es3 != null) {
1951+
gl3es3.glRenderbufferStorageMultisample(target, samples, format, width, height);
19401952
} else {
19411953
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glRenderbufferStorageMultisample()"));
19421954
}
@@ -1948,6 +1960,8 @@ public void readBuffer(int buf) {
19481960
gl2x.glReadBuffer(buf);
19491961
} else if (gl3 != null) {
19501962
gl3.glReadBuffer(buf);
1963+
} else if (gl3es3 != null) {
1964+
gl3es3.glReadBuffer(buf);
19511965
} else {
19521966
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glReadBuffer()"));
19531967
}
@@ -1959,6 +1973,11 @@ public void drawBuffer(int buf) {
19591973
gl2x.glDrawBuffer(buf);
19601974
} else if (gl3 != null) {
19611975
gl3.glDrawBuffer(buf);
1976+
} else if (gl3es3 != null) {
1977+
IntBuffer intBuffer = IntBuffer.allocate(1);
1978+
intBuffer.put(buf);
1979+
intBuffer.rewind();
1980+
gl3es3.glDrawBuffers(1, intBuffer);
19621981
} else {
19631982
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glDrawBuffer()"));
19641983
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL