Skip to content

Commit

Permalink
Merge branch 'feature/shader-improvements' into dev-funkin
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteMasterEric committed Jun 14, 2024
2 parents 8926c56 + 3a867ff commit 212a7e6
Showing 1 changed file with 13 additions and 90 deletions.
103 changes: 13 additions & 90 deletions src/openfl/utils/_internal/ShaderMacro.hx
Original file line number Diff line number Diff line change
Expand Up @@ -469,20 +469,10 @@ class ShaderMacro
switch (glVersion)
{
default:
// We don't know this GLSL version, so don't do anything.
// Don't make any changes to undefined versions.
return source;

case "100":
return source;
case "110":
return source;
case "120":
return source;
case "130":
return source;
case "140":
return source;
case "150":
case "100", "110", "120", "130", "140", "150":
return source;

case "300 es":
Expand All @@ -501,42 +491,21 @@ class ShaderMacro
result = glFragColorKeyword.replace(result, "fragColor");
return result;

case "310 es":
case "310 es", "320 es":
var result = processGLSLText(source, "300 es", isFragment);
return result;

case "320 es":
var result = processGLSLText(source, "310 es", isFragment);
return result;

case "330":
#if desktop
var result = processGLSLText(source, "320 es", isFragment);
var result = processGLSLText(source, "300 es", isFragment);
#else
var result = source;
#end
return result;
case "400":

case "400", "410", "420", "430", "440", "450", "460":
var result = processGLSLText(source, "330", isFragment);
return result;
case "410":
var result = processGLSLText(source, "400", isFragment);
return result;
case "420":
var result = processGLSLText(source, "410", isFragment);
return result;
case "430":
var result = processGLSLText(source, "420", isFragment);
return result;
case "440":
var result = processGLSLText(source, "430", isFragment);
return result;
case "450":
var result = processGLSLText(source, "440", isFragment);
return result;
case "460":
var result = processGLSLText(source, "450", isFragment);
return result;
}
}

Expand All @@ -553,17 +522,10 @@ class ShaderMacro
case "300 es": "out vec4 fragColor;\n";
#end

case "310 es": buildGLSLHeaders("300 es");
case "320 es": buildGLSLHeaders("310 es");
case "330": buildGLSLHeaders("320 es");
case "400": buildGLSLHeaders("330");
case "410": buildGLSLHeaders("400");
case "420": buildGLSLHeaders("410");
case "430": buildGLSLHeaders("420");
case "440": buildGLSLHeaders("430");
case "450": buildGLSLHeaders("440");
case "460": buildGLSLHeaders("450");
case "310 es", "320 es", "330", "400", "410", "420", "430", "440", "450", "460":
buildGLSLHeaders("300 es");

// Don't add any default headers to undefined versions
default: "";
};
}
Expand All @@ -576,31 +538,19 @@ class ShaderMacro

switch (glVersion)
{
// Don't add any extensions to undefined versions
default:
return glExtensions;

case "100":
return glExtensions;
case "110":
return glExtensions;
case "120":
return glExtensions;
case "130":
return glExtensions;
case "140":
return glExtensions;
case "150":
return glExtensions;

case "300 es":
#if desktop
case "300 es", "310 es", "320 es", "330":
var hasSeparateShaderObjects = false;
for (extension in glExtensions)
{
if (extension.name == "GL_ARB_separate_shader_objects") hasSeparateShaderObjects = true;
if (extension.name == "GL_EXT_separate_shader_objects") hasSeparateShaderObjects = true;
}

#if desktop
if (!hasSeparateShaderObjects)
{
#if linux
Expand All @@ -609,35 +559,8 @@ class ShaderMacro
return glExtensions.concat([{name: "GL_ARB_separate_shader_objects", behavior: "require"}]);
#end
}
#end
return glExtensions;

case "310 es":
var result = buildGLSLExtensions(glExtensions, "300 es", isFragment);
return result;

case "320 es":
var result = buildGLSLExtensions(glExtensions, "310 es", isFragment);
return result;

case "330":
var result = buildGLSLExtensions(glExtensions, "320 es", isFragment);
return result;

case "400":
return glExtensions;
case "410":
return glExtensions;
case "420":
return glExtensions;
case "430":
return glExtensions;
case "440":
return glExtensions;
case "450":
return glExtensions;
case "460":
return glExtensions;
#end
}
}

Expand Down

0 comments on commit 212a7e6

Please sign in to comment.