GLSL 120 Tweaks to Iris Shader Transformation #743
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes 3 changes to the shader transformation process in Iris.
First one is simple, catches calls to
texture2DGradARB
and enables the extension if it's there alongsidetexture2DLod
andtexture3DLod
.Adds the
GL_EXT_gpu_shader4
extension to all GLSL 120 shaders. This extension contains a lot of things, but primarily it has a number of things that are essentially "backports" of GLSL 130+ functionality. Namely integer overload functions of things that only accepted floats in GLSL 120, allowing integer operands on certain operators that only accepted floats, addingfetchTexel
functions, and more. Since modern Iris hijacks all versions up to 330, many shaders tend to put in functionality that relies on some of these smaller differences, even though they specify a#version 120
header. This extension helps narrow the gap between GLSL 130 and 120.As far as I can tell, the
GL_EXT_gpu_shader4
extension is pretty much universally available on any GL3 class hardware, if we merge this we'll just have to see if we run into anyone with hardware/drivers that doesn't provide this extension, but it seems probably safe to me.in
/out
keywords, though basically all implementations do actually provide it, but with different degrees of support. For example, at least under Nvidia, a vertex shader cannot use an integer type with the out keyword, but can if you usevarying
. I've included a regex which essentially downgrades allin
andout
usage tovarying
.Since modern Iris forces GLSL 330, it actually has basically the opposite transformation, where it upgrades all usage of
varying
toin
/out
. This transformation is only performance on shaders with version GLSL 120.