Skip to content
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

GLSL 120 Tweaks to Iris Shader Transformation #743

Merged
merged 4 commits into from
Nov 24, 2024

Conversation

Cleptomania
Copy link
Member

This makes 3 changes to the shader transformation process in Iris.

  1. First one is simple, catches calls to texture2DGradARB and enables the extension if it's there alongside texture2DLod and texture3DLod.

  2. 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, adding fetchTexel 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.

  1. GLSL 120 doesn't technically support the use of the 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 use varying. I've included a regex which essentially downgrades all in and out usage to varying.

Since modern Iris forces GLSL 330, it actually has basically the opposite transformation, where it upgrades all usage of varying to in/out. This transformation is only performance on shaders with version GLSL 120.

Copy link
Collaborator

@embeddedt embeddedt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine, but I don't know GLSL 120 that well.

@ah-OOG-ah ah-OOG-ah merged commit 7807223 into master Nov 24, 2024
1 check passed
@ah-OOG-ah ah-OOG-ah deleted the iris-shader-transformer-tweaks branch November 24, 2024 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants