Skip to content

ARM Mali upbringing #5475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 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,20 @@ protected static String[] preprocessFragmentSource(String[] fragSrc0,
int offset = 2;

fragSrc = preprocessShaderSource(fragSrc0, search, replace, offset);
fragSrc[0] = "#version " + version;
fragSrc[1] = "out vec4 _fragColor;";
fragSrc[0] = "#version " + version + versionSuffix;
if (" es".equals(versionSuffix)) {
fragSrc[1] = "out mediump vec4 _fragColor;";
} else {
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 +1961,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 +1978,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 Expand Up @@ -2225,7 +2232,7 @@ protected boolean hasPackedDepthStencilSupport() {

protected boolean hasAnisoSamplingSupport() {
int major = getGLVersion()[0];
if (major < 3) {
if (isES() || major < 3) {
String ext = getString(EXTENSIONS);
return -1 < ext.indexOf("_texture_filter_anisotropic");
} else {
Expand Down
43 changes: 31 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 Expand Up @@ -1926,6 +1934,8 @@ public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX
gl2x.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
} else if (gl3 != null) {
gl3.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
} else if (gl3es3 != null) {
gl3es3.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
} else {
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glBlitFramebuffer()"));
}
Expand All @@ -1937,6 +1947,8 @@ public void renderbufferStorageMultisample(int target, int samples, int format,
gl2x.glRenderbufferStorageMultisample(target, samples, format, width, height);
} else if (gl3 != null) {
gl3.glRenderbufferStorageMultisample(target, samples, format, width, height);
} else if (gl3es3 != null) {
gl3es3.glRenderbufferStorageMultisample(target, samples, format, width, height);
} else {
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glRenderbufferStorageMultisample()"));
}
Expand All @@ -1948,6 +1960,8 @@ public void readBuffer(int buf) {
gl2x.glReadBuffer(buf);
} else if (gl3 != null) {
gl3.glReadBuffer(buf);
} else if (gl3es3 != null) {
gl3es3.glReadBuffer(buf);
} else {
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glReadBuffer()"));
}
Expand All @@ -1959,6 +1973,11 @@ public void drawBuffer(int buf) {
gl2x.glDrawBuffer(buf);
} else if (gl3 != null) {
gl3.glDrawBuffer(buf);
} else if (gl3es3 != null) {
IntBuffer intBuffer = IntBuffer.allocate(1);
intBuffer.put(buf);
intBuffer.rewind();
gl3es3.glDrawBuffers(1, intBuffer);
} else {
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glDrawBuffer()"));
}
Expand Down