mirror of https://github.com/encounter/SDL.git
Fixed OpenGL ES shader compilation on Linux
This commit is contained in:
parent
8a15a738f3
commit
bc57d3e35c
|
@ -496,7 +496,7 @@ GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, GLenum shader_t
|
|||
GLuint id = 0;
|
||||
GLint compileSuccessful = GL_FALSE;
|
||||
int attempt, num_src;
|
||||
const GLchar *shader_src_list[2];
|
||||
const GLchar *shader_src_list[3];
|
||||
const GLchar *shader_body = GLES2_GetShader(type);
|
||||
|
||||
if (!shader_body) {
|
||||
|
@ -506,6 +506,9 @@ GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, GLenum shader_t
|
|||
|
||||
for (attempt = 0; attempt < 2 && !compileSuccessful; ++attempt) {
|
||||
num_src = 0;
|
||||
|
||||
shader_src_list[num_src++] = GLES2_GetShaderPrologue(type);
|
||||
|
||||
if (shader_type == GL_FRAGMENT_SHADER) {
|
||||
if (attempt == 0) {
|
||||
shader_src_list[num_src++] = GLES2_GetShaderInclude(data->texcoord_precision_hint);
|
||||
|
@ -513,6 +516,7 @@ GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, GLenum shader_t
|
|||
shader_src_list[num_src++] = GLES2_GetShaderInclude(GLES2_SHADER_FRAGMENT_INCLUDE_UNDEF_PRECISION);
|
||||
}
|
||||
}
|
||||
|
||||
shader_src_list[num_src++] = shader_body;
|
||||
|
||||
SDL_assert(num_src <= SDL_arraysize(shader_src_list));
|
||||
|
|
|
@ -326,11 +326,13 @@ static const char GLES2_Fragment_TextureNV21BT709[] = \
|
|||
#endif
|
||||
|
||||
/* Custom Android video format texture */
|
||||
static const char GLES2_Fragment_TextureExternalOES[] = " \
|
||||
static const char GLES2_Fragment_TextureExternalOES_Prologue[] = " \
|
||||
#extension GL_OES_EGL_image_external : require\n\
|
||||
";
|
||||
static const char GLES2_Fragment_TextureExternalOES[] = " \
|
||||
uniform samplerExternalOES u_texture; \
|
||||
varying mediump vec4 v_color;\n\
|
||||
varying SDL_TEXCOORD_PRECISION vec2 v_texCoord;\n\
|
||||
varying mediump vec4 v_color; \
|
||||
varying SDL_TEXCOORD_PRECISION vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
|
@ -344,7 +346,18 @@ static const char GLES2_Fragment_TextureExternalOES[] = " \
|
|||
* Shader selector *
|
||||
*************************************************************************************************/
|
||||
|
||||
const char *GLES2_GetShaderInclude(GLES2_ShaderIncludeType type) {
|
||||
const char *GLES2_GetShaderPrologue(GLES2_ShaderType type)
|
||||
{
|
||||
switch (type) {
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES:
|
||||
return GLES2_Fragment_TextureExternalOES_Prologue;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
const char *GLES2_GetShaderInclude(GLES2_ShaderIncludeType type)
|
||||
{
|
||||
switch (type) {
|
||||
case GLES2_SHADER_FRAGMENT_INCLUDE_UNDEF_PRECISION:
|
||||
return GLES2_Fragment_Include_Undef_Precision;
|
||||
|
@ -359,7 +372,8 @@ const char *GLES2_GetShaderInclude(GLES2_ShaderIncludeType type) {
|
|||
}
|
||||
}
|
||||
|
||||
GLES2_ShaderIncludeType GLES2_GetTexCoordPrecisionEnumFromHint() {
|
||||
GLES2_ShaderIncludeType GLES2_GetTexCoordPrecisionEnumFromHint()
|
||||
{
|
||||
const char *texcoord_hint = SDL_GetHint("SDL_RENDER_OPENGLES2_TEXCOORD_PRECISION");
|
||||
GLES2_ShaderIncludeType value = GLES2_SHADER_FRAGMENT_INCLUDE_BEST_TEXCOORD_PRECISION;
|
||||
if (texcoord_hint) {
|
||||
|
|
|
@ -60,9 +60,10 @@ typedef enum
|
|||
GLES2_SHADER_COUNT
|
||||
} GLES2_ShaderType;
|
||||
|
||||
const char *GLES2_GetShader(GLES2_ShaderType type);
|
||||
const char *GLES2_GetShaderInclude(GLES2_ShaderIncludeType type);
|
||||
GLES2_ShaderIncludeType GLES2_GetTexCoordPrecisionEnumFromHint(void);
|
||||
extern const char *GLES2_GetShaderPrologue(GLES2_ShaderType type);
|
||||
extern const char *GLES2_GetShaderInclude(GLES2_ShaderIncludeType type);
|
||||
extern const char *GLES2_GetShader(GLES2_ShaderType type);
|
||||
extern GLES2_ShaderIncludeType GLES2_GetTexCoordPrecisionEnumFromHint(void);
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL_ES2 */
|
||||
|
||||
|
|
Loading…
Reference in New Issue