Use ESSL 1.0 for EGLRenderer shaders

We still ostensibly support GLES 2.0 GPUs.
This commit is contained in:
Cameron Gutman 2025-12-27 22:56:20 -06:00
commit d1f43ca258
8 changed files with 15 additions and 40 deletions

View file

@ -84,11 +84,9 @@
<file alias="gamecontrollerdb.txt">SDL_GameControllerDB/gamecontrollerdb.txt</file> <file alias="gamecontrollerdb.txt">SDL_GameControllerDB/gamecontrollerdb.txt</file>
<file alias="ModeSeven.ttf">ModeSeven.ttf</file> <file alias="ModeSeven.ttf">ModeSeven.ttf</file>
<file alias="egl_nv12.frag">shaders/egl_nv12.frag</file> <file alias="egl_nv12.frag">shaders/egl_nv12.frag</file>
<file alias="egl_nv12.vert">shaders/egl_nv12.vert</file>
<file alias="egl_opaque.frag">shaders/egl_opaque.frag</file> <file alias="egl_opaque.frag">shaders/egl_opaque.frag</file>
<file alias="egl_opaque.vert">shaders/egl_opaque.vert</file>
<file alias="egl_overlay.frag">shaders/egl_overlay.frag</file> <file alias="egl_overlay.frag">shaders/egl_overlay.frag</file>
<file alias="egl_overlay.vert">shaders/egl_overlay.vert</file> <file alias="egl.vert">shaders/egl.vert</file>
<file alias="d3d11_vertex.fxc">shaders/d3d11_vertex.fxc</file> <file alias="d3d11_vertex.fxc">shaders/d3d11_vertex.fxc</file>
<file alias="d3d11_overlay_pixel.fxc">shaders/d3d11_overlay_pixel.fxc</file> <file alias="d3d11_overlay_pixel.fxc">shaders/d3d11_overlay_pixel.fxc</file>
<file alias="d3d11_yuv420_pixel.fxc">shaders/d3d11_yuv420_pixel.fxc</file> <file alias="d3d11_yuv420_pixel.fxc">shaders/d3d11_yuv420_pixel.fxc</file>

View file

@ -1,9 +1,7 @@
#version 300 es
#extension GL_OES_EGL_image_external : require #extension GL_OES_EGL_image_external : require
precision mediump float; precision mediump float;
out vec4 FragColor;
in vec2 vTextCoord; varying vec2 vTexCoord;
uniform mat3 yuvmat; uniform mat3 yuvmat;
uniform vec3 offset; uniform vec3 offset;
@ -12,11 +10,11 @@ uniform samplerExternalOES plane1;
uniform samplerExternalOES plane2; uniform samplerExternalOES plane2;
void main() { void main() {
vec3 YCbCr = vec3( vec3 YCbCr = vec3(
texture2D(plane1, vTextCoord)[0], texture2D(plane1, vTexCoord)[0],
texture2D(plane2, vTextCoord + chromaOffset).xy texture2D(plane2, vTexCoord + chromaOffset).xy
); );
YCbCr -= offset; YCbCr -= offset;
FragColor = vec4(clamp(yuvmat * YCbCr, 0.0, 1.0), 1.0f); gl_FragColor = vec4(clamp(yuvmat * YCbCr, 0.0, 1.0), 1.0f);
} }

View file

@ -1,10 +0,0 @@
#version 300 es
layout (location = 0) in vec2 aPosition; // 2D: X,Y
layout (location = 1) in vec2 aTexCoord;
out vec2 vTextCoord;
void main() {
vTextCoord = aTexCoord;
gl_Position = vec4(aPosition, 0, 1);
}

View file

@ -1,12 +1,10 @@
#version 300 es
#extension GL_OES_EGL_image_external : require #extension GL_OES_EGL_image_external : require
precision mediump float; precision mediump float;
out vec4 FragColor;
in vec2 vTextCoord; varying vec2 vTexCoord;
uniform samplerExternalOES uTexture; uniform samplerExternalOES uTexture;
void main() { void main() {
FragColor = texture2D(uTexture, vTextCoord); gl_FragColor = texture2D(uTexture, vTexCoord);
} }

View file

@ -1,10 +0,0 @@
#version 300 es
layout (location = 0) in vec2 aPosition; // 2D: X,Y
layout (location = 1) in vec2 aTexCoord;
out vec2 vTextCoord;
void main() {
vTextCoord = aTexCoord;
gl_Position = vec4(aPosition, 0, 1);
}

View file

@ -1,4 +1,5 @@
precision mediump float; precision mediump float;
uniform sampler2D uTexture; uniform sampler2D uTexture;
varying vec2 vTexCoord; varying vec2 vTexCoord;

View file

@ -351,7 +351,7 @@ bool EGLRenderer::compileShaders() {
// XXX: TODO: other formats // XXX: TODO: other formats
if (m_EGLImagePixelFormat == AV_PIX_FMT_NV12 || m_EGLImagePixelFormat == AV_PIX_FMT_P010) { if (m_EGLImagePixelFormat == AV_PIX_FMT_NV12 || m_EGLImagePixelFormat == AV_PIX_FMT_P010) {
m_ShaderProgram = compileShader("egl_nv12.vert", "egl_nv12.frag"); m_ShaderProgram = compileShader("egl.vert", "egl_nv12.frag");
if (!m_ShaderProgram) { if (!m_ShaderProgram) {
return false; return false;
} }
@ -369,7 +369,7 @@ bool EGLRenderer::compileShaders() {
glUseProgram(0); glUseProgram(0);
} }
else if (m_EGLImagePixelFormat == AV_PIX_FMT_DRM_PRIME) { else if (m_EGLImagePixelFormat == AV_PIX_FMT_DRM_PRIME) {
m_ShaderProgram = compileShader("egl_opaque.vert", "egl_opaque.frag"); m_ShaderProgram = compileShader("egl.vert", "egl_opaque.frag");
if (!m_ShaderProgram) { if (!m_ShaderProgram) {
return false; return false;
} }
@ -389,7 +389,7 @@ bool EGLRenderer::compileShaders() {
return false; return false;
} }
m_OverlayShaderProgram = compileShader("egl_overlay.vert", "egl_overlay.frag"); m_OverlayShaderProgram = compileShader("egl.vert", "egl_overlay.frag");
if (!m_OverlayShaderProgram) { if (!m_OverlayShaderProgram) {
return false; return false;
} }